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 |
11 #include "src/assert-scope.h" | 11 #include "src/assert-scope.h" |
12 #include "src/bailout-reason.h" | 12 #include "src/bailout-reason.h" |
13 #include "src/base/bits.h" | 13 #include "src/base/bits.h" |
14 #include "src/base/flags.h" | 14 #include "src/base/flags.h" |
15 #include "src/builtins/builtins.h" | 15 #include "src/builtins/builtins.h" |
16 #include "src/checks.h" | 16 #include "src/checks.h" |
17 #include "src/elements-kind.h" | 17 #include "src/elements-kind.h" |
18 #include "src/field-index.h" | 18 #include "src/field-index.h" |
19 #include "src/flags.h" | 19 #include "src/flags.h" |
20 #include "src/list.h" | 20 #include "src/list.h" |
21 #include "src/messages.h" | 21 #include "src/messages.h" |
22 #include "src/property-details.h" | 22 #include "src/property-details.h" |
| 23 #include "src/source-position.h" |
23 #include "src/unicode-decoder.h" | 24 #include "src/unicode-decoder.h" |
24 #include "src/unicode.h" | 25 #include "src/unicode.h" |
25 #include "src/zone/zone.h" | 26 #include "src/zone/zone.h" |
26 | 27 |
27 #if V8_TARGET_ARCH_ARM | 28 #if V8_TARGET_ARCH_ARM |
28 #include "src/arm/constants-arm.h" // NOLINT | 29 #include "src/arm/constants-arm.h" // NOLINT |
29 #elif V8_TARGET_ARCH_ARM64 | 30 #elif V8_TARGET_ARCH_ARM64 |
30 #include "src/arm64/constants-arm64.h" // NOLINT | 31 #include "src/arm64/constants-arm64.h" // NOLINT |
31 #elif V8_TARGET_ARCH_MIPS | 32 #elif V8_TARGET_ARCH_MIPS |
32 #include "src/mips/constants-mips.h" // NOLINT | 33 #include "src/mips/constants-mips.h" // NOLINT |
(...skipping 4915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4948 | 4949 |
4949 // Maximal memory consumption for a single ByteArray. | 4950 // Maximal memory consumption for a single ByteArray. |
4950 static const int kMaxSize = 512 * MB; | 4951 static const int kMaxSize = 512 * MB; |
4951 // Maximal length of a single ByteArray. | 4952 // Maximal length of a single ByteArray. |
4952 static const int kMaxLength = kMaxSize - kHeaderSize; | 4953 static const int kMaxLength = kMaxSize - kHeaderSize; |
4953 | 4954 |
4954 private: | 4955 private: |
4955 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 4956 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
4956 }; | 4957 }; |
4957 | 4958 |
| 4959 template <class T> |
| 4960 class PodArray : public ByteArray { |
| 4961 public: |
| 4962 STATIC_ASSERT(std::is_pod<T>::value); |
| 4963 T get(int index) { |
| 4964 T result; |
| 4965 copy_out(index * sizeof(T), reinterpret_cast<byte*>(&result), sizeof(T)); |
| 4966 return result; |
| 4967 } |
| 4968 void set(int index, const T& value) { |
| 4969 copy_in(index * sizeof(T), reinterpret_cast<const byte*>(&value), |
| 4970 sizeof(T)); |
| 4971 } |
| 4972 int length() { return ByteArray::length() / sizeof(T); } |
| 4973 DECLARE_CAST(PodArray<T>); |
| 4974 |
| 4975 private: |
| 4976 DISALLOW_IMPLICIT_CONSTRUCTORS(PodArray<T>); |
| 4977 }; |
4958 | 4978 |
4959 // BytecodeArray represents a sequence of interpreter bytecodes. | 4979 // BytecodeArray represents a sequence of interpreter bytecodes. |
4960 class BytecodeArray : public FixedArrayBase { | 4980 class BytecodeArray : public FixedArrayBase { |
4961 public: | 4981 public: |
4962 static int SizeFor(int length) { | 4982 static int SizeFor(int length) { |
4963 return OBJECT_POINTER_ALIGN(kHeaderSize + length); | 4983 return OBJECT_POINTER_ALIGN(kHeaderSize + length); |
4964 } | 4984 } |
4965 | 4985 |
4966 // Setter and getter | 4986 // Setter and getter |
4967 inline byte get(int index); | 4987 inline byte get(int index); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5180 elementType scalar); \ | 5200 elementType scalar); \ |
5181 static inline elementType defaultValue(); \ | 5201 static inline elementType defaultValue(); \ |
5182 }; \ | 5202 }; \ |
5183 \ | 5203 \ |
5184 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array; | 5204 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array; |
5185 | 5205 |
5186 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) | 5206 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) |
5187 | 5207 |
5188 #undef FIXED_TYPED_ARRAY_TRAITS | 5208 #undef FIXED_TYPED_ARRAY_TRAITS |
5189 | 5209 |
5190 | |
5191 // DeoptimizationInputData is a fixed array used to hold the deoptimization | 5210 // DeoptimizationInputData is a fixed array used to hold the deoptimization |
5192 // data for code generated by the Hydrogen/Lithium compiler. It also | 5211 // data for code generated by the Hydrogen/Lithium compiler. It also |
5193 // contains information about functions that were inlined. If N different | 5212 // contains information about functions that were inlined. If N different |
5194 // functions were inlined then first N elements of the literal array will | 5213 // functions were inlined then first N elements of the literal array will |
5195 // contain these functions. | 5214 // contain these functions. |
5196 // | 5215 // |
5197 // It can be empty. | 5216 // It can be empty. |
5198 class DeoptimizationInputData: public FixedArray { | 5217 class DeoptimizationInputData: public FixedArray { |
5199 public: | 5218 public: |
5200 // Layout description. Indices in the array. | 5219 // Layout description. Indices in the array. |
5201 static const int kTranslationByteArrayIndex = 0; | 5220 static const int kTranslationByteArrayIndex = 0; |
5202 static const int kInlinedFunctionCountIndex = 1; | 5221 static const int kInlinedFunctionCountIndex = 1; |
5203 static const int kLiteralArrayIndex = 2; | 5222 static const int kLiteralArrayIndex = 2; |
5204 static const int kOsrAstIdIndex = 3; | 5223 static const int kOsrAstIdIndex = 3; |
5205 static const int kOsrPcOffsetIndex = 4; | 5224 static const int kOsrPcOffsetIndex = 4; |
5206 static const int kOptimizationIdIndex = 5; | 5225 static const int kOptimizationIdIndex = 5; |
5207 static const int kSharedFunctionInfoIndex = 6; | 5226 static const int kSharedFunctionInfoIndex = 6; |
5208 static const int kWeakCellCacheIndex = 7; | 5227 static const int kWeakCellCacheIndex = 7; |
5209 static const int kFirstDeoptEntryIndex = 8; | 5228 static const int kInliningPositionsIndex = 8; |
| 5229 static const int kFirstDeoptEntryIndex = 9; |
5210 | 5230 |
5211 // Offsets of deopt entry elements relative to the start of the entry. | 5231 // Offsets of deopt entry elements relative to the start of the entry. |
5212 static const int kAstIdRawOffset = 0; | 5232 static const int kAstIdRawOffset = 0; |
5213 static const int kTranslationIndexOffset = 1; | 5233 static const int kTranslationIndexOffset = 1; |
5214 static const int kArgumentsStackHeightOffset = 2; | 5234 static const int kArgumentsStackHeightOffset = 2; |
5215 static const int kPcOffset = 3; | 5235 static const int kPcOffset = 3; |
5216 static const int kDeoptEntrySize = 4; | 5236 static const int kDeoptEntrySize = 4; |
5217 | 5237 |
5218 // Simple element accessors. | 5238 // Simple element accessors. |
5219 #define DECLARE_ELEMENT_ACCESSORS(name, type) \ | 5239 #define DECLARE_ELEMENT_ACCESSORS(name, type) \ |
5220 inline type* name(); \ | 5240 inline type* name(); \ |
5221 inline void Set##name(type* value); | 5241 inline void Set##name(type* value); |
5222 | 5242 |
5223 DECLARE_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray) | 5243 DECLARE_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray) |
5224 DECLARE_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi) | 5244 DECLARE_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi) |
5225 DECLARE_ELEMENT_ACCESSORS(LiteralArray, FixedArray) | 5245 DECLARE_ELEMENT_ACCESSORS(LiteralArray, FixedArray) |
5226 DECLARE_ELEMENT_ACCESSORS(OsrAstId, Smi) | 5246 DECLARE_ELEMENT_ACCESSORS(OsrAstId, Smi) |
5227 DECLARE_ELEMENT_ACCESSORS(OsrPcOffset, Smi) | 5247 DECLARE_ELEMENT_ACCESSORS(OsrPcOffset, Smi) |
5228 DECLARE_ELEMENT_ACCESSORS(OptimizationId, Smi) | 5248 DECLARE_ELEMENT_ACCESSORS(OptimizationId, Smi) |
5229 DECLARE_ELEMENT_ACCESSORS(SharedFunctionInfo, Object) | 5249 DECLARE_ELEMENT_ACCESSORS(SharedFunctionInfo, Object) |
5230 DECLARE_ELEMENT_ACCESSORS(WeakCellCache, Object) | 5250 DECLARE_ELEMENT_ACCESSORS(WeakCellCache, Object) |
| 5251 DECLARE_ELEMENT_ACCESSORS(InliningPositions, PodArray<InliningPosition>) |
5231 | 5252 |
5232 #undef DECLARE_ELEMENT_ACCESSORS | 5253 #undef DECLARE_ELEMENT_ACCESSORS |
5233 | 5254 |
5234 // Accessors for elements of the ith deoptimization entry. | 5255 // Accessors for elements of the ith deoptimization entry. |
5235 #define DECLARE_ENTRY_ACCESSORS(name, type) \ | 5256 #define DECLARE_ENTRY_ACCESSORS(name, type) \ |
5236 inline type* name(int i); \ | 5257 inline type* name(int i); \ |
5237 inline void Set##name(int i, type* value); | 5258 inline void Set##name(int i, type* value); |
5238 | 5259 |
5239 DECLARE_ENTRY_ACCESSORS(AstIdRaw, Smi) | 5260 DECLARE_ENTRY_ACCESSORS(AstIdRaw, Smi) |
5240 DECLARE_ENTRY_ACCESSORS(TranslationIndex, Smi) | 5261 DECLARE_ENTRY_ACCESSORS(TranslationIndex, Smi) |
(...skipping 21 matching lines...) Expand all Loading... |
5262 | 5283 |
5263 private: | 5284 private: |
5264 static int IndexForEntry(int i) { | 5285 static int IndexForEntry(int i) { |
5265 return kFirstDeoptEntryIndex + (i * kDeoptEntrySize); | 5286 return kFirstDeoptEntryIndex + (i * kDeoptEntrySize); |
5266 } | 5287 } |
5267 | 5288 |
5268 | 5289 |
5269 static int LengthFor(int entry_count) { return IndexForEntry(entry_count); } | 5290 static int LengthFor(int entry_count) { return IndexForEntry(entry_count); } |
5270 }; | 5291 }; |
5271 | 5292 |
5272 | |
5273 // DeoptimizationOutputData is a fixed array used to hold the deoptimization | 5293 // DeoptimizationOutputData is a fixed array used to hold the deoptimization |
5274 // data for code generated by the full compiler. | 5294 // data for code generated by the full compiler. |
5275 // The format of the these objects is | 5295 // The format of the these objects is |
5276 // [i * 2]: Ast ID for ith deoptimization. | 5296 // [i * 2]: Ast ID for ith deoptimization. |
5277 // [i * 2 + 1]: PC and state of ith deoptimization | 5297 // [i * 2 + 1]: PC and state of ith deoptimization |
5278 class DeoptimizationOutputData: public FixedArray { | 5298 class DeoptimizationOutputData: public FixedArray { |
5279 public: | 5299 public: |
5280 inline int DeoptPoints(); | 5300 inline int DeoptPoints(); |
5281 | 5301 |
5282 inline BailoutId AstId(int index); | 5302 inline BailoutId AstId(int index); |
(...skipping 6473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11756 } | 11776 } |
11757 return value; | 11777 return value; |
11758 } | 11778 } |
11759 }; | 11779 }; |
11760 | 11780 |
11761 | 11781 |
11762 } // NOLINT, false-positive due to second-order macros. | 11782 } // NOLINT, false-positive due to second-order macros. |
11763 } // NOLINT, false-positive due to second-order macros. | 11783 } // NOLINT, false-positive due to second-order macros. |
11764 | 11784 |
11765 #endif // V8_OBJECTS_H_ | 11785 #endif // V8_OBJECTS_H_ |
OLD | NEW |