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

[parser] Move Token::NEW parsing into the switch of ParsePrimaryExpression

All uses of ParseMemberExpression go through
ParseMemberWithNewPrefixesExpression, and ParseMemberExpression always starts
with ParsePrimaryExprssion, so we can simply move Token::NEW handling into
ParsePrimaryExpression. That avoids an unnecessary branch on the hot path.

Change-Id: I2bcce8e106c547c6d308ee6b0fce8747c7214886
Reviewed-on: https://chromium-review.googlesource.com/c/1485838Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59827}
parent 792383e3
......@@ -1059,7 +1059,6 @@ class ParserBase {
V8_INLINE ExpressionT ParseLeftHandSideExpression();
ExpressionT ParseLeftHandSideContinuation(ExpressionT expression);
ExpressionT ParseMemberWithPresentNewPrefixesExpression();
V8_INLINE ExpressionT ParseMemberWithNewPrefixesExpression();
ExpressionT ParseFunctionExpression();
V8_INLINE ExpressionT ParseMemberExpression();
V8_INLINE ExpressionT
......@@ -1705,6 +1704,9 @@ ParserBase<Impl>::ParsePrimaryExpression() {
}
switch (token) {
case Token::NEW:
return ParseMemberWithPresentNewPrefixesExpression();
case Token::THIS: {
Consume(Token::THIS);
return impl()->ThisExpression();
......@@ -3026,7 +3028,7 @@ ParserBase<Impl>::ParseLeftHandSideExpression() {
// LeftHandSideExpression ::
// (NewExpression | MemberExpression) ...
ExpressionT result = ParseMemberWithNewPrefixesExpression();
ExpressionT result = ParseMemberExpression();
if (!Token::IsPropertyOrCall(peek())) return result;
return ParseLeftHandSideContinuation(result);
}
......@@ -3196,7 +3198,7 @@ ParserBase<Impl>::ParseMemberWithPresentNewPrefixesExpression() {
result = ParseNewTargetExpression();
return ParseMemberExpressionContinuation(result);
} else {
result = ParseMemberWithNewPrefixesExpression();
result = ParseMemberExpression();
}
if (peek() == Token::LPAREN) {
// NewExpression with arguments.
......@@ -3219,13 +3221,6 @@ ParserBase<Impl>::ParseMemberWithPresentNewPrefixesExpression() {
return factory()->NewCallNew(result, args, new_pos);
}
template <typename Impl>
typename ParserBase<Impl>::ExpressionT
ParserBase<Impl>::ParseMemberWithNewPrefixesExpression() {
return peek() == Token::NEW ? ParseMemberWithPresentNewPrefixesExpression()
: ParseMemberExpression();
}
template <typename Impl>
typename ParserBase<Impl>::ExpressionT
ParserBase<Impl>::ParseFunctionExpression() {
......
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