Commit a9d00623 authored by verwaest's avatar verwaest Committed by Commit bot

Don't preallocate temps, params, decls space if we're ScopeInfo backed

Such scopes don't use those lists.

BUG=v8:5209

Review-Url: https://codereview.chromium.org/2221003002
Cr-Commit-Position: refs/heads/master@{#38485}
parent 75020297
...@@ -124,7 +124,7 @@ Scope::Scope(Zone* zone, Scope* inner_scope, ScopeType scope_type, ...@@ -124,7 +124,7 @@ Scope::Scope(Zone* zone, Scope* inner_scope, ScopeType scope_type,
: zone_(zone), : zone_(zone),
outer_scope_(nullptr), outer_scope_(nullptr),
variables_(zone), variables_(zone),
decls_(4, zone), decls_(0, zone),
scope_info_(scope_info), scope_info_(scope_info),
scope_type_(scope_type), scope_type_(scope_type),
already_resolved_(true) { already_resolved_(true) {
...@@ -146,8 +146,8 @@ DeclarationScope::DeclarationScope(Zone* zone, Scope* inner_scope, ...@@ -146,8 +146,8 @@ DeclarationScope::DeclarationScope(Zone* zone, Scope* inner_scope,
: Scope(zone, inner_scope, scope_type, scope_info), : Scope(zone, inner_scope, scope_type, scope_info),
function_kind_(scope_info.is_null() ? kNormalFunction function_kind_(scope_info.is_null() ? kNormalFunction
: scope_info->function_kind()), : scope_info->function_kind()),
temps_(4, zone), temps_(0, zone),
params_(4, zone), params_(0, zone),
sloppy_block_function_map_(zone), sloppy_block_function_map_(zone),
module_descriptor_(nullptr) { module_descriptor_(nullptr) {
SetDefaults(); SetDefaults();
...@@ -702,7 +702,6 @@ bool Scope::RemoveUnresolved(VariableProxy* var) { ...@@ -702,7 +702,6 @@ bool Scope::RemoveUnresolved(VariableProxy* var) {
Variable* Scope::NewTemporary(const AstRawString* name) { Variable* Scope::NewTemporary(const AstRawString* name) {
DCHECK(!already_resolved());
DeclarationScope* scope = GetClosureScope(); DeclarationScope* scope = GetClosureScope();
Variable* var = new(zone()) Variable(scope, Variable* var = new(zone()) Variable(scope,
name, name,
...@@ -714,6 +713,7 @@ Variable* Scope::NewTemporary(const AstRawString* name) { ...@@ -714,6 +713,7 @@ Variable* Scope::NewTemporary(const AstRawString* name) {
} }
int DeclarationScope::RemoveTemporary(Variable* var) { int DeclarationScope::RemoveTemporary(Variable* var) {
DCHECK(!already_resolved());
DCHECK_NOT_NULL(var); DCHECK_NOT_NULL(var);
// Temporaries are only placed in ClosureScopes. // Temporaries are only placed in ClosureScopes.
DCHECK_EQ(GetClosureScope(), this); DCHECK_EQ(GetClosureScope(), this);
...@@ -735,6 +735,7 @@ int DeclarationScope::RemoveTemporary(Variable* var) { ...@@ -735,6 +735,7 @@ int DeclarationScope::RemoveTemporary(Variable* var) {
void Scope::AddDeclaration(Declaration* declaration) { void Scope::AddDeclaration(Declaration* declaration) {
DCHECK(!already_resolved());
decls_.Add(declaration, zone()); decls_.Add(declaration, zone());
} }
......
...@@ -814,6 +814,7 @@ class DeclarationScope : public Scope { ...@@ -814,6 +814,7 @@ class DeclarationScope : public Scope {
// adjusting the scope of temporaries used when desugaring parameter // adjusting the scope of temporaries used when desugaring parameter
// initializers. // initializers.
void AddTemporary(Variable* var) { void AddTemporary(Variable* var) {
DCHECK(!already_resolved());
// Temporaries are only placed in ClosureScopes. // Temporaries are only placed in ClosureScopes.
DCHECK_EQ(GetClosureScope(), this); DCHECK_EQ(GetClosureScope(), this);
temps_.Add(var, zone()); temps_.Add(var, zone());
......
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