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

Unified Diff: src/parsing/parser.cc

Issue 2452403003: Changed statement ZoneList to a ZoneChunkList
Patch Set: Created 4 years, 2 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/parsing/parser.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/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index 61d63c7cec2624b3588383b763d71fd499d61f89..508e04ba673ce2a3e619d369ff755650316a627d 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -192,12 +192,12 @@ Expression* Parser::RewriteSuperCall(Expression* super_call) {
// }
Variable* var_tmp =
scope()->NewTemporary(ast_value_factory()->empty_string());
- Block* block = factory()->NewBlock(nullptr, 1, false, kNoSourcePosition);
+ Block* block = factory()->NewBlock(nullptr, false, kNoSourcePosition);
Assignment* assignment = factory()->NewAssignment(
Token::ASSIGN, factory()->NewVariableProxy(var_tmp), super_call,
kNoSourcePosition);
- block->statements()->Add(
- factory()->NewExpressionStatement(assignment, kNoSourcePosition), zone());
+ block->statements()->push_back(
+ factory()->NewExpressionStatement(assignment, kNoSourcePosition));
const AstRawString* init_fn_name =
ast_value_factory()->dot_class_field_init_string();
VariableProxy* init_fn_proxy =
@@ -209,7 +209,7 @@ Expression* Parser::RewriteSuperCall(Expression* super_call) {
IfStatement* if_statement = factory()->NewIfStatement(
condition, initialize, factory()->NewEmptyStatement(kNoSourcePosition),
kNoSourcePosition);
- block->statements()->Add(if_statement, zone());
+ block->statements()->push_back(if_statement);
return factory()->NewDoExpression(block, var_tmp, kNoSourcePosition);
}
@@ -231,13 +231,13 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
// Set start and end position to the same value
function_scope->set_start_position(pos);
function_scope->set_end_position(pos);
- ZoneList<Statement*>* body = NULL;
+ ZoneChunkList<Statement*>* body = NULL;
{
FunctionState function_state(&function_state_, &scope_state_,
function_scope);
- body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone());
+ body = new (zone()) ZoneChunkList<Statement*>(zone());
if (call_super) {
// $super_constructor = %_GetSuperConstructor(<this-function>)
// %reflect_construct(
@@ -274,7 +274,7 @@ FunctionLiteral* Parser::DefaultConstructor(const AstRawString* name,
if (requires_class_field_init) {
call = CallClassFieldInitializer(scope(), call);
}
- body->Add(factory()->NewReturnStatement(call, pos), zone());
+ body->push_back(factory()->NewReturnStatement(call, pos));
}
materialized_literal_count = function_state.materialized_literal_count();
@@ -756,7 +756,8 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
FunctionState function_state(&function_state_, &scope_state_, scope);
- ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone());
+ ZoneChunkList<Statement*>* body =
+ new (zone()) ZoneChunkList<Statement*>(zone());
bool ok = true;
int beg_pos = scanner()->location().beg_pos;
if (parsing_module_) {
@@ -773,9 +774,8 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
PrepareGeneratorVariables(&function_state);
Expression* initial_yield =
BuildInitialYield(kNoSourcePosition, kGeneratorFunction);
- body->Add(
- factory()->NewExpressionStatement(initial_yield, kNoSourcePosition),
- zone());
+ body->push_back(
+ factory()->NewExpressionStatement(initial_yield, kNoSourcePosition));
ParseModuleItemList(body, &ok);
ok = ok &&
@@ -809,10 +809,11 @@ FunctionLiteral* Parser::DoParseProgram(ParseInfo* info) {
}
if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) {
- if (body->length() != 1 ||
- !body->at(0)->IsExpressionStatement() ||
- !body->at(0)->AsExpressionStatement()->
- expression()->IsFunctionLiteral()) {
+ if (body->size() != 1 || !body->front()->IsExpressionStatement() ||
+ !body->front()
+ ->AsExpressionStatement()
+ ->expression()
+ ->IsFunctionLiteral()) {
ReportMessage(MessageTemplate::kSingleFunctionLiteral);
ok = false;
}
@@ -1036,8 +1037,7 @@ Statement* Parser::ParseModuleItem(bool* ok) {
}
}
-
-void Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) {
+void Parser::ParseModuleItemList(ZoneChunkList<Statement*>* body, bool* ok) {
// ecma262/#prod-Module
// Module :
// ModuleBody?
@@ -1050,7 +1050,7 @@ void Parser::ParseModuleItemList(ZoneList<Statement*>* body, bool* ok) {
while (peek() != Token::EOS) {
Statement* stat = ParseModuleItem(CHECK_OK_VOID);
if (stat && !stat->IsEmpty()) {
- body->Add(stat, zone());
+ body->push_back(stat);
}
}
}
@@ -1520,7 +1520,7 @@ Block* Parser::BuildInitializationBlock(
DeclarationParsingResult* parsing_result,
ZoneList<const AstRawString*>* names, bool* ok) {
Block* result = factory()->NewBlock(
- NULL, 1, true, parsing_result->descriptor.declaration_pos);
+ NULL, true, parsing_result->descriptor.declaration_pos);
for (auto declaration : parsing_result->declarations) {
PatternRewriter::DeclareAndInitializeVariables(
this, result, &(parsing_result->descriptor), &declaration, names,
@@ -1711,7 +1711,7 @@ Statement* Parser::RewriteSwitchStatement(Expression* tag,
// }
// }
- Block* switch_block = factory()->NewBlock(NULL, 2, false, kNoSourcePosition);
+ Block* switch_block = factory()->NewBlock(NULL, false, kNoSourcePosition);
Variable* tag_variable =
NewTemporary(ast_value_factory()->dot_switch_tag_string());
@@ -1720,22 +1720,20 @@ Statement* Parser::RewriteSwitchStatement(Expression* tag,
tag->position());
Statement* tag_statement =
factory()->NewExpressionStatement(tag_assign, kNoSourcePosition);
- switch_block->statements()->Add(tag_statement, zone());
+ switch_block->statements()->push_back(tag_statement);
// make statement: undefined;
// This is needed so the tag isn't returned as the value, in case the switch
// statements don't have a value.
- switch_block->statements()->Add(
- factory()->NewExpressionStatement(
- factory()->NewUndefinedLiteral(kNoSourcePosition), kNoSourcePosition),
- zone());
+ switch_block->statements()->push_back(factory()->NewExpressionStatement(
+ factory()->NewUndefinedLiteral(kNoSourcePosition), kNoSourcePosition));
Expression* tag_read = factory()->NewVariableProxy(tag_variable);
switch_statement->Initialize(tag_read, cases);
- Block* cases_block = factory()->NewBlock(NULL, 1, false, kNoSourcePosition);
- cases_block->statements()->Add(switch_statement, zone());
+ Block* cases_block = factory()->NewBlock(NULL, false, kNoSourcePosition);
+ cases_block->statements()->push_back(switch_statement);
cases_block->set_scope(scope);
- switch_block->statements()->Add(cases_block, zone());
+ switch_block->statements()->push_back(cases_block);
return switch_block;
}
@@ -1763,7 +1761,7 @@ void Parser::RewriteCatchPattern(CatchInfo* catch_info, bool* ok) {
factory()->NewVariableProxy(catch_info->variable));
catch_info->init_block =
- factory()->NewBlock(nullptr, 8, true, kNoSourcePosition);
+ factory()->NewBlock(nullptr, true, kNoSourcePosition);
PatternRewriter::DeclareAndInitializeVariables(
this, catch_info->init_block, &descriptor, &decl,
&catch_info->bound_names, ok);
@@ -1814,8 +1812,8 @@ Statement* Parser::RewriteTryStatement(Block* try_block, Block* catch_block,
kNoSourcePosition);
}
- try_block = factory()->NewBlock(nullptr, 1, false, kNoSourcePosition);
- try_block->statements()->Add(statement, zone());
+ try_block = factory()->NewBlock(nullptr, false, kNoSourcePosition);
+ try_block->statements()->push_back(statement);
catch_block = nullptr; // Clear to indicate it's been handled.
}
@@ -1891,11 +1889,10 @@ Statement* Parser::InitializeForEachStatement(ForEachStatement* stmt,
this, factory()->NewAssignment(Token::ASSIGN, each, temp_proxy,
kNoSourcePosition),
scope());
- auto block = factory()->NewBlock(nullptr, 2, false, kNoSourcePosition);
- block->statements()->Add(
- factory()->NewExpressionStatement(assign_each, kNoSourcePosition),
- zone());
- block->statements()->Add(body, zone());
+ auto block = factory()->NewBlock(nullptr, false, kNoSourcePosition);
+ block->statements()->push_back(
+ factory()->NewExpressionStatement(assign_each, kNoSourcePosition));
+ block->statements()->push_back(body);
body = block;
each = factory()->NewVariableProxy(temp);
}
@@ -1929,13 +1926,11 @@ Block* Parser::RewriteForVarInLegacy(const ForInfo& for_info) {
const AstRawString* name = decl.pattern->AsVariableProxy()->raw_name();
VariableProxy* single_var = NewUnresolved(name);
Block* init_block = factory()->NewBlock(
- nullptr, 2, true, for_info.parsing_result.descriptor.declaration_pos);
- init_block->statements()->Add(
- factory()->NewExpressionStatement(
- factory()->NewAssignment(Token::ASSIGN, single_var,
- decl.initializer, kNoSourcePosition),
- kNoSourcePosition),
- zone());
+ nullptr, true, for_info.parsing_result.descriptor.declaration_pos);
+ init_block->statements()->push_back(factory()->NewExpressionStatement(
+ factory()->NewAssignment(Token::ASSIGN, single_var, decl.initializer,
+ kNoSourcePosition),
+ kNoSourcePosition));
return init_block;
}
return nullptr;
@@ -1964,7 +1959,7 @@ void Parser::DesugarBindingInForEachStatement(ForInfo* for_info,
for_info->parsing_result.declarations[0];
Variable* temp = NewTemporary(ast_value_factory()->dot_for_string());
auto each_initialization_block =
- factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
+ factory()->NewBlock(nullptr, true, kNoSourcePosition);
{
auto descriptor = for_info->parsing_result.descriptor;
descriptor.declaration_pos = kNoSourcePosition;
@@ -2009,8 +2004,8 @@ void Parser::DesugarBindingInForEachStatement(ForInfo* for_info,
}
}
- *body_block = factory()->NewBlock(nullptr, 3, false, kNoSourcePosition);
- (*body_block)->statements()->Add(each_initialization_block, zone());
+ *body_block = factory()->NewBlock(nullptr, false, kNoSourcePosition);
+ (*body_block)->statements()->push_back(each_initialization_block);
*each_variable = factory()->NewVariableProxy(temp, for_info->position);
}
@@ -2020,7 +2015,7 @@ Block* Parser::CreateForEachStatementTDZ(Block* init_block,
if (IsLexicalVariableMode(for_info.parsing_result.descriptor.mode)) {
DCHECK_NULL(init_block);
- init_block = factory()->NewBlock(nullptr, 1, false, kNoSourcePosition);
+ init_block = factory()->NewBlock(nullptr, false, kNoSourcePosition);
for (int i = 0; i < for_info.bound_names.length(); ++i) {
// TODO(adamk): This needs to be some sort of special
@@ -2096,9 +2091,9 @@ Statement* Parser::InitializeForOfStatement(ForOfStatement* for_of,
Token::ASSIGN, proxy,
factory()->NewSmiLiteral(Parser::kAbruptCompletion, nopos), nopos);
- Block* block = factory()->NewBlock(nullptr, 1, true, nopos);
- block->statements()->Add(
- factory()->NewExpressionStatement(assignment, nopos), zone());
+ Block* block = factory()->NewBlock(nullptr, true, nopos);
+ block->statements()->push_back(
+ factory()->NewExpressionStatement(assignment, nopos));
set_completion_abrupt = block;
}
@@ -2110,10 +2105,10 @@ Statement* Parser::InitializeForOfStatement(ForOfStatement* for_of,
Expression* assignment =
factory()->NewAssignment(Token::ASSIGN, tmp, result_value, nopos);
- Block* block = factory()->NewBlock(nullptr, 2, false, nopos);
- block->statements()->Add(
- factory()->NewExpressionStatement(assignment, nopos), zone());
- block->statements()->Add(set_completion_abrupt, zone());
+ Block* block = factory()->NewBlock(nullptr, false, nopos);
+ block->statements()->push_back(
+ factory()->NewExpressionStatement(assignment, nopos));
+ block->statements()->push_back(set_completion_abrupt);
result_value = factory()->NewDoExpression(block, var_tmp, nopos);
}
@@ -2137,18 +2132,18 @@ Statement* Parser::InitializeForOfStatement(ForOfStatement* for_of,
Token::ASSIGN, proxy,
factory()->NewSmiLiteral(Parser::kNormalCompletion, nopos), nopos);
- Block* block = factory()->NewBlock(nullptr, 1, true, nopos);
- block->statements()->Add(
- factory()->NewExpressionStatement(assignment, nopos), zone());
+ Block* block = factory()->NewBlock(nullptr, true, nopos);
+ block->statements()->push_back(
+ factory()->NewExpressionStatement(assignment, nopos));
set_completion_normal = block;
}
// { #loop-body; #set_completion_normal }
// Statement* body (gets overwritten)
if (finalize) {
- Block* block = factory()->NewBlock(nullptr, 2, false, nopos);
- block->statements()->Add(body, zone());
- block->statements()->Add(set_completion_normal, zone());
+ Block* block = factory()->NewBlock(nullptr, false, nopos);
+ block->statements()->push_back(body);
+ block->statements()->push_back(set_completion_normal);
body = block;
}
@@ -2200,11 +2195,10 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
DCHECK(for_info.bound_names.length() > 0);
ZoneList<Variable*> temps(for_info.bound_names.length(), zone());
- Block* outer_block = factory()->NewBlock(
- nullptr, for_info.bound_names.length() + 4, false, kNoSourcePosition);
+ Block* outer_block = factory()->NewBlock(nullptr, false, kNoSourcePosition);
// Add statement: let/const x = i.
- outer_block->statements()->Add(init, zone());
+ outer_block->statements()->push_back(init);
const AstRawString* temp_name = ast_value_factory()->dot_for_string();
@@ -2218,7 +2212,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
proxy, kNoSourcePosition);
Statement* assignment_statement =
factory()->NewExpressionStatement(assignment, kNoSourcePosition);
- outer_block->statements()->Add(assignment_statement, zone());
+ outer_block->statements()->push_back(assignment_statement);
temps.Add(temp, zone());
}
@@ -2232,14 +2226,12 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
Token::ASSIGN, first_proxy, const1, kNoSourcePosition);
Statement* assignment_statement =
factory()->NewExpressionStatement(assignment, kNoSourcePosition);
- outer_block->statements()->Add(assignment_statement, zone());
+ outer_block->statements()->push_back(assignment_statement);
}
// make statement: undefined;
- outer_block->statements()->Add(
- factory()->NewExpressionStatement(
- factory()->NewUndefinedLiteral(kNoSourcePosition), kNoSourcePosition),
- zone());
+ outer_block->statements()->push_back(factory()->NewExpressionStatement(
+ factory()->NewUndefinedLiteral(kNoSourcePosition), kNoSourcePosition));
// Make statement: outer: for (;;)
// Note that we don't actually create the label, or set this loop up as an
@@ -2248,15 +2240,15 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
// in this function that looks up break targets.
ForStatement* outer_loop =
factory()->NewForStatement(NULL, kNoSourcePosition);
- outer_block->statements()->Add(outer_loop, zone());
+ outer_block->statements()->push_back(outer_loop);
outer_block->set_scope(scope());
- Block* inner_block = factory()->NewBlock(NULL, 3, false, kNoSourcePosition);
+ Block* inner_block = factory()->NewBlock(NULL, false, kNoSourcePosition);
{
BlockState block_state(&scope_state_, inner_scope);
- Block* ignore_completion_block = factory()->NewBlock(
- nullptr, for_info.bound_names.length() + 3, true, kNoSourcePosition);
+ Block* ignore_completion_block =
+ factory()->NewBlock(nullptr, true, kNoSourcePosition);
ZoneList<Variable*> inner_vars(for_info.bound_names.length(), zone());
// For each let variable x:
// make statement: let/const x = temp_x.
@@ -2272,7 +2264,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
factory()->NewExpressionStatement(assignment, kNoSourcePosition);
DCHECK(init->position() != kNoSourcePosition);
decl->proxy()->var()->set_initializer_position(init->position());
- ignore_completion_block->statements()->Add(assignment_statement, zone());
+ ignore_completion_block->statements()->push_back(assignment_statement);
}
// Make statement: if (first == 1) { first = 0; } else { next; }
@@ -2298,7 +2290,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
}
Statement* clear_first_or_next = factory()->NewIfStatement(
compare, clear_first, next, kNoSourcePosition);
- ignore_completion_block->statements()->Add(clear_first_or_next, zone());
+ ignore_completion_block->statements()->push_back(clear_first_or_next);
}
Variable* flag = NewTemporary(temp_name);
@@ -2310,7 +2302,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
Token::ASSIGN, flag_proxy, const1, kNoSourcePosition);
Statement* assignment_statement =
factory()->NewExpressionStatement(assignment, kNoSourcePosition);
- ignore_completion_block->statements()->Add(assignment_statement, zone());
+ ignore_completion_block->statements()->push_back(assignment_statement);
}
// Make statement: if (!cond) break.
@@ -2318,12 +2310,11 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
Statement* stop =
factory()->NewBreakStatement(outer_loop, kNoSourcePosition);
Statement* noop = factory()->NewEmptyStatement(kNoSourcePosition);
- ignore_completion_block->statements()->Add(
- factory()->NewIfStatement(cond, noop, stop, cond->position()),
- zone());
+ ignore_completion_block->statements()->push_back(
+ factory()->NewIfStatement(cond, noop, stop, cond->position()));
}
- inner_block->statements()->Add(ignore_completion_block, zone());
+ inner_block->statements()->push_back(ignore_completion_block);
// Make cond expression for main loop: flag == 1.
Expression* flag_cond = NULL;
{
@@ -2366,7 +2357,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
// and ensures that any break or continue statements in body point to
// the right place.
loop->Initialize(NULL, flag_cond, compound_next_statement, body);
- inner_block->statements()->Add(loop, zone());
+ inner_block->statements()->push_back(loop);
// Make statement: {{if (flag == 1) break;}}
{
@@ -2384,9 +2375,9 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
Statement* if_flag_break =
factory()->NewIfStatement(compare, stop, empty, kNoSourcePosition);
Block* ignore_completion_block =
- factory()->NewBlock(NULL, 1, true, kNoSourcePosition);
- ignore_completion_block->statements()->Add(if_flag_break, zone());
- inner_block->statements()->Add(ignore_completion_block, zone());
+ factory()->NewBlock(NULL, true, kNoSourcePosition);
+ ignore_completion_block->statements()->push_back(if_flag_break);
+ inner_block->statements()->push_back(ignore_completion_block);
}
inner_scope->set_end_position(scanner()->location().end_pos);
@@ -2619,7 +2610,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(
DeclarationScope* scope = NewFunctionScope(kind);
SetLanguageMode(scope, language_mode);
- ZoneList<Statement*>* body = nullptr;
+ ZoneChunkList<Statement*>* body = nullptr;
int materialized_literal_count = -1;
int expected_property_count = -1;
DuplicateFinder duplicate_finder(scanner()->unicode_cache());
@@ -2908,7 +2899,7 @@ Block* Parser::BuildParameterInitializationBlock(
const ParserFormalParameters& parameters, bool* ok) {
DCHECK(!parameters.is_simple);
DCHECK(scope()->is_function_scope());
- Block* init_block = factory()->NewBlock(NULL, 1, true, kNoSourcePosition);
+ Block* init_block = factory()->NewBlock(NULL, true, kNoSourcePosition);
for (int i = 0; i < parameters.params.length(); ++i) {
auto parameter = parameters.params[i];
if (parameter.is_rest && parameter.pattern->IsVariableProxy()) break;
@@ -2948,7 +2939,7 @@ Block* Parser::BuildParameterInitializationBlock(
param_scope->set_start_position(descriptor.initialization_pos);
param_scope->set_end_position(parameter.initializer_end_position);
param_scope->RecordEvalCall();
- param_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition);
+ param_block = factory()->NewBlock(NULL, true, kNoSourcePosition);
param_block->set_scope(param_scope);
descriptor.hoist_scope = scope();
// Pass the appropriate scope in so that PatternRewriter can appropriately
@@ -2970,7 +2961,7 @@ Block* Parser::BuildParameterInitializationBlock(
if (param_scope != nullptr) {
CheckConflictingVarDeclarations(param_scope, CHECK_OK);
}
- init_block->statements()->Add(param_block, zone());
+ init_block->statements()->push_back(param_block);
}
}
return init_block;
@@ -2986,7 +2977,7 @@ Block* Parser::BuildRejectPromiseOnException(Block* inner_block, bool* ok) {
// } finally {
// %AsyncFunctionPromiseRelease(.promise);
// }
- Block* result = factory()->NewBlock(nullptr, 2, true, kNoSourcePosition);
+ Block* result = factory()->NewBlock(nullptr, true, kNoSourcePosition);
// .promise = %AsyncFunctionPromiseCreate();
Statement* set_promise;
@@ -3000,7 +2991,7 @@ Block* Parser::BuildRejectPromiseOnException(Block* inner_block, bool* ok) {
set_promise =
factory()->NewExpressionStatement(assign_promise, kNoSourcePosition);
}
- result->statements()->Add(set_promise, zone());
+ result->statements()->push_back(set_promise);
// catch (.catch) { return %RejectPromise(.promise, .catch), .promise }
Scope* catch_scope = NewScope(CATCH_SCOPE);
@@ -3008,13 +2999,13 @@ Block* Parser::BuildRejectPromiseOnException(Block* inner_block, bool* ok) {
Variable* catch_variable =
catch_scope->DeclareLocal(ast_value_factory()->dot_catch_string(), VAR,
kCreatedInitialized, NORMAL_VARIABLE);
- Block* catch_block = factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
+ Block* catch_block = factory()->NewBlock(nullptr, true, kNoSourcePosition);
Expression* promise_reject = BuildRejectPromise(
factory()->NewVariableProxy(catch_variable), kNoSourcePosition);
ReturnStatement* return_promise_reject =
factory()->NewReturnStatement(promise_reject, kNoSourcePosition);
- catch_block->statements()->Add(return_promise_reject, zone());
+ catch_block->statements()->push_back(return_promise_reject);
TryStatement* try_catch_statement =
factory()->NewTryCatchStatementForAsyncAwait(inner_block, catch_scope,
@@ -3023,12 +3014,11 @@ Block* Parser::BuildRejectPromiseOnException(Block* inner_block, bool* ok) {
// There is no TryCatchFinally node, so wrap it in an outer try/finally
Block* outer_try_block =
- factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
- outer_try_block->statements()->Add(try_catch_statement, zone());
+ factory()->NewBlock(nullptr, true, kNoSourcePosition);
+ outer_try_block->statements()->push_back(try_catch_statement);
// finally { %AsyncFunctionPromiseRelease(.promise) }
- Block* finally_block =
- factory()->NewBlock(nullptr, 1, true, kNoSourcePosition);
+ Block* finally_block = factory()->NewBlock(nullptr, true, kNoSourcePosition);
{
ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone());
args->Add(factory()->NewVariableProxy(PromiseVariable()), zone());
@@ -3036,13 +3026,13 @@ Block* Parser::BuildRejectPromiseOnException(Block* inner_block, bool* ok) {
Context::ASYNC_FUNCTION_PROMISE_RELEASE_INDEX, args, kNoSourcePosition);
Statement* promise_release = factory()->NewExpressionStatement(
call_promise_release, kNoSourcePosition);
- finally_block->statements()->Add(promise_release, zone());
+ finally_block->statements()->push_back(promise_release);
}
Statement* try_finally_statement = factory()->NewTryFinallyStatement(
outer_try_block, finally_block, kNoSourcePosition);
- result->statements()->Add(try_finally_statement, zone());
+ result->statements()->push_back(try_finally_statement);
return result;
}
@@ -3111,12 +3101,13 @@ Expression* Parser::BuildInitialYield(int pos, FunctionKind kind) {
Yield::kOnExceptionThrow);
}
-ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
+ZoneChunkList<Statement*>* Parser::ParseEagerFunctionBody(
const AstRawString* function_name, int pos,
const ParserFormalParameters& parameters, FunctionKind kind,
FunctionLiteral::FunctionType function_type, bool* ok) {
ParsingModeScope mode(this, allow_lazy() ? PARSE_LAZILY : PARSE_EAGERLY);
- ZoneList<Statement*>* result = new(zone()) ZoneList<Statement*>(8, zone());
+ ZoneChunkList<Statement*>* result =
+ new (zone()) ZoneChunkList<Statement*>(zone());
static const int kFunctionNameAssignmentIndex = 0;
if (function_type == FunctionLiteral::kNamedExpression) {
@@ -3126,18 +3117,18 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
// function and let it refer to the function itself (closure).
// Not having parsed the function body, the language mode may still change,
// so we reserve a spot and create the actual const assignment later.
- DCHECK_EQ(kFunctionNameAssignmentIndex, result->length());
- result->Add(NULL, zone());
+ DCHECK_EQ(kFunctionNameAssignmentIndex, result->size());
+ result->push_back(NULL);
}
- ZoneList<Statement*>* body = result;
+ ZoneChunkList<Statement*>* body = result;
DeclarationScope* function_scope = scope()->AsDeclarationScope();
DeclarationScope* inner_scope = function_scope;
Block* inner_block = nullptr;
if (!parameters.is_simple) {
inner_scope = NewVarblockScope();
inner_scope->set_start_position(scanner()->location().beg_pos);
- inner_block = factory()->NewBlock(NULL, 8, true, kNoSourcePosition);
+ inner_block = factory()->NewBlock(NULL, true, kNoSourcePosition);
inner_block->set_scope(inner_scope);
body = inner_block->statements();
}
@@ -3157,20 +3148,18 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
// - If the generator terminates for whatever reason, we must close it.
// Hence the finally clause.
- Block* try_block =
- factory()->NewBlock(nullptr, 3, false, kNoSourcePosition);
+ Block* try_block = factory()->NewBlock(nullptr, false, kNoSourcePosition);
Expression* initial_yield = BuildInitialYield(pos, kind);
- try_block->statements()->Add(
- factory()->NewExpressionStatement(initial_yield, kNoSourcePosition),
- zone());
+ try_block->statements()->push_back(
+ factory()->NewExpressionStatement(initial_yield, kNoSourcePosition));
ParseStatementList(try_block->statements(), Token::RBRACE, CHECK_OK);
Statement* final_return = factory()->NewReturnStatement(
BuildIteratorResult(nullptr, true), kNoSourcePosition);
- try_block->statements()->Add(final_return, zone());
+ try_block->statements()->push_back(final_return);
Block* finally_block =
- factory()->NewBlock(nullptr, 1, false, kNoSourcePosition);
+ factory()->NewBlock(nullptr, false, kNoSourcePosition);
ZoneList<Expression*>* args =
new (zone()) ZoneList<Expression*>(1, zone());
VariableProxy* call_proxy = factory()->NewVariableProxy(
@@ -3178,12 +3167,11 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
args->Add(call_proxy, zone());
Expression* call = factory()->NewCallRuntime(
Runtime::kInlineGeneratorClose, args, kNoSourcePosition);
- finally_block->statements()->Add(
- factory()->NewExpressionStatement(call, kNoSourcePosition), zone());
+ finally_block->statements()->push_back(
+ factory()->NewExpressionStatement(call, kNoSourcePosition));
- body->Add(factory()->NewTryFinallyStatement(try_block, finally_block,
- kNoSourcePosition),
- zone());
+ body->push_back(factory()->NewTryFinallyStatement(
+ try_block, finally_block, kNoSourcePosition));
} else if (IsAsyncFunction(kind)) {
const bool accept_IN = true;
ParseAsyncFunctionBody(inner_scope, body, kind, FunctionBodyType::kNormal,
@@ -3193,9 +3181,8 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
}
if (IsSubclassConstructor(kind)) {
- body->Add(factory()->NewReturnStatement(ThisExpression(kNoSourcePosition),
- kNoSourcePosition),
- zone());
+ body->push_back(factory()->NewReturnStatement(
+ ThisExpression(kNoSourcePosition), kNoSourcePosition));
}
}
@@ -3228,8 +3215,8 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
}
inner_scope = nullptr;
- result->Add(init_block, zone());
- result->Add(inner_block, zone());
+ result->push_back(init_block);
+ result->push_back(inner_block);
} else {
DCHECK_EQ(inner_scope, function_scope);
if (is_sloppy(function_scope->language_mode())) {
@@ -3260,7 +3247,12 @@ ZoneList<Statement*>* Parser::ParseEagerFunctionBody(
} else {
statement = factory()->NewEmptyStatement(kNoSourcePosition);
}
- result->Set(kFunctionNameAssignmentIndex, statement);
+
+ {
+ auto it = result->begin();
+ for (int i = 0; i < kFunctionNameAssignmentIndex; i++) it++;
+ *it = statement;
+ }
}
MarkCollectedTailCallExpressions();
@@ -3300,7 +3292,7 @@ PreParser::PreParseResult Parser::ParseFunctionBodyWithPreParser(
Expression* Parser::InstallHomeObject(Expression* function_literal,
Expression* home_object) {
- Block* do_block = factory()->NewBlock(nullptr, 1, false, kNoSourcePosition);
+ Block* do_block = factory()->NewBlock(nullptr, false, kNoSourcePosition);
Variable* result_var =
scope()->NewTemporary(ast_value_factory()->empty_string());
DoExpression* do_expr =
@@ -3308,16 +3300,16 @@ Expression* Parser::InstallHomeObject(Expression* function_literal,
Assignment* init = factory()->NewAssignment(
Token::ASSIGN, factory()->NewVariableProxy(result_var), function_literal,
kNoSourcePosition);
- do_block->statements()->Add(
- factory()->NewExpressionStatement(init, kNoSourcePosition), zone());
+ do_block->statements()->push_back(
+ factory()->NewExpressionStatement(init, kNoSourcePosition));
Property* home_object_property = factory()->NewProperty(
factory()->NewVariableProxy(result_var),
factory()->NewSymbolLiteral("home_object_symbol", kNoSourcePosition),
kNoSourcePosition);
Assignment* assignment = factory()->NewAssignment(
Token::ASSIGN, home_object_property, home_object, kNoSourcePosition);
- do_block->statements()->Add(
- factory()->NewExpressionStatement(assignment, kNoSourcePosition), zone());
+ do_block->statements()->push_back(
+ factory()->NewExpressionStatement(assignment, kNoSourcePosition));
return do_expr;
}
@@ -3356,7 +3348,8 @@ FunctionLiteral* Parser::SynthesizeClassFieldInitializer(int count) {
initializer_scope->set_end_position(scanner()->location().end_pos);
FunctionState initializer_state(&function_state_, &scope_state_,
initializer_scope);
- ZoneList<Statement*>* body = new (zone()) ZoneList<Statement*>(count, zone());
+ ZoneChunkList<Statement*>* body =
+ new (zone()) ZoneChunkList<Statement*>(zone());
for (int i = 0; i < count; ++i) {
const AstRawString* name =
ClassFieldVariableName(true, ast_value_factory(), i);
@@ -3383,18 +3376,16 @@ FunctionLiteral* Parser::SynthesizeClassFieldInitializer(int count) {
// function(){}; static y = function(){}; }
kNoSourcePosition),
zone());
- body->Add(factory()->NewExpressionStatement(
- factory()->NewCallRuntime(
- Runtime::kDefineDataProperty,
- define_property_args, // TODO(bakkot) verify that this is
- // the same as object_define_property
- kNoSourcePosition),
- kNoSourcePosition),
- zone());
+ body->push_back(factory()->NewExpressionStatement(
+ factory()->NewCallRuntime(
+ Runtime::kDefineDataProperty,
+ define_property_args, // TODO(bakkot) verify that this is
+ // the same as object_define_property
+ kNoSourcePosition),
+ kNoSourcePosition));
}
- body->Add(factory()->NewReturnStatement(ThisExpression(kNoSourcePosition),
- kNoSourcePosition),
- zone());
+ body->push_back(factory()->NewReturnStatement(
+ ThisExpression(kNoSourcePosition), kNoSourcePosition));
FunctionLiteral* function_literal = factory()->NewFunctionLiteral(
ast_value_factory()->empty_string(), initializer_scope, body,
initializer_state.materialized_literal_count(),
@@ -3415,7 +3406,7 @@ FunctionLiteral* Parser::InsertClassFieldInitializer(
factory(), ast_value_factory()->this_string(), kNoSourcePosition,
THIS_VARIABLE)),
kNoSourcePosition);
- constructor->body()->InsertAt(0, call_initializer, zone());
+ constructor->body()->push_front(call_initializer);
return constructor;
}
@@ -3514,7 +3505,7 @@ Expression* Parser::RewriteClassLiteral(const AstRawString* name,
ClassInfo* class_info, int pos,
bool* ok) {
int end_pos = scanner()->location().end_pos;
- Block* do_block = factory()->NewBlock(nullptr, 1, false, pos);
+ Block* do_block = factory()->NewBlock(nullptr, false, pos);
Variable* result_var = NewTemporary(ast_value_factory()->empty_string());
DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos);
@@ -3551,13 +3542,11 @@ Expression* Parser::RewriteClassLiteral(const AstRawString* name,
factory()->NewVariableProxy(class_info->static_initializer_var));
}
- do_block->statements()->Add(
- factory()->NewExpressionStatement(
- factory()->NewAssignment(Token::ASSIGN,
- factory()->NewVariableProxy(result_var),
- class_literal, kNoSourcePosition),
- pos),
- zone());
+ do_block->statements()->push_back(factory()->NewExpressionStatement(
+ factory()->NewAssignment(Token::ASSIGN,
+ factory()->NewVariableProxy(result_var),
+ class_literal, kNoSourcePosition),
+ pos));
if (allow_harmony_class_fields() &&
(has_instance_fields || (has_extends && !has_default_constructor))) {
// Default constructors for derived classes without fields will not try to
@@ -3574,9 +3563,8 @@ Expression* Parser::RewriteClassLiteral(const AstRawString* name,
Assignment* assignment = factory()->NewAssignment(
Token::INIT, factory()->NewVariableProxy(init_fn_var), initializer,
kNoSourcePosition);
- do_block->statements()->Add(
- factory()->NewExpressionStatement(assignment, kNoSourcePosition),
- zone());
+ do_block->statements()->push_back(
+ factory()->NewExpressionStatement(assignment, kNoSourcePosition));
}
for (int i = 0; i < class_info->instance_field_initializers->length(); ++i) {
const AstRawString* function_name =
@@ -3601,9 +3589,8 @@ Expression* Parser::RewriteClassLiteral(const AstRawString* name,
Assignment* function_assignment = factory()->NewAssignment(
Token::INIT, factory()->NewVariableProxy(function_var), function_value,
kNoSourcePosition);
- do_block->statements()->Add(factory()->NewExpressionStatement(
- function_assignment, kNoSourcePosition),
- zone());
+ do_block->statements()->push_back(factory()->NewExpressionStatement(
+ function_assignment, kNoSourcePosition));
}
do_block->set_scope(scope()->FinalizeBlockScope());
do_expr->set_represented_function(class_info->constructor);
@@ -3655,7 +3642,7 @@ void Parser::InsertShadowingVarBindingInitializers(Block* inner_block) {
factory()->NewAssignment(Token::ASSIGN, to, from, kNoSourcePosition);
Statement* statement =
factory()->NewExpressionStatement(assignment, kNoSourcePosition);
- inner_block->statements()->InsertAt(0, statement, zone());
+ inner_block->statements()->push_front(statement);
}
}
@@ -4106,7 +4093,7 @@ Expression* Parser::ExpressionListToExpression(ZoneList<Expression*>* args) {
// This method intoduces the line initializing the generator object
// when desugaring the body of async_function.
-void Parser::PrepareAsyncFunctionBody(ZoneList<Statement*>* body,
+void Parser::PrepareAsyncFunctionBody(ZoneChunkList<Statement*>* body,
FunctionKind kind, int pos) {
// function async_function() {
// .generator_object = %CreateGeneratorObject();
@@ -4123,14 +4110,14 @@ void Parser::PrepareAsyncFunctionBody(ZoneList<Statement*>* body,
Expression* init_generator_variable = factory()->NewAssignment(
Token::INIT, factory()->NewVariableProxy(temp),
BuildCreateJSGeneratorObject(pos, kind), kNoSourcePosition);
- body->Add(factory()->NewExpressionStatement(init_generator_variable,
- kNoSourcePosition),
- zone());
+ body->push_back(factory()->NewExpressionStatement(init_generator_variable,
+ kNoSourcePosition));
}
// This method completes the desugaring of the body of async_function.
-void Parser::RewriteAsyncFunctionBody(ZoneList<Statement*>* body, Block* block,
- Expression* return_value, bool* ok) {
+void Parser::RewriteAsyncFunctionBody(ZoneChunkList<Statement*>* body,
+ Block* block, Expression* return_value,
+ bool* ok) {
// function async_function() {
// .generator_object = %CreateGeneratorObject();
// BuildRejectPromiseOnException({
@@ -4140,11 +4127,10 @@ void Parser::RewriteAsyncFunctionBody(ZoneList<Statement*>* body, Block* block,
// }
return_value = BuildResolvePromise(return_value, return_value->position());
- block->statements()->Add(
- factory()->NewReturnStatement(return_value, return_value->position()),
- zone());
+ block->statements()->push_back(
+ factory()->NewReturnStatement(return_value, return_value->position()));
block = BuildRejectPromiseOnException(block, CHECK_OK_VOID);
- body->Add(block, zone());
+ body->push_back(block);
}
Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) {
@@ -4176,7 +4162,7 @@ Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) {
const int nopos = kNoSourcePosition;
- Block* do_block = factory()->NewBlock(nullptr, 2, false, nopos);
+ Block* do_block = factory()->NewBlock(nullptr, false, nopos);
Variable* promise = PromiseVariable();
@@ -4184,9 +4170,8 @@ Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) {
Variable* temp_var = NewTemporary(ast_value_factory()->empty_string());
Expression* value_assignment = factory()->NewAssignment(
Token::ASSIGN, factory()->NewVariableProxy(temp_var), value, nopos);
- do_block->statements()->Add(
- factory()->NewExpressionStatement(value_assignment, value->position()),
- zone());
+ do_block->statements()->push_back(
+ factory()->NewExpressionStatement(value_assignment, value->position()));
ZoneList<Expression*>* async_function_await_args =
new (zone()) ZoneList<Expression*>(3, zone());
@@ -4202,9 +4187,8 @@ Expression* Parser::RewriteAwaitExpression(Expression* value, int await_pos) {
Expression* async_function_await =
factory()->NewCallRuntime(Context::ASYNC_FUNCTION_AWAIT_CAUGHT_INDEX,
async_function_await_args, nopos);
- do_block->statements()->Add(
- factory()->NewExpressionStatement(async_function_await, await_pos),
- zone());
+ do_block->statements()->push_back(
+ factory()->NewExpressionStatement(async_function_await, await_pos));
// Wrap await to provide a break location between value evaluation and yield.
Expression* do_expr = factory()->NewDoExpression(do_block, promise, nopos);
@@ -4358,10 +4342,9 @@ Expression* Parser::RewriteSpreads(ArrayLiteral* lit) {
// $R = lit
Expression* init_result = factory()->NewAssignment(
Token::INIT, factory()->NewVariableProxy(result), lit, kNoSourcePosition);
- Block* do_block = factory()->NewBlock(nullptr, 16, false, kNoSourcePosition);
- do_block->statements()->Add(
- factory()->NewExpressionStatement(init_result, kNoSourcePosition),
- zone());
+ Block* do_block = factory()->NewBlock(nullptr, false, kNoSourcePosition);
+ do_block->statements()->push_back(
+ factory()->NewExpressionStatement(init_result, kNoSourcePosition));
// Traverse the array literal starting from the first spread.
while (s != lit->EndValue()) {
Expression* value = *s++;
@@ -4376,13 +4359,10 @@ Expression* Parser::RewriteSpreads(ArrayLiteral* lit) {
ZoneList<Expression*>* append_element_args = NewExpressionList(2);
append_element_args->Add(factory()->NewVariableProxy(result), zone());
append_element_args->Add(value, zone());
- do_block->statements()->Add(
- factory()->NewExpressionStatement(
- factory()->NewCallRuntime(Runtime::kAppendElement,
- append_element_args,
- kNoSourcePosition),
- kNoSourcePosition),
- zone());
+ do_block->statements()->push_back(factory()->NewExpressionStatement(
+ factory()->NewCallRuntime(Runtime::kAppendElement,
+ append_element_args, kNoSourcePosition),
+ kNoSourcePosition));
} else {
Property* length_property = factory()->NewProperty(
factory()->NewVariableProxy(result),
@@ -4391,9 +4371,8 @@ Expression* Parser::RewriteSpreads(ArrayLiteral* lit) {
kNoSourcePosition);
CountOperation* count_op = factory()->NewCountOperation(
Token::INC, true /* prefix */, length_property, kNoSourcePosition);
- do_block->statements()->Add(
- factory()->NewExpressionStatement(count_op, kNoSourcePosition),
- zone());
+ do_block->statements()->push_back(
+ factory()->NewExpressionStatement(count_op, kNoSourcePosition));
}
} else {
// If it's a spread, we're adding a for/of loop iterating through it.
@@ -4417,7 +4396,7 @@ Expression* Parser::RewriteSpreads(ArrayLiteral* lit) {
InitializeForOfStatement(loop->AsForOfStatement(),
factory()->NewVariableProxy(each), subject,
append_body, finalize);
- do_block->statements()->Add(loop, zone());
+ do_block->statements()->push_back(loop);
}
}
// Now, rewind the original array literal to truncate everything from the
@@ -4712,11 +4691,11 @@ Expression* Parser::RewriteYieldStar(Expression* generator,
ast_value_factory()->empty_string(), nopos);
Statement* throw_call = factory()->NewExpressionStatement(call, nopos);
- Block* then = factory()->NewBlock(nullptr, 4 + 1, false, nopos);
+ Block* then = factory()->NewBlock(nullptr, false, nopos);
BuildIteratorCloseForCompletion(
then->statements(), var_iterator,
factory()->NewSmiLiteral(Parser::kNormalCompletion, nopos));
- then->statements()->Add(throw_call, zone());
+ then->statements()->push_back(throw_call);
check_throw = factory()->NewIfStatement(
condition, then, factory()->NewEmptyStatement(nopos), nopos);
}
@@ -4862,12 +4841,12 @@ Expression* Parser::RewriteYieldStar(Expression* generator,
// try { ... } catch(e) { ... }
Statement* try_catch;
{
- Block* try_block = factory()->NewBlock(nullptr, 2, false, nopos);
- try_block->statements()->Add(yield_output, zone());
- try_block->statements()->Add(set_mode_next, zone());
+ Block* try_block = factory()->NewBlock(nullptr, false, nopos);
+ try_block->statements()->push_back(yield_output);
+ try_block->statements()->push_back(set_mode_next);
- Block* catch_block = factory()->NewBlock(nullptr, 1, false, nopos);
- catch_block->statements()->Add(set_mode_throw, zone());
+ Block* catch_block = factory()->NewBlock(nullptr, false, nopos);
+ catch_block->statements()->push_back(set_mode_throw);
Scope* catch_scope = NewScope(CATCH_SCOPE);
catch_scope->set_is_hidden();
@@ -4882,13 +4861,13 @@ Expression* Parser::RewriteYieldStar(Expression* generator,
// try { ... } finally { ... }
Statement* try_finally;
{
- Block* try_block = factory()->NewBlock(nullptr, 1, false, nopos);
- try_block->statements()->Add(try_catch, zone());
+ Block* try_block = factory()->NewBlock(nullptr, false, nopos);
+ try_block->statements()->push_back(try_catch);
- Block* finally = factory()->NewBlock(nullptr, 2, false, nopos);
- finally->statements()->Add(get_input, zone());
- finally->statements()->Add(factory()->NewContinueStatement(loop, nopos),
- zone());
+ Block* finally = factory()->NewBlock(nullptr, false, nopos);
+ finally->statements()->push_back(get_input);
+ finally->statements()->push_back(
+ factory()->NewContinueStatement(loop, nopos));
try_finally = factory()->NewTryFinallyStatement(try_block, finally, nopos);
}
@@ -4896,21 +4875,21 @@ Expression* Parser::RewriteYieldStar(Expression* generator,
// switch (mode) { ... }
SwitchStatement* switch_mode = factory()->NewSwitchStatement(nullptr, nopos);
{
- auto case_next = new (zone()) ZoneList<Statement*>(3, zone());
- case_next->Add(call_next, zone());
- case_next->Add(validate_next_output, zone());
- case_next->Add(factory()->NewBreakStatement(switch_mode, nopos), zone());
+ auto case_next = new (zone()) ZoneChunkList<Statement*>(zone());
+ case_next->push_back(call_next);
+ case_next->push_back(validate_next_output);
+ case_next->push_back(factory()->NewBreakStatement(switch_mode, nopos));
- auto case_return = new (zone()) ZoneList<Statement*>(5, zone());
+ auto case_return = new (zone()) ZoneChunkList<Statement*>(zone());
BuildIteratorClose(case_return, var_iterator, var_input, var_output);
- case_return->Add(factory()->NewBreakStatement(switch_mode, nopos), zone());
+ case_return->push_back(factory()->NewBreakStatement(switch_mode, nopos));
- auto case_throw = new (zone()) ZoneList<Statement*>(5, zone());
- case_throw->Add(get_throw, zone());
- case_throw->Add(check_throw, zone());
- case_throw->Add(call_throw, zone());
- case_throw->Add(validate_throw_output, zone());
- case_throw->Add(factory()->NewBreakStatement(switch_mode, nopos), zone());
+ auto case_throw = new (zone()) ZoneChunkList<Statement*>(zone());
+ case_throw->push_back(get_throw);
+ case_throw->push_back(check_throw);
+ case_throw->push_back(call_throw);
+ case_throw->push_back(validate_throw_output);
+ case_throw->push_back(factory()->NewBreakStatement(switch_mode, nopos));
auto cases = new (zone()) ZoneList<CaseClause*>(3, zone());
Expression* knext =
@@ -4929,11 +4908,11 @@ Expression* Parser::RewriteYieldStar(Expression* generator,
// while (true) { ... }
// Already defined earlier: WhileStatement* loop = ...
{
- Block* loop_body = factory()->NewBlock(nullptr, 4, false, nopos);
- loop_body->statements()->Add(switch_mode, zone());
- loop_body->statements()->Add(if_done, zone());
- loop_body->statements()->Add(set_mode_return, zone());
- loop_body->statements()->Add(try_finally, zone());
+ Block* loop_body = factory()->NewBlock(nullptr, false, nopos);
+ loop_body->statements()->push_back(switch_mode);
+ loop_body->statements()->push_back(if_done);
+ loop_body->statements()->push_back(set_mode_return);
+ loop_body->statements()->push_back(try_finally);
loop->Initialize(factory()->NewBooleanLiteral(true, nopos), loop_body);
}
@@ -4944,18 +4923,18 @@ Expression* Parser::RewriteYieldStar(Expression* generator,
// The rewriter needs to process the get_value statement only, hence we
// put the preceding statements into an init block.
- Block* do_block_ = factory()->NewBlock(nullptr, 7, true, nopos);
- do_block_->statements()->Add(initialize_input, zone());
- do_block_->statements()->Add(initialize_mode, zone());
- do_block_->statements()->Add(initialize_output, zone());
- do_block_->statements()->Add(get_iterator, zone());
- do_block_->statements()->Add(validate_iterator, zone());
- do_block_->statements()->Add(loop, zone());
- do_block_->statements()->Add(maybe_return_value, zone());
+ Block* do_block_ = factory()->NewBlock(nullptr, true, nopos);
+ do_block_->statements()->push_back(initialize_input);
+ do_block_->statements()->push_back(initialize_mode);
+ do_block_->statements()->push_back(initialize_output);
+ do_block_->statements()->push_back(get_iterator);
+ do_block_->statements()->push_back(validate_iterator);
+ do_block_->statements()->push_back(loop);
+ do_block_->statements()->push_back(maybe_return_value);
- Block* do_block = factory()->NewBlock(nullptr, 2, false, nopos);
- do_block->statements()->Add(do_block_, zone());
- do_block->statements()->Add(get_value, zone());
+ Block* do_block = factory()->NewBlock(nullptr, false, nopos);
+ do_block->statements()->push_back(do_block_);
+ do_block->statements()->push_back(get_value);
Variable* dot_result =
NewTemporary(ast_value_factory()->dot_result_string());
@@ -4985,7 +4964,7 @@ Statement* Parser::CheckCallable(Variable* var, Expression* error, int pos) {
return validate_var;
}
-void Parser::BuildIteratorClose(ZoneList<Statement*>* statements,
+void Parser::BuildIteratorClose(ZoneChunkList<Statement*>* statements,
Variable* iterator, Variable* input,
Variable* var_output) {
//
@@ -5076,10 +5055,10 @@ void Parser::BuildIteratorClose(ZoneList<Statement*>* statements,
nopos);
}
- statements->Add(get_return, zone());
- statements->Add(check_return, zone());
- statements->Add(call_return, zone());
- statements->Add(validate_output, zone());
+ statements->push_back(get_return);
+ statements->push_back(check_return);
+ statements->push_back(call_return);
+ statements->push_back(validate_output);
}
void Parser::FinalizeIteratorUse(Variable* completion, Expression* condition,
@@ -5138,16 +5117,14 @@ void Parser::FinalizeIteratorUse(Variable* completion, Expression* condition,
// }
Block* maybe_close;
{
- Block* block = factory()->NewBlock(nullptr, 2, true, nopos);
+ Block* block = factory()->NewBlock(nullptr, true, nopos);
Expression* proxy = factory()->NewVariableProxy(completion);
BuildIteratorCloseForCompletion(block->statements(), iter, proxy);
- DCHECK(block->statements()->length() == 2);
+ DCHECK(block->statements()->size() == 2);
- maybe_close = factory()->NewBlock(nullptr, 1, true, nopos);
- maybe_close->statements()->Add(
- factory()->NewIfStatement(condition, block,
- factory()->NewEmptyStatement(nopos), nopos),
- zone());
+ maybe_close = factory()->NewBlock(nullptr, true, nopos);
+ maybe_close->statements()->push_back(factory()->NewIfStatement(
+ condition, block, factory()->NewEmptyStatement(nopos), nopos));
}
// try { #try_block }
@@ -5175,9 +5152,9 @@ void Parser::FinalizeIteratorUse(Variable* completion, Expression* condition,
factory()->NewCallRuntime(Runtime::kReThrow, args, nopos), nopos);
}
- Block* catch_block = factory()->NewBlock(nullptr, 2, false, nopos);
- catch_block->statements()->Add(set_completion_throw, zone());
- catch_block->statements()->Add(rethrow, zone());
+ Block* catch_block = factory()->NewBlock(nullptr, false, nopos);
+ catch_block->statements()->push_back(set_completion_throw);
+ catch_block->statements()->push_back(rethrow);
try_catch = factory()->NewTryCatchStatementForReThrow(
iterator_use, catch_scope, catch_variable, catch_block, nopos);
@@ -5186,20 +5163,20 @@ void Parser::FinalizeIteratorUse(Variable* completion, Expression* condition,
// try { #try_catch } finally { #maybe_close }
Statement* try_finally;
{
- Block* try_block = factory()->NewBlock(nullptr, 1, false, nopos);
- try_block->statements()->Add(try_catch, zone());
+ Block* try_block = factory()->NewBlock(nullptr, false, nopos);
+ try_block->statements()->push_back(try_catch);
try_finally =
factory()->NewTryFinallyStatement(try_block, maybe_close, nopos);
}
- target->statements()->Add(initialize_completion, zone());
- target->statements()->Add(try_finally, zone());
+ target->statements()->push_back(initialize_completion);
+ target->statements()->push_back(try_finally);
}
-void Parser::BuildIteratorCloseForCompletion(ZoneList<Statement*>* statements,
- Variable* iterator,
- Expression* completion) {
+void Parser::BuildIteratorCloseForCompletion(
+ ZoneChunkList<Statement*>* statements, Variable* iterator,
+ Expression* completion) {
//
// This function adds two statements to [statements], corresponding to the
// following code:
@@ -5257,11 +5234,11 @@ void Parser::BuildIteratorCloseForCompletion(ZoneList<Statement*>* statements,
Expression* call =
factory()->NewCallRuntime(Runtime::kInlineCall, args, nopos);
- Block* try_block = factory()->NewBlock(nullptr, 1, false, nopos);
- try_block->statements()->Add(factory()->NewExpressionStatement(call, nopos),
- zone());
+ Block* try_block = factory()->NewBlock(nullptr, false, nopos);
+ try_block->statements()->push_back(
+ factory()->NewExpressionStatement(call, nopos));
- Block* catch_block = factory()->NewBlock(nullptr, 0, false, nopos);
+ Block* catch_block = factory()->NewBlock(nullptr, false, nopos);
Scope* catch_scope = NewScope(CATCH_SCOPE);
Variable* catch_variable =
@@ -5315,9 +5292,9 @@ void Parser::BuildIteratorCloseForCompletion(ZoneList<Statement*>* statements,
is_receiver_call, factory()->NewEmptyStatement(nopos), throw_call,
nopos);
- validate_return = factory()->NewBlock(nullptr, 2, false, nopos);
- validate_return->statements()->Add(call_return, zone());
- validate_return->statements()->Add(check_return, zone());
+ validate_return = factory()->NewBlock(nullptr, false, nopos);
+ validate_return->statements()->push_back(call_return);
+ validate_return->statements()->push_back(check_return);
}
// if (completion === kThrowCompletion) {
@@ -5332,9 +5309,9 @@ void Parser::BuildIteratorCloseForCompletion(ZoneList<Statement*>* statements,
Token::EQ_STRICT, completion,
factory()->NewSmiLiteral(Parser::kThrowCompletion, nopos), nopos);
- Block* then_block = factory()->NewBlock(nullptr, 2, false, nopos);
- then_block->statements()->Add(check_return_callable, zone());
- then_block->statements()->Add(try_call_return, zone());
+ Block* then_block = factory()->NewBlock(nullptr, false, nopos);
+ then_block->statements()->push_back(check_return_callable);
+ then_block->statements()->push_back(try_call_return);
call_return_carefully = factory()->NewIfStatement(condition, then_block,
validate_return, nopos);
@@ -5352,8 +5329,8 @@ void Parser::BuildIteratorCloseForCompletion(ZoneList<Statement*>* statements,
nopos);
}
- statements->Add(get_return, zone());
- statements->Add(maybe_call_return, zone());
+ statements->push_back(get_return);
+ statements->push_back(maybe_call_return);
}
Statement* Parser::FinalizeForOfStatement(ForOfStatement* loop,
@@ -5395,10 +5372,10 @@ Statement* Parser::FinalizeForOfStatement(ForOfStatement* loop,
nopos);
}
- Block* final_loop = factory()->NewBlock(nullptr, 2, false, nopos);
+ Block* final_loop = factory()->NewBlock(nullptr, false, nopos);
{
- Block* try_block = factory()->NewBlock(nullptr, 1, false, nopos);
- try_block->statements()->Add(loop, zone());
+ Block* try_block = factory()->NewBlock(nullptr, false, nopos);
+ try_block->statements()->push_back(loop);
FinalizeIteratorUse(var_completion, closing_condition, loop->iterator(),
try_block, final_loop);
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698