diff options
author | Michaël Zasso <targos@protonmail.com> | 2021-08-29 14:20:49 +0200 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2021-08-30 21:02:51 +0200 |
commit | 50930a0fa08297d0ce7e67fa6594fe47937b99ff (patch) | |
tree | 96bd30c0c63790bc1992a2f241a3df94d563b283 /deps/v8/src/parsing | |
parent | b63e449b2eade1111b52f6559669400a4e855903 (diff) | |
download | node-new-50930a0fa08297d0ce7e67fa6594fe47937b99ff.tar.gz |
deps: update V8 to 9.3.345.16
PR-URL: https://github.com/nodejs/node/pull/39469
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'deps/v8/src/parsing')
-rw-r--r-- | deps/v8/src/parsing/literal-buffer.cc | 20 | ||||
-rw-r--r-- | deps/v8/src/parsing/literal-buffer.h | 23 | ||||
-rw-r--r-- | deps/v8/src/parsing/parse-info.cc | 20 | ||||
-rw-r--r-- | deps/v8/src/parsing/parse-info.h | 12 | ||||
-rw-r--r-- | deps/v8/src/parsing/parser-base.h | 29 | ||||
-rw-r--r-- | deps/v8/src/parsing/parser.cc | 16 | ||||
-rw-r--r-- | deps/v8/src/parsing/parser.h | 7 | ||||
-rw-r--r-- | deps/v8/src/parsing/pending-compilation-error-handler.cc | 2 | ||||
-rw-r--r-- | deps/v8/src/parsing/preparse-data-impl.h | 3 | ||||
-rw-r--r-- | deps/v8/src/parsing/preparse-data.cc | 8 | ||||
-rw-r--r-- | deps/v8/src/parsing/preparse-data.h | 6 | ||||
-rw-r--r-- | deps/v8/src/parsing/preparser.cc | 5 | ||||
-rw-r--r-- | deps/v8/src/parsing/preparser.h | 16 | ||||
-rw-r--r-- | deps/v8/src/parsing/rewriter.cc | 1 | ||||
-rw-r--r-- | deps/v8/src/parsing/scanner-character-streams.cc | 21 | ||||
-rw-r--r-- | deps/v8/src/parsing/scanner-inl.h | 11 | ||||
-rw-r--r-- | deps/v8/src/parsing/scanner.cc | 64 | ||||
-rw-r--r-- | deps/v8/src/parsing/scanner.h | 72 |
18 files changed, 177 insertions, 159 deletions
diff --git a/deps/v8/src/parsing/literal-buffer.cc b/deps/v8/src/parsing/literal-buffer.cc index a3e665a5c3..25388e938a 100644 --- a/deps/v8/src/parsing/literal-buffer.cc +++ b/deps/v8/src/parsing/literal-buffer.cc @@ -4,6 +4,7 @@ #include "src/parsing/literal-buffer.h" +#include "src/base/strings.h" #include "src/execution/isolate.h" #include "src/execution/local-isolate.h" #include "src/heap/factory.h" @@ -31,7 +32,8 @@ int LiteralBuffer::NewCapacity(int min_capacity) { void LiteralBuffer::ExpandBuffer() { int min_capacity = std::max({kInitialCapacity, backing_store_.length()}); - Vector<byte> new_store = Vector<byte>::New(NewCapacity(min_capacity)); + base::Vector<byte> new_store = + base::Vector<byte>::New(NewCapacity(min_capacity)); if (position_ > 0) { MemCopy(new_store.begin(), backing_store_.begin(), position_); } @@ -41,12 +43,12 @@ void LiteralBuffer::ExpandBuffer() { void LiteralBuffer::ConvertToTwoByte() { DCHECK(is_one_byte()); - Vector<byte> new_store; - int new_content_size = position_ * kUC16Size; + base::Vector<byte> new_store; + int new_content_size = position_ * base::kUC16Size; if (new_content_size >= backing_store_.length()) { // Ensure room for all currently read code units as UC16 as well // as the code unit about to be stored. - new_store = Vector<byte>::New(NewCapacity(new_content_size)); + new_store = base::Vector<byte>::New(NewCapacity(new_content_size)); } else { new_store = backing_store_; } @@ -63,21 +65,21 @@ void LiteralBuffer::ConvertToTwoByte() { is_one_byte_ = false; } -void LiteralBuffer::AddTwoByteChar(uc32 code_unit) { +void LiteralBuffer::AddTwoByteChar(base::uc32 code_unit) { DCHECK(!is_one_byte()); if (position_ >= backing_store_.length()) ExpandBuffer(); if (code_unit <= - static_cast<uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) { + static_cast<base::uc32>(unibrow::Utf16::kMaxNonSurrogateCharCode)) { *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = code_unit; - position_ += kUC16Size; + position_ += base::kUC16Size; } else { *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = unibrow::Utf16::LeadSurrogate(code_unit); - position_ += kUC16Size; + position_ += base::kUC16Size; if (position_ >= backing_store_.length()) ExpandBuffer(); *reinterpret_cast<uint16_t*>(&backing_store_[position_]) = unibrow::Utf16::TrailSurrogate(code_unit); - position_ += kUC16Size; + position_ += base::kUC16Size; } } diff --git a/deps/v8/src/parsing/literal-buffer.h b/deps/v8/src/parsing/literal-buffer.h index 3a3457082c..408c11381e 100644 --- a/deps/v8/src/parsing/literal-buffer.h +++ b/deps/v8/src/parsing/literal-buffer.h @@ -5,8 +5,9 @@ #ifndef V8_PARSING_LITERAL_BUFFER_H_ #define V8_PARSING_LITERAL_BUFFER_H_ +#include "src/base/strings.h" +#include "src/base/vector.h" #include "src/strings/unicode-decoder.h" -#include "src/utils/vector.h" namespace v8 { namespace internal { @@ -26,9 +27,9 @@ class LiteralBuffer final { AddOneByteChar(static_cast<byte>(code_unit)); } - V8_INLINE void AddChar(uc32 code_unit) { + V8_INLINE void AddChar(base::uc32 code_unit) { if (is_one_byte()) { - if (code_unit <= static_cast<uc32>(unibrow::Latin1::kMaxChar)) { + if (code_unit <= static_cast<base::uc32>(unibrow::Latin1::kMaxChar)) { AddOneByteChar(static_cast<byte>(code_unit)); return; } @@ -39,22 +40,24 @@ class LiteralBuffer final { bool is_one_byte() const { return is_one_byte_; } - bool Equals(Vector<const char> keyword) const { + bool Equals(base::Vector<const char> keyword) const { return is_one_byte() && keyword.length() == position_ && (memcmp(keyword.begin(), backing_store_.begin(), position_) == 0); } - Vector<const uint16_t> two_byte_literal() const { + base::Vector<const uint16_t> two_byte_literal() const { return literal<uint16_t>(); } - Vector<const uint8_t> one_byte_literal() const { return literal<uint8_t>(); } + base::Vector<const uint8_t> one_byte_literal() const { + return literal<uint8_t>(); + } template <typename Char> - Vector<const Char> literal() const { + base::Vector<const Char> literal() const { DCHECK_EQ(is_one_byte_, sizeof(Char) == 1); DCHECK_EQ(position_ & (sizeof(Char) - 1), 0); - return Vector<const Char>( + return base::Vector<const Char>( reinterpret_cast<const Char*>(backing_store_.begin()), position_ >> (sizeof(Char) - 1)); } @@ -89,12 +92,12 @@ class LiteralBuffer final { position_ += kOneByteSize; } - void AddTwoByteChar(uc32 code_unit); + void AddTwoByteChar(base::uc32 code_unit); int NewCapacity(int min_capacity); void ExpandBuffer(); void ConvertToTwoByte(); - Vector<byte> backing_store_; + base::Vector<byte> backing_store_; int position_; bool is_one_byte_; diff --git a/deps/v8/src/parsing/parse-info.cc b/deps/v8/src/parsing/parse-info.cc index 6f469383a3..ba06f94402 100644 --- a/deps/v8/src/parsing/parse-info.cc +++ b/deps/v8/src/parsing/parse-info.cc @@ -32,7 +32,7 @@ UnoptimizedCompileFlags::UnoptimizedCompileFlags(Isolate* isolate, set_block_coverage_enabled(isolate->is_block_code_coverage()); set_might_always_opt(FLAG_always_opt || FLAG_prepare_always_opt); set_allow_natives_syntax(FLAG_allow_natives_syntax); - set_allow_lazy_compile(FLAG_lazy); + set_allow_lazy_compile(true); set_collect_source_positions(!FLAG_enable_lazy_source_positions || isolate->NeedsDetailedOptimizedCodeLineInfo()); set_allow_harmony_top_level_await(FLAG_harmony_top_level_await); @@ -47,8 +47,9 @@ UnoptimizedCompileFlags UnoptimizedCompileFlags::ForFunctionCompile( flags.SetFlagsFromFunction(&shared); flags.SetFlagsForFunctionFromScript(script); - flags.set_allow_lazy_parsing(true); + flags.set_is_lazy_compile(true); + #if V8_ENABLE_WEBASSEMBLY flags.set_is_asm_wasm_broken(shared.is_asm_wasm_broken()); #endif // V8_ENABLE_WEBASSEMBLY @@ -79,7 +80,8 @@ UnoptimizedCompileFlags UnoptimizedCompileFlags::ForScriptCompile( isolate->is_collecting_type_profile(), script.IsUserJavaScript(), flags.outer_language_mode(), construct_repl_mode(script.is_repl_mode()), script.origin_options().IsModule() ? ScriptType::kModule - : ScriptType::kClassic); + : ScriptType::kClassic, + FLAG_lazy); if (script.is_wrapped()) { flags.set_function_syntax_kind(FunctionSyntaxKind::kWrapped); } @@ -90,11 +92,11 @@ UnoptimizedCompileFlags UnoptimizedCompileFlags::ForScriptCompile( // static UnoptimizedCompileFlags UnoptimizedCompileFlags::ForToplevelCompile( Isolate* isolate, bool is_user_javascript, LanguageMode language_mode, - REPLMode repl_mode, ScriptType type) { + REPLMode repl_mode, ScriptType type, bool lazy) { UnoptimizedCompileFlags flags(isolate, isolate->GetNextScriptId()); flags.SetFlagsForToplevelCompile(isolate->is_collecting_type_profile(), is_user_javascript, language_mode, repl_mode, - type); + type, lazy); LOG(isolate, ScriptEvent(Logger::ScriptEventType::kReserveId, flags.script_id())); @@ -131,14 +133,15 @@ void UnoptimizedCompileFlags::SetFlagsFromFunction(T function) { set_has_static_private_methods_or_accessors( function->has_static_private_methods_or_accessors()); set_is_toplevel(function->is_toplevel()); - set_is_oneshot_iife(function->is_oneshot_iife()); } void UnoptimizedCompileFlags::SetFlagsForToplevelCompile( bool is_collecting_type_profile, bool is_user_javascript, - LanguageMode language_mode, REPLMode repl_mode, ScriptType type) { - set_allow_lazy_parsing(true); + LanguageMode language_mode, REPLMode repl_mode, ScriptType type, + bool lazy) { set_is_toplevel(true); + set_allow_lazy_parsing(lazy); + set_allow_lazy_compile(lazy); set_collect_type_profile(is_user_javascript && is_collecting_type_profile); set_outer_language_mode( stricter_language_mode(outer_language_mode(), language_mode)); @@ -305,7 +308,6 @@ void ParseInfo::set_character_stream( void ParseInfo::CheckFlagsForToplevelCompileFromScript( Script script, bool is_collecting_type_profile) { CheckFlagsForFunctionFromScript(script); - DCHECK(flags().allow_lazy_parsing()); DCHECK(flags().is_toplevel()); DCHECK_EQ(flags().collect_type_profile(), is_collecting_type_profile && script.IsUserJavaScript()); diff --git a/deps/v8/src/parsing/parse-info.h b/deps/v8/src/parsing/parse-info.h index d203ebed85..55ba2b1cd7 100644 --- a/deps/v8/src/parsing/parse-info.h +++ b/deps/v8/src/parsing/parse-info.h @@ -60,7 +60,6 @@ class Zone; V(might_always_opt, bool, 1, _) \ V(allow_natives_syntax, bool, 1, _) \ V(allow_lazy_compile, bool, 1, _) \ - V(is_oneshot_iife, bool, 1, _) \ V(collect_source_positions, bool, 1, _) \ V(allow_harmony_top_level_await, bool, 1, _) \ V(is_repl_mode, bool, 1, _) @@ -68,9 +67,11 @@ class Zone; class V8_EXPORT_PRIVATE UnoptimizedCompileFlags { public: // Set-up flags for a toplevel compilation. - static UnoptimizedCompileFlags ForToplevelCompile( - Isolate* isolate, bool is_user_javascript, LanguageMode language_mode, - REPLMode repl_mode, ScriptType type = ScriptType::kClassic); + static UnoptimizedCompileFlags ForToplevelCompile(Isolate* isolate, + bool is_user_javascript, + LanguageMode language_mode, + REPLMode repl_mode, + ScriptType type, bool lazy); // Set-up flags for a compiling a particular function (either a lazy compile // or a recompile). @@ -133,7 +134,8 @@ class V8_EXPORT_PRIVATE UnoptimizedCompileFlags { void SetFlagsForToplevelCompile(bool is_collecting_type_profile, bool is_user_javascript, LanguageMode language_mode, - REPLMode repl_mode, ScriptType type); + REPLMode repl_mode, ScriptType type, + bool lazy); void SetFlagsForFunctionFromScript(Script script); uint32_t flags_; diff --git a/deps/v8/src/parsing/parser-base.h b/deps/v8/src/parsing/parser-base.h index d30c3f1b1f..108b11edc8 100644 --- a/deps/v8/src/parsing/parser-base.h +++ b/deps/v8/src/parsing/parser-base.h @@ -6,6 +6,7 @@ #define V8_PARSING_PARSER_BASE_H_ #include <stdint.h> + #include <utility> #include <vector> @@ -18,8 +19,8 @@ #include "src/codegen/bailout-reason.h" #include "src/common/globals.h" #include "src/common/message-template.h" -#include "src/logging/counters.h" #include "src/logging/log.h" +#include "src/logging/runtime-call-stats-scope.h" #include "src/objects/function-kind.h" #include "src/parsing/expression-scope.h" #include "src/parsing/func-name-inferrer.h" @@ -240,14 +241,13 @@ class ParserBase { const Impl* impl() const { return static_cast<const Impl*>(this); } ParserBase(Zone* zone, Scanner* scanner, uintptr_t stack_limit, - v8::Extension* extension, AstValueFactory* ast_value_factory, + AstValueFactory* ast_value_factory, PendingCompilationErrorHandler* pending_error_handler, RuntimeCallStats* runtime_call_stats, Logger* logger, UnoptimizedCompileFlags flags, bool parsing_on_main_thread) : scope_(nullptr), original_scope_(nullptr), function_state_(nullptr), - extension_(extension), fni_(ast_value_factory), ast_value_factory_(ast_value_factory), ast_node_factory_(ast_value_factory, zone), @@ -594,7 +594,6 @@ class ParserBase { instance_fields(parser->impl()->NewClassPropertyList(4)), constructor(parser->impl()->NullExpression()), has_seen_constructor(false), - has_name_static_property(false), has_static_computed_names(false), has_static_elements(false), has_static_private_methods(false), @@ -614,7 +613,6 @@ class ParserBase { FunctionLiteralT constructor; bool has_seen_constructor; - bool has_name_static_property; bool has_static_computed_names; bool has_static_elements; bool has_static_private_methods; @@ -1540,7 +1538,6 @@ class ParserBase { Scope* object_literal_scope_ = nullptr; Scope* original_scope_; // The top scope for the current parsing item. FunctionState* function_state_; // Function state stack. - v8::Extension* extension_; FuncNameInferrer fni_; AstValueFactory* ast_value_factory_; // Not owned. typename Types::Factory ast_node_factory_; @@ -1949,7 +1946,7 @@ ParserBase<Impl>::ParsePrimaryExpression() { return ParseTemplateLiteral(impl()->NullExpression(), beg_pos, false); case Token::MOD: - if (flags().allow_natives_syntax() || extension_ != nullptr) { + if (flags().allow_natives_syntax() || impl()->ParsingExtension()) { return ParseV8Intrinsic(); } break; @@ -2315,11 +2312,6 @@ ParserBase<Impl>::ParseClassPropertyDefinition(ClassInfo* class_info, name_expression = ParseProperty(prop_info); } - if (!class_info->has_name_static_property && prop_info->is_static && - impl()->IsName(prop_info->name)) { - class_info->has_name_static_property = true; - } - switch (prop_info->kind) { case ParsePropertyKind::kAssign: case ParsePropertyKind::kClassField: @@ -3461,11 +3453,6 @@ ParserBase<Impl>::ParseLeftHandSideContinuation(ExpressionT result) { // function literal eagerly, we can also compile it eagerly. if (result->IsFunctionLiteral()) { result->AsFunctionLiteral()->SetShouldEagerCompile(); - if (scope()->is_script_scope()) { - // A non-top-level iife is likely to be executed multiple times - // and so shouldn`t be optimized as one-shot. - result->AsFunctionLiteral()->mark_as_oneshot_iife(); - } } } bool has_spread; @@ -5414,10 +5401,10 @@ ParserBase<Impl>::ParseExpressionOrLabelledStatement( } } - // If we have an extension, we allow a native function declaration. - // A native function declaration starts with "native function" with - // no line-terminator between the two words. - if (extension_ != nullptr && peek() == Token::FUNCTION && + // We allow a native function declaration if we're parsing the source for an + // extension. A native function declaration starts with "native function" + // with no line-terminator between the two words. + if (impl()->ParsingExtension() && peek() == Token::FUNCTION && !scanner()->HasLineTerminatorBeforeNext() && impl()->IsNative(expr) && !scanner()->literal_contains_escapes()) { return ParseNativeDeclaration(); diff --git a/deps/v8/src/parsing/parser.cc b/deps/v8/src/parsing/parser.cc index 0671fc5f6b..0abfbe8d8f 100644 --- a/deps/v8/src/parsing/parser.cc +++ b/deps/v8/src/parsing/parser.cc @@ -20,6 +20,7 @@ #include "src/compiler-dispatcher/compiler-dispatcher.h" #include "src/logging/counters.h" #include "src/logging/log.h" +#include "src/logging/runtime-call-stats-scope.h" #include "src/numbers/conversions-inl.h" #include "src/objects/scope-info.h" #include "src/parsing/parse-info.h" @@ -344,7 +345,7 @@ Expression* Parser::ExpressionFromLiteral(Token::Value token, int pos) { Expression* Parser::NewV8Intrinsic(const AstRawString* name, const ScopedPtrList<Expression>& args, int pos) { - if (extension_ != nullptr) { + if (ParsingExtension()) { // The extension structures are only accessible while parsing the // very first time, not when reparsing because of lazy compilation. GetClosureScope()->ForceEagerCompilation(); @@ -420,7 +421,7 @@ Expression* Parser::NewV8RuntimeFunctionForFuzzing( Parser::Parser(ParseInfo* info) : ParserBase<Parser>( - info->zone(), &scanner_, info->stack_limit(), info->extension(), + info->zone(), &scanner_, info->stack_limit(), info->GetOrCreateAstValueFactory(), info->pending_error_handler(), info->runtime_call_stats(), info->logger(), info->flags(), true), info_(info), @@ -1022,9 +1023,6 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info, flags().class_scope_has_private_brand()); result->set_has_static_private_methods_or_accessors( flags().has_static_private_methods_or_accessors()); - if (flags().is_oneshot_iife()) { - result->mark_as_oneshot_iife(); - } } DCHECK_IMPLIES(result, function_literal_id == result->function_literal_id()); @@ -1787,7 +1785,7 @@ Statement* Parser::DeclareNative(const AstRawString* name, int pos) { // other functions are set up when entering the surrounding scope. VariableProxy* proxy = DeclareBoundVariable(name, VariableMode::kVar, pos); NativeFunctionLiteral* lit = - factory()->NewNativeFunctionLiteral(name, extension_, kNoSourcePosition); + factory()->NewNativeFunctionLiteral(name, extension(), kNoSourcePosition); return factory()->NewExpressionStatement( factory()->NewAssignment(Token::INIT, proxy, lit, kNoSourcePosition), pos); @@ -2561,7 +2559,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral( // that tracks unresolved variables. DCHECK_IMPLIES(parse_lazily(), info()->flags().allow_lazy_compile()); DCHECK_IMPLIES(parse_lazily(), has_error() || allow_lazy_); - DCHECK_IMPLIES(parse_lazily(), extension_ == nullptr); + DCHECK_IMPLIES(parse_lazily(), extension() == nullptr); const bool is_lazy = eager_compile_hint == FunctionLiteral::kShouldLazyCompile; @@ -3134,7 +3132,6 @@ FunctionLiteral* Parser::CreateInitializerFunction( // - proxy // - extends // - properties -// - has_name_static_property // - has_static_computed_names Expression* Parser::RewriteClassLiteral(ClassScope* block_scope, const AstRawString* name, @@ -3185,7 +3182,6 @@ Expression* Parser::RewriteClassLiteral(ClassScope* block_scope, block_scope, class_info->extends, class_info->constructor, class_info->public_members, class_info->private_members, static_initializer, instance_members_initializer_function, pos, end_pos, - class_info->has_name_static_property, class_info->has_static_computed_names, class_info->is_anonymous, class_info->has_private_methods, class_info->home_object_variable, class_info->static_home_object_variable); @@ -3468,6 +3464,8 @@ void Parser::SetFunctionNameFromPropertyName(ObjectLiteralProperty* property, void Parser::SetFunctionNameFromIdentifierRef(Expression* value, Expression* identifier) { if (!identifier->IsVariableProxy()) return; + // IsIdentifierRef of parenthesized expressions is false. + if (identifier->is_parenthesized()) return; SetFunctionName(value, identifier->AsVariableProxy()->raw_name()); } diff --git a/deps/v8/src/parsing/parser.h b/deps/v8/src/parsing/parser.h index 07efef277e..6b50ed134c 100644 --- a/deps/v8/src/parsing/parser.h +++ b/deps/v8/src/parsing/parser.h @@ -586,6 +586,10 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { return !property->IsPrototype(); } + V8_INLINE v8::Extension* extension() const { return info_->extension(); } + + V8_INLINE bool ParsingExtension() const { return extension() != nullptr; } + V8_INLINE bool IsNative(Expression* expr) const { DCHECK_NOT_NULL(expr); return expr->IsVariableProxy() && @@ -772,7 +776,8 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) { V8_INLINE const AstRawString* GetNumberAsSymbol() const { double double_value = scanner()->DoubleValue(); char array[100]; - const char* string = DoubleToCString(double_value, ArrayVector(array)); + const char* string = + DoubleToCString(double_value, base::ArrayVector(array)); return ast_value_factory()->GetOneByteString(string); } diff --git a/deps/v8/src/parsing/pending-compilation-error-handler.cc b/deps/v8/src/parsing/pending-compilation-error-handler.cc index 2ab5b3eb1a..60bc8ada27 100644 --- a/deps/v8/src/parsing/pending-compilation-error-handler.cc +++ b/deps/v8/src/parsing/pending-compilation-error-handler.cc @@ -61,7 +61,7 @@ Handle<String> PendingCompilationErrorHandler::MessageDetails::ArgumentString( return isolate->factory()->undefined_string(); case kConstCharString: return isolate->factory() - ->NewStringFromUtf8(CStrVector(char_arg_), AllocationType::kOld) + ->NewStringFromUtf8(base::CStrVector(char_arg_), AllocationType::kOld) .ToHandleChecked(); case kAstRawString: UNREACHABLE(); diff --git a/deps/v8/src/parsing/preparse-data-impl.h b/deps/v8/src/parsing/preparse-data-impl.h index 937244f30b..eb528fa645 100644 --- a/deps/v8/src/parsing/preparse-data-impl.h +++ b/deps/v8/src/parsing/preparse-data-impl.h @@ -195,7 +195,8 @@ class OnHeapConsumedPreparseData final // A serialized PreparseData in zone memory (as apposed to being on-heap). class ZonePreparseData : public ZoneObject { public: - V8_EXPORT_PRIVATE ZonePreparseData(Zone* zone, Vector<uint8_t>* byte_data, + V8_EXPORT_PRIVATE ZonePreparseData(Zone* zone, + base::Vector<uint8_t>* byte_data, int child_length); ZonePreparseData(const ZonePreparseData&) = delete; diff --git a/deps/v8/src/parsing/preparse-data.cc b/deps/v8/src/parsing/preparse-data.cc index a085d55e1e..1643c6ba1a 100644 --- a/deps/v8/src/parsing/preparse-data.cc +++ b/deps/v8/src/parsing/preparse-data.cc @@ -134,9 +134,9 @@ struct RawPreparseData {}; void PreparseDataBuilder::ByteData::Finalize(Zone* zone) { uint8_t* raw_zone_data = zone->NewArray<uint8_t, RawPreparseData>(index_); - base::Memcpy(raw_zone_data, byte_data_->data(), index_); + memcpy(raw_zone_data, byte_data_->data(), index_); byte_data_->resize(0); - zone_byte_data_ = Vector<uint8_t>(raw_zone_data, index_); + zone_byte_data_ = base::Vector<uint8_t>(raw_zone_data, index_); #ifdef DEBUG is_finalized_ = true; #endif @@ -255,7 +255,7 @@ void PreparseDataBuilder::AddChild(PreparseDataBuilder* child) { void PreparseDataBuilder::FinalizeChildren(Zone* zone) { DCHECK(!finalized_children_); - Vector<PreparseDataBuilder*> children = + base::Vector<PreparseDataBuilder*> children = CloneVector(zone, children_buffer_.ToConstVector()); children_buffer_.Rewind(); children_ = children; @@ -774,7 +774,7 @@ OnHeapConsumedPreparseData::OnHeapConsumedPreparseData( DCHECK(VerifyDataStart()); } -ZonePreparseData::ZonePreparseData(Zone* zone, Vector<uint8_t>* byte_data, +ZonePreparseData::ZonePreparseData(Zone* zone, base::Vector<uint8_t>* byte_data, int children_length) : byte_data_(byte_data->begin(), byte_data->end(), zone), children_(children_length, zone) {} diff --git a/deps/v8/src/parsing/preparse-data.h b/deps/v8/src/parsing/preparse-data.h index 1c4695a0ae..8132ac1dc5 100644 --- a/deps/v8/src/parsing/preparse-data.h +++ b/deps/v8/src/parsing/preparse-data.h @@ -7,11 +7,11 @@ #include <memory> +#include "src/base/vector.h" #include "src/common/globals.h" #include "src/handles/handles.h" #include "src/handles/maybe-handles.h" #include "src/utils/scoped-list.h" -#include "src/utils/vector.h" #include "src/zone/zone-chunk-list.h" #include "src/zone/zone-containers.h" @@ -168,7 +168,7 @@ class V8_EXPORT_PRIVATE PreparseDataBuilder : public ZoneObject, }; // Once the data is finalized, it lives in a Zone, this implies // is_finalized_ == true. - Vector<uint8_t> zone_byte_data_; + base::Vector<uint8_t> zone_byte_data_; }; uint8_t free_quarters_in_last_byte_; @@ -228,7 +228,7 @@ class V8_EXPORT_PRIVATE PreparseDataBuilder : public ZoneObject, ByteData byte_data_; union { ScopedPtrList<PreparseDataBuilder> children_buffer_; - Vector<PreparseDataBuilder*> children_; + base::Vector<PreparseDataBuilder*> children_; }; DeclarationScope* function_scope_; diff --git a/deps/v8/src/parsing/preparser.cc b/deps/v8/src/parsing/preparser.cc index 4547e602ee..ffd34beeaf 100644 --- a/deps/v8/src/parsing/preparser.cc +++ b/deps/v8/src/parsing/preparser.cc @@ -2,16 +2,17 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "src/parsing/preparser.h" + #include <cmath> #include "src/base/logging.h" #include "src/common/globals.h" -#include "src/logging/counters.h" +#include "src/logging/runtime-call-stats-scope.h" #include "src/numbers/conversions-inl.h" #include "src/numbers/conversions.h" #include "src/parsing/parser-base.h" #include "src/parsing/preparse-data.h" -#include "src/parsing/preparser.h" #include "src/strings/unicode.h" #include "src/utils/allocation.h" #include "src/utils/utils.h" diff --git a/deps/v8/src/parsing/preparser.h b/deps/v8/src/parsing/preparser.h index 93f5dc5cf2..1949e7f8a7 100644 --- a/deps/v8/src/parsing/preparser.h +++ b/deps/v8/src/parsing/preparser.h @@ -310,7 +310,6 @@ class PreParserExpression { // More dummy implementations of things PreParser doesn't need to track: void SetShouldEagerCompile() {} - void mark_as_oneshot_iife() {} int position() const { return kNoSourcePosition; } void set_function_token_position(int position) {} @@ -936,10 +935,9 @@ class PreParser : public ParserBase<PreParser> { PendingCompilationErrorHandler* pending_error_handler, RuntimeCallStats* runtime_call_stats, Logger* logger, UnoptimizedCompileFlags flags, bool parsing_on_main_thread = true) - : ParserBase<PreParser>(zone, scanner, stack_limit, nullptr, - ast_value_factory, pending_error_handler, - runtime_call_stats, logger, flags, - parsing_on_main_thread), + : ParserBase<PreParser>(zone, scanner, stack_limit, ast_value_factory, + pending_error_handler, runtime_call_stats, logger, + flags, parsing_on_main_thread), use_counts_(nullptr), preparse_data_builder_(nullptr), preparse_data_builder_buffer_() { @@ -1327,6 +1325,14 @@ class PreParser : public ParserBase<PreParser> { return false; } + V8_INLINE bool ParsingExtension() const { + // Preparsing is disabled for extensions (because the extension + // details aren't passed to lazily compiled functions), so we + // don't accept "native function" in the preparser and there is + // no need to keep track of "native". + return false; + } + V8_INLINE bool IsNative(const PreParserExpression& expr) const { // Preparsing is disabled for extensions (because the extension // details aren't passed to lazily compiled functions), so we diff --git a/deps/v8/src/parsing/rewriter.cc b/deps/v8/src/parsing/rewriter.cc index 35f82e25ab..d20fea9d48 100644 --- a/deps/v8/src/parsing/rewriter.cc +++ b/deps/v8/src/parsing/rewriter.cc @@ -6,6 +6,7 @@ #include "src/ast/ast.h" #include "src/ast/scopes.h" +#include "src/logging/runtime-call-stats-scope.h" #include "src/objects/objects-inl.h" #include "src/parsing/parse-info.h" #include "src/parsing/parser.h" diff --git a/deps/v8/src/parsing/scanner-character-streams.cc b/deps/v8/src/parsing/scanner-character-streams.cc index a5fec69e84..becc72c12d 100644 --- a/deps/v8/src/parsing/scanner-character-streams.cc +++ b/deps/v8/src/parsing/scanner-character-streams.cc @@ -8,9 +8,10 @@ #include <vector> #include "include/v8.h" +#include "src/base/strings.h" #include "src/common/globals.h" #include "src/handles/handles.h" -#include "src/logging/counters.h" +#include "src/logging/runtime-call-stats-scope.h" #include "src/objects/objects-inl.h" #include "src/parsing/scanner.h" #include "src/strings/unicode-inl.h" @@ -278,7 +279,7 @@ class BufferedCharacterStream : public Utf16CharacterStream { : byte_stream_(other.byte_stream_) {} static const size_t kBufferSize = 512; - uc16 buffer_[kBufferSize]; + base::uc16 buffer_[kBufferSize]; ByteStream<uint8_t> byte_stream_; }; @@ -392,7 +393,7 @@ class BufferedUtf16CharacterStream : public Utf16CharacterStream { // Fixed sized buffer that this class reads from. // The base class' buffer_start_ should always point to buffer_. - uc16 buffer_[kBufferSize]; + base::uc16 buffer_[kBufferSize]; }; BufferedUtf16CharacterStream::BufferedUtf16CharacterStream() @@ -418,7 +419,7 @@ bool BufferedUtf16CharacterStream::ReadBlock() { namespace { -static const uc16 kWindows1252ToUC16[256] = { +static const base::uc16 kWindows1252ToUC16[256] = { 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007, // 00-07 0x0008, 0x0009, 0x000A, 0x000B, 0x000C, 0x000D, 0x000E, 0x000F, // 08-0F 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017, // 10-17 @@ -504,7 +505,7 @@ class Windows1252CharacterStream final : public Utf16CharacterStream { V8_NOEXCEPT : byte_stream_(other.byte_stream_) {} static const size_t kBufferSize = 512; - uc16 buffer_[kBufferSize]; + base::uc16 buffer_[kBufferSize]; ChunkedStream<uint8_t> byte_stream_; }; @@ -653,7 +654,7 @@ void Utf8ExternalStreamingStream::FillBufferFromCurrentChunk() { unibrow::uchar t = unibrow::Utf8::ValueOfIncrementalFinish(&state); if (t != unibrow::Utf8::kBufferEmpty) { DCHECK_EQ(t, unibrow::Utf8::kBadChar); - *output_cursor = static_cast<uc16>(t); + *output_cursor = static_cast<base::uc16>(t); buffer_end_++; current_.pos.chars++; current_.pos.incomplete_char = 0; @@ -672,13 +673,14 @@ void Utf8ExternalStreamingStream::FillBufferFromCurrentChunk() { unibrow::uchar t = unibrow::Utf8::ValueOfIncremental(&cursor, &state, &incomplete_char); if (V8_LIKELY(t < kUtf8Bom)) { - *(output_cursor++) = static_cast<uc16>(t); // The most frequent case. + *(output_cursor++) = + static_cast<base::uc16>(t); // The most frequent case. } else if (t == unibrow::Utf8::kIncomplete) { continue; } else if (t == kUtf8Bom) { // BOM detected at beginning of the stream. Don't copy it. } else if (t <= unibrow::Utf16::kMaxNonSurrogateCharCode) { - *(output_cursor++) = static_cast<uc16>(t); + *(output_cursor++) = static_cast<base::uc16>(t); } else { *(output_cursor++) = unibrow::Utf16::LeadSurrogate(t); *(output_cursor++) = unibrow::Utf16::TrailSurrogate(t); @@ -692,7 +694,8 @@ void Utf8ExternalStreamingStream::FillBufferFromCurrentChunk() { unibrow::uchar t = unibrow::Utf8::ValueOfIncremental(&cursor, &state, &incomplete_char); if (V8_LIKELY(t <= unibrow::Utf16::kMaxNonSurrogateCharCode)) { - *(output_cursor++) = static_cast<uc16>(t); // The most frequent case. + *(output_cursor++) = + static_cast<base::uc16>(t); // The most frequent case. } else if (t == unibrow::Utf8::kIncomplete) { continue; } else { diff --git a/deps/v8/src/parsing/scanner-inl.h b/deps/v8/src/parsing/scanner-inl.h index b255dccc05..0e191330c0 100644 --- a/deps/v8/src/parsing/scanner-inl.h +++ b/deps/v8/src/parsing/scanner-inl.h @@ -251,7 +251,7 @@ static constexpr const uint8_t character_scan_flags[128] = { #undef CALL_GET_SCAN_FLAGS }; -inline bool CharCanBeKeyword(uc32 c) { +inline bool CharCanBeKeyword(base::uc32 c) { return static_cast<uint32_t>(c) < arraysize(character_scan_flags) && CanBeKeyword(character_scan_flags[c]); } @@ -273,7 +273,7 @@ V8_INLINE Token::Value Scanner::ScanIdentifierOrKeywordInner() { // Otherwise we'll fall into the slow path after scanning the identifier. DCHECK(!IdentifierNeedsSlowPath(scan_flags)); AddLiteralChar(static_cast<char>(c0_)); - AdvanceUntil([this, &scan_flags](uc32 c0) { + AdvanceUntil([this, &scan_flags](base::uc32 c0) { if (V8_UNLIKELY(static_cast<uint32_t>(c0) > kMaxAscii)) { // A non-ascii character means we need to drop through to the slow // path. @@ -296,7 +296,8 @@ V8_INLINE Token::Value Scanner::ScanIdentifierOrKeywordInner() { if (V8_LIKELY(!IdentifierNeedsSlowPath(scan_flags))) { if (!CanBeKeyword(scan_flags)) return Token::IDENTIFIER; // Could be a keyword or identifier. - Vector<const uint8_t> chars = next().literal_chars.one_byte_literal(); + base::Vector<const uint8_t> chars = + next().literal_chars.one_byte_literal(); return KeywordOrIdentifierToken(chars.begin(), chars.length()); } @@ -304,7 +305,7 @@ V8_INLINE Token::Value Scanner::ScanIdentifierOrKeywordInner() { } else { // Special case for escapes at the start of an identifier. escaped = true; - uc32 c = ScanIdentifierUnicodeEscape(); + base::uc32 c = ScanIdentifierUnicodeEscape(); DCHECK(!IsIdentifierStart(Invalid())); if (c == '\\' || !IsIdentifierStart(c)) { return Token::ILLEGAL; @@ -453,7 +454,7 @@ V8_INLINE Token::Value Scanner::ScanSingleToken() { // / // /* /= Advance(); if (c0_ == '/') { - uc32 c = Peek(); + base::uc32 c = Peek(); if (c == '#' || c == '@') { Advance(); Advance(); diff --git a/deps/v8/src/parsing/scanner.cc b/deps/v8/src/parsing/scanner.cc index 8ee64a1696..b624694295 100644 --- a/deps/v8/src/parsing/scanner.cc +++ b/deps/v8/src/parsing/scanner.cc @@ -12,6 +12,7 @@ #include "src/ast/ast-value-factory.h" #include "src/base/platform/wrappers.h" +#include "src/base/strings.h" #include "src/numbers/conversions-inl.h" #include "src/objects/bigint.h" #include "src/parsing/parse-info.h" @@ -109,19 +110,19 @@ void Scanner::Initialize() { } // static -bool Scanner::IsInvalid(uc32 c) { +bool Scanner::IsInvalid(base::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) { +base::uc32 Scanner::ScanHexNumber(int expected_length) { DCHECK_LE(expected_length, 4); // prevent overflow int begin = source_pos() - 2; - uc32 x = 0; + base::uc32 x = 0; for (int i = 0; i < expected_length; i++) { - int d = HexValue(c0_); + int d = base::HexValue(c0_); if (d < 0) { ReportScannerError(Location(begin, begin + expected_length + 2), unicode @@ -137,9 +138,10 @@ uc32 Scanner::ScanHexNumber(int expected_length) { } template <bool capture_raw> -uc32 Scanner::ScanUnlimitedLengthHexNumber(uc32 max_value, int beg_pos) { - uc32 x = 0; - int d = HexValue(c0_); +base::uc32 Scanner::ScanUnlimitedLengthHexNumber(base::uc32 max_value, + int beg_pos) { + base::uc32 x = 0; + int d = base::HexValue(c0_); if (d < 0) return Invalid(); while (d >= 0) { @@ -150,7 +152,7 @@ uc32 Scanner::ScanUnlimitedLengthHexNumber(uc32 max_value, int beg_pos) { return Invalid(); } Advance<capture_raw>(); - d = HexValue(c0_); + d = base::HexValue(c0_); } return x; @@ -209,7 +211,7 @@ Token::Value Scanner::SkipSingleLineComment() { // separately by the lexical grammar and becomes part of the // stream of input elements for the syntactic grammar (see // ECMA-262, section 7.4). - AdvanceUntil([](uc32 c0_) { return unibrow::IsLineTerminator(c0_); }); + AdvanceUntil([](base::uc32 c0_) { return unibrow::IsLineTerminator(c0_); }); return Token::WHITESPACE; } @@ -237,11 +239,11 @@ void Scanner::TryToParseSourceURLComment() { Advance(); } if (!name.is_one_byte()) return; - Vector<const uint8_t> name_literal = name.one_byte_literal(); + base::Vector<const uint8_t> name_literal = name.one_byte_literal(); LiteralBuffer* value; - if (name_literal == StaticOneByteVector("sourceURL")) { + if (name_literal == base::StaticOneByteVector("sourceURL")) { value = &source_url_; - } else if (name_literal == StaticOneByteVector("sourceMappingURL")) { + } else if (name_literal == base::StaticOneByteVector("sourceMappingURL")) { value = &source_mapping_url_; } else { return; @@ -276,7 +278,7 @@ Token::Value Scanner::SkipMultiLineComment() { // Until we see the first newline, check for * and newline characters. if (!next().after_line_terminator) { do { - AdvanceUntil([](uc32 c0) { + AdvanceUntil([](base::uc32 c0) { if (V8_UNLIKELY(static_cast<uint32_t>(c0) > kMaxAscii)) { return unibrow::IsLineTerminator(c0); } @@ -301,7 +303,7 @@ Token::Value Scanner::SkipMultiLineComment() { // After we've seen newline, simply try to find '*/'. while (c0_ != kEndOfInput) { - AdvanceUntil([](uc32 c0) { return c0 == '*'; }); + AdvanceUntil([](base::uc32 c0) { return c0 == '*'; }); while (c0_ == '*') { Advance(); @@ -369,7 +371,7 @@ void Scanner::SeekForward(int pos) { template <bool capture_raw> bool Scanner::ScanEscape() { - uc32 c = c0_; + base::uc32 c = c0_; Advance<capture_raw>(); // Skip escaped newlines. @@ -425,9 +427,9 @@ bool Scanner::ScanEscape() { } template <bool capture_raw> -uc32 Scanner::ScanOctalEscape(uc32 c, int length) { +base::uc32 Scanner::ScanOctalEscape(base::uc32 c, int length) { DCHECK('0' <= c && c <= '7'); - uc32 x = c - '0'; + base::uc32 x = c - '0'; int i = 0; for (; i < length; i++) { int d = c0_ - '0'; @@ -451,11 +453,11 @@ uc32 Scanner::ScanOctalEscape(uc32 c, int length) { } Token::Value Scanner::ScanString() { - uc32 quote = c0_; + base::uc32 quote = c0_; next().literal_chars.Start(); while (true) { - AdvanceUntil([this](uc32 c0) { + AdvanceUntil([this](base::uc32 c0) { if (V8_UNLIKELY(static_cast<uint32_t>(c0) > kMaxAscii)) { if (V8_UNLIKELY(unibrow::IsStringLiteralLineTerminator(c0))) { return true; @@ -531,7 +533,7 @@ Token::Value Scanner::ScanTemplateSpan() { next().raw_literal_chars.Start(); const bool capture_raw = true; while (true) { - uc32 c = c0_; + base::uc32 c = c0_; if (c == '`') { Advance(); // Consume '`' result = Token::TEMPLATE_TAIL; @@ -547,7 +549,7 @@ Token::Value Scanner::ScanTemplateSpan() { if (unibrow::IsLineTerminator(c0_)) { // The TV of LineContinuation :: \ LineTerminatorSequence is the empty // code unit sequence. - uc32 lastChar = c0_; + base::uc32 lastChar = c0_; Advance(); if (lastChar == '\r') { // Also skip \n. @@ -610,7 +612,7 @@ Handle<String> Scanner::SourceMappingUrl(IsolateT* isolate) const { template Handle<String> Scanner::SourceMappingUrl(Isolate* isolate) const; template Handle<String> Scanner::SourceMappingUrl(LocalIsolate* isolate) const; -bool Scanner::ScanDigitsWithNumericSeparators(bool (*predicate)(uc32 ch), +bool Scanner::ScanDigitsWithNumericSeparators(bool (*predicate)(base::uc32 ch), bool is_check_first_digit) { // we must have at least one digit after 'x'/'b'/'o' if (is_check_first_digit && !predicate(c0_)) return false; @@ -670,7 +672,7 @@ bool Scanner::ScanDecimalAsSmiWithNumericSeparators(uint64_t* value) { } separator_seen = false; *value = 10 * *value + (c0_ - '0'); - uc32 first_char = c0_; + base::uc32 first_char = c0_; Advance(); AddLiteralChar(first_char); } @@ -691,7 +693,7 @@ bool Scanner::ScanDecimalAsSmi(uint64_t* value, bool allow_numeric_separator) { while (IsDecimalDigit(c0_)) { *value = 10 * *value + (c0_ - '0'); - uc32 first_char = c0_; + base::uc32 first_char = c0_; Advance(); AddLiteralChar(first_char); } @@ -869,7 +871,7 @@ Token::Value Scanner::ScanNumber(bool seen_period) { return is_bigint ? Token::BIGINT : Token::NUMBER; } -uc32 Scanner::ScanIdentifierUnicodeEscape() { +base::uc32 Scanner::ScanIdentifierUnicodeEscape() { Advance(); if (c0_ != 'u') return Invalid(); Advance(); @@ -877,13 +879,13 @@ uc32 Scanner::ScanIdentifierUnicodeEscape() { } template <bool capture_raw> -uc32 Scanner::ScanUnicodeEscape() { +base::uc32 Scanner::ScanUnicodeEscape() { // Accept both \uxxxx and \u{xxxxxx}. In the latter case, the number of // hex digits between { } is arbitrary. \ and u have already been read. if (c0_ == '{') { int begin = source_pos() - 2; Advance<capture_raw>(); - uc32 cp = + base::uc32 cp = ScanUnlimitedLengthHexNumber<capture_raw>(String::kMaxCodePoint, begin); if (cp == kInvalidSequence || c0_ != '}') { ReportScannerError(source_pos(), @@ -902,7 +904,7 @@ Token::Value Scanner::ScanIdentifierOrKeywordInnerSlow(bool escaped, while (true) { if (c0_ == '\\') { escaped = true; - uc32 c = ScanIdentifierUnicodeEscape(); + base::uc32 c = ScanIdentifierUnicodeEscape(); // Only allow legal identifier part characters. // TODO(verwaest): Make this true. // DCHECK(!IsIdentifierPart('\')); @@ -922,7 +924,7 @@ Token::Value Scanner::ScanIdentifierOrKeywordInnerSlow(bool escaped, } if (can_be_keyword && next().literal_chars.is_one_byte()) { - Vector<const uint8_t> chars = next().literal_chars.one_byte_literal(); + base::Vector<const uint8_t> chars = next().literal_chars.one_byte_literal(); Token::Value token = KeywordOrIdentifierToken(chars.begin(), chars.length()); if (base::IsInRange(token, Token::IDENTIFIER, Token::YIELD)) return token; @@ -1043,10 +1045,10 @@ double Scanner::DoubleValue() { const char* Scanner::CurrentLiteralAsCString(Zone* zone) const { DCHECK(is_literal_one_byte()); - Vector<const uint8_t> vector = literal_one_byte_string(); + base::Vector<const uint8_t> vector = literal_one_byte_string(); int length = vector.length(); char* buffer = zone->NewArray<char>(length + 1); - base::Memcpy(buffer, vector.begin(), length); + memcpy(buffer, vector.begin(), length); buffer[length] = '\0'; return buffer; } diff --git a/deps/v8/src/parsing/scanner.h b/deps/v8/src/parsing/scanner.h index d93f581366..3474f7270d 100644 --- a/deps/v8/src/parsing/scanner.h +++ b/deps/v8/src/parsing/scanner.h @@ -12,6 +12,7 @@ #include "include/v8.h" #include "src/base/logging.h" +#include "src/base/strings.h" #include "src/common/globals.h" #include "src/common/message-template.h" #include "src/parsing/literal-buffer.h" @@ -39,7 +40,7 @@ class Zone; // or one part of a surrogate pair that make a single 21 bit code point. class Utf16CharacterStream { public: - static constexpr uc32 kEndOfInput = static_cast<uc32>(-1); + static constexpr base::uc32 kEndOfInput = static_cast<base::uc32>(-1); virtual ~Utf16CharacterStream() = default; @@ -50,11 +51,11 @@ class Utf16CharacterStream { V8_INLINE void reset_parser_error_flag() { has_parser_error_ = false; } V8_INLINE bool has_parser_error() const { return has_parser_error_; } - inline uc32 Peek() { + inline base::uc32 Peek() { if (V8_LIKELY(buffer_cursor_ < buffer_end_)) { - return static_cast<uc32>(*buffer_cursor_); + return static_cast<base::uc32>(*buffer_cursor_); } else if (ReadBlockChecked()) { - return static_cast<uc32>(*buffer_cursor_); + return static_cast<base::uc32>(*buffer_cursor_); } else { return kEndOfInput; } @@ -62,8 +63,8 @@ class Utf16CharacterStream { // Returns and advances past the next UTF-16 code unit in the input // stream. If there are no more code units it returns kEndOfInput. - inline uc32 Advance() { - uc32 result = Peek(); + inline base::uc32 Advance() { + base::uc32 result = Peek(); buffer_cursor_++; return result; } @@ -72,11 +73,11 @@ class Utf16CharacterStream { // that meets the checks requirement. If there are no more code units it // returns kEndOfInput. template <typename FunctionType> - V8_INLINE uc32 AdvanceUntil(FunctionType check) { + V8_INLINE base::uc32 AdvanceUntil(FunctionType check) { while (true) { auto next_cursor_pos = std::find_if(buffer_cursor_, buffer_end_, [&check](uint16_t raw_c0_) { - uc32 c0_ = static_cast<uc32>(raw_c0_); + base::uc32 c0_ = static_cast<base::uc32>(raw_c0_); return check(c0_); }); @@ -88,7 +89,7 @@ class Utf16CharacterStream { } } else { buffer_cursor_ = next_cursor_pos + 1; - return static_cast<uc32>(*next_cursor_pos); + return static_cast<base::uc32>(*next_cursor_pos); } } } @@ -267,11 +268,11 @@ class V8_EXPORT_PRIVATE Scanner { }; // -1 is outside of the range of any real source code. - static constexpr uc32 kEndOfInput = Utf16CharacterStream::kEndOfInput; - static constexpr uc32 kInvalidSequence = static_cast<uc32>(-1); + static constexpr base::uc32 kEndOfInput = Utf16CharacterStream::kEndOfInput; + static constexpr base::uc32 kInvalidSequence = static_cast<base::uc32>(-1); - static constexpr uc32 Invalid() { return Scanner::kInvalidSequence; } - static bool IsInvalid(uc32 c); + static constexpr base::uc32 Invalid() { return Scanner::kInvalidSequence; } + static bool IsInvalid(base::uc32 c); explicit Scanner(Utf16CharacterStream* source, UnoptimizedCompileFlags flags); @@ -350,7 +351,7 @@ class V8_EXPORT_PRIVATE Scanner { if (!is_next_literal_one_byte()) return false; if (peek_location().length() != N + 1) return false; - Vector<const uint8_t> next = next_literal_one_byte_string(); + base::Vector<const uint8_t> next = next_literal_one_byte_string(); const char* chars = reinterpret_cast<const char*>(next.begin()); return next.length() == N - 1 && strncmp(s, chars, N - 1) == 0; } @@ -360,7 +361,7 @@ class V8_EXPORT_PRIVATE Scanner { DCHECK(current().CanAccessLiteral()); if (!is_literal_one_byte()) return false; - Vector<const uint8_t> current = literal_one_byte_string(); + base::Vector<const uint8_t> current = literal_one_byte_string(); const char* chars = reinterpret_cast<const char*>(current.begin()); return current.length() == N - 1 && strncmp(s, chars, N - 1) == 0; } @@ -471,7 +472,7 @@ class V8_EXPORT_PRIVATE Scanner { // Scans octal escape sequence. Also accepts "\0" decimal escape sequence. template <bool capture_raw> - uc32 ScanOctalEscape(uc32 c, int length); + base::uc32 ScanOctalEscape(base::uc32 c, int length); // Call this after setting source_ to the input. void Init() { @@ -502,11 +503,13 @@ class V8_EXPORT_PRIVATE Scanner { // Seek to the next_ token at the given position. void SeekNext(size_t position); - V8_INLINE void AddLiteralChar(uc32 c) { next().literal_chars.AddChar(c); } + V8_INLINE void AddLiteralChar(base::uc32 c) { + next().literal_chars.AddChar(c); + } V8_INLINE void AddLiteralChar(char c) { next().literal_chars.AddChar(c); } - V8_INLINE void AddRawLiteralChar(uc32 c) { + V8_INLINE void AddRawLiteralChar(base::uc32 c) { next().raw_literal_chars.AddChar(c); } @@ -532,7 +535,7 @@ class V8_EXPORT_PRIVATE Scanner { bool CombineSurrogatePair() { DCHECK(!unibrow::Utf16::IsLeadSurrogate(kEndOfInput)); if (unibrow::Utf16::IsLeadSurrogate(c0_)) { - uc32 c1 = source_->Advance(); + base::uc32 c1 = source_->Advance(); DCHECK(!unibrow::Utf16::IsTrailSurrogate(kEndOfInput)); if (unibrow::Utf16::IsTrailSurrogate(c1)) { c0_ = unibrow::Utf16::CombineSurrogatePair(c0_, c1); @@ -543,21 +546,22 @@ class V8_EXPORT_PRIVATE Scanner { return false; } - void PushBack(uc32 ch) { + void PushBack(base::uc32 ch) { DCHECK(IsInvalid(c0_) || base::IsInRange(c0_, 0u, unibrow::Utf16::kMaxNonSurrogateCharCode)); source_->Back(); c0_ = ch; } - uc32 Peek() const { return source_->Peek(); } + base::uc32 Peek() const { return source_->Peek(); } inline Token::Value Select(Token::Value tok) { Advance(); return tok; } - inline Token::Value Select(uc32 next, Token::Value then, Token::Value else_) { + inline Token::Value Select(base::uc32 next, Token::Value then, + Token::Value else_) { Advance(); if (c0_ == next) { Advance(); @@ -579,12 +583,12 @@ class V8_EXPORT_PRIVATE Scanner { // requested for tokens that do not have a literal. Hence, we treat any // token as a one-byte literal. E.g. Token::FUNCTION pretends to have a // literal "function". - Vector<const uint8_t> literal_one_byte_string() const { + base::Vector<const uint8_t> literal_one_byte_string() const { DCHECK(current().CanAccessLiteral() || Token::IsKeyword(current().token) || current().token == Token::ESCAPED_KEYWORD); return current().literal_chars.one_byte_literal(); } - Vector<const uint16_t> literal_two_byte_string() const { + base::Vector<const uint16_t> literal_two_byte_string() const { DCHECK(current().CanAccessLiteral() || Token::IsKeyword(current().token) || current().token == Token::ESCAPED_KEYWORD); return current().literal_chars.two_byte_literal(); @@ -596,11 +600,11 @@ class V8_EXPORT_PRIVATE Scanner { } // Returns the literal string for the next token (the token that // would be returned if Next() were called). - Vector<const uint8_t> next_literal_one_byte_string() const { + base::Vector<const uint8_t> next_literal_one_byte_string() const { DCHECK(next().CanAccessLiteral()); return next().literal_chars.one_byte_literal(); } - Vector<const uint16_t> next_literal_two_byte_string() const { + base::Vector<const uint16_t> next_literal_two_byte_string() const { DCHECK(next().CanAccessLiteral()); return next().literal_chars.two_byte_literal(); } @@ -608,11 +612,11 @@ class V8_EXPORT_PRIVATE Scanner { DCHECK(next().CanAccessLiteral()); return next().literal_chars.is_one_byte(); } - Vector<const uint8_t> raw_literal_one_byte_string() const { + base::Vector<const uint8_t> raw_literal_one_byte_string() const { DCHECK(current().CanAccessRawLiteral()); return current().raw_literal_chars.one_byte_literal(); } - Vector<const uint16_t> raw_literal_two_byte_string() const { + base::Vector<const uint16_t> raw_literal_two_byte_string() const { DCHECK(current().CanAccessRawLiteral()); return current().raw_literal_chars.two_byte_literal(); } @@ -622,12 +626,12 @@ class V8_EXPORT_PRIVATE Scanner { } template <bool capture_raw, bool unicode = false> - uc32 ScanHexNumber(int expected_length); + base::uc32 ScanHexNumber(int expected_length); // Scan a number of any length but not bigger than max_value. For example, the // number can be 000000001, so it's very long in characters but its value is // small. template <bool capture_raw> - uc32 ScanUnlimitedLengthHexNumber(uc32 max_value, int beg_pos); + base::uc32 ScanUnlimitedLengthHexNumber(base::uc32 max_value, int beg_pos); // Scans a single JavaScript token. V8_INLINE Token::Value ScanSingleToken(); @@ -647,7 +651,7 @@ class V8_EXPORT_PRIVATE Scanner { // Scans a possible HTML comment -- begins with '<!'. Token::Value ScanHtmlComment(); - bool ScanDigitsWithNumericSeparators(bool (*predicate)(uc32 ch), + bool ScanDigitsWithNumericSeparators(bool (*predicate)(base::uc32 ch), bool is_check_first_digit); bool ScanDecimalDigits(bool allow_numeric_separator); // Optimized function to scan decimal number as Smi. @@ -676,10 +680,10 @@ class V8_EXPORT_PRIVATE Scanner { // Decodes a Unicode escape-sequence which is part of an identifier. // If the escape sequence cannot be decoded the result is kBadChar. - uc32 ScanIdentifierUnicodeEscape(); + base::uc32 ScanIdentifierUnicodeEscape(); // Helper for the above functions. template <bool capture_raw> - uc32 ScanUnicodeEscape(); + base::uc32 ScanUnicodeEscape(); Token::Value ScanTemplateSpan(); @@ -718,7 +722,7 @@ class V8_EXPORT_PRIVATE Scanner { Utf16CharacterStream* const source_; // One Unicode character look-ahead; c0_ < 0 at the end of the input. - uc32 c0_; + base::uc32 c0_; TokenDesc token_storage_[3]; |