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

Unified Diff: runtime/vm/object.h

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
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 38394)
+++ runtime/vm/object.h (working copy)
@@ -3047,59 +3047,66 @@
class Iterator : ValueObject {
public:
Iterator(const PcDescriptors& descriptors, intptr_t kind_mask)
- : descriptors_(descriptors), kind_mask_(kind_mask), current_ix_(0) {
+ : descriptors_(descriptors),
+ kind_mask_(kind_mask),
+ next_ix_(0),
+ current_ix_(-1) {
MoveToMatching();
}
- bool HasNext() const { return current_ix_ < descriptors_.Length(); }
-
- intptr_t NextDeoptId() {
- ASSERT(HasNext());
- const intptr_t res = descriptors_.recAt(current_ix_++)->deopt_id();
- MoveToMatching();
- return res;
+ bool MoveNext() {
+ if (HasNext()) {
+ current_ix_ = next_ix_++;
+ MoveToMatching();
+ return true;
+ } else {
+ return false;
+ }
}
- uword NextPc() {
- ASSERT(HasNext());
- const uword res = descriptors_.recAt(current_ix_++)->pc();
- MoveToMatching();
- return res;
+ uword Pc() const { return descriptors_.recAt(current_ix_)->pc(); }
+ intptr_t DeoptId() const {
+ return descriptors_.recAt(current_ix_)->deopt_id();
}
-
- void NextRec(RawPcDescriptors::PcDescriptorRec* result) {
- ASSERT(HasNext());
- const RawPcDescriptors::PcDescriptorRec* r =
- descriptors_.recAt(current_ix_++);
- r->CopyTo(result);
- MoveToMatching();
+ intptr_t TokenPos() const {
+ return descriptors_.recAt(current_ix_)->token_pos();
}
+ intptr_t TryIndex() const {
+ return descriptors_.recAt(current_ix_)->try_index();
+ }
+ RawPcDescriptors::Kind Kind() const {
+ return descriptors_.recAt(current_ix_)->kind();
+ }
private:
friend class PcDescriptors;
+ bool HasNext() const { return next_ix_ < descriptors_.Length(); }
+
// For nested iterations, starting at element after.
explicit Iterator(const Iterator& iter)
: ValueObject(),
descriptors_(iter.descriptors_),
kind_mask_(iter.kind_mask_),
+ next_ix_(iter.next_ix_),
current_ix_(iter.current_ix_) {}
// Moves to record that matches kind_mask_.
void MoveToMatching() {
- while (current_ix_ < descriptors_.Length()) {
+ while (next_ix_ < descriptors_.Length()) {
const RawPcDescriptors::PcDescriptorRec& rec =
- *descriptors_.recAt(current_ix_);
+ *descriptors_.recAt(next_ix_);
if ((rec.kind() & kind_mask_) != 0) {
return; // Current is valid.
} else {
- ++current_ix_;
+ ++next_ix_;
}
}
}
const PcDescriptors& descriptors_;
const intptr_t kind_mask_;
+ intptr_t next_ix_;
intptr_t current_ix_;
};
@@ -3113,7 +3120,7 @@
intptr_t RecordSizeInBytes() const;
RawPcDescriptors::PcDescriptorRec* recAt(intptr_t ix) const {
- ASSERT(ix < Length());
+ ASSERT((0 <= ix) && (ix < Length()));
uint8_t* d = raw_ptr()->data() + (ix * RecordSizeInBytes());
return reinterpret_cast<RawPcDescriptors::PcDescriptorRec*>(d);
}
« no previous file with comments | « runtime/vm/debugger.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698