Index: src/code-stub-assembler.cc |
diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc |
index 0f2e528eb6bebe3a80a75866f7fb414300e2d49a..a9394f6b7f2ea8c43ee4e923750084184219e3cc 100644 |
--- a/src/code-stub-assembler.cc |
+++ b/src/code-stub-assembler.cc |
@@ -2381,6 +2381,55 @@ Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) { |
return var_result.value(); |
} |
+Node* CodeStubAssembler::ToName(Node* context, Node* value) { |
+ typedef CodeStubAssembler::Label Label; |
+ typedef CodeStubAssembler::Variable Variable; |
+ |
+ Label end(this); |
+ Variable var_result(this, MachineRepresentation::kTagged); |
+ |
+ Label is_number(this); |
+ GotoIf(WordIsSmi(value), &is_number); |
+ |
+ Label not_name(this); |
+ Node* value_instance_type = LoadInstanceType(value); |
+ STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE); |
+ GotoIf(Int32GreaterThan(value_instance_type, Int32Constant(LAST_NAME_TYPE)), |
+ ¬_name); |
+ |
+ var_result.Bind(value); |
+ Goto(&end); |
+ |
+ Bind(&is_number); |
+ { |
+ Callable callable = CodeFactory::NumberToString(isolate()); |
+ var_result.Bind(CallStub(callable, context, value)); |
+ Goto(&end); |
+ } |
+ |
+ Bind(¬_name); |
+ { |
+ GotoIf(Word32Equal(value_instance_type, Int32Constant(HEAP_NUMBER_TYPE)), |
+ &is_number); |
+ |
+ Label not_oddball(this); |
+ GotoIf(Word32NotEqual(value_instance_type, Int32Constant(ODDBALL_TYPE)), |
+ ¬_oddball); |
+ |
+ var_result.Bind(LoadObjectField(value, Oddball::kToStringOffset)); |
+ Goto(&end); |
+ |
+ Bind(¬_oddball); |
+ { |
+ var_result.Bind(CallRuntime(Runtime::kToName, context, value)); |
+ Goto(&end); |
+ } |
+ } |
+ |
+ Bind(&end); |
+ return var_result.value(); |
+} |
+ |
Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, |
uint32_t mask) { |
return Word32Shr(Word32And(word32, Int32Constant(mask)), |