Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(954)

Unified Diff: src/crankshaft/hydrogen.cc

Issue 1944323002: [compiler] Move inline function tracing to Crankshaft. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | src/crankshaft/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/crankshaft/hydrogen.cc
diff --git a/src/crankshaft/hydrogen.cc b/src/crankshaft/hydrogen.cc
index d70b4805e1a66fc045f9612b0721add3d4328f91..ed5451fa02904395a7f21b8437efb643327b4b6b 100644
--- a/src/crankshaft/hydrogen.cc
+++ b/src/crankshaft/hydrogen.cc
@@ -1353,6 +1353,10 @@ void HGraphBuilder::LoopBuilder::EndBody() {
HGraph* HGraphBuilder::CreateGraph() {
graph_ = new (zone()) HGraph(info_, descriptor_);
if (FLAG_hydrogen_stats) isolate()->GetHStatistics()->Initialize(info_);
+ if (!info_->IsStub() && info_->is_tracking_positions()) {
+ TraceInlinedFunction(info_->shared_info(), SourcePosition::Unknown(),
+ InlinedFunctionInfo::kNoParentId);
+ }
CompilationPhase phase("H_Block building", info_);
set_current_block(graph()->entry_block());
if (!BuildGraph()) return NULL;
@@ -1360,6 +1364,51 @@ HGraph* HGraphBuilder::CreateGraph() {
return graph_;
}
+int HGraphBuilder::TraceInlinedFunction(Handle<SharedFunctionInfo> shared,
+ SourcePosition position,
+ int parent_id) {
+ DCHECK(info_->is_tracking_positions());
+
+ int inline_id = static_cast<int>(info_->inlined_function_infos().size());
+ InlinedFunctionInfo info(parent_id, position, UnboundScript::kNoScriptId,
+ shared->start_position());
+ if (!shared->script()->IsUndefined()) {
+ Handle<Script> script(Script::cast(shared->script()));
+ info.script_id = script->id();
+
+ if (FLAG_hydrogen_track_positions && !script->source()->IsUndefined()) {
+ CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
+ OFStream os(tracing_scope.file());
+ os << "--- FUNCTION SOURCE (" << shared->DebugName()->ToCString().get()
+ << ") id{" << info_->optimization_id() << "," << inline_id
+ << "} ---\n";
+ {
+ DisallowHeapAllocation no_allocation;
+ int start = shared->start_position();
+ int len = shared->end_position() - start;
+ String::SubStringRange source(String::cast(script->source()), start,
+ len);
+ for (const auto& c : source) {
+ os << AsReversiblyEscapedUC16(c);
+ }
+ }
+
+ os << "\n--- END ---\n";
+ }
+ }
+
+ info_->inlined_function_infos().push_back(info);
+
+ if (FLAG_hydrogen_track_positions && inline_id != 0) {
+ CodeTracer::Scope tracing_scope(isolate()->GetCodeTracer());
+ OFStream os(tracing_scope.file());
+ os << "INLINE (" << shared->DebugName()->ToCString().get() << ") id{"
+ << info_->optimization_id() << "," << inline_id << "} AS " << inline_id
+ << " AT " << position << std::endl;
+ }
+
+ return inline_id;
+}
HInstruction* HGraphBuilder::AddInstruction(HInstruction* instr) {
DCHECK(current_block() != NULL);
@@ -3787,10 +3836,6 @@ HGraph::HGraph(CompilationInfo* info, CallInterfaceDescriptor descriptor)
start_environment_ = new (zone_)
HEnvironment(zone_, descriptor.GetRegisterParameterCount() + 1);
} else {
- if (info->is_tracking_positions()) {
- info->TraceInlinedFunction(info->shared_info(), SourcePosition::Unknown(),
- InlinedFunctionInfo::kNoParentId);
- }
start_environment_ =
new(zone_) HEnvironment(NULL, info->scope(), info->closure(), zone_);
}
@@ -3819,7 +3864,10 @@ void HGraph::FinalizeUniqueness() {
int HGraph::SourcePositionToScriptPosition(SourcePosition pos) {
return (FLAG_hydrogen_track_positions && !pos.IsUnknown())
- ? info()->start_position_for(pos.inlining_id()) + pos.position()
+ ? info()->inlined_function_infos()
+ .at(pos.inlining_id())
+ .start_position +
+ pos.position()
: pos.raw();
}
@@ -8647,8 +8695,8 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
int inlining_id = 0;
if (top_info()->is_tracking_positions()) {
- inlining_id = top_info()->TraceInlinedFunction(
- target_shared, source_position(), function_state()->inlining_id());
+ inlining_id = TraceInlinedFunction(target_shared, source_position(),
+ function_state()->inlining_id());
}
// Save the pending call context. Set up new one for the inlined function.
« no previous file with comments | « src/crankshaft/hydrogen.h ('k') | src/crankshaft/ia32/lithium-codegen-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698