aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/ast
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2018-09-07 17:07:13 +0200
committerMichaël Zasso <targos@protonmail.com>2018-09-07 20:59:13 +0200
commit586db2414a338e1bf6eaf6e672a3adc7ce309f6a (patch)
tree139fa972aef648481ddee22a3a85b99707d28df5 /deps/v8/src/ast
parent12ed7c94e5160aa6d38e3d2cb2a73dae0a6f9342 (diff)
downloadandroid-node-v8-586db2414a338e1bf6eaf6e672a3adc7ce309f6a.tar.gz
android-node-v8-586db2414a338e1bf6eaf6e672a3adc7ce309f6a.tar.bz2
android-node-v8-586db2414a338e1bf6eaf6e672a3adc7ce309f6a.zip
deps: update V8 to 6.9.427.22
PR-URL: https://github.com/nodejs/node/pull/21983 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'deps/v8/src/ast')
-rw-r--r--deps/v8/src/ast/ast-traversal-visitor.h22
-rw-r--r--deps/v8/src/ast/ast-value-factory.cc2
-rw-r--r--deps/v8/src/ast/ast-value-factory.h10
-rw-r--r--deps/v8/src/ast/ast.cc121
-rw-r--r--deps/v8/src/ast/ast.h251
-rw-r--r--deps/v8/src/ast/compile-time-value.cc53
-rw-r--r--deps/v8/src/ast/compile-time-value.h46
-rw-r--r--deps/v8/src/ast/modules.cc17
-rw-r--r--deps/v8/src/ast/modules.h31
-rw-r--r--deps/v8/src/ast/prettyprinter.cc21
-rw-r--r--deps/v8/src/ast/prettyprinter.h16
-rw-r--r--deps/v8/src/ast/scopes.cc205
-rw-r--r--deps/v8/src/ast/scopes.h29
-rw-r--r--deps/v8/src/ast/variables.cc2
-rw-r--r--deps/v8/src/ast/variables.h9
15 files changed, 393 insertions, 442 deletions
diff --git a/deps/v8/src/ast/ast-traversal-visitor.h b/deps/v8/src/ast/ast-traversal-visitor.h
index 35432fa647..640de541b5 100644
--- a/deps/v8/src/ast/ast-traversal-visitor.h
+++ b/deps/v8/src/ast/ast-traversal-visitor.h
@@ -41,7 +41,7 @@ class AstTraversalVisitor : public AstVisitor<Subclass> {
// Iteration left-to-right.
void VisitDeclarations(Declaration::List* declarations);
- void VisitStatements(ZoneList<Statement*>* statements);
+ void VisitStatements(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(
- ZoneList<Statement*>* stmts) {
+ ZonePtrList<Statement>* stmts) {
for (int i = 0; i < stmts->length(); ++i) {
Statement* stmt = stmts->at(i);
RECURSE(Visit(stmt));
@@ -198,14 +198,14 @@ void AstTraversalVisitor<Subclass>::VisitSwitchStatement(
PROCESS_NODE(stmt);
RECURSE(Visit(stmt->tag()));
- ZoneList<CaseClause*>* clauses = stmt->cases();
+ ZonePtrList<CaseClause>* clauses = stmt->cases();
for (int i = 0; i < clauses->length(); ++i) {
CaseClause* clause = clauses->at(i);
if (!clause->is_default()) {
Expression* label = clause->label();
RECURSE(Visit(label));
}
- ZoneList<Statement*>* stmts = clause->statements();
+ 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);
- ZoneList<ObjectLiteralProperty*>* props = expr->properties();
+ 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);
- ZoneList<Expression*>* values = expr->values();
+ 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()));
- ZoneList<Expression*>* args = expr->arguments();
+ 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()));
- ZoneList<Expression*>* args = expr->arguments();
+ 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);
- ZoneList<Expression*>* args = expr->arguments();
+ ZonePtrList<Expression>* args = expr->arguments();
for (int i = 0; i < args->length(); ++i) {
Expression* arg = args->at(i);
RECURSE_EXPRESSION(Visit(arg));
@@ -487,7 +487,7 @@ void AstTraversalVisitor<Subclass>::VisitClassLiteral(ClassLiteral* expr) {
if (expr->instance_fields_initializer_function() != nullptr) {
RECURSE_EXPRESSION(Visit(expr->instance_fields_initializer_function()));
}
- ZoneList<ClassLiteralProperty*>* props = expr->properties();
+ ZonePtrList<ClassLiteral::Property>* props = expr->properties();
for (int i = 0; i < props->length(); ++i) {
ClassLiteralProperty* prop = props->at(i);
if (!prop->key()->IsLiteral()) {
@@ -501,7 +501,7 @@ template <class Subclass>
void AstTraversalVisitor<Subclass>::VisitInitializeClassFieldsStatement(
InitializeClassFieldsStatement* stmt) {
PROCESS_NODE(stmt);
- ZoneList<ClassLiteralProperty*>* props = stmt->fields();
+ ZonePtrList<ClassLiteral::Property>* props = stmt->fields();
for (int i = 0; i < props->length(); ++i) {
ClassLiteralProperty* prop = props->at(i);
if (!prop->key()->IsLiteral()) {
diff --git a/deps/v8/src/ast/ast-value-factory.cc b/deps/v8/src/ast/ast-value-factory.cc
index 5efecc5375..fc8be819f6 100644
--- a/deps/v8/src/ast/ast-value-factory.cc
+++ b/deps/v8/src/ast/ast-value-factory.cc
@@ -182,7 +182,7 @@ std::forward_list<const AstRawString*> AstConsString::ToRawStrings() const {
return result;
}
-AstStringConstants::AstStringConstants(Isolate* isolate, uint32_t hash_seed)
+AstStringConstants::AstStringConstants(Isolate* isolate, uint64_t hash_seed)
: zone_(isolate->allocator(), ZONE_NAME),
string_table_(AstRawString::Compare),
hash_seed_(hash_seed) {
diff --git a/deps/v8/src/ast/ast-value-factory.h b/deps/v8/src/ast/ast-value-factory.h
index a453455dd0..e85b0675bf 100644
--- a/deps/v8/src/ast/ast-value-factory.h
+++ b/deps/v8/src/ast/ast-value-factory.h
@@ -240,14 +240,14 @@ class AstBigInt {
class AstStringConstants final {
public:
- AstStringConstants(Isolate* isolate, uint32_t hash_seed);
+ AstStringConstants(Isolate* isolate, uint64_t hash_seed);
#define F(name, str) \
const AstRawString* name##_string() const { return name##_string_; }
AST_STRING_CONSTANTS(F)
#undef F
- uint32_t hash_seed() const { return hash_seed_; }
+ uint64_t hash_seed() const { return hash_seed_; }
const base::CustomMatcherHashMap* string_table() const {
return &string_table_;
}
@@ -255,7 +255,7 @@ class AstStringConstants final {
private:
Zone zone_;
base::CustomMatcherHashMap string_table_;
- uint32_t hash_seed_;
+ uint64_t hash_seed_;
#define F(name, str) AstRawString* name##_string_;
AST_STRING_CONSTANTS(F)
@@ -267,7 +267,7 @@ class AstStringConstants final {
class AstValueFactory {
public:
AstValueFactory(Zone* zone, const AstStringConstants* string_constants,
- uint32_t hash_seed)
+ uint64_t hash_seed)
: string_table_(string_constants->string_table()),
strings_(nullptr),
strings_end_(&strings_),
@@ -354,7 +354,7 @@ class AstValueFactory {
Zone* zone_;
- uint32_t hash_seed_;
+ uint64_t hash_seed_;
};
} // namespace internal
} // namespace v8
diff --git a/deps/v8/src/ast/ast.cc b/deps/v8/src/ast/ast.cc
index 15b8bff61b..5a4add6039 100644
--- a/deps/v8/src/ast/ast.cc
+++ b/deps/v8/src/ast/ast.cc
@@ -7,7 +7,6 @@
#include <cmath> // For isfinite.
#include <vector>
-#include "src/ast/compile-time-value.h"
#include "src/ast/prettyprinter.h"
#include "src/ast/scopes.h"
#include "src/base/hashmap.h"
@@ -19,6 +18,7 @@
#include "src/double.h"
#include "src/elements.h"
#include "src/objects-inl.h"
+#include "src/objects/literal-objects-inl.h"
#include "src/objects/literal-objects.h"
#include "src/objects/map.h"
#include "src/property-details.h"
@@ -114,6 +114,13 @@ bool Expression::IsTheHoleLiteral() const {
return IsLiteral() && AsLiteral()->type() == Literal::kTheHole;
}
+bool Expression::IsCompileTimeValue() {
+ if (IsLiteral()) return true;
+ MaterializedLiteral* literal = AsMaterializedLiteral();
+ if (literal == nullptr) return false;
+ return literal->IsSimple();
+}
+
bool Expression::IsUndefinedLiteral() const {
if (IsLiteral() && AsLiteral()->type() == Literal::kUndefined) return true;
@@ -334,8 +341,7 @@ ClassLiteralProperty::ClassLiteralProperty(Expression* key, Expression* value,
bool ObjectLiteral::Property::IsCompileTimeValue() const {
return kind_ == CONSTANT ||
- (kind_ == MATERIALIZED_LITERAL &&
- CompileTimeValue::IsCompileTimeValue(value_));
+ (kind_ == MATERIALIZED_LITERAL && value_->IsCompileTimeValue());
}
@@ -360,19 +366,37 @@ void ObjectLiteral::CalculateEmitStore(Zone* zone) {
Literal* literal = property->key()->AsLiteral();
DCHECK(!literal->IsNullLiteral());
- // If there is an existing entry do not emit a store unless the previous
- // entry was also an accessor.
uint32_t hash = literal->Hash();
ZoneHashMap::Entry* entry = table.LookupOrInsert(literal, hash, allocator);
- if (entry->value != nullptr) {
- auto previous_kind =
+ if (entry->value == nullptr) {
+ entry->value = property;
+ } else {
+ // We already have a later definition of this property, so we don't need
+ // to emit a store for the current one.
+ //
+ // There are two subtleties here.
+ //
+ // (1) Emitting a store might actually be incorrect. For example, in {get
+ // foo() {}, foo: 42}, the getter store would override the data property
+ // (which, being a non-computed compile-time valued property, is already
+ // part of the initial literal object.
+ //
+ // (2) If the later definition is an accessor (say, a getter), and the
+ // current definition is a complementary accessor (here, a setter), then
+ // we still must emit a store for the current definition.
+
+ auto later_kind =
static_cast<ObjectLiteral::Property*>(entry->value)->kind();
- if (!((property->kind() == GETTER && previous_kind == SETTER) ||
- (property->kind() == SETTER && previous_kind == GETTER))) {
+ bool complementary_accessors =
+ (property->kind() == GETTER && later_kind == SETTER) ||
+ (property->kind() == SETTER && later_kind == GETTER);
+ if (!complementary_accessors) {
property->set_emit_store(false);
+ if (later_kind == GETTER || later_kind == SETTER) {
+ entry->value = property;
+ }
}
}
- entry->value = property;
}
}
@@ -427,7 +451,7 @@ int ObjectLiteral::InitDepthAndFlags() {
Literal* key = property->key()->AsLiteral();
Expression* value = property->value();
- bool is_compile_time_value = CompileTimeValue::IsCompileTimeValue(value);
+ bool is_compile_time_value = value->IsCompileTimeValue();
is_simple = is_simple && is_compile_time_value;
// Keep track of the number of elements in the object literal and
@@ -454,8 +478,8 @@ int ObjectLiteral::InitDepthAndFlags() {
return depth_acc;
}
-void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
- if (!constant_properties_.is_null()) return;
+void ObjectLiteral::BuildBoilerplateDescription(Isolate* isolate) {
+ if (!boilerplate_description_.is_null()) return;
int index_keys = 0;
bool has_seen_proto = false;
@@ -476,17 +500,17 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
}
}
- Handle<BoilerplateDescription> constant_properties =
- isolate->factory()->NewBoilerplateDescription(boilerplate_properties_,
- properties()->length(),
- index_keys, has_seen_proto);
+ Handle<ObjectBoilerplateDescription> boilerplate_description =
+ isolate->factory()->NewObjectBoilerplateDescription(
+ boilerplate_properties_, properties()->length(), index_keys,
+ has_seen_proto);
int position = 0;
for (int i = 0; i < properties()->length(); i++) {
ObjectLiteral::Property* property = properties()->at(i);
if (property->IsPrototype()) continue;
- if (static_cast<uint32_t>(position) == boilerplate_properties_ * 2) {
+ if (static_cast<uint32_t>(position) == boilerplate_properties_) {
DCHECK(property->is_computed_name());
break;
}
@@ -510,11 +534,12 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
Handle<Object> value = GetBoilerplateValue(property->value(), isolate);
// Add name, value pair to the fixed array.
- constant_properties->set(position++, *key);
- constant_properties->set(position++, *value);
+ boilerplate_description->set_key_value(position++, *key, *value);
}
- constant_properties_ = constant_properties;
+ boilerplate_description->set_flags(EncodeLiteralType());
+
+ boilerplate_description_ = boilerplate_description;
}
bool ObjectLiteral::IsFastCloningSupported() const {
@@ -528,8 +553,8 @@ bool ObjectLiteral::IsFastCloningSupported() const {
bool ArrayLiteral::is_empty() const {
DCHECK(is_initialized());
- return values()->is_empty() &&
- (constant_elements().is_null() || constant_elements()->is_empty());
+ return values()->is_empty() && (boilerplate_description().is_null() ||
+ boilerplate_description()->is_empty());
}
int ArrayLiteral::InitDepthAndFlags() {
@@ -550,7 +575,7 @@ int ArrayLiteral::InitDepthAndFlags() {
if (subliteral_depth > depth_acc) depth_acc = subliteral_depth;
}
- if (!CompileTimeValue::IsCompileTimeValue(element)) {
+ if (!element->IsCompileTimeValue()) {
is_simple = false;
}
}
@@ -563,8 +588,8 @@ int ArrayLiteral::InitDepthAndFlags() {
return depth_acc;
}
-void ArrayLiteral::BuildConstantElements(Isolate* isolate) {
- if (!constant_elements_.is_null()) return;
+void ArrayLiteral::BuildBoilerplateDescription(Isolate* isolate) {
+ if (!boilerplate_description_.is_null()) return;
int constants_length =
first_spread_index_ >= 0 ? first_spread_index_ : values()->length();
@@ -606,7 +631,7 @@ void ArrayLiteral::BuildConstantElements(Isolate* isolate) {
// elements array to a copy-on-write array.
if (is_simple() && depth() == 1 && array_index > 0 &&
IsSmiOrObjectElementsKind(kind)) {
- fixed_array->set_map(isolate->heap()->fixed_cow_array_map());
+ fixed_array->set_map(ReadOnlyRoots(isolate).fixed_cow_array_map());
}
Handle<FixedArrayBase> elements = fixed_array;
@@ -615,14 +640,12 @@ void ArrayLiteral::BuildConstantElements(Isolate* isolate) {
elements = isolate->factory()->NewFixedDoubleArray(constants_length);
// We are copying from non-fast-double to fast-double.
ElementsKind from_kind = TERMINAL_FAST_ELEMENTS_KIND;
- accessor->CopyElements(fixed_array, from_kind, elements, constants_length);
+ accessor->CopyElements(isolate, fixed_array, from_kind, elements,
+ constants_length);
}
- // Remember both the literal's constant values as well as the ElementsKind.
- Handle<ConstantElementsPair> literals =
- isolate->factory()->NewConstantElementsPair(kind, elements);
-
- constant_elements_ = literals;
+ boilerplate_description_ =
+ isolate->factory()->NewArrayBoilerplateDescription(kind, elements);
}
bool ArrayLiteral::IsFastCloningSupported() const {
@@ -643,8 +666,17 @@ Handle<Object> MaterializedLiteral::GetBoilerplateValue(Expression* expression,
if (expression->IsLiteral()) {
return expression->AsLiteral()->BuildValue(isolate);
}
- if (CompileTimeValue::IsCompileTimeValue(expression)) {
- return CompileTimeValue::GetValue(isolate, expression);
+ if (expression->IsCompileTimeValue()) {
+ if (expression->IsObjectLiteral()) {
+ ObjectLiteral* object_literal = expression->AsObjectLiteral();
+ DCHECK(object_literal->is_simple());
+ return object_literal->boilerplate_description();
+ } else {
+ DCHECK(expression->IsArrayLiteral());
+ ArrayLiteral* array_literal = expression->AsArrayLiteral();
+ DCHECK(array_literal->is_simple());
+ return array_literal->boilerplate_description();
+ }
}
return isolate->factory()->uninitialized_value();
}
@@ -669,10 +701,12 @@ bool MaterializedLiteral::NeedsInitialAllocationSite() {
void MaterializedLiteral::BuildConstants(Isolate* isolate) {
if (IsArrayLiteral()) {
- return AsArrayLiteral()->BuildConstantElements(isolate);
+ AsArrayLiteral()->BuildBoilerplateDescription(isolate);
+ return;
}
if (IsObjectLiteral()) {
- return AsObjectLiteral()->BuildConstantProperties(isolate);
+ AsObjectLiteral()->BuildBoilerplateDescription(isolate);
+ return;
}
DCHECK(IsRegExpLiteral());
}
@@ -698,7 +732,7 @@ Handle<TemplateObjectDescription> GetTemplateObject::GetOrBuildDescription(
if (this->cooked_strings()->at(i) != nullptr) {
cooked_strings->set(i, *this->cooked_strings()->at(i)->string());
} else {
- cooked_strings->set(i, isolate->heap()->undefined_value());
+ cooked_strings->set(i, ReadOnlyRoots(isolate).undefined_value());
}
}
}
@@ -806,9 +840,10 @@ Call::CallType Call::GetCallType() const {
if (proxy->var()->IsUnallocated()) {
return GLOBAL_CALL;
} else if (proxy->var()->IsLookupSlot()) {
- // Calls going through 'with' always use DYNAMIC rather than DYNAMIC_LOCAL
- // or DYNAMIC_GLOBAL.
- return proxy->var()->mode() == DYNAMIC ? WITH_CALL : OTHER_CALL;
+ // Calls going through 'with' always use VariableMode::kDynamic rather
+ // than VariableMode::kDynamicLocal or VariableMode::kDynamicGlobal.
+ return proxy->var()->mode() == VariableMode::kDynamic ? WITH_CALL
+ : OTHER_CALL;
}
}
@@ -831,7 +866,7 @@ Call::CallType Call::GetCallType() const {
return OTHER_CALL;
}
-CaseClause::CaseClause(Expression* label, ZoneList<Statement*>* statements)
+CaseClause::CaseClause(Expression* label, ZonePtrList<Statement>* statements)
: label_(label), statements_(statements) {}
bool Literal::IsPropertyName() const {
@@ -954,7 +989,7 @@ const char* CallRuntime::debug_name() {
case k##NodeType: \
return static_cast<const NodeType*>(this)->labels();
-ZoneList<const AstRawString*>* BreakableStatement::labels() const {
+ZonePtrList<const AstRawString>* BreakableStatement::labels() const {
switch (node_type()) {
BREAKABLE_NODE_LIST(RETURN_LABELS)
ITERATION_NODE_LIST(RETURN_LABELS)
diff --git a/deps/v8/src/ast/ast.h b/deps/v8/src/ast/ast.h
index 35dede266b..5a2346ad9f 100644
--- a/deps/v8/src/ast/ast.h
+++ b/deps/v8/src/ast/ast.h
@@ -241,6 +241,8 @@ class Expression : public AstNode {
// that this also checks for loads of the global "undefined" variable.
bool IsUndefinedLiteral() const;
+ bool IsCompileTimeValue();
+
protected:
Expression(int pos, NodeType type) : AstNode(pos, type) {}
@@ -255,7 +257,7 @@ class BreakableStatement : public Statement {
TARGET_FOR_NAMED_ONLY
};
- ZoneList<const AstRawString*>* labels() const;
+ ZonePtrList<const AstRawString>* labels() const;
// Testers.
bool is_target_for_anonymous() const {
@@ -277,12 +279,12 @@ class BreakableStatement : public Statement {
class Block : public BreakableStatement {
public:
- ZoneList<Statement*>* statements() { return &statements_; }
+ ZonePtrList<Statement>* statements() { return &statements_; }
bool ignore_completion_value() const {
return IgnoreCompletionField::decode(bit_field_);
}
- inline ZoneList<const AstRawString*>* labels() const;
+ inline ZonePtrList<const AstRawString>* labels() const;
bool IsJump() const {
return !statements_.is_empty() && statements_.last()->IsJump() &&
@@ -295,7 +297,7 @@ class Block : public BreakableStatement {
private:
friend class AstNodeFactory;
- ZoneList<Statement*> statements_;
+ ZonePtrList<Statement> statements_;
Scope* scope_;
class IgnoreCompletionField
@@ -304,7 +306,7 @@ class Block : public BreakableStatement {
: public BitField<bool, IgnoreCompletionField::kNext, 1> {};
protected:
- Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity,
+ Block(Zone* zone, ZonePtrList<const AstRawString>* labels, int capacity,
bool ignore_completion_value)
: BreakableStatement(TARGET_FOR_NAMED_ONLY, kNoSourcePosition, kBlock),
statements_(capacity, zone),
@@ -319,18 +321,18 @@ class LabeledBlock final : public Block {
friend class AstNodeFactory;
friend class Block;
- LabeledBlock(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity,
- bool ignore_completion_value)
+ LabeledBlock(Zone* zone, ZonePtrList<const AstRawString>* labels,
+ int capacity, bool ignore_completion_value)
: Block(zone, labels, capacity, ignore_completion_value),
labels_(labels) {
DCHECK_NOT_NULL(labels);
DCHECK_GT(labels->length(), 0);
}
- ZoneList<const AstRawString*>* labels_;
+ ZonePtrList<const AstRawString>* labels_;
};
-inline ZoneList<const AstRawString*>* Block::labels() const {
+inline ZonePtrList<const AstRawString>* Block::labels() const {
if (IsLabeledField::decode(bit_field_)) {
return static_cast<const LabeledBlock*>(this)->labels_;
}
@@ -437,10 +439,10 @@ class IterationStatement : public BreakableStatement {
Statement* body() const { return body_; }
void set_body(Statement* s) { body_ = s; }
- ZoneList<const AstRawString*>* labels() const { return labels_; }
+ ZonePtrList<const AstRawString>* labels() const { return labels_; }
protected:
- IterationStatement(ZoneList<const AstRawString*>* labels, int pos,
+ IterationStatement(ZonePtrList<const AstRawString>* labels, int pos,
NodeType type)
: BreakableStatement(TARGET_FOR_ANONYMOUS, pos, type),
labels_(labels),
@@ -451,7 +453,7 @@ class IterationStatement : public BreakableStatement {
BreakableStatement::kNextBitFieldIndex;
private:
- ZoneList<const AstRawString*>* labels_;
+ ZonePtrList<const AstRawString>* labels_;
Statement* body_;
};
@@ -468,7 +470,7 @@ class DoWhileStatement final : public IterationStatement {
private:
friend class AstNodeFactory;
- DoWhileStatement(ZoneList<const AstRawString*>* labels, int pos)
+ DoWhileStatement(ZonePtrList<const AstRawString>* labels, int pos)
: IterationStatement(labels, pos, kDoWhileStatement), cond_(nullptr) {}
Expression* cond_;
@@ -487,7 +489,7 @@ class WhileStatement final : public IterationStatement {
private:
friend class AstNodeFactory;
- WhileStatement(ZoneList<const AstRawString*>* labels, int pos)
+ WhileStatement(ZonePtrList<const AstRawString>* labels, int pos)
: IterationStatement(labels, pos, kWhileStatement), cond_(nullptr) {}
Expression* cond_;
@@ -511,7 +513,7 @@ class ForStatement final : public IterationStatement {
private:
friend class AstNodeFactory;
- ForStatement(ZoneList<const AstRawString*>* labels, int pos)
+ ForStatement(ZonePtrList<const AstRawString>* labels, int pos)
: IterationStatement(labels, pos, kForStatement),
init_(nullptr),
cond_(nullptr),
@@ -537,7 +539,7 @@ class ForEachStatement : public IterationStatement {
}
protected:
- ForEachStatement(ZoneList<const AstRawString*>* labels, int pos,
+ ForEachStatement(ZonePtrList<const AstRawString>* labels, int pos,
NodeType type)
: IterationStatement(labels, pos, type) {}
};
@@ -564,7 +566,7 @@ class ForInStatement final : public ForEachStatement {
private:
friend class AstNodeFactory;
- ForInStatement(ZoneList<const AstRawString*>* labels, int pos)
+ ForInStatement(ZonePtrList<const AstRawString>* labels, int pos)
: ForEachStatement(labels, pos, kForInStatement),
each_(nullptr),
subject_(nullptr) {
@@ -630,7 +632,7 @@ class ForOfStatement final : public ForEachStatement {
private:
friend class AstNodeFactory;
- ForOfStatement(ZoneList<const AstRawString*>* labels, int pos)
+ ForOfStatement(ZonePtrList<const AstRawString>* labels, int pos)
: ForEachStatement(labels, pos, kForOfStatement),
iterator_(nullptr),
assign_iterator_(nullptr),
@@ -757,40 +759,40 @@ class CaseClause final : public ZoneObject {
DCHECK(!is_default());
return label_;
}
- ZoneList<Statement*>* statements() const { return statements_; }
+ ZonePtrList<Statement>* statements() const { return statements_; }
private:
friend class AstNodeFactory;
- CaseClause(Expression* label, ZoneList<Statement*>* statements);
+ CaseClause(Expression* label, ZonePtrList<Statement>* statements);
Expression* label_;
- ZoneList<Statement*>* statements_;
+ ZonePtrList<Statement>* statements_;
};
class SwitchStatement final : public BreakableStatement {
public:
- ZoneList<const AstRawString*>* labels() const { return labels_; }
+ ZonePtrList<const AstRawString>* labels() const { return labels_; }
Expression* tag() const { return tag_; }
void set_tag(Expression* t) { tag_ = t; }
- ZoneList<CaseClause*>* cases() { return &cases_; }
+ ZonePtrList<CaseClause>* cases() { return &cases_; }
private:
friend class AstNodeFactory;
- SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels,
+ SwitchStatement(Zone* zone, ZonePtrList<const AstRawString>* labels,
Expression* tag, int pos)
: BreakableStatement(TARGET_FOR_ANONYMOUS, pos, kSwitchStatement),
labels_(labels),
tag_(tag),
cases_(4, zone) {}
- ZoneList<const AstRawString*>* labels_;
+ ZonePtrList<const AstRawString>* labels_;
Expression* tag_;
- ZoneList<CaseClause*> cases_;
+ ZonePtrList<CaseClause> cases_;
};
@@ -1120,8 +1122,8 @@ class MaterializedLiteral : public Expression {
void BuildConstants(Isolate* isolate);
// If the expression is a literal, return the literal value;
- // if the expression is a materialized literal and is simple return a
- // compile time value as encoded by CompileTimeValue::GetValue().
+ // if the expression is a materialized literal and is_simple
+ // then return an Array or Object Boilerplate Description
// Otherwise, return undefined literal as the placeholder
// in the object literal boilerplate.
Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate);
@@ -1275,12 +1277,12 @@ class ObjectLiteral final : public AggregateLiteral {
public:
typedef ObjectLiteralProperty Property;
- Handle<BoilerplateDescription> constant_properties() const {
- DCHECK(!constant_properties_.is_null());
- return constant_properties_;
+ Handle<ObjectBoilerplateDescription> boilerplate_description() const {
+ DCHECK(!boilerplate_description_.is_null());
+ return boilerplate_description_;
}
int properties_count() const { return boilerplate_properties_; }
- ZoneList<Property*>* properties() const { return properties_; }
+ ZonePtrList<Property>* properties() const { return properties_; }
bool has_elements() const { return HasElementsField::decode(bit_field_); }
bool has_rest_property() const {
return HasRestPropertyField::decode(bit_field_);
@@ -1303,17 +1305,17 @@ class ObjectLiteral final : public AggregateLiteral {
// Populate the depth field and flags, returns the depth.
int InitDepthAndFlags();
- // Get the constant properties fixed array, populating it if necessary.
- Handle<BoilerplateDescription> GetOrBuildConstantProperties(
+ // Get the boilerplate description, populating it if necessary.
+ Handle<ObjectBoilerplateDescription> GetOrBuildBoilerplateDescription(
Isolate* isolate) {
- if (constant_properties_.is_null()) {
- BuildConstantProperties(isolate);
+ if (boilerplate_description_.is_null()) {
+ BuildBoilerplateDescription(isolate);
}
- return constant_properties();
+ return boilerplate_description();
}
- // Populate the constant properties fixed array.
- void BuildConstantProperties(Isolate* isolate);
+ // Populate the boilerplate description.
+ void BuildBoilerplateDescription(Isolate* isolate);
// Mark all computed expressions that are bound to a key that
// is shadowed by a later occurrence of the same key. For the
@@ -1355,7 +1357,7 @@ class ObjectLiteral final : public AggregateLiteral {
private:
friend class AstNodeFactory;
- ObjectLiteral(ZoneList<Property*>* properties,
+ ObjectLiteral(ZonePtrList<Property>* properties,
uint32_t boilerplate_properties, int pos,
bool has_rest_property)
: AggregateLiteral(pos, kObjectLiteral),
@@ -1380,7 +1382,7 @@ class ObjectLiteral final : public AggregateLiteral {
}
uint32_t boilerplate_properties_;
- Handle<BoilerplateDescription> constant_properties_;
+ Handle<ObjectBoilerplateDescription> boilerplate_description_;
ZoneList<Property*>* properties_;
class HasElementsField
@@ -1423,11 +1425,11 @@ class AccessorTable
// for minimizing the work when constructing it at runtime.
class ArrayLiteral final : public AggregateLiteral {
public:
- Handle<ConstantElementsPair> constant_elements() const {
- return constant_elements_;
+ Handle<ArrayBoilerplateDescription> boilerplate_description() const {
+ return boilerplate_description_;
}
- ZoneList<Expression*>* values() const { return values_; }
+ ZonePtrList<Expression>* values() const { return values_; }
int first_spread_index() const { return first_spread_index_; }
@@ -1436,16 +1438,17 @@ class ArrayLiteral final : public AggregateLiteral {
// Populate the depth field and flags, returns the depth.
int InitDepthAndFlags();
- // Get the constant elements fixed array, populating it if necessary.
- Handle<ConstantElementsPair> GetOrBuildConstantElements(Isolate* isolate) {
- if (constant_elements_.is_null()) {
- BuildConstantElements(isolate);
+ // Get the boilerplate description, populating it if necessary.
+ Handle<ArrayBoilerplateDescription> GetOrBuildBoilerplateDescription(
+ Isolate* isolate) {
+ if (boilerplate_description_.is_null()) {
+ BuildBoilerplateDescription(isolate);
}
- return constant_elements();
+ return boilerplate_description();
}
- // Populate the constant elements fixed array.
- void BuildConstantElements(Isolate* isolate);
+ // Populate the boilerplate description.
+ void BuildBoilerplateDescription(Isolate* isolate);
// Determines whether the {CreateShallowArrayLiteral} builtin can be used.
bool IsFastCloningSupported() const;
@@ -1458,15 +1461,14 @@ class ArrayLiteral final : public AggregateLiteral {
private:
friend class AstNodeFactory;
- ArrayLiteral(ZoneList<Expression*>* values, int first_spread_index, int pos)
+ ArrayLiteral(ZonePtrList<Expression>* values, int first_spread_index, int pos)
: AggregateLiteral(pos, kArrayLiteral),
first_spread_index_(first_spread_index),
- values_(values) {
- }
+ values_(values) {}
int first_spread_index_;
- Handle<ConstantElementsPair> constant_elements_;
- ZoneList<Expression*>* values_;
+ Handle<ArrayBoilerplateDescription> boilerplate_description_;
+ ZonePtrList<Expression>* values_;
};
enum class HoleCheckMode { kRequired, kElided };
@@ -1633,7 +1635,7 @@ class ResolvedProperty final : public Expression {
class Call final : public Expression {
public:
Expression* expression() const { return expression_; }
- ZoneList<Expression*>* arguments() const { return arguments_; }
+ ZonePtrList<Expression>* arguments() const { return arguments_; }
bool is_possibly_eval() const {
return IsPossiblyEvalField::decode(bit_field_);
@@ -1672,17 +1674,15 @@ class Call final : public Expression {
private:
friend class AstNodeFactory;
- Call(Expression* expression, ZoneList<Expression*>* arguments, int pos,
+ Call(Expression* expression, ZonePtrList<Expression>* arguments, int pos,
PossiblyEval possibly_eval)
- : Expression(pos, kCall),
- expression_(expression),
- arguments_(arguments) {
+ : Expression(pos, kCall), expression_(expression), arguments_(arguments) {
bit_field_ |=
IsPossiblyEvalField::encode(possibly_eval == IS_POSSIBLY_EVAL) |
IsTaggedTemplateField::encode(false);
}
- Call(Expression* expression, ZoneList<Expression*>* arguments, int pos,
+ Call(Expression* expression, ZonePtrList<Expression>* arguments, int pos,
TaggedTemplateTag tag)
: Expression(pos, kCall), expression_(expression), arguments_(arguments) {
bit_field_ |= IsPossiblyEvalField::encode(false) |
@@ -1695,14 +1695,14 @@ class Call final : public Expression {
: public BitField<bool, IsPossiblyEvalField::kNext, 1> {};
Expression* expression_;
- ZoneList<Expression*>* arguments_;
+ ZonePtrList<Expression>* arguments_;
};
class CallNew final : public Expression {
public:
Expression* expression() const { return expression_; }
- ZoneList<Expression*>* arguments() const { return arguments_; }
+ ZonePtrList<Expression>* arguments() const { return arguments_; }
bool only_last_arg_is_spread() {
return !arguments_->is_empty() && arguments_->last()->IsSpread();
@@ -1711,14 +1711,13 @@ class CallNew final : public Expression {
private:
friend class AstNodeFactory;
- CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos)
+ CallNew(Expression* expression, ZonePtrList<Expression>* arguments, int pos)
: Expression(pos, kCallNew),
expression_(expression),
- arguments_(arguments) {
- }
+ arguments_(arguments) {}
Expression* expression_;
- ZoneList<Expression*>* arguments_;
+ ZonePtrList<Expression>* arguments_;
};
// The CallRuntime class does not represent any official JavaScript
@@ -1727,7 +1726,7 @@ class CallNew final : public Expression {
// implemented in JavaScript.
class CallRuntime final : public Expression {
public:
- ZoneList<Expression*>* arguments() const { return arguments_; }
+ ZonePtrList<Expression>* arguments() const { return arguments_; }
bool is_jsruntime() const { return function_ == nullptr; }
int context_index() const {
@@ -1745,11 +1744,11 @@ class CallRuntime final : public Expression {
friend class AstNodeFactory;
CallRuntime(const Runtime::Function* function,
- ZoneList<Expression*>* arguments, int pos)
+ ZonePtrList<Expression>* arguments, int pos)
: Expression(pos, kCallRuntime),
function_(function),
arguments_(arguments) {}
- CallRuntime(int context_index, ZoneList<Expression*>* arguments, int pos)
+ CallRuntime(int context_index, ZonePtrList<Expression>* arguments, int pos)
: Expression(pos, kCallRuntime),
context_index_(context_index),
function_(nullptr),
@@ -1757,7 +1756,7 @@ class CallRuntime final : public Expression {
int context_index_;
const Runtime::Function* function_;
- ZoneList<Expression*>* arguments_;
+ ZonePtrList<Expression>* arguments_;
};
@@ -2190,7 +2189,7 @@ class FunctionLiteral final : public Expression {
const AstConsString* raw_name() const { return raw_name_; }
void set_raw_name(const AstConsString* name) { raw_name_ = name; }
DeclarationScope* scope() const { return scope_; }
- ZoneList<Statement*>* body() const { return body_; }
+ ZonePtrList<Statement>* body() const { return body_; }
void set_function_token_position(int pos) { function_token_position_ = pos; }
int function_token_position() const { return function_token_position_; }
int start_position() const;
@@ -2310,7 +2309,7 @@ class FunctionLiteral final : public Expression {
FunctionLiteral(
Zone* zone, const AstRawString* name, AstValueFactory* ast_value_factory,
- DeclarationScope* scope, ZoneList<Statement*>* body,
+ DeclarationScope* scope, ZonePtrList<Statement>* body,
int expected_property_count, int parameter_count, int function_length,
FunctionType function_type, ParameterFlag has_duplicate_parameters,
EagerCompileHint eager_compile_hint, int position, bool has_braces,
@@ -2359,7 +2358,7 @@ class FunctionLiteral final : public Expression {
const AstConsString* raw_name_;
DeclarationScope* scope_;
- ZoneList<Statement*>* body_;
+ ZonePtrList<Statement>* body_;
const AstConsString* raw_inferred_name_;
Handle<String> inferred_name_;
ProducedPreParsedScopeData* produced_preparsed_scope_data_;
@@ -2407,15 +2406,16 @@ class ClassLiteralProperty final : public LiteralProperty {
class InitializeClassFieldsStatement final : public Statement {
public:
typedef ClassLiteralProperty Property;
- ZoneList<Property*>* fields() const { return fields_; }
+
+ ZonePtrList<Property>* fields() const { return fields_; }
private:
friend class AstNodeFactory;
- InitializeClassFieldsStatement(ZoneList<Property*>* fields, int pos)
+ InitializeClassFieldsStatement(ZonePtrList<Property>* fields, int pos)
: Statement(pos, kInitializeClassFieldsStatement), fields_(fields) {}
- ZoneList<Property*>* fields_;
+ ZonePtrList<Property>* fields_;
};
class ClassLiteral final : public Expression {
@@ -2426,7 +2426,7 @@ class ClassLiteral final : public Expression {
Variable* class_variable() const { return class_variable_; }
Expression* extends() const { return extends_; }
FunctionLiteral* constructor() const { return constructor_; }
- ZoneList<Property*>* properties() const { return properties_; }
+ ZonePtrList<Property>* properties() const { return properties_; }
int start_position() const { return position(); }
int end_position() const { return end_position_; }
bool has_name_static_property() const {
@@ -2455,7 +2455,7 @@ class ClassLiteral final : public Expression {
friend class AstNodeFactory;
ClassLiteral(Scope* scope, Variable* class_variable, Expression* extends,
- FunctionLiteral* constructor, ZoneList<Property*>* properties,
+ FunctionLiteral* constructor, ZonePtrList<Property>* properties,
FunctionLiteral* static_fields_initializer,
FunctionLiteral* instance_fields_initializer_function,
int start_position, int end_position,
@@ -2481,7 +2481,7 @@ class ClassLiteral final : public Expression {
Variable* class_variable_;
Expression* extends_;
FunctionLiteral* constructor_;
- ZoneList<Property*>* properties_;
+ ZonePtrList<Property>* properties_;
FunctionLiteral* static_fields_initializer_;
FunctionLiteral* instance_fields_initializer_function_;
class HasNameStaticProperty
@@ -2636,10 +2636,10 @@ class GetIterator final : public Expression {
// (defined at https://tc39.github.io/ecma262/#sec-gettemplateobject).
class GetTemplateObject final : public Expression {
public:
- const ZoneList<const AstRawString*>* cooked_strings() const {
+ const ZonePtrList<const AstRawString>* cooked_strings() const {
return cooked_strings_;
}
- const ZoneList<const AstRawString*>* raw_strings() const {
+ const ZonePtrList<const AstRawString>* raw_strings() const {
return raw_strings_;
}
@@ -2648,34 +2648,35 @@ class GetTemplateObject final : public Expression {
private:
friend class AstNodeFactory;
- GetTemplateObject(const ZoneList<const AstRawString*>* cooked_strings,
- const ZoneList<const AstRawString*>* raw_strings, int pos)
+ GetTemplateObject(const ZonePtrList<const AstRawString>* cooked_strings,
+ const ZonePtrList<const AstRawString>* raw_strings, int pos)
: Expression(pos, kGetTemplateObject),
cooked_strings_(cooked_strings),
raw_strings_(raw_strings) {}
- const ZoneList<const AstRawString*>* cooked_strings_;
- const ZoneList<const AstRawString*>* raw_strings_;
+ const ZonePtrList<const AstRawString>* cooked_strings_;
+ const ZonePtrList<const AstRawString>* raw_strings_;
};
class TemplateLiteral final : public Expression {
public:
- using StringList = ZoneList<const AstRawString*>;
- using ExpressionList = ZoneList<Expression*>;
-
- const StringList* string_parts() const { return string_parts_; }
- const ExpressionList* substitutions() const { return substitutions_; }
+ const ZonePtrList<const AstRawString>* string_parts() const {
+ return string_parts_;
+ }
+ const ZonePtrList<Expression>* substitutions() const {
+ return substitutions_;
+ }
private:
friend class AstNodeFactory;
- TemplateLiteral(const StringList* parts, const ExpressionList* substitutions,
- int pos)
+ TemplateLiteral(const ZonePtrList<const AstRawString>* parts,
+ const ZonePtrList<Expression>* substitutions, int pos)
: Expression(pos, kTemplateLiteral),
string_parts_(parts),
substitutions_(substitutions) {}
- const StringList* string_parts_;
- const ExpressionList* substitutions_;
+ const ZonePtrList<const AstRawString>* string_parts_;
+ const ZonePtrList<Expression>* substitutions_;
};
// ----------------------------------------------------------------------------
@@ -2692,7 +2693,7 @@ class AstVisitor BASE_EMBEDDED {
for (Declaration* decl : *declarations) Visit(decl);
}
- void VisitStatements(ZoneList<Statement*>* statements) {
+ void VisitStatements(ZonePtrList<Statement>* statements) {
for (int i = 0; i < statements->length(); i++) {
Statement* stmt = statements->at(i);
Visit(stmt);
@@ -2700,7 +2701,7 @@ class AstVisitor BASE_EMBEDDED {
}
}
- void VisitExpressions(ZoneList<Expression*>* expressions) {
+ void VisitExpressions(ZonePtrList<Expression>* expressions) {
for (int i = 0; i < expressions->length(); i++) {
// The variable statement visiting code may pass null expressions
// to this code. Maybe this should be handled by introducing an
@@ -2794,7 +2795,7 @@ class AstNodeFactory final BASE_EMBEDDED {
}
Block* NewBlock(int capacity, bool ignore_completion_value,
- ZoneList<const AstRawString*>* labels = nullptr) {
+ ZonePtrList<const AstRawString>* labels = nullptr) {
return labels != nullptr
? new (zone_) LabeledBlock(zone_, labels, capacity,
ignore_completion_value)
@@ -2802,22 +2803,22 @@ class AstNodeFactory final BASE_EMBEDDED {
Block(zone_, labels, capacity, ignore_completion_value);
}
-#define STATEMENT_WITH_LABELS(NodeType) \
- NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \
- return new (zone_) NodeType(labels, pos); \
+#define STATEMENT_WITH_LABELS(NodeType) \
+ NodeType* New##NodeType(ZonePtrList<const AstRawString>* labels, int pos) { \
+ return new (zone_) NodeType(labels, pos); \
}
STATEMENT_WITH_LABELS(DoWhileStatement)
STATEMENT_WITH_LABELS(WhileStatement)
STATEMENT_WITH_LABELS(ForStatement)
#undef STATEMENT_WITH_LABELS
- SwitchStatement* NewSwitchStatement(ZoneList<const AstRawString*>* labels,
+ SwitchStatement* NewSwitchStatement(ZonePtrList<const AstRawString>* labels,
Expression* tag, int pos) {
return new (zone_) SwitchStatement(zone_, labels, tag, pos);
}
ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode,
- ZoneList<const AstRawString*>* labels,
+ ZonePtrList<const AstRawString>* labels,
int pos) {
switch (visit_mode) {
case ForEachStatement::ENUMERATE: {
@@ -2830,7 +2831,7 @@ class AstNodeFactory final BASE_EMBEDDED {
UNREACHABLE();
}
- ForOfStatement* NewForOfStatement(ZoneList<const AstRawString*>* labels,
+ ForOfStatement* NewForOfStatement(ZonePtrList<const AstRawString>* labels,
int pos) {
return new (zone_) ForOfStatement(labels, pos);
}
@@ -2921,7 +2922,7 @@ class AstNodeFactory final BASE_EMBEDDED {
}
CaseClause* NewCaseClause(Expression* label,
- ZoneList<Statement*>* statements) {
+ ZonePtrList<Statement>* statements) {
return new (zone_) CaseClause(label, statements);
}
@@ -2961,7 +2962,7 @@ class AstNodeFactory final BASE_EMBEDDED {
}
ObjectLiteral* NewObjectLiteral(
- ZoneList<ObjectLiteral::Property*>* properties,
+ ZonePtrList<ObjectLiteral::Property>* properties,
uint32_t boilerplate_properties, int pos, bool has_rest_property) {
return new (zone_) ObjectLiteral(properties, boilerplate_properties, pos,
has_rest_property);
@@ -2986,12 +2987,11 @@ class AstNodeFactory final BASE_EMBEDDED {
return new (zone_) RegExpLiteral(pattern, flags, pos);
}
- ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
- int pos) {
+ ArrayLiteral* NewArrayLiteral(ZonePtrList<Expression>* values, int pos) {
return new (zone_) ArrayLiteral(values, -1, pos);
}
- ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
+ ArrayLiteral* NewArrayLiteral(ZonePtrList<Expression>* values,
int first_spread_index, int pos) {
return new (zone_) ArrayLiteral(values, first_spread_index, pos);
}
@@ -3027,35 +3027,34 @@ class AstNodeFactory final BASE_EMBEDDED {
return new (zone_) ResolvedProperty(obj, property, pos);
}
- Call* NewCall(Expression* expression, ZoneList<Expression*>* arguments,
+ Call* NewCall(Expression* expression, ZonePtrList<Expression>* arguments,
int pos, Call::PossiblyEval possibly_eval = Call::NOT_EVAL) {
return new (zone_) Call(expression, arguments, pos, possibly_eval);
}
Call* NewTaggedTemplate(Expression* expression,
- ZoneList<Expression*>* arguments, int pos) {
+ ZonePtrList<Expression>* arguments, int pos) {
return new (zone_)
Call(expression, arguments, pos, Call::TaggedTemplateTag::kTrue);
}
CallNew* NewCallNew(Expression* expression,
- ZoneList<Expression*>* arguments,
- int pos) {
+ ZonePtrList<Expression>* arguments, int pos) {
return new (zone_) CallNew(expression, arguments, pos);
}
CallRuntime* NewCallRuntime(Runtime::FunctionId id,
- ZoneList<Expression*>* arguments, int pos) {
+ ZonePtrList<Expression>* arguments, int pos) {
return new (zone_) CallRuntime(Runtime::FunctionForId(id), arguments, pos);
}
CallRuntime* NewCallRuntime(const Runtime::Function* function,
- ZoneList<Expression*>* arguments, int pos) {
+ ZonePtrList<Expression>* arguments, int pos) {
return new (zone_) CallRuntime(function, arguments, pos);
}
CallRuntime* NewCallRuntime(int context_index,
- ZoneList<Expression*>* arguments, int pos) {
+ ZonePtrList<Expression>* arguments, int pos) {
return new (zone_) CallRuntime(context_index, arguments, pos);
}
@@ -3158,7 +3157,7 @@ class AstNodeFactory final BASE_EMBEDDED {
FunctionLiteral* NewFunctionLiteral(
const AstRawString* name, DeclarationScope* scope,
- ZoneList<Statement*>* body, int expected_property_count,
+ ZonePtrList<Statement>* body, int expected_property_count,
int parameter_count, int function_length,
FunctionLiteral::ParameterFlag has_duplicate_parameters,
FunctionLiteral::FunctionType function_type,
@@ -3176,7 +3175,7 @@ class AstNodeFactory final BASE_EMBEDDED {
// result of an eval (top-level or otherwise), or the result of calling
// the Function constructor.
FunctionLiteral* NewScriptOrEvalFunctionLiteral(DeclarationScope* scope,
- ZoneList<Statement*>* body,
+ ZonePtrList<Statement>* body,
int expected_property_count,
int parameter_count) {
return new (zone_) FunctionLiteral(
@@ -3184,7 +3183,7 @@ class AstNodeFactory final BASE_EMBEDDED {
body, expected_property_count, parameter_count, parameter_count,
FunctionLiteral::kAnonymousExpression,
FunctionLiteral::kNoDuplicateParameters,
- FunctionLiteral::kShouldLazyCompile, 0, true,
+ FunctionLiteral::kShouldLazyCompile, 0, /* has_braces */ false,
FunctionLiteral::kIdTypeTopLevel);
}
@@ -3198,7 +3197,7 @@ class AstNodeFactory final BASE_EMBEDDED {
ClassLiteral* NewClassLiteral(
Scope* scope, Variable* variable, Expression* extends,
FunctionLiteral* constructor,
- ZoneList<ClassLiteral::Property*>* properties,
+ ZonePtrList<ClassLiteral::Property>* properties,
FunctionLiteral* static_fields_initializer,
FunctionLiteral* instance_fields_initializer_function, int start_position,
int end_position, bool has_name_static_property,
@@ -3255,14 +3254,14 @@ class AstNodeFactory final BASE_EMBEDDED {
}
GetTemplateObject* NewGetTemplateObject(
- const ZoneList<const AstRawString*>* cooked_strings,
- const ZoneList<const AstRawString*>* raw_strings, int pos) {
+ const ZonePtrList<const AstRawString>* cooked_strings,
+ const ZonePtrList<const AstRawString>* raw_strings, int pos) {
return new (zone_) GetTemplateObject(cooked_strings, raw_strings, pos);
}
TemplateLiteral* NewTemplateLiteral(
- const ZoneList<const AstRawString*>* string_parts,
- const ZoneList<Expression*>* substitutions, int pos) {
+ const ZonePtrList<const AstRawString>* string_parts,
+ const ZonePtrList<Expression>* substitutions, int pos) {
return new (zone_) TemplateLiteral(string_parts, substitutions, pos);
}
@@ -3271,7 +3270,7 @@ class AstNodeFactory final BASE_EMBEDDED {
}
InitializeClassFieldsStatement* NewInitializeClassFieldsStatement(
- ZoneList<ClassLiteralProperty*>* args, int pos) {
+ ZonePtrList<ClassLiteral::Property>* args, int pos) {
return new (zone_) InitializeClassFieldsStatement(args, pos);
}
diff --git a/deps/v8/src/ast/compile-time-value.cc b/deps/v8/src/ast/compile-time-value.cc
deleted file mode 100644
index f21759ab7d..0000000000
--- a/deps/v8/src/ast/compile-time-value.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2016 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/ast/compile-time-value.h"
-
-#include "src/ast/ast.h"
-#include "src/handles-inl.h"
-#include "src/heap/factory.h"
-#include "src/isolate.h"
-#include "src/objects-inl.h"
-
-namespace v8 {
-namespace internal {
-
-bool CompileTimeValue::IsCompileTimeValue(Expression* expression) {
- if (expression->IsLiteral()) return true;
- MaterializedLiteral* literal = expression->AsMaterializedLiteral();
- if (literal == nullptr) return false;
- return literal->IsSimple();
-}
-
-Handle<FixedArray> CompileTimeValue::GetValue(Isolate* isolate,
- Expression* expression) {
- Factory* factory = isolate->factory();
- DCHECK(IsCompileTimeValue(expression));
- Handle<FixedArray> result = factory->NewFixedArray(2, TENURED);
- if (expression->IsObjectLiteral()) {
- ObjectLiteral* object_literal = expression->AsObjectLiteral();
- DCHECK(object_literal->is_simple());
- int literalTypeFlag = object_literal->EncodeLiteralType();
- DCHECK_NE(kArrayLiteralFlag, literalTypeFlag);
- result->set(kLiteralTypeSlot, Smi::FromInt(literalTypeFlag));
- result->set(kElementsSlot, *object_literal->constant_properties());
- } else {
- ArrayLiteral* array_literal = expression->AsArrayLiteral();
- DCHECK(array_literal->is_simple());
- result->set(kLiteralTypeSlot, Smi::FromInt(kArrayLiteralFlag));
- result->set(kElementsSlot, *array_literal->constant_elements());
- }
- return result;
-}
-
-int CompileTimeValue::GetLiteralTypeFlags(Handle<FixedArray> value) {
- return Smi::ToInt(value->get(kLiteralTypeSlot));
-}
-
-Handle<HeapObject> CompileTimeValue::GetElements(Handle<FixedArray> value) {
- return Handle<HeapObject>(HeapObject::cast(value->get(kElementsSlot)));
-}
-
-} // namespace internal
-} // namespace v8
diff --git a/deps/v8/src/ast/compile-time-value.h b/deps/v8/src/ast/compile-time-value.h
deleted file mode 100644
index 874bc1b32f..0000000000
--- a/deps/v8/src/ast/compile-time-value.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2015 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef V8_AST_COMPILE_TIME_VALUE_H_
-#define V8_AST_COMPILE_TIME_VALUE_H_
-
-#include "src/allocation.h"
-#include "src/globals.h"
-
-namespace v8 {
-namespace internal {
-
-class Expression;
-
-// Support for handling complex values (array and object literals) that
-// can be fully handled at compile time.
-class CompileTimeValue : public AllStatic {
- public:
- // This is a special marker used to encode array literals. The value has to be
- // different from any value possibly returned by
- // ObjectLiteral::EncodeLiteralType.
- static const int kArrayLiteralFlag = -1;
-
- static bool IsCompileTimeValue(Expression* expression);
-
- // Get the value as a compile time value.
- static Handle<FixedArray> GetValue(Isolate* isolate, Expression* expression);
-
- // Get the encoded literal type. This can either be kArrayLiteralFlag or
- // encoded properties of an ObjectLiteral returned by
- // ObjectLiteral::EncodeLiteralType.
- static int GetLiteralTypeFlags(Handle<FixedArray> value);
-
- // Get the elements of a compile time value returned by GetValue().
- static Handle<HeapObject> GetElements(Handle<FixedArray> value);
-
- private:
- static const int kLiteralTypeSlot = 0;
- static const int kElementsSlot = 1;
-};
-
-} // namespace internal
-} // namespace v8
-
-#endif // V8_AST_COMPILE_TIME_VALUE_H_
diff --git a/deps/v8/src/ast/modules.cc b/deps/v8/src/ast/modules.cc
index b583f35793..0f66ac91ec 100644
--- a/deps/v8/src/ast/modules.cc
+++ b/deps/v8/src/ast/modules.cc
@@ -6,12 +6,27 @@
#include "src/ast/ast-value-factory.h"
#include "src/ast/scopes.h"
#include "src/objects-inl.h"
-#include "src/objects/module.h"
+#include "src/objects/module-inl.h"
#include "src/pending-compilation-error-handler.h"
namespace v8 {
namespace internal {
+bool ModuleDescriptor::AstRawStringComparer::operator()(
+ const AstRawString* lhs, const AstRawString* rhs) const {
+ // Fast path for equal pointers: a pointer is not strictly less than itself.
+ if (lhs == rhs) return false;
+
+ // Order by contents (ordering by hash is unstable across runs).
+ if (lhs->is_one_byte() != rhs->is_one_byte()) {
+ return lhs->is_one_byte();
+ }
+ if (lhs->byte_length() != rhs->byte_length()) {
+ return lhs->byte_length() < rhs->byte_length();
+ }
+ return memcmp(lhs->raw_data(), rhs->raw_data(), lhs->byte_length()) < 0;
+}
+
void ModuleDescriptor::AddImport(const AstRawString* import_name,
const AstRawString* local_name,
const AstRawString* module_request,
diff --git a/deps/v8/src/ast/modules.h b/deps/v8/src/ast/modules.h
index 465eca447f..44e86dce42 100644
--- a/deps/v8/src/ast/modules.h
+++ b/deps/v8/src/ast/modules.h
@@ -124,10 +124,21 @@ class ModuleDescriptor : public ZoneObject {
ModuleRequest(int index, int position) : index(index), position(position) {}
};
+ // Custom content-based comparer for the below maps, to keep them stable
+ // across parses.
+ struct AstRawStringComparer {
+ bool operator()(const AstRawString* lhs, const AstRawString* rhs) const;
+ };
+
+ typedef ZoneMap<const AstRawString*, ModuleRequest, AstRawStringComparer>
+ ModuleRequestMap;
+ typedef ZoneMultimap<const AstRawString*, Entry*, AstRawStringComparer>
+ RegularExportMap;
+ typedef ZoneMap<const AstRawString*, Entry*, AstRawStringComparer>
+ RegularImportMap;
+
// Module requests.
- const ZoneMap<const AstRawString*, ModuleRequest>& module_requests() const {
- return module_requests_;
- }
+ const ModuleRequestMap& module_requests() const { return module_requests_; }
// Namespace imports.
const ZoneVector<const Entry*>& namespace_imports() const {
@@ -135,9 +146,7 @@ class ModuleDescriptor : public ZoneObject {
}
// All the remaining imports, indexed by local name.
- const ZoneMap<const AstRawString*, Entry*>& regular_imports() const {
- return regular_imports_;
- }
+ const RegularImportMap& regular_imports() const { return regular_imports_; }
// Star exports and explicitly indirect exports.
const ZoneVector<const Entry*>& special_exports() const {
@@ -146,9 +155,7 @@ class ModuleDescriptor : public ZoneObject {
// All the remaining exports, indexed by local name.
// After canonicalization (see Validate), these are exactly the local exports.
- const ZoneMultimap<const AstRawString*, Entry*>& regular_exports() const {
- return regular_exports_;
- }
+ const RegularExportMap& regular_exports() const { return regular_exports_; }
void AddRegularExport(Entry* entry) {
DCHECK_NOT_NULL(entry->export_name);
@@ -188,11 +195,11 @@ class ModuleDescriptor : public ZoneObject {
Handle<ModuleInfo> module_info);
private:
- ZoneMap<const AstRawString*, ModuleRequest> module_requests_;
+ ModuleRequestMap module_requests_;
ZoneVector<const Entry*> special_exports_;
ZoneVector<const Entry*> namespace_imports_;
- ZoneMultimap<const AstRawString*, Entry*> regular_exports_;
- ZoneMap<const AstRawString*, Entry*> regular_imports_;
+ RegularExportMap regular_exports_;
+ RegularImportMap regular_imports_;
// If there are multiple export entries with the same export name, return the
// last of them (in source order). Otherwise return nullptr.
diff --git a/deps/v8/src/ast/prettyprinter.cc b/deps/v8/src/ast/prettyprinter.cc
index 4f9029810a..ef086bcefc 100644
--- a/deps/v8/src/ast/prettyprinter.cc
+++ b/deps/v8/src/ast/prettyprinter.cc
@@ -498,16 +498,14 @@ void CallPrinter::VisitRewritableExpression(RewritableExpression* node) {
Find(node->expression());
}
-
-void CallPrinter::FindStatements(ZoneList<Statement*>* statements) {
+void CallPrinter::FindStatements(ZonePtrList<Statement>* statements) {
if (statements == nullptr) return;
for (int i = 0; i < statements->length(); i++) {
Find(statements->at(i));
}
}
-
-void CallPrinter::FindArguments(ZoneList<Expression*>* arguments) {
+void CallPrinter::FindArguments(ZonePtrList<Expression>* arguments) {
if (found_) return;
for (int i = 0; i < arguments->length(); i++) {
Find(arguments->at(i));
@@ -589,7 +587,7 @@ void AstPrinter::Print(const char* format, ...) {
}
}
-void AstPrinter::PrintLabels(ZoneList<const AstRawString*>* labels) {
+void AstPrinter::PrintLabels(ZonePtrList<const AstRawString>* labels) {
if (labels != nullptr) {
for (int i = 0; i < labels->length(); i++) {
PrintLiteral(labels->at(i), false);
@@ -748,8 +746,7 @@ void AstPrinter::PrintLiteralWithModeIndented(const char* info, Variable* var,
}
}
-
-void AstPrinter::PrintLabelsIndented(ZoneList<const AstRawString*>* labels) {
+void AstPrinter::PrintLabelsIndented(ZonePtrList<const AstRawString>* labels) {
if (labels == nullptr || labels->length() == 0) return;
PrintIndented("LABELS ");
PrintLabels(labels);
@@ -809,15 +806,13 @@ void AstPrinter::PrintParameters(DeclarationScope* scope) {
}
}
-
-void AstPrinter::PrintStatements(ZoneList<Statement*>* statements) {
+void AstPrinter::PrintStatements(ZonePtrList<Statement>* statements) {
for (int i = 0; i < statements->length(); i++) {
Visit(statements->at(i));
}
}
-
-void AstPrinter::PrintArguments(ZoneList<Expression*>* arguments) {
+void AstPrinter::PrintArguments(ZonePtrList<Expression>* arguments) {
for (int i = 0; i < arguments->length(); i++) {
Visit(arguments->at(i));
}
@@ -1040,7 +1035,7 @@ void AstPrinter::VisitInitializeClassFieldsStatement(
}
void AstPrinter::PrintClassProperties(
- ZoneList<ClassLiteral::Property*>* properties) {
+ ZonePtrList<ClassLiteral::Property>* properties) {
for (int i = 0; i < properties->length(); i++) {
ClassLiteral::Property* property = properties->at(i);
const char* prop_kind = nullptr;
@@ -1119,7 +1114,7 @@ void AstPrinter::VisitObjectLiteral(ObjectLiteral* node) {
}
void AstPrinter::PrintObjectProperties(
- ZoneList<ObjectLiteral::Property*>* properties) {
+ ZonePtrList<ObjectLiteral::Property>* properties) {
for (int i = 0; i < properties->length(); i++) {
ObjectLiteral::Property* property = properties->at(i);
const char* prop_kind = nullptr;
diff --git a/deps/v8/src/ast/prettyprinter.h b/deps/v8/src/ast/prettyprinter.h
index d93137b7cf..cc29052c2d 100644
--- a/deps/v8/src/ast/prettyprinter.h
+++ b/deps/v8/src/ast/prettyprinter.h
@@ -56,8 +56,8 @@ class CallPrinter final : public AstVisitor<CallPrinter> {
protected:
void PrintLiteral(Handle<Object> value, bool quote);
void PrintLiteral(const AstRawString* value, bool quote);
- void FindStatements(ZoneList<Statement*>* statements);
- void FindArguments(ZoneList<Expression*>* arguments);
+ void FindStatements(ZonePtrList<Statement>* statements);
+ void FindArguments(ZonePtrList<Expression>* arguments);
};
@@ -88,17 +88,17 @@ class AstPrinter final : public AstVisitor<AstPrinter> {
void Init();
- void PrintLabels(ZoneList<const AstRawString*>* labels);
+ void PrintLabels(ZonePtrList<const AstRawString>* labels);
void PrintLiteral(const AstRawString* value, bool quote);
void PrintLiteral(const AstConsString* value, bool quote);
void PrintLiteral(Literal* literal, bool quote);
void PrintIndented(const char* txt);
void PrintIndentedVisit(const char* s, AstNode* node);
- void PrintStatements(ZoneList<Statement*>* statements);
+ void PrintStatements(ZonePtrList<Statement>* statements);
void PrintDeclarations(Declaration::List* declarations);
void PrintParameters(DeclarationScope* scope);
- void PrintArguments(ZoneList<Expression*>* arguments);
+ void PrintArguments(ZonePtrList<Expression>* arguments);
void PrintCaseClause(CaseClause* clause);
void PrintLiteralIndented(const char* info, Literal* literal, bool quote);
void PrintLiteralIndented(const char* info, const AstRawString* value,
@@ -107,9 +107,9 @@ class AstPrinter final : public AstVisitor<AstPrinter> {
bool quote);
void PrintLiteralWithModeIndented(const char* info, Variable* var,
const AstRawString* value);
- void PrintLabelsIndented(ZoneList<const AstRawString*>* labels);
- void PrintObjectProperties(ZoneList<ObjectLiteral::Property*>* properties);
- void PrintClassProperties(ZoneList<ClassLiteral::Property*>* properties);
+ void PrintLabelsIndented(ZonePtrList<const AstRawString>* labels);
+ void PrintObjectProperties(ZonePtrList<ObjectLiteral::Property>* properties);
+ void PrintClassProperties(ZonePtrList<ClassLiteral::Property>* properties);
void inc_indent() { indent_++; }
void dec_indent() { indent_--; }
diff --git a/deps/v8/src/ast/scopes.cc b/deps/v8/src/ast/scopes.cc
index 42affeea2c..18db88f950 100644
--- a/deps/v8/src/ast/scopes.cc
+++ b/deps/v8/src/ast/scopes.cc
@@ -13,10 +13,11 @@
#include "src/counters.h"
#include "src/messages.h"
#include "src/objects-inl.h"
-#include "src/objects/module.h"
+#include "src/objects/module-inl.h"
#include "src/objects/scope-info.h"
#include "src/parsing/parse-info.h"
#include "src/parsing/preparsed-scope-data.h"
+#include "src/zone/zone-list-inl.h"
namespace v8 {
namespace internal {
@@ -75,8 +76,8 @@ Variable* VariableMap::DeclareName(Zone* zone, const AstRawString* name,
if (p->value == nullptr) {
// The variable has not been declared yet -> insert it.
DCHECK_EQ(name, p->key);
- p->value =
- mode == VAR ? kDummyPreParserVariable : kDummyPreParserLexicalVariable;
+ p->value = mode == VariableMode::kVar ? kDummyPreParserVariable
+ : kDummyPreParserLexicalVariable;
}
return reinterpret_cast<Variable*>(p->value);
}
@@ -189,6 +190,13 @@ DeclarationScope::DeclarationScope(Zone* zone, Scope* outer_scope,
SetDefaults();
}
+bool DeclarationScope::IsDeclaredParameter(const AstRawString* name) {
+ // If IsSimpleParameterList is false, duplicate parameters are not allowed,
+ // however `arguments` may be allowed if function is not strict code. Thus,
+ // the assumptions explained above do not hold.
+ return params_.Contains(variables_.Lookup(name));
+}
+
ModuleScope::ModuleScope(DeclarationScope* script_scope,
AstValueFactory* ast_value_factory)
: DeclarationScope(ast_value_factory->zone(), script_scope, MODULE_SCOPE,
@@ -199,11 +207,10 @@ ModuleScope::ModuleScope(DeclarationScope* script_scope,
DeclareThis(ast_value_factory);
}
-ModuleScope::ModuleScope(Handle<ScopeInfo> scope_info,
+ModuleScope::ModuleScope(Isolate* isolate, Handle<ScopeInfo> scope_info,
AstValueFactory* avfactory)
: DeclarationScope(avfactory->zone(), MODULE_SCOPE, scope_info) {
Zone* zone = avfactory->zone();
- Isolate* isolate = scope_info->GetIsolate();
Handle<ModuleInfo> module_info(scope_info->ModuleDescriptorInfo(), isolate);
set_language_mode(LanguageMode::kStrict);
@@ -289,8 +296,9 @@ Scope::Scope(Zone* zone, const AstRawString* catch_variable_name,
// Cache the catch variable, even though it's also available via the
// scope_info, as the parser expects that a catch scope always has the catch
// variable as first and only variable.
- Variable* variable = Declare(zone, catch_variable_name, VAR, NORMAL_VARIABLE,
- kCreatedInitialized, maybe_assigned);
+ Variable* variable =
+ Declare(zone, catch_variable_name, VariableMode::kVar, NORMAL_VARIABLE,
+ kCreatedInitialized, maybe_assigned);
AllocateHeapSlot(variable);
}
@@ -389,7 +397,8 @@ bool Scope::ContainsAsmModule() const {
return false;
}
-Scope* Scope::DeserializeScopeChain(Zone* zone, ScopeInfo* scope_info,
+Scope* Scope::DeserializeScopeChain(Isolate* isolate, Zone* zone,
+ ScopeInfo* scope_info,
DeclarationScope* script_scope,
AstValueFactory* ast_value_factory,
DeserializationMode deserialization_mode) {
@@ -400,7 +409,8 @@ Scope* Scope::DeserializeScopeChain(Zone* zone, ScopeInfo* scope_info,
while (scope_info) {
if (scope_info->scope_type() == WITH_SCOPE) {
// For scope analysis, debug-evaluate is equivalent to a with scope.
- outer_scope = new (zone) Scope(zone, WITH_SCOPE, handle(scope_info));
+ outer_scope =
+ new (zone) Scope(zone, WITH_SCOPE, handle(scope_info, isolate));
// TODO(yangguo): Remove once debug-evaluate properly keeps track of the
// function scope in which we are evaluating.
@@ -412,40 +422,40 @@ Scope* Scope::DeserializeScopeChain(Zone* zone, ScopeInfo* scope_info,
// scope info of this script context onto the existing script scope to
// avoid nesting script scopes.
if (deserialization_mode == DeserializationMode::kIncludingVariables) {
- script_scope->SetScriptScopeInfo(handle(scope_info));
+ script_scope->SetScriptScopeInfo(handle(scope_info, isolate));
}
DCHECK(!scope_info->HasOuterScopeInfo());
break;
} else if (scope_info->scope_type() == FUNCTION_SCOPE) {
- outer_scope =
- new (zone) DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info));
+ outer_scope = new (zone)
+ DeclarationScope(zone, FUNCTION_SCOPE, handle(scope_info, isolate));
if (scope_info->IsAsmModule())
outer_scope->AsDeclarationScope()->set_asm_module();
} else if (scope_info->scope_type() == EVAL_SCOPE) {
- outer_scope =
- new (zone) DeclarationScope(zone, EVAL_SCOPE, handle(scope_info));
+ outer_scope = new (zone)
+ DeclarationScope(zone, EVAL_SCOPE, 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));
+ outer_scope = new (zone)
+ DeclarationScope(zone, BLOCK_SCOPE, handle(scope_info, isolate));
} else {
- outer_scope = new (zone) Scope(zone, BLOCK_SCOPE, handle(scope_info));
+ outer_scope =
+ new (zone) Scope(zone, BLOCK_SCOPE, handle(scope_info, isolate));
}
} else if (scope_info->scope_type() == MODULE_SCOPE) {
- outer_scope =
- new (zone) ModuleScope(handle(scope_info), ast_value_factory);
+ outer_scope = new (zone)
+ ModuleScope(isolate, handle(scope_info, isolate), ast_value_factory);
} else {
DCHECK_EQ(scope_info->scope_type(), CATCH_SCOPE);
- DCHECK_EQ(scope_info->LocalCount(), 1);
DCHECK_EQ(scope_info->ContextLocalCount(), 1);
- DCHECK_EQ(scope_info->ContextLocalMode(0), VAR);
+ DCHECK_EQ(scope_info->ContextLocalMode(0), VariableMode::kVar);
DCHECK_EQ(scope_info->ContextLocalInitFlag(0), kCreatedInitialized);
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)),
- maybe_assigned, handle(scope_info));
+ outer_scope = new (zone)
+ 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();
@@ -605,12 +615,13 @@ void DeclarationScope::HoistSloppyBlockFunctions(AstNodeFactory* factory) {
// Based on the preceding checks, it doesn't matter what we pass as
// sloppy_mode_block_scope_function_redefinition.
bool ok = true;
- DeclareVariable(declaration, VAR,
- Variable::DefaultInitializationFlag(VAR), nullptr, &ok);
+ DeclareVariable(declaration, VariableMode::kVar,
+ Variable::DefaultInitializationFlag(VariableMode::kVar),
+ nullptr, &ok);
DCHECK(ok);
} else {
DCHECK(is_being_lazily_parsed_);
- Variable* var = DeclareVariableName(name, VAR);
+ Variable* var = DeclareVariableName(name, VariableMode::kVar);
if (var != kDummyPreParserVariable &&
var != kDummyPreParserLexicalVariable) {
DCHECK(FLAG_preparser_scope_analysis);
@@ -633,7 +644,7 @@ void DeclarationScope::AttachOuterScopeInfo(ParseInfo* info, Isolate* isolate) {
DeclarationScope(info->zone(), info->ast_value_factory());
info->set_script_scope(script_scope);
ReplaceOuterScope(Scope::DeserializeScopeChain(
- info->zone(), *outer_scope_info, script_scope,
+ isolate, info->zone(), *outer_scope_info, script_scope,
info->ast_value_factory(),
Scope::DeserializationMode::kIncludingVariables));
} else {
@@ -703,7 +714,8 @@ void DeclarationScope::DeclareThis(AstValueFactory* ast_value_factory) {
bool derived_constructor = IsDerivedConstructor(function_kind_);
Variable* var =
Declare(zone(), ast_value_factory->this_string(),
- derived_constructor ? CONST : VAR, THIS_VARIABLE,
+ derived_constructor ? VariableMode::kConst : VariableMode::kVar,
+ THIS_VARIABLE,
derived_constructor ? kNeedsInitialization : kCreatedInitialized);
receiver_ = var;
}
@@ -717,7 +729,8 @@ void DeclarationScope::DeclareArguments(AstValueFactory* ast_value_factory) {
// Declare 'arguments' variable which exists in all non arrow functions.
// Note that it might never be accessed, in which case it won't be
// allocated during variable allocation.
- arguments_ = Declare(zone(), ast_value_factory->arguments_string(), VAR);
+ arguments_ = Declare(zone(), ast_value_factory->arguments_string(),
+ VariableMode::kVar);
} else if (IsLexical(arguments_)) {
// Check if there's lexically declared variable named arguments to avoid
// redeclaration. See ES#sec-functiondeclarationinstantiation, step 20.
@@ -731,12 +744,14 @@ void DeclarationScope::DeclareDefaultFunctionVariables(
DCHECK(!is_arrow_scope());
DeclareThis(ast_value_factory);
- new_target_ = Declare(zone(), ast_value_factory->new_target_string(), CONST);
+ new_target_ = Declare(zone(), ast_value_factory->new_target_string(),
+ VariableMode::kConst);
if (IsConciseMethod(function_kind_) || IsClassConstructor(function_kind_) ||
IsAccessorFunction(function_kind_)) {
EnsureRareData()->this_function =
- Declare(zone(), ast_value_factory->this_function_string(), CONST);
+ Declare(zone(), ast_value_factory->this_function_string(),
+ VariableMode::kConst);
}
}
@@ -746,10 +761,10 @@ Variable* DeclarationScope::DeclareFunctionVar(const AstRawString* name) {
DCHECK_NULL(variables_.Lookup(name));
VariableKind kind = is_sloppy(language_mode()) ? SLOPPY_FUNCTION_NAME_VARIABLE
: NORMAL_VARIABLE;
- function_ =
- new (zone()) Variable(this, name, CONST, kind, kCreatedInitialized);
+ function_ = new (zone())
+ Variable(this, name, VariableMode::kConst, kind, kCreatedInitialized);
if (calls_sloppy_eval()) {
- NonLocal(name, DYNAMIC);
+ NonLocal(name, VariableMode::kDynamic);
} else {
variables_.Add(zone(), function_);
}
@@ -913,11 +928,12 @@ void Scope::Snapshot::Reparent(DeclarationScope* new_parent) const {
new_parent->locals_.MoveTail(outer_closure->locals(), top_local_);
for (Variable* local : new_parent->locals_) {
- DCHECK(local->mode() == TEMPORARY || local->mode() == VAR);
+ DCHECK(local->mode() == VariableMode::kTemporary ||
+ local->mode() == VariableMode::kVar);
DCHECK_EQ(local->scope(), local->scope()->GetClosureScope());
DCHECK_NE(local->scope(), new_parent);
local->set_scope(new_parent);
- if (local->mode() == VAR) {
+ if (local->mode() == VariableMode::kVar) {
outer_closure->variables_.Remove(local);
new_parent->variables_.Add(new_parent->zone(), local);
}
@@ -949,10 +965,6 @@ Variable* Scope::LookupInScopeInfo(const AstRawString* name) {
// The Scope is backed up by ScopeInfo. This means it cannot operate in a
// heap-independent mode, and all strings must be internalized immediately. So
// it's ok to get the Handle<String> here.
- // If we have a serialized scope info, we might find the variable there.
- // There should be no local slot with the given name.
- DCHECK_LT(scope_info_->StackSlotIndex(*name_handle), 0);
-
bool found = false;
VariableLocation location;
@@ -979,7 +991,7 @@ Variable* Scope::LookupInScopeInfo(const AstRawString* name) {
index = scope_info_->FunctionContextSlotIndex(*name_handle);
if (index < 0) return nullptr; // Nowhere found.
Variable* var = AsDeclarationScope()->DeclareFunctionVar(name);
- DCHECK_EQ(CONST, var->mode());
+ DCHECK_EQ(VariableMode::kConst, var->mode());
var->AllocateTo(VariableLocation::CONTEXT, index);
return variables_.Lookup(name);
}
@@ -1016,10 +1028,10 @@ Variable* DeclarationScope::DeclareParameter(
DCHECK(!is_being_lazily_parsed_);
DCHECK(!was_lazily_parsed_);
Variable* var;
- if (mode == TEMPORARY) {
+ if (mode == VariableMode::kTemporary) {
var = NewTemporary(name);
} else {
- DCHECK_EQ(mode, VAR);
+ DCHECK_EQ(mode, VariableMode::kVar);
var = Declare(zone(), name, mode);
// TODO(wingo): Avoid O(n^2) check.
if (is_duplicate != nullptr) {
@@ -1049,17 +1061,17 @@ Variable* DeclarationScope::DeclareParameterName(
if (FLAG_preparser_scope_analysis) {
Variable* var;
if (declare_as_local) {
- var = Declare(zone(), name, VAR);
+ var = Declare(zone(), name, VariableMode::kVar);
} else {
- var = new (zone())
- Variable(this, name, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized);
+ var = new (zone()) Variable(this, name, VariableMode::kTemporary,
+ NORMAL_VARIABLE, kCreatedInitialized);
}
if (add_parameter) {
params_.Add(var, zone());
}
return var;
}
- DeclareVariableName(name, VAR);
+ DeclareVariableName(name, VariableMode::kVar);
return nullptr;
}
@@ -1067,12 +1079,14 @@ Variable* Scope::DeclareLocal(const AstRawString* name, VariableMode mode,
InitializationFlag init_flag, VariableKind kind,
MaybeAssignedFlag maybe_assigned_flag) {
DCHECK(!already_resolved_);
- // This function handles VAR, LET, and CONST modes. DYNAMIC variables are
- // introduced during variable allocation, and TEMPORARY variables are
- // allocated via NewTemporary().
+ // This function handles VariableMode::kVar, VariableMode::kLet, and
+ // VariableMode::kConst modes. VariableMode::kDynamic variables are
+ // introduced during variable allocation, and VariableMode::kTemporary
+ // variables are allocated via NewTemporary().
DCHECK(IsDeclaredVariableMode(mode));
DCHECK_IMPLIES(GetDeclarationScope()->is_being_lazily_parsed(),
- mode == VAR || mode == LET || mode == CONST);
+ mode == VariableMode::kVar || mode == VariableMode::kLet ||
+ mode == VariableMode::kConst);
DCHECK(!GetDeclarationScope()->was_lazily_parsed());
return Declare(zone(), name, mode, kind, init_flag, maybe_assigned_flag);
}
@@ -1085,7 +1099,7 @@ Variable* Scope::DeclareVariable(
DCHECK(!GetDeclarationScope()->is_being_lazily_parsed());
DCHECK(!GetDeclarationScope()->was_lazily_parsed());
- if (mode == VAR && !is_declaration_scope()) {
+ if (mode == VariableMode::kVar && !is_declaration_scope()) {
return GetDeclarationScope()->DeclareVariable(
declaration, mode, init, sloppy_mode_block_scope_function_redefinition,
ok);
@@ -1108,11 +1122,12 @@ Variable* Scope::DeclareVariable(
// assigned because they might be accessed by a lazily parsed top-level
// function, which, for efficiency, we preparse without variable tracking.
if (is_script_scope() || is_module_scope()) {
- if (mode != CONST) proxy->set_is_assigned();
+ if (mode != VariableMode::kConst) proxy->set_is_assigned();
}
Variable* var = nullptr;
- if (is_eval_scope() && is_sloppy(language_mode()) && mode == VAR) {
+ if (is_eval_scope() && is_sloppy(language_mode()) &&
+ mode == VariableMode::kVar) {
// In a var binding in a sloppy direct eval, pollute the enclosing scope
// with this new binding by doing the following:
// The proxy is bound to a lookup variable to force a dynamic declaration
@@ -1173,7 +1188,7 @@ Variable* Scope::DeclareVariable(
*ok = false;
return nullptr;
}
- } else if (mode == VAR) {
+ } else if (mode == VariableMode::kVar) {
var->set_maybe_assigned();
}
}
@@ -1199,7 +1214,7 @@ Variable* Scope::DeclareVariableName(const AstRawString* name,
DCHECK(!already_resolved_);
DCHECK(GetDeclarationScope()->is_being_lazily_parsed());
- if (mode == VAR && !is_declaration_scope()) {
+ if (mode == VariableMode::kVar && !is_declaration_scope()) {
return GetDeclarationScope()->DeclareVariableName(name, mode);
}
DCHECK(!is_with_scope());
@@ -1220,7 +1235,7 @@ Variable* Scope::DeclareVariableName(const AstRawString* name,
// a function declaration, it's an error. This is an error PreParser
// hasn't previously detected. TODO(marja): Investigate whether we can now
// start returning this error.
- } else if (mode == VAR) {
+ } else if (mode == VariableMode::kVar) {
var->set_maybe_assigned();
}
var->set_is_used();
@@ -1237,9 +1252,9 @@ void Scope::DeclareCatchVariableName(const AstRawString* name) {
DCHECK(scope_info_.is_null());
if (FLAG_preparser_scope_analysis) {
- Declare(zone(), name, VAR);
+ Declare(zone(), name, VariableMode::kVar);
} else {
- variables_.DeclareName(zone(), name, VAR);
+ variables_.DeclareName(zone(), name, VariableMode::kVar);
}
}
@@ -1253,11 +1268,11 @@ void Scope::AddUnresolved(VariableProxy* proxy) {
Variable* DeclarationScope::DeclareDynamicGlobal(const AstRawString* name,
VariableKind kind) {
DCHECK(is_script_scope());
- return variables_.Declare(zone(), this, name, DYNAMIC_GLOBAL, kind);
+ return variables_.Declare(zone(), this, name, VariableMode::kDynamicGlobal,
+ kind);
// TODO(neis): Mark variable as maybe-assigned?
}
-
bool Scope::RemoveUnresolved(VariableProxy* var) {
if (unresolved_ == var) {
unresolved_ = var->next_unresolved();
@@ -1284,8 +1299,8 @@ 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, TEMPORARY, NORMAL_VARIABLE, kCreatedInitialized);
+ Variable* var = new (zone()) Variable(scope, name, VariableMode::kTemporary,
+ NORMAL_VARIABLE, kCreatedInitialized);
scope->AddLocal(var);
if (maybe_assigned == kMaybeAssigned) var->set_maybe_assigned();
return var;
@@ -1302,7 +1317,7 @@ Declaration* Scope::CheckConflictingVarDeclarations() {
Scope* current = this;
if (decl->IsVariableDeclaration() &&
decl->AsVariableDeclaration()->AsNested() != nullptr) {
- DCHECK_EQ(mode, VAR);
+ DCHECK_EQ(mode, VariableMode::kVar);
current = decl->AsVariableDeclaration()->AsNested()->scope();
} else if (IsLexicalVariableMode(mode)) {
if (!is_block_scope()) continue;
@@ -1327,7 +1342,7 @@ Declaration* Scope::CheckConflictingVarDeclarations() {
}
Declaration* Scope::CheckLexDeclarationsConflictingWith(
- const ZoneList<const AstRawString*>& names) {
+ const ZonePtrList<const AstRawString>& names) {
DCHECK(is_block_scope());
for (int i = 0; i < names.length(); ++i) {
Variable* var = LookupLocal(names.at(i));
@@ -1467,11 +1482,11 @@ Scope* Scope::GetOuterScopeWithContext() {
}
Handle<StringSet> DeclarationScope::CollectNonLocals(
- ParseInfo* info, Handle<StringSet> non_locals) {
+ Isolate* isolate, ParseInfo* info, Handle<StringSet> non_locals) {
VariableProxy* free_variables = FetchFreeVariables(this, info);
for (VariableProxy* proxy = free_variables; proxy != nullptr;
proxy = proxy->next_unresolved()) {
- non_locals = StringSet::Add(non_locals, proxy->name());
+ non_locals = StringSet::Add(isolate, non_locals, proxy->name());
}
return non_locals;
}
@@ -1759,7 +1774,7 @@ void Scope::Print(int n) {
{
bool printed_header = false;
for (Variable* local : locals_) {
- if (local->mode() != TEMPORARY) continue;
+ if (local->mode() != VariableMode::kTemporary) continue;
if (!printed_header) {
printed_header = true;
Indent(n1, "// temporary vars:\n");
@@ -1829,7 +1844,8 @@ Variable* Scope::LookupRecursive(ParseInfo* info, VariableProxy* proxy,
// variables.
// TODO(yangguo): Remove once debug-evaluate creates proper ScopeInfo for the
// scopes in which it's evaluating.
- if (is_debug_evaluate_scope_) return NonLocal(proxy->raw_name(), DYNAMIC);
+ if (is_debug_evaluate_scope_)
+ return NonLocal(proxy->raw_name(), VariableMode::kDynamic);
// Try to find the variable in this scope.
Variable* var = LookupLocal(proxy->raw_name());
@@ -1892,7 +1908,7 @@ Variable* Scope::LookupRecursive(ParseInfo* info, VariableProxy* proxy,
var->ForceContextAllocation();
if (proxy->is_assigned()) var->set_maybe_assigned();
}
- return NonLocal(proxy->raw_name(), DYNAMIC);
+ return NonLocal(proxy->raw_name(), VariableMode::kDynamic);
}
if (is_declaration_scope() && AsDeclarationScope()->calls_sloppy_eval()) {
@@ -1904,13 +1920,13 @@ Variable* Scope::LookupRecursive(ParseInfo* info, VariableProxy* proxy,
// here (this excludes block and catch scopes), and variable lookups at
// script scope are always dynamic.
if (var->IsGlobalObjectProperty()) {
- return NonLocal(proxy->raw_name(), DYNAMIC_GLOBAL);
+ return NonLocal(proxy->raw_name(), VariableMode::kDynamicGlobal);
}
if (var->is_dynamic()) return var;
Variable* invalidated = var;
- var = NonLocal(proxy->raw_name(), DYNAMIC_LOCAL);
+ var = NonLocal(proxy->raw_name(), VariableMode::kDynamicLocal);
var->set_local_if_not_shadowed(invalidated);
}
@@ -1937,11 +1953,11 @@ void SetNeedsHoleCheck(Variable* var, VariableProxy* proxy) {
}
void UpdateNeedsHoleCheck(Variable* var, VariableProxy* proxy, Scope* scope) {
- if (var->mode() == DYNAMIC_LOCAL) {
+ if (var->mode() == VariableMode::kDynamicLocal) {
// Dynamically introduced variables never need a hole check (since they're
- // VAR bindings, either from var or function declarations), but the variable
- // they shadow might need a hole check, which we want to do if we decide
- // that no shadowing variable was dynamically introoduced.
+ // VariableMode::kVar bindings, either from var or function declarations),
+ // but the variable they shadow might need a hole check, which we want to do
+ // if we decide that no shadowing variable was dynamically introoduced.
DCHECK_EQ(kCreatedInitialized, var->initialization_flag());
return UpdateNeedsHoleCheck(var->local_if_not_shadowed(), proxy, scope);
}
@@ -1956,12 +1972,12 @@ void UpdateNeedsHoleCheck(Variable* var, VariableProxy* proxy, Scope* scope) {
}
// Check if the binding really needs an initialization check. The check
- // can be skipped in the following situation: we have a LET or CONST
- // binding, both the Variable and the VariableProxy have the same
- // declaration scope (i.e. they are both in global code, in the
- // same function or in the same eval code), the VariableProxy is in
- // the source physically located after the initializer of the variable,
- // and that the initializer cannot be skipped due to a nonlinear scope.
+ // can be skipped in the following situation: we have a VariableMode::kLet or
+ // VariableMode::kConst binding, both the Variable and the VariableProxy have
+ // the same declaration scope (i.e. they are both in global code, in the same
+ // function or in the same eval code), the VariableProxy is in the source
+ // physically located after the initializer of the variable, and that the
+ // initializer cannot be skipped due to a nonlinear scope.
//
// The condition on the closure scopes is a conservative check for
// nested functions that access a binding and are called before the
@@ -2136,7 +2152,7 @@ bool Scope::MustAllocateInContext(Variable* var) {
//
// Temporary variables are always stack-allocated. Catch-bound variables are
// always context-allocated.
- if (var->mode() == TEMPORARY) return false;
+ if (var->mode() == VariableMode::kTemporary) return false;
if (is_catch_scope()) return true;
if ((is_script_scope() || is_eval_scope()) &&
IsLexicalVariableMode(var->mode())) {
@@ -2356,21 +2372,8 @@ void Scope::AllocateScopeInfosRecursively(Isolate* isolate,
}
}
-void Scope::AllocateDebuggerScopeInfos(Isolate* isolate,
- MaybeHandle<ScopeInfo> outer_scope) {
- if (scope_info_.is_null()) {
- scope_info_ = ScopeInfo::Create(isolate, zone(), this, outer_scope);
- }
- MaybeHandle<ScopeInfo> outer = NeedsContext() ? scope_info_ : outer_scope;
- for (Scope* scope = inner_scope_; scope != nullptr; scope = scope->sibling_) {
- if (scope->is_function_scope()) continue;
- scope->AllocateDebuggerScopeInfos(isolate, outer);
- }
-}
-
// static
-void DeclarationScope::AllocateScopeInfos(ParseInfo* info, Isolate* isolate,
- AnalyzeMode mode) {
+void DeclarationScope::AllocateScopeInfos(ParseInfo* info, Isolate* isolate) {
DeclarationScope* scope = info->literal()->scope();
if (!scope->scope_info_.is_null()) return; // Allocated by outer function.
@@ -2380,9 +2383,6 @@ void DeclarationScope::AllocateScopeInfos(ParseInfo* info, Isolate* isolate,
}
scope->AllocateScopeInfosRecursively(isolate, outer_scope);
- if (mode == AnalyzeMode::kDebugger) {
- scope->AllocateDebuggerScopeInfos(isolate, outer_scope);
- }
// The debugger expects all shared function infos to contain a scope info.
// Since the top-most scope will end up in a shared function info, make sure
@@ -2396,7 +2396,8 @@ void DeclarationScope::AllocateScopeInfos(ParseInfo* info, Isolate* isolate,
// Ensuring that the outer script scope has a scope info avoids having
// special case for native contexts vs other contexts.
if (info->script_scope() && info->script_scope()->scope_info_.is_null()) {
- info->script_scope()->scope_info_ = handle(ScopeInfo::Empty(isolate));
+ info->script_scope()->scope_info_ =
+ handle(ScopeInfo::Empty(isolate), isolate);
}
}
diff --git a/deps/v8/src/ast/scopes.h b/deps/v8/src/ast/scopes.h
index c95e3a380a..5618adee9e 100644
--- a/deps/v8/src/ast/scopes.h
+++ b/deps/v8/src/ast/scopes.h
@@ -78,8 +78,6 @@ class SloppyBlockFunctionMap : public ZoneHashMap {
int count_;
};
-enum class AnalyzeMode { kRegular, kDebugger };
-
// Global invariants after AST construction: Each reference (i.e. identifier)
// to a JavaScript variable (including global properties) is represented by a
// VariableProxy node. Immediately after AST construction and before variable
@@ -134,7 +132,8 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
enum class DeserializationMode { kIncludingVariables, kScopesOnly };
- static Scope* DeserializeScopeChain(Zone* zone, ScopeInfo* scope_info,
+ static Scope* DeserializeScopeChain(Isolate* isolate, Zone* zone,
+ ScopeInfo* scope_info,
DeclarationScope* script_scope,
AstValueFactory* ast_value_factory,
DeserializationMode deserialization_mode);
@@ -256,7 +255,7 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
// which is an error even though the two 'e's are declared in different
// scopes.
Declaration* CheckLexDeclarationsConflictingWith(
- const ZoneList<const AstRawString*>& names);
+ const ZonePtrList<const AstRawString>& names);
// ---------------------------------------------------------------------------
// Scope-specific info.
@@ -366,7 +365,8 @@ class V8_EXPORT_PRIVATE Scope : public NON_EXPORTED_BASE(ZoneObject) {
// Whether this needs to be represented by a runtime context.
bool NeedsContext() const {
// Catch scopes always have heap slots.
- DCHECK(!is_catch_scope() || num_heap_slots() > 0);
+ DCHECK_IMPLIES(is_catch_scope(), num_heap_slots() > 0);
+ DCHECK_IMPLIES(is_with_scope(), num_heap_slots() > 0);
return num_heap_slots() > 0;
}
@@ -646,12 +646,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
// Creates a script scope.
DeclarationScope(Zone* zone, AstValueFactory* ast_value_factory);
- bool IsDeclaredParameter(const AstRawString* name) {
- // If IsSimpleParameterList is false, duplicate parameters are not allowed,
- // however `arguments` may be allowed if function is not strict code. Thus,
- // the assumptions explained above do not hold.
- return params_.Contains(variables_.Lookup(name));
- }
+ bool IsDeclaredParameter(const AstRawString* name);
FunctionKind function_kind() const { return function_kind_; }
@@ -812,7 +807,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
// The local variable 'arguments' if we need to allocate it; nullptr
// otherwise.
Variable* arguments() const {
- DCHECK(!is_arrow_scope() || arguments_ == nullptr);
+ DCHECK_IMPLIES(is_arrow_scope(), arguments_ == nullptr);
return arguments_;
}
@@ -867,10 +862,9 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
// Allocate ScopeInfos for top scope and any inner scopes that need them.
// Does nothing if ScopeInfo is already allocated.
- static void AllocateScopeInfos(ParseInfo* info, Isolate* isolate,
- AnalyzeMode mode);
+ static void AllocateScopeInfos(ParseInfo* info, Isolate* isolate);
- Handle<StringSet> CollectNonLocals(ParseInfo* info,
+ Handle<StringSet> CollectNonLocals(Isolate* isolate, ParseInfo* info,
Handle<StringSet> non_locals);
// Determine if we can use lazy compilation for this scope.
@@ -964,7 +958,7 @@ class V8_EXPORT_PRIVATE DeclarationScope : public Scope {
bool has_inferred_function_name_ : 1;
// Parameter list in source order.
- ZoneList<Variable*> params_;
+ ZonePtrList<Variable> params_;
// Map of function names to lists of functions defined in sloppy blocks
SloppyBlockFunctionMap* sloppy_block_function_map_;
// Convenience variable.
@@ -1031,7 +1025,8 @@ class ModuleScope final : public DeclarationScope {
// The generated ModuleDescriptor does not preserve all information. In
// particular, its module_requests map will be empty because we no longer need
// the map after parsing.
- ModuleScope(Handle<ScopeInfo> scope_info, AstValueFactory* ast_value_factory);
+ ModuleScope(Isolate* isolate, Handle<ScopeInfo> scope_info,
+ AstValueFactory* ast_value_factory);
ModuleDescriptor* module() const {
DCHECK_NOT_NULL(module_descriptor_);
diff --git a/deps/v8/src/ast/variables.cc b/deps/v8/src/ast/variables.cc
index bce552c2c1..addcf8db2b 100644
--- a/deps/v8/src/ast/variables.cc
+++ b/deps/v8/src/ast/variables.cc
@@ -26,7 +26,7 @@ Variable::Variable(Variable* other)
bool Variable::IsGlobalObjectProperty() const {
// Temporaries are never global, they must always be allocated in the
// activation frame.
- return (IsDynamicVariableMode(mode()) || mode() == VAR) &&
+ return (IsDynamicVariableMode(mode()) || mode() == VariableMode::kVar) &&
scope_ != nullptr && scope_->is_script_scope();
}
diff --git a/deps/v8/src/ast/variables.h b/deps/v8/src/ast/variables.h
index 4d58c8fed9..10ac5c48a5 100644
--- a/deps/v8/src/ast/variables.h
+++ b/deps/v8/src/ast/variables.h
@@ -36,7 +36,8 @@ class Variable final : public ZoneObject {
LocationField::encode(VariableLocation::UNALLOCATED) |
VariableKindField::encode(kind)) {
// Var declared variables never need initialization.
- DCHECK(!(mode == VAR && initialization_flag == kNeedsInitialization));
+ DCHECK(!(mode == VariableMode::kVar &&
+ initialization_flag == kNeedsInitialization));
}
explicit Variable(Variable* other);
@@ -137,7 +138,8 @@ class Variable final : public ZoneObject {
}
Variable* local_if_not_shadowed() const {
- DCHECK(mode() == DYNAMIC_LOCAL && local_if_not_shadowed_ != nullptr);
+ DCHECK(mode() == VariableMode::kDynamicLocal &&
+ local_if_not_shadowed_ != nullptr);
return local_if_not_shadowed_;
}
@@ -175,7 +177,8 @@ class Variable final : public ZoneObject {
static InitializationFlag DefaultInitializationFlag(VariableMode mode) {
DCHECK(IsDeclaredVariableMode(mode));
- return mode == VAR ? kCreatedInitialized : kNeedsInitialization;
+ return mode == VariableMode::kVar ? kCreatedInitialized
+ : kNeedsInitialization;
}
typedef ThreadedList<Variable> List;