@downdraft/native-mobile-android-arm64 0.0.0 → 0.1.0
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/include/node/cppgc/allocation.h +308 -0
- package/include/node/cppgc/common.h +28 -0
- package/include/node/cppgc/cross-thread-persistent.h +462 -0
- package/include/node/cppgc/custom-space.h +97 -0
- package/include/node/cppgc/default-platform.h +68 -0
- package/include/node/cppgc/explicit-management.h +100 -0
- package/include/node/cppgc/garbage-collected.h +114 -0
- package/include/node/cppgc/heap-consistency.h +309 -0
- package/include/node/cppgc/heap-handle.h +48 -0
- package/include/node/cppgc/heap-state.h +82 -0
- package/include/node/cppgc/heap-statistics.h +126 -0
- package/include/node/cppgc/heap.h +202 -0
- package/include/node/cppgc/internal/api-constants.h +75 -0
- package/include/node/cppgc/internal/atomic-entry-flag.h +48 -0
- package/include/node/cppgc/internal/base-page-handle.h +43 -0
- package/include/node/cppgc/internal/caged-heap-local-data.h +117 -0
- package/include/node/cppgc/internal/caged-heap.h +64 -0
- package/include/node/cppgc/internal/compiler-specific.h +46 -0
- package/include/node/cppgc/internal/conditional-stack-allocated.h +41 -0
- package/include/node/cppgc/internal/finalizer-trait.h +93 -0
- package/include/node/cppgc/internal/gc-info.h +150 -0
- package/include/node/cppgc/internal/logging.h +50 -0
- package/include/node/cppgc/internal/member-storage.h +305 -0
- package/include/node/cppgc/internal/name-trait.h +141 -0
- package/include/node/cppgc/internal/persistent-node.h +219 -0
- package/include/node/cppgc/internal/pointer-policies.h +280 -0
- package/include/node/cppgc/internal/write-barrier.h +487 -0
- package/include/node/cppgc/liveness-broker.h +78 -0
- package/include/node/cppgc/macros.h +56 -0
- package/include/node/cppgc/member.h +669 -0
- package/include/node/cppgc/name-provider.h +75 -0
- package/include/node/cppgc/object-size-trait.h +58 -0
- package/include/node/cppgc/persistent.h +376 -0
- package/include/node/cppgc/platform.h +174 -0
- package/include/node/cppgc/prefinalizer.h +75 -0
- package/include/node/cppgc/process-heap-statistics.h +36 -0
- package/include/node/cppgc/sentinel-pointer.h +39 -0
- package/include/node/cppgc/source-location.h +16 -0
- package/include/node/cppgc/tagged-member.h +114 -0
- package/include/node/cppgc/testing.h +106 -0
- package/include/node/cppgc/trace-trait.h +127 -0
- package/include/node/cppgc/type-traits.h +272 -0
- package/include/node/cppgc/visitor.h +534 -0
- package/include/node/js_native_api.h +634 -0
- package/include/node/js_native_api_types.h +244 -0
- package/include/node/libplatform/libplatform-export.h +29 -0
- package/include/node/libplatform/libplatform.h +112 -0
- package/include/node/libplatform/v8-tracing.h +343 -0
- package/include/node/node.h +1744 -0
- package/include/node/node_api.h +265 -0
- package/include/node/node_api_types.h +58 -0
- package/include/node/node_buffer.h +94 -0
- package/include/node/node_object_wrap.h +145 -0
- package/include/node/node_version.h +116 -0
- package/include/node/uv/aix.h +32 -0
- package/include/node/uv/bsd.h +34 -0
- package/include/node/uv/darwin.h +61 -0
- package/include/node/uv/errno.h +483 -0
- package/include/node/uv/linux.h +34 -0
- package/include/node/uv/os390.h +33 -0
- package/include/node/uv/posix.h +31 -0
- package/include/node/uv/sunos.h +44 -0
- package/include/node/uv/threadpool.h +37 -0
- package/include/node/uv/tree.h +521 -0
- package/include/node/uv/unix.h +509 -0
- package/include/node/uv/version.h +43 -0
- package/include/node/uv/win.h +698 -0
- package/include/node/uv.h +1994 -0
- package/include/node/v8-array-buffer.h +646 -0
- package/include/node/v8-callbacks.h +533 -0
- package/include/node/v8-container.h +183 -0
- package/include/node/v8-context.h +580 -0
- package/include/node/v8-cpp-heap-external.h +56 -0
- package/include/node/v8-cppgc.h +194 -0
- package/include/node/v8-data.h +96 -0
- package/include/node/v8-date.h +57 -0
- package/include/node/v8-debug.h +210 -0
- package/include/node/v8-embedder-heap.h +54 -0
- package/include/node/v8-embedder-state-scope.h +52 -0
- package/include/node/v8-exception.h +298 -0
- package/include/node/v8-extension.h +60 -0
- package/include/node/v8-external-memory-accounter.h +60 -0
- package/include/node/v8-external.h +73 -0
- package/include/node/v8-fast-api-calls.h +784 -0
- package/include/node/v8-forward.h +82 -0
- package/include/node/v8-function-callback.h +708 -0
- package/include/node/v8-function.h +148 -0
- package/include/node/v8-handle-base.h +155 -0
- package/include/node/v8-initialization.h +343 -0
- package/include/node/v8-inspector-protocol.h +13 -0
- package/include/node/v8-inspector.h +458 -0
- package/include/node/v8-internal.h +1827 -0
- package/include/node/v8-isolate.h +1925 -0
- package/include/node/v8-json.h +54 -0
- package/include/node/v8-local-handle.h +884 -0
- package/include/node/v8-locker.h +138 -0
- package/include/node/v8-maybe.h +185 -0
- package/include/node/v8-memory-span.h +273 -0
- package/include/node/v8-message.h +215 -0
- package/include/node/v8-metrics.h +273 -0
- package/include/node/v8-microtask-queue.h +152 -0
- package/include/node/v8-microtask.h +28 -0
- package/include/node/v8-object.h +1134 -0
- package/include/node/v8-persistent-handle.h +556 -0
- package/include/node/v8-platform.h +1552 -0
- package/include/node/v8-primitive-object.h +118 -0
- package/include/node/v8-primitive.h +1056 -0
- package/include/node/v8-profiler.h +1401 -0
- package/include/node/v8-promise.h +185 -0
- package/include/node/v8-proxy.h +49 -0
- package/include/node/v8-regexp.h +105 -0
- package/include/node/v8-sandbox.h +170 -0
- package/include/node/v8-script.h +996 -0
- package/include/node/v8-snapshot.h +302 -0
- package/include/node/v8-source-location.h +91 -0
- package/include/node/v8-statistics.h +246 -0
- package/include/node/v8-template.h +1096 -0
- package/include/node/v8-trace-categories.h +28 -0
- package/include/node/v8-traced-handle.h +420 -0
- package/include/node/v8-typed-array.h +386 -0
- package/include/node/v8-unwinder-state.h +30 -0
- package/include/node/v8-unwinder.h +146 -0
- package/include/node/v8-util.h +549 -0
- package/include/node/v8-value-serializer-version.h +24 -0
- package/include/node/v8-value-serializer.h +316 -0
- package/include/node/v8-value.h +674 -0
- package/include/node/v8-version-string.h +38 -0
- package/include/node/v8-version.h +20 -0
- package/include/node/v8-wasm-trap-handler-posix.h +31 -0
- package/include/node/v8-wasm-trap-handler-win.h +28 -0
- package/include/node/v8-wasm.h +325 -0
- package/include/node/v8-weak-callback-info.h +88 -0
- package/include/node/v8.h +88 -0
- package/include/node/v8config.h +1077 -0
- package/lib/libc++_shared.so +0 -0
- package/lib/libnode.so +4 -0
- package/package.json +23 -3
|
@@ -0,0 +1,75 @@
|
|
|
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_PREFINALIZER_H_
|
|
6
|
+
#define INCLUDE_CPPGC_PREFINALIZER_H_
|
|
7
|
+
|
|
8
|
+
#include "cppgc/internal/compiler-specific.h"
|
|
9
|
+
#include "cppgc/liveness-broker.h"
|
|
10
|
+
|
|
11
|
+
namespace cppgc {
|
|
12
|
+
|
|
13
|
+
namespace internal {
|
|
14
|
+
|
|
15
|
+
class V8_EXPORT PrefinalizerRegistration final {
|
|
16
|
+
public:
|
|
17
|
+
using Callback = bool (*)(const cppgc::LivenessBroker&, void*);
|
|
18
|
+
|
|
19
|
+
PrefinalizerRegistration(void*, Callback);
|
|
20
|
+
|
|
21
|
+
void* operator new(size_t, void* location) = delete;
|
|
22
|
+
void* operator new(size_t) = delete;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} // namespace internal
|
|
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
|
+
*/
|
|
56
|
+
#define CPPGC_USING_PRE_FINALIZER(Class, PreFinalizer) \
|
|
57
|
+
public: \
|
|
58
|
+
static bool InvokePreFinalizer(const cppgc::LivenessBroker& liveness_broker, \
|
|
59
|
+
void* object) { \
|
|
60
|
+
static_assert(cppgc::IsGarbageCollectedOrMixinTypeV<Class>, \
|
|
61
|
+
"Only garbage collected objects can have prefinalizers"); \
|
|
62
|
+
Class* self = static_cast<Class*>(object); \
|
|
63
|
+
if (liveness_broker.IsHeapObjectAlive(self)) return false; \
|
|
64
|
+
self->PreFinalizer(); \
|
|
65
|
+
return true; \
|
|
66
|
+
} \
|
|
67
|
+
\
|
|
68
|
+
private: \
|
|
69
|
+
CPPGC_NO_UNIQUE_ADDRESS cppgc::internal::PrefinalizerRegistration \
|
|
70
|
+
prefinalizer_dummy_{this, Class::InvokePreFinalizer}; \
|
|
71
|
+
static_assert(true, "Force semicolon.")
|
|
72
|
+
|
|
73
|
+
} // namespace cppgc
|
|
74
|
+
|
|
75
|
+
#endif // INCLUDE_CPPGC_PREFINALIZER_H_
|
|
@@ -0,0 +1,36 @@
|
|
|
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_PROCESS_HEAP_STATISTICS_H_
|
|
6
|
+
#define INCLUDE_CPPGC_PROCESS_HEAP_STATISTICS_H_
|
|
7
|
+
|
|
8
|
+
#include <atomic>
|
|
9
|
+
#include <cstddef>
|
|
10
|
+
|
|
11
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
12
|
+
|
|
13
|
+
namespace cppgc {
|
|
14
|
+
namespace internal {
|
|
15
|
+
class ProcessHeapStatisticsUpdater;
|
|
16
|
+
} // namespace internal
|
|
17
|
+
|
|
18
|
+
class V8_EXPORT ProcessHeapStatistics final {
|
|
19
|
+
public:
|
|
20
|
+
static size_t TotalAllocatedObjectSize() {
|
|
21
|
+
return total_allocated_object_size_.load(std::memory_order_relaxed);
|
|
22
|
+
}
|
|
23
|
+
static size_t TotalAllocatedSpace() {
|
|
24
|
+
return total_allocated_space_.load(std::memory_order_relaxed);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private:
|
|
28
|
+
static std::atomic_size_t total_allocated_space_;
|
|
29
|
+
static std::atomic_size_t total_allocated_object_size_;
|
|
30
|
+
|
|
31
|
+
friend class internal::ProcessHeapStatisticsUpdater;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
} // namespace cppgc
|
|
35
|
+
|
|
36
|
+
#endif // INCLUDE_CPPGC_PROCESS_HEAP_STATISTICS_H_
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright 2021 the V8 project authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#ifndef INCLUDE_CPPGC_SENTINEL_POINTER_H_
|
|
6
|
+
#define INCLUDE_CPPGC_SENTINEL_POINTER_H_
|
|
7
|
+
|
|
8
|
+
#include <cstdint>
|
|
9
|
+
|
|
10
|
+
#include "cppgc/internal/api-constants.h"
|
|
11
|
+
|
|
12
|
+
namespace cppgc {
|
|
13
|
+
namespace internal {
|
|
14
|
+
|
|
15
|
+
// Special tag type used to denote some sentinel member. The semantics of the
|
|
16
|
+
// sentinel is defined by the embedder.
|
|
17
|
+
struct SentinelPointer {
|
|
18
|
+
#if defined(CPPGC_POINTER_COMPRESSION)
|
|
19
|
+
static constexpr intptr_t kSentinelValue =
|
|
20
|
+
1 << api_constants::kPointerCompressionShift;
|
|
21
|
+
#else // !defined(CPPGC_POINTER_COMPRESSION)
|
|
22
|
+
static constexpr intptr_t kSentinelValue = 0b10;
|
|
23
|
+
#endif // !defined(CPPGC_POINTER_COMPRESSION)
|
|
24
|
+
template <typename T>
|
|
25
|
+
operator T*() const {
|
|
26
|
+
return reinterpret_cast<T*>(kSentinelValue);
|
|
27
|
+
}
|
|
28
|
+
// Hidden friends.
|
|
29
|
+
friend bool operator==(SentinelPointer, SentinelPointer) { return true; }
|
|
30
|
+
friend bool operator!=(SentinelPointer, SentinelPointer) { return false; }
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
} // namespace internal
|
|
34
|
+
|
|
35
|
+
constexpr internal::SentinelPointer kSentinelPointer;
|
|
36
|
+
|
|
37
|
+
} // namespace cppgc
|
|
38
|
+
|
|
39
|
+
#endif // INCLUDE_CPPGC_SENTINEL_POINTER_H_
|
|
@@ -0,0 +1,16 @@
|
|
|
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_SOURCE_LOCATION_H_
|
|
6
|
+
#define INCLUDE_CPPGC_SOURCE_LOCATION_H_
|
|
7
|
+
|
|
8
|
+
#include "v8-source-location.h"
|
|
9
|
+
|
|
10
|
+
namespace cppgc {
|
|
11
|
+
|
|
12
|
+
using SourceLocation = v8::SourceLocation;
|
|
13
|
+
|
|
14
|
+
} // namespace cppgc
|
|
15
|
+
|
|
16
|
+
#endif // INCLUDE_CPPGC_SOURCE_LOCATION_H_
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Copyright 2025 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_TAGGED_MEMBER_H_
|
|
6
|
+
#define INCLUDE_CPPGC_TAGGED_MEMBER_H_
|
|
7
|
+
|
|
8
|
+
#include <atomic>
|
|
9
|
+
#include <concepts>
|
|
10
|
+
#include <cstddef>
|
|
11
|
+
#include <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "cppgc/internal/api-constants.h"
|
|
14
|
+
#include "cppgc/macros.h"
|
|
15
|
+
#include "cppgc/member.h"
|
|
16
|
+
#include "cppgc/visitor.h"
|
|
17
|
+
|
|
18
|
+
namespace cppgc::subtle {
|
|
19
|
+
|
|
20
|
+
// The class allows to store a Member along with a single bit tag. It uses
|
|
21
|
+
// distinct tag types, Tag1 and Tag2, to represent the two states of the tag.
|
|
22
|
+
// The tag is stored in the least significant bit of the pointer.
|
|
23
|
+
//
|
|
24
|
+
// Example usage:
|
|
25
|
+
// struct ParentTag {};
|
|
26
|
+
// struct ShadowHostTag {};
|
|
27
|
+
//
|
|
28
|
+
// /* Constructs a member with the pointer to parent tag: */
|
|
29
|
+
// TaggedUncompressedMember<Node, ParentTag, ShadowHostTag>
|
|
30
|
+
// m(ParentTag{}, parent);
|
|
31
|
+
template <typename Pointee, typename Tag1, typename Tag2>
|
|
32
|
+
class TaggedUncompressedMember final {
|
|
33
|
+
CPPGC_DISALLOW_NEW();
|
|
34
|
+
static constexpr uintptr_t kTagBit = 0b1;
|
|
35
|
+
static_assert(kTagBit < internal::api_constants::kAllocationGranularity,
|
|
36
|
+
"The tag must live in the alignment bits of the pointer.");
|
|
37
|
+
|
|
38
|
+
public:
|
|
39
|
+
TaggedUncompressedMember(Tag1, Pointee* ptr) : ptr_(ptr) {}
|
|
40
|
+
TaggedUncompressedMember(Tag2, Pointee* ptr)
|
|
41
|
+
: ptr_(reinterpret_cast<Pointee*>(reinterpret_cast<uintptr_t>(ptr) |
|
|
42
|
+
kTagBit)) {}
|
|
43
|
+
|
|
44
|
+
template <typename Tag>
|
|
45
|
+
Pointee* GetAs() const {
|
|
46
|
+
auto* raw = ptr_.Get();
|
|
47
|
+
if constexpr (std::same_as<Tag, Tag1>) {
|
|
48
|
+
CPPGC_DCHECK(Is<Tag1>());
|
|
49
|
+
return raw;
|
|
50
|
+
} else {
|
|
51
|
+
static_assert(std::same_as<Tag, Tag2>);
|
|
52
|
+
CPPGC_DCHECK(Is<Tag2>());
|
|
53
|
+
return GetUntagged();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
template <typename Tag>
|
|
58
|
+
Pointee* TryGetAs() const {
|
|
59
|
+
auto* raw = ptr_.Get();
|
|
60
|
+
if constexpr (std::same_as<Tag, Tag1>) {
|
|
61
|
+
return (reinterpret_cast<uintptr_t>(raw) & kTagBit) ? nullptr : raw;
|
|
62
|
+
} else {
|
|
63
|
+
static_assert(std::same_as<Tag, Tag2>);
|
|
64
|
+
return (reinterpret_cast<uintptr_t>(raw) & kTagBit)
|
|
65
|
+
? reinterpret_cast<Pointee*>(reinterpret_cast<uintptr_t>(raw) &
|
|
66
|
+
~kTagBit)
|
|
67
|
+
: nullptr;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
Pointee* GetUntagged() const {
|
|
72
|
+
return reinterpret_cast<Pointee*>(reinterpret_cast<uintptr_t>(ptr_.Get()) &
|
|
73
|
+
~kTagBit);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
template <typename Tag>
|
|
77
|
+
void SetAs(Pointee* pointee) {
|
|
78
|
+
if constexpr (std::same_as<Tag, Tag1>) {
|
|
79
|
+
ptr_ = pointee;
|
|
80
|
+
} else {
|
|
81
|
+
static_assert(std::same_as<Tag, Tag2>);
|
|
82
|
+
ptr_ = reinterpret_cast<Pointee*>(reinterpret_cast<uintptr_t>(pointee) |
|
|
83
|
+
kTagBit);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
template <typename Tag>
|
|
88
|
+
bool Is() const {
|
|
89
|
+
const bool tag_set = reinterpret_cast<uintptr_t>(ptr_.Get()) & kTagBit;
|
|
90
|
+
if constexpr (std::same_as<Tag, Tag1>) {
|
|
91
|
+
return !tag_set;
|
|
92
|
+
} else {
|
|
93
|
+
static_assert(std::same_as<Tag, Tag2>);
|
|
94
|
+
return tag_set;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
void Trace(Visitor* v) const {
|
|
99
|
+
// Construct an untagged pointer and pass it to Visitor::Trace(). The plugin
|
|
100
|
+
// would warn that ptr_ is untraced, which is why CPPGC_PLUGIN_IGNORE is
|
|
101
|
+
// used.
|
|
102
|
+
auto* untagged = reinterpret_cast<Pointee*>(
|
|
103
|
+
reinterpret_cast<uintptr_t>(ptr_.GetRawAtomic()) & ~kTagBit);
|
|
104
|
+
UncompressedMember<Pointee> temp(untagged);
|
|
105
|
+
v->Trace(temp);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private:
|
|
109
|
+
CPPGC_PLUGIN_IGNORE("See Trace()") UncompressedMember<Pointee> ptr_;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
} // namespace cppgc::subtle
|
|
113
|
+
|
|
114
|
+
#endif // INCLUDE_CPPGC_TAGGED_MEMBER_H_
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright 2021 the V8 project authors. All rights reserved.
|
|
2
|
+
// Use of this source code is governed by a BSD-style license that can be
|
|
3
|
+
// found in the LICENSE file.
|
|
4
|
+
|
|
5
|
+
#ifndef INCLUDE_CPPGC_TESTING_H_
|
|
6
|
+
#define INCLUDE_CPPGC_TESTING_H_
|
|
7
|
+
|
|
8
|
+
#include "cppgc/common.h"
|
|
9
|
+
#include "cppgc/macros.h"
|
|
10
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
11
|
+
|
|
12
|
+
namespace cppgc {
|
|
13
|
+
|
|
14
|
+
class HeapHandle;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Namespace contains testing helpers.
|
|
18
|
+
*/
|
|
19
|
+
namespace testing {
|
|
20
|
+
|
|
21
|
+
/**
|
|
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.
|
|
29
|
+
*/
|
|
30
|
+
class V8_EXPORT V8_NODISCARD OverrideEmbedderStackStateScope final {
|
|
31
|
+
CPPGC_STACK_ALLOCATED();
|
|
32
|
+
|
|
33
|
+
public:
|
|
34
|
+
/**
|
|
35
|
+
* Constructs a scoped object that automatically enters and leaves the scope.
|
|
36
|
+
*
|
|
37
|
+
* \param heap_handle The corresponding heap.
|
|
38
|
+
*/
|
|
39
|
+
explicit OverrideEmbedderStackStateScope(HeapHandle& heap_handle,
|
|
40
|
+
EmbedderStackState state);
|
|
41
|
+
~OverrideEmbedderStackStateScope();
|
|
42
|
+
|
|
43
|
+
OverrideEmbedderStackStateScope(const OverrideEmbedderStackStateScope&) =
|
|
44
|
+
delete;
|
|
45
|
+
OverrideEmbedderStackStateScope& operator=(
|
|
46
|
+
const OverrideEmbedderStackStateScope&) = delete;
|
|
47
|
+
|
|
48
|
+
private:
|
|
49
|
+
HeapHandle& heap_handle_;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Testing interface for managed heaps that allows for controlling garbage
|
|
54
|
+
* collection timings. Embedders should use this class when testing the
|
|
55
|
+
* interaction of their code with incremental/concurrent garbage collection.
|
|
56
|
+
*/
|
|
57
|
+
class V8_EXPORT StandaloneTestingHeap final {
|
|
58
|
+
public:
|
|
59
|
+
explicit StandaloneTestingHeap(HeapHandle&);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Start an incremental garbage collection.
|
|
63
|
+
*/
|
|
64
|
+
void StartGarbageCollection();
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Perform an incremental step. This will also schedule concurrent steps if
|
|
68
|
+
* needed.
|
|
69
|
+
*
|
|
70
|
+
* \param stack_state The state of the stack during the step.
|
|
71
|
+
*/
|
|
72
|
+
bool PerformMarkingStep(EmbedderStackState stack_state);
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Finalize the current garbage collection cycle atomically.
|
|
76
|
+
* Assumes that garbage collection is in progress.
|
|
77
|
+
*
|
|
78
|
+
* \param stack_state The state of the stack for finalizing the garbage
|
|
79
|
+
* collection cycle.
|
|
80
|
+
*/
|
|
81
|
+
void FinalizeGarbageCollection(EmbedderStackState stack_state);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Toggle main thread marking on/off. Allows to stress concurrent marking
|
|
85
|
+
* (e.g. to better detect data races).
|
|
86
|
+
*
|
|
87
|
+
* \param should_mark Denotes whether the main thread should contribute to
|
|
88
|
+
* marking. Defaults to true.
|
|
89
|
+
*/
|
|
90
|
+
void ToggleMainThreadMarking(bool should_mark);
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Force enable compaction for the next garbage collection cycle.
|
|
94
|
+
*/
|
|
95
|
+
void ForceCompactionForNextGarbageCollection();
|
|
96
|
+
|
|
97
|
+
private:
|
|
98
|
+
HeapHandle& heap_handle_;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
V8_EXPORT bool IsHeapObjectOld(void*);
|
|
102
|
+
|
|
103
|
+
} // namespace testing
|
|
104
|
+
} // namespace cppgc
|
|
105
|
+
|
|
106
|
+
#endif // INCLUDE_CPPGC_TESTING_H_
|
|
@@ -0,0 +1,127 @@
|
|
|
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_TRACE_TRAIT_H_
|
|
6
|
+
#define INCLUDE_CPPGC_TRACE_TRAIT_H_
|
|
7
|
+
|
|
8
|
+
#include <type_traits>
|
|
9
|
+
|
|
10
|
+
#include "cppgc/type-traits.h"
|
|
11
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
|
12
|
+
|
|
13
|
+
namespace cppgc {
|
|
14
|
+
|
|
15
|
+
class Visitor;
|
|
16
|
+
|
|
17
|
+
namespace internal {
|
|
18
|
+
|
|
19
|
+
class RootVisitor;
|
|
20
|
+
|
|
21
|
+
using TraceRootCallback = void (*)(RootVisitor&, const void* object);
|
|
22
|
+
|
|
23
|
+
// Implementation of the default TraceTrait handling GarbageCollected and
|
|
24
|
+
// GarbageCollectedMixin.
|
|
25
|
+
template <typename T,
|
|
26
|
+
bool = IsGarbageCollectedMixinTypeV<std::remove_const_t<T>>>
|
|
27
|
+
struct TraceTraitImpl;
|
|
28
|
+
|
|
29
|
+
} // namespace internal
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Callback for invoking tracing on a given object.
|
|
33
|
+
*
|
|
34
|
+
* \param visitor The visitor to dispatch to.
|
|
35
|
+
* \param object The object to invoke tracing on.
|
|
36
|
+
*/
|
|
37
|
+
using TraceCallback = void (*)(Visitor* visitor, const void* object);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Describes how to trace an object, i.e., how to visit all Oilpan-relevant
|
|
41
|
+
* fields of an object.
|
|
42
|
+
*/
|
|
43
|
+
struct TraceDescriptor {
|
|
44
|
+
/**
|
|
45
|
+
* Adjusted base pointer, i.e., the pointer to the class inheriting directly
|
|
46
|
+
* from GarbageCollected, of the object that is being traced.
|
|
47
|
+
*/
|
|
48
|
+
const void* base_object_payload;
|
|
49
|
+
/**
|
|
50
|
+
* Callback for tracing the object.
|
|
51
|
+
*/
|
|
52
|
+
TraceCallback callback;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Callback for getting a TraceDescriptor for a given address.
|
|
57
|
+
*
|
|
58
|
+
* \param address Possibly inner address of an object.
|
|
59
|
+
* \returns a TraceDescriptor for the provided address.
|
|
60
|
+
*/
|
|
61
|
+
using TraceDescriptorCallback = TraceDescriptor (*)(const void* address);
|
|
62
|
+
|
|
63
|
+
namespace internal {
|
|
64
|
+
|
|
65
|
+
struct V8_EXPORT TraceTraitFromInnerAddressImpl {
|
|
66
|
+
static TraceDescriptor GetTraceDescriptor(const void* address);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Trait specifying how the garbage collector processes an object of type T.
|
|
71
|
+
*
|
|
72
|
+
* Advanced users may override handling by creating a specialization for their
|
|
73
|
+
* type.
|
|
74
|
+
*/
|
|
75
|
+
template <typename T>
|
|
76
|
+
struct TraceTraitBase {
|
|
77
|
+
static_assert(internal::IsTraceableV<T>, "T must have a Trace() method");
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Accessor for retrieving a TraceDescriptor to process an object of type T.
|
|
81
|
+
*
|
|
82
|
+
* \param self The object to be processed.
|
|
83
|
+
* \returns a TraceDescriptor to process the object.
|
|
84
|
+
*/
|
|
85
|
+
static TraceDescriptor GetTraceDescriptor(const void* self) {
|
|
86
|
+
return internal::TraceTraitImpl<T>::GetTraceDescriptor(
|
|
87
|
+
static_cast<const T*>(self));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Function invoking the tracing for an object of type T.
|
|
92
|
+
*
|
|
93
|
+
* \param visitor The visitor to dispatch to.
|
|
94
|
+
* \param self The object to invoke tracing on.
|
|
95
|
+
*/
|
|
96
|
+
static void Trace(Visitor* visitor, const void* self) {
|
|
97
|
+
static_cast<const T*>(self)->Trace(visitor);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
} // namespace internal
|
|
102
|
+
|
|
103
|
+
template <typename T>
|
|
104
|
+
struct TraceTrait : public internal::TraceTraitBase<T> {};
|
|
105
|
+
|
|
106
|
+
namespace internal {
|
|
107
|
+
|
|
108
|
+
template <typename T>
|
|
109
|
+
struct TraceTraitImpl<T, false> {
|
|
110
|
+
static_assert(IsGarbageCollectedTypeV<T>,
|
|
111
|
+
"T must be of type GarbageCollected or GarbageCollectedMixin");
|
|
112
|
+
static TraceDescriptor GetTraceDescriptor(const void* self) {
|
|
113
|
+
return {self, TraceTrait<T>::Trace};
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
template <typename T>
|
|
118
|
+
struct TraceTraitImpl<T, true> {
|
|
119
|
+
static TraceDescriptor GetTraceDescriptor(const void* self) {
|
|
120
|
+
return internal::TraceTraitFromInnerAddressImpl::GetTraceDescriptor(self);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
} // namespace internal
|
|
125
|
+
} // namespace cppgc
|
|
126
|
+
|
|
127
|
+
#endif // INCLUDE_CPPGC_TRACE_TRAIT_H_
|