14 #include "include/v8-internal.h" 15 #include "src/base/atomic-utils.h" 16 #include "src/base/build_config.h" 17 #include "src/base/flags.h" 18 #include "src/base/logging.h" 19 #include "src/base/macros.h" 21 #define V8_INFINITY std::numeric_limits<double>::infinity() 35 #if !defined(USE_SIMULATOR) 36 #if (V8_TARGET_ARCH_ARM64 && !V8_HOST_ARCH_ARM64) 37 #define USE_SIMULATOR 1 39 #if (V8_TARGET_ARCH_ARM && !V8_HOST_ARCH_ARM) 40 #define USE_SIMULATOR 1 42 #if (V8_TARGET_ARCH_PPC && !V8_HOST_ARCH_PPC) 43 #define USE_SIMULATOR 1 45 #if (V8_TARGET_ARCH_MIPS && !V8_HOST_ARCH_MIPS) 46 #define USE_SIMULATOR 1 48 #if (V8_TARGET_ARCH_MIPS64 && !V8_HOST_ARCH_MIPS64) 49 #define USE_SIMULATOR 1 51 #if (V8_TARGET_ARCH_S390 && !V8_HOST_ARCH_S390) 52 #define USE_SIMULATOR 1 58 #if V8_TARGET_ARCH_PPC 59 #define V8_EMBEDDED_CONSTANT_POOL true 61 #define V8_EMBEDDED_CONSTANT_POOL false 64 #ifdef V8_TARGET_ARCH_ARM 68 #define V8_DEFAULT_STACK_SIZE_KB 864 72 #define V8_DEFAULT_STACK_SIZE_KB 984 76 constexpr
int kStackSpaceRequiredForCompilation = 40;
79 #if V8_TARGET_ARCH_64_BIT 80 #define V8_DOUBLE_FIELDS_UNBOXING true 82 #define V8_DOUBLE_FIELDS_UNBOXING false 86 #if defined(V8_TRACE_MAPS) || defined(V8_TRACE_IGNITION) 87 #define V8_SFI_HAS_UNIQUE_ID true 104 constexpr
int KB = 1024;
105 constexpr
int MB = KB * KB;
106 constexpr
int GB = KB * KB * KB;
107 constexpr
int kMaxInt = 0x7FFFFFFF;
108 constexpr
int kMinInt = -kMaxInt - 1;
109 constexpr
int kMaxInt8 = (1 << 7) - 1;
110 constexpr
int kMinInt8 = -(1 << 7);
111 constexpr
int kMaxUInt8 = (1 << 8) - 1;
112 constexpr
int kMinUInt8 = 0;
113 constexpr
int kMaxInt16 = (1 << 15) - 1;
114 constexpr
int kMinInt16 = -(1 << 15);
115 constexpr
int kMaxUInt16 = (1 << 16) - 1;
116 constexpr
int kMinUInt16 = 0;
118 constexpr
uint32_t kMaxUInt32 = 0xFFFFFFFFu;
119 constexpr
int kMinUInt32 = 0;
121 constexpr
int kUInt8Size =
sizeof(uint8_t);
122 constexpr
int kCharSize =
sizeof(
char);
123 constexpr
int kShortSize =
sizeof(short);
124 constexpr
int kUInt16Size =
sizeof(uint16_t);
125 constexpr
int kIntSize =
sizeof(
int);
126 constexpr
int kInt32Size =
sizeof(int32_t);
127 constexpr
int kInt64Size =
sizeof(
int64_t);
128 constexpr
int kUInt32Size =
sizeof(
uint32_t);
129 constexpr
int kSizetSize =
sizeof(
size_t);
130 constexpr
int kFloatSize =
sizeof(float);
131 constexpr
int kDoubleSize =
sizeof(double);
132 constexpr
int kIntptrSize =
sizeof(intptr_t);
133 constexpr
int kUIntptrSize =
sizeof(
uintptr_t);
134 constexpr
int kSystemPointerSize =
sizeof(
void*);
135 constexpr
int kSystemPointerHexDigits = kSystemPointerSize == 4 ? 8 : 12;
136 #if V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT 137 constexpr
int kRegisterSize = kSystemPointerSize + kSystemPointerSize;
139 constexpr
int kRegisterSize = kSystemPointerSize;
141 constexpr
int kPCOnStackSize = kRegisterSize;
142 constexpr
int kFPOnStackSize = kRegisterSize;
144 #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32 145 constexpr
int kElidedFrameSlots = kPCOnStackSize / kSystemPointerSize;
147 constexpr
int kElidedFrameSlots = 0;
150 constexpr
int kDoubleSizeLog2 = 3;
151 #if V8_TARGET_ARCH_ARM64 153 constexpr
size_t kMaxWasmCodeMemory = 128 * MB;
155 constexpr
size_t kMaxWasmCodeMemory = 1024 * MB;
158 #if V8_HOST_ARCH_64_BIT 159 constexpr
int kSystemPointerSizeLog2 = 3;
160 constexpr intptr_t kIntptrSignBit =
161 static_cast<intptr_t
>(
uintptr_t{0x8000000000000000});
163 constexpr
bool kRequiresCodeRange =
true;
164 #if V8_HOST_ARCH_PPC && V8_TARGET_ARCH_PPC && V8_OS_LINUX 165 constexpr
size_t kMaximalCodeRangeSize = 512 * MB;
166 constexpr
size_t kMinExpectedOSPageSize = 64 * KB;
167 #elif V8_TARGET_ARCH_ARM64 168 constexpr
size_t kMaximalCodeRangeSize = 128 * MB;
169 constexpr
size_t kMinExpectedOSPageSize = 4 * KB;
171 constexpr
size_t kMaximalCodeRangeSize = 128 * MB;
172 constexpr
size_t kMinExpectedOSPageSize = 4 * KB;
175 constexpr
size_t kMinimumCodeRangeSize = 4 * MB;
176 constexpr
size_t kReservedCodeRangePages = 1;
178 constexpr
size_t kMinimumCodeRangeSize = 3 * MB;
179 constexpr
size_t kReservedCodeRangePages = 0;
182 constexpr
int kSystemPointerSizeLog2 = 2;
183 constexpr intptr_t kIntptrSignBit = 0x80000000;
184 constexpr
uintptr_t kUintptrAllBitsSet = 0xFFFFFFFFu;
185 #if V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT 187 constexpr
bool kRequiresCodeRange =
true;
188 constexpr
size_t kMaximalCodeRangeSize = 256 * MB;
189 constexpr
size_t kMinimumCodeRangeSize = 3 * MB;
190 constexpr
size_t kMinExpectedOSPageSize = 4 * KB;
191 #elif V8_HOST_ARCH_PPC && V8_TARGET_ARCH_PPC && V8_OS_LINUX 192 constexpr
bool kRequiresCodeRange =
false;
193 constexpr
size_t kMaximalCodeRangeSize = 0 * MB;
194 constexpr
size_t kMinimumCodeRangeSize = 0 * MB;
195 constexpr
size_t kMinExpectedOSPageSize = 64 * KB;
197 constexpr
bool kRequiresCodeRange =
false;
198 constexpr
size_t kMaximalCodeRangeSize = 0 * MB;
199 constexpr
size_t kMinimumCodeRangeSize = 0 * MB;
200 constexpr
size_t kMinExpectedOSPageSize = 4 * KB;
202 constexpr
size_t kReservedCodeRangePages = 0;
205 STATIC_ASSERT(kSystemPointerSize == (1 << kSystemPointerSizeLog2));
207 constexpr
int kTaggedSize = kSystemPointerSize;
208 constexpr
int kTaggedSizeLog2 = kSystemPointerSizeLog2;
209 STATIC_ASSERT(kTaggedSize == (1 << kTaggedSizeLog2));
213 using Tagged_t = Address;
214 using AtomicTagged_t = base::AtomicWord;
215 using AsAtomicTagged = base::AsAtomicPointerImpl<AtomicTagged_t>;
216 STATIC_ASSERT(
sizeof(Tagged_t) == kTaggedSize);
217 STATIC_ASSERT(
sizeof(AtomicTagged_t) == kTaggedSize);
220 constexpr
int kPointerSize = kSystemPointerSize;
221 constexpr
int kPointerSizeLog2 = kSystemPointerSizeLog2;
222 STATIC_ASSERT(kPointerSize == (1 << kPointerSizeLog2));
224 constexpr
int kEmbedderDataSlotSize =
225 #ifdef V8_COMPRESS_POINTERS 230 constexpr
int kEmbedderDataSlotSizeInTaggedSlots =
231 kEmbedderDataSlotSize / kTaggedSize;
232 STATIC_ASSERT(kEmbedderDataSlotSize >= kSystemPointerSize);
234 constexpr
int kExternalAllocationSoftLimit =
235 internal::Internals::kExternalAllocationSoftLimit;
244 constexpr
int kMaxRegularHeapObjectSize = 507136;
246 constexpr
int kBitsPerByte = 8;
247 constexpr
int kBitsPerByteLog2 = 3;
248 constexpr
int kBitsPerSystemPointer = kSystemPointerSize * kBitsPerByte;
249 constexpr
int kBitsPerInt = kIntSize * kBitsPerByte;
252 constexpr
uint32_t kBinary32SignMask = 0x80000000u;
253 constexpr
uint32_t kBinary32ExponentMask = 0x7f800000u;
254 constexpr
uint32_t kBinary32MantissaMask = 0x007fffffu;
255 constexpr
int kBinary32ExponentBias = 127;
256 constexpr
int kBinary32MaxExponent = 0xFE;
257 constexpr
int kBinary32MinExponent = 0x01;
258 constexpr
int kBinary32MantissaBits = 23;
259 constexpr
int kBinary32ExponentShift = 23;
263 constexpr uint64_t kQuietNaNMask =
static_cast<uint64_t
>(0xfff) << 51;
268 typedef uint16_t uc16;
269 typedef int32_t uc32;
270 constexpr
int kOneByteSize = kCharSize;
271 constexpr
int kUC16Size =
sizeof(uc16);
274 constexpr
int kSimd128Size = 16;
277 #define FUNCTION_ADDR(f) (reinterpret_cast<v8::internal::Address>(f)) 281 template <
typename F>
282 F FUNCTION_CAST(byte* addr) {
283 return reinterpret_cast<F
>(
reinterpret_cast<Address
>(addr));
286 template <
typename F>
287 F FUNCTION_CAST(Address addr) {
288 return reinterpret_cast<F
>(addr);
295 #if V8_HOST_ARCH_PPC && \ 296 (V8_OS_AIX || (V8_TARGET_ARCH_PPC64 && V8_TARGET_BIG_ENDIAN)) 297 #define USES_FUNCTION_DESCRIPTORS 1 298 #define FUNCTION_ENTRYPOINT_ADDRESS(f) \ 299 (reinterpret_cast<v8::internal::Address*>( \ 300 &(reinterpret_cast<intptr_t*>(f)[0]))) 302 #define USES_FUNCTION_DESCRIPTORS 0 311 enum class LanguageMode :
bool { kSloppy, kStrict };
312 static const size_t LanguageModeSize = 2;
314 inline size_t hash_value(LanguageMode mode) {
315 return static_cast<size_t>(mode);
318 inline std::ostream& operator<<(std::ostream& os,
const LanguageMode& mode) {
320 case LanguageMode::kSloppy:
321 return os <<
"sloppy";
322 case LanguageMode::kStrict:
323 return os <<
"strict";
328 inline bool is_sloppy(LanguageMode language_mode) {
329 return language_mode == LanguageMode::kSloppy;
332 inline bool is_strict(LanguageMode language_mode) {
333 return language_mode != LanguageMode::kSloppy;
336 inline bool is_valid_language_mode(
int language_mode) {
337 return language_mode ==
static_cast<int>(LanguageMode::kSloppy) ||
338 language_mode == static_cast<int>(LanguageMode::kStrict);
341 inline LanguageMode construct_language_mode(
bool strict_bit) {
342 return static_cast<LanguageMode
>(strict_bit);
347 inline LanguageMode stricter_language_mode(LanguageMode mode1,
348 LanguageMode mode2) {
349 STATIC_ASSERT(LanguageModeSize == 2);
350 return static_cast<LanguageMode
>(
static_cast<int>(mode1) |
351 static_cast<int>(mode2));
356 enum class StoreOrigin { kMaybeKeyed, kNamed };
358 enum TypeofMode :
int { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
361 enum SaveFPRegsMode { kDontSaveFPRegs, kSaveFPRegs };
362 enum ArgvMode { kArgvOnStack, kArgvInRegister };
365 constexpr
int kNoSourcePosition = -1;
368 constexpr
int kNoDeoptimizationId = -1;
378 enum class DeoptimizeKind : uint8_t {
382 kLastDeoptimizeKind = kLazy
384 inline size_t hash_value(DeoptimizeKind kind) {
385 return static_cast<size_t>(kind);
387 inline std::ostream& operator<<(std::ostream& os, DeoptimizeKind kind) {
389 case DeoptimizeKind::kEager:
390 return os <<
"Eager";
391 case DeoptimizeKind::kSoft:
393 case DeoptimizeKind::kLazy:
399 enum class IsolateAllocationMode {
406 #ifdef V8_COMPRESS_POINTERS 407 kDefault = kInV8Heap,
409 kDefault = kInCppHeap,
415 enum class LookupHoistingMode {
kNormal, kLegacySloppy };
417 inline std::ostream& operator<<(std::ostream& os,
418 const LookupHoistingMode& mode) {
420 case LookupHoistingMode::kNormal:
421 return os <<
"normal hoisting";
422 case LookupHoistingMode::kLegacySloppy:
423 return os <<
"legacy sloppy hoisting";
428 static_assert(kSmiValueSize <= 32,
"Unsupported Smi tagging scheme");
431 static_assert((kSmiValueSize + kSmiShiftSize + kSmiTagSize) % 32 == 0,
432 "Unsupported Smi tagging scheme");
434 constexpr
bool kIsSmiValueInUpper32Bits =
435 (kSmiValueSize + kSmiShiftSize + kSmiTagSize) == 64;
436 constexpr
bool kIsSmiValueInLower32Bits =
437 (kSmiValueSize + kSmiShiftSize + kSmiTagSize) == 32;
438 static_assert(!SmiValuesAre32Bits() == SmiValuesAre31Bits(),
439 "Unsupported Smi tagging scheme");
440 static_assert(SmiValuesAre32Bits() == kIsSmiValueInUpper32Bits,
441 "Unsupported Smi tagging scheme");
442 static_assert(SmiValuesAre31Bits() == kIsSmiValueInLower32Bits,
443 "Unsupported Smi tagging scheme");
446 constexpr intptr_t kSmiSignMask =
static_cast<intptr_t
>(
447 uintptr_t{1} << (kSmiValueSize + kSmiShiftSize + kSmiTagSize - 1));
450 constexpr
int kObjectAlignmentBits = kTaggedSizeLog2;
451 constexpr intptr_t kObjectAlignment = 1 << kObjectAlignmentBits;
452 constexpr intptr_t kObjectAlignmentMask = kObjectAlignment - 1;
455 constexpr intptr_t kPointerAlignment = (1 << kSystemPointerSizeLog2);
456 constexpr intptr_t kPointerAlignmentMask = kPointerAlignment - 1;
459 constexpr intptr_t kDoubleAlignment = 8;
460 constexpr intptr_t kDoubleAlignmentMask = kDoubleAlignment - 1;
464 constexpr
int kCodeAlignmentBits = 5;
465 constexpr intptr_t kCodeAlignment = 1 << kCodeAlignmentBits;
466 constexpr intptr_t kCodeAlignmentMask = kCodeAlignment - 1;
468 const Address kWeakHeapObjectMask = 1 << 1;
482 const uint32_t kClearedWeakHeapObjectLower32 = 3;
486 #ifdef V8_HOST_ARCH_64_BIT 487 constexpr uint64_t kClearedFreeMemoryValue = 0;
488 constexpr uint64_t kZapValue = uint64_t{0xdeadbeedbeadbeef};
489 constexpr uint64_t kHandleZapValue = uint64_t{0x1baddead0baddeaf};
490 constexpr uint64_t kGlobalHandleZapValue = uint64_t{0x1baffed00baffedf};
491 constexpr uint64_t kFromSpaceZapValue = uint64_t{0x1beefdad0beefdaf};
492 constexpr uint64_t kDebugZapValue = uint64_t{0xbadbaddbbadbaddb};
493 constexpr uint64_t kSlotsZapValue = uint64_t{0xbeefdeadbeefdeef};
494 constexpr uint64_t kFreeListZapValue = 0xfeed1eaffeed1eaf;
496 constexpr
uint32_t kClearedFreeMemoryValue = 0;
497 constexpr
uint32_t kZapValue = 0xdeadbeef;
498 constexpr
uint32_t kHandleZapValue = 0xbaddeaf;
499 constexpr
uint32_t kGlobalHandleZapValue = 0xbaffedf;
500 constexpr
uint32_t kFromSpaceZapValue = 0xbeefdaf;
501 constexpr
uint32_t kSlotsZapValue = 0xbeefdeef;
502 constexpr
uint32_t kDebugZapValue = 0xbadbaddb;
503 constexpr
uint32_t kFreeListZapValue = 0xfeed1eaf;
506 constexpr
int kCodeZapValue = 0xbadc0de;
507 constexpr
uint32_t kPhantomReferenceZap = 0xca11bac;
510 static const intptr_t kPageAlignmentMask = (intptr_t{1} << kPageSizeBits) - 1;
515 #define PROCESSOR_CACHE_LINE_SIZE 64 519 constexpr
uint32_t kQuietNaNHighBitsMask = 0xfff << (51 - 32);
531 class DeclarationScope;
535 class DescriptorArray;
536 class TransitionArray;
537 class ExternalReference;
538 class FeedbackVector;
541 class FreeStoreAllocationPolicy;
542 class FunctionTemplateInfo;
543 class GlobalDictionary;
544 template <
typename T>
class Handle;
547 class HeapObjectReference;
549 class InterceptorInfo;
555 class LargeObjectSpace;
556 class MacroAssembler;
559 class MarkCompactCollector;
560 template <
typename T>
582 template <
typename Config,
class Allocator = FreeStoreAllocationPolicy>
598 enum AllocationSpace {
610 FIRST_SPACE = RO_SPACE,
611 LAST_SPACE = NEW_LO_SPACE,
612 FIRST_GROWABLE_PAGED_SPACE = OLD_SPACE,
613 LAST_GROWABLE_PAGED_SPACE = MAP_SPACE
615 constexpr
int kSpaceTagSize = 4;
616 STATIC_ASSERT(FIRST_SPACE == 0);
618 enum AllocationAlignment { kWordAligned, kDoubleAligned, kDoubleUnaligned };
620 enum class AccessMode { ATOMIC, NON_ATOMIC };
623 enum WriteBarrierKind : uint8_t {
626 kPointerWriteBarrier,
630 inline size_t hash_value(WriteBarrierKind kind) {
631 return static_cast<uint8_t
>(kind);
634 inline std::ostream& operator<<(std::ostream& os, WriteBarrierKind kind) {
636 case kNoWriteBarrier:
637 return os <<
"NoWriteBarrier";
638 case kMapWriteBarrier:
639 return os <<
"MapWriteBarrier";
640 case kPointerWriteBarrier:
641 return os <<
"PointerWriteBarrier";
642 case kFullWriteBarrier:
643 return os <<
"FullWriteBarrier";
652 enum PretenureFlag { NOT_TENURED, TENURED, TENURED_READ_ONLY };
654 inline std::ostream& operator<<(std::ostream& os,
const PretenureFlag& flag) {
657 return os <<
"NotTenured";
659 return os <<
"Tenured";
660 case TENURED_READ_ONLY:
661 return os <<
"TenuredReadOnly";
666 enum MinimumCapacity {
667 USE_DEFAULT_MINIMUM_CAPACITY,
668 USE_CUSTOM_MINIMUM_CAPACITY
671 enum GarbageCollector { SCAVENGER, MARK_COMPACTOR, MINOR_MARK_COMPACTOR };
673 enum Executability { NOT_EXECUTABLE, EXECUTABLE };
675 enum Movability { kMovable, kImmovable };
679 VISIT_ALL_IN_MINOR_MC_MARK,
680 VISIT_ALL_IN_MINOR_MC_UPDATE,
681 VISIT_ALL_IN_SCAVENGE,
682 VISIT_ALL_IN_SWEEP_NEWSPACE,
684 VISIT_FOR_SERIALIZATION,
697 enum ParseRestriction {
698 NO_PARSE_RESTRICTION,
699 ONLY_SINGLE_FUNCTION_LITERAL
723 int constant_pool_size;
724 byte* unwinding_info;
725 int unwinding_info_size;
730 enum InlineCacheState {
748 inline const char* InlineCacheState2String(InlineCacheState state) {
751 return "UNINITIALIZED";
753 return "PREMONOMORPHIC";
755 return "MONOMORPHIC";
756 case RECOMPUTE_HANDLER:
757 return "RECOMPUTE_HANDLER";
759 return "POLYMORPHIC";
761 return "MEGAMORPHIC";
768 enum WhereToStart { kStartAtReceiver, kStartAtPrototype };
770 enum ResultSentinel { kNotFound = -1, kUnsupported = -2 };
772 enum ShouldThrow { kThrowOnError, kDontThrow };
776 kStoreBufferFullEvent,
777 kStoreBufferStartScanningPagesEvent,
778 kStoreBufferScanningPageEvent
782 typedef void (*StoreBufferCallback)(Heap* heap,
784 StoreBufferEvent event);
792 unsigned int man_low :32;
793 unsigned int man_high :20;
794 unsigned int exp :11;
795 unsigned int sign :1;
803 unsigned int sign :1;
804 unsigned int exp :11;
805 unsigned int man_high :20;
806 unsigned int man_low :32;
810 #if V8_TARGET_LITTLE_ENDIAN 812 constexpr
int kIeeeDoubleMantissaWordOffset = 0;
813 constexpr
int kIeeeDoubleExponentWordOffset = 4;
816 constexpr
int kIeeeDoubleMantissaWordOffset = 4;
817 constexpr
int kIeeeDoubleExponentWordOffset = 0;
825 #define HAS_SMI_TAG(value) \ 826 ((static_cast<intptr_t>(value) & ::i::kSmiTagMask) == ::i::kSmiTag) 828 #define HAS_HEAP_OBJECT_TAG(value) \ 829 (((static_cast<intptr_t>(value) & ::i::kHeapObjectTagMask) == \ 830 ::i::kHeapObjectTag)) 833 #define OBJECT_POINTER_ALIGN(value) \ 834 (((value) + kObjectAlignmentMask) & ~kObjectAlignmentMask) 838 #define OBJECT_POINTER_PADDING(value) (OBJECT_POINTER_ALIGN(value) - (value)) 841 #define POINTER_SIZE_ALIGN(value) \ 842 (((value) + kPointerAlignmentMask) & ~kPointerAlignmentMask) 846 #define POINTER_SIZE_PADDING(value) (POINTER_SIZE_ALIGN(value) - (value)) 849 #define CODE_POINTER_ALIGN(value) \ 850 (((value) + kCodeAlignmentMask) & ~kCodeAlignmentMask) 854 #define CODE_POINTER_PADDING(value) (CODE_POINTER_ALIGN(value) - (value)) 857 #define DOUBLE_POINTER_ALIGN(value) \ 858 (((value) + kDoubleAlignmentMask) & ~kDoubleAlignmentMask) 900 NUMBER_OF_CPU_FEATURES,
910 enum class ConvertReceiverMode :
unsigned {
916 inline size_t hash_value(ConvertReceiverMode mode) {
917 return bit_cast<
unsigned>(mode);
920 inline std::ostream& operator<<(std::ostream& os, ConvertReceiverMode mode) {
922 case ConvertReceiverMode::kNullOrUndefined:
923 return os <<
"NULL_OR_UNDEFINED";
924 case ConvertReceiverMode::kNotNullOrUndefined:
925 return os <<
"NOT_NULL_OR_UNDEFINED";
926 case ConvertReceiverMode::kAny:
934 enum class OrdinaryToPrimitiveHint { kNumber, kString };
938 enum class ToPrimitiveHint { kDefault, kNumber, kString };
941 enum class CreateArgumentsType : uint8_t {
947 inline size_t hash_value(CreateArgumentsType type) {
948 return bit_cast<uint8_t>(type);
951 inline std::ostream& operator<<(std::ostream& os, CreateArgumentsType type) {
953 case CreateArgumentsType::kMappedArguments:
954 return os <<
"MAPPED_ARGUMENTS";
955 case CreateArgumentsType::kUnmappedArguments:
956 return os <<
"UNMAPPED_ARGUMENTS";
957 case CreateArgumentsType::kRestParameter:
958 return os <<
"REST_PARAMETER";
963 enum ScopeType : uint8_t {
973 inline std::ostream& operator<<(std::ostream& os, ScopeType type) {
975 case ScopeType::EVAL_SCOPE:
976 return os <<
"EVAL_SCOPE";
977 case ScopeType::FUNCTION_SCOPE:
978 return os <<
"FUNCTION_SCOPE";
979 case ScopeType::MODULE_SCOPE:
980 return os <<
"MODULE_SCOPE";
981 case ScopeType::SCRIPT_SCOPE:
982 return os <<
"SCRIPT_SCOPE";
983 case ScopeType::CATCH_SCOPE:
984 return os <<
"CATCH_SCOPE";
985 case ScopeType::BLOCK_SCOPE:
986 return os <<
"BLOCK_SCOPE";
987 case ScopeType::WITH_SCOPE:
988 return os <<
"WITH_SCOPE";
995 enum AllocationSiteMode {
996 DONT_TRACK_ALLOCATION_SITE,
997 TRACK_ALLOCATION_SITE,
998 LAST_ALLOCATION_SITE_MODE = TRACK_ALLOCATION_SITE
1001 enum class AllocationSiteUpdateMode { kUpdate, kCheckOnly };
1004 #if (V8_TARGET_ARCH_MIPS && !defined(_MIPS_ARCH_MIPS32R6) && \ 1005 (!defined(USE_SIMULATOR) || !defined(_MIPS_TARGET_SIMULATOR))) || \ 1006 (V8_TARGET_ARCH_MIPS64 && !defined(_MIPS_ARCH_MIPS64R6) && \ 1007 (!defined(USE_SIMULATOR) || !defined(_MIPS_TARGET_SIMULATOR))) 1008 constexpr
uint32_t kHoleNanUpper32 = 0xFFFF7FFF;
1009 constexpr
uint32_t kHoleNanLower32 = 0xFFFF7FFF;
1011 constexpr
uint32_t kHoleNanUpper32 = 0xFFF7FFFF;
1012 constexpr
uint32_t kHoleNanLower32 = 0xFFF7FFFF;
1015 constexpr uint64_t kHoleNanInt64 =
1016 (
static_cast<uint64_t
>(kHoleNanUpper32) << 32) | kHoleNanLower32;
1019 constexpr
double kMaxSafeInteger = 9007199254740991.0;
1022 enum class VariableMode : uint8_t {
1049 inline const char* VariableMode2String(VariableMode mode) {
1051 case VariableMode::kVar:
1053 case VariableMode::kLet:
1055 case VariableMode::kConst:
1057 case VariableMode::kDynamic:
1059 case VariableMode::kDynamicGlobal:
1060 return "DYNAMIC_GLOBAL";
1061 case VariableMode::kDynamicLocal:
1062 return "DYNAMIC_LOCAL";
1063 case VariableMode::kTemporary:
1070 enum VariableKind : uint8_t {
1073 SLOPPY_FUNCTION_NAME_VARIABLE
1076 inline bool IsDynamicVariableMode(VariableMode mode) {
1077 return mode >= VariableMode::kDynamic && mode <= VariableMode::kDynamicLocal;
1080 inline bool IsDeclaredVariableMode(VariableMode mode) {
1081 STATIC_ASSERT(static_cast<uint8_t>(VariableMode::kLet) ==
1083 return mode <= VariableMode::kVar;
1086 inline bool IsLexicalVariableMode(VariableMode mode) {
1087 STATIC_ASSERT(static_cast<uint8_t>(VariableMode::kLet) ==
1089 return mode <= VariableMode::kConst;
1092 enum VariableLocation : uint8_t {
1121 kLastVariableLocation = MODULE
1146 enum InitializationFlag : uint8_t { kNeedsInitialization, kCreatedInitialized };
1148 enum MaybeAssignedFlag : uint8_t { kNotAssigned, kMaybeAssigned };
1150 enum ParseErrorType { kSyntaxError = 0, kReferenceError = 1 };
1152 enum FunctionKind : uint8_t {
1157 kDerivedConstructor,
1163 kClassMembersInitializerFunction,
1165 kDefaultBaseConstructor,
1166 kDefaultDerivedConstructor,
1167 kAsyncArrowFunction,
1168 kAsyncConciseMethod,
1170 kConciseGeneratorMethod,
1171 kAsyncConciseGeneratorMethod,
1172 kAsyncGeneratorFunction,
1173 kLastFunctionKind = kAsyncGeneratorFunction,
1176 inline bool IsArrowFunction(FunctionKind kind) {
1177 return kind == FunctionKind::kArrowFunction ||
1178 kind == FunctionKind::kAsyncArrowFunction;
1181 inline bool IsModule(FunctionKind kind) {
1182 return kind == FunctionKind::kModule;
1185 inline bool IsAsyncGeneratorFunction(FunctionKind kind) {
1186 return kind == FunctionKind::kAsyncGeneratorFunction ||
1187 kind == FunctionKind::kAsyncConciseGeneratorMethod;
1190 inline bool IsGeneratorFunction(FunctionKind kind) {
1191 return kind == FunctionKind::kGeneratorFunction ||
1192 kind == FunctionKind::kConciseGeneratorMethod ||
1193 IsAsyncGeneratorFunction(kind);
1196 inline bool IsAsyncFunction(FunctionKind kind) {
1197 return kind == FunctionKind::kAsyncFunction ||
1198 kind == FunctionKind::kAsyncArrowFunction ||
1199 kind == FunctionKind::kAsyncConciseMethod ||
1200 IsAsyncGeneratorFunction(kind);
1203 inline bool IsResumableFunction(FunctionKind kind) {
1204 return IsGeneratorFunction(kind) || IsAsyncFunction(kind) || IsModule(kind);
1207 inline bool IsConciseMethod(FunctionKind kind) {
1208 return kind == FunctionKind::kConciseMethod ||
1209 kind == FunctionKind::kConciseGeneratorMethod ||
1210 kind == FunctionKind::kAsyncConciseMethod ||
1211 kind == FunctionKind::kAsyncConciseGeneratorMethod ||
1212 kind == FunctionKind::kClassMembersInitializerFunction;
1215 inline bool IsGetterFunction(FunctionKind kind) {
1216 return kind == FunctionKind::kGetterFunction;
1219 inline bool IsSetterFunction(FunctionKind kind) {
1220 return kind == FunctionKind::kSetterFunction;
1223 inline bool IsAccessorFunction(FunctionKind kind) {
1224 return kind == FunctionKind::kGetterFunction ||
1225 kind == FunctionKind::kSetterFunction;
1228 inline bool IsDefaultConstructor(FunctionKind kind) {
1229 return kind == FunctionKind::kDefaultBaseConstructor ||
1230 kind == FunctionKind::kDefaultDerivedConstructor;
1233 inline bool IsBaseConstructor(FunctionKind kind) {
1234 return kind == FunctionKind::kBaseConstructor ||
1235 kind == FunctionKind::kDefaultBaseConstructor;
1238 inline bool IsDerivedConstructor(FunctionKind kind) {
1239 return kind == FunctionKind::kDerivedConstructor ||
1240 kind == FunctionKind::kDefaultDerivedConstructor;
1244 inline bool IsClassConstructor(FunctionKind kind) {
1245 return IsBaseConstructor(kind) || IsDerivedConstructor(kind);
1248 inline bool IsClassMembersInitializerFunction(FunctionKind kind) {
1249 return kind == FunctionKind::kClassMembersInitializerFunction;
1252 inline bool IsConstructable(FunctionKind kind) {
1253 if (IsAccessorFunction(kind))
return false;
1254 if (IsConciseMethod(kind))
return false;
1255 if (IsArrowFunction(kind))
return false;
1256 if (IsGeneratorFunction(kind))
return false;
1257 if (IsAsyncFunction(kind))
return false;
1261 inline std::ostream& operator<<(std::ostream& os, FunctionKind kind) {
1263 case FunctionKind::kNormalFunction:
1264 return os <<
"NormalFunction";
1265 case FunctionKind::kArrowFunction:
1266 return os <<
"ArrowFunction";
1267 case FunctionKind::kGeneratorFunction:
1268 return os <<
"GeneratorFunction";
1269 case FunctionKind::kConciseMethod:
1270 return os <<
"ConciseMethod";
1271 case FunctionKind::kDerivedConstructor:
1272 return os <<
"DerivedConstructor";
1273 case FunctionKind::kBaseConstructor:
1274 return os <<
"BaseConstructor";
1275 case FunctionKind::kGetterFunction:
1276 return os <<
"GetterFunction";
1277 case FunctionKind::kSetterFunction:
1278 return os <<
"SetterFunction";
1279 case FunctionKind::kAsyncFunction:
1280 return os <<
"AsyncFunction";
1281 case FunctionKind::kModule:
1282 return os <<
"Module";
1283 case FunctionKind::kClassMembersInitializerFunction:
1284 return os <<
"ClassMembersInitializerFunction";
1285 case FunctionKind::kDefaultBaseConstructor:
1286 return os <<
"DefaultBaseConstructor";
1287 case FunctionKind::kDefaultDerivedConstructor:
1288 return os <<
"DefaultDerivedConstructor";
1289 case FunctionKind::kAsyncArrowFunction:
1290 return os <<
"AsyncArrowFunction";
1291 case FunctionKind::kAsyncConciseMethod:
1292 return os <<
"AsyncConciseMethod";
1293 case FunctionKind::kConciseGeneratorMethod:
1294 return os <<
"ConciseGeneratorMethod";
1295 case FunctionKind::kAsyncConciseGeneratorMethod:
1296 return os <<
"AsyncConciseGeneratorMethod";
1297 case FunctionKind::kAsyncGeneratorFunction:
1298 return os <<
"AsyncGeneratorFunction";
1303 enum class InterpreterPushArgsMode :
unsigned {
1309 inline size_t hash_value(InterpreterPushArgsMode mode) {
1310 return bit_cast<
unsigned>(mode);
1313 inline std::ostream& operator<<(std::ostream& os,
1314 InterpreterPushArgsMode mode) {
1316 case InterpreterPushArgsMode::kArrayFunction:
1317 return os <<
"ArrayFunction";
1318 case InterpreterPushArgsMode::kWithFinalSpread:
1319 return os <<
"WithFinalSpread";
1320 case InterpreterPushArgsMode::kOther:
1321 return os <<
"Other";
1326 inline uint32_t ObjectHash(Address address) {
1329 return static_cast<uint32_t>(address >> kTaggedSizeLog2);
1351 kSignedSmallInputs = 0x3,
1353 kNumberOrOddball = 0xF,
1376 kSignedSmall = 0x001,
1378 kNumberOrOddball = 0x007,
1379 kInternalizedString = 0x008,
1384 kReceiverOrNullOrUndefined = 0x180,
1389 enum class Operation {
1414 kGreaterThanOrEqual,
1425 kEnumCacheKeysAndIndices = 0x1,
1426 kEnumCacheKeys = 0x3,
1430 STATIC_ASSERT((ForInFeedback::kNone |
1431 ForInFeedback::kEnumCacheKeysAndIndices) ==
1432 ForInFeedback::kEnumCacheKeysAndIndices);
1433 STATIC_ASSERT((ForInFeedback::kEnumCacheKeysAndIndices |
1434 ForInFeedback::kEnumCacheKeys) == ForInFeedback::kEnumCacheKeys);
1435 STATIC_ASSERT((ForInFeedback::kEnumCacheKeys | ForInFeedback::kAny) ==
1436 ForInFeedback::kAny);
1438 enum class UnicodeEncoding : uint8_t {
1444 inline size_t hash_value(UnicodeEncoding encoding) {
1445 return static_cast<uint8_t
>(encoding);
1448 inline std::ostream& operator<<(std::ostream& os, UnicodeEncoding encoding) {
1450 case UnicodeEncoding::UTF16:
1451 return os <<
"UTF16";
1452 case UnicodeEncoding::UTF32:
1453 return os <<
"UTF32";
1458 enum class IterationKind { kKeys, kValues, kEntries };
1460 inline std::ostream& operator<<(std::ostream& os, IterationKind kind) {
1462 case IterationKind::kKeys:
1463 return os <<
"IterationKind::kKeys";
1464 case IterationKind::kValues:
1465 return os <<
"IterationKind::kValues";
1466 case IterationKind::kEntries:
1467 return os <<
"IterationKind::kEntries";
1472 enum class CollectionKind { kMap, kSet };
1474 inline std::ostream& operator<<(std::ostream& os, CollectionKind kind) {
1476 case CollectionKind::kMap:
1477 return os <<
"CollectionKind::kMap";
1478 case CollectionKind::kSet:
1479 return os <<
"CollectionKind::kSet";
1487 enum class DataPropertyInLiteralFlag {
1490 kSetFunctionName = 1 << 1
1492 typedef base::Flags<DataPropertyInLiteralFlag> DataPropertyInLiteralFlags;
1493 DEFINE_OPERATORS_FOR_FLAGS(DataPropertyInLiteralFlags)
1495 enum ExternalArrayType {
1496 kExternalInt8Array = 1,
1497 kExternalUint8Array,
1498 kExternalInt16Array,
1499 kExternalUint16Array,
1500 kExternalInt32Array,
1501 kExternalUint32Array,
1502 kExternalFloat32Array,
1503 kExternalFloat64Array,
1504 kExternalUint8ClampedArray,
1505 kExternalBigInt64Array,
1506 kExternalBigUint64Array,
1511 : name(name), file(file), line(line) {}
1517 inline std::ostream& operator<<(std::ostream& os,
1519 os <<
"(" << info.name <<
":" << info.file <<
":" << info.line <<
")";
1523 enum class OptimizationMarker {
1527 kCompileOptimizedConcurrent,
1528 kInOptimizationQueue
1531 inline std::ostream& operator<<(std::ostream& os,
1532 const OptimizationMarker& marker) {
1534 case OptimizationMarker::kLogFirstExecution:
1535 return os <<
"OptimizationMarker::kLogFirstExecution";
1536 case OptimizationMarker::kNone:
1537 return os <<
"OptimizationMarker::kNone";
1538 case OptimizationMarker::kCompileOptimized:
1539 return os <<
"OptimizationMarker::kCompileOptimized";
1540 case OptimizationMarker::kCompileOptimizedConcurrent:
1541 return os <<
"OptimizationMarker::kCompileOptimizedConcurrent";
1542 case OptimizationMarker::kInOptimizationQueue:
1543 return os <<
"OptimizationMarker::kInOptimizationQueue";
1549 enum class SpeculationMode { kAllowSpeculation, kDisallowSpeculation };
1551 inline std::ostream& operator<<(std::ostream& os,
1552 SpeculationMode speculation_mode) {
1553 switch (speculation_mode) {
1554 case SpeculationMode::kAllowSpeculation:
1555 return os <<
"SpeculationMode::kAllowSpeculation";
1556 case SpeculationMode::kDisallowSpeculation:
1557 return os <<
"SpeculationMode::kDisallowSpeculation";
1563 enum class BlockingBehavior { kBlock, kDontBlock };
1565 enum class ConcurrencyMode { kNotConcurrent, kConcurrent };
1567 #define FOR_EACH_ISOLATE_ADDRESS_NAME(C) \ 1568 C(Handler, handler) \ 1569 C(CEntryFP, c_entry_fp) \ 1570 C(CFunction, c_function) \ 1571 C(Context, context) \ 1572 C(PendingException, pending_exception) \ 1573 C(PendingHandlerContext, pending_handler_context) \ 1574 C(PendingHandlerEntrypoint, pending_handler_entrypoint) \ 1575 C(PendingHandlerConstantPool, pending_handler_constant_pool) \ 1576 C(PendingHandlerFP, pending_handler_fp) \ 1577 C(PendingHandlerSP, pending_handler_sp) \ 1578 C(ExternalCaughtException, external_caught_exception) \ 1579 C(JSEntrySP, js_entry_sp) 1581 enum IsolateAddressId {
1582 #define DECLARE_ENUM(CamelName, hacker_name) k##CamelName##Address, 1583 FOR_EACH_ISOLATE_ADDRESS_NAME(DECLARE_ENUM)
1585 kIsolateAddressCount
1588 V8_INLINE
static bool HasWeakHeapObjectTag(Address value) {
1590 return ((static_cast<intptr_t>(value) & kHeapObjectTagMask) ==
1591 kWeakHeapObjectTag);
1596 V8_INLINE
static bool HasWeakHeapObjectTag(
const Object* value) {
1597 return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
1598 kWeakHeapObjectTag);
1601 enum class HeapObjectReferenceType {
1606 enum class PoisoningMitigationLevel {
1612 enum class LoadSensitivity {
1621 #define FOREACH_WASM_TRAPREASON(V) \ 1622 V(TrapUnreachable) \ 1623 V(TrapMemOutOfBounds) \ 1624 V(TrapUnalignedAccess) \ 1626 V(TrapDivUnrepresentable) \ 1628 V(TrapFloatUnrepresentable) \ 1629 V(TrapFuncInvalid) \ 1630 V(TrapFuncSigMismatch) 1632 enum KeyedAccessLoadMode {
1634 LOAD_IGNORE_OUT_OF_BOUNDS,
1637 enum KeyedAccessStoreMode {
1639 STORE_TRANSITION_TO_OBJECT,
1640 STORE_TRANSITION_TO_DOUBLE,
1641 STORE_AND_GROW_NO_TRANSITION_HANDLE_COW,
1642 STORE_AND_GROW_TRANSITION_TO_OBJECT,
1643 STORE_AND_GROW_TRANSITION_TO_DOUBLE,
1644 STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS,
1645 STORE_NO_TRANSITION_HANDLE_COW
1648 enum MutableMode { MUTABLE, IMMUTABLE };
1650 static inline bool IsTransitionStoreMode(KeyedAccessStoreMode store_mode) {
1651 return store_mode == STORE_TRANSITION_TO_OBJECT ||
1652 store_mode == STORE_TRANSITION_TO_DOUBLE ||
1653 store_mode == STORE_AND_GROW_TRANSITION_TO_OBJECT ||
1654 store_mode == STORE_AND_GROW_TRANSITION_TO_DOUBLE;
1657 static inline bool IsCOWHandlingStoreMode(KeyedAccessStoreMode store_mode) {
1658 return store_mode == STORE_NO_TRANSITION_HANDLE_COW ||
1659 store_mode == STORE_AND_GROW_NO_TRANSITION_HANDLE_COW;
1662 static inline KeyedAccessStoreMode GetNonTransitioningStoreMode(
1663 KeyedAccessStoreMode store_mode,
bool receiver_was_cow) {
1664 switch (store_mode) {
1665 case STORE_AND_GROW_NO_TRANSITION_HANDLE_COW:
1666 case STORE_AND_GROW_TRANSITION_TO_OBJECT:
1667 case STORE_AND_GROW_TRANSITION_TO_DOUBLE:
1668 store_mode = STORE_AND_GROW_NO_TRANSITION_HANDLE_COW;
1670 case STANDARD_STORE:
1671 case STORE_TRANSITION_TO_OBJECT:
1672 case STORE_TRANSITION_TO_DOUBLE:
1674 receiver_was_cow ? STORE_NO_TRANSITION_HANDLE_COW : STANDARD_STORE;
1676 case STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS:
1677 case STORE_NO_TRANSITION_HANDLE_COW:
1680 DCHECK(!IsTransitionStoreMode(store_mode));
1681 DCHECK_IMPLIES(receiver_was_cow, IsCOWHandlingStoreMode(store_mode));
1685 static inline bool IsGrowStoreMode(KeyedAccessStoreMode store_mode) {
1686 return store_mode >= STORE_AND_GROW_NO_TRANSITION_HANDLE_COW &&
1687 store_mode <= STORE_AND_GROW_TRANSITION_TO_DOUBLE;
1690 enum IcCheckType { ELEMENT, PROPERTY };
1696 #endif // V8_GLOBALS_H_