Commit bb46aab5 authored by jameslahm's avatar jameslahm Committed by V8 LUCI CQ

[parser] Use cached ThisExpression in this.x

..., this.x(), this.?x and this?.x(). For common
case like these, it's not necessary to store the
source position for the ThisExpression. And we
could use the cached kNoSourcePosition ThisExpression
for these.

Bug: v8:10914
Change-Id: I02e2bc1633f6da036535d7a76bdabeac0d22f4d9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3585490Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: 王澳 <wangao.james@bytedance.com>
Cr-Commit-Position: refs/heads/main@{#79982}
parent ee6f81cb
......@@ -1948,6 +1948,11 @@ ParserBase<Impl>::ParsePrimaryExpression() {
case Token::THIS: {
Consume(Token::THIS);
// Not necessary for this.x, this.x(), this?.x and this?.x() to
// store the source position for ThisExpression.
if (peek() == Token::PERIOD || peek() == Token::QUESTION_PERIOD) {
return impl()->ThisExpression();
}
return impl()->NewThisExpression(beg_pos);
}
......
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