1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
11 #include "src/base/build_config.h"
12 #include "src/base/logging.h"
13 #include "src/base/macros.h"
15 // Unfortunately, the INFINITY macro cannot be used with the '-pedantic'
16 // warning flag and certain versions of GCC due to a bug:
17 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931
18 // For now, we use the more involved template-based version from <limits>, but
19 // only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x)
20 #if V8_CC_GNU && V8_GNUC_PREREQ(2, 96, 0) && !V8_GNUC_PREREQ(4, 1, 0)
21 # include <limits> // NOLINT
22 # define V8_INFINITY std::numeric_limits<double>::infinity()
24 # define V8_INFINITY HUGE_VAL
26 # define V8_INFINITY INFINITY
29 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM || \
30 V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_MIPS
31 #define V8_TURBOFAN_BACKEND 1
33 #define V8_TURBOFAN_BACKEND 0
35 #if V8_TURBOFAN_BACKEND && !(V8_OS_WIN && V8_TARGET_ARCH_X64)
36 #define V8_TURBOFAN_TARGET 1
38 #define V8_TURBOFAN_TARGET 0
51 // Determine whether we are running in a simulated environment.
52 // Setting USE_SIMULATOR explicitly from the build script will force
53 // the use of a simulated environment.
54 #if !defined(USE_SIMULATOR)
55 #if (V8_TARGET_ARCH_ARM64 && !V8_HOST_ARCH_ARM64)
56 #define USE_SIMULATOR 1
58 #if (V8_TARGET_ARCH_ARM && !V8_HOST_ARCH_ARM)
59 #define USE_SIMULATOR 1
61 #if (V8_TARGET_ARCH_MIPS && !V8_HOST_ARCH_MIPS)
62 #define USE_SIMULATOR 1
64 #if (V8_TARGET_ARCH_MIPS64 && !V8_HOST_ARCH_MIPS64)
65 #define USE_SIMULATOR 1
69 // Determine whether the architecture uses an out-of-line constant pool.
70 #define V8_OOL_CONSTANT_POOL 0
72 #ifdef V8_TARGET_ARCH_ARM
73 // Set stack limit lower for ARM than for other architectures because
74 // stack allocating MacroAssembler takes 120K bytes.
75 // See issue crbug.com/405338
76 #define V8_DEFAULT_STACK_SIZE_KB 864
78 // Slightly less than 1MB, since Windows' default stack size for
79 // the main execution thread is 1MB for both 32 and 64-bit.
80 #define V8_DEFAULT_STACK_SIZE_KB 984
84 // Support for alternative bool type. This is only enabled if the code is
85 // compiled with USE_MYBOOL defined. This catches some nasty type bugs.
86 // For instance, 'bool b = "false";' results in b == true! This is a hidden
88 // However, redefining the bool type does have some negative impact on some
89 // platforms. It gives rise to compiler warnings (i.e. with
90 // MSVC) in the API header files when mixing code that uses the standard
91 // bool with code that uses the redefined version.
92 // This does not actually belong in the platform code, but needs to be
93 // defined here because the platform code uses bool, and platform.h is
94 // include very early in the main include file.
97 typedef unsigned int __my_bool__;
98 #define bool __my_bool__ // use 'indirection' to avoid name clashes
101 typedef uint8_t byte;
102 typedef byte* Address;
104 // -----------------------------------------------------------------------------
107 struct float32x4_value_t { float storage[4]; };
108 struct float64x2_value_t { double storage[2]; };
109 struct int32x4_value_t { int32_t storage[4]; };
110 union simd128_value_t {
112 float32x4_value_t f4;
113 float64x2_value_t d2;
118 const int MB = KB * KB;
119 const int GB = KB * KB * KB;
120 const int kMaxInt = 0x7FFFFFFF;
121 const int kMinInt = -kMaxInt - 1;
122 const int kMaxInt8 = (1 << 7) - 1;
123 const int kMinInt8 = -(1 << 7);
124 const int kMaxUInt8 = (1 << 8) - 1;
125 const int kMinUInt8 = 0;
126 const int kMaxInt16 = (1 << 15) - 1;
127 const int kMinInt16 = -(1 << 15);
128 const int kMaxUInt16 = (1 << 16) - 1;
129 const int kMinUInt16 = 0;
131 const uint32_t kMaxUInt32 = 0xFFFFFFFFu;
133 const int kCharSize = sizeof(char); // NOLINT
134 const int kShortSize = sizeof(short); // NOLINT
135 const int kIntSize = sizeof(int); // NOLINT
136 const int kInt32Size = sizeof(int32_t); // NOLINT
137 const int kInt64Size = sizeof(int64_t); // NOLINT
138 const int kDoubleSize = sizeof(double); // NOLINT
139 const int kFloatSize = sizeof(float); // NOLINT
140 const int kFloat32x4Size = sizeof(float32x4_value_t); // NOLINT
141 const int kFloat64x2Size = sizeof(float64x2_value_t); // NOLINT
142 const int kInt32x4Size = sizeof(int32x4_value_t); // NOLINT
143 const int kSIMD128Size = sizeof(simd128_value_t); // NOLINT
144 const int kIntptrSize = sizeof(intptr_t); // NOLINT
145 const int kPointerSize = sizeof(void*); // NOLINT
146 #if V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT
147 const int kRegisterSize = kPointerSize + kPointerSize;
149 const int kRegisterSize = kPointerSize;
151 const int kPCOnStackSize = kRegisterSize;
152 const int kFPOnStackSize = kRegisterSize;
154 const int kDoubleSizeLog2 = 3;
156 #if V8_HOST_ARCH_64_BIT
157 const int kPointerSizeLog2 = 3;
158 const intptr_t kIntptrSignBit = V8_INT64_C(0x8000000000000000);
159 const uintptr_t kUintptrAllBitsSet = V8_UINT64_C(0xFFFFFFFFFFFFFFFF);
160 const bool kRequiresCodeRange = true;
161 const size_t kMaximalCodeRangeSize = 512 * MB;
163 const size_t kMinimumCodeRangeSize = 4 * MB;
164 const size_t kReservedCodeRangePages = 1;
166 const size_t kMinimumCodeRangeSize = 3 * MB;
167 const size_t kReservedCodeRangePages = 0;
170 const int kPointerSizeLog2 = 2;
171 const intptr_t kIntptrSignBit = 0x80000000;
172 const uintptr_t kUintptrAllBitsSet = 0xFFFFFFFFu;
173 #if V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT
174 // x32 port also requires code range.
175 const bool kRequiresCodeRange = true;
176 const size_t kMaximalCodeRangeSize = 256 * MB;
177 const size_t kMinimumCodeRangeSize = 3 * MB;
178 const size_t kReservedCodeRangePages = 0;
180 const bool kRequiresCodeRange = false;
181 const size_t kMaximalCodeRangeSize = 0 * MB;
182 const size_t kMinimumCodeRangeSize = 0 * MB;
183 const size_t kReservedCodeRangePages = 0;
187 STATIC_ASSERT(kPointerSize == (1 << kPointerSizeLog2));
189 const int kBitsPerByte = 8;
190 const int kBitsPerByteLog2 = 3;
191 const int kBitsPerPointer = kPointerSize * kBitsPerByte;
192 const int kBitsPerInt = kIntSize * kBitsPerByte;
194 // IEEE 754 single precision floating point number bit layout.
195 const uint32_t kBinary32SignMask = 0x80000000u;
196 const uint32_t kBinary32ExponentMask = 0x7f800000u;
197 const uint32_t kBinary32MantissaMask = 0x007fffffu;
198 const int kBinary32ExponentBias = 127;
199 const int kBinary32MaxExponent = 0xFE;
200 const int kBinary32MinExponent = 0x01;
201 const int kBinary32MantissaBits = 23;
202 const int kBinary32ExponentShift = 23;
204 // Quiet NaNs have bits 51 to 62 set, possibly the sign bit, and no
206 const uint64_t kQuietNaNMask = static_cast<uint64_t>(0xfff) << 51;
208 // Latin1/UTF-16 constants
209 // Code-point values in Unicode 4.0 are 21 bits wide.
210 // Code units in UTF-16 are 16 bits wide.
211 typedef uint16_t uc16;
212 typedef int32_t uc32;
213 const int kOneByteSize = kCharSize;
214 const int kUC16Size = sizeof(uc16); // NOLINT
217 // Round up n to be a multiple of sz, where sz is a power of 2.
218 #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1))
221 // FUNCTION_ADDR(f) gets the address of a C function f.
222 #define FUNCTION_ADDR(f) \
223 (reinterpret_cast<v8::internal::Address>(reinterpret_cast<intptr_t>(f)))
226 // FUNCTION_CAST<F>(addr) casts an address into a function
227 // of type F. Used to invoke generated code from within C.
228 template <typename F>
229 F FUNCTION_CAST(Address addr) {
230 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr));
234 // -----------------------------------------------------------------------------
235 // Forward declarations for frequently used classes
236 // (sorted alphabetically)
238 class FreeStoreAllocationPolicy;
239 template <typename T, class P = FreeStoreAllocationPolicy> class List;
241 // -----------------------------------------------------------------------------
242 // Declarations for use in both the preparser and the rest of V8.
244 // The Strict Mode (ECMA-262 5th edition, 4.2.2).
246 enum StrictMode { SLOPPY, STRICT };
249 // Mask for the sign bit in a smi.
250 const intptr_t kSmiSignMask = kIntptrSignBit;
252 const int kObjectAlignmentBits = kPointerSizeLog2;
253 const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits;
254 const intptr_t kObjectAlignmentMask = kObjectAlignment - 1;
256 // Desired alignment for pointers.
257 const intptr_t kPointerAlignment = (1 << kPointerSizeLog2);
258 const intptr_t kPointerAlignmentMask = kPointerAlignment - 1;
260 // Desired alignment for double values.
261 const intptr_t kDoubleAlignment = 8;
262 const intptr_t kDoubleAlignmentMask = kDoubleAlignment - 1;
264 // Desired alignment for generated code is 32 bytes (to improve cache line
266 const int kCodeAlignmentBits = 5;
267 const intptr_t kCodeAlignment = 1 << kCodeAlignmentBits;
268 const intptr_t kCodeAlignmentMask = kCodeAlignment - 1;
270 // The owner field of a page is tagged with the page header tag. We need that
271 // to find out if a slot is part of a large object. If we mask out the lower
272 // 0xfffff bits (1M pages), go to the owner offset, and see that this field
273 // is tagged with the page header tag, we can just look up the owner.
274 // Otherwise, we know that we are somewhere (not within the first 1M) in a
276 const int kPageHeaderTag = 3;
277 const int kPageHeaderTagSize = 2;
278 const intptr_t kPageHeaderTagMask = (1 << kPageHeaderTagSize) - 1;
281 // Zap-value: The value used for zapping dead objects.
282 // Should be a recognizable hex value tagged as a failure.
283 #ifdef V8_HOST_ARCH_64_BIT
284 const Address kZapValue =
285 reinterpret_cast<Address>(V8_UINT64_C(0xdeadbeedbeadbeef));
286 const Address kHandleZapValue =
287 reinterpret_cast<Address>(V8_UINT64_C(0x1baddead0baddeaf));
288 const Address kGlobalHandleZapValue =
289 reinterpret_cast<Address>(V8_UINT64_C(0x1baffed00baffedf));
290 const Address kFromSpaceZapValue =
291 reinterpret_cast<Address>(V8_UINT64_C(0x1beefdad0beefdaf));
292 const uint64_t kDebugZapValue = V8_UINT64_C(0xbadbaddbbadbaddb);
293 const uint64_t kSlotsZapValue = V8_UINT64_C(0xbeefdeadbeefdeef);
294 const uint64_t kFreeListZapValue = 0xfeed1eaffeed1eaf;
296 const Address kZapValue = reinterpret_cast<Address>(0xdeadbeef);
297 const Address kHandleZapValue = reinterpret_cast<Address>(0xbaddeaf);
298 const Address kGlobalHandleZapValue = reinterpret_cast<Address>(0xbaffedf);
299 const Address kFromSpaceZapValue = reinterpret_cast<Address>(0xbeefdaf);
300 const uint32_t kSlotsZapValue = 0xbeefdeef;
301 const uint32_t kDebugZapValue = 0xbadbaddb;
302 const uint32_t kFreeListZapValue = 0xfeed1eaf;
305 const int kCodeZapValue = 0xbadc0de;
306 const uint32_t kPhantomReferenceZap = 0xca11bac;
308 // On Intel architecture, cache line size is 64 bytes.
309 // On ARM it may be less (32 bytes), but as far this constant is
310 // used for aligning data, it doesn't hurt to align on a greater value.
311 #define PROCESSOR_CACHE_LINE_SIZE 64
313 // Constants relevant to double precision floating point numbers.
314 // If looking only at the top 32 bits, the QNaN mask is bits 19 to 30.
315 const uint32_t kQuietNaNHighBitsMask = 0xfff << (51 - 32);
318 // -----------------------------------------------------------------------------
319 // Forward declarations for frequently used classes
333 class DescriptorArray;
334 class TransitionArray;
335 class ExternalReference;
337 class FunctionTemplateInfo;
339 class SeededNumberDictionary;
340 class UnseededNumberDictionary;
341 class NameDictionary;
342 template <typename T> class MaybeHandle;
343 template <typename T> class Handle;
347 class InterceptorInfo;
353 class LargeObjectSpace;
355 class MacroAssembler;
358 class MarkCompactCollector;
367 template <typename Config, class Allocator = FreeStoreAllocationPolicy>
375 class MessageLocation;
377 typedef bool (*WeakSlotCallback)(Object** pointer);
379 typedef bool (*WeakSlotCallbackWithHeap)(Heap* heap, Object** pointer);
381 // -----------------------------------------------------------------------------
384 // NOTE: SpaceIterator depends on AllocationSpace enumeration values being
386 enum AllocationSpace {
387 NEW_SPACE, // Semispaces collected with copying collector.
388 OLD_POINTER_SPACE, // May contain pointers to new space.
389 OLD_DATA_SPACE, // Must not have pointers to new space.
390 CODE_SPACE, // No pointers to new space, marked executable.
391 MAP_SPACE, // Only and all map objects.
392 CELL_SPACE, // Only and all cell objects.
393 PROPERTY_CELL_SPACE, // Only and all global property cell objects.
394 LO_SPACE, // Promoted large objects.
396 FIRST_SPACE = NEW_SPACE,
397 LAST_SPACE = LO_SPACE,
398 FIRST_PAGED_SPACE = OLD_POINTER_SPACE,
399 LAST_PAGED_SPACE = PROPERTY_CELL_SPACE
401 const int kSpaceTagSize = 3;
402 const int kSpaceTagMask = (1 << kSpaceTagSize) - 1;
405 // A flag that indicates whether objects should be pretenured when
406 // allocated (allocated directly into the old generation) or not
407 // (allocated in the young generation if the object size and type
409 enum PretenureFlag { NOT_TENURED, TENURED };
411 enum MinimumCapacity {
412 USE_DEFAULT_MINIMUM_CAPACITY,
413 USE_CUSTOM_MINIMUM_CAPACITY
416 enum GarbageCollector { SCAVENGER, MARK_COMPACTOR };
418 enum Executability { NOT_EXECUTABLE, EXECUTABLE };
422 VISIT_ALL_IN_SCAVENGE,
423 VISIT_ALL_IN_SWEEP_NEWSPACE,
427 // Flag indicating whether code is built into the VM (one of the natives files).
428 enum NativesFlag { NOT_NATIVES_CODE, NATIVES_CODE };
431 // A CodeDesc describes a buffer holding instructions and relocation
432 // information. The instructions start at the beginning of the buffer
433 // and grow forward, the relocation information starts at the end of
434 // the buffer and grows backward.
436 // |<--------------- buffer_size ---------------->|
437 // |<-- instr_size -->| |<-- reloc_size -->|
438 // +==================+========+==================+
439 // | instructions | free | reloc info |
440 // +==================+========+==================+
454 // Callback function used for iterating objects in heap spaces,
455 // for example, scanning heap objects.
456 typedef int (*HeapObjectCallback)(HeapObject* obj);
459 // Callback function used for checking constraints when copying/relocating
460 // objects. Returns true if an object can be copied/relocated from its
461 // old_addr to a new_addr.
462 typedef bool (*ConstraintCallback)(Address new_addr, Address old_addr);
465 // Callback function on inline caches, used for iterating over inline caches
467 typedef void (*InlineCacheCallback)(Code* code, Address ic);
470 // State for inline cache call sites. Aliased as IC::State.
471 enum InlineCacheState {
472 // Has never been executed.
474 // Has been executed but monomorhic state has been delayed.
476 // Has been executed and only one receiver type has been seen.
478 // Check failed due to prototype (or map deprecation).
480 // Multiple receiver types have been seen.
482 // Many receiver types have been seen.
484 // A generic handler is installed and no extra typefeedback is recorded.
486 // Special state for debug break or step in prepare stubs.
488 // Type-vector-based ICs have a default state, with the full calculation
489 // of IC state only determined by a look at the IC and the typevector
495 enum CallFunctionFlags {
496 NO_CALL_FUNCTION_FLAGS,
498 // Always wrap the receiver and call to the JSFunction. Only use this flag
499 // both the receiver type and the target method are statically known.
504 enum CallConstructorFlags {
505 NO_CALL_CONSTRUCTOR_FLAGS,
506 // The call target is cached in the instruction stream.
507 RECORD_CONSTRUCTOR_TARGET
511 enum CacheHolderFlag {
513 kCacheOnPrototypeReceiverIsDictionary,
514 kCacheOnPrototypeReceiverIsPrimitive,
519 // The Store Buffer (GC).
521 kStoreBufferFullEvent,
522 kStoreBufferStartScanningPagesEvent,
523 kStoreBufferScanningPageEvent
527 typedef void (*StoreBufferCallback)(Heap* heap,
529 StoreBufferEvent event);
532 // Union used for fast testing of specific double values.
533 union DoubleRepresentation {
536 DoubleRepresentation(double x) { value = x; }
537 bool operator==(const DoubleRepresentation& other) const {
538 return bits == other.bits;
543 // Union used for customized checking of the IEEE double types
544 // inlined within v8 runtime, rather than going to the underlying
545 // platform headers and libraries
546 union IeeeDoubleLittleEndianArchType {
549 unsigned int man_low :32;
550 unsigned int man_high :20;
551 unsigned int exp :11;
552 unsigned int sign :1;
557 union IeeeDoubleBigEndianArchType {
560 unsigned int sign :1;
561 unsigned int exp :11;
562 unsigned int man_high :20;
563 unsigned int man_low :32;
569 struct AccessorDescriptor {
570 Object* (*getter)(Isolate* isolate, Object* object, void* data);
572 Isolate* isolate, JSObject* object, Object* value, void* data);
577 // -----------------------------------------------------------------------------
582 #define HAS_SMI_TAG(value) \
583 ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag)
585 #define HAS_FAILURE_TAG(value) \
586 ((reinterpret_cast<intptr_t>(value) & kFailureTagMask) == kFailureTag)
588 // OBJECT_POINTER_ALIGN returns the value aligned as a HeapObject pointer
589 #define OBJECT_POINTER_ALIGN(value) \
590 (((value) + kObjectAlignmentMask) & ~kObjectAlignmentMask)
592 // POINTER_SIZE_ALIGN returns the value aligned as a pointer.
593 #define POINTER_SIZE_ALIGN(value) \
594 (((value) + kPointerAlignmentMask) & ~kPointerAlignmentMask)
596 // CODE_POINTER_ALIGN returns the value aligned as a generated code segment.
597 #define CODE_POINTER_ALIGN(value) \
598 (((value) + kCodeAlignmentMask) & ~kCodeAlignmentMask)
600 // Support for tracking C++ memory allocation. Insert TRACK_MEMORY("Fisk")
601 // inside a C++ class and new and delete will be overloaded so logging is
603 // This file (globals.h) is included before log.h, so we use direct calls to
604 // the Logger rather than the LOG macro.
606 #define TRACK_MEMORY(name) \
607 void* operator new(size_t size) { \
608 void* result = ::operator new(size); \
609 Logger::NewEventStatic(name, result, size); \
612 void operator delete(void* object) { \
613 Logger::DeleteEventStatic(name, object); \
614 ::operator delete(object); \
617 #define TRACK_MEMORY(name)
621 // CPU feature flags.
634 MOVW_MOVT_IMMEDIATE_LOADS,
645 NUMBER_OF_CPU_FEATURES
649 // Used to specify if a macro instruction must perform a smi check on tagged
658 EVAL_SCOPE, // The top-level scope for an eval source.
659 FUNCTION_SCOPE, // The top-level scope for a function.
660 MODULE_SCOPE, // The scope introduced by a module literal
661 GLOBAL_SCOPE, // The top-level scope for a program or a top-level eval.
662 CATCH_SCOPE, // The scope introduced by catch.
663 BLOCK_SCOPE, // The scope introduced by a new block.
664 WITH_SCOPE, // The scope introduced by with.
665 ARROW_SCOPE // The top-level scope for an arrow function literal.
669 const uint32_t kHoleNanUpper32 = 0x7FFFFFFF;
670 const uint32_t kHoleNanLower32 = 0xFFFFFFFF;
671 const uint32_t kNaNOrInfinityLowerBoundUpper32 = 0x7FF00000;
673 const uint64_t kHoleNanInt64 =
674 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32;
675 const uint64_t kLastNonNaNInt64 =
676 (static_cast<uint64_t>(kNaNOrInfinityLowerBoundUpper32) << 32);
679 // The order of this enum has to be kept in sync with the predicates below.
681 // User declared variables:
682 VAR, // declared via 'var', and 'function' declarations
684 CONST_LEGACY, // declared via legacy 'const' declarations
686 LET, // declared via 'let' declarations (first lexical)
688 CONST, // declared via 'const' declarations
690 MODULE, // declared via 'module' declaration (last lexical)
692 // Variables introduced by the compiler:
693 INTERNAL, // like VAR, but not user-visible (may or may not
696 TEMPORARY, // temporary variables (not user-visible), stack-allocated
697 // unless the scope as a whole has forced context allocation
699 DYNAMIC, // always require dynamic lookup (we don't know
702 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the
703 // variable is global unless it has been shadowed
704 // by an eval-introduced variable
706 DYNAMIC_LOCAL // requires dynamic lookup, but we know that the
707 // variable is local and where it is unless it
708 // has been shadowed by an eval-introduced
713 inline bool IsDynamicVariableMode(VariableMode mode) {
714 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL;
718 inline bool IsDeclaredVariableMode(VariableMode mode) {
719 return mode >= VAR && mode <= MODULE;
723 inline bool IsLexicalVariableMode(VariableMode mode) {
724 return mode >= LET && mode <= MODULE;
728 inline bool IsImmutableVariableMode(VariableMode mode) {
729 return (mode >= CONST && mode <= MODULE) || mode == CONST_LEGACY;
733 // ES6 Draft Rev3 10.2 specifies declarative environment records with mutable
734 // and immutable bindings that can be in two states: initialized and
735 // uninitialized. In ES5 only immutable bindings have these two states. When
736 // accessing a binding, it needs to be checked for initialization. However in
737 // the following cases the binding is initialized immediately after creation
738 // so the initialization check can always be skipped:
739 // 1. Var declared local variables.
741 // 2. A local variable introduced by a function declaration.
744 // function x(foo) {}
745 // 4. Catch bound variables.
746 // try {} catch (foo) {}
747 // 6. Function variables of named function expressions.
748 // var x = function foo() {}
749 // 7. Implicit binding of 'this'.
750 // 8. Implicit binding of 'arguments' in functions.
752 // ES5 specified object environment records which are introduced by ES elements
753 // such as Program and WithStatement that associate identifier bindings with the
754 // properties of some object. In the specification only mutable bindings exist
755 // (which may be non-writable) and have no distinct initialization step. However
756 // V8 allows const declarations in global code with distinct creation and
757 // initialization steps which are represented by non-writable properties in the
758 // global object. As a result also these bindings need to be checked for
761 // The following enum specifies a flag that indicates if the binding needs a
762 // distinct initialization step (kNeedsInitialization) or if the binding is
763 // immediately initialized upon creation (kCreatedInitialized).
764 enum InitializationFlag {
765 kNeedsInitialization,
770 enum MaybeAssignedFlag { kNotAssigned, kMaybeAssigned };
773 enum ClearExceptionFlag {
780 TREAT_MINUS_ZERO_AS_ZERO,
785 enum Signedness { kSigned, kUnsigned };
791 kGeneratorFunction = 2,
793 kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod
797 inline bool IsValidFunctionKind(FunctionKind kind) {
798 return kind == FunctionKind::kNormalFunction ||
799 kind == FunctionKind::kArrowFunction ||
800 kind == FunctionKind::kGeneratorFunction ||
801 kind == FunctionKind::kConciseMethod ||
802 kind == FunctionKind::kConciseGeneratorMethod;
806 inline bool IsArrowFunction(FunctionKind kind) {
807 DCHECK(IsValidFunctionKind(kind));
808 return kind & FunctionKind::kArrowFunction;
812 inline bool IsGeneratorFunction(FunctionKind kind) {
813 DCHECK(IsValidFunctionKind(kind));
814 return kind & FunctionKind::kGeneratorFunction;
818 inline bool IsConciseMethod(FunctionKind kind) {
819 DCHECK(IsValidFunctionKind(kind));
820 return kind & FunctionKind::kConciseMethod;
822 } } // namespace v8::internal
824 namespace i = v8::internal;
826 #endif // V8_GLOBALS_H_