Index: src/x87/code-stubs-x87.cc |
diff --git a/src/x87/code-stubs-x87.cc b/src/x87/code-stubs-x87.cc |
index 1c6820f89b841d726208610d64bffeff4f4a5f7b..a7673a09e1f810deaa152fc48523c12528630e1b 100644 |
--- a/src/x87/code-stubs-x87.cc |
+++ b/src/x87/code-stubs-x87.cc |
@@ -2328,23 +2328,21 @@ void ToNumberStub::Generate(MacroAssembler* masm) { |
__ Ret(); |
__ bind(¬_heap_number); |
- Label not_string, slow_string; |
+ NonNumberToNumberStub stub(masm->isolate()); |
+ __ TailCallStub(&stub); |
+} |
+ |
+void NonNumberToNumberStub::Generate(MacroAssembler* masm) { |
+ // The NonNumberToNumber stub takes one argument in eax. |
+ __ AssertNotNumber(eax); |
+ |
+ Label not_string; |
__ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); |
// eax: object |
// edi: object map |
__ j(above_equal, ¬_string, Label::kNear); |
- // Check if string has a cached array index. |
- __ test(FieldOperand(eax, String::kHashFieldOffset), |
- Immediate(String::kContainsCachedArrayIndexMask)); |
- __ j(not_zero, &slow_string, Label::kNear); |
- __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); |
- __ IndexFromHash(eax, eax); |
- __ Ret(); |
- __ bind(&slow_string); |
- __ pop(ecx); // Pop return address. |
- __ push(eax); // Push argument. |
- __ push(ecx); // Push return address. |
- __ TailCallRuntime(Runtime::kStringToNumber); |
+ StringToNumberStub stub(masm->isolate()); |
+ __ TailCallStub(&stub); |
__ bind(¬_string); |
Label not_oddball; |
@@ -2360,6 +2358,25 @@ void ToNumberStub::Generate(MacroAssembler* masm) { |
__ TailCallRuntime(Runtime::kToNumber); |
} |
+void StringToNumberStub::Generate(MacroAssembler* masm) { |
+ // The StringToNumber stub takes one argument in eax. |
+ __ AssertString(eax); |
+ |
+ // Check if string has a cached array index. |
+ Label runtime; |
+ __ test(FieldOperand(eax, String::kHashFieldOffset), |
+ Immediate(String::kContainsCachedArrayIndexMask)); |
+ __ j(not_zero, &runtime, Label::kNear); |
+ __ mov(eax, FieldOperand(eax, String::kHashFieldOffset)); |
+ __ IndexFromHash(eax, eax); |
+ __ Ret(); |
+ |
+ __ bind(&runtime); |
+ __ PopReturnAddressTo(ecx); // Pop return address. |
+ __ Push(eax); // Push argument. |
+ __ PushReturnAddressFrom(ecx); // Push return address. |
+ __ TailCallRuntime(Runtime::kStringToNumber); |
+} |
void ToLengthStub::Generate(MacroAssembler* masm) { |
// The ToLength stub takes on argument in eax. |