v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
globals.h
Go to the documentation of this file.
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_HEAP_CPPGC_GLOBALS_H_
6#define V8_HEAP_CPPGC_GLOBALS_H_
7
8#include <stddef.h>
9#include <stdint.h>
10
13
14namespace cppgc {
15namespace internal {
16
17using Address = uint8_t*;
18using ConstAddress = const uint8_t*;
19
20constexpr size_t kKB = 1024;
21constexpr size_t kMB = kKB * 1024;
22constexpr size_t kGB = kMB * 1024;
23
24// AccessMode used for choosing between atomic and non-atomic accesses.
25enum class AccessMode : uint8_t { kNonAtomic, kAtomic };
26
27// See 6.7.6 (http://eel.is/c++draft/basic.align) for alignment restrictions. We
28// do not fully support all alignment restrictions (following
29// alignof(std​::​max_­align_­t)) but limit to alignof(double).
30//
31// This means that any scalar type with stricter alignment requirements (in
32// practice: long double) cannot be used unrestricted in garbage-collected
33// objects.
34#if defined(V8_HOST_ARCH_64_BIT)
35constexpr size_t kAllocationGranularity = 8;
36#else // !V8_HOST_ARCH_64_BIT
37constexpr size_t kAllocationGranularity = 4;
38#endif // !V8_HOST_ARCH_64_BIT
40
41constexpr size_t kPageSizeLog2 = 17;
42constexpr size_t kPageSize = 1 << kPageSizeLog2;
43constexpr size_t kPageOffsetMask = kPageSize - 1;
44constexpr size_t kPageBaseMask = ~kPageOffsetMask;
45
46constexpr size_t kLargeObjectSizeThreshold = kPageSize / 2;
47
49constexpr size_t kFreeListEntrySize = 2 * sizeof(uintptr_t);
50
51#if defined(CPPGC_POINTER_COMPRESSION)
52constexpr size_t kSlotSize = sizeof(uint32_t);
53#else // !defined(CPPGC_POINTER_COMPRESSION)
54constexpr size_t kSlotSize = sizeof(uintptr_t);
55#endif // !defined(CPPGC_POINTER_COMPRESSION)
56
57} // namespace internal
58} // namespace cppgc
59
60#endif // V8_HEAP_CPPGC_GLOBALS_H_
constexpr size_t kPageSizeLog2
Definition globals.h:41
constexpr size_t kGB
Definition globals.h:22
constexpr size_t kPageSize
Definition globals.h:42
uint8_t * Address
Definition globals.h:17
constexpr size_t kSlotSize
Definition globals.h:54
constexpr size_t kPageOffsetMask
Definition globals.h:43
constexpr size_t kMB
Definition globals.h:21
const uint8_t * ConstAddress
Definition globals.h:18
constexpr size_t kAllocationGranularity
Definition globals.h:37
constexpr size_t kPageBaseMask
Definition globals.h:44
constexpr size_t kAllocationMask
Definition globals.h:39
constexpr size_t kKB
Definition globals.h:20
constexpr GCInfoIndex kFreeListGCInfoIndex
Definition globals.h:48
constexpr size_t kLargeObjectSizeThreshold
Definition globals.h:46
uint16_t GCInfoIndex
Definition gc-info.h:21
constexpr size_t kFreeListEntrySize
Definition globals.h:49