libv8-node 16.10.0.0-x86_64-darwin → 18.8.0.0-x86_64-darwin
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/paths.rb +1 -1
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/include/cppgc/allocation.h +100 -22
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +114 -33
- data/vendor/v8/include/cppgc/default-platform.h +2 -10
- data/vendor/v8/include/cppgc/explicit-management.h +22 -4
- data/vendor/v8/include/cppgc/garbage-collected.h +15 -26
- data/vendor/v8/include/cppgc/heap-consistency.h +30 -0
- data/vendor/v8/include/cppgc/heap-state.h +12 -0
- data/vendor/v8/include/cppgc/heap.h +7 -2
- data/vendor/v8/include/cppgc/internal/api-constants.h +8 -0
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +25 -14
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +4 -1
- data/vendor/v8/include/cppgc/internal/gc-info.h +90 -10
- data/vendor/v8/include/cppgc/internal/logging.h +3 -3
- data/vendor/v8/include/cppgc/internal/name-trait.h +11 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +73 -29
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +26 -15
- data/vendor/v8/include/cppgc/internal/write-barrier.h +62 -23
- data/vendor/v8/include/cppgc/liveness-broker.h +4 -1
- data/vendor/v8/include/cppgc/member.h +7 -2
- data/vendor/v8/include/cppgc/persistent.h +38 -33
- data/vendor/v8/include/cppgc/platform.h +4 -1
- data/vendor/v8/include/cppgc/prefinalizer.h +35 -12
- data/vendor/v8/include/cppgc/testing.h +9 -2
- data/vendor/v8/include/cppgc/type-traits.h +6 -13
- data/vendor/v8/include/cppgc/visitor.h +9 -7
- data/vendor/v8/include/libplatform/libplatform.h +0 -11
- data/vendor/v8/include/libplatform/v8-tracing.h +0 -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 +21 -128
- 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 +172 -24
- 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 +56 -28
- data/vendor/v8/include/v8-internal.h +217 -55
- 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 +69 -16
- 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 +400 -17
- 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 +88 -13
- 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 +4 -3
- data/vendor/v8/include/v8-unwinder.h +132 -0
- data/vendor/v8/include/v8-util.h +7 -1
- 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 -12601
- data/vendor/v8/include/v8config.h +102 -12
- data/vendor/v8/x86_64-darwin/libv8/obj/libv8_monolith.a +0 -0
- metadata +47 -5
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +0 -30
@@ -11,6 +11,7 @@
|
|
11
11
|
#include "cppgc/heap-state.h"
|
12
12
|
#include "cppgc/internal/api-constants.h"
|
13
13
|
#include "cppgc/internal/atomic-entry-flag.h"
|
14
|
+
#include "cppgc/platform.h"
|
14
15
|
#include "cppgc/sentinel-pointer.h"
|
15
16
|
#include "cppgc/trace-trait.h"
|
16
17
|
#include "v8config.h" // NOLINT(build/include_directory)
|
@@ -66,10 +67,8 @@ class V8_EXPORT WriteBarrier final {
|
|
66
67
|
template <typename HeapHandleCallback>
|
67
68
|
static V8_INLINE Type GetWriteBarrierType(const void* slot, Params& params,
|
68
69
|
HeapHandleCallback callback);
|
69
|
-
|
70
|
-
|
71
|
-
static V8_INLINE Type GetWriteBarrierTypeForExternallyReferencedObject(
|
72
|
-
const void* value, Params& params, HeapHandleCallback callback);
|
70
|
+
// Returns the required write barrier for a given `value`.
|
71
|
+
static V8_INLINE Type GetWriteBarrierType(const void* value, Params& params);
|
73
72
|
|
74
73
|
static V8_INLINE void DijkstraMarkingBarrier(const Params& params,
|
75
74
|
const void* object);
|
@@ -81,9 +80,13 @@ class V8_EXPORT WriteBarrier final {
|
|
81
80
|
#if defined(CPPGC_YOUNG_GENERATION)
|
82
81
|
static V8_INLINE void GenerationalBarrier(const Params& params,
|
83
82
|
const void* slot);
|
84
|
-
|
83
|
+
static V8_INLINE void GenerationalBarrierForSourceObject(
|
84
|
+
const Params& params, const void* inner_pointer);
|
85
|
+
#else // !CPPGC_YOUNG_GENERATION
|
85
86
|
static V8_INLINE void GenerationalBarrier(const Params& params,
|
86
87
|
const void* slot) {}
|
88
|
+
static V8_INLINE void GenerationalBarrierForSourceObject(
|
89
|
+
const Params& params, const void* inner_pointer) {}
|
87
90
|
#endif // CPPGC_YOUNG_GENERATION
|
88
91
|
|
89
92
|
#if V8_ENABLE_CHECKS
|
@@ -121,8 +124,10 @@ class V8_EXPORT WriteBarrier final {
|
|
121
124
|
#if defined(CPPGC_YOUNG_GENERATION)
|
122
125
|
static CagedHeapLocalData& GetLocalData(HeapHandle&);
|
123
126
|
static void GenerationalBarrierSlow(const CagedHeapLocalData& local_data,
|
124
|
-
const AgeTable&
|
127
|
+
const AgeTable& age_table,
|
125
128
|
const void* slot, uintptr_t value_offset);
|
129
|
+
static void GenerationalBarrierForSourceObjectSlow(
|
130
|
+
const CagedHeapLocalData& local_data, const void* object);
|
126
131
|
#endif // CPPGC_YOUNG_GENERATION
|
127
132
|
|
128
133
|
static AtomicEntryFlag incremental_or_concurrent_marking_flag_;
|
@@ -147,9 +152,20 @@ class V8_EXPORT WriteBarrierTypeForCagedHeapPolicy final {
|
|
147
152
|
return ValueModeDispatch<value_mode>::Get(slot, value, params, callback);
|
148
153
|
}
|
149
154
|
|
155
|
+
template <WriteBarrier::ValueMode value_mode, typename HeapHandleCallback>
|
156
|
+
static V8_INLINE WriteBarrier::Type Get(const void* value,
|
157
|
+
WriteBarrier::Params& params,
|
158
|
+
HeapHandleCallback callback) {
|
159
|
+
return GetNoSlot(value, params, callback);
|
160
|
+
}
|
161
|
+
|
162
|
+
private:
|
163
|
+
WriteBarrierTypeForCagedHeapPolicy() = delete;
|
164
|
+
|
150
165
|
template <typename HeapHandleCallback>
|
151
|
-
static V8_INLINE WriteBarrier::Type
|
152
|
-
|
166
|
+
static V8_INLINE WriteBarrier::Type GetNoSlot(const void* value,
|
167
|
+
WriteBarrier::Params& params,
|
168
|
+
HeapHandleCallback) {
|
153
169
|
if (!TryGetCagedHeap(value, value, params)) {
|
154
170
|
return WriteBarrier::Type::kNone;
|
155
171
|
}
|
@@ -159,14 +175,14 @@ class V8_EXPORT WriteBarrierTypeForCagedHeapPolicy final {
|
|
159
175
|
return SetAndReturnType<WriteBarrier::Type::kNone>(params);
|
160
176
|
}
|
161
177
|
|
162
|
-
private:
|
163
|
-
WriteBarrierTypeForCagedHeapPolicy() = delete;
|
164
|
-
|
165
178
|
template <WriteBarrier::ValueMode value_mode>
|
166
179
|
struct ValueModeDispatch;
|
167
180
|
|
168
181
|
static V8_INLINE bool TryGetCagedHeap(const void* slot, const void* value,
|
169
182
|
WriteBarrier::Params& params) {
|
183
|
+
// TODO(chromium:1056170): Check if the null check can be folded in with
|
184
|
+
// the rest of the write barrier.
|
185
|
+
if (!value) return false;
|
170
186
|
params.start = reinterpret_cast<uintptr_t>(value) &
|
171
187
|
~(api_constants::kCagedHeapReservationAlignment - 1);
|
172
188
|
const uintptr_t slot_offset =
|
@@ -193,6 +209,11 @@ struct WriteBarrierTypeForCagedHeapPolicy::ValueModeDispatch<
|
|
193
209
|
static V8_INLINE WriteBarrier::Type Get(const void* slot, const void* value,
|
194
210
|
WriteBarrier::Params& params,
|
195
211
|
HeapHandleCallback) {
|
212
|
+
#if !defined(CPPGC_YOUNG_GENERATION)
|
213
|
+
if (V8_LIKELY(!WriteBarrier::IsAnyIncrementalOrConcurrentMarking())) {
|
214
|
+
return SetAndReturnType<WriteBarrier::Type::kNone>(params);
|
215
|
+
}
|
216
|
+
#endif // !CPPGC_YOUNG_GENERATION
|
196
217
|
bool within_cage = TryGetCagedHeap(slot, value, params);
|
197
218
|
if (!within_cage) {
|
198
219
|
return WriteBarrier::Type::kNone;
|
@@ -257,10 +278,10 @@ class V8_EXPORT WriteBarrierTypeForNonCagedHeapPolicy final {
|
|
257
278
|
return ValueModeDispatch<value_mode>::Get(slot, value, params, callback);
|
258
279
|
}
|
259
280
|
|
260
|
-
template <typename HeapHandleCallback>
|
261
|
-
static V8_INLINE WriteBarrier::Type
|
262
|
-
|
263
|
-
|
281
|
+
template <WriteBarrier::ValueMode value_mode, typename HeapHandleCallback>
|
282
|
+
static V8_INLINE WriteBarrier::Type Get(const void* value,
|
283
|
+
WriteBarrier::Params& params,
|
284
|
+
HeapHandleCallback callback) {
|
264
285
|
// The slot will never be used in `Get()` below.
|
265
286
|
return Get<WriteBarrier::ValueMode::kValuePresent>(nullptr, value, params,
|
266
287
|
callback);
|
@@ -287,7 +308,10 @@ struct WriteBarrierTypeForNonCagedHeapPolicy::ValueModeDispatch<
|
|
287
308
|
HeapHandleCallback callback) {
|
288
309
|
// The following check covers nullptr as well as sentinel pointer.
|
289
310
|
if (object <= static_cast<void*>(kSentinelPointer)) {
|
290
|
-
return WriteBarrier::Type::kNone;
|
311
|
+
return SetAndReturnType<WriteBarrier::Type::kNone>(params);
|
312
|
+
}
|
313
|
+
if (V8_LIKELY(!WriteBarrier::IsAnyIncrementalOrConcurrentMarking())) {
|
314
|
+
return SetAndReturnType<WriteBarrier::Type::kNone>(params);
|
291
315
|
}
|
292
316
|
if (IsMarking(object, ¶ms.heap)) {
|
293
317
|
return SetAndReturnType<WriteBarrier::Type::kMarking>(params);
|
@@ -331,12 +355,10 @@ WriteBarrier::Type WriteBarrier::GetWriteBarrierType(
|
|
331
355
|
}
|
332
356
|
|
333
357
|
// static
|
334
|
-
|
335
|
-
WriteBarrier::
|
336
|
-
|
337
|
-
|
338
|
-
return WriteBarrierTypePolicy::GetForExternallyReferenced(value, params,
|
339
|
-
callback);
|
358
|
+
WriteBarrier::Type WriteBarrier::GetWriteBarrierType(
|
359
|
+
const void* value, WriteBarrier::Params& params) {
|
360
|
+
return WriteBarrierTypePolicy::Get<ValueMode::kValuePresent>(value, params,
|
361
|
+
[]() {});
|
340
362
|
}
|
341
363
|
|
342
364
|
// static
|
@@ -383,11 +405,28 @@ void WriteBarrier::GenerationalBarrier(const Params& params, const void* slot) {
|
|
383
405
|
const AgeTable& age_table = local_data.age_table;
|
384
406
|
|
385
407
|
// Bail out if the slot is in young generation.
|
386
|
-
if (V8_LIKELY(age_table
|
408
|
+
if (V8_LIKELY(age_table.GetAge(params.slot_offset) == AgeTable::Age::kYoung))
|
409
|
+
return;
|
387
410
|
|
388
411
|
GenerationalBarrierSlow(local_data, age_table, slot, params.value_offset);
|
389
412
|
}
|
390
413
|
|
414
|
+
// static
|
415
|
+
void WriteBarrier::GenerationalBarrierForSourceObject(
|
416
|
+
const Params& params, const void* inner_pointer) {
|
417
|
+
CheckParams(Type::kGenerational, params);
|
418
|
+
|
419
|
+
const CagedHeapLocalData& local_data = params.caged_heap();
|
420
|
+
const AgeTable& age_table = local_data.age_table;
|
421
|
+
|
422
|
+
// Assume that if the first element is in young generation, the whole range is
|
423
|
+
// in young generation.
|
424
|
+
if (V8_LIKELY(age_table.GetAge(params.slot_offset) == AgeTable::Age::kYoung))
|
425
|
+
return;
|
426
|
+
|
427
|
+
GenerationalBarrierForSourceObjectSlow(local_data, inner_pointer);
|
428
|
+
}
|
429
|
+
|
391
430
|
#endif // !CPPGC_YOUNG_GENERATION
|
392
431
|
|
393
432
|
} // namespace internal
|
@@ -44,7 +44,10 @@ class V8_EXPORT LivenessBroker final {
|
|
44
44
|
public:
|
45
45
|
template <typename T>
|
46
46
|
bool IsHeapObjectAlive(const T* object) const {
|
47
|
-
|
47
|
+
// nullptr objects are considered alive to allow weakness to be used from
|
48
|
+
// stack while running into a conservative GC. Treating nullptr as dead
|
49
|
+
// would mean that e.g. custom collectins could not be strongified on stack.
|
50
|
+
return !object ||
|
48
51
|
IsHeapObjectAliveImpl(
|
49
52
|
TraceTrait<T>::GetTraceDescriptor(object).base_object_payload);
|
50
53
|
}
|
@@ -26,7 +26,7 @@ class MemberBase {
|
|
26
26
|
protected:
|
27
27
|
struct AtomicInitializerTag {};
|
28
28
|
|
29
|
-
MemberBase()
|
29
|
+
MemberBase() : raw_(nullptr) {}
|
30
30
|
explicit MemberBase(const void* value) : raw_(value) {}
|
31
31
|
MemberBase(const void* value, AtomicInitializerTag) { SetRawAtomic(value); }
|
32
32
|
|
@@ -46,7 +46,10 @@ class MemberBase {
|
|
46
46
|
void ClearFromGC() const { raw_ = nullptr; }
|
47
47
|
|
48
48
|
private:
|
49
|
-
|
49
|
+
// All constructors initialize `raw_`. Do not add a default value here as it
|
50
|
+
// results in a non-atomic write on some builds, even when the atomic version
|
51
|
+
// of the constructor is used.
|
52
|
+
mutable const void* raw_;
|
50
53
|
};
|
51
54
|
|
52
55
|
// The basic class from which all Member classes are 'generated'.
|
@@ -218,6 +221,8 @@ class BasicMember final : private MemberBase, private CheckingPolicy {
|
|
218
221
|
|
219
222
|
void ClearFromGC() const { MemberBase::ClearFromGC(); }
|
220
223
|
|
224
|
+
T* GetFromGC() const { return Get(); }
|
225
|
+
|
221
226
|
friend class cppgc::Visitor;
|
222
227
|
template <typename U>
|
223
228
|
friend struct cppgc::TraceTrait;
|
@@ -41,11 +41,11 @@ class PersistentBase {
|
|
41
41
|
node_ = nullptr;
|
42
42
|
}
|
43
43
|
|
44
|
-
|
44
|
+
protected:
|
45
45
|
mutable const void* raw_ = nullptr;
|
46
46
|
mutable PersistentNode* node_ = nullptr;
|
47
47
|
|
48
|
-
friend class
|
48
|
+
friend class PersistentRegionBase;
|
49
49
|
};
|
50
50
|
|
51
51
|
// The basic class from which all Persistent classes are generated.
|
@@ -118,10 +118,10 @@ class BasicPersistent final : public PersistentBase,
|
|
118
118
|
template <typename U, typename MemberBarrierPolicy,
|
119
119
|
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
120
120
|
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
121
|
-
BasicPersistent(
|
122
|
-
|
123
|
-
|
124
|
-
|
121
|
+
BasicPersistent(
|
122
|
+
const internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
|
123
|
+
MemberCheckingPolicy>& member,
|
124
|
+
const SourceLocation& loc = SourceLocation::Current())
|
125
125
|
: BasicPersistent(member.Get(), loc) {}
|
126
126
|
|
127
127
|
~BasicPersistent() { Clear(); }
|
@@ -159,9 +159,8 @@ class BasicPersistent final : public PersistentBase,
|
|
159
159
|
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
160
160
|
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
161
161
|
BasicPersistent& operator=(
|
162
|
-
internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
|
163
|
-
|
164
|
-
member) {
|
162
|
+
const internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
|
163
|
+
MemberCheckingPolicy>& member) {
|
165
164
|
return operator=(member.Get());
|
166
165
|
}
|
167
166
|
|
@@ -259,6 +258,12 @@ class BasicPersistent final : public PersistentBase,
|
|
259
258
|
}
|
260
259
|
}
|
261
260
|
|
261
|
+
// Set Get() for details.
|
262
|
+
V8_CLANG_NO_SANITIZE("cfi-unrelated-cast")
|
263
|
+
T* GetFromGC() const {
|
264
|
+
return static_cast<T*>(const_cast<void*>(GetValue()));
|
265
|
+
}
|
266
|
+
|
262
267
|
friend class cppgc::Visitor;
|
263
268
|
};
|
264
269
|
|
@@ -286,12 +291,12 @@ template <typename T1, typename PersistentWeaknessPolicy,
|
|
286
291
|
typename PersistentLocationPolicy, typename PersistentCheckingPolicy,
|
287
292
|
typename T2, typename MemberWriteBarrierPolicy,
|
288
293
|
typename MemberWeaknessTag, typename MemberCheckingPolicy>
|
289
|
-
bool operator==(
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
294
|
+
bool operator==(
|
295
|
+
const BasicPersistent<T1, PersistentWeaknessPolicy,
|
296
|
+
PersistentLocationPolicy, PersistentCheckingPolicy>&
|
297
|
+
p,
|
298
|
+
const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
299
|
+
MemberCheckingPolicy>& m) {
|
295
300
|
return p.Get() == m.Get();
|
296
301
|
}
|
297
302
|
|
@@ -299,12 +304,12 @@ template <typename T1, typename PersistentWeaknessPolicy,
|
|
299
304
|
typename PersistentLocationPolicy, typename PersistentCheckingPolicy,
|
300
305
|
typename T2, typename MemberWriteBarrierPolicy,
|
301
306
|
typename MemberWeaknessTag, typename MemberCheckingPolicy>
|
302
|
-
bool operator!=(
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
307
|
+
bool operator!=(
|
308
|
+
const BasicPersistent<T1, PersistentWeaknessPolicy,
|
309
|
+
PersistentLocationPolicy, PersistentCheckingPolicy>&
|
310
|
+
p,
|
311
|
+
const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
312
|
+
MemberCheckingPolicy>& m) {
|
308
313
|
return !(p == m);
|
309
314
|
}
|
310
315
|
|
@@ -312,12 +317,12 @@ template <typename T1, typename MemberWriteBarrierPolicy,
|
|
312
317
|
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
313
318
|
typename T2, typename PersistentWeaknessPolicy,
|
314
319
|
typename PersistentLocationPolicy, typename PersistentCheckingPolicy>
|
315
|
-
bool operator==(
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
320
|
+
bool operator==(
|
321
|
+
const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
322
|
+
MemberCheckingPolicy>& m,
|
323
|
+
const BasicPersistent<T1, PersistentWeaknessPolicy,
|
324
|
+
PersistentLocationPolicy, PersistentCheckingPolicy>&
|
325
|
+
p) {
|
321
326
|
return m.Get() == p.Get();
|
322
327
|
}
|
323
328
|
|
@@ -325,12 +330,12 @@ template <typename T1, typename MemberWriteBarrierPolicy,
|
|
325
330
|
typename MemberWeaknessTag, typename MemberCheckingPolicy,
|
326
331
|
typename T2, typename PersistentWeaknessPolicy,
|
327
332
|
typename PersistentLocationPolicy, typename PersistentCheckingPolicy>
|
328
|
-
bool operator!=(
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
333
|
+
bool operator!=(
|
334
|
+
const BasicMember<T2, MemberWeaknessTag, MemberWriteBarrierPolicy,
|
335
|
+
MemberCheckingPolicy>& m,
|
336
|
+
const BasicPersistent<T1, PersistentWeaknessPolicy,
|
337
|
+
PersistentLocationPolicy, PersistentCheckingPolicy>&
|
338
|
+
p) {
|
334
339
|
return !(m == p);
|
335
340
|
}
|
336
341
|
|
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
#include <memory>
|
9
9
|
|
10
|
+
#include "cppgc/source-location.h"
|
10
11
|
#include "v8-platform.h" // NOLINT(build/include_directory)
|
11
12
|
#include "v8config.h" // NOLINT(build/include_directory)
|
12
13
|
|
@@ -145,9 +146,11 @@ V8_EXPORT void ShutdownProcess();
|
|
145
146
|
|
146
147
|
namespace internal {
|
147
148
|
|
148
|
-
V8_EXPORT void
|
149
|
+
V8_EXPORT void Fatal(const std::string& reason = std::string(),
|
150
|
+
const SourceLocation& = SourceLocation::Current());
|
149
151
|
|
150
152
|
} // namespace internal
|
153
|
+
|
151
154
|
} // namespace cppgc
|
152
155
|
|
153
156
|
#endif // INCLUDE_CPPGC_PLATFORM_H_
|
@@ -6,23 +6,17 @@
|
|
6
6
|
#define INCLUDE_CPPGC_PREFINALIZER_H_
|
7
7
|
|
8
8
|
#include "cppgc/internal/compiler-specific.h"
|
9
|
-
#include "cppgc/internal/prefinalizer-handler.h"
|
10
9
|
#include "cppgc/liveness-broker.h"
|
11
10
|
|
12
11
|
namespace cppgc {
|
13
12
|
|
14
13
|
namespace internal {
|
15
14
|
|
16
|
-
|
17
|
-
class PrefinalizerRegistration final {
|
15
|
+
class V8_EXPORT PrefinalizerRegistration final {
|
18
16
|
public:
|
19
|
-
|
20
|
-
static_assert(sizeof(&T::InvokePreFinalizer) > 0,
|
21
|
-
"USING_PRE_FINALIZER(T) must be defined.");
|
17
|
+
using Callback = bool (*)(const cppgc::LivenessBroker&, void*);
|
22
18
|
|
23
|
-
|
24
|
-
{self, T::InvokePreFinalizer});
|
25
|
-
}
|
19
|
+
PrefinalizerRegistration(void*, Callback);
|
26
20
|
|
27
21
|
void* operator new(size_t, void* location) = delete;
|
28
22
|
void* operator new(size_t) = delete;
|
@@ -30,6 +24,35 @@ class PrefinalizerRegistration final {
|
|
30
24
|
|
31
25
|
} // namespace internal
|
32
26
|
|
27
|
+
/**
|
28
|
+
* Macro must be used in the private section of `Class` and registers a
|
29
|
+
* prefinalization callback `void Class::PreFinalizer()`. The callback is
|
30
|
+
* invoked on garbage collection after the collector has found an object to be
|
31
|
+
* dead.
|
32
|
+
*
|
33
|
+
* Callback properties:
|
34
|
+
* - The callback is invoked before a possible destructor for the corresponding
|
35
|
+
* object.
|
36
|
+
* - The callback may access the whole object graph, irrespective of whether
|
37
|
+
* objects are considered dead or alive.
|
38
|
+
* - The callback is invoked on the same thread as the object was created on.
|
39
|
+
*
|
40
|
+
* Example:
|
41
|
+
* \code
|
42
|
+
* class WithPrefinalizer : public GarbageCollected<WithPrefinalizer> {
|
43
|
+
* CPPGC_USING_PRE_FINALIZER(WithPrefinalizer, Dispose);
|
44
|
+
*
|
45
|
+
* public:
|
46
|
+
* void Trace(Visitor*) const {}
|
47
|
+
* void Dispose() { prefinalizer_called = true; }
|
48
|
+
* ~WithPrefinalizer() {
|
49
|
+
* // prefinalizer_called == true
|
50
|
+
* }
|
51
|
+
* private:
|
52
|
+
* bool prefinalizer_called = false;
|
53
|
+
* };
|
54
|
+
* \endcode
|
55
|
+
*/
|
33
56
|
#define CPPGC_USING_PRE_FINALIZER(Class, PreFinalizer) \
|
34
57
|
public: \
|
35
58
|
static bool InvokePreFinalizer(const cppgc::LivenessBroker& liveness_broker, \
|
@@ -38,13 +61,13 @@ class PrefinalizerRegistration final {
|
|
38
61
|
"Only garbage collected objects can have prefinalizers"); \
|
39
62
|
Class* self = static_cast<Class*>(object); \
|
40
63
|
if (liveness_broker.IsHeapObjectAlive(self)) return false; \
|
41
|
-
self->
|
64
|
+
self->PreFinalizer(); \
|
42
65
|
return true; \
|
43
66
|
} \
|
44
67
|
\
|
45
68
|
private: \
|
46
|
-
CPPGC_NO_UNIQUE_ADDRESS cppgc::internal::PrefinalizerRegistration
|
47
|
-
prefinalizer_dummy_{this};
|
69
|
+
CPPGC_NO_UNIQUE_ADDRESS cppgc::internal::PrefinalizerRegistration \
|
70
|
+
prefinalizer_dummy_{this, Class::InvokePreFinalizer}; \
|
48
71
|
static_assert(true, "Force semicolon.")
|
49
72
|
|
50
73
|
} // namespace cppgc
|
@@ -19,8 +19,13 @@ class HeapHandle;
|
|
19
19
|
namespace testing {
|
20
20
|
|
21
21
|
/**
|
22
|
-
* Overrides the state of the stack with the provided value.
|
23
|
-
*
|
22
|
+
* Overrides the state of the stack with the provided value. Parameters passed
|
23
|
+
* to explicit garbage collection calls still take precedence. Must not be
|
24
|
+
* nested.
|
25
|
+
*
|
26
|
+
* This scope is useful to make the garbage collector consider the stack when
|
27
|
+
* tasks that invoke garbage collection (through the provided platform) contain
|
28
|
+
* interesting pointers on its stack.
|
24
29
|
*/
|
25
30
|
class V8_EXPORT V8_NODISCARD OverrideEmbedderStackStateScope final {
|
26
31
|
CPPGC_STACK_ALLOCATED();
|
@@ -93,6 +98,8 @@ class V8_EXPORT StandaloneTestingHeap final {
|
|
93
98
|
HeapHandle& heap_handle_;
|
94
99
|
};
|
95
100
|
|
101
|
+
V8_EXPORT bool IsHeapObjectOld(void*);
|
102
|
+
|
96
103
|
} // namespace testing
|
97
104
|
} // namespace cppgc
|
98
105
|
|
@@ -24,14 +24,6 @@ class StrongMemberTag;
|
|
24
24
|
class UntracedMemberTag;
|
25
25
|
class WeakMemberTag;
|
26
26
|
|
27
|
-
// Pre-C++17 custom implementation of std::void_t.
|
28
|
-
template <typename... Ts>
|
29
|
-
struct make_void {
|
30
|
-
typedef void type;
|
31
|
-
};
|
32
|
-
template <typename... Ts>
|
33
|
-
using void_t = typename make_void<Ts...>::type;
|
34
|
-
|
35
27
|
// Not supposed to be specialized by the user.
|
36
28
|
template <typename T>
|
37
29
|
struct IsWeak : std::false_type {};
|
@@ -42,7 +34,7 @@ template <typename T, typename = void>
|
|
42
34
|
struct IsTraceMethodConst : std::false_type {};
|
43
35
|
|
44
36
|
template <typename T>
|
45
|
-
struct IsTraceMethodConst<T, void_t<decltype(std::declval<const T>().Trace(
|
37
|
+
struct IsTraceMethodConst<T, std::void_t<decltype(std::declval<const T>().Trace(
|
46
38
|
std::declval<Visitor*>()))>> : std::true_type {
|
47
39
|
};
|
48
40
|
|
@@ -53,7 +45,7 @@ struct IsTraceable : std::false_type {
|
|
53
45
|
|
54
46
|
template <typename T>
|
55
47
|
struct IsTraceable<
|
56
|
-
T, void_t<decltype(std::declval<T>().Trace(std::declval<Visitor*>()))>>
|
48
|
+
T, std::void_t<decltype(std::declval<T>().Trace(std::declval<Visitor*>()))>>
|
57
49
|
: std::true_type {
|
58
50
|
// All Trace methods should be marked as const. If an object of type
|
59
51
|
// 'T' is traceable then any object of type 'const T' should also
|
@@ -72,8 +64,8 @@ struct HasGarbageCollectedMixinTypeMarker : std::false_type {
|
|
72
64
|
|
73
65
|
template <typename T>
|
74
66
|
struct HasGarbageCollectedMixinTypeMarker<
|
75
|
-
T,
|
76
|
-
|
67
|
+
T, std::void_t<
|
68
|
+
typename std::remove_const_t<T>::IsGarbageCollectedMixinTypeMarker>>
|
77
69
|
: std::true_type {
|
78
70
|
static_assert(sizeof(T), "T must be fully defined");
|
79
71
|
};
|
@@ -85,7 +77,8 @@ struct HasGarbageCollectedTypeMarker : std::false_type {
|
|
85
77
|
|
86
78
|
template <typename T>
|
87
79
|
struct HasGarbageCollectedTypeMarker<
|
88
|
-
T,
|
80
|
+
T,
|
81
|
+
std::void_t<typename std::remove_const_t<T>::IsGarbageCollectedTypeMarker>>
|
89
82
|
: std::true_type {
|
90
83
|
static_assert(sizeof(T), "T must be fully defined");
|
91
84
|
};
|
@@ -12,6 +12,7 @@
|
|
12
12
|
#include "cppgc/internal/pointer-policies.h"
|
13
13
|
#include "cppgc/liveness-broker.h"
|
14
14
|
#include "cppgc/member.h"
|
15
|
+
#include "cppgc/sentinel-pointer.h"
|
15
16
|
#include "cppgc/source-location.h"
|
16
17
|
#include "cppgc/trace-trait.h"
|
17
18
|
#include "cppgc/type-traits.h"
|
@@ -318,10 +319,10 @@ class V8_EXPORT Visitor {
|
|
318
319
|
template <typename PointerType>
|
319
320
|
static void HandleWeak(const LivenessBroker& info, const void* object) {
|
320
321
|
const PointerType* weak = static_cast<const PointerType*>(object);
|
322
|
+
auto* raw_ptr = weak->GetFromGC();
|
321
323
|
// Sentinel values are preserved for weak pointers.
|
322
|
-
if (
|
323
|
-
|
324
|
-
if (!info.IsHeapObjectAlive(raw)) {
|
324
|
+
if (raw_ptr == kSentinelPointer) return;
|
325
|
+
if (!info.IsHeapObjectAlive(raw_ptr)) {
|
325
326
|
weak->ClearFromGC();
|
326
327
|
}
|
327
328
|
}
|
@@ -335,11 +336,11 @@ class V8_EXPORT Visitor {
|
|
335
336
|
static_assert(internal::IsGarbageCollectedOrMixinType<PointeeType>::value,
|
336
337
|
"Persistent's pointee type must be GarbageCollected or "
|
337
338
|
"GarbageCollectedMixin");
|
338
|
-
|
339
|
+
auto* ptr = p.GetFromGC();
|
340
|
+
if (!ptr) {
|
339
341
|
return;
|
340
342
|
}
|
341
|
-
VisitRoot(
|
342
|
-
loc);
|
343
|
+
VisitRoot(ptr, TraceTrait<PointeeType>::GetTraceDescriptor(ptr), loc);
|
343
344
|
}
|
344
345
|
|
345
346
|
template <
|
@@ -354,7 +355,8 @@ class V8_EXPORT Visitor {
|
|
354
355
|
"GarbageCollectedMixin");
|
355
356
|
static_assert(!internal::IsAllocatedOnCompactableSpace<PointeeType>::value,
|
356
357
|
"Weak references to compactable objects are not allowed");
|
357
|
-
|
358
|
+
auto* ptr = p.GetFromGC();
|
359
|
+
VisitWeakRoot(ptr, TraceTrait<PointeeType>::GetTraceDescriptor(ptr),
|
358
360
|
&HandleWeak<WeakPersistent>, &p, loc);
|
359
361
|
}
|
360
362
|
|
@@ -89,17 +89,6 @@ V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform* platform,
|
|
89
89
|
v8::Isolate* isolate,
|
90
90
|
double idle_time_in_seconds);
|
91
91
|
|
92
|
-
/**
|
93
|
-
* Attempts to set the tracing controller for the given platform.
|
94
|
-
*
|
95
|
-
* The |platform| has to be created using |NewDefaultPlatform|.
|
96
|
-
*
|
97
|
-
*/
|
98
|
-
V8_DEPRECATE_SOON("Access the DefaultPlatform directly")
|
99
|
-
V8_PLATFORM_EXPORT void SetTracingController(
|
100
|
-
v8::Platform* platform,
|
101
|
-
v8::platform::tracing::TracingController* tracing_controller);
|
102
|
-
|
103
92
|
/**
|
104
93
|
* Notifies the given platform about the Isolate getting deleted soon. Has to be
|
105
94
|
* called for all Isolates which are deleted - unless we're shutting down the
|