From bbc68d41103498b7cd311cfc159998acc40a4c1a Mon Sep 17 00:00:00 2001 From: gsathya Date: Wed, 14 Dec 2016 13:03:47 -0800 Subject: [PATCH] [parser] remove %catch parsing Promise catch prediction no longer has to be threaded through the parser since the code using %catch has been moved to TF codestubs. This is currently dead code. BUG=v8:5343,v8:5741 Review-Url: https://codereview.chromium.org/2575133002 Cr-Commit-Position: refs/heads/master@{#41701} --- src/ast/ast.h | 9 --------- src/ast/prettyprinter.cc | 7 ++++--- src/parsing/parser-base.h | 3 --- src/parsing/parser.cc | 12 +++--------- 4 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/ast/ast.h b/src/ast/ast.h index d60cee90a0..c518248c28 100644 --- a/src/ast/ast.h +++ b/src/ast/ast.h @@ -3237,15 +3237,6 @@ class AstNodeFactory final BASE_EMBEDDED { try_block, scope, variable, catch_block, HandlerTable::UNCAUGHT, pos); } - TryCatchStatement* NewTryCatchStatementForPromiseReject(Block* try_block, - Scope* scope, - Variable* variable, - Block* catch_block, - int pos) { - return new (zone_) TryCatchStatement( - try_block, scope, variable, catch_block, HandlerTable::PROMISE, pos); - } - TryCatchStatement* NewTryCatchStatementForDesugaring(Block* try_block, Scope* scope, Variable* variable, diff --git a/src/ast/prettyprinter.cc b/src/ast/prettyprinter.cc index 2f939554ab..59690a856b 100644 --- a/src/ast/prettyprinter.cc +++ b/src/ast/prettyprinter.cc @@ -879,15 +879,16 @@ void AstPrinter::PrintTryStatement(TryStatement* node) { case HandlerTable::CAUGHT: prediction = "CAUGHT"; break; - case HandlerTable::PROMISE: - prediction = "PROMISE"; - break; case HandlerTable::DESUGARING: prediction = "DESUGARING"; break; case HandlerTable::ASYNC_AWAIT: prediction = "ASYNC_AWAIT"; break; + case HandlerTable::PROMISE: + // Catch prediction resulting in promise rejections aren't + // parsed by the parser. + UNREACHABLE(); } Print(" %s\n", prediction); } diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h index 3efb207c1f..ba89162129 100644 --- a/src/parsing/parser-base.h +++ b/src/parsing/parser-base.h @@ -642,7 +642,6 @@ class ParserBase { scope(nullptr), init_block(parser->impl()->NullBlock()), inner_block(parser->impl()->NullBlock()), - for_promise_reject(false), bound_names(1, parser->zone()), tail_call_expressions(parser->zone()) {} IdentifierT name; @@ -651,7 +650,6 @@ class ParserBase { Scope* scope; BlockT init_block; BlockT inner_block; - bool for_promise_reject; ZoneList bound_names; TailCallExpressionList tail_call_expressions; }; @@ -5121,7 +5119,6 @@ typename ParserBase::StatementT ParserBase::ParseTryStatement( } CatchInfo catch_info(this); - catch_info.for_promise_reject = allow_natives() && Check(Token::MOD); if (peek() != Token::CATCH && peek() != Token::FINALLY) { ReportMessage(MessageTemplate::kNoCatchOrFinally); diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc index dffad26ecb..1386611862 100644 --- a/src/parsing/parser.cc +++ b/src/parsing/parser.cc @@ -1814,15 +1814,9 @@ Statement* Parser::RewriteTryStatement(Block* try_block, Block* catch_block, DCHECK_NOT_NULL(catch_info.scope); DCHECK_NOT_NULL(catch_info.variable); TryCatchStatement* statement; - if (catch_info.for_promise_reject) { - statement = factory()->NewTryCatchStatementForPromiseReject( - try_block, catch_info.scope, catch_info.variable, catch_block, - kNoSourcePosition); - } else { - statement = factory()->NewTryCatchStatement( - try_block, catch_info.scope, catch_info.variable, catch_block, - kNoSourcePosition); - } + statement = factory()->NewTryCatchStatement(try_block, catch_info.scope, + catch_info.variable, + catch_block, kNoSourcePosition); try_block = factory()->NewBlock(nullptr, 1, false, kNoSourcePosition); try_block->statements()->Add(statement, zone());