From 77f85fa0d3c7a95f3dfc9452e3fc5c21db684fae Mon Sep 17 00:00:00 2001 From: "titzer@chromium.org" Date: Fri, 24 May 2013 12:40:08 +0000 Subject: [PATCH] Remove offset() and is_in_object() from hydrogen and lithium LoadNamedField and StoreNamedField and use the appropriate methods on HObjectAccess instead BUG= Review URL: https://codereview.chromium.org/15881003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14806 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/lithium-arm.cc | 3 ++- src/arm/lithium-arm.h | 3 --- src/arm/lithium-codegen-arm.cc | 13 ++++++++----- src/hydrogen-instructions.h | 11 +++++------ src/ia32/lithium-codegen-ia32.cc | 15 ++++++++------- src/ia32/lithium-ia32.cc | 5 +++-- src/ia32/lithium-ia32.h | 3 --- src/mips/lithium-codegen-mips.cc | 12 +++++++----- src/mips/lithium-mips.cc | 3 ++- src/mips/lithium-mips.h | 3 --- src/x64/lithium-codegen-x64.cc | 14 ++++++++------ src/x64/lithium-x64.cc | 5 +++-- src/x64/lithium-x64.h | 3 --- 13 files changed, 46 insertions(+), 47 deletions(-) diff --git a/src/arm/lithium-arm.cc b/src/arm/lithium-arm.cc index 6cfcd31..8140cc8 100644 --- a/src/arm/lithium-arm.cc +++ b/src/arm/lithium-arm.cc @@ -2327,13 +2327,14 @@ LInstruction* LChunkBuilder::DoTrapAllocationMemento( LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { + bool is_in_object = instr->access().IsInobject(); bool needs_write_barrier = instr->NeedsWriteBarrier(); bool needs_write_barrier_for_map = !instr->transition().is_null() && instr->NeedsWriteBarrierForMap(); LOperand* obj; if (needs_write_barrier) { - obj = instr->is_in_object() + obj = is_in_object ? UseRegister(instr->object()) : UseTempRegister(instr->object()); } else { diff --git a/src/arm/lithium-arm.h b/src/arm/lithium-arm.h index 0d01bfd..fed5f6d 100644 --- a/src/arm/lithium-arm.h +++ b/src/arm/lithium-arm.h @@ -2147,9 +2147,6 @@ class LStoreNamedField: public LTemplateInstruction<0, 2, 1> { virtual void PrintDataTo(StringStream* stream); - Handle name() const { return hydrogen()->name(); } - bool is_in_object() { return hydrogen()->is_in_object(); } - int offset() { return hydrogen()->offset(); } Handle transition() const { return hydrogen()->transition(); } Representation representation() const { return hydrogen()->field_representation(); diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index b175c58..e22aa40 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -3073,7 +3073,8 @@ void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) { void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { - int offset = instr->hydrogen()->offset(); + HObjectAccess access = instr->hydrogen()->access(); + int offset = access.offset(); Register object = ToRegister(instr->object()); if (instr->hydrogen()->representation().IsDouble()) { DwVfpRegister result = ToDoubleRegister(instr->result()); @@ -3082,7 +3083,7 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { } Register result = ToRegister(instr->result()); - if (instr->hydrogen()->is_in_object()) { + if (access.IsInobject()) { __ ldr(result, FieldMemOperand(object, offset)); } else { __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); @@ -4233,7 +4234,9 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { Register object = ToRegister(instr->object()); Register scratch = scratch0(); - int offset = instr->offset(); + + HObjectAccess access = instr->hydrogen()->access(); + int offset = access.offset(); Handle transition = instr->transition(); @@ -4245,7 +4248,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } } else if (FLAG_track_double_fields && representation.IsDouble()) { ASSERT(transition.is_null()); - ASSERT(instr->is_in_object()); + ASSERT(access.IsInobject()); ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); DwVfpRegister value = ToDoubleRegister(instr->value()); __ vstr(value, FieldMemOperand(object, offset)); @@ -4278,7 +4281,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { HType type = instr->hydrogen()->value()->type(); SmiCheck check_needed = type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; - if (instr->is_in_object()) { + if (access.IsInobject()) { __ str(value, FieldMemOperand(object, offset)); if (instr->hydrogen()->NeedsWriteBarrier()) { // Update the write barrier for the object for in-object properties. diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index 43a5ad8..b99eff8 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -5235,6 +5235,10 @@ class HObjectAccess { void PrintTo(StringStream* stream); + inline bool Equals(HObjectAccess that) const { + return value_ == that.value_; // portion and offset must match + } + protected: void SetGVNFlags(HValue *instr, bool is_store); @@ -5308,9 +5312,7 @@ class HLoadNamedField: public HTemplateInstruction<2> { bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); } HObjectAccess access() const { return access_; } - bool is_in_object() const { return access_.IsInobject(); } Representation field_representation() const { return representation_; } - int offset() const { return access_.offset(); } virtual Representation RequiredInputRepresentation(int index) { return Representation::Tagged(); @@ -5322,7 +5324,7 @@ class HLoadNamedField: public HTemplateInstruction<2> { protected: virtual bool DataEquals(HValue* other) { HLoadNamedField* b = HLoadNamedField::cast(other); - return is_in_object() == b->is_in_object() && offset() == b->offset(); + return access_.Equals(b->access_); } private: @@ -5661,9 +5663,6 @@ class HStoreNamedField: public HTemplateInstruction<2> { HValue* value() { return OperandAt(1); } HObjectAccess access() const { return access_; } - Handle name() const { return access_.name(); } - bool is_in_object() const { return access_.IsInobject(); } - int offset() const { return access_.offset(); } Handle transition() const { return transition_; } UniqueValueId transition_unique_id() const { return transition_unique_id_; } void set_transition(Handle map) { transition_ = map; } diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index 3e23763..e809840 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -2967,7 +2967,8 @@ void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) { void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { - int offset = instr->hydrogen()->offset(); + HObjectAccess access = instr->hydrogen()->access(); + int offset = access.offset(); Register object = ToRegister(instr->object()); if (FLAG_track_double_fields && instr->hydrogen()->representation().IsDouble()) { @@ -2983,7 +2984,7 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { } Register result = ToRegister(instr->result()); - if (instr->hydrogen()->is_in_object()) { + if (access.IsInobject()) { __ mov(result, FieldOperand(object, offset)); } else { __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); @@ -4239,8 +4240,8 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { Representation representation = instr->representation(); Register object = ToRegister(instr->object()); - - int offset = instr->offset(); + HObjectAccess access = instr->hydrogen()->access(); + int offset = access.offset(); Handle transition = instr->transition(); @@ -4266,7 +4267,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } } else if (FLAG_track_double_fields && representation.IsDouble()) { ASSERT(transition.is_null()); - ASSERT(instr->is_in_object()); + ASSERT(access.IsInobject()); ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); if (CpuFeatures::IsSupported(SSE2)) { CpuFeatureScope scope(masm(), SSE2); @@ -4306,7 +4307,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; Register write_register = object; - if (!instr->is_in_object()) { + if (!access.IsInobject()) { write_register = ToRegister(instr->temp()); __ mov(write_register, FieldOperand(object, JSObject::kPropertiesOffset)); @@ -4327,7 +4328,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { if (instr->hydrogen()->NeedsWriteBarrier()) { Register value = ToRegister(instr->value()); - Register temp = instr->is_in_object() ? ToRegister(instr->temp()) : object; + Register temp = access.IsInobject() ? ToRegister(instr->temp()) : object; // Update the write barrier for the object for in-object properties. __ RecordWriteField(write_register, offset, diff --git a/src/ia32/lithium-ia32.cc b/src/ia32/lithium-ia32.cc index e5b1474..b3f4051 100644 --- a/src/ia32/lithium-ia32.cc +++ b/src/ia32/lithium-ia32.cc @@ -2437,13 +2437,14 @@ LInstruction* LChunkBuilder::DoTrapAllocationMemento( LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { + bool is_in_object = instr->access().IsInobject(); bool needs_write_barrier = instr->NeedsWriteBarrier(); bool needs_write_barrier_for_map = !instr->transition().is_null() && instr->NeedsWriteBarrierForMap(); LOperand* obj; if (needs_write_barrier) { - obj = instr->is_in_object() + obj = is_in_object ? UseRegister(instr->object()) : UseTempRegister(instr->object()); } else { @@ -2476,7 +2477,7 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { // We only need a scratch register if we have a write barrier or we // have a store into the properties array (not in-object-property). - LOperand* temp = (!instr->is_in_object() || needs_write_barrier || + LOperand* temp = (!is_in_object || needs_write_barrier || needs_write_barrier_for_map) ? TempRegister() : NULL; // We need a temporary register for write barrier of the map field. diff --git a/src/ia32/lithium-ia32.h b/src/ia32/lithium-ia32.h index 6712e76..eb6ddd3 100644 --- a/src/ia32/lithium-ia32.h +++ b/src/ia32/lithium-ia32.h @@ -2213,9 +2213,6 @@ class LStoreNamedField: public LTemplateInstruction<0, 2, 2> { virtual void PrintDataTo(StringStream* stream); - Handle name() const { return hydrogen()->name(); } - bool is_in_object() { return hydrogen()->is_in_object(); } - int offset() { return hydrogen()->offset(); } Handle transition() const { return hydrogen()->transition(); } Representation representation() const { return hydrogen()->field_representation(); diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc index 1cdea12..db216dd 100644 --- a/src/mips/lithium-codegen-mips.cc +++ b/src/mips/lithium-codegen-mips.cc @@ -2710,7 +2710,8 @@ void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) { void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { - int offset = instr->hydrogen()->offset(); + HObjectAccess access = instr->hydrogen()->access(); + int offset = access.offset(); Register object = ToRegister(instr->object()); if (instr->hydrogen()->representation().IsDouble()) { DoubleRegister result = ToDoubleRegister(instr->result()); @@ -2719,7 +2720,7 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { } Register result = ToRegister(instr->result()); - if (instr->hydrogen()->is_in_object()) { + if (access.IsInobject()) { __ lw(result, FieldMemOperand(object, offset)); } else { __ lw(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); @@ -3921,7 +3922,8 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { Register object = ToRegister(instr->object()); Register scratch = scratch0(); - int offset = instr->offset(); + HObjectAccess access = instr->hydrogen()->access(); + int offset = access.offset(); Handle transition = instr->transition(); @@ -3933,7 +3935,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } } else if (FLAG_track_double_fields && representation.IsDouble()) { ASSERT(transition.is_null()); - ASSERT(instr->is_in_object()); + ASSERT(access.IsInobject()); ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); DoubleRegister value = ToDoubleRegister(instr->value()); __ sdc1(value, FieldMemOperand(object, offset)); @@ -3966,7 +3968,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { HType type = instr->hydrogen()->value()->type(); SmiCheck check_needed = type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; - if (instr->is_in_object()) { + if (access.IsInobject()) { __ sw(value, FieldMemOperand(object, offset)); if (instr->hydrogen()->NeedsWriteBarrier()) { // Update the write barrier for the object for in-object properties. diff --git a/src/mips/lithium-mips.cc b/src/mips/lithium-mips.cc index 3f96c39..5ceca49 100644 --- a/src/mips/lithium-mips.cc +++ b/src/mips/lithium-mips.cc @@ -2205,13 +2205,14 @@ LInstruction* LChunkBuilder::DoTrapAllocationMemento( LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { + bool is_in_object = instr->access().IsInobject(); bool needs_write_barrier = instr->NeedsWriteBarrier(); bool needs_write_barrier_for_map = !instr->transition().is_null() && instr->NeedsWriteBarrierForMap(); LOperand* obj; if (needs_write_barrier) { - obj = instr->is_in_object() + obj = is_in_object ? UseRegister(instr->object()) : UseTempRegister(instr->object()); } else { diff --git a/src/mips/lithium-mips.h b/src/mips/lithium-mips.h index 3156722..e7e57e6 100644 --- a/src/mips/lithium-mips.h +++ b/src/mips/lithium-mips.h @@ -2094,9 +2094,6 @@ class LStoreNamedField: public LTemplateInstruction<0, 2, 1> { virtual void PrintDataTo(StringStream* stream); - Handle name() const { return hydrogen()->name(); } - bool is_in_object() { return hydrogen()->is_in_object(); } - int offset() { return hydrogen()->offset(); } Handle transition() const { return hydrogen()->transition(); } Representation representation() const { return hydrogen()->field_representation(); diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index 44d056f..33d7e0d 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -2700,7 +2700,8 @@ void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) { void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { - int offset = instr->hydrogen()->offset(); + HObjectAccess access = instr->hydrogen()->access(); + int offset = access.offset(); Register object = ToRegister(instr->object()); if (FLAG_track_double_fields && instr->hydrogen()->representation().IsDouble()) { @@ -2710,7 +2711,7 @@ void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { } Register result = ToRegister(instr->result()); - if (instr->hydrogen()->is_in_object()) { + if (access.IsInobject()) { __ movq(result, FieldOperand(object, offset)); } else { __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset)); @@ -3931,7 +3932,8 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { Register object = ToRegister(instr->object()); - int offset = instr->offset(); + HObjectAccess access = instr->hydrogen()->access(); + int offset = access.offset(); Handle transition = instr->transition(); @@ -3957,7 +3959,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { } } else if (FLAG_track_double_fields && representation.IsDouble()) { ASSERT(transition.is_null()); - ASSERT(instr->is_in_object()); + ASSERT(access.IsInobject()); ASSERT(!instr->hydrogen()->NeedsWriteBarrier()); XMMRegister value = ToDoubleRegister(instr->value()); __ movsd(FieldOperand(object, offset), value); @@ -3991,7 +3993,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { type.IsHeapObject() ? OMIT_SMI_CHECK : INLINE_SMI_CHECK; Register write_register = object; - if (!instr->is_in_object()) { + if (!access.IsInobject()) { write_register = ToRegister(instr->temp()); __ movq(write_register, FieldOperand(object, JSObject::kPropertiesOffset)); } @@ -4012,7 +4014,7 @@ void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) { if (instr->hydrogen()->NeedsWriteBarrier()) { Register value = ToRegister(instr->value()); - Register temp = instr->is_in_object() ? ToRegister(instr->temp()) : object; + Register temp = access.IsInobject() ? ToRegister(instr->temp()) : object; // Update the write barrier for the object for in-object properties. __ RecordWriteField(write_register, offset, diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc index db98f23..4aec3e2 100644 --- a/src/x64/lithium-x64.cc +++ b/src/x64/lithium-x64.cc @@ -2260,13 +2260,14 @@ LInstruction* LChunkBuilder::DoTrapAllocationMemento( LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { + bool is_in_object = instr->access().IsInobject(); bool needs_write_barrier = instr->NeedsWriteBarrier(); bool needs_write_barrier_for_map = !instr->transition().is_null() && instr->NeedsWriteBarrierForMap(); LOperand* obj; if (needs_write_barrier) { - obj = instr->is_in_object() + obj = is_in_object ? UseRegister(instr->object()) : UseTempRegister(instr->object()); } else { @@ -2295,7 +2296,7 @@ LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { // We only need a scratch register if we have a write barrier or we // have a store into the properties array (not in-object-property). - LOperand* temp = (!instr->is_in_object() || needs_write_barrier || + LOperand* temp = (!is_in_object || needs_write_barrier || needs_write_barrier_for_map) ? TempRegister() : NULL; LStoreNamedField* result = new(zone()) LStoreNamedField(obj, val, temp); diff --git a/src/x64/lithium-x64.h b/src/x64/lithium-x64.h index 920ea0c..7397c81 100644 --- a/src/x64/lithium-x64.h +++ b/src/x64/lithium-x64.h @@ -2065,9 +2065,6 @@ class LStoreNamedField: public LTemplateInstruction<0, 2, 1> { virtual void PrintDataTo(StringStream* stream); - Handle name() const { return hydrogen()->name(); } - bool is_in_object() { return hydrogen()->is_in_object(); } - int offset() { return hydrogen()->offset(); } Handle transition() const { return hydrogen()->transition(); } Representation representation() const { return hydrogen()->field_representation(); -- 2.7.4