Index: src/ast.h |
diff --git a/src/ast.h b/src/ast.h |
index b4f7348eee314eaac011db31d3b238b877d7ef82..42f6c8bd939423cc08c48b69191594ed7dc37d11 100644 |
--- a/src/ast.h |
+++ b/src/ast.h |
@@ -1409,27 +1409,35 @@ class MaterializedLiteral : public Expression { |
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_; } |
- |
- int depth() const { return depth_; } |
- |
protected: |
MaterializedLiteral(Isolate* isolate, |
int literal_index, |
- bool is_simple, |
- int depth, |
int pos) |
: Expression(isolate, pos), |
literal_index_(literal_index), |
- is_simple_(is_simple), |
- depth_(depth) {} |
+ is_simple_(false) {} |
+ |
+ // 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_; } |
+ void set_is_simple(bool is_simple) { is_simple_ = is_simple; } |
+ friend class CompileTimeValue; |
+ |
+ // Populate the constant properties/elements fixed array. |
+ void BuildConstants(Isolate* isolate, int* depth); |
+ friend class ArrayLiteral; |
+ friend class ObjectLiteral; |
+ |
+ // 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(). |
+ // Otherwise, return undefined literal as the placeholder |
+ // in the object literal boilerplate. |
+ Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate); |
private: |
int literal_index_; |
bool is_simple_; |
- int depth_; |
}; |
@@ -1493,6 +1501,12 @@ class ObjectLiteral V8_FINAL : public MaterializedLiteral { |
bool may_store_doubles() const { return may_store_doubles_; } |
bool has_function() const { return has_function_; } |
+ // Decide if a property should be in the object boilerplate. |
+ static bool IsBoilerplateProperty(Property* property); |
+ |
+ // Populate the constant properties fixed array. |
+ void BuildConstantProperties(Isolate* isolate, int* depth = NULL); |
+ |
// Mark all computed expressions that are bound to a key that |
// is shadowed by a later occurrence of the same key. For the |
// marked expressions, no store code is emitted. |
@@ -1512,25 +1526,22 @@ class ObjectLiteral V8_FINAL : public MaterializedLiteral { |
protected: |
ObjectLiteral(Isolate* isolate, |
- Handle<FixedArray> constant_properties, |
ZoneList<Property*>* properties, |
int literal_index, |
- bool is_simple, |
- bool fast_elements, |
- int depth, |
- bool may_store_doubles, |
+ int boilerplate_properties, |
bool has_function, |
int pos) |
- : MaterializedLiteral(isolate, literal_index, is_simple, depth, pos), |
- constant_properties_(constant_properties), |
+ : MaterializedLiteral(isolate, literal_index, pos), |
properties_(properties), |
- fast_elements_(fast_elements), |
- may_store_doubles_(may_store_doubles), |
+ boilerplate_properties_(boilerplate_properties), |
+ fast_elements_(false), |
+ may_store_doubles_(false), |
has_function_(has_function) {} |
private: |
Handle<FixedArray> constant_properties_; |
ZoneList<Property*>* properties_; |
+ int boilerplate_properties_; |
bool fast_elements_; |
bool may_store_doubles_; |
bool has_function_; |
@@ -1551,7 +1562,7 @@ class RegExpLiteral V8_FINAL : public MaterializedLiteral { |
Handle<String> flags, |
int literal_index, |
int pos) |
- : MaterializedLiteral(isolate, literal_index, false, 1, pos), |
+ : MaterializedLiteral(isolate, literal_index, pos), |
pattern_(pattern), |
flags_(flags) {} |
@@ -1575,16 +1586,15 @@ class ArrayLiteral V8_FINAL : public MaterializedLiteral { |
return BailoutId(first_element_id_.ToInt() + i); |
} |
+ // Populate the constant elements fixed array. |
+ void BuildConstantElements(Isolate* isolate, int* depth = NULL); |
+ |
protected: |
ArrayLiteral(Isolate* isolate, |
- Handle<FixedArray> constant_elements, |
ZoneList<Expression*>* values, |
int literal_index, |
- bool is_simple, |
- int depth, |
int pos) |
- : MaterializedLiteral(isolate, literal_index, is_simple, depth, pos), |
- constant_elements_(constant_elements), |
+ : MaterializedLiteral(isolate, literal_index, pos), |
values_(values), |
first_element_id_(ReserveIdRange(isolate, values->length())) {} |
@@ -3066,18 +3076,14 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
} |
ObjectLiteral* NewObjectLiteral( |
- Handle<FixedArray> constant_properties, |
ZoneList<ObjectLiteral::Property*>* properties, |
int literal_index, |
- bool is_simple, |
- bool fast_elements, |
- int depth, |
- bool may_store_doubles, |
+ int boilerplate_properties, |
bool has_function, |
int pos) { |
ObjectLiteral* lit = new(zone_) ObjectLiteral( |
- isolate_, constant_properties, properties, literal_index, |
- is_simple, fast_elements, depth, may_store_doubles, has_function, pos); |
+ isolate_, properties, literal_index, boilerplate_properties, |
+ has_function, pos); |
VISIT_AND_RETURN(ObjectLiteral, lit) |
} |
@@ -3099,15 +3105,11 @@ class AstNodeFactory V8_FINAL BASE_EMBEDDED { |
VISIT_AND_RETURN(RegExpLiteral, lit); |
} |
- ArrayLiteral* NewArrayLiteral(Handle<FixedArray> constant_elements, |
- ZoneList<Expression*>* values, |
+ ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, |
int literal_index, |
- bool is_simple, |
- int depth, |
int pos) { |
ArrayLiteral* lit = new(zone_) ArrayLiteral( |
- isolate_, constant_elements, values, literal_index, is_simple, |
- depth, pos); |
+ isolate_, values, literal_index, pos); |
VISIT_AND_RETURN(ArrayLiteral, lit) |
} |