OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
(...skipping 12265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12276 } | 12276 } |
12277 | 12277 |
12278 | 12278 |
12279 void HOptimizedGraphBuilder::GenerateToInteger(CallRuntime* call) { | 12279 void HOptimizedGraphBuilder::GenerateToInteger(CallRuntime* call) { |
12280 DCHECK_EQ(1, call->arguments()->length()); | 12280 DCHECK_EQ(1, call->arguments()->length()); |
12281 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 12281 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
12282 HValue* input = Pop(); | 12282 HValue* input = Pop(); |
12283 if (input->type().IsSmi()) { | 12283 if (input->type().IsSmi()) { |
12284 return ast_context()->ReturnValue(input); | 12284 return ast_context()->ReturnValue(input); |
12285 } else { | 12285 } else { |
12286 IfBuilder if_inputissmi(this); | 12286 Callable callable = CodeFactory::ToInteger(isolate()); |
12287 if_inputissmi.If<HIsSmiAndBranch>(input); | 12287 HValue* stub = Add<HConstant>(callable.code()); |
12288 if_inputissmi.Then(); | 12288 HValue* values[] = {context(), input}; |
12289 { | 12289 HInstruction* result = |
12290 // Return the input value. | 12290 New<HCallWithDescriptor>(stub, 0, callable.descriptor(), |
12291 Push(input); | 12291 Vector<HValue*>(values, arraysize(values))); |
12292 Add<HSimulate>(call->id(), FIXED_SIMULATE); | 12292 return ast_context()->ReturnInstruction(result, call->id()); |
12293 } | |
12294 if_inputissmi.Else(); | |
12295 { | |
12296 Add<HPushArguments>(input); | |
12297 Push(Add<HCallRuntime>(Runtime::FunctionForId(Runtime::kToInteger), 1)); | |
12298 Add<HSimulate>(call->id(), FIXED_SIMULATE); | |
12299 } | |
12300 if_inputissmi.End(); | |
12301 return ast_context()->ReturnValue(Pop()); | |
12302 } | 12293 } |
12303 } | 12294 } |
12304 | 12295 |
12305 | 12296 |
12306 void HOptimizedGraphBuilder::GenerateToName(CallRuntime* call) { | 12297 void HOptimizedGraphBuilder::GenerateToName(CallRuntime* call) { |
12307 DCHECK_EQ(1, call->arguments()->length()); | 12298 DCHECK_EQ(1, call->arguments()->length()); |
12308 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 12299 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
12309 HValue* input = Pop(); | 12300 HValue* input = Pop(); |
12310 if (input->type().IsSmi()) { | 12301 if (input->type().IsSmi()) { |
12311 HValue* result = BuildNumberToString(input, Type::SignedSmall()); | 12302 HValue* result = BuildNumberToString(input, Type::SignedSmall()); |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13571 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13562 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13572 } | 13563 } |
13573 | 13564 |
13574 #ifdef DEBUG | 13565 #ifdef DEBUG |
13575 graph_->Verify(false); // No full verify. | 13566 graph_->Verify(false); // No full verify. |
13576 #endif | 13567 #endif |
13577 } | 13568 } |
13578 | 13569 |
13579 } // namespace internal | 13570 } // namespace internal |
13580 } // namespace v8 | 13571 } // namespace v8 |
OLD | NEW |