| 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 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1352 builder_->set_current_block(exit_block_); | 1352 builder_->set_current_block(exit_block_); |
| 1353 } | 1353 } |
| 1354 finished_ = true; | 1354 finished_ = true; |
| 1355 } | 1355 } |
| 1356 | 1356 |
| 1357 | 1357 |
| 1358 HGraph* HGraphBuilder::CreateGraph() { | 1358 HGraph* HGraphBuilder::CreateGraph() { |
| 1359 graph_ = new (zone()) HGraph(info_, descriptor_); | 1359 graph_ = new (zone()) HGraph(info_, descriptor_); |
| 1360 if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); | 1360 if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); |
| 1361 if (!info_->IsStub() && info_->is_tracking_positions()) { | 1361 if (!info_->IsStub() && info_->is_tracking_positions()) { |
| 1362 TraceInlinedFunction(info_->shared_info(), SourcePosition::Unknown(), | 1362 TraceInlinedFunction(info_->shared_info(), SourcePosition::Unknown()); |
| 1363 InlinedFunctionInfo::kNoParentId); | |
| 1364 } | 1363 } |
| 1365 CompilationPhase phase("H_Block building", info_); | 1364 CompilationPhase phase("H_Block building", info_); |
| 1366 set_current_block(graph()->entry_block()); | 1365 set_current_block(graph()->entry_block()); |
| 1367 if (!BuildGraph()) return NULL; | 1366 if (!BuildGraph()) return NULL; |
| 1368 graph()->FinalizeUniqueness(); | 1367 graph()->FinalizeUniqueness(); |
| 1369 return graph_; | 1368 return graph_; |
| 1370 } | 1369 } |
| 1371 | 1370 |
| 1372 int HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 1371 int HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
| 1373 SourcePosition position, | 1372 SourcePosition position) { |
| 1374 int parent_id) { | |
| 1375 DCHECK(info_->is_tracking_positions()); | 1373 DCHECK(info_->is_tracking_positions()); |
| 1376 | 1374 |
| 1377 int inline_id = static_cast<int>(info_->inlined_function_infos().size()); | 1375 int inline_id = static_cast<int>(info_->inlined_function_infos().size()); |
| 1378 InlinedFunctionInfo info(parent_id, position, UnboundScript::kNoScriptId, | 1376 InlinedFunctionInfo info(shared->start_position()); |
| 1379 shared->start_position()); | |
| 1380 if (!shared->script()->IsUndefined()) { | 1377 if (!shared->script()->IsUndefined()) { |
| 1381 Handle<Script> script(Script::cast(shared->script())); | 1378 Handle<Script> script(Script::cast(shared->script())); |
| 1382 info.script_id = script->id(); | |
| 1383 | 1379 |
| 1384 if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) { | 1380 if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) { |
| 1385 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | 1381 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
| 1386 Object* source_name = script->name(); | 1382 Object* source_name = script->name(); |
| 1387 OFStream os(tracing_scope.file()); | 1383 OFStream os(tracing_scope.file()); |
| 1388 os << "--- FUNCTION SOURCE ("; | 1384 os << "--- FUNCTION SOURCE ("; |
| 1389 if (source_name->IsString()) { | 1385 if (source_name->IsString()) { |
| 1390 os << String::cast(source_name)->ToCString().get() << ":"; | 1386 os << String::cast(source_name)->ToCString().get() << ":"; |
| 1391 } | 1387 } |
| 1392 os << shared->DebugName()->ToCString().get() << ") id{"; | 1388 os << shared->DebugName()->ToCString().get() << ") id{"; |
| (...skipping 7258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8651 // TryInline should always return true). | 8647 // TryInline should always return true). |
| 8652 | 8648 |
| 8653 // Type-check the inlined function. | 8649 // Type-check the inlined function. |
| 8654 DCHECK(target_shared->has_deoptimization_support()); | 8650 DCHECK(target_shared->has_deoptimization_support()); |
| 8655 AstTyper(target_info.isolate(), target_info.zone(), target_info.closure(), | 8651 AstTyper(target_info.isolate(), target_info.zone(), target_info.closure(), |
| 8656 target_info.scope(), target_info.osr_ast_id(), target_info.literal()) | 8652 target_info.scope(), target_info.osr_ast_id(), target_info.literal()) |
| 8657 .Run(); | 8653 .Run(); |
| 8658 | 8654 |
| 8659 int inlining_id = 0; | 8655 int inlining_id = 0; |
| 8660 if (top_info()->is_tracking_positions()) { | 8656 if (top_info()->is_tracking_positions()) { |
| 8661 inlining_id = TraceInlinedFunction(target_shared, source_position(), | 8657 inlining_id = TraceInlinedFunction(target_shared, source_position()); |
| 8662 function_state()->inlining_id()); | |
| 8663 } | 8658 } |
| 8664 | 8659 |
| 8665 // Save the pending call context. Set up new one for the inlined function. | 8660 // Save the pending call context. Set up new one for the inlined function. |
| 8666 // The function state is new-allocated because we need to delete it | 8661 // The function state is new-allocated because we need to delete it |
| 8667 // in two different places. | 8662 // in two different places. |
| 8668 FunctionState* target_state = new FunctionState( | 8663 FunctionState* target_state = new FunctionState( |
| 8669 this, &target_info, inlining_kind, inlining_id, | 8664 this, &target_info, inlining_kind, inlining_id, |
| 8670 function_state()->ComputeTailCallMode(syntactic_tail_call_mode)); | 8665 function_state()->ComputeTailCallMode(syntactic_tail_call_mode)); |
| 8671 | 8666 |
| 8672 HConstant* undefined = graph()->GetConstantUndefined(); | 8667 HConstant* undefined = graph()->GetConstantUndefined(); |
| (...skipping 5072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13745 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13740 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13746 } | 13741 } |
| 13747 | 13742 |
| 13748 #ifdef DEBUG | 13743 #ifdef DEBUG |
| 13749 graph_->Verify(false); // No full verify. | 13744 graph_->Verify(false); // No full verify. |
| 13750 #endif | 13745 #endif |
| 13751 } | 13746 } |
| 13752 | 13747 |
| 13753 } // namespace internal | 13748 } // namespace internal |
| 13754 } // namespace v8 | 13749 } // namespace v8 |
| OLD | NEW |