Index: runtime/vm/kernel_binary_flowgraph.cc |
diff --git a/runtime/vm/kernel_binary_flowgraph.cc b/runtime/vm/kernel_binary_flowgraph.cc |
index 6d0725dce7990bae6ea00ea0de7bee9da9899048..37f596c4fa2535ec5c15ee3e6198bac1a1ef6388 100644 |
--- a/runtime/vm/kernel_binary_flowgraph.cc |
+++ b/runtime/vm/kernel_binary_flowgraph.cc |
@@ -3287,6 +3287,32 @@ FlowGraph* StreamingFlowGraphBuilder::BuildGraphOfFunction( |
SkipDartType(); // read return type. |
+ if (FLAG_causal_async_stacks && |
+ (dart_function.IsAsyncFunction() || dart_function.IsAsyncGenerator())) { |
+ LocalScope* scope = parsed_function()->node_sequence()->scope(); |
+ // :async_stack_trace = _asyncStackTraceHelper(:async_op); |
+ const dart::Library& async_lib = |
+ dart::Library::Handle(dart::Library::AsyncLibrary()); |
+ const Function& target = Function::ZoneHandle( |
+ Z, |
+ async_lib.LookupFunctionAllowPrivate(Symbols::AsyncStackTraceHelper())); |
+ ASSERT(!target.IsNull()); |
+ |
+ // TODO(johnmccutchan): Why does this have the null value? |
+ LocalVariable* async_op = |
+ scope->child()->LookupVariable(Symbols::AsyncOperation(), false); |
+ ASSERT(async_op != NULL); |
+ ASSERT(async_op->is_captured()); |
+ body += LoadLocal(async_op); |
+ body += PushArgument(); |
+ body += StaticCall(TokenPosition::kNoSource, target, 1); |
+ LocalVariable* async_stack_trace_var = |
+ scope->LookupVariable(Symbols::AsyncStackTraceVar(), false); |
+ ASSERT(async_stack_trace_var != NULL); |
+ body += StoreLocal(TokenPosition::kNoSource, async_stack_trace_var); |
+ body += Drop(); |
+ } |
+ |
bool has_body = ReadTag() == kSomething; // read first part of body. |
if (dart_function.is_native()) { |