Index: src/arm/code-stubs-arm.cc |
diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc |
index 3f1c8708ad4e9230a7dac684270d33aab514674f..bd83cd1ae8cdfdfc4f15e02292025f115366e1a7 100644 |
--- a/src/arm/code-stubs-arm.cc |
+++ b/src/arm/code-stubs-arm.cc |
@@ -2661,29 +2661,28 @@ void SubStringStub::Generate(MacroAssembler* masm) { |
void ToNumberStub::Generate(MacroAssembler* masm) { |
// The ToNumber stub takes one argument in r0. |
- Label not_smi; |
- __ JumpIfNotSmi(r0, ¬_smi); |
- __ Ret(); |
- __ bind(¬_smi); |
+ STATIC_ASSERT(kSmiTag == 0); |
+ __ tst(r0, Operand(kSmiTagMask)); |
+ __ Ret(eq); |
__ CompareObjectType(r0, r1, r1, HEAP_NUMBER_TYPE); |
// r0: receiver |
// r1: receiver instance type |
__ Ret(eq); |
- Label not_string, slow_string; |
- __ cmp(r1, Operand(FIRST_NONSTRING_TYPE)); |
- __ b(hs, ¬_string); |
- // Check if string has a cached array index. |
- __ ldr(r2, FieldMemOperand(r0, String::kHashFieldOffset)); |
- __ tst(r2, Operand(String::kContainsCachedArrayIndexMask)); |
- __ b(ne, &slow_string); |
- __ IndexFromHash(r2, r0); |
- __ Ret(); |
- __ bind(&slow_string); |
- __ push(r0); // Push argument. |
- __ TailCallRuntime(Runtime::kStringToNumber); |
- __ bind(¬_string); |
+ NonNumberToNumberStub stub(masm->isolate()); |
+ __ TailCallStub(&stub); |
+} |
+ |
+void NonNumberToNumberStub::Generate(MacroAssembler* masm) { |
+ // The NonNumberToNumber stub takes one argument in r0. |
+ __ AssertNotNumber(r0); |
+ |
+ __ CompareObjectType(r0, r1, r1, FIRST_NONSTRING_TYPE); |
+ // r0: receiver |
+ // r1: receiver instance type |
+ StringToNumberStub stub(masm->isolate()); |
+ __ TailCallStub(&stub, lo); |
Label not_oddball; |
__ cmp(r1, Operand(ODDBALL_TYPE)); |
@@ -2692,10 +2691,26 @@ void ToNumberStub::Generate(MacroAssembler* masm) { |
__ Ret(); |
__ bind(¬_oddball); |
- __ push(r0); // Push argument. |
+ __ Push(r0); // Push argument. |
__ TailCallRuntime(Runtime::kToNumber); |
} |
+void StringToNumberStub::Generate(MacroAssembler* masm) { |
+ // The StringToNumber stub takes one argument in r0. |
+ __ AssertString(r0); |
+ |
+ // Check if string has a cached array index. |
+ Label runtime; |
+ __ ldr(r2, FieldMemOperand(r0, String::kHashFieldOffset)); |
+ __ tst(r2, Operand(String::kContainsCachedArrayIndexMask)); |
+ __ b(ne, &runtime); |
+ __ IndexFromHash(r2, r0); |
+ __ Ret(); |
+ |
+ __ bind(&runtime); |
+ __ Push(r0); // Push argument. |
+ __ TailCallRuntime(Runtime::kStringToNumber); |
+} |
void ToLengthStub::Generate(MacroAssembler* masm) { |
// The ToLength stub takes one argument in r0. |