From 2bb77cd8d58522dff8eb465c8eded7b8ee53cab5 Mon Sep 17 00:00:00 2001 From: "srdjan@google.com" Date: Mon, 7 Jul 2014 18:25:45 +0000 Subject: [PATCH] Iterate over PcDescriptors only via iterators, not via an index. (preparation for more compression of PcDescriptors). R=asiva@google.com Review URL: https://codereview.chromium.org//356923006 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@38032 260f80e4-7a28-3924-810f-c04153c831b5 --- runtime/vm/block_scheduler.cc | 3 +- runtime/vm/code_descriptors.cc | 2 +- runtime/vm/code_descriptors.h | 6 +- runtime/vm/code_descriptors_test.cc | 8 +- runtime/vm/coverage.cc | 14 ++- runtime/vm/debugger.cc | 134 +++++++++++----------- runtime/vm/debugger.h | 11 +- runtime/vm/debugger_arm.cc | 16 +-- runtime/vm/debugger_arm64.cc | 16 +-- runtime/vm/debugger_ia32.cc | 16 +-- runtime/vm/debugger_mips.cc | 16 +-- runtime/vm/debugger_x64.cc | 16 +-- runtime/vm/deopt_instructions.cc | 8 +- runtime/vm/flow_graph_builder.cc | 6 +- runtime/vm/flow_graph_compiler.cc | 6 +- runtime/vm/flow_graph_compiler.h | 6 +- runtime/vm/flow_graph_compiler_arm.cc | 28 ++--- runtime/vm/flow_graph_compiler_arm64.cc | 27 ++--- runtime/vm/flow_graph_compiler_ia32.cc | 27 ++--- runtime/vm/flow_graph_compiler_mips.cc | 27 ++--- runtime/vm/flow_graph_compiler_x64.cc | 27 ++--- runtime/vm/intermediate_language.cc | 6 +- runtime/vm/intermediate_language.h | 4 +- runtime/vm/intermediate_language_arm.cc | 30 ++--- runtime/vm/intermediate_language_arm64.cc | 28 ++--- runtime/vm/intermediate_language_ia32.cc | 32 +++--- runtime/vm/intermediate_language_mips.cc | 22 ++-- runtime/vm/intermediate_language_x64.cc | 28 ++--- runtime/vm/object.cc | 129 ++++++++++++--------- runtime/vm/object.h | 74 ++++++------ runtime/vm/object_test.cc | 46 +++++--- runtime/vm/raw_object.h | 23 +++- runtime/vm/simulator_arm.cc | 13 ++- runtime/vm/stack_frame.cc | 18 +-- 34 files changed, 460 insertions(+), 413 deletions(-) diff --git a/runtime/vm/block_scheduler.cc b/runtime/vm/block_scheduler.cc index 2533757e771..1e2dd98bdba 100644 --- a/runtime/vm/block_scheduler.cc +++ b/runtime/vm/block_scheduler.cc @@ -21,7 +21,8 @@ static intptr_t ComputeEdgeCount(const Code& unoptimized_code, // Assume everything was visited once. return 1; } - uword pc = unoptimized_code.GetPcForDeoptId(deopt_id, PcDescriptors::kDeopt); + const uword pc = + unoptimized_code.GetPcForDeoptId(deopt_id, RawPcDescriptors::kDeopt); Array& array = Array::Handle(); array ^= CodePatcher::GetEdgeCounterAt(pc, unoptimized_code); ASSERT(!array.IsNull()); diff --git a/runtime/vm/code_descriptors.cc b/runtime/vm/code_descriptors.cc index b8899123b0b..3e5eaa3bdeb 100644 --- a/runtime/vm/code_descriptors.cc +++ b/runtime/vm/code_descriptors.cc @@ -6,7 +6,7 @@ namespace dart { -void DescriptorList::AddDescriptor(PcDescriptors::Kind kind, +void DescriptorList::AddDescriptor(RawPcDescriptors::Kind kind, intptr_t pc_offset, intptr_t deopt_id, intptr_t token_index, diff --git a/runtime/vm/code_descriptors.h b/runtime/vm/code_descriptors.h index 9f066d9eaf4..dda6b0b952b 100644 --- a/runtime/vm/code_descriptors.h +++ b/runtime/vm/code_descriptors.h @@ -17,7 +17,7 @@ class DescriptorList : public ZoneAllocated { public: struct PcDesc { intptr_t pc_offset; // PC offset value of the descriptor. - PcDescriptors::Kind kind; // Descriptor kind (kDeopt, kOther). + RawPcDescriptors::Kind kind; // Descriptor kind (kDeopt, kOther). intptr_t deopt_id; // Deoptimization id. intptr_t data; // Token position or deopt reason. intptr_t try_index; // Try block index of PC or deopt array index. @@ -41,7 +41,7 @@ class DescriptorList : public ZoneAllocated { intptr_t PcOffset(intptr_t index) const { return list_[index].pc_offset; } - PcDescriptors::Kind Kind(intptr_t index) const { + RawPcDescriptors::Kind Kind(intptr_t index) const { return list_[index].kind; } intptr_t DeoptId(intptr_t index) const { @@ -57,7 +57,7 @@ class DescriptorList : public ZoneAllocated { return list_[index].try_index; } - void AddDescriptor(PcDescriptors::Kind kind, + void AddDescriptor(RawPcDescriptors::Kind kind, intptr_t pc_offset, intptr_t deopt_id, intptr_t token_index, diff --git a/runtime/vm/code_descriptors_test.cc b/runtime/vm/code_descriptors_test.cc index 3dd4b98e1ea..564a01830e7 100644 --- a/runtime/vm/code_descriptors_test.cc +++ b/runtime/vm/code_descriptors_test.cc @@ -257,9 +257,11 @@ TEST_CASE(StackmapGC) { const PcDescriptors& descriptors = PcDescriptors::Handle(code.pc_descriptors()); int call_count = 0; - for (int i = 0; i < descriptors.Length(); ++i) { - if (descriptors.DescriptorKind(i) == PcDescriptors::kUnoptStaticCall) { - stackmap_table_builder->AddEntry(descriptors.PC(i) - code.EntryPoint(), + PcDescriptors::Iterator iter(descriptors); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + if (rec.kind() == RawPcDescriptors::kUnoptStaticCall) { + stackmap_table_builder->AddEntry(rec.pc - code.EntryPoint(), stack_bitmap, 0); ++call_count; diff --git a/runtime/vm/coverage.cc b/runtime/vm/coverage.cc index 4572eb87d09..ed72bb0aaaa 100644 --- a/runtime/vm/coverage.cc +++ b/runtime/vm/coverage.cc @@ -90,16 +90,18 @@ void CodeCoverage::CompileAndAdd(const Function& function, const intptr_t end_pos = function.end_token_pos(); intptr_t last_line = -1; intptr_t last_count = 0; - for (int j = 0; j < descriptors.Length(); j++) { + PcDescriptors::Iterator iter(descriptors); + while (iter.HasNext()) { HANDLESCOPE(isolate); - PcDescriptors::Kind kind = descriptors.DescriptorKind(j); + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + RawPcDescriptors::Kind kind = rec.kind(); // Only IC based calls have counting. - if ((kind == PcDescriptors::kIcCall) || - (kind == PcDescriptors::kUnoptStaticCall)) { - intptr_t deopt_id = descriptors.DeoptId(j); + if ((kind == RawPcDescriptors::kIcCall) || + (kind == RawPcDescriptors::kUnoptStaticCall)) { + intptr_t deopt_id = rec.deopt_id; const ICData* ic_data= (*ic_data_array)[deopt_id]; if (!ic_data->IsNull()) { - intptr_t token_pos = descriptors.TokenPos(j); + intptr_t token_pos = rec.token_pos; // Filter out descriptors that do not map to tokens in the source code. if (token_pos < begin_pos || token_pos > end_pos) { diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc index 057e8f34a04..c1ef49a3f2c 100644 --- a/runtime/vm/debugger.cc +++ b/runtime/vm/debugger.cc @@ -180,7 +180,7 @@ ActivationFrame::ActivationFrame( code_(Code::ZoneHandle(code.raw())), function_(Function::ZoneHandle(code.function())), token_pos_(-1), - pc_desc_index_(-1), + desc_rec_(NULL), line_number_(-1), column_number_(-1), context_level_(-1), @@ -359,10 +359,12 @@ intptr_t ActivationFrame::TokenPos() { if (token_pos_ < 0) { token_pos_ = Scanner::kNoSourcePos; GetPcDescriptors(); - for (intptr_t i = 0; i < pc_desc_.Length(); i++) { - if (pc_desc_.PC(i) == pc_) { - pc_desc_index_ = i; - token_pos_ = pc_desc_.TokenPos(i); + PcDescriptors::Iterator iter(pc_desc_); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + if (rec.pc == pc_) { + desc_rec_ = &rec; + token_pos_ = rec.token_pos; break; } } @@ -371,20 +373,11 @@ intptr_t ActivationFrame::TokenPos() { } -intptr_t ActivationFrame::PcDescIndex() { - if (pc_desc_index_ < 0) { - TokenPos(); // Sets pc_desc_index_ as a side effect. - } - return pc_desc_index_; -} - - intptr_t ActivationFrame::TryIndex() { - intptr_t desc_index = PcDescIndex(); - if (desc_index < 0) { + if (desc_rec_ == NULL) { return -1; } else { - return pc_desc_.TryIndex(desc_index); + return desc_rec_->try_index; } } @@ -431,11 +424,10 @@ intptr_t ActivationFrame::ContextLevel() { if (context_level_ < 0 && !ctx_.IsNull()) { ASSERT(!code_.is_optimized()); context_level_ = 0; - intptr_t pc_desc_idx = PcDescIndex(); // TODO(hausner): What to do if there is no descriptor entry // for the code position of the frame? For now say we are at context // level 0. - if (pc_desc_idx < 0) { + if (desc_rec_ == NULL) { return context_level_; } ASSERT(!pc_desc_.IsNull()); @@ -929,38 +921,34 @@ void DebuggerStackTrace::AddActivation(ActivationFrame* frame) { } -static bool IsSafeDescKind(PcDescriptors::Kind kind) { - return ((kind == PcDescriptors::kIcCall) || - (kind == PcDescriptors::kOptStaticCall) || - (kind == PcDescriptors::kUnoptStaticCall) || - (kind == PcDescriptors::kClosureCall) || - (kind == PcDescriptors::kRuntimeCall)); +static bool IsSafeDescKind(int8_t kind) { + return ((kind == RawPcDescriptors::kIcCall) || + (kind == RawPcDescriptors::kOptStaticCall) || + (kind == RawPcDescriptors::kUnoptStaticCall) || + (kind == RawPcDescriptors::kClosureCall) || + (kind == RawPcDescriptors::kRuntimeCall)); } -static bool IsSafePoint(const PcDescriptors& desc, intptr_t i) { - return IsSafeDescKind(desc.DescriptorKind(i)) && - (desc.TokenPos(i) != Scanner::kNoSourcePos); +static bool IsSafePoint(const RawPcDescriptors::PcDescriptorRec& rec) { + return IsSafeDescKind(rec.kind()) && (rec.token_pos != Scanner::kNoSourcePos); } -CodeBreakpoint::CodeBreakpoint(const Code& code, intptr_t pc_desc_index) +CodeBreakpoint::CodeBreakpoint(const Code& code, + const RawPcDescriptors::PcDescriptorRec& rec) : code_(code.raw()), - pc_desc_index_(pc_desc_index), - pc_(0), + token_pos_(rec.token_pos), + pc_(rec.pc), line_number_(-1), is_enabled_(false), src_bpt_(NULL), - next_(NULL) { - saved_value_ = 0; + next_(NULL), + breakpoint_kind_(rec.kind()), + saved_value_(0) { ASSERT(!code.IsNull()); - PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors()); - ASSERT(pc_desc_index < desc.Length()); - token_pos_ = desc.TokenPos(pc_desc_index); ASSERT(token_pos_ > 0); - pc_ = desc.PC(pc_desc_index); ASSERT(pc_ != 0); - breakpoint_kind_ = desc.DescriptorKind(pc_desc_index); ASSERT(IsSafeDescKind(breakpoint_kind_)); } @@ -974,7 +962,7 @@ CodeBreakpoint::~CodeBreakpoint() { pc_ = 0ul; src_bpt_ = NULL; next_ = NULL; - breakpoint_kind_ = PcDescriptors::kOther; + breakpoint_kind_ = RawPcDescriptors::kOther; #endif } @@ -1214,16 +1202,18 @@ void Debugger::SetInternalBreakpoints(const Function& target_function) { DeoptimizeWorld(); ASSERT(!target_function.HasOptimizedCode()); PcDescriptors& desc = PcDescriptors::Handle(isolate, code.pc_descriptors()); - for (intptr_t i = 0; i < desc.Length(); i++) { - if (IsSafePoint(desc, i)) { - CodeBreakpoint* bpt = GetCodeBreakpoint(desc.PC(i)); + PcDescriptors::Iterator iter(desc); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + if (IsSafePoint(rec)) { + CodeBreakpoint* bpt = GetCodeBreakpoint(rec.pc); if (bpt != NULL) { // There is already a breakpoint for this address. Make sure // it is enabled. bpt->Enable(); continue; } - bpt = new CodeBreakpoint(code, i); + bpt = new CodeBreakpoint(code, rec); RegisterCodeBreakpoint(bpt); bpt->Enable(); } @@ -1263,10 +1253,10 @@ ActivationFrame* Debugger::CollectDartFrame(Isolate* isolate, bool is_closure_call = false; const PcDescriptors& pc_desc = PcDescriptors::Handle(isolate, code.pc_descriptors()); - - for (int i = 0; i < pc_desc.Length(); i++) { - if (pc_desc.PC(i) == pc && - pc_desc.DescriptorKind(i) == PcDescriptors::kClosureCall) { + PcDescriptors::Iterator iter(pc_desc); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + if ((rec.pc == pc) && (rec.kind() == RawPcDescriptors::kClosureCall)) { is_closure_call = true; break; } @@ -1556,15 +1546,18 @@ intptr_t Debugger::ResolveBreakpointPos(const Function& func, Code& code = Code::Handle(func.unoptimized_code()); ASSERT(!code.IsNull()); PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors()); - intptr_t best_fit_index = -1; intptr_t best_fit_pos = INT_MAX; + const RawPcDescriptors::PcDescriptorRec* best_fit_rec = NULL; uword lowest_pc = kUwordMax; - intptr_t lowest_pc_index = -1; + const RawPcDescriptors::PcDescriptorRec* lowest_pc_rec = NULL; - for (intptr_t i = 0; i < desc.Length(); i++) { - intptr_t desc_token_pos = desc.TokenPos(i); + const RawPcDescriptors::PcDescriptorRec* rec = NULL; + PcDescriptors::Iterator iter(desc); + while (iter.HasNext()) { + rec = &iter.Next(); + intptr_t desc_token_pos = rec->token_pos; ASSERT(desc_token_pos >= 0); - if (IsSafePoint(desc, i)) { + if (IsSafePoint(*rec)) { if ((desc_token_pos < requested_token_pos) || (desc_token_pos > last_token_pos)) { // This descriptor is outside the desired token range. @@ -1574,24 +1567,24 @@ intptr_t Debugger::ResolveBreakpointPos(const Function& func, // So far, this descriptor has the lowest token position after // the first acceptable token position. best_fit_pos = desc_token_pos; - best_fit_index = i; + best_fit_rec = rec; } - if (desc.PC(i) < lowest_pc) { + if (rec->pc < lowest_pc) { // This descriptor so far has the lowest code address. - lowest_pc = desc.PC(i); - lowest_pc_index = i; + lowest_pc = rec->pc; + lowest_pc_rec = rec; } } } - if (lowest_pc_index >= 0) { + if (lowest_pc_rec != NULL) { // We found the pc descriptor that has the lowest execution address. // This is the first possible breakpoint after the requested token // position. We use this instead of the nearest PC descriptor // measured in token index distance. - best_fit_index = lowest_pc_index; + best_fit_rec = lowest_pc_rec; } - if (best_fit_index >= 0) { - return desc.TokenPos(best_fit_index); + if (best_fit_rec != NULL) { + return best_fit_rec->token_pos; } // We didn't find a safe point in the given token range. Try and find // a safe point in the remaining source code of the function. @@ -1610,26 +1603,27 @@ void Debugger::MakeCodeBreakpointAt(const Function& func, ASSERT(!code.IsNull()); PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors()); uword lowest_pc = kUwordMax; - intptr_t lowest_pc_index = -1; // Find the safe point with the lowest compiled code address // that maps to the token position of the source breakpoint. - for (intptr_t i = 0; i < desc.Length(); i++) { - intptr_t desc_token_pos = desc.TokenPos(i); - if ((desc_token_pos == bpt->token_pos_) && IsSafePoint(desc, i)) { - if (desc.PC(i) < lowest_pc) { - // This descriptor so far has the lowest code address. - lowest_pc = desc.PC(i); - lowest_pc_index = i; + PcDescriptors::Iterator iter(desc); + const RawPcDescriptors::PcDescriptorRec* lowest_rec = NULL; + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + intptr_t desc_token_pos = rec.token_pos; + if ((desc_token_pos == bpt->token_pos_) && IsSafePoint(rec)) { + if (rec.pc < lowest_pc) { + lowest_pc = rec.pc; + lowest_rec = &rec; } } } - if (lowest_pc_index < 0) { + if (lowest_rec == NULL) { return; } - CodeBreakpoint* code_bpt = GetCodeBreakpoint(desc.PC(lowest_pc_index)); + CodeBreakpoint* code_bpt = GetCodeBreakpoint(lowest_rec->pc); if (code_bpt == NULL) { // No code breakpoint for this code exists; create one. - code_bpt = new CodeBreakpoint(code, lowest_pc_index); + code_bpt = new CodeBreakpoint(code, *lowest_rec); RegisterCodeBreakpoint(code_bpt); } code_bpt->set_src_bpt(bpt); diff --git a/runtime/vm/debugger.h b/runtime/vm/debugger.h index d75f5977efe..a8833d6ebba 100644 --- a/runtime/vm/debugger.h +++ b/runtime/vm/debugger.h @@ -79,7 +79,8 @@ class SourceBreakpoint { // function gets compiled as a regular function and as a closure. class CodeBreakpoint { public: - CodeBreakpoint(const Code& code, intptr_t pc_desc_index); + CodeBreakpoint(const Code& code, + const RawPcDescriptors::PcDescriptorRec& rec); ~CodeBreakpoint(); RawFunction* function() const; @@ -105,13 +106,11 @@ class CodeBreakpoint { void set_next(CodeBreakpoint* value) { next_ = value; } CodeBreakpoint* next() const { return this->next_; } - intptr_t pc_desc_index() const { return pc_desc_index_; } void PatchCode(); void RestoreCode(); RawCode* code_; - intptr_t pc_desc_index_; intptr_t token_pos_; uword pc_; intptr_t line_number_; @@ -120,7 +119,7 @@ class CodeBreakpoint { SourceBreakpoint* src_bpt_; CodeBreakpoint* next_; - PcDescriptors::Kind breakpoint_kind_; + RawPcDescriptors::Kind breakpoint_kind_; uword saved_value_; friend class Debugger; @@ -191,7 +190,6 @@ class ActivationFrame : public ZoneAllocated { intptr_t frame_ctx_level, intptr_t var_ctx_level); - intptr_t PcDescIndex(); intptr_t TryIndex(); void GetPcDescriptors(); void GetVarDescriptors(); @@ -214,7 +212,8 @@ class ActivationFrame : public ZoneAllocated { const Code& code_; const Function& function_; intptr_t token_pos_; - intptr_t pc_desc_index_; + const RawPcDescriptors::PcDescriptorRec* desc_rec_; + intptr_t line_number_; intptr_t column_number_; intptr_t context_level_; diff --git a/runtime/vm/debugger_arm.cc b/runtime/vm/debugger_arm.cc index a345836eefa..65458fa256b 100644 --- a/runtime/vm/debugger_arm.cc +++ b/runtime/vm/debugger_arm.cc @@ -45,10 +45,10 @@ void CodeBreakpoint::PatchCode() { { WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); switch (breakpoint_kind_) { - case PcDescriptors::kIcCall: - case PcDescriptors::kUnoptStaticCall: - case PcDescriptors::kRuntimeCall: - case PcDescriptors::kClosureCall: { + case RawPcDescriptors::kIcCall: + case RawPcDescriptors::kUnoptStaticCall: + case RawPcDescriptors::kRuntimeCall: + case RawPcDescriptors::kClosureCall: { saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); CodePatcher::PatchStaticCallAt(pc_, code, StubCode::BreakpointRuntimeEntryPoint()); @@ -69,10 +69,10 @@ void CodeBreakpoint::RestoreCode() { { WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); switch (breakpoint_kind_) { - case PcDescriptors::kIcCall: - case PcDescriptors::kUnoptStaticCall: - case PcDescriptors::kClosureCall: - case PcDescriptors::kRuntimeCall: { + case RawPcDescriptors::kIcCall: + case RawPcDescriptors::kUnoptStaticCall: + case RawPcDescriptors::kClosureCall: + case RawPcDescriptors::kRuntimeCall: { CodePatcher::PatchStaticCallAt(pc_, code, saved_value_); break; } diff --git a/runtime/vm/debugger_arm64.cc b/runtime/vm/debugger_arm64.cc index 12886438be3..3fb7b88d79b 100644 --- a/runtime/vm/debugger_arm64.cc +++ b/runtime/vm/debugger_arm64.cc @@ -52,10 +52,10 @@ void CodeBreakpoint::PatchCode() { { WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); switch (breakpoint_kind_) { - case PcDescriptors::kIcCall: - case PcDescriptors::kUnoptStaticCall: - case PcDescriptors::kRuntimeCall: - case PcDescriptors::kClosureCall: { + case RawPcDescriptors::kIcCall: + case RawPcDescriptors::kUnoptStaticCall: + case RawPcDescriptors::kRuntimeCall: + case RawPcDescriptors::kClosureCall: { int32_t offset = CodePatcher::GetPoolOffsetAt(pc_); ASSERT((offset > 0) && ((offset & 0x7) == 0)); saved_value_ = static_cast(offset); @@ -80,10 +80,10 @@ void CodeBreakpoint::RestoreCode() { { WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); switch (breakpoint_kind_) { - case PcDescriptors::kIcCall: - case PcDescriptors::kUnoptStaticCall: - case PcDescriptors::kClosureCall: - case PcDescriptors::kRuntimeCall: { + case RawPcDescriptors::kIcCall: + case RawPcDescriptors::kUnoptStaticCall: + case RawPcDescriptors::kClosureCall: + case RawPcDescriptors::kRuntimeCall: { CodePatcher::SetPoolOffsetAt(pc_, static_cast(saved_value_)); break; } diff --git a/runtime/vm/debugger_ia32.cc b/runtime/vm/debugger_ia32.cc index 594113ed3e6..470c33330bb 100644 --- a/runtime/vm/debugger_ia32.cc +++ b/runtime/vm/debugger_ia32.cc @@ -49,10 +49,10 @@ void CodeBreakpoint::PatchCode() { { WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); switch (breakpoint_kind_) { - case PcDescriptors::kIcCall: - case PcDescriptors::kUnoptStaticCall: - case PcDescriptors::kRuntimeCall: - case PcDescriptors::kClosureCall: { + case RawPcDescriptors::kIcCall: + case RawPcDescriptors::kUnoptStaticCall: + case RawPcDescriptors::kRuntimeCall: + case RawPcDescriptors::kClosureCall: { saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); CodePatcher::PatchStaticCallAt(pc_, code, StubCode::BreakpointRuntimeEntryPoint()); @@ -73,10 +73,10 @@ void CodeBreakpoint::RestoreCode() { { WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); switch (breakpoint_kind_) { - case PcDescriptors::kIcCall: - case PcDescriptors::kUnoptStaticCall: - case PcDescriptors::kClosureCall: - case PcDescriptors::kRuntimeCall: { + case RawPcDescriptors::kIcCall: + case RawPcDescriptors::kUnoptStaticCall: + case RawPcDescriptors::kClosureCall: + case RawPcDescriptors::kRuntimeCall: { CodePatcher::PatchStaticCallAt(pc_, code, saved_value_); break; } diff --git a/runtime/vm/debugger_mips.cc b/runtime/vm/debugger_mips.cc index 570d4d015dc..b54a5e91858 100644 --- a/runtime/vm/debugger_mips.cc +++ b/runtime/vm/debugger_mips.cc @@ -45,10 +45,10 @@ void CodeBreakpoint::PatchCode() { { WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); switch (breakpoint_kind_) { - case PcDescriptors::kIcCall: - case PcDescriptors::kUnoptStaticCall: - case PcDescriptors::kRuntimeCall: - case PcDescriptors::kClosureCall: { + case RawPcDescriptors::kIcCall: + case RawPcDescriptors::kUnoptStaticCall: + case RawPcDescriptors::kRuntimeCall: + case RawPcDescriptors::kClosureCall: { saved_value_ = CodePatcher::GetStaticCallTargetAt(pc_, code); CodePatcher::PatchStaticCallAt(pc_, code, StubCode::BreakpointRuntimeEntryPoint()); @@ -69,10 +69,10 @@ void CodeBreakpoint::RestoreCode() { { WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); switch (breakpoint_kind_) { - case PcDescriptors::kIcCall: - case PcDescriptors::kUnoptStaticCall: - case PcDescriptors::kClosureCall: - case PcDescriptors::kRuntimeCall: { + case RawPcDescriptors::kIcCall: + case RawPcDescriptors::kUnoptStaticCall: + case RawPcDescriptors::kClosureCall: + case RawPcDescriptors::kRuntimeCall: { CodePatcher::PatchStaticCallAt(pc_, code, saved_value_); break; } diff --git a/runtime/vm/debugger_x64.cc b/runtime/vm/debugger_x64.cc index 171a0b39d00..97fd0527479 100644 --- a/runtime/vm/debugger_x64.cc +++ b/runtime/vm/debugger_x64.cc @@ -54,10 +54,10 @@ void CodeBreakpoint::PatchCode() { { WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); switch (breakpoint_kind_) { - case PcDescriptors::kIcCall: - case PcDescriptors::kUnoptStaticCall: - case PcDescriptors::kRuntimeCall: - case PcDescriptors::kClosureCall: { + case RawPcDescriptors::kIcCall: + case RawPcDescriptors::kUnoptStaticCall: + case RawPcDescriptors::kRuntimeCall: + case RawPcDescriptors::kClosureCall: { int32_t offset = CodePatcher::GetPoolOffsetAt(pc_); ASSERT((offset > 0) && ((offset % 8) == 7)); saved_value_ = static_cast(offset); @@ -82,10 +82,10 @@ void CodeBreakpoint::RestoreCode() { { WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size()); switch (breakpoint_kind_) { - case PcDescriptors::kIcCall: - case PcDescriptors::kUnoptStaticCall: - case PcDescriptors::kClosureCall: - case PcDescriptors::kRuntimeCall: { + case RawPcDescriptors::kIcCall: + case RawPcDescriptors::kUnoptStaticCall: + case RawPcDescriptors::kClosureCall: + case RawPcDescriptors::kRuntimeCall: { CodePatcher::SetPoolOffsetAt(pc_, static_cast(saved_value_)); break; } diff --git a/runtime/vm/deopt_instructions.cc b/runtime/vm/deopt_instructions.cc index 2f365fbfd20..ccd731646d7 100644 --- a/runtime/vm/deopt_instructions.cc +++ b/runtime/vm/deopt_instructions.cc @@ -568,11 +568,11 @@ class DeoptRetAddressInstr : public DeoptInstr { code ^= deopt_context->ObjectAt(object_table_index_); ASSERT(!code.IsNull()); uword continue_at_pc = code.GetPcForDeoptId(deopt_id_, - PcDescriptors::kDeopt); + RawPcDescriptors::kDeopt); ASSERT(continue_at_pc != 0); *dest_addr = continue_at_pc; - uword pc = code.GetPcForDeoptId(deopt_id_, PcDescriptors::kIcCall); + uword pc = code.GetPcForDeoptId(deopt_id_, RawPcDescriptors::kIcCall); if (pc != 0) { // If the deoptimization happened at an IC call, update the IC data // to avoid repeated deoptimization at the same site next time around. @@ -1256,7 +1256,7 @@ uword DeoptInstr::GetRetAddress(DeoptInstr* instr, *code ^= object_table.At(ret_address_instr->object_table_index()); ASSERT(!code->IsNull()); uword res = code->GetPcForDeoptId(ret_address_instr->deopt_id(), - PcDescriptors::kDeopt); + RawPcDescriptors::kDeopt); ASSERT(res != 0); return res; } @@ -1394,7 +1394,7 @@ void DeoptInfoBuilder::AddReturnAddress(const Code& code, // TODO(vegorov): verify after deoptimization targets as well. #ifdef DEBUG ASSERT(Isolate::IsDeoptAfter(deopt_id) || - (code.GetPcForDeoptId(deopt_id, PcDescriptors::kDeopt) != 0)); + (code.GetPcForDeoptId(deopt_id, RawPcDescriptors::kDeopt) != 0)); #endif const intptr_t object_table_index = FindOrAddObjectInTable(code); ASSERT(dest_index == FrameSize()); diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc index a96024acc6a..467567bac0e 100644 --- a/runtime/vm/flow_graph_builder.cc +++ b/runtime/vm/flow_graph_builder.cc @@ -1016,7 +1016,7 @@ void EffectGraphVisitor::VisitReturnNode(ReturnNode* node) { if ((node->token_pos() != Scanner::kNoSourcePos) && !function.is_native() && FLAG_enable_debugger) { AddInstruction(new(I) DebugStepCheckInstr(node->token_pos(), - PcDescriptors::kRuntimeCall)); + RawPcDescriptors::kRuntimeCall)); } if (FLAG_enable_type_checks) { @@ -3119,8 +3119,8 @@ void EffectGraphVisitor::VisitStoreLocalNode(StoreLocalNode* node) { if (node->value()->IsLiteralNode() || node->value()->IsLoadLocalNode()) { if (FLAG_enable_debugger) { - AddInstruction(new(I) DebugStepCheckInstr(node->token_pos(), - PcDescriptors::kRuntimeCall)); + AddInstruction(new(I) DebugStepCheckInstr( + node->token_pos(), RawPcDescriptors::kRuntimeCall)); } } diff --git a/runtime/vm/flow_graph_compiler.cc b/runtime/vm/flow_graph_compiler.cc index 66d3c959bc7..7af48c520f1 100644 --- a/runtime/vm/flow_graph_compiler.cc +++ b/runtime/vm/flow_graph_compiler.cc @@ -274,14 +274,14 @@ void FlowGraphCompiler::EmitInstructionPrologue(Instruction* instr) { if (!is_optimizing()) { if (FLAG_enable_type_checks && instr->IsAssertAssignable()) { AssertAssignableInstr* assert = instr->AsAssertAssignable(); - AddCurrentDescriptor(PcDescriptors::kDeopt, + AddCurrentDescriptor(RawPcDescriptors::kDeopt, assert->deopt_id(), assert->token_pos()); } else if (instr->CanBecomeDeoptimizationTarget() && !instr->IsGoto()) { // Instructions that can be deoptimization targets need to record kDeopt // PcDescriptor corresponding to their deopt id. GotoInstr records its // own so that it can control the placement. - AddCurrentDescriptor(PcDescriptors::kDeopt, + AddCurrentDescriptor(RawPcDescriptors::kDeopt, instr->deopt_id(), Scanner::kNoSourcePos); } @@ -487,7 +487,7 @@ void FlowGraphCompiler::SetNeedsStacktrace(intptr_t try_index) { // Uses current pc position and try-index. -void FlowGraphCompiler::AddCurrentDescriptor(PcDescriptors::Kind kind, +void FlowGraphCompiler::AddCurrentDescriptor(RawPcDescriptors::Kind kind, intptr_t deopt_id, intptr_t token_pos) { pc_descriptors_list()->AddDescriptor(kind, diff --git a/runtime/vm/flow_graph_compiler.h b/runtime/vm/flow_graph_compiler.h index a5f2e4f832f..4ebb760930a 100644 --- a/runtime/vm/flow_graph_compiler.h +++ b/runtime/vm/flow_graph_compiler.h @@ -301,13 +301,13 @@ class FlowGraphCompiler : public ValueObject { void GenerateCall(intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs); void GenerateDartCall(intptr_t deopt_id, intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs); void GenerateAssertAssignable(intptr_t token_pos, @@ -415,7 +415,7 @@ class FlowGraphCompiler : public ValueObject { const Array& handler_types, bool needs_stacktrace); void SetNeedsStacktrace(intptr_t try_index); - void AddCurrentDescriptor(PcDescriptors::Kind kind, + void AddCurrentDescriptor(RawPcDescriptors::Kind kind, intptr_t deopt_id, intptr_t token_pos); diff --git a/runtime/vm/flow_graph_compiler_arm.cc b/runtime/vm/flow_graph_compiler_arm.cc index 7a4b4d9c2a2..de05ea5f4da 100644 --- a/runtime/vm/flow_graph_compiler_arm.cc +++ b/runtime/vm/flow_graph_compiler_arm.cc @@ -1106,7 +1106,7 @@ void FlowGraphCompiler::CompileGraph() { void FlowGraphCompiler::GenerateCall(intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); @@ -1117,7 +1117,7 @@ void FlowGraphCompiler::GenerateCall(intptr_t token_pos, void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); AddCurrentDescriptor(kind, deopt_id, token_pos); @@ -1130,7 +1130,8 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kDeopt, + deopt_id_after, token_pos); } } @@ -1141,7 +1142,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, intptr_t argument_count, LocationSummary* locs) { __ CallRuntime(entry, argument_count); - AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); RecordSafepoint(locs); if (deopt_id != Isolate::kNoDeoptId) { // Marks either the continuation point in unoptimized code or the @@ -1152,7 +1153,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - AddCurrentDescriptor(PcDescriptors::kDeopt, + AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); } @@ -1196,7 +1197,7 @@ void FlowGraphCompiler::EmitOptimizedInstanceCall( GenerateDartCall(deopt_id, token_pos, target_label, - PcDescriptors::kIcCall, + RawPcDescriptors::kIcCall, locs); __ Drop(argument_count); } @@ -1214,7 +1215,7 @@ void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, GenerateDartCall(deopt_id, token_pos, target_label, - PcDescriptors::kIcCall, + RawPcDescriptors::kIcCall, locs); __ Drop(argument_count); #if defined(DEBUG) @@ -1277,7 +1278,8 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( __ LoadObject(R4, arguments_descriptor); __ AddImmediate(R1, Instructions::HeaderSize() - kHeapObjectTag); __ blx(R1); - AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kOther, + Isolate::kNoDeoptId, token_pos); RecordSafepoint(locs); AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); __ Drop(argument_count); @@ -1304,7 +1306,7 @@ void FlowGraphCompiler::EmitUnoptimizedStaticCall( GenerateDartCall(deopt_id, token_pos, &target_label, - PcDescriptors::kUnoptStaticCall, + RawPcDescriptors::kUnoptStaticCall, locs); __ Drop(argument_count); #if defined(DEBUG) @@ -1326,7 +1328,7 @@ void FlowGraphCompiler::EmitOptimizedStaticCall( GenerateDartCall(deopt_id, token_pos, &StubCode::CallStaticFunctionLabel(), - PcDescriptors::kOptStaticCall, + RawPcDescriptors::kOptStaticCall, locs); AddStaticCallTarget(function); __ Drop(argument_count); @@ -1349,7 +1351,7 @@ void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg, &StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); } if (token_pos != Scanner::kNoSourcePos) { - AddCurrentDescriptor(PcDescriptors::kRuntimeCall, + AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, Isolate::kNoDeoptId, token_pos); } @@ -1379,7 +1381,7 @@ void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left, &StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); } if (token_pos != Scanner::kNoSourcePos) { - AddCurrentDescriptor(PcDescriptors::kRuntimeCall, + AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, Isolate::kNoDeoptId, token_pos); } @@ -1503,7 +1505,7 @@ void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, GenerateDartCall(deopt_id, token_index, &StubCode::CallStaticFunctionLabel(), - PcDescriptors::kOptStaticCall, + RawPcDescriptors::kOptStaticCall, locs); const Function& function = *sorted[i].target; AddStaticCallTarget(function); diff --git a/runtime/vm/flow_graph_compiler_arm64.cc b/runtime/vm/flow_graph_compiler_arm64.cc index 4b815877517..4e4c2f76323 100644 --- a/runtime/vm/flow_graph_compiler_arm64.cc +++ b/runtime/vm/flow_graph_compiler_arm64.cc @@ -1114,7 +1114,7 @@ void FlowGraphCompiler::CompileGraph() { void FlowGraphCompiler::GenerateCall(intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); @@ -1125,7 +1125,7 @@ void FlowGraphCompiler::GenerateCall(intptr_t token_pos, void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); AddCurrentDescriptor(kind, deopt_id, token_pos); @@ -1138,7 +1138,7 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); } } @@ -1149,7 +1149,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, intptr_t argument_count, LocationSummary* locs) { __ CallRuntime(entry, argument_count); - AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); RecordSafepoint(locs); if (deopt_id != Isolate::kNoDeoptId) { // Marks either the continuation point in unoptimized code or the @@ -1160,7 +1160,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); } } } @@ -1202,7 +1202,7 @@ void FlowGraphCompiler::EmitOptimizedInstanceCall( GenerateDartCall(deopt_id, token_pos, target_label, - PcDescriptors::kIcCall, + RawPcDescriptors::kIcCall, locs); __ Drop(argument_count); } @@ -1220,7 +1220,7 @@ void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, GenerateDartCall(deopt_id, token_pos, target_label, - PcDescriptors::kIcCall, + RawPcDescriptors::kIcCall, locs); __ Drop(argument_count); #if defined(DEBUG) @@ -1283,7 +1283,8 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( __ LoadObject(R4, arguments_descriptor, PP); __ AddImmediate(R1, R1, Instructions::HeaderSize() - kHeapObjectTag, PP); __ blr(R1); - AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kOther, + Isolate::kNoDeoptId, token_pos); RecordSafepoint(locs); AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); __ Drop(argument_count); @@ -1310,7 +1311,7 @@ void FlowGraphCompiler::EmitUnoptimizedStaticCall( GenerateDartCall(deopt_id, token_pos, &target_label, - PcDescriptors::kUnoptStaticCall, + RawPcDescriptors::kUnoptStaticCall, locs); #if defined(DEBUG) __ LoadImmediate(R5, kInvalidObjectPointer, kNoPP); @@ -1332,7 +1333,7 @@ void FlowGraphCompiler::EmitOptimizedStaticCall( GenerateDartCall(deopt_id, token_pos, &StubCode::CallStaticFunctionLabel(), - PcDescriptors::kOptStaticCall, + RawPcDescriptors::kOptStaticCall, locs); AddStaticCallTarget(function); __ Drop(argument_count); @@ -1355,7 +1356,7 @@ void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg, &StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); } if (token_pos != Scanner::kNoSourcePos) { - AddCurrentDescriptor(PcDescriptors::kRuntimeCall, + AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, Isolate::kNoDeoptId, token_pos); } @@ -1385,7 +1386,7 @@ void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left, &StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); } if (token_pos != Scanner::kNoSourcePos) { - AddCurrentDescriptor(PcDescriptors::kRuntimeCall, + AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, Isolate::kNoDeoptId, token_pos); } @@ -1490,7 +1491,7 @@ void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, GenerateDartCall(deopt_id, token_index, &StubCode::CallStaticFunctionLabel(), - PcDescriptors::kOptStaticCall, + RawPcDescriptors::kOptStaticCall, locs); const Function& function = *sorted[i].target; AddStaticCallTarget(function); diff --git a/runtime/vm/flow_graph_compiler_ia32.cc b/runtime/vm/flow_graph_compiler_ia32.cc index 25d3fd95da2..74fa42c5cdf 100644 --- a/runtime/vm/flow_graph_compiler_ia32.cc +++ b/runtime/vm/flow_graph_compiler_ia32.cc @@ -1115,7 +1115,7 @@ void FlowGraphCompiler::CompileGraph() { void FlowGraphCompiler::GenerateCall(intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs) { __ call(label); AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); @@ -1126,7 +1126,7 @@ void FlowGraphCompiler::GenerateCall(intptr_t token_pos, void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs) { __ call(label); AddCurrentDescriptor(kind, deopt_id, token_pos); @@ -1139,7 +1139,7 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); } } @@ -1150,7 +1150,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, intptr_t argument_count, LocationSummary* locs) { __ CallRuntime(entry, argument_count); - AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); RecordSafepoint(locs); if (deopt_id != Isolate::kNoDeoptId) { // Marks either the continuation point in unoptimized code or the @@ -1161,7 +1161,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); } } } @@ -1187,7 +1187,7 @@ void FlowGraphCompiler::EmitUnoptimizedStaticCall( GenerateDartCall(deopt_id, token_pos, &target_label, - PcDescriptors::kUnoptStaticCall, + RawPcDescriptors::kUnoptStaticCall, locs); __ Drop(argument_count); #if defined(DEBUG) @@ -1230,7 +1230,7 @@ void FlowGraphCompiler::EmitOptimizedInstanceCall( GenerateDartCall(deopt_id, token_pos, target_label, - PcDescriptors::kIcCall, + RawPcDescriptors::kIcCall, locs); __ Drop(argument_count); } @@ -1248,7 +1248,7 @@ void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, GenerateDartCall(deopt_id, token_pos, target_label, - PcDescriptors::kIcCall, + RawPcDescriptors::kIcCall, locs); __ Drop(argument_count); #if defined(DEBUG) @@ -1311,7 +1311,8 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( __ LoadObject(EDX, arguments_descriptor); __ addl(EBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); __ call(EBX); - AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kOther, + Isolate::kNoDeoptId, token_pos); RecordSafepoint(locs); AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); __ Drop(argument_count); @@ -1331,7 +1332,7 @@ void FlowGraphCompiler::EmitOptimizedStaticCall( GenerateDartCall(deopt_id, token_pos, &StubCode::CallStaticFunctionLabel(), - PcDescriptors::kOptStaticCall, + RawPcDescriptors::kOptStaticCall, locs); AddStaticCallTarget(function); __ Drop(argument_count); @@ -1360,7 +1361,7 @@ void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg, __ call(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); } if (token_pos != Scanner::kNoSourcePos) { - AddCurrentDescriptor(PcDescriptors::kRuntimeCall, + AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, Isolate::kNoDeoptId, token_pos); } @@ -1388,7 +1389,7 @@ void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left, __ call(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); } if (token_pos != Scanner::kNoSourcePos) { - AddCurrentDescriptor(PcDescriptors::kRuntimeCall, + AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, Isolate::kNoDeoptId, token_pos); } @@ -1500,7 +1501,7 @@ void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, GenerateDartCall(deopt_id, token_index, &StubCode::CallStaticFunctionLabel(), - PcDescriptors::kOptStaticCall, + RawPcDescriptors::kOptStaticCall, locs); const Function& function = *sorted[i].target; AddStaticCallTarget(function); diff --git a/runtime/vm/flow_graph_compiler_mips.cc b/runtime/vm/flow_graph_compiler_mips.cc index d86d7441fd1..97a60ca7f4b 100644 --- a/runtime/vm/flow_graph_compiler_mips.cc +++ b/runtime/vm/flow_graph_compiler_mips.cc @@ -1142,7 +1142,7 @@ void FlowGraphCompiler::CompileGraph() { void FlowGraphCompiler::GenerateCall(intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); @@ -1153,7 +1153,7 @@ void FlowGraphCompiler::GenerateCall(intptr_t token_pos, void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs) { __ BranchLinkPatchable(label); AddCurrentDescriptor(kind, deopt_id, token_pos); @@ -1166,7 +1166,7 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - AddCurrentDescriptor(PcDescriptors::kDeopt, + AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); } @@ -1179,7 +1179,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, intptr_t argument_count, LocationSummary* locs) { __ CallRuntime(entry, argument_count); - AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); RecordSafepoint(locs); if (deopt_id != Isolate::kNoDeoptId) { // Marks either the continuation point in unoptimized code or the @@ -1190,7 +1190,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - AddCurrentDescriptor(PcDescriptors::kDeopt, + AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); } @@ -1234,7 +1234,7 @@ void FlowGraphCompiler::EmitOptimizedInstanceCall( GenerateDartCall(deopt_id, token_pos, target_label, - PcDescriptors::kIcCall, + RawPcDescriptors::kIcCall, locs); __ Drop(argument_count); } @@ -1253,7 +1253,7 @@ void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, GenerateDartCall(deopt_id, token_pos, target_label, - PcDescriptors::kIcCall, + RawPcDescriptors::kIcCall, locs); __ TraceSimMsg("InstanceCall return"); __ Drop(argument_count); @@ -1319,7 +1319,8 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( __ LoadObject(S4, arguments_descriptor); __ AddImmediate(T1, Instructions::HeaderSize() - kHeapObjectTag); __ jalr(T1); - AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kOther, + Isolate::kNoDeoptId, token_pos); RecordSafepoint(locs); AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); __ Drop(argument_count); @@ -1346,7 +1347,7 @@ void FlowGraphCompiler::EmitUnoptimizedStaticCall( GenerateDartCall(deopt_id, token_pos, &target_label, - PcDescriptors::kUnoptStaticCall, + RawPcDescriptors::kUnoptStaticCall, locs); #if defined(DEBUG) __ LoadImmediate(S4, kInvalidObjectPointer); @@ -1369,7 +1370,7 @@ void FlowGraphCompiler::EmitOptimizedStaticCall( GenerateDartCall(deopt_id, token_pos, &StubCode::CallStaticFunctionLabel(), - PcDescriptors::kOptStaticCall, + RawPcDescriptors::kOptStaticCall, locs); AddStaticCallTarget(function); __ Drop(argument_count); @@ -1395,7 +1396,7 @@ void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg, &StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); } if (token_pos != Scanner::kNoSourcePos) { - AddCurrentDescriptor(PcDescriptors::kRuntimeCall, + AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, Isolate::kNoDeoptId, token_pos); } @@ -1428,7 +1429,7 @@ void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left, &StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); } if (token_pos != Scanner::kNoSourcePos) { - AddCurrentDescriptor(PcDescriptors::kRuntimeCall, + AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, Isolate::kNoDeoptId, token_pos); } @@ -1561,7 +1562,7 @@ void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, GenerateDartCall(deopt_id, token_index, &StubCode::CallStaticFunctionLabel(), - PcDescriptors::kOptStaticCall, + RawPcDescriptors::kOptStaticCall, locs); const Function& function = *sorted[i].target; AddStaticCallTarget(function); diff --git a/runtime/vm/flow_graph_compiler_x64.cc b/runtime/vm/flow_graph_compiler_x64.cc index f183de655fb..9e1f7a7e2e8 100644 --- a/runtime/vm/flow_graph_compiler_x64.cc +++ b/runtime/vm/flow_graph_compiler_x64.cc @@ -1152,7 +1152,7 @@ void FlowGraphCompiler::CompileGraph() { void FlowGraphCompiler::GenerateCall(intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs) { __ Call(label, PP); AddCurrentDescriptor(kind, Isolate::kNoDeoptId, token_pos); @@ -1163,7 +1163,7 @@ void FlowGraphCompiler::GenerateCall(intptr_t token_pos, void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, intptr_t token_pos, const ExternalLabel* label, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, LocationSummary* locs) { __ CallPatchable(label); AddCurrentDescriptor(kind, deopt_id, token_pos); @@ -1176,7 +1176,7 @@ void FlowGraphCompiler::GenerateDartCall(intptr_t deopt_id, } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); } } @@ -1187,7 +1187,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, intptr_t argument_count, LocationSummary* locs) { __ CallRuntime(entry, argument_count); - AddCurrentDescriptor(PcDescriptors::kOther, deopt_id, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kOther, deopt_id, token_pos); RecordSafepoint(locs); if (deopt_id != Isolate::kNoDeoptId) { // Marks either the continuation point in unoptimized code or the @@ -1198,7 +1198,7 @@ void FlowGraphCompiler::GenerateRuntimeCall(intptr_t token_pos, } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - AddCurrentDescriptor(PcDescriptors::kDeopt, deopt_id_after, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos); } } } @@ -1224,7 +1224,7 @@ void FlowGraphCompiler::EmitUnoptimizedStaticCall( GenerateDartCall(deopt_id, token_pos, &target_label, - PcDescriptors::kUnoptStaticCall, + RawPcDescriptors::kUnoptStaticCall, locs); __ Drop(argument_count); #if defined(DEBUG) @@ -1267,7 +1267,7 @@ void FlowGraphCompiler::EmitOptimizedInstanceCall( GenerateDartCall(deopt_id, token_pos, target_label, - PcDescriptors::kIcCall, + RawPcDescriptors::kIcCall, locs); __ Drop(argument_count); } @@ -1285,7 +1285,7 @@ void FlowGraphCompiler::EmitInstanceCall(ExternalLabel* target_label, GenerateDartCall(deopt_id, token_pos, target_label, - PcDescriptors::kIcCall, + RawPcDescriptors::kIcCall, locs); __ Drop(argument_count); #if defined(DEBUG) @@ -1347,7 +1347,8 @@ void FlowGraphCompiler::EmitMegamorphicInstanceCall( __ AddImmediate( RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag), PP); __ call(RCX); - AddCurrentDescriptor(PcDescriptors::kOther, Isolate::kNoDeoptId, token_pos); + AddCurrentDescriptor(RawPcDescriptors::kOther, + Isolate::kNoDeoptId, token_pos); RecordSafepoint(locs); AddDeoptIndexAtCall(Isolate::ToDeoptAfter(deopt_id), token_pos); __ Drop(argument_count); @@ -1367,7 +1368,7 @@ void FlowGraphCompiler::EmitOptimizedStaticCall( GenerateDartCall(deopt_id, token_pos, &StubCode::CallStaticFunctionLabel(), - PcDescriptors::kOptStaticCall, + RawPcDescriptors::kOptStaticCall, locs); AddStaticCallTarget(function); __ Drop(argument_count); @@ -1396,7 +1397,7 @@ void FlowGraphCompiler::EmitEqualityRegConstCompare(Register reg, __ CallPatchable(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); } if (token_pos != Scanner::kNoSourcePos) { - AddCurrentDescriptor(PcDescriptors::kRuntimeCall, + AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, Isolate::kNoDeoptId, token_pos); } @@ -1424,7 +1425,7 @@ void FlowGraphCompiler::EmitEqualityRegRegCompare(Register left, __ CallPatchable(&StubCode::UnoptimizedIdenticalWithNumberCheckLabel()); } if (token_pos != Scanner::kNoSourcePos) { - AddCurrentDescriptor(PcDescriptors::kRuntimeCall, + AddCurrentDescriptor(RawPcDescriptors::kRuntimeCall, Isolate::kNoDeoptId, token_pos); } @@ -1493,7 +1494,7 @@ void FlowGraphCompiler::EmitTestAndCall(const ICData& ic_data, GenerateDartCall(deopt_id, token_index, &StubCode::CallStaticFunctionLabel(), - PcDescriptors::kOptStaticCall, + RawPcDescriptors::kOptStaticCall, locs); const Function& function = *sorted[i].target; AddStaticCallTarget(function); diff --git a/runtime/vm/intermediate_language.cc b/runtime/vm/intermediate_language.cc index 2007daa4c05..552fcfa9f16 100644 --- a/runtime/vm/intermediate_language.cc +++ b/runtime/vm/intermediate_language.cc @@ -2054,7 +2054,7 @@ LocationSummary* JoinEntryInstr::MakeLocationSummary(Isolate* isolate, void JoinEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ Bind(compiler->GetJumpLabel(this)); if (!compiler->is_optimizing()) { - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_, Scanner::kNoSourcePos); } @@ -2292,7 +2292,7 @@ void InstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { } else { // Unoptimized code. ASSERT(!HasICData()); - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id(), token_pos()); compiler->GenerateInstanceCall(deopt_id(), @@ -2355,7 +2355,7 @@ void StaticCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { if (!compiler->is_optimizing()) { // Some static calls can be optimized by the optimizing compiler (e.g. sqrt) // and therefore need a deoptimization descriptor. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id(), token_pos()); } diff --git a/runtime/vm/intermediate_language.h b/runtime/vm/intermediate_language.h index 20a84392b7d..de943f0ff96 100644 --- a/runtime/vm/intermediate_language.h +++ b/runtime/vm/intermediate_language.h @@ -3884,7 +3884,7 @@ class NativeCallInstr : public TemplateDefinition<0> { class DebugStepCheckInstr : public TemplateInstruction<0> { public: DebugStepCheckInstr(intptr_t token_pos, - PcDescriptors::Kind stub_kind) + RawPcDescriptors::Kind stub_kind) : token_pos_(token_pos), stub_kind_(stub_kind) { } @@ -3900,7 +3900,7 @@ class DebugStepCheckInstr : public TemplateInstruction<0> { private: const intptr_t token_pos_; - const PcDescriptors::Kind stub_kind_; + const RawPcDescriptors::Kind stub_kind_; DISALLOW_COPY_AND_ASSIGN(DebugStepCheckInstr); }; diff --git a/runtime/vm/intermediate_language_arm.cc b/runtime/vm/intermediate_language_arm.cc index 65a494f55a0..2e314d00bc8 100644 --- a/runtime/vm/intermediate_language_arm.cc +++ b/runtime/vm/intermediate_language_arm.cc @@ -219,7 +219,7 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ LoadImmediate(R5, 0); __ AddImmediate(R2, Instructions::HeaderSize() - kHeapObjectTag); __ blx(R2); - compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall, + compiler->AddCurrentDescriptor(RawPcDescriptors::kClosureCall, deopt_id(), token_pos()); compiler->RecordSafepoint(locs()); @@ -231,7 +231,7 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos()); } @@ -951,7 +951,7 @@ void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ LoadImmediate(R1, argc_tag); compiler->GenerateCall(token_pos(), stub_entry, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ Pop(result); } @@ -1931,7 +1931,7 @@ class StoreInstanceFieldSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->temp(0).reg(), R0); compiler->RestoreLiveRegisters(locs); @@ -2380,7 +2380,7 @@ void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { compiler->GenerateCall(token_pos(), &StubCode::AllocateArrayLabel(), - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); ASSERT(locs()->out(0).reg() == kResultReg); } @@ -2405,7 +2405,7 @@ class BoxDoubleSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->out(0).reg(), R0); compiler->RestoreLiveRegisters(locs); @@ -2437,7 +2437,7 @@ class BoxFloat32x4SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ mov(locs->out(0).reg(), Operand(R0)); compiler->RestoreLiveRegisters(locs); @@ -2469,7 +2469,7 @@ class BoxFloat64x2SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ mov(locs->out(0).reg(), Operand(R0)); compiler->RestoreLiveRegisters(locs); @@ -2754,7 +2754,7 @@ void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const ExternalLabel label(StubCode::AllocateContextEntryPoint()); compiler->GenerateCall(token_pos(), &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); } @@ -2869,7 +2869,7 @@ class CheckStackOverflowSlowPath : public SlowPathCode { if (FLAG_use_osr && !compiler->is_optimizing() && instruction_->in_loop()) { // In unoptimized code, record loop stack checks as possible OSR entries. - compiler->AddCurrentDescriptor(PcDescriptors::kOsrEntry, + compiler->AddCurrentDescriptor(RawPcDescriptors::kOsrEntry, instruction_->deopt_id(), 0); // No token position. } @@ -3705,7 +3705,7 @@ class BoxInt32x4SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ mov(locs->out(0).reg(), Operand(R0)); compiler->RestoreLiveRegisters(locs); @@ -5925,7 +5925,7 @@ class BoxIntegerSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ mov(locs->out(0).reg(), Operand(R0)); compiler->RestoreLiveRegisters(locs); @@ -6261,7 +6261,7 @@ void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { // On ARM the deoptimization descriptor points after the edge counter // code so that we can reuse the same pattern matching code as at call // sites, which matches backwards from the end of the pattern. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_, Scanner::kNoSourcePos); } @@ -6287,7 +6287,7 @@ void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { // points after the edge counter code so that we can reuse the same // pattern matching code as at call sites, which matches backwards from // the end of the pattern. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, GetDeoptId(), Scanner::kNoSourcePos); } @@ -6421,7 +6421,7 @@ void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const ExternalLabel label(stub.EntryPoint()); compiler->GenerateCall(token_pos(), &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ Drop(ArgumentCount()); // Discard arguments. } diff --git a/runtime/vm/intermediate_language_arm64.cc b/runtime/vm/intermediate_language_arm64.cc index 3334c820811..e2fb39fc8dd 100644 --- a/runtime/vm/intermediate_language_arm64.cc +++ b/runtime/vm/intermediate_language_arm64.cc @@ -214,7 +214,7 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ LoadImmediate(R5, 0, PP); __ AddImmediate(R2, R2, Instructions::HeaderSize() - kHeapObjectTag, PP); __ blr(R2); - compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall, + compiler->AddCurrentDescriptor(RawPcDescriptors::kClosureCall, deopt_id(), token_pos()); compiler->RecordSafepoint(locs()); @@ -226,7 +226,7 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos()); } @@ -796,7 +796,7 @@ void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ LoadImmediate(R1, argc_tag, PP); compiler->GenerateCall(token_pos(), stub_entry, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ Pop(result); } @@ -1619,7 +1619,7 @@ class StoreInstanceFieldSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ mov(locs->temp(0).reg(), R0); compiler->RestoreLiveRegisters(locs); @@ -1964,7 +1964,7 @@ void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { ASSERT(locs()->in(kLengthPos).reg() == R2); compiler->GenerateCall(token_pos(), &StubCode::AllocateArrayLabel(), - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); ASSERT(locs()->out(0).reg() == R0); } @@ -1989,7 +1989,7 @@ class BoxDoubleSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ mov(locs->out(0).reg(), R0); compiler->RestoreLiveRegisters(locs); @@ -2021,7 +2021,7 @@ class BoxFloat32x4SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ mov(locs->out(0).reg(), R0); compiler->RestoreLiveRegisters(locs); @@ -2053,7 +2053,7 @@ class BoxFloat64x2SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ mov(locs->out(0).reg(), R0); compiler->RestoreLiveRegisters(locs); @@ -2329,7 +2329,7 @@ void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const ExternalLabel label(StubCode::AllocateContextEntryPoint()); compiler->GenerateCall(token_pos(), &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); } @@ -2442,7 +2442,7 @@ class CheckStackOverflowSlowPath : public SlowPathCode { if (FLAG_use_osr && !compiler->is_optimizing() && instruction_->in_loop()) { // In unoptimized code, record loop stack checks as possible OSR entries. - compiler->AddCurrentDescriptor(PcDescriptors::kOsrEntry, + compiler->AddCurrentDescriptor(RawPcDescriptors::kOsrEntry, instruction_->deopt_id(), 0); // No token position. } @@ -3208,7 +3208,7 @@ class BoxInt32x4SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ mov(locs->out(0).reg(), R0); compiler->RestoreLiveRegisters(locs); @@ -5168,7 +5168,7 @@ void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { // On ARM64 the deoptimization descriptor points after the edge counter // code so that we can reuse the same pattern matching code as at call // sites, which matches backwards from the end of the pattern. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_, Scanner::kNoSourcePos); } @@ -5194,7 +5194,7 @@ void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { // points after the edge counter code so that we can reuse the same // pattern matching code as at call sites, which matches backwards from // the end of the pattern. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, GetDeoptId(), Scanner::kNoSourcePos); } @@ -5336,7 +5336,7 @@ void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const ExternalLabel label(stub.EntryPoint()); compiler->GenerateCall(token_pos(), &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ Drop(ArgumentCount()); // Discard arguments. } diff --git a/runtime/vm/intermediate_language_ia32.cc b/runtime/vm/intermediate_language_ia32.cc index ea956eec3eb..d292f311245 100644 --- a/runtime/vm/intermediate_language_ia32.cc +++ b/runtime/vm/intermediate_language_ia32.cc @@ -817,7 +817,7 @@ void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { &StubCode::CallNativeCFunctionLabel(); compiler->GenerateCall(token_pos(), stub_entry, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ popl(result); } @@ -1718,7 +1718,7 @@ class StoreInstanceFieldSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->temp(0).reg(), EAX); compiler->RestoreLiveRegisters(locs); @@ -2185,7 +2185,7 @@ void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ Bind(&slow_path); compiler->GenerateCall(token_pos(), &StubCode::AllocateArrayLabel(), - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ Bind(&done); ASSERT(locs()->out(0).reg() == kResultReg); @@ -2211,7 +2211,7 @@ class BoxDoubleSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->out(0).reg(), EAX); compiler->RestoreLiveRegisters(locs); @@ -2243,7 +2243,7 @@ class BoxFloat32x4SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->out(0).reg(), EAX); compiler->RestoreLiveRegisters(locs); @@ -2275,7 +2275,7 @@ class BoxFloat64x2SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->out(0).reg(), EAX); compiler->RestoreLiveRegisters(locs); @@ -2581,7 +2581,7 @@ class AllocateContextSlowPath : public SlowPathCode { const ExternalLabel label(StubCode::AllocateContextEntryPoint()); compiler->GenerateCall(instruction_->token_pos(), &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); ASSERT(instruction_->locs()->out(0).reg() == EAX); compiler->RestoreLiveRegisters(instruction_->locs()); @@ -2671,7 +2671,7 @@ void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const ExternalLabel label(StubCode::AllocateContextEntryPoint()); compiler->GenerateCall(token_pos(), &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); } @@ -2779,7 +2779,7 @@ class CheckStackOverflowSlowPath : public SlowPathCode { if (FLAG_use_osr && !compiler->is_optimizing() && instruction_->in_loop()) { // In unoptimized code, record loop stack checks as possible OSR entries. - compiler->AddCurrentDescriptor(PcDescriptors::kOsrEntry, + compiler->AddCurrentDescriptor(RawPcDescriptors::kOsrEntry, instruction_->deopt_id(), 0); // No token position. } @@ -3618,7 +3618,7 @@ class BoxInt32x4SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->out(0).reg(), EAX); compiler->RestoreLiveRegisters(locs); @@ -5700,7 +5700,7 @@ class BoxIntegerSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->out(0).reg(), EAX); compiler->RestoreLiveRegisters(locs); @@ -6035,7 +6035,7 @@ void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { // The deoptimization descriptor points after the edge counter code for // uniformity with ARM and MIPS, where we can reuse pattern matching // code that matches backwards from the end of the pattern. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_, Scanner::kNoSourcePos); } @@ -6061,7 +6061,7 @@ void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { // after the edge counter for uniformity with ARM and MIPS, where we can // reuse pattern matching that matches backwards from the end of the // pattern. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, GetDeoptId(), Scanner::kNoSourcePos); } @@ -6266,7 +6266,7 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ xorl(ECX, ECX); __ addl(EBX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); __ call(EBX); - compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall, + compiler->AddCurrentDescriptor(RawPcDescriptors::kClosureCall, deopt_id(), token_pos()); compiler->RecordSafepoint(locs()); @@ -6278,7 +6278,7 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos()); } @@ -6319,7 +6319,7 @@ void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const ExternalLabel label(stub.EntryPoint()); compiler->GenerateCall(token_pos(), &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ Drop(ArgumentCount()); // Discard arguments. } diff --git a/runtime/vm/intermediate_language_mips.cc b/runtime/vm/intermediate_language_mips.cc index b41b223e2f5..a4a33bd7d54 100644 --- a/runtime/vm/intermediate_language_mips.cc +++ b/runtime/vm/intermediate_language_mips.cc @@ -239,7 +239,7 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ lw(T2, FieldAddress(T0, Function::instructions_offset())); __ AddImmediate(T2, Instructions::HeaderSize() - kHeapObjectTag); __ jalr(T2); - compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall, + compiler->AddCurrentDescriptor(RawPcDescriptors::kClosureCall, deopt_id(), token_pos()); compiler->RecordSafepoint(locs()); @@ -251,7 +251,7 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos()); } @@ -906,7 +906,7 @@ void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ LoadImmediate(A1, argc_tag); compiler->GenerateCall(token_pos(), stub_entry, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ Pop(result); } @@ -1734,7 +1734,7 @@ class StoreInstanceFieldSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ mov(locs->temp(0).reg(), V0); compiler->RestoreLiveRegisters(locs); @@ -2113,7 +2113,7 @@ void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ Bind(&slow_path); compiler->GenerateCall(token_pos(), &StubCode::AllocateArrayLabel(), - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ Bind(&done); ASSERT(locs()->out(0).reg() == kResultReg); @@ -2139,7 +2139,7 @@ class BoxDoubleSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); if (locs->out(0).reg() != V0) { __ mov(locs->out(0).reg(), V0); @@ -2388,7 +2388,7 @@ void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const ExternalLabel label(StubCode::AllocateContextEntryPoint()); compiler->GenerateCall(token_pos(), &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); } @@ -2513,7 +2513,7 @@ class CheckStackOverflowSlowPath : public SlowPathCode { if (FLAG_use_osr && !compiler->is_optimizing() && instruction_->in_loop()) { // In unoptimized code, record loop stack checks as possible OSR entries. - compiler->AddCurrentDescriptor(PcDescriptors::kOsrEntry, + compiler->AddCurrentDescriptor(RawPcDescriptors::kOsrEntry, instruction_->deopt_id(), 0); // No token position. } @@ -4510,7 +4510,7 @@ void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { // On MIPS the deoptimization descriptor points after the edge counter // code so that we can reuse the same pattern matching code as at call // sites, which matches backwards from the end of the pattern. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_, Scanner::kNoSourcePos); } @@ -4537,7 +4537,7 @@ void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { // points after the edge counter code so that we can reuse the same // pattern matching code as at call sites, which matches backwards from // the end of the pattern. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, GetDeoptId(), Scanner::kNoSourcePos); } @@ -4683,7 +4683,7 @@ void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const ExternalLabel label(stub.EntryPoint()); compiler->GenerateCall(token_pos(), &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ Drop(ArgumentCount()); // Discard arguments. } diff --git a/runtime/vm/intermediate_language_x64.cc b/runtime/vm/intermediate_language_x64.cc index 069af17d663..4a60aac258b 100644 --- a/runtime/vm/intermediate_language_x64.cc +++ b/runtime/vm/intermediate_language_x64.cc @@ -747,7 +747,7 @@ void NativeCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { &StubCode::CallNativeCFunctionLabel(); compiler->GenerateCall(token_pos(), stub_entry, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ popq(result); } @@ -1560,7 +1560,7 @@ class StoreInstanceFieldSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->temp(0).reg(), RAX); compiler->RestoreLiveRegisters(locs); @@ -2019,7 +2019,7 @@ void CreateArrayInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ Bind(&slow_path); compiler->GenerateCall(token_pos(), &StubCode::AllocateArrayLabel(), - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ Bind(&done); ASSERT(locs()->out(0).reg() == kResultReg); @@ -2045,7 +2045,7 @@ class BoxDoubleSlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->out(0).reg(), RAX); compiler->RestoreLiveRegisters(locs); @@ -2077,7 +2077,7 @@ class BoxFloat32x4SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->out(0).reg(), RAX); compiler->RestoreLiveRegisters(locs); @@ -2109,7 +2109,7 @@ class BoxFloat64x2SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->out(0).reg(), RAX); compiler->RestoreLiveRegisters(locs); @@ -2392,7 +2392,7 @@ void AllocateContextInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const ExternalLabel label(StubCode::AllocateContextEntryPoint()); compiler->GenerateCall(token_pos(), &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); } @@ -2506,7 +2506,7 @@ class CheckStackOverflowSlowPath : public SlowPathCode { if (FLAG_use_osr && !compiler->is_optimizing() && instruction_->in_loop()) { // In unoptimized code, record loop stack checks as possible OSR entries. - compiler->AddCurrentDescriptor(PcDescriptors::kOsrEntry, + compiler->AddCurrentDescriptor(RawPcDescriptors::kOsrEntry, instruction_->deopt_id(), 0); // No token position. } @@ -3439,7 +3439,7 @@ class BoxInt32x4SlowPath : public SlowPathCode { compiler->SaveLiveRegisters(locs); compiler->GenerateCall(Scanner::kNoSourcePos, // No token position. &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs); __ MoveRegister(locs->out(0).reg(), RAX); compiler->RestoreLiveRegisters(locs); @@ -5604,7 +5604,7 @@ void TargetEntryInstr::EmitNativeCode(FlowGraphCompiler* compiler) { // The deoptimization descriptor points after the edge counter code for // uniformity with ARM and MIPS, where we can reuse pattern matching // code that matches backwards from the end of the pattern. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_, Scanner::kNoSourcePos); } @@ -5630,7 +5630,7 @@ void GotoInstr::EmitNativeCode(FlowGraphCompiler* compiler) { // after the edge counter for uniformity with ARM and MIPS, where we can // reuse pattern matching that matches backwards from the end of the // pattern. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, GetDeoptId(), Scanner::kNoSourcePos); } @@ -5772,7 +5772,7 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { __ xorq(RBX, RBX); __ addq(RCX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); __ call(RCX); - compiler->AddCurrentDescriptor(PcDescriptors::kClosureCall, + compiler->AddCurrentDescriptor(RawPcDescriptors::kClosureCall, deopt_id(), token_pos()); compiler->RecordSafepoint(locs()); @@ -5784,7 +5784,7 @@ void ClosureCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { } else { // Add deoptimization continuation point after the call and before the // arguments are removed. - compiler->AddCurrentDescriptor(PcDescriptors::kDeopt, + compiler->AddCurrentDescriptor(RawPcDescriptors::kDeopt, deopt_id_after, token_pos()); } @@ -5825,7 +5825,7 @@ void AllocateObjectInstr::EmitNativeCode(FlowGraphCompiler* compiler) { const ExternalLabel label(stub.EntryPoint()); compiler->GenerateCall(token_pos(), &label, - PcDescriptors::kOther, + RawPcDescriptors::kOther, locs()); __ Drop(ArgumentCount()); // Discard arguments. } diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index d7b5284c382..ce4f450ca01 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -10195,16 +10195,16 @@ RawPcDescriptors* PcDescriptors::New(intptr_t num_descriptors) { } -const char* PcDescriptors::KindAsStr(intptr_t index) const { - switch (DescriptorKind(index)) { - case PcDescriptors::kDeopt: return "deopt "; - case PcDescriptors::kIcCall: return "ic-call "; - case PcDescriptors::kOptStaticCall: return "opt-call "; - case PcDescriptors::kUnoptStaticCall: return "unopt-call "; - case PcDescriptors::kClosureCall: return "closure-call "; - case PcDescriptors::kRuntimeCall: return "runtime-call "; - case PcDescriptors::kOsrEntry: return "osr-entry "; - case PcDescriptors::kOther: return "other "; +const char* PcDescriptors::KindAsStr(RawPcDescriptors::Kind kind) { + switch (kind) { + case RawPcDescriptors::kDeopt: return "deopt "; + case RawPcDescriptors::kIcCall: return "ic-call "; + case RawPcDescriptors::kOptStaticCall: return "opt-call "; + case RawPcDescriptors::kUnoptStaticCall: return "unopt-call "; + case RawPcDescriptors::kClosureCall: return "closure-call "; + case RawPcDescriptors::kRuntimeCall: return "runtime-call "; + case RawPcDescriptors::kOsrEntry: return "osr-entry "; + case RawPcDescriptors::kOther: return "other "; } UNREACHABLE(); return ""; @@ -10233,25 +10233,29 @@ const char* PcDescriptors::ToCString() const { "%#-*" Px "\t%s\t%" Pd "\t\t%" Pd "\t%" Pd "\n"; // First compute the buffer size required. intptr_t len = 1; // Trailing '\0'. - for (intptr_t i = 0; i < Length(); i++) { + Iterator iter(*this); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); len += OS::SNPrint(NULL, 0, kFormat, addr_width, - PC(i), - KindAsStr(i), - DeoptId(i), - TokenPos(i), - TryIndex(i)); + rec.pc, + KindAsStr(rec.kind()), + rec.deopt_id, + rec.token_pos, + rec.try_index); } // Allocate the buffer. char* buffer = Isolate::Current()->current_zone()->Alloc(len); // Layout the fields in the buffer. intptr_t index = 0; - for (intptr_t i = 0; i < Length(); i++) { + Iterator iter2(*this); + while (iter2.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter2.Next(); index += OS::SNPrint((buffer + index), (len - index), kFormat, addr_width, - PC(i), - KindAsStr(i), - DeoptId(i), - TokenPos(i), - TryIndex(i)); + rec.pc, + KindAsStr(rec.kind()), + rec.deopt_id, + rec.token_pos, + rec.try_index); } return buffer; } @@ -10264,13 +10268,15 @@ void PcDescriptors::PrintToJSONObject(JSONObject* jsobj) const { // generate an ID. Currently we only print PcDescriptors inline with a Code. jsobj->AddProperty("id", ""); JSONArray members(jsobj, "members"); - for (intptr_t i = 0; i < Length(); i++) { + Iterator iter(*this); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); JSONObject descriptor(&members); - descriptor.AddPropertyF("pc", "%" Px "", PC(i)); - descriptor.AddProperty("kind", KindAsStr(i)); - descriptor.AddProperty("deoptId", DeoptId(i)); - descriptor.AddProperty("tokenPos", TokenPos(i)); - descriptor.AddProperty("tryIndex", TryIndex(i)); + descriptor.AddPropertyF("pc", "%" Px "", rec.pc); + descriptor.AddProperty("kind", KindAsStr(rec.kind())); + descriptor.AddProperty("deoptId", static_cast(rec.deopt_id)); + descriptor.AddProperty("tokenPos", static_cast(rec.token_pos)); + descriptor.AddProperty("tryIndex", static_cast(rec.try_index)); } } @@ -10297,17 +10303,21 @@ void PcDescriptors::Verify(const Function& function) const { return; } // Only check ids for unoptimized code that is optimizable. - if (!function.IsOptimizable()) return; - for (intptr_t i = 0; i < Length(); i++) { - PcDescriptors::Kind kind = DescriptorKind(i); + if (!function.IsOptimizable()) { + return; + } + Iterator iter(*this); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + RawPcDescriptors::Kind kind = rec.kind(); // 'deopt_id' is set for kDeopt and kIcCall and must be unique for one kind. intptr_t deopt_id = Isolate::kNoDeoptId; - if ((DescriptorKind(i) != PcDescriptors::kDeopt) || - (DescriptorKind(i) != PcDescriptors::kIcCall)) { + if ((kind != RawPcDescriptors::kDeopt) || + (kind != RawPcDescriptors::kIcCall)) { continue; } - deopt_id = DeoptId(i); + deopt_id = rec.deopt_id; if (Isolate::IsDeoptAfter(deopt_id)) { // TODO(vegorov): some instructions contain multiple calls and have // multiple "after" targets recorded. Right now it is benign but might @@ -10315,10 +10325,12 @@ void PcDescriptors::Verify(const Function& function) const { continue; } - for (intptr_t k = i + 1; k < Length(); k++) { - if (kind == DescriptorKind(k)) { + Iterator nested(iter); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& nested_rec = nested.Next(); + if (kind == nested_rec.kind()) { if (deopt_id != Isolate::kNoDeoptId) { - ASSERT(DeoptId(k) != deopt_id); + ASSERT(nested_rec.deopt_id != deopt_id); } } } @@ -10327,10 +10339,12 @@ void PcDescriptors::Verify(const Function& function) const { } -uword PcDescriptors::GetPcForKind(Kind kind) const { - for (intptr_t i = 0; i < Length(); i++) { - if (DescriptorKind(i) == kind) { - return PC(i); +uword PcDescriptors::GetPcForKind(RawPcDescriptors::Kind kind) const { + Iterator iter(*this); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + if (rec.kind() == kind) { + return rec.pc; } } return 0; @@ -11827,24 +11841,26 @@ RawCode* Code::FindCode(uword pc, int64_t timestamp) { intptr_t Code::GetTokenIndexOfPC(uword pc) const { - intptr_t token_pos = -1; const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); - for (intptr_t i = 0; i < descriptors.Length(); i++) { - if (descriptors.PC(i) == pc) { - token_pos = descriptors.TokenPos(i); - break; + PcDescriptors::Iterator iter(descriptors); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + if (rec.pc == pc) { + return rec.token_pos; } } - return token_pos; + return -1; } -uword Code::GetPcForDeoptId(intptr_t deopt_id, PcDescriptors::Kind kind) const { +uword Code::GetPcForDeoptId(intptr_t deopt_id, + RawPcDescriptors::Kind kind) const { const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); - for (intptr_t i = 0; i < descriptors.Length(); i++) { - if ((descriptors.DeoptId(i) == deopt_id) && - (descriptors.DescriptorKind(i) == kind)) { - uword pc = descriptors.PC(i); + PcDescriptors::Iterator iter(descriptors); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + if ((rec.deopt_id == deopt_id) && (rec.kind() == kind)) { + uword pc = rec.pc; ASSERT(ContainsInstructionAt(pc)); return pc; } @@ -11855,10 +11871,11 @@ uword Code::GetPcForDeoptId(intptr_t deopt_id, PcDescriptors::Kind kind) const { intptr_t Code::GetDeoptIdForOsr(uword pc) const { const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors()); - for (intptr_t i = 0; i < descriptors.Length(); ++i) { - if ((descriptors.PC(i) == pc) && - (descriptors.DescriptorKind(i) == PcDescriptors::kOsrEntry)) { - return descriptors.DeoptId(i); + PcDescriptors::Iterator iter(descriptors); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + if ((rec.pc == pc) && (rec.kind() == RawPcDescriptors::kOsrEntry)) { + return rec.deopt_id; } } return Isolate::kNoDeoptId; diff --git a/runtime/vm/object.h b/runtime/vm/object.h index 24aaa12c7b0..f0fec3a4649 100644 --- a/runtime/vm/object.h +++ b/runtime/vm/object.h @@ -2985,50 +2985,15 @@ class LocalVarDescriptors : public Object { class PcDescriptors : public Object { public: - enum Kind { - kDeopt, // Deoptimization continuation point. - kIcCall, // IC call. - kOptStaticCall, // Call directly to known target, e.g. static call. - kUnoptStaticCall, // Call to a known target via a stub. - kClosureCall, // Closure call. - kRuntimeCall, // Runtime call. - kOsrEntry, // OSR entry point in unoptimized code. - kOther - }; - - intptr_t Length() const; - - uword PC(intptr_t index) const { - ASSERT(index < Length()); - return raw_ptr()->data()[index].pc; - } - PcDescriptors::Kind DescriptorKind(intptr_t index) const { - ASSERT(index < Length()); - return static_cast(raw_ptr()->data()[index].kind); - } - intptr_t DeoptId(intptr_t index) const { - ASSERT(index < Length()); - return raw_ptr()->data()[index].deopt_id; - } - intptr_t TokenPos(intptr_t index) const { - ASSERT(index < Length()); - return raw_ptr()->data()[index].token_pos; - } - intptr_t TryIndex(intptr_t index) const { - ASSERT(index < Length()); - return raw_ptr()->data()[index].try_index; - } - const char* KindAsStr(intptr_t index) const; - void AddDescriptor(intptr_t index, uword pc, - PcDescriptors::Kind kind, + RawPcDescriptors::Kind kind, int64_t deopt_id, int64_t token_pos, // Or deopt reason. intptr_t try_index) const { // Or deopt index. - RawPcDescriptors::PcDescriptorRec* rec = &raw_ptr()->data()[index]; + RawPcDescriptors::PcDescriptorRec* rec = recAt(index); rec->pc = pc; - rec->kind = kind; + rec->kind_ = kind; ASSERT(Utils::IsInt(32, deopt_id)); rec->deopt_id = deopt_id; ASSERT(Utils::IsInt(32, token_pos)); @@ -3055,7 +3020,7 @@ class PcDescriptors : public Object { static RawPcDescriptors* New(intptr_t num_descriptors); // Returns 0 if not found. - uword GetPcForKind(Kind kind) const; + uword GetPcForKind(RawPcDescriptors::Kind kind) const; // Verify (assert) assumptions about pc descriptors in debug mode. void Verify(const Function& function) const; @@ -3067,7 +3032,36 @@ class PcDescriptors : public Object { // We would have a VisitPointers function here to traverse the // pc descriptors table to visit objects if any in the table. + class Iterator : public ValueObject { + public: + explicit Iterator(const PcDescriptors& descriptors) + : descriptors_(descriptors), current_ix_(0) {} + + // For nested iterations, starting at element after. + explicit Iterator(const Iterator& iter) + : descriptors_(iter.descriptors_), current_ix_(iter.current_ix_) {} + + bool HasNext() { return current_ix_ < descriptors_.Length(); } + + const RawPcDescriptors::PcDescriptorRec& Next() { + ASSERT(HasNext()); + return *descriptors_.recAt(current_ix_++); + } + + private: + const PcDescriptors& descriptors_; + intptr_t current_ix_; + }; + private: + static const char* KindAsStr(RawPcDescriptors::Kind kind); + + intptr_t Length() const; + + RawPcDescriptors::PcDescriptorRec* recAt(intptr_t ix) const { + ASSERT(ix < Length()); + return &raw_ptr()->data()[ix]; + } void SetLength(intptr_t value) const; FINAL_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors, Object); @@ -3684,7 +3678,7 @@ class Code : public Object { uword GetLazyDeoptPc() const; // Find pc, return 0 if not found. - uword GetPcForDeoptId(intptr_t deopt_id, PcDescriptors::Kind kind) const; + uword GetPcForDeoptId(intptr_t deopt_id, RawPcDescriptors::Kind kind) const; intptr_t GetDeoptIdForOsr(uword pc) const; // Returns true if there is an object in the code between 'start_offset' diff --git a/runtime/vm/object_test.cc b/runtime/vm/object_test.cc index 3cb1beb4535..a80c496d3c9 100644 --- a/runtime/vm/object_test.cc +++ b/runtime/vm/object_test.cc @@ -2729,12 +2729,12 @@ TEST_CASE(PcDescriptors) { // Add PcDescriptors to the code. PcDescriptors& descriptors = PcDescriptors::Handle(); descriptors ^= PcDescriptors::New(kNumEntries); - descriptors.AddDescriptor(0, 10, PcDescriptors::kOther, 1, 20, 1); - descriptors.AddDescriptor(1, 20, PcDescriptors::kDeopt, 2, 30, 0); - descriptors.AddDescriptor(2, 30, PcDescriptors::kOther, 3, 40, 1); - descriptors.AddDescriptor(3, 10, PcDescriptors::kOther, 4, 40, 2); - descriptors.AddDescriptor(4, 10, PcDescriptors::kOther, 5, 80, 3); - descriptors.AddDescriptor(5, 80, PcDescriptors::kOther, 6, 150, 3); + descriptors.AddDescriptor(0, 10, RawPcDescriptors::kOther, 1, 20, 1); + descriptors.AddDescriptor(1, 20, RawPcDescriptors::kDeopt, 2, 30, 0); + descriptors.AddDescriptor(2, 30, RawPcDescriptors::kOther, 3, 40, 1); + descriptors.AddDescriptor(3, 10, RawPcDescriptors::kOther, 4, 40, 2); + descriptors.AddDescriptor(4, 10, RawPcDescriptors::kOther, 5, 80, 3); + descriptors.AddDescriptor(5, 80, RawPcDescriptors::kOther, 6, 150, 3); extern void GenerateIncrement(Assembler* assembler); Assembler _assembler_; @@ -2745,16 +2745,30 @@ TEST_CASE(PcDescriptors) { // Verify the PcDescriptor entries by accessing them. const PcDescriptors& pc_descs = PcDescriptors::Handle(code.pc_descriptors()); - EXPECT_EQ(kNumEntries, pc_descs.Length()); - EXPECT_EQ(1, pc_descs.TryIndex(0)); - EXPECT_EQ(static_cast(10), pc_descs.PC(0)); - EXPECT_EQ(1, pc_descs.DeoptId(0)); - EXPECT_EQ(20, pc_descs.TokenPos(0)); - EXPECT_EQ(3, pc_descs.TryIndex(5)); - EXPECT_EQ(static_cast(80), pc_descs.PC(5)); - EXPECT_EQ(150, pc_descs.TokenPos(5)); - EXPECT_EQ(PcDescriptors::kOther, pc_descs.DescriptorKind(0)); - EXPECT_EQ(PcDescriptors::kDeopt, pc_descs.DescriptorKind(1)); + PcDescriptors::Iterator iter(pc_descs); + const RawPcDescriptors::PcDescriptorRec& rec0 = iter.Next(); + const RawPcDescriptors::PcDescriptorRec& rec1 = iter.Next(); + const RawPcDescriptors::PcDescriptorRec& rec2 = iter.Next(); + const RawPcDescriptors::PcDescriptorRec& rec3 = iter.Next(); + const RawPcDescriptors::PcDescriptorRec& rec4 = iter.Next(); + const RawPcDescriptors::PcDescriptorRec& rec5 = iter.Next(); + ASSERT(!iter.HasNext()); + + EXPECT_EQ(1, rec0.try_index); + EXPECT_EQ(static_cast(10), rec0.pc); + EXPECT_EQ(1, rec0.deopt_id); + EXPECT_EQ(20, rec0.token_pos); + + EXPECT_EQ(3, rec5.try_index); + EXPECT_EQ(static_cast(80), rec5.pc); + EXPECT_EQ(150, rec5.token_pos); + EXPECT_EQ(RawPcDescriptors::kOther, rec0.kind()); + EXPECT_EQ(RawPcDescriptors::kDeopt, rec1.kind()); + + EXPECT_EQ(30, rec1.token_pos); + EXPECT_EQ(40, rec2.token_pos); + EXPECT_EQ(40, rec3.token_pos); + EXPECT_EQ(80, rec4.token_pos); } diff --git a/runtime/vm/raw_object.h b/runtime/vm/raw_object.h index 6dc181c6958..9d39c33a99d 100644 --- a/runtime/vm/raw_object.h +++ b/runtime/vm/raw_object.h @@ -902,18 +902,33 @@ class RawInstructions : public RawObject { class RawPcDescriptors : public RawObject { - RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); - - intptr_t length_; // Number of descriptors. + public: + enum Kind { + kDeopt, // Deoptimization continuation point. + kIcCall, // IC call. + kOptStaticCall, // Call directly to known target, e.g. static call. + kUnoptStaticCall, // Call to a known target via a stub. + kClosureCall, // Closure call. + kRuntimeCall, // Runtime call. + kOsrEntry, // OSR entry point in unoptimized code. + kOther + }; struct PcDescriptorRec { uword pc; int32_t deopt_id; int32_t token_pos; // Or deopt reason. int16_t try_index; // Or deopt index. - int8_t kind; + int8_t kind_; + + Kind kind() const { return static_cast(kind_); } }; + private: + RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); + + intptr_t length_; // Number of descriptors. + // Variable length data follows here. PcDescriptorRec* data() { OPEN_ARRAY_START(PcDescriptorRec, intptr_t); } diff --git a/runtime/vm/simulator_arm.cc b/runtime/vm/simulator_arm.cc index a8e4e17309e..4946642b77c 100644 --- a/runtime/vm/simulator_arm.cc +++ b/runtime/vm/simulator_arm.cc @@ -269,12 +269,13 @@ intptr_t SimulatorDebugger::GetApproximateTokenIndex(const Code& code, intptr_t token_pos = -1; const PcDescriptors& descriptors = PcDescriptors::Handle(code.pc_descriptors()); - for (intptr_t i = 0; i < descriptors.Length(); i++) { - if (descriptors.PC(i) == pc) { - token_pos = descriptors.TokenPos(i); - break; - } else if ((token_pos <= 0) && (descriptors.PC(i) > pc)) { - token_pos = descriptors.TokenPos(i); + PcDescriptors::Iterator iter(descriptors); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + if (rec.pc == pc) { + return rec.token_pos; + } else if ((token_pos <= 0) && (rec.pc > pc)) { + token_pos = rec.token_pos; } } return token_pos; diff --git a/runtime/vm/stack_frame.cc b/runtime/vm/stack_frame.cc index 0c5961231a3..692a358ca19 100644 --- a/runtime/vm/stack_frame.cc +++ b/runtime/vm/stack_frame.cc @@ -224,11 +224,11 @@ bool StackFrame::FindExceptionHandler(Isolate* isolate, REUSABLE_PC_DESCRIPTORS_HANDLESCOPE(isolate); PcDescriptors& descriptors = reused_pc_descriptors_handle.Handle(); descriptors = code.pc_descriptors(); - const intptr_t len = descriptors.Length(); - for (intptr_t i = 0; i < len; i++) { - if ((static_cast(descriptors.PC(i)) == pc()) && - (descriptors.TryIndex(i) != -1)) { - const intptr_t try_index = descriptors.TryIndex(i); + PcDescriptors::Iterator iter(descriptors); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + if ((rec.pc == pc()) && (rec.try_index != -1)) { + const intptr_t try_index = rec.try_index; RawExceptionHandlers::HandlerInfo handler_info; handlers.GetHandlerInfo(try_index, &handler_info); *handler_pc = handler_info.handler_pc; @@ -249,9 +249,11 @@ intptr_t StackFrame::GetTokenPos() const { const PcDescriptors& descriptors = PcDescriptors::Handle(code.pc_descriptors()); ASSERT(!descriptors.IsNull()); - for (int i = 0; i < descriptors.Length(); i++) { - if (static_cast(descriptors.PC(i)) == pc()) { - return descriptors.TokenPos(i); + PcDescriptors::Iterator iter(descriptors); + while (iter.HasNext()) { + const RawPcDescriptors::PcDescriptorRec& rec = iter.Next(); + if (rec.pc == pc()) { + return rec.token_pos; } } return -1;