Commit f9c5997c authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Directly keep track of the scope stack on the parser again.

By now lazy allocation of block scopes probably doesn't make that much sense anymore, since the memory overhead significantly reduced. Not indirecting scope() over ScopeState is faster, which is more important at this point.

BUG=v8:5209

Change-Id: I2968f01252769e7b1198a0a0876765a06ab0d3bd
Reviewed-on: https://chromium-review.googlesource.com/445025Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43313}
parent 9dae9206
...@@ -201,7 +201,7 @@ class ParserBase { ...@@ -201,7 +201,7 @@ class ParserBase {
v8::Extension* extension, AstValueFactory* ast_value_factory, v8::Extension* extension, AstValueFactory* ast_value_factory,
RuntimeCallStats* runtime_call_stats, RuntimeCallStats* runtime_call_stats,
bool parsing_on_main_thread = true) bool parsing_on_main_thread = true)
: scope_state_(nullptr), : scope_(nullptr),
function_state_(nullptr), function_state_(nullptr),
extension_(extension), extension_(extension),
fni_(nullptr), fni_(nullptr),
...@@ -290,57 +290,26 @@ class ParserBase { ...@@ -290,57 +290,26 @@ class ParserBase {
class ObjectLiteralChecker; class ObjectLiteralChecker;
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// ScopeState and its subclasses implement the parser's scope stack. // BlockState and FunctionState implement the parser's scope stack.
// ScopeState keeps track of the current scope, and the outer ScopeState. The // The parser's current scope is in scope_. BlockState and FunctionState
// parser's scope_state_ points to the top ScopeState. ScopeState's // constructors push on the scope stack and the destructors pop. They are also
// constructor push on the scope stack and the destructors pop. BlockState and // used to hold the parser's per-funcion state.
// FunctionState are used to hold additional per-block and per-function state. class BlockState BASE_EMBEDDED {
class ScopeState BASE_EMBEDDED {
public: public:
V8_INLINE Scope* scope() const { return scope_; } BlockState(Scope** scope_stack, Scope* scope)
Zone* zone() const { return scope_->zone(); } : scope_stack_(scope_stack), outer_scope_(*scope_stack) {
*scope_stack_ = scope;
protected:
ScopeState(ScopeState** scope_stack, Scope* scope)
: scope_stack_(scope_stack), outer_scope_(*scope_stack), scope_(scope) {
*scope_stack = this;
} }
~ScopeState() { *scope_stack_ = outer_scope_; }
private:
ScopeState** const scope_stack_;
ScopeState* const outer_scope_;
Scope* const scope_;
};
class BlockState final : public ScopeState { BlockState(Zone* zone, Scope** scope_stack)
public: : BlockState(scope_stack,
BlockState(ScopeState** scope_stack, Scope* scope) new (zone) Scope(zone, *scope_stack, BLOCK_SCOPE)) {}
: ScopeState(scope_stack, scope) {}
// BlockState(ScopeState**) automatically manages Scope(BLOCK_SCOPE) ~BlockState() { *scope_stack_ = outer_scope_; }
// allocation.
// TODO(verwaest): Move to LazyBlockState class that only allocates the
// scope when needed.
explicit BlockState(Zone* zone, ScopeState** scope_stack)
: ScopeState(scope_stack, NewScope(zone, *scope_stack)) {}
void SetNonlinear() { this->scope()->SetNonlinear(); }
void set_start_position(int pos) { this->scope()->set_start_position(pos); }
void set_end_position(int pos) { this->scope()->set_end_position(pos); }
void set_is_hidden() { this->scope()->set_is_hidden(); }
Scope* FinalizedBlockScope() const {
return this->scope()->FinalizeBlockScope();
}
LanguageMode language_mode() const {
return this->scope()->language_mode();
}
private: private:
Scope* NewScope(Zone* zone, ScopeState* outer_state) { Scope** const scope_stack_;
Scope* parent = outer_state->scope(); Scope* const outer_scope_;
return new (zone) Scope(zone, parent, BLOCK_SCOPE);
}
}; };
struct DestructuringAssignment { struct DestructuringAssignment {
...@@ -402,15 +371,13 @@ class ParserBase { ...@@ -402,15 +371,13 @@ class ParserBase {
kInsideForInOfBody, kInsideForInOfBody,
}; };
class FunctionState final : public ScopeState { class FunctionState final : public BlockState {
public: public:
FunctionState(FunctionState** function_state_stack, FunctionState(FunctionState** function_state_stack, Scope** scope_stack,
ScopeState** scope_stack, DeclarationScope* scope); DeclarationScope* scope);
~FunctionState(); ~FunctionState();
DeclarationScope* scope() const { DeclarationScope* scope() const { return scope_->AsDeclarationScope(); }
return ScopeState::scope()->AsDeclarationScope();
}
void AddProperty() { expected_property_count_++; } void AddProperty() { expected_property_count_++; }
int expected_property_count() { return expected_property_count_; } int expected_property_count() { return expected_property_count_; }
...@@ -470,11 +437,11 @@ class ParserBase { ...@@ -470,11 +437,11 @@ class ParserBase {
private: private:
void AddDestructuringAssignment(DestructuringAssignment pair) { void AddDestructuringAssignment(DestructuringAssignment pair) {
destructuring_assignments_to_rewrite_.Add(pair, this->zone()); destructuring_assignments_to_rewrite_.Add(pair, scope_->zone());
} }
void AddNonPatternForRewriting(ExpressionT expr, bool* ok) { void AddNonPatternForRewriting(ExpressionT expr, bool* ok) {
non_patterns_to_rewrite_.Add(expr, this->zone()); non_patterns_to_rewrite_.Add(expr, scope_->zone());
if (non_patterns_to_rewrite_.length() >= if (non_patterns_to_rewrite_.length() >=
std::numeric_limits<uint16_t>::max()) std::numeric_limits<uint16_t>::max())
*ok = false; *ok = false;
...@@ -490,6 +457,7 @@ class ParserBase { ...@@ -490,6 +457,7 @@ class ParserBase {
FunctionState** function_state_stack_; FunctionState** function_state_stack_;
FunctionState* outer_function_state_; FunctionState* outer_function_state_;
DeclarationScope* scope_;
ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_; ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_;
TailCallExpressionList tail_call_expressions_; TailCallExpressionList tail_call_expressions_;
...@@ -1270,12 +1238,11 @@ class ParserBase { ...@@ -1270,12 +1238,11 @@ class ParserBase {
StatementT ParseTryStatement(bool* ok); StatementT ParseTryStatement(bool* ok);
StatementT ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok); StatementT ParseForStatement(ZoneList<const AstRawString*>* labels, bool* ok);
StatementT ParseForEachStatementWithDeclarations( StatementT ParseForEachStatementWithDeclarations(
int stmt_pos, ForInfo* for_info, BlockState* for_state, int stmt_pos, ForInfo* for_info, ZoneList<const AstRawString*>* labels,
ZoneList<const AstRawString*>* labels, bool* ok); bool* ok);
StatementT ParseForEachStatementWithoutDeclarations( StatementT ParseForEachStatementWithoutDeclarations(
int stmt_pos, ExpressionT expression, int lhs_beg_pos, int lhs_end_pos, int stmt_pos, ExpressionT expression, int lhs_beg_pos, int lhs_end_pos,
ForInfo* for_info, BlockState* for_state, ForInfo* for_info, ZoneList<const AstRawString*>* labels, bool* ok);
ZoneList<const AstRawString*>* labels, bool* ok);
// Parse a C-style for loop: 'for (<init>; <cond>; <step>) { ... }' // Parse a C-style for loop: 'for (<init>; <cond>; <step>) { ... }'
StatementT ParseStandardForLoop(int stmt_pos, StatementT init, StatementT ParseStandardForLoop(int stmt_pos, StatementT init,
...@@ -1405,7 +1372,7 @@ class ParserBase { ...@@ -1405,7 +1372,7 @@ class ParserBase {
ModuleDescriptor* module() const { ModuleDescriptor* module() const {
return scope()->AsModuleScope()->module(); return scope()->AsModuleScope()->module();
} }
Scope* scope() const { return scope_state_->scope(); } Scope* scope() const { return scope_; }
// Stack of expression classifiers. // Stack of expression classifiers.
// The top of the stack is always pointed to by classifier(). // The top of the stack is always pointed to by classifier().
...@@ -1448,7 +1415,7 @@ class ParserBase { ...@@ -1448,7 +1415,7 @@ class ParserBase {
// Parser base's protected field members. // Parser base's protected field members.
ScopeState* scope_state_; // Scope stack. Scope* scope_; // Scope stack.
FunctionState* function_state_; // Function state stack. FunctionState* function_state_; // Function state stack.
v8::Extension* extension_; v8::Extension* extension_;
FuncNameInferrer* fni_; FuncNameInferrer* fni_;
...@@ -1488,13 +1455,14 @@ class ParserBase { ...@@ -1488,13 +1455,14 @@ class ParserBase {
template <typename Impl> template <typename Impl>
ParserBase<Impl>::FunctionState::FunctionState( ParserBase<Impl>::FunctionState::FunctionState(
FunctionState** function_state_stack, ScopeState** scope_stack, FunctionState** function_state_stack, Scope** scope_stack,
DeclarationScope* scope) DeclarationScope* scope)
: ScopeState(scope_stack, scope), : BlockState(scope_stack, scope),
next_materialized_literal_index_(0), next_materialized_literal_index_(0),
expected_property_count_(0), expected_property_count_(0),
function_state_stack_(function_state_stack), function_state_stack_(function_state_stack),
outer_function_state_(*function_state_stack), outer_function_state_(*function_state_stack),
scope_(scope),
destructuring_assignments_to_rewrite_(16, scope->zone()), destructuring_assignments_to_rewrite_(16, scope->zone()),
tail_call_expressions_(scope->zone()), tail_call_expressions_(scope->zone()),
return_expr_context_(ReturnExprContext::kInsideValidBlock), return_expr_context_(ReturnExprContext::kInsideValidBlock),
...@@ -2334,9 +2302,8 @@ ParserBase<Impl>::ParseClassFieldForInitializer(bool has_initializer, ...@@ -2334,9 +2302,8 @@ ParserBase<Impl>::ParseClassFieldForInitializer(bool has_initializer,
FunctionKind kind = FunctionKind::kConciseMethod; FunctionKind kind = FunctionKind::kConciseMethod;
DeclarationScope* initializer_scope = NewFunctionScope(kind); DeclarationScope* initializer_scope = NewFunctionScope(kind);
initializer_scope->set_start_position(scanner()->location().end_pos); initializer_scope->set_start_position(scanner()->location().end_pos);
FunctionState initializer_state(&function_state_, &scope_state_, FunctionState initializer_state(&function_state_, &scope_, initializer_scope);
initializer_scope); DCHECK_EQ(initializer_scope, scope());
DCHECK(scope() == initializer_scope);
scope()->SetLanguageMode(STRICT); scope()->SetLanguageMode(STRICT);
ExpressionClassifier expression_classifier(this); ExpressionClassifier expression_classifier(this);
ExpressionT value; ExpressionT value;
...@@ -3972,7 +3939,7 @@ void ParserBase<Impl>::ParseFunctionBody( ...@@ -3972,7 +3939,7 @@ void ParserBase<Impl>::ParseFunctionBody(
} }
{ {
BlockState block_state(&scope_state_, inner_scope); BlockState block_state(&scope_, inner_scope);
if (IsGeneratorFunction(kind)) { if (IsGeneratorFunction(kind)) {
impl()->ParseAndRewriteGeneratorFunctionBody(pos, kind, body, ok); impl()->ParseAndRewriteGeneratorFunctionBody(pos, kind, body, ok);
...@@ -4152,7 +4119,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral( ...@@ -4152,7 +4119,7 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
bool should_be_used_once_hint = false; bool should_be_used_once_hint = false;
bool has_braces = true; bool has_braces = true;
{ {
FunctionState function_state(&function_state_, &scope_state_, FunctionState function_state(&function_state_, &scope_,
formal_parameters.scope); formal_parameters.scope);
Expect(Token::ARROW, CHECK_OK); Expect(Token::ARROW, CHECK_OK);
...@@ -4295,20 +4262,18 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseClassLiteral( ...@@ -4295,20 +4262,18 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseClassLiteral(
return impl()->EmptyExpression(); return impl()->EmptyExpression();
} }
BlockState block_state(zone(), &scope_state_); BlockState block_state(zone(), &scope_);
RaiseLanguageMode(STRICT); RaiseLanguageMode(STRICT);
ClassInfo class_info(this); ClassInfo class_info(this);
impl()->DeclareClassVariable(name, &class_info, class_token_pos, CHECK_OK); impl()->DeclareClassVariable(name, &class_info, class_token_pos, CHECK_OK);
scope()->set_start_position(scanner()->location().end_pos);
if (Check(Token::EXTENDS)) { if (Check(Token::EXTENDS)) {
block_state.set_start_position(scanner()->location().end_pos);
ExpressionClassifier extends_classifier(this); ExpressionClassifier extends_classifier(this);
class_info.extends = ParseLeftHandSideExpression(CHECK_OK); class_info.extends = ParseLeftHandSideExpression(CHECK_OK);
impl()->RewriteNonPattern(CHECK_OK); impl()->RewriteNonPattern(CHECK_OK);
impl()->AccumulateFormalParameterContainmentErrors(); impl()->AccumulateFormalParameterContainmentErrors();
} else {
block_state.set_start_position(scanner()->location().end_pos);
} }
ClassLiteralChecker checker(this); ClassLiteralChecker checker(this);
...@@ -4850,8 +4815,8 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseBlock( ...@@ -4850,8 +4815,8 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseBlock(
// Parse the statements and collect escaping labels. // Parse the statements and collect escaping labels.
Expect(Token::LBRACE, CHECK_OK_CUSTOM(NullBlock)); Expect(Token::LBRACE, CHECK_OK_CUSTOM(NullBlock));
{ {
BlockState block_state(zone(), &scope_state_); BlockState block_state(zone(), &scope_);
block_state.set_start_position(scanner()->location().beg_pos); scope()->set_start_position(scanner()->location().beg_pos);
typename Types::Target target(this, body); typename Types::Target target(this, body);
while (peek() != Token::RBRACE) { while (peek() != Token::RBRACE) {
...@@ -4862,8 +4827,8 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseBlock( ...@@ -4862,8 +4827,8 @@ typename ParserBase<Impl>::BlockT ParserBase<Impl>::ParseBlock(
} }
Expect(Token::RBRACE, CHECK_OK_CUSTOM(NullBlock)); Expect(Token::RBRACE, CHECK_OK_CUSTOM(NullBlock));
block_state.set_end_position(scanner()->location().end_pos); scope()->set_end_position(scanner()->location().end_pos);
body->set_scope(block_state.FinalizedBlockScope()); body->set_scope(scope()->FinalizeBlockScope());
} }
return body; return body;
} }
...@@ -4876,13 +4841,13 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseScopedStatement( ...@@ -4876,13 +4841,13 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseScopedStatement(
} else { } else {
// Make a block around the statement for a lexical binding // Make a block around the statement for a lexical binding
// is introduced by a FunctionDeclaration. // is introduced by a FunctionDeclaration.
BlockState block_state(zone(), &scope_state_); BlockState block_state(zone(), &scope_);
block_state.set_start_position(scanner()->location().beg_pos); scope()->set_start_position(scanner()->location().beg_pos);
BlockT block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition); BlockT block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition);
StatementT body = ParseFunctionDeclaration(CHECK_OK); StatementT body = ParseFunctionDeclaration(CHECK_OK);
block->statements()->Add(body, zone()); block->statements()->Add(body, zone());
block_state.set_end_position(scanner()->location().end_pos); scope()->set_end_position(scanner()->location().end_pos);
block->set_scope(block_state.FinalizedBlockScope()); block->set_scope(scope()->FinalizeBlockScope());
return block; return block;
} }
} }
...@@ -5165,7 +5130,7 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseWithStatement( ...@@ -5165,7 +5130,7 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseWithStatement(
Scope* with_scope = NewScope(WITH_SCOPE); Scope* with_scope = NewScope(WITH_SCOPE);
StatementT body = impl()->NullStatement(); StatementT body = impl()->NullStatement();
{ {
BlockState block_state(&scope_state_, with_scope); BlockState block_state(&scope_, with_scope);
with_scope->set_start_position(scanner()->peek_location().beg_pos); with_scope->set_start_position(scanner()->peek_location().beg_pos);
body = ParseStatement(labels, CHECK_OK); body = ParseStatement(labels, CHECK_OK);
with_scope->set_end_position(scanner()->location().end_pos); with_scope->set_end_position(scanner()->location().end_pos);
...@@ -5257,9 +5222,9 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseSwitchStatement( ...@@ -5257,9 +5222,9 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseSwitchStatement(
auto switch_statement = factory()->NewSwitchStatement(labels, switch_pos); auto switch_statement = factory()->NewSwitchStatement(labels, switch_pos);
{ {
BlockState cases_block_state(zone(), &scope_state_); BlockState cases_block_state(zone(), &scope_);
cases_block_state.set_start_position(scanner()->location().beg_pos); scope()->set_start_position(scanner()->location().beg_pos);
cases_block_state.SetNonlinear(); scope()->SetNonlinear();
typename Types::Target target(this, switch_statement); typename Types::Target target(this, switch_statement);
bool default_seen = false; bool default_seen = false;
...@@ -5292,9 +5257,9 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseSwitchStatement( ...@@ -5292,9 +5257,9 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseSwitchStatement(
} }
Expect(Token::RBRACE, CHECK_OK); Expect(Token::RBRACE, CHECK_OK);
cases_block_state.set_end_position(scanner()->location().end_pos); scope()->set_end_position(scanner()->location().end_pos);
return impl()->RewriteSwitchStatement( return impl()->RewriteSwitchStatement(tag, switch_statement, cases,
tag, switch_statement, cases, cases_block_state.FinalizedBlockScope()); scope()->FinalizeBlockScope());
} }
} }
...@@ -5340,16 +5305,15 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseTryStatement( ...@@ -5340,16 +5305,15 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseTryStatement(
CollectExpressionsInTailPositionToListScope CollectExpressionsInTailPositionToListScope
collect_tail_call_expressions_scope( collect_tail_call_expressions_scope(
function_state_, &catch_info.tail_call_expressions); function_state_, &catch_info.tail_call_expressions);
BlockState catch_block_state(&scope_state_, catch_info.scope); BlockState catch_block_state(&scope_, catch_info.scope);
catch_block = factory()->NewBlock(nullptr, 16, false, kNoSourcePosition); catch_block = factory()->NewBlock(nullptr, 16, false, kNoSourcePosition);
// Create a block scope to hold any lexical declarations created // Create a block scope to hold any lexical declarations created
// as part of destructuring the catch parameter. // as part of destructuring the catch parameter.
{ {
BlockState catch_variable_block_state(zone(), &scope_state_); BlockState catch_variable_block_state(zone(), &scope_);
catch_variable_block_state.set_start_position( scope()->set_start_position(scanner()->location().beg_pos);
scanner()->location().beg_pos);
typename Types::Target target(this, catch_block); typename Types::Target target(this, catch_block);
// This does not simply call ParsePrimaryExpression to avoid // This does not simply call ParsePrimaryExpression to avoid
...@@ -5374,10 +5338,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseTryStatement( ...@@ -5374,10 +5338,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseTryStatement(
catch_info.inner_block = ParseBlock(nullptr, CHECK_OK); catch_info.inner_block = ParseBlock(nullptr, CHECK_OK);
catch_block->statements()->Add(catch_info.inner_block, zone()); catch_block->statements()->Add(catch_info.inner_block, zone());
impl()->ValidateCatchBlock(catch_info, CHECK_OK); impl()->ValidateCatchBlock(catch_info, CHECK_OK);
catch_variable_block_state.set_end_position( scope()->set_end_position(scanner()->location().end_pos);
scanner()->location().end_pos); catch_block->set_scope(scope()->FinalizeBlockScope());
catch_block->set_scope(
catch_variable_block_state.FinalizedBlockScope());
} }
} }
...@@ -5402,11 +5364,11 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement( ...@@ -5402,11 +5364,11 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement(
bool bound_names_are_lexical = false; bool bound_names_are_lexical = false;
// Create an in-between scope for let-bound iteration variables. // Create an in-between scope for let-bound iteration variables.
BlockState for_state(zone(), &scope_state_); BlockState for_state(zone(), &scope_);
Expect(Token::FOR, CHECK_OK); Expect(Token::FOR, CHECK_OK);
Expect(Token::LPAREN, CHECK_OK); Expect(Token::LPAREN, CHECK_OK);
for_state.set_start_position(scanner()->location().beg_pos); scope()->set_start_position(scanner()->location().beg_pos);
for_state.set_is_hidden(); scope()->set_is_hidden();
StatementT init = impl()->NullStatement(); StatementT init = impl()->NullStatement();
...@@ -5420,8 +5382,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement( ...@@ -5420,8 +5382,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement(
for_info.position = scanner()->location().beg_pos; for_info.position = scanner()->location().beg_pos;
if (CheckInOrOf(&for_info.mode)) { if (CheckInOrOf(&for_info.mode)) {
return ParseForEachStatementWithDeclarations(stmt_pos, &for_info, return ParseForEachStatementWithDeclarations(stmt_pos, &for_info, labels,
&for_state, labels, ok); ok);
} }
// One or more declaration not followed by in/of. // One or more declaration not followed by in/of.
...@@ -5446,9 +5408,9 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement( ...@@ -5446,9 +5408,9 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement(
} }
if (is_for_each) { if (is_for_each) {
return ParseForEachStatementWithoutDeclarations( return ParseForEachStatementWithoutDeclarations(stmt_pos, expression,
stmt_pos, expression, lhs_beg_pos, lhs_end_pos, &for_info, &for_state, lhs_beg_pos, lhs_end_pos,
labels, ok); &for_info, labels, ok);
} }
// Initializer is just an expression. // Initializer is just an expression.
init = factory()->NewExpressionStatement(expression, lhs_beg_pos); init = factory()->NewExpressionStatement(expression, lhs_beg_pos);
...@@ -5462,8 +5424,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement( ...@@ -5462,8 +5424,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForStatement(
template <typename Impl> template <typename Impl>
typename ParserBase<Impl>::StatementT typename ParserBase<Impl>::StatementT
ParserBase<Impl>::ParseForEachStatementWithDeclarations( ParserBase<Impl>::ParseForEachStatementWithDeclarations(
int stmt_pos, ForInfo* for_info, BlockState* for_state, int stmt_pos, ForInfo* for_info, ZoneList<const AstRawString*>* labels,
ZoneList<const AstRawString*>* labels, bool* ok) { bool* ok) {
// Just one declaration followed by in/of. // Just one declaration followed by in/of.
if (for_info->parsing_result.declarations.length() != 1) { if (for_info->parsing_result.declarations.length() != 1) {
impl()->ReportMessageAt(for_info->parsing_result.bindings_loc, impl()->ReportMessageAt(for_info->parsing_result.bindings_loc,
...@@ -5507,8 +5469,8 @@ ParserBase<Impl>::ParseForEachStatementWithDeclarations( ...@@ -5507,8 +5469,8 @@ ParserBase<Impl>::ParseForEachStatementWithDeclarations(
{ {
ReturnExprScope no_tail_calls(function_state_, ReturnExprScope no_tail_calls(function_state_,
ReturnExprContext::kInsideForInOfBody); ReturnExprContext::kInsideForInOfBody);
BlockState block_state(zone(), &scope_state_); BlockState block_state(zone(), &scope_);
block_state.set_start_position(scanner()->location().beg_pos); scope()->set_start_position(scanner()->location().beg_pos);
StatementT body = ParseStatement(nullptr, CHECK_OK); StatementT body = ParseStatement(nullptr, CHECK_OK);
...@@ -5520,14 +5482,14 @@ ParserBase<Impl>::ParseForEachStatementWithDeclarations( ...@@ -5520,14 +5482,14 @@ ParserBase<Impl>::ParseForEachStatementWithDeclarations(
final_loop = impl()->InitializeForEachStatement( final_loop = impl()->InitializeForEachStatement(
loop, each_variable, enumerable, body_block, each_keyword_pos); loop, each_variable, enumerable, body_block, each_keyword_pos);
block_state.set_end_position(scanner()->location().end_pos); scope()->set_end_position(scanner()->location().end_pos);
body_block->set_scope(block_state.FinalizedBlockScope()); body_block->set_scope(scope()->FinalizeBlockScope());
} }
init_block = impl()->CreateForEachStatementTDZ(init_block, *for_info, ok); init_block = impl()->CreateForEachStatementTDZ(init_block, *for_info, ok);
for_state->set_end_position(scanner()->location().end_pos); scope()->set_end_position(scanner()->location().end_pos);
Scope* for_scope = for_state->FinalizedBlockScope(); Scope* for_scope = scope()->FinalizeBlockScope();
// Parsed for-in loop w/ variable declarations. // Parsed for-in loop w/ variable declarations.
if (!impl()->IsNullStatement(init_block)) { if (!impl()->IsNullStatement(init_block)) {
init_block->statements()->Add(final_loop, zone()); init_block->statements()->Add(final_loop, zone());
...@@ -5543,8 +5505,7 @@ template <typename Impl> ...@@ -5543,8 +5505,7 @@ template <typename Impl>
typename ParserBase<Impl>::StatementT typename ParserBase<Impl>::StatementT
ParserBase<Impl>::ParseForEachStatementWithoutDeclarations( ParserBase<Impl>::ParseForEachStatementWithoutDeclarations(
int stmt_pos, ExpressionT expression, int lhs_beg_pos, int lhs_end_pos, int stmt_pos, ExpressionT expression, int lhs_beg_pos, int lhs_end_pos,
ForInfo* for_info, BlockState* for_state, ForInfo* for_info, ZoneList<const AstRawString*>* labels, bool* ok) {
ZoneList<const AstRawString*>* labels, bool* ok) {
// Initializer is reference followed by in/of. // Initializer is reference followed by in/of.
if (!expression->IsArrayLiteral() && !expression->IsObjectLiteral()) { if (!expression->IsArrayLiteral() && !expression->IsObjectLiteral()) {
expression = impl()->CheckAndRewriteReferenceExpression( expression = impl()->CheckAndRewriteReferenceExpression(
...@@ -5567,24 +5528,25 @@ ParserBase<Impl>::ParseForEachStatementWithoutDeclarations( ...@@ -5567,24 +5528,25 @@ ParserBase<Impl>::ParseForEachStatementWithoutDeclarations(
} }
Expect(Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
Scope* for_scope = scope();
{ {
ReturnExprScope no_tail_calls(function_state_, ReturnExprScope no_tail_calls(function_state_,
ReturnExprContext::kInsideForInOfBody); ReturnExprContext::kInsideForInOfBody);
BlockState block_state(zone(), &scope_state_); BlockState block_state(zone(), &scope_);
block_state.set_start_position(scanner()->location().beg_pos); scope()->set_start_position(scanner()->location().beg_pos);
StatementT body = ParseStatement(nullptr, CHECK_OK); StatementT body = ParseStatement(nullptr, CHECK_OK);
block_state.set_end_position(scanner()->location().end_pos); scope()->set_end_position(scanner()->location().end_pos);
StatementT final_loop = impl()->InitializeForEachStatement( StatementT final_loop = impl()->InitializeForEachStatement(
loop, expression, enumerable, body, each_keyword_pos); loop, expression, enumerable, body, each_keyword_pos);
Scope* for_scope = for_state->FinalizedBlockScope(); for_scope = for_scope->FinalizeBlockScope();
DCHECK_NULL(for_scope);
USE(for_scope); USE(for_scope);
Scope* block_scope = block_state.FinalizedBlockScope(); DCHECK_NULL(for_scope);
DCHECK_NULL(block_scope); Scope* block_scope = scope()->FinalizeBlockScope();
USE(block_scope); USE(block_scope);
DCHECK_NULL(block_scope);
return final_loop; return final_loop;
} }
} }
...@@ -5606,13 +5568,12 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStandardForLoop( ...@@ -5606,13 +5568,12 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStandardForLoop(
// If there are let bindings, then condition and the next statement of the // If there are let bindings, then condition and the next statement of the
// for loop must be parsed in a new scope. // for loop must be parsed in a new scope.
Scope* inner_scope = scope(); Scope* inner_scope = scope();
// TODO(verwaest): Allocate this through a ScopeState as well.
if (bound_names_are_lexical && for_info->bound_names.length() > 0) { if (bound_names_are_lexical && for_info->bound_names.length() > 0) {
inner_scope = NewScopeWithParent(inner_scope, BLOCK_SCOPE); inner_scope = NewScopeWithParent(inner_scope, BLOCK_SCOPE);
inner_scope->set_start_position(scanner()->location().beg_pos); inner_scope->set_start_position(scanner()->location().beg_pos);
} }
{ {
BlockState block_state(&scope_state_, inner_scope); BlockState block_state(&scope_, inner_scope);
if (peek() != Token::SEMICOLON) { if (peek() != Token::SEMICOLON) {
cond = ParseExpression(true, CHECK_OK); cond = ParseExpression(true, CHECK_OK);
...@@ -5631,13 +5592,13 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStandardForLoop( ...@@ -5631,13 +5592,13 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseStandardForLoop(
if (bound_names_are_lexical && for_info->bound_names.length() > 0) { if (bound_names_are_lexical && for_info->bound_names.length() > 0) {
auto result = impl()->DesugarLexicalBindingsInForStatement( auto result = impl()->DesugarLexicalBindingsInForStatement(
loop, init, cond, next, body, inner_scope, *for_info, CHECK_OK); loop, init, cond, next, body, inner_scope, *for_info, CHECK_OK);
for_state->set_end_position(scanner()->location().end_pos); scope()->set_end_position(scanner()->location().end_pos);
inner_scope->set_end_position(scanner()->location().end_pos); inner_scope->set_end_position(scanner()->location().end_pos);
return result; return result;
} }
for_state->set_end_position(scanner()->location().end_pos); scope()->set_end_position(scanner()->location().end_pos);
Scope* for_scope = for_state->FinalizedBlockScope(); Scope* for_scope = scope()->FinalizeBlockScope();
if (for_scope != nullptr) { if (for_scope != nullptr) {
// Rewrite a for statement of the form // Rewrite a for statement of the form
// for (const x = i; c; n) b // for (const x = i; c; n) b
...@@ -5691,12 +5652,12 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForAwaitStatement( ...@@ -5691,12 +5652,12 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForAwaitStatement(
for_info.mode = ForEachStatement::ITERATE; for_info.mode = ForEachStatement::ITERATE;
// Create an in-between scope for let-bound iteration variables. // Create an in-between scope for let-bound iteration variables.
BlockState for_state(zone(), &scope_state_); BlockState for_state(zone(), &scope_);
Expect(Token::FOR, CHECK_OK); Expect(Token::FOR, CHECK_OK);
Expect(Token::AWAIT, CHECK_OK); Expect(Token::AWAIT, CHECK_OK);
Expect(Token::LPAREN, CHECK_OK); Expect(Token::LPAREN, CHECK_OK);
for_state.set_start_position(scanner()->location().beg_pos); scope()->set_start_position(scanner()->location().beg_pos);
for_state.set_is_hidden(); scope()->set_is_hidden();
auto loop = factory()->NewForOfStatement(labels, stmt_pos); auto loop = factory()->NewForOfStatement(labels, stmt_pos);
typename Types::Target target(this, loop); typename Types::Target target(this, loop);
...@@ -5768,22 +5729,22 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForAwaitStatement( ...@@ -5768,22 +5729,22 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForAwaitStatement(
Expect(Token::RPAREN, CHECK_OK); Expect(Token::RPAREN, CHECK_OK);
StatementT final_loop = impl()->NullStatement(); StatementT final_loop = impl()->NullStatement();
Scope* for_scope = scope();
{ {
ReturnExprScope no_tail_calls(function_state_, ReturnExprScope no_tail_calls(function_state_,
ReturnExprContext::kInsideForInOfBody); ReturnExprContext::kInsideForInOfBody);
BlockState block_state(zone(), &scope_state_); BlockState block_state(zone(), &scope_);
block_state.set_start_position(scanner()->location().beg_pos); scope()->set_start_position(scanner()->location().beg_pos);
StatementT body = ParseStatement(nullptr, CHECK_OK); StatementT body = ParseStatement(nullptr, CHECK_OK);
block_state.set_end_position(scanner()->location().end_pos); scope()->set_end_position(scanner()->location().end_pos);
if (has_declarations) { if (has_declarations) {
BlockT body_block = impl()->NullBlock(); BlockT body_block = impl()->NullBlock();
impl()->DesugarBindingInForEachStatement(&for_info, &body_block, impl()->DesugarBindingInForEachStatement(&for_info, &body_block,
&each_variable, CHECK_OK); &each_variable, CHECK_OK);
body_block->statements()->Add(body, zone()); body_block->statements()->Add(body, zone());
body_block->set_scope(block_state.FinalizedBlockScope()); body_block->set_scope(scope()->FinalizeBlockScope());
for_state.set_end_position(scanner()->location().end_pos);
const bool finalize = true; const bool finalize = true;
final_loop = impl()->InitializeForOfStatement( final_loop = impl()->InitializeForOfStatement(
...@@ -5795,10 +5756,10 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForAwaitStatement( ...@@ -5795,10 +5756,10 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForAwaitStatement(
loop, each_variable, iterable, body, finalize, IteratorType::kAsync, loop, each_variable, iterable, body, finalize, IteratorType::kAsync,
each_keyword_pos); each_keyword_pos);
Scope* for_scope = for_state.FinalizedBlockScope(); for_scope = for_scope->FinalizeBlockScope();
DCHECK_NULL(for_scope); DCHECK_NULL(for_scope);
USE(for_scope); USE(for_scope);
Scope* block_scope = block_state.FinalizedBlockScope(); Scope* block_scope = scope()->FinalizeBlockScope();
DCHECK_NULL(block_scope); DCHECK_NULL(block_scope);
USE(block_scope); USE(block_scope);
return final_loop; return final_loop;
...@@ -5809,8 +5770,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForAwaitStatement( ...@@ -5809,8 +5770,8 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseForAwaitStatement(
BlockT init_block = BlockT init_block =
impl()->CreateForEachStatementTDZ(impl()->NullBlock(), for_info, ok); impl()->CreateForEachStatementTDZ(impl()->NullBlock(), for_info, ok);
for_state.set_end_position(scanner()->location().end_pos); for_scope->set_end_position(scanner()->location().end_pos);
Scope* for_scope = for_state.FinalizedBlockScope(); for_scope = for_scope->FinalizeBlockScope();
// Parsed for-in loop w/ variable declarations. // Parsed for-in loop w/ variable declarations.
if (!impl()->IsNullStatement(init_block)) { if (!impl()->IsNullStatement(init_block)) {
init_block->statements()->Add(final_loop, zone()); init_block->statements()->Add(final_loop, zone());
......
...@@ -181,8 +181,7 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name, ...@@ -181,8 +181,7 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
ZoneList<Statement*>* body = NULL; ZoneList<Statement*>* body = NULL;
{ {
FunctionState function_state(&function_state_, &scope_state_, FunctionState function_state(&function_state_, &scope_, function_scope);
function_scope);
body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone()); body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone());
if (call_super) { if (call_super) {
...@@ -657,7 +656,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { ...@@ -657,7 +656,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
// Note that this function can be called from the main thread or from a // Note that this function can be called from the main thread or from a
// background thread. We should not access anything Isolate / heap dependent // background thread. We should not access anything Isolate / heap dependent
// via ParseInfo, and also not pass it forward. // via ParseInfo, and also not pass it forward.
DCHECK_NULL(scope_state_); DCHECK_NULL(scope_);
DCHECK_NULL(target_stack_); DCHECK_NULL(target_stack_);
ParsingModeScope mode(this, allow_lazy_ ? PARSE_LAZILY : PARSE_EAGERLY); ParsingModeScope mode(this, allow_lazy_ ? PARSE_LAZILY : PARSE_EAGERLY);
...@@ -681,7 +680,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) { ...@@ -681,7 +680,7 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
scope->set_start_position(0); scope->set_start_position(0);
FunctionState function_state(&function_state_, &scope_state_, scope); FunctionState function_state(&function_state_, &scope_, scope);
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
bool ok = true; bool ok = true;
...@@ -823,7 +822,7 @@ FunctionLiteral* Parser::DoParseFunction(ParseInfo* info, ...@@ -823,7 +822,7 @@ FunctionLiteral* Parser::DoParseFunction(ParseInfo* info,
const AstRawString* raw_name, const AstRawString* raw_name,
Utf16CharacterStream* source) { Utf16CharacterStream* source) {
scanner_.Initialize(source); scanner_.Initialize(source);
DCHECK_NULL(scope_state_); DCHECK_NULL(scope_);
DCHECK_NULL(target_stack_); DCHECK_NULL(target_stack_);
DCHECK(ast_value_factory()); DCHECK(ast_value_factory());
...@@ -844,9 +843,8 @@ FunctionLiteral* Parser::DoParseFunction(ParseInfo* info, ...@@ -844,9 +843,8 @@ FunctionLiteral* Parser::DoParseFunction(ParseInfo* info,
Scope* outer = original_scope_; Scope* outer = original_scope_;
DeclarationScope* outer_function = outer->GetClosureScope(); DeclarationScope* outer_function = outer->GetClosureScope();
DCHECK(outer); DCHECK(outer);
FunctionState function_state(&function_state_, &scope_state_, FunctionState function_state(&function_state_, &scope_, outer_function);
outer_function); BlockState block_state(&scope_, outer);
BlockState block_state(&scope_state_, outer);
DCHECK(is_sloppy(outer->language_mode()) || DCHECK(is_sloppy(outer->language_mode()) ||
is_strict(info->language_mode())); is_strict(info->language_mode()));
FunctionLiteral::FunctionType function_type = ComputeFunctionType(info); FunctionLiteral::FunctionType function_type = ComputeFunctionType(info);
...@@ -886,7 +884,7 @@ FunctionLiteral* Parser::DoParseFunction(ParseInfo* info, ...@@ -886,7 +884,7 @@ FunctionLiteral* Parser::DoParseFunction(ParseInfo* info,
// Parsing patterns as variable reference expression creates // Parsing patterns as variable reference expression creates
// NewUnresolved references in current scope. Entrer arrow function // NewUnresolved references in current scope. Entrer arrow function
// scope for formal parameter parsing. // scope for formal parameter parsing.
BlockState block_state(&scope_state_, scope); BlockState block_state(&scope_, scope);
if (Check(Token::LPAREN)) { if (Check(Token::LPAREN)) {
// '(' StrictFormalParameters ')' // '(' StrictFormalParameters ')'
ParseFormalParameterList(&formals, &ok); ParseFormalParameterList(&formals, &ok);
...@@ -2252,7 +2250,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( ...@@ -2252,7 +2250,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
Block* inner_block = factory()->NewBlock(NULL, 3, false, kNoSourcePosition); Block* inner_block = factory()->NewBlock(NULL, 3, false, kNoSourcePosition);
{ {
BlockState block_state(&scope_state_, inner_scope); BlockState block_state(&scope_, inner_scope);
Block* ignore_completion_block = factory()->NewBlock( Block* ignore_completion_block = factory()->NewBlock(
nullptr, for_info.bound_names.length() + 3, true, kNoSourcePosition); nullptr, for_info.bound_names.length() + 3, true, kNoSourcePosition);
...@@ -2962,14 +2960,14 @@ Block* Parser::BuildParameterInitializationBlock( ...@@ -2962,14 +2960,14 @@ Block* Parser::BuildParameterInitializationBlock(
param_scope); param_scope);
} }
BlockState block_state(&scope_state_, param_scope); BlockState block_state(&scope_, param_scope);
DeclarationParsingResult::Declaration decl( DeclarationParsingResult::Declaration decl(
parameter->pattern, parameter->initializer_end_position, initial_value); parameter->pattern, parameter->initializer_end_position, initial_value);
PatternRewriter::DeclareAndInitializeVariables( PatternRewriter::DeclareAndInitializeVariables(
this, param_block, &descriptor, &decl, nullptr, CHECK_OK); this, param_block, &descriptor, &decl, nullptr, CHECK_OK);
if (param_block != init_block) { if (param_block != init_block) {
param_scope = block_state.FinalizedBlockScope(); param_scope = param_scope->FinalizeBlockScope();
if (param_scope != nullptr) { if (param_scope != nullptr) {
CheckConflictingVarDeclarations(param_scope, CHECK_OK); CheckConflictingVarDeclarations(param_scope, CHECK_OK);
} }
...@@ -3122,7 +3120,7 @@ ZoneList<Statement*>* Parser::ParseFunction( ...@@ -3122,7 +3120,7 @@ ZoneList<Statement*>* Parser::ParseFunction(
bool* has_duplicate_parameters, int* expected_property_count, bool* ok) { bool* has_duplicate_parameters, int* expected_property_count, bool* ok) {
ParsingModeScope mode(this, allow_lazy_ ? PARSE_LAZILY : PARSE_EAGERLY); ParsingModeScope mode(this, allow_lazy_ ? PARSE_LAZILY : PARSE_EAGERLY);
FunctionState function_state(&function_state_, &scope_state_, function_scope); FunctionState function_state(&function_state_, &scope_, function_scope);
DuplicateFinder duplicate_finder; DuplicateFinder duplicate_finder;
ExpressionClassifier formals_classifier(this, &duplicate_finder); ExpressionClassifier formals_classifier(this, &duplicate_finder);
...@@ -3307,7 +3305,7 @@ void Parser::InsertShadowingVarBindingInitializers(Block* inner_block) { ...@@ -3307,7 +3305,7 @@ void Parser::InsertShadowingVarBindingInitializers(Block* inner_block) {
DCHECK(inner_scope->is_declaration_scope()); DCHECK(inner_scope->is_declaration_scope());
Scope* function_scope = inner_scope->outer_scope(); Scope* function_scope = inner_scope->outer_scope();
DCHECK(function_scope->is_function_scope()); DCHECK(function_scope->is_function_scope());
BlockState block_state(&scope_state_, inner_scope); BlockState block_state(&scope_, inner_scope);
for (Declaration* decl : *inner_scope->declarations()) { for (Declaration* decl : *inner_scope->declarations()) {
if (decl->proxy()->var()->mode() != VAR || !decl->IsVariableDeclaration()) { if (decl->proxy()->var()->mode() != VAR || !decl->IsVariableDeclaration()) {
continue; continue;
......
...@@ -103,10 +103,11 @@ PreParser::PreParseResult PreParser::PreParseFunction( ...@@ -103,10 +103,11 @@ PreParser::PreParseResult PreParser::PreParseFunction(
ResetFunctionLiteralId(); ResetFunctionLiteralId();
// The caller passes the function_scope which is not yet inserted into the // The caller passes the function_scope which is not yet inserted into the
// scope_state_. All scopes above the function_scope are ignored by the // scope stack. All scopes above the function_scope are ignored by the
// PreParser. // PreParser.
DCHECK_NULL(scope_state_); DCHECK_NULL(function_state_);
FunctionState function_state(&function_state_, &scope_state_, function_scope); DCHECK_NULL(scope_);
FunctionState function_state(&function_state_, &scope_, function_scope);
// This indirection is needed so that we can use the CHECK_OK macros. // This indirection is needed so that we can use the CHECK_OK macros.
bool ok_holder = true; bool ok_holder = true;
bool* ok = &ok_holder; bool* ok = &ok_holder;
...@@ -143,7 +144,7 @@ PreParser::PreParseResult PreParser::PreParseFunction( ...@@ -143,7 +144,7 @@ PreParser::PreParseResult PreParser::PreParseFunction(
} }
{ {
BlockState block_state(&scope_state_, inner_scope); BlockState block_state(&scope_, inner_scope);
result = ParseStatementListAndLogFunction( result = ParseStatementListAndLogFunction(
&formals, has_duplicate_parameters, may_abort, ok); &formals, has_duplicate_parameters, may_abort, ok);
} }
...@@ -234,7 +235,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral( ...@@ -234,7 +235,7 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
DeclarationScope* function_scope = NewFunctionScope(kind); DeclarationScope* function_scope = NewFunctionScope(kind);
function_scope->SetLanguageMode(language_mode); function_scope->SetLanguageMode(language_mode);
FunctionState function_state(&function_state_, &scope_state_, function_scope); FunctionState function_state(&function_state_, &scope_, function_scope);
DuplicateFinder duplicate_finder; DuplicateFinder duplicate_finder;
ExpressionClassifier formals_classifier(this, &duplicate_finder); ExpressionClassifier formals_classifier(this, &duplicate_finder);
GetNextFunctionLiteralId(); GetNextFunctionLiteralId();
......
...@@ -905,7 +905,7 @@ class PreParser : public ParserBase<PreParser> { ...@@ -905,7 +905,7 @@ class PreParser : public ParserBase<PreParser> {
// captured the syntax error), and false if a stack-overflow happened // captured the syntax error), and false if a stack-overflow happened
// during parsing. // during parsing.
PreParseResult PreParseProgram(bool is_module = false) { PreParseResult PreParseProgram(bool is_module = false) {
DCHECK_NULL(scope_state_); DCHECK_NULL(scope_);
DeclarationScope* scope = NewScriptScope(); DeclarationScope* scope = NewScriptScope();
#ifdef DEBUG #ifdef DEBUG
scope->set_is_being_lazily_parsed(true); scope->set_is_being_lazily_parsed(true);
...@@ -916,7 +916,7 @@ class PreParser : public ParserBase<PreParser> { ...@@ -916,7 +916,7 @@ class PreParser : public ParserBase<PreParser> {
// the global scope. // the global scope.
if (is_module) scope = NewModuleScope(scope); if (is_module) scope = NewModuleScope(scope);
FunctionState top_scope(&function_state_, &scope_state_, scope); FunctionState top_scope(&function_state_, &scope_, scope);
bool ok = true; bool ok = true;
int start_position = scanner()->peek_location().beg_pos; int start_position = scanner()->peek_location().beg_pos;
parsing_module_ = is_module; parsing_module_ = is_module;
......
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