@babylonjs/v8-android-jit-nointl-nosnapshot 11.110.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/include/APIDesign.md +72 -0
  2. package/dist/include/DEPS +10 -0
  3. package/dist/include/DIR_METADATA +11 -0
  4. package/dist/include/OWNERS +23 -0
  5. package/dist/include/cppgc/DEPS +8 -0
  6. package/dist/include/cppgc/OWNERS +2 -0
  7. package/dist/include/cppgc/README.md +135 -0
  8. package/dist/include/cppgc/allocation.h +310 -0
  9. package/dist/include/cppgc/common.h +28 -0
  10. package/dist/include/cppgc/cross-thread-persistent.h +464 -0
  11. package/dist/include/cppgc/custom-space.h +97 -0
  12. package/dist/include/cppgc/default-platform.h +67 -0
  13. package/dist/include/cppgc/ephemeron-pair.h +30 -0
  14. package/dist/include/cppgc/explicit-management.h +100 -0
  15. package/dist/include/cppgc/garbage-collected.h +106 -0
  16. package/dist/include/cppgc/heap-consistency.h +309 -0
  17. package/dist/include/cppgc/heap-handle.h +48 -0
  18. package/dist/include/cppgc/heap-state.h +82 -0
  19. package/dist/include/cppgc/heap-statistics.h +120 -0
  20. package/dist/include/cppgc/heap.h +202 -0
  21. package/dist/include/cppgc/internal/api-constants.h +65 -0
  22. package/dist/include/cppgc/internal/atomic-entry-flag.h +48 -0
  23. package/dist/include/cppgc/internal/base-page-handle.h +45 -0
  24. package/dist/include/cppgc/internal/caged-heap-local-data.h +111 -0
  25. package/dist/include/cppgc/internal/caged-heap.h +61 -0
  26. package/dist/include/cppgc/internal/compiler-specific.h +38 -0
  27. package/dist/include/cppgc/internal/finalizer-trait.h +93 -0
  28. package/dist/include/cppgc/internal/gc-info.h +155 -0
  29. package/dist/include/cppgc/internal/logging.h +50 -0
  30. package/dist/include/cppgc/internal/member-storage.h +236 -0
  31. package/dist/include/cppgc/internal/name-trait.h +137 -0
  32. package/dist/include/cppgc/internal/persistent-node.h +214 -0
  33. package/dist/include/cppgc/internal/pointer-policies.h +207 -0
  34. package/dist/include/cppgc/internal/write-barrier.h +477 -0
  35. package/dist/include/cppgc/liveness-broker.h +78 -0
  36. package/dist/include/cppgc/macros.h +26 -0
  37. package/dist/include/cppgc/member.h +566 -0
  38. package/dist/include/cppgc/name-provider.h +65 -0
  39. package/dist/include/cppgc/object-size-trait.h +58 -0
  40. package/dist/include/cppgc/persistent.h +366 -0
  41. package/dist/include/cppgc/platform.h +158 -0
  42. package/dist/include/cppgc/prefinalizer.h +75 -0
  43. package/dist/include/cppgc/process-heap-statistics.h +36 -0
  44. package/dist/include/cppgc/sentinel-pointer.h +32 -0
  45. package/dist/include/cppgc/source-location.h +92 -0
  46. package/dist/include/cppgc/testing.h +106 -0
  47. package/dist/include/cppgc/trace-trait.h +120 -0
  48. package/dist/include/cppgc/type-traits.h +249 -0
  49. package/dist/include/cppgc/visitor.h +411 -0
  50. package/dist/include/js_protocol-1.2.json +997 -0
  51. package/dist/include/js_protocol-1.3.json +1159 -0
  52. package/dist/include/js_protocol.pdl +1766 -0
  53. package/dist/include/libplatform/DEPS +9 -0
  54. package/dist/include/libplatform/libplatform-export.h +29 -0
  55. package/dist/include/libplatform/libplatform.h +106 -0
  56. package/dist/include/libplatform/v8-tracing.h +333 -0
  57. package/dist/include/v8-array-buffer.h +512 -0
  58. package/dist/include/v8-callbacks.h +412 -0
  59. package/dist/include/v8-container.h +129 -0
  60. package/dist/include/v8-context.h +415 -0
  61. package/dist/include/v8-cppgc.h +231 -0
  62. package/dist/include/v8-data.h +80 -0
  63. package/dist/include/v8-date.h +48 -0
  64. package/dist/include/v8-debug.h +168 -0
  65. package/dist/include/v8-embedder-heap.h +223 -0
  66. package/dist/include/v8-embedder-state-scope.h +51 -0
  67. package/dist/include/v8-exception.h +217 -0
  68. package/dist/include/v8-extension.h +62 -0
  69. package/dist/include/v8-external.h +37 -0
  70. package/dist/include/v8-fast-api-calls.h +957 -0
  71. package/dist/include/v8-forward.h +81 -0
  72. package/dist/include/v8-function-callback.h +475 -0
  73. package/dist/include/v8-function.h +133 -0
  74. package/dist/include/v8-initialization.h +289 -0
  75. package/dist/include/v8-inspector-protocol.h +13 -0
  76. package/dist/include/v8-inspector.h +397 -0
  77. package/dist/include/v8-internal.h +851 -0
  78. package/dist/include/v8-isolate.h +1695 -0
  79. package/dist/include/v8-json.h +47 -0
  80. package/dist/include/v8-local-handle.h +455 -0
  81. package/dist/include/v8-locker.h +138 -0
  82. package/dist/include/v8-maybe.h +160 -0
  83. package/dist/include/v8-memory-span.h +43 -0
  84. package/dist/include/v8-message.h +214 -0
  85. package/dist/include/v8-metrics.h +311 -0
  86. package/dist/include/v8-microtask-queue.h +157 -0
  87. package/dist/include/v8-microtask.h +28 -0
  88. package/dist/include/v8-object.h +768 -0
  89. package/dist/include/v8-persistent-handle.h +588 -0
  90. package/dist/include/v8-platform.h +1130 -0
  91. package/dist/include/v8-primitive-object.h +118 -0
  92. package/dist/include/v8-primitive.h +866 -0
  93. package/dist/include/v8-profiler.h +1277 -0
  94. package/dist/include/v8-promise.h +174 -0
  95. package/dist/include/v8-proxy.h +50 -0
  96. package/dist/include/v8-regexp.h +106 -0
  97. package/dist/include/v8-script.h +803 -0
  98. package/dist/include/v8-snapshot.h +196 -0
  99. package/dist/include/v8-statistics.h +217 -0
  100. package/dist/include/v8-template.h +1018 -0
  101. package/dist/include/v8-traced-handle.h +420 -0
  102. package/dist/include/v8-typed-array.h +282 -0
  103. package/dist/include/v8-unwinder-state.h +31 -0
  104. package/dist/include/v8-unwinder.h +132 -0
  105. package/dist/include/v8-util.h +656 -0
  106. package/dist/include/v8-value-serializer-version.h +24 -0
  107. package/dist/include/v8-value-serializer.h +302 -0
  108. package/dist/include/v8-value.h +531 -0
  109. package/dist/include/v8-version-string.h +38 -0
  110. package/dist/include/v8-version.h +20 -0
  111. package/dist/include/v8-wasm-trap-handler-posix.h +31 -0
  112. package/dist/include/v8-wasm-trap-handler-win.h +28 -0
  113. package/dist/include/v8-wasm.h +200 -0
  114. package/dist/include/v8-weak-callback-info.h +80 -0
  115. package/dist/include/v8.h +88 -0
  116. package/dist/include/v8config.h +904 -0
  117. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.aar +0 -0
  118. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.aar.md5 +1 -0
  119. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.aar.sha1 +1 -0
  120. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.pom +10 -0
  121. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.pom.md5 +1 -0
  122. package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.pom.sha1 +1 -0
  123. package/dist/org/chromium/v8-android/maven-metadata.xml +12 -0
  124. package/dist/org/chromium/v8-android/maven-metadata.xml.md5 +1 -0
  125. package/dist/org/chromium/v8-android/maven-metadata.xml.sha1 +1 -0
  126. package/package.json +24 -0
@@ -0,0 +1,120 @@
1
+ // Copyright 2021 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 INCLUDE_CPPGC_HEAP_STATISTICS_H_
6
+ #define INCLUDE_CPPGC_HEAP_STATISTICS_H_
7
+
8
+ #include <cstddef>
9
+ #include <cstdint>
10
+ #include <string>
11
+ #include <vector>
12
+
13
+ namespace cppgc {
14
+
15
+ /**
16
+ * `HeapStatistics` contains memory consumption and utilization statistics for a
17
+ * cppgc heap.
18
+ */
19
+ struct HeapStatistics final {
20
+ /**
21
+ * Specifies the detail level of the heap statistics. Brief statistics contain
22
+ * only the top-level allocated and used memory statistics for the entire
23
+ * heap. Detailed statistics also contain a break down per space and page, as
24
+ * well as freelist statistics and object type histograms. Note that used
25
+ * memory reported by brief statistics and detailed statistics might differ
26
+ * slightly.
27
+ */
28
+ enum DetailLevel : uint8_t {
29
+ kBrief,
30
+ kDetailed,
31
+ };
32
+
33
+ /**
34
+ * Object statistics for a single type.
35
+ */
36
+ struct ObjectStatsEntry {
37
+ /**
38
+ * Number of allocated bytes.
39
+ */
40
+ size_t allocated_bytes;
41
+ /**
42
+ * Number of allocated objects.
43
+ */
44
+ size_t object_count;
45
+ };
46
+
47
+ /**
48
+ * Page granularity statistics. For each page the statistics record the
49
+ * allocated memory size and overall used memory size for the page.
50
+ */
51
+ struct PageStatistics {
52
+ /** Overall committed amount of memory for the page. */
53
+ size_t committed_size_bytes = 0;
54
+ /** Resident amount of memory held by the page. */
55
+ size_t resident_size_bytes = 0;
56
+ /** Amount of memory actually used on the page. */
57
+ size_t used_size_bytes = 0;
58
+ /** Statistics for object allocated on the page. Filled only when
59
+ * NameProvider::SupportsCppClassNamesAsObjectNames() is true. */
60
+ std::vector<ObjectStatsEntry> object_statistics;
61
+ };
62
+
63
+ /**
64
+ * Statistics of the freelist (used only in non-large object spaces). For
65
+ * each bucket in the freelist the statistics record the bucket size, the
66
+ * number of freelist entries in the bucket, and the overall allocated memory
67
+ * consumed by these freelist entries.
68
+ */
69
+ struct FreeListStatistics {
70
+ /** bucket sizes in the freelist. */
71
+ std::vector<size_t> bucket_size;
72
+ /** number of freelist entries per bucket. */
73
+ std::vector<size_t> free_count;
74
+ /** memory size consumed by freelist entries per size. */
75
+ std::vector<size_t> free_size;
76
+ };
77
+
78
+ /**
79
+ * Space granularity statistics. For each space the statistics record the
80
+ * space name, the amount of allocated memory and overall used memory for the
81
+ * space. The statistics also contain statistics for each of the space's
82
+ * pages, its freelist and the objects allocated on the space.
83
+ */
84
+ struct SpaceStatistics {
85
+ /** The space name */
86
+ std::string name;
87
+ /** Overall committed amount of memory for the heap. */
88
+ size_t committed_size_bytes = 0;
89
+ /** Resident amount of memory held by the heap. */
90
+ size_t resident_size_bytes = 0;
91
+ /** Amount of memory actually used on the space. */
92
+ size_t used_size_bytes = 0;
93
+ /** Statistics for each of the pages in the space. */
94
+ std::vector<PageStatistics> page_stats;
95
+ /** Statistics for the freelist of the space. */
96
+ FreeListStatistics free_list_stats;
97
+ };
98
+
99
+ /** Overall committed amount of memory for the heap. */
100
+ size_t committed_size_bytes = 0;
101
+ /** Resident amount of memory held by the heap. */
102
+ size_t resident_size_bytes = 0;
103
+ /** Amount of memory actually used on the heap. */
104
+ size_t used_size_bytes = 0;
105
+ /** Detail level of this HeapStatistics. */
106
+ DetailLevel detail_level;
107
+
108
+ /** Statistics for each of the spaces in the heap. Filled only when
109
+ * `detail_level` is `DetailLevel::kDetailed`. */
110
+ std::vector<SpaceStatistics> space_stats;
111
+
112
+ /**
113
+ * Vector of `cppgc::GarbageCollected` type names.
114
+ */
115
+ std::vector<std::string> type_names;
116
+ };
117
+
118
+ } // namespace cppgc
119
+
120
+ #endif // INCLUDE_CPPGC_HEAP_STATISTICS_H_
@@ -0,0 +1,202 @@
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 INCLUDE_CPPGC_HEAP_H_
6
+ #define INCLUDE_CPPGC_HEAP_H_
7
+
8
+ #include <cstddef>
9
+ #include <cstdint>
10
+ #include <memory>
11
+ #include <vector>
12
+
13
+ #include "cppgc/common.h"
14
+ #include "cppgc/custom-space.h"
15
+ #include "cppgc/platform.h"
16
+ #include "v8config.h" // NOLINT(build/include_directory)
17
+
18
+ /**
19
+ * cppgc - A C++ garbage collection library.
20
+ */
21
+ namespace cppgc {
22
+
23
+ class AllocationHandle;
24
+ class HeapHandle;
25
+
26
+ /**
27
+ * Implementation details of cppgc. Those details are considered internal and
28
+ * may change at any point in time without notice. Users should never rely on
29
+ * the contents of this namespace.
30
+ */
31
+ namespace internal {
32
+ class Heap;
33
+ } // namespace internal
34
+
35
+ class V8_EXPORT Heap {
36
+ public:
37
+ /**
38
+ * Specifies the stack state the embedder is in.
39
+ */
40
+ using StackState = EmbedderStackState;
41
+
42
+ /**
43
+ * Specifies whether conservative stack scanning is supported.
44
+ */
45
+ enum class StackSupport : uint8_t {
46
+ /**
47
+ * Conservative stack scan is supported.
48
+ */
49
+ kSupportsConservativeStackScan,
50
+ /**
51
+ * Conservative stack scan is not supported. Embedders may use this option
52
+ * when using custom infrastructure that is unsupported by the library.
53
+ */
54
+ kNoConservativeStackScan,
55
+ };
56
+
57
+ /**
58
+ * Specifies supported marking types.
59
+ */
60
+ enum class MarkingType : uint8_t {
61
+ /**
62
+ * Atomic stop-the-world marking. This option does not require any write
63
+ * barriers but is the most intrusive in terms of jank.
64
+ */
65
+ kAtomic,
66
+ /**
67
+ * Incremental marking interleaves marking with the rest of the application
68
+ * workload on the same thread.
69
+ */
70
+ kIncremental,
71
+ /**
72
+ * Incremental and concurrent marking.
73
+ */
74
+ kIncrementalAndConcurrent
75
+ };
76
+
77
+ /**
78
+ * Specifies supported sweeping types.
79
+ */
80
+ enum class SweepingType : uint8_t {
81
+ /**
82
+ * Atomic stop-the-world sweeping. All of sweeping is performed at once.
83
+ */
84
+ kAtomic,
85
+ /**
86
+ * Incremental sweeping interleaves sweeping with the rest of the
87
+ * application workload on the same thread.
88
+ */
89
+ kIncremental,
90
+ /**
91
+ * Incremental and concurrent sweeping. Sweeping is split and interleaved
92
+ * with the rest of the application.
93
+ */
94
+ kIncrementalAndConcurrent
95
+ };
96
+
97
+ /**
98
+ * Constraints for a Heap setup.
99
+ */
100
+ struct ResourceConstraints {
101
+ /**
102
+ * Allows the heap to grow to some initial size in bytes before triggering
103
+ * garbage collections. This is useful when it is known that applications
104
+ * need a certain minimum heap to run to avoid repeatedly invoking the
105
+ * garbage collector when growing the heap.
106
+ */
107
+ size_t initial_heap_size_bytes = 0;
108
+ };
109
+
110
+ /**
111
+ * Options specifying Heap properties (e.g. custom spaces) when initializing a
112
+ * heap through `Heap::Create()`.
113
+ */
114
+ struct HeapOptions {
115
+ /**
116
+ * Creates reasonable defaults for instantiating a Heap.
117
+ *
118
+ * \returns the HeapOptions that can be passed to `Heap::Create()`.
119
+ */
120
+ static HeapOptions Default() { return {}; }
121
+
122
+ /**
123
+ * Custom spaces added to heap are required to have indices forming a
124
+ * numbered sequence starting at 0, i.e., their `kSpaceIndex` must
125
+ * correspond to the index they reside in the vector.
126
+ */
127
+ std::vector<std::unique_ptr<CustomSpaceBase>> custom_spaces;
128
+
129
+ /**
130
+ * Specifies whether conservative stack scan is supported. When conservative
131
+ * stack scan is not supported, the collector may try to invoke
132
+ * garbage collections using non-nestable task, which are guaranteed to have
133
+ * no interesting stack, through the provided Platform. If such tasks are
134
+ * not supported by the Platform, the embedder must take care of invoking
135
+ * the GC through `ForceGarbageCollectionSlow()`.
136
+ */
137
+ StackSupport stack_support = StackSupport::kSupportsConservativeStackScan;
138
+
139
+ /**
140
+ * Specifies which types of marking are supported by the heap.
141
+ */
142
+ MarkingType marking_support = MarkingType::kIncrementalAndConcurrent;
143
+
144
+ /**
145
+ * Specifies which types of sweeping are supported by the heap.
146
+ */
147
+ SweepingType sweeping_support = SweepingType::kIncrementalAndConcurrent;
148
+
149
+ /**
150
+ * Resource constraints specifying various properties that the internal
151
+ * GC scheduler follows.
152
+ */
153
+ ResourceConstraints resource_constraints;
154
+ };
155
+
156
+ /**
157
+ * Creates a new heap that can be used for object allocation.
158
+ *
159
+ * \param platform implemented and provided by the embedder.
160
+ * \param options HeapOptions specifying various properties for the Heap.
161
+ * \returns a new Heap instance.
162
+ */
163
+ static std::unique_ptr<Heap> Create(
164
+ std::shared_ptr<Platform> platform,
165
+ HeapOptions options = HeapOptions::Default());
166
+
167
+ virtual ~Heap() = default;
168
+
169
+ /**
170
+ * Forces garbage collection.
171
+ *
172
+ * \param source String specifying the source (or caller) triggering a
173
+ * forced garbage collection.
174
+ * \param reason String specifying the reason for the forced garbage
175
+ * collection.
176
+ * \param stack_state The embedder stack state, see StackState.
177
+ */
178
+ void ForceGarbageCollectionSlow(
179
+ const char* source, const char* reason,
180
+ StackState stack_state = StackState::kMayContainHeapPointers);
181
+
182
+ /**
183
+ * \returns the opaque handle for allocating objects using
184
+ * `MakeGarbageCollected()`.
185
+ */
186
+ AllocationHandle& GetAllocationHandle();
187
+
188
+ /**
189
+ * \returns the opaque heap handle which may be used to refer to this heap in
190
+ * other APIs. Valid as long as the underlying `Heap` is alive.
191
+ */
192
+ HeapHandle& GetHeapHandle();
193
+
194
+ private:
195
+ Heap() = default;
196
+
197
+ friend class internal::Heap;
198
+ };
199
+
200
+ } // namespace cppgc
201
+
202
+ #endif // INCLUDE_CPPGC_HEAP_H_
@@ -0,0 +1,65 @@
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 INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
7
+
8
+ #include <cstddef>
9
+ #include <cstdint>
10
+
11
+ #include "v8config.h" // NOLINT(build/include_directory)
12
+
13
+ namespace cppgc {
14
+ namespace internal {
15
+
16
+ // Embedders should not rely on this code!
17
+
18
+ // Internal constants to avoid exposing internal types on the API surface.
19
+ namespace api_constants {
20
+
21
+ constexpr size_t kKB = 1024;
22
+ constexpr size_t kMB = kKB * 1024;
23
+ constexpr size_t kGB = kMB * 1024;
24
+
25
+ // Offset of the uint16_t bitfield from the payload contaning the
26
+ // in-construction bit. This is subtracted from the payload pointer to get
27
+ // to the right bitfield.
28
+ static constexpr size_t kFullyConstructedBitFieldOffsetFromPayload =
29
+ 2 * sizeof(uint16_t);
30
+ // Mask for in-construction bit.
31
+ static constexpr uint16_t kFullyConstructedBitMask = uint16_t{1};
32
+
33
+ static constexpr size_t kPageSize = size_t{1} << 17;
34
+
35
+ #if defined(V8_TARGET_ARCH_ARM64) && defined(V8_OS_MACOS)
36
+ constexpr size_t kGuardPageSize = 0;
37
+ #else
38
+ constexpr size_t kGuardPageSize = 4096;
39
+ #endif
40
+
41
+ static constexpr size_t kLargeObjectSizeThreshold = kPageSize / 2;
42
+
43
+ #if defined(CPPGC_CAGED_HEAP)
44
+ #if defined(CPPGC_2GB_CAGE)
45
+ constexpr size_t kCagedHeapReservationSize = static_cast<size_t>(2) * kGB;
46
+ #else // !defined(CPPGC_2GB_CAGE)
47
+ constexpr size_t kCagedHeapReservationSize = static_cast<size_t>(4) * kGB;
48
+ #endif // !defined(CPPGC_2GB_CAGE)
49
+ constexpr size_t kCagedHeapReservationAlignment = kCagedHeapReservationSize;
50
+ #endif // defined(CPPGC_CAGED_HEAP)
51
+
52
+ static constexpr size_t kDefaultAlignment = sizeof(void*);
53
+
54
+ // Maximum support alignment for a type as in `alignof(T)`.
55
+ static constexpr size_t kMaxSupportedAlignment = 2 * kDefaultAlignment;
56
+
57
+ // Granularity of heap allocations.
58
+ constexpr size_t kAllocationGranularity = sizeof(void*);
59
+
60
+ } // namespace api_constants
61
+
62
+ } // namespace internal
63
+ } // namespace cppgc
64
+
65
+ #endif // INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
@@ -0,0 +1,48 @@
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 INCLUDE_CPPGC_INTERNAL_ATOMIC_ENTRY_FLAG_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_ATOMIC_ENTRY_FLAG_H_
7
+
8
+ #include <atomic>
9
+
10
+ namespace cppgc {
11
+ namespace internal {
12
+
13
+ // A flag which provides a fast check whether a scope may be entered on the
14
+ // current thread, without needing to access thread-local storage or mutex. Can
15
+ // have false positives (i.e., spuriously report that it might be entered), so
16
+ // it is expected that this will be used in tandem with a precise check that the
17
+ // scope is in fact entered on that thread.
18
+ //
19
+ // Example:
20
+ // g_frobnicating_flag.MightBeEntered() &&
21
+ // ThreadLocalFrobnicator().IsFrobnicating()
22
+ //
23
+ // Relaxed atomic operations are sufficient, since:
24
+ // - all accesses remain atomic
25
+ // - each thread must observe its own operations in order
26
+ // - no thread ever exits the flag more times than it enters (if used correctly)
27
+ // And so if a thread observes zero, it must be because it has observed an equal
28
+ // number of exits as entries.
29
+ class AtomicEntryFlag final {
30
+ public:
31
+ void Enter() { entries_.fetch_add(1, std::memory_order_relaxed); }
32
+ void Exit() { entries_.fetch_sub(1, std::memory_order_relaxed); }
33
+
34
+ // Returns false only if the current thread is not between a call to Enter
35
+ // and a call to Exit. Returns true if this thread or another thread may
36
+ // currently be in the scope guarded by this flag.
37
+ bool MightBeEntered() const {
38
+ return entries_.load(std::memory_order_relaxed) != 0;
39
+ }
40
+
41
+ private:
42
+ std::atomic_int entries_{0};
43
+ };
44
+
45
+ } // namespace internal
46
+ } // namespace cppgc
47
+
48
+ #endif // INCLUDE_CPPGC_INTERNAL_ATOMIC_ENTRY_FLAG_H_
@@ -0,0 +1,45 @@
1
+ // Copyright 2022 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 INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
7
+
8
+ #include "cppgc/heap-handle.h"
9
+ #include "cppgc/internal/api-constants.h"
10
+ #include "cppgc/internal/logging.h"
11
+ #include "v8config.h" // NOLINT(build/include_directory)
12
+
13
+ namespace cppgc {
14
+ namespace internal {
15
+
16
+ // The class is needed in the header to allow for fast access to HeapHandle in
17
+ // the write barrier.
18
+ class BasePageHandle {
19
+ public:
20
+ static V8_INLINE BasePageHandle* FromPayload(void* payload) {
21
+ return reinterpret_cast<BasePageHandle*>(
22
+ (reinterpret_cast<uintptr_t>(payload) &
23
+ ~(api_constants::kPageSize - 1)) +
24
+ api_constants::kGuardPageSize);
25
+ }
26
+ static V8_INLINE const BasePageHandle* FromPayload(const void* payload) {
27
+ return FromPayload(const_cast<void*>(payload));
28
+ }
29
+
30
+ HeapHandle& heap_handle() { return heap_handle_; }
31
+ const HeapHandle& heap_handle() const { return heap_handle_; }
32
+
33
+ protected:
34
+ explicit BasePageHandle(HeapHandle& heap_handle) : heap_handle_(heap_handle) {
35
+ CPPGC_DCHECK(reinterpret_cast<uintptr_t>(this) % api_constants::kPageSize ==
36
+ api_constants::kGuardPageSize);
37
+ }
38
+
39
+ HeapHandle& heap_handle_;
40
+ };
41
+
42
+ } // namespace internal
43
+ } // namespace cppgc
44
+
45
+ #endif // INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
@@ -0,0 +1,111 @@
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 INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
7
+
8
+ #include <array>
9
+ #include <cstddef>
10
+ #include <cstdint>
11
+
12
+ #include "cppgc/internal/api-constants.h"
13
+ #include "cppgc/internal/caged-heap.h"
14
+ #include "cppgc/internal/logging.h"
15
+ #include "cppgc/platform.h"
16
+ #include "v8config.h" // NOLINT(build/include_directory)
17
+
18
+ #if __cpp_lib_bitopts
19
+ #include <bit>
20
+ #endif // __cpp_lib_bitopts
21
+
22
+ #if defined(CPPGC_CAGED_HEAP)
23
+
24
+ namespace cppgc {
25
+ namespace internal {
26
+
27
+ class HeapBase;
28
+ class HeapBaseHandle;
29
+
30
+ #if defined(CPPGC_YOUNG_GENERATION)
31
+
32
+ // AgeTable is the bytemap needed for the fast generation check in the write
33
+ // barrier. AgeTable contains entries that correspond to 4096 bytes memory
34
+ // regions (cards). Each entry in the table represents generation of the objects
35
+ // that reside on the corresponding card (young, old or mixed).
36
+ class V8_EXPORT AgeTable final {
37
+ static constexpr size_t kRequiredSize = 1 * api_constants::kMB;
38
+ static constexpr size_t kAllocationGranularity =
39
+ api_constants::kAllocationGranularity;
40
+
41
+ public:
42
+ // Represents age of the objects living on a single card.
43
+ enum class Age : uint8_t { kOld, kYoung, kMixed };
44
+ // When setting age for a range, consider or ignore ages of the adjacent
45
+ // cards.
46
+ enum class AdjacentCardsPolicy : uint8_t { kConsider, kIgnore };
47
+
48
+ static constexpr size_t kCardSizeInBytes =
49
+ api_constants::kCagedHeapReservationSize / kRequiredSize;
50
+
51
+ void SetAge(uintptr_t cage_offset, Age age) {
52
+ table_[card(cage_offset)] = age;
53
+ }
54
+
55
+ V8_INLINE Age GetAge(uintptr_t cage_offset) const {
56
+ return table_[card(cage_offset)];
57
+ }
58
+
59
+ void SetAgeForRange(uintptr_t cage_offset_begin, uintptr_t cage_offset_end,
60
+ Age age, AdjacentCardsPolicy adjacent_cards_policy);
61
+
62
+ Age GetAgeForRange(uintptr_t cage_offset_begin,
63
+ uintptr_t cage_offset_end) const;
64
+
65
+ void ResetForTesting();
66
+
67
+ private:
68
+ V8_INLINE size_t card(uintptr_t offset) const {
69
+ constexpr size_t kGranularityBits =
70
+ #if __cpp_lib_bitopts
71
+ std::countr_zero(static_cast<uint32_t>(kCardSizeInBytes));
72
+ #elif V8_HAS_BUILTIN_CTZ
73
+ __builtin_ctz(static_cast<uint32_t>(kCardSizeInBytes));
74
+ #else //! V8_HAS_BUILTIN_CTZ
75
+ // Hardcode and check with assert.
76
+ #if defined(CPPGC_2GB_CAGE)
77
+ 11;
78
+ #else // !defined(CPPGC_2GB_CAGE)
79
+ 12;
80
+ #endif // !defined(CPPGC_2GB_CAGE)
81
+ #endif // !V8_HAS_BUILTIN_CTZ
82
+ static_assert((1 << kGranularityBits) == kCardSizeInBytes);
83
+ const size_t entry = offset >> kGranularityBits;
84
+ CPPGC_DCHECK(table_.size() > entry);
85
+ return entry;
86
+ }
87
+
88
+ std::array<Age, kRequiredSize> table_;
89
+ };
90
+
91
+ static_assert(sizeof(AgeTable) == 1 * api_constants::kMB,
92
+ "Size of AgeTable is 1MB");
93
+
94
+ #endif // CPPGC_YOUNG_GENERATION
95
+
96
+ struct CagedHeapLocalData final {
97
+ V8_INLINE static CagedHeapLocalData& Get() {
98
+ return *reinterpret_cast<CagedHeapLocalData*>(CagedHeapBase::GetBase());
99
+ }
100
+
101
+ #if defined(CPPGC_YOUNG_GENERATION)
102
+ AgeTable age_table;
103
+ #endif
104
+ };
105
+
106
+ } // namespace internal
107
+ } // namespace cppgc
108
+
109
+ #endif // defined(CPPGC_CAGED_HEAP)
110
+
111
+ #endif // INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
@@ -0,0 +1,61 @@
1
+ // Copyright 2022 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 INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_H_
7
+
8
+ #include <climits>
9
+ #include <cstddef>
10
+
11
+ #include "cppgc/internal/api-constants.h"
12
+ #include "cppgc/internal/base-page-handle.h"
13
+ #include "v8config.h" // NOLINT(build/include_directory)
14
+
15
+ #if defined(CPPGC_CAGED_HEAP)
16
+
17
+ namespace cppgc {
18
+ namespace internal {
19
+
20
+ class V8_EXPORT CagedHeapBase {
21
+ public:
22
+ V8_INLINE static uintptr_t OffsetFromAddress(const void* address) {
23
+ return reinterpret_cast<uintptr_t>(address) &
24
+ (api_constants::kCagedHeapReservationAlignment - 1);
25
+ }
26
+
27
+ V8_INLINE static bool IsWithinCage(const void* address) {
28
+ CPPGC_DCHECK(g_heap_base_);
29
+ return (reinterpret_cast<uintptr_t>(address) &
30
+ ~(api_constants::kCagedHeapReservationAlignment - 1)) ==
31
+ g_heap_base_;
32
+ }
33
+
34
+ V8_INLINE static bool AreWithinCage(const void* addr1, const void* addr2) {
35
+ #if defined(CPPGC_2GB_CAGE)
36
+ static constexpr size_t kHalfWordShift = sizeof(uint32_t) * CHAR_BIT - 1;
37
+ #else //! defined(CPPGC_2GB_CAGE)
38
+ static constexpr size_t kHalfWordShift = sizeof(uint32_t) * CHAR_BIT;
39
+ #endif //! defined(CPPGC_2GB_CAGE)
40
+ static_assert((static_cast<size_t>(1) << kHalfWordShift) ==
41
+ api_constants::kCagedHeapReservationSize);
42
+ CPPGC_DCHECK(g_heap_base_);
43
+ return !(((reinterpret_cast<uintptr_t>(addr1) ^ g_heap_base_) |
44
+ (reinterpret_cast<uintptr_t>(addr2) ^ g_heap_base_)) >>
45
+ kHalfWordShift);
46
+ }
47
+
48
+ V8_INLINE static uintptr_t GetBase() { return g_heap_base_; }
49
+
50
+ private:
51
+ friend class CagedHeap;
52
+
53
+ static uintptr_t g_heap_base_;
54
+ };
55
+
56
+ } // namespace internal
57
+ } // namespace cppgc
58
+
59
+ #endif // defined(CPPGC_CAGED_HEAP)
60
+
61
+ #endif // INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_H_
@@ -0,0 +1,38 @@
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 INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_
7
+
8
+ namespace cppgc {
9
+
10
+ #if defined(__has_attribute)
11
+ #define CPPGC_HAS_ATTRIBUTE(FEATURE) __has_attribute(FEATURE)
12
+ #else
13
+ #define CPPGC_HAS_ATTRIBUTE(FEATURE) 0
14
+ #endif
15
+
16
+ #if defined(__has_cpp_attribute)
17
+ #define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) __has_cpp_attribute(FEATURE)
18
+ #else
19
+ #define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) 0
20
+ #endif
21
+
22
+ // [[no_unique_address]] comes in C++20 but supported in clang with -std >=
23
+ // c++11.
24
+ #if CPPGC_HAS_CPP_ATTRIBUTE(no_unique_address)
25
+ #define CPPGC_NO_UNIQUE_ADDRESS [[no_unique_address]]
26
+ #else
27
+ #define CPPGC_NO_UNIQUE_ADDRESS
28
+ #endif
29
+
30
+ #if CPPGC_HAS_ATTRIBUTE(unused)
31
+ #define CPPGC_UNUSED __attribute__((unused))
32
+ #else
33
+ #define CPPGC_UNUSED
34
+ #endif
35
+
36
+ } // namespace cppgc
37
+
38
+ #endif // INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_