blob: 67bdb63b86ee7a008e1fe0eebaab710c6d0eec60 [file] [log] [blame]
Ben Murdoch3ef787d2012-04-12 10:51:47 +01001// Copyright 2012 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Steve Blocka7e24c12009-10-30 11:49:00 +00004
5#ifndef V8_GLOBALS_H_
6#define V8_GLOBALS_H_
7
Emily Bernierd0a1eb72015-03-24 16:35:39 -04008#include <stddef.h>
9#include <stdint.h>
Ben Murdoch589d6972011-11-30 16:04:58 +000010
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000011#include <ostream>
12
Ben Murdochb8a8cc12014-11-26 15:28:44 +000013#include "src/base/build_config.h"
14#include "src/base/logging.h"
15#include "src/base/macros.h"
Ben Murdoch589d6972011-11-30 16:04:58 +000016
17// Unfortunately, the INFINITY macro cannot be used with the '-pedantic'
18// warning flag and certain versions of GCC due to a bug:
19// http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11931
20// For now, we use the more involved template-based version from <limits>, but
21// only when compiling with GCC versions affected by the bug (2.96.x - 4.0.x)
Ben Murdochb8a8cc12014-11-26 15:28:44 +000022#if V8_CC_GNU && V8_GNUC_PREREQ(2, 96, 0) && !V8_GNUC_PREREQ(4, 1, 0)
23# include <limits> // NOLINT
24# define V8_INFINITY std::numeric_limits<double>::infinity()
25#elif V8_LIBC_MSVCRT
26# define V8_INFINITY HUGE_VAL
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000027#elif V8_OS_AIX
28#define V8_INFINITY (__builtin_inff())
Ben Murdochb8a8cc12014-11-26 15:28:44 +000029#else
30# define V8_INFINITY INFINITY
Ben Murdoch589d6972011-11-30 16:04:58 +000031#endif
32
Steve Blocka7e24c12009-10-30 11:49:00 +000033namespace v8 {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000034
35namespace base {
36class Mutex;
37class RecursiveMutex;
38class VirtualMemory;
39}
40
Steve Blocka7e24c12009-10-30 11:49:00 +000041namespace internal {
42
John Reck59135872010-11-02 12:39:01 -070043// Determine whether we are running in a simulated environment.
44// Setting USE_SIMULATOR explicitly from the build script will force
45// the use of a simulated environment.
46#if !defined(USE_SIMULATOR)
Ben Murdochb8a8cc12014-11-26 15:28:44 +000047#if (V8_TARGET_ARCH_ARM64 && !V8_HOST_ARCH_ARM64)
John Reck59135872010-11-02 12:39:01 -070048#define USE_SIMULATOR 1
49#endif
Ben Murdochb8a8cc12014-11-26 15:28:44 +000050#if (V8_TARGET_ARCH_ARM && !V8_HOST_ARCH_ARM)
51#define USE_SIMULATOR 1
52#endif
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000053#if (V8_TARGET_ARCH_PPC && !V8_HOST_ARCH_PPC)
54#define USE_SIMULATOR 1
55#endif
Ben Murdochb8a8cc12014-11-26 15:28:44 +000056#if (V8_TARGET_ARCH_MIPS && !V8_HOST_ARCH_MIPS)
57#define USE_SIMULATOR 1
58#endif
59#if (V8_TARGET_ARCH_MIPS64 && !V8_HOST_ARCH_MIPS64)
John Reck59135872010-11-02 12:39:01 -070060#define USE_SIMULATOR 1
61#endif
62#endif
63
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000064// Determine whether the architecture uses an embedded constant pool
65// (contiguous constant pool embedded in code object).
66#if V8_TARGET_ARCH_PPC
67#define V8_EMBEDDED_CONSTANT_POOL 1
68#else
69#define V8_EMBEDDED_CONSTANT_POOL 0
70#endif
Ben Murdochb8a8cc12014-11-26 15:28:44 +000071
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
Steve Blocka7e24c12009-10-30 11:49:00 +000077#else
Ben Murdochb8a8cc12014-11-26 15:28:44 +000078// 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
Steve Blocka7e24c12009-10-30 11:49:00 +000081#endif
82
Ben Murdochb8a8cc12014-11-26 15:28:44 +000083
Emily Bernierd0a1eb72015-03-24 16:35:39 -040084// Determine whether double field unboxing feature is enabled.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000085#if V8_TARGET_ARCH_64_BIT
86#define V8_DOUBLE_FIELDS_UNBOXING 1
Emily Bernierd0a1eb72015-03-24 16:35:39 -040087#else
88#define V8_DOUBLE_FIELDS_UNBOXING 0
Steve Blocka7e24c12009-10-30 11:49:00 +000089#endif
90
Emily Bernierd0a1eb72015-03-24 16:35:39 -040091
Steve Blocka7e24c12009-10-30 11:49:00 +000092typedef uint8_t byte;
93typedef byte* Address;
94
Steve Blocka7e24c12009-10-30 11:49:00 +000095// -----------------------------------------------------------------------------
96// Constants
97
98const int KB = 1024;
99const int MB = KB * KB;
100const int GB = KB * KB * KB;
101const int kMaxInt = 0x7FFFFFFF;
102const int kMinInt = -kMaxInt - 1;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000103const int kMaxInt8 = (1 << 7) - 1;
104const int kMinInt8 = -(1 << 7);
105const int kMaxUInt8 = (1 << 8) - 1;
106const int kMinUInt8 = 0;
107const int kMaxInt16 = (1 << 15) - 1;
108const int kMinInt16 = -(1 << 15);
109const int kMaxUInt16 = (1 << 16) - 1;
110const int kMinUInt16 = 0;
Steve Blocka7e24c12009-10-30 11:49:00 +0000111
112const uint32_t kMaxUInt32 = 0xFFFFFFFFu;
113
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000114const int kCharSize = sizeof(char); // NOLINT
115const int kShortSize = sizeof(short); // NOLINT
116const int kIntSize = sizeof(int); // NOLINT
117const int kInt32Size = sizeof(int32_t); // NOLINT
118const int kInt64Size = sizeof(int64_t); // NOLINT
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000119const int kFloatSize = sizeof(float); // NOLINT
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000120const int kDoubleSize = sizeof(double); // NOLINT
121const int kIntptrSize = sizeof(intptr_t); // NOLINT
122const int kPointerSize = sizeof(void*); // NOLINT
123#if V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT
124const int kRegisterSize = kPointerSize + kPointerSize;
125#else
126const int kRegisterSize = kPointerSize;
127#endif
128const int kPCOnStackSize = kRegisterSize;
129const int kFPOnStackSize = kRegisterSize;
Steve Blocka7e24c12009-10-30 11:49:00 +0000130
Ben Murdoch3fb3ca82011-12-02 17:19:32 +0000131const int kDoubleSizeLog2 = 3;
132
Steve Blocka7e24c12009-10-30 11:49:00 +0000133#if V8_HOST_ARCH_64_BIT
134const int kPointerSizeLog2 = 3;
135const intptr_t kIntptrSignBit = V8_INT64_C(0x8000000000000000);
John Reck59135872010-11-02 12:39:01 -0700136const uintptr_t kUintptrAllBitsSet = V8_UINT64_C(0xFFFFFFFFFFFFFFFF);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000137const bool kRequiresCodeRange = true;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000138#if V8_TARGET_ARCH_MIPS64
139// To use pseudo-relative jumps such as j/jal instructions which have 28-bit
140// encoded immediate, the addresses have to be in range of 256MB aligned
141// region. Used only for large object space.
142const size_t kMaximalCodeRangeSize = 256 * MB;
143#else
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000144const size_t kMaximalCodeRangeSize = 512 * MB;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000145#endif
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400146#if V8_OS_WIN
147const size_t kMinimumCodeRangeSize = 4 * MB;
148const size_t kReservedCodeRangePages = 1;
149#else
150const size_t kMinimumCodeRangeSize = 3 * MB;
151const size_t kReservedCodeRangePages = 0;
152#endif
Steve Blocka7e24c12009-10-30 11:49:00 +0000153#else
154const int kPointerSizeLog2 = 2;
155const intptr_t kIntptrSignBit = 0x80000000;
John Reck59135872010-11-02 12:39:01 -0700156const uintptr_t kUintptrAllBitsSet = 0xFFFFFFFFu;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000157#if V8_TARGET_ARCH_X64 && V8_TARGET_ARCH_32_BIT
158// x32 port also requires code range.
159const bool kRequiresCodeRange = true;
160const size_t kMaximalCodeRangeSize = 256 * MB;
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400161const size_t kMinimumCodeRangeSize = 3 * MB;
162const size_t kReservedCodeRangePages = 0;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000163#else
164const bool kRequiresCodeRange = false;
165const size_t kMaximalCodeRangeSize = 0 * MB;
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400166const size_t kMinimumCodeRangeSize = 0 * MB;
167const size_t kReservedCodeRangePages = 0;
Steve Blocka7e24c12009-10-30 11:49:00 +0000168#endif
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000169#endif
170
171STATIC_ASSERT(kPointerSize == (1 << kPointerSizeLog2));
Steve Blocka7e24c12009-10-30 11:49:00 +0000172
Steve Blocka7e24c12009-10-30 11:49:00 +0000173const int kBitsPerByte = 8;
174const int kBitsPerByteLog2 = 3;
175const int kBitsPerPointer = kPointerSize * kBitsPerByte;
176const int kBitsPerInt = kIntSize * kBitsPerByte;
177
Steve Block6ded16b2010-05-10 14:33:55 +0100178// IEEE 754 single precision floating point number bit layout.
179const uint32_t kBinary32SignMask = 0x80000000u;
180const uint32_t kBinary32ExponentMask = 0x7f800000u;
181const uint32_t kBinary32MantissaMask = 0x007fffffu;
182const int kBinary32ExponentBias = 127;
183const int kBinary32MaxExponent = 0xFE;
184const int kBinary32MinExponent = 0x01;
185const int kBinary32MantissaBits = 23;
186const int kBinary32ExponentShift = 23;
Steve Blocka7e24c12009-10-30 11:49:00 +0000187
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100188// Quiet NaNs have bits 51 to 62 set, possibly the sign bit, and no
189// other bits set.
190const uint64_t kQuietNaNMask = static_cast<uint64_t>(0xfff) << 51;
191
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000192// Latin1/UTF-16 constants
Steve Block9fac8402011-05-12 15:51:54 +0100193// Code-point values in Unicode 4.0 are 21 bits wide.
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100194// Code units in UTF-16 are 16 bits wide.
Steve Block9fac8402011-05-12 15:51:54 +0100195typedef uint16_t uc16;
196typedef int32_t uc32;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000197const int kOneByteSize = kCharSize;
Steve Block9fac8402011-05-12 15:51:54 +0100198const int kUC16Size = sizeof(uc16); // NOLINT
Steve Block9fac8402011-05-12 15:51:54 +0100199
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000200// 128 bit SIMD value size.
201const int kSimd128Size = 16;
Ben Murdochb0fe1622011-05-05 13:52:32 +0100202
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000203// Round up n to be a multiple of sz, where sz is a power of 2.
204#define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1))
Steve Blocka7e24c12009-10-30 11:49:00 +0000205
206
207// FUNCTION_ADDR(f) gets the address of a C function f.
208#define FUNCTION_ADDR(f) \
209 (reinterpret_cast<v8::internal::Address>(reinterpret_cast<intptr_t>(f)))
210
211
212// FUNCTION_CAST<F>(addr) casts an address into a function
213// of type F. Used to invoke generated code from within C.
214template <typename F>
215F FUNCTION_CAST(Address addr) {
216 return reinterpret_cast<F>(reinterpret_cast<intptr_t>(addr));
217}
218
219
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000220// Determine whether the architecture uses function descriptors
221// which provide a level of indirection between the function pointer
222// and the function entrypoint.
223#if V8_HOST_ARCH_PPC && \
224 (V8_OS_AIX || (V8_TARGET_ARCH_PPC64 && V8_TARGET_BIG_ENDIAN))
225#define USES_FUNCTION_DESCRIPTORS 1
226#define FUNCTION_ENTRYPOINT_ADDRESS(f) \
227 (reinterpret_cast<v8::internal::Address*>( \
228 &(reinterpret_cast<intptr_t*>(f)[0])))
229#else
230#define USES_FUNCTION_DESCRIPTORS 0
231#endif
232
233
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -0800234// -----------------------------------------------------------------------------
235// Forward declarations for frequently used classes
236// (sorted alphabetically)
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100237
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -0800238class FreeStoreAllocationPolicy;
239template <typename T, class P = FreeStoreAllocationPolicy> class List;
Steve Blockd0582a62009-12-15 09:54:21 +0000240
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100241// -----------------------------------------------------------------------------
242// Declarations for use in both the preparser and the rest of V8.
243
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100244// The Strict Mode (ECMA-262 5th edition, 4.2.2).
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000245
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000246enum LanguageMode {
247 // LanguageMode is expressed as a bitmask. Descriptions of the bits:
248 STRICT_BIT = 1 << 0,
249 STRONG_BIT = 1 << 1,
250 LANGUAGE_END,
251
252 // Shorthands for some common language modes.
253 SLOPPY = 0,
254 STRICT = STRICT_BIT,
255 STRONG = STRICT_BIT | STRONG_BIT
256};
257
258
259inline std::ostream& operator<<(std::ostream& os, const LanguageMode& mode) {
260 switch (mode) {
261 case SLOPPY:
262 return os << "sloppy";
263 case STRICT:
264 return os << "strict";
265 case STRONG:
266 return os << "strong";
267 default:
268 return os << "unknown";
269 }
270}
271
272
273inline bool is_sloppy(LanguageMode language_mode) {
274 return (language_mode & STRICT_BIT) == 0;
275}
276
277
278inline bool is_strict(LanguageMode language_mode) {
279 return language_mode & STRICT_BIT;
280}
281
282
283inline bool is_strong(LanguageMode language_mode) {
284 return language_mode & STRONG_BIT;
285}
286
287
288inline bool is_valid_language_mode(int language_mode) {
289 return language_mode == SLOPPY || language_mode == STRICT ||
290 language_mode == STRONG;
291}
292
293
294inline LanguageMode construct_language_mode(bool strict_bit, bool strong_bit) {
295 int language_mode = 0;
296 if (strict_bit) language_mode |= STRICT_BIT;
297 if (strong_bit) language_mode |= STRONG_BIT;
298 DCHECK(is_valid_language_mode(language_mode));
299 return static_cast<LanguageMode>(language_mode);
300}
301
302
303// Strong mode behaviour must sometimes be signalled by a two valued enum where
304// caching is involved, to prevent sloppy and strict mode from being incorrectly
305// differentiated.
306enum class Strength : bool {
307 WEAK, // sloppy, strict behaviour
308 STRONG // strong behaviour
309};
310
311
312inline bool is_strong(Strength strength) {
313 return strength == Strength::STRONG;
314}
315
316
317inline std::ostream& operator<<(std::ostream& os, const Strength& strength) {
318 return os << (is_strong(strength) ? "strong" : "weak");
319}
320
321
322inline Strength strength(LanguageMode language_mode) {
323 return is_strong(language_mode) ? Strength::STRONG : Strength::WEAK;
324}
325
326
327inline size_t hash_value(Strength strength) {
328 return static_cast<size_t>(strength);
329}
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000330
331
332// Mask for the sign bit in a smi.
333const intptr_t kSmiSignMask = kIntptrSignBit;
334
335const int kObjectAlignmentBits = kPointerSizeLog2;
336const intptr_t kObjectAlignment = 1 << kObjectAlignmentBits;
337const intptr_t kObjectAlignmentMask = kObjectAlignment - 1;
338
339// Desired alignment for pointers.
340const intptr_t kPointerAlignment = (1 << kPointerSizeLog2);
341const intptr_t kPointerAlignmentMask = kPointerAlignment - 1;
342
343// Desired alignment for double values.
344const intptr_t kDoubleAlignment = 8;
345const intptr_t kDoubleAlignmentMask = kDoubleAlignment - 1;
346
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000347// Desired alignment for 128 bit SIMD values.
348const intptr_t kSimd128Alignment = 16;
349const intptr_t kSimd128AlignmentMask = kSimd128Alignment - 1;
350
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000351// Desired alignment for generated code is 32 bytes (to improve cache line
352// utilization).
353const int kCodeAlignmentBits = 5;
354const intptr_t kCodeAlignment = 1 << kCodeAlignmentBits;
355const intptr_t kCodeAlignmentMask = kCodeAlignment - 1;
356
357// The owner field of a page is tagged with the page header tag. We need that
358// to find out if a slot is part of a large object. If we mask out the lower
359// 0xfffff bits (1M pages), go to the owner offset, and see that this field
360// is tagged with the page header tag, we can just look up the owner.
361// Otherwise, we know that we are somewhere (not within the first 1M) in a
362// large object.
363const int kPageHeaderTag = 3;
364const int kPageHeaderTagSize = 2;
365const intptr_t kPageHeaderTagMask = (1 << kPageHeaderTagSize) - 1;
366
367
368// Zap-value: The value used for zapping dead objects.
369// Should be a recognizable hex value tagged as a failure.
370#ifdef V8_HOST_ARCH_64_BIT
371const Address kZapValue =
372 reinterpret_cast<Address>(V8_UINT64_C(0xdeadbeedbeadbeef));
373const Address kHandleZapValue =
374 reinterpret_cast<Address>(V8_UINT64_C(0x1baddead0baddeaf));
375const Address kGlobalHandleZapValue =
376 reinterpret_cast<Address>(V8_UINT64_C(0x1baffed00baffedf));
377const Address kFromSpaceZapValue =
378 reinterpret_cast<Address>(V8_UINT64_C(0x1beefdad0beefdaf));
379const uint64_t kDebugZapValue = V8_UINT64_C(0xbadbaddbbadbaddb);
380const uint64_t kSlotsZapValue = V8_UINT64_C(0xbeefdeadbeefdeef);
381const uint64_t kFreeListZapValue = 0xfeed1eaffeed1eaf;
382#else
383const Address kZapValue = reinterpret_cast<Address>(0xdeadbeef);
384const Address kHandleZapValue = reinterpret_cast<Address>(0xbaddeaf);
385const Address kGlobalHandleZapValue = reinterpret_cast<Address>(0xbaffedf);
386const Address kFromSpaceZapValue = reinterpret_cast<Address>(0xbeefdaf);
387const uint32_t kSlotsZapValue = 0xbeefdeef;
388const uint32_t kDebugZapValue = 0xbadbaddb;
389const uint32_t kFreeListZapValue = 0xfeed1eaf;
390#endif
391
392const int kCodeZapValue = 0xbadc0de;
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400393const uint32_t kPhantomReferenceZap = 0xca11bac;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000394
395// On Intel architecture, cache line size is 64 bytes.
396// On ARM it may be less (32 bytes), but as far this constant is
397// used for aligning data, it doesn't hurt to align on a greater value.
398#define PROCESSOR_CACHE_LINE_SIZE 64
399
400// Constants relevant to double precision floating point numbers.
401// If looking only at the top 32 bits, the QNaN mask is bits 19 to 30.
402const uint32_t kQuietNaNHighBitsMask = 0xfff << (51 - 32);
403
404
405// -----------------------------------------------------------------------------
406// Forward declarations for frequently used classes
407
408class AccessorInfo;
409class Allocation;
410class Arguments;
411class Assembler;
412class Code;
413class CodeGenerator;
414class CodeStub;
415class Context;
416class Debug;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000417class DebugInfo;
418class Descriptor;
419class DescriptorArray;
420class TransitionArray;
421class ExternalReference;
422class FixedArray;
423class FunctionTemplateInfo;
424class MemoryChunk;
425class SeededNumberDictionary;
426class UnseededNumberDictionary;
427class NameDictionary;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000428class GlobalDictionary;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000429template <typename T> class MaybeHandle;
430template <typename T> class Handle;
431class Heap;
432class HeapObject;
433class IC;
434class InterceptorInfo;
435class Isolate;
436class JSReceiver;
437class JSArray;
438class JSFunction;
439class JSObject;
440class LargeObjectSpace;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000441class MacroAssembler;
442class Map;
443class MapSpace;
444class MarkCompactCollector;
445class NewSpace;
446class Object;
447class OldSpace;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000448class ParameterCount;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000449class Foreign;
450class Scope;
451class ScopeInfo;
452class Script;
453class Smi;
454template <typename Config, class Allocator = FreeStoreAllocationPolicy>
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000455class SplayTree;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000456class String;
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400457class Symbol;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000458class Name;
459class Struct;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000460class TypeFeedbackVector;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000461class Variable;
462class RelocInfo;
463class Deserializer;
464class MessageLocation;
465
466typedef bool (*WeakSlotCallback)(Object** pointer);
467
468typedef bool (*WeakSlotCallbackWithHeap)(Heap* heap, Object** pointer);
469
470// -----------------------------------------------------------------------------
471// Miscellaneous
472
473// NOTE: SpaceIterator depends on AllocationSpace enumeration values being
474// consecutive.
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400475// Keep this enum in sync with the ObjectSpace enum in v8.h
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000476enum AllocationSpace {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000477 NEW_SPACE, // Semispaces collected with copying collector.
478 OLD_SPACE, // May contain pointers to new space.
479 CODE_SPACE, // No pointers to new space, marked executable.
480 MAP_SPACE, // Only and all map objects.
481 LO_SPACE, // Promoted large objects.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000482
483 FIRST_SPACE = NEW_SPACE,
484 LAST_SPACE = LO_SPACE,
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000485 FIRST_PAGED_SPACE = OLD_SPACE,
486 LAST_PAGED_SPACE = MAP_SPACE
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000487};
488const int kSpaceTagSize = 3;
489const int kSpaceTagMask = (1 << kSpaceTagSize) - 1;
490
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000491enum AllocationAlignment {
492 kWordAligned,
493 kDoubleAligned,
494 kDoubleUnaligned,
495 kSimd128Unaligned
496};
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000497
498// A flag that indicates whether objects should be pretenured when
499// allocated (allocated directly into the old generation) or not
500// (allocated in the young generation if the object size and type
501// allows).
502enum PretenureFlag { NOT_TENURED, TENURED };
503
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000504inline std::ostream& operator<<(std::ostream& os, const PretenureFlag& flag) {
505 switch (flag) {
506 case NOT_TENURED:
507 return os << "NotTenured";
508 case TENURED:
509 return os << "Tenured";
510 }
511 UNREACHABLE();
512 return os;
513}
514
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000515enum MinimumCapacity {
516 USE_DEFAULT_MINIMUM_CAPACITY,
517 USE_CUSTOM_MINIMUM_CAPACITY
518};
519
520enum GarbageCollector { SCAVENGER, MARK_COMPACTOR };
521
522enum Executability { NOT_EXECUTABLE, EXECUTABLE };
523
524enum VisitMode {
525 VISIT_ALL,
526 VISIT_ALL_IN_SCAVENGE,
527 VISIT_ALL_IN_SWEEP_NEWSPACE,
528 VISIT_ONLY_STRONG
529};
530
531// Flag indicating whether code is built into the VM (one of the natives files).
532enum NativesFlag { NOT_NATIVES_CODE, NATIVES_CODE };
533
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000534// JavaScript defines two kinds of 'nil'.
535enum NilValue { kNullValue, kUndefinedValue };
536
537// ParseRestriction is used to restrict the set of valid statements in a
538// unit of compilation. Restriction violations cause a syntax error.
539enum ParseRestriction {
540 NO_PARSE_RESTRICTION, // All expressions are allowed.
541 ONLY_SINGLE_FUNCTION_LITERAL // Only a single FunctionLiteral expression.
542};
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000543
544// A CodeDesc describes a buffer holding instructions and relocation
545// information. The instructions start at the beginning of the buffer
546// and grow forward, the relocation information starts at the end of
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000547// the buffer and grows backward. A constant pool may exist at the
548// end of the instructions.
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100549//
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000550// |<--------------- buffer_size ----------------------------------->|
551// |<------------- instr_size ---------->| |<-- reloc_size -->|
552// | |<- const_pool_size ->| |
553// +=====================================+========+==================+
554// | instructions | data | free | reloc info |
555// +=====================================+========+==================+
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000556// ^
557// |
558// buffer
559
560struct CodeDesc {
561 byte* buffer;
562 int buffer_size;
563 int instr_size;
564 int reloc_size;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000565 int constant_pool_size;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000566 Assembler* origin;
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100567};
568
569
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000570// Callback function used for checking constraints when copying/relocating
571// objects. Returns true if an object can be copied/relocated from its
572// old_addr to a new_addr.
573typedef bool (*ConstraintCallback)(Address new_addr, Address old_addr);
574
575
576// Callback function on inline caches, used for iterating over inline caches
577// in compiled code.
578typedef void (*InlineCacheCallback)(Code* code, Address ic);
579
580
581// State for inline cache call sites. Aliased as IC::State.
582enum InlineCacheState {
583 // Has never been executed.
584 UNINITIALIZED,
585 // Has been executed but monomorhic state has been delayed.
586 PREMONOMORPHIC,
587 // Has been executed and only one receiver type has been seen.
588 MONOMORPHIC,
589 // Check failed due to prototype (or map deprecation).
590 PROTOTYPE_FAILURE,
591 // Multiple receiver types have been seen.
592 POLYMORPHIC,
593 // Many receiver types have been seen.
594 MEGAMORPHIC,
595 // A generic handler is installed and no extra typefeedback is recorded.
596 GENERIC,
597 // Special state for debug break or step in prepare stubs.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000598 DEBUG_STUB
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000599};
600
601
602enum CacheHolderFlag {
603 kCacheOnPrototype,
604 kCacheOnPrototypeReceiverIsDictionary,
605 kCacheOnPrototypeReceiverIsPrimitive,
606 kCacheOnReceiver
607};
608
609
610// The Store Buffer (GC).
611typedef enum {
612 kStoreBufferFullEvent,
613 kStoreBufferStartScanningPagesEvent,
614 kStoreBufferScanningPageEvent
615} StoreBufferEvent;
616
617
618typedef void (*StoreBufferCallback)(Heap* heap,
619 MemoryChunk* page,
620 StoreBufferEvent event);
621
622
623// Union used for fast testing of specific double values.
624union DoubleRepresentation {
625 double value;
626 int64_t bits;
627 DoubleRepresentation(double x) { value = x; }
628 bool operator==(const DoubleRepresentation& other) const {
629 return bits == other.bits;
630 }
631};
632
633
634// Union used for customized checking of the IEEE double types
635// inlined within v8 runtime, rather than going to the underlying
636// platform headers and libraries
637union IeeeDoubleLittleEndianArchType {
638 double d;
639 struct {
640 unsigned int man_low :32;
641 unsigned int man_high :20;
642 unsigned int exp :11;
643 unsigned int sign :1;
644 } bits;
645};
646
647
648union IeeeDoubleBigEndianArchType {
649 double d;
650 struct {
651 unsigned int sign :1;
652 unsigned int exp :11;
653 unsigned int man_high :20;
654 unsigned int man_low :32;
655 } bits;
656};
657
658
659// AccessorCallback
660struct AccessorDescriptor {
661 Object* (*getter)(Isolate* isolate, Object* object, void* data);
662 Object* (*setter)(
663 Isolate* isolate, JSObject* object, Object* value, void* data);
664 void* data;
665};
666
667
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000668// -----------------------------------------------------------------------------
669// Macros
670
671// Testers for test.
672
673#define HAS_SMI_TAG(value) \
674 ((reinterpret_cast<intptr_t>(value) & kSmiTagMask) == kSmiTag)
675
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000676// OBJECT_POINTER_ALIGN returns the value aligned as a HeapObject pointer
677#define OBJECT_POINTER_ALIGN(value) \
678 (((value) + kObjectAlignmentMask) & ~kObjectAlignmentMask)
679
680// POINTER_SIZE_ALIGN returns the value aligned as a pointer.
681#define POINTER_SIZE_ALIGN(value) \
682 (((value) + kPointerAlignmentMask) & ~kPointerAlignmentMask)
683
684// CODE_POINTER_ALIGN returns the value aligned as a generated code segment.
685#define CODE_POINTER_ALIGN(value) \
686 (((value) + kCodeAlignmentMask) & ~kCodeAlignmentMask)
687
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000688// DOUBLE_POINTER_ALIGN returns the value algined for double pointers.
689#define DOUBLE_POINTER_ALIGN(value) \
690 (((value) + kDoubleAlignmentMask) & ~kDoubleAlignmentMask)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000691
692
693// CPU feature flags.
694enum CpuFeature {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400695 // x86
696 SSE4_1,
697 SSE3,
698 SAHF,
699 AVX,
700 FMA3,
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000701 BMI1,
702 BMI2,
703 LZCNT,
704 POPCNT,
705 ATOM,
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400706 // ARM
707 VFP3,
708 ARMv7,
709 ARMv8,
710 SUDIV,
711 MLS,
712 UNALIGNED_ACCESSES,
713 MOVW_MOVT_IMMEDIATE_LOADS,
714 VFP32DREGS,
715 NEON,
716 // MIPS, MIPS64
717 FPU,
718 FP64FPU,
719 MIPSr1,
720 MIPSr2,
721 MIPSr6,
722 // ARM64
723 ALWAYS_ALIGN_CSP,
724 COHERENT_CACHE,
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000725 // PPC
726 FPR_GPR_MOV,
727 LWSYNC,
728 ISELECT,
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400729 NUMBER_OF_CPU_FEATURES
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000730};
731
732
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000733// Defines hints about receiver values based on structural knowledge.
734enum class ConvertReceiverMode : unsigned {
735 kNullOrUndefined, // Guaranteed to be null or undefined.
736 kNotNullOrUndefined, // Guaranteed to never be null or undefined.
737 kAny // No specific knowledge about receiver.
738};
739
740inline size_t hash_value(ConvertReceiverMode mode) {
741 return bit_cast<unsigned>(mode);
742}
743
744inline std::ostream& operator<<(std::ostream& os, ConvertReceiverMode mode) {
745 switch (mode) {
746 case ConvertReceiverMode::kNullOrUndefined:
747 return os << "NULL_OR_UNDEFINED";
748 case ConvertReceiverMode::kNotNullOrUndefined:
749 return os << "NOT_NULL_OR_UNDEFINED";
750 case ConvertReceiverMode::kAny:
751 return os << "ANY";
752 }
753 UNREACHABLE();
754 return os;
755}
756
757
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000758// Used to specify if a macro instruction must perform a smi check on tagged
759// values.
760enum SmiCheckType {
761 DONT_DO_SMI_CHECK,
762 DO_SMI_CHECK
763};
764
765
766enum ScopeType {
767 EVAL_SCOPE, // The top-level scope for an eval source.
768 FUNCTION_SCOPE, // The top-level scope for a function.
769 MODULE_SCOPE, // The scope introduced by a module literal
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400770 SCRIPT_SCOPE, // The top-level scope for a script or a top-level eval.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000771 CATCH_SCOPE, // The scope introduced by catch.
772 BLOCK_SCOPE, // The scope introduced by a new block.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000773 WITH_SCOPE // The scope introduced by with.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000774};
775
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000776// The mips architecture prior to revision 5 has inverted encoding for sNaN.
777#if (V8_TARGET_ARCH_MIPS && !defined(_MIPS_ARCH_MIPS32R6)) || \
778 (V8_TARGET_ARCH_MIPS64 && !defined(_MIPS_ARCH_MIPS64R6))
779const uint32_t kHoleNanUpper32 = 0xFFFF7FFF;
780const uint32_t kHoleNanLower32 = 0xFFFF7FFF;
781#else
782const uint32_t kHoleNanUpper32 = 0xFFF7FFFF;
783const uint32_t kHoleNanLower32 = 0xFFF7FFFF;
784#endif
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000785
786const uint64_t kHoleNanInt64 =
787 (static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32;
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000788
789
790// ES6 section 20.1.2.6 Number.MAX_SAFE_INTEGER
791const double kMaxSafeInteger = 9007199254740991.0; // 2^53-1
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000792
793
794// The order of this enum has to be kept in sync with the predicates below.
795enum VariableMode {
796 // User declared variables:
797 VAR, // declared via 'var', and 'function' declarations
798
799 CONST_LEGACY, // declared via legacy 'const' declarations
800
801 LET, // declared via 'let' declarations (first lexical)
802
803 CONST, // declared via 'const' declarations
804
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000805 IMPORT, // declared via 'import' declarations (last lexical)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000806
807 // Variables introduced by the compiler:
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000808 TEMPORARY, // temporary variables (not user-visible), stack-allocated
809 // unless the scope as a whole has forced context allocation
810
811 DYNAMIC, // always require dynamic lookup (we don't know
812 // the declaration)
813
814 DYNAMIC_GLOBAL, // requires dynamic lookup, but we know that the
815 // variable is global unless it has been shadowed
816 // by an eval-introduced variable
817
818 DYNAMIC_LOCAL // requires dynamic lookup, but we know that the
819 // variable is local and where it is unless it
820 // has been shadowed by an eval-introduced
821 // variable
822};
823
824
825inline bool IsDynamicVariableMode(VariableMode mode) {
826 return mode >= DYNAMIC && mode <= DYNAMIC_LOCAL;
827}
828
829
830inline bool IsDeclaredVariableMode(VariableMode mode) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000831 return mode >= VAR && mode <= IMPORT;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000832}
833
834
835inline bool IsLexicalVariableMode(VariableMode mode) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000836 return mode >= LET && mode <= IMPORT;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000837}
838
839
840inline bool IsImmutableVariableMode(VariableMode mode) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000841 return mode == CONST || mode == CONST_LEGACY || mode == IMPORT;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000842}
843
844
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000845enum class VariableLocation {
846 // Before and during variable allocation, a variable whose location is
847 // not yet determined. After allocation, a variable looked up as a
848 // property on the global object (and possibly absent). name() is the
849 // variable name, index() is invalid.
850 UNALLOCATED,
851
852 // A slot in the parameter section on the stack. index() is the
853 // parameter index, counting left-to-right. The receiver is index -1;
854 // the first parameter is index 0.
855 PARAMETER,
856
857 // A slot in the local section on the stack. index() is the variable
858 // index in the stack frame, starting at 0.
859 LOCAL,
860
861 // An indexed slot in a heap context. index() is the variable index in
862 // the context object on the heap, starting at 0. scope() is the
863 // corresponding scope.
864 CONTEXT,
865
866 // An indexed slot in a script context that contains a respective global
867 // property cell. name() is the variable name, index() is the variable
868 // index in the context object on the heap, starting at 0. scope() is the
869 // corresponding script scope.
870 GLOBAL,
871
872 // A named slot in a heap context. name() is the variable name in the
873 // context object on the heap, with lookup starting at the current
874 // context. index() is invalid.
875 LOOKUP
876};
877
878
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000879// ES6 Draft Rev3 10.2 specifies declarative environment records with mutable
880// and immutable bindings that can be in two states: initialized and
881// uninitialized. In ES5 only immutable bindings have these two states. When
882// accessing a binding, it needs to be checked for initialization. However in
883// the following cases the binding is initialized immediately after creation
884// so the initialization check can always be skipped:
885// 1. Var declared local variables.
886// var foo;
887// 2. A local variable introduced by a function declaration.
888// function foo() {}
889// 3. Parameters
890// function x(foo) {}
891// 4. Catch bound variables.
892// try {} catch (foo) {}
893// 6. Function variables of named function expressions.
894// var x = function foo() {}
895// 7. Implicit binding of 'this'.
896// 8. Implicit binding of 'arguments' in functions.
897//
898// ES5 specified object environment records which are introduced by ES elements
899// such as Program and WithStatement that associate identifier bindings with the
900// properties of some object. In the specification only mutable bindings exist
901// (which may be non-writable) and have no distinct initialization step. However
902// V8 allows const declarations in global code with distinct creation and
903// initialization steps which are represented by non-writable properties in the
904// global object. As a result also these bindings need to be checked for
905// initialization.
906//
907// The following enum specifies a flag that indicates if the binding needs a
908// distinct initialization step (kNeedsInitialization) or if the binding is
909// immediately initialized upon creation (kCreatedInitialized).
910enum InitializationFlag {
911 kNeedsInitialization,
912 kCreatedInitialized
913};
914
915
916enum MaybeAssignedFlag { kNotAssigned, kMaybeAssigned };
917
918
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000919// Serialized in PreparseData, so numeric values should not be changed.
920enum ParseErrorType { kSyntaxError = 0, kReferenceError = 1 };
921
922
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000923enum ClearExceptionFlag {
924 KEEP_EXCEPTION,
925 CLEAR_EXCEPTION
926};
927
928
929enum MinusZeroMode {
930 TREAT_MINUS_ZERO_AS_ZERO,
931 FAIL_ON_MINUS_ZERO
932};
933
934
935enum Signedness { kSigned, kUnsigned };
936
937
938enum FunctionKind {
939 kNormalFunction = 0,
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000940 kArrowFunction = 1 << 0,
941 kGeneratorFunction = 1 << 1,
942 kConciseMethod = 1 << 2,
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400943 kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod,
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000944 kAccessorFunction = 1 << 3,
945 kDefaultConstructor = 1 << 4,
946 kSubclassConstructor = 1 << 5,
947 kBaseConstructor = 1 << 6,
948 kInObjectLiteral = 1 << 7,
949 kDefaultBaseConstructor = kDefaultConstructor | kBaseConstructor,
950 kDefaultSubclassConstructor = kDefaultConstructor | kSubclassConstructor,
951 kClassConstructor =
952 kBaseConstructor | kSubclassConstructor | kDefaultConstructor,
953 kConciseMethodInObjectLiteral = kConciseMethod | kInObjectLiteral,
954 kConciseGeneratorMethodInObjectLiteral =
955 kConciseGeneratorMethod | kInObjectLiteral,
956 kAccessorFunctionInObjectLiteral = kAccessorFunction | kInObjectLiteral,
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000957};
958
959
960inline bool IsValidFunctionKind(FunctionKind kind) {
961 return kind == FunctionKind::kNormalFunction ||
962 kind == FunctionKind::kArrowFunction ||
963 kind == FunctionKind::kGeneratorFunction ||
964 kind == FunctionKind::kConciseMethod ||
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400965 kind == FunctionKind::kConciseGeneratorMethod ||
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000966 kind == FunctionKind::kAccessorFunction ||
967 kind == FunctionKind::kDefaultBaseConstructor ||
968 kind == FunctionKind::kDefaultSubclassConstructor ||
969 kind == FunctionKind::kBaseConstructor ||
970 kind == FunctionKind::kSubclassConstructor ||
971 kind == FunctionKind::kConciseMethodInObjectLiteral ||
972 kind == FunctionKind::kConciseGeneratorMethodInObjectLiteral ||
973 kind == FunctionKind::kAccessorFunctionInObjectLiteral;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000974}
975
976
977inline bool IsArrowFunction(FunctionKind kind) {
978 DCHECK(IsValidFunctionKind(kind));
979 return kind & FunctionKind::kArrowFunction;
980}
981
982
983inline bool IsGeneratorFunction(FunctionKind kind) {
984 DCHECK(IsValidFunctionKind(kind));
985 return kind & FunctionKind::kGeneratorFunction;
986}
987
988
989inline bool IsConciseMethod(FunctionKind kind) {
990 DCHECK(IsValidFunctionKind(kind));
991 return kind & FunctionKind::kConciseMethod;
992}
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400993
994
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000995inline bool IsAccessorFunction(FunctionKind kind) {
996 DCHECK(IsValidFunctionKind(kind));
997 return kind & FunctionKind::kAccessorFunction;
998}
999
1000
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001001inline bool IsDefaultConstructor(FunctionKind kind) {
1002 DCHECK(IsValidFunctionKind(kind));
1003 return kind & FunctionKind::kDefaultConstructor;
1004}
1005
1006
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001007inline bool IsBaseConstructor(FunctionKind kind) {
1008 DCHECK(IsValidFunctionKind(kind));
1009 return kind & FunctionKind::kBaseConstructor;
1010}
1011
1012
1013inline bool IsSubclassConstructor(FunctionKind kind) {
1014 DCHECK(IsValidFunctionKind(kind));
1015 return kind & FunctionKind::kSubclassConstructor;
1016}
1017
1018
1019inline bool IsClassConstructor(FunctionKind kind) {
1020 DCHECK(IsValidFunctionKind(kind));
1021 return kind & FunctionKind::kClassConstructor;
1022}
1023
1024
1025inline bool IsConstructable(FunctionKind kind, LanguageMode mode) {
1026 if (IsAccessorFunction(kind)) return false;
1027 if (IsConciseMethod(kind) && !IsGeneratorFunction(kind)) return false;
1028 if (IsArrowFunction(kind)) return false;
1029 if (is_strong(mode)) return IsClassConstructor(kind);
1030 return true;
1031}
1032
1033
1034inline bool IsInObjectLiteral(FunctionKind kind) {
1035 DCHECK(IsValidFunctionKind(kind));
1036 return kind & FunctionKind::kInObjectLiteral;
1037}
1038
1039
1040inline FunctionKind WithObjectLiteralBit(FunctionKind kind) {
1041 kind = static_cast<FunctionKind>(kind | FunctionKind::kInObjectLiteral);
1042 DCHECK(IsValidFunctionKind(kind));
1043 return kind;
1044}
1045} // namespace internal
1046} // namespace v8
Steve Blocka7e24c12009-10-30 11:49:00 +00001047
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001048namespace i = v8::internal;
1049
Steve Blocka7e24c12009-10-30 11:49:00 +00001050#endif // V8_GLOBALS_H_