Skip to content

Commit 730d2c6

Browse files
alexmarkovcommit-bot@chromium.org
authored andcommitted
[vm/bytecode] Fix removal of empty scopes in local variable info
Even if a scope doesn't have variables, it may define a context level different from enclosing scope. As debugger needs to know context level at any point, bytecode generator should not elide such scopes. Change-Id: I2f97deae55285b758f91aee852338432dcddf373 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/109898 Reviewed-by: Régis Crelier <[email protected]> Reviewed-by: Ryan Macnak <[email protected]> Commit-Queue: Alexander Markov <[email protected]>
1 parent d3a09dd commit 730d2c6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/vm/lib/bytecode/local_variable_table.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Scope extends LocalVariableEntry {
5151
}
5252

5353
Scope.readContents(BufferedReader reader, int startPC) : super(startPC) {
54-
endPC = startPC = reader.readPackedUInt30();
54+
endPC = startPC + reader.readPackedUInt30();
5555
contextLevel = reader.readSLEB128();
5656
position = reader.readPackedUInt30() - 1;
5757
endPosition = reader.readPackedUInt30() - 1;
@@ -152,7 +152,9 @@ class LocalVariableTable {
152152
final scope = activeScopes.removeLast();
153153
scope.endPC = pc;
154154
scope.endPosition = endPosition;
155-
if (scope.variables.isEmpty) {
155+
if (scope.variables.isEmpty &&
156+
activeScopes.isNotEmpty &&
157+
scope.contextLevel == activeScopes.last.contextLevel) {
156158
scopes.remove(scope);
157159
}
158160
}

0 commit comments

Comments
 (0)