From: titzer@chromium.org Date: Tue, 2 Jul 2013 15:31:17 +0000 (+0000) Subject: Remove HFixedArrayBaseLength instruction and replace with regular HLoadNamedField. X-Git-Tag: upstream/4.7.83~13566 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=63abcc515bd439f932948c45cd6800c85d8b1ada;p=platform%2Fupstream%2Fv8.git Remove HFixedArrayBaseLength instruction and replace with regular HLoadNamedField. BUG= Review URL: https://codereview.chromium.org/18508002 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15454 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index c28b641..b08353e 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -1796,13 +1796,6 @@ LInstruction* LChunkBuilder::DoClassOfTestAndBranch( } -LInstruction* LChunkBuilder::DoFixedArrayBaseLength( - HFixedArrayBaseLength* instr) { - LOperand* array = UseRegisterAtStart(instr->value()); - return DefineAsRegister(new(zone()) LFixedArrayBaseLength(array)); -} - - LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) { LOperand* map = UseRegisterAtStart(instr->value()); return DefineAsRegister(new(zone()) LMapEnumLength(map)); diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index f34b623..39cab8f 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -99,7 +99,6 @@ class LCodeGen; V(DoubleToSmi) \ V(DummyUse) \ V(ElementsKind) \ - V(FixedArrayBaseLength) \ V(FunctionLiteral) \ V(GetCachedArrayIndex) \ V(GlobalObject) \ @@ -1281,20 +1280,6 @@ class LCmpMapAndBranch: public LControlInstruction<1, 1> { }; -class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> { - public: - explicit LFixedArrayBaseLength(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength, - "fixed-array-base-length") - DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength) -}; - - class LMapEnumLength: public LTemplateInstruction<1, 1, 0> { public: explicit LMapEnumLength(LOperand* value) { diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index 8525095..272db15 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -1846,13 +1846,6 @@ void LCodeGen::DoConstantT(LConstantT* instr) { } -void LCodeGen::DoFixedArrayBaseLength(LFixedArrayBaseLength* instr) { - Register result = ToRegister(instr->result()); - Register array = ToRegister(instr->value()); - __ ldr(result, FieldMemOperand(array, FixedArrayBase::kLengthOffset)); -} - - void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) { Register result = ToRegister(instr->result()); Register map = ToRegister(instr->value()); diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index 06c9039..96266af 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -510,8 +510,7 @@ HValue* CodeStubGraphBuilder::BuildCodeStub() { HInstruction* elements = AddLoadElements(js_array); - HInstruction* elements_length = - AddInstruction(new(zone) HFixedArrayBaseLength(elements)); + HInstruction* elements_length = AddLoadFixedArrayLength(elements); HValue* new_elements = BuildAllocateElementsAndInitializeElementsHeader( context(), to_kind, elements_length); diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index ab028a9..26bda87 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -111,7 +111,6 @@ class LChunkBuilder; V(ElementsKind) \ V(EnterInlined) \ V(EnvironmentMarker) \ - V(FixedArrayBaseLength) \ V(ForceRepresentation) \ V(FunctionLiteral) \ V(GetCachedArrayIndex) \ @@ -2542,29 +2541,6 @@ class HCallRuntime: public HCall<1> { }; -class HFixedArrayBaseLength: public HUnaryOperation { - public: - explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) { - set_type(HType::Smi()); - set_representation(Representation::Smi()); - SetFlag(kUseGVN); - SetGVNFlag(kDependsOnArrayLengths); - } - - virtual Representation RequiredInputRepresentation(int index) { - return Representation::Tagged(); - } - - DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength) - - protected: - virtual bool DataEquals(HValue* other) { return true; } - - private: - virtual bool IsDeletable() const { return true; } -}; - - class HMapEnumLength: public HUnaryOperation { public: explicit HMapEnumLength(HValue* value) : HUnaryOperation(value) { diff --git a/src/hydrogen.cc b/src/hydrogen.cc index ff340b7..32ce879 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -1132,7 +1132,7 @@ HValue* HGraphBuilder::BuildCheckForCapacityGrow(HValue* object, length_checker.IfCompare(length, key, Token::EQ); length_checker.Then(); - HValue* current_capacity = Add(elements); + HValue* current_capacity = AddLoadFixedArrayLength(elements); IfBuilder capacity_checker(this); @@ -1188,7 +1188,7 @@ HValue* HGraphBuilder::BuildCopyElementsOnWrite(HValue* object, Handle(heap->fixed_cow_array_map())); cow_checker.Then(); - HValue* capacity = Add(elements); + HValue* capacity = AddLoadFixedArrayLength(elements); HValue* new_elements = BuildGrowElementsCapacity(object, elements, kind, length, capacity); @@ -1243,10 +1243,10 @@ HInstruction* HGraphBuilder::BuildUncheckedMonomorphicElementAccess( if (is_js_array) { length = AddLoad(object, HObjectAccess::ForArrayLength(), mapcheck, Representation::Smi()); - length->set_type(HType::Smi()); } else { - length = Add(elements); + length = AddLoadFixedArrayLength(elements); } + length->set_type(HType::Smi()); HValue* checked_key = NULL; if (IsExternalArrayElementsKind(elements_kind)) { if (store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS) { @@ -1416,6 +1416,14 @@ HLoadNamedField* HGraphBuilder::AddLoadElements(HValue* object, } +HLoadNamedField* HGraphBuilder::AddLoadFixedArrayLength(HValue* object) { + HLoadNamedField* instr = AddLoad(object, HObjectAccess::ForFixedArrayLength(), + NULL, Representation::Smi()); + instr->set_type(HType::Smi()); + return instr; +} + + HValue* HGraphBuilder::BuildNewElementsCapacity(HValue* context, HValue* old_capacity) { Zone* zone = this->zone(); @@ -6813,7 +6821,7 @@ HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess( LAST_ELEMENTS_KIND); if (elements_kind == FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND && todo_external_array) { - HInstruction* length = Add(elements); + HInstruction* length = AddLoadFixedArrayLength(elements); checked_key = Add(key, length); external_elements = Add(elements); } @@ -6873,7 +6881,7 @@ HValue* HOptimizedGraphBuilder::HandlePolymorphicElementAccess( if_jsarray->GotoNoSimulate(join); set_current_block(if_fastobject); - length = AddInstruction(new(zone()) HFixedArrayBaseLength(elements)); + length = AddLoadFixedArrayLength(elements); checked_key = Add(key, length); access = AddInstruction(BuildFastElementAccess( elements, checked_key, val, elements_kind_branch, diff --git a/src/hydrogen.h b/src/hydrogen.h index 3ea3262..3a8d242 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -1135,6 +1135,8 @@ class HGraphBuilder { HLoadNamedField* AddLoadElements(HValue *object, HValue *typecheck = NULL); + HLoadNamedField* AddLoadFixedArrayLength(HValue *object); + class IfBuilder { public: explicit IfBuilder(HGraphBuilder* builder, diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 96fb98e..defae1c 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -1773,14 +1773,6 @@ void LCodeGen::DoConstantT(LConstantT* instr) { } -void LCodeGen::DoFixedArrayBaseLength( - LFixedArrayBaseLength* instr) { - Register result = ToRegister(instr->result()); - Register array = ToRegister(instr->value()); - __ mov(result, FieldOperand(array, FixedArrayBase::kLengthOffset)); -} - - void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) { Register result = ToRegister(instr->result()); Register map = ToRegister(instr->value()); diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index c01cf8c..8231c4e 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -1816,13 +1816,6 @@ LInstruction* LChunkBuilder::DoClassOfTestAndBranch( } -LInstruction* LChunkBuilder::DoFixedArrayBaseLength( - HFixedArrayBaseLength* instr) { - LOperand* array = UseRegisterAtStart(instr->value()); - return DefineAsRegister(new(zone()) LFixedArrayBaseLength(array)); -} - - LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) { LOperand* map = UseRegisterAtStart(instr->value()); return DefineAsRegister(new(zone()) LMapEnumLength(map)); diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index 59c6c81..e48e881 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -94,7 +94,6 @@ class LCodeGen; V(DoubleToSmi) \ V(DummyUse) \ V(ElementsKind) \ - V(FixedArrayBaseLength) \ V(FunctionLiteral) \ V(GetCachedArrayIndex) \ V(GlobalObject) \ @@ -1251,20 +1250,6 @@ class LCmpMapAndBranch: public LControlInstruction<1, 0> { }; -class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> { - public: - explicit LFixedArrayBaseLength(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength, - "fixed-array-base-length") - DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength) -}; - - class LMapEnumLength: public LTemplateInstruction<1, 1, 0> { public: explicit LMapEnumLength(LOperand* value) { diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 3e55923..8109e8a 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -1675,13 +1675,6 @@ void LCodeGen::DoConstantT(LConstantT* instr) { } -void LCodeGen::DoFixedArrayBaseLength(LFixedArrayBaseLength* instr) { - Register result = ToRegister(instr->result()); - Register array = ToRegister(instr->value()); - __ lw(result, FieldMemOperand(array, FixedArrayBase::kLengthOffset)); -} - - void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) { Register result = ToRegister(instr->result()); Register map = ToRegister(instr->value()); diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index e68c722..638eaa4 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -1716,13 +1716,6 @@ LInstruction* LChunkBuilder::DoClassOfTestAndBranch( } -LInstruction* LChunkBuilder::DoFixedArrayBaseLength( - HFixedArrayBaseLength* instr) { - LOperand* array = UseRegisterAtStart(instr->value()); - return DefineAsRegister(new(zone()) LFixedArrayBaseLength(array)); -} - - LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) { LOperand* map = UseRegisterAtStart(instr->value()); return DefineAsRegister(new(zone()) LMapEnumLength(map)); diff --git a/src/mips/lithium-mips.h b/src/mips/lithium-mips.h index 3e94301..06d30d0 100644 --- a/src/mips/lithium-mips.h +++ b/src/mips/lithium-mips.h @@ -99,7 +99,6 @@ class LCodeGen; V(DoubleToSmi) \ V(DummyUse) \ V(ElementsKind) \ - V(FixedArrayBaseLength) \ V(FunctionLiteral) \ V(GetCachedArrayIndex) \ V(GlobalObject) \ @@ -1260,20 +1259,6 @@ class LCmpMapAndBranch: public LControlInstruction<1, 1> { }; -class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> { - public: - explicit LFixedArrayBaseLength(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength, - "fixed-array-base-length") - DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength) -}; - - class LMapEnumLength: public LTemplateInstruction<1, 1, 0> { public: explicit LMapEnumLength(LOperand* value) { diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index c97475a..de43f86 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -1553,13 +1553,6 @@ void LCodeGen::DoConstantT(LConstantT* instr) { } -void LCodeGen::DoFixedArrayBaseLength(LFixedArrayBaseLength* instr) { - Register result = ToRegister(instr->result()); - Register array = ToRegister(instr->value()); - __ movq(result, FieldOperand(array, FixedArrayBase::kLengthOffset)); -} - - void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) { Register result = ToRegister(instr->result()); Register map = ToRegister(instr->value()); diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index 9c2373a..95a44f0 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -1718,13 +1718,6 @@ LInstruction* LChunkBuilder::DoClassOfTestAndBranch( } -LInstruction* LChunkBuilder::DoFixedArrayBaseLength( - HFixedArrayBaseLength* instr) { - LOperand* array = UseRegisterAtStart(instr->value()); - return DefineAsRegister(new(zone()) LFixedArrayBaseLength(array)); -} - - LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) { LOperand* map = UseRegisterAtStart(instr->value()); return DefineAsRegister(new(zone()) LMapEnumLength(map)); diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h index d6edd6d..a7530be 100644 --- a/src/x64/lithium-x64.h +++ b/src/x64/lithium-x64.h @@ -99,7 +99,6 @@ class LCodeGen; V(DoubleToSmi) \ V(DummyUse) \ V(ElementsKind) \ - V(FixedArrayBaseLength) \ V(MapEnumLength) \ V(FunctionLiteral) \ V(GetCachedArrayIndex) \ @@ -1233,20 +1232,6 @@ class LCmpMapAndBranch: public LControlInstruction<1, 0> { }; -class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> { - public: - explicit LFixedArrayBaseLength(LOperand* value) { - inputs_[0] = value; - } - - LOperand* value() { return inputs_[0]; } - - DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength, - "fixed-array-base-length") - DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength) -}; - - class LMapEnumLength: public LTemplateInstruction<1, 1, 0> { public: explicit LMapEnumLength(LOperand* value) {