@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,100 @@
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 subtle {
19
+
20
+ template <typename T>
21
+ void FreeUnreferencedObject(HeapHandle& heap_handle, T& object);
22
+ template <typename T>
23
+ bool Resize(T& object, AdditionalBytes additional_bytes);
24
+
25
+ } // namespace subtle
26
+
27
+ namespace internal {
28
+
29
+ class ExplicitManagementImpl final {
30
+ private:
31
+ V8_EXPORT static void FreeUnreferencedObject(HeapHandle&, void*);
32
+ V8_EXPORT static bool Resize(void*, size_t);
33
+
34
+ template <typename T>
35
+ friend void subtle::FreeUnreferencedObject(HeapHandle&, T&);
36
+ template <typename T>
37
+ friend bool subtle::Resize(T&, AdditionalBytes);
38
+ };
39
+ } // namespace internal
40
+
41
+ namespace subtle {
42
+
43
+ /**
44
+ * Informs the garbage collector that `object` can be immediately reclaimed. The
45
+ * destructor may not be invoked immediately but only on next garbage
46
+ * collection.
47
+ *
48
+ * It is up to the embedder to guarantee that no other object holds a reference
49
+ * to `object` after calling `FreeUnreferencedObject()`. In case such a
50
+ * reference exists, it's use results in a use-after-free.
51
+ *
52
+ * To aid in using the API, `FreeUnreferencedObject()` may be called from
53
+ * destructors on objects that would be reclaimed in the same garbage collection
54
+ * cycle.
55
+ *
56
+ * \param heap_handle The corresponding heap.
57
+ * \param object Reference to an object that is of type `GarbageCollected` and
58
+ * should be immediately reclaimed.
59
+ */
60
+ template <typename T>
61
+ void FreeUnreferencedObject(HeapHandle& heap_handle, T& object) {
62
+ static_assert(IsGarbageCollectedTypeV<T>,
63
+ "Object must be of type GarbageCollected.");
64
+ internal::ExplicitManagementImpl::FreeUnreferencedObject(heap_handle,
65
+ &object);
66
+ }
67
+
68
+ /**
69
+ * Tries to resize `object` of type `T` with additional bytes on top of
70
+ * sizeof(T). Resizing is only useful with trailing inlined storage, see e.g.
71
+ * `MakeGarbageCollected(AllocationHandle&, AdditionalBytes)`.
72
+ *
73
+ * `Resize()` performs growing or shrinking as needed and may skip the operation
74
+ * for internal reasons, see return value.
75
+ *
76
+ * It is up to the embedder to guarantee that in case of shrinking a larger
77
+ * object down, the reclaimed area is not used anymore. Any subsequent use
78
+ * results in a use-after-free.
79
+ *
80
+ * The `object` must be live when calling `Resize()`.
81
+ *
82
+ * \param object Reference to an object that is of type `GarbageCollected` and
83
+ * should be resized.
84
+ * \param additional_bytes Bytes in addition to sizeof(T) that the object should
85
+ * provide.
86
+ * \returns true when the operation was successful and the result can be relied
87
+ * on, and false otherwise.
88
+ */
89
+ template <typename T>
90
+ bool Resize(T& object, AdditionalBytes additional_bytes) {
91
+ static_assert(IsGarbageCollectedTypeV<T>,
92
+ "Object must be of type GarbageCollected.");
93
+ return internal::ExplicitManagementImpl::Resize(
94
+ &object, sizeof(T) + additional_bytes.value);
95
+ }
96
+
97
+ } // namespace subtle
98
+ } // namespace cppgc
99
+
100
+ #endif // INCLUDE_CPPGC_EXPLICIT_MANAGEMENT_H_
@@ -0,0 +1,106 @@
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_GARBAGE_COLLECTED_H_
6
+ #define INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
7
+
8
+ #include "cppgc/internal/api-constants.h"
9
+ #include "cppgc/platform.h"
10
+ #include "cppgc/trace-trait.h"
11
+ #include "cppgc/type-traits.h"
12
+
13
+ namespace cppgc {
14
+
15
+ class Visitor;
16
+
17
+ /**
18
+ * Base class for managed objects. Only descendent types of `GarbageCollected`
19
+ * can be constructed using `MakeGarbageCollected()`. Must be inherited from as
20
+ * left-most base class.
21
+ *
22
+ * Types inheriting from GarbageCollected must provide a method of
23
+ * signature `void Trace(cppgc::Visitor*) const` that dispatchs all managed
24
+ * pointers to the visitor and delegates to garbage-collected base classes.
25
+ * The method must be virtual if the type is not directly a child of
26
+ * GarbageCollected and marked as final.
27
+ *
28
+ * \code
29
+ * // Example using final class.
30
+ * class FinalType final : public GarbageCollected<FinalType> {
31
+ * public:
32
+ * void Trace(cppgc::Visitor* visitor) const {
33
+ * // Dispatch using visitor->Trace(...);
34
+ * }
35
+ * };
36
+ *
37
+ * // Example using non-final base class.
38
+ * class NonFinalBase : public GarbageCollected<NonFinalBase> {
39
+ * public:
40
+ * virtual void Trace(cppgc::Visitor*) const {}
41
+ * };
42
+ *
43
+ * class FinalChild final : public NonFinalBase {
44
+ * public:
45
+ * void Trace(cppgc::Visitor* visitor) const final {
46
+ * // Dispatch using visitor->Trace(...);
47
+ * NonFinalBase::Trace(visitor);
48
+ * }
49
+ * };
50
+ * \endcode
51
+ */
52
+ template <typename T>
53
+ class GarbageCollected {
54
+ public:
55
+ using IsGarbageCollectedTypeMarker = void;
56
+ using ParentMostGarbageCollectedType = T;
57
+
58
+ // Must use MakeGarbageCollected.
59
+ void* operator new(size_t) = delete;
60
+ void* operator new[](size_t) = delete;
61
+ // The garbage collector is taking care of reclaiming the object. Also,
62
+ // virtual destructor requires an unambiguous, accessible 'operator delete'.
63
+ void operator delete(void*) {
64
+ #ifdef V8_ENABLE_CHECKS
65
+ internal::Fatal(
66
+ "Manually deleting a garbage collected object is not allowed");
67
+ #endif // V8_ENABLE_CHECKS
68
+ }
69
+ void operator delete[](void*) = delete;
70
+
71
+ protected:
72
+ GarbageCollected() = default;
73
+ };
74
+
75
+ /**
76
+ * Base class for managed mixin objects. Such objects cannot be constructed
77
+ * directly but must be mixed into the inheritance hierarchy of a
78
+ * GarbageCollected object.
79
+ *
80
+ * Types inheriting from GarbageCollectedMixin must override a virtual method
81
+ * of signature `void Trace(cppgc::Visitor*) const` that dispatchs all managed
82
+ * pointers to the visitor and delegates to base classes.
83
+ *
84
+ * \code
85
+ * class Mixin : public GarbageCollectedMixin {
86
+ * public:
87
+ * void Trace(cppgc::Visitor* visitor) const override {
88
+ * // Dispatch using visitor->Trace(...);
89
+ * }
90
+ * };
91
+ * \endcode
92
+ */
93
+ class GarbageCollectedMixin {
94
+ public:
95
+ using IsGarbageCollectedMixinTypeMarker = void;
96
+
97
+ /**
98
+ * This Trace method must be overriden by objects inheriting from
99
+ * GarbageCollectedMixin.
100
+ */
101
+ virtual void Trace(cppgc::Visitor*) const {}
102
+ };
103
+
104
+ } // namespace cppgc
105
+
106
+ #endif // INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
@@ -0,0 +1,309 @@
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/member.h"
13
+ #include "cppgc/trace-trait.h"
14
+ #include "v8config.h" // NOLINT(build/include_directory)
15
+
16
+ namespace cppgc {
17
+
18
+ class HeapHandle;
19
+
20
+ namespace subtle {
21
+
22
+ /**
23
+ * **DO NOT USE: Use the appropriate managed types.**
24
+ *
25
+ * Consistency helpers that aid in maintaining a consistent internal state of
26
+ * the garbage collector.
27
+ */
28
+ class HeapConsistency final {
29
+ public:
30
+ using WriteBarrierParams = internal::WriteBarrier::Params;
31
+ using WriteBarrierType = internal::WriteBarrier::Type;
32
+
33
+ /**
34
+ * Gets the required write barrier type for a specific write.
35
+ *
36
+ * \param slot Slot containing the pointer to the object. The slot itself
37
+ * must reside in an object that has been allocated using
38
+ * `MakeGarbageCollected()`.
39
+ * \param value The pointer to the object. May be an interior pointer to an
40
+ * interface of the actual object.
41
+ * \param params Parameters that may be used for actual write barrier calls.
42
+ * Only filled if return value indicates that a write barrier is needed. The
43
+ * contents of the `params` are an implementation detail.
44
+ * \returns whether a write barrier is needed and which barrier to invoke.
45
+ */
46
+ static V8_INLINE WriteBarrierType GetWriteBarrierType(
47
+ const void* slot, const void* value, WriteBarrierParams& params) {
48
+ return internal::WriteBarrier::GetWriteBarrierType(slot, value, params);
49
+ }
50
+
51
+ /**
52
+ * Gets the required write barrier type for a specific write. This override is
53
+ * only used for all the BasicMember types.
54
+ *
55
+ * \param slot Slot containing the pointer to the object. The slot itself
56
+ * must reside in an object that has been allocated using
57
+ * `MakeGarbageCollected()`.
58
+ * \param value The pointer to the object held via `BasicMember`.
59
+ * \param params Parameters that may be used for actual write barrier calls.
60
+ * Only filled if return value indicates that a write barrier is needed. The
61
+ * contents of the `params` are an implementation detail.
62
+ * \returns whether a write barrier is needed and which barrier to invoke.
63
+ */
64
+ template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
65
+ typename CheckingPolicy>
66
+ static V8_INLINE WriteBarrierType GetWriteBarrierType(
67
+ const internal::BasicMember<T, WeaknessTag, WriteBarrierPolicy,
68
+ CheckingPolicy>& value,
69
+ WriteBarrierParams& params) {
70
+ return internal::WriteBarrier::GetWriteBarrierType(
71
+ value.GetRawSlot(), value.GetRawStorage(), params);
72
+ }
73
+
74
+ /**
75
+ * Gets the required write barrier type for a specific write.
76
+ *
77
+ * \param slot Slot to some part of an object. The object must not necessarily
78
+ have been allocated using `MakeGarbageCollected()` but can also live
79
+ off-heap or on stack.
80
+ * \param params Parameters that may be used for actual write barrier calls.
81
+ * Only filled if return value indicates that a write barrier is needed. The
82
+ * contents of the `params` are an implementation detail.
83
+ * \param callback Callback returning the corresponding heap handle. The
84
+ * callback is only invoked if the heap cannot otherwise be figured out. The
85
+ * callback must not allocate.
86
+ * \returns whether a write barrier is needed and which barrier to invoke.
87
+ */
88
+ template <typename HeapHandleCallback>
89
+ static V8_INLINE WriteBarrierType
90
+ GetWriteBarrierType(const void* slot, WriteBarrierParams& params,
91
+ HeapHandleCallback callback) {
92
+ return internal::WriteBarrier::GetWriteBarrierType(slot, params, callback);
93
+ }
94
+
95
+ /**
96
+ * Gets the required write barrier type for a specific write.
97
+ * This version is meant to be used in conjunction with with a marking write
98
+ * barrier barrier which doesn't consider the slot.
99
+ *
100
+ * \param value The pointer to the object. May be an interior pointer to an
101
+ * interface of the actual object.
102
+ * \param params Parameters that may be used for actual write barrier calls.
103
+ * Only filled if return value indicates that a write barrier is needed. The
104
+ * contents of the `params` are an implementation detail.
105
+ * \returns whether a write barrier is needed and which barrier to invoke.
106
+ */
107
+ static V8_INLINE WriteBarrierType
108
+ GetWriteBarrierType(const void* value, WriteBarrierParams& params) {
109
+ return internal::WriteBarrier::GetWriteBarrierType(value, params);
110
+ }
111
+
112
+ /**
113
+ * Conservative Dijkstra-style write barrier that processes an object if it
114
+ * has not yet been processed.
115
+ *
116
+ * \param params The parameters retrieved from `GetWriteBarrierType()`.
117
+ * \param object The pointer to the object. May be an interior pointer to a
118
+ * an interface of the actual object.
119
+ */
120
+ static V8_INLINE void DijkstraWriteBarrier(const WriteBarrierParams& params,
121
+ const void* object) {
122
+ internal::WriteBarrier::DijkstraMarkingBarrier(params, object);
123
+ }
124
+
125
+ /**
126
+ * Conservative Dijkstra-style write barrier that processes a range of
127
+ * elements if they have not yet been processed.
128
+ *
129
+ * \param params The parameters retrieved from `GetWriteBarrierType()`.
130
+ * \param first_element Pointer to the first element that should be processed.
131
+ * The slot itself must reside in an object that has been allocated using
132
+ * `MakeGarbageCollected()`.
133
+ * \param element_size Size of the element in bytes.
134
+ * \param number_of_elements Number of elements that should be processed,
135
+ * starting with `first_element`.
136
+ * \param trace_callback The trace callback that should be invoked for each
137
+ * element if necessary.
138
+ */
139
+ static V8_INLINE void DijkstraWriteBarrierRange(
140
+ const WriteBarrierParams& params, const void* first_element,
141
+ size_t element_size, size_t number_of_elements,
142
+ TraceCallback trace_callback) {
143
+ internal::WriteBarrier::DijkstraMarkingBarrierRange(
144
+ params, first_element, element_size, number_of_elements,
145
+ trace_callback);
146
+ }
147
+
148
+ /**
149
+ * Steele-style write barrier that re-processes an object if it has already
150
+ * been processed.
151
+ *
152
+ * \param params The parameters retrieved from `GetWriteBarrierType()`.
153
+ * \param object The pointer to the object which must point to an object that
154
+ * has been allocated using `MakeGarbageCollected()`. Interior pointers are
155
+ * not supported.
156
+ */
157
+ static V8_INLINE void SteeleWriteBarrier(const WriteBarrierParams& params,
158
+ const void* object) {
159
+ internal::WriteBarrier::SteeleMarkingBarrier(params, object);
160
+ }
161
+
162
+ /**
163
+ * Generational barrier for maintaining consistency when running with multiple
164
+ * generations.
165
+ *
166
+ * \param params The parameters retrieved from `GetWriteBarrierType()`.
167
+ * \param slot Slot containing the pointer to the object. The slot itself
168
+ * must reside in an object that has been allocated using
169
+ * `MakeGarbageCollected()`.
170
+ */
171
+ static V8_INLINE void GenerationalBarrier(const WriteBarrierParams& params,
172
+ const void* slot) {
173
+ internal::WriteBarrier::GenerationalBarrier<
174
+ internal::WriteBarrier::GenerationalBarrierType::kPreciseSlot>(params,
175
+ slot);
176
+ }
177
+
178
+ /**
179
+ * Generational barrier for maintaining consistency when running with multiple
180
+ * generations. This version is used when slot contains uncompressed pointer.
181
+ *
182
+ * \param params The parameters retrieved from `GetWriteBarrierType()`.
183
+ * \param slot Uncompressed slot containing the direct pointer to the object.
184
+ * The slot itself must reside in an object that has been allocated using
185
+ * `MakeGarbageCollected()`.
186
+ */
187
+ static V8_INLINE void GenerationalBarrierForUncompressedSlot(
188
+ const WriteBarrierParams& params, const void* uncompressed_slot) {
189
+ internal::WriteBarrier::GenerationalBarrier<
190
+ internal::WriteBarrier::GenerationalBarrierType::
191
+ kPreciseUncompressedSlot>(params, uncompressed_slot);
192
+ }
193
+
194
+ /**
195
+ * Generational barrier for source object that may contain outgoing pointers
196
+ * to objects in young generation.
197
+ *
198
+ * \param params The parameters retrieved from `GetWriteBarrierType()`.
199
+ * \param inner_pointer Pointer to the source object.
200
+ */
201
+ static V8_INLINE void GenerationalBarrierForSourceObject(
202
+ const WriteBarrierParams& params, const void* inner_pointer) {
203
+ internal::WriteBarrier::GenerationalBarrier<
204
+ internal::WriteBarrier::GenerationalBarrierType::kImpreciseSlot>(
205
+ params, inner_pointer);
206
+ }
207
+
208
+ private:
209
+ HeapConsistency() = delete;
210
+ };
211
+
212
+ /**
213
+ * Disallows garbage collection finalizations. Any garbage collection triggers
214
+ * result in a crash when in this scope.
215
+ *
216
+ * Note that the garbage collector already covers paths that can lead to garbage
217
+ * collections, so user code does not require checking
218
+ * `IsGarbageCollectionAllowed()` before allocations.
219
+ */
220
+ class V8_EXPORT V8_NODISCARD DisallowGarbageCollectionScope final {
221
+ CPPGC_STACK_ALLOCATED();
222
+
223
+ public:
224
+ /**
225
+ * \returns whether garbage collections are currently allowed.
226
+ */
227
+ static bool IsGarbageCollectionAllowed(HeapHandle& heap_handle);
228
+
229
+ /**
230
+ * Enters a disallow garbage collection scope. Must be paired with `Leave()`.
231
+ * Prefer a scope instance of `DisallowGarbageCollectionScope`.
232
+ *
233
+ * \param heap_handle The corresponding heap.
234
+ */
235
+ static void Enter(HeapHandle& heap_handle);
236
+
237
+ /**
238
+ * Leaves a disallow garbage collection scope. Must be paired with `Enter()`.
239
+ * Prefer a scope instance of `DisallowGarbageCollectionScope`.
240
+ *
241
+ * \param heap_handle The corresponding heap.
242
+ */
243
+ static void Leave(HeapHandle& heap_handle);
244
+
245
+ /**
246
+ * Constructs a scoped object that automatically enters and leaves a disallow
247
+ * garbage collection scope based on its lifetime.
248
+ *
249
+ * \param heap_handle The corresponding heap.
250
+ */
251
+ explicit DisallowGarbageCollectionScope(HeapHandle& heap_handle);
252
+ ~DisallowGarbageCollectionScope();
253
+
254
+ DisallowGarbageCollectionScope(const DisallowGarbageCollectionScope&) =
255
+ delete;
256
+ DisallowGarbageCollectionScope& operator=(
257
+ const DisallowGarbageCollectionScope&) = delete;
258
+
259
+ private:
260
+ HeapHandle& heap_handle_;
261
+ };
262
+
263
+ /**
264
+ * Avoids invoking garbage collection finalizations. Already running garbage
265
+ * collection phase are unaffected by this scope.
266
+ *
267
+ * Should only be used temporarily as the scope has an impact on memory usage
268
+ * and follow up garbage collections.
269
+ */
270
+ class V8_EXPORT V8_NODISCARD NoGarbageCollectionScope final {
271
+ CPPGC_STACK_ALLOCATED();
272
+
273
+ public:
274
+ /**
275
+ * Enters a no garbage collection scope. Must be paired with `Leave()`. Prefer
276
+ * a scope instance of `NoGarbageCollectionScope`.
277
+ *
278
+ * \param heap_handle The corresponding heap.
279
+ */
280
+ static void Enter(HeapHandle& heap_handle);
281
+
282
+ /**
283
+ * Leaves a no garbage collection scope. Must be paired with `Enter()`. Prefer
284
+ * a scope instance of `NoGarbageCollectionScope`.
285
+ *
286
+ * \param heap_handle The corresponding heap.
287
+ */
288
+ static void Leave(HeapHandle& heap_handle);
289
+
290
+ /**
291
+ * Constructs a scoped object that automatically enters and leaves a no
292
+ * garbage collection scope based on its lifetime.
293
+ *
294
+ * \param heap_handle The corresponding heap.
295
+ */
296
+ explicit NoGarbageCollectionScope(HeapHandle& heap_handle);
297
+ ~NoGarbageCollectionScope();
298
+
299
+ NoGarbageCollectionScope(const NoGarbageCollectionScope&) = delete;
300
+ NoGarbageCollectionScope& operator=(const NoGarbageCollectionScope&) = delete;
301
+
302
+ private:
303
+ HeapHandle& heap_handle_;
304
+ };
305
+
306
+ } // namespace subtle
307
+ } // namespace cppgc
308
+
309
+ #endif // INCLUDE_CPPGC_HEAP_CONSISTENCY_H_
@@ -0,0 +1,48 @@
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_HEAP_HANDLE_H_
6
+ #define INCLUDE_CPPGC_HEAP_HANDLE_H_
7
+
8
+ #include "v8config.h" // NOLINT(build/include_directory)
9
+
10
+ namespace cppgc {
11
+
12
+ namespace internal {
13
+ class HeapBase;
14
+ class WriteBarrierTypeForCagedHeapPolicy;
15
+ class WriteBarrierTypeForNonCagedHeapPolicy;
16
+ } // namespace internal
17
+
18
+ /**
19
+ * Opaque handle used for additional heap APIs.
20
+ */
21
+ class HeapHandle {
22
+ public:
23
+ // Deleted copy ctor to avoid treating the type by value.
24
+ HeapHandle(const HeapHandle&) = delete;
25
+ HeapHandle& operator=(const HeapHandle&) = delete;
26
+
27
+ private:
28
+ HeapHandle() = default;
29
+
30
+ V8_INLINE bool is_incremental_marking_in_progress() const {
31
+ return is_incremental_marking_in_progress_;
32
+ }
33
+
34
+ V8_INLINE bool is_young_generation_enabled() const {
35
+ return is_young_generation_enabled_;
36
+ }
37
+
38
+ bool is_incremental_marking_in_progress_ = false;
39
+ bool is_young_generation_enabled_ = false;
40
+
41
+ friend class internal::HeapBase;
42
+ friend class internal::WriteBarrierTypeForCagedHeapPolicy;
43
+ friend class internal::WriteBarrierTypeForNonCagedHeapPolicy;
44
+ };
45
+
46
+ } // namespace cppgc
47
+
48
+ #endif // INCLUDE_CPPGC_HEAP_HANDLE_H_
@@ -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_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 currently sweeping on the thread
43
+ * owning this heap. This API allows the caller to determine whether it has
44
+ * been called from a destructor of a managed object. This API is experimental
45
+ * and may be removed in future.
46
+ *
47
+ * \param heap_handle The corresponding heap.
48
+ * \returns true if the garbage collector is currently sweeping on this
49
+ * thread, and false otherwise.
50
+ */
51
+ static bool IsSweepingOnOwningThread(const HeapHandle& heap_handle);
52
+
53
+ /**
54
+ * Returns whether the garbage collector is in the atomic pause, i.e., the
55
+ * mutator is stopped from running. This API is experimental and is expected
56
+ * to be removed in future.
57
+ *
58
+ * \param heap_handle The corresponding heap.
59
+ * \returns true if the garbage collector is currently in the atomic pause,
60
+ * and false otherwise.
61
+ */
62
+ static bool IsInAtomicPause(const HeapHandle& heap_handle);
63
+
64
+ /**
65
+ * Returns whether the last garbage collection was finalized conservatively
66
+ * (i.e., with a non-empty stack). This API is experimental and is expected to
67
+ * be removed in future.
68
+ *
69
+ * \param heap_handle The corresponding heap.
70
+ * \returns true if the last garbage collection was finalized conservatively,
71
+ * and false otherwise.
72
+ */
73
+ static bool PreviousGCWasConservative(const HeapHandle& heap_handle);
74
+
75
+ private:
76
+ HeapState() = delete;
77
+ };
78
+
79
+ } // namespace subtle
80
+ } // namespace cppgc
81
+
82
+ #endif // INCLUDE_CPPGC_HEAP_STATE_H_