Index: src/parser.cc |
diff --git a/src/parser.cc b/src/parser.cc |
index 778527ff548b4be1eb0377da38e579f1dc73a50d..7c51b694c88022d06b66416a9764c5e7badb56b7 100644 |
--- a/src/parser.cc |
+++ b/src/parser.cc |
@@ -103,7 +103,7 @@ void RegExpBuilder::FlushCharacters() { |
if (characters_ != NULL) { |
RegExpTree* atom = new(zone()) RegExpAtom(characters_->ToConstVector()); |
characters_ = NULL; |
- text_.Add(atom); |
+ text_.Add(atom, zone()); |
LAST(ADD_ATOM); |
} |
} |
@@ -115,12 +115,12 @@ void RegExpBuilder::FlushText() { |
if (num_text == 0) { |
return; |
} else if (num_text == 1) { |
- terms_.Add(text_.last()); |
+ terms_.Add(text_.last(), zone()); |
} else { |
- RegExpText* text = new(zone()) RegExpText(); |
+ RegExpText* text = new(zone()) RegExpText(zone()); |
for (int i = 0; i < num_text; i++) |
- text_.Get(i)->AppendToText(text); |
- terms_.Add(text); |
+ text_.Get(i)->AppendToText(text, zone()); |
+ terms_.Add(text, zone()); |
} |
text_.Clear(); |
} |
@@ -129,9 +129,9 @@ void RegExpBuilder::FlushText() { |
void RegExpBuilder::AddCharacter(uc16 c) { |
pending_empty_ = false; |
if (characters_ == NULL) { |
- characters_ = new(zone()) ZoneList<uc16>(4); |
+ characters_ = new(zone()) ZoneList<uc16>(4, zone()); |
} |
- characters_->Add(c); |
+ characters_->Add(c, zone()); |
LAST(ADD_CHAR); |
} |
@@ -148,10 +148,10 @@ void RegExpBuilder::AddAtom(RegExpTree* term) { |
} |
if (term->IsTextElement()) { |
FlushCharacters(); |
- text_.Add(term); |
+ text_.Add(term, zone()); |
} else { |
FlushText(); |
- terms_.Add(term); |
+ terms_.Add(term, zone()); |
} |
LAST(ADD_ATOM); |
} |
@@ -159,7 +159,7 @@ void RegExpBuilder::AddAtom(RegExpTree* term) { |
void RegExpBuilder::AddAssertion(RegExpTree* assert) { |
FlushText(); |
- terms_.Add(assert); |
+ terms_.Add(assert, zone()); |
LAST(ADD_ASSERT); |
} |
@@ -178,9 +178,9 @@ void RegExpBuilder::FlushTerms() { |
} else if (num_terms == 1) { |
alternative = terms_.last(); |
} else { |
- alternative = new(zone()) RegExpAlternative(terms_.GetList()); |
+ alternative = new(zone()) RegExpAlternative(terms_.GetList(zone())); |
} |
- alternatives_.Add(alternative); |
+ alternatives_.Add(alternative, zone()); |
terms_.Clear(); |
LAST(ADD_NONE); |
} |
@@ -195,7 +195,7 @@ RegExpTree* RegExpBuilder::ToRegExp() { |
if (num_alternatives == 1) { |
return alternatives_.last(); |
} |
- return new(zone()) RegExpDisjunction(alternatives_.GetList()); |
+ return new(zone()) RegExpDisjunction(alternatives_.GetList(zone())); |
} |
@@ -214,7 +214,7 @@ void RegExpBuilder::AddQuantifierToAtom(int min, |
int num_chars = char_vector.length(); |
if (num_chars > 1) { |
Vector<const uc16> prefix = char_vector.SubVector(0, num_chars - 1); |
- text_.Add(new(zone()) RegExpAtom(prefix)); |
+ text_.Add(new(zone()) RegExpAtom(prefix), zone()); |
char_vector = char_vector.SubVector(num_chars - 1, num_chars); |
} |
characters_ = NULL; |
@@ -233,7 +233,7 @@ void RegExpBuilder::AddQuantifierToAtom(int min, |
if (min == 0) { |
return; |
} |
- terms_.Add(atom); |
+ terms_.Add(atom, zone()); |
return; |
} |
} else { |
@@ -241,7 +241,7 @@ void RegExpBuilder::AddQuantifierToAtom(int min, |
UNREACHABLE(); |
return; |
} |
- terms_.Add(new(zone()) RegExpQuantifier(min, max, type, atom)); |
+ terms_.Add(new(zone()) RegExpQuantifier(min, max, type, atom), zone()); |
LAST(ADD_TERM); |
} |
@@ -270,7 +270,7 @@ Handle<String> Parser::LookupCachedSymbol(int symbol_id) { |
if (symbol_cache_.length() <= symbol_id) { |
// Increase length to index + 1. |
symbol_cache_.AddBlock(Handle<String>::null(), |
- symbol_id + 1 - symbol_cache_.length()); |
+ symbol_id + 1 - symbol_cache_.length(), zone()); |
} |
Handle<String> result = symbol_cache_.at(symbol_id); |
if (result.is_null()) { |
@@ -408,7 +408,7 @@ unsigned* ScriptDataImpl::ReadAddress(int position) { |
Scope* Parser::NewScope(Scope* parent, ScopeType type) { |
- Scope* result = new(zone()) Scope(parent, type); |
+ Scope* result = new(zone()) Scope(parent, type, zone()); |
result->Initialize(); |
return result; |
} |
@@ -538,7 +538,7 @@ Parser::Parser(Handle<Script> script, |
ScriptDataImpl* pre_data, |
Zone* zone) |
: isolate_(script->GetIsolate()), |
- symbol_cache_(pre_data ? pre_data->symbol_count() : 0), |
+ symbol_cache_(pre_data ? pre_data->symbol_count() : 0, zone), |
script_(script), |
scanner_(isolate_->unicode_cache()), |
reusable_preparser_(NULL), |
@@ -570,7 +570,7 @@ FunctionLiteral* Parser::ParseProgram(CompilationInfo* info) { |
HistogramTimerScope timer(isolate()->counters()->parse()); |
Handle<String> source(String::cast(script_->source())); |
isolate()->counters()->total_parse_size()->Increment(source->length()); |
- fni_ = new(zone()) FuncNameInferrer(isolate()); |
+ fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); |
// Initialize parser state. |
source->TryFlatten(); |
@@ -609,7 +609,8 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, |
if (info->is_eval()) { |
Handle<SharedFunctionInfo> shared = info->shared_info(); |
if (!info->is_global() && (shared.is_null() || shared->is_function())) { |
- scope = Scope::DeserializeScopeChain(*info->calling_context(), scope); |
+ scope = Scope::DeserializeScopeChain(*info->calling_context(), scope, |
+ zone()); |
} |
if (!scope->is_global_scope() || info->language_mode() != CLASSIC_MODE) { |
scope = NewScope(scope, EVAL_SCOPE); |
@@ -619,7 +620,7 @@ FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, |
scope->set_end_position(source->length()); |
FunctionState function_state(this, scope, isolate()); |
top_scope_->SetLanguageMode(info->language_mode()); |
- ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16); |
+ ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); |
bool ok = true; |
int beg_loc = scanner().location().beg_pos; |
ParseSourceElements(body, Token::EOS, info->is_eval(), &ok); |
@@ -696,7 +697,7 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info, |
ASSERT(target_stack_ == NULL); |
Handle<String> name(String::cast(shared_info->name())); |
- fni_ = new(zone()) FuncNameInferrer(isolate()); |
+ fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); |
fni_->PushEnclosingName(name); |
mode_ = PARSE_EAGERLY; |
@@ -709,7 +710,8 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info, |
Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE); |
info->SetGlobalScope(scope); |
if (!info->closure().is_null()) { |
- scope = Scope::DeserializeScopeChain(info->closure()->context(), scope); |
+ scope = Scope::DeserializeScopeChain(info->closure()->context(), scope, |
+ zone()); |
} |
FunctionState function_state(this, scope, isolate()); |
ASSERT(scope->language_mode() != STRICT_MODE || !info->is_classic_mode()); |
@@ -944,12 +946,13 @@ class InitializationBlockFinder : public ParserFinder { |
// function contains only assignments of this type. |
class ThisNamedPropertyAssignmentFinder : public ParserFinder { |
public: |
- explicit ThisNamedPropertyAssignmentFinder(Isolate* isolate) |
+ ThisNamedPropertyAssignmentFinder(Isolate* isolate, Zone* zone) |
: isolate_(isolate), |
only_simple_this_property_assignments_(true), |
- names_(0), |
- assigned_arguments_(0), |
- assigned_constants_(0) { |
+ names_(0, zone), |
+ assigned_arguments_(0, zone), |
+ assigned_constants_(0, zone), |
+ zone_(zone) { |
} |
void Update(Scope* scope, Statement* stat) { |
@@ -1058,9 +1061,9 @@ class ThisNamedPropertyAssignmentFinder : public ParserFinder { |
return; |
} |
} |
- names_.Add(name); |
- assigned_arguments_.Add(index); |
- assigned_constants_.Add(isolate_->factory()->undefined_value()); |
+ names_.Add(name, zone()); |
+ assigned_arguments_.Add(index, zone()); |
+ assigned_constants_.Add(isolate_->factory()->undefined_value(), zone()); |
} |
void AssignmentFromConstant(Handle<String> name, Handle<Object> value) { |
@@ -1072,9 +1075,9 @@ class ThisNamedPropertyAssignmentFinder : public ParserFinder { |
return; |
} |
} |
- names_.Add(name); |
- assigned_arguments_.Add(-1); |
- assigned_constants_.Add(value); |
+ names_.Add(name, zone()); |
+ assigned_arguments_.Add(-1, zone()); |
+ assigned_constants_.Add(value, zone()); |
} |
void AssignmentFromSomethingElse() { |
@@ -1086,17 +1089,20 @@ class ThisNamedPropertyAssignmentFinder : public ParserFinder { |
if (names_.capacity() == 0) { |
ASSERT(assigned_arguments_.capacity() == 0); |
ASSERT(assigned_constants_.capacity() == 0); |
- names_.Initialize(4); |
- assigned_arguments_.Initialize(4); |
- assigned_constants_.Initialize(4); |
+ names_.Initialize(4, zone()); |
+ assigned_arguments_.Initialize(4, zone()); |
+ assigned_constants_.Initialize(4, zone()); |
} |
} |
+ Zone* zone() const { return zone_; } |
+ |
Isolate* isolate_; |
bool only_simple_this_property_assignments_; |
ZoneStringList names_; |
ZoneList<int> assigned_arguments_; |
ZoneObjectList assigned_constants_; |
+ Zone* zone_; |
}; |
@@ -1115,7 +1121,8 @@ void* Parser::ParseSourceElements(ZoneList<Statement*>* processor, |
ASSERT(processor != NULL); |
InitializationBlockFinder block_finder(top_scope_, target_stack_); |
- ThisNamedPropertyAssignmentFinder this_property_assignment_finder(isolate()); |
+ ThisNamedPropertyAssignmentFinder this_property_assignment_finder(isolate(), |
+ zone()); |
bool directive_prologue = true; // Parsing directive prologue. |
while (peek() != end_token) { |
@@ -1173,7 +1180,7 @@ void* Parser::ParseSourceElements(ZoneList<Statement*>* processor, |
if (top_scope_->is_function_scope()) { |
this_property_assignment_finder.Update(top_scope_, stat); |
} |
- processor->Add(stat); |
+ processor->Add(stat, zone()); |
} |
// Propagate the collected information on this property assignments. |
@@ -1244,7 +1251,7 @@ Block* Parser::ParseModuleDeclaration(ZoneStringList* names, bool* ok) { |
// 'module' Identifier Module |
// Create new block with one expected declaration. |
- Block* block = factory()->NewBlock(NULL, 1, true); |
+ Block* block = factory()->NewBlock(NULL, 1, true, zone()); |
Handle<String> name = ParseIdentifier(CHECK_OK); |
#ifdef DEBUG |
@@ -1270,7 +1277,7 @@ Block* Parser::ParseModuleDeclaration(ZoneStringList* names, bool* ok) { |
// TODO(rossberg): Add initialization statement to block. |
- if (names) names->Add(name); |
+ if (names) names->Add(name, zone()); |
return block; |
} |
@@ -1307,7 +1314,7 @@ Module* Parser::ParseModuleLiteral(bool* ok) { |
// '{' ModuleElement '}' |
// Construct block expecting 16 statements. |
- Block* body = factory()->NewBlock(NULL, 16, false); |
+ Block* body = factory()->NewBlock(NULL, 16, false, zone()); |
#ifdef DEBUG |
if (FLAG_print_interface_details) PrintF("# Literal "); |
#endif |
@@ -1319,7 +1326,7 @@ Module* Parser::ParseModuleLiteral(bool* ok) { |
{ |
BlockState block_state(this, scope); |
- TargetCollector collector; |
+ TargetCollector collector(zone()); |
Target target(&this->target_stack_, &collector); |
Target target_body(&this->target_stack_, body); |
InitializationBlockFinder block_finder(top_scope_, target_stack_); |
@@ -1364,7 +1371,7 @@ Module* Parser::ParseModulePath(bool* ok) { |
PrintF("# Path .%s ", name->ToAsciiArray()); |
#endif |
Module* member = factory()->NewModulePath(result, name); |
- result->interface()->Add(name, member->interface(), ok); |
+ result->interface()->Add(name, member->interface(), zone(), ok); |
if (!*ok) { |
#ifdef DEBUG |
if (FLAG_print_interfaces) { |
@@ -1395,7 +1402,8 @@ Module* Parser::ParseModuleVariable(bool* ok) { |
PrintF("# Module variable %s ", name->ToAsciiArray()); |
#endif |
VariableProxy* proxy = top_scope_->NewUnresolved( |
- factory(), name, scanner().location().beg_pos, Interface::NewModule()); |
+ factory(), name, scanner().location().beg_pos, |
+ Interface::NewModule(zone())); |
return factory()->NewModuleVariable(proxy); |
} |
@@ -1444,14 +1452,14 @@ Block* Parser::ParseImportDeclaration(bool* ok) { |
// TODO(ES6): implement destructuring ImportSpecifiers |
Expect(Token::IMPORT, CHECK_OK); |
- ZoneStringList names(1); |
+ ZoneStringList names(1, zone()); |
Handle<String> name = ParseIdentifierName(CHECK_OK); |
- names.Add(name); |
+ names.Add(name, zone()); |
while (peek() == Token::COMMA) { |
Consume(Token::COMMA); |
name = ParseIdentifierName(CHECK_OK); |
- names.Add(name); |
+ names.Add(name, zone()); |
} |
ExpectContextualKeyword("from", CHECK_OK); |
@@ -1460,14 +1468,14 @@ Block* Parser::ParseImportDeclaration(bool* ok) { |
// Generate a separate declaration for each identifier. |
// TODO(ES6): once we implement destructuring, make that one declaration. |
- Block* block = factory()->NewBlock(NULL, 1, true); |
+ Block* block = factory()->NewBlock(NULL, 1, true, zone()); |
for (int i = 0; i < names.length(); ++i) { |
#ifdef DEBUG |
if (FLAG_print_interface_details) |
PrintF("# Import %s ", names[i]->ToAsciiArray()); |
#endif |
- Interface* interface = Interface::NewUnknown(); |
- module->interface()->Add(names[i], interface, ok); |
+ Interface* interface = Interface::NewUnknown(zone()); |
+ module->interface()->Add(names[i], interface, zone(), ok); |
if (!*ok) { |
#ifdef DEBUG |
if (FLAG_print_interfaces) { |
@@ -1502,17 +1510,17 @@ Statement* Parser::ParseExportDeclaration(bool* ok) { |
Expect(Token::EXPORT, CHECK_OK); |
Statement* result = NULL; |
- ZoneStringList names(1); |
+ ZoneStringList names(1, zone()); |
switch (peek()) { |
case Token::IDENTIFIER: { |
Handle<String> name = ParseIdentifier(CHECK_OK); |
// Handle 'module' as a context-sensitive keyword. |
if (!name->IsEqualTo(CStrVector("module"))) { |
- names.Add(name); |
+ names.Add(name, zone()); |
while (peek() == Token::COMMA) { |
Consume(Token::COMMA); |
name = ParseIdentifier(CHECK_OK); |
- names.Add(name); |
+ names.Add(name, zone()); |
} |
ExpectSemicolon(CHECK_OK); |
result = factory()->NewEmptyStatement(); |
@@ -1545,8 +1553,10 @@ Statement* Parser::ParseExportDeclaration(bool* ok) { |
if (FLAG_print_interface_details) |
PrintF("# Export %s ", names[i]->ToAsciiArray()); |
#endif |
- Interface* inner = Interface::NewUnknown(); |
- interface->Add(names[i], inner, CHECK_OK); |
+ Interface* inner = Interface::NewUnknown(zone()); |
+ interface->Add(names[i], inner, zone(), CHECK_OK); |
+ if (!*ok) |
+ return NULL; |
VariableProxy* proxy = NewUnresolved(names[i], LET, inner); |
USE(proxy); |
// TODO(rossberg): Rethink whether we actually need to store export |
@@ -1673,7 +1683,7 @@ Statement* Parser::ParseStatement(ZoneStringList* labels, bool* ok) { |
// one must take great care not to treat it as a |
// fall-through. It is much easier just to wrap the entire |
// try-statement in a statement block and put the labels there |
- Block* result = factory()->NewBlock(labels, 1, false); |
+ Block* result = factory()->NewBlock(labels, 1, false, zone()); |
Target target(&this->target_stack_, result); |
TryStatement* statement = ParseTryStatement(CHECK_OK); |
if (statement) { |
@@ -1872,7 +1882,7 @@ void Parser::Declare(Declaration* declaration, bool resolve, bool* ok) { |
if (FLAG_print_interface_details) |
PrintF("# Declare %s\n", var->name()->ToAsciiArray()); |
#endif |
- proxy->interface()->Unify(var->interface(), &ok); |
+ proxy->interface()->Unify(var->interface(), zone(), &ok); |
if (!ok) { |
#ifdef DEBUG |
if (FLAG_print_interfaces) { |
@@ -1971,7 +1981,7 @@ Statement* Parser::ParseFunctionDeclaration(ZoneStringList* names, bool* ok) { |
Declaration* declaration = |
factory()->NewFunctionDeclaration(proxy, mode, fun, top_scope_); |
Declare(declaration, true, CHECK_OK); |
- if (names) names->Add(name); |
+ if (names) names->Add(name, zone()); |
return factory()->NewEmptyStatement(); |
} |
@@ -1986,7 +1996,7 @@ Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) { |
// (ECMA-262, 3rd, 12.2) |
// |
// Construct block expecting 16 statements. |
- Block* result = factory()->NewBlock(labels, 16, false); |
+ Block* result = factory()->NewBlock(labels, 16, false, zone()); |
Target target(&this->target_stack_, result); |
Expect(Token::LBRACE, CHECK_OK); |
InitializationBlockFinder block_finder(top_scope_, target_stack_); |
@@ -2009,14 +2019,14 @@ Block* Parser::ParseScopedBlock(ZoneStringList* labels, bool* ok) { |
// '{' BlockElement* '}' |
// Construct block expecting 16 statements. |
- Block* body = factory()->NewBlock(labels, 16, false); |
+ Block* body = factory()->NewBlock(labels, 16, false, zone()); |
Scope* block_scope = NewScope(top_scope_, BLOCK_SCOPE); |
// Parse the statements and collect escaping labels. |
Expect(Token::LBRACE, CHECK_OK); |
block_scope->set_start_position(scanner().location().beg_pos); |
{ BlockState block_state(this, block_scope); |
- TargetCollector collector; |
+ TargetCollector collector(zone()); |
Target target(&this->target_stack_, &collector); |
Target target_body(&this->target_stack_, body); |
InitializationBlockFinder block_finder(top_scope_, target_stack_); |
@@ -2166,7 +2176,7 @@ Block* Parser::ParseVariableDeclarations( |
// is inside an initializer block, it is ignored. |
// |
// Create new block with one expected declaration. |
- Block* block = factory()->NewBlock(NULL, 1, true); |
+ Block* block = factory()->NewBlock(NULL, 1, true, zone()); |
int nvars = 0; // the number of variables declared |
Handle<String> name; |
do { |
@@ -2210,7 +2220,7 @@ Block* Parser::ParseVariableDeclarations( |
*ok = false; |
return NULL; |
} |
- if (names) names->Add(name); |
+ if (names) names->Add(name, zone()); |
// Parse initialization expression if present and/or needed. A |
// declaration of the form: |
@@ -2289,13 +2299,14 @@ Block* Parser::ParseVariableDeclarations( |
// properties defined in prototype objects. |
if (initialization_scope->is_global_scope()) { |
// Compute the arguments for the runtime call. |
- ZoneList<Expression*>* arguments = new(zone()) ZoneList<Expression*>(3); |
+ ZoneList<Expression*>* arguments = |
+ new(zone()) ZoneList<Expression*>(3, zone()); |
// We have at least 1 parameter. |
- arguments->Add(factory()->NewLiteral(name)); |
+ arguments->Add(factory()->NewLiteral(name), zone()); |
CallRuntime* initialize; |
if (is_const) { |
- arguments->Add(value); |
+ arguments->Add(value, zone()); |
value = NULL; // zap the value to avoid the unnecessary assignment |
// Construct the call to Runtime_InitializeConstGlobal |
@@ -2310,14 +2321,14 @@ Block* Parser::ParseVariableDeclarations( |
// Add strict mode. |
// We may want to pass singleton to avoid Literal allocations. |
LanguageMode language_mode = initialization_scope->language_mode(); |
- arguments->Add(factory()->NewNumberLiteral(language_mode)); |
+ arguments->Add(factory()->NewNumberLiteral(language_mode), zone()); |
// Be careful not to assign a value to the global variable if |
// we're in a with. The initialization value should not |
// necessarily be stored in the global object in that case, |
// which is why we need to generate a separate assignment node. |
if (value != NULL && !inside_with()) { |
- arguments->Add(value); |
+ arguments->Add(value, zone()); |
value = NULL; // zap the value to avoid the unnecessary assignment |
} |
@@ -2417,8 +2428,10 @@ Statement* Parser::ParseExpressionOrLabelledStatement(ZoneStringList* labels, |
*ok = false; |
return NULL; |
} |
- if (labels == NULL) labels = new(zone()) ZoneStringList(4); |
- labels->Add(label); |
+ if (labels == NULL) { |
+ labels = new(zone()) ZoneStringList(4, zone()); |
+ } |
+ labels->Add(label, zone()); |
// Remove the "ghost" variable that turned out to be a label |
// from the top scope. This way, we don't try to resolve it |
// during the scope processing. |
@@ -2630,12 +2643,13 @@ CaseClause* Parser::ParseCaseClause(bool* default_seen_ptr, bool* ok) { |
} |
Expect(Token::COLON, CHECK_OK); |
int pos = scanner().location().beg_pos; |
- ZoneList<Statement*>* statements = new(zone()) ZoneList<Statement*>(5); |
+ ZoneList<Statement*>* statements = |
+ new(zone()) ZoneList<Statement*>(5, zone()); |
while (peek() != Token::CASE && |
peek() != Token::DEFAULT && |
peek() != Token::RBRACE) { |
Statement* stat = ParseStatement(NULL, CHECK_OK); |
- statements->Add(stat); |
+ statements->Add(stat, zone()); |
} |
return new(zone()) CaseClause(isolate(), label, statements, pos); |
@@ -2656,11 +2670,11 @@ SwitchStatement* Parser::ParseSwitchStatement(ZoneStringList* labels, |
Expect(Token::RPAREN, CHECK_OK); |
bool default_seen = false; |
- ZoneList<CaseClause*>* cases = new(zone()) ZoneList<CaseClause*>(4); |
+ ZoneList<CaseClause*>* cases = new(zone()) ZoneList<CaseClause*>(4, zone()); |
Expect(Token::LBRACE, CHECK_OK); |
while (peek() != Token::RBRACE) { |
CaseClause* clause = ParseCaseClause(&default_seen, CHECK_OK); |
- cases->Add(clause); |
+ cases->Add(clause, zone()); |
} |
Expect(Token::RBRACE, CHECK_OK); |
@@ -2701,7 +2715,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
Expect(Token::TRY, CHECK_OK); |
- TargetCollector try_collector; |
+ TargetCollector try_collector(zone()); |
Block* try_block; |
{ Target target(&this->target_stack_, &try_collector); |
@@ -2719,7 +2733,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
// then we will need to collect escaping targets from the catch |
// block. Since we don't know yet if there will be a finally block, we |
// always collect the targets. |
- TargetCollector catch_collector; |
+ TargetCollector catch_collector(zone()); |
Scope* catch_scope = NULL; |
Variable* catch_variable = NULL; |
Block* catch_block = NULL; |
@@ -2773,7 +2787,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
TryCatchStatement* statement = factory()->NewTryCatchStatement( |
index, try_block, catch_scope, catch_variable, catch_block); |
statement->set_escaping_targets(try_collector.targets()); |
- try_block = factory()->NewBlock(NULL, 1, false); |
+ try_block = factory()->NewBlock(NULL, 1, false, zone()); |
try_block->AddStatement(statement, zone()); |
catch_block = NULL; // Clear to indicate it's been handled. |
} |
@@ -2790,7 +2804,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) { |
int index = current_function_state_->NextHandlerIndex(); |
result = factory()->NewTryFinallyStatement(index, try_block, finally_block); |
// Combine the jump targets of the try block and the possible catch block. |
- try_collector.targets()->AddAll(*catch_collector.targets()); |
+ try_collector.targets()->AddAll(*catch_collector.targets(), zone()); |
} |
result->set_escaping_targets(try_collector.targets()); |
@@ -2879,7 +2893,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { |
Statement* body = ParseStatement(NULL, CHECK_OK); |
loop->Initialize(each, enumerable, body); |
- Block* result = factory()->NewBlock(NULL, 2, false); |
+ Block* result = factory()->NewBlock(NULL, 2, false, zone()); |
result->AddStatement(variable_statement, zone()); |
result->AddStatement(loop, zone()); |
top_scope_ = saved_scope; |
@@ -2925,7 +2939,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { |
Expect(Token::RPAREN, CHECK_OK); |
Statement* body = ParseStatement(NULL, CHECK_OK); |
- Block* body_block = factory()->NewBlock(NULL, 3, false); |
+ Block* body_block = factory()->NewBlock(NULL, 3, false, zone()); |
Assignment* assignment = factory()->NewAssignment( |
Token::ASSIGN, each, temp_proxy, RelocInfo::kNoPosition); |
Statement* assignment_statement = |
@@ -3014,7 +3028,7 @@ Statement* Parser::ParseForStatement(ZoneStringList* labels, bool* ok) { |
// for (; c; n) b |
// } |
ASSERT(init != NULL); |
- Block* result = factory()->NewBlock(NULL, 2, false); |
+ Block* result = factory()->NewBlock(NULL, 2, false, zone()); |
result->AddStatement(init, zone()); |
result->AddStatement(loop, zone()); |
result->set_scope(for_scope); |
@@ -3459,7 +3473,7 @@ Expression* Parser::ParseNewPrefix(PositionStack* stack, bool* ok) { |
if (!stack->is_empty()) { |
int last = stack->pop(); |
result = factory()->NewCallNew( |
- result, new(zone()) ZoneList<Expression*>(0), last); |
+ result, new(zone()) ZoneList<Expression*>(0, zone()), last); |
} |
return result; |
} |
@@ -3649,7 +3663,7 @@ Expression* Parser::ParsePrimaryExpression(bool* ok) { |
if (FLAG_print_interface_details) |
PrintF("# Variable %s ", name->ToAsciiArray()); |
#endif |
- Interface* interface = Interface::NewUnknown(); |
+ Interface* interface = Interface::NewUnknown(zone()); |
result = top_scope_->NewUnresolved( |
factory(), name, scanner().location().beg_pos, interface); |
break; |
@@ -3749,7 +3763,7 @@ Expression* Parser::ParseArrayLiteral(bool* ok) { |
// ArrayLiteral :: |
// '[' Expression? (',' Expression?)* ']' |
- ZoneList<Expression*>* values = new(zone()) ZoneList<Expression*>(4); |
+ ZoneList<Expression*>* values = new(zone()) ZoneList<Expression*>(4, zone()); |
Expect(Token::LBRACK, CHECK_OK); |
while (peek() != Token::RBRACK) { |
Expression* elem; |
@@ -3758,7 +3772,7 @@ Expression* Parser::ParseArrayLiteral(bool* ok) { |
} else { |
elem = ParseAssignmentExpression(true, CHECK_OK); |
} |
- values->Add(elem); |
+ values->Add(elem, zone()); |
if (peek() != Token::RBRACK) { |
Expect(Token::COMMA, CHECK_OK); |
} |
@@ -4127,7 +4141,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) { |
// )*[','] '}' |
ZoneList<ObjectLiteral::Property*>* properties = |
- new(zone()) ZoneList<ObjectLiteral::Property*>(4); |
+ new(zone()) ZoneList<ObjectLiteral::Property*>(4, zone()); |
int number_of_boilerplate_properties = 0; |
bool has_function = false; |
@@ -4164,7 +4178,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) { |
} |
// Validate the property. |
checker.CheckProperty(property, loc, CHECK_OK); |
- properties->Add(property); |
+ properties->Add(property, zone()); |
if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); |
if (fni_ != NULL) { |
@@ -4232,7 +4246,7 @@ Expression* Parser::ParseObjectLiteral(bool* ok) { |
if (IsBoilerplateProperty(property)) number_of_boilerplate_properties++; |
// Validate the property |
checker.CheckProperty(property, loc, CHECK_OK); |
- properties->Add(property); |
+ properties->Add(property, zone()); |
// TODO(1240767): Consider allowing trailing comma. |
if (peek() != Token::RBRACE) Expect(Token::COMMA, CHECK_OK); |
@@ -4291,12 +4305,12 @@ ZoneList<Expression*>* Parser::ParseArguments(bool* ok) { |
// Arguments :: |
// '(' (AssignmentExpression)*[','] ')' |
- ZoneList<Expression*>* result = new(zone()) ZoneList<Expression*>(4); |
+ ZoneList<Expression*>* result = new(zone()) ZoneList<Expression*>(4, zone()); |
Expect(Token::LPAREN, CHECK_OK); |
bool done = (peek() == Token::RPAREN); |
while (!done) { |
Expression* argument = ParseAssignmentExpression(true, CHECK_OK); |
- result->Add(argument); |
+ result->Add(argument, zone()); |
if (result->length() > kMaxNumFunctionParameters) { |
ReportMessageAt(scanner().location(), "too_many_arguments", |
Vector<const char*>::empty()); |
@@ -4585,7 +4599,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name, |
} |
if (!is_lazily_compiled) { |
- body = new(zone()) ZoneList<Statement*>(8); |
+ body = new(zone()) ZoneList<Statement*>(8, zone()); |
if (fvar != NULL) { |
VariableProxy* fproxy = |
top_scope_->NewUnresolved(factory(), function_name); |
@@ -4594,7 +4608,8 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name, |
factory()->NewAssignment(fvar_init_op, |
fproxy, |
factory()->NewThisFunction(), |
- RelocInfo::kNoPosition))); |
+ RelocInfo::kNoPosition)), |
+ zone()); |
} |
ParseSourceElements(body, Token::RBRACE, false, CHECK_OK); |
@@ -4993,7 +5008,7 @@ void Parser::RegisterTargetUse(Label* target, Target* stop) { |
// the break target to any TargetCollectors passed on the stack. |
for (Target* t = target_stack_; t != stop; t = t->previous()) { |
TargetCollector* collector = t->node()->AsTargetCollector(); |
- if (collector != NULL) collector->AddTarget(target); |
+ if (collector != NULL) collector->AddTarget(target, zone()); |
} |
} |
@@ -5040,9 +5055,9 @@ Expression* Parser::NewThrowError(Handle<String> constructor, |
Handle<JSArray> array = isolate()->factory()->NewJSArrayWithElements( |
elements, FAST_ELEMENTS, TENURED); |
- ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2); |
- args->Add(factory()->NewLiteral(type)); |
- args->Add(factory()->NewLiteral(array)); |
+ ZoneList<Expression*>* args = new(zone()) ZoneList<Expression*>(2, zone()); |
+ args->Add(factory()->NewLiteral(type), zone()); |
+ args->Add(factory()->NewLiteral(array), zone()); |
CallRuntime* call_constructor = |
factory()->NewCallRuntime(constructor, NULL, args); |
return factory()->NewThrow(call_constructor, scanner().location().beg_pos); |
@@ -5236,8 +5251,8 @@ RegExpTree* RegExpParser::ParseDisjunction() { |
Advance(); |
// everything except \x0a, \x0d, \u2028 and \u2029 |
ZoneList<CharacterRange>* ranges = |
- new(zone()) ZoneList<CharacterRange>(2); |
- CharacterRange::AddClassEscape('.', ranges); |
+ new(zone()) ZoneList<CharacterRange>(2, zone()); |
+ CharacterRange::AddClassEscape('.', ranges, zone()); |
RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false); |
builder->AddAtom(atom); |
break; |
@@ -5263,12 +5278,12 @@ RegExpTree* RegExpParser::ParseDisjunction() { |
Advance(2); |
} else { |
if (captures_ == NULL) { |
- captures_ = new(zone()) ZoneList<RegExpCapture*>(2); |
+ captures_ = new(zone()) ZoneList<RegExpCapture*>(2, zone()); |
} |
if (captures_started() >= kMaxCaptures) { |
ReportError(CStrVector("Too many captures") CHECK_FAILED); |
} |
- captures_->Add(NULL); |
+ captures_->Add(NULL, zone()); |
} |
// Store current state and begin new disjunction parsing. |
stored_state = new(zone()) RegExpParserState(stored_state, type, |
@@ -5306,8 +5321,8 @@ RegExpTree* RegExpParser::ParseDisjunction() { |
uc32 c = Next(); |
Advance(2); |
ZoneList<CharacterRange>* ranges = |
- new(zone()) ZoneList<CharacterRange>(2); |
- CharacterRange::AddClassEscape(c, ranges); |
+ new(zone()) ZoneList<CharacterRange>(2, zone()); |
+ CharacterRange::AddClassEscape(c, ranges, zone()); |
RegExpTree* atom = new(zone()) RegExpCharacterClass(ranges, false); |
builder->AddAtom(atom); |
break; |
@@ -5782,11 +5797,12 @@ static const uc16 kNoCharClass = 0; |
// escape (i.e., 's' means whitespace, from '\s'). |
static inline void AddRangeOrEscape(ZoneList<CharacterRange>* ranges, |
uc16 char_class, |
- CharacterRange range) { |
+ CharacterRange range, |
+ Zone* zone) { |
if (char_class != kNoCharClass) { |
- CharacterRange::AddClassEscape(char_class, ranges); |
+ CharacterRange::AddClassEscape(char_class, ranges, zone); |
} else { |
- ranges->Add(range); |
+ ranges->Add(range, zone); |
} |
} |
@@ -5802,7 +5818,8 @@ RegExpTree* RegExpParser::ParseCharacterClass() { |
is_negated = true; |
Advance(); |
} |
- ZoneList<CharacterRange>* ranges = new(zone()) ZoneList<CharacterRange>(2); |
+ ZoneList<CharacterRange>* ranges = |
+ new(zone()) ZoneList<CharacterRange>(2, zone()); |
while (has_more() && current() != ']') { |
uc16 char_class = kNoCharClass; |
CharacterRange first = ParseClassAtom(&char_class CHECK_FAILED); |
@@ -5813,25 +5830,25 @@ RegExpTree* RegExpParser::ParseCharacterClass() { |
// following code report an error. |
break; |
} else if (current() == ']') { |
- AddRangeOrEscape(ranges, char_class, first); |
- ranges->Add(CharacterRange::Singleton('-')); |
+ AddRangeOrEscape(ranges, char_class, first, zone()); |
+ ranges->Add(CharacterRange::Singleton('-'), zone()); |
break; |
} |
uc16 char_class_2 = kNoCharClass; |
CharacterRange next = ParseClassAtom(&char_class_2 CHECK_FAILED); |
if (char_class != kNoCharClass || char_class_2 != kNoCharClass) { |
// Either end is an escaped character class. Treat the '-' verbatim. |
- AddRangeOrEscape(ranges, char_class, first); |
- ranges->Add(CharacterRange::Singleton('-')); |
- AddRangeOrEscape(ranges, char_class_2, next); |
+ AddRangeOrEscape(ranges, char_class, first, zone()); |
+ ranges->Add(CharacterRange::Singleton('-'), zone()); |
+ AddRangeOrEscape(ranges, char_class_2, next, zone()); |
continue; |
} |
if (first.from() > next.to()) { |
return ReportError(CStrVector(kRangeOutOfOrder) CHECK_FAILED); |
} |
- ranges->Add(CharacterRange::Range(first.from(), next.to())); |
+ ranges->Add(CharacterRange::Range(first.from(), next.to()), zone()); |
} else { |
- AddRangeOrEscape(ranges, char_class, first); |
+ AddRangeOrEscape(ranges, char_class, first, zone()); |
} |
} |
if (!has_more()) { |
@@ -5839,7 +5856,7 @@ RegExpTree* RegExpParser::ParseCharacterClass() { |
} |
Advance(); |
if (ranges->length() == 0) { |
- ranges->Add(CharacterRange::Everything()); |
+ ranges->Add(CharacterRange::Everything(), zone()); |
is_negated = !is_negated; |
} |
return new(zone()) RegExpCharacterClass(ranges, is_negated); |