diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/v8/src/parsing | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/v8/src/parsing')
-rw-r--r-- | chromium/v8/src/parsing/parser-base.h | 26 | ||||
-rw-r--r-- | chromium/v8/src/parsing/parser.cc | 10 | ||||
-rw-r--r-- | chromium/v8/src/parsing/parser.h | 10 | ||||
-rw-r--r-- | chromium/v8/src/parsing/parsing.cc | 24 | ||||
-rw-r--r-- | chromium/v8/src/parsing/parsing.h | 29 | ||||
-rw-r--r-- | chromium/v8/src/parsing/pending-compilation-error-handler.cc | 12 | ||||
-rw-r--r-- | chromium/v8/src/parsing/pending-compilation-error-handler.h | 13 | ||||
-rw-r--r-- | chromium/v8/src/parsing/preparse-data-impl.h | 2 | ||||
-rw-r--r-- | chromium/v8/src/parsing/preparser.cc | 4 | ||||
-rw-r--r-- | chromium/v8/src/parsing/preparser.h | 4 | ||||
-rw-r--r-- | chromium/v8/src/parsing/scanner-inl.h | 2 | ||||
-rw-r--r-- | chromium/v8/src/parsing/scanner.cc | 37 | ||||
-rw-r--r-- | chromium/v8/src/parsing/scanner.h | 14 | ||||
-rw-r--r-- | chromium/v8/src/parsing/token.h | 4 |
14 files changed, 115 insertions, 76 deletions
diff --git a/chromium/v8/src/parsing/parser-base.h b/chromium/v8/src/parsing/parser-base.h index 903ce2bb7f8..3519599a882 100644 --- a/chromium/v8/src/parsing/parser-base.h +++ b/chromium/v8/src/parsing/parser-base.h @@ -786,7 +786,7 @@ class ParserBase { // should automatically use scope() as parent, and be fine with // NewScope(ScopeType) above. Scope* NewScopeWithParent(Scope* parent, ScopeType scope_type) const { - // Must always use the specific constructors for the blacklisted scope + // Must always use the specific constructors for the blocklisted scope // types. DCHECK_NE(FUNCTION_SCOPE, scope_type); DCHECK_NE(SCRIPT_SCOPE, scope_type); @@ -2755,8 +2755,7 @@ ParserBase<Impl>::ParseAssignmentExpressionCoverGrammar() { Token::Value op = peek(); if (!Token::IsArrowOrAssignmentOp(op)) return expression; - if ((op == Token::ASSIGN_NULLISH || op == Token::ASSIGN_OR || - op == Token::ASSIGN_AND) && + if (Token::IsLogicalAssignmentOp(op) && !flags().allow_harmony_logical_assignment()) { return expression; } @@ -2830,13 +2829,8 @@ ParserBase<Impl>::ParseAssignmentExpressionCoverGrammar() { ExpressionT right = ParseAssignmentExpression(); - if (op == Token::ASSIGN) { - // We try to estimate the set of properties set by constructors. We define a - // new property whenever there is an assignment to a property of 'this'. We - // should probably only add properties if we haven't seen them before. - // Otherwise we'll probably overestimate the number of properties. - if (impl()->IsThisProperty(expression)) function_state_->AddProperty(); - + // Anonymous function name inference applies to =, ||=, &&=, and ??=. + if (op == Token::ASSIGN || Token::IsLogicalAssignmentOp(op)) { impl()->CheckAssigningFunctionLiteralToProperty(expression, right); // Check if the right hand side is a call to avoid inferring a @@ -2850,10 +2844,20 @@ ParserBase<Impl>::ParseAssignmentExpressionCoverGrammar() { impl()->SetFunctionNameFromIdentifierRef(right, expression); } else { + fni_.RemoveLastFunction(); + } + + if (op == Token::ASSIGN) { + // We try to estimate the set of properties set by constructors. We define a + // new property whenever there is an assignment to a property of 'this'. We + // should probably only add properties if we haven't seen them before. + // Otherwise we'll probably overestimate the number of properties. + if (impl()->IsThisProperty(expression)) function_state_->AddProperty(); + } else { + // Only initializers (i.e. no compound assignments) are allowed in patterns. expression_scope()->RecordPatternError( Scanner::Location(lhs_beg_pos, end_position()), MessageTemplate::kInvalidDestructuringTarget); - fni_.RemoveLastFunction(); } return factory()->NewAssignment(op, expression, right, op_position); diff --git a/chromium/v8/src/parsing/parser.cc b/chromium/v8/src/parsing/parser.cc index 63b8b9c6f94..9577b373973 100644 --- a/chromium/v8/src/parsing/parser.cc +++ b/chromium/v8/src/parsing/parser.cc @@ -357,8 +357,8 @@ Expression* Parser::NewV8Intrinsic(const AstRawString* name, const Runtime::Function* function = Runtime::FunctionForName(name->raw_data(), name->length()); - // Be more premissive when fuzzing. Intrinsics are not supported. - if (FLAG_allow_natives_for_fuzzing) { + // Be more permissive when fuzzing. Intrinsics are not supported. + if (FLAG_fuzzing) { return NewV8RuntimeFunctionForFuzzing(function, args, pos); } @@ -392,13 +392,13 @@ Expression* Parser::NewV8Intrinsic(const AstRawString* name, Expression* Parser::NewV8RuntimeFunctionForFuzzing( const Runtime::Function* function, const ScopedPtrList<Expression>& args, int pos) { - CHECK(FLAG_allow_natives_for_fuzzing); + CHECK(FLAG_fuzzing); - // Intrinsics are not supported for fuzzing. Only allow whitelisted runtime + // Intrinsics are not supported for fuzzing. Only allow allowlisted runtime // functions. Also prevent later errors due to too few arguments and just // ignore this call. if (function == nullptr || - !Runtime::IsWhitelistedForFuzzing(function->function_id) || + !Runtime::IsAllowListedForFuzzing(function->function_id) || function->nargs > args.length()) { return factory()->NewUndefinedLiteral(kNoSourcePosition); } diff --git a/chromium/v8/src/parsing/parser.h b/chromium/v8/src/parsing/parser.h index 472c9a71ab4..431ed5a37e9 100644 --- a/chromium/v8/src/parsing/parser.h +++ b/chromium/v8/src/parsing/parser.h @@ -170,10 +170,10 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { friend class i::ArrowHeadParsingScope<ParserTypes<Parser>>; friend bool v8::internal::parsing::ParseProgram( ParseInfo*, Handle<Script>, MaybeHandle<ScopeInfo> maybe_outer_scope_info, - Isolate*, parsing::ReportErrorsAndStatisticsMode stats_mode); + Isolate*, parsing::ReportStatisticsMode stats_mode); friend bool v8::internal::parsing::ParseFunction( ParseInfo*, Handle<SharedFunctionInfo> shared_info, Isolate*, - parsing::ReportErrorsAndStatisticsMode stats_mode); + parsing::ReportStatisticsMode stats_mode); bool AllowsLazyParsingWithoutUnresolvedVariables() const { return !MaybeParsingArrowhead() && @@ -541,10 +541,14 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { return property != nullptr && property->obj()->IsThisExpression(); } - // Returns true if the expression is of type "obj.#foo". + // Returns true if the expression is of type "obj.#foo" or "obj?.#foo". V8_INLINE static bool IsPrivateReference(Expression* expression) { DCHECK_NOT_NULL(expression); Property* property = expression->AsProperty(); + if (expression->IsOptionalChain()) { + Expression* expr_inner = expression->AsOptionalChain()->expression(); + property = expr_inner->AsProperty(); + } return property != nullptr && property->IsPrivateReference(); } diff --git a/chromium/v8/src/parsing/parsing.cc b/chromium/v8/src/parsing/parsing.cc index e126874d7dc..53f6cf045b7 100644 --- a/chromium/v8/src/parsing/parsing.cc +++ b/chromium/v8/src/parsing/parsing.cc @@ -7,6 +7,7 @@ #include <memory> #include "src/ast/ast.h" +#include "src/base/v8-fallthrough.h" #include "src/execution/vm-state-inl.h" #include "src/handles/maybe-handles.h" #include "src/objects/objects-inl.h" @@ -24,14 +25,13 @@ namespace { void MaybeReportErrorsAndStatistics(ParseInfo* info, Handle<Script> script, Isolate* isolate, Parser* parser, - ReportErrorsAndStatisticsMode mode) { - if (mode == ReportErrorsAndStatisticsMode::kYes) { - if (info->literal() == nullptr) { - info->pending_error_handler()->PrepareErrors(isolate, - info->ast_value_factory()); - info->pending_error_handler()->ReportErrors(isolate, script); - } - parser->UpdateStatistics(isolate, script); + ReportStatisticsMode mode) { + switch (mode) { + case ReportStatisticsMode::kYes: + parser->UpdateStatistics(isolate, script); + break; + case ReportStatisticsMode::kNo: + break; } } @@ -39,7 +39,7 @@ void MaybeReportErrorsAndStatistics(ParseInfo* info, Handle<Script> script, bool ParseProgram(ParseInfo* info, Handle<Script> script, MaybeHandle<ScopeInfo> maybe_outer_scope_info, - Isolate* isolate, ReportErrorsAndStatisticsMode mode) { + Isolate* isolate, ReportStatisticsMode mode) { DCHECK(info->flags().is_toplevel()); DCHECK_NULL(info->literal()); @@ -62,12 +62,12 @@ bool ParseProgram(ParseInfo* info, Handle<Script> script, } bool ParseProgram(ParseInfo* info, Handle<Script> script, Isolate* isolate, - ReportErrorsAndStatisticsMode mode) { + ReportStatisticsMode mode) { return ParseProgram(info, script, kNullMaybeHandle, isolate, mode); } bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info, - Isolate* isolate, ReportErrorsAndStatisticsMode mode) { + Isolate* isolate, ReportStatisticsMode mode) { DCHECK(!info->flags().is_toplevel()); DCHECK(!shared_info.is_null()); DCHECK_NULL(info->literal()); @@ -93,7 +93,7 @@ bool ParseFunction(ParseInfo* info, Handle<SharedFunctionInfo> shared_info, } bool ParseAny(ParseInfo* info, Handle<SharedFunctionInfo> shared_info, - Isolate* isolate, ReportErrorsAndStatisticsMode mode) { + Isolate* isolate, ReportStatisticsMode mode) { DCHECK(!shared_info.is_null()); if (info->flags().is_toplevel()) { MaybeHandle<ScopeInfo> maybe_outer_scope_info; diff --git a/chromium/v8/src/parsing/parsing.h b/chromium/v8/src/parsing/parsing.h index f2350171391..f105b630d4f 100644 --- a/chromium/v8/src/parsing/parsing.h +++ b/chromium/v8/src/parsing/parsing.h @@ -15,36 +15,37 @@ class SharedFunctionInfo; namespace parsing { -enum class ReportErrorsAndStatisticsMode { kYes, kNo }; +enum class ReportStatisticsMode { kYes, kNo }; // Parses the top-level source code represented by the parse info and sets its // function literal. Returns false (and deallocates any allocated AST nodes) if // parsing failed. -V8_EXPORT_PRIVATE bool ParseProgram( - ParseInfo* info, Handle<Script> script, Isolate* isolate, - ReportErrorsAndStatisticsMode mode = ReportErrorsAndStatisticsMode::kYes); +V8_EXPORT_PRIVATE bool ParseProgram(ParseInfo* info, Handle<Script> script, + Isolate* isolate, + ReportStatisticsMode mode); // Parses the top-level source code represented by the parse info and sets its // function literal. Allows passing an |outer_scope| for programs that exist in // another scope (e.g. eval). Returns false (and deallocates any allocated AST // nodes) if parsing failed. -V8_EXPORT_PRIVATE bool ParseProgram( - ParseInfo* info, Handle<Script> script, MaybeHandle<ScopeInfo> outer_scope, - Isolate* isolate, - ReportErrorsAndStatisticsMode mode = ReportErrorsAndStatisticsMode::kYes); +V8_EXPORT_PRIVATE bool ParseProgram(ParseInfo* info, Handle<Script> script, + MaybeHandle<ScopeInfo> outer_scope, + Isolate* isolate, + ReportStatisticsMode mode); // Like ParseProgram but for an individual function which already has a // allocated shared function info. -V8_EXPORT_PRIVATE bool ParseFunction( - ParseInfo* info, Handle<SharedFunctionInfo> shared_info, Isolate* isolate, - ReportErrorsAndStatisticsMode mode = ReportErrorsAndStatisticsMode::kYes); +V8_EXPORT_PRIVATE bool ParseFunction(ParseInfo* info, + Handle<SharedFunctionInfo> shared_info, + Isolate* isolate, + ReportStatisticsMode mode); // If you don't know whether info->is_toplevel() is true or not, use this method // to dispatch to either of the above functions. Prefer to use the above methods // whenever possible. -V8_EXPORT_PRIVATE bool ParseAny( - ParseInfo* info, Handle<SharedFunctionInfo> shared_info, Isolate* isolate, - ReportErrorsAndStatisticsMode mode = ReportErrorsAndStatisticsMode::kYes); +V8_EXPORT_PRIVATE bool ParseAny(ParseInfo* info, + Handle<SharedFunctionInfo> shared_info, + Isolate* isolate, ReportStatisticsMode mode); } // namespace parsing } // namespace internal diff --git a/chromium/v8/src/parsing/pending-compilation-error-handler.cc b/chromium/v8/src/parsing/pending-compilation-error-handler.cc index f131b7ad8e6..5e0b8fec0e6 100644 --- a/chromium/v8/src/parsing/pending-compilation-error-handler.cc +++ b/chromium/v8/src/parsing/pending-compilation-error-handler.cc @@ -5,6 +5,7 @@ #include "src/parsing/pending-compilation-error-handler.h" #include "src/ast/ast-value-factory.h" +#include "src/base/export-template.h" #include "src/base/logging.h" #include "src/debug/debug.h" #include "src/execution/isolate.h" @@ -139,10 +140,13 @@ void PendingCompilationErrorHandler::PrepareErrors( ast_value_factory->Internalize(isolate); error_details_.Prepare(isolate); } -template void PendingCompilationErrorHandler::PrepareErrors( - Isolate* isolate, AstValueFactory* ast_value_factory); -template void PendingCompilationErrorHandler::PrepareErrors( - OffThreadIsolate* isolate, AstValueFactory* ast_value_factory); +template EXPORT_TEMPLATE_DEFINE( + V8_EXPORT_PRIVATE) void PendingCompilationErrorHandler:: + PrepareErrors(Isolate* isolate, AstValueFactory* ast_value_factory); +template EXPORT_TEMPLATE_DEFINE( + V8_EXPORT_PRIVATE) void PendingCompilationErrorHandler:: + PrepareErrors(OffThreadIsolate* isolate, + AstValueFactory* ast_value_factory); void PendingCompilationErrorHandler::ReportErrors(Isolate* isolate, Handle<Script> script) const { diff --git a/chromium/v8/src/parsing/pending-compilation-error-handler.h b/chromium/v8/src/parsing/pending-compilation-error-handler.h index 4d15ac91cab..2b1e60c4e59 100644 --- a/chromium/v8/src/parsing/pending-compilation-error-handler.h +++ b/chromium/v8/src/parsing/pending-compilation-error-handler.h @@ -49,8 +49,10 @@ class PendingCompilationErrorHandler { // Handle errors detected during parsing. template <typename LocalIsolate> + EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) void PrepareErrors(LocalIsolate* isolate, AstValueFactory* ast_value_factory); - void ReportErrors(Isolate* isolate, Handle<Script> script) const; + V8_EXPORT_PRIVATE void ReportErrors(Isolate* isolate, + Handle<Script> script) const; // Handle warnings detected during compilation. template <typename LocalIsolate> @@ -139,6 +141,15 @@ class PendingCompilationErrorHandler { DISALLOW_COPY_AND_ASSIGN(PendingCompilationErrorHandler); }; +extern template void PendingCompilationErrorHandler::PrepareErrors( + Isolate* isolate, AstValueFactory* ast_value_factory); +extern template void PendingCompilationErrorHandler::PrepareErrors( + OffThreadIsolate* isolate, AstValueFactory* ast_value_factory); +extern template void PendingCompilationErrorHandler::PrepareWarnings( + Isolate* isolate); +extern template void PendingCompilationErrorHandler::PrepareWarnings( + OffThreadIsolate* isolate); + } // namespace internal } // namespace v8 #endif // V8_PARSING_PENDING_COMPILATION_ERROR_HANDLER_H_ diff --git a/chromium/v8/src/parsing/preparse-data-impl.h b/chromium/v8/src/parsing/preparse-data-impl.h index 707e76236d8..7a8b17bafbf 100644 --- a/chromium/v8/src/parsing/preparse-data-impl.h +++ b/chromium/v8/src/parsing/preparse-data-impl.h @@ -37,8 +37,6 @@ class BaseConsumedPreparseData : public ConsumedPreparseData { public: class ByteData : public PreparseByteDataConstants { public: - ByteData() {} - // Reading from the ByteData is only allowed when a ReadingScope is on the // stack. This ensures that we have a DisallowHeapAllocation in place // whenever ByteData holds a raw pointer into the heap. diff --git a/chromium/v8/src/parsing/preparser.cc b/chromium/v8/src/parsing/preparser.cc index f9af109d817..8b68f62c94e 100644 --- a/chromium/v8/src/parsing/preparser.cc +++ b/chromium/v8/src/parsing/preparser.cc @@ -325,10 +325,6 @@ PreParser::Expression PreParser::ParseFunctionLiteral( // Parsing the body may change the language mode in our scope. language_mode = function_scope->language_mode(); - if (is_sloppy(language_mode)) { - function_scope->HoistSloppyBlockFunctions(nullptr); - } - // Validate name and parameter names. We can do this only after parsing the // function, since the function can declare itself strict. CheckFunctionName(language_mode, function_name, function_name_validity, diff --git a/chromium/v8/src/parsing/preparser.h b/chromium/v8/src/parsing/preparser.h index 5280e3d2268..2b376d575a3 100644 --- a/chromium/v8/src/parsing/preparser.h +++ b/chromium/v8/src/parsing/preparser.h @@ -575,6 +575,10 @@ class PreParserFactory { } PreParserExpression NewOptionalChain(const PreParserExpression& expr) { + // Needed to track `delete a?.#b` early errors + if (expr.IsPrivateReference()) { + return PreParserExpression::PrivateReference(); + } return PreParserExpression::Default(); } diff --git a/chromium/v8/src/parsing/scanner-inl.h b/chromium/v8/src/parsing/scanner-inl.h index bd4d0284d86..b255dccc05e 100644 --- a/chromium/v8/src/parsing/scanner-inl.h +++ b/chromium/v8/src/parsing/scanner-inl.h @@ -305,7 +305,7 @@ V8_INLINE Token::Value Scanner::ScanIdentifierOrKeywordInner() { // Special case for escapes at the start of an identifier. escaped = true; uc32 c = ScanIdentifierUnicodeEscape(); - DCHECK(!IsIdentifierStart(-1)); + DCHECK(!IsIdentifierStart(Invalid())); if (c == '\\' || !IsIdentifierStart(c)) { return Token::ILLEGAL; } diff --git a/chromium/v8/src/parsing/scanner.cc b/chromium/v8/src/parsing/scanner.cc index 52a1bf0724c..e27cb041020 100644 --- a/chromium/v8/src/parsing/scanner.cc +++ b/chromium/v8/src/parsing/scanner.cc @@ -107,6 +107,12 @@ void Scanner::Initialize() { Scan(); } +// static +bool Scanner::IsInvalid(uc32 c) { + DCHECK(c == Invalid() || base::IsInRange(c, 0u, String::kMaxCodePoint)); + return c == Scanner::Invalid(); +} + template <bool capture_raw, bool unicode> uc32 Scanner::ScanHexNumber(int expected_length) { DCHECK_LE(expected_length, 4); // prevent overflow @@ -120,7 +126,7 @@ uc32 Scanner::ScanHexNumber(int expected_length) { unicode ? MessageTemplate::kInvalidUnicodeEscapeSequence : MessageTemplate::kInvalidHexEscapeSequence); - return -1; + return Invalid(); } x = x * 16 + d; Advance<capture_raw>(); @@ -130,17 +136,17 @@ uc32 Scanner::ScanHexNumber(int expected_length) { } template <bool capture_raw> -uc32 Scanner::ScanUnlimitedLengthHexNumber(int max_value, int beg_pos) { +uc32 Scanner::ScanUnlimitedLengthHexNumber(uc32 max_value, int beg_pos) { uc32 x = 0; int d = HexValue(c0_); - if (d < 0) return -1; + if (d < 0) return Invalid(); while (d >= 0) { x = x * 16 + d; if (x > max_value) { ReportScannerError(Location(beg_pos, source_pos() + 1), MessageTemplate::kUndefinedUnicodeCodePoint); - return -1; + return Invalid(); } Advance<capture_raw>(); d = HexValue(c0_); @@ -386,7 +392,7 @@ bool Scanner::ScanEscape() { case 't' : c = '\t'; break; case 'u' : { c = ScanUnicodeEscape<capture_raw>(); - if (c < 0) return false; + if (IsInvalid(c)) return false; break; } case 'v': @@ -394,7 +400,7 @@ bool Scanner::ScanEscape() { break; case 'x': { c = ScanHexNumber<capture_raw>(2); - if (c < 0) return false; + if (IsInvalid(c)) return false; break; } case '0': // Fall through. @@ -416,6 +422,7 @@ bool Scanner::ScanEscape() { template <bool capture_raw> uc32 Scanner::ScanOctalEscape(uc32 c, int length) { + DCHECK('0' <= c && c <= '7'); uc32 x = c - '0'; int i = 0; for (; i < length; i++) { @@ -553,7 +560,7 @@ Token::Value Scanner::ScanTemplateSpan() { scanner_error_state.MoveErrorTo(next_); octal_error_state.MoveErrorTo(next_); } - } else if (c < 0) { + } else if (c == kEndOfInput) { // Unterminated template literal break; } else { @@ -861,7 +868,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) { uc32 Scanner::ScanIdentifierUnicodeEscape() { Advance(); - if (c0_ != 'u') return -1; + if (c0_ != 'u') return Invalid(); Advance(); return ScanUnicodeEscape<false>(); } @@ -873,11 +880,12 @@ uc32 Scanner::ScanUnicodeEscape() { if (c0_ == '{') { int begin = source_pos() - 2; Advance<capture_raw>(); - uc32 cp = ScanUnlimitedLengthHexNumber<capture_raw>(0x10FFFF, begin); - if (cp < 0 || c0_ != '}') { + uc32 cp = + ScanUnlimitedLengthHexNumber<capture_raw>(String::kMaxCodePoint, begin); + if (cp == kInvalidSequence || c0_ != '}') { ReportScannerError(source_pos(), MessageTemplate::kInvalidUnicodeEscapeSequence); - return -1; + return Invalid(); } Advance<capture_raw>(); return cp; @@ -895,7 +903,7 @@ Token::Value Scanner::ScanIdentifierOrKeywordInnerSlow(bool escaped, // Only allow legal identifier part characters. // TODO(verwaest): Make this true. // DCHECK(!IsIdentifierPart('\')); - DCHECK(!IsIdentifierPart(-1)); + DCHECK(!IsIdentifierPart(Invalid())); if (c == '\\' || !IsIdentifierPart(c)) { return Token::ILLEGAL; } @@ -986,8 +994,9 @@ Maybe<int> Scanner::ScanRegExpFlags() { // Scan regular expression flags. JSRegExp::Flags flags; while (IsIdentifierPart(c0_)) { - JSRegExp::Flags flag = JSRegExp::FlagFromChar(c0_); - if (flag == JSRegExp::kInvalid) return Nothing<int>(); + base::Optional<JSRegExp::Flags> maybe_flag = JSRegExp::FlagFromChar(c0_); + if (!maybe_flag.has_value()) return Nothing<int>(); + JSRegExp::Flags flag = *maybe_flag; if (flags & flag) return Nothing<int>(); Advance(); flags |= flag; diff --git a/chromium/v8/src/parsing/scanner.h b/chromium/v8/src/parsing/scanner.h index 830067e1ad5..6ac7dde01b6 100644 --- a/chromium/v8/src/parsing/scanner.h +++ b/chromium/v8/src/parsing/scanner.h @@ -39,7 +39,7 @@ class Zone; // or one part of a surrogate pair that make a single 21 bit code point. class Utf16CharacterStream { public: - static const uc32 kEndOfInput = -1; + static constexpr uc32 kEndOfInput = static_cast<uc32>(-1); virtual ~Utf16CharacterStream() = default; @@ -267,8 +267,11 @@ class V8_EXPORT_PRIVATE Scanner { }; // -1 is outside of the range of any real source code. - static const int kNoOctalLocation = -1; - static const uc32 kEndOfInput = Utf16CharacterStream::kEndOfInput; + static constexpr uc32 kEndOfInput = Utf16CharacterStream::kEndOfInput; + static constexpr uc32 kInvalidSequence = static_cast<uc32>(-1); + + static constexpr uc32 Invalid() { return Scanner::kInvalidSequence; } + static bool IsInvalid(uc32 c); explicit Scanner(Utf16CharacterStream* source, UnoptimizedCompileFlags flags); @@ -541,7 +544,8 @@ class V8_EXPORT_PRIVATE Scanner { } void PushBack(uc32 ch) { - DCHECK_LE(c0_, static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)); + DCHECK(IsInvalid(c0_) || + base::IsInRange(c0_, 0u, unibrow::Utf16::kMaxNonSurrogateCharCode)); source_->Back(); c0_ = ch; } @@ -623,7 +627,7 @@ class V8_EXPORT_PRIVATE Scanner { // number can be 000000001, so it's very long in characters but its value is // small. template <bool capture_raw> - uc32 ScanUnlimitedLengthHexNumber(int max_value, int beg_pos); + uc32 ScanUnlimitedLengthHexNumber(uc32 max_value, int beg_pos); // Scans a single JavaScript token. V8_INLINE Token::Value ScanSingleToken(); diff --git a/chromium/v8/src/parsing/token.h b/chromium/v8/src/parsing/token.h index ef92238de2a..dabbff0e0e7 100644 --- a/chromium/v8/src/parsing/token.h +++ b/chromium/v8/src/parsing/token.h @@ -284,6 +284,10 @@ class V8_EXPORT_PRIVATE Token { return base::IsInRange(token, INIT, ASSIGN_SUB); } + static bool IsLogicalAssignmentOp(Value token) { + return base::IsInRange(token, ASSIGN_NULLISH, ASSIGN_AND); + } + static bool IsBinaryOp(Value op) { return base::IsInRange(op, COMMA, SUB); } static bool IsCompareOp(Value op) { return base::IsInRange(op, EQ, IN); } |