From cd78dbe709e7feddbb95d95ae8a7db7c0014daaa Mon Sep 17 00:00:00 2001 From: "fschneider@google.com" Date: Tue, 16 Sep 2014 10:31:47 +0000 Subject: [PATCH] Refactor generating lazy deoptimization descriptors. Instead of having special handling for closure calls, pass the number of input operands down so that the correct lazy deoptimization environment is generated at calls. There is no functional change here - this is to simplify having calls with pushed arguments and input operands (like closure calls). Runtime calls still do not have a correct lazy deoptimization environment the environment should only be used for creating stack traces from optimized code. Fix a bug with --trace-deoptimization-verbose printing: We cannot call ToCString on objects when the slots have not been filled in yet. (e.g. Closures) R=vegorov@google.com Review URL: https://codereview.chromium.org//575443002 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@40306 260f80e4-7a28-3924-810f-c04153c831b5 --- .../vm/dart/inline_stack_frame_test.dart | 3 -- runtime/vm/deferred_objects.cc | 8 ++-- runtime/vm/flow_graph.cc | 10 ----- runtime/vm/flow_graph_builder.cc | 3 +- runtime/vm/flow_graph_compiler.cc | 30 +++++++++++++- runtime/vm/flow_graph_compiler.h | 16 ++++++-- runtime/vm/flow_graph_compiler_arm.cc | 40 +++--------------- runtime/vm/flow_graph_compiler_arm64.cc | 37 +++-------------- runtime/vm/flow_graph_compiler_ia32.cc | 37 +++-------------- runtime/vm/flow_graph_compiler_mips.cc | 41 +++---------------- runtime/vm/flow_graph_compiler_x64.cc | 37 +++-------------- runtime/vm/intermediate_language.cc | 7 +++- runtime/vm/intermediate_language.h | 4 +- runtime/vm/intermediate_language_arm.cc | 21 +++------- runtime/vm/intermediate_language_arm64.cc | 21 +++------- runtime/vm/intermediate_language_ia32.cc | 21 +++------- runtime/vm/intermediate_language_mips.cc | 21 +++------- runtime/vm/intermediate_language_x64.cc | 21 +++------- 18 files changed, 105 insertions(+), 273 deletions(-) diff --git a/runtime/tests/vm/dart/inline_stack_frame_test.dart b/runtime/tests/vm/dart/inline_stack_frame_test.dart index 62fa81934ee..a4fece1bb7a 100644 --- a/runtime/tests/vm/dart/inline_stack_frame_test.dart +++ b/runtime/tests/vm/dart/inline_stack_frame_test.dart @@ -14,9 +14,6 @@ import "package:expect/expect.dart"; // method in the invocation chain. The test is run during warmup to ensure // unoptimized code produces the correct result and is then run // in a loop to ensure optimization kicks in and some inlining is done. -// Note: it appears that functions which have a throw are not inlined (func4) -// and functions that have try/catch in them are not optimized (func1). -// func2 is not inlined as func1 has not been optimized. class Test { String func1(var k) { diff --git a/runtime/vm/deferred_objects.cc b/runtime/vm/deferred_objects.cc index a275a5c9b62..7dc8c957e1d 100644 --- a/runtime/vm/deferred_objects.cc +++ b/runtime/vm/deferred_objects.cc @@ -88,9 +88,11 @@ void DeferredObjectRef::Materialize(DeoptContext* deopt_context) { DeferredObject* obj = deopt_context->GetDeferredObject(index()); *slot() = obj->object(); if (FLAG_trace_deoptimization_verbose) { - OS::PrintErr("writing instance ref at %" Px ": %s\n", - reinterpret_cast(slot()), - Instance::Handle(obj->object()).ToCString()); + const Class& cls = Class::Handle(Isolate::Current()->class_table()->At( + Object::Handle(obj->object()).GetClassId())); + OS::PrintErr("writing instance of class %s ref at %" Px ".\n", + cls.ToCString(), + reinterpret_cast(slot())); } } diff --git a/runtime/vm/flow_graph.cc b/runtime/vm/flow_graph.cc index 82bf692b4ea..cfdd9658984 100644 --- a/runtime/vm/flow_graph.cc +++ b/runtime/vm/flow_graph.cc @@ -766,16 +766,6 @@ void FlowGraph::AttachEnvironment(Instruction* instr, *env, num_non_copied_params_, &parsed_function_); - // TODO(fschneider): Add predicates CanEagerlyDeoptimize and - // CanLazilyDeoptimize to instructions to generally deal with instructions - // that have pushed arguments and input operands. - // Right now, closure calls are the only instructions that have both. They - // also don't have an eager deoptimziation point, so the environment attached - // here is only used for after the call. - if (instr->IsClosureCall()) { - deopt_env = deopt_env->DeepCopy(isolate(), - deopt_env->Length() - instr->InputCount()); - } instr->SetEnvironment(deopt_env); for (Environment::DeepIterator it(deopt_env); !it.Done(); it.Advance()) { Value* use = it.CurrentValue(); diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc index cdefacb4d6c..4787ba7cb7e 100644 --- a/runtime/vm/flow_graph_builder.cc +++ b/runtime/vm/flow_graph_builder.cc @@ -299,7 +299,8 @@ void InlineExitCollector::PrepareGraphs(FlowGraph* callee_graph) { // optimizations need deoptimization info for non-deoptable instructions, // eg, LICM on GOTOs. if (instr->env() != NULL) { - call_->env()->DeepCopyToOuter(callee_graph->isolate(), instr); + call_->env()->DeepCopyToOuter( + callee_graph->isolate(), instr, call_->InputCount()); } } if (instr->IsGoto()) { diff --git a/runtime/vm/flow_graph_compiler.cc b/runtime/vm/flow_graph_compiler.cc index 74694403ed3..64e44af5541 100644 --- a/runtime/vm/flow_graph_compiler.cc +++ b/runtime/vm/flow_graph_compiler.cc @@ -541,13 +541,16 @@ void FlowGraphCompiler::AddStaticCallTarget(const Function& func) { void FlowGraphCompiler::AddDeoptIndexAtCall(intptr_t deopt_id, - intptr_t token_pos) { + intptr_t token_pos, + intptr_t input_count) { ASSERT(is_optimizing()); ASSERT(!intrinsic_mode()); + Environment* env = pending_deoptimization_env_->DeepCopy( + isolate(), pending_deoptimization_env_->Length() - input_count); CompilerDeoptInfo* info = new CompilerDeoptInfo(deopt_id, ICData::kDeoptAtCall, - pending_deoptimization_env_); + env); info->set_pc_offset(assembler()->CodeSize()); deopt_infos_.Add(info); } @@ -872,6 +875,29 @@ void FlowGraphCompiler::TryIntrinsify() { } +// Record safe point and deoptimization info if applicable. +void FlowGraphCompiler::RecordCallInfo(intptr_t token_pos, + RawPcDescriptors::Kind kind, + intptr_t deopt_id, + LocationSummary* locs, + intptr_t input_count_adjustment) { + AddCurrentDescriptor(kind, deopt_id, token_pos); + RecordSafepoint(locs); + if (deopt_id != Isolate::kNoDeoptId) { + // Marks either the continuation point in unoptimized code or the + // deoptimization point in optimized code, after call. + const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); + if (is_optimizing()) { + AddDeoptIndexAtCall(deopt_id_after, token_pos, input_count_adjustment); + } else { + // Add deoptimization continuation point after the call and before the + // arguments are removed. + AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); + } + } +} + + void FlowGraphCompiler::GenerateInstanceCall( intptr_t deopt_id, intptr_t token_pos, diff --git a/runtime/vm/flow_graph_compiler.h b/runtime/vm/flow_graph_compiler.h index 9ce9f47f022..fee2f89dfdd 100644 --- a/runtime/vm/flow_graph_compiler.h +++ b/runtime/vm/flow_graph_compiler.h @@ -320,6 +320,12 @@ class FlowGraphCompiler : public ValueObject { void TryIntrinsify(); + void RecordCallInfo(intptr_t token_pos, + RawPcDescriptors::Kind kind, + intptr_t deopt_id, + LocationSummary* locs, + intptr_t input_count_adjustment); + void GenerateRuntimeCall(intptr_t token_pos, intptr_t deopt_id, const RuntimeEntry& entry, @@ -445,12 +451,8 @@ class FlowGraphCompiler : public ValueObject { intptr_t deopt_id, intptr_t token_pos); - void RecordSafepoint(LocationSummary* locs); - Label* AddDeoptStub(intptr_t deopt_id, ICData::DeoptReasonId reason); - void AddDeoptIndexAtCall(intptr_t deopt_id, intptr_t token_pos); - void AddSlowPathCode(SlowPathCode* slow_path); void FinalizeExceptionHandlers(const Code& code); @@ -506,8 +508,14 @@ class FlowGraphCompiler : public ValueObject { void EmitFrameEntry(); + void RecordSafepoint(LocationSummary* locs); + void AddStaticCallTarget(const Function& function); + void AddDeoptIndexAtCall(intptr_t deopt_id, + intptr_t token_pos, + intptr_t input_count); + void GenerateDeferredCode(); void EmitInstructionPrologue(Instruction* instr); diff --git a/runtime/vm/flow_graph_compiler_arm.cc b/runtime/vm/flow_graph_compiler_arm.cc index 67c26edb1ab..23fa9bb574a 100644 --- a/runtime/vm/flow_graph_compiler_arm.cc +++ b/runtime/vm/flow_graph_compiler_arm.cc @@ -1103,8 +1103,7 @@ void FlowGraphCompiler::GenerateCall(intptr_t token_pos, RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); - AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); - RecordSafepoint(locs); + RecordCallInfo(token_pos, kind, Isolate::kNoDeoptId, locs, 0); } @@ -1114,19 +1113,7 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); - AddCurrentDescriptor(kind, deopt_id, token_pos); - RecordSafepoint(locs); - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); - if (is_optimizing()) { - AddDeoptIndexAtCall(deopt_id_after, token_pos); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - AddCurrentDescriptor(RawPcDescriptors::kDeopt, - deopt_id_after, token_pos); - } + RecordCallInfo(token_pos, kind, deopt_id, locs, locs->input_count()); } @@ -1136,22 +1123,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, intptr_t argument_count, LocationSummary* locs) { __ CallRuntime(entry, argument_count); - AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); - RecordSafepoint(locs); - if (deopt_id != Isolate::kNoDeoptId) { - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); - if (is_optimizing()) { - AddDeoptIndexAtCall(deopt_id_after, token_pos); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - AddCurrentDescriptor(RawPcDescriptors::kDeopt, - deopt_id_after, - token_pos); - } - } + RecordCallInfo(token_pos, RawPcDescriptors::kOther, deopt_id, locs, 0); } @@ -1271,10 +1243,8 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( __ LoadObject(R4, arguments_descriptor); __ AddImmediate(R1, Instructions::HeaderSize() - kHeapObjectTag); __ blx(R1); - AddCurrentDescriptor(RawPcDescriptors::kOther, - Isolate::kNoDeoptId, token_pos); - RecordSafepoint(locs); - AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); + RecordCallInfo( + token_pos, RawPcDescriptors::kOther, deopt_id, locs, locs->input_count()); __ Drop(argument_count); } diff --git a/runtime/vm/flow_graph_compiler_arm64.cc b/runtime/vm/flow_graph_compiler_arm64.cc index 4ec82608aa6..eedbea911cb 100644 --- a/runtime/vm/flow_graph_compiler_arm64.cc +++ b/runtime/vm/flow_graph_compiler_arm64.cc @@ -1113,8 +1113,7 @@ void FlowGraphCompiler::GenerateCall(intptr_t token_pos, RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); - AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); - RecordSafepoint(locs); + RecordCallInfo(token_pos, kind, Isolate::kNoDeoptId, locs, 0); } @@ -1124,18 +1123,7 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); - AddCurrentDescriptor(kind, deopt_id, token_pos); - RecordSafepoint(locs); - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); - if (is_optimizing()) { - AddDeoptIndexAtCall(deopt_id_after, token_pos); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); - } + RecordCallInfo(token_pos, kind, deopt_id, locs, locs->input_count()); } @@ -1145,20 +1133,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, intptr_t argument_count, LocationSummary* locs) { __ CallRuntime(entry, argument_count); - AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); - RecordSafepoint(locs); - if (deopt_id != Isolate::kNoDeoptId) { - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); - if (is_optimizing()) { - AddDeoptIndexAtCall(deopt_id_after, token_pos); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); - } - } + RecordCallInfo(token_pos, RawPcDescriptors::kOther, deopt_id, locs, 0); } @@ -1278,10 +1253,8 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( __ LoadObject(R4, arguments_descriptor, PP); __ AddImmediate(R1, R1, Instructions::HeaderSize() - kHeapObjectTag, PP); __ blr(R1); - AddCurrentDescriptor(RawPcDescriptors::kOther, - Isolate::kNoDeoptId, token_pos); - RecordSafepoint(locs); - AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); + RecordCallInfo( + token_pos, RawPcDescriptors::kOther, deopt_id, locs, locs->input_count()); __ Drop(argument_count); } diff --git a/runtime/vm/flow_graph_compiler_ia32.cc b/runtime/vm/flow_graph_compiler_ia32.cc index 6236d5c8b4b..e19df6282cc 100644 --- a/runtime/vm/flow_graph_compiler_ia32.cc +++ b/runtime/vm/flow_graph_compiler_ia32.cc @@ -1110,8 +1110,7 @@ void FlowGraphCompiler::GenerateCall(intptr_t token_pos, RawPcDescriptors::Kind kind, LocationSummary* locs) { __ call(label); - AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); - RecordSafepoint(locs); + RecordCallInfo(token_pos, kind, Isolate::kNoDeoptId, locs, 0); } @@ -1121,18 +1120,7 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, RawPcDescriptors::Kind kind, LocationSummary* locs) { __ call(label); - AddCurrentDescriptor(kind, deopt_id, token_pos); - RecordSafepoint(locs); - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); - if (is_optimizing()) { - AddDeoptIndexAtCall(deopt_id_after, token_pos); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); - } + RecordCallInfo(token_pos, kind, deopt_id, locs, locs->input_count()); } @@ -1142,20 +1130,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, intptr_t argument_count, LocationSummary* locs) { __ CallRuntime(entry, argument_count); - AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); - RecordSafepoint(locs); - if (deopt_id != Isolate::kNoDeoptId) { - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); - if (is_optimizing()) { - AddDeoptIndexAtCall(deopt_id_after, token_pos); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); - } - } + RecordCallInfo(token_pos, RawPcDescriptors::kOther, deopt_id, locs, 0); } @@ -1297,10 +1272,8 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( __ LoadObject(EDX, arguments_descriptor); __ addl(EBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); __ call(EBX); - AddCurrentDescriptor(RawPcDescriptors::kOther, - Isolate::kNoDeoptId, token_pos); - RecordSafepoint(locs); - AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); + RecordCallInfo( + token_pos, RawPcDescriptors::kOther, deopt_id, locs, locs->input_count()); __ Drop(argument_count); } diff --git a/runtime/vm/flow_graph_compiler_mips.cc b/runtime/vm/flow_graph_compiler_mips.cc index 8ed3f907c19..cbf3814eb2e 100644 --- a/runtime/vm/flow_graph_compiler_mips.cc +++ b/runtime/vm/flow_graph_compiler_mips.cc @@ -1139,8 +1139,7 @@ void FlowGraphCompiler::GenerateCall(intptr_t token_pos, RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); - AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); - RecordSafepoint(locs); + RecordCallInfo(token_pos, kind, Isolate::kNoDeoptId, locs, 0); } @@ -1150,20 +1149,7 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); - AddCurrentDescriptor(kind, deopt_id, token_pos); - RecordSafepoint(locs); - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); - if (is_optimizing()) { - AddDeoptIndexAtCall(deopt_id_after, token_pos); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - AddCurrentDescriptor(RawPcDescriptors::kDeopt, - deopt_id_after, - token_pos); - } + RecordCallInfo(token_pos, kind, deopt_id, locs, locs->input_count()); } @@ -1173,22 +1159,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, intptr_t argument_count, LocationSummary* locs) { __ CallRuntime(entry, argument_count); - AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); - RecordSafepoint(locs); - if (deopt_id != Isolate::kNoDeoptId) { - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); - if (is_optimizing()) { - AddDeoptIndexAtCall(deopt_id_after, token_pos); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - AddCurrentDescriptor(RawPcDescriptors::kDeopt, - deopt_id_after, - token_pos); - } - } + RecordCallInfo(token_pos, RawPcDescriptors::kOther, deopt_id, locs, 0); } @@ -1312,10 +1283,8 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( __ LoadObject(S4, arguments_descriptor); __ AddImmediate(T1, Instructions::HeaderSize() - kHeapObjectTag); __ jalr(T1); - AddCurrentDescriptor(RawPcDescriptors::kOther, - Isolate::kNoDeoptId, token_pos); - RecordSafepoint(locs); - AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); + RecordCallInfo( + token_pos, RawPcDescriptors::kOther, deopt_id, locs, locs->input_count()); __ Drop(argument_count); } diff --git a/runtime/vm/flow_graph_compiler_x64.cc b/runtime/vm/flow_graph_compiler_x64.cc index 051dc85839c..f1d14ff105e 100644 --- a/runtime/vm/flow_graph_compiler_x64.cc +++ b/runtime/vm/flow_graph_compiler_x64.cc @@ -1148,8 +1148,7 @@ void FlowGraphCompiler::GenerateCall(intptr_t token_pos, RawPcDescriptors::Kind kind, LocationSummary* locs) { __ Call(label, PP); - AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); - RecordSafepoint(locs); + RecordCallInfo(token_pos, kind, Isolate::kNoDeoptId, locs, 0); } @@ -1159,18 +1158,7 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, RawPcDescriptors::Kind kind, LocationSummary* locs) { __ CallPatchable(label); - AddCurrentDescriptor(kind, deopt_id, token_pos); - RecordSafepoint(locs); - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); - if (is_optimizing()) { - AddDeoptIndexAtCall(deopt_id_after, token_pos); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); - } + RecordCallInfo(token_pos, kind, deopt_id, locs, locs->input_count()); } @@ -1180,20 +1168,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, intptr_t argument_count, LocationSummary* locs) { __ CallRuntime(entry, argument_count); - AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); - RecordSafepoint(locs); - if (deopt_id != Isolate::kNoDeoptId) { - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id); - if (is_optimizing()) { - AddDeoptIndexAtCall(deopt_id_after, token_pos); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); - } - } + RecordCallInfo(token_pos, RawPcDescriptors::kOther, deopt_id, locs, 0); } @@ -1334,10 +1309,8 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( __ AddImmediate( RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag), PP); __ call(RCX); - AddCurrentDescriptor(RawPcDescriptors::kOther, - Isolate::kNoDeoptId, token_pos); - RecordSafepoint(locs); - AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); + RecordCallInfo( + token_pos, RawPcDescriptors::kOther, deopt_id, locs, locs->input_count()); __ Drop(argument_count); } diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc index 3c12e4b634c..3adc9daa480 100644 --- a/runtime/vm/intermediate_language.cc +++ b/runtime/vm/intermediate_language.cc @@ -2722,12 +2722,15 @@ void Environment::DeepCopyTo(Isolate* isolate, Instruction* instr) const { // Copies the environment as outer on an inlined instruction and updates the // environment use lists. -void Environment::DeepCopyToOuter(Isolate* isolate, Instruction* instr) const { +void Environment::DeepCopyToOuter(Isolate* isolate, + Instruction* instr, + intptr_t input_count) const { // Create a deep copy removing caller arguments from the environment. ASSERT(this != NULL); ASSERT(instr->env()->outer() == NULL); intptr_t argument_count = instr->env()->fixed_parameter_count(); - Environment* copy = DeepCopy(isolate, values_.length() - argument_count); + Environment* copy = DeepCopy(isolate, + values_.length() - argument_count - input_count); instr->env()->outer_ = copy; intptr_t use_index = instr->env()->Length(); // Start index after inner. for (Environment::DeepIterator it(copy); !it.Done(); it.Advance()) { diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h index 43259525404..86af90fc2ff 100644 --- a/runtime/vm/intermediate_language.h +++ b/runtime/vm/intermediate_language.h @@ -8376,7 +8376,9 @@ class Environment : public ZoneAllocated { } void DeepCopyTo(Isolate* isolate, Instruction* instr) const; - void DeepCopyToOuter(Isolate* isolate, Instruction* instr) const; + void DeepCopyToOuter(Isolate* isolate, + Instruction* instr, + intptr_t input_count) const; void PrintTo(BufferFormatter* f) const; const char* ToCString() const; diff --git a/runtime/vm/intermediate_language_arm.cc b/runtime/vm/intermediate_language_arm.cc index 17162281dcc..9534e0d67e0 100644 --- a/runtime/vm/intermediate_language_arm.cc +++ b/runtime/vm/intermediate_language_arm.cc @@ -227,22 +227,11 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ LoadImmediate(R5, 0); __ AddImmediate(R2, Instructions::HeaderSize() - kHeapObjectTag); __ blx(R2); - compiler->AddCurrentDescriptor(RawPcDescriptors::kClosureCall, - deopt_id(), - token_pos()); - compiler->RecordSafepoint(locs()); - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id()); - if (compiler->is_optimizing()) { - compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos()); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, - deopt_id_after, - token_pos()); - } + compiler->RecordCallInfo(token_pos(), + RawPcDescriptors::kClosureCall, + deopt_id(), + locs(), + locs()->input_count()); __ Drop(argument_count); } diff --git a/runtime/vm/intermediate_language_arm64.cc b/runtime/vm/intermediate_language_arm64.cc index c977a8e8941..98afa1c6b22 100644 --- a/runtime/vm/intermediate_language_arm64.cc +++ b/runtime/vm/intermediate_language_arm64.cc @@ -222,22 +222,11 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ LoadImmediate(R5, 0, PP); __ AddImmediate(R2, R2, Instructions::HeaderSize() - kHeapObjectTag, PP); __ blr(R2); - compiler->AddCurrentDescriptor(RawPcDescriptors::kClosureCall, - deopt_id(), - token_pos()); - compiler->RecordSafepoint(locs()); - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id()); - if (compiler->is_optimizing()) { - compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos()); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, - deopt_id_after, - token_pos()); - } + compiler->RecordCallInfo(token_pos(), + RawPcDescriptors::kClosureCall, + deopt_id(), + locs(), + locs()->input_count()); __ Drop(argument_count); } diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc index 629a225fc1d..2b9340fdf90 100644 --- a/runtime/vm/intermediate_language_ia32.cc +++ b/runtime/vm/intermediate_language_ia32.cc @@ -6885,22 +6885,11 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ xorl(ECX, ECX); __ addl(EBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); __ call(EBX); - compiler->AddCurrentDescriptor(RawPcDescriptors::kClosureCall, - deopt_id(), - token_pos()); - compiler->RecordSafepoint(locs()); - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id()); - if (compiler->is_optimizing()) { - compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos()); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, - deopt_id_after, - token_pos()); - } + compiler->RecordCallInfo(token_pos(), + RawPcDescriptors::kClosureCall, + deopt_id(), + locs(), + locs()->input_count()); __ Drop(argument_count); } diff --git a/runtime/vm/intermediate_language_mips.cc b/runtime/vm/intermediate_language_mips.cc index 4462f6ecda8..de342c65cf2 100644 --- a/runtime/vm/intermediate_language_mips.cc +++ b/runtime/vm/intermediate_language_mips.cc @@ -247,22 +247,11 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ lw(T2, FieldAddress(T0, Function::instructions_offset())); __ AddImmediate(T2, Instructions::HeaderSize() - kHeapObjectTag); __ jalr(T2); - compiler->AddCurrentDescriptor(RawPcDescriptors::kClosureCall, - deopt_id(), - token_pos()); - compiler->RecordSafepoint(locs()); - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id()); - if (compiler->is_optimizing()) { - compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos()); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, - deopt_id_after, - token_pos()); - } + compiler->RecordCallInfo(token_pos(), + RawPcDescriptors::kClosureCall, + deopt_id(), + locs(), + locs()->input_count()); __ Drop(argument_count); } diff --git a/runtime/vm/intermediate_language_x64.cc b/runtime/vm/intermediate_language_x64.cc index 93b0492f23e..9ce0349df5c 100644 --- a/runtime/vm/intermediate_language_x64.cc +++ b/runtime/vm/intermediate_language_x64.cc @@ -5888,22 +5888,11 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ xorq(RBX, RBX); __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); __ call(RCX); - compiler->AddCurrentDescriptor(RawPcDescriptors::kClosureCall, - deopt_id(), - token_pos()); - compiler->RecordSafepoint(locs()); - // Marks either the continuation point in unoptimized code or the - // deoptimization point in optimized code, after call. - const intptr_t deopt_id_after = Isolate::ToDeoptAfter(deopt_id()); - if (compiler->is_optimizing()) { - compiler->AddDeoptIndexAtCall(deopt_id_after, token_pos()); - } else { - // Add deoptimization continuation point after the call and before the - // arguments are removed. - compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, - deopt_id_after, - token_pos()); - } + compiler->RecordCallInfo(token_pos(), + RawPcDescriptors::kClosureCall, + deopt_id(), + locs(), + locs()->input_count()); __ Drop(argument_count); }