Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1081)

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 2692803006: Track the 'awaiter return' call stack use it to detect uncaught exceptions in async functions (Closed)
Patch Set: rmacnak review Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/flow_graph_builder.cc
diff --git a/runtime/vm/flow_graph_builder.cc b/runtime/vm/flow_graph_builder.cc
index b5061df62c0c177a370d615ce6f4d2f04399b615..69ec40a76b031ff58441554df61757fb9857cc01 100644
--- a/runtime/vm/flow_graph_builder.cc
+++ b/runtime/vm/flow_graph_builder.cc
@@ -323,7 +323,8 @@ FlowGraphBuilder::FlowGraphBuilder(
nesting_stack_(NULL),
osr_id_(osr_id),
jump_count_(0),
- await_joins_(new (Z) ZoneGrowableArray<JoinEntryInstr*>()) {}
+ await_joins_(new (Z) ZoneGrowableArray<JoinEntryInstr*>()),
+ await_token_positions_(new (Z) ZoneGrowableArray<TokenPosition>()) {}
void FlowGraphBuilder::AddCatchEntry(CatchBlockEntryInstr* entry) {
@@ -2186,6 +2187,8 @@ void EffectGraphVisitor::VisitAwaitMarkerNode(AwaitMarkerNode* node) {
Value* jump_val = Bind(new (Z) ConstantInstr(
Smi::ZoneHandle(Z, Smi::New(jump_count)), node->token_pos()));
Do(BuildStoreLocal(*jump_var, jump_val, node->token_pos()));
+ // Add a mapping from jump_count -> token_position.
+ owner()->AppendAwaitTokenPosition(node->token_pos());
// Save the current context for resuming.
BuildSaveContext(*ctx_var, node->token_pos());
}
@@ -4078,6 +4081,7 @@ void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) {
ASSERT(!catch_block->stacktrace_var().is_captured());
CatchBlockEntryInstr* catch_entry = new (Z) CatchBlockEntryInstr(
+ catch_block->token_pos(), (node->token_pos() == TokenPosition::kNoSource),
owner()->AllocateBlockId(), catch_handler_index, owner()->graph_entry(),
catch_block->handler_types(), try_handler_index,
catch_block->exception_var(), catch_block->stacktrace_var(),
@@ -4120,6 +4124,8 @@ void EffectGraphVisitor::VisitTryCatchNode(TryCatchNode* node) {
const Array& types = Array::ZoneHandle(Z, Array::New(1, Heap::kOld));
types.SetAt(0, Object::dynamic_type());
CatchBlockEntryInstr* finally_entry = new (Z) CatchBlockEntryInstr(
+ finally_block->token_pos(),
+ true, // this is not a catch block from user code.
owner()->AllocateBlockId(), original_handler_index,
owner()->graph_entry(), types, catch_handler_index,
catch_block->exception_var(), catch_block->stacktrace_var(),
@@ -4367,10 +4373,16 @@ FlowGraph* FlowGraphBuilder::BuildGraph() {
FlowGraph* graph =
new (Z) FlowGraph(parsed_function(), graph_entry_, last_used_block_id_);
+ graph->set_await_token_positions(await_token_positions_);
return graph;
}
+void FlowGraphBuilder::AppendAwaitTokenPosition(TokenPosition token_pos) {
+ await_token_positions_->Add(token_pos);
+}
+
+
void FlowGraphBuilder::PruneUnreachable() {
ASSERT(osr_id_ != Compiler::kNoOSRDeoptId);
BitVector* block_marks = new (Z) BitVector(Z, last_used_block_id_ + 1);

Powered by Google App Engine
This is Rietveld 408576698