Introduce parent ScopeState class and track the scope through the state in the parser

This will allow us to move more state from Scope into ScopeState and lazily allocate full Scopes only when needed.

BUG=v8:5209

Review-Url: https://codereview.chromium.org/2160593002
Cr-Commit-Position: refs/heads/master@{#37858}
This commit is contained in:
verwaest 2016-07-19 03:06:38 -07:00 committed by Commit bot
parent 7c3ddd2cf4
commit 4f552f5a17
4 changed files with 292 additions and 282 deletions

View File

@ -201,10 +201,10 @@ class ParserBase : public Traits {
v8::Extension* extension, AstValueFactory* ast_value_factory,
ParserRecorder* log, typename Traits::Type::Parser this_object)
: Traits(this_object),
scope_(NULL),
function_state_(NULL),
scope_state_(nullptr),
function_state_(nullptr),
extension_(extension),
fni_(NULL),
fni_(nullptr),
ast_value_factory_(ast_value_factory),
log_(log),
mode_(PARSE_EAGERLY), // Lazy mode must be set explicitly.
@ -272,21 +272,34 @@ class ParserBase : public Traits {
class ObjectLiteralCheckerBase;
// ---------------------------------------------------------------------------
// FunctionState and BlockState together implement the parser's scope stack.
// The parser's current scope is in scope_. BlockState and FunctionState
// constructors push on the scope stack and the destructors pop. They are also
// used to hold the parser's per-function and per-block state.
class BlockState BASE_EMBEDDED {
// ScopeState and its subclasses implement the parser's scope stack.
// ScopeState keeps track of the current scope, and the outer ScopeState. The
// parser's scope_state_ points to the top ScopeState. ScopeState's
// constructor push on the scope stack and the destructors pop. BlockState and
// FunctionState are used to hold additional per-block and per-function state.
class ScopeState BASE_EMBEDDED {
public:
BlockState(Scope** scope_stack, Scope* scope)
: scope_stack_(scope_stack), outer_scope_(*scope_stack) {
*scope_stack_ = scope;
V8_INLINE Scope* scope() const { return scope_; }
protected:
ScopeState(ScopeState** scope_stack, Scope* scope)
: scope_stack_(scope_stack), outer_scope_(*scope_stack), scope_(scope) {
*scope_stack = this;
}
~BlockState() { *scope_stack_ = outer_scope_; }
~ScopeState() { *scope_stack_ = outer_scope_; }
Zone* zone() const { return scope_->zone(); }
private:
Scope** scope_stack_;
Scope* outer_scope_;
ScopeState** scope_stack_;
ScopeState* outer_scope_;
Scope* scope_;
};
class BlockState final : public ScopeState {
public:
BlockState(ScopeState** scope_stack, Scope* scope)
: ScopeState(scope_stack, scope) {}
};
struct DestructuringAssignment {
@ -356,10 +369,10 @@ class ParserBase : public Traits {
kInsideForInOfBody,
};
class FunctionState BASE_EMBEDDED {
class FunctionState final : public ScopeState {
public:
FunctionState(FunctionState** function_state_stack, Scope** scope_stack,
Scope* scope, FunctionKind kind,
FunctionState(FunctionState** function_state_stack,
ScopeState** scope_stack, Scope* scope, FunctionKind kind,
typename Traits::Type::Factory* factory);
~FunctionState();
@ -458,13 +471,11 @@ class ParserBase : public Traits {
private:
void AddDestructuringAssignment(DestructuringAssignment pair) {
destructuring_assignments_to_rewrite_.Add(pair, (*scope_stack_)->zone());
destructuring_assignments_to_rewrite_.Add(pair, this->zone());
}
V8_INLINE Scope* scope() { return *scope_stack_; }
void AddNonPatternForRewriting(ExpressionT expr, bool* ok) {
non_patterns_to_rewrite_.Add(expr, (*scope_stack_)->zone());
non_patterns_to_rewrite_.Add(expr, this->zone());
if (non_patterns_to_rewrite_.length() >=
std::numeric_limits<uint16_t>::max())
*ok = false;
@ -495,8 +506,6 @@ class ParserBase : public Traits {
FunctionState** function_state_stack_;
FunctionState* outer_function_state_;
Scope** scope_stack_;
Scope* outer_scope_;
ZoneList<DestructuringAssignment> destructuring_assignments_to_rewrite_;
TailCallExpressionList tail_call_expressions_;
@ -815,7 +824,7 @@ class ParserBase : public Traits {
return function_state_->factory();
}
LanguageMode language_mode() { return scope_->language_mode(); }
LanguageMode language_mode() { return scope()->language_mode(); }
bool is_generator() const { return function_state_->is_generator(); }
bool is_async_function() const {
return function_state_->is_async_function();
@ -1191,7 +1200,10 @@ class ParserBase : public Traits {
bool has_seen_constructor_;
};
Scope* scope_; // Scope stack.
ModuleDescriptor* module() const { return scope()->module(); }
Scope* scope() const { return scope_state_->scope(); }
ScopeState* scope_state_; // Scope stack.
FunctionState* function_state_; // Function state stack.
v8::Extension* extension_;
FuncNameInferrer* fni_;
@ -1221,9 +1233,10 @@ class ParserBase : public Traits {
template <class Traits>
ParserBase<Traits>::FunctionState::FunctionState(
FunctionState** function_state_stack, Scope** scope_stack, Scope* scope,
FunctionKind kind, typename Traits::Type::Factory* factory)
: next_materialized_literal_index_(0),
FunctionState** function_state_stack, ScopeState** scope_stack,
Scope* scope, FunctionKind kind, typename Traits::Type::Factory* factory)
: ScopeState(scope_stack, scope),
next_materialized_literal_index_(0),
expected_property_count_(0),
this_location_(Scanner::Location::invalid()),
return_location_(Scanner::Location::invalid()),
@ -1232,8 +1245,6 @@ ParserBase<Traits>::FunctionState::FunctionState(
generator_object_variable_(NULL),
function_state_stack_(function_state_stack),
outer_function_state_(*function_state_stack),
scope_stack_(scope_stack),
outer_scope_(*scope_stack),
destructuring_assignments_to_rewrite_(16, scope->zone()),
tail_call_expressions_(scope->zone()),
return_expr_context_(ReturnExprContext::kInsideValidBlock),
@ -1242,7 +1253,6 @@ ParserBase<Traits>::FunctionState::FunctionState(
factory_(factory),
next_function_is_parenthesized_(false),
this_function_is_parenthesized_(false) {
*scope_stack_ = scope;
*function_state_stack = this;
if (outer_function_state_) {
this_function_is_parenthesized_ =
@ -1254,7 +1264,6 @@ ParserBase<Traits>::FunctionState::FunctionState(
template <class Traits>
ParserBase<Traits>::FunctionState::~FunctionState() {
*scope_stack_ = outer_scope_;
*function_state_stack_ = outer_function_state_;
}
@ -1370,7 +1379,7 @@ ParserBase<Traits>::ParseAndClassifyIdentifier(ExpressionClassifier* classifier,
}
}
if (this->IsArguments(name)) {
scope_->RecordArgumentsUsage();
scope()->RecordArgumentsUsage();
classifier->RecordStrictModeFormalParameterError(
scanner()->location(), MessageTemplate::kStrictEvalArguments);
if (is_strict(language_mode())) {
@ -1438,7 +1447,7 @@ ParserBase<Traits>::ParseIdentifierOrStrictReservedWord(
}
IdentifierT name = this->GetSymbol(scanner());
if (this->IsArguments(name)) scope_->RecordArgumentsUsage();
if (this->IsArguments(name)) scope()->RecordArgumentsUsage();
return name;
}
@ -1458,7 +1467,7 @@ ParserBase<Traits>::ParseIdentifierName(bool* ok) {
}
IdentifierT name = this->GetSymbol(scanner());
if (this->IsArguments(name)) scope_->RecordArgumentsUsage();
if (this->IsArguments(name)) scope()->RecordArgumentsUsage();
return name;
}
@ -1516,7 +1525,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
case Token::THIS: {
BindingPatternUnexpectedToken(classifier);
Consume(Token::THIS);
return this->ThisExpression(scope_, factory(), beg_pos);
return this->ThisExpression(scope(), factory(), beg_pos);
}
case Token::NULL_LITERAL:
@ -1549,7 +1558,7 @@ ParserBase<Traits>::ParsePrimaryExpression(ExpressionClassifier* classifier,
// Using eval or arguments in this context is OK even in strict mode.
IdentifierT name = ParseAndClassifyIdentifier(classifier, CHECK_OK);
return this->ExpressionFromIdentifier(
name, beg_pos, scanner()->location().end_pos, scope_, factory());
name, beg_pos, scanner()->location().end_pos, scope(), factory());
}
case Token::STRING: {
@ -1975,7 +1984,7 @@ ParserBase<Traits>::ParsePropertyDefinition(
}
}
ExpressionT lhs = this->ExpressionFromIdentifier(
*name, next_beg_pos, next_end_pos, scope_, factory());
*name, next_beg_pos, next_end_pos, scope(), factory());
CheckDestructuringElement(lhs, classifier, next_beg_pos, next_end_pos);
if (peek() == Token::ASSIGN) {
@ -2282,7 +2291,7 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
IdentifierT name =
ParseAndClassifyIdentifier(&arrow_formals_classifier, CHECK_OK);
expression = this->ExpressionFromIdentifier(
name, position(), scanner()->location().end_pos, scope_, factory());
name, position(), scanner()->location().end_pos, scope(), factory());
}
if (peek() == Token::ARROW) {
@ -2298,13 +2307,13 @@ ParserBase<Traits>::ParseAssignmentExpression(bool accept_IN,
ValidateFormalParameterInitializer(&arrow_formals_classifier, ok);
Scanner::Location loc(lhs_beg_pos, scanner()->location().end_pos);
Scope* scope = this->NewScope(scope_, FUNCTION_SCOPE,
Scope* scope = this->NewScope(this->scope(), FUNCTION_SCOPE,
is_async ? FunctionKind::kAsyncArrowFunction
: FunctionKind::kArrowFunction);
// Because the arrow's parameters were parsed in the outer scope, any
// usage flags that might have been triggered there need to be copied
// to the arrow scope.
scope_->PropagateUsageFlagsToScope(scope);
this->scope()->PropagateUsageFlagsToScope(scope);
FormalParametersT parameters(scope);
if (!arrow_formals_classifier.is_simple_parameter_list()) {
scope->SetHasNonSimpleParameters();
@ -2726,7 +2735,7 @@ ParserBase<Traits>::ParseUnaryExpression(ExpressionClassifier* classifier,
MessageTemplate::kAwaitBindingIdentifier);
return this->ExpressionFromIdentifier(
name, beg_pos, scanner()->location().end_pos, scope_, factory());
name, beg_pos, scanner()->location().end_pos, scope(), factory());
}
default:
break;
@ -2871,7 +2880,7 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
// no explicit receiver.
// These calls are marked as potentially direct eval calls. Whether
// they are actually direct calls to eval is determined at run time.
this->CheckPossibleEvalCall(result, scope_);
this->CheckPossibleEvalCall(result, scope());
bool is_super_call = result->IsSuperCallReference();
if (spread_pos.IsValid()) {
@ -2884,7 +2893,7 @@ ParserBase<Traits>::ParseLeftHandSideExpression(
// Explicit calls to the super constructor using super() perform an
// implicit binding assignment to the 'this' variable.
if (is_super_call) {
ExpressionT this_expr = this->ThisExpression(scope_, factory(), pos);
ExpressionT this_expr = this->ThisExpression(scope(), factory(), pos);
result =
factory()->NewAssignment(Token::INIT, this_expr, result, pos);
}
@ -3022,7 +3031,7 @@ ParserBase<Traits>::ParseMemberExpression(ExpressionClassifier* classifier,
return this->EmptyExpression();
}
return this->FunctionSentExpression(scope_, factory(), pos);
return this->FunctionSentExpression(scope(), factory(), pos);
}
bool is_generator = Check(Token::MUL);
@ -3065,13 +3074,13 @@ ParserBase<Traits>::ParseSuperExpression(bool is_new,
Expect(Token::SUPER, CHECK_OK);
int pos = position();
Scope* scope = scope_->ReceiverScope();
Scope* scope = this->scope()->ReceiverScope();
FunctionKind kind = scope->function_kind();
if (IsConciseMethod(kind) || IsAccessorFunction(kind) ||
IsClassConstructor(kind)) {
if (peek() == Token::PERIOD || peek() == Token::LBRACK) {
scope->RecordSuperPropertyUsage();
return this->NewSuperPropertyReference(scope_, factory(), pos);
return this->NewSuperPropertyReference(this->scope(), factory(), pos);
}
// new super() is never allowed.
// super() is only allowed in derived constructor
@ -3079,7 +3088,7 @@ ParserBase<Traits>::ParseSuperExpression(bool is_new,
// TODO(rossberg): This might not be the correct FunctionState for the
// method here.
function_state_->set_super_location(scanner()->location());
return this->NewSuperCallReference(scope_, factory(), pos);
return this->NewSuperCallReference(this->scope(), factory(), pos);
}
}
@ -3108,14 +3117,14 @@ ParserBase<Traits>::ParseNewTargetExpression(bool* ok) {
int pos = position();
ExpectMetaProperty(CStrVector("target"), "new.target", pos, CHECK_OK);
if (!scope_->ReceiverScope()->is_function_scope()) {
if (!scope()->ReceiverScope()->is_function_scope()) {
ReportMessageAt(scanner()->location(),
MessageTemplate::kUnexpectedNewTarget);
*ok = false;
return this->EmptyExpression();
}
return this->NewTargetExpression(scope_, factory(), pos);
return this->NewTargetExpression(scope(), factory(), pos);
}
template <class Traits>
@ -3357,7 +3366,7 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
FunctionKind arrow_kind = is_async ? kAsyncArrowFunction : kArrowFunction;
{
typename Traits::Type::Factory function_factory(ast_value_factory());
FunctionState function_state(&function_state_, &scope_,
FunctionState function_state(&function_state_, &scope_state_,
formal_parameters.scope, arrow_kind,
&function_factory);
@ -3372,7 +3381,7 @@ ParserBase<Traits>::ParseArrowFunctionLiteral(
// Multiple statement body
Consume(Token::LBRACE);
bool is_lazily_parsed =
(mode() == PARSE_LAZILY && scope_->AllowsLazyParsing());
(mode() == PARSE_LAZILY && scope()->AllowsLazyParsing());
if (is_lazily_parsed) {
body = this->NewStatementList(0, zone());
this->SkipLazyFunctionBody(&materialized_literal_count,

File diff suppressed because it is too large Load Diff

View File

@ -130,16 +130,17 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
log_ = log;
use_counts_ = use_counts;
// Lazy functions always have trivial outer scopes (no with/catch scopes).
Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE);
PreParserFactory top_factory(NULL);
FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction,
&top_factory);
scope_->SetLanguageMode(language_mode);
Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind);
DCHECK_NULL(scope_state_);
Scope* top_scope = NewScope(nullptr, SCRIPT_SCOPE);
PreParserFactory top_factory(nullptr);
FunctionState top_state(&function_state_, &scope_state_, top_scope,
kNormalFunction, &top_factory);
scope()->SetLanguageMode(language_mode);
Scope* function_scope = NewScope(scope(), FUNCTION_SCOPE, kind);
if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters();
PreParserFactory function_factory(NULL);
FunctionState function_state(&function_state_, &scope_, function_scope, kind,
&function_factory);
PreParserFactory function_factory(nullptr);
FunctionState function_state(&function_state_, &scope_state_, function_scope,
kind, &function_factory);
DCHECK_EQ(Token::LBRACE, scanner()->current_token());
bool ok = true;
int start_position = peek_position();
@ -153,7 +154,7 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
ReportUnexpectedToken(scanner()->current_token());
} else {
DCHECK_EQ(Token::RBRACE, scanner()->peek());
if (is_strict(scope_->language_mode())) {
if (is_strict(scope()->language_mode())) {
int end_pos = scanner()->location().end_pos;
CheckStrictOctalLiteral(start_position, end_pos, &ok);
CheckDecimalLiteralWithLeadingZero(use_counts, start_position, end_pos);
@ -253,13 +254,13 @@ void PreParser::ParseStatementList(int end_token, bool* ok,
bool use_strict_found = statement.IsUseStrictLiteral();
if (use_strict_found) {
scope_->SetLanguageMode(
static_cast<LanguageMode>(scope_->language_mode() | STRICT));
scope()->SetLanguageMode(
static_cast<LanguageMode>(scope()->language_mode() | STRICT));
} else if (!statement.IsStringLiteral()) {
directive_prologue = false;
}
if (use_strict_found && !scope_->HasSimpleParameters()) {
if (use_strict_found && !scope()->HasSimpleParameters()) {
// TC39 deemed "use strict" directives to be an error when occurring
// in the body of a function with non-simple parameter list, on
// 29/7/2015. https://goo.gl/ueA7Ln
@ -306,8 +307,8 @@ PreParser::Statement PreParser::ParseScopedStatement(bool legacy, bool* ok) {
(legacy && allow_harmony_restrictive_declarations())) {
return ParseSubStatement(kDisallowLabelledFunctionStatement, ok);
} else {
Scope* body_scope = NewScope(scope_, BLOCK_SCOPE);
BlockState block_state(&scope_, body_scope);
Scope* body_scope = NewScope(scope(), BLOCK_SCOPE);
BlockState block_state(&scope_state_, body_scope);
return ParseFunctionDeclaration(ok);
}
}
@ -477,11 +478,11 @@ PreParser::Statement PreParser::ParseBlock(bool* ok) {
// Block ::
// '{' StatementList '}'
Scope* block_scope = NewScope(scope_, BLOCK_SCOPE);
Scope* block_scope = NewScope(scope(), BLOCK_SCOPE);
Expect(Token::LBRACE, CHECK_OK);
Statement final = Statement::Default();
{
BlockState block_state(&scope_, block_scope);
BlockState block_state(&scope_state_, block_scope);
while (peek() != Token::RBRACE) {
final = ParseStatementListItem(CHECK_OK);
}
@ -791,8 +792,8 @@ PreParser::Statement PreParser::ParseWithStatement(bool* ok) {
ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
Scope* with_scope = NewScope(scope_, WITH_SCOPE);
BlockState block_state(&scope_, with_scope);
Scope* with_scope = NewScope(scope(), WITH_SCOPE);
BlockState block_state(&scope_state_, with_scope);
ParseScopedStatement(true, CHECK_OK);
return Statement::Default();
}
@ -807,9 +808,9 @@ PreParser::Statement PreParser::ParseSwitchStatement(bool* ok) {
ParseExpression(true, CHECK_OK);
Expect(Token::RPAREN, CHECK_OK);
Scope* cases_scope = NewScope(scope_, BLOCK_SCOPE);
Scope* cases_scope = NewScope(scope(), BLOCK_SCOPE);
{
BlockState cases_block_state(&scope_, cases_scope);
BlockState cases_block_state(&scope_state_, cases_scope);
Expect(Token::LBRACE, CHECK_OK);
Token::Value token = peek();
while (token != Token::RBRACE) {
@ -868,10 +869,10 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
// 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
// Create an in-between scope for let-bound iteration variables.
Scope* for_scope = NewScope(scope_, BLOCK_SCOPE);
Scope* for_scope = NewScope(scope(), BLOCK_SCOPE);
bool has_lexical = false;
BlockState block_state(&scope_, for_scope);
BlockState block_state(&scope_state_, for_scope);
Expect(Token::FOR, CHECK_OK);
Expect(Token::LPAREN, CHECK_OK);
if (peek() != Token::SEMICOLON) {
@ -958,9 +959,9 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
}
Expect(Token::RPAREN, CHECK_OK);
Scope* body_scope = NewScope(scope_, BLOCK_SCOPE);
Scope* body_scope = NewScope(scope(), BLOCK_SCOPE);
{
BlockState block_state(&scope_, body_scope);
BlockState block_state(&scope_state_, body_scope);
ParseScopedStatement(true, CHECK_OK);
}
return Statement::Default();
@ -973,11 +974,11 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
// If there are let bindings, then condition and the next statement of the
// for loop must be parsed in a new scope.
Scope* inner_scope = scope_;
Scope* inner_scope = scope();
if (has_lexical) inner_scope = NewScope(for_scope, BLOCK_SCOPE);
{
BlockState block_state(&scope_, inner_scope);
BlockState block_state(&scope_state_, inner_scope);
if (peek() != Token::SEMICOLON) {
ParseExpression(true, CHECK_OK);
@ -1042,7 +1043,7 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
if (tok == Token::CATCH) {
Consume(Token::CATCH);
Expect(Token::LPAREN, CHECK_OK);
Scope* catch_scope = NewScope(scope_, CATCH_SCOPE);
Scope* catch_scope = NewScope(scope(), CATCH_SCOPE);
ExpressionClassifier pattern_classifier(this);
ParsePrimaryExpression(&pattern_classifier, CHECK_OK);
ValidateBindingPattern(&pattern_classifier, CHECK_OK);
@ -1051,10 +1052,10 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
CollectExpressionsInTailPositionToListScope
collect_tail_call_expressions_scope(
function_state_, &tail_call_expressions_in_catch_block);
BlockState block_state(&scope_, catch_scope);
Scope* block_scope = NewScope(scope_, BLOCK_SCOPE);
BlockState block_state(&scope_state_, catch_scope);
Scope* block_scope = NewScope(scope(), BLOCK_SCOPE);
{
BlockState block_state(&scope_, block_scope);
BlockState block_state(&scope_state_, block_scope);
ParseBlock(CHECK_OK);
}
}
@ -1109,12 +1110,12 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
// '(' FormalParameterList? ')' '{' FunctionBody '}'
// Parse function body.
bool outer_is_script_scope = scope_->is_script_scope();
Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind);
bool outer_is_script_scope = scope()->is_script_scope();
Scope* function_scope = NewScope(scope(), FUNCTION_SCOPE, kind);
function_scope->SetLanguageMode(language_mode);
PreParserFactory factory(NULL);
FunctionState function_state(&function_state_, &scope_, function_scope, kind,
&factory);
FunctionState function_state(&function_state_, &scope_state_, function_scope,
kind, &factory);
DuplicateFinder duplicate_finder(scanner()->unicode_cache());
ExpressionClassifier formals_classifier(this, &duplicate_finder);
@ -1209,7 +1210,7 @@ void PreParser::ParseLazyFunctionLiteralBody(bool* ok,
log_->LogFunction(body_start, body_end,
function_state_->materialized_literal_count(),
function_state_->expected_property_count(), language_mode(),
scope_->uses_super_property(), scope_->calls_eval());
scope()->uses_super_property(), scope()->calls_eval());
}
PreParserExpression PreParser::ParseClassLiteral(
@ -1230,12 +1231,12 @@ PreParserExpression PreParser::ParseClassLiteral(
}
LanguageMode class_language_mode = language_mode();
Scope* scope = NewScope(scope_, BLOCK_SCOPE);
BlockState block_state(&scope_, scope);
scope_->SetLanguageMode(
Scope* scope = NewScope(this->scope(), BLOCK_SCOPE);
BlockState block_state(&scope_state_, scope);
this->scope()->SetLanguageMode(
static_cast<LanguageMode>(class_language_mode | STRICT));
// TODO(marja): Make PreParser use scope names too.
// scope_->SetScopeName(name);
// this->scope()->SetScopeName(name);
bool has_extends = Check(Token::EXTENDS);
if (has_extends) {
@ -1312,7 +1313,7 @@ PreParserExpression PreParser::ParseDoExpression(bool* ok) {
void PreParserTraits::ParseAsyncArrowSingleExpressionBody(
PreParserStatementList body, bool accept_IN,
Type::ExpressionClassifier* classifier, int pos, bool* ok) {
Scope* scope = pre_parser_->scope_;
Scope* scope = pre_parser_->scope();
scope->ForceContextAllocation();
PreParserExpression return_value = pre_parser_->ParseAssignmentExpression(

View File

@ -1037,7 +1037,8 @@ class PreParser : public ParserBase<PreParserTraits> {
// during parsing.
PreParseResult PreParseProgram(int* materialized_literals = 0,
bool is_module = false) {
Scope* scope = NewScope(scope_, SCRIPT_SCOPE);
DCHECK_NULL(scope_state_);
Scope* scope = NewScope(nullptr, SCRIPT_SCOPE);
// ModuleDeclarationInstantiation for Source Text Module Records creates a
// new Module Environment Record whose outer lexical environment record is
@ -1046,9 +1047,9 @@ class PreParser : public ParserBase<PreParserTraits> {
scope = NewScope(scope, MODULE_SCOPE);
}
PreParserFactory factory(NULL);
FunctionState top_scope(&function_state_, &scope_, scope, kNormalFunction,
&factory);
PreParserFactory factory(nullptr);
FunctionState top_scope(&function_state_, &scope_state_, scope,
kNormalFunction, &factory);
bool ok = true;
int start_position = scanner()->peek_location().beg_pos;
parsing_module_ = is_module;
@ -1056,7 +1057,7 @@ class PreParser : public ParserBase<PreParserTraits> {
if (stack_overflow()) return kPreParseStackOverflow;
if (!ok) {
ReportUnexpectedToken(scanner()->current_token());
} else if (is_strict(scope_->language_mode())) {
} else if (is_strict(this->scope()->language_mode())) {
CheckStrictOctalLiteral(start_position, scanner()->location().end_pos,
&ok);
CheckDecimalLiteralWithLeadingZero(use_counts_, start_position,
@ -1245,11 +1246,11 @@ PreParserStatementList PreParser::ParseEagerFunctionBody(
FunctionLiteral::FunctionType function_type, bool* ok) {
ParsingModeScope parsing_mode(this, PARSE_EAGERLY);
Scope* inner_scope = scope_;
if (!parameters.is_simple) inner_scope = NewScope(scope_, BLOCK_SCOPE);
Scope* inner_scope = scope();
if (!parameters.is_simple) inner_scope = NewScope(scope(), BLOCK_SCOPE);
{
BlockState block_state(&scope_, inner_scope);
BlockState block_state(&scope_state_, inner_scope);
ParseStatementList(Token::RBRACE, ok);
if (!*ok) return PreParserStatementList();
}