libv8-node 15.14.0.1-aarch64-linux-musl → 18.8.0.0-aarch64-linux-musl
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libv8-node/location.rb +1 -1
- data/ext/libv8-node/paths.rb +5 -1
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/{out.gn → aarch64-linux-musl}/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/allocation.h +184 -47
- data/vendor/v8/include/cppgc/common.h +9 -6
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +465 -0
- data/vendor/v8/include/cppgc/custom-space.h +37 -2
- data/vendor/v8/include/cppgc/default-platform.h +40 -49
- data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
- data/vendor/v8/include/cppgc/explicit-management.h +100 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +19 -29
- data/vendor/v8/include/cppgc/heap-consistency.h +266 -0
- data/vendor/v8/include/cppgc/heap-state.h +82 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
- data/vendor/v8/include/cppgc/heap.h +73 -6
- data/vendor/v8/include/cppgc/internal/api-constants.h +11 -3
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +27 -15
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +4 -1
- data/vendor/v8/include/cppgc/internal/gc-info.h +124 -13
- data/vendor/v8/include/cppgc/internal/logging.h +3 -3
- data/vendor/v8/include/cppgc/internal/name-trait.h +122 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +116 -16
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +84 -32
- data/vendor/v8/include/cppgc/internal/write-barrier.h +392 -35
- data/vendor/v8/include/cppgc/liveness-broker.h +11 -2
- data/vendor/v8/include/cppgc/macros.h +2 -0
- data/vendor/v8/include/cppgc/member.h +91 -26
- data/vendor/v8/include/cppgc/name-provider.h +65 -0
- data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
- data/vendor/v8/include/cppgc/persistent.h +70 -41
- data/vendor/v8/include/cppgc/platform.h +52 -26
- data/vendor/v8/include/cppgc/prefinalizer.h +36 -13
- data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
- data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
- data/vendor/v8/include/cppgc/source-location.h +2 -1
- data/vendor/v8/include/cppgc/testing.h +106 -0
- data/vendor/v8/include/cppgc/trace-trait.h +8 -3
- data/vendor/v8/include/cppgc/type-traits.h +163 -32
- data/vendor/v8/include/cppgc/visitor.h +194 -28
- data/vendor/v8/include/libplatform/libplatform.h +11 -11
- data/vendor/v8/include/libplatform/v8-tracing.h +2 -1
- data/vendor/v8/include/v8-array-buffer.h +445 -0
- data/vendor/v8/include/v8-callbacks.h +397 -0
- data/vendor/v8/include/v8-container.h +129 -0
- data/vendor/v8/include/v8-context.h +407 -0
- data/vendor/v8/include/v8-cppgc.h +151 -159
- data/vendor/v8/include/v8-data.h +80 -0
- data/vendor/v8/include/v8-date.h +43 -0
- data/vendor/v8/include/v8-debug.h +168 -0
- data/vendor/v8/include/v8-embedder-heap.h +218 -0
- data/vendor/v8/include/v8-embedder-state-scope.h +51 -0
- data/vendor/v8/include/v8-exception.h +217 -0
- data/vendor/v8/include/v8-extension.h +62 -0
- data/vendor/v8/include/v8-external.h +37 -0
- data/vendor/v8/include/v8-fast-api-calls.h +703 -152
- data/vendor/v8/include/v8-forward.h +81 -0
- data/vendor/v8/include/v8-function-callback.h +475 -0
- data/vendor/v8/include/v8-function.h +125 -0
- data/vendor/v8/include/v8-initialization.h +315 -0
- data/vendor/v8/include/v8-inspector.h +76 -27
- data/vendor/v8/include/v8-internal.h +285 -51
- data/vendor/v8/include/v8-isolate.h +1709 -0
- data/vendor/v8/include/v8-json.h +47 -0
- data/vendor/v8/include/v8-local-handle.h +455 -0
- data/vendor/v8/include/v8-locker.h +149 -0
- data/vendor/v8/include/v8-maybe.h +137 -0
- data/vendor/v8/include/v8-memory-span.h +43 -0
- data/vendor/v8/include/v8-message.h +216 -0
- data/vendor/v8/include/v8-metrics.h +131 -9
- data/vendor/v8/include/v8-microtask-queue.h +152 -0
- data/vendor/v8/include/v8-microtask.h +28 -0
- data/vendor/v8/include/v8-object.h +775 -0
- data/vendor/v8/include/v8-persistent-handle.h +590 -0
- data/vendor/v8/include/v8-platform.h +433 -25
- data/vendor/v8/include/v8-primitive-object.h +118 -0
- data/vendor/v8/include/v8-primitive.h +866 -0
- data/vendor/v8/include/v8-profiler.h +149 -10
- data/vendor/v8/include/v8-promise.h +174 -0
- data/vendor/v8/include/v8-proxy.h +50 -0
- data/vendor/v8/include/v8-regexp.h +105 -0
- data/vendor/v8/include/v8-script.h +747 -0
- data/vendor/v8/include/v8-snapshot.h +196 -0
- data/vendor/v8/include/v8-statistics.h +217 -0
- data/vendor/v8/include/v8-template.h +1079 -0
- data/vendor/v8/include/v8-traced-handle.h +420 -0
- data/vendor/v8/include/v8-typed-array.h +282 -0
- data/vendor/v8/include/v8-unwinder-state.h +31 -0
- data/vendor/v8/include/v8-unwinder.h +132 -0
- data/vendor/v8/include/v8-util.h +8 -2
- data/vendor/v8/include/v8-value-serializer-version.h +1 -1
- data/vendor/v8/include/v8-value-serializer.h +279 -0
- data/vendor/v8/include/v8-value.h +526 -0
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm.h +257 -0
- data/vendor/v8/include/v8-weak-callback-info.h +87 -0
- data/vendor/v8/include/v8.h +41 -12051
- data/vendor/v8/include/v8config.h +142 -21
- metadata +64 -10
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +0 -30
- data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -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,46 @@ 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 interleaves marking with the rest of the application
|
72
|
+
* workload 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 sweeping interleaves sweeping with the rest of the
|
91
|
+
* application workload on the same thread.
|
92
|
+
*/
|
93
|
+
kIncremental,
|
94
|
+
/**
|
95
|
+
* Incremental and concurrent sweeping. Sweeping is split and interleaved
|
96
|
+
* with the rest of the application.
|
97
|
+
*/
|
98
|
+
kIncrementalAndConcurrent
|
99
|
+
};
|
100
|
+
|
54
101
|
/**
|
55
102
|
* Constraints for a Heap setup.
|
56
103
|
*/
|
@@ -66,33 +113,43 @@ class V8_EXPORT Heap {
|
|
66
113
|
|
67
114
|
/**
|
68
115
|
* Options specifying Heap properties (e.g. custom spaces) when initializing a
|
69
|
-
* heap through Heap::Create()
|
116
|
+
* heap through `Heap::Create()`.
|
70
117
|
*/
|
71
118
|
struct HeapOptions {
|
72
119
|
/**
|
73
120
|
* Creates reasonable defaults for instantiating a Heap.
|
74
121
|
*
|
75
|
-
* \returns the HeapOptions that can be passed to Heap::Create()
|
122
|
+
* \returns the HeapOptions that can be passed to `Heap::Create()`.
|
76
123
|
*/
|
77
124
|
static HeapOptions Default() { return {}; }
|
78
125
|
|
79
126
|
/**
|
80
127
|
* Custom spaces added to heap are required to have indices forming a
|
81
|
-
* numbered sequence starting at 0, i.e., their kSpaceIndex must
|
82
|
-
* to the index they reside in the vector.
|
128
|
+
* numbered sequence starting at 0, i.e., their `kSpaceIndex` must
|
129
|
+
* correspond to the index they reside in the vector.
|
83
130
|
*/
|
84
131
|
std::vector<std::unique_ptr<CustomSpaceBase>> custom_spaces;
|
85
132
|
|
86
133
|
/**
|
87
|
-
* Specifies whether
|
134
|
+
* Specifies whether conservative stack scan is supported. When conservative
|
88
135
|
* stack scan is not supported, the collector may try to invoke
|
89
136
|
* garbage collections using non-nestable task, which are guaranteed to have
|
90
137
|
* no interesting stack, through the provided Platform. If such tasks are
|
91
138
|
* not supported by the Platform, the embedder must take care of invoking
|
92
|
-
* the GC through ForceGarbageCollectionSlow()
|
139
|
+
* the GC through `ForceGarbageCollectionSlow()`.
|
93
140
|
*/
|
94
141
|
StackSupport stack_support = StackSupport::kSupportsConservativeStackScan;
|
95
142
|
|
143
|
+
/**
|
144
|
+
* Specifies which types of marking are supported by the heap.
|
145
|
+
*/
|
146
|
+
MarkingType marking_support = MarkingType::kIncrementalAndConcurrent;
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Specifies which types of sweeping are supported by the heap.
|
150
|
+
*/
|
151
|
+
SweepingType sweeping_support = SweepingType::kIncrementalAndConcurrent;
|
152
|
+
|
96
153
|
/**
|
97
154
|
* Resource constraints specifying various properties that the internal
|
98
155
|
* GC scheduler follows.
|
@@ -126,8 +183,18 @@ class V8_EXPORT Heap {
|
|
126
183
|
const char* source, const char* reason,
|
127
184
|
StackState stack_state = StackState::kMayContainHeapPointers);
|
128
185
|
|
186
|
+
/**
|
187
|
+
* \returns the opaque handle for allocating objects using
|
188
|
+
* `MakeGarbageCollected()`.
|
189
|
+
*/
|
129
190
|
AllocationHandle& GetAllocationHandle();
|
130
191
|
|
192
|
+
/**
|
193
|
+
* \returns the opaque heap handle which may be used to refer to this heap in
|
194
|
+
* other APIs. Valid as long as the underlying `Heap` is alive.
|
195
|
+
*/
|
196
|
+
HeapHandle& GetHeapHandle();
|
197
|
+
|
131
198
|
private:
|
132
199
|
Heap() = default;
|
133
200
|
|
@@ -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 <
|
9
|
-
#include <
|
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
|
31
|
+
static constexpr uint16_t kFullyConstructedBitMask = uint16_t{1};
|
32
32
|
|
33
33
|
static constexpr size_t kPageSize = size_t{1} << 17;
|
34
34
|
|
@@ -39,6 +39,14 @@ constexpr size_t kCagedHeapReservationSize = static_cast<size_t>(4) * kGB;
|
|
39
39
|
constexpr size_t kCagedHeapReservationAlignment = kCagedHeapReservationSize;
|
40
40
|
#endif
|
41
41
|
|
42
|
+
static constexpr size_t kDefaultAlignment = sizeof(void*);
|
43
|
+
|
44
|
+
// Maximum support alignment for a type as in `alignof(T)`.
|
45
|
+
static constexpr size_t kMaxSupportedAlignment = 2 * kDefaultAlignment;
|
46
|
+
|
47
|
+
// Granularity of heap allocations.
|
48
|
+
constexpr size_t kAllocationGranularity = sizeof(void*);
|
49
|
+
|
42
50
|
} // namespace api_constants
|
43
51
|
|
44
52
|
} // namespace internal
|
@@ -6,10 +6,13 @@
|
|
6
6
|
#define INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
|
7
7
|
|
8
8
|
#include <array>
|
9
|
+
#include <cstddef>
|
10
|
+
#include <cstdint>
|
9
11
|
|
10
12
|
#include "cppgc/internal/api-constants.h"
|
11
13
|
#include "cppgc/internal/logging.h"
|
12
14
|
#include "cppgc/platform.h"
|
15
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
13
16
|
|
14
17
|
namespace cppgc {
|
15
18
|
namespace internal {
|
@@ -18,32 +21,41 @@ class HeapBase;
|
|
18
21
|
|
19
22
|
#if defined(CPPGC_YOUNG_GENERATION)
|
20
23
|
|
21
|
-
// AgeTable
|
22
|
-
//
|
24
|
+
// AgeTable is the bytemap needed for the fast generation check in the write
|
25
|
+
// barrier. AgeTable contains entries that correspond to 512 bytes memory
|
26
|
+
// regions (cards). Each entry in the table represents generation of the objects
|
27
|
+
// that reside on the corresponding card (young, old or mixed).
|
23
28
|
class AgeTable final {
|
24
|
-
static constexpr size_t
|
29
|
+
static constexpr size_t kRequiredSize = 1 * api_constants::kMB;
|
30
|
+
static constexpr size_t kAllocationGranularity =
|
31
|
+
api_constants::kAllocationGranularity;
|
25
32
|
|
26
33
|
public:
|
27
|
-
enum class Age : uint8_t { kOld, kYoung,
|
34
|
+
enum class Age : uint8_t { kOld, kYoung, kMixed };
|
28
35
|
|
29
|
-
static constexpr size_t
|
36
|
+
static constexpr size_t kCardSizeInBytes =
|
37
|
+
(api_constants::kCagedHeapReservationSize / kAllocationGranularity) /
|
38
|
+
kRequiredSize;
|
30
39
|
|
31
|
-
|
32
|
-
|
40
|
+
void SetAge(uintptr_t cage_offset, Age age) {
|
41
|
+
table_[card(cage_offset)] = age;
|
42
|
+
}
|
43
|
+
V8_INLINE Age GetAge(uintptr_t cage_offset) const {
|
44
|
+
return table_[card(cage_offset)];
|
45
|
+
}
|
33
46
|
|
34
47
|
void Reset(PageAllocator* allocator);
|
35
48
|
|
36
49
|
private:
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
size_t entry(uintptr_t offset) const {
|
50
|
+
V8_INLINE size_t card(uintptr_t offset) const {
|
51
|
+
constexpr size_t kGranularityBits =
|
52
|
+
__builtin_ctz(static_cast<uint32_t>(kCardSizeInBytes));
|
41
53
|
const size_t entry = offset >> kGranularityBits;
|
42
54
|
CPPGC_DCHECK(table_.size() > entry);
|
43
55
|
return entry;
|
44
56
|
}
|
45
57
|
|
46
|
-
std::array<Age,
|
58
|
+
std::array<Age, kRequiredSize> table_;
|
47
59
|
};
|
48
60
|
|
49
61
|
static_assert(sizeof(AgeTable) == 1 * api_constants::kMB,
|
@@ -52,10 +64,10 @@ static_assert(sizeof(AgeTable) == 1 * api_constants::kMB,
|
|
52
64
|
#endif // CPPGC_YOUNG_GENERATION
|
53
65
|
|
54
66
|
struct CagedHeapLocalData final {
|
55
|
-
|
67
|
+
CagedHeapLocalData(HeapBase&, PageAllocator&);
|
56
68
|
|
57
|
-
bool
|
58
|
-
HeapBase
|
69
|
+
bool is_incremental_marking_in_progress = false;
|
70
|
+
HeapBase& heap_base;
|
59
71
|
#if defined(CPPGC_YOUNG_GENERATION)
|
60
72
|
AgeTable age_table;
|
61
73
|
#endif
|
@@ -21,13 +21,13 @@ namespace cppgc {
|
|
21
21
|
|
22
22
|
// [[no_unique_address]] comes in C++20 but supported in clang with -std >=
|
23
23
|
// c++11.
|
24
|
-
#if CPPGC_HAS_CPP_ATTRIBUTE(no_unique_address)
|
24
|
+
#if CPPGC_HAS_CPP_ATTRIBUTE(no_unique_address)
|
25
25
|
#define CPPGC_NO_UNIQUE_ADDRESS [[no_unique_address]]
|
26
26
|
#else
|
27
27
|
#define CPPGC_NO_UNIQUE_ADDRESS
|
28
28
|
#endif
|
29
29
|
|
30
|
-
#if CPPGC_HAS_ATTRIBUTE(unused)
|
30
|
+
#if CPPGC_HAS_ATTRIBUTE(unused)
|
31
31
|
#define CPPGC_UNUSED __attribute__((unused))
|
32
32
|
#else
|
33
33
|
#define CPPGC_UNUSED
|
@@ -19,7 +19,8 @@ struct HasFinalizeGarbageCollectedObject : std::false_type {};
|
|
19
19
|
|
20
20
|
template <typename T>
|
21
21
|
struct HasFinalizeGarbageCollectedObject<
|
22
|
-
T,
|
22
|
+
T,
|
23
|
+
std::void_t<decltype(std::declval<T>().FinalizeGarbageCollectedObject())>>
|
23
24
|
: std::true_type {};
|
24
25
|
|
25
26
|
// The FinalizerTraitImpl specifies how to finalize objects.
|
@@ -76,6 +77,8 @@ struct FinalizerTrait {
|
|
76
77
|
}
|
77
78
|
|
78
79
|
public:
|
80
|
+
static constexpr bool HasFinalizer() { return kNonTrivialFinalizer; }
|
81
|
+
|
79
82
|
// The callback used to finalize an object of type T.
|
80
83
|
static constexpr FinalizationCallback kCallback =
|
81
84
|
kNonTrivialFinalizer ? Finalize : nullptr;
|
@@ -5,9 +5,12 @@
|
|
5
5
|
#ifndef INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
|
6
6
|
#define INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
|
7
7
|
|
8
|
-
#include <
|
8
|
+
#include <atomic>
|
9
|
+
#include <cstdint>
|
10
|
+
#include <type_traits>
|
9
11
|
|
10
12
|
#include "cppgc/internal/finalizer-trait.h"
|
13
|
+
#include "cppgc/internal/name-trait.h"
|
11
14
|
#include "cppgc/trace-trait.h"
|
12
15
|
#include "v8config.h" // NOLINT(build/include_directory)
|
13
16
|
|
@@ -16,26 +19,134 @@ namespace internal {
|
|
16
19
|
|
17
20
|
using GCInfoIndex = uint16_t;
|
18
21
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
GCInfoIndex
|
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
|
+
}
|
24
30
|
|
25
31
|
private:
|
26
|
-
|
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
|
+
|
52
|
+
NameCallback);
|
53
|
+
static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
|
54
|
+
TraceCallback,
|
55
|
+
FinalizationCallback);
|
56
|
+
static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
|
57
|
+
TraceCallback,
|
58
|
+
NameCallback);
|
59
|
+
static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
|
60
|
+
TraceCallback);
|
61
|
+
};
|
62
|
+
|
63
|
+
#define DISPATCH(is_polymorphic, has_finalizer, has_non_hidden_name, function) \
|
64
|
+
template <typename T> \
|
65
|
+
struct EnsureGCInfoIndexTrait::EnsureGCInfoIndexTraitDispatch< \
|
66
|
+
T, is_polymorphic, has_finalizer, has_non_hidden_name> { \
|
67
|
+
V8_INLINE GCInfoIndex \
|
68
|
+
operator()(std::atomic<GCInfoIndex>& registered_index) { \
|
69
|
+
return function; \
|
70
|
+
} \
|
71
|
+
};
|
72
|
+
|
73
|
+
// --------------------------------------------------------------------- //
|
74
|
+
// DISPATCH(is_polymorphic, has_finalizer, has_non_hidden_name, function)
|
75
|
+
// --------------------------------------------------------------------- //
|
76
|
+
DISPATCH(true, true, true, //
|
77
|
+
EnsureGCInfoIndexPolymorphic(registered_index, //
|
78
|
+
TraceTrait<T>::Trace, //
|
79
|
+
FinalizerTrait<T>::kCallback, //
|
80
|
+
NameTrait<T>::GetName)) //
|
81
|
+
DISPATCH(true, true, false, //
|
82
|
+
EnsureGCInfoIndexPolymorphic(registered_index, //
|
83
|
+
TraceTrait<T>::Trace, //
|
84
|
+
FinalizerTrait<T>::kCallback)) //
|
85
|
+
DISPATCH(true, false, true, //
|
86
|
+
EnsureGCInfoIndexPolymorphic(registered_index, //
|
87
|
+
TraceTrait<T>::Trace, //
|
88
|
+
NameTrait<T>::GetName)) //
|
89
|
+
DISPATCH(true, false, false, //
|
90
|
+
EnsureGCInfoIndexPolymorphic(registered_index, //
|
91
|
+
TraceTrait<T>::Trace)) //
|
92
|
+
DISPATCH(false, true, true, //
|
93
|
+
EnsureGCInfoIndexNonPolymorphic(registered_index, //
|
94
|
+
TraceTrait<T>::Trace, //
|
95
|
+
FinalizerTrait<T>::kCallback, //
|
96
|
+
NameTrait<T>::GetName)) //
|
97
|
+
DISPATCH(false, true, false, //
|
98
|
+
EnsureGCInfoIndexNonPolymorphic(registered_index, //
|
99
|
+
TraceTrait<T>::Trace, //
|
100
|
+
FinalizerTrait<T>::kCallback)) //
|
101
|
+
DISPATCH(false, false, true, //
|
102
|
+
EnsureGCInfoIndexNonPolymorphic(registered_index, //
|
103
|
+
TraceTrait<T>::Trace, //
|
104
|
+
NameTrait<T>::GetName)) //
|
105
|
+
DISPATCH(false, false, false, //
|
106
|
+
EnsureGCInfoIndexNonPolymorphic(registered_index, //
|
107
|
+
TraceTrait<T>::Trace)) //
|
108
|
+
|
109
|
+
#undef DISPATCH
|
110
|
+
|
111
|
+
// Fold types based on finalizer behavior. Note that finalizer characteristics
|
112
|
+
// align with trace behavior, i.e., destructors are virtual when trace methods
|
113
|
+
// are and vice versa.
|
114
|
+
template <typename T, typename ParentMostGarbageCollectedType>
|
115
|
+
struct GCInfoFolding {
|
116
|
+
static constexpr bool kHasVirtualDestructorAtBase =
|
117
|
+
std::has_virtual_destructor<ParentMostGarbageCollectedType>::value;
|
118
|
+
static constexpr bool kBothTypesAreTriviallyDestructible =
|
119
|
+
std::is_trivially_destructible<ParentMostGarbageCollectedType>::value &&
|
120
|
+
std::is_trivially_destructible<T>::value;
|
121
|
+
static constexpr bool kHasCustomFinalizerDispatchAtBase =
|
122
|
+
internal::HasFinalizeGarbageCollectedObject<
|
123
|
+
ParentMostGarbageCollectedType>::value;
|
124
|
+
#ifdef CPPGC_SUPPORTS_OBJECT_NAMES
|
125
|
+
static constexpr bool kWantsDetailedObjectNames = true;
|
126
|
+
#else // !CPPGC_SUPPORTS_OBJECT_NAMES
|
127
|
+
static constexpr bool kWantsDetailedObjectNames = false;
|
128
|
+
#endif // !CPPGC_SUPPORTS_OBJECT_NAMES
|
129
|
+
|
130
|
+
// Folding would regresses name resolution when deriving names from C++
|
131
|
+
// class names as it would just folds a name to the base class name.
|
132
|
+
using ResultType = std::conditional_t<(kHasVirtualDestructorAtBase ||
|
133
|
+
kBothTypesAreTriviallyDestructible ||
|
134
|
+
kHasCustomFinalizerDispatchAtBase) &&
|
135
|
+
!kWantsDetailedObjectNames,
|
136
|
+
ParentMostGarbageCollectedType, T>;
|
27
137
|
};
|
28
138
|
|
29
139
|
// Trait determines how the garbage collector treats objects wrt. to traversing,
|
30
140
|
// finalization, and naming.
|
31
141
|
template <typename T>
|
32
|
-
struct GCInfoTrait {
|
33
|
-
static GCInfoIndex Index() {
|
142
|
+
struct GCInfoTrait final {
|
143
|
+
V8_INLINE static GCInfoIndex Index() {
|
34
144
|
static_assert(sizeof(T), "T must be fully defined");
|
35
|
-
static
|
36
|
-
|
37
|
-
|
38
|
-
return
|
145
|
+
static std::atomic<GCInfoIndex>
|
146
|
+
registered_index; // Uses zero initialization.
|
147
|
+
const GCInfoIndex index = registered_index.load(std::memory_order_acquire);
|
148
|
+
return index ? index
|
149
|
+
: EnsureGCInfoIndexTrait::EnsureIndex<T>(registered_index);
|
39
150
|
}
|
40
151
|
};
|
41
152
|
|
@@ -20,18 +20,18 @@ FatalImpl(const char*, const SourceLocation& = SourceLocation::Current());
|
|
20
20
|
template <typename>
|
21
21
|
struct EatParams {};
|
22
22
|
|
23
|
-
#if DEBUG
|
23
|
+
#if defined(DEBUG)
|
24
24
|
#define CPPGC_DCHECK_MSG(condition, message) \
|
25
25
|
do { \
|
26
26
|
if (V8_UNLIKELY(!(condition))) { \
|
27
27
|
::cppgc::internal::DCheckImpl(message); \
|
28
28
|
} \
|
29
29
|
} while (false)
|
30
|
-
#else
|
30
|
+
#else // !defined(DEBUG)
|
31
31
|
#define CPPGC_DCHECK_MSG(condition, message) \
|
32
32
|
(static_cast<void>(::cppgc::internal::EatParams<decltype( \
|
33
33
|
static_cast<void>(condition), message)>{}))
|
34
|
-
#endif
|
34
|
+
#endif // !defined(DEBUG)
|
35
35
|
|
36
36
|
#define CPPGC_DCHECK(condition) CPPGC_DCHECK_MSG(condition, #condition)
|
37
37
|
|
@@ -0,0 +1,122 @@
|
|
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 <type_traits>
|
10
|
+
|
11
|
+
#include "cppgc/name-provider.h"
|
12
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
13
|
+
|
14
|
+
namespace cppgc {
|
15
|
+
namespace internal {
|
16
|
+
|
17
|
+
#if CPPGC_SUPPORTS_OBJECT_NAMES && defined(__clang__)
|
18
|
+
#define CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME 1
|
19
|
+
|
20
|
+
// Provides constexpr c-string storage for a name of fixed |Size| characters.
|
21
|
+
// Automatically appends terminating 0 byte.
|
22
|
+
template <size_t Size>
|
23
|
+
struct NameBuffer {
|
24
|
+
char name[Size + 1]{};
|
25
|
+
|
26
|
+
static constexpr NameBuffer FromCString(const char* str) {
|
27
|
+
NameBuffer result;
|
28
|
+
for (size_t i = 0; i < Size; ++i) result.name[i] = str[i];
|
29
|
+
result.name[Size] = 0;
|
30
|
+
return result;
|
31
|
+
}
|
32
|
+
};
|
33
|
+
|
34
|
+
template <typename T>
|
35
|
+
const char* GetTypename() {
|
36
|
+
static constexpr char kSelfPrefix[] =
|
37
|
+
"const char *cppgc::internal::GetTypename() [T =";
|
38
|
+
static_assert(__builtin_strncmp(__PRETTY_FUNCTION__, kSelfPrefix,
|
39
|
+
sizeof(kSelfPrefix) - 1) == 0,
|
40
|
+
"The prefix must match");
|
41
|
+
static constexpr const char* kTypenameStart =
|
42
|
+
__PRETTY_FUNCTION__ + sizeof(kSelfPrefix);
|
43
|
+
static constexpr size_t kTypenameSize =
|
44
|
+
__builtin_strlen(__PRETTY_FUNCTION__) - sizeof(kSelfPrefix) - 1;
|
45
|
+
// NameBuffer is an indirection that is needed to make sure that only a
|
46
|
+
// substring of __PRETTY_FUNCTION__ gets materialized in the binary.
|
47
|
+
static constexpr auto buffer =
|
48
|
+
NameBuffer<kTypenameSize>::FromCString(kTypenameStart);
|
49
|
+
return buffer.name;
|
50
|
+
}
|
51
|
+
|
52
|
+
#else
|
53
|
+
#define CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME 0
|
54
|
+
#endif
|
55
|
+
|
56
|
+
struct HeapObjectName {
|
57
|
+
const char* value;
|
58
|
+
bool name_was_hidden;
|
59
|
+
};
|
60
|
+
|
61
|
+
class V8_EXPORT NameTraitBase {
|
62
|
+
protected:
|
63
|
+
static HeapObjectName GetNameFromTypeSignature(const char*);
|
64
|
+
};
|
65
|
+
|
66
|
+
// Trait that specifies how the garbage collector retrieves the name for a
|
67
|
+
// given object.
|
68
|
+
template <typename T>
|
69
|
+
class NameTrait final : public NameTraitBase {
|
70
|
+
public:
|
71
|
+
static constexpr bool HasNonHiddenName() {
|
72
|
+
#if CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
|
73
|
+
return true;
|
74
|
+
#elif CPPGC_SUPPORTS_OBJECT_NAMES
|
75
|
+
return true;
|
76
|
+
#else // !CPPGC_SUPPORTS_OBJECT_NAMES
|
77
|
+
return std::is_base_of<NameProvider, T>::value;
|
78
|
+
#endif // !CPPGC_SUPPORTS_OBJECT_NAMES
|
79
|
+
}
|
80
|
+
|
81
|
+
static HeapObjectName GetName(const void* obj) {
|
82
|
+
return GetNameFor(static_cast<const T*>(obj));
|
83
|
+
}
|
84
|
+
|
85
|
+
private:
|
86
|
+
static HeapObjectName GetNameFor(const NameProvider* name_provider) {
|
87
|
+
return {name_provider->GetHumanReadableName(), false};
|
88
|
+
}
|
89
|
+
|
90
|
+
static HeapObjectName GetNameFor(...) {
|
91
|
+
#if CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
|
92
|
+
return {GetTypename<T>(), false};
|
93
|
+
#elif CPPGC_SUPPORTS_OBJECT_NAMES
|
94
|
+
|
95
|
+
#if defined(V8_CC_GNU)
|
96
|
+
#define PRETTY_FUNCTION_VALUE __PRETTY_FUNCTION__
|
97
|
+
#elif defined(V8_CC_MSVC)
|
98
|
+
#define PRETTY_FUNCTION_VALUE __FUNCSIG__
|
99
|
+
#else
|
100
|
+
#define PRETTY_FUNCTION_VALUE nullptr
|
101
|
+
#endif
|
102
|
+
|
103
|
+
static const HeapObjectName leaky_name =
|
104
|
+
GetNameFromTypeSignature(PRETTY_FUNCTION_VALUE);
|
105
|
+
return {leaky_name, false};
|
106
|
+
|
107
|
+
#undef PRETTY_FUNCTION_VALUE
|
108
|
+
|
109
|
+
#else // !CPPGC_SUPPORTS_OBJECT_NAMES
|
110
|
+
return {NameProvider::kHiddenName, true};
|
111
|
+
#endif // !CPPGC_SUPPORTS_OBJECT_NAMES
|
112
|
+
}
|
113
|
+
};
|
114
|
+
|
115
|
+
using NameCallback = HeapObjectName (*)(const void*);
|
116
|
+
|
117
|
+
} // namespace internal
|
118
|
+
} // namespace cppgc
|
119
|
+
|
120
|
+
#undef CPPGC_SUPPORTS_COMPILE_TIME_TYPENAME
|
121
|
+
|
122
|
+
#endif // INCLUDE_CPPGC_INTERNAL_NAME_TRAIT_H_
|