Chromium Code Reviews| Index: src/parser.cc |
| diff --git a/src/parser.cc b/src/parser.cc |
| index 7e648ede5a61dc030b58718e39e3d8c5a4db88ed..c83a88644d3bedccb978a93c56b42d94e7ab1fa6 100644 |
| --- a/src/parser.cc |
| +++ b/src/parser.cc |
| @@ -3377,7 +3377,9 @@ Expression* Parser::ParseArrayLiteral(bool* ok) { |
| Handle<FixedArray> object_literals = |
| isolate()->factory()->NewFixedArray(values->length(), TENURED); |
| Handle<FixedDoubleArray> double_literals; |
| + |
| ElementsKind elements_kind = FAST_SMI_ONLY_ELEMENTS; |
| + bool has_ony_undefined_values = true; |
|
Jakob Kummerow
2011/12/06 10:01:12
s/ony/only/
|
| // Fill in the literals. |
| bool is_simple = true; |
| @@ -3401,6 +3403,7 @@ Expression* Parser::ParseArrayLiteral(bool* ok) { |
| // FAST_DOUBLE_ELEMENTS and FAST_ELEMENTS as necessary. Always remember |
| // the tagged value, no matter what the ElementsKind is in case we |
| // ultimately end up in FAST_ELEMENTS. |
| + has_ony_undefined_values = false; |
|
Jakob Kummerow
2011/12/06 10:01:12
s/ony/only/
|
| object_literals->set(i, *boilerplate_value); |
| if (elements_kind == FAST_SMI_ONLY_ELEMENTS) { |
| // Smi only elements. Notice if a transition to FAST_DOUBLE_ELEMENTS or |
| @@ -3439,6 +3442,13 @@ Expression* Parser::ParseArrayLiteral(bool* ok) { |
| } |
| } |
| + // Very small array literals that don't have a concrete hint about their type |
| + // from a constant value should default to the slow case to avoid lots of |
| + // elements transitions on really small objects. |
| + if (has_ony_undefined_values && values->length() <= 2) { |
|
Jakob Kummerow
2011/12/06 10:01:12
s/ony/only/
|
| + elements_kind = FAST_ELEMENTS; |
| + } |
| + |
| // 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 && |