From 8f170a66e7badc4044f2d0bc19ae9611f0cd4cec Mon Sep 17 00:00:00 2001 From: "vegorov@chromium.org" Date: Thu, 13 Feb 2014 16:09:28 +0000 Subject: [PATCH] Improve positions tracking inside the HGraphBuilder. Instead of tracking simple absolute offset from the start of the script like other places do, track a pair of (inlining id, offset from the start of inlined function). This enables us to pinpoint with inlining path an instruction came from. Previously in multi-script environments we emitted positions that made very little sense because inside a single optimized function they would point to different scripts without a way to distinguish them. Start dumping the source of every inlined function to make possible IR viewing tools with integrated source views as there was previously no way to acquire this information from IR dumps. We also dump source position at which each inlining occured. Tracked positions are written into hydrogen.cfg as pos:_. Flag --emit-opt-code-positions is renamed by this change into --hydrogen-track-positions to better convey it's meaning. In addition this change assigned global unique identifier to each optimization performed inside isolate. This allows to precisely match compilation artifacts (e.g. IR and disassembly) and deoptimizations. BUG= R=yangguo@chromium.org Review URL: https://codereview.chromium.org/140683011 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19360 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-arm.cc | 1 - src/arm/lithium-arm.h | 2 - src/arm/lithium-codegen-arm.cc | 4 +- src/codegen.cc | 2 + src/compiler.cc | 14 ++- src/compiler.h | 5 + src/deoptimizer.cc | 13 +- src/flag-definitions.h | 7 +- src/hydrogen-instructions.cc | 21 +++- src/hydrogen-instructions.h | 124 +++++++++++++----- src/hydrogen-representation-changes.cc | 5 +- src/hydrogen.cc | 224 ++++++++++++++++++++++++++------- src/hydrogen.h | 89 ++++++++++--- src/ia32/lithium-codegen-ia32.cc | 4 +- src/isolate.cc | 3 +- src/isolate.h | 10 ++ src/lithium-codegen.cc | 8 +- src/mips/lithium-codegen-mips.cc | 4 +- src/objects.h | 4 +- src/x64/lithium-codegen-x64.cc | 4 +- 20 files changed, 417 insertions(+), 131 deletions(-) diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 38509a6..8eb5eb7 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -840,7 +840,6 @@ void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { void LChunkBuilder::VisitInstruction(HInstruction* current) { HInstruction* old_current = current_instruction_; current_instruction_ = current; - if (current->has_position()) position_ = current->position(); LInstruction* instr = NULL; if (current->CanReplaceWithDummyUses()) { diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index 29a1766..982ac2c 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -2580,7 +2580,6 @@ class LChunkBuilder V8_FINAL : public LChunkBuilderBase { current_block_(NULL), next_block_(NULL), allocator_(allocator), - position_(RelocInfo::kNoPosition), instruction_pending_deoptimization_environment_(NULL), pending_deoptimization_ast_id_(BailoutId::None()) { } @@ -2717,7 +2716,6 @@ class LChunkBuilder V8_FINAL : public LChunkBuilderBase { HBasicBlock* current_block_; HBasicBlock* next_block_; LAllocator* allocator_; - int position_; LInstruction* instruction_pending_deoptimization_environment_; BailoutId pending_deoptimization_ast_id_; diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 54ec589..424f2e6 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -277,7 +277,8 @@ bool LCodeGen::GenerateDeferredCode() { HValue* value = instructions_->at(code->instruction_index())->hydrogen_value(); - RecordAndWritePosition(value->position()); + RecordAndWritePosition( + chunk()->graph()->SourcePositionToScriptPosition(value->position())); Comment(";;; <@%d,#%d> " "-------------------- Deferred %s --------------------", @@ -906,6 +907,7 @@ void LCodeGen::PopulateDeoptimizationData(Handle code) { translations_.CreateByteArray(isolate()->factory()); data->SetTranslationByteArray(*translations); data->SetInlinedFunctionCount(Smi::FromInt(inlined_function_count_)); + data->SetOptimizationId(Smi::FromInt(info_->optimization_id())); Handle literals = factory()->NewFixedArray(deoptimization_literals_.length(), TENURED); diff --git a/src/codegen.cc b/src/codegen.cc index 13ce221..f6c3668 100644 --- a/src/codegen.cc +++ b/src/codegen.cc @@ -165,6 +165,8 @@ void CodeGenerator::PrintCode(Handle code, CompilationInfo* info) { function->debug_name()->ToCString().get(), tracing_scope.file()); } PrintF(tracing_scope.file(), "--- Optimized code ---\n"); + PrintF(tracing_scope.file(), + "optimization_id = %d\n", info->optimization_id()); } else { PrintF(tracing_scope.file(), "--- Code ---\n"); } diff --git a/src/compiler.cc b/src/compiler.cc index 6ebbe41..003c5ab 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -60,7 +60,8 @@ CompilationInfo::CompilationInfo(Handle