Commit ff85f50e authored by hpayer@chromium.org's avatar hpayer@chromium.org

Refactoring BuildAllocateElements.

BUG=

Review URL: https://codereview.chromium.org/13693004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14147 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c6385558
......@@ -376,7 +376,7 @@ HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
AddInstruction(new(zone) HFixedArrayBaseLength(elements));
HValue* new_elements =
BuildAllocateElements(context(), to_kind, elements_length);
BuildAllocateAndInitializeElements(context(), to_kind, elements_length);
BuildCopyElements(context(), elements,
casted_stub()->from_kind(), new_elements,
......
......@@ -1238,7 +1238,6 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess(
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)
......@@ -1273,7 +1272,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()
......@@ -1286,8 +1293,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;
}
......@@ -1372,7 +1387,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,
......
......@@ -1042,6 +1042,14 @@ class HGraphBuilder {
ElementsKind kind,
HValue* capacity);
void BuildInitializeElements(HValue* elements,
ElementsKind kind,
HValue* capacity);
HValue* BuildAllocateAndInitializeElements(HValue* context,
ElementsKind kind,
HValue* capacity);
HValue* BuildGrowElementsCapacity(HValue* object,
HValue* elements,
ElementsKind kind,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment