Commit f3e9edd1 authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[zone] Cleanup zone allocations in src/ast and tests

... by migrating old-style code
  MyObject* obj = new (zone) MyObject(...)

to the new style
  MyObject* obj = zone->New<MyObject>(...)

Bug: v8:10689
Change-Id: I79fc4f9793a0c7a3bd38230ca4e23d33344fc1b2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2288863Reviewed-by: 's avatarSathya Gunasekaran  <gsathya@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68792}
parent e4f5f23b
......@@ -268,21 +268,21 @@ AstStringConstants::AstStringConstants(Isolate* isolate, uint64_t hash_seed)
string_table_(AstRawString::Compare),
hash_seed_(hash_seed) {
DCHECK_EQ(ThreadId::Current(), isolate->thread_id());
#define F(name, str) \
{ \
const char* data = str; \
Vector<const uint8_t> literal(reinterpret_cast<const uint8_t*>(data), \
static_cast<int>(strlen(data))); \
uint32_t hash_field = StringHasher::HashSequentialString<uint8_t>( \
literal.begin(), literal.length(), hash_seed_); \
name##_string_ = new (&zone_) AstRawString(true, literal, hash_field); \
/* The Handle returned by the factory is located on the roots */ \
/* array, not on the temporary HandleScope, so this is safe. */ \
name##_string_->set_string(isolate->factory()->name##_string()); \
base::HashMap::Entry* entry = \
string_table_.InsertNew(name##_string_, name##_string_->Hash()); \
DCHECK_NULL(entry->value); \
entry->value = reinterpret_cast<void*>(1); \
#define F(name, str) \
{ \
const char* data = str; \
Vector<const uint8_t> literal(reinterpret_cast<const uint8_t*>(data), \
static_cast<int>(strlen(data))); \
uint32_t hash_field = StringHasher::HashSequentialString<uint8_t>( \
literal.begin(), literal.length(), hash_seed_); \
name##_string_ = zone_.New<AstRawString>(true, literal, hash_field); \
/* The Handle returned by the factory is located on the roots */ \
/* array, not on the temporary HandleScope, so this is safe. */ \
name##_string_->set_string(isolate->factory()->name##_string()); \
base::HashMap::Entry* entry = \
string_table_.InsertNew(name##_string_, name##_string_->Hash()); \
DCHECK_NULL(entry->value); \
entry->value = reinterpret_cast<void*>(1); \
}
AST_STRING_CONSTANTS(F)
#undef F
......@@ -333,7 +333,7 @@ const AstRawString* AstValueFactory::CloneFromOtherFactory(
}
AstConsString* AstValueFactory::NewConsString() {
return new (zone()) AstConsString;
return zone()->New<AstConsString>();
}
AstConsString* AstValueFactory::NewConsString(const AstRawString* str) {
......@@ -379,7 +379,7 @@ AstRawString* AstValueFactory::GetString(uint32_t hash_field, bool is_one_byte,
int length = literal_bytes.length();
byte* new_literal_bytes = zone()->NewArray<byte>(length);
memcpy(new_literal_bytes, literal_bytes.begin(), length);
AstRawString* new_string = new (zone()) AstRawString(
AstRawString* new_string = zone()->New<AstRawString>(
is_one_byte, Vector<const byte>(new_literal_bytes, length), hash_field);
CHECK_NOT_NULL(new_string);
AddString(new_string);
......
......@@ -83,6 +83,7 @@ class AstRawString final : public ZoneObject {
friend class AstRawStringInternalizationKey;
friend class AstStringConstants;
friend class AstValueFactory;
friend Zone;
// Members accessed only by the AstValueFactory & related classes:
static bool Compare(void* a, void* b);
......@@ -133,8 +134,7 @@ class AstConsString final : public ZoneObject {
if (!IsEmpty()) {
// We're putting the new string to the head of the list, meaning
// the string segments will be in reverse order.
Segment* tmp = new (zone->New(sizeof(Segment))) Segment;
*tmp = segment_;
Segment* tmp = zone->New<Segment>(segment_);
segment_.next = tmp;
}
segment_.string = s;
......@@ -163,6 +163,7 @@ class AstConsString final : public ZoneObject {
private:
friend class AstValueFactory;
friend Zone;
AstConsString() : string_(), segment_({nullptr, nullptr}) {}
......
......@@ -1063,7 +1063,7 @@ Literal* AstNodeFactory::NewNumberLiteral(double number, int pos) {
if (DoubleToSmiInteger(number, &int_value)) {
return NewSmiLiteral(int_value, pos);
}
return new (zone_) Literal(number, pos);
return zone_->New<Literal>(number, pos);
}
const char* CallRuntime::debug_name() {
......
......@@ -144,8 +144,6 @@ class AstNode: public ZoneObject {
};
#undef DECLARE_TYPE_ENUM
void* operator new(size_t size, Zone* zone) { return zone->New(size); }
NodeType node_type() const { return NodeTypeField::decode(bit_field_); }
int position() const { return position_; }
......@@ -166,10 +164,6 @@ class AstNode: public ZoneObject {
MaterializedLiteral* AsMaterializedLiteral();
private:
// Hidden to prevent accidental usage. It would have to load the
// current zone from the TLS.
void* operator new(size_t size);
int position_;
using NodeTypeField = base::BitField<NodeType, 0, 6>;
......@@ -290,6 +284,7 @@ class Expression : public AstNode {
class FailureExpression : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
FailureExpression() : Expression(kNoSourcePosition, kFailureExpression) {}
};
......@@ -330,6 +325,7 @@ class Block final : public BreakableStatement {
private:
friend class AstNodeFactory;
friend Zone;
ZonePtrList<Statement> statements_;
Scope* scope_;
......@@ -376,6 +372,7 @@ class VariableDeclaration : public Declaration {
private:
friend class AstNodeFactory;
friend Zone;
using IsNestedField = Declaration::NextBitField<bool, 1>;
......@@ -398,6 +395,7 @@ class NestedVariableDeclaration final : public VariableDeclaration {
private:
friend class AstNodeFactory;
friend Zone;
NestedVariableDeclaration(Scope* scope, int pos)
: VariableDeclaration(pos, true), scope_(scope) {}
......@@ -418,6 +416,7 @@ class FunctionDeclaration final : public Declaration {
private:
friend class AstNodeFactory;
friend Zone;
FunctionDeclaration(FunctionLiteral* fun, int pos)
: Declaration(pos, kFunctionDeclaration), fun_(fun) {}
......@@ -452,6 +451,7 @@ class DoWhileStatement final : public IterationStatement {
private:
friend class AstNodeFactory;
friend Zone;
explicit DoWhileStatement(int pos)
: IterationStatement(pos, kDoWhileStatement), cond_(nullptr) {}
......@@ -471,6 +471,7 @@ class WhileStatement final : public IterationStatement {
private:
friend class AstNodeFactory;
friend Zone;
explicit WhileStatement(int pos)
: IterationStatement(pos, kWhileStatement), cond_(nullptr) {}
......@@ -495,6 +496,7 @@ class ForStatement final : public IterationStatement {
private:
friend class AstNodeFactory;
friend Zone;
explicit ForStatement(int pos)
: IterationStatement(pos, kForStatement),
......@@ -532,6 +534,7 @@ class ForEachStatement : public IterationStatement {
protected:
friend class AstNodeFactory;
friend Zone;
ForEachStatement(int pos, NodeType type)
: IterationStatement(pos, type), each_(nullptr), subject_(nullptr) {}
......@@ -543,6 +546,7 @@ class ForEachStatement : public IterationStatement {
class ForInStatement final : public ForEachStatement {
private:
friend class AstNodeFactory;
friend Zone;
explicit ForInStatement(int pos) : ForEachStatement(pos, kForInStatement) {}
};
......@@ -554,6 +558,7 @@ class ForOfStatement final : public ForEachStatement {
private:
friend class AstNodeFactory;
friend Zone;
ForOfStatement(int pos, IteratorType type)
: ForEachStatement(pos, kForOfStatement), type_(type) {}
......@@ -568,6 +573,7 @@ class ExpressionStatement final : public Statement {
private:
friend class AstNodeFactory;
friend Zone;
ExpressionStatement(Expression* expression, int pos)
: Statement(pos, kExpressionStatement), expression_(expression) {}
......@@ -588,6 +594,7 @@ class ContinueStatement final : public JumpStatement {
private:
friend class AstNodeFactory;
friend Zone;
ContinueStatement(IterationStatement* target, int pos)
: JumpStatement(pos, kContinueStatement), target_(target) {}
......@@ -602,6 +609,7 @@ class BreakStatement final : public JumpStatement {
private:
friend class AstNodeFactory;
friend Zone;
BreakStatement(BreakableStatement* target, int pos)
: JumpStatement(pos, kBreakStatement), target_(target) {}
......@@ -625,6 +633,7 @@ class ReturnStatement final : public JumpStatement {
private:
friend class AstNodeFactory;
friend Zone;
ReturnStatement(Expression* expression, Type type, int pos, int end_position)
: JumpStatement(pos, kReturnStatement),
......@@ -649,6 +658,7 @@ class WithStatement final : public Statement {
private:
friend class AstNodeFactory;
friend Zone;
WithStatement(Scope* scope, Expression* expression, Statement* statement,
int pos)
......@@ -673,6 +683,7 @@ class CaseClause final : public ZoneObject {
private:
friend class AstNodeFactory;
friend Zone;
CaseClause(Zone* zone, Expression* label,
const ScopedPtrList<Statement>& statements);
......@@ -691,6 +702,7 @@ class SwitchStatement final : public BreakableStatement {
private:
friend class AstNodeFactory;
friend Zone;
SwitchStatement(Zone* zone, Expression* tag, int pos)
: BreakableStatement(pos, kSwitchStatement), tag_(tag), cases_(4, zone) {}
......@@ -719,6 +731,7 @@ class IfStatement final : public Statement {
private:
friend class AstNodeFactory;
friend Zone;
IfStatement(Expression* condition, Statement* then_statement,
Statement* else_statement, int pos)
......@@ -816,6 +829,7 @@ class TryCatchStatement final : public TryStatement {
private:
friend class AstNodeFactory;
friend Zone;
TryCatchStatement(Block* try_block, Scope* scope, Block* catch_block,
HandlerTable::CatchPrediction catch_prediction, int pos)
......@@ -837,6 +851,7 @@ class TryFinallyStatement final : public TryStatement {
private:
friend class AstNodeFactory;
friend Zone;
TryFinallyStatement(Block* try_block, Block* finally_block, int pos)
: TryStatement(try_block, pos, kTryFinallyStatement),
......@@ -849,6 +864,7 @@ class TryFinallyStatement final : public TryStatement {
class DebuggerStatement final : public Statement {
private:
friend class AstNodeFactory;
friend Zone;
explicit DebuggerStatement(int pos) : Statement(pos, kDebuggerStatement) {}
};
......@@ -857,6 +873,7 @@ class DebuggerStatement final : public Statement {
class EmptyStatement final : public Statement {
private:
friend class AstNodeFactory;
friend Zone;
EmptyStatement() : Statement(kNoSourcePosition, kEmptyStatement) {}
};
......@@ -877,6 +894,7 @@ class SloppyBlockFunctionStatement final : public Statement {
private:
friend class AstNodeFactory;
friend Zone;
using TokenField = Statement::NextBitField<Token::Value, 8>;
......@@ -979,6 +997,7 @@ class Literal final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
using TypeField = Expression::NextBitField<Type, 4>;
......@@ -1068,6 +1087,7 @@ class RegExpLiteral final : public MaterializedLiteral {
private:
friend class AstNodeFactory;
friend Zone;
RegExpLiteral(const AstRawString* pattern, int flags, int pos)
: MaterializedLiteral(pos, kRegExpLiteral),
......@@ -1126,6 +1146,7 @@ class AggregateLiteral : public MaterializedLiteral {
protected:
friend class AstNodeFactory;
friend Zone;
AggregateLiteral(int pos, NodeType type)
: MaterializedLiteral(pos, type), depth_(0) {
bit_field_ |=
......@@ -1204,6 +1225,7 @@ class ObjectLiteralProperty final : public LiteralProperty {
private:
friend class AstNodeFactory;
friend Zone;
ObjectLiteralProperty(Expression* key, Expression* value, Kind kind,
bool is_computed_name);
......@@ -1295,6 +1317,7 @@ class ObjectLiteral final : public AggregateLiteral {
private:
friend class AstNodeFactory;
friend Zone;
ObjectLiteral(Zone* zone, const ScopedPtrList<Property>& properties,
uint32_t boilerplate_properties, int pos,
......@@ -1369,6 +1392,7 @@ class ArrayLiteral final : public AggregateLiteral {
private:
friend class AstNodeFactory;
friend Zone;
ArrayLiteral(Zone* zone, const ScopedPtrList<Expression>& values,
int first_spread_index, int pos)
......@@ -1388,6 +1412,7 @@ enum class HoleCheckMode { kRequired, kElided };
class ThisExpression final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
ThisExpression() : Expression(kNoSourcePosition, kThisExpression) {}
};
......@@ -1479,6 +1504,7 @@ class VariableProxy final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
VariableProxy(Variable* var, int start_position);
......@@ -1520,6 +1546,7 @@ class OptionalChain final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
explicit OptionalChain(Expression* expression)
: Expression(0, kOptionalChain), expression_(expression) {}
......@@ -1588,6 +1615,7 @@ class Property final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
Property(Expression* obj, Expression* key, int pos, bool optional_chain)
: Expression(pos, kProperty), obj_(obj), key_(key) {
......@@ -1648,6 +1676,7 @@ class Call final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
Call(Zone* zone, Expression* expression,
const ScopedPtrList<Expression>& arguments, int pos,
......@@ -1694,6 +1723,7 @@ class CallNew final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
CallNew(Zone* zone, Expression* expression,
const ScopedPtrList<Expression>& arguments, int pos)
......@@ -1729,6 +1759,7 @@ class CallRuntime final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
CallRuntime(Zone* zone, const Runtime::Function* function,
const ScopedPtrList<Expression>& arguments, int pos)
......@@ -1759,6 +1790,7 @@ class UnaryOperation final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
UnaryOperation(Token::Value op, Expression* expression, int pos)
: Expression(pos, kUnaryOperation), expression_(expression) {
......@@ -1784,6 +1816,7 @@ class BinaryOperation final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
BinaryOperation(Token::Value op, Expression* left, Expression* right, int pos)
: Expression(pos, kBinaryOperation), left_(left), right_(right) {
......@@ -1816,6 +1849,7 @@ class NaryOperation final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
NaryOperation(Zone* zone, Token::Value op, Expression* first,
size_t initial_subsequent_size)
......@@ -1867,6 +1901,7 @@ class CountOperation final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos)
: Expression(pos, kCountOperation), expression_(expr) {
......@@ -1893,6 +1928,7 @@ class CompareOperation final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
CompareOperation(Token::Value op, Expression* left, Expression* right,
int pos)
......@@ -1916,6 +1952,7 @@ class Spread final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
Spread(Expression* expression, int pos, int expr_pos)
: Expression(pos, kSpread),
......@@ -1934,6 +1971,7 @@ class Conditional final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
Conditional(Expression* condition, Expression* then_expression,
Expression* else_expression, int position)
......@@ -1971,6 +2009,7 @@ class Assignment : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
using TokenField = Expression::NextBitField<Token::Value, 7>;
using LookupHoistingModeField = TokenField::Next<bool, 1>;
......@@ -1985,6 +2024,7 @@ class CompoundAssignment final : public Assignment {
private:
friend class AstNodeFactory;
friend Zone;
CompoundAssignment(Token::Value op, Expression* target, Expression* value,
int pos, BinaryOperation* binary_operation)
......@@ -2019,6 +2059,7 @@ class Suspend : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
friend class Yield;
friend class YieldStar;
friend class Await;
......@@ -2037,6 +2078,7 @@ class Suspend : public Expression {
class Yield final : public Suspend {
private:
friend class AstNodeFactory;
friend Zone;
Yield(Expression* expression, int pos, OnAbruptResume on_abrupt_resume)
: Suspend(kYield, expression, pos, on_abrupt_resume) {}
};
......@@ -2044,6 +2086,7 @@ class Yield final : public Suspend {
class YieldStar final : public Suspend {
private:
friend class AstNodeFactory;
friend Zone;
YieldStar(Expression* expression, int pos)
: Suspend(kYieldStar, expression, pos,
Suspend::OnAbruptResume::kNoControl) {}
......@@ -2052,6 +2095,7 @@ class YieldStar final : public Suspend {
class Await final : public Suspend {
private:
friend class AstNodeFactory;
friend Zone;
Await(Expression* expression, int pos)
: Suspend(kAwait, expression, pos, Suspend::kOnExceptionThrow) {}
......@@ -2063,6 +2107,7 @@ class Throw final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
Throw(Expression* exception, int pos)
: Expression(pos, kThrow), exception_(exception) {}
......@@ -2242,6 +2287,7 @@ class FunctionLiteral final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
FunctionLiteral(Zone* zone, const AstConsString* name,
AstValueFactory* ast_value_factory, DeclarationScope* scope,
......@@ -2348,6 +2394,7 @@ class ClassLiteralProperty final : public LiteralProperty {
private:
friend class AstNodeFactory;
friend Zone;
ClassLiteralProperty(Expression* key, Expression* value, Kind kind,
bool is_static, bool is_computed_name, bool is_private);
......@@ -2366,6 +2413,7 @@ class InitializeClassMembersStatement final : public Statement {
private:
friend class AstNodeFactory;
friend Zone;
InitializeClassMembersStatement(ZonePtrList<Property>* fields, int pos)
: Statement(pos, kInitializeClassMembersStatement), fields_(fields) {}
......@@ -2411,6 +2459,7 @@ class ClassLiteral final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
ClassLiteral(ClassScope* scope, Expression* extends,
FunctionLiteral* constructor,
......@@ -2460,6 +2509,7 @@ class NativeFunctionLiteral final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
NativeFunctionLiteral(const AstRawString* name, v8::Extension* extension,
int pos)
......@@ -2478,6 +2528,7 @@ class SuperPropertyReference final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
// We take in ThisExpression* only as a proof that it was accessed.
SuperPropertyReference(Expression* home_object, int pos)
......@@ -2496,6 +2547,7 @@ class SuperCallReference final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
// We take in ThisExpression* only as a proof that it was accessed.
SuperCallReference(VariableProxy* new_target_var,
......@@ -2519,6 +2571,7 @@ class ImportCallExpression final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
ImportCallExpression(Expression* argument, int pos)
: Expression(pos, kImportCallExpression), argument_(argument) {}
......@@ -2531,6 +2584,7 @@ class ImportCallExpression final : public Expression {
class EmptyParentheses final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
explicit EmptyParentheses(int pos) : Expression(pos, kEmptyParentheses) {
mark_parenthesized();
......@@ -2554,6 +2608,7 @@ class GetTemplateObject final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
GetTemplateObject(const ZonePtrList<const AstRawString>* cooked_strings,
const ZonePtrList<const AstRawString>* raw_strings, int pos)
......@@ -2576,6 +2631,7 @@ class TemplateLiteral final : public Expression {
private:
friend class AstNodeFactory;
friend Zone;
TemplateLiteral(const ZonePtrList<const AstRawString>* parts,
const ZonePtrList<Expression>* substitutions, int pos)
: Expression(pos, kTemplateLiteral),
......@@ -2691,32 +2747,32 @@ class AstNodeFactory final {
AstNodeFactory(AstValueFactory* ast_value_factory, Zone* zone)
: zone_(zone),
ast_value_factory_(ast_value_factory),
empty_statement_(new (zone) class EmptyStatement()),
this_expression_(new (zone) class ThisExpression()),
failure_expression_(new (zone) class FailureExpression()) {}
empty_statement_(zone->New<class EmptyStatement>()),
this_expression_(zone->New<class ThisExpression>()),
failure_expression_(zone->New<class FailureExpression>()) {}
AstNodeFactory* ast_node_factory() { return this; }
AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
VariableDeclaration* NewVariableDeclaration(int pos) {
return new (zone_) VariableDeclaration(pos);
return zone_->New<VariableDeclaration>(pos);
}
NestedVariableDeclaration* NewNestedVariableDeclaration(Scope* scope,
int pos) {
return new (zone_) NestedVariableDeclaration(scope, pos);
return zone_->New<NestedVariableDeclaration>(scope, pos);
}
FunctionDeclaration* NewFunctionDeclaration(FunctionLiteral* fun, int pos) {
return new (zone_) FunctionDeclaration(fun, pos);
return zone_->New<FunctionDeclaration>(fun, pos);
}
Block* NewBlock(int capacity, bool ignore_completion_value) {
return new (zone_) Block(zone_, capacity, ignore_completion_value, false);
return zone_->New<Block>(zone_, capacity, ignore_completion_value, false);
}
Block* NewBlock(bool ignore_completion_value, bool is_breakable) {
return new (zone_) Block(ignore_completion_value, is_breakable);
return zone_->New<Block>(ignore_completion_value, is_breakable);
}
Block* NewBlock(bool ignore_completion_value,
......@@ -2727,60 +2783,60 @@ class AstNodeFactory final {
}
#define STATEMENT_WITH_POSITION(NodeType) \
NodeType* New##NodeType(int pos) { return new (zone_) NodeType(pos); }
NodeType* New##NodeType(int pos) { return zone_->New<NodeType>(pos); }
STATEMENT_WITH_POSITION(DoWhileStatement)
STATEMENT_WITH_POSITION(WhileStatement)
STATEMENT_WITH_POSITION(ForStatement)
#undef STATEMENT_WITH_POSITION
SwitchStatement* NewSwitchStatement(Expression* tag, int pos) {
return new (zone_) SwitchStatement(zone_, tag, pos);
return zone_->New<SwitchStatement>(zone_, tag, pos);
}
ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode,
int pos) {
switch (visit_mode) {
case ForEachStatement::ENUMERATE: {
return new (zone_) ForInStatement(pos);
return zone_->New<ForInStatement>(pos);
}
case ForEachStatement::ITERATE: {
return new (zone_) ForOfStatement(pos, IteratorType::kNormal);
return zone_->New<ForOfStatement>(pos, IteratorType::kNormal);
}
}
UNREACHABLE();
}
ForOfStatement* NewForOfStatement(int pos, IteratorType type) {
return new (zone_) ForOfStatement(pos, type);
return zone_->New<ForOfStatement>(pos, type);
}
ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) {
return new (zone_) ExpressionStatement(expression, pos);
return zone_->New<ExpressionStatement>(expression, pos);
}
ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) {
return new (zone_) ContinueStatement(target, pos);
return zone_->New<ContinueStatement>(target, pos);
}
BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) {
return new (zone_) BreakStatement(target, pos);
return zone_->New<BreakStatement>(target, pos);
}
ReturnStatement* NewReturnStatement(Expression* expression, int pos,
int end_position = kNoSourcePosition) {
return new (zone_) ReturnStatement(expression, ReturnStatement::kNormal,
return zone_->New<ReturnStatement>(expression, ReturnStatement::kNormal,
pos, end_position);
}
ReturnStatement* NewAsyncReturnStatement(
Expression* expression, int pos, int end_position = kNoSourcePosition) {
return new (zone_) ReturnStatement(
return zone_->New<ReturnStatement>(
expression, ReturnStatement::kAsyncReturn, pos, end_position);
}
ReturnStatement* NewSyntheticAsyncReturnStatement(
Expression* expression, int pos, int end_position = kNoSourcePosition) {
return new (zone_) ReturnStatement(
return zone_->New<ReturnStatement>(
expression, ReturnStatement::kSyntheticAsyncReturn, pos, end_position);
}
......@@ -2788,18 +2844,18 @@ class AstNodeFactory final {
Expression* expression,
Statement* statement,
int pos) {
return new (zone_) WithStatement(scope, expression, statement, pos);
return zone_->New<WithStatement>(scope, expression, statement, pos);
}
IfStatement* NewIfStatement(Expression* condition, Statement* then_statement,
Statement* else_statement, int pos) {
return new (zone_)
IfStatement(condition, then_statement, else_statement, pos);
return zone_->New<IfStatement>(condition, then_statement, else_statement,
pos);
}
TryCatchStatement* NewTryCatchStatement(Block* try_block, Scope* scope,
Block* catch_block, int pos) {
return new (zone_) TryCatchStatement(try_block, scope, catch_block,
return zone_->New<TryCatchStatement>(try_block, scope, catch_block,
HandlerTable::CAUGHT, pos);
}
......@@ -2807,7 +2863,7 @@ class AstNodeFactory final {
Scope* scope,
Block* catch_block,
int pos) {
return new (zone_) TryCatchStatement(try_block, scope, catch_block,
return zone_->New<TryCatchStatement>(try_block, scope, catch_block,
HandlerTable::UNCAUGHT, pos);
}
......@@ -2815,7 +2871,7 @@ class AstNodeFactory final {
Scope* scope,
Block* catch_block,
int pos) {
return new (zone_) TryCatchStatement(try_block, scope, catch_block,
return zone_->New<TryCatchStatement>(try_block, scope, catch_block,
HandlerTable::DESUGARING, pos);
}
......@@ -2823,7 +2879,7 @@ class AstNodeFactory final {
Scope* scope,
Block* catch_block,
int pos) {
return new (zone_) TryCatchStatement(try_block, scope, catch_block,
return zone_->New<TryCatchStatement>(try_block, scope, catch_block,
HandlerTable::ASYNC_AWAIT, pos);
}
......@@ -2831,17 +2887,17 @@ class AstNodeFactory final {
Scope* scope,
Block* catch_block,
int pos) {
return new (zone_) TryCatchStatement(
return zone_->New<TryCatchStatement>(
try_block, scope, catch_block, HandlerTable::UNCAUGHT_ASYNC_AWAIT, pos);
}
TryFinallyStatement* NewTryFinallyStatement(Block* try_block,
Block* finally_block, int pos) {
return new (zone_) TryFinallyStatement(try_block, finally_block, pos);
return zone_->New<TryFinallyStatement>(try_block, finally_block, pos);
}
DebuggerStatement* NewDebuggerStatement(int pos) {
return new (zone_) DebuggerStatement(pos);
return zone_->New<DebuggerStatement>(pos);
}
class EmptyStatement* EmptyStatement() {
......@@ -2865,197 +2921,197 @@ class AstNodeFactory final {
SloppyBlockFunctionStatement* NewSloppyBlockFunctionStatement(
int pos, Variable* var, Token::Value init) {
return new (zone_)
SloppyBlockFunctionStatement(pos, var, init, EmptyStatement());
return zone_->New<SloppyBlockFunctionStatement>(pos, var, init,
EmptyStatement());
}
CaseClause* NewCaseClause(Expression* label,
const ScopedPtrList<Statement>& statements) {
return new (zone_) CaseClause(zone_, label, statements);
return zone_->New<CaseClause>(zone_, label, statements);
}
Literal* NewStringLiteral(const AstRawString* string, int pos) {
DCHECK_NOT_NULL(string);
return new (zone_) Literal(string, pos);
return zone_->New<Literal>(string, pos);
}
// A JavaScript symbol (ECMA-262 edition 6).
Literal* NewSymbolLiteral(AstSymbol symbol, int pos) {
return new (zone_) Literal(symbol, pos);
return zone_->New<Literal>(symbol, pos);
}
Literal* NewNumberLiteral(double number, int pos);
Literal* NewSmiLiteral(int number, int pos) {
return new (zone_) Literal(number, pos);
return zone_->New<Literal>(number, pos);
}
Literal* NewBigIntLiteral(AstBigInt bigint, int pos) {
return new (zone_) Literal(bigint, pos);
return zone_->New<Literal>(bigint, pos);
}
Literal* NewBooleanLiteral(bool b, int pos) {
return new (zone_) Literal(b, pos);
return zone_->New<Literal>(b, pos);
}
Literal* NewNullLiteral(int pos) {
return new (zone_) Literal(Literal::kNull, pos);
return zone_->New<Literal>(Literal::kNull, pos);
}
Literal* NewUndefinedLiteral(int pos) {
return new (zone_) Literal(Literal::kUndefined, pos);
return zone_->New<Literal>(Literal::kUndefined, pos);
}
Literal* NewTheHoleLiteral() {
return new (zone_) Literal(Literal::kTheHole, kNoSourcePosition);
return zone_->New<Literal>(Literal::kTheHole, kNoSourcePosition);
}
ObjectLiteral* NewObjectLiteral(
const ScopedPtrList<ObjectLiteral::Property>& properties,
uint32_t boilerplate_properties, int pos, bool has_rest_property) {
return new (zone_) ObjectLiteral(zone_, properties, boilerplate_properties,
return zone_->New<ObjectLiteral>(zone_, properties, boilerplate_properties,
pos, has_rest_property);
}
ObjectLiteral::Property* NewObjectLiteralProperty(
Expression* key, Expression* value, ObjectLiteralProperty::Kind kind,
bool is_computed_name) {
return new (zone_)
ObjectLiteral::Property(key, value, kind, is_computed_name);
return zone_->New<ObjectLiteral::Property>(key, value, kind,
is_computed_name);
}
ObjectLiteral::Property* NewObjectLiteralProperty(Expression* key,
Expression* value,
bool is_computed_name) {
return new (zone_) ObjectLiteral::Property(ast_value_factory_, key, value,
return zone_->New<ObjectLiteral::Property>(ast_value_factory_, key, value,
is_computed_name);
}
RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, int flags,
int pos) {
return new (zone_) RegExpLiteral(pattern, flags, pos);
return zone_->New<RegExpLiteral>(pattern, flags, pos);
}
ArrayLiteral* NewArrayLiteral(const ScopedPtrList<Expression>& values,
int pos) {
return new (zone_) ArrayLiteral(zone_, values, -1, pos);
return zone_->New<ArrayLiteral>(zone_, values, -1, pos);
}
ArrayLiteral* NewArrayLiteral(const ScopedPtrList<Expression>& values,
int first_spread_index, int pos) {
return new (zone_) ArrayLiteral(zone_, values, first_spread_index, pos);
return zone_->New<ArrayLiteral>(zone_, values, first_spread_index, pos);
}
VariableProxy* NewVariableProxy(Variable* var,
int start_position = kNoSourcePosition) {
return new (zone_) VariableProxy(var, start_position);
return zone_->New<VariableProxy>(var, start_position);
}
VariableProxy* NewVariableProxy(const AstRawString* name,
VariableKind variable_kind,
int start_position = kNoSourcePosition) {
DCHECK_NOT_NULL(name);
return new (zone_) VariableProxy(name, variable_kind, start_position);
return zone_->New<VariableProxy>(name, variable_kind, start_position);
}
// Recreates the VariableProxy in this Zone.
VariableProxy* CopyVariableProxy(VariableProxy* proxy) {
return new (zone_) VariableProxy(proxy);
return zone_->New<VariableProxy>(proxy);
}
Variable* CopyVariable(Variable* variable) {
return new (zone_) Variable(variable);
return zone_->New<Variable>(variable);
}
OptionalChain* NewOptionalChain(Expression* expression) {
return new (zone_) OptionalChain(expression);
return zone_->New<OptionalChain>(expression);
}
Property* NewProperty(Expression* obj, Expression* key, int pos,
bool optional_chain = false) {
return new (zone_) Property(obj, key, pos, optional_chain);
return zone_->New<Property>(obj, key, pos, optional_chain);
}
Call* NewCall(Expression* expression,
const ScopedPtrList<Expression>& arguments, int pos,
Call::PossiblyEval possibly_eval = Call::NOT_EVAL,
bool optional_chain = false) {
return new (zone_)
Call(zone_, expression, arguments, pos, possibly_eval, optional_chain);
return zone_->New<Call>(zone_, expression, arguments, pos, possibly_eval,
optional_chain);
}
Call* NewTaggedTemplate(Expression* expression,
const ScopedPtrList<Expression>& arguments, int pos) {
return new (zone_)
Call(zone_, expression, arguments, pos, Call::TaggedTemplateTag::kTrue);
return zone_->New<Call>(zone_, expression, arguments, pos,
Call::TaggedTemplateTag::kTrue);
}
CallNew* NewCallNew(Expression* expression,
const ScopedPtrList<Expression>& arguments, int pos) {
return new (zone_) CallNew(zone_, expression, arguments, pos);
return zone_->New<CallNew>(zone_, expression, arguments, pos);
}
CallRuntime* NewCallRuntime(Runtime::FunctionId id,
const ScopedPtrList<Expression>& arguments,
int pos) {
return new (zone_)
CallRuntime(zone_, Runtime::FunctionForId(id), arguments, pos);
return zone_->New<CallRuntime>(zone_, Runtime::FunctionForId(id), arguments,
pos);
}
CallRuntime* NewCallRuntime(const Runtime::Function* function,
const ScopedPtrList<Expression>& arguments,
int pos) {
return new (zone_) CallRuntime(zone_, function, arguments, pos);
return zone_->New<CallRuntime>(zone_, function, arguments, pos);
}
CallRuntime* NewCallRuntime(int context_index,
const ScopedPtrList<Expression>& arguments,
int pos) {
return new (zone_) CallRuntime(zone_, context_index, arguments, pos);
return zone_->New<CallRuntime>(zone_, context_index, arguments, pos);
}
UnaryOperation* NewUnaryOperation(Token::Value op,
Expression* expression,
int pos) {
return new (zone_) UnaryOperation(op, expression, pos);
return zone_->New<UnaryOperation>(op, expression, pos);
}
BinaryOperation* NewBinaryOperation(Token::Value op,
Expression* left,
Expression* right,
int pos) {
return new (zone_) BinaryOperation(op, left, right, pos);
return zone_->New<BinaryOperation>(op, left, right, pos);
}
NaryOperation* NewNaryOperation(Token::Value op, Expression* first,
size_t initial_subsequent_size) {
return new (zone_) NaryOperation(zone_, op, first, initial_subsequent_size);
return zone_->New<NaryOperation>(zone_, op, first, initial_subsequent_size);
}
CountOperation* NewCountOperation(Token::Value op,
bool is_prefix,
Expression* expr,
int pos) {
return new (zone_) CountOperation(op, is_prefix, expr, pos);
return zone_->New<CountOperation>(op, is_prefix, expr, pos);
}
CompareOperation* NewCompareOperation(Token::Value op,
Expression* left,
Expression* right,
int pos) {
return new (zone_) CompareOperation(op, left, right, pos);
return zone_->New<CompareOperation>(op, left, right, pos);
}
Spread* NewSpread(Expression* expression, int pos, int expr_pos) {
return new (zone_) Spread(expression, pos, expr_pos);
return zone_->New<Spread>(expression, pos, expr_pos);
}
Conditional* NewConditional(Expression* condition,
Expression* then_expression,
Expression* else_expression,
int position) {
return new (zone_)
Conditional(condition, then_expression, else_expression, position);
return zone_->New<Conditional>(condition, then_expression, else_expression,
position);
}
Assignment* NewAssignment(Token::Value op,
......@@ -3071,10 +3127,10 @@ class AstNodeFactory final {
}
if (op == Token::ASSIGN || op == Token::INIT) {
return new (zone_)
Assignment(AstNode::kAssignment, op, target, value, pos);
return zone_->New<Assignment>(AstNode::kAssignment, op, target, value,
pos);
} else {
return new (zone_) CompoundAssignment(
return zone_->New<CompoundAssignment>(
op, target, value, pos,
NewBinaryOperation(Token::BinaryOpForAssignment(op), target, value,
pos + 1));
......@@ -3084,20 +3140,20 @@ class AstNodeFactory final {
Suspend* NewYield(Expression* expression, int pos,
Suspend::OnAbruptResume on_abrupt_resume) {
if (!expression) expression = NewUndefinedLiteral(pos);
return new (zone_) Yield(expression, pos, on_abrupt_resume);
return zone_->New<Yield>(expression, pos, on_abrupt_resume);
}
YieldStar* NewYieldStar(Expression* expression, int pos) {
return new (zone_) YieldStar(expression, pos);
return zone_->New<YieldStar>(expression, pos);
}
Await* NewAwait(Expression* expression, int pos) {
if (!expression) expression = NewUndefinedLiteral(pos);
return new (zone_) Await(expression, pos);
return zone_->New<Await>(expression, pos);
}
Throw* NewThrow(Expression* exception, int pos) {
return new (zone_) Throw(exception, pos);
return zone_->New<Throw>(exception, pos);
}
FunctionLiteral* NewFunctionLiteral(
......@@ -3109,7 +3165,7 @@ class AstNodeFactory final {
FunctionLiteral::EagerCompileHint eager_compile_hint, int position,
bool has_braces, int function_literal_id,
ProducedPreparseData* produced_preparse_data = nullptr) {
return new (zone_) FunctionLiteral(
return zone_->New<FunctionLiteral>(
zone_, name ? ast_value_factory_->NewConsString(name) : nullptr,
ast_value_factory_, scope, body, expected_property_count,
parameter_count, function_length, function_syntax_kind,
......@@ -3123,7 +3179,7 @@ class AstNodeFactory final {
FunctionLiteral* NewScriptOrEvalFunctionLiteral(
DeclarationScope* scope, const ScopedPtrList<Statement>& body,
int expected_property_count, int parameter_count) {
return new (zone_) FunctionLiteral(
return zone_->New<FunctionLiteral>(
zone_, ast_value_factory_->empty_cons_string(), ast_value_factory_,
scope, body, expected_property_count, parameter_count, parameter_count,
FunctionSyntaxKind::kAnonymousExpression,
......@@ -3135,7 +3191,7 @@ class AstNodeFactory final {
ClassLiteral::Property* NewClassLiteralProperty(
Expression* key, Expression* value, ClassLiteralProperty::Kind kind,
bool is_static, bool is_computed_name, bool is_private) {
return new (zone_) ClassLiteral::Property(key, value, kind, is_static,
return zone_->New<ClassLiteral::Property>(key, value, kind, is_static,
is_computed_name, is_private);
}
......@@ -3148,7 +3204,7 @@ class AstNodeFactory final {
int start_position, int end_position, bool has_name_static_property,
bool has_static_computed_names, bool is_anonymous,
bool has_private_methods) {
return new (zone_) ClassLiteral(
return zone_->New<ClassLiteral>(
scope, extends, constructor, public_members, private_members,
static_fields_initializer, instance_members_initializer_function,
start_position, end_position, has_name_static_property,
......@@ -3158,44 +3214,44 @@ class AstNodeFactory final {
NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
v8::Extension* extension,
int pos) {
return new (zone_) NativeFunctionLiteral(name, extension, pos);
return zone_->New<NativeFunctionLiteral>(name, extension, pos);
}
SuperPropertyReference* NewSuperPropertyReference(Expression* home_object,
int pos) {
return new (zone_) SuperPropertyReference(home_object, pos);
return zone_->New<SuperPropertyReference>(home_object, pos);
}
SuperCallReference* NewSuperCallReference(VariableProxy* new_target_var,
VariableProxy* this_function_var,
int pos) {
return new (zone_)
SuperCallReference(new_target_var, this_function_var, pos);
return zone_->New<SuperCallReference>(new_target_var, this_function_var,
pos);
}
EmptyParentheses* NewEmptyParentheses(int pos) {
return new (zone_) EmptyParentheses(pos);
return zone_->New<EmptyParentheses>(pos);
}
GetTemplateObject* NewGetTemplateObject(
const ZonePtrList<const AstRawString>* cooked_strings,
const ZonePtrList<const AstRawString>* raw_strings, int pos) {
return new (zone_) GetTemplateObject(cooked_strings, raw_strings, pos);
return zone_->New<GetTemplateObject>(cooked_strings, raw_strings, pos);
}
TemplateLiteral* NewTemplateLiteral(
const ZonePtrList<const AstRawString>* string_parts,
const ZonePtrList<Expression>* substitutions, int pos) {
return new (zone_) TemplateLiteral(string_parts, substitutions, pos);
return zone_->New<TemplateLiteral>(string_parts, substitutions, pos);
}
ImportCallExpression* NewImportCallExpression(Expression* args, int pos) {
return new (zone_) ImportCallExpression(args, pos);
return zone_->New<ImportCallExpression>(args, pos);
}
InitializeClassMembersStatement* NewInitializeClassMembersStatement(
ZonePtrList<ClassLiteral::Property>* args, int pos) {
return new (zone_) InitializeClassMembersStatement(args, pos);
return zone_->New<InitializeClassMembersStatement>(args, pos);
}
Zone* zone() const { return zone_; }
......
......@@ -32,7 +32,7 @@ void SourceTextModuleDescriptor::AddImport(
const AstRawString* import_name, const AstRawString* local_name,
const AstRawString* module_request, const Scanner::Location loc,
const Scanner::Location specifier_loc, Zone* zone) {
Entry* entry = new (zone) Entry(loc);
Entry* entry = zone->New<Entry>(loc);
entry->local_name = local_name;
entry->import_name = import_name;
entry->module_request = AddModuleRequest(module_request, specifier_loc);
......@@ -43,7 +43,7 @@ void SourceTextModuleDescriptor::AddStarImport(
const AstRawString* local_name, const AstRawString* module_request,
const Scanner::Location loc, const Scanner::Location specifier_loc,
Zone* zone) {
Entry* entry = new (zone) Entry(loc);
Entry* entry = zone->New<Entry>(loc);
entry->local_name = local_name;
entry->module_request = AddModuleRequest(module_request, specifier_loc);
AddNamespaceImport(entry, zone);
......@@ -57,7 +57,7 @@ void SourceTextModuleDescriptor::AddEmptyImport(
void SourceTextModuleDescriptor::AddExport(const AstRawString* local_name,
const AstRawString* export_name,
Scanner::Location loc, Zone* zone) {
Entry* entry = new (zone) Entry(loc);
Entry* entry = zone->New<Entry>(loc);
entry->export_name = export_name;
entry->local_name = local_name;
AddRegularExport(entry);
......@@ -69,7 +69,7 @@ void SourceTextModuleDescriptor::AddExport(
const Scanner::Location specifier_loc, Zone* zone) {
DCHECK_NOT_NULL(import_name);
DCHECK_NOT_NULL(export_name);
Entry* entry = new (zone) Entry(loc);
Entry* entry = zone->New<Entry>(loc);
entry->export_name = export_name;
entry->import_name = import_name;
entry->module_request = AddModuleRequest(module_request, specifier_loc);
......@@ -79,7 +79,7 @@ void SourceTextModuleDescriptor::AddExport(
void SourceTextModuleDescriptor::AddStarExport(
const AstRawString* module_request, const Scanner::Location loc,
const Scanner::Location specifier_loc, Zone* zone) {
Entry* entry = new (zone) Entry(loc);
Entry* entry = zone->New<Entry>(loc);
entry->module_request = AddModuleRequest(module_request, specifier_loc);
AddSpecialExport(entry, zone);
}
......
......@@ -54,7 +54,7 @@ Variable* VariableMap::Declare(Zone* zone, Scope* scope,
// The variable has not been declared yet -> insert it.
DCHECK_EQ(name, p->key);
Variable* variable =
new (zone) Variable(scope, name, mode, kind, initialization_flag,
zone->New<Variable>(scope, name, mode, kind, initialization_flag,
maybe_assigned_flag, is_static_flag);
p->value = variable;
}
......@@ -138,8 +138,8 @@ DeclarationScope::DeclarationScope(Zone* zone, Scope* outer_scope,
ModuleScope::ModuleScope(DeclarationScope* script_scope,
AstValueFactory* avfactory)
: DeclarationScope(avfactory->zone(), script_scope, MODULE_SCOPE, kModule),
module_descriptor_(new (avfactory->zone())
SourceTextModuleDescriptor(avfactory->zone())) {
module_descriptor_(avfactory->zone()->New<SourceTextModuleDescriptor>(
avfactory->zone())) {
set_language_mode(LanguageMode::kStrict);
DeclareThis(avfactory);
}
......@@ -357,13 +357,13 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
while (!scope_info.is_null()) {
if (scope_info.scope_type() == WITH_SCOPE) {
if (scope_info.IsDebugEvaluateScope()) {
outer_scope = new (zone)
DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info, isolate));
outer_scope = zone->New<DeclarationScope>(zone, FUNCTION_SCOPE,
handle(scope_info, isolate));
outer_scope->set_is_debug_evaluate_scope();
} else {
// For scope analysis, debug-evaluate is equivalent to a with scope.
outer_scope =
new (zone) Scope(zone, WITH_SCOPE, handle(scope_info, isolate));
zone->New<Scope>(zone, WITH_SCOPE, handle(scope_info, isolate));
}
} else if (scope_info.scope_type() == SCRIPT_SCOPE) {
......@@ -377,28 +377,28 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
DCHECK(!scope_info.HasOuterScopeInfo());
break;
} else if (scope_info.scope_type() == FUNCTION_SCOPE) {
outer_scope = new (zone)
DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info, isolate));
outer_scope = zone->New<DeclarationScope>(zone, FUNCTION_SCOPE,
handle(scope_info, isolate));
if (scope_info.IsAsmModule()) {
outer_scope->AsDeclarationScope()->set_is_asm_module();
}
} else if (scope_info.scope_type() == EVAL_SCOPE) {
outer_scope = new (zone)
DeclarationScope(zone, EVAL_SCOPE, handle(scope_info, isolate));
outer_scope = zone->New<DeclarationScope>(zone, EVAL_SCOPE,
handle(scope_info, isolate));
} else if (scope_info.scope_type() == CLASS_SCOPE) {
outer_scope = new (zone) ClassScope(isolate, zone, ast_value_factory,
outer_scope = zone->New<ClassScope>(isolate, zone, ast_value_factory,
handle(scope_info, isolate));
} else if (scope_info.scope_type() == BLOCK_SCOPE) {
if (scope_info.is_declaration_scope()) {
outer_scope = new (zone)
DeclarationScope(zone, BLOCK_SCOPE, handle(scope_info, isolate));
outer_scope = zone->New<DeclarationScope>(zone, BLOCK_SCOPE,
handle(scope_info, isolate));
} else {
outer_scope =
new (zone) Scope(zone, BLOCK_SCOPE, handle(scope_info, isolate));
zone->New<Scope>(zone, BLOCK_SCOPE, handle(scope_info, isolate));
}
} else if (scope_info.scope_type() == MODULE_SCOPE) {
outer_scope = new (zone)
ModuleScope(isolate, handle(scope_info, isolate), ast_value_factory);
outer_scope = zone->New<ModuleScope>(isolate, handle(scope_info, isolate),
ast_value_factory);
} else {
DCHECK_EQ(scope_info.scope_type(), CATCH_SCOPE);
DCHECK_EQ(scope_info.ContextLocalCount(), 1);
......@@ -407,9 +407,9 @@ Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
String name = scope_info.ContextLocalName(0);
MaybeAssignedFlag maybe_assigned =
scope_info.ContextLocalMaybeAssignedFlag(0);
outer_scope = new (zone)
Scope(zone, ast_value_factory->GetString(handle(name, isolate)),
maybe_assigned, handle(scope_info, isolate));
outer_scope = zone->New<Scope>(
zone, ast_value_factory->GetString(handle(name, isolate)),
maybe_assigned, handle(scope_info, isolate));
}
if (deserialization_mode == DeserializationMode::kScopesOnly) {
outer_scope->scope_info_ = Handle<ScopeInfo>::null();
......@@ -621,12 +621,12 @@ void DeclarationScope::DeclareThis(AstValueFactory* ast_value_factory) {
bool derived_constructor = IsDerivedConstructor(function_kind_);
receiver_ = new (zone())
Variable(this, ast_value_factory->this_string(),
derived_constructor ? VariableMode::kConst : VariableMode::kVar,
THIS_VARIABLE,
derived_constructor ? kNeedsInitialization : kCreatedInitialized,
kNotAssigned);
receiver_ = zone()->New<Variable>(
this, ast_value_factory->this_string(),
derived_constructor ? VariableMode::kConst : VariableMode::kVar,
THIS_VARIABLE,
derived_constructor ? kNeedsInitialization : kCreatedInitialized,
kNotAssigned);
}
void DeclarationScope::DeclareArguments(AstValueFactory* ast_value_factory) {
......@@ -677,8 +677,8 @@ Variable* DeclarationScope::DeclareFunctionVar(const AstRawString* name,
DCHECK_NULL(cache->variables_.Lookup(name));
VariableKind kind = is_sloppy(language_mode()) ? SLOPPY_FUNCTION_NAME_VARIABLE
: NORMAL_VARIABLE;
function_ = new (zone())
Variable(this, name, VariableMode::kConst, kind, kCreatedInitialized);
function_ = zone()->New<Variable>(this, name, VariableMode::kConst, kind,
kCreatedInitialized);
if (sloppy_eval_can_extend_vars()) {
cache->NonLocal(name, VariableMode::kDynamic);
} else {
......@@ -1131,7 +1131,7 @@ Variable* Scope::NewTemporary(const AstRawString* name) {
Variable* Scope::NewTemporary(const AstRawString* name,
MaybeAssignedFlag maybe_assigned) {
DeclarationScope* scope = GetClosureScope();
Variable* var = new (zone()) Variable(scope, name, VariableMode::kTemporary,
Variable* var = zone()->New<Variable>(scope, name, VariableMode::kTemporary,
NORMAL_VARIABLE, kCreatedInitialized);
scope->AddLocal(var);
if (maybe_assigned == kMaybeAssigned) var->SetMaybeAssigned();
......
......@@ -699,6 +699,7 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
friend class DeclarationScope;
friend class ClassScope;
friend class ScopeTestHelper;
friend Zone;
Zone* zone_;
......@@ -1260,7 +1261,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
V8_INLINE RareData* EnsureRareData() {
if (rare_data_ == nullptr) {
rare_data_ = new (zone_) RareData;
rare_data_ = zone_->New<RareData>();
}
return rare_data_;
}
......@@ -1441,8 +1442,8 @@ class V8_EXPORT_PRIVATE ClassScope : public Scope {
}
V8_INLINE RareData* EnsureRareData() {
if (GetRareData() == nullptr) {
rare_data_and_is_parsing_heritage_.SetPointer(new (zone_)
RareData(zone_));
rare_data_and_is_parsing_heritage_.SetPointer(
zone_->New<RareData>(zone_));
}
return GetRareData();
}
......
......@@ -3375,7 +3375,7 @@ TEST(SerializationOfMaybeAssignmentFlag) {
i::Handle<i::String> str = name->string();
CHECK(str->IsInternalizedString());
i::DeclarationScope* script_scope =
new (&zone) i::DeclarationScope(&zone, &avf);
zone.New<i::DeclarationScope>(&zone, &avf);
i::Scope* s = i::Scope::DeserializeScopeChain(
isolate, &zone, context->scope_info(), script_scope, &avf,
i::Scope::DeserializationMode::kIncludingVariables);
......@@ -3424,7 +3424,7 @@ TEST(IfArgumentsArrayAccessedThenParametersMaybeAssigned) {
avf.Internalize(isolate);
i::DeclarationScope* script_scope =
new (&zone) i::DeclarationScope(&zone, &avf);
zone.New<i::DeclarationScope>(&zone, &avf);
i::Scope* s = i::Scope::DeserializeScopeChain(
isolate, &zone, context->scope_info(), script_scope, &avf,
i::Scope::DeserializationMode::kIncludingVariables);
......@@ -4349,7 +4349,7 @@ i::Scope* DeserializeFunctionScope(i::Isolate* isolate, i::Zone* zone,
i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(
i::JSReceiver::GetProperty(isolate, m, name).ToHandleChecked());
i::DeclarationScope* script_scope =
new (zone) i::DeclarationScope(zone, &avf);
zone->New<i::DeclarationScope>(zone, &avf);
i::Scope* s = i::Scope::DeserializeScopeChain(
isolate, zone, f->context().scope_info(), script_scope, &avf,
i::Scope::DeserializationMode::kIncludingVariables);
......
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