Index: src/parser.cc |
diff --git a/src/parser.cc b/src/parser.cc |
index 1df7c21450253e67a1b4674da43593b5b5551a11..0fef2e2b0e9915c6cf0804ef5c133b494ab8fc6b 100644 |
--- a/src/parser.cc |
+++ b/src/parser.cc |
@@ -3461,6 +3461,12 @@ Expression* Parser::ParseArrayLiteral(bool* ok) { |
} |
} |
+ // Simple and shallow arrays can be lazily copied, we transform the |
+ // elements array to a copy-on-write array. |
+ if (is_simple && depth == 1 && values.length() > 0) { |
+ literals->set_map(Heap::fixed_cow_array_map()); |
+ } |
+ |
return NEW(ArrayLiteral(literals, values.elements(), |
literal_index, is_simple, depth)); |
} |
@@ -3477,6 +3483,19 @@ bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { |
return lit != NULL && lit->is_simple(); |
} |
+ |
+bool CompileTimeValue::ArrayLiteralElementNeedsInitialization( |
+ Expression* value) { |
+ // If value is a literal the property value is already set in the |
+ // boilerplate object. |
+ if (value->AsLiteral() != NULL) return false; |
+ // If value is a materialized literal the property value is already set |
+ // in the boilerplate object if it is simple. |
+ if (CompileTimeValue::IsCompileTimeValue(value)) return false; |
+ return true; |
+} |
+ |
+ |
Handle<FixedArray> CompileTimeValue::GetValue(Expression* expression) { |
ASSERT(IsCompileTimeValue(expression)); |
Handle<FixedArray> result = Factory::NewFixedArray(2, TENURED); |