From bdff9c70b8079efabe2b3e6b2636f57ef792ffba Mon Sep 17 00:00:00 2001 From: "bmeurer@chromium.org" Date: Wed, 10 Jul 2013 12:19:02 +0000 Subject: [PATCH] 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 --- src/code-stubs-hydrogen.cc | 29 ++++++++--------------------- src/hydrogen.cc | 11 ++++++----- src/hydrogen.h | 1 + 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index 51734da2f1..fad8cfba2b 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -528,45 +528,32 @@ Handle KeyedStoreFastElementStub::GenerateCode() { template <> HValue* CodeStubGraphBuilder::BuildCodeStub() { - Zone* zone = this->zone(); - HValue* js_array = GetParameter(0); HValue* map = GetParameter(1); info()->MarkAsSavesCallerDoubles(); - AddInstruction(new(zone) HTrapAllocationMemento(js_array)); + Add(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(array_length, - graph()->GetConstant0(), - Token::EQ); + if_builder.IfNot(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(); diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 70bc4cbe97..e1b14b2c6d 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -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); diff --git a/src/hydrogen.h b/src/hydrogen.h index b9de5c637d..b8f71228e3 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -1378,6 +1378,7 @@ class HGraphBuilder { HValue* BuildGrowElementsCapacity(HValue* object, HValue* elements, ElementsKind kind, + ElementsKind new_kind, HValue* length, HValue* new_capacity);