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 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 set_current_block(graph()->entry_block()); | 1365 set_current_block(graph()->entry_block()); |
1366 if (!BuildGraph()) return NULL; | 1366 if (!BuildGraph()) return NULL; |
1367 graph()->FinalizeUniqueness(); | 1367 graph()->FinalizeUniqueness(); |
1368 return graph_; | 1368 return graph_; |
1369 } | 1369 } |
1370 | 1370 |
1371 int HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, | 1371 int HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared, |
1372 SourcePosition position) { | 1372 SourcePosition position) { |
1373 DCHECK(info_->is_tracking_positions()); | 1373 DCHECK(info_->is_tracking_positions()); |
1374 | 1374 |
1375 int inline_id = static_cast<int>(info_->inlined_function_infos().size()); | 1375 int inline_id = static_cast<int>(graph()->inlined_function_infos().size()); |
1376 InlinedFunctionInfo info(shared->start_position()); | 1376 HInlinedFunctionInfo info(shared->start_position()); |
1377 if (!shared->script()->IsUndefined()) { | 1377 if (!shared->script()->IsUndefined()) { |
1378 Handle<Script> script(Script::cast(shared->script())); | 1378 Handle<Script> script(Script::cast(shared->script())); |
1379 | 1379 |
1380 if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) { | 1380 if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) { |
1381 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | 1381 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
1382 Object* source_name = script->name(); | 1382 Object* source_name = script->name(); |
1383 OFStream os(tracing_scope.file()); | 1383 OFStream os(tracing_scope.file()); |
1384 os << "--- FUNCTION SOURCE ("; | 1384 os << "--- FUNCTION SOURCE ("; |
1385 if (source_name->IsString()) { | 1385 if (source_name->IsString()) { |
1386 os << String::cast(source_name)->ToCString().get() << ":"; | 1386 os << String::cast(source_name)->ToCString().get() << ":"; |
1387 } | 1387 } |
1388 os << shared->DebugName()->ToCString().get() << ") id{"; | 1388 os << shared->DebugName()->ToCString().get() << ") id{"; |
1389 os << info_->optimization_id() << "," << inline_id << "} ---\n"; | 1389 os << info_->optimization_id() << "," << inline_id << "} ---\n"; |
1390 { | 1390 { |
1391 DisallowHeapAllocation no_allocation; | 1391 DisallowHeapAllocation no_allocation; |
1392 int start = shared->start_position(); | 1392 int start = shared->start_position(); |
1393 int len = shared->end_position() - start; | 1393 int len = shared->end_position() - start; |
1394 String::SubStringRange source(String::cast(script->source()), start, | 1394 String::SubStringRange source(String::cast(script->source()), start, |
1395 len); | 1395 len); |
1396 for (const auto& c : source) { | 1396 for (const auto& c : source) { |
1397 os << AsReversiblyEscapedUC16(c); | 1397 os << AsReversiblyEscapedUC16(c); |
1398 } | 1398 } |
1399 } | 1399 } |
1400 | 1400 |
1401 os << "\n--- END ---\n"; | 1401 os << "\n--- END ---\n"; |
1402 } | 1402 } |
1403 } | 1403 } |
1404 | 1404 |
1405 info_->inlined_function_infos().push_back(info); | 1405 graph()->inlined_function_infos().push_back(info); |
1406 | 1406 |
1407 if (FLAG_hydrogen_track_positions && inline_id != 0) { | 1407 if (FLAG_hydrogen_track_positions && inline_id != 0) { |
1408 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); | 1408 CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer()); |
1409 OFStream os(tracing_scope.file()); | 1409 OFStream os(tracing_scope.file()); |
1410 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" | 1410 os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{" |
1411 << info_->optimization_id() << "," << inline_id << "} AS " << inline_id | 1411 << info_->optimization_id() << "," << inline_id << "} AS " << inline_id |
1412 << " AT " << position << std::endl; | 1412 << " AT " << position << std::endl; |
1413 } | 1413 } |
1414 | 1414 |
1415 return inline_id; | 1415 return inline_id; |
(...skipping 2401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3817 for (int i = 0; i < blocks()->length(); ++i) { | 3817 for (int i = 0; i < blocks()->length(); ++i) { |
3818 for (HInstructionIterator it(blocks()->at(i)); !it.Done(); it.Advance()) { | 3818 for (HInstructionIterator it(blocks()->at(i)); !it.Done(); it.Advance()) { |
3819 it.Current()->FinalizeUniqueness(); | 3819 it.Current()->FinalizeUniqueness(); |
3820 } | 3820 } |
3821 } | 3821 } |
3822 } | 3822 } |
3823 | 3823 |
3824 | 3824 |
3825 int HGraph::SourcePositionToScriptPosition(SourcePosition pos) { | 3825 int HGraph::SourcePositionToScriptPosition(SourcePosition pos) { |
3826 return (FLAG_hydrogen_track_positions && !pos.IsUnknown()) | 3826 return (FLAG_hydrogen_track_positions && !pos.IsUnknown()) |
3827 ? info()->inlined_function_infos() | 3827 ? inlined_function_infos_.at(pos.inlining_id()).start_position + |
3828 .at(pos.inlining_id()) | |
3829 .start_position + | |
3830 pos.position() | 3828 pos.position() |
3831 : pos.raw(); | 3829 : pos.raw(); |
3832 } | 3830 } |
3833 | 3831 |
3834 | 3832 |
3835 // Block ordering was implemented with two mutually recursive methods, | 3833 // Block ordering was implemented with two mutually recursive methods, |
3836 // HGraph::Postorder and HGraph::PostorderLoopBlocks. | 3834 // HGraph::Postorder and HGraph::PostorderLoopBlocks. |
3837 // The recursion could lead to stack overflow so the algorithm has been | 3835 // The recursion could lead to stack overflow so the algorithm has been |
3838 // implemented iteratively. | 3836 // implemented iteratively. |
3839 // At a high level the algorithm looks like this: | 3837 // At a high level the algorithm looks like this: |
(...skipping 9900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13740 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13738 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13741 } | 13739 } |
13742 | 13740 |
13743 #ifdef DEBUG | 13741 #ifdef DEBUG |
13744 graph_->Verify(false); // No full verify. | 13742 graph_->Verify(false); // No full verify. |
13745 #endif | 13743 #endif |
13746 } | 13744 } |
13747 | 13745 |
13748 } // namespace internal | 13746 } // namespace internal |
13749 } // namespace v8 | 13747 } // namespace v8 |
OLD | NEW |