OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1830 matching lines...) Loading... |
1841 DECLARE_CONCRETE_INSTRUCTION(CallRuntime) | 1841 DECLARE_CONCRETE_INSTRUCTION(CallRuntime) |
1842 | 1842 |
1843 private: | 1843 private: |
1844 const Runtime::Function* c_function_; | 1844 const Runtime::Function* c_function_; |
1845 Handle<String> name_; | 1845 Handle<String> name_; |
1846 }; | 1846 }; |
1847 | 1847 |
1848 | 1848 |
1849 class HJSArrayLength: public HTemplateInstruction<2> { | 1849 class HJSArrayLength: public HTemplateInstruction<2> { |
1850 public: | 1850 public: |
1851 HJSArrayLength(HValue* value, HValue* typecheck) { | 1851 HJSArrayLength(HValue* value, HValue* typecheck, |
| 1852 HType type = HType::Tagged()) { |
| 1853 set_type(type); |
1852 // The length of an array is stored as a tagged value in the array | 1854 // The length of an array is stored as a tagged value in the array |
1853 // object. It is guaranteed to be 32 bit integer, but it can be | 1855 // object. It is guaranteed to be 32 bit integer, but it can be |
1854 // represented as either a smi or heap number. | 1856 // represented as either a smi or heap number. |
1855 SetOperandAt(0, value); | 1857 SetOperandAt(0, value); |
1856 SetOperandAt(1, typecheck); | 1858 SetOperandAt(1, typecheck); |
1857 set_representation(Representation::Tagged()); | 1859 set_representation(Representation::Tagged()); |
1858 SetFlag(kUseGVN); | 1860 SetFlag(kUseGVN); |
1859 SetGVNFlag(kDependsOnArrayLengths); | 1861 SetGVNFlag(kDependsOnArrayLengths); |
1860 SetGVNFlag(kDependsOnMaps); | 1862 SetGVNFlag(kDependsOnMaps); |
1861 } | 1863 } |
1862 | 1864 |
1863 virtual Representation RequiredInputRepresentation(int index) { | 1865 virtual Representation RequiredInputRepresentation(int index) { |
1864 return Representation::Tagged(); | 1866 return Representation::Tagged(); |
1865 } | 1867 } |
1866 | 1868 |
1867 virtual void PrintDataTo(StringStream* stream); | 1869 virtual void PrintDataTo(StringStream* stream); |
1868 | 1870 |
1869 HValue* value() { return OperandAt(0); } | 1871 HValue* value() { return OperandAt(0); } |
1870 HValue* typecheck() { return OperandAt(1); } | 1872 HValue* typecheck() { return OperandAt(1); } |
1871 | 1873 |
1872 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength) | 1874 DECLARE_CONCRETE_INSTRUCTION(JSArrayLength) |
1873 | 1875 |
1874 protected: | 1876 protected: |
1875 virtual bool DataEquals(HValue* other) { return true; } | 1877 virtual bool DataEquals(HValue* other_raw) { return true; } |
1876 }; | 1878 }; |
1877 | 1879 |
1878 | 1880 |
1879 class HFixedArrayBaseLength: public HUnaryOperation { | 1881 class HFixedArrayBaseLength: public HUnaryOperation { |
1880 public: | 1882 public: |
1881 explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) { | 1883 explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) { |
1882 set_representation(Representation::Tagged()); | 1884 set_representation(Representation::Tagged()); |
1883 SetFlag(kUseGVN); | 1885 SetFlag(kUseGVN); |
1884 SetGVNFlag(kDependsOnArrayLengths); | 1886 SetGVNFlag(kDependsOnArrayLengths); |
1885 } | 1887 } |
(...skipping 2087 matching lines...) Loading... |
3973 class ArrayInstructionInterface { | 3975 class ArrayInstructionInterface { |
3974 public: | 3976 public: |
3975 virtual HValue* GetKey() = 0; | 3977 virtual HValue* GetKey() = 0; |
3976 virtual void SetKey(HValue* key) = 0; | 3978 virtual void SetKey(HValue* key) = 0; |
3977 virtual void SetIndexOffset(uint32_t index_offset) = 0; | 3979 virtual void SetIndexOffset(uint32_t index_offset) = 0; |
3978 virtual bool IsDehoisted() = 0; | 3980 virtual bool IsDehoisted() = 0; |
3979 virtual void SetDehoisted(bool is_dehoisted) = 0; | 3981 virtual void SetDehoisted(bool is_dehoisted) = 0; |
3980 virtual ~ArrayInstructionInterface() { }; | 3982 virtual ~ArrayInstructionInterface() { }; |
3981 }; | 3983 }; |
3982 | 3984 |
3983 | |
3984 enum HoleCheckMode { PERFORM_HOLE_CHECK, OMIT_HOLE_CHECK }; | |
3985 | |
3986 class HLoadKeyedFastElement | 3985 class HLoadKeyedFastElement |
3987 : public HTemplateInstruction<2>, public ArrayInstructionInterface { | 3986 : public HTemplateInstruction<2>, public ArrayInstructionInterface { |
3988 public: | 3987 public: |
3989 HLoadKeyedFastElement(HValue* obj, | 3988 HLoadKeyedFastElement(HValue* obj, |
3990 HValue* key, | 3989 HValue* key, |
3991 HoleCheckMode hole_check_mode = PERFORM_HOLE_CHECK) | 3990 ElementsKind elements_kind = FAST_ELEMENTS) |
3992 : hole_check_mode_(hole_check_mode), | 3991 : bit_field_(0) { |
3993 index_offset_(0), | 3992 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind)); |
3994 is_dehoisted_(false) { | 3993 bit_field_ = ElementsKindField::encode(elements_kind); |
| 3994 if (IsFastSmiElementsKind(elements_kind) && |
| 3995 IsFastPackedElementsKind(elements_kind)) { |
| 3996 set_type(HType::Smi()); |
| 3997 } |
3995 SetOperandAt(0, obj); | 3998 SetOperandAt(0, obj); |
3996 SetOperandAt(1, key); | 3999 SetOperandAt(1, key); |
3997 set_representation(Representation::Tagged()); | 4000 set_representation(Representation::Tagged()); |
3998 SetGVNFlag(kDependsOnArrayElements); | 4001 SetGVNFlag(kDependsOnArrayElements); |
3999 SetFlag(kUseGVN); | 4002 SetFlag(kUseGVN); |
4000 } | 4003 } |
4001 | 4004 |
4002 HValue* object() { return OperandAt(0); } | 4005 HValue* object() { return OperandAt(0); } |
4003 HValue* key() { return OperandAt(1); } | 4006 HValue* key() { return OperandAt(1); } |
4004 uint32_t index_offset() { return index_offset_; } | 4007 uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); } |
4005 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } | 4008 void SetIndexOffset(uint32_t index_offset) { |
| 4009 bit_field_ = IndexOffsetField::update(bit_field_, index_offset); |
| 4010 } |
4006 HValue* GetKey() { return key(); } | 4011 HValue* GetKey() { return key(); } |
4007 void SetKey(HValue* key) { SetOperandAt(1, key); } | 4012 void SetKey(HValue* key) { SetOperandAt(1, key); } |
4008 bool IsDehoisted() { return is_dehoisted_; } | 4013 bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); } |
4009 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } | 4014 void SetDehoisted(bool is_dehoisted) { |
| 4015 bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted); |
| 4016 } |
| 4017 ElementsKind elements_kind() const { |
| 4018 return ElementsKindField::decode(bit_field_); |
| 4019 } |
4010 | 4020 |
4011 virtual Representation RequiredInputRepresentation(int index) { | 4021 virtual Representation RequiredInputRepresentation(int index) { |
4012 // The key is supposed to be Integer32. | 4022 // The key is supposed to be Integer32. |
4013 return index == 0 | 4023 return index == 0 |
4014 ? Representation::Tagged() | 4024 ? Representation::Tagged() |
4015 : Representation::Integer32(); | 4025 : Representation::Integer32(); |
4016 } | 4026 } |
4017 | 4027 |
4018 virtual void PrintDataTo(StringStream* stream); | 4028 virtual void PrintDataTo(StringStream* stream); |
4019 | 4029 |
4020 bool RequiresHoleCheck(); | 4030 bool RequiresHoleCheck(); |
4021 | 4031 |
4022 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement) | 4032 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement) |
4023 | 4033 |
4024 protected: | 4034 protected: |
4025 virtual bool DataEquals(HValue* other) { | 4035 virtual bool DataEquals(HValue* other) { |
4026 if (!other->IsLoadKeyedFastElement()) return false; | 4036 if (!other->IsLoadKeyedFastElement()) return false; |
4027 HLoadKeyedFastElement* other_load = HLoadKeyedFastElement::cast(other); | 4037 HLoadKeyedFastElement* other_load = HLoadKeyedFastElement::cast(other); |
4028 if (is_dehoisted_ && index_offset_ != other_load->index_offset_) | 4038 if (IsDehoisted() && index_offset() != other_load->index_offset()) |
4029 return false; | 4039 return false; |
4030 return hole_check_mode_ == other_load->hole_check_mode_; | 4040 return elements_kind() == other_load->elements_kind(); |
4031 } | 4041 } |
4032 | 4042 |
4033 private: | 4043 private: |
4034 HoleCheckMode hole_check_mode_; | 4044 class ElementsKindField: public BitField<ElementsKind, 0, 4> {}; |
4035 uint32_t index_offset_; | 4045 class IndexOffsetField: public BitField<uint32_t, 4, 27> {}; |
4036 bool is_dehoisted_; | 4046 class IsDehoistedField: public BitField<bool, 31, 1> {}; |
| 4047 uint32_t bit_field_; |
4037 }; | 4048 }; |
4038 | 4049 |
4039 | 4050 |
| 4051 enum HoleCheckMode { PERFORM_HOLE_CHECK, OMIT_HOLE_CHECK }; |
| 4052 |
| 4053 |
4040 class HLoadKeyedFastDoubleElement | 4054 class HLoadKeyedFastDoubleElement |
4041 : public HTemplateInstruction<2>, public ArrayInstructionInterface { | 4055 : public HTemplateInstruction<2>, public ArrayInstructionInterface { |
4042 public: | 4056 public: |
4043 HLoadKeyedFastDoubleElement( | 4057 HLoadKeyedFastDoubleElement( |
4044 HValue* elements, | 4058 HValue* elements, |
4045 HValue* key, | 4059 HValue* key, |
4046 HoleCheckMode hole_check_mode = PERFORM_HOLE_CHECK) | 4060 HoleCheckMode hole_check_mode = PERFORM_HOLE_CHECK) |
4047 : index_offset_(0), | 4061 : index_offset_(0), |
4048 is_dehoisted_(false), | 4062 is_dehoisted_(false), |
4049 hole_check_mode_(hole_check_mode) { | 4063 hole_check_mode_(hole_check_mode) { |
4050 SetOperandAt(0, elements); | 4064 SetOperandAt(0, elements); |
4051 SetOperandAt(1, key); | 4065 SetOperandAt(1, key); |
4052 set_representation(Representation::Double()); | 4066 set_representation(Representation::Double()); |
4053 SetGVNFlag(kDependsOnDoubleArrayElements); | 4067 SetGVNFlag(kDependsOnDoubleArrayElements); |
4054 SetFlag(kUseGVN); | 4068 SetFlag(kUseGVN); |
4055 } | 4069 } |
4056 | 4070 |
4057 HValue* elements() { return OperandAt(0); } | 4071 HValue* elements() { return OperandAt(0); } |
4058 HValue* key() { return OperandAt(1); } | 4072 HValue* key() { return OperandAt(1); } |
4059 uint32_t index_offset() { return index_offset_; } | 4073 uint32_t index_offset() { return index_offset_; } |
4060 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } | 4074 void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; } |
4061 HValue* GetKey() { return key(); } | 4075 HValue* GetKey() { return key(); } |
4062 void SetKey(HValue* key) { SetOperandAt(1, key); } | 4076 void SetKey(HValue* key) { SetOperandAt(1, key); } |
4063 bool IsDehoisted() { return is_dehoisted_; } | 4077 bool IsDehoisted() { return is_dehoisted_; } |
4064 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } | 4078 void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; } |
4065 | 4079 |
(...skipping 1022 matching lines...) Loading... |
5088 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); | 5102 DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex); |
5089 }; | 5103 }; |
5090 | 5104 |
5091 | 5105 |
5092 #undef DECLARE_INSTRUCTION | 5106 #undef DECLARE_INSTRUCTION |
5093 #undef DECLARE_CONCRETE_INSTRUCTION | 5107 #undef DECLARE_CONCRETE_INSTRUCTION |
5094 | 5108 |
5095 } } // namespace v8::internal | 5109 } } // namespace v8::internal |
5096 | 5110 |
5097 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 5111 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |