[scanner] Try and recover some perf from launching nullish

Launching nullish behind a flag resulted in a small performance
regression in the adwords parsing benchmark. From local tests, doing a
little manual PGO seemed to improve performance slightly.

Parse.duration on this benchmark dropped from 1,639.188 ms to 1,535.312 ms

Bug: chromium:997652
Change-Id: I537985793cdf310a0dda5a69ded9f0ea2c0a7fb0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1773098
Commit-Queue: Joshua Litt <joshualitt@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63417}
This commit is contained in:
Joshua Litt 2019-08-27 08:21:20 -07:00 committed by Commit Bot
parent 0366533c1f
commit 6abfd167a1

View File

@ -365,11 +365,11 @@ V8_INLINE Token::Value Scanner::ScanSingleToken() {
case Token::CONDITIONAL:
// ? ?. ??
Advance();
if (allow_harmony_optional_chaining() && c0_ == '.') {
if (V8_UNLIKELY(allow_harmony_optional_chaining() && c0_ == '.')) {
Advance();
if (!IsDecimalDigit(c0_)) return Token::QUESTION_PERIOD;
PushBack('.');
} else if (allow_harmony_nullish() && c0_ == '?') {
} else if (V8_UNLIKELY(allow_harmony_nullish() && c0_ == '?')) {
return Select(Token::NULLISH);
}
return Token::CONDITIONAL;