| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
| 6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
| 7 | 7 |
| 8 #include <iosfwd> | 8 #include <iosfwd> |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // - Module | 161 // - Module |
| 162 // - WeakCell | 162 // - WeakCell |
| 163 // | 163 // |
| 164 // Formats of Object*: | 164 // Formats of Object*: |
| 165 // Smi: [31 bit signed int] 0 | 165 // Smi: [31 bit signed int] 0 |
| 166 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01 | 166 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01 |
| 167 | 167 |
| 168 namespace v8 { | 168 namespace v8 { |
| 169 namespace internal { | 169 namespace internal { |
| 170 | 170 |
| 171 struct InliningPosition; |
| 172 |
| 171 enum KeyedAccessStoreMode { | 173 enum KeyedAccessStoreMode { |
| 172 STANDARD_STORE, | 174 STANDARD_STORE, |
| 173 STORE_TRANSITION_TO_OBJECT, | 175 STORE_TRANSITION_TO_OBJECT, |
| 174 STORE_TRANSITION_TO_DOUBLE, | 176 STORE_TRANSITION_TO_DOUBLE, |
| 175 STORE_AND_GROW_NO_TRANSITION, | 177 STORE_AND_GROW_NO_TRANSITION, |
| 176 STORE_AND_GROW_TRANSITION_TO_OBJECT, | 178 STORE_AND_GROW_TRANSITION_TO_OBJECT, |
| 177 STORE_AND_GROW_TRANSITION_TO_DOUBLE, | 179 STORE_AND_GROW_TRANSITION_TO_DOUBLE, |
| 178 STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS, | 180 STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS, |
| 179 STORE_NO_TRANSITION_HANDLE_COW | 181 STORE_NO_TRANSITION_HANDLE_COW |
| 180 }; | 182 }; |
| (...skipping 4767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4948 | 4950 |
| 4949 // Maximal memory consumption for a single ByteArray. | 4951 // Maximal memory consumption for a single ByteArray. |
| 4950 static const int kMaxSize = 512 * MB; | 4952 static const int kMaxSize = 512 * MB; |
| 4951 // Maximal length of a single ByteArray. | 4953 // Maximal length of a single ByteArray. |
| 4952 static const int kMaxLength = kMaxSize - kHeaderSize; | 4954 static const int kMaxLength = kMaxSize - kHeaderSize; |
| 4953 | 4955 |
| 4954 private: | 4956 private: |
| 4955 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 4957 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
| 4956 }; | 4958 }; |
| 4957 | 4959 |
| 4960 template <class T> |
| 4961 class PodArray : public ByteArray { |
| 4962 public: |
| 4963 T get(int index) { |
| 4964 STATIC_ASSERT(std::is_pod<T>::value); |
| 4965 T result; |
| 4966 copy_out(index * sizeof(T), reinterpret_cast<byte*>(&result), sizeof(T)); |
| 4967 return result; |
| 4968 } |
| 4969 void set(int index, const T& value) { |
| 4970 copy_in(index * sizeof(T), reinterpret_cast<const byte*>(&value), |
| 4971 sizeof(T)); |
| 4972 } |
| 4973 int length() { return ByteArray::length() / sizeof(T); } |
| 4974 DECLARE_CAST(PodArray<T>); |
| 4975 |
| 4976 private: |
| 4977 DISALLOW_IMPLICIT_CONSTRUCTORS(PodArray<T>); |
| 4978 }; |
| 4958 | 4979 |
| 4959 // BytecodeArray represents a sequence of interpreter bytecodes. | 4980 // BytecodeArray represents a sequence of interpreter bytecodes. |
| 4960 class BytecodeArray : public FixedArrayBase { | 4981 class BytecodeArray : public FixedArrayBase { |
| 4961 public: | 4982 public: |
| 4962 static int SizeFor(int length) { | 4983 static int SizeFor(int length) { |
| 4963 return OBJECT_POINTER_ALIGN(kHeaderSize + length); | 4984 return OBJECT_POINTER_ALIGN(kHeaderSize + length); |
| 4964 } | 4985 } |
| 4965 | 4986 |
| 4966 // Setter and getter | 4987 // Setter and getter |
| 4967 inline byte get(int index); | 4988 inline byte get(int index); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5180 elementType scalar); \ | 5201 elementType scalar); \ |
| 5181 static inline elementType defaultValue(); \ | 5202 static inline elementType defaultValue(); \ |
| 5182 }; \ | 5203 }; \ |
| 5183 \ | 5204 \ |
| 5184 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array; | 5205 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array; |
| 5185 | 5206 |
| 5186 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) | 5207 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) |
| 5187 | 5208 |
| 5188 #undef FIXED_TYPED_ARRAY_TRAITS | 5209 #undef FIXED_TYPED_ARRAY_TRAITS |
| 5189 | 5210 |
| 5190 | |
| 5191 // DeoptimizationInputData is a fixed array used to hold the deoptimization | 5211 // DeoptimizationInputData is a fixed array used to hold the deoptimization |
| 5192 // data for code generated by the Hydrogen/Lithium compiler. It also | 5212 // data for code generated by the Hydrogen/Lithium compiler. It also |
| 5193 // contains information about functions that were inlined. If N different | 5213 // contains information about functions that were inlined. If N different |
| 5194 // functions were inlined then first N elements of the literal array will | 5214 // functions were inlined then first N elements of the literal array will |
| 5195 // contain these functions. | 5215 // contain these functions. |
| 5196 // | 5216 // |
| 5197 // It can be empty. | 5217 // It can be empty. |
| 5198 class DeoptimizationInputData: public FixedArray { | 5218 class DeoptimizationInputData: public FixedArray { |
| 5199 public: | 5219 public: |
| 5200 // Layout description. Indices in the array. | 5220 // Layout description. Indices in the array. |
| 5201 static const int kTranslationByteArrayIndex = 0; | 5221 static const int kTranslationByteArrayIndex = 0; |
| 5202 static const int kInlinedFunctionCountIndex = 1; | 5222 static const int kInlinedFunctionCountIndex = 1; |
| 5203 static const int kLiteralArrayIndex = 2; | 5223 static const int kLiteralArrayIndex = 2; |
| 5204 static const int kOsrAstIdIndex = 3; | 5224 static const int kOsrAstIdIndex = 3; |
| 5205 static const int kOsrPcOffsetIndex = 4; | 5225 static const int kOsrPcOffsetIndex = 4; |
| 5206 static const int kOptimizationIdIndex = 5; | 5226 static const int kOptimizationIdIndex = 5; |
| 5207 static const int kSharedFunctionInfoIndex = 6; | 5227 static const int kSharedFunctionInfoIndex = 6; |
| 5208 static const int kWeakCellCacheIndex = 7; | 5228 static const int kWeakCellCacheIndex = 7; |
| 5209 static const int kFirstDeoptEntryIndex = 8; | 5229 static const int kInliningPositionsIndex = 8; |
| 5230 static const int kFirstDeoptEntryIndex = 9; |
| 5210 | 5231 |
| 5211 // Offsets of deopt entry elements relative to the start of the entry. | 5232 // Offsets of deopt entry elements relative to the start of the entry. |
| 5212 static const int kAstIdRawOffset = 0; | 5233 static const int kAstIdRawOffset = 0; |
| 5213 static const int kTranslationIndexOffset = 1; | 5234 static const int kTranslationIndexOffset = 1; |
| 5214 static const int kArgumentsStackHeightOffset = 2; | 5235 static const int kArgumentsStackHeightOffset = 2; |
| 5215 static const int kPcOffset = 3; | 5236 static const int kPcOffset = 3; |
| 5216 static const int kDeoptEntrySize = 4; | 5237 static const int kDeoptEntrySize = 4; |
| 5217 | 5238 |
| 5218 // Simple element accessors. | 5239 // Simple element accessors. |
| 5219 #define DECLARE_ELEMENT_ACCESSORS(name, type) \ | 5240 #define DECLARE_ELEMENT_ACCESSORS(name, type) \ |
| 5220 inline type* name(); \ | 5241 inline type* name(); \ |
| 5221 inline void Set##name(type* value); | 5242 inline void Set##name(type* value); |
| 5222 | 5243 |
| 5223 DECLARE_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray) | 5244 DECLARE_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray) |
| 5224 DECLARE_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi) | 5245 DECLARE_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi) |
| 5225 DECLARE_ELEMENT_ACCESSORS(LiteralArray, FixedArray) | 5246 DECLARE_ELEMENT_ACCESSORS(LiteralArray, FixedArray) |
| 5226 DECLARE_ELEMENT_ACCESSORS(OsrAstId, Smi) | 5247 DECLARE_ELEMENT_ACCESSORS(OsrAstId, Smi) |
| 5227 DECLARE_ELEMENT_ACCESSORS(OsrPcOffset, Smi) | 5248 DECLARE_ELEMENT_ACCESSORS(OsrPcOffset, Smi) |
| 5228 DECLARE_ELEMENT_ACCESSORS(OptimizationId, Smi) | 5249 DECLARE_ELEMENT_ACCESSORS(OptimizationId, Smi) |
| 5229 DECLARE_ELEMENT_ACCESSORS(SharedFunctionInfo, Object) | 5250 DECLARE_ELEMENT_ACCESSORS(SharedFunctionInfo, Object) |
| 5230 DECLARE_ELEMENT_ACCESSORS(WeakCellCache, Object) | 5251 DECLARE_ELEMENT_ACCESSORS(WeakCellCache, Object) |
| 5252 DECLARE_ELEMENT_ACCESSORS(InliningPositions, PodArray<InliningPosition>) |
| 5231 | 5253 |
| 5232 #undef DECLARE_ELEMENT_ACCESSORS | 5254 #undef DECLARE_ELEMENT_ACCESSORS |
| 5233 | 5255 |
| 5234 // Accessors for elements of the ith deoptimization entry. | 5256 // Accessors for elements of the ith deoptimization entry. |
| 5235 #define DECLARE_ENTRY_ACCESSORS(name, type) \ | 5257 #define DECLARE_ENTRY_ACCESSORS(name, type) \ |
| 5236 inline type* name(int i); \ | 5258 inline type* name(int i); \ |
| 5237 inline void Set##name(int i, type* value); | 5259 inline void Set##name(int i, type* value); |
| 5238 | 5260 |
| 5239 DECLARE_ENTRY_ACCESSORS(AstIdRaw, Smi) | 5261 DECLARE_ENTRY_ACCESSORS(AstIdRaw, Smi) |
| 5240 DECLARE_ENTRY_ACCESSORS(TranslationIndex, Smi) | 5262 DECLARE_ENTRY_ACCESSORS(TranslationIndex, Smi) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5262 | 5284 |
| 5263 private: | 5285 private: |
| 5264 static int IndexForEntry(int i) { | 5286 static int IndexForEntry(int i) { |
| 5265 return kFirstDeoptEntryIndex + (i * kDeoptEntrySize); | 5287 return kFirstDeoptEntryIndex + (i * kDeoptEntrySize); |
| 5266 } | 5288 } |
| 5267 | 5289 |
| 5268 | 5290 |
| 5269 static int LengthFor(int entry_count) { return IndexForEntry(entry_count); } | 5291 static int LengthFor(int entry_count) { return IndexForEntry(entry_count); } |
| 5270 }; | 5292 }; |
| 5271 | 5293 |
| 5272 | |
| 5273 // DeoptimizationOutputData is a fixed array used to hold the deoptimization | 5294 // DeoptimizationOutputData is a fixed array used to hold the deoptimization |
| 5274 // data for code generated by the full compiler. | 5295 // data for code generated by the full compiler. |
| 5275 // The format of the these objects is | 5296 // The format of the these objects is |
| 5276 // [i * 2]: Ast ID for ith deoptimization. | 5297 // [i * 2]: Ast ID for ith deoptimization. |
| 5277 // [i * 2 + 1]: PC and state of ith deoptimization | 5298 // [i * 2 + 1]: PC and state of ith deoptimization |
| 5278 class DeoptimizationOutputData: public FixedArray { | 5299 class DeoptimizationOutputData: public FixedArray { |
| 5279 public: | 5300 public: |
| 5280 inline int DeoptPoints(); | 5301 inline int DeoptPoints(); |
| 5281 | 5302 |
| 5282 inline BailoutId AstId(int index); | 5303 inline BailoutId AstId(int index); |
| (...skipping 6473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11756 } | 11777 } |
| 11757 return value; | 11778 return value; |
| 11758 } | 11779 } |
| 11759 }; | 11780 }; |
| 11760 | 11781 |
| 11761 | 11782 |
| 11762 } // NOLINT, false-positive due to second-order macros. | 11783 } // NOLINT, false-positive due to second-order macros. |
| 11763 } // NOLINT, false-positive due to second-order macros. | 11784 } // NOLINT, false-positive due to second-order macros. |
| 11764 | 11785 |
| 11765 #endif // V8_OBJECTS_H_ | 11786 #endif // V8_OBJECTS_H_ |
| OLD | NEW |