Commit 3e3fc9f2 authored by Toon Verwaest's avatar Toon Verwaest Committed by Commit Bot

[parser] Use ScopedPtrList to avoid static prediction of ZonePtrList sizes

This CL introduces a ScopedPtrList that's a view over an underlying ZonePtrList
buffer. Whenever a ScopedPtrList is the top-of-stack list, you can add values
through it, which will add them to the end of the buffer. Once the list is
done, you can copy out the values to a real ZonePtrList. That way you do not
need to guess what the required size of the list is, and you get better cache
locality.

Change-Id: I2d229d73bb25bbb450ae5b6767ab100abad2b3a3
Reviewed-on: https://chromium-review.googlesource.com/c/1296458
Commit-Queue: Toon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56939}
parent ecbf6296
......@@ -41,7 +41,7 @@ class AstTraversalVisitor : public AstVisitor<Subclass> {
// Iteration left-to-right.
void VisitDeclarations(Declaration::List* declarations);
void VisitStatements(ZonePtrList<Statement>* statements);
void VisitStatements(const ZonePtrList<Statement>* statements);
// Individual nodes
#define DECLARE_VISIT(type) void Visit##type(type* node);
......@@ -112,7 +112,7 @@ void AstTraversalVisitor<Subclass>::VisitDeclarations(
template <class Subclass>
void AstTraversalVisitor<Subclass>::VisitStatements(
ZonePtrList<Statement>* stmts) {
const ZonePtrList<Statement>* stmts) {
for (int i = 0; i < stmts->length(); ++i) {
Statement* stmt = stmts->at(i);
RECURSE(Visit(stmt));
......@@ -205,7 +205,7 @@ void AstTraversalVisitor<Subclass>::VisitSwitchStatement(
Expression* label = clause->label();
RECURSE(Visit(label));
}
ZonePtrList<Statement>* stmts = clause->statements();
const ZonePtrList<Statement>* stmts = clause->statements();
RECURSE(VisitStatements(stmts));
}
}
......@@ -330,7 +330,7 @@ void AstTraversalVisitor<Subclass>::VisitRegExpLiteral(RegExpLiteral* expr) {
template <class Subclass>
void AstTraversalVisitor<Subclass>::VisitObjectLiteral(ObjectLiteral* expr) {
PROCESS_EXPRESSION(expr);
ZonePtrList<ObjectLiteralProperty>* props = expr->properties();
const ZonePtrList<ObjectLiteralProperty>* props = expr->properties();
for (int i = 0; i < props->length(); ++i) {
ObjectLiteralProperty* prop = props->at(i);
RECURSE_EXPRESSION(Visit(prop->key()));
......@@ -341,7 +341,7 @@ void AstTraversalVisitor<Subclass>::VisitObjectLiteral(ObjectLiteral* expr) {
template <class Subclass>
void AstTraversalVisitor<Subclass>::VisitArrayLiteral(ArrayLiteral* expr) {
PROCESS_EXPRESSION(expr);
ZonePtrList<Expression>* values = expr->values();
const ZonePtrList<Expression>* values = expr->values();
for (int i = 0; i < values->length(); ++i) {
Expression* value = values->at(i);
RECURSE_EXPRESSION(Visit(value));
......@@ -404,7 +404,7 @@ template <class Subclass>
void AstTraversalVisitor<Subclass>::VisitCall(Call* expr) {
PROCESS_EXPRESSION(expr);
RECURSE_EXPRESSION(Visit(expr->expression()));
ZonePtrList<Expression>* args = expr->arguments();
const ZonePtrList<Expression>* args = expr->arguments();
for (int i = 0; i < args->length(); ++i) {
Expression* arg = args->at(i);
RECURSE_EXPRESSION(Visit(arg));
......@@ -415,7 +415,7 @@ template <class Subclass>
void AstTraversalVisitor<Subclass>::VisitCallNew(CallNew* expr) {
PROCESS_EXPRESSION(expr);
RECURSE_EXPRESSION(Visit(expr->expression()));
ZonePtrList<Expression>* args = expr->arguments();
const ZonePtrList<Expression>* args = expr->arguments();
for (int i = 0; i < args->length(); ++i) {
Expression* arg = args->at(i);
RECURSE_EXPRESSION(Visit(arg));
......@@ -425,7 +425,7 @@ void AstTraversalVisitor<Subclass>::VisitCallNew(CallNew* expr) {
template <class Subclass>
void AstTraversalVisitor<Subclass>::VisitCallRuntime(CallRuntime* expr) {
PROCESS_EXPRESSION(expr);
ZonePtrList<Expression>* args = expr->arguments();
const ZonePtrList<Expression>* args = expr->arguments();
for (int i = 0; i < args->length(); ++i) {
Expression* arg = args->at(i);
RECURSE_EXPRESSION(Visit(arg));
......
......@@ -646,7 +646,7 @@ void ArrayLiteral::BuildBoilerplateDescription(Isolate* isolate) {
bool ArrayLiteral::IsFastCloningSupported() const {
return depth() <= 1 &&
values()->length() <=
values_.length() <=
ConstructorBuiltins::kMaximumClonedShallowArrayElements;
}
......@@ -862,8 +862,11 @@ Call::CallType Call::GetCallType() const {
return OTHER_CALL;
}
CaseClause::CaseClause(Expression* label, ZonePtrList<Statement>* statements)
: label_(label), statements_(statements) {}
CaseClause::CaseClause(Expression* label,
const ScopedPtrList<Statement>& statements)
: label_(label), statements_(0, nullptr) {
statements.CopyTo(&statements_);
}
bool Literal::IsPropertyName() const {
if (type() != kString) return false;
......
This diff is collapsed.
......@@ -501,14 +501,14 @@ void CallPrinter::VisitRewritableExpression(RewritableExpression* node) {
Find(node->expression());
}
void CallPrinter::FindStatements(ZonePtrList<Statement>* statements) {
void CallPrinter::FindStatements(const ZonePtrList<Statement>* statements) {
if (statements == nullptr) return;
for (int i = 0; i < statements->length(); i++) {
Find(statements->at(i));
}
}
void CallPrinter::FindArguments(ZonePtrList<Expression>* arguments) {
void CallPrinter::FindArguments(const ZonePtrList<Expression>* arguments) {
if (found_) return;
for (int i = 0; i < arguments->length(); i++) {
Find(arguments->at(i));
......@@ -813,13 +813,13 @@ void AstPrinter::PrintParameters(DeclarationScope* scope) {
}
}
void AstPrinter::PrintStatements(ZonePtrList<Statement>* statements) {
void AstPrinter::PrintStatements(const ZonePtrList<Statement>* statements) {
for (int i = 0; i < statements->length(); i++) {
Visit(statements->at(i));
}
}
void AstPrinter::PrintArguments(ZonePtrList<Expression>* arguments) {
void AstPrinter::PrintArguments(const ZonePtrList<Expression>* arguments) {
for (int i = 0; i < arguments->length(); i++) {
Visit(arguments->at(i));
}
......@@ -1050,7 +1050,7 @@ void AstPrinter::VisitInitializeClassFieldsStatement(
}
void AstPrinter::PrintClassProperties(
ZonePtrList<ClassLiteral::Property>* properties) {
const ZonePtrList<ClassLiteral::Property>* properties) {
for (int i = 0; i < properties->length(); i++) {
ClassLiteral::Property* property = properties->at(i);
const char* prop_kind = nullptr;
......@@ -1126,7 +1126,7 @@ void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) {
}
void AstPrinter::PrintObjectProperties(
ZonePtrList<ObjectLiteral::Property>* properties) {
const ZonePtrList<ObjectLiteral::Property>* properties) {
for (int i = 0; i < properties->length(); i++) {
ObjectLiteral::Property* property = properties->at(i);
const char* prop_kind = nullptr;
......
......@@ -59,8 +59,8 @@ class CallPrinter final : public AstVisitor<CallPrinter> {
protected:
void PrintLiteral(Handle<Object> value, bool quote);
void PrintLiteral(const AstRawString* value, bool quote);
void FindStatements(ZonePtrList<Statement>* statements);
void FindArguments(ZonePtrList<Expression>* arguments);
void FindStatements(const ZonePtrList<Statement>* statements);
void FindArguments(const ZonePtrList<Expression>* arguments);
};
......@@ -98,10 +98,10 @@ class AstPrinter final : public AstVisitor<AstPrinter> {
void PrintIndented(const char* txt);
void PrintIndentedVisit(const char* s, AstNode* node);
void PrintStatements(ZonePtrList<Statement>* statements);
void PrintStatements(const ZonePtrList<Statement>* statements);
void PrintDeclarations(Declaration::List* declarations);
void PrintParameters(DeclarationScope* scope);
void PrintArguments(ZonePtrList<Expression>* arguments);
void PrintArguments(const ZonePtrList<Expression>* arguments);
void PrintCaseClause(CaseClause* clause);
void PrintLiteralIndented(const char* info, Literal* literal, bool quote);
void PrintLiteralIndented(const char* info, const AstRawString* value,
......@@ -112,8 +112,10 @@ class AstPrinter final : public AstVisitor<AstPrinter> {
const AstRawString* value);
void PrintLabelsIndented(ZonePtrList<const AstRawString>* labels,
const char* prefix = "");
void PrintObjectProperties(ZonePtrList<ObjectLiteral::Property>* properties);
void PrintClassProperties(ZonePtrList<ClassLiteral::Property>* properties);
void PrintObjectProperties(
const ZonePtrList<ObjectLiteral::Property>* properties);
void PrintClassProperties(
const ZonePtrList<ClassLiteral::Property>* properties);
void inc_indent() { indent_++; }
void dec_indent() { indent_--; }
......
......@@ -1327,7 +1327,8 @@ void BytecodeGenerator::VisitDeclarations(Declaration::List* declarations) {
globals_builder_ = new (zone()) GlobalDeclarationsBuilder(zone());
}
void BytecodeGenerator::VisitStatements(ZonePtrList<Statement>* statements) {
void BytecodeGenerator::VisitStatements(
const ZonePtrList<Statement>* statements) {
for (int i = 0; i < statements->length(); i++) {
// Allocate an outer register allocations scope for the statement.
RegisterAllocationScope allocation_scope(this);
......@@ -2450,7 +2451,7 @@ void BytecodeGenerator::BuildArrayLiteralSpread(Spread* spread, Register array,
}
void BytecodeGenerator::BuildCreateArrayLiteral(
ZonePtrList<Expression>* elements, ArrayLiteral* expr) {
const ZonePtrList<Expression>* elements, ArrayLiteral* expr) {
RegisterAllocationScope register_scope(this);
Register index = register_allocator()->NewRegister();
Register array = register_allocator()->NewRegister();
......@@ -3578,7 +3579,7 @@ void BytecodeGenerator::VisitResolvedProperty(ResolvedProperty* expr) {
UNREACHABLE();
}
void BytecodeGenerator::VisitArguments(ZonePtrList<Expression>* args,
void BytecodeGenerator::VisitArguments(const ZonePtrList<Expression>* args,
RegisterList* arg_regs) {
// Visit arguments.
for (int i = 0; i < static_cast<int>(args->length()); i++) {
......@@ -3755,7 +3756,7 @@ void BytecodeGenerator::VisitCall(Call* expr) {
void BytecodeGenerator::VisitCallSuper(Call* expr) {
RegisterAllocationScope register_scope(this);
SuperCallReference* super = expr->expression()->AsSuperCallReference();
ZonePtrList<Expression>* args = expr->arguments();
const ZonePtrList<Expression>* args = expr->arguments();
int first_spread_index = 0;
for (; first_spread_index < args->length(); first_spread_index++) {
......
......@@ -44,7 +44,7 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
// Visiting function for declarations list and statements are overridden.
void VisitDeclarations(Declaration::List* declarations);
void VisitStatements(ZonePtrList<Statement>* statments);
void VisitStatements(const ZonePtrList<Statement>* statments);
private:
class ContextScope;
......@@ -101,7 +101,8 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
// Visit the arguments expressions in |args| and store them in |args_regs|,
// growing |args_regs| for each argument visited.
void VisitArguments(ZonePtrList<Expression>* args, RegisterList* arg_regs);
void VisitArguments(const ZonePtrList<Expression>* args,
RegisterList* arg_regs);
// Visit a keyed super property load. The optional
// |opt_receiver_out| register will have the receiver stored to it
......@@ -186,7 +187,7 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
// Create Array literals. |expr| can be nullptr, but if provided,
// a boilerplate will be used to create an initial array for elements
// before the first spread.
void BuildCreateArrayLiteral(ZonePtrList<Expression>* elements,
void BuildCreateArrayLiteral(const ZonePtrList<Expression>* elements,
ArrayLiteral* expr);
void BuildCreateObjectLiteral(Register literal, uint8_t flags, size_t entry);
void AllocateTopLevelRegisters();
......
This diff is collapsed.
This diff is collapsed.
......@@ -137,6 +137,10 @@ struct ParserTypes<Parser> {
typedef ParserFormalParameters FormalParameters;
typedef v8::internal::Statement* Statement;
typedef ZonePtrList<v8::internal::Statement>* StatementList;
typedef ScopedPtrList<v8::internal::Statement> ScopedStatementList;
typedef ScopedPtrList<v8::internal::Expression> ScopedExpressionList;
typedef ScopedPtrList<v8::internal::ObjectLiteralProperty>
ScopedObjectPropertyList;
typedef v8::internal::Block* Block;
typedef v8::internal::BreakableStatement* BreakableStatement;
typedef v8::internal::ForStatement* ForStatement;
......@@ -533,11 +537,13 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
Expression* CloseTemplateLiteral(TemplateLiteralState* state, int start,
Expression* tag);
ArrayLiteral* ArrayLiteralFromListWithSpread(ZonePtrList<Expression>* list);
Expression* SpreadCall(Expression* function, ZonePtrList<Expression>* args,
int pos, Call::PossiblyEval is_possibly_eval);
Expression* SpreadCallNew(Expression* function, ZonePtrList<Expression>* args,
int pos);
ArrayLiteral* ArrayLiteralFromListWithSpread(
const ScopedPtrList<Expression>& list);
Expression* SpreadCall(Expression* function,
const ScopedPtrList<Expression>& args, int pos,
Call::PossiblyEval is_possibly_eval);
Expression* SpreadCallNew(Expression* function,
const ScopedPtrList<Expression>& args, int pos);
Expression* RewriteSuperCall(Expression* call_expression);
void SetLanguageMode(Scope* scope, LanguageMode mode);
......@@ -736,9 +742,8 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
// A shortcut for performing a ToString operation
V8_INLINE Expression* ToString(Expression* expr) {
if (expr->IsStringLiteral()) return expr;
ZonePtrList<Expression>* args =
new (zone()) ZonePtrList<Expression>(1, zone());
args->Add(expr, zone());
ScopedPtrList<Expression> args(zone(), expression_buffer());
args.Add(expr);
return factory()->NewCallRuntime(Runtime::kInlineToString, args,
expr->position());
}
......@@ -898,8 +903,8 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
}
V8_INLINE Expression* NewV8Intrinsic(const AstRawString* name,
ZonePtrList<Expression>* args, int pos,
bool* ok);
const ScopedPtrList<Expression>& args,
int pos, bool* ok);
V8_INLINE Statement* NewThrowStatement(Expression* exception, int pos) {
return factory()->NewExpressionStatement(
......@@ -953,7 +958,7 @@ class V8_EXPORT_PRIVATE Parser : public NON_EXPORTED_BASE(ParserBase<Parser>) {
const Scanner::Location& params_loc,
bool* ok);
Expression* ExpressionListToExpression(ZonePtrList<Expression>* args);
Expression* ExpressionListToExpression(const ScopedPtrList<Expression>& args);
void SetFunctionNameFromPropertyName(LiteralProperty* property,
const AstRawString* name,
......
......@@ -110,6 +110,11 @@ class PatternRewriter final : public AstVisitor<PatternRewriter> {
AstValueFactory* ast_value_factory() const {
return parser_->ast_value_factory();
}
ZonePtrList<Expression>* expression_buffer() {
return parser_->expression_buffer();
}
Zone* zone() const { return parser_->zone(); }
Scope* scope() const { return scope_; }
......@@ -336,15 +341,9 @@ void PatternRewriter::VisitObjectLiteral(ObjectLiteral* pattern,
Variable** temp_var) {
auto temp = *temp_var = CreateTempVar(current_value_);
ZonePtrList<Expression>* rest_runtime_callargs = nullptr;
ScopedPtrList<Expression> rest_runtime_callargs(zone(), expression_buffer());
if (pattern->has_rest_property()) {
// non_rest_properties_count = pattern->properties()->length - 1;
// args_length = 1 + non_rest_properties_count because we need to
// pass temp as well to the runtime function.
int args_length = pattern->properties()->length();
rest_runtime_callargs =
new (zone()) ZonePtrList<Expression>(args_length, zone());
rest_runtime_callargs->Add(factory()->NewVariableProxy(temp), zone());
rest_runtime_callargs.Add(factory()->NewVariableProxy(temp));
}
block_->statements()->Add(parser_->BuildAssertIsCoercible(temp, pattern),
......@@ -378,8 +377,8 @@ void PatternRewriter::VisitObjectLiteral(ObjectLiteral* pattern,
if (property->is_computed_name()) {
DCHECK(!key->IsPropertyName() || !key->IsNumberLiteral());
auto args = new (zone()) ZonePtrList<Expression>(1, zone());
args->Add(key, zone());
ScopedPtrList<Expression> args(zone(), expression_buffer());
args.Add(key);
auto to_name_key = CreateTempVar(factory()->NewCallRuntime(
Runtime::kToName, args, kNoSourcePosition));
key = factory()->NewVariableProxy(to_name_key);
......@@ -388,8 +387,7 @@ void PatternRewriter::VisitObjectLiteral(ObjectLiteral* pattern,
DCHECK(key->IsPropertyName() || key->IsNumberLiteral());
}
DCHECK_NOT_NULL(rest_runtime_callargs);
rest_runtime_callargs->Add(excluded_property, zone());
rest_runtime_callargs.Add(excluded_property);
}
value = factory()->NewProperty(factory()->NewVariableProxy(temp), key,
......@@ -557,7 +555,7 @@ void PatternRewriter::VisitArrayLiteral(ArrayLiteral* node,
// let array = [];
Variable* array;
{
auto empty_exprs = new (zone()) ZonePtrList<Expression>(0, zone());
ScopedPtrList<Expression> empty_exprs(zone(), expression_buffer());
array = CreateTempVar(
factory()->NewArrayLiteral(empty_exprs, kNoSourcePosition));
}
......
......@@ -414,61 +414,67 @@ class PreParserExpression {
friend class PreParser;
friend class PreParserFactory;
friend class PreParserExpressionList;
friend class PreParserScopedExpressionList;
};
// The pre-parser doesn't need to build lists of expressions, identifiers, or
// the like. If the PreParser is used in variable tracking mode, it needs to
// build lists of variables though.
class PreParserExpressionList {
class PreParserExpressionList {};
class PreParserStatement;
class PreParserStatementList {
public:
PreParserStatementList() : PreParserStatementList(false) {}
PreParserStatementList* operator->() { return this; }
void Add(const PreParserStatement& element, Zone* zone) {}
static PreParserStatementList Null() { return PreParserStatementList(true); }
bool IsNull() const { return is_null_; }
private:
explicit PreParserStatementList(bool is_null) : is_null_(is_null) {}
bool is_null_;
};
class PreParserScopedStatementList {
public:
PreParserScopedStatementList(Zone* zone,
const PreParserStatementList& buffer) {}
void Add(const PreParserStatement& element) {}
};
class PreParserScopedExpressionList {
using VariableZoneThreadedListType =
ZoneThreadedList<VariableProxy, VariableProxy::PreParserNext>;
public:
// These functions make list->Add(some_expression) work (and do nothing).
PreParserExpressionList() : PreParserExpressionList(0) {}
PreParserExpressionList* operator->() { return this; }
void Add(const PreParserExpression& expression, Zone* zone) {
PreParserScopedExpressionList(Zone* zone,
const PreParserExpressionList& buffer)
: length_(0), variables_(nullptr) {}
int length() const { return length_; }
void Add(const PreParserExpression& expression) {
if (expression.variables_ != nullptr) {
DCHECK_NOT_NULL(zone);
if (variables_ == nullptr) {
variables_ = new (zone) VariableZoneThreadedListType();
variables_ = expression.variables_;
} else {
variables_->Append(std::move(*expression.variables_));
}
variables_->Append(std::move(*expression.variables_));
}
++length_;
}
int length() const { return length_; }
static PreParserExpressionList Null() { return PreParserExpressionList(-1); }
bool IsNull() const { return length_ == -1; }
void Set(int index, const PreParserExpression& element) {}
private:
explicit PreParserExpressionList(int n) : length_(n), variables_(nullptr) {}
int length_;
VariableZoneThreadedListType* variables_;
friend class PreParser;
friend class PreParserFactory;
};
class PreParserStatement;
class PreParserStatementList {
public:
PreParserStatementList() : PreParserStatementList(false) {}
PreParserStatementList* operator->() { return this; }
void Add(const PreParserStatement& element, Zone* zone) {}
static PreParserStatementList Null() { return PreParserStatementList(true); }
bool IsNull() const { return is_null_; }
private:
explicit PreParserStatementList(bool is_null) : is_null_(is_null) {}
bool is_null_;
};
class PreParserStatement {
public:
static PreParserStatement Default() {
......@@ -589,8 +595,9 @@ class PreParserFactory {
int js_flags, int pos) {
return PreParserExpression::Default();
}
PreParserExpression NewArrayLiteral(const PreParserExpressionList& values,
int first_spread_index, int pos) {
PreParserExpression NewArrayLiteral(
const PreParserScopedExpressionList& values, int first_spread_index,
int pos) {
return PreParserExpression::ArrayLiteral(values.variables_);
}
PreParserExpression NewClassLiteralProperty(const PreParserExpression& key,
......@@ -613,8 +620,8 @@ class PreParserFactory {
return PreParserExpression::Default(value.variables_);
}
PreParserExpression NewObjectLiteral(
const PreParserExpressionList& properties, int boilerplate_properties,
int pos, bool has_rest_property) {
const PreParserScopedExpressionList& properties,
int boilerplate_properties, int pos, bool has_rest_property) {
return PreParserExpression::ObjectLiteral(properties.variables_);
}
PreParserExpression NewVariableProxy(void* variable) {
......@@ -686,8 +693,9 @@ class PreParserFactory {
return PreParserExpression::Default();
}
PreParserExpression NewCall(
PreParserExpression expression, const PreParserExpressionList& arguments,
int pos, Call::PossiblyEval possibly_eval = Call::NOT_EVAL) {
PreParserExpression expression,
const PreParserScopedExpressionList& arguments, int pos,
Call::PossiblyEval possibly_eval = Call::NOT_EVAL) {
if (possibly_eval == Call::IS_POSSIBLY_EVAL) {
DCHECK(expression.IsIdentifier() && expression.AsIdentifier().IsEval());
return PreParserExpression::CallEval();
......@@ -695,12 +703,12 @@ class PreParserFactory {
return PreParserExpression::Call();
}
PreParserExpression NewTaggedTemplate(
PreParserExpression expression, const PreParserExpressionList& arguments,
int pos) {
PreParserExpression expression,
const PreParserScopedExpressionList& arguments, int pos) {
return PreParserExpression::CallTaggedTemplate();
}
PreParserExpression NewCallNew(const PreParserExpression& expression,
const PreParserExpressionList& arguments,
const PreParserScopedExpressionList& arguments,
int pos) {
return PreParserExpression::Default();
}
......@@ -800,8 +808,9 @@ class PreParserFactory {
return PreParserStatement::Default();
}
PreParserStatement NewCaseClause(const PreParserExpression& label,
PreParserStatementList statements) {
PreParserStatement NewCaseClause(
const PreParserExpression& label,
const PreParserScopedStatementList& statements) {
return PreParserStatement::Default();
}
......@@ -922,6 +931,9 @@ struct ParserTypes<PreParser> {
typedef PreParserFormalParameters FormalParameters;
typedef PreParserStatement Statement;
typedef PreParserStatementList StatementList;
typedef PreParserScopedStatementList ScopedStatementList;
typedef PreParserScopedExpressionList ScopedExpressionList;
typedef PreParserScopedExpressionList ScopedObjectPropertyList;
typedef PreParserStatement Block;
typedef PreParserStatement BreakableStatement;
typedef PreParserStatement IterationStatement;
......@@ -1082,13 +1094,13 @@ class PreParser : public ParserBase<PreParser> {
}
V8_INLINE void SetAsmModule() {}
V8_INLINE PreParserExpression SpreadCall(const PreParserExpression& function,
const PreParserExpressionList& args,
int pos,
Call::PossiblyEval possibly_eval);
V8_INLINE PreParserExpression
SpreadCall(const PreParserExpression& function,
const PreParserScopedExpressionList& args, int pos,
Call::PossiblyEval possibly_eval);
V8_INLINE PreParserExpression
SpreadCallNew(const PreParserExpression& function,
const PreParserExpressionList& args, int pos);
const PreParserScopedExpressionList& args, int pos);
V8_INLINE void RewriteDestructuringAssignments() {}
......@@ -1553,10 +1565,6 @@ class PreParser : public ParserBase<PreParser> {
V8_INLINE static PreParserExpression NullLiteralProperty() {
return PreParserExpression::Null();
}
V8_INLINE static PreParserExpressionList NullExpressionList() {
return PreParserExpressionList::Null();
}
V8_INLINE static PreParserStatementList NullStatementList() {
return PreParserStatementList::Null();
}
......@@ -1651,9 +1659,9 @@ class PreParser : public ParserBase<PreParser> {
return PreParserStatementList();
}
V8_INLINE PreParserExpression
NewV8Intrinsic(const PreParserIdentifier& name,
const PreParserExpressionList& arguments, int pos, bool* ok) {
V8_INLINE PreParserExpression NewV8Intrinsic(
const PreParserIdentifier& name,
const PreParserScopedExpressionList& arguments, int pos, bool* ok) {
return PreParserExpression::Default();
}
......@@ -1714,7 +1722,7 @@ class PreParser : public ParserBase<PreParser> {
}
V8_INLINE PreParserExpression
ExpressionListToExpression(const PreParserExpressionList& args) {
ExpressionListToExpression(const PreParserScopedExpressionList& args) {
return PreParserExpression::Default(args.variables_);
}
......@@ -1752,16 +1760,16 @@ class PreParser : public ParserBase<PreParser> {
PreParsedScopeDataBuilder* preparsed_scope_data_builder_;
};
PreParserExpression PreParser::SpreadCall(const PreParserExpression& function,
const PreParserExpressionList& args,
int pos,
Call::PossiblyEval possibly_eval) {
PreParserExpression PreParser::SpreadCall(
const PreParserExpression& function,
const PreParserScopedExpressionList& args, int pos,
Call::PossiblyEval possibly_eval) {
return factory()->NewCall(function, args, pos, possibly_eval);
}
PreParserExpression PreParser::SpreadCallNew(
const PreParserExpression& function, const PreParserExpressionList& args,
int pos) {
const PreParserExpression& function,
const PreParserScopedExpressionList& args, int pos) {
return factory()->NewCallNew(function, args, pos);
}
......
......@@ -225,6 +225,9 @@ class ZoneList final {
V8_INLINE int capacity() const { return capacity_; }
Vector<T> ToVector() const { return Vector<T>(data_, length_); }
Vector<T> ToVector(int start, int length) const {
return Vector<T>(data_ + start, Min(length_ - start, length));
}
Vector<const T> ToConstVector() const {
return Vector<const T>(data_, length_);
......@@ -318,6 +321,47 @@ class ZoneList final {
template <typename T>
using ZonePtrList = ZoneList<T*>;
template <typename T>
class ScopedPtrList final {
public:
ScopedPtrList(Zone* zone, ZonePtrList<T>* buffer)
: zone_(zone),
buffer_(buffer),
start_(buffer->length()),
end_(buffer->length()) {}
~ScopedPtrList() {
DCHECK_EQ(buffer_->length(), end_);
buffer_->Rewind(start_);
}
int length() const { return end_ - start_; }
T* at(int i) const { return buffer_->at(i + start_); }
void CopyTo(ZonePtrList<T>* target) const {
target->Initialize(length(), zone_);
target->AddAll(buffer_->ToVector(start_, length()), zone_);
}
void Add(T* value) {
DCHECK_EQ(buffer_->length(), end_);
buffer_->Add(value, zone_);
++end_;
}
void AddAll(const ZonePtrList<T>& list) {
DCHECK_EQ(buffer_->length(), end_);
buffer_->AddAll(list, zone_);
end_ += list.length();
}
private:
Zone* zone_;
ZonePtrList<T>* buffer_;
int start_;
int end_;
};
// ZoneThreadedList is a special variant of the ThreadedList that can be put
// into a Zone.
template <typename T, typename TLTraits = base::ThreadedListTraits<T>>
......
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