Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index c669cc24175f6954475d3422e31dace59fcb9305..d7605aa61c3f9314f59b83739abfb99d5f64167c 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -9760,6 +9760,15 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
HInstruction* object = Add<HAllocate>(object_size_constant, type, |
pretenure_flag, instance_type, site_context->current()); |
+ // If allocation folding reaches Page::kMaxRegularHeapObjectSize the |
+ // elements array may not get folded into the object. Hence, we set the |
+ // elements pointer to empty fixed array and let store elimination remove |
+ // this store in the folding case. |
+ HConstant* empty_fixed_array = Add<HConstant>( |
+ isolate()->factory()->empty_fixed_array()); |
+ Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
+ empty_fixed_array, INITIALIZING_STORE); |
+ |
BuildEmitObjectHeader(boilerplate_object, object); |
Handle<FixedArrayBase> elements(boilerplate_object->elements()); |
@@ -9783,14 +9792,6 @@ HInstruction* HOptimizedGraphBuilder::BuildFastLiteral( |
if (elements_size > 0) { |
HValue* object_elements_size = Add<HConstant>(elements_size); |
if (boilerplate_object->HasFastDoubleElements()) { |
- // Allocation folding will not be able to fold |object| and |
- // |object_elements| together if they are pre-tenured. |
- if (pretenure_flag == TENURED) { |
- HConstant* empty_fixed_array = Add<HConstant>( |
- isolate()->factory()->empty_fixed_array()); |
- Add<HStoreNamedField>(object, HObjectAccess::ForElementsPointer(), |
- empty_fixed_array); |
- } |
object_elements = Add<HAllocate>(object_elements_size, HType::Tagged(), |
pretenure_flag, FIXED_DOUBLE_ARRAY_TYPE, site_context->current()); |
} else { |