Chromium Code Reviews

Unified Diff: src/code-stubs.cc

Issue 2302923002: [stubs] Port ToName stub to TurboFan. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
« no previous file with comments | « src/code-stubs.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index 2b71716dc3f037bb8eea080b80ba2f5671e7ab13..173b9a393d30947bc919f926b9c9cc5505fe9a31 100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -4663,6 +4663,64 @@ void ToIntegerStub::GenerateAssembly(CodeStubAssembler* assembler) const {
}
}
+compiler::Node* ToNameStub::Generate(CodeStubAssembler* assembler,
+ compiler::Node* value,
+ compiler::Node* context) {
+ typedef CodeStubAssembler::Label Label;
+ typedef compiler::Node Node;
+ typedef CodeStubAssembler::Variable Variable;
+
+ Label end(assembler);
+ Variable var_result(assembler, MachineRepresentation::kTagged);
+
+ Label is_number(assembler, Label::kDeferred);
+ assembler->GotoIf(assembler->WordIsSmi(value), &is_number);
+
+ Label not_name(assembler, Label::kDeferred);
+ Node* value_instance_type = assembler->LoadInstanceType(value);
+ assembler->GotoIf(
+ assembler->Int32GreaterThan(value_instance_type,
+ assembler->Int32Constant(LAST_NAME_TYPE)),
+ &not_name);
+
+ var_result.Bind(value);
+ assembler->Goto(&end);
+
+ assembler->Bind(&is_number);
+ {
+ Callable callable = CodeFactory::NumberToString(assembler->isolate());
+ var_result.Bind(assembler->CallStub(callable, context, value));
Benedikt Meurer 2016/09/02 04:36:25 You can tail call to the stub here.
+ assembler->Goto(&end);
+ }
+
+ assembler->Bind(&not_name);
+ {
+ assembler->GotoIf(
+ assembler->Word32Equal(value_instance_type,
+ assembler->Int32Constant(HEAP_NUMBER_TYPE)),
+ &is_number);
+
+ Label not_oddball(assembler, Label::kDeferred);
+ assembler->GotoIf(
+ assembler->Word32NotEqual(value_instance_type,
+ assembler->Int32Constant(ODDBALL_TYPE)),
+ &not_oddball);
+
+ var_result.Bind(
+ assembler->LoadObjectField(value, Oddball::kToStringOffset));
+ assembler->Goto(&end);
+
+ assembler->Bind(&not_oddball);
+ {
+ var_result.Bind(assembler->CallRuntime(Runtime::kToName, context, value));
Benedikt Meurer 2016/09/02 04:36:25 Likewise you can tail call to the runtime here.
+ assembler->Goto(&end);
+ }
+ }
+
+ assembler->Bind(&end);
+ return var_result.value();
+}
+
void StoreInterceptorStub::GenerateAssembly(
CodeStubAssembler* assembler) const {
typedef compiler::Node Node;
@@ -5088,9 +5146,7 @@ compiler::Node* ForInFilterStub::Generate(CodeStubAssembler* assembler,
assembler->Bind(&return_to_name);
{
- // TODO(cbruni): inline ToName here.
- Callable callable = CodeFactory::ToName(assembler->isolate());
- var_result.Bind(assembler->CallStub(callable, context, key));
+ var_result.Bind(ToNameStub::Generate(assembler, key, context));
assembler->Goto(&end);
}
« no previous file with comments | « src/code-stubs.h ('k') | src/ia32/code-stubs-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine