Chromium Code Reviews| Index: src/hydrogen-instructions.h |
| diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h |
| index 5396c53926f6c10cd3f87e305d16f67d47759515..9852a4e35b278a6aec7294b7bfc9bf8b159f664a 100644 |
| --- a/src/hydrogen-instructions.h |
| +++ b/src/hydrogen-instructions.h |
| @@ -619,6 +619,7 @@ class HValue: public ZoneObject { |
| void AssumeRepresentation(Representation r); |
| virtual bool IsConvertibleToInteger() const { return true; } |
| + virtual bool IsValueTaggedSmi() const { return false; } |
|
Michael Starzinger
2012/06/12 08:10:43
Can't we use HValue::CalculateInferredType instead
danno
2012/06/12 09:59:22
No, unfortunately not. The representation is tagge
Michael Starzinger
2012/06/12 10:48:05
Yes, I agree, the representation has to be tagged.
|
| HType type() const { return type_; } |
| void set_type(HType new_type) { |
| @@ -1848,7 +1849,9 @@ class HCallRuntime: public HCall<1> { |
| class HJSArrayLength: public HTemplateInstruction<2> { |
| public: |
| - HJSArrayLength(HValue* value, HValue* typecheck) { |
| + HJSArrayLength(HValue* value, HValue* typecheck, |
| + bool result_is_smi) |
|
Michael Starzinger
2012/06/12 08:10:43
Can we use an enum instead of a bool flag here?
danno
2012/06/12 09:59:22
Done.
|
| + : result_is_smi_(result_is_smi) { |
| // The length of an array is stored as a tagged value in the array |
| // object. It is guaranteed to be 32 bit integer, but it can be |
| // represented as either a smi or heap number. |
| @@ -1869,10 +1872,20 @@ class HJSArrayLength: public HTemplateInstruction<2> { |
| HValue* value() { return OperandAt(0); } |
| HValue* typecheck() { return OperandAt(1); } |
| + virtual bool IsValueTaggedSmi() const { |
|
Michael Starzinger
2012/06/12 08:10:43
See first comment in this file.
danno
2012/06/12 09:59:22
See my reply above.
On 2012/06/12 08:10:43, Micha
|
| + return result_is_smi_; |
| + } |
| + |
| DECLARE_CONCRETE_INSTRUCTION(JSArrayLength) |
| protected: |
| - virtual bool DataEquals(HValue* other) { return true; } |
| + virtual bool DataEquals(HValue* other_raw) { |
| + HJSArrayLength* other = HJSArrayLength::cast(other_raw); |
| + return result_is_smi_ == other->result_is_smi_; |
| + } |
| + |
| + private: |
| + bool result_is_smi_; |
| }; |
| @@ -3980,7 +3993,6 @@ class ArrayInstructionInterface { |
| virtual ~ArrayInstructionInterface() { }; |
| }; |
| - |
| enum HoleCheckMode { PERFORM_HOLE_CHECK, OMIT_HOLE_CHECK }; |
| class HLoadKeyedFastElement |
| @@ -3988,10 +4000,14 @@ class HLoadKeyedFastElement |
| public: |
| HLoadKeyedFastElement(HValue* obj, |
| HValue* key, |
| - HoleCheckMode hole_check_mode = PERFORM_HOLE_CHECK) |
| - : hole_check_mode_(hole_check_mode), |
| - index_offset_(0), |
| - is_dehoisted_(false) { |
| + HoleCheckMode mode, |
| + ElementsKind elements_kind = FAST_ELEMENTS) |
| + : bit_field_(0) { |
| + ASSERT(IsFastSmiOrObjectElementsKind(elements_kind)); |
| + ASSERT(mode == OMIT_HOLE_CHECK || |
| + IsFastHoleyElementsKind(elements_kind)); |
| + bit_field_ = ElementsKindField::encode(elements_kind) | |
| + HoleCheckModeField::encode(mode); |
| SetOperandAt(0, obj); |
| SetOperandAt(1, key); |
| set_representation(Representation::Tagged()); |
| @@ -4001,12 +4017,27 @@ class HLoadKeyedFastElement |
| HValue* object() { return OperandAt(0); } |
| HValue* key() { return OperandAt(1); } |
| - uint32_t index_offset() { return index_offset_; } |
| - void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } |
| + uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } |
| + void SetIndexOffset(uint32_t index_offset) { |
| + bit_field_ = IndexOffsetField::update(bit_field_, index_offset); |
| + } |
| HValue* GetKey() { return key(); } |
| void SetKey(HValue* key) { SetOperandAt(1, key); } |
| - bool IsDehoisted() { return is_dehoisted_; } |
| - void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
| + bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
| + void SetDehoisted(bool is_dehoisted) { |
| + bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
| + } |
| + ElementsKind elements_kind() const { |
| + return ElementsKindField::decode(bit_field_); |
| + } |
| + HoleCheckMode hole_check_mode() const { |
| + return HoleCheckModeField::decode(bit_field_); |
| + } |
| + |
| + virtual bool IsValueTaggedSmi() const { |
| + return IsFastSmiElementsKind(elements_kind()) && |
| + IsFastPackedElementsKind(elements_kind()); |
| + } |
| virtual Representation RequiredInputRepresentation(int index) { |
| // The key is supposed to be Integer32. |
| @@ -4025,15 +4056,18 @@ class HLoadKeyedFastElement |
| virtual bool DataEquals(HValue* other) { |
| if (!other->IsLoadKeyedFastElement()) return false; |
| HLoadKeyedFastElement* other_load = HLoadKeyedFastElement::cast(other); |
| - if (is_dehoisted_ && index_offset_ != other_load->index_offset_) |
| + if (IsDehoisted() && index_offset() != other_load->index_offset()) |
| return false; |
| - return hole_check_mode_ == other_load->hole_check_mode_; |
| + return elements_kind() == other_load->elements_kind() && |
| + hole_check_mode() == other_load->hole_check_mode(); |
| } |
| private: |
| - HoleCheckMode hole_check_mode_; |
| - uint32_t index_offset_; |
| - bool is_dehoisted_; |
| + class ElementsKindField: public BitField<ElementsKind, 0, 4> {}; |
| + class IndexOffsetField: public BitField<uint32_t, 4, 25> {}; |
| + class HoleCheckModeField: public BitField<HoleCheckMode, 29, 1> {}; |
| + class IsDehoistedField: public BitField<bool, 30, 1> {}; |
| + uint32_t bit_field_; |
| }; |
| @@ -4044,15 +4078,15 @@ class HLoadKeyedFastDoubleElement |
| HValue* elements, |
| HValue* key, |
| HoleCheckMode hole_check_mode = PERFORM_HOLE_CHECK) |
| - : index_offset_(0), |
| - is_dehoisted_(false), |
| - hole_check_mode_(hole_check_mode) { |
| - SetOperandAt(0, elements); |
| - SetOperandAt(1, key); |
| - set_representation(Representation::Double()); |
| + : index_offset_(0), |
| + is_dehoisted_(false), |
| + hole_check_mode_(hole_check_mode) { |
| + SetOperandAt(0, elements); |
| + SetOperandAt(1, key); |
| + set_representation(Representation::Double()); |
| SetGVNFlag(kDependsOnDoubleArrayElements); |
| SetFlag(kUseGVN); |
| - } |
| + } |
| HValue* elements() { return OperandAt(0); } |
| HValue* key() { return OperandAt(1); } |