Skip to content

Commit 6db6a0c

Browse files
committed
[vm/bytecode] Capture :controller_stream variable in async* functions
Test: runtime/observatory/tests/service/async_star_step_out_test.dart Change-Id: If6dec1b5005b0736edaf85b974581f294e602f40 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114463 Reviewed-by: Régis Crelier <[email protected]>
1 parent b6897ea commit 6db6a0c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

pkg/kernel/lib/transformations/continuation.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class ContinuationVariables {
1616
static const awaitJumpVar = ':await_jump_var';
1717
static const awaitContextVar = ':await_ctx_var';
1818
static const asyncStackTraceVar = ':async_stack_trace';
19+
static const controllerStreamVar = ':controller_stream';
1920
static const exceptionParam = ':exception';
2021
static const stackTraceParam = ':stack_trace';
2122

@@ -919,7 +920,7 @@ class AsyncStarFunctionRewriter extends AsyncRewriterBase {
919920

920921
// dynamic :controller_stream;
921922
VariableDeclaration controllerStreamVariable =
922-
new VariableDeclaration(":controller_stream");
923+
new VariableDeclaration(ContinuationVariables.controllerStreamVar);
923924
statements.add(controllerStreamVariable);
924925

925926
setupAsyncContinuations(statements);

pkg/vm/lib/bytecode/local_vars.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,13 @@ class _ScopeBuilder extends RecursiveVisitor<Null> {
390390
_useVariable(_currentFrame.parent
391391
.getSyntheticVar(ContinuationVariables.awaitContextVar));
392392

393+
// Debugger looks for :controller_stream variable among captured
394+
// variables in a context, so make sure to capture it.
395+
if (_currentFrame.parent.dartAsyncMarker == AsyncMarker.AsyncStar) {
396+
_useVariable(_currentFrame.parent
397+
.getSyntheticVar(ContinuationVariables.controllerStreamVar));
398+
}
399+
393400
if (locals.options.causalAsyncStacks &&
394401
(_currentFrame.parent.dartAsyncMarker == AsyncMarker.Async ||
395402
_currentFrame.parent.dartAsyncMarker ==

0 commit comments

Comments
 (0)