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/ast/ast.h

Issue 2205013002: Revert of Put Scopes into temporary Zone (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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 | « no previous file | src/ast/ast.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast.h
diff --git a/src/ast/ast.h b/src/ast/ast.h
index 85f15fb2d0a00a32a1959f49acf482711fcaebf8..19e530c915912f5df9a28ca6581df7b6d8cc40d0 100644
--- a/src/ast/ast.h
+++ b/src/ast/ast.h
@@ -1690,7 +1690,6 @@
VariableProxy(Zone* zone, const AstRawString* name,
Variable::Kind variable_kind, int start_position,
int end_position);
- VariableProxy(Zone* zone, const VariableProxy* copy_from);
static int parent_num_ids() { return Expression::num_ids(); }
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
@@ -3044,22 +3043,27 @@
class AstNodeFactory final BASE_EMBEDDED {
public:
explicit AstNodeFactory(AstValueFactory* ast_value_factory)
- : zone_(nullptr), ast_value_factory_(ast_value_factory) {
+ : local_zone_(nullptr),
+ parser_zone_(nullptr),
+ ast_value_factory_(ast_value_factory) {
if (ast_value_factory != nullptr) {
- zone_ = ast_value_factory->zone();
+ local_zone_ = ast_value_factory->zone();
+ parser_zone_ = ast_value_factory->zone();
}
}
AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
void set_ast_value_factory(AstValueFactory* ast_value_factory) {
ast_value_factory_ = ast_value_factory;
- zone_ = ast_value_factory->zone();
+ local_zone_ = ast_value_factory->zone();
+ parser_zone_ = ast_value_factory->zone();
}
VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy,
VariableMode mode, Scope* scope,
int pos) {
- return new (zone_) VariableDeclaration(zone_, proxy, mode, scope, pos);
+ return new (parser_zone_)
+ VariableDeclaration(parser_zone_, proxy, mode, scope, pos);
}
FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy,
@@ -3067,18 +3071,19 @@
FunctionLiteral* fun,
Scope* scope,
int pos) {
- return new (zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos);
+ return new (parser_zone_)
+ FunctionDeclaration(parser_zone_, proxy, mode, fun, scope, pos);
}
Block* NewBlock(ZoneList<const AstRawString*>* labels, int capacity,
bool ignore_completion_value, int pos) {
- return new (zone_)
- Block(zone_, labels, capacity, ignore_completion_value, pos);
+ return new (local_zone_)
+ Block(local_zone_, labels, capacity, ignore_completion_value, pos);
}
#define STATEMENT_WITH_LABELS(NodeType) \
NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \
- return new (zone_) NodeType(zone_, labels, pos); \
+ return new (local_zone_) NodeType(local_zone_, labels, pos); \
}
STATEMENT_WITH_LABELS(DoWhileStatement)
STATEMENT_WITH_LABELS(WhileStatement)
@@ -3091,10 +3096,10 @@
int pos) {
switch (visit_mode) {
case ForEachStatement::ENUMERATE: {
- return new (zone_) ForInStatement(zone_, labels, pos);
+ return new (local_zone_) ForInStatement(local_zone_, labels, pos);
}
case ForEachStatement::ITERATE: {
- return new (zone_) ForOfStatement(zone_, labels, pos);
+ return new (local_zone_) ForOfStatement(local_zone_, labels, pos);
}
}
UNREACHABLE();
@@ -3102,41 +3107,42 @@
}
ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) {
- return new (zone_) ExpressionStatement(zone_, expression, pos);
+ return new (local_zone_) ExpressionStatement(local_zone_, expression, pos);
}
ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) {
- return new (zone_) ContinueStatement(zone_, target, pos);
+ return new (local_zone_) ContinueStatement(local_zone_, target, pos);
}
BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) {
- return new (zone_) BreakStatement(zone_, target, pos);
+ return new (local_zone_) BreakStatement(local_zone_, target, pos);
}
ReturnStatement* NewReturnStatement(Expression* expression, int pos) {
- return new (zone_) ReturnStatement(zone_, expression, pos);
+ return new (local_zone_) ReturnStatement(local_zone_, expression, pos);
}
WithStatement* NewWithStatement(Scope* scope,
Expression* expression,
Statement* statement,
int pos) {
- return new (zone_) WithStatement(zone_, scope, expression, statement, pos);
+ return new (local_zone_)
+ WithStatement(local_zone_, scope, expression, statement, pos);
}
IfStatement* NewIfStatement(Expression* condition,
Statement* then_statement,
Statement* else_statement,
int pos) {
- return new (zone_)
- IfStatement(zone_, condition, then_statement, else_statement, pos);
+ return new (local_zone_) IfStatement(local_zone_, condition, then_statement,
+ else_statement, pos);
}
TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope,
Variable* variable,
Block* catch_block, int pos) {
- return new (zone_)
- TryCatchStatement(zone_, try_block, scope, variable, catch_block,
+ return new (local_zone_)
+ TryCatchStatement(local_zone_, try_block, scope, variable, catch_block,
HandlerTable::CAUGHT, pos);
}
@@ -3145,8 +3151,8 @@
Variable* variable,
Block* catch_block,
int pos) {
- return new (zone_)
- TryCatchStatement(zone_, try_block, scope, variable, catch_block,
+ return new (local_zone_)
+ TryCatchStatement(local_zone_, try_block, scope, variable, catch_block,
HandlerTable::UNCAUGHT, pos);
}
@@ -3155,81 +3161,88 @@
Variable* variable,
Block* catch_block,
int pos) {
- return new (zone_)
- TryCatchStatement(zone_, try_block, scope, variable, catch_block,
+ return new (local_zone_)
+ TryCatchStatement(local_zone_, try_block, scope, variable, catch_block,
HandlerTable::PROMISE, pos);
}
TryFinallyStatement* NewTryFinallyStatement(Block* try_block,
Block* finally_block, int pos) {
- return new (zone_)
- TryFinallyStatement(zone_, try_block, finally_block, pos);
+ return new (local_zone_)
+ TryFinallyStatement(local_zone_, try_block, finally_block, pos);
}
DebuggerStatement* NewDebuggerStatement(int pos) {
- return new (zone_) DebuggerStatement(zone_, pos);
+ return new (local_zone_) DebuggerStatement(local_zone_, pos);
}
EmptyStatement* NewEmptyStatement(int pos) {
- return new (zone_) EmptyStatement(zone_, pos);
+ return new (local_zone_) EmptyStatement(local_zone_, pos);
}
SloppyBlockFunctionStatement* NewSloppyBlockFunctionStatement(
Statement* statement, Scope* scope) {
- return new (zone_) SloppyBlockFunctionStatement(zone_, statement, scope);
+ return new (parser_zone_)
+ SloppyBlockFunctionStatement(parser_zone_, statement, scope);
}
CaseClause* NewCaseClause(
Expression* label, ZoneList<Statement*>* statements, int pos) {
- return new (zone_) CaseClause(zone_, label, statements, pos);
+ return new (local_zone_) CaseClause(local_zone_, label, statements, pos);
}
Literal* NewStringLiteral(const AstRawString* string, int pos) {
- return new (zone_)
- Literal(zone_, ast_value_factory_->NewString(string), pos);
+ return new (local_zone_)
+ Literal(local_zone_, ast_value_factory_->NewString(string), pos);
}
// A JavaScript symbol (ECMA-262 edition 6).
Literal* NewSymbolLiteral(const char* name, int pos) {
- return new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos);
+ return new (local_zone_)
+ Literal(local_zone_, ast_value_factory_->NewSymbol(name), pos);
}
Literal* NewNumberLiteral(double number, int pos, bool with_dot = false) {
- return new (zone_)
- Literal(zone_, ast_value_factory_->NewNumber(number, with_dot), pos);
+ return new (local_zone_) Literal(
+ local_zone_, ast_value_factory_->NewNumber(number, with_dot), pos);
}
Literal* NewSmiLiteral(int number, int pos) {
- return new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos);
+ return new (local_zone_)
+ Literal(local_zone_, ast_value_factory_->NewSmi(number), pos);
}
Literal* NewBooleanLiteral(bool b, int pos) {
- return new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos);
+ return new (local_zone_)
+ Literal(local_zone_, ast_value_factory_->NewBoolean(b), pos);
}
Literal* NewNullLiteral(int pos) {
- return new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos);
+ return new (local_zone_)
+ Literal(local_zone_, ast_value_factory_->NewNull(), pos);
}
Literal* NewUndefinedLiteral(int pos) {
- return new (zone_) Literal(zone_, ast_value_factory_->NewUndefined(), pos);
+ return new (local_zone_)
+ Literal(local_zone_, ast_value_factory_->NewUndefined(), pos);
}
Literal* NewTheHoleLiteral(int pos) {
- return new (zone_) Literal(zone_, ast_value_factory_->NewTheHole(), pos);
+ return new (local_zone_)
+ Literal(local_zone_, ast_value_factory_->NewTheHole(), pos);
}
ObjectLiteral* NewObjectLiteral(
ZoneList<ObjectLiteral::Property*>* properties, int literal_index,
uint32_t boilerplate_properties, int pos) {
- return new (zone_) ObjectLiteral(zone_, properties, literal_index,
- boilerplate_properties, pos);
+ return new (local_zone_) ObjectLiteral(
+ local_zone_, properties, literal_index, boilerplate_properties, pos);
}
ObjectLiteral::Property* NewObjectLiteralProperty(
Expression* key, Expression* value, ObjectLiteralProperty::Kind kind,
bool is_static, bool is_computed_name) {
- return new (zone_)
+ return new (local_zone_)
ObjectLiteral::Property(key, value, kind, is_static, is_computed_name);
}
@@ -3237,32 +3250,35 @@
Expression* value,
bool is_static,
bool is_computed_name) {
- return new (zone_) ObjectLiteral::Property(ast_value_factory_, key, value,
- is_static, is_computed_name);
+ return new (local_zone_) ObjectLiteral::Property(
+ ast_value_factory_, key, value, is_static, is_computed_name);
}
RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, int flags,
int literal_index, int pos) {
- return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos);
+ return new (local_zone_)
+ RegExpLiteral(local_zone_, pattern, flags, literal_index, pos);
}
ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
int literal_index,
int pos) {
- return new (zone_) ArrayLiteral(zone_, values, -1, literal_index, pos);
+ return new (local_zone_)
+ ArrayLiteral(local_zone_, values, -1, literal_index, pos);
}
ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
int first_spread_index, int literal_index,
int pos) {
- return new (zone_)
- ArrayLiteral(zone_, values, first_spread_index, literal_index, pos);
+ return new (local_zone_) ArrayLiteral(
+ local_zone_, values, first_spread_index, literal_index, pos);
}
VariableProxy* NewVariableProxy(Variable* var,
int start_position = kNoSourcePosition,
int end_position = kNoSourcePosition) {
- return new (zone_) VariableProxy(zone_, var, start_position, end_position);
+ return new (parser_zone_)
+ VariableProxy(parser_zone_, var, start_position, end_position);
}
VariableProxy* NewVariableProxy(const AstRawString* name,
@@ -3270,89 +3286,87 @@
int start_position = kNoSourcePosition,
int end_position = kNoSourcePosition) {
DCHECK_NOT_NULL(name);
- return new (zone_)
- VariableProxy(zone_, name, variable_kind, start_position, end_position);
- }
-
- // Recreates the VariableProxy in this Zone.
- VariableProxy* CopyVariableProxy(VariableProxy* proxy) {
- return new (zone_) VariableProxy(zone_, proxy);
+ return new (parser_zone_) VariableProxy(parser_zone_, name, variable_kind,
+ start_position, end_position);
}
Property* NewProperty(Expression* obj, Expression* key, int pos) {
- return new (zone_) Property(zone_, obj, key, pos);
+ return new (local_zone_) Property(local_zone_, obj, key, pos);
}
Call* NewCall(Expression* expression,
ZoneList<Expression*>* arguments,
int pos) {
- return new (zone_) Call(zone_, expression, arguments, pos);
+ return new (local_zone_) Call(local_zone_, expression, arguments, pos);
}
CallNew* NewCallNew(Expression* expression,
ZoneList<Expression*>* arguments,
int pos) {
- return new (zone_) CallNew(zone_, expression, arguments, pos);
+ return new (local_zone_) CallNew(local_zone_, expression, arguments, pos);
}
CallRuntime* NewCallRuntime(Runtime::FunctionId id,
ZoneList<Expression*>* arguments, int pos) {
- return new (zone_)
- CallRuntime(zone_, Runtime::FunctionForId(id), arguments, pos);
+ return new (local_zone_)
+ CallRuntime(local_zone_, Runtime::FunctionForId(id), arguments, pos);
}
CallRuntime* NewCallRuntime(const Runtime::Function* function,
ZoneList<Expression*>* arguments, int pos) {
- return new (zone_) CallRuntime(zone_, function, arguments, pos);
+ return new (local_zone_) CallRuntime(local_zone_, function, arguments, pos);
}
CallRuntime* NewCallRuntime(int context_index,
ZoneList<Expression*>* arguments, int pos) {
- return new (zone_) CallRuntime(zone_, context_index, arguments, pos);
+ return new (local_zone_)
+ CallRuntime(local_zone_, context_index, arguments, pos);
}
UnaryOperation* NewUnaryOperation(Token::Value op,
Expression* expression,
int pos) {
- return new (zone_) UnaryOperation(zone_, op, expression, pos);
+ return new (local_zone_) UnaryOperation(local_zone_, op, expression, pos);
}
BinaryOperation* NewBinaryOperation(Token::Value op,
Expression* left,
Expression* right,
int pos) {
- return new (zone_) BinaryOperation(zone_, op, left, right, pos);
+ return new (local_zone_) BinaryOperation(local_zone_, op, left, right, pos);
}
CountOperation* NewCountOperation(Token::Value op,
bool is_prefix,
Expression* expr,
int pos) {
- return new (zone_) CountOperation(zone_, op, is_prefix, expr, pos);
+ return new (local_zone_)
+ CountOperation(local_zone_, op, is_prefix, expr, pos);
}
CompareOperation* NewCompareOperation(Token::Value op,
Expression* left,
Expression* right,
int pos) {
- return new (zone_) CompareOperation(zone_, op, left, right, pos);
+ return new (local_zone_)
+ CompareOperation(local_zone_, op, left, right, pos);
}
Spread* NewSpread(Expression* expression, int pos, int expr_pos) {
- return new (zone_) Spread(zone_, expression, pos, expr_pos);
+ return new (local_zone_) Spread(local_zone_, expression, pos, expr_pos);
}
Conditional* NewConditional(Expression* condition,
Expression* then_expression,
Expression* else_expression,
int position) {
- return new (zone_) Conditional(zone_, condition, then_expression,
- else_expression, position);
+ return new (local_zone_) Conditional(
+ local_zone_, condition, then_expression, else_expression, position);
}
RewritableExpression* NewRewritableExpression(Expression* expression) {
DCHECK_NOT_NULL(expression);
- return new (zone_) RewritableExpression(zone_, expression);
+ return new (local_zone_) RewritableExpression(local_zone_, expression);
}
Assignment* NewAssignment(Token::Value op,
@@ -3360,7 +3374,8 @@
Expression* value,
int pos) {
DCHECK(Token::IsAssignmentOp(op));
- Assignment* assign = new (zone_) Assignment(zone_, op, target, value, pos);
+ Assignment* assign =
+ new (local_zone_) Assignment(local_zone_, op, target, value, pos);
if (assign->is_compound()) {
DCHECK(Token::IsAssignmentOp(op));
assign->binary_operation_ =
@@ -3372,12 +3387,12 @@
Yield* NewYield(Expression* generator_object, Expression* expression, int pos,
Yield::OnException on_exception) {
if (!expression) expression = NewUndefinedLiteral(pos);
- return new (zone_)
- Yield(zone_, generator_object, expression, pos, on_exception);
+ return new (local_zone_)
+ Yield(local_zone_, generator_object, expression, pos, on_exception);
}
Throw* NewThrow(Expression* exception, int pos) {
- return new (zone_) Throw(zone_, exception, pos);
+ return new (local_zone_) Throw(local_zone_, exception, pos);
}
FunctionLiteral* NewFunctionLiteral(
@@ -3388,8 +3403,8 @@
FunctionLiteral::FunctionType function_type,
FunctionLiteral::EagerCompileHint eager_compile_hint, FunctionKind kind,
int position) {
- return new (zone_) FunctionLiteral(
- zone_, name, ast_value_factory_, scope, body,
+ return new (local_zone_) FunctionLiteral(
+ local_zone_, name, ast_value_factory_, scope, body,
materialized_literal_count, expected_property_count, parameter_count,
function_type, has_duplicate_parameters, eager_compile_hint, kind,
position, true);
@@ -3401,9 +3416,9 @@
FunctionLiteral* NewScriptOrEvalFunctionLiteral(
Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count,
int expected_property_count) {
- return new (zone_) FunctionLiteral(
- zone_, ast_value_factory_->empty_string(), ast_value_factory_, scope,
- body, materialized_literal_count, expected_property_count, 0,
+ return new (local_zone_) FunctionLiteral(
+ local_zone_, ast_value_factory_->empty_string(), ast_value_factory_,
+ scope, body, materialized_literal_count, expected_property_count, 0,
FunctionLiteral::kAnonymousExpression,
FunctionLiteral::kNoDuplicateParameters,
FunctionLiteral::kShouldLazyCompile, FunctionKind::kNormalFunction, 0,
@@ -3414,58 +3429,59 @@
FunctionLiteral* constructor,
ZoneList<ObjectLiteral::Property*>* properties,
int start_position, int end_position) {
- return new (zone_) ClassLiteral(zone_, proxy, extends, constructor,
- properties, start_position, end_position);
+ return new (local_zone_)
+ ClassLiteral(local_zone_, proxy, extends, constructor, properties,
+ start_position, end_position);
}
NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
v8::Extension* extension,
int pos) {
- return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos);
+ return new (local_zone_)
+ NativeFunctionLiteral(local_zone_, name, extension, pos);
}
DoExpression* NewDoExpression(Block* block, Variable* result_var, int pos) {
VariableProxy* result = NewVariableProxy(result_var, pos);
- return new (zone_) DoExpression(zone_, block, result, pos);
+ return new (local_zone_) DoExpression(local_zone_, block, result, pos);
}
ThisFunction* NewThisFunction(int pos) {
- return new (zone_) ThisFunction(zone_, pos);
+ return new (local_zone_) ThisFunction(local_zone_, pos);
}
SuperPropertyReference* NewSuperPropertyReference(VariableProxy* this_var,
Expression* home_object,
int pos) {
- return new (zone_)
- SuperPropertyReference(zone_, this_var, home_object, pos);
+ return new (local_zone_)
+ SuperPropertyReference(local_zone_, this_var, home_object, pos);
}
SuperCallReference* NewSuperCallReference(VariableProxy* this_var,
VariableProxy* new_target_var,
VariableProxy* this_function_var,
int pos) {
- return new (zone_) SuperCallReference(zone_, this_var, new_target_var,
- this_function_var, pos);
+ return new (local_zone_) SuperCallReference(
+ local_zone_, this_var, new_target_var, this_function_var, pos);
}
EmptyParentheses* NewEmptyParentheses(int pos) {
- return new (zone_) EmptyParentheses(zone_, pos);
- }
-
- Zone* zone() const { return zone_; }
- void set_zone(Zone* zone) { zone_ = zone; }
+ return new (local_zone_) EmptyParentheses(local_zone_, pos);
+ }
+
+ Zone* zone() const { return local_zone_; }
// Handles use of temporary zones when parsing inner function bodies.
class BodyScope {
public:
BodyScope(AstNodeFactory* factory, Zone* temp_zone, bool use_temp_zone)
- : factory_(factory), prev_zone_(factory->zone_) {
+ : factory_(factory), prev_zone_(factory->local_zone_) {
if (use_temp_zone) {
- factory->zone_ = temp_zone;
+ factory->local_zone_ = temp_zone;
}
}
- ~BodyScope() { factory_->zone_ = prev_zone_; }
+ ~BodyScope() { factory_->local_zone_ = prev_zone_; }
private:
AstNodeFactory* factory_;
@@ -3477,7 +3493,10 @@
// which we can guarantee is not going to be compiled or have its AST
// inspected.
// See ParseFunctionLiteral in parser.cc for preconditions.
- Zone* zone_;
+ Zone* local_zone_;
+ // ZoneObjects which need to persist until scope analysis must be allocated in
+ // the parser-level zone.
+ Zone* parser_zone_;
AstValueFactory* ast_value_factory_;
};
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698