Commit 792383e3 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Outline handling of postfix ops

This saves some binary size.

Change-Id: I64d20be63922ba0aab0b664fb30c3e2e023bb860
Reviewed-on: https://chromium-review.googlesource.com/c/1485841
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59826}
parent 75629d5f
......@@ -1054,6 +1054,8 @@ class ParserBase {
ExpressionT ParseAwaitExpression();
V8_INLINE ExpressionT ParseUnaryExpression();
V8_INLINE ExpressionT ParsePostfixExpression();
V8_NOINLINE ExpressionT ParsePostfixContinuation(ExpressionT expression,
int lhs_beg_pos);
V8_INLINE ExpressionT ParseLeftHandSideExpression();
ExpressionT ParseLeftHandSideContinuation(ExpressionT expression);
ExpressionT ParseMemberWithPresentNewPrefixesExpression();
......@@ -2993,7 +2995,17 @@ ParserBase<Impl>::ParsePostfixExpression() {
int lhs_beg_pos = peek_position();
ExpressionT expression = ParseLeftHandSideExpression();
if (!scanner()->HasLineTerminatorBeforeNext() && Token::IsCountOp(peek())) {
if (V8_LIKELY(!Token::IsCountOp(peek()) ||
scanner()->HasLineTerminatorBeforeNext())) {
return expression;
}
return ParsePostfixContinuation(expression, lhs_beg_pos);
}
template <typename Impl>
typename ParserBase<Impl>::ExpressionT
ParserBase<Impl>::ParsePostfixContinuation(ExpressionT expression,
int lhs_beg_pos) {
if (V8_UNLIKELY(!IsValidReferenceExpression(expression))) {
expression = RewriteInvalidReferenceExpression(
expression, lhs_beg_pos, end_position(),
......@@ -3004,13 +3016,8 @@ ParserBase<Impl>::ParsePostfixExpression() {
}
Token::Value next = Next();
expression =
factory()->NewCountOperation(next,
false /* postfix */,
expression,
return factory()->NewCountOperation(next, false /* postfix */, expression,
position());
}
return expression;
}
template <typename Impl>
......
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