Setup local var descriptors in kernel mode.
Closes https://github.com/dart-lang/sdk/issues/28054
R=kmillikin@google.com
Review-Url: https://codereview.chromium.org/2589733002 .
diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
index 1b22da2..fee4b89 100644
--- a/runtime/vm/compiler.cc
+++ b/runtime/vm/compiler.cc
@@ -1593,8 +1593,12 @@
// if state changed while compiling in background.
LongJumpScope jump;
if (setjmp(*jump.Set()) == 0) {
- Parser::ParseFunction(parsed_function);
- parsed_function->AllocateVariables();
+ if (function.kernel_function() == NULL) {
+ Parser::ParseFunction(parsed_function);
+ parsed_function->AllocateVariables();
+ } else {
+ parsed_function->EnsureKernelScopes();
+ }
const LocalVarDescriptors& var_descs = LocalVarDescriptors::Handle(
parsed_function->node_sequence()->scope()->GetVarDescriptors(function));
ASSERT(!var_descs.IsNull());
diff --git a/runtime/vm/kernel_to_il.cc b/runtime/vm/kernel_to_il.cc
index e5d75e7..98f83f8 100644
--- a/runtime/vm/kernel_to_il.cc
+++ b/runtime/vm/kernel_to_il.cc
@@ -662,7 +662,7 @@
node->body()->AcceptStatementVisitor(this);
}
- // Ensure that :await_jump_var and :await_ctx_var are captured.
+ // Ensure that :await_jump_var, :await_ctx_var and :async_op are captured.
if (node->async_marker() == FunctionNode::kSyncYielding) {
{
LocalVariable* temp = NULL;
@@ -676,6 +676,13 @@
(depth_.function_ == 0) ? &result_->yield_context_variable : &temp,
Symbols::AwaitContextVar());
}
+ {
+ LocalVariable* temp =
+ scope_->LookupVariable(Symbols::AsyncOperation(), true);
+ if (temp != NULL) {
+ scope_->CaptureVariable(temp);
+ }
+ }
}
}
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index bd3efd6..c438d9f 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -13822,9 +13822,6 @@
if (v.IsNull()) {
ASSERT(!is_optimized());
const Function& f = Function::Handle(function());
- if (f.kernel_function() != NULL) {
- return v.raw();
- }
ASSERT(!f.IsIrregexpFunction()); // Not yet implemented.
Compiler::ComputeLocalVarDescriptors(*this);
}