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

Unified Diff: src/parsing/rewriter.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/preparser.h ('k') | src/regexp/jsregexp.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/rewriter.cc
diff --git a/src/parsing/rewriter.cc b/src/parsing/rewriter.cc
index 69ac4171c273eef7aa0aa14d1524a1944c04e203..c8802127c201ee5dba2ea2c89831113a3c52ba35 100644
--- a/src/parsing/rewriter.cc
+++ b/src/parsing/rewriter.cc
@@ -42,7 +42,7 @@ class Processor final : public AstVisitor<Processor> {
InitializeAstVisitor(parser->stack_limit());
}
- void Process(ZoneList<Statement*>* statements);
+ void Process(ZoneChunkList<Statement*>* statements);
bool result_assigned() const { return result_assigned_; }
Zone* zone() { return zone_; }
@@ -115,24 +115,23 @@ Statement* Processor::AssignUndefinedBefore(Statement* s) {
Expression* undef = factory()->NewUndefinedLiteral(kNoSourcePosition);
Expression* assignment = factory()->NewAssignment(Token::ASSIGN, result_proxy,
undef, kNoSourcePosition);
- Block* b = factory()->NewBlock(NULL, 2, false, kNoSourcePosition);
- b->statements()->Add(
- factory()->NewExpressionStatement(assignment, kNoSourcePosition), zone());
- b->statements()->Add(s, zone());
+ Block* b = factory()->NewBlock(NULL, false, kNoSourcePosition);
+ b->statements()->push_back(
+ factory()->NewExpressionStatement(assignment, kNoSourcePosition));
+ b->statements()->push_back(s);
return b;
}
-
-void Processor::Process(ZoneList<Statement*>* statements) {
+void Processor::Process(ZoneChunkList<Statement*>* statements) {
// If we're in a breakable scope (named block, iteration, or switch), we walk
// all statements. The last value producing statement before the break needs
// to assign to .result. If we're not in a breakable scope, only the last
// value producing statement in the block assigns to .result, so we can stop
// early.
- for (int i = statements->length() - 1; i >= 0 && (breakable_ || !is_set_);
- --i) {
- Visit(statements->at(i));
- statements->Set(i, replacement_);
+ for (auto it = statements->rbegin();
+ it != statements->rend() && (breakable_ || !is_set_); ++it) {
+ Visit(*it);
+ *it = replacement_;
}
}
@@ -261,10 +260,10 @@ void Processor::VisitTryFinallyStatement(TryFinallyStatement* node) {
Token::ASSIGN, backup_proxy, result_proxy, kNoSourcePosition);
Expression* restore = factory()->NewAssignment(
Token::ASSIGN, result_proxy, backup_proxy, kNoSourcePosition);
- node->finally_block()->statements()->InsertAt(
- 0, factory()->NewExpressionStatement(save, kNoSourcePosition), zone());
- node->finally_block()->statements()->Add(
- factory()->NewExpressionStatement(restore, kNoSourcePosition), zone());
+ node->finally_block()->statements()->push_front(
+ factory()->NewExpressionStatement(save, kNoSourcePosition));
+ node->finally_block()->statements()->push_back(
+ factory()->NewExpressionStatement(restore, kNoSourcePosition));
is_set_ = set_after;
}
Visit(node->try_block());
@@ -363,8 +362,8 @@ bool Rewriter::Rewrite(ParseInfo* info) {
if (!scope->is_script_scope() && !scope->is_eval_scope()) return true;
DeclarationScope* closure_scope = scope->GetClosureScope();
- ZoneList<Statement*>* body = function->body();
- if (!body->is_empty()) {
+ ZoneChunkList<Statement*>* body = function->body();
+ if (body->size() > 0) {
Variable* result = closure_scope->NewTemporary(
info->ast_value_factory()->dot_result_string());
// The name string must be internalized at this point.
@@ -383,7 +382,7 @@ bool Rewriter::Rewrite(ParseInfo* info) {
processor.factory()->NewVariableProxy(result, pos);
Statement* result_statement =
processor.factory()->NewReturnStatement(result_proxy, pos);
- body->Add(result_statement, info->zone());
+ body->push_back(result_statement);
}
}
@@ -396,11 +395,11 @@ bool Rewriter::Rewrite(Parser* parser, DeclarationScope* closure_scope,
DCHECK_EQ(closure_scope, closure_scope->GetClosureScope());
DCHECK(block->scope() == nullptr ||
block->scope()->GetClosureScope() == closure_scope);
- ZoneList<Statement*>* body = block->statements();
+ ZoneChunkList<Statement*>* body = block->statements();
VariableProxy* result = expr->result();
Variable* result_var = result->var();
- if (!body->is_empty()) {
+ if (body->size() > 0) {
Processor processor(parser, closure_scope, result_var, factory);
processor.Process(body);
if (processor.HasStackOverflow()) return false;
@@ -410,7 +409,7 @@ bool Rewriter::Rewrite(Parser* parser, DeclarationScope* closure_scope,
Expression* undef = node_factory->NewUndefinedLiteral(kNoSourcePosition);
Statement* completion = node_factory->NewExpressionStatement(
processor.SetResult(undef), expr->position());
- body->Add(completion, factory->zone());
+ body->push_back(completion);
}
}
return true;
« no previous file with comments | « src/parsing/preparser.h ('k') | src/regexp/jsregexp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698