mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
[vm/bytecode] Fix iteration of bytecode local variables
Previously, BytecodeLocalVariablesIterator::IsDone() returned true when iterator was standing at the last entry. As a result, if the last entry is a scope without variables, then it was ignored and bytecode flow graph builder would not get a correct context level for that scope. The fix is for IsDone() to return true only after stepping past the last entry. Fixes service/async_generator_breakpoint_test/1 with bytecode. Change-Id: I768eec9a0e43342cc0f155a6c35cb3de50f3d14a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116880 Reviewed-by: Régis Crelier <regis@google.com> Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
parent
eac977bef0
commit
586869c3f6
1 changed files with 7 additions and 3 deletions
|
@ -436,10 +436,11 @@ class BytecodeLocalVariablesIterator : ValueObject {
|
|||
}
|
||||
|
||||
bool MoveNext() {
|
||||
if (entries_remaining_ == 0) {
|
||||
if (entries_remaining_ <= 0) {
|
||||
// Finished looking at the last entry, now we're done.
|
||||
entries_remaining_ = -1;
|
||||
return false;
|
||||
}
|
||||
ASSERT(entries_remaining_ > 0);
|
||||
--entries_remaining_;
|
||||
cur_kind_and_flags_ = reader_.ReadByte();
|
||||
cur_start_pc_ += reader_.ReadSLEB128();
|
||||
|
@ -464,7 +465,10 @@ class BytecodeLocalVariablesIterator : ValueObject {
|
|||
return true;
|
||||
}
|
||||
|
||||
bool IsDone() const { return entries_remaining_ == 0; }
|
||||
// Returns true after iterator moved past the last entry and
|
||||
// MoveNext() returned false.
|
||||
bool IsDone() const { return entries_remaining_ < 0; }
|
||||
|
||||
intptr_t Kind() const { return cur_kind_and_flags_ & kKindMask; }
|
||||
bool IsScope() const { return Kind() == kScope; }
|
||||
bool IsVariableDeclaration() const { return Kind() == kVariableDeclaration; }
|
||||
|
|
Loading…
Reference in a new issue