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

Unified Diff: src/parsing/parser-base.h

Issue 2372513003: [es8] Remove syntactic tail calls support. (Closed)
Patch Set: 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/parsing/parser.cc ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser-base.h
diff --git a/src/parsing/parser-base.h b/src/parsing/parser-base.h
index ff8f19be381dba783d57ecb31525e2e1b6d97e54..062679d298f47bbd9705be8f437d044128f6343a 100644
--- a/src/parsing/parser-base.h
+++ b/src/parsing/parser-base.h
@@ -340,14 +340,6 @@ class ParserBase {
expressions_.Add(expr, zone_);
}
- void AddExplicitTailCall(ExpressionT expr, const Scanner::Location& loc) {
- if (!has_explicit_tail_calls()) {
- loc_ = loc;
- has_explicit_tail_calls_ = true;
- }
- expressions_.Add(expr, zone_);
- }
-
void Append(const TailCallExpressionList& other) {
if (!has_explicit_tail_calls()) {
loc_ = other.loc_;
@@ -437,14 +429,6 @@ class ParserBase {
tail_call_expressions_.AddImplicitTailCall(expression);
}
}
- void AddExplicitTailCallExpression(ExpressionT expression,
- const Scanner::Location& loc) {
- DCHECK(expression->IsCall());
- if (return_expr_context() ==
- ReturnExprContext::kInsideValidReturnStatement) {
- tail_call_expressions_.AddExplicitTailCall(expression, loc);
- }
- }
ZoneList<typename ExpressionClassifier::Error>* GetReportedErrorList() {
return &reported_errors_;
@@ -1057,14 +1041,6 @@ class ParserBase {
}
}
- void CheckNoTailCallExpressions(bool* ok) {
- if (FLAG_harmony_explicit_tailcalls &&
- classifier()->has_tail_call_expression()) {
- ReportClassifierError(classifier()->tail_call_expression_error());
- *ok = false;
- }
- }
-
void ExpressionUnexpectedToken() {
MessageTemplate::Template message = MessageTemplate::kUnexpectedToken;
const char* arg;
@@ -1175,7 +1151,6 @@ class ParserBase {
ExpressionT ParseAssignmentExpression(bool accept_IN, bool* ok);
ExpressionT ParseYieldExpression(bool accept_IN, bool* ok);
- ExpressionT ParseTailCallExpression(bool* ok);
ExpressionT ParseConditionalExpression(bool accept_IN, bool* ok);
ExpressionT ParseBinaryExpression(int prec, bool accept_IN, bool* ok);
ExpressionT ParseUnaryExpression(bool* ok);
@@ -1857,7 +1832,6 @@ ParserBase<Impl>::ParseExpressionCoverGrammar(bool accept_IN, bool* ok) {
ExpressionT result = impl()->EmptyExpression();
while (true) {
- CheckNoTailCallExpressions(CHECK_OK);
int comma_pos = position();
ExpressionClassifier binding_classifier(this);
ExpressionT right;
@@ -1926,7 +1900,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral(
Consume(Token::ELLIPSIS);
int expr_pos = peek_position();
ExpressionT argument = ParseAssignmentExpression(true, CHECK_OK);
- CheckNoTailCallExpressions(CHECK_OK);
elem = factory()->NewSpread(argument, start_pos, expr_pos);
if (first_spread_index < 0) {
@@ -1950,7 +1923,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseArrayLiteral(
} else {
int beg_pos = peek_position();
elem = ParseAssignmentExpression(true, CHECK_OK);
- CheckNoTailCallExpressions(CHECK_OK);
CheckDestructuringElement(elem, beg_pos, scanner()->location().end_pos);
}
values->Add(elem, zone_);
@@ -2535,7 +2507,6 @@ typename ParserBase<Impl>::ExpressionListT ParserBase<Impl>::ParseArguments(
ExpressionT argument =
ParseAssignmentExpression(true, CHECK_OK_CUSTOM(NullExpressionList));
- CheckNoTailCallExpressions(CHECK_OK_CUSTOM(NullExpressionList));
if (!maybe_arrow) {
impl()->RewriteNonPattern(CHECK_OK_CUSTOM(NullExpressionList));
}
@@ -2727,8 +2698,6 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
impl()->Accumulate(productions, false);
}
- CheckNoTailCallExpressions(CHECK_OK);
-
if (is_destructuring_assignment) {
ValidateAssignmentPattern(CHECK_OK);
} else {
@@ -2750,7 +2719,6 @@ ParserBase<Impl>::ParseAssignmentExpression(bool accept_IN, bool* ok) {
ExpressionClassifier rhs_classifier(this);
ExpressionT right = ParseAssignmentExpression(accept_IN, CHECK_OK);
- CheckNoTailCallExpressions(CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
impl()->AccumulateFormalParameterContainmentErrors();
@@ -2847,75 +2815,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseYieldExpression(
return yield;
}
-template <typename Impl>
-typename ParserBase<Impl>::ExpressionT
-ParserBase<Impl>::ParseTailCallExpression(bool* ok) {
- // TailCallExpression::
- // 'continue' MemberExpression Arguments
- // 'continue' CallExpression Arguments
- // 'continue' MemberExpression TemplateLiteral
- // 'continue' CallExpression TemplateLiteral
- Expect(Token::CONTINUE, CHECK_OK);
- int pos = position();
- int sub_expression_pos = peek_position();
- ExpressionT expression = ParseLeftHandSideExpression(CHECK_OK);
- CheckNoTailCallExpressions(CHECK_OK);
-
- Scanner::Location loc(pos, scanner()->location().end_pos);
-
- if (!expression->IsCall()) {
- Scanner::Location sub_loc(sub_expression_pos, loc.end_pos);
- impl()->ReportMessageAt(sub_loc,
- MessageTemplate::kUnexpectedInsideTailCall);
- *ok = false;
- return impl()->EmptyExpression();
- }
- if (impl()->IsDirectEvalCall(expression)) {
- Scanner::Location sub_loc(sub_expression_pos, loc.end_pos);
- impl()->ReportMessageAt(sub_loc,
- MessageTemplate::kUnexpectedTailCallOfEval);
- *ok = false;
- return impl()->EmptyExpression();
- }
- if (!is_strict(language_mode())) {
- impl()->ReportMessageAt(loc, MessageTemplate::kUnexpectedSloppyTailCall);
- *ok = false;
- return impl()->EmptyExpression();
- }
- if (is_resumable()) {
- Scanner::Location sub_loc(sub_expression_pos, loc.end_pos);
- impl()->ReportMessageAt(sub_loc, MessageTemplate::kUnexpectedTailCall);
- *ok = false;
- return impl()->EmptyExpression();
- }
- ReturnExprContext return_expr_context =
- function_state_->return_expr_context();
- if (return_expr_context != ReturnExprContext::kInsideValidReturnStatement) {
- MessageTemplate::Template msg = MessageTemplate::kNone;
- switch (return_expr_context) {
- case ReturnExprContext::kInsideValidReturnStatement:
- UNREACHABLE();
- return impl()->EmptyExpression();
- case ReturnExprContext::kInsideValidBlock:
- msg = MessageTemplate::kUnexpectedTailCall;
- break;
- case ReturnExprContext::kInsideTryBlock:
- msg = MessageTemplate::kUnexpectedTailCallInTryBlock;
- break;
- case ReturnExprContext::kInsideForInOfBody:
- msg = MessageTemplate::kUnexpectedTailCallInForInOf;
- break;
- }
- impl()->ReportMessageAt(loc, msg);
- *ok = false;
- return impl()->EmptyExpression();
- }
- classifier()->RecordTailCallExpressionError(
- loc, MessageTemplate::kUnexpectedTailCall);
- function_state_->AddExplicitTailCallExpression(expression, loc);
- return expression;
-}
-
// Precedence = 3
template <typename Impl>
typename ParserBase<Impl>::ExpressionT
@@ -2929,7 +2828,6 @@ ParserBase<Impl>::ParseConditionalExpression(bool accept_IN,
// We start using the binary expression parser for prec >= 4 only!
ExpressionT expression = ParseBinaryExpression(4, accept_IN, CHECK_OK);
if (peek() != Token::CONDITIONAL) return expression;
- CheckNoTailCallExpressions(CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
BindingPatternUnexpectedToken();
ArrowFormalParametersUnexpectedToken();
@@ -2955,7 +2853,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBinaryExpression(
for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) {
// prec1 >= 4
while (Precedence(peek(), accept_IN) == prec1) {
- CheckNoTailCallExpressions(CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
BindingPatternUnexpectedToken();
ArrowFormalParametersUnexpectedToken();
@@ -2965,9 +2862,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseBinaryExpression(
const bool is_right_associative = op == Token::EXP;
const int next_prec = is_right_associative ? prec1 : prec1 + 1;
ExpressionT y = ParseBinaryExpression(next_prec, accept_IN, CHECK_OK);
- if (op != Token::OR && op != Token::AND) {
- CheckNoTailCallExpressions(CHECK_OK);
- }
impl()->RewriteNonPattern(CHECK_OK);
if (impl()->ShortcutNumericLiteralBinaryExpression(&x, y, op, pos)) {
@@ -3025,7 +2919,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression(
op = Next();
int pos = position();
ExpressionT expression = ParseUnaryExpression(CHECK_OK);
- CheckNoTailCallExpressions(CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
if (op == Token::DELETE && is_strict(language_mode())) {
@@ -3051,7 +2944,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseUnaryExpression(
op = Next();
int beg_pos = peek_position();
ExpressionT expression = ParseUnaryExpression(CHECK_OK);
- CheckNoTailCallExpressions(CHECK_OK);
expression = CheckAndRewriteReferenceExpression(
expression, beg_pos, scanner()->location().end_pos,
MessageTemplate::kInvalidLhsInPrefixOp, CHECK_OK);
@@ -3089,7 +2981,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParsePostfixExpression(
ExpressionT expression = ParseLeftHandSideExpression(CHECK_OK);
if (!scanner()->HasAnyLineTerminatorBeforeNext() &&
Token::IsCountOp(peek())) {
- CheckNoTailCallExpressions(CHECK_OK);
BindingPatternUnexpectedToken();
ArrowFormalParametersUnexpectedToken();
@@ -3115,10 +3006,6 @@ ParserBase<Impl>::ParseLeftHandSideExpression(bool* ok) {
// LeftHandSideExpression ::
// (NewExpression | MemberExpression) ...
- if (FLAG_harmony_explicit_tailcalls && peek() == Token::CONTINUE) {
- return ParseTailCallExpression(ok);
- }
-
bool is_async = false;
ExpressionT result =
ParseMemberWithNewPrefixesExpression(&is_async, CHECK_OK);
@@ -3126,7 +3013,6 @@ ParserBase<Impl>::ParseLeftHandSideExpression(bool* ok) {
while (true) {
switch (peek()) {
case Token::LBRACK: {
- CheckNoTailCallExpressions(CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
BindingPatternUnexpectedToken();
ArrowFormalParametersUnexpectedToken();
@@ -3140,7 +3026,6 @@ ParserBase<Impl>::ParseLeftHandSideExpression(bool* ok) {
}
case Token::LPAREN: {
- CheckNoTailCallExpressions(CHECK_OK);
int pos;
impl()->RewriteNonPattern(CHECK_OK);
BindingPatternUnexpectedToken();
@@ -3228,7 +3113,6 @@ ParserBase<Impl>::ParseLeftHandSideExpression(bool* ok) {
}
case Token::PERIOD: {
- CheckNoTailCallExpressions(CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
BindingPatternUnexpectedToken();
ArrowFormalParametersUnexpectedToken();
@@ -3243,7 +3127,6 @@ ParserBase<Impl>::ParseLeftHandSideExpression(bool* ok) {
case Token::TEMPLATE_SPAN:
case Token::TEMPLATE_TAIL: {
- CheckNoTailCallExpressions(CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
BindingPatternUnexpectedToken();
ArrowFormalParametersUnexpectedToken();
@@ -4071,7 +3954,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseTemplateLiteral(
int expr_pos = peek_position();
ExpressionT expression = ParseExpressionCoverGrammar(true, CHECK_OK);
- CheckNoTailCallExpressions(CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK);
impl()->AddTemplateExpression(&ts, expression);
@@ -4990,16 +4872,6 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseTryStatement(
DCHECK(peek() == Token::FINALLY || !impl()->IsNullStatement(catch_block));
if (Check(Token::FINALLY)) {
finally_block = ParseBlock(nullptr, CHECK_OK);
-
- if (FLAG_harmony_explicit_tailcalls &&
- catch_info.tail_call_expressions.has_explicit_tail_calls()) {
- // TODO(ishell): update chapter number.
- // ES8 XX.YY.ZZ
- impl()->ReportMessageAt(catch_info.tail_call_expressions.location(),
- MessageTemplate::kUnexpectedTailCallInCatchBlock);
- *ok = false;
- return impl()->NullStatement();
- }
}
return impl()->RewriteTryStatement(try_block, catch_block, finally_block,
« no previous file with comments | « src/parsing/parser.cc ('k') | src/parsing/preparser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698