Commit e08d944b authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Remove unnecessary RETURN_IF* from ParseMember*

Since tokens turn illegal automatically upon failure, we can delay checking in
places where we'll return upon illegal token anyway. We still need checks
before uses of a possible invalid expression (nullptr in parser), so keep those
checks for now; possibly pushing a previously higher check to right before the
dereference.

Bug: v8:8363 ,v8:7926

Change-Id: Ia402fc83c15f4c3258a335614b9213f8211a3c53
Reviewed-on: https://chromium-review.googlesource.com/c/1299081Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56985}
parent ff6138ad
......@@ -3426,17 +3426,13 @@ ParserBase<Impl>::ParseMemberExpression() {
ExpressionT result;
if (peek() == Token::FUNCTION) {
result = ParseFunctionExpression();
RETURN_IF_PARSE_ERROR;
} else if (peek() == Token::SUPER) {
const bool is_new = false;
result = ParseSuperExpression(is_new);
RETURN_IF_PARSE_ERROR;
} else if (allow_harmony_dynamic_import() && peek() == Token::IMPORT) {
result = ParseImportExpressions();
RETURN_IF_PARSE_ERROR;
} else {
result = ParsePrimaryExpression();
RETURN_IF_PARSE_ERROR;
}
return ParseMemberExpressionContinuation(result);
......@@ -3553,18 +3549,17 @@ ParserBase<Impl>::DoParseMemberExpressionContinuation(ExpressionT expression) {
Consume(Token::LBRACK);
int pos = position();
ExpressionT index = ParseExpressionCoverGrammar(true);
// TODO(verwaest): Remove once we have FailureExpression.
RETURN_IF_PARSE_ERROR;
expression = factory()->NewProperty(expression, index, pos);
impl()->PushPropertyName(index);
Expect(Token::RBRACK);
RETURN_IF_PARSE_ERROR;
break;
}
case Token::PERIOD: {
Consume(Token::PERIOD);
int pos = peek_position();
ExpressionT key = ParseIdentifierNameOrPrivateName();
RETURN_IF_PARSE_ERROR;
expression = factory()->NewProperty(expression, key, pos);
break;
}
......@@ -3576,6 +3571,8 @@ ParserBase<Impl>::DoParseMemberExpressionContinuation(ExpressionT expression) {
pos = position();
} else {
pos = peek_position();
// TODO(verwaest): Remove once we have FailureExpression.
RETURN_IF_PARSE_ERROR;
if (expression->IsFunctionLiteral()) {
// If the tag function looks like an IIFE, set_parenthesized() to
// force eager compilation.
......@@ -3583,7 +3580,6 @@ ParserBase<Impl>::DoParseMemberExpressionContinuation(ExpressionT expression) {
}
}
expression = ParseTemplateLiteral(expression, pos, true);
RETURN_IF_PARSE_ERROR;
break;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment