Index: src/x64/code-stubs-x64.cc |
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc |
index 1eb9379580dd0072b72116c9968ec566ced78aed..620f84c6b3ac14f0d3e9f29ed52da9d41f50e7f1 100644 |
--- a/src/x64/code-stubs-x64.cc |
+++ b/src/x64/code-stubs-x64.cc |
@@ -2572,23 +2572,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 rax. |
+ __ AssertNotNumber(rax); |
+ |
+ Label not_string; |
__ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi); |
// rax: object |
// rdi: object map |
__ j(above_equal, ¬_string, Label::kNear); |
- // Check if string has a cached array index. |
- __ testl(FieldOperand(rax, String::kHashFieldOffset), |
- Immediate(String::kContainsCachedArrayIndexMask)); |
- __ j(not_zero, &slow_string, Label::kNear); |
- __ movl(rax, FieldOperand(rax, String::kHashFieldOffset)); |
- __ IndexFromHash(rax, rax); |
- __ Ret(); |
- __ bind(&slow_string); |
- __ PopReturnAddressTo(rcx); // Pop return address. |
- __ Push(rax); // Push argument. |
- __ PushReturnAddressFrom(rcx); // Push return address. |
- __ TailCallRuntime(Runtime::kStringToNumber); |
+ StringToNumberStub stub(masm->isolate()); |
+ __ TailCallStub(&stub); |
__ bind(¬_string); |
Label not_oddball; |
@@ -2604,6 +2602,25 @@ void ToNumberStub::Generate(MacroAssembler* masm) { |
__ TailCallRuntime(Runtime::kToNumber); |
} |
+void StringToNumberStub::Generate(MacroAssembler* masm) { |
+ // The StringToNumber stub takes one argument in rax. |
+ __ AssertString(rax); |
+ |
+ // Check if string has a cached array index. |
+ Label runtime; |
+ __ testl(FieldOperand(rax, String::kHashFieldOffset), |
+ Immediate(String::kContainsCachedArrayIndexMask)); |
+ __ j(not_zero, &runtime, Label::kNear); |
+ __ movl(rax, FieldOperand(rax, String::kHashFieldOffset)); |
+ __ IndexFromHash(rax, rax); |
+ __ Ret(); |
+ |
+ __ bind(&runtime); |
+ __ PopReturnAddressTo(rcx); // Pop return address. |
+ __ Push(rax); // Push argument. |
+ __ PushReturnAddressFrom(rcx); // Push return address. |
+ __ TailCallRuntime(Runtime::kStringToNumber); |
+} |
void ToLengthStub::Generate(MacroAssembler* masm) { |
// The ToLength stub takes on argument in rax. |