From: bmeurer@chromium.org Date: Mon, 2 Dec 2013 11:24:31 +0000 (+0000) Subject: Fix HInnerAllocatedObject to use an HValue for the offset. X-Git-Tag: upstream/4.7.83~11472 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a3d1df29f12a3e53b2d291c35a5cd834e7bba009;p=platform%2Fupstream%2Fv8.git Fix HInnerAllocatedObject to use an HValue for the offset. R=hpayer@chromium.org, mvstanton@chromium.org Review URL: https://codereview.chromium.org/98673003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18181 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 5a09ae8..3e8806d 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -272,7 +272,8 @@ void LStoreCodeEntry::PrintDataTo(StringStream* stream) { void LInnerAllocatedObject::PrintDataTo(StringStream* stream) { stream->Add(" = "); base_object()->PrintTo(stream); - stream->Add(" + %d", offset()); + stream->Add(" + "); + offset()->PrintTo(stream); } @@ -1116,11 +1117,11 @@ LInstruction* LChunkBuilder::DoStoreCodeEntry( LInstruction* LChunkBuilder::DoInnerAllocatedObject( - HInnerAllocatedObject* inner_object) { - LOperand* base_object = UseRegisterAtStart(inner_object->base_object()); - LInnerAllocatedObject* result = - new(zone()) LInnerAllocatedObject(base_object); - return DefineAsRegister(result); + HInnerAllocatedObject* instr) { + LOperand* base_object = UseRegisterAtStart(instr->base_object()); + LOperand* offset = UseRegisterOrConstantAtStart(instr->offset()); + return DefineAsRegister( + new(zone()) LInnerAllocatedObject(base_object, offset)); } diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index 19e26ba..cfafc06 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -1798,19 +1798,19 @@ class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> { }; -class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 1, 0> { +class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> { public: - explicit LInnerAllocatedObject(LOperand* base_object) { + LInnerAllocatedObject(LOperand* base_object, LOperand* offset) { inputs_[0] = base_object; + inputs_[1] = offset; } - LOperand* base_object() { return inputs_[0]; } - int offset() { return hydrogen()->offset(); } + LOperand* base_object() const { return inputs_[0]; } + LOperand* offset() const { return inputs_[1]; } virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; - DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object") - DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject) + DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object") }; diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index c81d3e9..b432bc8 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -4179,7 +4179,13 @@ void LCodeGen::DoStoreCodeEntry(LStoreCodeEntry* instr) { void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) { Register result = ToRegister(instr->result()); Register base = ToRegister(instr->base_object()); - __ add(result, base, Operand(instr->offset())); + if (instr->offset()->IsConstantOperand()) { + LConstantOperand* offset = LConstantOperand::cast(instr->offset()); + __ add(result, base, Operand(ToInteger32(offset))); + } else { + Register offset = ToRegister(instr->offset()); + __ add(result, base, offset); + } } diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index 03b8c18..acda324 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -469,7 +469,8 @@ HValue* CodeStubGraphBuilder::BuildCodeStub() { ASSERT(FLAG_allocation_site_pretenuring || (size == object_size)); if (FLAG_allocation_site_pretenuring) { - BuildCreateAllocationMemento(object, object_size, allocation_site); + BuildCreateAllocationMemento( + object, Add(object_size), allocation_site); } environment()->Push(object); diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index e93d340..9f96202 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -3505,7 +3505,7 @@ void HAllocate::HandleSideEffectDominator(GVNFlag side_effect, HInnerAllocatedObject::New(zone, context(), dominator_allocate, - dominator_size_constant, + dominator_size, type()); dominated_allocate_instr->InsertBefore(this); DeleteAndReplaceWith(dominated_allocate_instr); @@ -3601,11 +3601,9 @@ void HAllocate::UpdateFreeSpaceFiller(int32_t free_space_size) { void HAllocate::CreateFreeSpaceFiller(int32_t free_space_size) { ASSERT(filler_free_space_size_ == NULL); Zone* zone = block()->zone(); - int32_t dominator_size = - HConstant::cast(dominating_allocate_->size())->GetInteger32Constant(); HInstruction* free_space_instr = HInnerAllocatedObject::New(zone, context(), dominating_allocate_, - dominator_size, type()); + dominating_allocate_->size(), type()); free_space_instr->InsertBefore(this); HConstant* filler_map = HConstant::New( zone, diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 52e3ba0..d4beb6e 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -5609,21 +5609,21 @@ class HStoreCodeEntry V8_FINAL: public HTemplateInstruction<2> { }; -class HInnerAllocatedObject V8_FINAL: public HTemplateInstruction<1> { +class HInnerAllocatedObject V8_FINAL : public HTemplateInstruction<2> { public: static HInnerAllocatedObject* New(Zone* zone, HValue* context, HValue* value, - int offset, + HValue* offset, HType type = HType::Tagged()) { return new(zone) HInnerAllocatedObject(value, offset, type); } HValue* base_object() { return OperandAt(0); } - int offset() { return offset_; } + HValue* offset() { return OperandAt(1); } virtual Representation RequiredInputRepresentation(int index) V8_OVERRIDE { - return Representation::Tagged(); + return index == 0 ? Representation::Tagged() : Representation::Integer32(); } virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; @@ -5631,15 +5631,16 @@ class HInnerAllocatedObject V8_FINAL: public HTemplateInstruction<1> { DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject) private: - HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) - : HTemplateInstruction<1>(type), offset_(offset) { + HInnerAllocatedObject(HValue* value, + HValue* offset, + HType type = HType::Tagged()) + : HTemplateInstruction<2>(type) { ASSERT(value->IsAllocate()); SetOperandAt(0, value); + SetOperandAt(1, offset); set_type(type); set_representation(Representation::Tagged()); } - - int offset_; }; diff --git a/src/hydrogen.cc b/src/hydrogen.cc index b6498b1..76c5ca0 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -2237,25 +2237,8 @@ HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, length_field); if (mode == TRACK_ALLOCATION_SITE) { - BuildCreateAllocationMemento(array, - JSArray::kSize, - allocation_site_payload); - if (FLAG_allocation_site_pretenuring) { - // TODO(mvstanton): move this code into BuildCreateAllocationMemento when - // constructed arrays also pay attention to pretenuring. - HObjectAccess access = - HObjectAccess::ForAllocationSiteOffset( - AllocationSite::kMementoCreateCountOffset); - HValue* create_info = Add(allocation_site_payload, - access); - HInstruction* new_create_info = - AddUncasted(create_info, graph()->GetConstant1()); - new_create_info->ClearFlag(HValue::kCanOverflow); - HStoreNamedField* store = Add(allocation_site_payload, - access, new_create_info); - // No write barrier needed to store a smi. - store->SkipWriteBarrier(); - } + BuildCreateAllocationMemento( + array, Add(JSArray::kSize), allocation_site_payload); } int elements_location = JSArray::kSize; @@ -2263,9 +2246,10 @@ HInnerAllocatedObject* HGraphBuilder::BuildJSArrayHeader(HValue* array, elements_location += AllocationMemento::kSize; } - HValue* elements = Add(array, elements_location); + HInnerAllocatedObject* elements = Add( + array, Add(elements_location)); Add(array, HObjectAccess::ForElementsPointer(), elements); - return static_cast(elements); + return elements; } @@ -2495,7 +2479,8 @@ HValue* HGraphBuilder::BuildCloneShallowArray(HValue* boilerplate, // Create an allocation site info if requested. if (mode == TRACK_ALLOCATION_SITE) { - BuildCreateAllocationMemento(object, JSArray::kSize, allocation_site); + BuildCreateAllocationMemento( + object, Add(JSArray::kSize), allocation_site); } if (length > 0) { @@ -2588,18 +2573,31 @@ void HGraphBuilder::BuildCompareNil( } -HValue* HGraphBuilder::BuildCreateAllocationMemento(HValue* previous_object, - int previous_object_size, - HValue* alloc_site) { - ASSERT(alloc_site != NULL); - HInnerAllocatedObject* alloc_memento = Add( +void HGraphBuilder::BuildCreateAllocationMemento( + HValue* previous_object, + HValue* previous_object_size, + HValue* allocation_site) { + ASSERT(allocation_site != NULL); + HInnerAllocatedObject* allocation_memento = Add( previous_object, previous_object_size); - Handle alloc_memento_map = - isolate()->factory()->allocation_memento_map(); - AddStoreMapConstant(alloc_memento, alloc_memento_map); - HObjectAccess access = HObjectAccess::ForAllocationMementoSite(); - Add(alloc_memento, access, alloc_site); - return alloc_memento; + AddStoreMapConstant( + allocation_memento, isolate()->factory()->allocation_memento_map()); + Add( + allocation_memento, + HObjectAccess::ForAllocationMementoSite(), + allocation_site); + if (FLAG_allocation_site_pretenuring) { + HValue* memento_create_count = Add( + allocation_site, HObjectAccess::ForAllocationSiteOffset( + AllocationSite::kMementoCreateCountOffset)); + memento_create_count = AddUncasted( + memento_create_count, graph()->GetConstant1()); + HStoreNamedField* store = Add( + allocation_site, HObjectAccess::ForAllocationSiteOffset( + AllocationSite::kMementoCreateCountOffset), memento_create_count); + // No write barrier needed to store a smi. + store->SkipWriteBarrier(); + } } diff --git a/src/hydrogen.h b/src/hydrogen.h index 6a6aef0..61e98b2 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -1718,9 +1718,9 @@ class HGraphBuilder { Handle type, HIfContinuation* continuation); - HValue* BuildCreateAllocationMemento(HValue* previous_object, - int previous_object_size, - HValue* payload); + void BuildCreateAllocationMemento(HValue* previous_object, + HValue* previous_object_size, + HValue* payload); HInstruction* BuildConstantMapCheck(Handle constant, CompilationInfo* info); diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 739f042..d3a5ff3 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -4426,7 +4426,13 @@ void LCodeGen::DoStoreCodeEntry(LStoreCodeEntry* instr) { void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) { Register result = ToRegister(instr->result()); Register base = ToRegister(instr->base_object()); - __ lea(result, Operand(base, instr->offset())); + if (instr->offset()->IsConstantOperand()) { + LConstantOperand* offset = LConstantOperand::cast(instr->offset()); + __ lea(result, Operand(base, ToInteger32(offset))); + } else { + Register offset = ToRegister(instr->offset()); + __ lea(result, Operand(base, offset, times_1, 0)); + } } diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index 678c0ca..aa35e9d 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -302,7 +302,8 @@ void LStoreCodeEntry::PrintDataTo(StringStream* stream) { void LInnerAllocatedObject::PrintDataTo(StringStream* stream) { stream->Add(" = "); base_object()->PrintTo(stream); - stream->Add(" + %d", offset()); + stream->Add(" + "); + offset()->PrintTo(stream); } @@ -1201,11 +1202,11 @@ LInstruction* LChunkBuilder::DoStoreCodeEntry( LInstruction* LChunkBuilder::DoInnerAllocatedObject( - HInnerAllocatedObject* inner_object) { - LOperand* base_object = UseRegisterAtStart(inner_object->base_object()); - LInnerAllocatedObject* result = - new(zone()) LInnerAllocatedObject(base_object); - return DefineAsRegister(result); + HInnerAllocatedObject* instr) { + LOperand* base_object = UseRegisterAtStart(instr->base_object()); + LOperand* offset = UseRegisterOrConstantAtStart(instr->offset()); + return DefineAsRegister( + new(zone()) LInnerAllocatedObject(base_object, offset)); } diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index b429120..ea4fef8 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -1801,19 +1801,19 @@ class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> { }; -class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 1, 0> { +class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> { public: - explicit LInnerAllocatedObject(LOperand* base_object) { + LInnerAllocatedObject(LOperand* base_object, LOperand* offset) { inputs_[0] = base_object; + inputs_[1] = offset; } - LOperand* base_object() { return inputs_[0]; } - int offset() { return hydrogen()->offset(); } + LOperand* base_object() const { return inputs_[0]; } + LOperand* offset() const { return inputs_[1]; } virtual void PrintDataTo(StringStream* stream); - DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object") - DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject) + DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object") }; diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index 046edbd..b196254 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -3972,7 +3972,13 @@ void LCodeGen::DoStoreCodeEntry(LStoreCodeEntry* instr) { void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) { Register result = ToRegister(instr->result()); Register base = ToRegister(instr->base_object()); - __ lea(result, Operand(base, instr->offset())); + if (instr->offset()->IsConstantOperand()) { + LConstantOperand* offset = LConstantOperand::cast(instr->offset()); + __ lea(result, Operand(base, ToInteger32(offset))); + } else { + Register offset = ToRegister(instr->offset()); + __ lea(result, Operand(base, offset, times_1, 0)); + } } diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index eb00593..0f7ebc4 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -275,7 +275,8 @@ void LStoreCodeEntry::PrintDataTo(StringStream* stream) { void LInnerAllocatedObject::PrintDataTo(StringStream* stream) { stream->Add(" = "); base_object()->PrintTo(stream); - stream->Add(" + %d", offset()); + stream->Add(" + "); + offset()->PrintTo(stream); } @@ -1116,11 +1117,11 @@ LInstruction* LChunkBuilder::DoStoreCodeEntry( LInstruction* LChunkBuilder::DoInnerAllocatedObject( - HInnerAllocatedObject* inner_object) { - LOperand* base_object = UseRegisterAtStart(inner_object->base_object()); - LInnerAllocatedObject* result = - new(zone()) LInnerAllocatedObject(base_object); - return DefineAsRegister(result); + HInnerAllocatedObject* instr) { + LOperand* base_object = UseRegisterAtStart(instr->base_object()); + LOperand* offset = UseRegisterOrConstantAtStart(instr->offset()); + return DefineAsRegister( + new(zone()) LInnerAllocatedObject(base_object, offset)); } diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h index ca7831c..44bd992 100644 --- a/src/x64/lithium-x64.h +++ b/src/x64/lithium-x64.h @@ -1746,19 +1746,19 @@ class LStoreCodeEntry V8_FINAL: public LTemplateInstruction<0, 1, 1> { }; -class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 1, 0> { +class LInnerAllocatedObject V8_FINAL: public LTemplateInstruction<1, 2, 0> { public: - explicit LInnerAllocatedObject(LOperand* base_object) { + LInnerAllocatedObject(LOperand* base_object, LOperand* offset) { inputs_[0] = base_object; + inputs_[1] = offset; } - LOperand* base_object() { return inputs_[0]; } - int offset() { return hydrogen()->offset(); } + LOperand* base_object() const { return inputs_[0]; } + LOperand* offset() const { return inputs_[1]; } virtual void PrintDataTo(StringStream* stream) V8_OVERRIDE; - DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "sub-allocated-object") - DECLARE_HYDROGEN_ACCESSOR(InnerAllocatedObject) + DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject, "inner-allocated-object") };