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 // Wrapper class for ByteArray which can store arbitrary C++ classes, as long |
| 4961 // as they can be copied with memcpy. |
| 4962 template <class T> |
| 4963 class PodArray : public ByteArray { |
| 4964 public: |
| 4965 void copy_out(int index, T* result) { |
| 4966 ByteArray::copy_out(index * sizeof(T), reinterpret_cast<byte*>(result), |
| 4967 sizeof(T)); |
| 4968 } |
| 4969 T get(int index) { |
| 4970 T result; |
| 4971 copy_out(index, &result); |
| 4972 return result; |
| 4973 } |
| 4974 void set(int index, const T& value) { |
| 4975 copy_in(index * sizeof(T), reinterpret_cast<const byte*>(&value), |
| 4976 sizeof(T)); |
| 4977 } |
| 4978 int length() { return ByteArray::length() / sizeof(T); } |
| 4979 DECLARE_CAST(PodArray<T>); |
| 4980 |
| 4981 private: |
| 4982 DISALLOW_IMPLICIT_CONSTRUCTORS(PodArray<T>); |
| 4983 }; |
4958 | 4984 |
4959 // BytecodeArray represents a sequence of interpreter bytecodes. | 4985 // BytecodeArray represents a sequence of interpreter bytecodes. |
4960 class BytecodeArray : public FixedArrayBase { | 4986 class BytecodeArray : public FixedArrayBase { |
4961 public: | 4987 public: |
4962 static int SizeFor(int length) { | 4988 static int SizeFor(int length) { |
4963 return OBJECT_POINTER_ALIGN(kHeaderSize + length); | 4989 return OBJECT_POINTER_ALIGN(kHeaderSize + length); |
4964 } | 4990 } |
4965 | 4991 |
4966 // Setter and getter | 4992 // Setter and getter |
4967 inline byte get(int index); | 4993 inline byte get(int index); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5180 elementType scalar); \ | 5206 elementType scalar); \ |
5181 static inline elementType defaultValue(); \ | 5207 static inline elementType defaultValue(); \ |
5182 }; \ | 5208 }; \ |
5183 \ | 5209 \ |
5184 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array; | 5210 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array; |
5185 | 5211 |
5186 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) | 5212 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) |
5187 | 5213 |
5188 #undef FIXED_TYPED_ARRAY_TRAITS | 5214 #undef FIXED_TYPED_ARRAY_TRAITS |
5189 | 5215 |
5190 | |
5191 // DeoptimizationInputData is a fixed array used to hold the deoptimization | 5216 // DeoptimizationInputData is a fixed array used to hold the deoptimization |
5192 // data for code generated by the Hydrogen/Lithium compiler. It also | 5217 // data for code generated by the Hydrogen/Lithium compiler. It also |
5193 // contains information about functions that were inlined. If N different | 5218 // contains information about functions that were inlined. If N different |
5194 // functions were inlined then first N elements of the literal array will | 5219 // functions were inlined then first N elements of the literal array will |
5195 // contain these functions. | 5220 // contain these functions. |
5196 // | 5221 // |
5197 // It can be empty. | 5222 // It can be empty. |
5198 class DeoptimizationInputData: public FixedArray { | 5223 class DeoptimizationInputData: public FixedArray { |
5199 public: | 5224 public: |
5200 // Layout description. Indices in the array. | 5225 // Layout description. Indices in the array. |
5201 static const int kTranslationByteArrayIndex = 0; | 5226 static const int kTranslationByteArrayIndex = 0; |
5202 static const int kInlinedFunctionCountIndex = 1; | 5227 static const int kInlinedFunctionCountIndex = 1; |
5203 static const int kLiteralArrayIndex = 2; | 5228 static const int kLiteralArrayIndex = 2; |
5204 static const int kOsrAstIdIndex = 3; | 5229 static const int kOsrAstIdIndex = 3; |
5205 static const int kOsrPcOffsetIndex = 4; | 5230 static const int kOsrPcOffsetIndex = 4; |
5206 static const int kOptimizationIdIndex = 5; | 5231 static const int kOptimizationIdIndex = 5; |
5207 static const int kSharedFunctionInfoIndex = 6; | 5232 static const int kSharedFunctionInfoIndex = 6; |
5208 static const int kWeakCellCacheIndex = 7; | 5233 static const int kWeakCellCacheIndex = 7; |
5209 static const int kFirstDeoptEntryIndex = 8; | 5234 static const int kInliningPositionsIndex = 8; |
| 5235 static const int kFirstDeoptEntryIndex = 9; |
5210 | 5236 |
5211 // Offsets of deopt entry elements relative to the start of the entry. | 5237 // Offsets of deopt entry elements relative to the start of the entry. |
5212 static const int kAstIdRawOffset = 0; | 5238 static const int kAstIdRawOffset = 0; |
5213 static const int kTranslationIndexOffset = 1; | 5239 static const int kTranslationIndexOffset = 1; |
5214 static const int kArgumentsStackHeightOffset = 2; | 5240 static const int kArgumentsStackHeightOffset = 2; |
5215 static const int kPcOffset = 3; | 5241 static const int kPcOffset = 3; |
5216 static const int kDeoptEntrySize = 4; | 5242 static const int kDeoptEntrySize = 4; |
5217 | 5243 |
5218 // Simple element accessors. | 5244 // Simple element accessors. |
5219 #define DECLARE_ELEMENT_ACCESSORS(name, type) \ | 5245 #define DECLARE_ELEMENT_ACCESSORS(name, type) \ |
5220 inline type* name(); \ | 5246 inline type* name(); \ |
5221 inline void Set##name(type* value); | 5247 inline void Set##name(type* value); |
5222 | 5248 |
5223 DECLARE_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray) | 5249 DECLARE_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray) |
5224 DECLARE_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi) | 5250 DECLARE_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi) |
5225 DECLARE_ELEMENT_ACCESSORS(LiteralArray, FixedArray) | 5251 DECLARE_ELEMENT_ACCESSORS(LiteralArray, FixedArray) |
5226 DECLARE_ELEMENT_ACCESSORS(OsrAstId, Smi) | 5252 DECLARE_ELEMENT_ACCESSORS(OsrAstId, Smi) |
5227 DECLARE_ELEMENT_ACCESSORS(OsrPcOffset, Smi) | 5253 DECLARE_ELEMENT_ACCESSORS(OsrPcOffset, Smi) |
5228 DECLARE_ELEMENT_ACCESSORS(OptimizationId, Smi) | 5254 DECLARE_ELEMENT_ACCESSORS(OptimizationId, Smi) |
5229 DECLARE_ELEMENT_ACCESSORS(SharedFunctionInfo, Object) | 5255 DECLARE_ELEMENT_ACCESSORS(SharedFunctionInfo, Object) |
5230 DECLARE_ELEMENT_ACCESSORS(WeakCellCache, Object) | 5256 DECLARE_ELEMENT_ACCESSORS(WeakCellCache, Object) |
| 5257 DECLARE_ELEMENT_ACCESSORS(InliningPositions, PodArray<InliningPosition>) |
5231 | 5258 |
5232 #undef DECLARE_ELEMENT_ACCESSORS | 5259 #undef DECLARE_ELEMENT_ACCESSORS |
5233 | 5260 |
5234 // Accessors for elements of the ith deoptimization entry. | 5261 // Accessors for elements of the ith deoptimization entry. |
5235 #define DECLARE_ENTRY_ACCESSORS(name, type) \ | 5262 #define DECLARE_ENTRY_ACCESSORS(name, type) \ |
5236 inline type* name(int i); \ | 5263 inline type* name(int i); \ |
5237 inline void Set##name(int i, type* value); | 5264 inline void Set##name(int i, type* value); |
5238 | 5265 |
5239 DECLARE_ENTRY_ACCESSORS(AstIdRaw, Smi) | 5266 DECLARE_ENTRY_ACCESSORS(AstIdRaw, Smi) |
5240 DECLARE_ENTRY_ACCESSORS(TranslationIndex, Smi) | 5267 DECLARE_ENTRY_ACCESSORS(TranslationIndex, Smi) |
(...skipping 21 matching lines...) Expand all Loading... |
5262 | 5289 |
5263 private: | 5290 private: |
5264 static int IndexForEntry(int i) { | 5291 static int IndexForEntry(int i) { |
5265 return kFirstDeoptEntryIndex + (i * kDeoptEntrySize); | 5292 return kFirstDeoptEntryIndex + (i * kDeoptEntrySize); |
5266 } | 5293 } |
5267 | 5294 |
5268 | 5295 |
5269 static int LengthFor(int entry_count) { return IndexForEntry(entry_count); } | 5296 static int LengthFor(int entry_count) { return IndexForEntry(entry_count); } |
5270 }; | 5297 }; |
5271 | 5298 |
5272 | |
5273 // DeoptimizationOutputData is a fixed array used to hold the deoptimization | 5299 // DeoptimizationOutputData is a fixed array used to hold the deoptimization |
5274 // data for code generated by the full compiler. | 5300 // data for code generated by the full compiler. |
5275 // The format of the these objects is | 5301 // The format of the these objects is |
5276 // [i * 2]: Ast ID for ith deoptimization. | 5302 // [i * 2]: Ast ID for ith deoptimization. |
5277 // [i * 2 + 1]: PC and state of ith deoptimization | 5303 // [i * 2 + 1]: PC and state of ith deoptimization |
5278 class DeoptimizationOutputData: public FixedArray { | 5304 class DeoptimizationOutputData: public FixedArray { |
5279 public: | 5305 public: |
5280 inline int DeoptPoints(); | 5306 inline int DeoptPoints(); |
5281 | 5307 |
5282 inline BailoutId AstId(int index); | 5308 inline BailoutId AstId(int index); |
(...skipping 6473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11756 } | 11782 } |
11757 return value; | 11783 return value; |
11758 } | 11784 } |
11759 }; | 11785 }; |
11760 | 11786 |
11761 | 11787 |
11762 } // NOLINT, false-positive due to second-order macros. | 11788 } // NOLINT, false-positive due to second-order macros. |
11763 } // NOLINT, false-positive due to second-order macros. | 11789 } // NOLINT, false-positive due to second-order macros. |
11764 | 11790 |
11765 #endif // V8_OBJECTS_H_ | 11791 #endif // V8_OBJECTS_H_ |
OLD | NEW |