36static_assert(
sizeof(VariableMap) == (
sizeof(
void*) + 2 *
sizeof(uint32_t) +
37 sizeof(ZoneAllocationPolicy)),
38 "Empty base optimization didn't kick in for VariableMap");
58 *was_added = p->
value ==
nullptr;
64 maybe_assigned_flag, is_static_flag);
98 : outer_scope_(nullptr), variables_(zone), scope_type_(scope_type) {
104 : outer_scope_(outer_scope), variables_(zone), scope_type_(scope_type) {
123 return home_object_variable;
129 Variable* static_home_object_variable =
130 Declare(
zone(), ast_value_factory->dot_static_home_object_string(),
137 return static_home_object_variable;
157 :
Scope(zone, outer_scope, scope_type),
158 function_kind_(function_kind),
170 avfactory->single_parse_zone())) {
179 module_descriptor_(nullptr) {
185 rare_data_and_is_parsing_heritage_(nullptr),
186 is_anonymous_class_(is_anonymous) {
190template <
typename IsolateT>
195 rare_data_and_is_parsing_heritage_(nullptr) {
197 if (
scope_info->ClassScopeHasPrivateBrand()) {
209 std::tie(name, index) =
scope_info->SavedClassVariable();
237 : outer_scope_(nullptr),
240 scope_type_(scope_type) {
244 already_resolved_ =
true;
249 scope_info->PrivateNameLookupSkipsOuterClass();
258 int home_object_index =
scope_info->ContextSlotIndex(
259 ast_value_factory->dot_home_object_string()->string());
262 if (home_object_index >= 0) {
271 :
Scope(zone, scope_type, ast_value_factory, scope_info),
272 function_kind_(scope_info->function_kind()),
280 if (
scope_info->ClassScopeHasPrivateBrand()) {
288 : outer_scope_(nullptr),
294 already_resolved_ =
true;
310#if V8_ENABLE_WEBASSEMBLY
311 is_asm_module_ =
false;
335 is_being_lazily_parsed_ =
336 outer_declaration_scope ? outer_declaration_scope->is_being_lazily_parsed_
343 scope_name_ =
nullptr;
344 already_resolved_ =
false;
345 needs_migration_ =
false;
392#if V8_ENABLE_WEBASSEMBLY
393void DeclarationScope::set_is_asm_module() { is_asm_module_ =
true; }
395bool Scope::IsAsmModule()
const {
399bool Scope::ContainsAsmModule()
const {
400 if (IsAsmModule())
return true;
405 if (!scope->is_function_scope() ||
406 scope->AsDeclarationScope()->ShouldEagerCompile()) {
407 if (scope->ContainsAsmModule())
return true;
415template <
typename IsolateT>
423 Scope* current_scope =
nullptr;
424 Scope* innermost_scope =
nullptr;
451#if V8_ENABLE_WEBASSEMBLY
496 if (current_scope !=
nullptr) {
500 if (innermost_scope ==
nullptr) innermost_scope = current_scope;
509 if (innermost_scope ==
nullptr)
return script_scope;
511 return innermost_scope;
514template <
typename IsolateT>
519 isolate->factory()->global_this_binding_scope_info());
536 DeserializationMode deserialization_mode,
ParseInfo* parse_info);
541 DeserializationMode deserialization_mode,
ParseInfo* parse_info);
586 DCHECK_EQ(factory ==
nullptr, is_being_lazily_parsed_);
603 const AstRawString* name = sloppy_block_function->name();
610 if (maybe_parameter !=
nullptr && maybe_parameter->
is_parameter()) {
616 bool should_hoist =
true;
628 should_hoist =
false;
634 if (!should_hoist)
continue;
637 DCHECK(!is_being_lazily_parsed_);
638 int pos = sloppy_block_function->position();
666 sloppy_block_function->init(), target, source,
pos);
669 sloppy_block_function->set_statement(
statement);
671 DCHECK(is_being_lazily_parsed_);
674 if (sloppy_block_function->init() == Token::kAssign) {
689 RuntimeCallCounterId::kCompileScopeAnalysis,
690 RuntimeCallStats::kThreadSpecific);
694 std::optional<AllowHandleDereference> allow_deref;
697 allow_deref.emplace();
719 allow_deref.emplace();
720 info->consumed_preparse_data()->RestoreScopeAllocationData(
721 scope, info->ast_value_factory(), info->
zone());
729 PrintF(
"Global scope:\n");
732 scope->CheckScopePositions();
745 this, ast_value_factory->this_string(),
753 if (derived_constructor) {
755 Variable::kHasHoleCheckUseInUnknownScope);
776 bool was_added =
false;
816 if (cache ==
nullptr) {
868 while (scope->
sibling_ !=
nullptr) {
902 DCHECK(!already_resolved_);
977 index =
scope_info->ContextSlotIndex(name->string(), &lookup_result);
990 index =
scope_info->FunctionContextSlotIndex(name_handle);
991 if (index < 0)
return nullptr;
995 return cache->variables_.Lookup(name);
1003 Variable* var = cache->variables_.Declare(
1014 bool is_optional,
bool is_rest,
1017 DCHECK(!already_resolved_);
1020 DCHECK(!is_optional || !is_rest);
1021 DCHECK(!is_being_lazily_parsed_);
1022 DCHECK(!was_lazily_parsed_);
1031 has_rest_ = is_rest;
1033 params_.Add(var,
zone());
1034 if (!is_rest) ++num_parameters_;
1035 if (name == ast_value_factory->arguments_string()) {
1036 has_arguments_parameter_ =
true;
1047 DCHECK(!already_resolved_);
1049 DCHECK(is_being_lazily_parsed_);
1051 has_rest_ = is_rest;
1052 if (!is_rest) ++num_parameters_;
1058 DCHECK(!already_resolved_);
1094 bool* was_added,
bool* sloppy_mode_block_scope_function_redefinition,
1099 DCHECK(!already_resolved_);
1106 sloppy_mode_block_scope_function_redefinition, ok);
1117 *was_added = var ==
nullptr;
1158 *sloppy_mode_block_scope_function_redefinition = *ok;
1181 DCHECK(!already_resolved_);
1214 DCHECK(!already_resolved_);
1229 DCHECK_IMPLIES(already_resolved_, reparsing_for_class_initializer_);
1239 return cache->variables_.Declare(
1265 bool* allowed_catch_binding_var_redeclaration) {
1266 if (has_checked_syntax_)
return nullptr;
1271 if (decl->IsVariableDeclaration() &&
1272 decl->AsVariableDeclaration()->AsNested() !=
nullptr) {
1273 Scope* current = decl->AsVariableDeclaration()->AsNested()->scope();
1280 Variable* other_var = current->LookupLocal(decl->var()->raw_name());
1281 if (current->is_catch_scope()) {
1282 *allowed_catch_binding_var_redeclaration |= other_var !=
nullptr;
1283 current = current->outer_scope();
1286 if (other_var !=
nullptr) {
1290 current = current->outer_scope();
1291 }
while (current !=
this);
1316 current->LookupInScopeOrScopeInfo(decl->var()->raw_name(), current);
1317 if (other_var !=
nullptr && !current->is_catch_scope()) {
1325 current = current->outer_scope();
1326 }
while (current !=
end);
1335 p = variables.Next(p)) {
1338 if (var !=
nullptr && var->
mode() <= mode_limit)
return name;
1348 DCHECK(has_this_declaration());
1349 DeclareThis(ast_value_factory);
1364 if (!private_name_scope_iter.
Done() &&
1366 DCHECK(info->pending_error_handler()->has_pending_error());
1371 DCHECK(info->pending_error_handler()->has_pending_error());
1391 if (!scope->is_declaration_scope() ||
1392 !scope->AsDeclarationScope()->has_this_declaration()) {
1393 if (scope->HasThisReference())
return true;
1401 const Scope* outer)
const {
1412 if (s->is_eval_scope())
return is_sloppy(s->language_mode());
1414 if (s->is_catch_scope())
continue;
1416 if (s->is_with_scope())
continue;
1417 DCHECK(s->is_module_scope() || s->is_block_scope() ||
1418 s->is_function_scope());
1427 return !force_eager_compilation_ &&
1435 if (s->NeedsContext()) n++;
1445 if (!s->NeedsContext())
continue;
1447 if (s->is_declaration_scope() &&
1448 s->AsDeclarationScope()->sloppy_eval_can_extend_vars()) {
1457 Scope* scope =
this;
1465 Scope* scope =
this;
1473 const Scope* scope =
this;
1481 Scope* scope =
this;
1489 DCHECK(!already_resolved_);
1502 Scope* scope =
this;
1512 Scope* scope =
this;
1516 if (scope ==
nullptr) {
1543 Scope* scope =
this;
1559bool WasLazilyParsed(
Scope* scope) {
1566template <
typename FunctionType>
1568 Scope* scope =
this;
1576 while (scope->
sibling_ ==
nullptr) {
1577 if (scope ==
this)
return;
1580 if (scope ==
this)
return;
1592 Scope* scope = other;
1594 if (scope ==
this)
return true;
1603 bool maybe_in_arrowhead) {
1604 this->
ForEach([max_outer_scope, ast_node_factory, new_unresolved_list,
1605 maybe_in_arrowhead](
Scope* scope) {
1608 if (WasLazilyParsed(scope)) {
1614 proxy !=
nullptr; proxy = proxy->next_unresolved()) {
1615 if (proxy->is_removed_from_unresolved())
continue;
1616 DCHECK(!proxy->is_resolved());
1619 if (var ==
nullptr) {
1624 maybe_in_arrowhead) {
1626 new_unresolved_list->
Add(copy);
1645 params_.DropAndClear();
1646 num_parameters_ = 0;
1651 sloppy_block_functions_.Clear();
1652 rare_data_ =
nullptr;
1669 has_simple_parameters_ =
true;
1670 DeclareDefaultFunctionVariables(ast_value_factory);
1675 needs_migration_ =
false;
1676 is_being_lazily_parsed_ =
false;
1679 was_lazily_parsed_ = !aborted;
1707 if (preparse_data_builder_ ==
nullptr)
return;
1708 preparse_data_builder_->SaveScopeAllocationData(
this, parser);
1713 bool maybe_in_arrowhead) {
1714 DCHECK(!force_eager_compilation_);
1735 const bool has_inner_functions = preparse_data_builder_ !=
nullptr &&
1736 preparse_data_builder_->HasInnerFunctions();
1737 if (maybe_in_arrowhead || !is_top_level_function || has_inner_functions) {
1742 maybe_in_arrowhead);
1754 PrintF(
"Inner function scope:\n");
1798 return "shadowrealm";
1803void Indent(
int n,
const char* str) {
PrintF(
"%*s%s", n,
"", str); }
1805void PrintName(
const AstRawString* name) {
1806 PrintF(
"%.*s", name->length(), name->raw_data());
1810 switch (var->location()) {
1814 PrintF(
"parameter[%d]", var->index());
1817 PrintF(
"local[%d]", var->index());
1820 PrintF(
"context[%d]", var->index());
1829 PrintF(
"repl global[%d]", var->index());
1834void PrintVar(
int indent,
Variable* var) {
1835 Indent(indent, VariableMode2String(var->mode()));
1837 if (var->raw_name()->IsEmpty())
1838 PrintF(
".%p",
reinterpret_cast<void*
>(var));
1840 PrintName(var->raw_name());
1841 PrintF(
"; // (%p) ",
reinterpret_cast<void*
>(var));
1843 bool comma = !var->IsUnallocated();
1844 if (var->has_forced_context_allocation()) {
1846 PrintF(
"forced context allocation");
1851 PrintF(
"never assigned");
1855 !var->binding_needs_init()) {
1857 PrintF(
"hole initialization elided");
1862void PrintMap(
int indent,
const char*
label, VariableMap* map,
bool locals,
1864 bool printed_label =
false;
1867 if (var == function_var)
continue;
1869 if ((
locals ? local : !local) &&
1870 (var->is_used() || !var->IsUnallocated())) {
1871 if (!printed_label) {
1872 Indent(indent,
label);
1873 printed_label =
true;
1875 PrintVar(indent, var);
1882void DeclarationScope::PrintParameters() {
1884 for (
int i = 0;
i < params_.
length();
i++) {
1886 const AstRawString* name = params_[
i]->raw_name();
1887 if (name->IsEmpty()) {
1888 PrintF(
".%p",
reinterpret_cast<void*
>(params_[
i]));
1896void Scope::Print(
int n) {
1897 int n0 = (n > 0 ?
n : 0);
1905 if (scope_name_ !=
nullptr && !scope_name_->IsEmpty()) {
1907 PrintName(scope_name_);
1917 PrintF(
" { // (%p) (%d, %d)\n",
reinterpret_cast<void*
>(
this),
1920 Indent(n1,
"// is hidden\n");
1924 if (function !=
nullptr) {
1925 Indent(n1,
"// (local) function name: ");
1926 PrintName(function->raw_name());
1932 Indent(n1,
"// strict mode scope\n");
1934#if V8_ENABLE_WEBASSEMBLY
1935 if (IsAsmModule()) Indent(n1,
"// scope is an asm module\n");
1939 Indent(n1,
"// scope calls sloppy 'eval'\n");
1942 Indent(n1,
"// scope skips outer class for #-names\n");
1947 if (scope->was_lazily_parsed()) Indent(n1,
"// lazily parsed\n");
1948 if (scope->ShouldEagerCompile()) Indent(n1,
"// will be compiled\n");
1949 if (scope->needs_private_name_context_chain_recalc()) {
1950 Indent(n1,
"// needs #-name context chain recalc\n");
1954 if (scope->class_scope_has_private_brand()) {
1955 Indent(n1,
"// class scope has private brand\n");
1968 if (function !=
nullptr) {
1969 Indent(n1,
"// function var:\n");
1970 PrintVar(n1, function);
1975 bool printed_header =
false;
1978 if (!printed_header) {
1979 printed_header =
true;
1980 Indent(n1,
"// temporary vars:\n");
1982 PrintVar(n1, local);
1987 PrintMap(n1,
"// local vars:\n", &
variables_,
true, function);
1988 PrintMap(n1,
"// dynamic vars:\n", &
variables_,
false, function);
1993 if (class_scope->GetRareData() !=
nullptr) {
1994 PrintMap(n1,
"// private name vars:\n",
1995 &(class_scope->GetRareData()->private_name_map),
true, function);
1996 Variable* brand = class_scope->brand();
1997 if (brand !=
nullptr) {
1998 Indent(n1,
"// brand var:\n");
1999 PrintVar(n1, brand);
2002 if (class_scope->class_variable() !=
nullptr) {
2003 Indent(n1,
"// class var");
2005 class_scope->class_variable()->is_used() ?
", used" :
", unused",
2006 class_scope->should_save_class_variable_index()
2008 :
", index not saved");
2009 PrintVar(n1, class_scope->class_variable());
2025void Scope::CheckScopePositions() {
2026 this->
ForEach([](Scope* scope) {
2028 if (!scope->is_hidden() && scope->inner_scope_ ==
nullptr) {
2036void Scope::CheckZones() {
2037 DCHECK(!needs_migration_);
2038 this->
ForEach([](Scope* scope) {
2039 if (WasLazilyParsed(scope)) {
2071template <Scope::ScopeLookupMode mode>
2074 bool force_context_allocation) {
2080 if (var !=
nullptr)
return var;
2119 if (var !=
nullptr &&
2121 if (mode ==
kParsedScope && force_context_allocation &&
2132 return LookupWith(proxy, scope, outer_scope_end, cache_scope,
2133 force_context_allocation);
2139 force_context_allocation);
2167 Scope* cache_scope,
bool force_context_allocation);
2168template Variable* Scope::Lookup<Scope::kDeserializedScope>(
2170 Scope* cache_scope,
bool force_context_allocation);
2174 bool force_context_allocation) {
2180 nullptr, force_context_allocation)
2182 outer_scope_end, cache_scope);
2184 if (var ==
nullptr)
return var;
2193 DCHECK(!scope->already_resolved_);
2199 Scope* target = cache_scope ==
nullptr ? scope : cache_scope;
2208 bool force_context_allocation) {
2216 Scope* entry_cache =
2217 cache_scope ==
nullptr ? scope->
outer_scope() : cache_scope;
2221 nullptr, force_context_allocation)
2223 outer_scope_end, entry_cache);
2224 if (var ==
nullptr)
return var;
2234 Scope* target = cache_scope ==
nullptr ? scope : cache_scope;
2243 Scope* target = cache_scope ==
nullptr ? scope : cache_scope;
2283 Variable::ForceHoleInitializationFlag flag) {
2288void UpdateNeedsHoleCheck(
Variable* var, VariableProxy* proxy, Scope* scope) {
2295 return UpdateNeedsHoleCheck(var->local_if_not_shadowed(), proxy, scope);
2304 SetNeedsHoleCheck(var, proxy, Variable::kHasHoleCheckUseInUnknownScope);
2326 if (var->scope()->GetClosureScope() != scope->GetClosureScope()) {
2327 SetNeedsHoleCheck(var, proxy,
2328 Variable::kHasHoleCheckUseInDifferentClosureScope);
2336 if (var->scope()->is_nonlinear() ||
2337 var->initializer_position() >= proxy->position()) {
2338 SetNeedsHoleCheck(var, proxy, Variable::kHasHoleCheckUseInSameClosureScope);
2347 UpdateNeedsHoleCheck(var, proxy,
this);
2356 if (var !=
nullptr) {
2371 if (WasLazilyParsed(
this)) {
2374 if (!
end->is_script_scope())
end =
end->outer_scope();
2387 scope = scope->sibling_) {
2388 if (!scope->ResolveVariablesRecursively(
end))
return false;
2445 bool has_mapped_arguments =
false;
2447 DCHECK(!is_arrow_scope());
2453 has_mapped_arguments =
2466 for (
int i = num_parameters() - 1;
i >= 0; --
i) {
2469 DCHECK(!has_rest_ || var != rest_parameter());
2471 if (has_mapped_arguments) {
2476 AllocateParameter(var,
i);
2495 if (!has_this_declaration())
return;
2551 !rest_parameter()->IsUnallocated());
2553 if (new_target_ !=
nullptr && !
MustAllocate(new_target_)) {
2554 new_target_ =
nullptr;
2557 NullifyRareVariableIf(RareVariable::kThisFunction, [=,
this](
Variable* var) {
2563 for (
const auto& it : module()->regular_imports()) {
2569 for (
const auto& it : module()->regular_exports()) {
2601 DCHECK(!scope->already_resolved_);
2624 bool must_have_context =
2626#if V8_ENABLE_WEBASSEMBLY
2627 scope->IsAsmModule() ||
2638 !must_have_context) {
2649template <
typename IsolateT>
2657 if (it != scope_infos_to_reuse.end()) {
2686 DCHECK_IMPLIES(scope->sibling_, scope->sibling_->UniqueIdInScript() !=
2687 scope->UniqueIdInScript());
2689 if (!scope->is_function_scope() ||
2690 scope->AsDeclarationScope()->ShouldEagerCompile()) {
2691 scope->AllocateScopeInfosRecursively(isolate, next_outer_scope,
2692 scope_infos_to_reuse);
2693 }
else if (
v8_flags.reuse_scope_infos) {
2694 auto scope_it = scope_infos_to_reuse.find(scope->UniqueIdInScript());
2695 if (scope_it != scope_infos_to_reuse.end()) {
2696 scope->scope_info_ = scope_it->second;
2699 scope_it->second = {};
2728 DCHECK(needs_private_name_context_chain_recalc_);
2747 for (scope =
this; scope !=
nullptr;
2757template <
typename IsolateT>
2760 IsolateT* isolate) {
2768 DCHECK((std::is_same<Isolate, v8::internal::Isolate>::value));
2777 std::unordered_map<int, Handle<ScopeInfo>> scope_infos_to_reuse;
2778 if (
v8_flags.reuse_scope_infos && infos->length() != 0) {
2782 ? parse_info_sfi->GetOuterScopeInfo()
2788 i <= parse_info->max_info_id(); ++
i) {
2790 if (maybe_info.
IsWeak()) {
2795 if (!sfi->scope_info()->IsEmpty()) {
2797 }
else if (sfi->HasOuterScopeInfo()) {
2808 auto it = scope_infos_to_reuse.find(
id);
2809 if (it != scope_infos_to_reuse.end()) {
2813 int last_checked_field_index = 0;
2815 it->second->Equals(
scope_info, parse_info_sfi->live_edited(),
2816 &last_checked_field_index);
2818 std::unique_ptr<char[]> script_source;
2819 size_t script_source_length = 0;
2820 std::unique_ptr<char[]> function_source;
2821 size_t function_source_length = 0;
2822 if (IsString(script->source())) {
2824 ->ToCString(&script_source_length);
2828 ->ToCString(parse_info_sfi->StartPosition(),
2829 parse_info_sfi->EndPosition() -
2830 parse_info_sfi->StartPosition(),
2831 &function_source_length);
2834 std::vector<Address> data{
2837 static_cast<Address>(equal_scopes),
2838 static_cast<Address>(last_checked_field_index),
2839 parse_info_sfi.
ptr(),
2844 parse_info->
literal()->function_literal_id()),
2856 it->second->HasOuterScopeInfo()
2857 ? it->second->OuterScopeInfo().ptr()
2861 script->GetNameOrSourceURL().ptr(),
2862 static_cast<Address>(parse_info_sfi->StartPosition()),
2863 static_cast<Address>(parse_info_sfi->EndPosition()),
2865 script->source().ptr(),
2866 reinterpret_cast<Address>(script_source.get()),
2867 script_source_length,
2868 reinterpret_cast<Address>(script_source.get() +
2869 parse_info_sfi->StartPosition()),
2870 reinterpret_cast<Address>(script_source.get() +
2871 parse_info_sfi->EndPosition()),
2873 parse_info_sfi->Name().
ptr(),
2874 reinterpret_cast<Address>(function_source.get()),
2875 function_source_length,
2876 reinterpret_cast<Address>(function_source.get() +
2877 function_source_length),
2882 Isolate* main_thread_isolate =
2885 std::is_same_v<IsolateT, Isolate>
2889 &data[0], data.size());
2910 scope_infos_to_reuse);
2926 isolate->factory()->empty_scope_info();
2939 bool is_function_var_in_context =
2942 (is_function_var_in_context ? 1 : 0);
2963 is_static_flag, was_added);
2966 has_static_private_methods_ |=
2970 result->is_static_flag() == is_static_flag) {
2979 RareData* rare_data = GetRareData();
2980 if (rare_data ==
nullptr) {
2987 RareData* rare_data = GetRareData();
2988 if (rare_data ==
nullptr) {
2995 RareData* rare_data = GetRareData();
2996 if (rare_data ==
nullptr ||
3002 if (tail_is_empty) {
3012 RareData* rare_data = GetRareData();
3013 if (rare_data ==
nullptr ||
3028 migrated_names.
Add(copy);
3032 if (tail_is_empty) {
3046 int index =
scope_info_->ContextSlotIndex(name->string(), &lookup_result);
3058 Variable* var = DeclarePrivateName(name, lookup_result.
mode,
3069 scope_iter.Next()) {
3074 if (var ==
nullptr && !scope->
scope_info_.is_null()) {
3077 if (var !=
nullptr) {
3085 RareData* rare_data = GetRareData();
3092 Variable* var = LookupPrivateName(proxy);
3093 if (var ==
nullptr) {
3098 info->pending_error_handler()->ReportMessageAt(
3100 MessageTemplate::kInvalidPrivateFieldResolution, proxy->raw_name());
3114 RareData* rare_data = GetRareData();
3120 private_name_scope_iter.
Next();
3127 if (!has_private_names && private_name_scope_iter.
Done() &&
3129 return unresolved.
first();
3133 DCHECK(proxy->IsPrivateName());
3135 unresolved.
Remove(proxy);
3140 if (has_private_names) {
3141 var = LookupLocalPrivateName(proxy->raw_name());
3142 if (var !=
nullptr) {
3148 has_explicit_static_private_methods_access_ |=
3156 if (var ==
nullptr) {
3159 if (private_name_scope_iter.
Done()) {
3177 int class_token_pos) {
3178 DCHECK_IMPLIES(GetRareData() !=
nullptr, GetRareData()->brand ==
nullptr);
3188 EnsureRareData()->brand = brand;
3195 int class_token_pos) {
3200 Declare(
zone(), name->IsEmpty() ? ast_value_factory->dot_string() : name,
3205 class_variable_->set_initializer_position(class_token_pos);
3206 return class_variable_;
3211 if (!
start->is_class_scope() ||
start->AsClassScope()->IsParsingHeritage()) {
3220 while (scope !=
nullptr) {
#define SBXCHECK(condition)
Entry * Next(Entry *entry) const
uint32_t occupancy() const
TemplateHashMapEntry< void *, void * > Entry
AllocationPolicy allocator() const
Entry * LookupOrInsert(const void *&key, uint32_t hash)
void * Remove(const void *&key, uint32_t hash)
uint32_t capacity() const
Entry * Lookup(const void *&key, uint32_t hash) const
void Prepend(ThreadedListBase &&list)
void MoveTail(ThreadedListBase *from_list, Iterator from_location)
void Append(ThreadedListBase &&list)
void Rewind(Iterator reset_point)
void set_lookup_hoisting_mode(LookupHoistingMode mode)
Variable * CopyVariable(Variable *variable)
VariableProxy * CopyVariableProxy(VariableProxy *proxy)
Assignment * NewAssignment(Token::Value op, Expression *target, Expression *value, int pos)
VariableDeclaration * NewVariableDeclaration(int pos)
VariableProxy * NewVariableProxy(Variable *var, int start_position=kNoSourcePosition)
AstValueFactory * ast_value_factory() const
ExpressionStatement * NewExpressionStatement(Expression *expression, int pos)
const AstRawString * GetString(Tagged< String > literal, const SharedStringAccessGuardIfNeeded &)
Zone * single_parse_zone() const
V8_INLINE RareData * EnsureRareData()
Variable * LookupLocalPrivateName(const AstRawString *name)
void ResetUnresolvedPrivateNameTail(UnresolvedList::Iterator tail)
Variable * DeclareClassVariable(AstValueFactory *ast_value_factory, const AstRawString *name, int class_token_pos)
void MigrateUnresolvedPrivateNameTail(AstNodeFactory *ast_node_factory, UnresolvedList::Iterator tail)
Variable * DeclarePrivateName(const AstRawString *name, VariableMode mode, IsStaticFlag is_static_flag, bool *was_added)
V8_WARN_UNUSED_RESULT bool ResolvePrivateNames(ParseInfo *info)
Variable * LookupPrivateNameInScopeInfo(const AstRawString *name)
Variable * LookupPrivateName(VariableProxy *proxy)
VariableProxy * ResolvePrivateNamesPartially()
UnresolvedList::Iterator GetUnresolvedPrivateNameTail()
Variable * DeclareBrandVariable(AstValueFactory *ast_value_factory, IsStaticFlag is_static_flag, int class_token_pos)
V8_INLINE bool IsParsingHeritage()
@ MIN_CONTEXT_EXTENDED_SLOTS
bool is_arrow_scope() const
void ResetAfterPreparsing(AstValueFactory *ast_value_factory, bool aborted)
void SetScriptScopeInfo(Handle< ScopeInfo > scope_info)
bool class_scope_has_private_brand_
static V8_WARN_UNUSED_RESULT bool Analyze(ParseInfo *info)
static V8_EXPORT_PRIVATE void AllocateScopeInfos(ParseInfo *info, DirectHandle< Script > script, IsolateT *isolate)
FunctionKind function_kind() const
bool should_ban_arguments() const
bool force_eager_compilation_
void DeserializeReceiver(AstValueFactory *ast_value_factory)
V8_INLINE void AllocateParameterLocals()
V8_INLINE RareData * EnsureRareData()
Variable * function_var() const
bool ShouldEagerCompile() const
void AddLocal(Variable *var)
void SavePreparseDataForDeclarationScope(Parser *parser)
bool uses_super_property_
Variable * DeclareGeneratorObjectVar(const AstRawString *name)
void HoistSloppyBlockFunctions(AstNodeFactory *factory)
FunctionKind function_kind_
bool needs_private_name_context_chain_recalc() const
void RecalcPrivateNameContextChain()
bool AllocateVariables(ParseInfo *info)
bool has_simple_parameters_
bool has_this_declaration_
void RecordParameter(bool is_rest)
void set_should_eager_compile()
void RecordNeedsPrivateNameContextChainRecalc()
bool has_arguments_parameter_
void DeclareSloppyBlockFunction(SloppyBlockFunctionStatement *sloppy_block_function)
void AnalyzePartially(Parser *parser, AstNodeFactory *ast_node_factory, bool maybe_in_arrowhead)
bool should_eager_compile_
bool AllowsLazyCompilation() const
void DeclareThis(AstValueFactory *ast_value_factory)
V8_INLINE void AllocateParameter(Variable *var, int index)
bool is_skipped_function_
bool needs_private_name_context_chain_recalc_
PreparseDataBuilder * preparse_data_builder() const
Declaration * CheckConflictingVarDeclarations(bool *allowed_catch_binding_var_redeclaration)
bool sloppy_eval_can_extend_vars() const
Variable * generator_object_var() const
bool was_lazily_parsed() const
bool has_this_declaration() const
Variable * DeclareParameter(const AstRawString *name, VariableMode mode, bool is_optional, bool is_rest, AstValueFactory *ast_value_factory, int position)
PreparseDataBuilder * preparse_data_builder_
void DeclareArguments(AstValueFactory *ast_value_factory)
Variable * DeclareFunctionVar(const AstRawString *name, Scope *cache=nullptr)
base::ThreadedList< SloppyBlockFunctionStatement > sloppy_block_functions_
V8_INLINE void AllocateLocals()
bool has_simple_parameters() const
void DeclareDefaultFunctionVariables(AstValueFactory *ast_value_factory)
void TakeUnresolvedReferencesFromParent()
Variable * DeclareDynamicGlobal(const AstRawString *name, VariableKind variable_kind, Scope *cache)
V8_INLINE void AllocateReceiver()
int function_literal_id() const
Handle< SharedFunctionInfo > shared_function_info() const
DeclarationScope * scope() const
Isolate * GetMainThreadIsolateUnsafe()
ModuleScope(DeclarationScope *script_scope, AstValueFactory *avfactory)
void AllocateModuleVariables()
void set_has_module_in_scope_chain()
DeclarationScope * script_scope() const
FunctionLiteral * literal() const
ClassScope * GetScope() const
PrivateNameScopeIterator(Scope *start)
void AddUnresolvedPrivateName(VariableProxy *proxy)
static Handle< ScopeInfo > Create(IsolateT *isolate, Zone *zone, Scope *scope, MaybeDirectHandle< ScopeInfo > outer_scope)
Scope * declaration_scope_
base::ThreadedList< Variable >::Iterator top_local_
UnresolvedList::Iterator top_unresolved_
void Reparent(DeclarationScope *new_parent)
int ContextLocalCount() const
bool HasSimpleParameters()
void AllocateNonParameterLocal(Variable *var)
int num_heap_slots() const
bool IsOuterScopeOf(Scope *other) const
V8_INLINE void AllocateHeapSlot(Variable *var)
Variable * LookupInScopeInfo(const AstRawString *name, Scope *cache)
bool NeedsScopeInfo() const
bool is_wrapped_function_
bool HasThisReference() const
void set_language_mode(LanguageMode language_mode)
bool is_repl_mode_scope() const
void set_end_position(int statement_pos)
bool has_using_declaration_
static Variable * LookupSloppyEval(VariableProxy *proxy, Scope *scope, Scope *outer_scope_end, Scope *cache_scope, bool force_context_allocation)
Variable * Declare(Zone *zone, const AstRawString *name, VariableMode mode, VariableKind kind, InitializationFlag initialization_flag, MaybeAssignedFlag maybe_assigned_flag, bool *was_added)
void AllocateScopeInfosRecursively(IsolateT *isolate, MaybeHandle< ScopeInfo > outer_scope, std::unordered_map< int, IndirectHandle< ScopeInfo > > &scope_infos_to_reuse)
bool AllowsLazyParsingWithoutUnresolvedVariables(const Scope *outer) const
int UniqueIdInScript() const
bool private_name_lookup_skips_outer_class() const
static Variable * Lookup(VariableProxy *proxy, Scope *scope, Scope *outer_scope_end, Scope *cache_scope=nullptr, bool force_context_allocation=false)
Scope * outer_scope() const
bool is_debug_evaluate_scope_
Scope * GetOuterScopeWithContext()
DeclarationScope * AsDeclarationScope()
static Scope * DeserializeScopeChain(IsolateT *isolate, Zone *zone, Tagged< ScopeInfo > scope_info, DeclarationScope *script_scope, AstValueFactory *ast_value_factory, DeserializationMode deserialization_mode, ParseInfo *info=nullptr)
static void SetScriptScopeInfo(IsolateT *isolate, DeclarationScope *script_scope)
int ContextChainLength(Scope *scope) const
bool IsConstructorScope() const
ClassScope * AsClassScope()
base::ThreadedList< Variable > * locals()
base::ThreadedList< Declaration > decls_
bool is_home_object_scope() const
DeclarationScope * GetScriptScope()
base::ThreadedList< Variable > locals_
bool is_script_scope() const
bool private_name_lookup_skips_outer_class_
const ScopeType scope_type_
bool RemoveInnerScope(Scope *inner_scope)
friend class DeclarationScope
int ContextHeaderLength() const
ModuleScope * AsModuleScope()
void AllocateVariablesRecursively()
DeclarationScope * GetReceiverScope()
bool is_declaration_scope_
bool is_debug_evaluate_scope() const
bool is_class_scope() const
void AddInnerScope(Scope *inner_scope)
Handle< ScopeInfo > scope_info() const
void DeleteUnresolved(VariableProxy *var)
bool has_forced_context_allocation_for_parameters() const
Variable * DeclareHomeObjectVariable(AstValueFactory *ast_value_factory)
Variable * DeclareCatchVariableName(const AstRawString *name)
bool is_eval_scope() const
V8_WARN_UNUSED_RESULT bool ResolveVariablesRecursively(Scope *end)
bool is_function_scope() const
ScopeType scope_type() const
Scope(Zone *zone, Scope *outer_scope, ScopeType scope_type)
bool force_context_allocation_for_parameters_
V8_INLINE void AllocateNonParameterLocalsAndDeclaredGlobals()
void AllocateStackSlot(Variable *var)
bool has_await_using_declaration_
Variable * DeclareStaticHomeObjectVariable(AstValueFactory *ast_value_factory)
bool MustAllocateInContext(Variable *var)
void AnalyzePartially(DeclarationScope *max_outer_scope, AstNodeFactory *ast_node_factory, UnresolvedList *new_unresolved_list, bool maybe_in_arrowhead)
Scope * inner_scope() const
void SavePreparseData(Parser *parser)
Variable * DeclareVariableName(const AstRawString *name, VariableMode mode, bool *was_added, VariableKind kind=NORMAL_VARIABLE)
DeclarationScope * GetClosureScope()
UnresolvedList unresolved_list_
static Variable * LookupWith(VariableProxy *proxy, Scope *scope, Scope *outer_scope_end, Scope *cache_scope, bool force_context_allocation)
static void ResolvePreparsedVariable(VariableProxy *proxy, Scope *scope, Scope *end)
void ResolveTo(VariableProxy *proxy, Variable *var)
Variable * NonLocal(const AstRawString *name, VariableMode mode)
bool NeedsContext() const
bool is_wrapped_function() const
DeclarationScope * GetNonEvalDeclarationScope()
bool is_block_scope_for_object_literal_
Variable * NewTemporary(const AstRawString *name)
const AstRawString * FindVariableDeclaredIn(Scope *scope, VariableMode mode_limit)
void ResolveVariable(VariableProxy *proxy)
bool inner_scope_calls_eval_
bool is_with_scope() const
void set_start_position(int statement_pos)
Scope * GetHomeObjectScope()
Variable * DeclareLocal(const AstRawString *name, VariableMode mode, VariableKind kind, bool *was_added, InitializationFlag init_flag=kCreatedInitialized)
Variable * DeclareVariable(Declaration *declaration, const AstRawString *name, int pos, VariableMode mode, VariableKind kind, InitializationFlag init, bool *was_added, bool *sloppy_mode_block_scope_function_redefinition, bool *ok)
bool is_block_scope() const
Scope * FinalizeBlockScope()
void set_is_debug_evaluate_scope()
void RewriteReplGlobalVariables()
int ContextChainLengthUntilOutermostSloppyEval() const
bool IsSkippableFunctionScope()
bool must_use_preparsed_scope_data_
V8_INLINE void ForEach(FunctionType callback)
bool MustAllocate(Variable *var)
DeclarationScope * GetDeclarationScope()
void ForceDynamicLookup(VariableProxy *proxy)
bool sloppy_eval_can_extend_vars_
void AddUnresolved(VariableProxy *proxy)
LanguageMode language_mode() const
DeclarationScope * GetConstructorScope()
Variable * LookupInScopeOrScopeInfo(const AstRawString *name, Scope *cache)
bool HasReceiverToDeserialize() const
bool is_catch_scope() const
int start_position() const
bool is_module_scope() const
IndirectHandle< ScopeInfo > scope_info_
bool ForceContextForLanguageMode() const
bool is_declaration_scope() const
Variable * LookupLocal(const AstRawString *name)
bool ShouldBanArguments()
V8_INLINE constexpr StorageType ptr() const
constexpr bool IsWeak() const
Tagged< HeapObject > GetHeapObjectAssumeWeak() const
static V8_EXPORT_PRIVATE v8::Platform * GetCurrentPlatform()
V8_EXPORT_PRIVATE Variable * Lookup(const AstRawString *name)
void Remove(Variable *var)
Variable * Declare(Zone *zone, Scope *scope, const AstRawString *name, VariableMode mode, VariableKind kind, InitializationFlag initialization_flag, MaybeAssignedFlag maybe_assigned_flag, IsStaticFlag is_static_flag, bool *was_added)
bool is_home_object() const
void mark_removed_from_unresolved()
void BindTo(Variable *var)
V8_INLINE VariableProxy * next_unresolved()
bool IsPrivateName() const
const AstRawString * raw_name() const
void set_needs_hole_check()
VariableMode mode() const
bool is_parameter() const
bool is_sloppy_block_function()
void AllocateTo(VariableLocation location, int index)
VariableLocation location() const
void set_local_if_not_shadowed(Variable *local)
bool has_forced_context_allocation() const
void set_initializer_position(int pos)
bool IsGlobalObjectProperty() const
void RewriteLocationForRepl()
void set_is_static_flag(IsStaticFlag is_static_flag)
void ForceHoleInitialization(ForceHoleInitializationFlag flag)
void set_scope(Scope *scope)
const AstRawString * raw_name() const
void ForceContextAllocation()
bool IsContextSlot() const
bool IsUnallocated() const
const JSFunctionRef function_
const ScopeInfoRef scope_info_
#define EXPORT_TEMPLATE_DEFINE(export)
ZoneVector< RpoNumber > & result
constexpr auto Header(size_t size)
SnapshotTable< OpIndex, VariableData >::Key Variable
bool(* FunctionType)(const Operation &op, Zone *zone)
V8_INLINE IndirectHandle< T > handle(Tagged< T > object, Isolate *isolate)
bool IsArrowFunction(FunctionKind kind)
bool is_sloppy(LanguageMode language_mode)
constexpr int kNoSourcePosition
bool IsClassConstructor(FunctionKind kind)
bool Is(IndirectHandle< U > value)
bool IsLexicalVariableMode(VariableMode mode)
bool IsDeclaredVariableMode(VariableMode mode)
void PrintF(const char *format,...)
Tagged(T object) -> Tagged< T >
bool IsGeneratorFunction(FunctionKind kind)
bool IsDerivedConstructor(FunctionKind kind)
@ kPrivateGetterAndSetter
bool IsConciseMethod(FunctionKind kind)
bool IsAsyncFunction(FunctionKind kind)
bool IsAccessorFunction(FunctionKind kind)
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in name
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in allocation gc speed threshold for starting incremental marking via a task in percent of available threshold for starting incremental marking immediately in percent of available Use a single schedule for determining a marking schedule between JS and C objects schedules the minor GC task with kUserVisible priority max worker number of concurrent for NumberOfWorkerThreads start background threads that allocate memory concurrent_array_buffer_sweeping use parallel threads to clear weak refs in the atomic pause trace progress of the incremental marking trace object counts and memory usage report a tick only when allocated zone memory changes by this amount TracingFlags::gc_stats TracingFlags::gc_stats track native contexts that are expected to be garbage collected verify heap pointers before and after GC memory reducer runs GC with ReduceMemoryFootprint flag Maximum number of memory reducer GCs scheduled Old gen GC speed is computed directly from gc tracer counters Perform compaction on full GCs based on V8 s default heuristics Perform compaction on every full GC Perform code space compaction when finalizing a full GC with stack Stress GC compaction to flush out bugs with moving objects flush of baseline code when it has not been executed recently Use time base code flushing instead of age Use a progress bar to scan large objects in increments when incremental marking is active force incremental marking for small heaps and run it more often force marking at random points between and force scavenge at random points between and reclaim otherwise unreachable unmodified wrapper objects when possible less compaction in non memory reducing mode use high priority threads for concurrent Marking Test mode only flag It allows an unit test to select evacuation candidates use incremental marking for CppHeap cppheap_concurrent_marking c value for membalancer A special constant to balance between memory and space tradeoff The smaller the more memory it uses enable use of SSE4 instructions if available enable use of AVX VNNI instructions if available enable use of POPCNT instruction if available force all emitted branches to be in long mode(MIPS/PPC only)") DEFINE_BOOL(partial_constant_pool
void Print(Tagged< Object > obj)
@ SLOPPY_FUNCTION_NAME_VARIABLE
@ SLOPPY_BLOCK_FUNCTION_VARIABLE
bool BindsSuper(FunctionKind kind)
bool is_strict(LanguageMode language_mode)
V8_EXPORT_PRIVATE FlagValues v8_flags
bool IsClassMembersInitializerFunction(FunctionKind kind)
bool IsPrivateMethodOrAccessorVariableMode(VariableMode mode)
bool IsDynamicVariableMode(VariableMode mode)
bool IsImmutableLexicalOrPrivateVariableMode(VariableMode mode)
bool IsDefaultConstructor(FunctionKind kind)
bool IsComplementaryAccessorPair(VariableMode a, VariableMode b)
const char * FunctionKind2String(FunctionKind kind)
Tagged< To > Cast(Tagged< From > value, const v8::SourceLocation &loc=INIT_SOURCE_LOCATION_IN_DEBUG)
#define DCHECK_NOT_NULL(val)
#define DCHECK_IMPLIES(v1, v2)
#define DCHECK_NE(v1, v2)
#define CHECK_EQ(lhs, rhs)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)
#define V8_EXPORT_PRIVATE
VariableMap private_name_map
UnresolvedList unresolved_private_names
Variable * generator_object
MaybeAssignedFlag maybe_assigned_flag
InitializationFlag init_flag
IsStaticFlag is_static_flag
#define V8_LIKELY(condition)
#define V8_UNLIKELY(condition)