[arm64] cleanup heap numbers detection
authorJacob.Bramley@arm.com <Jacob.Bramley@arm.com>
Wed, 24 Sep 2014 10:22:11 +0000 (10:22 +0000)
committerJacob.Bramley@arm.com <Jacob.Bramley@arm.com>
Wed, 24 Sep 2014 10:22:11 +0000 (10:22 +0000)
Make heap numbers detection more consistent on arm64.
All the tested benchmarks (octane2, kraken, sunspider, v8-v4 and lua) are unchanged (a57 and a53).

R=ulan@chromium.org, bmeurer@chromium.org
BUG=

Review URL: https://codereview.chromium.org/577273002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24176 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/arm64/code-stubs-arm64.cc
src/arm64/full-codegen-arm64.cc
src/arm64/lithium-arm64.cc
src/arm64/lithium-arm64.h
src/arm64/lithium-codegen-arm64.cc
src/arm64/lithium-codegen-arm64.h
src/arm64/macro-assembler-arm64.cc
src/arm64/macro-assembler-arm64.h

index 1702e468d516ffb01dc22c37817a2a25ebd8bbc2..4978e5e201de3d4704b4b49ccf4a8002db287712 100644 (file)
@@ -223,30 +223,30 @@ static void EmitIdenticalObjectComparison(MacroAssembler* masm,
   if ((cond == lt) || (cond == gt)) {
     __ JumpIfObjectType(right, scratch, scratch, FIRST_SPEC_OBJECT_TYPE, slow,
                         ge);
+  } else if (cond == eq) {
+    __ JumpIfHeapNumber(right, &heap_number);
   } else {
     Register right_type = scratch;
     __ JumpIfObjectType(right, right_type, right_type, HEAP_NUMBER_TYPE,
                         &heap_number);
     // Comparing JS objects with <=, >= is complicated.
-    if (cond != eq) {
-      __ Cmp(right_type, FIRST_SPEC_OBJECT_TYPE);
-      __ B(ge, slow);
-      // Normally here we fall through to return_equal, but undefined is
-      // special: (undefined == undefined) == true, but
-      // (undefined <= undefined) == false!  See ECMAScript 11.8.5.
-      if ((cond == le) || (cond == ge)) {
-        __ Cmp(right_type, ODDBALL_TYPE);
-        __ B(ne, &return_equal);
-        __ JumpIfNotRoot(right, Heap::kUndefinedValueRootIndex, &return_equal);
-        if (cond == le) {
-          // undefined <= undefined should fail.
-          __ Mov(result, GREATER);
-        } else  {
-          // undefined >= undefined should fail.
-          __ Mov(result, LESS);
-        }
-        __ Ret();
+    __ Cmp(right_type, FIRST_SPEC_OBJECT_TYPE);
+    __ B(ge, slow);
+    // Normally here we fall through to return_equal, but undefined is
+    // special: (undefined == undefined) == true, but
+    // (undefined <= undefined) == false!  See ECMAScript 11.8.5.
+    if ((cond == le) || (cond == ge)) {
+      __ Cmp(right_type, ODDBALL_TYPE);
+      __ B(ne, &return_equal);
+      __ JumpIfNotRoot(right, Heap::kUndefinedValueRootIndex, &return_equal);
+      if (cond == le) {
+        // undefined <= undefined should fail.
+        __ Mov(result, GREATER);
+      } else {
+        // undefined >= undefined should fail.
+        __ Mov(result, LESS);
       }
+      __ Ret();
     }
   }
 
@@ -350,10 +350,8 @@ static void EmitSmiNonsmiComparison(MacroAssembler* masm,
                                     Register right,
                                     FPRegister left_d,
                                     FPRegister right_d,
-                                    Register scratch,
                                     Label* slow,
                                     bool strict) {
-  DCHECK(!AreAliased(left, right, scratch));
   DCHECK(!AreAliased(left_d, right_d));
   DCHECK((left.is(x0) && right.is(x1)) ||
          (right.is(x0) && left.is(x1)));
@@ -367,8 +365,7 @@ static void EmitSmiNonsmiComparison(MacroAssembler* masm,
     // If right is not a number and left is a smi, then strict equality cannot
     // succeed. Return non-equal.
     Label is_heap_number;
-    __ JumpIfObjectType(right, scratch, scratch, HEAP_NUMBER_TYPE,
-                        &is_heap_number);
+    __ JumpIfHeapNumber(right, &is_heap_number);
     // Register right is a non-zero pointer, which is a valid NOT_EQUAL result.
     if (!right.is(result)) {
       __ Mov(result, NOT_EQUAL);
@@ -378,7 +375,7 @@ static void EmitSmiNonsmiComparison(MacroAssembler* masm,
   } else {
     // Smi compared non-strictly with a non-smi, non-heap-number. Call the
     // runtime.
-    __ JumpIfNotObjectType(right, scratch, scratch, HEAP_NUMBER_TYPE, slow);
+    __ JumpIfNotHeapNumber(right, slow);
   }
 
   // Left is the smi. Right is a heap number. Load right value into right_d, and
@@ -393,8 +390,7 @@ static void EmitSmiNonsmiComparison(MacroAssembler* masm,
     // If left is not a number and right is a smi then strict equality cannot
     // succeed. Return non-equal.
     Label is_heap_number;
-    __ JumpIfObjectType(left, scratch, scratch, HEAP_NUMBER_TYPE,
-                        &is_heap_number);
+    __ JumpIfHeapNumber(left, &is_heap_number);
     // Register left is a non-zero pointer, which is a valid NOT_EQUAL result.
     if (!left.is(result)) {
       __ Mov(result, NOT_EQUAL);
@@ -404,7 +400,7 @@ static void EmitSmiNonsmiComparison(MacroAssembler* masm,
   } else {
     // Smi compared non-strictly with a non-smi, non-heap-number. Call the
     // runtime.
-    __ JumpIfNotObjectType(left, scratch, scratch, HEAP_NUMBER_TYPE, slow);
+    __ JumpIfNotHeapNumber(left, slow);
   }
 
   // Right is the smi. Left is a heap number. Load left value into left_d, and
@@ -472,7 +468,6 @@ static void EmitCheckForInternalizedStringsOrObjects(MacroAssembler* masm,
 
 
 static void CompareICStub_CheckInputType(MacroAssembler* masm, Register input,
-                                         Register scratch,
                                          CompareICState::State expected,
                                          Label* fail) {
   Label ok;
@@ -480,8 +475,7 @@ static void CompareICStub_CheckInputType(MacroAssembler* masm, Register input,
     __ JumpIfNotSmi(input, fail);
   } else if (expected == CompareICState::NUMBER) {
     __ JumpIfSmi(input, &ok);
-    __ CheckMap(input, scratch, Heap::kHeapNumberMapRootIndex, fail,
-                DONT_DO_SMI_CHECK);
+    __ JumpIfNotHeapNumber(input, fail);
   }
   // We could be strict about internalized/non-internalized here, but as long as
   // hydrogen doesn't care, the stub doesn't have to care either.
@@ -496,8 +490,8 @@ void CompareICStub::GenerateGeneric(MacroAssembler* masm) {
   Condition cond = GetCondition();
 
   Label miss;
-  CompareICStub_CheckInputType(masm, lhs, x2, left(), &miss);
-  CompareICStub_CheckInputType(masm, rhs, x3, right(), &miss);
+  CompareICStub_CheckInputType(masm, lhs, left(), &miss);
+  CompareICStub_CheckInputType(masm, rhs, right(), &miss);
 
   Label slow;  // Call builtin.
   Label not_smis, both_loaded_as_doubles;
@@ -530,7 +524,7 @@ void CompareICStub::GenerateGeneric(MacroAssembler* masm) {
   // rhs_d, left into lhs_d.
   FPRegister rhs_d = d0;
   FPRegister lhs_d = d1;
-  EmitSmiNonsmiComparison(masm, lhs, rhs, lhs_d, rhs_d, x10, &slow, strict());
+  EmitSmiNonsmiComparison(masm, lhs, rhs, lhs_d, rhs_d, &slow, strict());
 
   __ Bind(&both_loaded_as_doubles);
   // The arguments have been converted to doubles and stored in rhs_d and
@@ -3140,11 +3134,7 @@ void StringCharCodeAtGenerator::GenerateSlow(
 
   __ Bind(&index_not_smi_);
   // If index is a heap number, try converting it to an integer.
-  __ CheckMap(index_,
-              result_,
-              Heap::kHeapNumberMapRootIndex,
-              index_not_number_,
-              DONT_DO_SMI_CHECK);
+  __ JumpIfNotHeapNumber(index_, index_not_number_);
   call_helper.BeforeCall(masm);
   // Save object_ on the stack and pass index_ as argument for runtime call.
   __ Push(object_, index_);
@@ -3265,15 +3255,13 @@ void CompareICStub::GenerateNumbers(MacroAssembler* masm) {
 
   // Load rhs if it's a heap number.
   __ JumpIfSmi(rhs, &handle_lhs);
-  __ CheckMap(rhs, x10, Heap::kHeapNumberMapRootIndex, &maybe_undefined1,
-              DONT_DO_SMI_CHECK);
+  __ JumpIfNotHeapNumber(rhs, &maybe_undefined1);
   __ Ldr(rhs_d, FieldMemOperand(rhs, HeapNumber::kValueOffset));
 
   // Load lhs if it's a heap number.
   __ Bind(&handle_lhs);
   __ JumpIfSmi(lhs, &values_in_d_regs);
-  __ CheckMap(lhs, x10, Heap::kHeapNumberMapRootIndex, &maybe_undefined2,
-              DONT_DO_SMI_CHECK);
+  __ JumpIfNotHeapNumber(lhs, &maybe_undefined2);
   __ Ldr(lhs_d, FieldMemOperand(lhs, HeapNumber::kValueOffset));
 
   __ Bind(&values_in_d_regs);
@@ -3293,7 +3281,7 @@ void CompareICStub::GenerateNumbers(MacroAssembler* masm) {
   if (Token::IsOrderedRelationalCompareOp(op())) {
     __ JumpIfNotRoot(rhs, Heap::kUndefinedValueRootIndex, &miss);
     __ JumpIfSmi(lhs, &unordered);
-    __ JumpIfNotObjectType(lhs, x10, x10, HEAP_NUMBER_TYPE, &maybe_undefined2);
+    __ JumpIfNotHeapNumber(lhs, &maybe_undefined2);
     __ B(&unordered);
   }
 
index 1928aa5839133c5caed138cd4f3cfb4d07496155..619568fb08384999d91abb40d8787eb39746bcc0 100644 (file)
@@ -2906,7 +2906,7 @@ void FullCodeGenerator::EmitIsMinusZero(CallRuntime* expr) {
                          &if_true, &if_false, &fall_through);
 
   // Only a HeapNumber can be -0.0, so return false if we have something else.
-  __ CheckMap(x0, x1, Heap::kHeapNumberMapRootIndex, if_false, DO_SMI_CHECK);
+  __ JumpIfNotHeapNumber(x0, if_false, DO_SMI_CHECK);
 
   // Test the bit pattern.
   __ Ldr(x10, FieldMemOperand(x0, HeapNumber::kValueOffset));
index 237714c86469df2835e9f63642bc4d3d09dcf6e4..502b046927f45b112fab3492bef3628f426b4ea5 100644 (file)
@@ -1246,7 +1246,6 @@ LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) {
     DCHECK(input_rep.IsSmiOrTagged());
     return AssignEnvironment(
         DefineAsRegister(new(zone()) LClampTToUint8(reg,
-                                                    TempRegister(),
                                                     TempDoubleRegister())));
   }
 }
index 82b6e50c08077efcb6d1e747c685e31f8ad5f274..6ead3fe8ca3ba5bfa70cafee0a1811f71b3e6456 100644 (file)
@@ -1040,17 +1040,15 @@ class LClampIToUint8 FINAL : public LTemplateInstruction<1, 1, 0> {
 };
 
 
-class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 2> {
+class LClampTToUint8 FINAL : public LTemplateInstruction<1, 1, 1> {
  public:
-  LClampTToUint8(LOperand* unclamped, LOperand* temp1, LOperand* temp2) {
+  LClampTToUint8(LOperand* unclamped, LOperand* temp1) {
     inputs_[0] = unclamped;
     temps_[0] = temp1;
-    temps_[1] = temp2;
   }
 
   LOperand* unclamped() { return inputs_[0]; }
   LOperand* temp1() { return temps_[0]; }
-  LOperand* temp2() { return temps_[1]; }
 
   DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8")
 };
index 40c5c4238f39187c8371bb9e96a3320eabb0fc01..29986424629cf601c9a5045b04db266f74477da7 100644 (file)
@@ -1128,6 +1128,12 @@ void LCodeGen::DeoptimizeIfMinusZero(DoubleRegister input, LInstruction* instr,
 }
 
 
+void LCodeGen::DeoptimizeIfNotHeapNumber(Register object, LInstruction* instr) {
+  __ CompareObjectMap(object, Heap::kHeapNumberMapRootIndex);
+  DeoptimizeIf(ne, instr, "not heap number");
+}
+
+
 void LCodeGen::DeoptimizeIfBitSet(Register rt, int bit, LInstruction* instr,
                                   const char* detail) {
   DeoptimizeBranch(instr, detail, reg_bit_set, rt, bit);
@@ -1377,11 +1383,11 @@ void LCodeGen::EmitBranchGeneric(InstrType instr,
     EmitGoto(left_block);
   } else if (left_block == next_block) {
     branch.EmitInverted(chunk_->GetAssemblyLabel(right_block));
-  } else if (right_block == next_block) {
-    branch.Emit(chunk_->GetAssemblyLabel(left_block));
   } else {
     branch.Emit(chunk_->GetAssemblyLabel(left_block));
-    __ B(chunk_->GetAssemblyLabel(right_block));
+    if (right_block != next_block) {
+      __ B(chunk_->GetAssemblyLabel(right_block));
+    }
   }
 }
 
@@ -2299,7 +2305,6 @@ void LCodeGen::DoClampIToUint8(LClampIToUint8* instr) {
 void LCodeGen::DoClampTToUint8(LClampTToUint8* instr) {
   Register input = ToRegister(instr->unclamped());
   Register result = ToRegister32(instr->result());
-  Register scratch = ToRegister(instr->temp1());
   Label done;
 
   // Both smi and heap number cases are handled.
@@ -2313,8 +2318,7 @@ void LCodeGen::DoClampTToUint8(LClampTToUint8* instr) {
 
   // Check for heap number.
   Label is_heap_number;
-  __ Ldr(scratch, FieldMemOperand(input, HeapObject::kMapOffset));
-  __ JumpIfRoot(scratch, Heap::kHeapNumberMapRootIndex, &is_heap_number);
+  __ JumpIfHeapNumber(input, &is_heap_number);
 
   // Check for undefined. Undefined is coverted to zero for clamping conversion.
   DeoptimizeIfNotRoot(input, Heap::kUndefinedValueRootIndex, instr);
@@ -2324,7 +2328,7 @@ void LCodeGen::DoClampTToUint8(LClampTToUint8* instr) {
   // Heap number case.
   __ Bind(&is_heap_number);
   DoubleRegister dbl_scratch = double_scratch();
-  DoubleRegister dbl_scratch2 = ToDoubleRegister(instr->temp2());
+  DoubleRegister dbl_scratch2 = ToDoubleRegister(instr->temp1());
   __ Ldr(dbl_scratch, FieldMemOperand(input, HeapNumber::kValueOffset));
   __ ClampDoubleToUint8(result, dbl_scratch, dbl_scratch2);
 
@@ -2460,8 +2464,7 @@ void LCodeGen::DoCompareMinusZeroAndBranch(LCompareMinusZeroAndBranch* instr) {
                        instr->TrueLabel(chunk()));
   } else {
     Register value = ToRegister(instr->value());
-    __ CheckMap(value, scratch, Heap::kHeapNumberMapRootIndex,
-                instr->FalseLabel(chunk()), DO_SMI_CHECK);
+    __ JumpIfNotHeapNumber(value, instr->FalseLabel(chunk()), DO_SMI_CHECK);
     __ Ldr(scratch, FieldMemOperand(value, HeapNumber::kValueOffset));
     __ JumpIfMinusZero(scratch, instr->TrueLabel(chunk()));
   }
@@ -3756,8 +3759,7 @@ void LCodeGen::DoDeferredMathAbsTagged(LMathAbsTagged* instr,
   Label runtime_allocation;
 
   // Deoptimize if the input is not a HeapNumber.
-  __ Ldr(temp1, FieldMemOperand(input, HeapObject::kMapOffset));
-  DeoptimizeIfNotRoot(temp1, Heap::kHeapNumberMapRootIndex, instr);
+  DeoptimizeIfNotHeapNumber(input, instr);
 
   // If the argument is positive, we can return it as-is, without any need to
   // allocate a new HeapNumber for the result. We have to do this in integer
@@ -4091,9 +4093,7 @@ void LCodeGen::DoPower(LPower* instr) {
   } else if (exponent_type.IsTagged()) {
     Label no_deopt;
     __ JumpIfSmi(tagged_exponent, &no_deopt);
-    DCHECK(!x0.is(tagged_exponent));
-    __ Ldr(x0, FieldMemOperand(tagged_exponent, HeapObject::kMapOffset));
-    DeoptimizeIfNotRoot(x0, Heap::kHeapNumberMapRootIndex, instr);
+    DeoptimizeIfNotHeapNumber(tagged_exponent, instr);
     __ Bind(&no_deopt);
     MathPowStub stub(isolate(), MathPowStub::TAGGED);
     __ CallStub(&stub);
@@ -4660,12 +4660,10 @@ void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) {
     Label convert_undefined;
 
     // Heap number map check.
-    __ Ldr(scratch, FieldMemOperand(input, HeapObject::kMapOffset));
     if (can_convert_undefined_to_nan) {
-      __ JumpIfNotRoot(scratch, Heap::kHeapNumberMapRootIndex,
-                       &convert_undefined);
+      __ JumpIfNotHeapNumber(input, &convert_undefined);
     } else {
-      DeoptimizeIfNotRoot(scratch, Heap::kHeapNumberMapRootIndex, instr);
+      DeoptimizeIfNotHeapNumber(input, instr);
     }
 
     // Load heap number.
@@ -5595,15 +5593,12 @@ void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr,
 
   Label done;
 
-  // Load heap object map.
-  __ Ldr(scratch1, FieldMemOperand(input, HeapObject::kMapOffset));
-
   if (instr->truncating()) {
     Register output = ToRegister(instr->result());
     Label check_bools;
 
     // If it's not a heap number, jump to undefined check.
-    __ JumpIfNotRoot(scratch1, Heap::kHeapNumberMapRootIndex, &check_bools);
+    __ JumpIfNotHeapNumber(input, &check_bools);
 
     // A heap number: load value and convert to int32 using truncating function.
     __ TruncateHeapNumberToI(output, input);
@@ -5626,8 +5621,7 @@ void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr,
     Register output = ToRegister32(instr->result());
     DoubleRegister dbl_scratch2 = ToDoubleRegister(temp2);
 
-    DeoptimizeIfNotRoot(scratch1, Heap::kHeapNumberMapRootIndex, instr,
-                        "not a heap number");
+    DeoptimizeIfNotHeapNumber(input, instr);
 
     // A heap number: load value and convert to int32 using non-truncating
     // function. If the result is out of range, branch to deoptimize.
@@ -5810,13 +5804,22 @@ void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) {
 
   Factory* factory = isolate()->factory();
   if (String::Equals(type_name, factory->number_string())) {
-    DCHECK(instr->temp1() != NULL);
-    Register map = ToRegister(instr->temp1());
-
     __ JumpIfSmi(value, true_label);
-    __ Ldr(map, FieldMemOperand(value, HeapObject::kMapOffset));
-    __ CompareRoot(map, Heap::kHeapNumberMapRootIndex);
-    EmitBranch(instr, eq);
+
+    int true_block = instr->TrueDestination(chunk_);
+    int false_block = instr->FalseDestination(chunk_);
+    int next_block = GetNextEmittedBlock();
+
+    if (true_block == false_block) {
+      EmitGoto(true_block);
+    } else if (true_block == next_block) {
+      __ JumpIfNotHeapNumber(value, chunk_->GetAssemblyLabel(false_block));
+    } else {
+      __ JumpIfHeapNumber(value, chunk_->GetAssemblyLabel(true_block));
+      if (false_block != next_block) {
+        __ B(chunk_->GetAssemblyLabel(false_block));
+      }
+    }
 
   } else if (String::Equals(type_name, factory->string_string())) {
     DCHECK((instr->temp1() != NULL) && (instr->temp2() != NULL));
index e24b0313611726762c6aae390228ea33ec453308..a141dfaeef13e6478ec7e565200ed386df2a52ca 100644 (file)
@@ -236,6 +236,7 @@ class LCodeGen: public LCodeGenBase {
                         LInstruction* instr, const char* detail = NULL);
   void DeoptimizeIfNotRoot(Register rt, Heap::RootListIndex index,
                            LInstruction* instr, const char* detail = NULL);
+  void DeoptimizeIfNotHeapNumber(Register object, LInstruction* instr);
   void DeoptimizeIfMinusZero(DoubleRegister input, LInstruction* instr,
                              const char* detail = NULL);
   void DeoptimizeIfBitSet(Register rt, int bit, LInstruction* instr,
index 394bb36c62ae6fa12b13482507d11dee44ebd0ca..f670403ab8112fe9b274c6c6386e03daa62796f0 100644 (file)
@@ -2247,58 +2247,38 @@ int MacroAssembler::CallSize(Handle<Code> code,
 }
 
 
+void MacroAssembler::JumpIfHeapNumber(Register object, Label* on_heap_number,
+                                      SmiCheckType smi_check_type) {
+  Label on_not_heap_number;
 
+  if (smi_check_type == DO_SMI_CHECK) {
+    JumpIfSmi(object, &on_not_heap_number);
+  }
 
-
-void MacroAssembler::JumpForHeapNumber(Register object,
-                                       Register heap_number_map,
-                                       Label* on_heap_number,
-                                       Label* on_not_heap_number) {
-  DCHECK(on_heap_number || on_not_heap_number);
   AssertNotSmi(object);
 
   UseScratchRegisterScope temps(this);
   Register temp = temps.AcquireX();
-
-  // Load the HeapNumber map if it is not passed.
-  if (heap_number_map.Is(NoReg)) {
-    heap_number_map = temps.AcquireX();
-    LoadRoot(heap_number_map, Heap::kHeapNumberMapRootIndex);
-  } else {
-    AssertRegisterIsRoot(heap_number_map, Heap::kHeapNumberMapRootIndex);
-  }
-
-  DCHECK(!AreAliased(temp, heap_number_map));
-
   Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset));
-  Cmp(temp, heap_number_map);
-
-  if (on_heap_number) {
-    B(eq, on_heap_number);
-  }
-  if (on_not_heap_number) {
-    B(ne, on_not_heap_number);
-  }
-}
-
+  JumpIfRoot(temp, Heap::kHeapNumberMapRootIndex, on_heap_number);
 
-void MacroAssembler::JumpIfHeapNumber(Register object,
-                                      Label* on_heap_number,
-                                      Register heap_number_map) {
-  JumpForHeapNumber(object,
-                    heap_number_map,
-                    on_heap_number,
-                    NULL);
+  Bind(&on_not_heap_number);
 }
 
 
 void MacroAssembler::JumpIfNotHeapNumber(Register object,
                                          Label* on_not_heap_number,
-                                         Register heap_number_map) {
-  JumpForHeapNumber(object,
-                    heap_number_map,
-                    NULL,
-                    on_not_heap_number);
+                                         SmiCheckType smi_check_type) {
+  if (smi_check_type == DO_SMI_CHECK) {
+    JumpIfSmi(object, on_not_heap_number);
+  }
+
+  AssertNotSmi(object);
+
+  UseScratchRegisterScope temps(this);
+  Register temp = temps.AcquireX();
+  Ldr(temp, FieldMemOperand(object, HeapObject::kMapOffset));
+  JumpIfNotRoot(temp, Heap::kHeapNumberMapRootIndex, on_not_heap_number);
 }
 
 
@@ -2332,8 +2312,7 @@ void MacroAssembler::LookupNumberStringCache(Register object,
   Label load_result_from_cache;
 
   JumpIfSmi(object, &is_smi);
-  CheckMap(object, scratch1, Heap::kHeapNumberMapRootIndex, not_found,
-           DONT_DO_SMI_CHECK);
+  JumpIfNotHeapNumber(object, not_found);
 
   STATIC_ASSERT(kDoubleSize == (kWRegSize * 2));
   Add(scratch1, object, HeapNumber::kValueOffset - kHeapObjectTag);
@@ -3741,9 +3720,16 @@ void MacroAssembler::CompareInstanceType(Register map,
 }
 
 
-void MacroAssembler::CompareMap(Register obj,
-                                Register scratch,
-                                Handle<Map> map) {
+void MacroAssembler::CompareObjectMap(Register obj, Heap::RootListIndex index) {
+  UseScratchRegisterScope temps(this);
+  Register obj_map = temps.AcquireX();
+  Ldr(obj_map, FieldMemOperand(obj, HeapObject::kMapOffset));
+  CompareRoot(obj_map, index);
+}
+
+
+void MacroAssembler::CompareObjectMap(Register obj, Register scratch,
+                                      Handle<Map> map) {
   Ldr(scratch, FieldMemOperand(obj, HeapObject::kMapOffset));
   CompareMap(scratch, map);
 }
@@ -3764,7 +3750,7 @@ void MacroAssembler::CheckMap(Register obj,
     JumpIfSmi(obj, fail);
   }
 
-  CompareMap(obj, scratch, map);
+  CompareObjectMap(obj, scratch, map);
   B(ne, fail);
 }
 
@@ -4004,8 +3990,7 @@ void MacroAssembler::StoreNumberToDoubleElements(Register value_reg,
   JumpIfSmi(value_reg, &store_num);
 
   // Ensure that the object is a heap number.
-  CheckMap(value_reg, scratch1, isolate()->factory()->heap_number_map(),
-           fail, DONT_DO_SMI_CHECK);
+  JumpIfNotHeapNumber(value_reg, fail);
 
   Ldr(fpscratch1, FieldMemOperand(value_reg, HeapNumber::kValueOffset));
 
@@ -4430,7 +4415,7 @@ void MacroAssembler::RecordWriteForMap(Register object,
     UseScratchRegisterScope temps(this);
     Register temp = temps.AcquireX();
 
-    CompareMap(map, temp, isolate()->factory()->meta_map());
+    CompareObjectMap(map, temp, isolate()->factory()->meta_map());
     Check(eq, kWrongAddressOrValuePassedToRecordWrite);
   }
 
index d4593ac5998e33c786d08e80f79029d683af769a..7a106a18b96cfcad255d34c5b4a1f6d9117433c6 100644 (file)
@@ -947,16 +947,10 @@ class MacroAssembler : public Assembler {
   // Abort execution if argument is not a string, enabled via --debug-code.
   void AssertString(Register object);
 
-  void JumpForHeapNumber(Register object,
-                         Register heap_number_map,
-                         Label* on_heap_number,
-                         Label* on_not_heap_number = NULL);
-  void JumpIfHeapNumber(Register object,
-                        Label* on_heap_number,
-                        Register heap_number_map = NoReg);
-  void JumpIfNotHeapNumber(Register object,
-                           Label* on_not_heap_number,
-                           Register heap_number_map = NoReg);
+  void JumpIfHeapNumber(Register object, Label* on_heap_number,
+                        SmiCheckType smi_check_type = DONT_DO_SMI_CHECK);
+  void JumpIfNotHeapNumber(Register object, Label* on_not_heap_number,
+                           SmiCheckType smi_check_type = DONT_DO_SMI_CHECK);
 
   // Sets the vs flag if the input is -0.0.
   void TestForMinusZero(DoubleRegister input);
@@ -1449,9 +1443,11 @@ class MacroAssembler : public Assembler {
 
   // Compare an object's map with the specified map. Condition flags are set
   // with result of map compare.
-  void CompareMap(Register obj,
-                  Register scratch,
-                  Handle<Map> map);
+  void CompareObjectMap(Register obj, Heap::RootListIndex index);
+
+  // Compare an object's map with the specified map. Condition flags are set
+  // with result of map compare.
+  void CompareObjectMap(Register obj, Register scratch, Handle<Map> map);
 
   // As above, but the map of the object is already loaded into the register
   // which is preserved by the code generated.