Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Unified Diff: src/code-stubs-hydrogen.cc

Issue 19793005: Turn ToNumberStub into a hydrogen code stub. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« 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-hydrogen.cc
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc
index 324dfa9f76a4f1965a85d7da1ea36accdb3ab474..f154bad23adb3248959846787eabaf28a29fad34 100644
--- a/src/code-stubs-hydrogen.cc
+++ b/src/code-stubs-hydrogen.cc
@@ -307,6 +307,37 @@ static Handle<Code> DoGenerateCode(Stub* stub) {
template <>
+HValue* CodeStubGraphBuilder<ToNumberStub>::BuildCodeStub() {
+ HValue* value = GetParameter(0);
+
+ // Check if the parameter is already a SMI or heap number.
+ IfBuilder if_number(this);
+ if_number.If<HIsSmiAndBranch>(value);
+ if_number.OrIf<HCompareMap>(value, isolate()->factory()->heap_number_map());
+ if_number.Then();
+
+ // Return the number.
+ Push(value);
+
+ if_number.Else();
+
+ // Convert the parameter to number using the builtin.
+ HValue* function = AddLoadJSBuiltin(Builtins::TO_NUMBER, context());
+ Add<HPushArgument>(value);
+ Push(Add<HInvokeFunction>(context(), function, 1));
+
+ if_number.End();
+
+ return Pop();
+}
+
+
+Handle<Code> ToNumberStub::GenerateCode() {
+ return DoGenerateCode(this);
+}
+
+
+template <>
HValue* CodeStubGraphBuilder<FastCloneShallowArrayStub>::BuildCodeStub() {
Zone* zone = this->zone();
Factory* factory = isolate()->factory();
« 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
This is Rietveld 408576698