Chromium Code Reviews| Index: runtime/vm/object.h |
| =================================================================== |
| --- runtime/vm/object.h (revision 38356) |
| +++ runtime/vm/object.h (working copy) |
| @@ -3047,34 +3047,53 @@ |
| 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(); } |
| + bool HasNext() const { return next_ix_ < descriptors_.Length(); } |
| intptr_t NextDeoptId() { |
|
hausner
2014/07/17 23:22:56
I find it a bit awkward that you have two accessor
srdjan
2014/07/18 18:16:45
Good suggestion, changed to:
while (i.MoveNext())
|
| ASSERT(HasNext()); |
| - const intptr_t res = descriptors_.recAt(current_ix_++)->deopt_id(); |
| + const intptr_t res = descriptors_.recAt(next_ix_)->deopt_id(); |
| + current_ix_ = next_ix_++; |
| MoveToMatching(); |
| return res; |
| } |
| uword NextPc() { |
| ASSERT(HasNext()); |
| - const uword res = descriptors_.recAt(current_ix_++)->pc(); |
| + const uword res = descriptors_.recAt(next_ix_)->pc(); |
| + current_ix_ = next_ix_++; |
| MoveToMatching(); |
| return res; |
| } |
| - void NextRec(RawPcDescriptors::PcDescriptorRec* result) { |
| + intptr_t NextTokenPos() { |
| ASSERT(HasNext()); |
| - const RawPcDescriptors::PcDescriptorRec* r = |
| - descriptors_.recAt(current_ix_++); |
| - r->CopyTo(result); |
| + const intptr_t res = descriptors_.recAt(next_ix_)->token_pos(); |
| + current_ix_ = next_ix_++; |
| MoveToMatching(); |
| + return res; |
| } |
| + uword current_pc() const { return descriptors_.recAt(current_ix_)->pc(); } |
| + intptr_t current_deopt_id() const { |
| + return descriptors_.recAt(current_ix_)->deopt_id(); |
| + } |
| + intptr_t current_token_pos() const { |
| + return descriptors_.recAt(current_ix_)->token_pos(); |
| + } |
| + intptr_t current_try_index() const { |
| + return descriptors_.recAt(current_ix_)->try_index(); |
| + } |
| + RawPcDescriptors::Kind current_kind() const { |
| + return descriptors_.recAt(current_ix_)->kind(); |
| + } |
| + |
| private: |
| friend class PcDescriptors; |
| @@ -3083,23 +3102,25 @@ |
| : 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 +3134,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); |
| } |