| Index: src/x64/builtins-x64.cc
|
| diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc
|
| index bade66978546701bfddd2f1fc507f5e69b389ad7..65c770cf800a61b31c5aadbb69a4cb571e845a55 100644
|
| --- a/src/x64/builtins-x64.cc
|
| +++ b/src/x64/builtins-x64.cc
|
| @@ -1663,14 +1663,14 @@ void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) {
|
| __ movp(rbx, Operand(rsp, rcx, times_pointer_size, 0));
|
|
|
| // Load the double value of the parameter into xmm1, maybe converting the
|
| - // parameter to a number first using the ToNumberStub if necessary.
|
| + // parameter to a number first using the ToNumber builtin if necessary.
|
| Label convert, convert_smi, convert_number, done_convert;
|
| __ bind(&convert);
|
| __ JumpIfSmi(rbx, &convert_smi);
|
| __ JumpIfRoot(FieldOperand(rbx, HeapObject::kMapOffset),
|
| Heap::kHeapNumberMapRootIndex, &convert_number);
|
| {
|
| - // Parameter is not a Number, use the ToNumberStub to convert it.
|
| + // Parameter is not a Number, use the ToNumber builtin to convert it.
|
| FrameScope scope(masm, StackFrame::INTERNAL);
|
| __ Integer32ToSmi(rax, rax);
|
| __ Integer32ToSmi(rcx, rcx);
|
| @@ -1678,8 +1678,7 @@ void Builtins::Generate_MathMaxMin(MacroAssembler* masm, MathMaxMinKind kind) {
|
| __ Push(rcx);
|
| __ Push(rdx);
|
| __ movp(rax, rbx);
|
| - ToNumberStub stub(masm->isolate());
|
| - __ CallStub(&stub);
|
| + __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
|
| __ movp(rbx, rax);
|
| __ Pop(rdx);
|
| __ Pop(rcx);
|
| @@ -1769,8 +1768,7 @@ void Builtins::Generate_NumberConstructor(MacroAssembler* masm) {
|
| }
|
|
|
| // 2a. Convert the first argument to a number.
|
| - ToNumberStub stub(masm->isolate());
|
| - __ TailCallStub(&stub);
|
| + __ Jump(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
|
|
|
| // 2b. No arguments, return +0 (already in rax).
|
| __ bind(&no_arguments);
|
| @@ -1821,8 +1819,7 @@ void Builtins::Generate_NumberConstructor_ConstructStub(MacroAssembler* masm) {
|
| __ Push(rdx);
|
| __ Push(rdi);
|
| __ Move(rax, rbx);
|
| - ToNumberStub stub(masm->isolate());
|
| - __ CallStub(&stub);
|
| + __ Call(masm->isolate()->builtins()->ToNumber(), RelocInfo::CODE_TARGET);
|
| __ Move(rbx, rax);
|
| __ Pop(rdi);
|
| __ Pop(rdx);
|
| @@ -2096,6 +2093,52 @@ void Builtins::Generate_StringToNumber(MacroAssembler* masm) {
|
| __ TailCallRuntime(Runtime::kStringToNumber);
|
| }
|
|
|
| +// static
|
| +void Builtins::Generate_ToNumber(MacroAssembler* masm) {
|
| + // The ToNumber stub takes one argument in rax.
|
| + Label not_smi;
|
| + __ JumpIfNotSmi(rax, ¬_smi, Label::kNear);
|
| + __ Ret();
|
| + __ bind(¬_smi);
|
| +
|
| + Label not_heap_number;
|
| + __ CompareRoot(FieldOperand(rax, HeapObject::kMapOffset),
|
| + Heap::kHeapNumberMapRootIndex);
|
| + __ j(not_equal, ¬_heap_number, Label::kNear);
|
| + __ Ret();
|
| + __ bind(¬_heap_number);
|
| +
|
| + __ Jump(masm->isolate()->builtins()->NonNumberToNumber(),
|
| + RelocInfo::CODE_TARGET);
|
| +}
|
| +
|
| +// static
|
| +void Builtins::Generate_NonNumberToNumber(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);
|
| + __ Jump(masm->isolate()->builtins()->StringToNumber(),
|
| + RelocInfo::CODE_TARGET);
|
| + __ bind(¬_string);
|
| +
|
| + Label not_oddball;
|
| + __ CmpInstanceType(rdi, ODDBALL_TYPE);
|
| + __ j(not_equal, ¬_oddball, Label::kNear);
|
| + __ movp(rax, FieldOperand(rax, Oddball::kToNumberOffset));
|
| + __ Ret();
|
| + __ bind(¬_oddball);
|
| +
|
| + __ PopReturnAddressTo(rcx); // Pop return address.
|
| + __ Push(rax); // Push argument.
|
| + __ PushReturnAddressFrom(rcx); // Push return address.
|
| + __ TailCallRuntime(Runtime::kToNumber);
|
| +}
|
| +
|
| void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
|
| // ----------- S t a t e -------------
|
| // -- rax : actual number of arguments
|
|
|