Use BuildGrowElementsCapacity for the TransitionElementsKind stub.

R=danno@chromium.org, dslomov@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15589 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
bmeurer@chromium.org 2013-07-10 12:19:02 +00:00
parent 22d7a85519
commit bdff9c70b8
3 changed files with 15 additions and 26 deletions

View File

@ -528,45 +528,32 @@ Handle<Code> KeyedStoreFastElementStub::GenerateCode() {
template <>
HValue* CodeStubGraphBuilder<TransitionElementsKindStub>::BuildCodeStub() {
Zone* zone = this->zone();
HValue* js_array = GetParameter(0);
HValue* map = GetParameter(1);
info()->MarkAsSavesCallerDoubles();
AddInstruction(new(zone) HTrapAllocationMemento(js_array));
Add<HTrapAllocationMemento>(js_array);
HInstruction* array_length =
AddLoad(js_array, HObjectAccess::ForArrayLength());
array_length->set_type(HType::Smi());
ElementsKind to_kind = casted_stub()->to_kind();
BuildNewSpaceArrayCheck(array_length, to_kind);
IfBuilder if_builder(this);
if_builder.If<HCompareNumericAndBranch>(array_length,
graph()->GetConstant0(),
Token::EQ);
if_builder.IfNot<HCompareNumericAndBranch>(array_length,
graph()->GetConstant0(),
Token::EQ);
if_builder.Then();
// Nothing to do, just change the map.
if_builder.Else();
HInstruction* elements = AddLoadElements(js_array);
HInstruction* elements_length = AddLoadFixedArrayLength(elements);
HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader(
context(), to_kind, elements_length);
BuildCopyElements(context(), elements,
casted_stub()->from_kind(), new_elements,
to_kind, array_length, elements_length);
AddStore(js_array, HObjectAccess::ForElementsPointer(), new_elements);
BuildGrowElementsCapacity(js_array, elements,
casted_stub()->from_kind(),
casted_stub()->to_kind(),
array_length, elements_length);
if_builder.End();

View File

@ -1159,7 +1159,7 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object,
BuildNewElementsCapacity(context, current_capacity);
HValue* new_elements = BuildGrowElementsCapacity(object, elements,
kind, length,
kind, kind, length,
new_capacity);
environment()->Push(new_elements);
@ -1203,7 +1203,7 @@ HValue* HGraphBuilder::BuildCopyElementsOnWrite(HValue* object,
HValue* capacity = AddLoadFixedArrayLength(elements);
HValue* new_elements = BuildGrowElementsCapacity(object, elements,
HValue* new_elements = BuildGrowElementsCapacity(object, elements, kind,
kind, length, capacity);
environment()->Push(new_elements);
@ -1475,17 +1475,18 @@ void HGraphBuilder::BuildNewSpaceArrayCheck(HValue* length, ElementsKind kind) {
HValue* HGraphBuilder::BuildGrowElementsCapacity(HValue* object,
HValue* elements,
ElementsKind kind,
ElementsKind new_kind,
HValue* length,
HValue* new_capacity) {
HValue* context = environment()->LookupContext();
BuildNewSpaceArrayCheck(new_capacity, kind);
BuildNewSpaceArrayCheck(new_capacity, new_kind);
HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader(
context, kind, new_capacity);
context, new_kind, new_capacity);
BuildCopyElements(context, elements, kind,
new_elements, kind,
new_elements, new_kind,
length, new_capacity);
AddStore(object, HObjectAccess::ForElementsPointer(), new_elements);

View File

@ -1378,6 +1378,7 @@ class HGraphBuilder {
HValue* BuildGrowElementsCapacity(HValue* object,
HValue* elements,
ElementsKind kind,
ElementsKind new_kind,
HValue* length,
HValue* new_capacity);