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

Unified Diff: src/hydrogen.cc

Issue 1378533002: [es6] Introduce %ToInteger and %ToLength. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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/hydrogen.h ('k') | src/json.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index fea0c377c968a49d49a6c8f238a67f5edd2ed530..a55da9d4bd0234016973ccecb1f7ea79295c0480 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -12217,6 +12217,33 @@ void HOptimizedGraphBuilder::GenerateIsRegExp(CallRuntime* call) {
}
+void HOptimizedGraphBuilder::GenerateToInteger(CallRuntime* call) {
+ DCHECK_EQ(1, call->arguments()->length());
+ CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
+ HValue* input = Pop();
+ if (input->type().IsSmi()) {
+ return ast_context()->ReturnValue(input);
+ } else {
+ IfBuilder if_inputissmi(this);
+ if_inputissmi.If<HIsSmiAndBranch>(input);
+ if_inputissmi.Then();
+ {
+ // Return the input value.
+ Push(input);
+ Add<HSimulate>(call->id(), FIXED_SIMULATE);
+ }
+ if_inputissmi.Else();
+ {
+ Add<HPushArguments>(input);
+ Push(Add<HCallRuntime>(Runtime::FunctionForId(Runtime::kToInteger), 1));
+ Add<HSimulate>(call->id(), FIXED_SIMULATE);
+ }
+ if_inputissmi.End();
+ return ast_context()->ReturnValue(Pop());
+ }
+}
+
+
void HOptimizedGraphBuilder::GenerateToObject(CallRuntime* call) {
DCHECK_EQ(1, call->arguments()->length());
CHECK_ALIVE(VisitForValue(call->arguments()->at(0)));
« no previous file with comments | « src/hydrogen.h ('k') | src/json.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698