Revert "Revert "Upgrade to 5.0.71.48"" DO NOT MERGE
This reverts commit f2e3994fa5148cc3d9946666f0b0596290192b0e,
and updates the x64 makefile properly so it doesn't break that
build.
FPIIM-449
Change-Id: Ib83e35bfbae6af627451c926a9650ec57c045605
(cherry picked from commit 109988c7ccb6f3fd1a58574fa3dfb88beaef6632)
diff --git a/src/ast/ast.h b/src/ast/ast.h
index 7f00955..dcb440d 100644
--- a/src/ast/ast.h
+++ b/src/ast/ast.h
@@ -91,7 +91,7 @@
V(CaseClause) \
V(EmptyParentheses) \
V(DoExpression) \
- V(RewritableAssignmentExpression)
+ V(RewritableExpression)
#define AST_NODE_LIST(V) \
DECLARATION_NODE_LIST(V) \
@@ -196,15 +196,18 @@
virtual NodeType node_type() const = 0;
int position() const { return position_; }
+#ifdef DEBUG
+ void PrettyPrint(Isolate* isolate);
+ void PrettyPrint();
+ void Print(Isolate* isolate);
+ void Print();
+#endif // DEBUG
+
// Type testing & conversion functions overridden by concrete subclasses.
#define DECLARE_NODE_FUNCTIONS(type) \
- bool Is##type() const { return node_type() == AstNode::k##type; } \
- type* As##type() { \
- return Is##type() ? reinterpret_cast<type*>(this) : NULL; \
- } \
- const type* As##type() const { \
- return Is##type() ? reinterpret_cast<const type*>(this) : NULL; \
- }
+ V8_INLINE bool Is##type() const; \
+ V8_INLINE type* As##type(); \
+ V8_INLINE const type* As##type() const;
AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
#undef DECLARE_NODE_FUNCTIONS
@@ -237,7 +240,6 @@
bool IsEmpty() { return AsEmptyStatement() != NULL; }
virtual bool IsJump() const { return false; }
- virtual void MarkTail() {}
};
@@ -317,6 +319,10 @@
// names because [] for string objects is handled only by keyed ICs.
virtual bool IsPropertyName() const { return false; }
+ // True iff the expression is a class or function expression without
+ // a syntactic name.
+ virtual bool IsAnonymousFunctionDefinition() const { return false; }
+
// True iff the expression is a literal represented as a smi.
bool IsSmiLiteral() const;
@@ -365,14 +371,6 @@
BailoutId id() const { return BailoutId(local_id(0)); }
TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); }
- // Parenthesized expressions in the form `( Expression )`.
- void set_is_parenthesized() {
- bit_field_ = ParenthesizedField::update(bit_field_, true);
- }
- bool is_parenthesized() const {
- return ParenthesizedField::decode(bit_field_);
- }
-
protected:
Expression(Zone* zone, int pos)
: AstNode(pos),
@@ -395,8 +393,6 @@
int base_id_;
Bounds bounds_;
class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {};
- class ParenthesizedField
- : public BitField16<bool, ToBooleanTypesField::kNext, 1> {};
uint16_t bit_field_;
// Ends with 16-bit field; deriving classes in turn begin with
// 16-bit fields for optimum packing efficiency.
@@ -471,10 +467,6 @@
&& labels() == NULL; // Good enough as an approximation...
}
- void MarkTail() override {
- if (!statements_.is_empty()) statements_.last()->MarkTail();
- }
-
Scope* scope() const { return scope_; }
void set_scope(Scope* scope) { scope_ = scope; }
@@ -505,8 +497,6 @@
VariableProxy* result() { return result_; }
void set_result(VariableProxy* v) { result_ = v; }
- void MarkTail() override { block_->MarkTail(); }
-
protected:
DoExpression(Zone* zone, Block* block, VariableProxy* result, int pos)
: Expression(zone, pos), block_(block), result_(result) {
@@ -555,24 +545,10 @@
return mode() == VAR ? kCreatedInitialized : kNeedsInitialization;
}
- bool is_class_declaration() const { return is_class_declaration_; }
-
- // VariableDeclarations can be grouped into consecutive declaration
- // groups. Each VariableDeclaration is associated with the start position of
- // the group it belongs to. The positions are used for strong mode scope
- // checks for classes and functions.
- int declaration_group_start() const { return declaration_group_start_; }
-
protected:
VariableDeclaration(Zone* zone, VariableProxy* proxy, VariableMode mode,
- Scope* scope, int pos, bool is_class_declaration = false,
- int declaration_group_start = -1)
- : Declaration(zone, proxy, mode, scope, pos),
- is_class_declaration_(is_class_declaration),
- declaration_group_start_(declaration_group_start) {}
-
- bool is_class_declaration_;
- int declaration_group_start_;
+ Scope* scope, int pos)
+ : Declaration(zone, proxy, mode, scope, pos) {}
};
@@ -820,6 +796,10 @@
FeedbackVectorSlotCache* cache) override;
FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; }
+ static const char* VisitModeString(VisitMode mode) {
+ return mode == ITERATE ? "for-of" : "for-in";
+ }
+
protected:
ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
: IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {}
@@ -857,9 +837,9 @@
static int num_ids() { return parent_num_ids() + 6; }
BailoutId BodyId() const { return BailoutId(local_id(0)); }
- BailoutId PrepareId() const { return BailoutId(local_id(1)); }
- BailoutId EnumId() const { return BailoutId(local_id(2)); }
- BailoutId ToObjectId() const { return BailoutId(local_id(3)); }
+ BailoutId EnumId() const { return BailoutId(local_id(1)); }
+ BailoutId ToObjectId() const { return BailoutId(local_id(2)); }
+ BailoutId PrepareId() const { return BailoutId(local_id(3)); }
BailoutId FilterId() const { return BailoutId(local_id(4)); }
BailoutId AssignmentId() const { return BailoutId(local_id(5)); }
BailoutId ContinueId() const override { return EntryId(); }
@@ -885,11 +865,13 @@
void Initialize(Expression* each,
Expression* subject,
Statement* body,
+ Variable* iterator,
Expression* assign_iterator,
Expression* next_result,
Expression* result_done,
Expression* assign_each) {
ForEachStatement::Initialize(each, subject, body);
+ iterator_ = iterator;
assign_iterator_ = assign_iterator;
next_result_ = next_result;
result_done_ = result_done;
@@ -900,6 +882,10 @@
return subject();
}
+ Variable* iterator() const {
+ return iterator_;
+ }
+
// iterator = subject[Symbol.iterator]()
Expression* assign_iterator() const {
return assign_iterator_;
@@ -934,6 +920,7 @@
protected:
ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
: ForEachStatement(zone, labels, pos),
+ iterator_(NULL),
assign_iterator_(NULL),
next_result_(NULL),
result_done_(NULL),
@@ -943,6 +930,7 @@
private:
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
+ Variable* iterator_;
Expression* assign_iterator_;
Expression* next_result_;
Expression* result_done_;
@@ -957,7 +945,6 @@
void set_expression(Expression* e) { expression_ = e; }
Expression* expression() const { return expression_; }
bool IsJump() const override { return expression_->IsThrow(); }
- void MarkTail() override { expression_->MarkTail(); }
protected:
ExpressionStatement(Zone* zone, Expression* expression, int pos)
@@ -1039,8 +1026,6 @@
BailoutId ToObjectId() const { return BailoutId(local_id(0)); }
BailoutId EntryId() const { return BailoutId(local_id(1)); }
- void MarkTail() override { statement_->MarkTail(); }
-
protected:
WithStatement(Zone* zone, Scope* scope, Expression* expression,
Statement* statement, int pos)
@@ -1083,10 +1068,6 @@
BailoutId EntryId() const { return BailoutId(local_id(0)); }
TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); }
- void MarkTail() override {
- if (!statements_->is_empty()) statements_->last()->MarkTail();
- }
-
Type* compare_type() { return compare_type_; }
void set_compare_type(Type* type) { compare_type_ = type; }
@@ -1119,10 +1100,6 @@
void set_tag(Expression* t) { tag_ = t; }
- void MarkTail() override {
- if (!cases_->is_empty()) cases_->last()->MarkTail();
- }
-
protected:
SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
: BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos),
@@ -1160,11 +1137,6 @@
&& HasElseStatement() && else_statement()->IsJump();
}
- void MarkTail() override {
- then_statement_->MarkTail();
- else_statement_->MarkTail();
- }
-
void set_base_id(int id) { base_id_ = id; }
static int num_ids() { return parent_num_ids() + 3; }
BailoutId IfId() const { return BailoutId(local_id(0)); }
@@ -1201,27 +1173,12 @@
Block* try_block() const { return try_block_; }
void set_try_block(Block* b) { try_block_ = b; }
- void set_base_id(int id) { base_id_ = id; }
- static int num_ids() { return parent_num_ids() + 1; }
- BailoutId HandlerId() const { return BailoutId(local_id(0)); }
-
protected:
TryStatement(Zone* zone, Block* try_block, int pos)
- : Statement(zone, pos),
- try_block_(try_block),
- base_id_(BailoutId::None().ToInt()) {}
- static int parent_num_ids() { return 0; }
-
- int base_id() const {
- DCHECK(!BailoutId(base_id_).IsNone());
- return base_id_;
- }
+ : Statement(zone, pos), try_block_(try_block) {}
private:
- int local_id(int n) const { return base_id() + parent_num_ids() + n; }
-
Block* try_block_;
- int base_id_;
};
@@ -1234,8 +1191,6 @@
Block* catch_block() const { return catch_block_; }
void set_catch_block(Block* b) { catch_block_ = b; }
- void MarkTail() override { catch_block_->MarkTail(); }
-
protected:
TryCatchStatement(Zone* zone, Block* try_block, Scope* scope,
Variable* variable, Block* catch_block, int pos)
@@ -1258,8 +1213,6 @@
Block* finally_block() const { return finally_block_; }
void set_finally_block(Block* b) { finally_block_ = b; }
- void MarkTail() override { finally_block_->MarkTail(); }
-
protected:
TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block,
int pos)
@@ -1472,6 +1425,8 @@
void set_receiver_type(Handle<Map> map) { receiver_type_ = map; }
+ bool NeedsSetFunctionName() const;
+
protected:
friend class AstNodeFactory;
@@ -1510,6 +1465,9 @@
bool may_store_doubles() const { return may_store_doubles_; }
bool has_function() const { return has_function_; }
bool has_elements() const { return has_elements_; }
+ bool has_shallow_properties() const {
+ return depth() == 1 && !has_elements() && !may_store_doubles();
+ }
// Decide if a property should be in the object boilerplate.
static bool IsBoilerplateProperty(Property* property);
@@ -1526,7 +1484,7 @@
int ComputeFlags(bool disable_mementos = false) const {
int flags = fast_elements() ? kFastElements : kNoFlags;
flags |= has_function() ? kHasFunction : kNoFlags;
- if (depth() == 1 && !has_elements() && !may_store_doubles()) {
+ if (has_shallow_properties()) {
flags |= kShallowProperties;
}
if (disable_mementos) {
@@ -1683,6 +1641,19 @@
return flags;
}
+ // Provide a mechanism for iterating through values to rewrite spreads.
+ ZoneList<Expression*>::iterator FirstSpread() const {
+ return (first_spread_index_ >= 0) ? values_->begin() + first_spread_index_
+ : values_->end();
+ }
+ ZoneList<Expression*>::iterator EndValue() const { return values_->end(); }
+
+ // Rewind an array literal omitting everything from the first spread on.
+ void RewindSpreads() {
+ values_->Rewind(first_spread_index_);
+ first_spread_index_ = -1;
+ }
+
enum Flags {
kNoFlags = 0,
kShallowElements = 1,
@@ -1975,7 +1946,10 @@
bit_field_ = IsUninitializedField::update(bit_field_, b);
}
- bool is_tail() const { return IsTailField::decode(bit_field_); }
+ TailCallMode tail_call_mode() const {
+ return IsTailField::decode(bit_field_) ? TailCallMode::kAllow
+ : TailCallMode::kDisallow;
+ }
void MarkTail() override {
bit_field_ = IsTailField::update(bit_field_, true);
}
@@ -2349,7 +2323,7 @@
op_(op),
left_(left),
right_(right),
- combined_type_(Type::None(zone)) {
+ combined_type_(Type::None()) {
DCHECK(Token::IsCompareOp(op));
}
static int parent_num_ids() { return Expression::num_ids(); }
@@ -2372,17 +2346,20 @@
Expression* expression() const { return expression_; }
void set_expression(Expression* e) { expression_ = e; }
+ int expression_position() const { return expr_pos_; }
+
static int num_ids() { return parent_num_ids(); }
protected:
- Spread(Zone* zone, Expression* expression, int pos)
- : Expression(zone, pos), expression_(expression) {}
+ Spread(Zone* zone, Expression* expression, int pos, int expr_pos)
+ : Expression(zone, pos), expression_(expression), expr_pos_(expr_pos) {}
static int parent_num_ids() { return Expression::num_ids(); }
private:
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
Expression* expression_;
+ int expr_pos_;
};
@@ -2505,18 +2482,32 @@
};
-class RewritableAssignmentExpression : public Expression {
+// The RewritableExpression class is a wrapper for AST nodes that wait
+// for some potential rewriting. However, even if such nodes are indeed
+// rewritten, the RewritableExpression wrapper nodes will survive in the
+// final AST and should be just ignored, i.e., they should be treated as
+// equivalent to the wrapped nodes. For this reason and to simplify later
+// phases, RewritableExpressions are considered as exceptions of AST nodes
+// in the following sense:
+//
+// 1. IsRewritableExpression and AsRewritableExpression behave as usual.
+// 2. All other Is* and As* methods are practically delegated to the
+// wrapped node, i.e. IsArrayLiteral() will return true iff the
+// wrapped node is an array literal.
+//
+// Furthermore, an invariant that should be respected is that the wrapped
+// node is not a RewritableExpression.
+class RewritableExpression : public Expression {
public:
- DECLARE_NODE_TYPE(RewritableAssignmentExpression)
+ DECLARE_NODE_TYPE(RewritableExpression)
- Expression* expression() { return expr_; }
+ Expression* expression() const { return expr_; }
bool is_rewritten() const { return is_rewritten_; }
- void set_expression(Expression* e) { expr_ = e; }
-
void Rewrite(Expression* new_expression) {
DCHECK(!is_rewritten());
DCHECK_NOT_NULL(new_expression);
+ DCHECK(!new_expression->IsRewritableExpression());
expr_ = new_expression;
is_rewritten_ = true;
}
@@ -2524,10 +2515,12 @@
static int num_ids() { return parent_num_ids(); }
protected:
- RewritableAssignmentExpression(Zone* zone, Expression* expression)
+ RewritableExpression(Zone* zone, Expression* expression)
: Expression(zone, expression->position()),
is_rewritten_(false),
- expr_(expression) {}
+ expr_(expression) {
+ DCHECK(!expression->IsRewritableExpression());
+ }
private:
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
@@ -2555,26 +2548,6 @@
void set_generator_object(Expression* e) { generator_object_ = e; }
void set_expression(Expression* e) { expression_ = e; }
- // Type feedback information.
- bool HasFeedbackSlots() const { return yield_kind() == kDelegating; }
- void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
- FeedbackVectorSlotCache* cache) override {
- if (HasFeedbackSlots()) {
- yield_first_feedback_slot_ = spec->AddKeyedLoadICSlot();
- keyed_load_feedback_slot_ = spec->AddLoadICSlot();
- done_feedback_slot_ = spec->AddLoadICSlot();
- }
- }
-
- FeedbackVectorSlot KeyedLoadFeedbackSlot() {
- DCHECK(!HasFeedbackSlots() || !yield_first_feedback_slot_.IsInvalid());
- return yield_first_feedback_slot_;
- }
-
- FeedbackVectorSlot DoneFeedbackSlot() { return keyed_load_feedback_slot_; }
-
- FeedbackVectorSlot ValueFeedbackSlot() { return done_feedback_slot_; }
-
protected:
Yield(Zone* zone, Expression* generator_object, Expression* expression,
Kind yield_kind, int pos)
@@ -2587,9 +2560,6 @@
Expression* generator_object_;
Expression* expression_;
Kind yield_kind_;
- FeedbackVectorSlot yield_first_feedback_slot_;
- FeedbackVectorSlot keyed_load_feedback_slot_;
- FeedbackVectorSlot done_feedback_slot_;
};
@@ -2615,15 +2585,13 @@
kAnonymousExpression,
kNamedExpression,
kDeclaration,
- kGlobalOrEval
+ kAccessorOrMethod
};
enum ParameterFlag { kNoDuplicateParameters, kHasDuplicateParameters };
enum EagerCompileHint { kShouldEagerCompile, kShouldLazyCompile };
- enum ArityRestriction { kNormalArity, kGetterArity, kSetterArity };
-
DECLARE_NODE_TYPE(FunctionLiteral)
Handle<String> name() const { return raw_name_->string(); }
@@ -2636,8 +2604,13 @@
int start_position() const;
int end_position() const;
int SourceSize() const { return end_position() - start_position(); }
- bool is_expression() const { return IsExpression::decode(bitfield_); }
- bool is_anonymous() const { return IsAnonymous::decode(bitfield_); }
+ bool is_declaration() const { return IsDeclaration::decode(bitfield_); }
+ bool is_named_expression() const {
+ return IsNamedExpression::decode(bitfield_);
+ }
+ bool is_anonymous_expression() const {
+ return IsAnonymousExpression::decode(bitfield_);
+ }
LanguageMode language_mode() const;
static bool NeedsHomeObject(Expression* expr);
@@ -2729,6 +2702,10 @@
dont_optimize_reason_ = reason;
}
+ bool IsAnonymousFunctionDefinition() const final {
+ return is_anonymous_expression();
+ }
+
protected:
FunctionLiteral(Zone* zone, const AstString* name,
AstValueFactory* ast_value_factory, Scope* scope,
@@ -2737,7 +2714,7 @@
FunctionType function_type,
ParameterFlag has_duplicate_parameters,
EagerCompileHint eager_compile_hint, FunctionKind kind,
- int position)
+ int position, bool is_function)
: Expression(zone, position),
raw_name_(name),
scope_(scope),
@@ -2750,26 +2727,28 @@
parameter_count_(parameter_count),
function_token_position_(RelocInfo::kNoPosition) {
bitfield_ =
- IsExpression::encode(function_type != kDeclaration) |
- IsAnonymous::encode(function_type == kAnonymousExpression) |
+ IsDeclaration::encode(function_type == kDeclaration) |
+ IsNamedExpression::encode(function_type == kNamedExpression) |
+ IsAnonymousExpression::encode(function_type == kAnonymousExpression) |
Pretenure::encode(false) |
HasDuplicateParameters::encode(has_duplicate_parameters ==
kHasDuplicateParameters) |
- IsFunction::encode(function_type != kGlobalOrEval) |
+ IsFunction::encode(is_function) |
ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) |
FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false);
DCHECK(IsValidFunctionKind(kind));
}
private:
- class IsExpression : public BitField16<bool, 0, 1> {};
- class IsAnonymous : public BitField16<bool, 1, 1> {};
- class Pretenure : public BitField16<bool, 2, 1> {};
- class HasDuplicateParameters : public BitField16<bool, 3, 1> {};
- class IsFunction : public BitField16<bool, 4, 1> {};
- class ShouldEagerCompile : public BitField16<bool, 5, 1> {};
- class FunctionKindBits : public BitField16<FunctionKind, 6, 8> {};
- class ShouldBeUsedOnceHint : public BitField16<bool, 15, 1> {};
+ class IsDeclaration : public BitField16<bool, 0, 1> {};
+ class IsNamedExpression : public BitField16<bool, 1, 1> {};
+ class IsAnonymousExpression : public BitField16<bool, 2, 1> {};
+ class Pretenure : public BitField16<bool, 3, 1> {};
+ class HasDuplicateParameters : public BitField16<bool, 4, 1> {};
+ class IsFunction : public BitField16<bool, 5, 1> {};
+ class ShouldEagerCompile : public BitField16<bool, 6, 1> {};
+ class ShouldBeUsedOnceHint : public BitField16<bool, 7, 1> {};
+ class FunctionKindBits : public BitField16<FunctionKind, 8, 8> {};
// Start with 16-bit field, which should get packed together
// with Expression's trailing 16-bit field.
@@ -2796,13 +2775,6 @@
DECLARE_NODE_TYPE(ClassLiteral)
- Handle<String> name() const { return raw_name_->string(); }
- const AstRawString* raw_name() const { return raw_name_; }
- void set_raw_name(const AstRawString* name) {
- DCHECK_NULL(raw_name_);
- raw_name_ = name;
- }
-
Scope* scope() const { return scope_; }
VariableProxy* class_variable_proxy() const { return class_variable_proxy_; }
Expression* extends() const { return extends_; }
@@ -2817,13 +2789,14 @@
BailoutId DeclsId() const { return BailoutId(local_id(1)); }
BailoutId ExitId() { return BailoutId(local_id(2)); }
BailoutId CreateLiteralId() const { return BailoutId(local_id(3)); }
+ BailoutId PrototypeId() { return BailoutId(local_id(4)); }
// Return an AST id for a property that is used in simulate instructions.
- BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 4)); }
+ BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 5)); }
// Unlike other AST nodes, this number of bailout IDs allocated for an
// ClassLiteral can vary, so num_ids() is not a static method.
- int num_ids() const { return parent_num_ids() + 4 + properties()->length(); }
+ int num_ids() const { return parent_num_ids() + 5 + properties()->length(); }
// Object literals need one feedback slot for each non-trivial value, as well
// as some slots for home objects.
@@ -2835,15 +2808,19 @@
class_variable_proxy()->var()->IsUnallocated();
}
- FeedbackVectorSlot ProxySlot() const { return slot_; }
+ FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; }
+ FeedbackVectorSlot ProxySlot() const { return proxy_slot_; }
+
+ bool IsAnonymousFunctionDefinition() const final {
+ return constructor()->raw_name()->length() == 0;
+ }
protected:
- ClassLiteral(Zone* zone, const AstRawString* name, Scope* scope,
- VariableProxy* class_variable_proxy, Expression* extends,
- FunctionLiteral* constructor, ZoneList<Property*>* properties,
- int start_position, int end_position)
+ ClassLiteral(Zone* zone, Scope* scope, VariableProxy* class_variable_proxy,
+ Expression* extends, FunctionLiteral* constructor,
+ ZoneList<Property*>* properties, int start_position,
+ int end_position)
: Expression(zone, start_position),
- raw_name_(name),
scope_(scope),
class_variable_proxy_(class_variable_proxy),
extends_(extends),
@@ -2856,14 +2833,14 @@
private:
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
- const AstRawString* raw_name_;
Scope* scope_;
VariableProxy* class_variable_proxy_;
Expression* extends_;
FunctionLiteral* constructor_;
ZoneList<Property*>* properties_;
int end_position_;
- FeedbackVectorSlot slot_;
+ FeedbackVectorSlot prototype_slot_;
+ FeedbackVectorSlot proxy_slot_;
};
@@ -3095,12 +3072,11 @@
AstValueFactory* ast_value_factory() const { return ast_value_factory_; }
- VariableDeclaration* NewVariableDeclaration(
- VariableProxy* proxy, VariableMode mode, Scope* scope, int pos,
- bool is_class_declaration = false, int declaration_group_start = -1) {
+ VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy,
+ VariableMode mode, Scope* scope,
+ int pos) {
return new (parser_zone_)
- VariableDeclaration(parser_zone_, proxy, mode, scope, pos,
- is_class_declaration, declaration_group_start);
+ VariableDeclaration(parser_zone_, proxy, mode, scope, pos);
}
FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy,
@@ -3389,8 +3365,8 @@
CompareOperation(local_zone_, op, left, right, pos);
}
- Spread* NewSpread(Expression* expression, int pos) {
- return new (local_zone_) Spread(local_zone_, expression, pos);
+ Spread* NewSpread(Expression* expression, int pos, int expr_pos) {
+ return new (local_zone_) Spread(local_zone_, expression, pos, expr_pos);
}
Conditional* NewConditional(Expression* condition,
@@ -3401,12 +3377,9 @@
local_zone_, condition, then_expression, else_expression, position);
}
- RewritableAssignmentExpression* NewRewritableAssignmentExpression(
- Expression* expression) {
+ RewritableExpression* NewRewritableExpression(Expression* expression) {
DCHECK_NOT_NULL(expression);
- DCHECK(expression->IsAssignment());
- return new (local_zone_)
- RewritableAssignmentExpression(local_zone_, expression);
+ return new (local_zone_) RewritableExpression(local_zone_, expression);
}
Assignment* NewAssignment(Token::Value op,
@@ -3449,16 +3422,31 @@
parser_zone_, name, ast_value_factory_, scope, body,
materialized_literal_count, expected_property_count, parameter_count,
function_type, has_duplicate_parameters, eager_compile_hint, kind,
- position);
+ position, true);
}
- ClassLiteral* NewClassLiteral(const AstRawString* name, Scope* scope,
- VariableProxy* proxy, Expression* extends,
+ // Creates a FunctionLiteral representing a top-level script, the
+ // result of an eval (top-level or otherwise), or the result of calling
+ // the Function constructor.
+ FunctionLiteral* NewScriptOrEvalFunctionLiteral(
+ Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count,
+ int expected_property_count) {
+ return new (parser_zone_) FunctionLiteral(
+ parser_zone_, ast_value_factory_->empty_string(), ast_value_factory_,
+ scope, body, materialized_literal_count, expected_property_count, 0,
+ FunctionLiteral::kAnonymousExpression,
+ FunctionLiteral::kNoDuplicateParameters,
+ FunctionLiteral::kShouldLazyCompile, FunctionKind::kNormalFunction, 0,
+ false);
+ }
+
+ ClassLiteral* NewClassLiteral(Scope* scope, VariableProxy* proxy,
+ Expression* extends,
FunctionLiteral* constructor,
ZoneList<ObjectLiteral::Property*>* properties,
int start_position, int end_position) {
return new (parser_zone_)
- ClassLiteral(parser_zone_, name, scope, proxy, extends, constructor,
+ ClassLiteral(parser_zone_, scope, proxy, extends, constructor,
properties, start_position, end_position);
}
@@ -3529,6 +3517,46 @@
};
+// Type testing & conversion functions overridden by concrete subclasses.
+// Inline functions for AstNode.
+
+#define DECLARE_NODE_FUNCTIONS(type) \
+ bool AstNode::Is##type() const { \
+ NodeType mine = node_type(); \
+ if (mine == AstNode::kRewritableExpression && \
+ AstNode::k##type != AstNode::kRewritableExpression) \
+ mine = reinterpret_cast<const RewritableExpression*>(this) \
+ ->expression() \
+ ->node_type(); \
+ return mine == AstNode::k##type; \
+ } \
+ type* AstNode::As##type() { \
+ NodeType mine = node_type(); \
+ AstNode* result = this; \
+ if (mine == AstNode::kRewritableExpression && \
+ AstNode::k##type != AstNode::kRewritableExpression) { \
+ result = \
+ reinterpret_cast<const RewritableExpression*>(this)->expression(); \
+ mine = result->node_type(); \
+ } \
+ return mine == AstNode::k##type ? reinterpret_cast<type*>(result) : NULL; \
+ } \
+ const type* AstNode::As##type() const { \
+ NodeType mine = node_type(); \
+ const AstNode* result = this; \
+ if (mine == AstNode::kRewritableExpression && \
+ AstNode::k##type != AstNode::kRewritableExpression) { \
+ result = \
+ reinterpret_cast<const RewritableExpression*>(this)->expression(); \
+ mine = result->node_type(); \
+ } \
+ return mine == AstNode::k##type ? reinterpret_cast<const type*>(result) \
+ : NULL; \
+ }
+AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
+#undef DECLARE_NODE_FUNCTIONS
+
+
} // namespace internal
} // namespace v8