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

[parser] Use ScopedPtrLists for temporary lists in DesugarLexicalBindingsInForStatement

That way we can avoid allocating unreusable zone memory.

Change-Id: I0f30cbf5133026c63a9729bc45e728daa4740e9f
Reviewed-on: https://chromium-review.googlesource.com/c/1488756Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59858}
parent d2729be4
...@@ -1936,7 +1936,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( ...@@ -1936,7 +1936,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
// } // }
DCHECK_GT(for_info.bound_names.length(), 0); DCHECK_GT(for_info.bound_names.length(), 0);
ZonePtrList<Variable> temps(for_info.bound_names.length(), zone()); ScopedPtrList<Variable> temps(pointer_buffer());
Block* outer_block = Block* outer_block =
factory()->NewBlock(for_info.bound_names.length() + 4, false); factory()->NewBlock(for_info.bound_names.length() + 4, false);
...@@ -1957,7 +1957,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( ...@@ -1957,7 +1957,7 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
Statement* assignment_statement = Statement* assignment_statement =
factory()->NewExpressionStatement(assignment, kNoSourcePosition); factory()->NewExpressionStatement(assignment, kNoSourcePosition);
outer_block->statements()->Add(assignment_statement, zone()); outer_block->statements()->Add(assignment_statement, zone());
temps.Add(temp, zone()); temps.Add(temp);
} }
Variable* first = nullptr; Variable* first = nullptr;
...@@ -1995,14 +1995,14 @@ Statement* Parser::DesugarLexicalBindingsInForStatement( ...@@ -1995,14 +1995,14 @@ Statement* Parser::DesugarLexicalBindingsInForStatement(
Block* ignore_completion_block = Block* ignore_completion_block =
factory()->NewBlock(for_info.bound_names.length() + 3, true); factory()->NewBlock(for_info.bound_names.length() + 3, true);
ZonePtrList<Variable> inner_vars(for_info.bound_names.length(), zone()); ScopedPtrList<Variable> inner_vars(pointer_buffer());
// For each let variable x: // For each let variable x:
// make statement: let/const x = temp_x. // make statement: let/const x = temp_x.
for (int i = 0; i < for_info.bound_names.length(); i++) { for (int i = 0; i < for_info.bound_names.length(); i++) {
VariableProxy* proxy = DeclareBoundVariable( VariableProxy* proxy = DeclareBoundVariable(
for_info.bound_names[i], for_info.parsing_result.descriptor.mode, for_info.bound_names[i], for_info.parsing_result.descriptor.mode,
kNoSourcePosition); kNoSourcePosition);
inner_vars.Add(proxy->var(), zone()); inner_vars.Add(proxy->var());
VariableProxy* temp_proxy = factory()->NewVariableProxy(temps.at(i)); VariableProxy* temp_proxy = factory()->NewVariableProxy(temps.at(i));
Assignment* assignment = factory()->NewAssignment( Assignment* assignment = factory()->NewAssignment(
Token::INIT, proxy, temp_proxy, kNoSourcePosition); Token::INIT, proxy, temp_proxy, kNoSourcePosition);
......
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