@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.
- package/dist/include/APIDesign.md +72 -0
- package/dist/include/DEPS +10 -0
- package/dist/include/DIR_METADATA +11 -0
- package/dist/include/OWNERS +23 -0
- package/dist/include/cppgc/DEPS +8 -0
- package/dist/include/cppgc/OWNERS +2 -0
- package/dist/include/cppgc/README.md +135 -0
- package/dist/include/cppgc/allocation.h +310 -0
- package/dist/include/cppgc/common.h +28 -0
- package/dist/include/cppgc/cross-thread-persistent.h +464 -0
- package/dist/include/cppgc/custom-space.h +97 -0
- package/dist/include/cppgc/default-platform.h +67 -0
- package/dist/include/cppgc/ephemeron-pair.h +30 -0
- package/dist/include/cppgc/explicit-management.h +100 -0
- package/dist/include/cppgc/garbage-collected.h +106 -0
- package/dist/include/cppgc/heap-consistency.h +309 -0
- package/dist/include/cppgc/heap-handle.h +48 -0
- package/dist/include/cppgc/heap-state.h +82 -0
- package/dist/include/cppgc/heap-statistics.h +120 -0
- package/dist/include/cppgc/heap.h +202 -0
- package/dist/include/cppgc/internal/api-constants.h +65 -0
- package/dist/include/cppgc/internal/atomic-entry-flag.h +48 -0
- package/dist/include/cppgc/internal/base-page-handle.h +45 -0
- package/dist/include/cppgc/internal/caged-heap-local-data.h +111 -0
- package/dist/include/cppgc/internal/caged-heap.h +61 -0
- package/dist/include/cppgc/internal/compiler-specific.h +38 -0
- package/dist/include/cppgc/internal/finalizer-trait.h +93 -0
- package/dist/include/cppgc/internal/gc-info.h +155 -0
- package/dist/include/cppgc/internal/logging.h +50 -0
- package/dist/include/cppgc/internal/member-storage.h +236 -0
- package/dist/include/cppgc/internal/name-trait.h +137 -0
- package/dist/include/cppgc/internal/persistent-node.h +214 -0
- package/dist/include/cppgc/internal/pointer-policies.h +207 -0
- package/dist/include/cppgc/internal/write-barrier.h +477 -0
- package/dist/include/cppgc/liveness-broker.h +78 -0
- package/dist/include/cppgc/macros.h +26 -0
- package/dist/include/cppgc/member.h +566 -0
- package/dist/include/cppgc/name-provider.h +65 -0
- package/dist/include/cppgc/object-size-trait.h +58 -0
- package/dist/include/cppgc/persistent.h +366 -0
- package/dist/include/cppgc/platform.h +158 -0
- package/dist/include/cppgc/prefinalizer.h +75 -0
- package/dist/include/cppgc/process-heap-statistics.h +36 -0
- package/dist/include/cppgc/sentinel-pointer.h +32 -0
- package/dist/include/cppgc/source-location.h +92 -0
- package/dist/include/cppgc/testing.h +106 -0
- package/dist/include/cppgc/trace-trait.h +120 -0
- package/dist/include/cppgc/type-traits.h +249 -0
- package/dist/include/cppgc/visitor.h +411 -0
- package/dist/include/js_protocol-1.2.json +997 -0
- package/dist/include/js_protocol-1.3.json +1159 -0
- package/dist/include/js_protocol.pdl +1766 -0
- package/dist/include/libplatform/DEPS +9 -0
- package/dist/include/libplatform/libplatform-export.h +29 -0
- package/dist/include/libplatform/libplatform.h +106 -0
- package/dist/include/libplatform/v8-tracing.h +333 -0
- package/dist/include/v8-array-buffer.h +512 -0
- package/dist/include/v8-callbacks.h +412 -0
- package/dist/include/v8-container.h +129 -0
- package/dist/include/v8-context.h +415 -0
- package/dist/include/v8-cppgc.h +231 -0
- package/dist/include/v8-data.h +80 -0
- package/dist/include/v8-date.h +48 -0
- package/dist/include/v8-debug.h +168 -0
- package/dist/include/v8-embedder-heap.h +223 -0
- package/dist/include/v8-embedder-state-scope.h +51 -0
- package/dist/include/v8-exception.h +217 -0
- package/dist/include/v8-extension.h +62 -0
- package/dist/include/v8-external.h +37 -0
- package/dist/include/v8-fast-api-calls.h +957 -0
- package/dist/include/v8-forward.h +81 -0
- package/dist/include/v8-function-callback.h +475 -0
- package/dist/include/v8-function.h +133 -0
- package/dist/include/v8-initialization.h +289 -0
- package/dist/include/v8-inspector-protocol.h +13 -0
- package/dist/include/v8-inspector.h +397 -0
- package/dist/include/v8-internal.h +851 -0
- package/dist/include/v8-isolate.h +1695 -0
- package/dist/include/v8-json.h +47 -0
- package/dist/include/v8-local-handle.h +455 -0
- package/dist/include/v8-locker.h +138 -0
- package/dist/include/v8-maybe.h +160 -0
- package/dist/include/v8-memory-span.h +43 -0
- package/dist/include/v8-message.h +214 -0
- package/dist/include/v8-metrics.h +311 -0
- package/dist/include/v8-microtask-queue.h +157 -0
- package/dist/include/v8-microtask.h +28 -0
- package/dist/include/v8-object.h +768 -0
- package/dist/include/v8-persistent-handle.h +588 -0
- package/dist/include/v8-platform.h +1130 -0
- package/dist/include/v8-primitive-object.h +118 -0
- package/dist/include/v8-primitive.h +866 -0
- package/dist/include/v8-profiler.h +1277 -0
- package/dist/include/v8-promise.h +174 -0
- package/dist/include/v8-proxy.h +50 -0
- package/dist/include/v8-regexp.h +106 -0
- package/dist/include/v8-script.h +803 -0
- package/dist/include/v8-snapshot.h +196 -0
- package/dist/include/v8-statistics.h +217 -0
- package/dist/include/v8-template.h +1018 -0
- package/dist/include/v8-traced-handle.h +420 -0
- package/dist/include/v8-typed-array.h +282 -0
- package/dist/include/v8-unwinder-state.h +31 -0
- package/dist/include/v8-unwinder.h +132 -0
- package/dist/include/v8-util.h +656 -0
- package/dist/include/v8-value-serializer-version.h +24 -0
- package/dist/include/v8-value-serializer.h +302 -0
- package/dist/include/v8-value.h +531 -0
- package/dist/include/v8-version-string.h +38 -0
- package/dist/include/v8-version.h +20 -0
- package/dist/include/v8-wasm-trap-handler-posix.h +31 -0
- package/dist/include/v8-wasm-trap-handler-win.h +28 -0
- package/dist/include/v8-wasm.h +200 -0
- package/dist/include/v8-weak-callback-info.h +80 -0
- package/dist/include/v8.h +88 -0
- package/dist/include/v8config.h +904 -0
- package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.aar +0 -0
- package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.aar.md5 +1 -0
- package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.aar.sha1 +1 -0
- package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.pom +10 -0
- package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.pom.md5 +1 -0
- package/dist/org/chromium/v8-android/11.110.1/v8-android-11.110.1.pom.sha1 +1 -0
- package/dist/org/chromium/v8-android/maven-metadata.xml +12 -0
- package/dist/org/chromium/v8-android/maven-metadata.xml.md5 +1 -0
- package/dist/org/chromium/v8-android/maven-metadata.xml.sha1 +1 -0
- package/package.json +24 -0
|
@@ -0,0 +1,93 @@
|
|
|
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_FINALIZER_TRAIT_H_
|
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_
|
|
7
|
+
|
|
8
|
+
#include <type_traits>
|
|
9
|
+
|
|
10
|
+
#include "cppgc/type-traits.h"
|
|
11
|
+
|
|
12
|
+
namespace cppgc {
|
|
13
|
+
namespace internal {
|
|
14
|
+
|
|
15
|
+
using FinalizationCallback = void (*)(void*);
|
|
16
|
+
|
|
17
|
+
template <typename T, typename = void>
|
|
18
|
+
struct HasFinalizeGarbageCollectedObject : std::false_type {};
|
|
19
|
+
|
|
20
|
+
template <typename T>
|
|
21
|
+
struct HasFinalizeGarbageCollectedObject<
|
|
22
|
+
T,
|
|
23
|
+
std::void_t<decltype(std::declval<T>().FinalizeGarbageCollectedObject())>>
|
|
24
|
+
: std::true_type {};
|
|
25
|
+
|
|
26
|
+
// The FinalizerTraitImpl specifies how to finalize objects.
|
|
27
|
+
template <typename T, bool isFinalized>
|
|
28
|
+
struct FinalizerTraitImpl;
|
|
29
|
+
|
|
30
|
+
template <typename T>
|
|
31
|
+
struct FinalizerTraitImpl<T, true> {
|
|
32
|
+
private:
|
|
33
|
+
// Dispatch to custom FinalizeGarbageCollectedObject().
|
|
34
|
+
struct Custom {
|
|
35
|
+
static void Call(void* obj) {
|
|
36
|
+
static_cast<T*>(obj)->FinalizeGarbageCollectedObject();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Dispatch to regular destructor.
|
|
41
|
+
struct Destructor {
|
|
42
|
+
static void Call(void* obj) { static_cast<T*>(obj)->~T(); }
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
using FinalizeImpl =
|
|
46
|
+
std::conditional_t<HasFinalizeGarbageCollectedObject<T>::value, Custom,
|
|
47
|
+
Destructor>;
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
static void Finalize(void* obj) {
|
|
51
|
+
static_assert(sizeof(T), "T must be fully defined");
|
|
52
|
+
FinalizeImpl::Call(obj);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
template <typename T>
|
|
57
|
+
struct FinalizerTraitImpl<T, false> {
|
|
58
|
+
static void Finalize(void* obj) {
|
|
59
|
+
static_assert(sizeof(T), "T must be fully defined");
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// The FinalizerTrait is used to determine if a type requires finalization and
|
|
64
|
+
// what finalization means.
|
|
65
|
+
template <typename T>
|
|
66
|
+
struct FinalizerTrait {
|
|
67
|
+
private:
|
|
68
|
+
// Object has a finalizer if it has
|
|
69
|
+
// - a custom FinalizeGarbageCollectedObject method, or
|
|
70
|
+
// - a destructor.
|
|
71
|
+
static constexpr bool kNonTrivialFinalizer =
|
|
72
|
+
internal::HasFinalizeGarbageCollectedObject<T>::value ||
|
|
73
|
+
!std::is_trivially_destructible<typename std::remove_cv<T>::type>::value;
|
|
74
|
+
|
|
75
|
+
static void Finalize(void* obj) {
|
|
76
|
+
internal::FinalizerTraitImpl<T, kNonTrivialFinalizer>::Finalize(obj);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public:
|
|
80
|
+
static constexpr bool HasFinalizer() { return kNonTrivialFinalizer; }
|
|
81
|
+
|
|
82
|
+
// The callback used to finalize an object of type T.
|
|
83
|
+
static constexpr FinalizationCallback kCallback =
|
|
84
|
+
kNonTrivialFinalizer ? Finalize : nullptr;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
template <typename T>
|
|
88
|
+
constexpr FinalizationCallback FinalizerTrait<T>::kCallback;
|
|
89
|
+
|
|
90
|
+
} // namespace internal
|
|
91
|
+
} // namespace cppgc
|
|
92
|
+
|
|
93
|
+
#endif // INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_
|
|
@@ -0,0 +1,155 @@
|
|
|
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_GC_INFO_H_
|
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
|
|
7
|
+
|
|
8
|
+
#include <atomic>
|
|
9
|
+
#include <cstdint>
|
|
10
|
+
#include <type_traits>
|
|
11
|
+
|
|
12
|
+
#include "cppgc/internal/finalizer-trait.h"
|
|
13
|
+
#include "cppgc/internal/name-trait.h"
|
|
14
|
+
#include "cppgc/trace-trait.h"
|
|
15
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
16
|
+
|
|
17
|
+
namespace cppgc {
|
|
18
|
+
namespace internal {
|
|
19
|
+
|
|
20
|
+
using GCInfoIndex = uint16_t;
|
|
21
|
+
|
|
22
|
+
struct V8_EXPORT EnsureGCInfoIndexTrait final {
|
|
23
|
+
// Acquires a new GC info object and returns the index. In addition, also
|
|
24
|
+
// updates `registered_index` atomically.
|
|
25
|
+
template <typename T>
|
|
26
|
+
V8_INLINE static GCInfoIndex EnsureIndex(
|
|
27
|
+
std::atomic<GCInfoIndex>& registered_index) {
|
|
28
|
+
return EnsureGCInfoIndexTraitDispatch<T>{}(registered_index);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private:
|
|
32
|
+
template <typename T, bool = std::is_polymorphic<T>::value,
|
|
33
|
+
bool = FinalizerTrait<T>::HasFinalizer(),
|
|
34
|
+
bool = NameTrait<T>::HasNonHiddenName()>
|
|
35
|
+
struct EnsureGCInfoIndexTraitDispatch;
|
|
36
|
+
|
|
37
|
+
static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic<GCInfoIndex>&,
|
|
38
|
+
TraceCallback,
|
|
39
|
+
FinalizationCallback,
|
|
40
|
+
NameCallback);
|
|
41
|
+
static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic<GCInfoIndex>&,
|
|
42
|
+
TraceCallback,
|
|
43
|
+
FinalizationCallback);
|
|
44
|
+
static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic<GCInfoIndex>&,
|
|
45
|
+
TraceCallback, NameCallback);
|
|
46
|
+
static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic<GCInfoIndex>&,
|
|
47
|
+
TraceCallback);
|
|
48
|
+
static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
|
|
49
|
+
TraceCallback,
|
|
50
|
+
FinalizationCallback,
|
|
51
|
+
NameCallback);
|
|
52
|
+
static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
|
|
53
|
+
TraceCallback,
|
|
54
|
+
FinalizationCallback);
|
|
55
|
+
static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
|
|
56
|
+
TraceCallback,
|
|
57
|
+
NameCallback);
|
|
58
|
+
static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
|
|
59
|
+
TraceCallback);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
#define DISPATCH(is_polymorphic, has_finalizer, has_non_hidden_name, function) \
|
|
63
|
+
template <typename T> \
|
|
64
|
+
struct EnsureGCInfoIndexTrait::EnsureGCInfoIndexTraitDispatch< \
|
|
65
|
+
T, is_polymorphic, has_finalizer, has_non_hidden_name> { \
|
|
66
|
+
V8_INLINE GCInfoIndex \
|
|
67
|
+
operator()(std::atomic<GCInfoIndex>& registered_index) { \
|
|
68
|
+
return function; \
|
|
69
|
+
} \
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// --------------------------------------------------------------------- //
|
|
73
|
+
// DISPATCH(is_polymorphic, has_finalizer, has_non_hidden_name, function)
|
|
74
|
+
// --------------------------------------------------------------------- //
|
|
75
|
+
DISPATCH(true, true, true, //
|
|
76
|
+
EnsureGCInfoIndexPolymorphic(registered_index, //
|
|
77
|
+
TraceTrait<T>::Trace, //
|
|
78
|
+
FinalizerTrait<T>::kCallback, //
|
|
79
|
+
NameTrait<T>::GetName)) //
|
|
80
|
+
DISPATCH(true, true, false, //
|
|
81
|
+
EnsureGCInfoIndexPolymorphic(registered_index, //
|
|
82
|
+
TraceTrait<T>::Trace, //
|
|
83
|
+
FinalizerTrait<T>::kCallback)) //
|
|
84
|
+
DISPATCH(true, false, true, //
|
|
85
|
+
EnsureGCInfoIndexPolymorphic(registered_index, //
|
|
86
|
+
TraceTrait<T>::Trace, //
|
|
87
|
+
NameTrait<T>::GetName)) //
|
|
88
|
+
DISPATCH(true, false, false, //
|
|
89
|
+
EnsureGCInfoIndexPolymorphic(registered_index, //
|
|
90
|
+
TraceTrait<T>::Trace)) //
|
|
91
|
+
DISPATCH(false, true, true, //
|
|
92
|
+
EnsureGCInfoIndexNonPolymorphic(registered_index, //
|
|
93
|
+
TraceTrait<T>::Trace, //
|
|
94
|
+
FinalizerTrait<T>::kCallback, //
|
|
95
|
+
NameTrait<T>::GetName)) //
|
|
96
|
+
DISPATCH(false, true, false, //
|
|
97
|
+
EnsureGCInfoIndexNonPolymorphic(registered_index, //
|
|
98
|
+
TraceTrait<T>::Trace, //
|
|
99
|
+
FinalizerTrait<T>::kCallback)) //
|
|
100
|
+
DISPATCH(false, false, true, //
|
|
101
|
+
EnsureGCInfoIndexNonPolymorphic(registered_index, //
|
|
102
|
+
TraceTrait<T>::Trace, //
|
|
103
|
+
NameTrait<T>::GetName)) //
|
|
104
|
+
DISPATCH(false, false, false, //
|
|
105
|
+
EnsureGCInfoIndexNonPolymorphic(registered_index, //
|
|
106
|
+
TraceTrait<T>::Trace)) //
|
|
107
|
+
|
|
108
|
+
#undef DISPATCH
|
|
109
|
+
|
|
110
|
+
// Fold types based on finalizer behavior. Note that finalizer characteristics
|
|
111
|
+
// align with trace behavior, i.e., destructors are virtual when trace methods
|
|
112
|
+
// are and vice versa.
|
|
113
|
+
template <typename T, typename ParentMostGarbageCollectedType>
|
|
114
|
+
struct GCInfoFolding {
|
|
115
|
+
static constexpr bool kHasVirtualDestructorAtBase =
|
|
116
|
+
std::has_virtual_destructor<ParentMostGarbageCollectedType>::value;
|
|
117
|
+
static constexpr bool kBothTypesAreTriviallyDestructible =
|
|
118
|
+
std::is_trivially_destructible<ParentMostGarbageCollectedType>::value &&
|
|
119
|
+
std::is_trivially_destructible<T>::value;
|
|
120
|
+
static constexpr bool kHasCustomFinalizerDispatchAtBase =
|
|
121
|
+
internal::HasFinalizeGarbageCollectedObject<
|
|
122
|
+
ParentMostGarbageCollectedType>::value;
|
|
123
|
+
#ifdef CPPGC_SUPPORTS_OBJECT_NAMES
|
|
124
|
+
static constexpr bool kWantsDetailedObjectNames = true;
|
|
125
|
+
#else // !CPPGC_SUPPORTS_OBJECT_NAMES
|
|
126
|
+
static constexpr bool kWantsDetailedObjectNames = false;
|
|
127
|
+
#endif // !CPPGC_SUPPORTS_OBJECT_NAMES
|
|
128
|
+
|
|
129
|
+
// Folding would regresses name resolution when deriving names from C++
|
|
130
|
+
// class names as it would just folds a name to the base class name.
|
|
131
|
+
using ResultType = std::conditional_t<(kHasVirtualDestructorAtBase ||
|
|
132
|
+
kBothTypesAreTriviallyDestructible ||
|
|
133
|
+
kHasCustomFinalizerDispatchAtBase) &&
|
|
134
|
+
!kWantsDetailedObjectNames,
|
|
135
|
+
ParentMostGarbageCollectedType, T>;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
// Trait determines how the garbage collector treats objects wrt. to traversing,
|
|
139
|
+
// finalization, and naming.
|
|
140
|
+
template <typename T>
|
|
141
|
+
struct GCInfoTrait final {
|
|
142
|
+
V8_INLINE static GCInfoIndex Index() {
|
|
143
|
+
static_assert(sizeof(T), "T must be fully defined");
|
|
144
|
+
static std::atomic<GCInfoIndex>
|
|
145
|
+
registered_index; // Uses zero initialization.
|
|
146
|
+
const GCInfoIndex index = registered_index.load(std::memory_order_acquire);
|
|
147
|
+
return index ? index
|
|
148
|
+
: EnsureGCInfoIndexTrait::EnsureIndex<T>(registered_index);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
} // namespace internal
|
|
153
|
+
} // namespace cppgc
|
|
154
|
+
|
|
155
|
+
#endif // INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
|
|
@@ -0,0 +1,50 @@
|
|
|
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_LOGGING_H_
|
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_LOGGING_H_
|
|
7
|
+
|
|
8
|
+
#include "cppgc/source-location.h"
|
|
9
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
10
|
+
|
|
11
|
+
namespace cppgc {
|
|
12
|
+
namespace internal {
|
|
13
|
+
|
|
14
|
+
void V8_EXPORT DCheckImpl(const char*,
|
|
15
|
+
const SourceLocation& = SourceLocation::Current());
|
|
16
|
+
[[noreturn]] void V8_EXPORT
|
|
17
|
+
FatalImpl(const char*, const SourceLocation& = SourceLocation::Current());
|
|
18
|
+
|
|
19
|
+
// Used to ignore -Wunused-variable.
|
|
20
|
+
template <typename>
|
|
21
|
+
struct EatParams {};
|
|
22
|
+
|
|
23
|
+
#if defined(DEBUG)
|
|
24
|
+
#define CPPGC_DCHECK_MSG(condition, message) \
|
|
25
|
+
do { \
|
|
26
|
+
if (V8_UNLIKELY(!(condition))) { \
|
|
27
|
+
::cppgc::internal::DCheckImpl(message); \
|
|
28
|
+
} \
|
|
29
|
+
} while (false)
|
|
30
|
+
#else // !defined(DEBUG)
|
|
31
|
+
#define CPPGC_DCHECK_MSG(condition, message) \
|
|
32
|
+
(static_cast<void>(::cppgc::internal::EatParams<decltype( \
|
|
33
|
+
static_cast<void>(condition), message)>{}))
|
|
34
|
+
#endif // !defined(DEBUG)
|
|
35
|
+
|
|
36
|
+
#define CPPGC_DCHECK(condition) CPPGC_DCHECK_MSG(condition, #condition)
|
|
37
|
+
|
|
38
|
+
#define CPPGC_CHECK_MSG(condition, message) \
|
|
39
|
+
do { \
|
|
40
|
+
if (V8_UNLIKELY(!(condition))) { \
|
|
41
|
+
::cppgc::internal::FatalImpl(message); \
|
|
42
|
+
} \
|
|
43
|
+
} while (false)
|
|
44
|
+
|
|
45
|
+
#define CPPGC_CHECK(condition) CPPGC_CHECK_MSG(condition, #condition)
|
|
46
|
+
|
|
47
|
+
} // namespace internal
|
|
48
|
+
} // namespace cppgc
|
|
49
|
+
|
|
50
|
+
#endif // INCLUDE_CPPGC_INTERNAL_LOGGING_H_
|
|
@@ -0,0 +1,236 @@
|
|
|
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_MEMBER_STORAGE_H_
|
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_MEMBER_STORAGE_H_
|
|
7
|
+
|
|
8
|
+
#include <atomic>
|
|
9
|
+
#include <cstddef>
|
|
10
|
+
#include <type_traits>
|
|
11
|
+
|
|
12
|
+
#include "cppgc/internal/api-constants.h"
|
|
13
|
+
#include "cppgc/internal/logging.h"
|
|
14
|
+
#include "cppgc/sentinel-pointer.h"
|
|
15
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
16
|
+
|
|
17
|
+
namespace cppgc {
|
|
18
|
+
namespace internal {
|
|
19
|
+
|
|
20
|
+
#if defined(CPPGC_POINTER_COMPRESSION)
|
|
21
|
+
|
|
22
|
+
#if defined(__clang__)
|
|
23
|
+
// Attribute const allows the compiler to assume that CageBaseGlobal::g_base_
|
|
24
|
+
// doesn't change (e.g. across calls) and thereby avoid redundant loads.
|
|
25
|
+
#define CPPGC_CONST __attribute__((const))
|
|
26
|
+
#define CPPGC_REQUIRE_CONSTANT_INIT \
|
|
27
|
+
__attribute__((require_constant_initialization))
|
|
28
|
+
#else // defined(__clang__)
|
|
29
|
+
#define CPPGC_CONST
|
|
30
|
+
#define CPPGC_REQUIRE_CONSTANT_INIT
|
|
31
|
+
#endif // defined(__clang__)
|
|
32
|
+
|
|
33
|
+
class CageBaseGlobal final {
|
|
34
|
+
public:
|
|
35
|
+
V8_INLINE CPPGC_CONST static uintptr_t Get() {
|
|
36
|
+
CPPGC_DCHECK(IsBaseConsistent());
|
|
37
|
+
return g_base_;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
V8_INLINE CPPGC_CONST static bool IsSet() {
|
|
41
|
+
CPPGC_DCHECK(IsBaseConsistent());
|
|
42
|
+
return (g_base_ & ~kLowerHalfWordMask) != 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private:
|
|
46
|
+
// We keep the lower halfword as ones to speed up decompression.
|
|
47
|
+
static constexpr uintptr_t kLowerHalfWordMask =
|
|
48
|
+
(api_constants::kCagedHeapReservationAlignment - 1);
|
|
49
|
+
|
|
50
|
+
static V8_EXPORT uintptr_t g_base_ CPPGC_REQUIRE_CONSTANT_INIT;
|
|
51
|
+
|
|
52
|
+
CageBaseGlobal() = delete;
|
|
53
|
+
|
|
54
|
+
V8_INLINE static bool IsBaseConsistent() {
|
|
55
|
+
return kLowerHalfWordMask == (g_base_ & kLowerHalfWordMask);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
friend class CageBaseGlobalUpdater;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
#undef CPPGC_REQUIRE_CONSTANT_INIT
|
|
62
|
+
#undef CPPGC_CONST
|
|
63
|
+
|
|
64
|
+
class V8_TRIVIAL_ABI CompressedPointer final {
|
|
65
|
+
public:
|
|
66
|
+
using IntegralType = uint32_t;
|
|
67
|
+
|
|
68
|
+
V8_INLINE CompressedPointer() : value_(0u) {}
|
|
69
|
+
V8_INLINE explicit CompressedPointer(const void* ptr)
|
|
70
|
+
: value_(Compress(ptr)) {}
|
|
71
|
+
V8_INLINE explicit CompressedPointer(std::nullptr_t) : value_(0u) {}
|
|
72
|
+
V8_INLINE explicit CompressedPointer(SentinelPointer)
|
|
73
|
+
: value_(kCompressedSentinel) {}
|
|
74
|
+
|
|
75
|
+
V8_INLINE const void* Load() const { return Decompress(value_); }
|
|
76
|
+
V8_INLINE const void* LoadAtomic() const {
|
|
77
|
+
return Decompress(
|
|
78
|
+
reinterpret_cast<const std::atomic<IntegralType>&>(value_).load(
|
|
79
|
+
std::memory_order_relaxed));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
V8_INLINE void Store(const void* ptr) { value_ = Compress(ptr); }
|
|
83
|
+
V8_INLINE void StoreAtomic(const void* value) {
|
|
84
|
+
reinterpret_cast<std::atomic<IntegralType>&>(value_).store(
|
|
85
|
+
Compress(value), std::memory_order_relaxed);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
V8_INLINE void Clear() { value_ = 0u; }
|
|
89
|
+
V8_INLINE bool IsCleared() const { return !value_; }
|
|
90
|
+
|
|
91
|
+
V8_INLINE bool IsSentinel() const { return value_ == kCompressedSentinel; }
|
|
92
|
+
|
|
93
|
+
V8_INLINE uint32_t GetAsInteger() const { return value_; }
|
|
94
|
+
|
|
95
|
+
V8_INLINE friend bool operator==(CompressedPointer a, CompressedPointer b) {
|
|
96
|
+
return a.value_ == b.value_;
|
|
97
|
+
}
|
|
98
|
+
V8_INLINE friend bool operator!=(CompressedPointer a, CompressedPointer b) {
|
|
99
|
+
return a.value_ != b.value_;
|
|
100
|
+
}
|
|
101
|
+
V8_INLINE friend bool operator<(CompressedPointer a, CompressedPointer b) {
|
|
102
|
+
return a.value_ < b.value_;
|
|
103
|
+
}
|
|
104
|
+
V8_INLINE friend bool operator<=(CompressedPointer a, CompressedPointer b) {
|
|
105
|
+
return a.value_ <= b.value_;
|
|
106
|
+
}
|
|
107
|
+
V8_INLINE friend bool operator>(CompressedPointer a, CompressedPointer b) {
|
|
108
|
+
return a.value_ > b.value_;
|
|
109
|
+
}
|
|
110
|
+
V8_INLINE friend bool operator>=(CompressedPointer a, CompressedPointer b) {
|
|
111
|
+
return a.value_ >= b.value_;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
static V8_INLINE IntegralType Compress(const void* ptr) {
|
|
115
|
+
static_assert(
|
|
116
|
+
SentinelPointer::kSentinelValue == 0b10,
|
|
117
|
+
"The compression scheme relies on the sentinel encoded as 0b10");
|
|
118
|
+
static constexpr size_t kGigaCageMask =
|
|
119
|
+
~(api_constants::kCagedHeapReservationAlignment - 1);
|
|
120
|
+
|
|
121
|
+
CPPGC_DCHECK(CageBaseGlobal::IsSet());
|
|
122
|
+
const uintptr_t base = CageBaseGlobal::Get();
|
|
123
|
+
CPPGC_DCHECK(!ptr || ptr == kSentinelPointer ||
|
|
124
|
+
(base & kGigaCageMask) ==
|
|
125
|
+
(reinterpret_cast<uintptr_t>(ptr) & kGigaCageMask));
|
|
126
|
+
|
|
127
|
+
#if defined(CPPGC_2GB_CAGE)
|
|
128
|
+
// Truncate the pointer.
|
|
129
|
+
auto compressed =
|
|
130
|
+
static_cast<IntegralType>(reinterpret_cast<uintptr_t>(ptr));
|
|
131
|
+
#else // !defined(CPPGC_2GB_CAGE)
|
|
132
|
+
const auto uptr = reinterpret_cast<uintptr_t>(ptr);
|
|
133
|
+
// Shift the pointer by one and truncate.
|
|
134
|
+
auto compressed = static_cast<IntegralType>(uptr >> 1);
|
|
135
|
+
#endif // !defined(CPPGC_2GB_CAGE)
|
|
136
|
+
// Normal compressed pointers must have the MSB set.
|
|
137
|
+
CPPGC_DCHECK((!compressed || compressed == kCompressedSentinel) ||
|
|
138
|
+
(compressed & (1 << 31)));
|
|
139
|
+
return compressed;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
static V8_INLINE void* Decompress(IntegralType ptr) {
|
|
143
|
+
CPPGC_DCHECK(CageBaseGlobal::IsSet());
|
|
144
|
+
const uintptr_t base = CageBaseGlobal::Get();
|
|
145
|
+
// Treat compressed pointer as signed and cast it to uint64_t, which will
|
|
146
|
+
// sign-extend it.
|
|
147
|
+
#if defined(CPPGC_2GB_CAGE)
|
|
148
|
+
const uint64_t mask = static_cast<uint64_t>(static_cast<int32_t>(ptr));
|
|
149
|
+
#else // !defined(CPPGC_2GB_CAGE)
|
|
150
|
+
// Then, shift the result by one. It's important to shift the unsigned
|
|
151
|
+
// value, as otherwise it would result in undefined behavior.
|
|
152
|
+
const uint64_t mask = static_cast<uint64_t>(static_cast<int32_t>(ptr)) << 1;
|
|
153
|
+
#endif // !defined(CPPGC_2GB_CAGE)
|
|
154
|
+
return reinterpret_cast<void*>(mask & base);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private:
|
|
158
|
+
#if defined(CPPGC_2GB_CAGE)
|
|
159
|
+
static constexpr IntegralType kCompressedSentinel =
|
|
160
|
+
SentinelPointer::kSentinelValue;
|
|
161
|
+
#else // !defined(CPPGC_2GB_CAGE)
|
|
162
|
+
static constexpr IntegralType kCompressedSentinel =
|
|
163
|
+
SentinelPointer::kSentinelValue >> 1;
|
|
164
|
+
#endif // !defined(CPPGC_2GB_CAGE)
|
|
165
|
+
// All constructors initialize `value_`. Do not add a default value here as it
|
|
166
|
+
// results in a non-atomic write on some builds, even when the atomic version
|
|
167
|
+
// of the constructor is used.
|
|
168
|
+
IntegralType value_;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
#endif // defined(CPPGC_POINTER_COMPRESSION)
|
|
172
|
+
|
|
173
|
+
class V8_TRIVIAL_ABI RawPointer final {
|
|
174
|
+
public:
|
|
175
|
+
using IntegralType = uintptr_t;
|
|
176
|
+
|
|
177
|
+
V8_INLINE RawPointer() : ptr_(nullptr) {}
|
|
178
|
+
V8_INLINE explicit RawPointer(const void* ptr) : ptr_(ptr) {}
|
|
179
|
+
|
|
180
|
+
V8_INLINE const void* Load() const { return ptr_; }
|
|
181
|
+
V8_INLINE const void* LoadAtomic() const {
|
|
182
|
+
return reinterpret_cast<const std::atomic<const void*>&>(ptr_).load(
|
|
183
|
+
std::memory_order_relaxed);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
V8_INLINE void Store(const void* ptr) { ptr_ = ptr; }
|
|
187
|
+
V8_INLINE void StoreAtomic(const void* ptr) {
|
|
188
|
+
reinterpret_cast<std::atomic<const void*>&>(ptr_).store(
|
|
189
|
+
ptr, std::memory_order_relaxed);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
V8_INLINE void Clear() { ptr_ = nullptr; }
|
|
193
|
+
V8_INLINE bool IsCleared() const { return !ptr_; }
|
|
194
|
+
|
|
195
|
+
V8_INLINE bool IsSentinel() const { return ptr_ == kSentinelPointer; }
|
|
196
|
+
|
|
197
|
+
V8_INLINE uintptr_t GetAsInteger() const {
|
|
198
|
+
return reinterpret_cast<uintptr_t>(ptr_);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
V8_INLINE friend bool operator==(RawPointer a, RawPointer b) {
|
|
202
|
+
return a.ptr_ == b.ptr_;
|
|
203
|
+
}
|
|
204
|
+
V8_INLINE friend bool operator!=(RawPointer a, RawPointer b) {
|
|
205
|
+
return a.ptr_ != b.ptr_;
|
|
206
|
+
}
|
|
207
|
+
V8_INLINE friend bool operator<(RawPointer a, RawPointer b) {
|
|
208
|
+
return a.ptr_ < b.ptr_;
|
|
209
|
+
}
|
|
210
|
+
V8_INLINE friend bool operator<=(RawPointer a, RawPointer b) {
|
|
211
|
+
return a.ptr_ <= b.ptr_;
|
|
212
|
+
}
|
|
213
|
+
V8_INLINE friend bool operator>(RawPointer a, RawPointer b) {
|
|
214
|
+
return a.ptr_ > b.ptr_;
|
|
215
|
+
}
|
|
216
|
+
V8_INLINE friend bool operator>=(RawPointer a, RawPointer b) {
|
|
217
|
+
return a.ptr_ >= b.ptr_;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private:
|
|
221
|
+
// All constructors initialize `ptr_`. Do not add a default value here as it
|
|
222
|
+
// results in a non-atomic write on some builds, even when the atomic version
|
|
223
|
+
// of the constructor is used.
|
|
224
|
+
const void* ptr_;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
#if defined(CPPGC_POINTER_COMPRESSION)
|
|
228
|
+
using MemberStorage = CompressedPointer;
|
|
229
|
+
#else // !defined(CPPGC_POINTER_COMPRESSION)
|
|
230
|
+
using MemberStorage = RawPointer;
|
|
231
|
+
#endif // !defined(CPPGC_POINTER_COMPRESSION)
|
|
232
|
+
|
|
233
|
+
} // namespace internal
|
|
234
|
+
} // namespace cppgc
|
|
235
|
+
|
|
236
|
+
#endif // INCLUDE_CPPGC_INTERNAL_MEMBER_STORAGE_H_
|
|
@@ -0,0 +1,137 @@
|
|
|
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_NAME_TRAIT_H_
|
|
6
|
+
#define INCLUDE_CPPGC_INTERNAL_NAME_TRAIT_H_
|
|
7
|
+
|
|
8
|
+
#include <cstddef>
|
|
9
|
+
#include <cstdint>
|
|
10
|
+
#include <type_traits>
|
|
11
|
+
|
|
12
|
+
#include "cppgc/name-provider.h"
|
|
13
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
14
|
+
|
|
15
|
+
namespace cppgc {
|
|
16
|
+
namespace internal {
|
|
17
|
+
|
|
18
|
+
#if CPPGC_SUPPORTS_OBJECT_NAMES && defined(__clang__)
|
|
19
|
+
#define CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME 1
|
|
20
|
+
|
|
21
|
+
// Provides constexpr c-string storage for a name of fixed |Size| characters.
|
|
22
|
+
// Automatically appends terminating 0 byte.
|
|
23
|
+
template <size_t Size>
|
|
24
|
+
struct NameBuffer {
|
|
25
|
+
char name[Size + 1]{};
|
|
26
|
+
|
|
27
|
+
static constexpr NameBuffer FromCString(const char* str) {
|
|
28
|
+
NameBuffer result;
|
|
29
|
+
for (size_t i = 0; i < Size; ++i) result.name[i] = str[i];
|
|
30
|
+
result.name[Size] = 0;
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
template <typename T>
|
|
36
|
+
const char* GetTypename() {
|
|
37
|
+
static constexpr char kSelfPrefix[] =
|
|
38
|
+
"const char *cppgc::internal::GetTypename() [T =";
|
|
39
|
+
static_assert(__builtin_strncmp(__PRETTY_FUNCTION__, kSelfPrefix,
|
|
40
|
+
sizeof(kSelfPrefix) - 1) == 0,
|
|
41
|
+
"The prefix must match");
|
|
42
|
+
static constexpr const char* kTypenameStart =
|
|
43
|
+
__PRETTY_FUNCTION__ + sizeof(kSelfPrefix);
|
|
44
|
+
static constexpr size_t kTypenameSize =
|
|
45
|
+
__builtin_strlen(__PRETTY_FUNCTION__) - sizeof(kSelfPrefix) - 1;
|
|
46
|
+
// NameBuffer is an indirection that is needed to make sure that only a
|
|
47
|
+
// substring of __PRETTY_FUNCTION__ gets materialized in the binary.
|
|
48
|
+
static constexpr auto buffer =
|
|
49
|
+
NameBuffer<kTypenameSize>::FromCString(kTypenameStart);
|
|
50
|
+
return buffer.name;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#else
|
|
54
|
+
#define CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME 0
|
|
55
|
+
#endif
|
|
56
|
+
|
|
57
|
+
struct HeapObjectName {
|
|
58
|
+
const char* value;
|
|
59
|
+
bool name_was_hidden;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
enum class HeapObjectNameForUnnamedObject : uint8_t {
|
|
63
|
+
kUseClassNameIfSupported,
|
|
64
|
+
kUseHiddenName,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
class V8_EXPORT NameTraitBase {
|
|
68
|
+
protected:
|
|
69
|
+
static HeapObjectName GetNameFromTypeSignature(const char*);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// Trait that specifies how the garbage collector retrieves the name for a
|
|
73
|
+
// given object.
|
|
74
|
+
template <typename T>
|
|
75
|
+
class NameTrait final : public NameTraitBase {
|
|
76
|
+
public:
|
|
77
|
+
static constexpr bool HasNonHiddenName() {
|
|
78
|
+
#if CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
|
|
79
|
+
return true;
|
|
80
|
+
#elif CPPGC_SUPPORTS_OBJECT_NAMES
|
|
81
|
+
return true;
|
|
82
|
+
#else // !CPPGC_SUPPORTS_OBJECT_NAMES
|
|
83
|
+
return std::is_base_of<NameProvider, T>::value;
|
|
84
|
+
#endif // !CPPGC_SUPPORTS_OBJECT_NAMES
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static HeapObjectName GetName(
|
|
88
|
+
const void* obj, HeapObjectNameForUnnamedObject name_retrieval_mode) {
|
|
89
|
+
return GetNameFor(static_cast<const T*>(obj), name_retrieval_mode);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private:
|
|
93
|
+
static HeapObjectName GetNameFor(const NameProvider* name_provider,
|
|
94
|
+
HeapObjectNameForUnnamedObject) {
|
|
95
|
+
// Objects inheriting from `NameProvider` are not considered unnamed as
|
|
96
|
+
// users already provided a name for them.
|
|
97
|
+
return {name_provider->GetHumanReadableName(), false};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
static HeapObjectName GetNameFor(
|
|
101
|
+
const void*, HeapObjectNameForUnnamedObject name_retrieval_mode) {
|
|
102
|
+
if (name_retrieval_mode == HeapObjectNameForUnnamedObject::kUseHiddenName)
|
|
103
|
+
return {NameProvider::kHiddenName, true};
|
|
104
|
+
|
|
105
|
+
#if CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
|
|
106
|
+
return {GetTypename<T>(), false};
|
|
107
|
+
#elif CPPGC_SUPPORTS_OBJECT_NAMES
|
|
108
|
+
|
|
109
|
+
#if defined(V8_CC_GNU)
|
|
110
|
+
#define PRETTY_FUNCTION_VALUE __PRETTY_FUNCTION__
|
|
111
|
+
#elif defined(V8_CC_MSVC)
|
|
112
|
+
#define PRETTY_FUNCTION_VALUE __FUNCSIG__
|
|
113
|
+
#else
|
|
114
|
+
#define PRETTY_FUNCTION_VALUE nullptr
|
|
115
|
+
#endif
|
|
116
|
+
|
|
117
|
+
static const HeapObjectName leaky_name =
|
|
118
|
+
GetNameFromTypeSignature(PRETTY_FUNCTION_VALUE);
|
|
119
|
+
return leaky_name;
|
|
120
|
+
|
|
121
|
+
#undef PRETTY_FUNCTION_VALUE
|
|
122
|
+
|
|
123
|
+
#else // !CPPGC_SUPPORTS_OBJECT_NAMES
|
|
124
|
+
return {NameProvider::kHiddenName, true};
|
|
125
|
+
#endif // !CPPGC_SUPPORTS_OBJECT_NAMES
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
using NameCallback = HeapObjectName (*)(const void*,
|
|
130
|
+
HeapObjectNameForUnnamedObject);
|
|
131
|
+
|
|
132
|
+
} // namespace internal
|
|
133
|
+
} // namespace cppgc
|
|
134
|
+
|
|
135
|
+
#undef CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
|
|
136
|
+
|
|
137
|
+
#endif // INCLUDE_CPPGC_INTERNAL_NAME_TRAIT_H_
|