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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 V(StoreGlobalCell) \ | 171 V(StoreGlobalCell) \ |
172 V(StoreGlobalGeneric) \ | 172 V(StoreGlobalGeneric) \ |
173 V(StoreKeyed) \ | 173 V(StoreKeyed) \ |
174 V(StoreKeyedGeneric) \ | 174 V(StoreKeyedGeneric) \ |
175 V(StoreNamedField) \ | 175 V(StoreNamedField) \ |
176 V(StoreNamedGeneric) \ | 176 V(StoreNamedGeneric) \ |
177 V(StringAdd) \ | 177 V(StringAdd) \ |
178 V(StringCharCodeAt) \ | 178 V(StringCharCodeAt) \ |
179 V(StringCharFromCode) \ | 179 V(StringCharFromCode) \ |
180 V(StringCompareAndBranch) \ | 180 V(StringCompareAndBranch) \ |
181 V(StringLength) \ | |
182 V(Sub) \ | 181 V(Sub) \ |
183 V(ThisFunction) \ | 182 V(ThisFunction) \ |
184 V(Throw) \ | 183 V(Throw) \ |
185 V(ToFastProperties) \ | 184 V(ToFastProperties) \ |
186 V(TransitionElementsKind) \ | 185 V(TransitionElementsKind) \ |
187 V(TrapAllocationMemento) \ | 186 V(TrapAllocationMemento) \ |
188 V(Typeof) \ | 187 V(Typeof) \ |
189 V(TypeofIsAndBranch) \ | 188 V(TypeofIsAndBranch) \ |
190 V(UnaryMathOperation) \ | 189 V(UnaryMathOperation) \ |
191 V(UnknownOSRValue) \ | 190 V(UnknownOSRValue) \ |
192 V(UseConst) \ | 191 V(UseConst) \ |
193 V(ValueOf) \ | 192 V(ValueOf) \ |
194 V(WrapReceiver) | 193 V(WrapReceiver) |
195 | 194 |
196 #define GVN_TRACKED_FLAG_LIST(V) \ | 195 #define GVN_TRACKED_FLAG_LIST(V) \ |
197 V(Maps) \ | 196 V(Maps) \ |
198 V(NewSpacePromotion) | 197 V(NewSpacePromotion) |
199 | 198 |
200 #define GVN_UNTRACKED_FLAG_LIST(V) \ | 199 #define GVN_UNTRACKED_FLAG_LIST(V) \ |
201 V(ArrayElements) \ | 200 V(ArrayElements) \ |
202 V(ArrayLengths) \ | 201 V(ArrayLengths) \ |
| 202 V(StringLengths) \ |
203 V(BackingStoreFields) \ | 203 V(BackingStoreFields) \ |
204 V(Calls) \ | 204 V(Calls) \ |
205 V(ContextSlots) \ | 205 V(ContextSlots) \ |
206 V(DoubleArrayElements) \ | 206 V(DoubleArrayElements) \ |
207 V(DoubleFields) \ | 207 V(DoubleFields) \ |
208 V(ElementsKind) \ | 208 V(ElementsKind) \ |
209 V(ElementsPointer) \ | 209 V(ElementsPointer) \ |
210 V(GlobalVars) \ | 210 V(GlobalVars) \ |
211 V(InobjectFields) \ | 211 V(InobjectFields) \ |
212 V(OsrEntries) \ | 212 V(OsrEntries) \ |
(...skipping 5625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5838 class HObjectAccess { | 5838 class HObjectAccess { |
5839 public: | 5839 public: |
5840 inline bool IsInobject() const { | 5840 inline bool IsInobject() const { |
5841 return portion() != kBackingStore && portion() != kExternalMemory; | 5841 return portion() != kBackingStore && portion() != kExternalMemory; |
5842 } | 5842 } |
5843 | 5843 |
5844 inline bool IsExternalMemory() const { | 5844 inline bool IsExternalMemory() const { |
5845 return portion() == kExternalMemory; | 5845 return portion() == kExternalMemory; |
5846 } | 5846 } |
5847 | 5847 |
| 5848 inline bool IsStringLength() const { |
| 5849 return portion() == kStringLengths; |
| 5850 } |
| 5851 |
5848 inline int offset() const { | 5852 inline int offset() const { |
5849 return OffsetField::decode(value_); | 5853 return OffsetField::decode(value_); |
5850 } | 5854 } |
5851 | 5855 |
5852 inline Representation representation() const { | 5856 inline Representation representation() const { |
5853 return Representation::FromKind(RepresentationField::decode(value_)); | 5857 return Representation::FromKind(RepresentationField::decode(value_)); |
5854 } | 5858 } |
5855 | 5859 |
5856 inline Handle<String> name() const { | 5860 inline Handle<String> name() const { |
5857 return name_; | 5861 return name_; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5891 return HObjectAccess(kExternalMemory, 0, Representation::Tagged()); | 5895 return HObjectAccess(kExternalMemory, 0, Representation::Tagged()); |
5892 } | 5896 } |
5893 | 5897 |
5894 static HObjectAccess ForFixedArrayLength() { | 5898 static HObjectAccess ForFixedArrayLength() { |
5895 return HObjectAccess( | 5899 return HObjectAccess( |
5896 kArrayLengths, | 5900 kArrayLengths, |
5897 FixedArray::kLengthOffset, | 5901 FixedArray::kLengthOffset, |
5898 FLAG_track_fields ? Representation::Smi() : Representation::Tagged()); | 5902 FLAG_track_fields ? Representation::Smi() : Representation::Tagged()); |
5899 } | 5903 } |
5900 | 5904 |
| 5905 static HObjectAccess ForStringLength() { |
| 5906 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); |
| 5907 return HObjectAccess( |
| 5908 kStringLengths, |
| 5909 String::kLengthOffset, |
| 5910 FLAG_track_fields ? Representation::Smi() : Representation::Tagged()); |
| 5911 } |
| 5912 |
5901 static HObjectAccess ForPropertiesPointer() { | 5913 static HObjectAccess ForPropertiesPointer() { |
5902 return HObjectAccess(kInobject, JSObject::kPropertiesOffset); | 5914 return HObjectAccess(kInobject, JSObject::kPropertiesOffset); |
5903 } | 5915 } |
5904 | 5916 |
5905 static HObjectAccess ForPrototypeOrInitialMap() { | 5917 static HObjectAccess ForPrototypeOrInitialMap() { |
5906 return HObjectAccess(kInobject, JSFunction::kPrototypeOrInitialMapOffset); | 5918 return HObjectAccess(kInobject, JSFunction::kPrototypeOrInitialMapOffset); |
5907 } | 5919 } |
5908 | 5920 |
5909 static HObjectAccess ForMap() { | 5921 static HObjectAccess ForMap() { |
5910 return HObjectAccess(kMaps, JSObject::kMapOffset); | 5922 return HObjectAccess(kMaps, JSObject::kMapOffset); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5954 } | 5966 } |
5955 | 5967 |
5956 protected: | 5968 protected: |
5957 void SetGVNFlags(HValue *instr, bool is_store); | 5969 void SetGVNFlags(HValue *instr, bool is_store); |
5958 | 5970 |
5959 private: | 5971 private: |
5960 // internal use only; different parts of an object or array | 5972 // internal use only; different parts of an object or array |
5961 enum Portion { | 5973 enum Portion { |
5962 kMaps, // map of an object | 5974 kMaps, // map of an object |
5963 kArrayLengths, // the length of an array | 5975 kArrayLengths, // the length of an array |
| 5976 kStringLengths, // the length of a string |
5964 kElementsPointer, // elements pointer | 5977 kElementsPointer, // elements pointer |
5965 kBackingStore, // some field in the backing store | 5978 kBackingStore, // some field in the backing store |
5966 kDouble, // some double field | 5979 kDouble, // some double field |
5967 kInobject, // some other in-object field | 5980 kInobject, // some other in-object field |
5968 kExternalMemory // some field in external memory | 5981 kExternalMemory // some field in external memory |
5969 }; | 5982 }; |
5970 | 5983 |
5971 HObjectAccess(Portion portion, int offset, | 5984 HObjectAccess(Portion portion, int offset, |
5972 Representation representation = Representation::Tagged(), | 5985 Representation representation = Representation::Tagged(), |
5973 Handle<String> name = Handle<String>::null()) | 5986 Handle<String> name = Handle<String>::null()) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6016 } | 6029 } |
6017 | 6030 |
6018 virtual bool HasEscapingOperandAt(int index) { return false; } | 6031 virtual bool HasEscapingOperandAt(int index) { return false; } |
6019 virtual Representation RequiredInputRepresentation(int index) { | 6032 virtual Representation RequiredInputRepresentation(int index) { |
6020 if (index == 0 && access().IsExternalMemory()) { | 6033 if (index == 0 && access().IsExternalMemory()) { |
6021 // object must be external in case of external memory access | 6034 // object must be external in case of external memory access |
6022 return Representation::External(); | 6035 return Representation::External(); |
6023 } | 6036 } |
6024 return Representation::Tagged(); | 6037 return Representation::Tagged(); |
6025 } | 6038 } |
| 6039 virtual Range* InferRange(Zone* zone); |
6026 virtual void PrintDataTo(StringStream* stream); | 6040 virtual void PrintDataTo(StringStream* stream); |
6027 | 6041 |
6028 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) | 6042 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) |
6029 | 6043 |
6030 protected: | 6044 protected: |
6031 virtual bool DataEquals(HValue* other) { | 6045 virtual bool DataEquals(HValue* other) { |
6032 HLoadNamedField* b = HLoadNamedField::cast(other); | 6046 HLoadNamedField* b = HLoadNamedField::cast(other); |
6033 return access_.Equals(b->access_); | 6047 return access_.Equals(b->access_); |
6034 } | 6048 } |
6035 | 6049 |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6851 SetFlag(kUseGVN); | 6865 SetFlag(kUseGVN); |
6852 SetGVNFlag(kChangesNewSpacePromotion); | 6866 SetGVNFlag(kChangesNewSpacePromotion); |
6853 } | 6867 } |
6854 | 6868 |
6855 virtual bool IsDeletable() const { | 6869 virtual bool IsDeletable() const { |
6856 return !value()->ToNumberCanBeObserved(); | 6870 return !value()->ToNumberCanBeObserved(); |
6857 } | 6871 } |
6858 }; | 6872 }; |
6859 | 6873 |
6860 | 6874 |
6861 class HStringLength: public HUnaryOperation { | |
6862 public: | |
6863 static HInstruction* New(Zone* zone, HValue* context, HValue* string); | |
6864 | |
6865 virtual Representation RequiredInputRepresentation(int index) { | |
6866 return Representation::Tagged(); | |
6867 } | |
6868 | |
6869 DECLARE_CONCRETE_INSTRUCTION(StringLength) | |
6870 | |
6871 protected: | |
6872 virtual bool DataEquals(HValue* other) { return true; } | |
6873 | |
6874 virtual Range* InferRange(Zone* zone) { | |
6875 return new(zone) Range(0, String::kMaxLength); | |
6876 } | |
6877 | |
6878 private: | |
6879 explicit HStringLength(HValue* string) | |
6880 : HUnaryOperation(string, HType::Smi()) { | |
6881 STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); | |
6882 set_representation(Representation::Tagged()); | |
6883 SetFlag(kUseGVN); | |
6884 SetGVNFlag(kDependsOnMaps); | |
6885 } | |
6886 | |
6887 virtual bool IsDeletable() const { return true; } | |
6888 }; | |
6889 | |
6890 | |
6891 template <int V> | 6875 template <int V> |
6892 class HMaterializedLiteral: public HTemplateInstruction<V> { | 6876 class HMaterializedLiteral: public HTemplateInstruction<V> { |
6893 public: | 6877 public: |
6894 HMaterializedLiteral<V>(int index, int depth, AllocationSiteMode mode) | 6878 HMaterializedLiteral<V>(int index, int depth, AllocationSiteMode mode) |
6895 : literal_index_(index), depth_(depth), allocation_site_mode_(mode) { | 6879 : literal_index_(index), depth_(depth), allocation_site_mode_(mode) { |
6896 this->set_representation(Representation::Tagged()); | 6880 this->set_representation(Representation::Tagged()); |
6897 } | 6881 } |
6898 | 6882 |
6899 HMaterializedLiteral<V>(int index, int depth) | 6883 HMaterializedLiteral<V>(int index, int depth) |
6900 : literal_index_(index), depth_(depth), | 6884 : literal_index_(index), depth_(depth), |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7270 virtual bool IsDeletable() const { return true; } | 7254 virtual bool IsDeletable() const { return true; } |
7271 }; | 7255 }; |
7272 | 7256 |
7273 | 7257 |
7274 #undef DECLARE_INSTRUCTION | 7258 #undef DECLARE_INSTRUCTION |
7275 #undef DECLARE_CONCRETE_INSTRUCTION | 7259 #undef DECLARE_CONCRETE_INSTRUCTION |
7276 | 7260 |
7277 } } // namespace v8::internal | 7261 } } // namespace v8::internal |
7278 | 7262 |
7279 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7263 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |