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() { ...@@ -376,7 +376,7 @@ HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
AddInstruction(new(zone) HFixedArrayBaseLength(elements)); AddInstruction(new(zone) HFixedArrayBaseLength(elements));
HValue* new_elements = HValue* new_elements =
BuildAllocateElements(context(), to_kind, elements_length); BuildAllocateAndInitializeElements(context(), to_kind, elements_length);
BuildCopyElements(context(), elements, BuildCopyElements(context(), elements,
casted_stub()->from_kind(), new_elements, casted_stub()->from_kind(), new_elements,
......
...@@ -1238,7 +1238,6 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess( ...@@ -1238,7 +1238,6 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess(
HValue* HGraphBuilder::BuildAllocateElements(HValue* context, HValue* HGraphBuilder::BuildAllocateElements(HValue* context,
ElementsKind kind, ElementsKind kind,
HValue* capacity) { HValue* capacity) {
BailoutId ast_id = current_block()->last_environment()->previous_ast_id();
Zone* zone = this->zone(); Zone* zone = this->zone();
int elements_size = IsFastDoubleElementsKind(kind) int elements_size = IsFastDoubleElementsKind(kind)
...@@ -1273,7 +1272,15 @@ HValue* HGraphBuilder::BuildAllocateElements(HValue* context, ...@@ -1273,7 +1272,15 @@ HValue* HGraphBuilder::BuildAllocateElements(HValue* context,
HValue* elements = HValue* elements =
AddInstruction(new(zone) HAllocate(context, total_size, AddInstruction(new(zone) HAllocate(context, total_size,
HType::JSArray(), flags)); 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(); Factory* factory = isolate()->factory();
Handle<Map> map = IsFastDoubleElementsKind(kind) Handle<Map> map = IsFastDoubleElementsKind(kind)
? factory->fixed_double_array_map() ? factory->fixed_double_array_map()
...@@ -1286,8 +1293,16 @@ HValue* HGraphBuilder::BuildAllocateElements(HValue* context, ...@@ -1286,8 +1293,16 @@ HValue* HGraphBuilder::BuildAllocateElements(HValue* context,
capacity, true, FixedArray::kLengthOffset); capacity, true, FixedArray::kLengthOffset);
AddInstruction(store_length); AddInstruction(store_length);
AddSimulate(ast_id, REMOVABLE_SIMULATE); 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, ...@@ -1372,7 +1387,7 @@ HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object,
BuildNewSpaceArrayCheck(new_capacity, kind); BuildNewSpaceArrayCheck(new_capacity, kind);
HValue* new_elements = HValue* new_elements =
BuildAllocateElements(context, kind, new_capacity); BuildAllocateAndInitializeElements(context, kind, new_capacity);
BuildCopyElements(context, elements, kind, BuildCopyElements(context, elements, kind,
new_elements, kind, new_elements, kind,
......
...@@ -1042,6 +1042,14 @@ class HGraphBuilder { ...@@ -1042,6 +1042,14 @@ class HGraphBuilder {
ElementsKind kind, ElementsKind kind,
HValue* capacity); HValue* capacity);
void BuildInitializeElements(HValue* elements,
ElementsKind kind,
HValue* capacity);
HValue* BuildAllocateAndInitializeElements(HValue* context,
ElementsKind kind,
HValue* capacity);
HValue* BuildGrowElementsCapacity(HValue* object, HValue* BuildGrowElementsCapacity(HValue* object,
HValue* elements, HValue* elements,
ElementsKind kind, 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