Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(663)

Unified Diff: src/ast/scopes.cc

Issue 2266973002: Allocate script scopes using a separate constructor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: update test Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/scopes.cc
diff --git a/src/ast/scopes.cc b/src/ast/scopes.cc
index 6d7a1bc5b15006911c912e06ac9f0cf168aea854..a111dede1cd364efc8fce82ce4d2adf08a53e9a8 100644
--- a/src/ast/scopes.cc
+++ b/src/ast/scopes.cc
@@ -77,6 +77,16 @@ void SloppyBlockFunctionMap::Declare(Zone* zone, const AstRawString* name,
// ----------------------------------------------------------------------------
// Implementation of Scope
+Scope::Scope(Zone* zone)
+ : zone_(zone),
+ outer_scope_(nullptr),
+ variables_(zone),
+ ordered_variables_(4, zone),
+ decls_(4, zone),
+ scope_type_(SCRIPT_SCOPE) {
+ SetDefaults();
+}
+
Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type)
: zone_(zone),
outer_scope_(outer_scope),
@@ -84,17 +94,12 @@ Scope::Scope(Zone* zone, Scope* outer_scope, ScopeType scope_type)
ordered_variables_(4, zone),
decls_(4, zone),
scope_type_(scope_type) {
+ DCHECK_NE(SCRIPT_SCOPE, scope_type);
SetDefaults();
- if (outer_scope == nullptr) {
- // If the outer scope is null, this cannot be a with scope. The outermost
- // scope must be a script scope.
- DCHECK_EQ(SCRIPT_SCOPE, scope_type);
- } else {
- set_language_mode(outer_scope->language_mode());
- force_context_allocation_ =
- !is_function_scope() && outer_scope->has_forced_context_allocation();
- outer_scope_->AddInnerScope(this);
- }
+ set_language_mode(outer_scope->language_mode());
+ force_context_allocation_ =
+ !is_function_scope() && outer_scope->has_forced_context_allocation();
+ outer_scope_->AddInnerScope(this);
}
Scope::Snapshot::Snapshot(Scope* scope)
@@ -103,6 +108,15 @@ Scope::Snapshot::Snapshot(Scope* scope)
top_unresolved_(scope->unresolved_),
top_temp_(scope->GetClosureScope()->temps()->length()) {}
+DeclarationScope::DeclarationScope(Zone* zone)
+ : Scope(zone),
+ function_kind_(kNormalFunction),
+ temps_(4, zone),
+ params_(4, zone),
+ sloppy_block_function_map_(zone) {
+ SetDefaults();
+}
+
DeclarationScope::DeclarationScope(Zone* zone, Scope* outer_scope,
ScopeType scope_type,
FunctionKind function_kind)
@@ -112,7 +126,7 @@ DeclarationScope::DeclarationScope(Zone* zone, Scope* outer_scope,
params_(4, zone),
sloppy_block_function_map_(zone) {
SetDefaults();
- if (outer_scope != nullptr) asm_function_ = outer_scope_->IsAsmModule();
+ asm_function_ = outer_scope_->IsAsmModule();
}
ModuleScope::ModuleScope(Zone* zone, DeclarationScope* script_scope,
« no previous file with comments | « src/ast/scopes.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698