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

Unified Diff: runtime/vm/compiler.cc

Issue 2692803006: Track the 'awaiter return' call stack use it to detect uncaught exceptions in async functions (Closed)
Patch Set: port to other architectures 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/compiler.cc
diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
index fae6a677ded1d9d3f0458006dd78f5b924861b16..940b18d6ed32f9a7c1d8513201e58fcaf6a9d8c4 100644
--- a/runtime/vm/compiler.cc
+++ b/runtime/vm/compiler.cc
@@ -543,6 +543,31 @@ void CompileParsedFunctionHelper::FinalizeCompilation(
Code::Handle(Code::FinalizeCode(function, assembler, optimized()));
code.set_is_optimized(optimized());
code.set_owner(function);
+#if !defined(PRODUCT)
rmacnak 2017/02/23 17:50:56 if (FLAG_support_debugger)
Cutch 2017/02/24 20:19:21 Done.
+ ZoneGrowableArray<TokenPosition>* await_token_positions =
+ flow_graph->await_token_positions();
+ if (await_token_positions != NULL) {
+ Smi& token_pos_value = Smi::Handle(zone);
+ if (await_token_positions->length() > 0) {
+ const Array& await_to_token_map = Array::Handle(
+ zone, Array::New(await_token_positions->length(), Heap::kOld));
+ ASSERT(!await_to_token_map.IsNull());
+ for (intptr_t i = 0; i < await_token_positions->length(); i++) {
+ TokenPosition token_pos = await_token_positions->At(i).FromSynthetic();
+ if (!token_pos.IsReal()) {
+ // Some async machinary uses sentinel values. Map them to
+ // no source position.
+ token_pos_value = Smi::New(TokenPosition::kNoSourcePos);
+ } else {
+ token_pos_value = Smi::New(token_pos.value());
+ }
+ await_to_token_map.SetAt(i, token_pos_value);
+ }
+ code.SetAwaitTokenPositions(await_to_token_map);
+ }
+ }
+#endif // !defined(PRODUCT)
+
if (!function.IsOptimizable()) {
// A function with huge unoptimized code can become non-optimizable
// after generating unoptimized code.

Powered by Google App Engine
This is Rietveld 408576698