diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index e8ca1b5b46fa72..4904bcb6615a45 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 12 #define V8_MINOR_VERSION 8 #define V8_BUILD_NUMBER 374 -#define V8_PATCH_LEVEL 22 +#define V8_PATCH_LEVEL 31 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/ast/ast-function-literal-id-reindexer.cc b/deps/v8/src/ast/ast-function-literal-id-reindexer.cc index c0892994528850..7c5030d090c7ea 100644 --- a/deps/v8/src/ast/ast-function-literal-id-reindexer.cc +++ b/deps/v8/src/ast/ast-function-literal-id-reindexer.cc @@ -31,13 +31,6 @@ void AstFunctionLiteralIdReindexer::VisitFunctionLiteral(FunctionLiteral* lit) { lit->set_function_literal_id(lit->function_literal_id() + delta_); } -void AstFunctionLiteralIdReindexer::VisitCall(Call* expr) { - AstTraversalVisitor::VisitCall(expr); - if (expr->is_possibly_eval()) { - expr->adjust_eval_scope_info_index(delta_); - } -} - void AstFunctionLiteralIdReindexer::VisitClassLiteral(ClassLiteral* expr) { // Manually visit the class literal so that we can change the property walk. // This should be kept in-sync with AstTraversalVisitor::VisitClassLiteral. diff --git a/deps/v8/src/ast/ast-function-literal-id-reindexer.h b/deps/v8/src/ast/ast-function-literal-id-reindexer.h index f7a41e0a9a5314..21eaeafd20273f 100644 --- a/deps/v8/src/ast/ast-function-literal-id-reindexer.h +++ b/deps/v8/src/ast/ast-function-literal-id-reindexer.h @@ -30,7 +30,6 @@ class AstFunctionLiteralIdReindexer final // AstTraversalVisitor implementation. void VisitFunctionLiteral(FunctionLiteral* lit); void VisitClassLiteral(ClassLiteral* lit); - void VisitCall(Call* lit); private: int delta_; diff --git a/deps/v8/src/ast/ast.h b/deps/v8/src/ast/ast.h index 53976fed46997b..5c1004c99a05c3 100644 --- a/deps/v8/src/ast/ast.h +++ b/deps/v8/src/ast/ast.h @@ -1731,7 +1731,7 @@ class CallBase : public Expression { class Call final : public CallBase { public: bool is_possibly_eval() const { - return EvalScopeInfoIndexField::decode(bit_field_) > 0; + return IsPossiblyEvalField::decode(bit_field_); } bool is_tagged_template() const { @@ -1742,15 +1742,6 @@ class Call final : public CallBase { return IsOptionalChainLinkField::decode(bit_field_); } - uint32_t eval_scope_info_index() const { - return EvalScopeInfoIndexField::decode(bit_field_); - } - - void adjust_eval_scope_info_index(int delta) { - bit_field_ = EvalScopeInfoIndexField::update( - bit_field_, eval_scope_info_index() + delta); - } - enum CallType { GLOBAL_CALL, WITH_CALL, @@ -1766,6 +1757,11 @@ class Call final : public CallBase { OTHER_CALL, }; + enum PossiblyEval { + IS_POSSIBLY_EVAL, + NOT_EVAL, + }; + // Helpers to determine how to handle the call. CallType GetCallType() const; @@ -1777,26 +1773,26 @@ class Call final : public CallBase { Call(Zone* zone, Expression* expression, const ScopedPtrList& arguments, int pos, bool has_spread, - int eval_scope_info_index, bool optional_chain) + PossiblyEval possibly_eval, bool optional_chain) : CallBase(zone, kCall, expression, arguments, pos, has_spread) { - bit_field_ |= IsTaggedTemplateField::encode(false) | - IsOptionalChainLinkField::encode(optional_chain) | - EvalScopeInfoIndexField::encode(eval_scope_info_index); - DCHECK_EQ(eval_scope_info_index > 0, is_possibly_eval()); + bit_field_ |= + IsPossiblyEvalField::encode(possibly_eval == IS_POSSIBLY_EVAL) | + IsTaggedTemplateField::encode(false) | + IsOptionalChainLinkField::encode(optional_chain); } Call(Zone* zone, Expression* expression, const ScopedPtrList& arguments, int pos, TaggedTemplateTag tag) : CallBase(zone, kCall, expression, arguments, pos, false) { - bit_field_ |= IsTaggedTemplateField::encode(true) | - IsOptionalChainLinkField::encode(false) | - EvalScopeInfoIndexField::encode(0); + bit_field_ |= IsPossiblyEvalField::encode(false) | + IsTaggedTemplateField::encode(true) | + IsOptionalChainLinkField::encode(false); } - using IsTaggedTemplateField = CallBase::NextBitField; + using IsPossiblyEvalField = CallBase::NextBitField; + using IsTaggedTemplateField = IsPossiblyEvalField::Next; using IsOptionalChainLinkField = IsTaggedTemplateField::Next; - using EvalScopeInfoIndexField = IsOptionalChainLinkField::Next; }; class CallNew final : public CallBase { @@ -3188,11 +3184,12 @@ class AstNodeFactory final { Call* NewCall(Expression* expression, const ScopedPtrList& arguments, int pos, - bool has_spread, int eval_scope_info_index = 0, + bool has_spread, + Call::PossiblyEval possibly_eval = Call::NOT_EVAL, bool optional_chain = false) { - DCHECK_IMPLIES(eval_scope_info_index > 0, !optional_chain); + DCHECK_IMPLIES(possibly_eval == Call::IS_POSSIBLY_EVAL, !optional_chain); return zone_->New(zone_, expression, arguments, pos, has_spread, - eval_scope_info_index, optional_chain); + possibly_eval, optional_chain); } SuperCallForwardArgs* NewSuperCallForwardArgs(SuperCallReference* expression, diff --git a/deps/v8/src/ast/scopes.cc b/deps/v8/src/ast/scopes.cc index e2b2405aaae8fb..109ce824b57f51 100644 --- a/deps/v8/src/ast/scopes.cc +++ b/deps/v8/src/ast/scopes.cc @@ -2607,23 +2607,6 @@ void ModuleScope::AllocateModuleVariables() { } } -// Needs to be kept in sync with ScopeInfo::UniqueIdInScript. -int Scope::UniqueIdInScript() const { - // Script scopes start "before" the script to avoid clashing with a scope that - // starts on character 0. - if (is_script_scope() || scope_type() == EVAL_SCOPE || - scope_type() == MODULE_SCOPE) { - return -1; - } - if (is_declaration_scope()) { - // Default constructors have the same start position as their parent class - // scope. Use the next char position to distinguish this scope. - return start_position() + - IsDefaultConstructor(AsDeclarationScope()->function_kind()); - } - return start_position(); -} - void Scope::AllocateVariablesRecursively() { this->ForEach([](Scope* scope) -> Iteration { DCHECK(!scope->already_resolved_); @@ -2675,63 +2658,33 @@ void Scope::AllocateVariablesRecursively() { } template -void Scope::AllocateScopeInfosRecursively( - IsolateT* isolate, MaybeHandle outer_scope, - std::unordered_map>& scope_infos_to_reuse) { +void Scope::AllocateScopeInfosRecursively(IsolateT* isolate, + MaybeHandle outer_scope) { DCHECK(scope_info_.is_null()); MaybeHandle next_outer_scope = outer_scope; - auto it = scope_infos_to_reuse.find(UniqueIdInScript()); - if (it != scope_infos_to_reuse.end()) { - scope_info_ = it->second; - CHECK(NeedsContext()); - // The ScopeInfo chain mirrors the context chain, so we only link to the - // next outer scope that needs a context. - next_outer_scope = scope_info_; - DCHECK(!scope_info_.is_null()); - DCHECK(!is_hidden_catch_scope()); - CHECK_EQ(scope_info_->scope_type(), scope_type_); - CHECK_EQ(scope_info_->ContextLength(), num_heap_slots_); -#ifdef DEBUG - // Consume the scope info. - it->second = {}; -#endif - } else if (NeedsScopeInfo()) { -#ifdef DEBUG - // Mark this ID as being used. Skip hidden scopes because they are - // synthetic, unreusable, but hard to make unique. - if (v8_flags.reuse_scope_infos && !is_hidden_catch_scope()) { - scope_infos_to_reuse[UniqueIdInScript()] = {}; - } -#endif + if (NeedsScopeInfo()) { scope_info_ = ScopeInfo::Create(isolate, zone(), this, outer_scope); - DCHECK_EQ(UniqueIdInScript(), scope_info_->UniqueIdInScript()); - // The ScopeInfo chain mirrors the context chain, so we only link to the - // next outer scope that needs a context. + // The ScopeInfo chain should mirror the context chain, so we only link to + // the next outer scope that needs a context. if (NeedsContext()) next_outer_scope = scope_info_; } // Allocate ScopeInfos for inner scopes. for (Scope* scope = inner_scope_; scope != nullptr; scope = scope->sibling_) { - DCHECK_GT(scope->UniqueIdInScript(), UniqueIdInScript()); - DCHECK_IMPLIES(scope->sibling_, scope->sibling_->UniqueIdInScript() != - scope->UniqueIdInScript()); if (!scope->is_function_scope() || scope->AsDeclarationScope()->ShouldEagerCompile()) { - scope->AllocateScopeInfosRecursively(isolate, next_outer_scope, - scope_infos_to_reuse); + scope->AllocateScopeInfosRecursively(isolate, next_outer_scope); } } } template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) void Scope:: - AllocateScopeInfosRecursively( - Isolate* isolate, MaybeHandle outer_scope, - std::unordered_map>& scope_infos_to_reuse); + AllocateScopeInfosRecursively(Isolate* isolate, + MaybeHandle outer_scope); template EXPORT_TEMPLATE_DEFINE(V8_EXPORT_PRIVATE) void Scope:: AllocateScopeInfosRecursively( - LocalIsolate* isolate, MaybeHandle outer_scope, - std::unordered_map>& scope_infos_to_reuse); + LocalIsolate* isolate, MaybeHandle outer_scope); void DeclarationScope::RecalcPrivateNameContextChain() { // The outermost scope in a class heritage expression is marked to skip the @@ -2776,9 +2729,7 @@ void DeclarationScope::RecordNeedsPrivateNameContextChainRecalc() { // static template -void DeclarationScope::AllocateScopeInfos(ParseInfo* info, - Handle