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

Unified Diff: runtime/vm/object.cc

Issue 403643002: One more iteration of PcDescriptor iterator improvement: do not copy record but access individual … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 38356)
+++ runtime/vm/object.cc (working copy)
@@ -10359,14 +10359,13 @@
intptr_t len = 1; // Trailing '\0'.
Iterator iter(*this, RawPcDescriptors::kAnyKind);
while (iter.HasNext()) {
hausner 2014/07/17 23:22:56 See other comment. This loop would become: while
srdjan 2014/07/18 18:16:45 Good suggestion, changed to: while (iter.MoveNext
- RawPcDescriptors::PcDescriptorRec rec;
- iter.NextRec(&rec);
+ uword pc = iter.NextPc();
len += OS::SNPrint(NULL, 0, kFormat, addr_width,
- rec.pc(),
- KindAsStr(rec.kind()),
- rec.deopt_id(),
- rec.token_pos(),
- rec.try_index());
+ pc,
+ KindAsStr(iter.current_kind()),
+ iter.current_deopt_id(),
+ iter.current_token_pos(),
+ iter.current_try_index());
}
// Allocate the buffer.
char* buffer = Isolate::Current()->current_zone()->Alloc<char>(len);
@@ -10374,14 +10373,13 @@
intptr_t index = 0;
Iterator iter2(*this, RawPcDescriptors::kAnyKind);
while (iter2.HasNext()) {
- RawPcDescriptors::PcDescriptorRec rec;
- iter2.NextRec(&rec);
+ uword pc = iter2.NextPc();
index += OS::SNPrint((buffer + index), (len - index), kFormat, addr_width,
- rec.pc(),
- KindAsStr(rec.kind()),
- rec.deopt_id(),
- rec.token_pos(),
- rec.try_index());
+ pc,
+ KindAsStr(iter.current_kind()),
+ iter.current_deopt_id(),
+ iter.current_token_pos(),
+ iter.current_try_index());
}
return buffer;
}
@@ -10396,14 +10394,13 @@
JSONArray members(jsobj, "members");
Iterator iter(*this, RawPcDescriptors::kAnyKind);
while (iter.HasNext()) {
- RawPcDescriptors::PcDescriptorRec rec;
- iter.NextRec(&rec);
+ uword pc = iter.NextPc();
JSONObject descriptor(&members);
- descriptor.AddPropertyF("pc", "%" Px "", rec.pc());
- descriptor.AddProperty("kind", KindAsStr(rec.kind()));
- descriptor.AddProperty("deoptId", static_cast<intptr_t>(rec.deopt_id()));
- descriptor.AddProperty("tokenPos", static_cast<intptr_t>(rec.token_pos()));
- descriptor.AddProperty("tryIndex", static_cast<intptr_t>(rec.try_index()));
+ descriptor.AddPropertyF("pc", "%" Px "", pc);
+ descriptor.AddProperty("kind", KindAsStr(iter.current_kind()));
+ descriptor.AddProperty("deoptId", iter.current_deopt_id());
+ descriptor.AddProperty("tokenPos", iter.current_token_pos());
+ descriptor.AddProperty("tryIndex", iter.current_try_index());
}
}
@@ -10435,11 +10432,10 @@
}
Iterator iter(*this, RawPcDescriptors::kDeopt | RawPcDescriptors::kIcCall);
while (iter.HasNext()) {
- RawPcDescriptors::PcDescriptorRec rec;
- iter.NextRec(&rec);
+ const intptr_t deopt_id = iter.NextDeoptId();
// 'deopt_id' is set for kDeopt and kIcCall and must be unique for one kind.
- if (Isolate::IsDeoptAfter(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
// lead to issues in the future. Fix that and enable verification.
@@ -10448,10 +10444,9 @@
Iterator nested(iter);
while (nested.HasNext()) {
- RawPcDescriptors::PcDescriptorRec nested_rec;
- nested.NextRec(&nested_rec);
- if (rec.kind() == nested_rec.kind()) {
- ASSERT(nested_rec.deopt_id() != rec.deopt_id());
+ intptr_t nested_deopt_id = nested.NextDeoptId();
+ if (iter.current_kind() == nested.current_kind()) {
+ ASSERT(nested_deopt_id != iter.current_deopt_id());
}
}
}
@@ -11961,10 +11956,9 @@
const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kAnyKind);
while (iter.HasNext()) {
- RawPcDescriptors::PcDescriptorRec rec;
- iter.NextRec(&rec);
- if (rec.pc() == pc) {
- return rec.token_pos();
+ const uword current_pc = iter.NextPc();
+ if (current_pc == pc) {
+ return iter.current_token_pos();
}
}
return -1;
@@ -11976,10 +11970,9 @@
const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
PcDescriptors::Iterator iter(descriptors, kind);
while (iter.HasNext()) {
- RawPcDescriptors::PcDescriptorRec rec;
- iter.NextRec(&rec);
- if (rec.deopt_id() == deopt_id) {
- uword pc = rec.pc();
+ const intptr_t current_deopt_id = iter.NextDeoptId();
+ if (current_deopt_id == deopt_id) {
+ uword pc = iter.current_pc();
ASSERT(ContainsInstructionAt(pc));
return pc;
}
@@ -11992,10 +11985,9 @@
const PcDescriptors& descriptors = PcDescriptors::Handle(pc_descriptors());
PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kOsrEntry);
while (iter.HasNext()) {
- RawPcDescriptors::PcDescriptorRec rec;
- iter.NextRec(&rec);
- if (rec.pc() == pc) {
- return rec.deopt_id();
+ const uword current_pc = iter.NextPc();
+ if (current_pc == pc) {
+ return iter.current_deopt_id();
}
}
return Isolate::kNoDeoptId;
« runtime/vm/object.h ('K') | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698