| 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 <memory> | 7 #include <memory> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
| (...skipping 1345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 builder_->set_current_block(exit_block_); | 1356 builder_->set_current_block(exit_block_); |
| 1357 } | 1357 } |
| 1358 finished_ = true; | 1358 finished_ = true; |
| 1359 } | 1359 } |
| 1360 | 1360 |
| 1361 | 1361 |
| 1362 HGraph* HGraphBuilder::CreateGraph() { | 1362 HGraph* HGraphBuilder::CreateGraph() { |
| 1363 DCHECK(!FLAG_minimal); | 1363 DCHECK(!FLAG_minimal); |
| 1364 graph_ = new (zone()) HGraph(info_, descriptor_); | 1364 graph_ = new (zone()) HGraph(info_, descriptor_); |
| 1365 if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); | 1365 if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_); |
| 1366 if (!info_->IsStub() && is_tracking_positions()) { | |
| 1367 TraceInlinedFunction(info_->shared_info(), SourcePosition::Unknown(), | |
| 1368 SourcePosition::kNotInlined); | |
| 1369 } | |
| 1370 CompilationPhase phase("H_Block building", info_); | 1366 CompilationPhase phase("H_Block building", info_); |
| 1371 set_current_block(graph()->entry_block()); | 1367 set_current_block(graph()->entry_block()); |
| 1372 if (!BuildGraph()) return NULL; | 1368 if (!BuildGraph()) return NULL; |
| 1373 graph()->FinalizeUniqueness(); | 1369 graph()->FinalizeUniqueness(); |
| 1374 return graph_; | 1370 return graph_; |
| 1375 } | 1371 } |
| 1376 | 1372 |
| 1377 void HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | |
| 1378 SourcePosition position, | |
| 1379 int inlining_id) { | |
| 1380 DCHECK(is_tracking_positions()); | |
| 1381 | |
| 1382 if (!shared->script()->IsUndefined(isolate())) { | |
| 1383 Handle<Script> script(Script::cast(shared->script()), isolate()); | |
| 1384 | |
| 1385 if (FLAG_hydrogen_track_positions && | |
| 1386 !script->source()->IsUndefined(isolate())) { | |
| 1387 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | |
| 1388 Object* source_name = script->name(); | |
| 1389 OFStream os(tracing_scope.file()); | |
| 1390 os << "--- FUNCTION SOURCE ("; | |
| 1391 if (source_name->IsString()) { | |
| 1392 os << String::cast(source_name)->ToCString().get() << ":"; | |
| 1393 } | |
| 1394 os << shared->DebugName()->ToCString().get() << ") id{"; | |
| 1395 os << info_->optimization_id() << "," << inlining_id << "} start{"; | |
| 1396 os << shared->start_position() << "} ---\n"; | |
| 1397 { | |
| 1398 DisallowHeapAllocation no_allocation; | |
| 1399 int start = shared->start_position(); | |
| 1400 int len = shared->end_position() - start; | |
| 1401 String::SubStringRange source(String::cast(script->source()), start, | |
| 1402 len); | |
| 1403 for (const auto& c : source) { | |
| 1404 os << AsReversiblyEscapedUC16(c); | |
| 1405 } | |
| 1406 } | |
| 1407 | |
| 1408 os << "\n--- END ---\n"; | |
| 1409 } | |
| 1410 } | |
| 1411 | |
| 1412 if (FLAG_hydrogen_track_positions && | |
| 1413 inlining_id != SourcePosition::kNotInlined) { | |
| 1414 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | |
| 1415 OFStream os(tracing_scope.file()); | |
| 1416 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" | |
| 1417 << info_->optimization_id() << "," << inlining_id << "} AS " | |
| 1418 << inlining_id << " AT "; | |
| 1419 if (position.IsKnown()) { | |
| 1420 os << "<" << position.InliningId() << ":" << position.ScriptOffset() | |
| 1421 << ">"; | |
| 1422 } else { | |
| 1423 os << "<?>"; | |
| 1424 } | |
| 1425 os << std::endl; | |
| 1426 } | |
| 1427 } | |
| 1428 | 1373 |
| 1429 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { | 1374 HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) { |
| 1430 DCHECK(current_block() != NULL); | 1375 DCHECK(current_block() != NULL); |
| 1431 DCHECK(!FLAG_hydrogen_track_positions || position_.IsKnown() || | 1376 DCHECK(!FLAG_hydrogen_track_positions || position_.IsKnown() || |
| 1432 !info_->IsOptimizing()); | 1377 !info_->IsOptimizing()); |
| 1433 current_block()->AddInstruction(instr, source_position()); | 1378 current_block()->AddInstruction(instr, source_position()); |
| 1434 if (graph()->IsInsideNoSideEffectsScope()) { | 1379 if (graph()->IsInsideNoSideEffectsScope()) { |
| 1435 instr->SetFlag(HValue::kHasNoObservableSideEffects); | 1380 instr->SetFlag(HValue::kHasNoObservableSideEffects); |
| 1436 } | 1381 } |
| 1437 return instr; | 1382 return instr; |
| (...skipping 6725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8163 // If target was lazily compiled, it's literals array may not yet be set up. | 8108 // If target was lazily compiled, it's literals array may not yet be set up. |
| 8164 JSFunction::EnsureLiterals(target); | 8109 JSFunction::EnsureLiterals(target); |
| 8165 | 8110 |
| 8166 // Type-check the inlined function. | 8111 // Type-check the inlined function. |
| 8167 DCHECK(target_shared->has_deoptimization_support()); | 8112 DCHECK(target_shared->has_deoptimization_support()); |
| 8168 AstTyper(target_info.isolate(), target_info.zone(), target_info.closure(), | 8113 AstTyper(target_info.isolate(), target_info.zone(), target_info.closure(), |
| 8169 target_info.scope(), target_info.osr_ast_id(), target_info.literal(), | 8114 target_info.scope(), target_info.osr_ast_id(), target_info.literal(), |
| 8170 &bounds_) | 8115 &bounds_) |
| 8171 .Run(); | 8116 .Run(); |
| 8172 | 8117 |
| 8173 if (is_tracking_positions()) { | |
| 8174 TraceInlinedFunction(target_shared, source_position(), inlining_id); | |
| 8175 } | |
| 8176 | |
| 8177 // Save the pending call context. Set up new one for the inlined function. | 8118 // Save the pending call context. Set up new one for the inlined function. |
| 8178 // The function state is new-allocated because we need to delete it | 8119 // The function state is new-allocated because we need to delete it |
| 8179 // in two different places. | 8120 // in two different places. |
| 8180 FunctionState* target_state = new FunctionState( | 8121 FunctionState* target_state = new FunctionState( |
| 8181 this, &target_info, inlining_kind, inlining_id, | 8122 this, &target_info, inlining_kind, inlining_id, |
| 8182 function_state()->ComputeTailCallMode(syntactic_tail_call_mode)); | 8123 function_state()->ComputeTailCallMode(syntactic_tail_call_mode)); |
| 8183 | 8124 |
| 8184 HConstant* undefined = graph()->GetConstantUndefined(); | 8125 HConstant* undefined = graph()->GetConstantUndefined(); |
| 8185 | 8126 |
| 8186 HEnvironment* inner_env = environment()->CopyForInlining( | 8127 HEnvironment* inner_env = environment()->CopyForInlining( |
| (...skipping 4850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13037 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12978 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13038 } | 12979 } |
| 13039 | 12980 |
| 13040 #ifdef DEBUG | 12981 #ifdef DEBUG |
| 13041 graph_->Verify(false); // No full verify. | 12982 graph_->Verify(false); // No full verify. |
| 13042 #endif | 12983 #endif |
| 13043 } | 12984 } |
| 13044 | 12985 |
| 13045 } // namespace internal | 12986 } // namespace internal |
| 13046 } // namespace v8 | 12987 } // namespace v8 |
| OLD | NEW |