Index: src/hydrogen.cc |
diff --git a/src/hydrogen.cc b/src/hydrogen.cc |
index 20973f02338f88996f17d57d974eb5fe3a0c02fd..bb3ef5e4706c7474ba58c4002925e71861b65a3e 100644 |
--- a/src/hydrogen.cc |
+++ b/src/hydrogen.cc |
@@ -1245,7 +1245,6 @@ HInstruction* HGraphBuilder::BuildFastArrayLengthLoad(HValue* object, |
HValue* HGraphBuilder::BuildAllocateElements(HValue* context, |
ElementsKind kind, |
HValue* capacity) { |
- BailoutId ast_id = current_block()->last_environment()->previous_ast_id(); |
Zone* zone = this->zone(); |
int elements_size = IsFastDoubleElementsKind(kind) |
@@ -1280,7 +1279,15 @@ HValue* HGraphBuilder::BuildAllocateElements(HValue* context, |
HValue* elements = |
AddInstruction(new(zone) HAllocate(context, total_size, |
HType::JSArray(), flags)); |
+ return elements; |
+} |
+ |
+void HGraphBuilder::BuildInitializeElements(HValue* elements, |
+ ElementsKind kind, |
+ HValue* capacity) { |
+ Zone* zone = this->zone(); |
+ BailoutId ast_id = current_block()->last_environment()->previous_ast_id(); |
Factory* factory = isolate()->factory(); |
Handle<Map> map = IsFastDoubleElementsKind(kind) |
? factory->fixed_double_array_map() |
@@ -1293,8 +1300,16 @@ HValue* HGraphBuilder::BuildAllocateElements(HValue* context, |
capacity, true, FixedArray::kLengthOffset); |
AddInstruction(store_length); |
AddSimulate(ast_id, REMOVABLE_SIMULATE); |
+} |
- return elements; |
+ |
+HValue* HGraphBuilder::BuildAllocateAndInitializeElements(HValue* context, |
+ ElementsKind kind, |
+ HValue* capacity) { |
+ HValue* new_elements = |
+ BuildAllocateElements(context, kind, capacity); |
+ BuildInitializeElements(new_elements, kind, capacity); |
+ return new_elements; |
} |
@@ -1379,7 +1394,7 @@ HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object, |
BuildNewSpaceArrayCheck(new_capacity, kind); |
HValue* new_elements = |
- BuildAllocateElements(context, kind, new_capacity); |
+ BuildAllocateAndInitializeElements(context, kind, new_capacity); |
BuildCopyElements(context, elements, kind, |
new_elements, kind, |