diff --git a/src/full-codegen/x87/full-codegen-x87.cc b/src/full-codegen/x87/full-codegen-x87.cc index 860e15b4ee..f9e0563467 100644 --- a/src/full-codegen/x87/full-codegen-x87.cc +++ b/src/full-codegen/x87/full-codegen-x87.cc @@ -3409,27 +3409,6 @@ void FullCodeGenerator::EmitToInteger(CallRuntime* expr) { } -void FullCodeGenerator::EmitToName(CallRuntime* expr) { - ZoneList* args = expr->arguments(); - DCHECK_EQ(1, args->length()); - - // Load the argument into eax and convert it. - VisitForAccumulatorValue(args->at(0)); - - // Convert the object to a name. - Label convert, done_convert; - __ JumpIfSmi(eax, &convert, Label::kNear); - STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE); - __ CmpObjectType(eax, LAST_NAME_TYPE, ecx); - __ j(below_equal, &done_convert, Label::kNear); - __ bind(&convert); - __ Push(eax); - __ CallRuntime(Runtime::kToName); - __ bind(&done_convert); - context()->Plug(eax); -} - - void FullCodeGenerator::EmitStringCharFromCode(CallRuntime* expr) { ZoneList* args = expr->arguments(); DCHECK(args->length() == 1); diff --git a/src/x87/code-stubs-x87.cc b/src/x87/code-stubs-x87.cc index 9fd6ce68bd..88bbf07cc8 100644 --- a/src/x87/code-stubs-x87.cc +++ b/src/x87/code-stubs-x87.cc @@ -2868,6 +2868,42 @@ void ToStringStub::Generate(MacroAssembler* masm) { } +void ToNameStub::Generate(MacroAssembler* masm) { + // The ToName stub takes one argument in eax. + Label is_number; + __ JumpIfSmi(eax, &is_number, Label::kNear); + + Label not_name; + STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE); + __ CmpObjectType(eax, LAST_NAME_TYPE, edi); + // eax: receiver + // edi: receiver map + __ j(above, ¬_name, Label::kNear); + __ Ret(); + __ bind(¬_name); + + Label not_heap_number; + __ CompareMap(eax, masm->isolate()->factory()->heap_number_map()); + __ j(not_equal, ¬_heap_number, Label::kNear); + __ bind(&is_number); + NumberToStringStub stub(isolate()); + __ TailCallStub(&stub); + __ bind(¬_heap_number); + + Label not_oddball; + __ CmpInstanceType(edi, ODDBALL_TYPE); + __ j(not_equal, ¬_oddball, Label::kNear); + __ mov(eax, FieldOperand(eax, Oddball::kToStringOffset)); + __ Ret(); + __ bind(¬_oddball); + + __ pop(ecx); // Pop return address. + __ push(eax); // Push argument. + __ push(ecx); // Push return address. + __ TailCallRuntime(Runtime::kToName); +} + + void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, Register left, Register right, diff --git a/src/x87/interface-descriptors-x87.cc b/src/x87/interface-descriptors-x87.cc index b64c75f064..2c34815677 100644 --- a/src/x87/interface-descriptors-x87.cc +++ b/src/x87/interface-descriptors-x87.cc @@ -118,6 +118,10 @@ const Register ToLengthDescriptor::ReceiverRegister() { return eax; } const Register ToStringDescriptor::ReceiverRegister() { return eax; } +// static +const Register ToNameDescriptor::ReceiverRegister() { return eax; } + + // static const Register ToObjectDescriptor::ReceiverRegister() { return eax; }