Index: src/x64/code-stubs-x64.cc |
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc |
index 7f976940b5a2213e505c3af0005405d9efb1dc8b..c0113f8bdd849a1099d9e4dbcf16c62daf25c2e0 100644 |
--- a/src/x64/code-stubs-x64.cc |
+++ b/src/x64/code-stubs-x64.cc |
@@ -3075,6 +3075,42 @@ void ToStringStub::Generate(MacroAssembler* masm) { |
} |
+void ToNameStub::Generate(MacroAssembler* masm) { |
+ // The ToName stub takes one argument in rax. |
+ Label is_number; |
+ __ JumpIfSmi(rax, &is_number, Label::kNear); |
+ |
+ Label not_name; |
+ STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE); |
+ __ CmpObjectType(rax, LAST_NAME_TYPE, rdi); |
+ // rax: receiver |
+ // rdi: receiver map |
+ __ j(above, ¬_name, Label::kNear); |
+ __ Ret(); |
+ __ bind(¬_name); |
+ |
+ 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::kToName); |
+} |
+ |
+ |
void StringHelper::GenerateFlatOneByteStringEquals(MacroAssembler* masm, |
Register left, |
Register right, |