diff --git a/src/arm/code-stubs-arm.cc b/src/arm/code-stubs-arm.cc index cb7981f7ed..de6803fa6f 100644 --- a/src/arm/code-stubs-arm.cc +++ b/src/arm/code-stubs-arm.cc @@ -2124,35 +2124,6 @@ void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, __ bind(&done); } -void ToStringStub::Generate(MacroAssembler* masm) { - // The ToString stub takes one argument in r0. - Label is_number; - __ JumpIfSmi(r0, &is_number); - - __ CompareObjectType(r0, r1, r1, FIRST_NONSTRING_TYPE); - // r0: receiver - // r1: receiver instance type - __ Ret(lo); - - Label not_heap_number; - __ cmp(r1, Operand(HEAP_NUMBER_TYPE)); - __ b(ne, ¬_heap_number); - __ bind(&is_number); - NumberToStringStub stub(isolate()); - __ TailCallStub(&stub); - __ bind(¬_heap_number); - - Label not_oddball; - __ cmp(r1, Operand(ODDBALL_TYPE)); - __ b(ne, ¬_oddball); - __ ldr(r0, FieldMemOperand(r0, Oddball::kToStringOffset)); - __ Ret(); - __ bind(¬_oddball); - - __ push(r0); // Push argument. - __ TailCallRuntime(Runtime::kToString); -} - void StringHelper::GenerateFlatOneByteStringEquals( MacroAssembler* masm, Register left, Register right, Register scratch1, diff --git a/src/arm64/code-stubs-arm64.cc b/src/arm64/code-stubs-arm64.cc index 1296360b2f..5c34c3952b 100644 --- a/src/arm64/code-stubs-arm64.cc +++ b/src/arm64/code-stubs-arm64.cc @@ -2673,37 +2673,6 @@ void CompareICStub::GenerateMiss(MacroAssembler* masm) { __ Jump(stub_entry); } -void ToStringStub::Generate(MacroAssembler* masm) { - // The ToString stub takes one argument in x0. - Label is_number; - __ JumpIfSmi(x0, &is_number); - - Label not_string; - __ JumpIfObjectType(x0, x1, x1, FIRST_NONSTRING_TYPE, ¬_string, hs); - // x0: receiver - // x1: receiver instance type - __ Ret(); - __ Bind(¬_string); - - Label not_heap_number; - __ Cmp(x1, HEAP_NUMBER_TYPE); - __ B(ne, ¬_heap_number); - __ Bind(&is_number); - NumberToStringStub stub(isolate()); - __ TailCallStub(&stub); - __ Bind(¬_heap_number); - - Label not_oddball; - __ Cmp(x1, ODDBALL_TYPE); - __ B(ne, ¬_oddball); - __ Ldr(x0, FieldMemOperand(x0, Oddball::kToStringOffset)); - __ Ret(); - __ Bind(¬_oddball); - - __ Push(x0); // Push argument. - __ TailCallRuntime(Runtime::kToString); -} - void StringHelper::GenerateFlatOneByteStringEquals( MacroAssembler* masm, Register left, Register right, Register scratch1, diff --git a/src/builtins/arm/builtins-arm.cc b/src/builtins/arm/builtins-arm.cc index 9fececcaf3..2c0bef2556 100644 --- a/src/builtins/arm/builtins-arm.cc +++ b/src/builtins/arm/builtins-arm.cc @@ -387,10 +387,9 @@ void Builtins::Generate_StringConstructor(MacroAssembler* masm) { __ bind(&to_string); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(r2); __ EnterBuiltinFrame(cp, r1, r2); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ LeaveBuiltinFrame(cp, r1, r2); __ SmiUntag(r2); } @@ -449,12 +448,11 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { __ bind(&convert); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(r6); __ EnterBuiltinFrame(cp, r1, r6); __ Push(r3); __ Move(r0, r2); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ Move(r2, r0); __ Pop(r3); __ LeaveBuiltinFrame(cp, r1, r6); diff --git a/src/builtins/arm64/builtins-arm64.cc b/src/builtins/arm64/builtins-arm64.cc index 2627dfe631..5f9522db38 100644 --- a/src/builtins/arm64/builtins-arm64.cc +++ b/src/builtins/arm64/builtins-arm64.cc @@ -379,10 +379,9 @@ void Builtins::Generate_StringConstructor(MacroAssembler* masm) { __ Bind(&to_string); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(x2); __ EnterBuiltinFrame(cp, x1, x2); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ LeaveBuiltinFrame(cp, x1, x2); __ SmiUntag(x2); } @@ -442,12 +441,11 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { __ Bind(&convert); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(x6); __ EnterBuiltinFrame(cp, x1, x6); __ Push(x3); __ Move(x0, x2); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ Move(x2, x0); __ Pop(x3); __ LeaveBuiltinFrame(cp, x1, x6); diff --git a/src/builtins/builtins-conversion.cc b/src/builtins/builtins-conversion.cc index 77a3e2f2eb..eccec6b8b9 100644 --- a/src/builtins/builtins-conversion.cc +++ b/src/builtins/builtins-conversion.cc @@ -151,6 +151,63 @@ void Builtins::Generate_ToNumber(CodeStubAssembler* assembler) { assembler->Return(assembler->ToNumber(context, input)); } +void Builtins::Generate_ToString(CodeStubAssembler* assembler) { + typedef CodeStubAssembler::Label Label; + typedef compiler::Node Node; + typedef TypeConversionDescriptor Descriptor; + + Node* input = assembler->Parameter(Descriptor::kArgument); + Node* context = assembler->Parameter(Descriptor::kContext); + + Label is_number(assembler); + Label runtime(assembler); + + assembler->GotoIf(assembler->WordIsSmi(input), &is_number); + + Node* input_map = assembler->LoadMap(input); + Node* input_instance_type = assembler->LoadMapInstanceType(input_map); + + Label not_string(assembler); + assembler->GotoIf( + assembler->Int32GreaterThanOrEqual( + input_instance_type, assembler->Int32Constant(FIRST_NONSTRING_TYPE)), + ¬_string); + assembler->Return(input); + + Label not_heap_number(assembler); + + assembler->Bind(¬_string); + { + assembler->GotoUnless( + assembler->WordEqual(input_map, assembler->HeapNumberMapConstant()), + ¬_heap_number); + assembler->Goto(&is_number); + } + + assembler->Bind(&is_number); + { + // TODO(tebbi): inline as soon as NumberToString is in the CodeStubAssembler + Callable callable = CodeFactory::NumberToString(assembler->isolate()); + assembler->Return(assembler->CallStub(callable, context, input)); + } + + assembler->Bind(¬_heap_number); + { + assembler->GotoIf( + assembler->Word32NotEqual(input_instance_type, + assembler->Int32Constant(ODDBALL_TYPE)), + &runtime); + assembler->Return( + assembler->LoadObjectField(input, Oddball::kToStringOffset)); + } + + assembler->Bind(&runtime); + { + assembler->Return( + assembler->CallRuntime(Runtime::kToString, context, input)); + } +} + Handle Builtins::OrdinaryToPrimitive(OrdinaryToPrimitiveHint hint) { switch (hint) { case OrdinaryToPrimitiveHint::kNumber: diff --git a/src/builtins/builtins.h b/src/builtins/builtins.h index ce03eb1e45..07ac4ff375 100644 --- a/src/builtins/builtins.h +++ b/src/builtins/builtins.h @@ -171,6 +171,7 @@ namespace internal { TFS(ToName, BUILTIN, kNoExtraICState, TypeConversion) \ TFS(NonNumberToNumber, BUILTIN, kNoExtraICState, TypeConversion) \ TFS(ToNumber, BUILTIN, kNoExtraICState, TypeConversion) \ + TFS(ToString, BUILTIN, kNoExtraICState, TypeConversion) \ \ /* Handlers */ \ ASH(KeyedLoadIC_Megamorphic, KEYED_LOAD_IC, kNoExtraICState) \ diff --git a/src/builtins/ia32/builtins-ia32.cc b/src/builtins/ia32/builtins-ia32.cc index 322f27a9fb..9dd621fca8 100644 --- a/src/builtins/ia32/builtins-ia32.cc +++ b/src/builtins/ia32/builtins-ia32.cc @@ -2041,10 +2041,9 @@ void Builtins::Generate_StringConstructor(MacroAssembler* masm) { __ bind(&to_string); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(ebx); __ EnterBuiltinFrame(esi, edi, ebx); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ LeaveBuiltinFrame(esi, edi, ebx); __ SmiUntag(ebx); } @@ -2108,11 +2107,10 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { __ bind(&convert); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(ebx); __ EnterBuiltinFrame(esi, edi, ebx); __ Push(edx); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ Pop(edx); __ LeaveBuiltinFrame(esi, edi, ebx); __ SmiUntag(ebx); diff --git a/src/builtins/mips/builtins-mips.cc b/src/builtins/mips/builtins-mips.cc index 5a37e2d5c1..a2b6bea626 100644 --- a/src/builtins/mips/builtins-mips.cc +++ b/src/builtins/mips/builtins-mips.cc @@ -395,10 +395,9 @@ void Builtins::Generate_StringConstructor(MacroAssembler* masm) { __ bind(&to_string); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(t0); __ EnterBuiltinFrame(cp, a1, t0); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ LeaveBuiltinFrame(cp, a1, t0); __ SmiUntag(t0); } @@ -459,11 +458,10 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { __ bind(&convert); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(t0); __ EnterBuiltinFrame(cp, a1, t0); __ Push(a3); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ Move(a0, v0); __ Pop(a3); __ LeaveBuiltinFrame(cp, a1, t0); diff --git a/src/builtins/mips64/builtins-mips64.cc b/src/builtins/mips64/builtins-mips64.cc index 2d75d6b915..f7225f01cd 100644 --- a/src/builtins/mips64/builtins-mips64.cc +++ b/src/builtins/mips64/builtins-mips64.cc @@ -394,10 +394,9 @@ void Builtins::Generate_StringConstructor(MacroAssembler* masm) { __ bind(&to_string); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(t0); __ EnterBuiltinFrame(cp, a1, t0); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ LeaveBuiltinFrame(cp, a1, t0); __ SmiUntag(t0); } @@ -458,11 +457,10 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { __ bind(&convert); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(t0); __ EnterBuiltinFrame(cp, a1, t0); __ Push(a3); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ Move(a0, v0); __ Pop(a3); __ LeaveBuiltinFrame(cp, a1, t0); diff --git a/src/builtins/ppc/builtins-ppc.cc b/src/builtins/ppc/builtins-ppc.cc index 36bfc4b97f..62390158ca 100644 --- a/src/builtins/ppc/builtins-ppc.cc +++ b/src/builtins/ppc/builtins-ppc.cc @@ -398,10 +398,9 @@ void Builtins::Generate_StringConstructor(MacroAssembler* masm) { __ bind(&to_string); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(r5); __ EnterBuiltinFrame(cp, r4, r5); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ LeaveBuiltinFrame(cp, r4, r5); __ SmiUntag(r5); } @@ -462,12 +461,11 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { __ bind(&convert); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(r9); __ EnterBuiltinFrame(cp, r4, r9); __ Push(r6); __ mr(r3, r5); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ mr(r5, r3); __ Pop(r6); __ LeaveBuiltinFrame(cp, r4, r9); diff --git a/src/builtins/s390/builtins-s390.cc b/src/builtins/s390/builtins-s390.cc index 1b4cfaa6ca..d140427ed7 100644 --- a/src/builtins/s390/builtins-s390.cc +++ b/src/builtins/s390/builtins-s390.cc @@ -396,10 +396,9 @@ void Builtins::Generate_StringConstructor(MacroAssembler* masm) { __ bind(&to_string); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(r4); __ EnterBuiltinFrame(cp, r3, r4); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ LeaveBuiltinFrame(cp, r3, r4); __ SmiUntag(r4); } @@ -459,12 +458,11 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { __ bind(&convert); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(r8); __ EnterBuiltinFrame(cp, r3, r8); __ Push(r5); __ LoadRR(r2, r4); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ LoadRR(r4, r2); __ Pop(r5); __ LeaveBuiltinFrame(cp, r3, r8); diff --git a/src/builtins/x64/builtins-x64.cc b/src/builtins/x64/builtins-x64.cc index 64672e53ea..beae2d29c3 100644 --- a/src/builtins/x64/builtins-x64.cc +++ b/src/builtins/x64/builtins-x64.cc @@ -2004,9 +2004,8 @@ void Builtins::Generate_StringConstructor(MacroAssembler* masm) { __ bind(&to_string); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ EnterBuiltinFrame(rsi, rdi, r8); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ LeaveBuiltinFrame(rsi, rdi, r8); } __ jmp(&drop_frame_and_ret, Label::kNear); @@ -2073,11 +2072,10 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { __ bind(&convert); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ EnterBuiltinFrame(rsi, rdi, r8); __ Push(rdx); __ Move(rax, rbx); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ Move(rbx, rax); __ Pop(rdx); __ LeaveBuiltinFrame(rsi, rdi, r8); diff --git a/src/builtins/x87/builtins-x87.cc b/src/builtins/x87/builtins-x87.cc index a3fc2346f2..8e096a3d0b 100644 --- a/src/builtins/x87/builtins-x87.cc +++ b/src/builtins/x87/builtins-x87.cc @@ -2058,10 +2058,9 @@ void Builtins::Generate_StringConstructor(MacroAssembler* masm) { __ bind(&to_string); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(ebx); __ EnterBuiltinFrame(esi, edi, ebx); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ LeaveBuiltinFrame(esi, edi, ebx); __ SmiUntag(ebx); } @@ -2125,11 +2124,10 @@ void Builtins::Generate_StringConstructor_ConstructStub(MacroAssembler* masm) { __ bind(&convert); { FrameScope scope(masm, StackFrame::MANUAL); - ToStringStub stub(masm->isolate()); __ SmiTag(ebx); __ EnterBuiltinFrame(esi, edi, ebx); __ Push(edx); - __ CallStub(&stub); + __ Call(masm->isolate()->builtins()->ToString(), RelocInfo::CODE_TARGET); __ Pop(edx); __ LeaveBuiltinFrame(esi, edi, ebx); __ SmiUntag(ebx); diff --git a/src/code-factory.cc b/src/code-factory.cc index 4b616b1b9a..67ef612ca9 100644 --- a/src/code-factory.cc +++ b/src/code-factory.cc @@ -191,8 +191,8 @@ Callable CodeFactory::StringToNumber(Isolate* isolate) { // static Callable CodeFactory::ToString(Isolate* isolate) { - ToStringStub stub(isolate); - return make_callable(stub); + return Callable(isolate->builtins()->ToString(), + TypeConversionDescriptor(isolate)); } // static diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index 055d1293ee..43411d44da 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -7,6 +7,7 @@ #include #include "src/bailout-reason.h" +#include "src/code-factory.h" #include "src/crankshaft/hydrogen.h" #include "src/crankshaft/lithium.h" #include "src/field-index.h" @@ -1042,10 +1043,10 @@ HValue* CodeStubGraphBuilderBase::BuildToString(HValue* input, bool convert) { } if_inputisprimitive.End(); // Convert the primitive to a string value. - ToStringStub stub(isolate()); HValue* values[] = {context(), Pop()}; - Push(AddUncasted(Add(stub.GetCode()), 0, - stub.GetCallInterfaceDescriptor(), + Callable toString = CodeFactory::ToString(isolate()); + Push(AddUncasted(Add(toString.code()), 0, + toString.descriptor(), ArrayVector(values))); } if_inputisstring.End(); diff --git a/src/code-stubs.h b/src/code-stubs.h index 7b9d76bfdb..453a54ca65 100644 --- a/src/code-stubs.h +++ b/src/code-stubs.h @@ -43,7 +43,6 @@ class ObjectLiteral; V(StoreBufferOverflow) \ V(StoreElement) \ V(SubString) \ - V(ToString) \ V(StoreIC) \ V(KeyedStoreIC) \ V(KeyedLoadIC) \ @@ -3114,14 +3113,6 @@ class SubStringStub : public TurboFanCodeStub { DEFINE_CODE_STUB(SubString, TurboFanCodeStub); }; -class ToStringStub final : public PlatformCodeStub { - public: - explicit ToStringStub(Isolate* isolate) : PlatformCodeStub(isolate) {} - - DEFINE_CALL_INTERFACE_DESCRIPTOR(TypeConversion); - DEFINE_PLATFORM_CODE_STUB(ToString, PlatformCodeStub); -}; - class ToObjectStub final : public TurboFanCodeStub { public: explicit ToObjectStub(Isolate* isolate) : TurboFanCodeStub(isolate) {} diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc index daee72d184..edab277fbe 100644 --- a/src/ia32/code-stubs-ia32.cc +++ b/src/ia32/code-stubs-ia32.cc @@ -2065,40 +2065,6 @@ void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, __ bind(&done); } -void ToStringStub::Generate(MacroAssembler* masm) { - // The ToString stub takes one argument in eax. - Label is_number; - __ JumpIfSmi(eax, &is_number, Label::kNear); - - Label not_string; - __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); - // eax: receiver - // edi: receiver map - __ j(above_equal, ¬_string, Label::kNear); - __ Ret(); - __ bind(¬_string); - - 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::kToString); -} - void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, Register left, diff --git a/src/mips/code-stubs-mips.cc b/src/mips/code-stubs-mips.cc index 7ab85dcec8..43e67354f2 100644 --- a/src/mips/code-stubs-mips.cc +++ b/src/mips/code-stubs-mips.cc @@ -2268,37 +2268,6 @@ void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, __ bind(&done); } -void ToStringStub::Generate(MacroAssembler* masm) { - // The ToString stub takes on argument in a0. - Label is_number; - __ JumpIfSmi(a0, &is_number); - - Label not_string; - __ GetObjectType(a0, a1, a1); - // a0: receiver - // a1: receiver instance type - __ Branch(¬_string, ge, a1, Operand(FIRST_NONSTRING_TYPE)); - __ Ret(USE_DELAY_SLOT); - __ mov(v0, a0); - __ bind(¬_string); - - Label not_heap_number; - __ Branch(¬_heap_number, ne, a1, Operand(HEAP_NUMBER_TYPE)); - __ bind(&is_number); - NumberToStringStub stub(isolate()); - __ TailCallStub(&stub); - __ bind(¬_heap_number); - - Label not_oddball; - __ Branch(¬_oddball, ne, a1, Operand(ODDBALL_TYPE)); - __ Ret(USE_DELAY_SLOT); - __ lw(v0, FieldMemOperand(a0, Oddball::kToStringOffset)); - __ bind(¬_oddball); - - __ push(a0); // Push argument. - __ TailCallRuntime(Runtime::kToString); -} - void StringHelper::GenerateFlatOneByteStringEquals( MacroAssembler* masm, Register left, Register right, Register scratch1, diff --git a/src/mips64/code-stubs-mips64.cc b/src/mips64/code-stubs-mips64.cc index b9356c9e92..e089b54f87 100644 --- a/src/mips64/code-stubs-mips64.cc +++ b/src/mips64/code-stubs-mips64.cc @@ -2271,37 +2271,6 @@ void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, __ bind(&done); } -void ToStringStub::Generate(MacroAssembler* masm) { - // The ToString stub takes on argument in a0. - Label is_number; - __ JumpIfSmi(a0, &is_number); - - Label not_string; - __ GetObjectType(a0, a1, a1); - // a0: receiver - // a1: receiver instance type - __ Branch(¬_string, ge, a1, Operand(FIRST_NONSTRING_TYPE)); - __ Ret(USE_DELAY_SLOT); - __ mov(v0, a0); - __ bind(¬_string); - - Label not_heap_number; - __ Branch(¬_heap_number, ne, a1, Operand(HEAP_NUMBER_TYPE)); - __ bind(&is_number); - NumberToStringStub stub(isolate()); - __ TailCallStub(&stub); - __ bind(¬_heap_number); - - Label not_oddball; - __ Branch(¬_oddball, ne, a1, Operand(ODDBALL_TYPE)); - __ Ret(USE_DELAY_SLOT); - __ ld(v0, FieldMemOperand(a0, Oddball::kToStringOffset)); - __ bind(¬_oddball); - - __ push(a0); // Push argument. - __ TailCallRuntime(Runtime::kToString); -} - void StringHelper::GenerateFlatOneByteStringEquals( MacroAssembler* masm, Register left, Register right, Register scratch1, diff --git a/src/ppc/code-stubs-ppc.cc b/src/ppc/code-stubs-ppc.cc index 1a1c28d25c..a3411950b5 100644 --- a/src/ppc/code-stubs-ppc.cc +++ b/src/ppc/code-stubs-ppc.cc @@ -2207,35 +2207,6 @@ void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, Register dest, __ bind(&done); } -void ToStringStub::Generate(MacroAssembler* masm) { - // The ToString stub takes one argument in r3. - Label is_number; - __ JumpIfSmi(r3, &is_number); - - __ CompareObjectType(r3, r4, r4, FIRST_NONSTRING_TYPE); - // r3: receiver - // r4: receiver instance type - __ Ret(lt); - - Label not_heap_number; - __ cmpi(r4, Operand(HEAP_NUMBER_TYPE)); - __ bne(¬_heap_number); - __ bind(&is_number); - NumberToStringStub stub(isolate()); - __ TailCallStub(&stub); - __ bind(¬_heap_number); - - Label not_oddball; - __ cmpi(r4, Operand(ODDBALL_TYPE)); - __ bne(¬_oddball); - __ LoadP(r3, FieldMemOperand(r3, Oddball::kToStringOffset)); - __ Ret(); - __ bind(¬_oddball); - - __ push(r3); // Push argument. - __ TailCallRuntime(Runtime::kToString); -} - void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, Register left, diff --git a/src/s390/code-stubs-s390.cc b/src/s390/code-stubs-s390.cc index e867bf9e11..514c98ce2f 100644 --- a/src/s390/code-stubs-s390.cc +++ b/src/s390/code-stubs-s390.cc @@ -2202,38 +2202,6 @@ void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, Register dest, __ bind(&done); } -void ToStringStub::Generate(MacroAssembler* masm) { - // The ToString stub takes one argument in r2. - Label done; - Label is_number; - __ JumpIfSmi(r2, &is_number); - - __ CompareObjectType(r2, r3, r3, FIRST_NONSTRING_TYPE); - // r2: receiver - // r3: receiver instance type - __ blt(&done); - - Label not_heap_number; - __ CmpP(r3, Operand(HEAP_NUMBER_TYPE)); - __ bne(¬_heap_number); - __ bind(&is_number); - NumberToStringStub stub(isolate()); - __ TailCallStub(&stub); - __ bind(¬_heap_number); - - Label not_oddball; - __ CmpP(r3, Operand(ODDBALL_TYPE)); - __ bne(¬_oddball); - __ LoadP(r2, FieldMemOperand(r2, Oddball::kToStringOffset)); - __ Ret(); - __ bind(¬_oddball); - - __ push(r2); // Push argument. - __ TailCallRuntime(Runtime::kToString); - - __ bind(&done); - __ Ret(); -} void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, Register left, diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc index 6dddab1f6c..2a962b32f9 100644 --- a/src/x64/code-stubs-x64.cc +++ b/src/x64/code-stubs-x64.cc @@ -2011,40 +2011,6 @@ void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, __ bind(&done); } -void ToStringStub::Generate(MacroAssembler* masm) { - // The ToString stub takes one argument in rax. - Label is_number; - __ JumpIfSmi(rax, &is_number, Label::kNear); - - Label not_string; - __ CmpObjectType(rax, FIRST_NONSTRING_TYPE, rdi); - // rax: receiver - // rdi: receiver map - __ j(above_equal, ¬_string, Label::kNear); - __ Ret(); - __ bind(¬_string); - - Label not_heap_number; - __ CompareRoot(rdi, Heap::kHeapNumberMapRootIndex); - __ j(not_equal, ¬_heap_number, Label::kNear); - __ bind(&is_number); - NumberToStringStub stub(isolate()); - __ TailCallStub(&stub); - __ bind(¬_heap_number); - - Label not_oddball; - __ CmpInstanceType(rdi, ODDBALL_TYPE); - __ j(not_equal, ¬_oddball, Label::kNear); - __ movp(rax, FieldOperand(rax, Oddball::kToStringOffset)); - __ Ret(); - __ bind(¬_oddball); - - __ PopReturnAddressTo(rcx); // Pop return address. - __ Push(rax); // Push argument. - __ PushReturnAddressFrom(rcx); // Push return address. - __ TailCallRuntime(Runtime::kToString); -} - void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, Register left, diff --git a/src/x87/code-stubs-x87.cc b/src/x87/code-stubs-x87.cc index 498bd58d5c..68111a7eef 100644 --- a/src/x87/code-stubs-x87.cc +++ b/src/x87/code-stubs-x87.cc @@ -1907,40 +1907,6 @@ void StringHelper::GenerateCopyCharacters(MacroAssembler* masm, __ bind(&done); } -void ToStringStub::Generate(MacroAssembler* masm) { - // The ToString stub takes one argument in eax. - Label is_number; - __ JumpIfSmi(eax, &is_number, Label::kNear); - - Label not_string; - __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edi); - // eax: receiver - // edi: receiver map - __ j(above_equal, ¬_string, Label::kNear); - __ Ret(); - __ bind(¬_string); - - 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::kToString); -} - void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, Register left,