libv8-node 15.14.0.1-aarch64-linux → 17.9.1.0-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8-node/location.rb +1 -1
  3. data/ext/libv8-node/paths.rb +5 -1
  4. data/lib/libv8/node/version.rb +3 -3
  5. data/vendor/v8/{out.gn → aarch64-linux}/libv8/obj/libv8_monolith.a +0 -0
  6. data/vendor/v8/include/cppgc/allocation.h +110 -44
  7. data/vendor/v8/include/cppgc/common.h +9 -6
  8. data/vendor/v8/include/cppgc/cross-thread-persistent.h +465 -0
  9. data/vendor/v8/include/cppgc/custom-space.h +37 -2
  10. data/vendor/v8/include/cppgc/default-platform.h +47 -48
  11. data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
  12. data/vendor/v8/include/cppgc/explicit-management.h +82 -0
  13. data/vendor/v8/include/cppgc/garbage-collected.h +4 -3
  14. data/vendor/v8/include/cppgc/heap-consistency.h +253 -0
  15. data/vendor/v8/include/cppgc/heap-state.h +70 -0
  16. data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
  17. data/vendor/v8/include/cppgc/heap.h +68 -6
  18. data/vendor/v8/include/cppgc/internal/api-constants.h +3 -3
  19. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +4 -3
  20. data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
  21. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +2 -0
  22. data/vendor/v8/include/cppgc/internal/gc-info.h +124 -13
  23. data/vendor/v8/include/cppgc/internal/name-trait.h +122 -0
  24. data/vendor/v8/include/cppgc/internal/persistent-node.h +94 -6
  25. data/vendor/v8/include/cppgc/internal/pointer-policies.h +81 -29
  26. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +1 -1
  27. data/vendor/v8/include/cppgc/internal/write-barrier.h +398 -35
  28. data/vendor/v8/include/cppgc/liveness-broker.h +11 -2
  29. data/vendor/v8/include/cppgc/macros.h +2 -0
  30. data/vendor/v8/include/cppgc/member.h +87 -25
  31. data/vendor/v8/include/cppgc/name-provider.h +65 -0
  32. data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
  33. data/vendor/v8/include/cppgc/persistent.h +41 -11
  34. data/vendor/v8/include/cppgc/platform.h +49 -25
  35. data/vendor/v8/include/cppgc/prefinalizer.h +2 -2
  36. data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
  37. data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
  38. data/vendor/v8/include/cppgc/source-location.h +2 -1
  39. data/vendor/v8/include/cppgc/testing.h +99 -0
  40. data/vendor/v8/include/cppgc/trace-trait.h +8 -3
  41. data/vendor/v8/include/cppgc/type-traits.h +157 -19
  42. data/vendor/v8/include/cppgc/visitor.h +194 -28
  43. data/vendor/v8/include/libplatform/libplatform.h +11 -0
  44. data/vendor/v8/include/libplatform/v8-tracing.h +2 -0
  45. data/vendor/v8/include/v8-array-buffer.h +433 -0
  46. data/vendor/v8/include/v8-callbacks.h +377 -0
  47. data/vendor/v8/include/v8-container.h +129 -0
  48. data/vendor/v8/include/v8-context.h +418 -0
  49. data/vendor/v8/include/v8-cppgc.h +261 -159
  50. data/vendor/v8/include/v8-data.h +65 -0
  51. data/vendor/v8/include/v8-date.h +43 -0
  52. data/vendor/v8/include/v8-debug.h +151 -0
  53. data/vendor/v8/include/v8-embedder-heap.h +238 -0
  54. data/vendor/v8/include/v8-exception.h +224 -0
  55. data/vendor/v8/include/v8-extension.h +62 -0
  56. data/vendor/v8/include/v8-external.h +37 -0
  57. data/vendor/v8/include/v8-fast-api-calls.h +652 -152
  58. data/vendor/v8/include/v8-forward.h +81 -0
  59. data/vendor/v8/include/v8-function-callback.h +475 -0
  60. data/vendor/v8/include/v8-function.h +122 -0
  61. data/vendor/v8/include/v8-initialization.h +282 -0
  62. data/vendor/v8/include/v8-inspector.h +33 -25
  63. data/vendor/v8/include/v8-internal.h +178 -31
  64. data/vendor/v8/include/v8-isolate.h +1662 -0
  65. data/vendor/v8/include/v8-json.h +47 -0
  66. data/vendor/v8/include/v8-local-handle.h +459 -0
  67. data/vendor/v8/include/v8-locker.h +148 -0
  68. data/vendor/v8/include/v8-maybe.h +137 -0
  69. data/vendor/v8/include/v8-memory-span.h +43 -0
  70. data/vendor/v8/include/v8-message.h +241 -0
  71. data/vendor/v8/include/v8-metrics.h +114 -9
  72. data/vendor/v8/include/v8-microtask-queue.h +152 -0
  73. data/vendor/v8/include/v8-microtask.h +28 -0
  74. data/vendor/v8/include/v8-object.h +770 -0
  75. data/vendor/v8/include/v8-persistent-handle.h +590 -0
  76. data/vendor/v8/include/v8-platform.h +74 -25
  77. data/vendor/v8/include/v8-primitive-object.h +118 -0
  78. data/vendor/v8/include/v8-primitive.h +858 -0
  79. data/vendor/v8/include/v8-profiler.h +72 -9
  80. data/vendor/v8/include/v8-promise.h +174 -0
  81. data/vendor/v8/include/v8-proxy.h +50 -0
  82. data/vendor/v8/include/v8-regexp.h +105 -0
  83. data/vendor/v8/include/v8-script.h +771 -0
  84. data/vendor/v8/include/v8-snapshot.h +198 -0
  85. data/vendor/v8/include/v8-statistics.h +215 -0
  86. data/vendor/v8/include/v8-template.h +1052 -0
  87. data/vendor/v8/include/v8-traced-handle.h +605 -0
  88. data/vendor/v8/include/v8-typed-array.h +282 -0
  89. data/vendor/v8/include/v8-unwinder-state.h +31 -0
  90. data/vendor/v8/include/v8-unwinder.h +129 -0
  91. data/vendor/v8/include/v8-util.h +8 -2
  92. data/vendor/v8/include/v8-value-serializer.h +249 -0
  93. data/vendor/v8/include/v8-value.h +526 -0
  94. data/vendor/v8/include/v8-version.h +3 -3
  95. data/vendor/v8/include/v8-wasm.h +245 -0
  96. data/vendor/v8/include/v8-weak-callback-info.h +73 -0
  97. data/vendor/v8/include/v8.h +41 -12050
  98. data/vendor/v8/include/v8config.h +87 -11
  99. metadata +60 -6
  100. data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -0,0 +1,82 @@
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_EXPLICIT_MANAGEMENT_H_
6
+ #define INCLUDE_CPPGC_EXPLICIT_MANAGEMENT_H_
7
+
8
+ #include <cstddef>
9
+
10
+ #include "cppgc/allocation.h"
11
+ #include "cppgc/internal/logging.h"
12
+ #include "cppgc/type-traits.h"
13
+
14
+ namespace cppgc {
15
+
16
+ class HeapHandle;
17
+
18
+ namespace internal {
19
+
20
+ V8_EXPORT void FreeUnreferencedObject(HeapHandle&, void*);
21
+ V8_EXPORT bool Resize(void*, size_t);
22
+
23
+ } // namespace internal
24
+
25
+ namespace subtle {
26
+
27
+ /**
28
+ * Informs the garbage collector that `object` can be immediately reclaimed. The
29
+ * destructor may not be invoked immediately but only on next garbage
30
+ * collection.
31
+ *
32
+ * It is up to the embedder to guarantee that no other object holds a reference
33
+ * to `object` after calling `FreeUnreferencedObject()`. In case such a
34
+ * reference exists, it's use results in a use-after-free.
35
+ *
36
+ * To aid in using the API, `FreeUnreferencedObject()` may be called from
37
+ * destructors on objects that would be reclaimed in the same garbage collection
38
+ * cycle.
39
+ *
40
+ * \param heap_handle The corresponding heap.
41
+ * \param object Reference to an object that is of type `GarbageCollected` and
42
+ * should be immediately reclaimed.
43
+ */
44
+ template <typename T>
45
+ void FreeUnreferencedObject(HeapHandle& heap_handle, T& object) {
46
+ static_assert(IsGarbageCollectedTypeV<T>,
47
+ "Object must be of type GarbageCollected.");
48
+ internal::FreeUnreferencedObject(heap_handle, &object);
49
+ }
50
+
51
+ /**
52
+ * Tries to resize `object` of type `T` with additional bytes on top of
53
+ * sizeof(T). Resizing is only useful with trailing inlined storage, see e.g.
54
+ * `MakeGarbageCollected(AllocationHandle&, AdditionalBytes)`.
55
+ *
56
+ * `Resize()` performs growing or shrinking as needed and may skip the operation
57
+ * for internal reasons, see return value.
58
+ *
59
+ * It is up to the embedder to guarantee that in case of shrinking a larger
60
+ * object down, the reclaimed area is not used anymore. Any subsequent use
61
+ * results in a use-after-free.
62
+ *
63
+ * The `object` must be live when calling `Resize()`.
64
+ *
65
+ * \param object Reference to an object that is of type `GarbageCollected` and
66
+ * should be resized.
67
+ * \param additional_bytes Bytes in addition to sizeof(T) that the object should
68
+ * provide.
69
+ * \returns true when the operation was successful and the result can be relied
70
+ * on, and false otherwise.
71
+ */
72
+ template <typename T>
73
+ bool Resize(T& object, AdditionalBytes additional_bytes) {
74
+ static_assert(IsGarbageCollectedTypeV<T>,
75
+ "Object must be of type GarbageCollected.");
76
+ return internal::Resize(&object, sizeof(T) + additional_bytes.value);
77
+ }
78
+
79
+ } // namespace subtle
80
+ } // namespace cppgc
81
+
82
+ #endif // INCLUDE_CPPGC_EXPLICIT_MANAGEMENT_H_
@@ -39,8 +39,8 @@ class GarbageCollectedBase {
39
39
  } // namespace internal
40
40
 
41
41
  /**
42
- * Base class for managed objects. Only descendent types of GarbageCollected
43
- * can be constructed using MakeGarbageCollected. Must be inherited from as
42
+ * Base class for managed objects. Only descendent types of `GarbageCollected`
43
+ * can be constructed using `MakeGarbageCollected()`. Must be inherited from as
44
44
  * left-most base class.
45
45
  *
46
46
  * Types inheriting from GarbageCollected must provide a method of
@@ -73,10 +73,11 @@ class GarbageCollectedBase {
73
73
  * };
74
74
  * \endcode
75
75
  */
76
- template <typename>
76
+ template <typename T>
77
77
  class GarbageCollected : public internal::GarbageCollectedBase {
78
78
  public:
79
79
  using IsGarbageCollectedTypeMarker = void;
80
+ using ParentMostGarbageCollectedType = T;
80
81
 
81
82
  protected:
82
83
  GarbageCollected() = default;
@@ -0,0 +1,253 @@
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_CONSISTENCY_H_
6
+ #define INCLUDE_CPPGC_HEAP_CONSISTENCY_H_
7
+
8
+ #include <cstddef>
9
+
10
+ #include "cppgc/internal/write-barrier.h"
11
+ #include "cppgc/macros.h"
12
+ #include "cppgc/trace-trait.h"
13
+ #include "v8config.h" // NOLINT(build/include_directory)
14
+
15
+ namespace cppgc {
16
+
17
+ class HeapHandle;
18
+
19
+ namespace subtle {
20
+
21
+ /**
22
+ * **DO NOT USE: Use the appropriate managed types.**
23
+ *
24
+ * Consistency helpers that aid in maintaining a consistent internal state of
25
+ * the garbage collector.
26
+ */
27
+ class HeapConsistency final {
28
+ public:
29
+ using WriteBarrierParams = internal::WriteBarrier::Params;
30
+ using WriteBarrierType = internal::WriteBarrier::Type;
31
+
32
+ /**
33
+ * Gets the required write barrier type for a specific write.
34
+ *
35
+ * \param slot Slot containing the pointer to the object. The slot itself
36
+ * must reside in an object that has been allocated using
37
+ * `MakeGarbageCollected()`.
38
+ * \param value The pointer to the object. May be an interior pointer to an
39
+ * interface of the actual object.
40
+ * \param params Parameters that may be used for actual write barrier calls.
41
+ * Only filled if return value indicates that a write barrier is needed. The
42
+ * contents of the `params` are an implementation detail.
43
+ * \returns whether a write barrier is needed and which barrier to invoke.
44
+ */
45
+ static V8_INLINE WriteBarrierType GetWriteBarrierType(
46
+ const void* slot, const void* value, WriteBarrierParams& params) {
47
+ return internal::WriteBarrier::GetWriteBarrierType(slot, value, params);
48
+ }
49
+
50
+ /**
51
+ * Gets the required write barrier type for a specific write.
52
+ *
53
+ * \param slot Slot to some part of an object. The object must not necessarily
54
+ have been allocated using `MakeGarbageCollected()` but can also live
55
+ off-heap or on stack.
56
+ * \param params Parameters that may be used for actual write barrier calls.
57
+ * Only filled if return value indicates that a write barrier is needed. The
58
+ * contents of the `params` are an implementation detail.
59
+ * \param callback Callback returning the corresponding heap handle. The
60
+ * callback is only invoked if the heap cannot otherwise be figured out. The
61
+ * callback must not allocate.
62
+ * \returns whether a write barrier is needed and which barrier to invoke.
63
+ */
64
+ template <typename HeapHandleCallback>
65
+ static V8_INLINE WriteBarrierType
66
+ GetWriteBarrierType(const void* slot, WriteBarrierParams& params,
67
+ HeapHandleCallback callback) {
68
+ return internal::WriteBarrier::GetWriteBarrierType(slot, params, callback);
69
+ }
70
+
71
+ /**
72
+ * Gets the required write barrier type for a specific write.
73
+ * This version is meant to be used in conjunction with with a marking write
74
+ * barrier barrier which doesn't consider the slot.
75
+ *
76
+ * \param value The pointer to the object. May be an interior pointer to an
77
+ * interface of the actual object.
78
+ * \param params Parameters that may be used for actual write barrier calls.
79
+ * Only filled if return value indicates that a write barrier is needed. The
80
+ * contents of the `params` are an implementation detail.
81
+ * \returns whether a write barrier is needed and which barrier to invoke.
82
+ */
83
+ static V8_INLINE WriteBarrierType
84
+ GetWriteBarrierType(const void* value, WriteBarrierParams& params) {
85
+ return internal::WriteBarrier::GetWriteBarrierType(value, params);
86
+ }
87
+
88
+ /**
89
+ * Conservative Dijkstra-style write barrier that processes an object if it
90
+ * has not yet been processed.
91
+ *
92
+ * \param params The parameters retrieved from `GetWriteBarrierType()`.
93
+ * \param object The pointer to the object. May be an interior pointer to a
94
+ * an interface of the actual object.
95
+ */
96
+ static V8_INLINE void DijkstraWriteBarrier(const WriteBarrierParams& params,
97
+ const void* object) {
98
+ internal::WriteBarrier::DijkstraMarkingBarrier(params, object);
99
+ }
100
+
101
+ /**
102
+ * Conservative Dijkstra-style write barrier that processes a range of
103
+ * elements if they have not yet been processed.
104
+ *
105
+ * \param params The parameters retrieved from `GetWriteBarrierType()`.
106
+ * \param first_element Pointer to the first element that should be processed.
107
+ * The slot itself must reside in an object that has been allocated using
108
+ * `MakeGarbageCollected()`.
109
+ * \param element_size Size of the element in bytes.
110
+ * \param number_of_elements Number of elements that should be processed,
111
+ * starting with `first_element`.
112
+ * \param trace_callback The trace callback that should be invoked for each
113
+ * element if necessary.
114
+ */
115
+ static V8_INLINE void DijkstraWriteBarrierRange(
116
+ const WriteBarrierParams& params, const void* first_element,
117
+ size_t element_size, size_t number_of_elements,
118
+ TraceCallback trace_callback) {
119
+ internal::WriteBarrier::DijkstraMarkingBarrierRange(
120
+ params, first_element, element_size, number_of_elements,
121
+ trace_callback);
122
+ }
123
+
124
+ /**
125
+ * Steele-style write barrier that re-processes an object if it has already
126
+ * been processed.
127
+ *
128
+ * \param params The parameters retrieved from `GetWriteBarrierType()`.
129
+ * \param object The pointer to the object which must point to an object that
130
+ * has been allocated using `MakeGarbageCollected()`. Interior pointers are
131
+ * not supported.
132
+ */
133
+ static V8_INLINE void SteeleWriteBarrier(const WriteBarrierParams& params,
134
+ const void* object) {
135
+ internal::WriteBarrier::SteeleMarkingBarrier(params, object);
136
+ }
137
+
138
+ /**
139
+ * Generational barrier for maintaining consistency when running with multiple
140
+ * generations.
141
+ *
142
+ * \param params The parameters retrieved from `GetWriteBarrierType()`.
143
+ * \param slot Slot containing the pointer to the object. The slot itself
144
+ * must reside in an object that has been allocated using
145
+ * `MakeGarbageCollected()`.
146
+ */
147
+ static V8_INLINE void GenerationalBarrier(const WriteBarrierParams& params,
148
+ const void* slot) {
149
+ internal::WriteBarrier::GenerationalBarrier(params, slot);
150
+ }
151
+
152
+ private:
153
+ HeapConsistency() = delete;
154
+ };
155
+
156
+ /**
157
+ * Disallows garbage collection finalizations. Any garbage collection triggers
158
+ * result in a crash when in this scope.
159
+ *
160
+ * Note that the garbage collector already covers paths that can lead to garbage
161
+ * collections, so user code does not require checking
162
+ * `IsGarbageCollectionAllowed()` before allocations.
163
+ */
164
+ class V8_EXPORT V8_NODISCARD DisallowGarbageCollectionScope final {
165
+ CPPGC_STACK_ALLOCATED();
166
+
167
+ public:
168
+ /**
169
+ * \returns whether garbage collections are currently allowed.
170
+ */
171
+ static bool IsGarbageCollectionAllowed(HeapHandle& heap_handle);
172
+
173
+ /**
174
+ * Enters a disallow garbage collection scope. Must be paired with `Leave()`.
175
+ * Prefer a scope instance of `DisallowGarbageCollectionScope`.
176
+ *
177
+ * \param heap_handle The corresponding heap.
178
+ */
179
+ static void Enter(HeapHandle& heap_handle);
180
+
181
+ /**
182
+ * Leaves a disallow garbage collection scope. Must be paired with `Enter()`.
183
+ * Prefer a scope instance of `DisallowGarbageCollectionScope`.
184
+ *
185
+ * \param heap_handle The corresponding heap.
186
+ */
187
+ static void Leave(HeapHandle& heap_handle);
188
+
189
+ /**
190
+ * Constructs a scoped object that automatically enters and leaves a disallow
191
+ * garbage collection scope based on its lifetime.
192
+ *
193
+ * \param heap_handle The corresponding heap.
194
+ */
195
+ explicit DisallowGarbageCollectionScope(HeapHandle& heap_handle);
196
+ ~DisallowGarbageCollectionScope();
197
+
198
+ DisallowGarbageCollectionScope(const DisallowGarbageCollectionScope&) =
199
+ delete;
200
+ DisallowGarbageCollectionScope& operator=(
201
+ const DisallowGarbageCollectionScope&) = delete;
202
+
203
+ private:
204
+ HeapHandle& heap_handle_;
205
+ };
206
+
207
+ /**
208
+ * Avoids invoking garbage collection finalizations. Already running garbage
209
+ * collection phase are unaffected by this scope.
210
+ *
211
+ * Should only be used temporarily as the scope has an impact on memory usage
212
+ * and follow up garbage collections.
213
+ */
214
+ class V8_EXPORT V8_NODISCARD NoGarbageCollectionScope final {
215
+ CPPGC_STACK_ALLOCATED();
216
+
217
+ public:
218
+ /**
219
+ * Enters a no garbage collection scope. Must be paired with `Leave()`. Prefer
220
+ * a scope instance of `NoGarbageCollectionScope`.
221
+ *
222
+ * \param heap_handle The corresponding heap.
223
+ */
224
+ static void Enter(HeapHandle& heap_handle);
225
+
226
+ /**
227
+ * Leaves a no garbage collection scope. Must be paired with `Enter()`. Prefer
228
+ * a scope instance of `NoGarbageCollectionScope`.
229
+ *
230
+ * \param heap_handle The corresponding heap.
231
+ */
232
+ static void Leave(HeapHandle& heap_handle);
233
+
234
+ /**
235
+ * Constructs a scoped object that automatically enters and leaves a no
236
+ * garbage collection scope based on its lifetime.
237
+ *
238
+ * \param heap_handle The corresponding heap.
239
+ */
240
+ explicit NoGarbageCollectionScope(HeapHandle& heap_handle);
241
+ ~NoGarbageCollectionScope();
242
+
243
+ NoGarbageCollectionScope(const NoGarbageCollectionScope&) = delete;
244
+ NoGarbageCollectionScope& operator=(const NoGarbageCollectionScope&) = delete;
245
+
246
+ private:
247
+ HeapHandle& heap_handle_;
248
+ };
249
+
250
+ } // namespace subtle
251
+ } // namespace cppgc
252
+
253
+ #endif // INCLUDE_CPPGC_HEAP_CONSISTENCY_H_
@@ -0,0 +1,70 @@
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_STATE_H_
6
+ #define INCLUDE_CPPGC_HEAP_STATE_H_
7
+
8
+ #include "v8config.h" // NOLINT(build/include_directory)
9
+
10
+ namespace cppgc {
11
+
12
+ class HeapHandle;
13
+
14
+ namespace subtle {
15
+
16
+ /**
17
+ * Helpers to peek into heap-internal state.
18
+ */
19
+ class V8_EXPORT HeapState final {
20
+ public:
21
+ /**
22
+ * Returns whether the garbage collector is marking. This API is experimental
23
+ * and is expected to be removed in future.
24
+ *
25
+ * \param heap_handle The corresponding heap.
26
+ * \returns true if the garbage collector is currently marking, and false
27
+ * otherwise.
28
+ */
29
+ static bool IsMarking(const HeapHandle& heap_handle);
30
+
31
+ /*
32
+ * Returns whether the garbage collector is sweeping. This API is experimental
33
+ * and is expected to be removed in future.
34
+ *
35
+ * \param heap_handle The corresponding heap.
36
+ * \returns true if the garbage collector is currently sweeping, and false
37
+ * otherwise.
38
+ */
39
+ static bool IsSweeping(const HeapHandle& heap_handle);
40
+
41
+ /**
42
+ * Returns whether the garbage collector is in the atomic pause, i.e., the
43
+ * mutator is stopped from running. This API is experimental and is expected
44
+ * to be removed in future.
45
+ *
46
+ * \param heap_handle The corresponding heap.
47
+ * \returns true if the garbage collector is currently in the atomic pause,
48
+ * and false otherwise.
49
+ */
50
+ static bool IsInAtomicPause(const HeapHandle& heap_handle);
51
+
52
+ /**
53
+ * Returns whether the last garbage collection was finalized conservatively
54
+ * (i.e., with a non-empty stack). This API is experimental and is expected to
55
+ * be removed in future.
56
+ *
57
+ * \param heap_handle The corresponding heap.
58
+ * \returns true if the last garbage collection was finalized conservatively,
59
+ * and false otherwise.
60
+ */
61
+ static bool PreviousGCWasConservative(const HeapHandle& heap_handle);
62
+
63
+ private:
64
+ HeapState() = delete;
65
+ };
66
+
67
+ } // namespace subtle
68
+ } // namespace cppgc
69
+
70
+ #endif // INCLUDE_CPPGC_HEAP_STATE_H_
@@ -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::HideInternalNames() is false. */
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 help 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_
@@ -5,6 +5,8 @@
5
5
  #ifndef INCLUDE_CPPGC_HEAP_H_
6
6
  #define INCLUDE_CPPGC_HEAP_H_
7
7
 
8
+ #include <cstddef>
9
+ #include <cstdint>
8
10
  #include <memory>
9
11
  #include <vector>
10
12
 
@@ -29,6 +31,11 @@ namespace internal {
29
31
  class Heap;
30
32
  } // namespace internal
31
33
 
34
+ /**
35
+ * Used for additional heap APIs.
36
+ */
37
+ class HeapHandle;
38
+
32
39
  class V8_EXPORT Heap {
33
40
  public:
34
41
  /**
@@ -51,6 +58,41 @@ class V8_EXPORT Heap {
51
58
  kNoConservativeStackScan,
52
59
  };
53
60
 
61
+ /**
62
+ * Specifies supported marking types
63
+ */
64
+ enum class MarkingType : uint8_t {
65
+ /**
66
+ * Atomic stop-the-world marking. This option does not require any write
67
+ * barriers but is the most intrusive in terms of jank.
68
+ */
69
+ kAtomic,
70
+ /**
71
+ * Incremental marking, i.e. interleave marking is the rest of the
72
+ * application on the same thread.
73
+ */
74
+ kIncremental,
75
+ /**
76
+ * Incremental and concurrent marking.
77
+ */
78
+ kIncrementalAndConcurrent
79
+ };
80
+
81
+ /**
82
+ * Specifies supported sweeping types
83
+ */
84
+ enum class SweepingType : uint8_t {
85
+ /**
86
+ * Atomic stop-the-world sweeping. All of sweeping is performed at once.
87
+ */
88
+ kAtomic,
89
+ /**
90
+ * Incremental and concurrent sweeping. Sweeping is split and interleaved
91
+ * with the rest of the application.
92
+ */
93
+ kIncrementalAndConcurrent
94
+ };
95
+
54
96
  /**
55
97
  * Constraints for a Heap setup.
56
98
  */
@@ -66,33 +108,43 @@ class V8_EXPORT Heap {
66
108
 
67
109
  /**
68
110
  * Options specifying Heap properties (e.g. custom spaces) when initializing a
69
- * heap through Heap::Create().
111
+ * heap through `Heap::Create()`.
70
112
  */
71
113
  struct HeapOptions {
72
114
  /**
73
115
  * Creates reasonable defaults for instantiating a Heap.
74
116
  *
75
- * \returns the HeapOptions that can be passed to Heap::Create().
117
+ * \returns the HeapOptions that can be passed to `Heap::Create()`.
76
118
  */
77
119
  static HeapOptions Default() { return {}; }
78
120
 
79
121
  /**
80
122
  * Custom spaces added to heap are required to have indices forming a
81
- * numbered sequence starting at 0, i.e., their kSpaceIndex must correspond
82
- * to the index they reside in the vector.
123
+ * numbered sequence starting at 0, i.e., their `kSpaceIndex` must
124
+ * correspond to the index they reside in the vector.
83
125
  */
84
126
  std::vector<std::unique_ptr<CustomSpaceBase>> custom_spaces;
85
127
 
86
128
  /**
87
- * Specifies whether conserative stack scan is supported. When conservative
129
+ * Specifies whether conservative stack scan is supported. When conservative
88
130
  * stack scan is not supported, the collector may try to invoke
89
131
  * garbage collections using non-nestable task, which are guaranteed to have
90
132
  * no interesting stack, through the provided Platform. If such tasks are
91
133
  * not supported by the Platform, the embedder must take care of invoking
92
- * the GC through ForceGarbageCollectionSlow().
134
+ * the GC through `ForceGarbageCollectionSlow()`.
93
135
  */
94
136
  StackSupport stack_support = StackSupport::kSupportsConservativeStackScan;
95
137
 
138
+ /**
139
+ * Specifies which types of marking are supported by the heap.
140
+ */
141
+ MarkingType marking_support = MarkingType::kIncrementalAndConcurrent;
142
+
143
+ /**
144
+ * Specifies which types of sweeping are supported by the heap.
145
+ */
146
+ SweepingType sweeping_support = SweepingType::kIncrementalAndConcurrent;
147
+
96
148
  /**
97
149
  * Resource constraints specifying various properties that the internal
98
150
  * GC scheduler follows.
@@ -126,8 +178,18 @@ class V8_EXPORT Heap {
126
178
  const char* source, const char* reason,
127
179
  StackState stack_state = StackState::kMayContainHeapPointers);
128
180
 
181
+ /**
182
+ * \returns the opaque handle for allocating objects using
183
+ * `MakeGarbageCollected()`.
184
+ */
129
185
  AllocationHandle& GetAllocationHandle();
130
186
 
187
+ /**
188
+ * \returns the opaque heap handle which may be used to refer to this heap in
189
+ * other APIs. Valid as long as the underlying `Heap` is alive.
190
+ */
191
+ HeapHandle& GetHeapHandle();
192
+
131
193
  private:
132
194
  Heap() = default;
133
195
 
@@ -5,8 +5,8 @@
5
5
  #ifndef INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
6
6
  #define INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
7
7
 
8
- #include <stddef.h>
9
- #include <stdint.h>
8
+ #include <cstddef>
9
+ #include <cstdint>
10
10
 
11
11
  #include "v8config.h" // NOLINT(build/include_directory)
12
12
 
@@ -28,7 +28,7 @@ constexpr size_t kGB = kMB * 1024;
28
28
  static constexpr size_t kFullyConstructedBitFieldOffsetFromPayload =
29
29
  2 * sizeof(uint16_t);
30
30
  // Mask for in-construction bit.
31
- static constexpr size_t kFullyConstructedBitMask = size_t{1};
31
+ static constexpr uint16_t kFullyConstructedBitMask = uint16_t{1};
32
32
 
33
33
  static constexpr size_t kPageSize = size_t{1} << 17;
34
34