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

Unified Diff: src/ast/ast-numbering.cc

Issue 2276243002: Mark await expressions as caught or uncaught (Closed)
Patch Set: Revert "Tests for caught exception" Created 4 years, 3 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
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/prettyprinter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast-numbering.cc
diff --git a/src/ast/ast-numbering.cc b/src/ast/ast-numbering.cc
index 0785d5a42d529a481d215834b05ccbfbd9d6824c..6de950161867257d0006407550fab84c35e6849a 100644
--- a/src/ast/ast-numbering.cc
+++ b/src/ast/ast-numbering.cc
@@ -249,6 +249,27 @@ void AstNumberingVisitor::VisitCallRuntime(CallRuntime* node) {
IncrementNodeCount();
node->set_base_id(ReserveIdRange(CallRuntime::num_ids()));
VisitArguments(node->arguments());
+ // To support catch prediction within async/await:
+ //
+ // The AstNumberingVisitor is when catch prediction currently occurs, and it
+ // is the only common point that has access to this information. The parser
+ // just doesn't know yet. Take the following two cases of catch prediction:
+ //
+ // try { await fn(); } catch (e) { }
+ // try { await fn(); } finally { }
+ //
+ // When parsing the await that we want to mark as caught or uncaught, it's
+ // not yet known whether it will be followed by a 'finally' or a 'catch.
+ // The AstNumberingVisitor is what learns whether it is caught. To make
+ // the information available later to the runtime, the AstNumberingVisitor
+ // has to stash it somewhere. Changing the runtime function into another
+ // one in ast-numbering seemed like a simple and straightforward solution to
+ // that problem.
+ if (node->is_jsruntime() &&
+ node->context_index() == Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX &&
+ catch_prediction_ == HandlerTable::ASYNC_AWAIT) {
+ node->set_context_index(Context::ASYNC_FUNCTION_AWAIT_UNCAUGHT_INDEX);
+ }
}
« no previous file with comments | « src/ast/ast.h ('k') | src/ast/prettyprinter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698