| Index: src/parser.cc
|
| diff --git a/src/parser.cc b/src/parser.cc
|
| index a7bb4e7985f7a3ac75de531d41415a4d73f47b5a..75fd7b73667eb611dd1393f26c1dc559addeff67 100644
|
| --- a/src/parser.cc
|
| +++ b/src/parser.cc
|
| @@ -3718,6 +3718,7 @@ Expression* Parser::ParseArrayLiteral(bool* ok) {
|
| isolate()->factory()->NewFixedArray(values->length(), TENURED);
|
| Handle<FixedDoubleArray> double_literals;
|
| ElementsKind elements_kind = FAST_SMI_ELEMENTS;
|
| + bool has_only_undefined_values = true;
|
| bool has_hole_values = false;
|
|
|
| // Fill in the literals.
|
| @@ -3749,6 +3750,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_only_undefined_values = false;
|
| object_literals->set(i, *boilerplate_value);
|
| if (elements_kind == FAST_SMI_ELEMENTS) {
|
| // Smi only elements. Notice if a transition to FAST_DOUBLE_ELEMENTS or
|
| @@ -3787,6 +3789,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_only_undefined_values && values->length() <= 2) {
|
| + 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 &&
|
|
|