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))); |