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

Unified Diff: src/crankshaft/lithium-codegen.cc

Issue 2451853002: Uniform and precise source positions for inlining (Closed)
Patch Set: fixed gcmole issue Created 4 years, 1 month 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
Index: src/crankshaft/lithium-codegen.cc
diff --git a/src/crankshaft/lithium-codegen.cc b/src/crankshaft/lithium-codegen.cc
index 7e2333f558b18200160b6c40bb36cdc7564c4abc..e03380560dd69374b10480086f846ed05b8b4428 100644
--- a/src/crankshaft/lithium-codegen.cc
+++ b/src/crankshaft/lithium-codegen.cc
@@ -103,9 +103,8 @@ bool LCodeGenBase::GenerateBody() {
GenerateBodyInstructionPre(instr);
HValue* value = instr->hydrogen_value();
- if (!value->position().IsUnknown()) {
- RecordAndWritePosition(
- chunk()->graph()->SourcePositionToScriptPosition(value->position()));
+ if (value->position().IsKnown()) {
+ RecordAndWritePosition(value->position());
}
instr->CompileToNative(codegen);
@@ -141,8 +140,8 @@ void LCodeGenBase::CheckEnvironmentUsage() {
#endif
}
-void LCodeGenBase::RecordAndWritePosition(int pos) {
- if (pos == kNoSourcePosition) return;
+void LCodeGenBase::RecordAndWritePosition(SourcePosition pos) {
+ if (!pos.IsKnown()) return;
source_position_table_builder_.AddPosition(masm_->pc_offset(), pos, false);
}
@@ -167,8 +166,7 @@ void LCodeGenBase::Comment(const char* format, ...) {
void LCodeGenBase::DeoptComment(const Deoptimizer::DeoptInfo& deopt_info) {
SourcePosition position = deopt_info.position;
int deopt_id = deopt_info.deopt_id;
- int raw_position = position.IsUnknown() ? 0 : position.raw();
- masm()->RecordDeoptReason(deopt_info.deopt_reason, raw_position, deopt_id);
+ masm()->RecordDeoptReason(deopt_info.deopt_reason, position, deopt_id);
}
@@ -311,6 +309,26 @@ void LCodeGenBase::WriteTranslationFrame(LEnvironment* environment,
}
}
+namespace {
+
+Handle<PodArray<InliningPosition>> CreateInliningPositions(
+ CompilationInfo* info) {
+ const CompilationInfo::InlinedFunctionList& inlined_functions =
+ info->inlined_functions();
+ if (inlined_functions.size() == 0) {
+ return Handle<PodArray<InliningPosition>>::cast(
+ info->isolate()->factory()->empty_byte_array());
+ }
+ Handle<PodArray<InliningPosition>> inl_positions =
+ PodArray<InliningPosition>::New(
+ info->isolate(), static_cast<int>(inlined_functions.size()), TENURED);
+ for (size_t i = 0; i < inlined_functions.size(); ++i) {
+ inl_positions->set(static_cast<int>(i), inlined_functions[i].position);
+ }
+ return inl_positions;
+}
+
+} // namespace
void LCodeGenBase::PopulateDeoptimizationData(Handle<Code> code) {
int length = deoptimizations_.length();
@@ -342,6 +360,9 @@ void LCodeGenBase::PopulateDeoptimizationData(Handle<Code> code) {
data->SetLiteralArray(*literals);
}
+ Handle<PodArray<InliningPosition>> inl_pos = CreateInliningPositions(info_);
+ data->SetInliningPositions(*inl_pos);
+
data->SetOsrAstId(Smi::FromInt(info_->osr_ast_id().ToInt()));
data->SetOsrPcOffset(Smi::FromInt(osr_pc_offset_));
@@ -360,16 +381,22 @@ void LCodeGenBase::PopulateDeoptimizationData(Handle<Code> code) {
void LCodeGenBase::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
DCHECK_EQ(0, deoptimization_literals_.length());
- for (Handle<SharedFunctionInfo> function : chunk()->inlined_functions()) {
- DefineDeoptimizationLiteral(function);
+ for (CompilationInfo::InlinedFunctionHolder& inlined :
+ info()->inlined_functions()) {
+ if (!inlined.shared_info.is_identical_to(info()->shared_info())) {
+ inlined.RegisterInlinedFunctionId(deoptimization_literals_.length());
+ DefineDeoptimizationLiteral(inlined.shared_info);
+ }
}
inlined_function_count_ = deoptimization_literals_.length();
// Define deoptimization literals for all unoptimized code objects of inlined
// functions. This ensures unoptimized code is kept alive by optimized code.
- AllowDeferredHandleDereference allow_shared_function_info_dereference;
- for (Handle<SharedFunctionInfo> function : chunk()->inlined_functions()) {
- DefineDeoptimizationLiteral(handle(function->code()));
+ for (const CompilationInfo::InlinedFunctionHolder& inlined :
+ info()->inlined_functions()) {
+ if (!inlined.shared_info.is_identical_to(info()->shared_info())) {
+ DefineDeoptimizationLiteral(inlined.inlined_code_object_root);
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698