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

Unified Diff: src/parsing/parser.cc

Issue 2161263003: [debug] use catch prediction flag for promise rejections. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 5 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: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 3cae66e2693f39c832686aadd81809b7ef8d56cc..8b69029972543e2e4c35bf2904474e4ee3af3fa3 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -2983,10 +2983,18 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
}
Token::Value tok = peek();
+ bool catch_for_promise_reject = false;
if (tok != Token::CATCH && tok != Token::FINALLY) {
- ReportMessage(MessageTemplate::kNoCatchOrFinally);
- *ok = false;
- return NULL;
+ if (allow_natives() && tok == Token::MOD) {
+ Consume(Token::MOD);
+ catch_for_promise_reject = true;
+ tok = peek();
+ DCHECK_EQ(Token::CATCH, tok);
Dan Ehrenberg 2016/07/21 21:07:33 Nit: I wonder if we should use CHECK here; if it w
+ } else {
+ ReportMessage(MessageTemplate::kNoCatchOrFinally);
+ *ok = false;
+ return NULL;
+ }
}
Scope* catch_scope = NULL;
@@ -3104,8 +3112,17 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
if (catch_block != NULL && finally_block != NULL) {
// If we have both, create an inner try/catch.
DCHECK(catch_scope != NULL && catch_variable != NULL);
- TryCatchStatement* statement = factory()->NewTryCatchStatement(
- try_block, catch_scope, catch_variable, catch_block, kNoSourcePosition);
+ TryCatchStatement* statement;
+ if (catch_for_promise_reject) {
+ statement = factory()->NewTryCatchStatementForPromiseReject(
+ try_block, catch_scope, catch_variable, catch_block,
+ kNoSourcePosition);
+ } else {
+ statement = factory()->NewTryCatchStatement(try_block, catch_scope,
+ catch_variable, catch_block,
+ kNoSourcePosition);
+ }
+
try_block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition);
try_block->statements()->Add(statement, zone());
catch_block = NULL; // Clear to indicate it's been handled.

Powered by Google App Engine
This is Rietveld 408576698