Commit 89778645 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[parser] Remove unnecessary ParseInfo from Scope methods

Some Scope methods were unnecessarily taking a ParseInfo, or using only
a single field from it. We can avoid passing around ParseInfo in these
cases, which will make splitting/removing it easier in the future.

Bug: v8:10314
Change-Id: I5c60783d27581c4f7d8c709314bbfc72ac5bd0f6
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2096630
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66678}
parent 622b1dc2
...@@ -1238,7 +1238,7 @@ bool DeclarationScope::AllocateVariables(ParseInfo* info) { ...@@ -1238,7 +1238,7 @@ bool DeclarationScope::AllocateVariables(ParseInfo* info) {
return false; return false;
} }
if (!ResolveVariablesRecursively(info)) { if (!ResolveVariablesRecursively(info->scope())) {
DCHECK(info->pending_error_handler()->has_pending_error()); DCHECK(info->pending_error_handler()->has_pending_error());
return false; return false;
} }
...@@ -1429,9 +1429,8 @@ bool Scope::IsOuterScopeOf(Scope* other) const { ...@@ -1429,9 +1429,8 @@ bool Scope::IsOuterScopeOf(Scope* other) const {
} }
void Scope::CollectNonLocals(DeclarationScope* max_outer_scope, void Scope::CollectNonLocals(DeclarationScope* max_outer_scope,
Isolate* isolate, ParseInfo* info, Isolate* isolate, Handle<StringSet>* non_locals) {
Handle<StringSet>* non_locals) { this->ForEach([max_outer_scope, isolate, non_locals](Scope* scope) {
this->ForEach([max_outer_scope, isolate, info, non_locals](Scope* scope) {
// Module variables must be allocated before variable resolution // Module variables must be allocated before variable resolution
// to ensure that UpdateNeedsHoleCheck() can detect import variables. // to ensure that UpdateNeedsHoleCheck() can detect import variables.
if (scope->is_module_scope()) { if (scope->is_module_scope()) {
...@@ -1453,7 +1452,7 @@ void Scope::CollectNonLocals(DeclarationScope* max_outer_scope, ...@@ -1453,7 +1452,7 @@ void Scope::CollectNonLocals(DeclarationScope* max_outer_scope,
// In this case we need to leave scopes in a way that they can be // In this case we need to leave scopes in a way that they can be
// allocated. If we resolved variables from lazy parsed scopes, we need // allocated. If we resolved variables from lazy parsed scopes, we need
// to context allocate the var. // to context allocate the var.
scope->ResolveTo(info, proxy, var); scope->ResolveTo(proxy, var);
if (!var->is_dynamic() && lookup != scope) if (!var->is_dynamic() && lookup != scope)
var->ForceContextAllocation(); var->ForceContextAllocation();
} }
...@@ -1502,8 +1501,8 @@ void Scope::AnalyzePartially(DeclarationScope* max_outer_scope, ...@@ -1502,8 +1501,8 @@ void Scope::AnalyzePartially(DeclarationScope* max_outer_scope,
} }
Handle<StringSet> DeclarationScope::CollectNonLocals( Handle<StringSet> DeclarationScope::CollectNonLocals(
Isolate* isolate, ParseInfo* info, Handle<StringSet> non_locals) { Isolate* isolate, Handle<StringSet> non_locals) {
Scope::CollectNonLocals(this, isolate, info, &non_locals); Scope::CollectNonLocals(this, isolate, &non_locals);
return non_locals; return non_locals;
} }
...@@ -2107,12 +2106,11 @@ Variable* Scope::LookupSloppyEval(VariableProxy* proxy, Scope* scope, ...@@ -2107,12 +2106,11 @@ Variable* Scope::LookupSloppyEval(VariableProxy* proxy, Scope* scope,
return var; return var;
} }
void Scope::ResolveVariable(ParseInfo* info, VariableProxy* proxy) { void Scope::ResolveVariable(VariableProxy* proxy) {
DCHECK(info->script_scope()->is_script_scope());
DCHECK(!proxy->is_resolved()); DCHECK(!proxy->is_resolved());
Variable* var = Lookup<kParsedScope>(proxy, this, nullptr); Variable* var = Lookup<kParsedScope>(proxy, this, nullptr);
DCHECK_NOT_NULL(var); DCHECK_NOT_NULL(var);
ResolveTo(info, proxy, var); ResolveTo(proxy, var);
} }
namespace { namespace {
...@@ -2175,7 +2173,7 @@ void UpdateNeedsHoleCheck(Variable* var, VariableProxy* proxy, Scope* scope) { ...@@ -2175,7 +2173,7 @@ void UpdateNeedsHoleCheck(Variable* var, VariableProxy* proxy, Scope* scope) {
} // anonymous namespace } // anonymous namespace
void Scope::ResolveTo(ParseInfo* info, VariableProxy* proxy, Variable* var) { void Scope::ResolveTo(VariableProxy* proxy, Variable* var) {
DCHECK_NOT_NULL(var); DCHECK_NOT_NULL(var);
UpdateNeedsHoleCheck(var, proxy, this); UpdateNeedsHoleCheck(var, proxy, this);
proxy->BindTo(var); proxy->BindTo(var);
...@@ -2197,14 +2195,12 @@ void Scope::ResolvePreparsedVariable(VariableProxy* proxy, Scope* scope, ...@@ -2197,14 +2195,12 @@ void Scope::ResolvePreparsedVariable(VariableProxy* proxy, Scope* scope,
} }
} }
bool Scope::ResolveVariablesRecursively(ParseInfo* info) { bool Scope::ResolveVariablesRecursively(Scope* end) {
DCHECK(info->script_scope()->is_script_scope());
// Lazy parsed declaration scopes are already partially analyzed. If there are // Lazy parsed declaration scopes are already partially analyzed. If there are
// unresolved references remaining, they just need to be resolved in outer // unresolved references remaining, they just need to be resolved in outer
// scopes. // scopes.
if (WasLazilyParsed(this)) { if (WasLazilyParsed(this)) {
DCHECK_EQ(variables_.occupancy(), 0); DCHECK_EQ(variables_.occupancy(), 0);
Scope* end = info->scope();
// Resolve in all parsed scopes except for the script scope. // Resolve in all parsed scopes except for the script scope.
if (!end->is_script_scope()) end = end->outer_scope(); if (!end->is_script_scope()) end = end->outer_scope();
...@@ -2214,13 +2210,13 @@ bool Scope::ResolveVariablesRecursively(ParseInfo* info) { ...@@ -2214,13 +2210,13 @@ bool Scope::ResolveVariablesRecursively(ParseInfo* info) {
} else { } else {
// Resolve unresolved variables for this scope. // Resolve unresolved variables for this scope.
for (VariableProxy* proxy : unresolved_list_) { for (VariableProxy* proxy : unresolved_list_) {
ResolveVariable(info, proxy); ResolveVariable(proxy);
} }
// Resolve unresolved variables for inner scopes. // Resolve unresolved variables for inner scopes.
for (Scope* scope = inner_scope_; scope != nullptr; for (Scope* scope = inner_scope_; scope != nullptr;
scope = scope->sibling_) { scope = scope->sibling_) {
if (!scope->ResolveVariablesRecursively(info)) return false; if (!scope->ResolveVariablesRecursively(end)) return false;
} }
} }
return true; return true;
......
...@@ -645,9 +645,9 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { ...@@ -645,9 +645,9 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
bool force_context_allocation); bool force_context_allocation);
static void ResolvePreparsedVariable(VariableProxy* proxy, Scope* scope, static void ResolvePreparsedVariable(VariableProxy* proxy, Scope* scope,
Scope* end); Scope* end);
void ResolveTo(ParseInfo* info, VariableProxy* proxy, Variable* var); void ResolveTo(VariableProxy* proxy, Variable* var);
void ResolveVariable(ParseInfo* info, VariableProxy* proxy); void ResolveVariable(VariableProxy* proxy);
V8_WARN_UNUSED_RESULT bool ResolveVariablesRecursively(ParseInfo* info); V8_WARN_UNUSED_RESULT bool ResolveVariablesRecursively(Scope* end);
// Finds free variables of this scope. This mutates the unresolved variables // Finds free variables of this scope. This mutates the unresolved variables
// list along the way, so full resolution cannot be done afterwards. // list along the way, so full resolution cannot be done afterwards.
...@@ -656,7 +656,7 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) { ...@@ -656,7 +656,7 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
UnresolvedList* new_unresolved_list, UnresolvedList* new_unresolved_list,
bool maybe_in_arrowhead); bool maybe_in_arrowhead);
void CollectNonLocals(DeclarationScope* max_outer_scope, Isolate* isolate, void CollectNonLocals(DeclarationScope* max_outer_scope, Isolate* isolate,
ParseInfo* info, Handle<StringSet>* non_locals); Handle<StringSet>* non_locals);
// Predicates. // Predicates.
bool MustAllocate(Variable* var); bool MustAllocate(Variable* var);
...@@ -1105,7 +1105,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope { ...@@ -1105,7 +1105,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
V8_EXPORT_PRIVATE static void AllocateScopeInfos(ParseInfo* info, V8_EXPORT_PRIVATE static void AllocateScopeInfos(ParseInfo* info,
LocalIsolate* isolate); LocalIsolate* isolate);
Handle<StringSet> CollectNonLocals(Isolate* isolate, ParseInfo* info, Handle<StringSet> CollectNonLocals(Isolate* isolate,
Handle<StringSet> non_locals); Handle<StringSet> non_locals);
// Determine if we can use lazy compilation for this scope. // Determine if we can use lazy compilation for this scope.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment