2012-02-22 12:26:36 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-11-05 19:18:10 +00:00
|
|
|
#ifndef V8_GLOBALS_H_
|
|
|
|
#define V8_GLOBALS_H_
|
|
|
|
|
2014-10-21 08:25:14 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
2011-09-07 12:39:53 +00:00
|
|
|
|
2017-10-18 14:06:04 +00:00
|
|
|
#include <limits>
|
2015-04-27 09:12:58 +00:00
|
|
|
#include <ostream>
|
|
|
|
|
2018-09-07 09:03:35 +00:00
|
|
|
#include "include/v8-internal.h"
|
2018-11-27 15:21:36 +00:00
|
|
|
#include "src/base/atomic-utils.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/base/build_config.h"
|
2016-12-19 16:30:36 +00:00
|
|
|
#include "src/base/flags.h"
|
2014-06-30 13:25:46 +00:00
|
|
|
#include "src/base/logging.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/base/macros.h"
|
2014-04-23 11:51:28 +00:00
|
|
|
|
2017-10-18 14:06:04 +00:00
|
|
|
#define V8_INFINITY std::numeric_limits<double>::infinity()
|
2014-12-20 13:17:20 +00:00
|
|
|
|
2013-07-31 07:51:46 +00:00
|
|
|
namespace v8 {
|
2014-06-30 13:25:46 +00:00
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class Mutex;
|
|
|
|
class RecursiveMutex;
|
|
|
|
}
|
|
|
|
|
2013-07-31 07:51:46 +00:00
|
|
|
namespace internal {
|
2013-07-29 12:12:39 +00:00
|
|
|
|
2010-10-25 16:40:41 +00:00
|
|
|
// Determine whether we are running in a simulated environment.
|
2010-10-26 08:12:17 +00:00
|
|
|
// Setting USE_SIMULATOR explicitly from the build script will force
|
|
|
|
// the use of a simulated environment.
|
|
|
|
#if !defined(USE_SIMULATOR)
|
2014-03-21 09:28:26 +00:00
|
|
|
#if (V8_TARGET_ARCH_ARM64 && !V8_HOST_ARCH_ARM64)
|
2014-02-12 09:19:30 +00:00
|
|
|
#define USE_SIMULATOR 1
|
|
|
|
#endif
|
2013-07-31 07:51:46 +00:00
|
|
|
#if (V8_TARGET_ARCH_ARM && !V8_HOST_ARCH_ARM)
|
|
|
|
#define USE_SIMULATOR 1
|
|
|
|
#endif
|
2015-01-16 07:42:00 +00:00
|
|
|
#if (V8_TARGET_ARCH_PPC && !V8_HOST_ARCH_PPC)
|
|
|
|
#define USE_SIMULATOR 1
|
|
|
|
#endif
|
2013-07-31 07:51:46 +00:00
|
|
|
#if (V8_TARGET_ARCH_MIPS && !V8_HOST_ARCH_MIPS)
|
|
|
|
#define USE_SIMULATOR 1
|
2010-10-26 08:12:17 +00:00
|
|
|
#endif
|
2014-07-09 11:08:26 +00:00
|
|
|
#if (V8_TARGET_ARCH_MIPS64 && !V8_HOST_ARCH_MIPS64)
|
|
|
|
#define USE_SIMULATOR 1
|
|
|
|
#endif
|
2016-03-10 14:02:50 +00:00
|
|
|
#if (V8_TARGET_ARCH_S390 && !V8_HOST_ARCH_S390)
|
|
|
|
#define USE_SIMULATOR 1
|
|
|
|
#endif
|
2013-06-21 13:02:38 +00:00
|
|
|
#endif
|
|
|
|
|
2015-06-04 14:44:00 +00:00
|
|
|
// Determine whether the architecture uses an embedded constant pool
|
|
|
|
// (contiguous constant pool embedded in code object).
|
|
|
|
#if V8_TARGET_ARCH_PPC
|
2018-09-19 17:41:30 +00:00
|
|
|
#define V8_EMBEDDED_CONSTANT_POOL true
|
2015-06-04 14:44:00 +00:00
|
|
|
#else
|
2018-09-19 17:41:30 +00:00
|
|
|
#define V8_EMBEDDED_CONSTANT_POOL false
|
2015-06-04 14:44:00 +00:00
|
|
|
#endif
|
2014-03-11 20:52:00 +00:00
|
|
|
|
2014-09-19 11:26:36 +00:00
|
|
|
#ifdef V8_TARGET_ARCH_ARM
|
|
|
|
// Set stack limit lower for ARM than for other architectures because
|
|
|
|
// stack allocating MacroAssembler takes 120K bytes.
|
|
|
|
// See issue crbug.com/405338
|
|
|
|
#define V8_DEFAULT_STACK_SIZE_KB 864
|
|
|
|
#else
|
|
|
|
// Slightly less than 1MB, since Windows' default stack size for
|
|
|
|
// the main execution thread is 1MB for both 32 and 64-bit.
|
|
|
|
#define V8_DEFAULT_STACK_SIZE_KB 984
|
|
|
|
#endif
|
|
|
|
|
2017-05-30 17:04:27 +00:00
|
|
|
// Minimum stack size in KB required by compilers.
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kStackSpaceRequiredForCompilation = 40;
|
2014-09-19 11:26:36 +00:00
|
|
|
|
2014-11-11 10:24:52 +00:00
|
|
|
// Determine whether double field unboxing feature is enabled.
|
2019-02-27 14:45:43 +00:00
|
|
|
#if V8_TARGET_ARCH_64_BIT && !defined(V8_COMPRESS_POINTERS)
|
2018-09-19 17:41:30 +00:00
|
|
|
#define V8_DOUBLE_FIELDS_UNBOXING true
|
2014-11-11 10:24:52 +00:00
|
|
|
#else
|
2018-09-19 17:41:30 +00:00
|
|
|
#define V8_DOUBLE_FIELDS_UNBOXING false
|
2014-11-11 10:24:52 +00:00
|
|
|
#endif
|
|
|
|
|
2017-05-16 15:52:10 +00:00
|
|
|
// Some types of tracing require the SFI to store a unique ID.
|
|
|
|
#if defined(V8_TRACE_MAPS) || defined(V8_TRACE_IGNITION)
|
2018-09-19 17:41:30 +00:00
|
|
|
#define V8_SFI_HAS_UNIQUE_ID true
|
2017-05-16 15:52:10 +00:00
|
|
|
#endif
|
|
|
|
|
2017-08-01 01:41:13 +00:00
|
|
|
// Superclass for classes only using static method functions.
|
|
|
|
// The subclass of AllStatic cannot be instantiated at all.
|
|
|
|
class AllStatic {
|
|
|
|
#ifdef DEBUG
|
|
|
|
public:
|
|
|
|
AllStatic() = delete;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2013-07-30 10:36:58 +00:00
|
|
|
typedef uint8_t byte;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Constants
|
|
|
|
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int KB = 1024;
|
|
|
|
constexpr int MB = KB * KB;
|
|
|
|
constexpr int GB = KB * KB * KB;
|
|
|
|
constexpr int kMaxInt = 0x7FFFFFFF;
|
|
|
|
constexpr int kMinInt = -kMaxInt - 1;
|
|
|
|
constexpr int kMaxInt8 = (1 << 7) - 1;
|
|
|
|
constexpr int kMinInt8 = -(1 << 7);
|
|
|
|
constexpr int kMaxUInt8 = (1 << 8) - 1;
|
|
|
|
constexpr int kMinUInt8 = 0;
|
|
|
|
constexpr int kMaxInt16 = (1 << 15) - 1;
|
|
|
|
constexpr int kMinInt16 = -(1 << 15);
|
|
|
|
constexpr int kMaxUInt16 = (1 << 16) - 1;
|
|
|
|
constexpr int kMinUInt16 = 0;
|
|
|
|
|
|
|
|
constexpr uint32_t kMaxUInt32 = 0xFFFFFFFFu;
|
|
|
|
constexpr int kMinUInt32 = 0;
|
|
|
|
|
|
|
|
constexpr int kUInt8Size = sizeof(uint8_t);
|
2019-01-14 13:34:42 +00:00
|
|
|
constexpr int kByteSize = sizeof(byte);
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kCharSize = sizeof(char);
|
|
|
|
constexpr int kShortSize = sizeof(short); // NOLINT
|
|
|
|
constexpr int kUInt16Size = sizeof(uint16_t);
|
|
|
|
constexpr int kIntSize = sizeof(int);
|
|
|
|
constexpr int kInt32Size = sizeof(int32_t);
|
|
|
|
constexpr int kInt64Size = sizeof(int64_t);
|
|
|
|
constexpr int kUInt32Size = sizeof(uint32_t);
|
|
|
|
constexpr int kSizetSize = sizeof(size_t);
|
|
|
|
constexpr int kFloatSize = sizeof(float);
|
|
|
|
constexpr int kDoubleSize = sizeof(double);
|
|
|
|
constexpr int kIntptrSize = sizeof(intptr_t);
|
|
|
|
constexpr int kUIntptrSize = sizeof(uintptr_t);
|
2018-11-19 15:44:21 +00:00
|
|
|
constexpr int kSystemPointerSize = sizeof(void*);
|
|
|
|
constexpr int kSystemPointerHexDigits = kSystemPointerSize == 4 ? 8 : 12;
|
2019-01-31 14:16:55 +00:00
|
|
|
constexpr int kPCOnStackSize = kSystemPointerSize;
|
|
|
|
constexpr int kFPOnStackSize = kSystemPointerSize;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2017-07-18 15:55:06 +00:00
|
|
|
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32
|
2018-11-19 15:44:21 +00:00
|
|
|
constexpr int kElidedFrameSlots = kPCOnStackSize / kSystemPointerSize;
|
2016-03-30 14:08:03 +00:00
|
|
|
#else
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kElidedFrameSlots = 0;
|
2016-03-30 14:08:03 +00:00
|
|
|
#endif
|
|
|
|
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kDoubleSizeLog2 = 3;
|
2018-05-18 16:01:01 +00:00
|
|
|
#if V8_TARGET_ARCH_ARM64
|
|
|
|
// ARM64 only supports direct calls within a 128 MB range.
|
2018-12-28 13:51:59 +00:00
|
|
|
constexpr size_t kMaxWasmCodeMB = 128;
|
2018-05-18 16:01:01 +00:00
|
|
|
#else
|
2018-12-28 13:51:59 +00:00
|
|
|
constexpr size_t kMaxWasmCodeMB = 1024;
|
2018-05-18 16:01:01 +00:00
|
|
|
#endif
|
2018-12-28 13:51:59 +00:00
|
|
|
constexpr size_t kMaxWasmCodeMemory = kMaxWasmCodeMB * MB;
|
2011-07-13 13:50:27 +00:00
|
|
|
|
2009-05-05 12:06:20 +00:00
|
|
|
#if V8_HOST_ARCH_64_BIT
|
2018-11-19 15:44:21 +00:00
|
|
|
constexpr int kSystemPointerSizeLog2 = 3;
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr intptr_t kIntptrSignBit =
|
2017-12-01 14:01:22 +00:00
|
|
|
static_cast<intptr_t>(uintptr_t{0x8000000000000000});
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr uintptr_t kUintptrAllBitsSet = uintptr_t{0xFFFFFFFFFFFFFFFF};
|
|
|
|
constexpr bool kRequiresCodeRange = true;
|
2018-09-13 08:53:07 +00:00
|
|
|
#if V8_HOST_ARCH_PPC && V8_TARGET_ARCH_PPC && V8_OS_LINUX
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr size_t kMaximalCodeRangeSize = 512 * MB;
|
2018-11-27 12:09:27 +00:00
|
|
|
constexpr size_t kMinExpectedOSPageSize = 64 * KB; // OS page on PPC Linux
|
2018-04-30 13:42:39 +00:00
|
|
|
#elif V8_TARGET_ARCH_ARM64
|
|
|
|
constexpr size_t kMaximalCodeRangeSize = 128 * MB;
|
2018-11-27 12:09:27 +00:00
|
|
|
constexpr size_t kMinExpectedOSPageSize = 4 * KB; // OS page.
|
2015-06-09 14:50:26 +00:00
|
|
|
#else
|
2018-05-04 13:05:33 +00:00
|
|
|
constexpr size_t kMaximalCodeRangeSize = 128 * MB;
|
2018-11-27 12:09:27 +00:00
|
|
|
constexpr size_t kMinExpectedOSPageSize = 4 * KB; // OS page.
|
2015-06-09 14:50:26 +00:00
|
|
|
#endif
|
2014-10-01 09:16:57 +00:00
|
|
|
#if V8_OS_WIN
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr size_t kMinimumCodeRangeSize = 4 * MB;
|
|
|
|
constexpr size_t kReservedCodeRangePages = 1;
|
2014-10-01 09:16:57 +00:00
|
|
|
#else
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr size_t kMinimumCodeRangeSize = 3 * MB;
|
|
|
|
constexpr size_t kReservedCodeRangePages = 0;
|
2014-10-01 09:16:57 +00:00
|
|
|
#endif
|
2009-05-04 13:29:29 +00:00
|
|
|
#else
|
2018-11-19 15:44:21 +00:00
|
|
|
constexpr int kSystemPointerSizeLog2 = 2;
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr intptr_t kIntptrSignBit = 0x80000000;
|
|
|
|
constexpr uintptr_t kUintptrAllBitsSet = 0xFFFFFFFFu;
|
2019-01-31 14:16:55 +00:00
|
|
|
#if V8_HOST_ARCH_PPC && V8_TARGET_ARCH_PPC && V8_OS_LINUX
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr bool kRequiresCodeRange = false;
|
|
|
|
constexpr size_t kMaximalCodeRangeSize = 0 * MB;
|
|
|
|
constexpr size_t kMinimumCodeRangeSize = 0 * MB;
|
2018-11-27 12:09:27 +00:00
|
|
|
constexpr size_t kMinExpectedOSPageSize = 64 * KB; // OS page on PPC Linux
|
2019-01-18 13:41:25 +00:00
|
|
|
#elif V8_TARGET_ARCH_MIPS
|
|
|
|
constexpr bool kRequiresCodeRange = false;
|
|
|
|
constexpr size_t kMaximalCodeRangeSize = 2048LL * MB;
|
|
|
|
constexpr size_t kMinimumCodeRangeSize = 0 * MB;
|
|
|
|
constexpr size_t kMinExpectedOSPageSize = 4 * KB; // OS page.
|
2014-06-24 05:27:44 +00:00
|
|
|
#else
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr bool kRequiresCodeRange = false;
|
|
|
|
constexpr size_t kMaximalCodeRangeSize = 0 * MB;
|
|
|
|
constexpr size_t kMinimumCodeRangeSize = 0 * MB;
|
2018-11-27 12:09:27 +00:00
|
|
|
constexpr size_t kMinExpectedOSPageSize = 4 * KB; // OS page.
|
2009-05-04 13:29:29 +00:00
|
|
|
#endif
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr size_t kReservedCodeRangePages = 0;
|
2014-06-24 05:27:44 +00:00
|
|
|
#endif
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2018-11-19 15:44:21 +00:00
|
|
|
STATIC_ASSERT(kSystemPointerSize == (1 << kSystemPointerSizeLog2));
|
|
|
|
|
2019-03-06 10:24:13 +00:00
|
|
|
#ifdef V8_COMPRESS_POINTERS
|
|
|
|
static_assert(
|
|
|
|
kSystemPointerSize == kInt64Size,
|
|
|
|
"Pointer compression can be enabled only for 64-bit architectures");
|
|
|
|
|
|
|
|
constexpr int kTaggedSize = kInt32Size;
|
|
|
|
constexpr int kTaggedSizeLog2 = 2;
|
|
|
|
|
|
|
|
// These types define raw and atomic storage types for tagged values stored
|
|
|
|
// on V8 heap.
|
|
|
|
using Tagged_t = int32_t;
|
|
|
|
using AtomicTagged_t = base::Atomic32;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2018-11-19 15:44:21 +00:00
|
|
|
constexpr int kTaggedSize = kSystemPointerSize;
|
|
|
|
constexpr int kTaggedSizeLog2 = kSystemPointerSizeLog2;
|
|
|
|
|
2018-11-27 15:21:36 +00:00
|
|
|
// These types define raw and atomic storage types for tagged values stored
|
|
|
|
// on V8 heap.
|
|
|
|
using Tagged_t = Address;
|
|
|
|
using AtomicTagged_t = base::AtomicWord;
|
2019-03-06 10:24:13 +00:00
|
|
|
|
|
|
|
#endif // V8_COMPRESS_POINTERS
|
|
|
|
|
2019-03-21 13:23:32 +00:00
|
|
|
// Defines whether the branchless or branchful implementation of pointer
|
|
|
|
// decompression should be used.
|
|
|
|
constexpr bool kUseBranchlessPtrDecompression = true;
|
|
|
|
|
2019-03-06 10:24:13 +00:00
|
|
|
STATIC_ASSERT(kTaggedSize == (1 << kTaggedSizeLog2));
|
|
|
|
|
2018-11-27 15:21:36 +00:00
|
|
|
using AsAtomicTagged = base::AsAtomicPointerImpl<AtomicTagged_t>;
|
|
|
|
STATIC_ASSERT(sizeof(Tagged_t) == kTaggedSize);
|
|
|
|
STATIC_ASSERT(sizeof(AtomicTagged_t) == kTaggedSize);
|
|
|
|
|
2019-03-06 10:24:13 +00:00
|
|
|
STATIC_ASSERT(kTaggedSize == kApiTaggedSize);
|
|
|
|
|
2018-11-19 15:44:21 +00:00
|
|
|
// TODO(ishell): use kTaggedSize or kSystemPointerSize instead.
|
2019-03-06 10:24:13 +00:00
|
|
|
#ifndef V8_COMPRESS_POINTERS
|
2018-11-19 15:44:21 +00:00
|
|
|
constexpr int kPointerSize = kSystemPointerSize;
|
|
|
|
constexpr int kPointerSizeLog2 = kSystemPointerSizeLog2;
|
|
|
|
STATIC_ASSERT(kPointerSize == (1 << kPointerSizeLog2));
|
2018-11-21 15:10:14 +00:00
|
|
|
#endif
|
2019-03-06 10:24:13 +00:00
|
|
|
|
|
|
|
constexpr int kEmbedderDataSlotSize = kSystemPointerSize;
|
2018-11-21 15:10:14 +00:00
|
|
|
|
|
|
|
constexpr int kEmbedderDataSlotSizeInTaggedSlots =
|
|
|
|
kEmbedderDataSlotSize / kTaggedSize;
|
|
|
|
STATIC_ASSERT(kEmbedderDataSlotSize >= kSystemPointerSize);
|
|
|
|
|
2018-09-06 14:04:07 +00:00
|
|
|
constexpr int kExternalAllocationSoftLimit =
|
|
|
|
internal::Internals::kExternalAllocationSoftLimit;
|
2016-06-21 09:25:08 +00:00
|
|
|
|
2016-09-06 12:58:59 +00:00
|
|
|
// Maximum object size that gets allocated into regular pages. Objects larger
|
|
|
|
// than that size are allocated in large object space and are never moved in
|
|
|
|
// memory. This also applies to new space allocation, since objects are never
|
|
|
|
// migrated from new space to large object space. Takes double alignment into
|
|
|
|
// account.
|
2016-09-07 09:43:13 +00:00
|
|
|
//
|
2019-03-04 12:24:44 +00:00
|
|
|
// Current value: half of the page size.
|
|
|
|
constexpr int kMaxRegularHeapObjectSize = (1 << (kPageSizeBits - 1));
|
2016-09-06 12:58:59 +00:00
|
|
|
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kBitsPerByte = 8;
|
|
|
|
constexpr int kBitsPerByteLog2 = 3;
|
2018-11-19 15:44:21 +00:00
|
|
|
constexpr int kBitsPerSystemPointer = kSystemPointerSize * kBitsPerByte;
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kBitsPerInt = kIntSize * kBitsPerByte;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2010-03-23 13:38:04 +00:00
|
|
|
// IEEE 754 single precision floating point number bit layout.
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr uint32_t kBinary32SignMask = 0x80000000u;
|
|
|
|
constexpr uint32_t kBinary32ExponentMask = 0x7f800000u;
|
|
|
|
constexpr uint32_t kBinary32MantissaMask = 0x007fffffu;
|
|
|
|
constexpr int kBinary32ExponentBias = 127;
|
|
|
|
constexpr int kBinary32MaxExponent = 0xFE;
|
|
|
|
constexpr int kBinary32MinExponent = 0x01;
|
|
|
|
constexpr int kBinary32MantissaBits = 23;
|
|
|
|
constexpr int kBinary32ExponentShift = 23;
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2011-09-26 12:44:36 +00:00
|
|
|
// Quiet NaNs have bits 51 to 62 set, possibly the sign bit, and no
|
|
|
|
// other bits set.
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr uint64_t kQuietNaNMask = static_cast<uint64_t>(0xfff) << 51;
|
2011-09-26 12:44:36 +00:00
|
|
|
|
2013-01-09 10:30:54 +00:00
|
|
|
// Latin1/UTF-16 constants
|
2010-12-22 20:14:19 +00:00
|
|
|
// Code-point values in Unicode 4.0 are 21 bits wide.
|
2012-03-12 12:35:28 +00:00
|
|
|
// Code units in UTF-16 are 16 bits wide.
|
2010-12-22 20:14:19 +00:00
|
|
|
typedef uint16_t uc16;
|
|
|
|
typedef int32_t uc32;
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kOneByteSize = kCharSize;
|
|
|
|
constexpr int kUC16Size = sizeof(uc16); // NOLINT
|
2010-12-22 20:14:19 +00:00
|
|
|
|
2015-06-02 22:56:00 +00:00
|
|
|
// 128 bit SIMD value size.
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kSimd128Size = 16;
|
2010-12-07 11:31:57 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
// FUNCTION_ADDR(f) gets the address of a C function f.
|
2018-04-13 22:28:05 +00:00
|
|
|
#define FUNCTION_ADDR(f) (reinterpret_cast<v8::internal::Address>(f))
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// FUNCTION_CAST<F>(addr) casts an address into a function
|
|
|
|
// of type F. Used to invoke generated code from within C.
|
2018-04-13 22:28:05 +00:00
|
|
|
template <typename F>
|
|
|
|
F FUNCTION_CAST(byte* addr) {
|
|
|
|
return reinterpret_cast<F>(reinterpret_cast<Address>(addr));
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
template <typename F>
|
|
|
|
F FUNCTION_CAST(Address addr) {
|
2018-04-13 22:28:05 +00:00
|
|
|
return reinterpret_cast<F>(addr);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-28 13:42:23 +00:00
|
|
|
// Determine whether the architecture uses function descriptors
|
|
|
|
// which provide a level of indirection between the function pointer
|
|
|
|
// and the function entrypoint.
|
|
|
|
#if V8_HOST_ARCH_PPC && \
|
|
|
|
(V8_OS_AIX || (V8_TARGET_ARCH_PPC64 && V8_TARGET_BIG_ENDIAN))
|
|
|
|
#define USES_FUNCTION_DESCRIPTORS 1
|
|
|
|
#define FUNCTION_ENTRYPOINT_ADDRESS(f) \
|
|
|
|
(reinterpret_cast<v8::internal::Address*>( \
|
|
|
|
&(reinterpret_cast<intptr_t*>(f)[0])))
|
|
|
|
#else
|
|
|
|
#define USES_FUNCTION_DESCRIPTORS 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2011-10-27 13:08:51 +00:00
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Declarations for use in both the preparser and the rest of V8.
|
|
|
|
|
|
|
|
// The Strict Mode (ECMA-262 5th edition, 4.2.2).
|
2014-03-11 14:41:22 +00:00
|
|
|
|
2017-10-16 10:55:06 +00:00
|
|
|
enum class LanguageMode : bool { kSloppy, kStrict };
|
|
|
|
static const size_t LanguageModeSize = 2;
|
|
|
|
|
|
|
|
inline size_t hash_value(LanguageMode mode) {
|
|
|
|
return static_cast<size_t>(mode);
|
|
|
|
}
|
2015-02-05 14:11:34 +00:00
|
|
|
|
[tracing] Improve tracing signals for compilation/optimization.
This adds OBJECT/SNAPSHOT trace events for Script and SharedFunctionInfo
objects, logging their creation with appropriate information to make
sense of them.
Based on that we introduces five flow events to model the optimized
compilation via tracing in the "disabled-by-default-v8.compile" category:
- "v8.optimizingCompile.start" logs the creation of the
PipelineCompilationJob (for TurboFan JavaScript optimization)
with the "function" argument referring to the trace event
object created for the SharedFunctionInfo.
- "v8.optimzingCompile.prepare" logs the preparation of the
PipelineCompilationJob on the main thread, also carrying the
"function" argument. This connects the flow event to the actual
tracing duration event associated with the preparation phases.
- "v8.optimizingCompile.execute" logs the (usually concurrent)
optimization of the TurboFan graph (again with "function").
- "v8.optimizingCompile.finalize" logs the main thread phase which
finalizes the optimized code and eventually installs it (in case
of success).
- "v8.optimizingCompile.end" signals the end of the
PipelineCompilationJob, which carries the "compilationInfo",
that contains the interesting bits of the OptimizedCompilationInfo,
specifically whether the compile was successfull and which functions
were inlined for example.
This also adds two instant events "V8.AbortOptimization" and
"V8.RetryOptimization" in "disabled-by-default-v8.compile" category
that are emitted when TurboFan cannot optimize a certain function.
In case of "V8.RetryOptimization", TurboFan might be able to optimize
it later, whereas "V8.AbortOptimization" permanently disables the
optimization of a given function. The JSON representation of this is
```js
{
"pid": 256639,
"tid": 256639,
"ts": 6935411377801,
"tts": 159116,
"ph": "I",
"cat": "disabled-by-default-v8.compile",
"name": "V8.AbortOptimization",
"dur": 0,
"tdur": 0,
"args": {
"reason": "Function is too big to be optimized",
"function": {
"id_ref": "0x600000001",
"scope": "v8::internal::SharedFunctionInfo"
}
}
},
```
where the "function" refers to a previously emitted SNAPSHOT for the
function in question. In the trace viewer it will show up as instant
event under "v8.optimizingCompile.prepare" in case of the relevant
example where optimization is disabled due to reaching the bytecode
limit (as in the JSON above), i.e. it'll look something like this
https://i.paste.pics/aafc2de9df10ea8f5acc1a761d80f07b.png
for the example highlighted in the recent blog post
https://ponyfoo.com/articles/javascript-performance-pitfalls-v8
that describes the optimization limit. The "v8.optimizingCompile.end"
duration event will also carry this information as part of the
"compilationInfo" object, but specifically for CI tools, etc. it might
be a whole lot easier to just look for the "V8.AbortOptimization"
instant event.
Bug: v8:8598, v8:9039
Tbr: ulan@chromium.org
Doc: bit.ly/v8-tracing-signals
Change-Id: Ic87ac336004690c65b6b15ad73bc6fbd4b5f12c4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1511483
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60448}
2019-03-25 14:14:25 +00:00
|
|
|
inline const char* LanguageMode2String(LanguageMode mode) {
|
2015-04-27 09:12:58 +00:00
|
|
|
switch (mode) {
|
2017-10-16 10:55:06 +00:00
|
|
|
case LanguageMode::kSloppy:
|
[tracing] Improve tracing signals for compilation/optimization.
This adds OBJECT/SNAPSHOT trace events for Script and SharedFunctionInfo
objects, logging their creation with appropriate information to make
sense of them.
Based on that we introduces five flow events to model the optimized
compilation via tracing in the "disabled-by-default-v8.compile" category:
- "v8.optimizingCompile.start" logs the creation of the
PipelineCompilationJob (for TurboFan JavaScript optimization)
with the "function" argument referring to the trace event
object created for the SharedFunctionInfo.
- "v8.optimzingCompile.prepare" logs the preparation of the
PipelineCompilationJob on the main thread, also carrying the
"function" argument. This connects the flow event to the actual
tracing duration event associated with the preparation phases.
- "v8.optimizingCompile.execute" logs the (usually concurrent)
optimization of the TurboFan graph (again with "function").
- "v8.optimizingCompile.finalize" logs the main thread phase which
finalizes the optimized code and eventually installs it (in case
of success).
- "v8.optimizingCompile.end" signals the end of the
PipelineCompilationJob, which carries the "compilationInfo",
that contains the interesting bits of the OptimizedCompilationInfo,
specifically whether the compile was successfull and which functions
were inlined for example.
This also adds two instant events "V8.AbortOptimization" and
"V8.RetryOptimization" in "disabled-by-default-v8.compile" category
that are emitted when TurboFan cannot optimize a certain function.
In case of "V8.RetryOptimization", TurboFan might be able to optimize
it later, whereas "V8.AbortOptimization" permanently disables the
optimization of a given function. The JSON representation of this is
```js
{
"pid": 256639,
"tid": 256639,
"ts": 6935411377801,
"tts": 159116,
"ph": "I",
"cat": "disabled-by-default-v8.compile",
"name": "V8.AbortOptimization",
"dur": 0,
"tdur": 0,
"args": {
"reason": "Function is too big to be optimized",
"function": {
"id_ref": "0x600000001",
"scope": "v8::internal::SharedFunctionInfo"
}
}
},
```
where the "function" refers to a previously emitted SNAPSHOT for the
function in question. In the trace viewer it will show up as instant
event under "v8.optimizingCompile.prepare" in case of the relevant
example where optimization is disabled due to reaching the bytecode
limit (as in the JSON above), i.e. it'll look something like this
https://i.paste.pics/aafc2de9df10ea8f5acc1a761d80f07b.png
for the example highlighted in the recent blog post
https://ponyfoo.com/articles/javascript-performance-pitfalls-v8
that describes the optimization limit. The "v8.optimizingCompile.end"
duration event will also carry this information as part of the
"compilationInfo" object, but specifically for CI tools, etc. it might
be a whole lot easier to just look for the "V8.AbortOptimization"
instant event.
Bug: v8:8598, v8:9039
Tbr: ulan@chromium.org
Doc: bit.ly/v8-tracing-signals
Change-Id: Ic87ac336004690c65b6b15ad73bc6fbd4b5f12c4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1511483
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60448}
2019-03-25 14:14:25 +00:00
|
|
|
return "sloppy";
|
2017-10-16 10:55:06 +00:00
|
|
|
case LanguageMode::kStrict:
|
[tracing] Improve tracing signals for compilation/optimization.
This adds OBJECT/SNAPSHOT trace events for Script and SharedFunctionInfo
objects, logging their creation with appropriate information to make
sense of them.
Based on that we introduces five flow events to model the optimized
compilation via tracing in the "disabled-by-default-v8.compile" category:
- "v8.optimizingCompile.start" logs the creation of the
PipelineCompilationJob (for TurboFan JavaScript optimization)
with the "function" argument referring to the trace event
object created for the SharedFunctionInfo.
- "v8.optimzingCompile.prepare" logs the preparation of the
PipelineCompilationJob on the main thread, also carrying the
"function" argument. This connects the flow event to the actual
tracing duration event associated with the preparation phases.
- "v8.optimizingCompile.execute" logs the (usually concurrent)
optimization of the TurboFan graph (again with "function").
- "v8.optimizingCompile.finalize" logs the main thread phase which
finalizes the optimized code and eventually installs it (in case
of success).
- "v8.optimizingCompile.end" signals the end of the
PipelineCompilationJob, which carries the "compilationInfo",
that contains the interesting bits of the OptimizedCompilationInfo,
specifically whether the compile was successfull and which functions
were inlined for example.
This also adds two instant events "V8.AbortOptimization" and
"V8.RetryOptimization" in "disabled-by-default-v8.compile" category
that are emitted when TurboFan cannot optimize a certain function.
In case of "V8.RetryOptimization", TurboFan might be able to optimize
it later, whereas "V8.AbortOptimization" permanently disables the
optimization of a given function. The JSON representation of this is
```js
{
"pid": 256639,
"tid": 256639,
"ts": 6935411377801,
"tts": 159116,
"ph": "I",
"cat": "disabled-by-default-v8.compile",
"name": "V8.AbortOptimization",
"dur": 0,
"tdur": 0,
"args": {
"reason": "Function is too big to be optimized",
"function": {
"id_ref": "0x600000001",
"scope": "v8::internal::SharedFunctionInfo"
}
}
},
```
where the "function" refers to a previously emitted SNAPSHOT for the
function in question. In the trace viewer it will show up as instant
event under "v8.optimizingCompile.prepare" in case of the relevant
example where optimization is disabled due to reaching the bytecode
limit (as in the JSON above), i.e. it'll look something like this
https://i.paste.pics/aafc2de9df10ea8f5acc1a761d80f07b.png
for the example highlighted in the recent blog post
https://ponyfoo.com/articles/javascript-performance-pitfalls-v8
that describes the optimization limit. The "v8.optimizingCompile.end"
duration event will also carry this information as part of the
"compilationInfo" object, but specifically for CI tools, etc. it might
be a whole lot easier to just look for the "V8.AbortOptimization"
instant event.
Bug: v8:8598, v8:9039
Tbr: ulan@chromium.org
Doc: bit.ly/v8-tracing-signals
Change-Id: Ic87ac336004690c65b6b15ad73bc6fbd4b5f12c4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1511483
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60448}
2019-03-25 14:14:25 +00:00
|
|
|
return "strict";
|
2015-04-27 09:12:58 +00:00
|
|
|
}
|
2017-06-22 07:49:08 +00:00
|
|
|
UNREACHABLE();
|
2015-04-27 09:12:58 +00:00
|
|
|
}
|
|
|
|
|
[tracing] Improve tracing signals for compilation/optimization.
This adds OBJECT/SNAPSHOT trace events for Script and SharedFunctionInfo
objects, logging their creation with appropriate information to make
sense of them.
Based on that we introduces five flow events to model the optimized
compilation via tracing in the "disabled-by-default-v8.compile" category:
- "v8.optimizingCompile.start" logs the creation of the
PipelineCompilationJob (for TurboFan JavaScript optimization)
with the "function" argument referring to the trace event
object created for the SharedFunctionInfo.
- "v8.optimzingCompile.prepare" logs the preparation of the
PipelineCompilationJob on the main thread, also carrying the
"function" argument. This connects the flow event to the actual
tracing duration event associated with the preparation phases.
- "v8.optimizingCompile.execute" logs the (usually concurrent)
optimization of the TurboFan graph (again with "function").
- "v8.optimizingCompile.finalize" logs the main thread phase which
finalizes the optimized code and eventually installs it (in case
of success).
- "v8.optimizingCompile.end" signals the end of the
PipelineCompilationJob, which carries the "compilationInfo",
that contains the interesting bits of the OptimizedCompilationInfo,
specifically whether the compile was successfull and which functions
were inlined for example.
This also adds two instant events "V8.AbortOptimization" and
"V8.RetryOptimization" in "disabled-by-default-v8.compile" category
that are emitted when TurboFan cannot optimize a certain function.
In case of "V8.RetryOptimization", TurboFan might be able to optimize
it later, whereas "V8.AbortOptimization" permanently disables the
optimization of a given function. The JSON representation of this is
```js
{
"pid": 256639,
"tid": 256639,
"ts": 6935411377801,
"tts": 159116,
"ph": "I",
"cat": "disabled-by-default-v8.compile",
"name": "V8.AbortOptimization",
"dur": 0,
"tdur": 0,
"args": {
"reason": "Function is too big to be optimized",
"function": {
"id_ref": "0x600000001",
"scope": "v8::internal::SharedFunctionInfo"
}
}
},
```
where the "function" refers to a previously emitted SNAPSHOT for the
function in question. In the trace viewer it will show up as instant
event under "v8.optimizingCompile.prepare" in case of the relevant
example where optimization is disabled due to reaching the bytecode
limit (as in the JSON above), i.e. it'll look something like this
https://i.paste.pics/aafc2de9df10ea8f5acc1a761d80f07b.png
for the example highlighted in the recent blog post
https://ponyfoo.com/articles/javascript-performance-pitfalls-v8
that describes the optimization limit. The "v8.optimizingCompile.end"
duration event will also carry this information as part of the
"compilationInfo" object, but specifically for CI tools, etc. it might
be a whole lot easier to just look for the "V8.AbortOptimization"
instant event.
Bug: v8:8598, v8:9039
Tbr: ulan@chromium.org
Doc: bit.ly/v8-tracing-signals
Change-Id: Ic87ac336004690c65b6b15ad73bc6fbd4b5f12c4
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1511483
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60448}
2019-03-25 14:14:25 +00:00
|
|
|
inline std::ostream& operator<<(std::ostream& os, LanguageMode mode) {
|
|
|
|
return os << LanguageMode2String(mode);
|
|
|
|
}
|
|
|
|
|
2015-02-05 14:11:34 +00:00
|
|
|
inline bool is_sloppy(LanguageMode language_mode) {
|
2017-10-16 10:55:06 +00:00
|
|
|
return language_mode == LanguageMode::kSloppy;
|
2015-02-05 14:11:34 +00:00
|
|
|
}
|
|
|
|
|
2015-02-04 09:34:05 +00:00
|
|
|
inline bool is_strict(LanguageMode language_mode) {
|
2017-10-16 10:55:06 +00:00
|
|
|
return language_mode != LanguageMode::kSloppy;
|
2015-02-04 09:34:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool is_valid_language_mode(int language_mode) {
|
2017-10-16 10:55:06 +00:00
|
|
|
return language_mode == static_cast<int>(LanguageMode::kSloppy) ||
|
|
|
|
language_mode == static_cast<int>(LanguageMode::kStrict);
|
2015-02-05 14:11:34 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 12:43:51 +00:00
|
|
|
inline LanguageMode construct_language_mode(bool strict_bit) {
|
|
|
|
return static_cast<LanguageMode>(strict_bit);
|
2015-02-04 09:34:05 +00:00
|
|
|
}
|
2011-10-27 13:08:51 +00:00
|
|
|
|
2017-10-16 10:55:06 +00:00
|
|
|
// Return kStrict if either of the language modes is kStrict, or kSloppy
|
|
|
|
// otherwise.
|
|
|
|
inline LanguageMode stricter_language_mode(LanguageMode mode1,
|
|
|
|
LanguageMode mode2) {
|
|
|
|
STATIC_ASSERT(LanguageModeSize == 2);
|
|
|
|
return static_cast<LanguageMode>(static_cast<int>(mode1) |
|
|
|
|
static_cast<int>(mode2));
|
|
|
|
}
|
|
|
|
|
2018-09-10 10:49:08 +00:00
|
|
|
// A non-keyed store is of the form a.x = foo or a["x"] = foo whereas
|
|
|
|
// a keyed store is of the form a[expression] = foo.
|
|
|
|
enum class StoreOrigin { kMaybeKeyed, kNamed };
|
|
|
|
|
2016-11-17 12:18:22 +00:00
|
|
|
enum TypeofMode : int { INSIDE_TYPEOF, NOT_INSIDE_TYPEOF };
|
|
|
|
|
2018-05-07 14:09:04 +00:00
|
|
|
// Enums used by CEntry.
|
|
|
|
enum SaveFPRegsMode { kDontSaveFPRegs, kSaveFPRegs };
|
|
|
|
enum ArgvMode { kArgvOnStack, kArgvInRegister };
|
|
|
|
|
2016-06-30 09:26:30 +00:00
|
|
|
// This constant is used as an undefined value when passing source positions.
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kNoSourcePosition = -1;
|
2015-02-05 14:11:34 +00:00
|
|
|
|
2016-07-19 08:22:04 +00:00
|
|
|
// This constant is used to indicate missing deoptimization information.
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kNoDeoptimizationId = -1;
|
2016-07-19 08:22:04 +00:00
|
|
|
|
2018-06-13 10:50:19 +00:00
|
|
|
// Deoptimize bailout kind:
|
|
|
|
// - Eager: a check failed in the optimized code and deoptimization happens
|
|
|
|
// immediately.
|
|
|
|
// - Lazy: the code has been marked as dependent on some assumption which
|
|
|
|
// is checked elsewhere and can trigger deoptimization the next time the
|
|
|
|
// code is executed.
|
|
|
|
// - Soft: similar to lazy deoptimization, but does not contribute to the
|
|
|
|
// total deopt count which can lead to disabling optimization for a function.
|
|
|
|
enum class DeoptimizeKind : uint8_t {
|
|
|
|
kEager,
|
|
|
|
kSoft,
|
|
|
|
kLazy,
|
|
|
|
kLastDeoptimizeKind = kLazy
|
|
|
|
};
|
2017-02-10 09:15:07 +00:00
|
|
|
inline size_t hash_value(DeoptimizeKind kind) {
|
|
|
|
return static_cast<size_t>(kind);
|
|
|
|
}
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, DeoptimizeKind kind) {
|
|
|
|
switch (kind) {
|
|
|
|
case DeoptimizeKind::kEager:
|
|
|
|
return os << "Eager";
|
|
|
|
case DeoptimizeKind::kSoft:
|
|
|
|
return os << "Soft";
|
2017-08-02 07:55:46 +00:00
|
|
|
case DeoptimizeKind::kLazy:
|
|
|
|
return os << "Lazy";
|
2017-02-10 09:15:07 +00:00
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2018-10-30 12:48:12 +00:00
|
|
|
enum class IsolateAllocationMode {
|
|
|
|
// Allocate Isolate in C++ heap using default new/delete operators.
|
2018-11-07 09:05:38 +00:00
|
|
|
kInCppHeap,
|
2018-10-30 12:48:12 +00:00
|
|
|
|
|
|
|
// Allocate Isolate in a committed region inside V8 heap reservation.
|
2018-11-07 09:05:38 +00:00
|
|
|
kInV8Heap,
|
2018-10-30 12:48:12 +00:00
|
|
|
|
|
|
|
#ifdef V8_COMPRESS_POINTERS
|
2018-11-07 09:05:38 +00:00
|
|
|
kDefault = kInV8Heap,
|
2018-10-30 12:48:12 +00:00
|
|
|
#else
|
2018-11-07 09:05:38 +00:00
|
|
|
kDefault = kInCppHeap,
|
2018-10-30 12:48:12 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2017-06-22 07:49:08 +00:00
|
|
|
// Indicates whether the lookup is related to sloppy-mode block-scoped
|
|
|
|
// function hoisting, and is a synthetic assignment for that.
|
|
|
|
enum class LookupHoistingMode { kNormal, kLegacySloppy };
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os,
|
|
|
|
const LookupHoistingMode& mode) {
|
|
|
|
switch (mode) {
|
|
|
|
case LookupHoistingMode::kNormal:
|
|
|
|
return os << "normal hoisting";
|
|
|
|
case LookupHoistingMode::kLegacySloppy:
|
|
|
|
return os << "legacy sloppy hoisting";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2018-06-05 10:45:41 +00:00
|
|
|
static_assert(kSmiValueSize <= 32, "Unsupported Smi tagging scheme");
|
|
|
|
// Smi sign bit position must be 32-bit aligned so we can use sign extension
|
|
|
|
// instructions on 64-bit architectures without additional shifts.
|
|
|
|
static_assert((kSmiValueSize + kSmiShiftSize + kSmiTagSize) % 32 == 0,
|
|
|
|
"Unsupported Smi tagging scheme");
|
|
|
|
|
|
|
|
constexpr bool kIsSmiValueInUpper32Bits =
|
|
|
|
(kSmiValueSize + kSmiShiftSize + kSmiTagSize) == 64;
|
|
|
|
constexpr bool kIsSmiValueInLower32Bits =
|
|
|
|
(kSmiValueSize + kSmiShiftSize + kSmiTagSize) == 32;
|
|
|
|
static_assert(!SmiValuesAre32Bits() == SmiValuesAre31Bits(),
|
|
|
|
"Unsupported Smi tagging scheme");
|
|
|
|
static_assert(SmiValuesAre32Bits() == kIsSmiValueInUpper32Bits,
|
|
|
|
"Unsupported Smi tagging scheme");
|
|
|
|
static_assert(SmiValuesAre31Bits() == kIsSmiValueInLower32Bits,
|
|
|
|
"Unsupported Smi tagging scheme");
|
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
// Mask for the sign bit in a smi.
|
2018-06-05 10:45:41 +00:00
|
|
|
constexpr intptr_t kSmiSignMask = static_cast<intptr_t>(
|
|
|
|
uintptr_t{1} << (kSmiValueSize + kSmiShiftSize + kSmiTagSize - 1));
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-11-19 15:44:21 +00:00
|
|
|
// Desired alignment for tagged pointers.
|
|
|
|
constexpr int kObjectAlignmentBits = kTaggedSizeLog2;
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr intptr_t kObjectAlignment = 1 << kObjectAlignmentBits;
|
|
|
|
constexpr intptr_t kObjectAlignmentMask = kObjectAlignment - 1;
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-11-19 15:44:21 +00:00
|
|
|
// Desired alignment for system pointers.
|
|
|
|
constexpr intptr_t kPointerAlignment = (1 << kSystemPointerSizeLog2);
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr intptr_t kPointerAlignmentMask = kPointerAlignment - 1;
|
2014-05-26 11:28:08 +00:00
|
|
|
|
|
|
|
// Desired alignment for double values.
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr intptr_t kDoubleAlignment = 8;
|
|
|
|
constexpr intptr_t kDoubleAlignmentMask = kDoubleAlignment - 1;
|
2014-05-26 11:28:08 +00:00
|
|
|
|
|
|
|
// Desired alignment for generated code is 32 bytes (to improve cache line
|
|
|
|
// utilization).
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kCodeAlignmentBits = 5;
|
|
|
|
constexpr intptr_t kCodeAlignment = 1 << kCodeAlignmentBits;
|
|
|
|
constexpr intptr_t kCodeAlignmentMask = kCodeAlignment - 1;
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-10-26 00:23:24 +00:00
|
|
|
const Address kWeakHeapObjectMask = 1 << 1;
|
2018-11-07 12:46:01 +00:00
|
|
|
|
|
|
|
// The lower 32 bits of the cleared weak reference value is always equal to
|
|
|
|
// the |kClearedWeakHeapObjectLower32| constant but on 64-bit architectures
|
|
|
|
// the value of the upper 32 bits part may be
|
|
|
|
// 1) zero when pointer compression is disabled,
|
|
|
|
// 2) upper 32 bits of the isolate root value when pointer compression is
|
|
|
|
// enabled.
|
|
|
|
// This is necessary to make pointer decompression computation also suitable
|
|
|
|
// for cleared weak reference.
|
|
|
|
// Note, that real heap objects can't have lower 32 bits equal to 3 because
|
|
|
|
// this offset belongs to page header. So, in either case it's enough to
|
|
|
|
// compare only the lower 32 bits of a MaybeObject value in order to figure
|
|
|
|
// out if it's a cleared reference or not.
|
|
|
|
const uint32_t kClearedWeakHeapObjectLower32 = 3;
|
2014-05-26 11:28:08 +00:00
|
|
|
|
|
|
|
// Zap-value: The value used for zapping dead objects.
|
|
|
|
// Should be a recognizable hex value tagged as a failure.
|
|
|
|
#ifdef V8_HOST_ARCH_64_BIT
|
2018-04-06 14:12:23 +00:00
|
|
|
constexpr uint64_t kClearedFreeMemoryValue = 0;
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr uint64_t kZapValue = uint64_t{0xdeadbeedbeadbeef};
|
|
|
|
constexpr uint64_t kHandleZapValue = uint64_t{0x1baddead0baddeaf};
|
|
|
|
constexpr uint64_t kGlobalHandleZapValue = uint64_t{0x1baffed00baffedf};
|
|
|
|
constexpr uint64_t kFromSpaceZapValue = uint64_t{0x1beefdad0beefdaf};
|
|
|
|
constexpr uint64_t kDebugZapValue = uint64_t{0xbadbaddbbadbaddb};
|
|
|
|
constexpr uint64_t kSlotsZapValue = uint64_t{0xbeefdeadbeefdeef};
|
|
|
|
constexpr uint64_t kFreeListZapValue = 0xfeed1eaffeed1eaf;
|
2014-05-26 11:28:08 +00:00
|
|
|
#else
|
2018-04-06 14:12:23 +00:00
|
|
|
constexpr uint32_t kClearedFreeMemoryValue = 0;
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr uint32_t kZapValue = 0xdeadbeef;
|
|
|
|
constexpr uint32_t kHandleZapValue = 0xbaddeaf;
|
|
|
|
constexpr uint32_t kGlobalHandleZapValue = 0xbaffedf;
|
|
|
|
constexpr uint32_t kFromSpaceZapValue = 0xbeefdaf;
|
|
|
|
constexpr uint32_t kSlotsZapValue = 0xbeefdeef;
|
|
|
|
constexpr uint32_t kDebugZapValue = 0xbadbaddb;
|
|
|
|
constexpr uint32_t kFreeListZapValue = 0xfeed1eaf;
|
2014-05-26 11:28:08 +00:00
|
|
|
#endif
|
|
|
|
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kCodeZapValue = 0xbadc0de;
|
|
|
|
constexpr uint32_t kPhantomReferenceZap = 0xca11bac;
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-07-24 20:13:40 +00:00
|
|
|
// Page constants.
|
|
|
|
static const intptr_t kPageAlignmentMask = (intptr_t{1} << kPageSizeBits) - 1;
|
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
// On Intel architecture, cache line size is 64 bytes.
|
|
|
|
// On ARM it may be less (32 bytes), but as far this constant is
|
|
|
|
// used for aligning data, it doesn't hurt to align on a greater value.
|
|
|
|
#define PROCESSOR_CACHE_LINE_SIZE 64
|
|
|
|
|
|
|
|
// Constants relevant to double precision floating point numbers.
|
|
|
|
// If looking only at the top 32 bits, the QNaN mask is bits 19 to 30.
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr uint32_t kQuietNaNHighBitsMask = 0xfff << (51 - 32);
|
2014-05-26 11:28:08 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Forward declarations for frequently used classes
|
|
|
|
|
|
|
|
class AccessorInfo;
|
|
|
|
class Arguments;
|
|
|
|
class Assembler;
|
|
|
|
class Code;
|
2018-05-07 13:36:00 +00:00
|
|
|
class CodeSpace;
|
2014-05-26 11:28:08 +00:00
|
|
|
class Context;
|
2018-10-23 23:02:20 +00:00
|
|
|
class DeclarationScope;
|
2014-05-26 11:28:08 +00:00
|
|
|
class Debug;
|
|
|
|
class DebugInfo;
|
|
|
|
class Descriptor;
|
|
|
|
class DescriptorArray;
|
|
|
|
class TransitionArray;
|
|
|
|
class ExternalReference;
|
2018-10-23 23:02:20 +00:00
|
|
|
class FeedbackVector;
|
2014-05-26 11:28:08 +00:00
|
|
|
class FixedArray;
|
2018-10-23 23:02:20 +00:00
|
|
|
class Foreign;
|
2017-11-10 13:50:47 +00:00
|
|
|
class FreeStoreAllocationPolicy;
|
2014-05-26 11:28:08 +00:00
|
|
|
class FunctionTemplateInfo;
|
2015-06-01 15:43:24 +00:00
|
|
|
class GlobalDictionary;
|
2014-05-26 11:28:08 +00:00
|
|
|
template <typename T> class Handle;
|
|
|
|
class Heap;
|
|
|
|
class HeapObject;
|
2018-03-19 13:53:31 +00:00
|
|
|
class HeapObjectReference;
|
2014-05-26 11:28:08 +00:00
|
|
|
class IC;
|
|
|
|
class InterceptorInfo;
|
|
|
|
class Isolate;
|
|
|
|
class JSReceiver;
|
|
|
|
class JSArray;
|
|
|
|
class JSFunction;
|
|
|
|
class JSObject;
|
|
|
|
class LargeObjectSpace;
|
|
|
|
class MacroAssembler;
|
|
|
|
class Map;
|
|
|
|
class MapSpace;
|
|
|
|
class MarkCompactCollector;
|
2018-10-23 23:02:20 +00:00
|
|
|
template <typename T>
|
|
|
|
class MaybeHandle;
|
2018-03-19 13:53:31 +00:00
|
|
|
class MaybeObject;
|
2018-10-23 23:02:20 +00:00
|
|
|
class MemoryChunk;
|
|
|
|
class MessageLocation;
|
|
|
|
class ModuleScope;
|
|
|
|
class Name;
|
|
|
|
class NameDictionary;
|
2019-02-13 03:55:38 +00:00
|
|
|
class NativeContext;
|
2014-05-26 11:28:08 +00:00
|
|
|
class NewSpace;
|
2018-07-02 10:15:19 +00:00
|
|
|
class NewLargeObjectSpace;
|
2018-10-23 23:02:20 +00:00
|
|
|
class NumberDictionary;
|
2014-05-26 11:28:08 +00:00
|
|
|
class Object;
|
2018-12-13 10:50:29 +00:00
|
|
|
class CompressedObjectSlot;
|
|
|
|
class CompressedMaybeObjectSlot;
|
|
|
|
class CompressedMapWordSlot;
|
|
|
|
class CompressedHeapObjectSlot;
|
2018-12-05 17:27:13 +00:00
|
|
|
class FullObjectSlot;
|
|
|
|
class FullMaybeObjectSlot;
|
|
|
|
class FullHeapObjectSlot;
|
2014-05-26 11:28:08 +00:00
|
|
|
class OldSpace;
|
2015-08-21 10:25:10 +00:00
|
|
|
class ParameterCount;
|
2018-03-19 17:44:32 +00:00
|
|
|
class ReadOnlySpace;
|
2018-10-23 23:02:20 +00:00
|
|
|
class RelocInfo;
|
2014-05-26 11:28:08 +00:00
|
|
|
class Scope;
|
|
|
|
class ScopeInfo;
|
|
|
|
class Script;
|
2018-10-23 23:02:20 +00:00
|
|
|
class SimpleNumberDictionary;
|
2014-05-26 11:28:08 +00:00
|
|
|
class Smi;
|
|
|
|
template <typename Config, class Allocator = FreeStoreAllocationPolicy>
|
2015-09-01 15:19:57 +00:00
|
|
|
class SplayTree;
|
2014-05-26 11:28:08 +00:00
|
|
|
class String;
|
|
|
|
class Struct;
|
2018-10-23 23:02:20 +00:00
|
|
|
class Symbol;
|
2014-05-26 11:28:08 +00:00
|
|
|
class Variable;
|
|
|
|
|
2018-12-05 17:27:13 +00:00
|
|
|
enum class SlotLocation { kOnHeap, kOffHeap };
|
|
|
|
|
|
|
|
template <SlotLocation slot_location>
|
|
|
|
struct SlotTraits;
|
|
|
|
|
|
|
|
// Off-heap slots are always full-pointer slots.
|
|
|
|
template <>
|
|
|
|
struct SlotTraits<SlotLocation::kOffHeap> {
|
|
|
|
using TObjectSlot = FullObjectSlot;
|
2018-12-06 08:07:00 +00:00
|
|
|
using TMapWordSlot = FullObjectSlot;
|
2018-12-05 17:27:13 +00:00
|
|
|
using TMaybeObjectSlot = FullMaybeObjectSlot;
|
|
|
|
using THeapObjectSlot = FullHeapObjectSlot;
|
|
|
|
};
|
|
|
|
|
|
|
|
// On-heap slots are either full-pointer slots or compressed slots depending
|
|
|
|
// on whether the pointer compression is enabled or not.
|
|
|
|
template <>
|
|
|
|
struct SlotTraits<SlotLocation::kOnHeap> {
|
2018-12-13 10:50:29 +00:00
|
|
|
#ifdef V8_COMPRESS_POINTERS
|
|
|
|
using TObjectSlot = CompressedObjectSlot;
|
|
|
|
using TMapWordSlot = CompressedMapWordSlot;
|
|
|
|
using TMaybeObjectSlot = CompressedMaybeObjectSlot;
|
|
|
|
using THeapObjectSlot = CompressedHeapObjectSlot;
|
|
|
|
#else
|
2018-12-05 17:27:13 +00:00
|
|
|
using TObjectSlot = FullObjectSlot;
|
2018-12-06 08:07:00 +00:00
|
|
|
using TMapWordSlot = FullObjectSlot;
|
2018-12-05 17:27:13 +00:00
|
|
|
using TMaybeObjectSlot = FullMaybeObjectSlot;
|
|
|
|
using THeapObjectSlot = FullHeapObjectSlot;
|
2018-12-13 10:50:29 +00:00
|
|
|
#endif
|
2018-12-05 17:27:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// An ObjectSlot instance describes a kTaggedSize-sized on-heap field ("slot")
|
2019-01-07 12:28:05 +00:00
|
|
|
// holding Object value (smi or strong heap object).
|
2018-12-05 17:27:13 +00:00
|
|
|
using ObjectSlot = SlotTraits<SlotLocation::kOnHeap>::TObjectSlot;
|
|
|
|
|
2018-12-06 08:07:00 +00:00
|
|
|
// An MapWordSlot instance describes a kTaggedSize-sized on-heap field ("slot")
|
2018-12-20 15:47:47 +00:00
|
|
|
// holding HeapObject (strong heap object) value or a forwarding pointer.
|
2018-12-06 08:07:00 +00:00
|
|
|
using MapWordSlot = SlotTraits<SlotLocation::kOnHeap>::TMapWordSlot;
|
|
|
|
|
2018-12-05 17:27:13 +00:00
|
|
|
// A MaybeObjectSlot instance describes a kTaggedSize-sized on-heap field
|
|
|
|
// ("slot") holding MaybeObject (smi or weak heap object or strong heap object).
|
|
|
|
using MaybeObjectSlot = SlotTraits<SlotLocation::kOnHeap>::TMaybeObjectSlot;
|
|
|
|
|
|
|
|
// A HeapObjectSlot instance describes a kTaggedSize-sized field ("slot")
|
|
|
|
// holding a weak or strong pointer to a heap object (think:
|
|
|
|
// HeapObjectReference).
|
|
|
|
using HeapObjectSlot = SlotTraits<SlotLocation::kOnHeap>::THeapObjectSlot;
|
|
|
|
|
2018-12-06 17:53:25 +00:00
|
|
|
typedef bool (*WeakSlotCallback)(FullObjectSlot pointer);
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-12-06 17:53:25 +00:00
|
|
|
typedef bool (*WeakSlotCallbackWithHeap)(Heap* heap, FullObjectSlot pointer);
|
2014-05-26 11:28:08 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Miscellaneous
|
|
|
|
|
|
|
|
// NOTE: SpaceIterator depends on AllocationSpace enumeration values being
|
|
|
|
// consecutive.
|
|
|
|
enum AllocationSpace {
|
2018-03-23 11:42:41 +00:00
|
|
|
RO_SPACE, // Immortal, immovable and immutable objects,
|
2018-07-02 10:15:19 +00:00
|
|
|
NEW_SPACE, // Young generation semispaces for regular objects collected with
|
|
|
|
// Scavenger.
|
|
|
|
OLD_SPACE, // Old generation regular object space.
|
|
|
|
CODE_SPACE, // Old generation code object space, marked executable.
|
|
|
|
MAP_SPACE, // Old generation map object space, non-movable.
|
|
|
|
LO_SPACE, // Old generation large object space.
|
2018-11-21 19:19:02 +00:00
|
|
|
CODE_LO_SPACE, // Old generation large code object space.
|
|
|
|
NEW_LO_SPACE, // Young generation large object space.
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-03-23 11:42:41 +00:00
|
|
|
FIRST_SPACE = RO_SPACE,
|
2018-07-02 10:15:19 +00:00
|
|
|
LAST_SPACE = NEW_LO_SPACE,
|
2019-02-28 16:07:25 +00:00
|
|
|
FIRST_MUTABLE_SPACE = NEW_SPACE,
|
|
|
|
LAST_MUTABLE_SPACE = NEW_LO_SPACE,
|
2018-03-23 11:42:41 +00:00
|
|
|
FIRST_GROWABLE_PAGED_SPACE = OLD_SPACE,
|
|
|
|
LAST_GROWABLE_PAGED_SPACE = MAP_SPACE
|
2014-05-26 11:28:08 +00:00
|
|
|
};
|
2018-11-21 19:19:02 +00:00
|
|
|
constexpr int kSpaceTagSize = 4;
|
2018-03-23 11:42:41 +00:00
|
|
|
STATIC_ASSERT(FIRST_SPACE == 0);
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2019-03-11 19:04:02 +00:00
|
|
|
enum class AllocationType : uint8_t {
|
2019-03-05 11:43:42 +00:00
|
|
|
kYoung, // Regular object allocated in NEW_SPACE or NEW_LO_SPACE
|
|
|
|
kOld, // Regular object allocated in OLD_SPACE or LO_SPACE
|
|
|
|
kCode, // Code object allocated in CODE_SPACE or CODE_LO_SPACE
|
|
|
|
kMap, // Map object allocated in MAP_SPACE
|
|
|
|
kReadOnly // Object allocated in RO_SPACE
|
|
|
|
};
|
|
|
|
|
2019-03-11 19:04:02 +00:00
|
|
|
inline size_t hash_value(AllocationType kind) {
|
|
|
|
return static_cast<uint8_t>(kind);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, AllocationType kind) {
|
|
|
|
switch (kind) {
|
|
|
|
case AllocationType::kYoung:
|
|
|
|
return os << "Young";
|
|
|
|
case AllocationType::kOld:
|
|
|
|
return os << "Old";
|
|
|
|
case AllocationType::kCode:
|
|
|
|
return os << "Code";
|
|
|
|
case AllocationType::kMap:
|
|
|
|
return os << "Map";
|
|
|
|
case AllocationType::kReadOnly:
|
|
|
|
return os << "ReadOnly";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2018-12-19 19:10:21 +00:00
|
|
|
// TODO(ishell): review and rename kWordAligned to kTaggedAligned.
|
2017-02-15 15:42:27 +00:00
|
|
|
enum AllocationAlignment { kWordAligned, kDoubleAligned, kDoubleUnaligned };
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2017-06-13 16:54:42 +00:00
|
|
|
enum class AccessMode { ATOMIC, NON_ATOMIC };
|
|
|
|
|
2016-05-03 13:55:16 +00:00
|
|
|
// Supported write barrier modes.
|
|
|
|
enum WriteBarrierKind : uint8_t {
|
|
|
|
kNoWriteBarrier,
|
|
|
|
kMapWriteBarrier,
|
|
|
|
kPointerWriteBarrier,
|
|
|
|
kFullWriteBarrier
|
|
|
|
};
|
|
|
|
|
|
|
|
inline size_t hash_value(WriteBarrierKind kind) {
|
|
|
|
return static_cast<uint8_t>(kind);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, WriteBarrierKind kind) {
|
|
|
|
switch (kind) {
|
|
|
|
case kNoWriteBarrier:
|
|
|
|
return os << "NoWriteBarrier";
|
|
|
|
case kMapWriteBarrier:
|
|
|
|
return os << "MapWriteBarrier";
|
|
|
|
case kPointerWriteBarrier:
|
|
|
|
return os << "PointerWriteBarrier";
|
|
|
|
case kFullWriteBarrier:
|
|
|
|
return os << "FullWriteBarrier";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
enum MinimumCapacity {
|
|
|
|
USE_DEFAULT_MINIMUM_CAPACITY,
|
|
|
|
USE_CUSTOM_MINIMUM_CAPACITY
|
|
|
|
};
|
|
|
|
|
2016-11-11 15:48:23 +00:00
|
|
|
enum GarbageCollector { SCAVENGER, MARK_COMPACTOR, MINOR_MARK_COMPACTOR };
|
2014-05-26 11:28:08 +00:00
|
|
|
|
|
|
|
enum Executability { NOT_EXECUTABLE, EXECUTABLE };
|
|
|
|
|
2017-11-14 11:41:18 +00:00
|
|
|
enum Movability { kMovable, kImmovable };
|
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
enum VisitMode {
|
|
|
|
VISIT_ALL,
|
2017-05-22 12:47:20 +00:00
|
|
|
VISIT_ALL_IN_MINOR_MC_MARK,
|
2017-05-11 08:06:59 +00:00
|
|
|
VISIT_ALL_IN_MINOR_MC_UPDATE,
|
2014-05-26 11:28:08 +00:00
|
|
|
VISIT_ALL_IN_SCAVENGE,
|
|
|
|
VISIT_ALL_IN_SWEEP_NEWSPACE,
|
2016-03-17 10:32:36 +00:00
|
|
|
VISIT_ONLY_STRONG,
|
2017-12-22 12:00:58 +00:00
|
|
|
VISIT_FOR_SERIALIZATION,
|
2014-05-26 11:28:08 +00:00
|
|
|
};
|
|
|
|
|
2019-04-01 11:41:03 +00:00
|
|
|
enum class BytecodeFlushMode {
|
|
|
|
kDoNotFlushBytecode,
|
|
|
|
kFlushBytecode,
|
|
|
|
kStressFlushBytecode,
|
|
|
|
};
|
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
// Flag indicating whether code is built into the VM (one of the natives files).
|
2016-11-17 04:39:30 +00:00
|
|
|
enum NativesFlag {
|
|
|
|
NOT_NATIVES_CODE,
|
|
|
|
EXTENSION_CODE,
|
|
|
|
INSPECTOR_CODE
|
|
|
|
};
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2015-03-09 14:51:13 +00:00
|
|
|
// ParseRestriction is used to restrict the set of valid statements in a
|
|
|
|
// unit of compilation. Restriction violations cause a syntax error.
|
|
|
|
enum ParseRestriction {
|
|
|
|
NO_PARSE_RESTRICTION, // All expressions are allowed.
|
|
|
|
ONLY_SINGLE_FUNCTION_LITERAL // Only a single FunctionLiteral expression.
|
|
|
|
};
|
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
// State for inline cache call sites. Aliased as IC::State.
|
|
|
|
enum InlineCacheState {
|
2018-12-11 12:23:21 +00:00
|
|
|
// No feedback will be collected.
|
|
|
|
NO_FEEDBACK,
|
2014-05-26 11:28:08 +00:00
|
|
|
// Has never been executed.
|
|
|
|
UNINITIALIZED,
|
2019-01-29 15:53:46 +00:00
|
|
|
// Has been executed but monomorphic state has been delayed.
|
2014-05-26 11:28:08 +00:00
|
|
|
PREMONOMORPHIC,
|
|
|
|
// Has been executed and only one receiver type has been seen.
|
|
|
|
MONOMORPHIC,
|
2014-07-18 13:50:21 +00:00
|
|
|
// Check failed due to prototype (or map deprecation).
|
2016-04-06 10:05:51 +00:00
|
|
|
RECOMPUTE_HANDLER,
|
2014-05-26 11:28:08 +00:00
|
|
|
// Multiple receiver types have been seen.
|
|
|
|
POLYMORPHIC,
|
|
|
|
// Many receiver types have been seen.
|
|
|
|
MEGAMORPHIC,
|
|
|
|
// A generic handler is installed and no extra typefeedback is recorded.
|
|
|
|
GENERIC,
|
|
|
|
};
|
|
|
|
|
2018-09-10 08:44:50 +00:00
|
|
|
// Printing support.
|
|
|
|
inline const char* InlineCacheState2String(InlineCacheState state) {
|
|
|
|
switch (state) {
|
2018-12-11 12:23:21 +00:00
|
|
|
case NO_FEEDBACK:
|
|
|
|
return "NOFEEDBACK";
|
2018-09-10 08:44:50 +00:00
|
|
|
case UNINITIALIZED:
|
|
|
|
return "UNINITIALIZED";
|
|
|
|
case PREMONOMORPHIC:
|
|
|
|
return "PREMONOMORPHIC";
|
|
|
|
case MONOMORPHIC:
|
|
|
|
return "MONOMORPHIC";
|
|
|
|
case RECOMPUTE_HANDLER:
|
|
|
|
return "RECOMPUTE_HANDLER";
|
|
|
|
case POLYMORPHIC:
|
|
|
|
return "POLYMORPHIC";
|
|
|
|
case MEGAMORPHIC:
|
|
|
|
return "MEGAMORPHIC";
|
|
|
|
case GENERIC:
|
|
|
|
return "GENERIC";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2016-06-08 14:43:22 +00:00
|
|
|
enum WhereToStart { kStartAtReceiver, kStartAtPrototype };
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2017-04-13 14:41:22 +00:00
|
|
|
enum ResultSentinel { kNotFound = -1, kUnsupported = -2 };
|
|
|
|
|
2019-02-07 13:19:57 +00:00
|
|
|
enum ShouldThrow {
|
|
|
|
kThrowOnError = Internals::kThrowOnError,
|
|
|
|
kDontThrow = Internals::kDontThrow
|
|
|
|
};
|
2017-10-25 18:07:04 +00:00
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
// The Store Buffer (GC).
|
|
|
|
typedef enum {
|
|
|
|
kStoreBufferFullEvent,
|
|
|
|
kStoreBufferStartScanningPagesEvent,
|
|
|
|
kStoreBufferScanningPageEvent
|
|
|
|
} StoreBufferEvent;
|
|
|
|
|
|
|
|
|
|
|
|
typedef void (*StoreBufferCallback)(Heap* heap,
|
|
|
|
MemoryChunk* page,
|
|
|
|
StoreBufferEvent event);
|
|
|
|
|
|
|
|
// Union used for customized checking of the IEEE double types
|
|
|
|
// inlined within v8 runtime, rather than going to the underlying
|
|
|
|
// platform headers and libraries
|
|
|
|
union IeeeDoubleLittleEndianArchType {
|
|
|
|
double d;
|
|
|
|
struct {
|
|
|
|
unsigned int man_low :32;
|
|
|
|
unsigned int man_high :20;
|
|
|
|
unsigned int exp :11;
|
|
|
|
unsigned int sign :1;
|
|
|
|
} bits;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
union IeeeDoubleBigEndianArchType {
|
|
|
|
double d;
|
|
|
|
struct {
|
|
|
|
unsigned int sign :1;
|
|
|
|
unsigned int exp :11;
|
|
|
|
unsigned int man_high :20;
|
|
|
|
unsigned int man_low :32;
|
|
|
|
} bits;
|
|
|
|
};
|
|
|
|
|
2016-06-02 15:02:08 +00:00
|
|
|
#if V8_TARGET_LITTLE_ENDIAN
|
|
|
|
typedef IeeeDoubleLittleEndianArchType IeeeDoubleArchType;
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kIeeeDoubleMantissaWordOffset = 0;
|
|
|
|
constexpr int kIeeeDoubleExponentWordOffset = 4;
|
2016-06-02 15:02:08 +00:00
|
|
|
#else
|
|
|
|
typedef IeeeDoubleBigEndianArchType IeeeDoubleArchType;
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr int kIeeeDoubleMantissaWordOffset = 4;
|
|
|
|
constexpr int kIeeeDoubleExponentWordOffset = 0;
|
2016-06-02 15:02:08 +00:00
|
|
|
#endif
|
2014-05-26 11:28:08 +00:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Macros
|
|
|
|
|
|
|
|
// Testers for test.
|
|
|
|
|
|
|
|
#define HAS_SMI_TAG(value) \
|
2018-10-26 00:23:24 +00:00
|
|
|
((static_cast<intptr_t>(value) & ::i::kSmiTagMask) == ::i::kSmiTag)
|
2017-06-16 14:58:23 +00:00
|
|
|
|
2018-10-26 00:23:24 +00:00
|
|
|
#define HAS_HEAP_OBJECT_TAG(value) \
|
|
|
|
(((static_cast<intptr_t>(value) & ::i::kHeapObjectTagMask) == \
|
2017-06-16 14:58:23 +00:00
|
|
|
::i::kHeapObjectTag))
|
2014-05-26 11:28:08 +00:00
|
|
|
|
|
|
|
// OBJECT_POINTER_ALIGN returns the value aligned as a HeapObject pointer
|
2019-03-06 10:24:13 +00:00
|
|
|
#define OBJECT_POINTER_ALIGN(value) \
|
|
|
|
(((value) + ::i::kObjectAlignmentMask) & ~::i::kObjectAlignmentMask)
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-11-21 19:45:44 +00:00
|
|
|
// OBJECT_POINTER_PADDING returns the padding size required to align value
|
|
|
|
// as a HeapObject pointer
|
|
|
|
#define OBJECT_POINTER_PADDING(value) (OBJECT_POINTER_ALIGN(value) - (value))
|
|
|
|
|
2018-12-12 10:35:55 +00:00
|
|
|
// POINTER_SIZE_ALIGN returns the value aligned as a system pointer.
|
2019-03-06 10:24:13 +00:00
|
|
|
#define POINTER_SIZE_ALIGN(value) \
|
|
|
|
(((value) + ::i::kPointerAlignmentMask) & ~::i::kPointerAlignmentMask)
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-11-22 18:57:02 +00:00
|
|
|
// POINTER_SIZE_PADDING returns the padding size required to align value
|
|
|
|
// as a system pointer.
|
|
|
|
#define POINTER_SIZE_PADDING(value) (POINTER_SIZE_ALIGN(value) - (value))
|
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
// CODE_POINTER_ALIGN returns the value aligned as a generated code segment.
|
2019-03-06 10:24:13 +00:00
|
|
|
#define CODE_POINTER_ALIGN(value) \
|
|
|
|
(((value) + ::i::kCodeAlignmentMask) & ~::i::kCodeAlignmentMask)
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-11-21 19:45:44 +00:00
|
|
|
// CODE_POINTER_PADDING returns the padding size required to align value
|
|
|
|
// as a generated code segment.
|
|
|
|
#define CODE_POINTER_PADDING(value) (CODE_POINTER_ALIGN(value) - (value))
|
|
|
|
|
2015-05-07 05:44:47 +00:00
|
|
|
// DOUBLE_POINTER_ALIGN returns the value algined for double pointers.
|
|
|
|
#define DOUBLE_POINTER_ALIGN(value) \
|
2019-03-06 10:24:13 +00:00
|
|
|
(((value) + ::i::kDoubleAlignmentMask) & ~::i::kDoubleAlignmentMask)
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2015-11-09 08:47:59 +00:00
|
|
|
// Defines hints about receiver values based on structural knowledge.
|
|
|
|
enum class ConvertReceiverMode : unsigned {
|
|
|
|
kNullOrUndefined, // Guaranteed to be null or undefined.
|
|
|
|
kNotNullOrUndefined, // Guaranteed to never be null or undefined.
|
|
|
|
kAny // No specific knowledge about receiver.
|
|
|
|
};
|
|
|
|
|
|
|
|
inline size_t hash_value(ConvertReceiverMode mode) {
|
|
|
|
return bit_cast<unsigned>(mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, ConvertReceiverMode mode) {
|
|
|
|
switch (mode) {
|
|
|
|
case ConvertReceiverMode::kNullOrUndefined:
|
|
|
|
return os << "NULL_OR_UNDEFINED";
|
|
|
|
case ConvertReceiverMode::kNotNullOrUndefined:
|
|
|
|
return os << "NOT_NULL_OR_UNDEFINED";
|
|
|
|
case ConvertReceiverMode::kAny:
|
|
|
|
return os << "ANY";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2016-07-14 10:25:45 +00:00
|
|
|
// Valid hints for the abstract operation OrdinaryToPrimitive,
|
|
|
|
// implemented according to ES6, section 7.1.1.
|
|
|
|
enum class OrdinaryToPrimitiveHint { kNumber, kString };
|
|
|
|
|
|
|
|
// Valid hints for the abstract operation ToPrimitive,
|
|
|
|
// implemented according to ES6, section 7.1.1.
|
|
|
|
enum class ToPrimitiveHint { kDefault, kNumber, kString };
|
|
|
|
|
[runtime] Optimize and unify rest parameters.
Replace the somewhat awkward RestParamAccessStub, which would always
call into the runtime anyway with a proper FastNewRestParameterStub,
which is basically based on the code that was already there for strict
arguments object materialization. But for rest parameters we could
optimize even further (leading to 8-10x improvements for functions with
rest parameters), by fixing the internal formal parameter count:
Every SharedFunctionInfo has a formal_parameter_count field, which
specifies the number of formal parameters, and is used to decide whether
we need to create an arguments adaptor frame when calling a function
(i.e. if there's a mismatch between the actual and expected parameters).
Previously the formal_parameter_count included the rest parameter, which
was sort of unfortunate, as that meant that calling a function with only
the non-rest parameters still required an arguments adaptor (plus some
other oddities). Now with this CL we fix, so that we do no longer
include the rest parameter in that count. Thereby checking for rest
parameters is very efficient, as we only need to check whether there is
an arguments adaptor frame, and if not create an empty array, otherwise
check whether the arguments adaptor frame has more parameters than
specified by the formal_parameter_count.
The FastNewRestParameterStub is written in a way that it can be directly
used by Ignition as well, and with some tweaks to the TurboFan backends
and the CodeStubAssembler, we should be able to rewrite it as
TurboFanCodeStub in the near future.
Drive-by-fix: Refactor and unify the CreateArgumentsType which was
different in TurboFan and Ignition; now we have a single enum class
which is used in both TurboFan and Ignition.
R=jarin@chromium.org, rmcilroy@chromium.org
TBR=rossberg@chromium.org
BUG=v8:2159
LOG=n
Review URL: https://codereview.chromium.org/1676883002
Cr-Commit-Position: refs/heads/master@{#33809}
2016-02-08 10:08:21 +00:00
|
|
|
// Defines specifics about arguments object or rest parameter creation.
|
|
|
|
enum class CreateArgumentsType : uint8_t {
|
|
|
|
kMappedArguments,
|
|
|
|
kUnmappedArguments,
|
|
|
|
kRestParameter
|
|
|
|
};
|
|
|
|
|
|
|
|
inline size_t hash_value(CreateArgumentsType type) {
|
|
|
|
return bit_cast<uint8_t>(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, CreateArgumentsType type) {
|
|
|
|
switch (type) {
|
|
|
|
case CreateArgumentsType::kMappedArguments:
|
|
|
|
return os << "MAPPED_ARGUMENTS";
|
|
|
|
case CreateArgumentsType::kUnmappedArguments:
|
|
|
|
return os << "UNMAPPED_ARGUMENTS";
|
|
|
|
case CreateArgumentsType::kRestParameter:
|
|
|
|
return os << "REST_PARAMETER";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2016-08-24 08:49:43 +00:00
|
|
|
enum ScopeType : uint8_t {
|
2014-05-26 11:28:08 +00:00
|
|
|
EVAL_SCOPE, // The top-level scope for an eval source.
|
|
|
|
FUNCTION_SCOPE, // The top-level scope for a function.
|
|
|
|
MODULE_SCOPE, // The scope introduced by a module literal
|
2014-11-12 11:34:09 +00:00
|
|
|
SCRIPT_SCOPE, // The top-level scope for a script or a top-level eval.
|
2014-05-26 11:28:08 +00:00
|
|
|
CATCH_SCOPE, // The scope introduced by catch.
|
|
|
|
BLOCK_SCOPE, // The scope introduced by a new block.
|
2015-10-07 14:55:38 +00:00
|
|
|
WITH_SCOPE // The scope introduced by with.
|
2014-05-26 11:28:08 +00:00
|
|
|
};
|
|
|
|
|
2018-03-08 14:49:09 +00:00
|
|
|
inline std::ostream& operator<<(std::ostream& os, ScopeType type) {
|
|
|
|
switch (type) {
|
|
|
|
case ScopeType::EVAL_SCOPE:
|
|
|
|
return os << "EVAL_SCOPE";
|
|
|
|
case ScopeType::FUNCTION_SCOPE:
|
|
|
|
return os << "FUNCTION_SCOPE";
|
|
|
|
case ScopeType::MODULE_SCOPE:
|
|
|
|
return os << "MODULE_SCOPE";
|
|
|
|
case ScopeType::SCRIPT_SCOPE:
|
|
|
|
return os << "SCRIPT_SCOPE";
|
|
|
|
case ScopeType::CATCH_SCOPE:
|
|
|
|
return os << "CATCH_SCOPE";
|
|
|
|
case ScopeType::BLOCK_SCOPE:
|
|
|
|
return os << "BLOCK_SCOPE";
|
|
|
|
case ScopeType::WITH_SCOPE:
|
|
|
|
return os << "WITH_SCOPE";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2016-12-29 13:02:08 +00:00
|
|
|
// AllocationSiteMode controls whether allocations are tracked by an allocation
|
|
|
|
// site.
|
|
|
|
enum AllocationSiteMode {
|
|
|
|
DONT_TRACK_ALLOCATION_SITE,
|
|
|
|
TRACK_ALLOCATION_SITE,
|
|
|
|
LAST_ALLOCATION_SITE_MODE = TRACK_ALLOCATION_SITE
|
|
|
|
};
|
|
|
|
|
2018-09-12 10:35:23 +00:00
|
|
|
enum class AllocationSiteUpdateMode { kUpdate, kCheckOnly };
|
|
|
|
|
2015-02-20 19:09:18 +00:00
|
|
|
// The mips architecture prior to revision 5 has inverted encoding for sNaN.
|
2016-07-27 10:55:19 +00:00
|
|
|
#if (V8_TARGET_ARCH_MIPS && !defined(_MIPS_ARCH_MIPS32R6) && \
|
|
|
|
(!defined(USE_SIMULATOR) || !defined(_MIPS_TARGET_SIMULATOR))) || \
|
|
|
|
(V8_TARGET_ARCH_MIPS64 && !defined(_MIPS_ARCH_MIPS64R6) && \
|
2017-07-18 15:55:06 +00:00
|
|
|
(!defined(USE_SIMULATOR) || !defined(_MIPS_TARGET_SIMULATOR)))
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr uint32_t kHoleNanUpper32 = 0xFFFF7FFF;
|
|
|
|
constexpr uint32_t kHoleNanLower32 = 0xFFFF7FFF;
|
2015-02-20 19:09:18 +00:00
|
|
|
#else
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr uint32_t kHoleNanUpper32 = 0xFFF7FFFF;
|
|
|
|
constexpr uint32_t kHoleNanLower32 = 0xFFF7FFFF;
|
2015-02-20 19:09:18 +00:00
|
|
|
#endif
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr uint64_t kHoleNanInt64 =
|
2014-05-26 11:28:08 +00:00
|
|
|
(static_cast<uint64_t>(kHoleNanUpper32) << 32) | kHoleNanLower32;
|
|
|
|
|
2015-09-29 07:41:03 +00:00
|
|
|
// ES6 section 20.1.2.6 Number.MAX_SAFE_INTEGER
|
2018-01-24 18:46:43 +00:00
|
|
|
constexpr double kMaxSafeInteger = 9007199254740991.0; // 2^53-1
|
2015-09-29 07:41:03 +00:00
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
// The order of this enum has to be kept in sync with the predicates below.
|
2018-05-28 15:44:58 +00:00
|
|
|
enum class VariableMode : uint8_t {
|
2014-05-26 11:28:08 +00:00
|
|
|
// User declared variables:
|
2018-05-28 15:44:58 +00:00
|
|
|
kLet, // declared via 'let' declarations (first lexical)
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-05-28 15:44:58 +00:00
|
|
|
kConst, // declared via 'const' declarations (last lexical)
|
2015-02-26 18:40:50 +00:00
|
|
|
|
2018-05-28 15:44:58 +00:00
|
|
|
kVar, // declared via 'var', and 'function' declarations
|
2017-07-12 22:17:11 +00:00
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
// Variables introduced by the compiler:
|
2018-05-28 15:44:58 +00:00
|
|
|
kTemporary, // temporary variables (not user-visible), stack-allocated
|
|
|
|
// unless the scope as a whole has forced context allocation
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-05-28 15:44:58 +00:00
|
|
|
kDynamic, // always require dynamic lookup (we don't know
|
|
|
|
// the declaration)
|
2014-05-26 11:28:08 +00:00
|
|
|
|
2018-05-28 15:44:58 +00:00
|
|
|
kDynamicGlobal, // requires dynamic lookup, but we know that the
|
2014-05-26 11:28:08 +00:00
|
|
|
// variable is global unless it has been shadowed
|
|
|
|
// by an eval-introduced variable
|
|
|
|
|
2018-12-19 13:43:06 +00:00
|
|
|
kDynamicLocal, // requires dynamic lookup, but we know that the
|
|
|
|
// variable is local and where it is unless it
|
|
|
|
// has been shadowed by an eval-introduced
|
|
|
|
// variable
|
|
|
|
|
|
|
|
kLastLexicalVariableMode = kConst,
|
2014-05-26 11:28:08 +00:00
|
|
|
};
|
|
|
|
|
2016-09-09 10:55:31 +00:00
|
|
|
// Printing support
|
|
|
|
#ifdef DEBUG
|
|
|
|
inline const char* VariableMode2String(VariableMode mode) {
|
|
|
|
switch (mode) {
|
2018-05-28 15:44:58 +00:00
|
|
|
case VariableMode::kVar:
|
2016-09-09 10:55:31 +00:00
|
|
|
return "VAR";
|
2018-05-28 15:44:58 +00:00
|
|
|
case VariableMode::kLet:
|
2016-09-09 10:55:31 +00:00
|
|
|
return "LET";
|
2018-05-28 15:44:58 +00:00
|
|
|
case VariableMode::kConst:
|
2016-09-09 10:55:31 +00:00
|
|
|
return "CONST";
|
2018-05-28 15:44:58 +00:00
|
|
|
case VariableMode::kDynamic:
|
2016-09-09 10:55:31 +00:00
|
|
|
return "DYNAMIC";
|
2018-05-28 15:44:58 +00:00
|
|
|
case VariableMode::kDynamicGlobal:
|
2016-09-09 10:55:31 +00:00
|
|
|
return "DYNAMIC_GLOBAL";
|
2018-05-28 15:44:58 +00:00
|
|
|
case VariableMode::kDynamicLocal:
|
2016-09-09 10:55:31 +00:00
|
|
|
return "DYNAMIC_LOCAL";
|
2018-05-28 15:44:58 +00:00
|
|
|
case VariableMode::kTemporary:
|
2016-09-09 10:55:31 +00:00
|
|
|
return "TEMPORARY";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum VariableKind : uint8_t {
|
|
|
|
NORMAL_VARIABLE,
|
2019-01-10 11:56:13 +00:00
|
|
|
PARAMETER_VARIABLE,
|
2016-09-09 10:55:31 +00:00
|
|
|
THIS_VARIABLE,
|
2019-01-25 11:45:28 +00:00
|
|
|
SLOPPY_BLOCK_FUNCTION_VARIABLE,
|
2017-07-12 22:01:15 +00:00
|
|
|
SLOPPY_FUNCTION_NAME_VARIABLE
|
2016-09-09 10:55:31 +00:00
|
|
|
};
|
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
inline bool IsDynamicVariableMode(VariableMode mode) {
|
2018-05-28 15:44:58 +00:00
|
|
|
return mode >= VariableMode::kDynamic && mode <= VariableMode::kDynamicLocal;
|
2014-05-26 11:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsDeclaredVariableMode(VariableMode mode) {
|
2018-05-28 15:44:58 +00:00
|
|
|
STATIC_ASSERT(static_cast<uint8_t>(VariableMode::kLet) ==
|
|
|
|
0); // Implies that mode >= VariableMode::kLet.
|
|
|
|
return mode <= VariableMode::kVar;
|
2014-05-26 11:28:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline bool IsLexicalVariableMode(VariableMode mode) {
|
2018-05-28 15:44:58 +00:00
|
|
|
STATIC_ASSERT(static_cast<uint8_t>(VariableMode::kLet) ==
|
|
|
|
0); // Implies that mode >= VariableMode::kLet.
|
2018-12-19 13:43:06 +00:00
|
|
|
return mode <= VariableMode::kLastLexicalVariableMode;
|
2014-05-26 11:28:08 +00:00
|
|
|
}
|
|
|
|
|
2016-08-25 08:46:08 +00:00
|
|
|
enum VariableLocation : uint8_t {
|
2015-07-06 16:36:28 +00:00
|
|
|
// Before and during variable allocation, a variable whose location is
|
|
|
|
// not yet determined. After allocation, a variable looked up as a
|
|
|
|
// property on the global object (and possibly absent). name() is the
|
|
|
|
// variable name, index() is invalid.
|
|
|
|
UNALLOCATED,
|
|
|
|
|
|
|
|
// A slot in the parameter section on the stack. index() is the
|
|
|
|
// parameter index, counting left-to-right. The receiver is index -1;
|
|
|
|
// the first parameter is index 0.
|
|
|
|
PARAMETER,
|
|
|
|
|
|
|
|
// A slot in the local section on the stack. index() is the variable
|
|
|
|
// index in the stack frame, starting at 0.
|
|
|
|
LOCAL,
|
|
|
|
|
|
|
|
// An indexed slot in a heap context. index() is the variable index in
|
|
|
|
// the context object on the heap, starting at 0. scope() is the
|
|
|
|
// corresponding scope.
|
|
|
|
CONTEXT,
|
|
|
|
|
|
|
|
// A named slot in a heap context. name() is the variable name in the
|
|
|
|
// context object on the heap, with lookup starting at the current
|
|
|
|
// context. index() is invalid.
|
2016-08-08 09:46:51 +00:00
|
|
|
LOOKUP,
|
2015-07-06 16:36:28 +00:00
|
|
|
|
2016-08-08 09:46:51 +00:00
|
|
|
// A named slot in a module's export table.
|
2016-08-25 08:46:08 +00:00
|
|
|
MODULE,
|
|
|
|
|
|
|
|
kLastVariableLocation = MODULE
|
2016-08-08 09:46:51 +00:00
|
|
|
};
|
2015-07-06 16:36:28 +00:00
|
|
|
|
2017-05-08 18:55:54 +00:00
|
|
|
// ES6 specifies declarative environment records with mutable and immutable
|
|
|
|
// bindings that can be in two states: initialized and uninitialized.
|
|
|
|
// When accessing a binding, it needs to be checked for initialization.
|
|
|
|
// However in the following cases the binding is initialized immediately
|
|
|
|
// after creation so the initialization check can always be skipped:
|
|
|
|
//
|
2014-05-26 11:28:08 +00:00
|
|
|
// 1. Var declared local variables.
|
|
|
|
// var foo;
|
|
|
|
// 2. A local variable introduced by a function declaration.
|
|
|
|
// function foo() {}
|
|
|
|
// 3. Parameters
|
|
|
|
// function x(foo) {}
|
|
|
|
// 4. Catch bound variables.
|
|
|
|
// try {} catch (foo) {}
|
2017-05-08 18:55:54 +00:00
|
|
|
// 6. Function name variables of named function expressions.
|
2014-05-26 11:28:08 +00:00
|
|
|
// var x = function foo() {}
|
|
|
|
// 7. Implicit binding of 'this'.
|
|
|
|
// 8. Implicit binding of 'arguments' in functions.
|
|
|
|
//
|
|
|
|
// The following enum specifies a flag that indicates if the binding needs a
|
|
|
|
// distinct initialization step (kNeedsInitialization) or if the binding is
|
|
|
|
// immediately initialized upon creation (kCreatedInitialized).
|
2016-08-25 08:46:08 +00:00
|
|
|
enum InitializationFlag : uint8_t { kNeedsInitialization, kCreatedInitialized };
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2016-08-25 08:46:08 +00:00
|
|
|
enum MaybeAssignedFlag : uint8_t { kNotAssigned, kMaybeAssigned };
|
2014-07-30 13:54:45 +00:00
|
|
|
|
2016-09-23 13:22:24 +00:00
|
|
|
enum ParseErrorType { kSyntaxError = 0, kReferenceError = 1 };
|
|
|
|
|
2018-02-23 19:03:58 +00:00
|
|
|
|
2017-01-24 14:37:01 +00:00
|
|
|
enum class InterpreterPushArgsMode : unsigned {
|
2018-03-21 11:48:28 +00:00
|
|
|
kArrayFunction,
|
2017-01-18 10:34:24 +00:00
|
|
|
kWithFinalSpread,
|
|
|
|
kOther
|
|
|
|
};
|
|
|
|
|
2017-01-24 14:37:01 +00:00
|
|
|
inline size_t hash_value(InterpreterPushArgsMode mode) {
|
2017-01-18 10:34:24 +00:00
|
|
|
return bit_cast<unsigned>(mode);
|
|
|
|
}
|
|
|
|
|
2017-01-24 14:37:01 +00:00
|
|
|
inline std::ostream& operator<<(std::ostream& os,
|
|
|
|
InterpreterPushArgsMode mode) {
|
2017-01-18 10:34:24 +00:00
|
|
|
switch (mode) {
|
2018-03-21 11:48:28 +00:00
|
|
|
case InterpreterPushArgsMode::kArrayFunction:
|
|
|
|
return os << "ArrayFunction";
|
2017-01-24 14:37:01 +00:00
|
|
|
case InterpreterPushArgsMode::kWithFinalSpread:
|
2017-01-18 10:34:24 +00:00
|
|
|
return os << "WithFinalSpread";
|
2017-01-24 14:37:01 +00:00
|
|
|
case InterpreterPushArgsMode::kOther:
|
2017-01-18 10:34:24 +00:00
|
|
|
return os << "Other";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
Reland of "[heap] Parallel newspace evacuation, semispace copy, and compaction \o/"
This reverts commit 85ba94f28ce4b5d64e4c148efb1fee85bdb6579b.
All parallelism can be turned off using --predictable, or --noparallel-compaction.
This patch completely parallelizes
- semispace copy: from space -> to space (within newspace)
- newspace evacuation: newspace -> oldspace
- oldspace compaction: oldspace -> oldspace
Previously newspace has been handled sequentially (semispace copy, newspace
evacuation) before compacting oldspace in parallel. However, on a high level
there are no dependencies between those two actions, hence we parallelize them
altogether. We base the number of evacuation tasks on the overall set of
to-be-processed pages (newspace + oldspace compaction pages).
Some low-level details:
- The hard cap on number of tasks has been lifted
- We cache store buffer entries locally before merging them back into the global
StoreBuffer in a finalization phase.
- We cache AllocationSite operations locally before merging them back into the
global pretenuring storage in a finalization phase.
- AllocationSite might be compacted while they would be needed for newspace
evacuation. To mitigate any problems we defer checking allocation sites for
newspace till merging locally buffered data.
CQ_EXTRA_TRYBOTS=tryserver.v8:v8_linux_arm64_gc_stress_dbg,v8_linux_gc_stress_dbg,v8_mac_gc_stress_dbg,v8_linux64_asan_rel,v8_linux64_tsan_rel,v8_mac64_asan_rel
BUG=chromium:524425
LOG=N
R=hpayer@chromium.org, ulan@chromium.org
Review URL: https://codereview.chromium.org/1640563004
Cr-Commit-Position: refs/heads/master@{#33552}
2016-01-27 13:23:54 +00:00
|
|
|
inline uint32_t ObjectHash(Address address) {
|
|
|
|
// All objects are at least pointer aligned, so we can remove the trailing
|
|
|
|
// zeros.
|
2018-11-19 15:44:21 +00:00
|
|
|
return static_cast<uint32_t>(address >> kTaggedSizeLog2);
|
Reland of "[heap] Parallel newspace evacuation, semispace copy, and compaction \o/"
This reverts commit 85ba94f28ce4b5d64e4c148efb1fee85bdb6579b.
All parallelism can be turned off using --predictable, or --noparallel-compaction.
This patch completely parallelizes
- semispace copy: from space -> to space (within newspace)
- newspace evacuation: newspace -> oldspace
- oldspace compaction: oldspace -> oldspace
Previously newspace has been handled sequentially (semispace copy, newspace
evacuation) before compacting oldspace in parallel. However, on a high level
there are no dependencies between those two actions, hence we parallelize them
altogether. We base the number of evacuation tasks on the overall set of
to-be-processed pages (newspace + oldspace compaction pages).
Some low-level details:
- The hard cap on number of tasks has been lifted
- We cache store buffer entries locally before merging them back into the global
StoreBuffer in a finalization phase.
- We cache AllocationSite operations locally before merging them back into the
global pretenuring storage in a finalization phase.
- AllocationSite might be compacted while they would be needed for newspace
evacuation. To mitigate any problems we defer checking allocation sites for
newspace till merging locally buffered data.
CQ_EXTRA_TRYBOTS=tryserver.v8:v8_linux_arm64_gc_stress_dbg,v8_linux_gc_stress_dbg,v8_mac_gc_stress_dbg,v8_linux64_asan_rel,v8_linux64_tsan_rel,v8_mac64_asan_rel
BUG=chromium:524425
LOG=N
R=hpayer@chromium.org, ulan@chromium.org
Review URL: https://codereview.chromium.org/1640563004
Cr-Commit-Position: refs/heads/master@{#33552}
2016-01-27 13:23:54 +00:00
|
|
|
}
|
|
|
|
|
2016-08-10 14:33:37 +00:00
|
|
|
// Type feedback is encoded in such a way that, we can combine the feedback
|
2016-08-09 06:48:03 +00:00
|
|
|
// at different points by performing an 'OR' operation. Type feedback moves
|
|
|
|
// to a more generic type when we combine feedback.
|
2017-12-11 11:47:08 +00:00
|
|
|
//
|
|
|
|
// kSignedSmall -> kSignedSmallInputs -> kNumber -> kNumberOrOddball -> kAny
|
[turbofan] Significantly improve ConsString creation performance.
This change significantly improves the performance of string
concatenation in optimized code for the case where the resulting string
is represented as a ConsString. On the relevant test cases we go from
serializeNaive: 10762 ms.
serializeClever: 7813 ms.
serializeConcat: 10271 ms.
to
serializeNaive: 10278 ms.
serializeClever: 5533 ms.
serializeConcat: 10310 ms.
which represents a 30% improvement on the "clever" benchmark, which
tests specifically the ConsString creation performance.
This was accomplished via a couple of different steps, which are briefly
outlined here:
1. The empty_string gets its own map, so that we can easily recognize
and handle it appropriately in the TurboFan type system. This
allows us to express (and assert) that the inputs to NewConsString
are non-empty strings, making sure that TurboFan no longer creates
"crippled ConsStrings" with empty left or right hand sides.
2. Further split the existing String types in TurboFan to be able to
distinguish between OneByte and TwoByte strings on the type system
level. This allows us to avoid having to dynamically lookup the
resulting ConsString map in case of ConsString creation (i.e. when
we know that both input strings are OneByte strings or at least
one of the input strings is TwoByte).
3. We also introduced more finegrained feedback for the Add bytecode
in the interpreter, having it collect feedback about ConsStrings,
specifically ConsOneByteString and ConsTwoByteString. This feedback
can be used by TurboFan to only inline the relevant code for what
was seen so far. This allows us to remove the Octane/Splay specific
magic in JSTypedLowering to detect ConsString creation, and instead
purely rely on the feedback of what was seen so far (also making it
possible to change the semantics of NewConsString to be a low-level
operator, which is only introduced in SimplifiedLowering by looking
at the input types of StringConcat).
4. On top of the before mentioned type and interpreter changes we added
new operators CheckNonEmptyString, CheckNonEmptyOneByteString, and
CheckNonEmptyTwoByteString, which perform the appropriate (dynamic)
checks.
There are several more improvements that are possible based on this, but
since the change was already quite big, we decided not to put everything
into the first change, but do some follow up tweaks to the type system,
and builtin optimizations later.
Tbr: mstarzinger@chromium.org
Bug: v8:8834, v8:8931, v8:8939, v8:8951
Change-Id: Ia24e17c6048bf2b04df966d3cd441f0edda05c93
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
Doc: https://bit.ly/fast-string-concatenation-in-javascript
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1499497
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60318}
2019-03-18 19:33:46 +00:00
|
|
|
// kConsString -> kString -> kAny
|
2017-12-11 11:47:08 +00:00
|
|
|
// kBigInt -> kAny
|
|
|
|
//
|
|
|
|
// Technically we wouldn't need the separation between the kNumber and the
|
|
|
|
// kNumberOrOddball values here, since for binary operations, we always
|
|
|
|
// truncate oddballs to numbers. In practice though it causes TurboFan to
|
|
|
|
// generate quite a lot of unused code though if we always handle numbers
|
|
|
|
// and oddballs everywhere, although in 99% of the use sites they are only
|
|
|
|
// used with numbers.
|
2016-08-09 06:48:03 +00:00
|
|
|
class BinaryOperationFeedback {
|
|
|
|
public:
|
2016-10-05 19:48:30 +00:00
|
|
|
enum {
|
|
|
|
kNone = 0x0,
|
|
|
|
kSignedSmall = 0x1,
|
2017-08-11 08:17:54 +00:00
|
|
|
kSignedSmallInputs = 0x3,
|
2017-08-28 11:33:08 +00:00
|
|
|
kNumber = 0x7,
|
|
|
|
kNumberOrOddball = 0xF,
|
[turbofan] Significantly improve ConsString creation performance.
This change significantly improves the performance of string
concatenation in optimized code for the case where the resulting string
is represented as a ConsString. On the relevant test cases we go from
serializeNaive: 10762 ms.
serializeClever: 7813 ms.
serializeConcat: 10271 ms.
to
serializeNaive: 10278 ms.
serializeClever: 5533 ms.
serializeConcat: 10310 ms.
which represents a 30% improvement on the "clever" benchmark, which
tests specifically the ConsString creation performance.
This was accomplished via a couple of different steps, which are briefly
outlined here:
1. The empty_string gets its own map, so that we can easily recognize
and handle it appropriately in the TurboFan type system. This
allows us to express (and assert) that the inputs to NewConsString
are non-empty strings, making sure that TurboFan no longer creates
"crippled ConsStrings" with empty left or right hand sides.
2. Further split the existing String types in TurboFan to be able to
distinguish between OneByte and TwoByte strings on the type system
level. This allows us to avoid having to dynamically lookup the
resulting ConsString map in case of ConsString creation (i.e. when
we know that both input strings are OneByte strings or at least
one of the input strings is TwoByte).
3. We also introduced more finegrained feedback for the Add bytecode
in the interpreter, having it collect feedback about ConsStrings,
specifically ConsOneByteString and ConsTwoByteString. This feedback
can be used by TurboFan to only inline the relevant code for what
was seen so far. This allows us to remove the Octane/Splay specific
magic in JSTypedLowering to detect ConsString creation, and instead
purely rely on the feedback of what was seen so far (also making it
possible to change the semantics of NewConsString to be a low-level
operator, which is only introduced in SimplifiedLowering by looking
at the input types of StringConcat).
4. On top of the before mentioned type and interpreter changes we added
new operators CheckNonEmptyString, CheckNonEmptyOneByteString, and
CheckNonEmptyTwoByteString, which perform the appropriate (dynamic)
checks.
There are several more improvements that are possible based on this, but
since the change was already quite big, we decided not to put everything
into the first change, but do some follow up tweaks to the type system,
and builtin optimizations later.
Tbr: mstarzinger@chromium.org
Bug: v8:8834, v8:8931, v8:8939, v8:8951
Change-Id: Ia24e17c6048bf2b04df966d3cd441f0edda05c93
Cq-Include-Trybots: luci.chromium.try:linux-blink-rel
Doc: https://bit.ly/fast-string-concatenation-in-javascript
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1499497
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Yang Guo <yangguo@chromium.org>
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60318}
2019-03-18 19:33:46 +00:00
|
|
|
kConsOneByteString = 0x10,
|
|
|
|
kConsTwoByteString = 0x20,
|
|
|
|
kConsString = kConsOneByteString | kConsTwoByteString,
|
|
|
|
kString = 0x70,
|
|
|
|
kBigInt = 0x100,
|
|
|
|
kAny = 0x3FF
|
2016-10-05 19:48:30 +00:00
|
|
|
};
|
2016-08-09 06:48:03 +00:00
|
|
|
};
|
|
|
|
|
2016-11-17 14:45:18 +00:00
|
|
|
// Type feedback is encoded in such a way that, we can combine the feedback
|
|
|
|
// at different points by performing an 'OR' operation. Type feedback moves
|
|
|
|
// to a more generic type when we combine feedback.
|
2017-12-11 11:43:03 +00:00
|
|
|
//
|
[turbofan] ReceiverOrNullOrUndefined feedback for JSEqual.
This changes the ReceiverOrOddball feedback on JSStrictEqual to
ReceiverOrNullOrUndefined feedback, which can also safely be
consumed by JSEqual (we cannot generally accept any oddball here
since booleans trigger implicit conversions, unfortunately).
Thus we replace the previously introduced CheckReceiverOrOddball
with CheckReceiverOrNullOrUndefined, and drop CheckOddball, since
we will no longer collect Oddball feedback separately.
TurboFan will then turn a JSEqual[ReceiverOrNullOrUndefined] into
a sequence like this:
```
left = CheckReceiverOrNullOrUndefined(left);
right = CheckReceiverOrNullOrUndefined(right);
result = if ObjectIsUndetectable(left) then
ObjectIsUndetectable(right)
else
ReferenceEqual(left, right);
```
This significantly improves the peak performance of abstract equality
with Receiver, Null or Undefined inputs. On the test case outlined in
http://crbug.com/v8/8356 we go from
naive: 2946 ms.
tenary: 2134 ms.
to
naive: 2230 ms.
tenary: 2250 ms.
which corresponds to a 25% improvement on the abstract equality case.
For regular code this will probably yield more performance, since we
get rid of the JSEqual operator, which might have arbitrary side
effects and thus blocks all kinds of TurboFan optimizations. The
JSStrictEqual case is slightly slower now, since it has to rule out
booleans as well (even though that's not strictly necessary, but
consistency is key here).
This way developers can safely use `a == b` instead of doing a dance
like `a == null ? b == null : a === b` (which is what dart2js does
right now) when both `a` and `b` are known to be Receiver, Null or
Undefined. The abstract equality is not only faster to parse than
the tenary, but also generates a shorter bytecode sequence. In the
test case referenced in http://crbug.com/v8/8356 the bytecode for
`naive` is
```
StackCheck
Ldar a1
TestEqual a0, [0]
JumpIfFalse [5]
LdaSmi [1]
Return
LdaSmi [2]
Return
```
which is 14 bytes, whereas the `tenary` function generates
```
StackCheck
Ldar a0
TestUndetectable
JumpIfFalse [7]
Ldar a1
TestUndetectable
Jump [7]
Ldar a1
TestEqualStrict a0, [0]
JumpIfToBooleanFalse [5]
LdaSmi [1]
Return
LdaSmi [2]
Return
```
which is 24 bytes. So the `naive` version is 40% smaller and requires
fewer bytecode dispatches.
Bug: chromium:898455, v8:8356
Change-Id: If3961b2518b4438700706b3bd6071d546305e233
Reviewed-on: https://chromium-review.googlesource.com/c/1297315
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56948}
2018-10-24 12:09:34 +00:00
|
|
|
// kSignedSmall -> kNumber -> kNumberOrOddball -> kAny
|
|
|
|
// kReceiver -> kReceiverOrNullOrUndefined -> kAny
|
|
|
|
// kInternalizedString -> kString -> kAny
|
|
|
|
// kSymbol -> kAny
|
|
|
|
// kBigInt -> kAny
|
2017-12-11 11:43:03 +00:00
|
|
|
//
|
|
|
|
// This is distinct from BinaryOperationFeedback on purpose, because the
|
|
|
|
// feedback that matters differs greatly as well as the way it is consumed.
|
2016-08-30 10:21:02 +00:00
|
|
|
class CompareOperationFeedback {
|
|
|
|
public:
|
2016-11-17 14:45:18 +00:00
|
|
|
enum {
|
[turbofan] ReceiverOrNullOrUndefined feedback for JSEqual.
This changes the ReceiverOrOddball feedback on JSStrictEqual to
ReceiverOrNullOrUndefined feedback, which can also safely be
consumed by JSEqual (we cannot generally accept any oddball here
since booleans trigger implicit conversions, unfortunately).
Thus we replace the previously introduced CheckReceiverOrOddball
with CheckReceiverOrNullOrUndefined, and drop CheckOddball, since
we will no longer collect Oddball feedback separately.
TurboFan will then turn a JSEqual[ReceiverOrNullOrUndefined] into
a sequence like this:
```
left = CheckReceiverOrNullOrUndefined(left);
right = CheckReceiverOrNullOrUndefined(right);
result = if ObjectIsUndetectable(left) then
ObjectIsUndetectable(right)
else
ReferenceEqual(left, right);
```
This significantly improves the peak performance of abstract equality
with Receiver, Null or Undefined inputs. On the test case outlined in
http://crbug.com/v8/8356 we go from
naive: 2946 ms.
tenary: 2134 ms.
to
naive: 2230 ms.
tenary: 2250 ms.
which corresponds to a 25% improvement on the abstract equality case.
For regular code this will probably yield more performance, since we
get rid of the JSEqual operator, which might have arbitrary side
effects and thus blocks all kinds of TurboFan optimizations. The
JSStrictEqual case is slightly slower now, since it has to rule out
booleans as well (even though that's not strictly necessary, but
consistency is key here).
This way developers can safely use `a == b` instead of doing a dance
like `a == null ? b == null : a === b` (which is what dart2js does
right now) when both `a` and `b` are known to be Receiver, Null or
Undefined. The abstract equality is not only faster to parse than
the tenary, but also generates a shorter bytecode sequence. In the
test case referenced in http://crbug.com/v8/8356 the bytecode for
`naive` is
```
StackCheck
Ldar a1
TestEqual a0, [0]
JumpIfFalse [5]
LdaSmi [1]
Return
LdaSmi [2]
Return
```
which is 14 bytes, whereas the `tenary` function generates
```
StackCheck
Ldar a0
TestUndetectable
JumpIfFalse [7]
Ldar a1
TestUndetectable
Jump [7]
Ldar a1
TestEqualStrict a0, [0]
JumpIfToBooleanFalse [5]
LdaSmi [1]
Return
LdaSmi [2]
Return
```
which is 24 bytes. So the `naive` version is 40% smaller and requires
fewer bytecode dispatches.
Bug: chromium:898455, v8:8356
Change-Id: If3961b2518b4438700706b3bd6071d546305e233
Reviewed-on: https://chromium-review.googlesource.com/c/1297315
Reviewed-by: Jaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56948}
2018-10-24 12:09:34 +00:00
|
|
|
kNone = 0x000,
|
|
|
|
kSignedSmall = 0x001,
|
|
|
|
kNumber = 0x003,
|
|
|
|
kNumberOrOddball = 0x007,
|
|
|
|
kInternalizedString = 0x008,
|
|
|
|
kString = 0x018,
|
|
|
|
kSymbol = 0x020,
|
|
|
|
kBigInt = 0x040,
|
|
|
|
kReceiver = 0x080,
|
|
|
|
kReceiverOrNullOrUndefined = 0x180,
|
|
|
|
kAny = 0x1ff
|
2016-11-17 14:45:18 +00:00
|
|
|
};
|
2016-08-30 10:21:02 +00:00
|
|
|
};
|
|
|
|
|
2017-10-25 17:43:04 +00:00
|
|
|
enum class Operation {
|
|
|
|
// Binary operations.
|
|
|
|
kAdd,
|
|
|
|
kSubtract,
|
|
|
|
kMultiply,
|
|
|
|
kDivide,
|
|
|
|
kModulus,
|
2017-11-28 10:05:00 +00:00
|
|
|
kExponentiate,
|
2017-10-25 17:43:04 +00:00
|
|
|
kBitwiseAnd,
|
|
|
|
kBitwiseOr,
|
|
|
|
kBitwiseXor,
|
|
|
|
kShiftLeft,
|
|
|
|
kShiftRight,
|
|
|
|
kShiftRightLogical,
|
|
|
|
// Unary operations.
|
|
|
|
kBitwiseNot,
|
|
|
|
kNegate,
|
|
|
|
kIncrement,
|
|
|
|
kDecrement,
|
|
|
|
// Compare operations.
|
|
|
|
kEqual,
|
|
|
|
kStrictEqual,
|
|
|
|
kLessThan,
|
|
|
|
kLessThanOrEqual,
|
|
|
|
kGreaterThan,
|
|
|
|
kGreaterThanOrEqual,
|
|
|
|
};
|
|
|
|
|
2017-09-01 10:49:06 +00:00
|
|
|
// Type feedback is encoded in such a way that, we can combine the feedback
|
|
|
|
// at different points by performing an 'OR' operation. Type feedback moves
|
|
|
|
// to a more generic type when we combine feedback.
|
|
|
|
// kNone -> kEnumCacheKeysAndIndices -> kEnumCacheKeys -> kAny
|
|
|
|
class ForInFeedback {
|
|
|
|
public:
|
|
|
|
enum {
|
|
|
|
kNone = 0x0,
|
|
|
|
kEnumCacheKeysAndIndices = 0x1,
|
|
|
|
kEnumCacheKeys = 0x3,
|
|
|
|
kAny = 0x7
|
|
|
|
};
|
|
|
|
};
|
|
|
|
STATIC_ASSERT((ForInFeedback::kNone |
|
|
|
|
ForInFeedback::kEnumCacheKeysAndIndices) ==
|
|
|
|
ForInFeedback::kEnumCacheKeysAndIndices);
|
|
|
|
STATIC_ASSERT((ForInFeedback::kEnumCacheKeysAndIndices |
|
|
|
|
ForInFeedback::kEnumCacheKeys) == ForInFeedback::kEnumCacheKeys);
|
|
|
|
STATIC_ASSERT((ForInFeedback::kEnumCacheKeys | ForInFeedback::kAny) ==
|
|
|
|
ForInFeedback::kAny);
|
|
|
|
|
2016-10-05 18:45:54 +00:00
|
|
|
enum class UnicodeEncoding : uint8_t {
|
|
|
|
// Different unicode encodings in a |word32|:
|
|
|
|
UTF16, // hi 16bits -> trailing surrogate or 0, low 16bits -> lead surrogate
|
|
|
|
UTF32, // full UTF32 code unit / Unicode codepoint
|
|
|
|
};
|
|
|
|
|
|
|
|
inline size_t hash_value(UnicodeEncoding encoding) {
|
|
|
|
return static_cast<uint8_t>(encoding);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, UnicodeEncoding encoding) {
|
|
|
|
switch (encoding) {
|
|
|
|
case UnicodeEncoding::UTF16:
|
|
|
|
return os << "UTF16";
|
|
|
|
case UnicodeEncoding::UTF32:
|
|
|
|
return os << "UTF32";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2016-11-14 15:58:48 +00:00
|
|
|
enum class IterationKind { kKeys, kValues, kEntries };
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, IterationKind kind) {
|
|
|
|
switch (kind) {
|
|
|
|
case IterationKind::kKeys:
|
|
|
|
return os << "IterationKind::kKeys";
|
|
|
|
case IterationKind::kValues:
|
|
|
|
return os << "IterationKind::kValues";
|
|
|
|
case IterationKind::kEntries:
|
|
|
|
return os << "IterationKind::kEntries";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2018-04-04 12:27:44 +00:00
|
|
|
enum class CollectionKind { kMap, kSet };
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os, CollectionKind kind) {
|
|
|
|
switch (kind) {
|
|
|
|
case CollectionKind::kMap:
|
|
|
|
return os << "CollectionKind::kMap";
|
|
|
|
case CollectionKind::kSet:
|
|
|
|
return os << "CollectionKind::kSet";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
}
|
|
|
|
|
2016-12-19 16:30:36 +00:00
|
|
|
// Flags for the runtime function kDefineDataPropertyInLiteral. A property can
|
|
|
|
// be enumerable or not, and, in case of functions, the function name
|
|
|
|
// can be set or not.
|
|
|
|
enum class DataPropertyInLiteralFlag {
|
|
|
|
kNoFlags = 0,
|
|
|
|
kDontEnum = 1 << 0,
|
|
|
|
kSetFunctionName = 1 << 1
|
|
|
|
};
|
|
|
|
typedef base::Flags<DataPropertyInLiteralFlag> DataPropertyInLiteralFlags;
|
|
|
|
DEFINE_OPERATORS_FOR_FLAGS(DataPropertyInLiteralFlags)
|
|
|
|
|
2017-02-06 12:26:31 +00:00
|
|
|
enum ExternalArrayType {
|
|
|
|
kExternalInt8Array = 1,
|
|
|
|
kExternalUint8Array,
|
|
|
|
kExternalInt16Array,
|
|
|
|
kExternalUint16Array,
|
|
|
|
kExternalInt32Array,
|
|
|
|
kExternalUint32Array,
|
|
|
|
kExternalFloat32Array,
|
|
|
|
kExternalFloat64Array,
|
|
|
|
kExternalUint8ClampedArray,
|
2018-02-17 07:44:01 +00:00
|
|
|
kExternalBigInt64Array,
|
|
|
|
kExternalBigUint64Array,
|
2017-02-06 12:26:31 +00:00
|
|
|
};
|
|
|
|
|
2017-04-05 17:40:36 +00:00
|
|
|
struct AssemblerDebugInfo {
|
|
|
|
AssemblerDebugInfo(const char* name, const char* file, int line)
|
|
|
|
: name(name), file(file), line(line) {}
|
|
|
|
const char* name;
|
|
|
|
const char* file;
|
|
|
|
int line;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os,
|
|
|
|
const AssemblerDebugInfo& info) {
|
|
|
|
os << "(" << info.name << ":" << info.file << ":" << info.line << ")";
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
2017-06-15 14:53:38 +00:00
|
|
|
enum class OptimizationMarker {
|
2017-11-30 15:23:42 +00:00
|
|
|
kLogFirstExecution,
|
2017-06-15 14:53:38 +00:00
|
|
|
kNone,
|
|
|
|
kCompileOptimized,
|
|
|
|
kCompileOptimizedConcurrent,
|
|
|
|
kInOptimizationQueue
|
|
|
|
};
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os,
|
|
|
|
const OptimizationMarker& marker) {
|
|
|
|
switch (marker) {
|
2017-11-30 15:23:42 +00:00
|
|
|
case OptimizationMarker::kLogFirstExecution:
|
|
|
|
return os << "OptimizationMarker::kLogFirstExecution";
|
2017-06-15 14:53:38 +00:00
|
|
|
case OptimizationMarker::kNone:
|
|
|
|
return os << "OptimizationMarker::kNone";
|
|
|
|
case OptimizationMarker::kCompileOptimized:
|
|
|
|
return os << "OptimizationMarker::kCompileOptimized";
|
|
|
|
case OptimizationMarker::kCompileOptimizedConcurrent:
|
|
|
|
return os << "OptimizationMarker::kCompileOptimizedConcurrent";
|
|
|
|
case OptimizationMarker::kInOptimizationQueue:
|
|
|
|
return os << "OptimizationMarker::kInOptimizationQueue";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
2017-12-08 14:07:56 +00:00
|
|
|
enum class SpeculationMode { kAllowSpeculation, kDisallowSpeculation };
|
|
|
|
|
|
|
|
inline std::ostream& operator<<(std::ostream& os,
|
|
|
|
SpeculationMode speculation_mode) {
|
|
|
|
switch (speculation_mode) {
|
|
|
|
case SpeculationMode::kAllowSpeculation:
|
|
|
|
return os << "SpeculationMode::kAllowSpeculation";
|
|
|
|
case SpeculationMode::kDisallowSpeculation:
|
|
|
|
return os << "SpeculationMode::kDisallowSpeculation";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
2018-02-14 13:53:13 +00:00
|
|
|
enum class BlockingBehavior { kBlock, kDontBlock };
|
|
|
|
|
2017-06-15 14:53:38 +00:00
|
|
|
enum class ConcurrencyMode { kNotConcurrent, kConcurrent };
|
|
|
|
|
2017-11-03 04:06:08 +00:00
|
|
|
#define FOR_EACH_ISOLATE_ADDRESS_NAME(C) \
|
|
|
|
C(Handler, handler) \
|
|
|
|
C(CEntryFP, c_entry_fp) \
|
|
|
|
C(CFunction, c_function) \
|
|
|
|
C(Context, context) \
|
|
|
|
C(PendingException, pending_exception) \
|
|
|
|
C(PendingHandlerContext, pending_handler_context) \
|
|
|
|
C(PendingHandlerEntrypoint, pending_handler_entrypoint) \
|
|
|
|
C(PendingHandlerConstantPool, pending_handler_constant_pool) \
|
|
|
|
C(PendingHandlerFP, pending_handler_fp) \
|
|
|
|
C(PendingHandlerSP, pending_handler_sp) \
|
|
|
|
C(ExternalCaughtException, external_caught_exception) \
|
2018-01-29 15:43:04 +00:00
|
|
|
C(JSEntrySP, js_entry_sp)
|
2017-06-23 12:21:39 +00:00
|
|
|
|
|
|
|
enum IsolateAddressId {
|
|
|
|
#define DECLARE_ENUM(CamelName, hacker_name) k##CamelName##Address,
|
|
|
|
FOR_EACH_ISOLATE_ADDRESS_NAME(DECLARE_ENUM)
|
|
|
|
#undef DECLARE_ENUM
|
|
|
|
kIsolateAddressCount
|
|
|
|
};
|
|
|
|
|
2018-10-26 00:23:24 +00:00
|
|
|
V8_INLINE static bool HasWeakHeapObjectTag(Address value) {
|
|
|
|
// TODO(jkummerow): Consolidate integer types here.
|
|
|
|
return ((static_cast<intptr_t>(value) & kHeapObjectTagMask) ==
|
2018-03-19 13:53:31 +00:00
|
|
|
kWeakHeapObjectTag);
|
|
|
|
}
|
|
|
|
|
2018-03-19 10:38:06 +00:00
|
|
|
enum class HeapObjectReferenceType {
|
|
|
|
WEAK,
|
|
|
|
STRONG,
|
|
|
|
};
|
|
|
|
|
2018-04-30 12:13:54 +00:00
|
|
|
enum class PoisoningMitigationLevel {
|
|
|
|
kPoisonAll,
|
|
|
|
kDontPoison,
|
|
|
|
kPoisonCriticalOnly
|
|
|
|
};
|
2018-06-06 13:22:09 +00:00
|
|
|
|
2018-04-30 12:13:54 +00:00
|
|
|
enum class LoadSensitivity {
|
|
|
|
kCritical, // Critical loads are poisoned whenever we can run untrusted
|
|
|
|
// code (i.e., when --untrusted-code-mitigations is on).
|
|
|
|
kUnsafe, // Unsafe loads are poisoned when full poisoning is on
|
|
|
|
// (--branch-load-poisoning).
|
|
|
|
kSafe // Safe loads are never poisoned.
|
|
|
|
};
|
2018-03-26 15:44:44 +00:00
|
|
|
|
2018-06-06 13:22:09 +00:00
|
|
|
// The reason for a WebAssembly trap.
|
|
|
|
#define FOREACH_WASM_TRAPREASON(V) \
|
|
|
|
V(TrapUnreachable) \
|
|
|
|
V(TrapMemOutOfBounds) \
|
2018-09-05 21:55:41 +00:00
|
|
|
V(TrapUnalignedAccess) \
|
2018-06-06 13:22:09 +00:00
|
|
|
V(TrapDivByZero) \
|
|
|
|
V(TrapDivUnrepresentable) \
|
|
|
|
V(TrapRemByZero) \
|
|
|
|
V(TrapFloatUnrepresentable) \
|
|
|
|
V(TrapFuncInvalid) \
|
2018-12-12 02:18:54 +00:00
|
|
|
V(TrapFuncSigMismatch) \
|
2019-01-14 16:49:07 +00:00
|
|
|
V(TrapDataSegmentDropped) \
|
2019-01-16 15:52:15 +00:00
|
|
|
V(TrapElemSegmentDropped) \
|
|
|
|
V(TrapTableOutOfBounds)
|
2018-06-06 13:22:09 +00:00
|
|
|
|
2018-09-26 11:14:44 +00:00
|
|
|
enum KeyedAccessLoadMode {
|
|
|
|
STANDARD_LOAD,
|
|
|
|
LOAD_IGNORE_OUT_OF_BOUNDS,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum KeyedAccessStoreMode {
|
|
|
|
STANDARD_STORE,
|
|
|
|
STORE_TRANSITION_TO_OBJECT,
|
|
|
|
STORE_TRANSITION_TO_DOUBLE,
|
|
|
|
STORE_AND_GROW_NO_TRANSITION_HANDLE_COW,
|
|
|
|
STORE_AND_GROW_TRANSITION_TO_OBJECT,
|
|
|
|
STORE_AND_GROW_TRANSITION_TO_DOUBLE,
|
|
|
|
STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS,
|
|
|
|
STORE_NO_TRANSITION_HANDLE_COW
|
|
|
|
};
|
|
|
|
|
|
|
|
enum MutableMode { MUTABLE, IMMUTABLE };
|
|
|
|
|
|
|
|
static inline bool IsTransitionStoreMode(KeyedAccessStoreMode store_mode) {
|
|
|
|
return store_mode == STORE_TRANSITION_TO_OBJECT ||
|
|
|
|
store_mode == STORE_TRANSITION_TO_DOUBLE ||
|
|
|
|
store_mode == STORE_AND_GROW_TRANSITION_TO_OBJECT ||
|
|
|
|
store_mode == STORE_AND_GROW_TRANSITION_TO_DOUBLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsCOWHandlingStoreMode(KeyedAccessStoreMode store_mode) {
|
|
|
|
return store_mode == STORE_NO_TRANSITION_HANDLE_COW ||
|
|
|
|
store_mode == STORE_AND_GROW_NO_TRANSITION_HANDLE_COW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline KeyedAccessStoreMode GetNonTransitioningStoreMode(
|
|
|
|
KeyedAccessStoreMode store_mode, bool receiver_was_cow) {
|
|
|
|
switch (store_mode) {
|
|
|
|
case STORE_AND_GROW_NO_TRANSITION_HANDLE_COW:
|
|
|
|
case STORE_AND_GROW_TRANSITION_TO_OBJECT:
|
|
|
|
case STORE_AND_GROW_TRANSITION_TO_DOUBLE:
|
|
|
|
store_mode = STORE_AND_GROW_NO_TRANSITION_HANDLE_COW;
|
|
|
|
break;
|
|
|
|
case STANDARD_STORE:
|
|
|
|
case STORE_TRANSITION_TO_OBJECT:
|
|
|
|
case STORE_TRANSITION_TO_DOUBLE:
|
|
|
|
store_mode =
|
|
|
|
receiver_was_cow ? STORE_NO_TRANSITION_HANDLE_COW : STANDARD_STORE;
|
|
|
|
break;
|
|
|
|
case STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS:
|
|
|
|
case STORE_NO_TRANSITION_HANDLE_COW:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
DCHECK(!IsTransitionStoreMode(store_mode));
|
|
|
|
DCHECK_IMPLIES(receiver_was_cow, IsCOWHandlingStoreMode(store_mode));
|
|
|
|
return store_mode;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsGrowStoreMode(KeyedAccessStoreMode store_mode) {
|
|
|
|
return store_mode >= STORE_AND_GROW_NO_TRANSITION_HANDLE_COW &&
|
|
|
|
store_mode <= STORE_AND_GROW_TRANSITION_TO_DOUBLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum IcCheckType { ELEMENT, PROPERTY };
|
Reland "[assembler] Split out CPUFeatures into its own file"
This is a reland of 3ad101f5bf9b30bd4378e1643fd86cc4c61d3aa9
Original change's description:
> [assembler] Split out CPUFeatures into its own file
>
> This reduces the preprocessor expanded source size by 84,675 LoC:
>
> gen ( 20 files): 71,349 to 1,523,934 ( 21x)
> src ( 624 files): 367,410 to 53,253,894 ( 145x)
> test ( 392 files): 490,503 to 37,436,176 ( 76x)
> third_party ( 432 files): 239,085 to 9,547,902 ( 40x)
> total ( 1520 files): 1,183,031 to 102,736,424 ( 87x)
>
> to
>
> gen ( 20 files): 71,349 to 1,523,794 ( 21x)
> src ( 624 files): 367,411 to 53,186,896 ( 145x)
> test ( 392 files): 490,504 to 37,418,639 ( 76x)
> third_party ( 432 files): 239,085 to 9,547,902 ( 40x)
> total ( 1520 files): 1,183,033 to 102,651,749 ( 87x)
>
>
> Change-Id: Ia8a79092051a42815b65e86a0784297915368c9b
> Reviewed-on: https://chromium-review.googlesource.com/c/1291471
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
> Reviewed-by: Marja Hölttä <marja@chromium.org>
> Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#58266}
TBR=marja@chromium.org,clemensh@chromium.org,ulan@chromium.org
Change-Id: I5b857666508b1c80dcadd0b470aada37dd49077e
Reviewed-on: https://chromium-review.googlesource.com/c/1379872
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58278}
2018-12-17 10:32:43 +00:00
|
|
|
|
|
|
|
// Helper stubs can be called in different ways depending on where the target
|
|
|
|
// code is located and how the call sequence is expected to look like:
|
2018-12-17 15:39:38 +00:00
|
|
|
// - CodeObject: Call on-heap {Code} object via {RelocInfo::CODE_TARGET}.
|
2018-12-17 13:20:16 +00:00
|
|
|
// - WasmRuntimeStub: Call native {WasmCode} stub via
|
|
|
|
// {RelocInfo::WASM_STUB_CALL}.
|
|
|
|
// - BuiltinPointer: Call a builtin based on a builtin pointer with dynamic
|
|
|
|
// contents. If builtins are embedded, we call directly into off-heap code
|
|
|
|
// without going through the on-heap Code trampoline.
|
|
|
|
enum class StubCallMode {
|
2018-12-17 15:39:38 +00:00
|
|
|
kCallCodeObject,
|
2018-12-17 13:20:16 +00:00
|
|
|
kCallWasmRuntimeStub,
|
|
|
|
kCallBuiltinPointer,
|
|
|
|
};
|
Reland "[assembler] Split out CPUFeatures into its own file"
This is a reland of 3ad101f5bf9b30bd4378e1643fd86cc4c61d3aa9
Original change's description:
> [assembler] Split out CPUFeatures into its own file
>
> This reduces the preprocessor expanded source size by 84,675 LoC:
>
> gen ( 20 files): 71,349 to 1,523,934 ( 21x)
> src ( 624 files): 367,410 to 53,253,894 ( 145x)
> test ( 392 files): 490,503 to 37,436,176 ( 76x)
> third_party ( 432 files): 239,085 to 9,547,902 ( 40x)
> total ( 1520 files): 1,183,031 to 102,736,424 ( 87x)
>
> to
>
> gen ( 20 files): 71,349 to 1,523,794 ( 21x)
> src ( 624 files): 367,411 to 53,186,896 ( 145x)
> test ( 392 files): 490,504 to 37,418,639 ( 76x)
> third_party ( 432 files): 239,085 to 9,547,902 ( 40x)
> total ( 1520 files): 1,183,033 to 102,651,749 ( 87x)
>
>
> Change-Id: Ia8a79092051a42815b65e86a0784297915368c9b
> Reviewed-on: https://chromium-review.googlesource.com/c/1291471
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
> Reviewed-by: Marja Hölttä <marja@chromium.org>
> Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#58266}
TBR=marja@chromium.org,clemensh@chromium.org,ulan@chromium.org
Change-Id: I5b857666508b1c80dcadd0b470aada37dd49077e
Reviewed-on: https://chromium-review.googlesource.com/c/1379872
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58278}
2018-12-17 10:32:43 +00:00
|
|
|
|
2019-02-25 10:31:51 +00:00
|
|
|
constexpr int kFunctionLiteralIdInvalid = -1;
|
|
|
|
constexpr int kFunctionLiteralIdTopLevel = 0;
|
|
|
|
|
2019-03-26 09:17:03 +00:00
|
|
|
constexpr int kSmallOrderedHashSetMinCapacity = 4;
|
|
|
|
constexpr int kSmallOrderedHashMapMinCapacity = 4;
|
|
|
|
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-05-26 11:28:08 +00:00
|
|
|
namespace i = v8::internal;
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
#endif // V8_GLOBALS_H_
|