Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: src/ast.h

Issue 40295: Optimizing generation of nested literals for both object and array literals. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
===================================================================
--- src/ast.h (revision 1467)
+++ src/ast.h (working copy)
@@ -95,6 +95,7 @@
// Forward declarations
class TargetCollector;
+class MaterializedLiteral;
#define DEF_FORWARD_DECLARATION(type) class type;
NODE_LIST(DEF_FORWARD_DECLARATION)
@@ -129,7 +130,9 @@
virtual BinaryOperation* AsBinaryOperation() { return NULL; }
virtual Assignment* AsAssignment() { return NULL; }
virtual FunctionLiteral* AsFunctionLiteral() { return NULL; }
+ virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; }
virtual ObjectLiteral* AsObjectLiteral() { return NULL; }
+ virtual ArrayLiteral* AsArrayLiteral() { return NULL; }
void set_statement_pos(int statement_pos) { statement_pos_ = statement_pos; }
int statement_pos() const { return statement_pos_; }
@@ -633,11 +636,20 @@
// Base class for literals that needs space in the corresponding JSFunction.
class MaterializedLiteral: public Expression {
public:
- explicit MaterializedLiteral(int literal_index)
- : literal_index_(literal_index) {}
+ explicit MaterializedLiteral(int literal_index, bool is_simple)
+ : literal_index_(literal_index), is_simple_(is_simple) {}
+
+ virtual MaterializedLiteral* AsMaterializedLiteral() { return this; }
+
int literal_index() { return literal_index_; }
+
+ // A materialized literal is simple if the values consist of only
+ // constants and simple object and array literals.
+ bool is_simple() const { return is_simple_; }
+
private:
int literal_index_;
+ bool is_simple_;
};
@@ -652,11 +664,11 @@
public:
enum Kind {
- CONSTANT, // Property with constant value (at compile time).
- COMPUTED, // Property with computed value (at execution time).
- OBJECT_LITERAL, // Property value is an object literal.
- GETTER, SETTER, // Property is an accessor function.
- PROTOTYPE // Property is __proto__.
+ CONSTANT, // Property with constant value (compile time).
+ COMPUTED, // Property with computed value (execution time).
+ MATERIALIZED_LITERAL, // Property value is a materialized literal.
+ GETTER, SETTER, // Property is an accessor function.
+ PROTOTYPE // Property is __proto__.
};
Property(Literal* key, Expression* value);
@@ -676,11 +688,9 @@
ZoneList<Property*>* properties,
int literal_index,
bool is_simple)
- : MaterializedLiteral(literal_index),
+ : MaterializedLiteral(literal_index, is_simple),
constant_properties_(constant_properties),
- properties_(properties),
- is_simple_(is_simple) {
- }
+ properties_(properties) {}
virtual ObjectLiteral* AsObjectLiteral() { return this; }
virtual void Accept(AstVisitor* v);
@@ -690,14 +700,9 @@
}
ZoneList<Property*>* properties() const { return properties_; }
- // An object literal is simple if the values consist of only
- // constants and simple object literals.
- bool is_simple() const { return is_simple_; }
-
private:
Handle<FixedArray> constant_properties_;
ZoneList<Property*>* properties_;
- bool is_simple_;
};
@@ -707,7 +712,7 @@
RegExpLiteral(Handle<String> pattern,
Handle<String> flags,
int literal_index)
- : MaterializedLiteral(literal_index),
+ : MaterializedLiteral(literal_index, false),
pattern_(pattern),
flags_(flags) {}
@@ -723,14 +728,18 @@
// An array literal has a literals object that is used
// for minimizing the work when constructing it at runtime.
-class ArrayLiteral: public Expression {
+class ArrayLiteral: public MaterializedLiteral {
public:
ArrayLiteral(Handle<FixedArray> literals,
- ZoneList<Expression*>* values)
- : literals_(literals), values_(values) {
- }
+ ZoneList<Expression*>* values,
+ int literal_index,
+ bool is_simple)
+ : MaterializedLiteral(literal_index, is_simple),
+ literals_(literals),
+ values_(values) {}
virtual void Accept(AstVisitor* v);
+ virtual ArrayLiteral* AsArrayLiteral() { return this; }
Handle<FixedArray> literals() const { return literals_; }
ZoneList<Expression*>* values() const { return values_; }
« no previous file with comments | « no previous file | src/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698