| Index: src/ast.h
|
| ===================================================================
|
| --- src/ast.h (revision 3935)
|
| +++ src/ast.h (working copy)
|
| @@ -1,4 +1,4 @@
|
| -// Copyright 2006-2008 the V8 project authors. All rights reserved.
|
| +// Copyright 2010 the V8 project authors. All rights reserved.
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| // met:
|
| @@ -102,6 +102,7 @@
|
| // Forward declarations
|
| class TargetCollector;
|
| class MaterializedLiteral;
|
| +class DefinitionInfo;
|
|
|
| #define DEF_FORWARD_DECLARATION(type) class type;
|
| AST_NODE_LIST(DEF_FORWARD_DECLARATION)
|
| @@ -182,7 +183,7 @@
|
|
|
| static const int kNoLabel = -1;
|
|
|
| - Expression() : num_(kNoLabel) {}
|
| + Expression() : num_(kNoLabel), def_(NULL), defined_vars_(NULL) {}
|
|
|
| virtual Expression* AsExpression() { return this; }
|
|
|
| @@ -193,6 +194,15 @@
|
| // names because [] for string objects is handled only by keyed ICs.
|
| virtual bool IsPropertyName() { return false; }
|
|
|
| + // True if the expression does not have (evaluated) subexpressions.
|
| + // Function literals are leaves because their subexpressions are not
|
| + // evaluated.
|
| + virtual bool IsLeaf() { return false; }
|
| +
|
| + // True if the expression has no side effects and is safe to
|
| + // evaluate out of order.
|
| + virtual bool IsTrivial() { return false; }
|
| +
|
| // Mark the expression as being compiled as an expression
|
| // statement. This is used to transform postfix increments to
|
| // (faster) prefix increments.
|
| @@ -206,9 +216,20 @@
|
| // AST node numbering ordered by evaluation order.
|
| void set_num(int n) { num_ = n; }
|
|
|
| + // Data flow information.
|
| + DefinitionInfo* var_def() { return def_; }
|
| + void set_var_def(DefinitionInfo* def) { def_ = def; }
|
| +
|
| + ZoneList<DefinitionInfo*>* defined_vars() { return defined_vars_; }
|
| + void set_defined_vars(ZoneList<DefinitionInfo*>* defined_vars) {
|
| + defined_vars_ = defined_vars;
|
| + }
|
| +
|
| private:
|
| StaticType type_;
|
| int num_;
|
| + DefinitionInfo* def_;
|
| + ZoneList<DefinitionInfo*>* defined_vars_;
|
| };
|
|
|
|
|
| @@ -720,6 +741,9 @@
|
| return false;
|
| }
|
|
|
| + virtual bool IsLeaf() { return true; }
|
| + virtual bool IsTrivial() { return true; }
|
| +
|
| // Identity testers.
|
| bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); }
|
| bool IsTrue() const { return handle_.is_identical_to(Factory::true_value()); }
|
| @@ -802,6 +826,8 @@
|
| virtual ObjectLiteral* AsObjectLiteral() { return this; }
|
| virtual void Accept(AstVisitor* v);
|
|
|
| + virtual bool IsLeaf() { return properties()->is_empty(); }
|
| +
|
| Handle<FixedArray> constant_properties() const {
|
| return constant_properties_;
|
| }
|
| @@ -825,6 +851,8 @@
|
|
|
| virtual void Accept(AstVisitor* v);
|
|
|
| + virtual bool IsLeaf() { return true; }
|
| +
|
| Handle<String> pattern() const { return pattern_; }
|
| Handle<String> flags() const { return flags_; }
|
|
|
| @@ -849,6 +877,8 @@
|
| virtual void Accept(AstVisitor* v);
|
| virtual ArrayLiteral* AsArrayLiteral() { return this; }
|
|
|
| + virtual bool IsLeaf() { return values()->is_empty(); }
|
| +
|
| Handle<FixedArray> constant_elements() const { return constant_elements_; }
|
| ZoneList<Expression*>* values() const { return values_; }
|
|
|
| @@ -896,6 +926,15 @@
|
| return var_ == NULL ? true : var_->IsValidLeftHandSide();
|
| }
|
|
|
| + virtual bool IsLeaf() {
|
| + ASSERT(var_ != NULL); // Variable must be resolved.
|
| + return var()->is_global() || var()->rewrite()->IsLeaf();
|
| + }
|
| +
|
| + // Reading from a mutable variable is a side effect, but 'this' is
|
| + // immutable.
|
| + virtual bool IsTrivial() { return is_this(); }
|
| +
|
| bool IsVariable(Handle<String> n) {
|
| return !is_this() && name().is_identical_to(n);
|
| }
|
| @@ -981,6 +1020,8 @@
|
| // Type testing & conversion
|
| virtual Slot* AsSlot() { return this; }
|
|
|
| + virtual bool IsLeaf() { return true; }
|
| +
|
| // Accessors
|
| Variable* var() const { return var_; }
|
| Type type() const { return type_; }
|
| @@ -1337,6 +1378,8 @@
|
| // Type testing & conversion
|
| virtual FunctionLiteral* AsFunctionLiteral() { return this; }
|
|
|
| + virtual bool IsLeaf() { return true; }
|
| +
|
| Handle<String> name() const { return name_; }
|
| Scope* scope() const { return scope_; }
|
| ZoneList<Statement*>* body() const { return body_; }
|
| @@ -1403,6 +1446,8 @@
|
|
|
| Handle<JSFunction> boilerplate() const { return boilerplate_; }
|
|
|
| + virtual bool IsLeaf() { return true; }
|
| +
|
| virtual void Accept(AstVisitor* v);
|
|
|
| private:
|
| @@ -1413,6 +1458,7 @@
|
| class ThisFunction: public Expression {
|
| public:
|
| virtual void Accept(AstVisitor* v);
|
| + virtual bool IsLeaf() { return true; }
|
| };
|
|
|
|
|
|
|