| Index: src/x64/code-stubs-x64.cc
|
| diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc
|
| index da72c29f3b434a817f80efe650a727fe71cb3183..f327b5008543bdfa4f541badfc04e0ababdf4f26 100644
|
| --- a/src/x64/code-stubs-x64.cc
|
| +++ b/src/x64/code-stubs-x64.cc
|
| @@ -3169,20 +3169,47 @@ void SubStringStub::Generate(MacroAssembler* masm) {
|
|
|
| void ToNumberStub::Generate(MacroAssembler* masm) {
|
| // The ToNumber stub takes one argument in rax.
|
| - Label check_heap_number, call_builtin;
|
| - __ JumpIfNotSmi(rax, &check_heap_number, Label::kNear);
|
| + Label not_smi;
|
| + __ JumpIfNotSmi(rax, ¬_smi, Label::kNear);
|
| __ Ret();
|
| + __ bind(¬_smi);
|
|
|
| - __ bind(&check_heap_number);
|
| + Label not_heap_number;
|
| __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset),
|
| Heap::kHeapNumberMapRootIndex);
|
| - __ j(not_equal, &call_builtin, Label::kNear);
|
| + __ j(not_equal, ¬_heap_number, Label::kNear);
|
| __ Ret();
|
| + __ bind(¬_heap_number);
|
| +
|
| + Label not_string, slow_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, 1, 1);
|
| + __ bind(¬_string);
|
| +
|
| + Label not_oddball;
|
| + __ CmpInstanceType(rdi, ODDBALL_TYPE);
|
| + __ j(not_equal, ¬_oddball, Label::kNear);
|
| + __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset));
|
| + __ Ret();
|
| + __ bind(¬_oddball);
|
|
|
| - __ bind(&call_builtin);
|
| - __ popq(rcx); // Pop return address.
|
| - __ pushq(rax);
|
| - __ pushq(rcx); // Push return address.
|
| + __ PopReturnAddressTo(rcx); // Pop return address.
|
| + __ Push(rax); // Push argument.
|
| + __ PushReturnAddressFrom(rcx); // Push return address.
|
| __ InvokeBuiltin(Builtins::TO_NUMBER, JUMP_FUNCTION);
|
| }
|
|
|
|
|