aha-libv8-node 16.0.0.0-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/libv8-node/.location.yml +1 -0
- data/ext/libv8-node/location.rb +76 -0
- data/ext/libv8-node/paths.rb +30 -0
- data/lib/libv8-node.rb +1 -0
- data/lib/libv8/node.rb +11 -0
- data/lib/libv8/node/version.rb +7 -0
- data/vendor/v8/include/cppgc/allocation.h +229 -0
- data/vendor/v8/include/cppgc/common.h +29 -0
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +345 -0
- data/vendor/v8/include/cppgc/custom-space.h +97 -0
- data/vendor/v8/include/cppgc/default-platform.h +75 -0
- data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +116 -0
- data/vendor/v8/include/cppgc/heap-consistency.h +236 -0
- data/vendor/v8/include/cppgc/heap-state.h +59 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +110 -0
- data/vendor/v8/include/cppgc/heap.h +199 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +47 -0
- data/vendor/v8/include/cppgc/internal/atomic-entry-flag.h +48 -0
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +68 -0
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +38 -0
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +90 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +47 -0
- data/vendor/v8/include/cppgc/internal/logging.h +50 -0
- data/vendor/v8/include/cppgc/internal/name-trait.h +111 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +132 -0
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +143 -0
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +30 -0
- data/vendor/v8/include/cppgc/internal/write-barrier.h +390 -0
- data/vendor/v8/include/cppgc/liveness-broker.h +74 -0
- data/vendor/v8/include/cppgc/macros.h +26 -0
- data/vendor/v8/include/cppgc/member.h +271 -0
- 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 +365 -0
- data/vendor/v8/include/cppgc/platform.h +151 -0
- data/vendor/v8/include/cppgc/prefinalizer.h +52 -0
- 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 +91 -0
- data/vendor/v8/include/cppgc/testing.h +50 -0
- data/vendor/v8/include/cppgc/trace-trait.h +116 -0
- data/vendor/v8/include/cppgc/type-traits.h +228 -0
- data/vendor/v8/include/cppgc/visitor.h +340 -0
- data/vendor/v8/include/libplatform/libplatform-export.h +29 -0
- data/vendor/v8/include/libplatform/libplatform.h +117 -0
- data/vendor/v8/include/libplatform/v8-tracing.h +334 -0
- data/vendor/v8/include/v8-cppgc.h +278 -0
- data/vendor/v8/include/v8-fast-api-calls.h +419 -0
- data/vendor/v8/include/v8-inspector-protocol.h +13 -0
- data/vendor/v8/include/v8-inspector.h +336 -0
- data/vendor/v8/include/v8-internal.h +462 -0
- data/vendor/v8/include/v8-metrics.h +189 -0
- data/vendor/v8/include/v8-platform.h +710 -0
- data/vendor/v8/include/v8-profiler.h +1116 -0
- data/vendor/v8/include/v8-unwinder-state.h +30 -0
- data/vendor/v8/include/v8-util.h +652 -0
- data/vendor/v8/include/v8-value-serializer-version.h +24 -0
- data/vendor/v8/include/v8-version-string.h +38 -0
- data/vendor/v8/include/v8-version.h +20 -0
- data/vendor/v8/include/v8-wasm-trap-handler-posix.h +31 -0
- data/vendor/v8/include/v8-wasm-trap-handler-win.h +28 -0
- data/vendor/v8/include/v8.h +12479 -0
- data/vendor/v8/include/v8config.h +521 -0
- data/vendor/v8/out.gn/libv8/obj/libv8_monolith.a +0 -0
- metadata +137 -0
@@ -0,0 +1,52 @@
|
|
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/internal/prefinalizer-handler.h"
|
10
|
+
#include "cppgc/liveness-broker.h"
|
11
|
+
|
12
|
+
namespace cppgc {
|
13
|
+
|
14
|
+
namespace internal {
|
15
|
+
|
16
|
+
template <typename T>
|
17
|
+
class PrefinalizerRegistration final {
|
18
|
+
public:
|
19
|
+
explicit PrefinalizerRegistration(T* self) {
|
20
|
+
static_assert(sizeof(&T::InvokePreFinalizer) > 0,
|
21
|
+
"USING_PRE_FINALIZER(T) must be defined.");
|
22
|
+
|
23
|
+
cppgc::internal::PreFinalizerRegistrationDispatcher::RegisterPrefinalizer(
|
24
|
+
{self, T::InvokePreFinalizer});
|
25
|
+
}
|
26
|
+
|
27
|
+
void* operator new(size_t, void* location) = delete;
|
28
|
+
void* operator new(size_t) = delete;
|
29
|
+
};
|
30
|
+
|
31
|
+
} // namespace internal
|
32
|
+
|
33
|
+
#define CPPGC_USING_PRE_FINALIZER(Class, PreFinalizer) \
|
34
|
+
public: \
|
35
|
+
static bool InvokePreFinalizer(const cppgc::LivenessBroker& liveness_broker, \
|
36
|
+
void* object) { \
|
37
|
+
static_assert(cppgc::IsGarbageCollectedOrMixinTypeV<Class>, \
|
38
|
+
"Only garbage collected objects can have prefinalizers"); \
|
39
|
+
Class* self = static_cast<Class*>(object); \
|
40
|
+
if (liveness_broker.IsHeapObjectAlive(self)) return false; \
|
41
|
+
self->Class::PreFinalizer(); \
|
42
|
+
return true; \
|
43
|
+
} \
|
44
|
+
\
|
45
|
+
private: \
|
46
|
+
CPPGC_NO_UNIQUE_ADDRESS cppgc::internal::PrefinalizerRegistration<Class> \
|
47
|
+
prefinalizer_dummy_{this}; \
|
48
|
+
static_assert(true, "Force semicolon.")
|
49
|
+
|
50
|
+
} // namespace cppgc
|
51
|
+
|
52
|
+
#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,32 @@
|
|
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
|
+
namespace cppgc {
|
11
|
+
namespace internal {
|
12
|
+
|
13
|
+
// Special tag type used to denote some sentinel member. The semantics of the
|
14
|
+
// sentinel is defined by the embedder.
|
15
|
+
struct SentinelPointer {
|
16
|
+
template <typename T>
|
17
|
+
operator T*() const { // NOLINT
|
18
|
+
static constexpr intptr_t kSentinelValue = 1;
|
19
|
+
return reinterpret_cast<T*>(kSentinelValue);
|
20
|
+
}
|
21
|
+
// Hidden friends.
|
22
|
+
friend bool operator==(SentinelPointer, SentinelPointer) { return true; }
|
23
|
+
friend bool operator!=(SentinelPointer, SentinelPointer) { return false; }
|
24
|
+
};
|
25
|
+
|
26
|
+
} // namespace internal
|
27
|
+
|
28
|
+
constexpr internal::SentinelPointer kSentinelPointer;
|
29
|
+
|
30
|
+
} // namespace cppgc
|
31
|
+
|
32
|
+
#endif // INCLUDE_CPPGC_SENTINEL_POINTER_H_
|
@@ -0,0 +1,91 @@
|
|
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 <string>
|
9
|
+
|
10
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
11
|
+
|
12
|
+
#if defined(__has_builtin)
|
13
|
+
#define CPPGC_SUPPORTS_SOURCE_LOCATION \
|
14
|
+
(__has_builtin(__builtin_FUNCTION) && __has_builtin(__builtin_FILE) && \
|
15
|
+
__has_builtin(__builtin_LINE)) // NOLINT
|
16
|
+
#elif defined(V8_CC_GNU) && __GNUC__ >= 7
|
17
|
+
#define CPPGC_SUPPORTS_SOURCE_LOCATION 1
|
18
|
+
#elif defined(V8_CC_INTEL) && __ICC >= 1800
|
19
|
+
#define CPPGC_SUPPORTS_SOURCE_LOCATION 1
|
20
|
+
#else
|
21
|
+
#define CPPGC_SUPPORTS_SOURCE_LOCATION 0
|
22
|
+
#endif
|
23
|
+
|
24
|
+
namespace cppgc {
|
25
|
+
|
26
|
+
/**
|
27
|
+
* Encapsulates source location information. Mimics C++20's
|
28
|
+
* `std::source_location`.
|
29
|
+
*/
|
30
|
+
class V8_EXPORT SourceLocation final {
|
31
|
+
public:
|
32
|
+
/**
|
33
|
+
* Construct source location information corresponding to the location of the
|
34
|
+
* call site.
|
35
|
+
*/
|
36
|
+
#if CPPGC_SUPPORTS_SOURCE_LOCATION
|
37
|
+
static constexpr SourceLocation Current(
|
38
|
+
const char* function = __builtin_FUNCTION(),
|
39
|
+
const char* file = __builtin_FILE(), size_t line = __builtin_LINE()) {
|
40
|
+
return SourceLocation(function, file, line);
|
41
|
+
}
|
42
|
+
#else
|
43
|
+
static constexpr SourceLocation Current() { return SourceLocation(); }
|
44
|
+
#endif // CPPGC_SUPPORTS_SOURCE_LOCATION
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Constructs unspecified source location information.
|
48
|
+
*/
|
49
|
+
constexpr SourceLocation() = default;
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Returns the name of the function associated with the position represented
|
53
|
+
* by this object, if any.
|
54
|
+
*
|
55
|
+
* \returns the function name as cstring.
|
56
|
+
*/
|
57
|
+
constexpr const char* Function() const { return function_; }
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Returns the name of the current source file represented by this object.
|
61
|
+
*
|
62
|
+
* \returns the file name as cstring.
|
63
|
+
*/
|
64
|
+
constexpr const char* FileName() const { return file_; }
|
65
|
+
|
66
|
+
/**
|
67
|
+
* Returns the line number represented by this object.
|
68
|
+
*
|
69
|
+
* \returns the line number.
|
70
|
+
*/
|
71
|
+
constexpr size_t Line() const { return line_; }
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Returns a human-readable string representing this object.
|
75
|
+
*
|
76
|
+
* \returns a human-readable string representing source location information.
|
77
|
+
*/
|
78
|
+
std::string ToString() const;
|
79
|
+
|
80
|
+
private:
|
81
|
+
constexpr SourceLocation(const char* function, const char* file, size_t line)
|
82
|
+
: function_(function), file_(file), line_(line) {}
|
83
|
+
|
84
|
+
const char* function_ = nullptr;
|
85
|
+
const char* file_ = nullptr;
|
86
|
+
size_t line_ = 0u;
|
87
|
+
};
|
88
|
+
|
89
|
+
} // namespace cppgc
|
90
|
+
|
91
|
+
#endif // INCLUDE_CPPGC_SOURCE_LOCATION_H_
|
@@ -0,0 +1,50 @@
|
|
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. Takes precedence
|
23
|
+
* over other parameters that set the stack state. Must no be nested.
|
24
|
+
*/
|
25
|
+
class V8_EXPORT V8_NODISCARD OverrideEmbedderStackStateScope final {
|
26
|
+
CPPGC_STACK_ALLOCATED();
|
27
|
+
|
28
|
+
public:
|
29
|
+
/**
|
30
|
+
* Constructs a scoped object that automatically enters and leaves the scope.
|
31
|
+
*
|
32
|
+
* \param heap_handle The corresponding heap.
|
33
|
+
*/
|
34
|
+
explicit OverrideEmbedderStackStateScope(HeapHandle& heap_handle,
|
35
|
+
EmbedderStackState state);
|
36
|
+
~OverrideEmbedderStackStateScope();
|
37
|
+
|
38
|
+
OverrideEmbedderStackStateScope(const OverrideEmbedderStackStateScope&) =
|
39
|
+
delete;
|
40
|
+
OverrideEmbedderStackStateScope& operator=(
|
41
|
+
const OverrideEmbedderStackStateScope&) = delete;
|
42
|
+
|
43
|
+
private:
|
44
|
+
HeapHandle& heap_handle_;
|
45
|
+
};
|
46
|
+
|
47
|
+
} // namespace testing
|
48
|
+
} // namespace cppgc
|
49
|
+
|
50
|
+
#endif // INCLUDE_CPPGC_TESTING_H_
|
@@ -0,0 +1,116 @@
|
|
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
|
+
// Implementation of the default TraceTrait handling GarbageCollected and
|
20
|
+
// GarbageCollectedMixin.
|
21
|
+
template <typename T,
|
22
|
+
bool =
|
23
|
+
IsGarbageCollectedMixinTypeV<typename std::remove_const<T>::type>>
|
24
|
+
struct TraceTraitImpl;
|
25
|
+
|
26
|
+
} // namespace internal
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Callback for invoking tracing on a given object.
|
30
|
+
*
|
31
|
+
* \param visitor The visitor to dispatch to.
|
32
|
+
* \param object The object to invoke tracing on.
|
33
|
+
*/
|
34
|
+
using TraceCallback = void (*)(Visitor* visitor, const void* object);
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Describes how to trace an object, i.e., how to visit all Oilpan-relevant
|
38
|
+
* fields of an object.
|
39
|
+
*/
|
40
|
+
struct TraceDescriptor {
|
41
|
+
/**
|
42
|
+
* Adjusted base pointer, i.e., the pointer to the class inheriting directly
|
43
|
+
* from GarbageCollected, of the object that is being traced.
|
44
|
+
*/
|
45
|
+
const void* base_object_payload;
|
46
|
+
/**
|
47
|
+
* Callback for tracing the object.
|
48
|
+
*/
|
49
|
+
TraceCallback callback;
|
50
|
+
};
|
51
|
+
|
52
|
+
namespace internal {
|
53
|
+
|
54
|
+
struct V8_EXPORT TraceTraitFromInnerAddressImpl {
|
55
|
+
static TraceDescriptor GetTraceDescriptor(const void* address);
|
56
|
+
};
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Trait specifying how the garbage collector processes an object of type T.
|
60
|
+
*
|
61
|
+
* Advanced users may override handling by creating a specialization for their
|
62
|
+
* type.
|
63
|
+
*/
|
64
|
+
template <typename T>
|
65
|
+
struct TraceTraitBase {
|
66
|
+
static_assert(internal::IsTraceableV<T>, "T must have a Trace() method");
|
67
|
+
|
68
|
+
/**
|
69
|
+
* Accessor for retrieving a TraceDescriptor to process an object of type T.
|
70
|
+
*
|
71
|
+
* \param self The object to be processed.
|
72
|
+
* \returns a TraceDescriptor to process the object.
|
73
|
+
*/
|
74
|
+
static TraceDescriptor GetTraceDescriptor(const void* self) {
|
75
|
+
return internal::TraceTraitImpl<T>::GetTraceDescriptor(
|
76
|
+
static_cast<const T*>(self));
|
77
|
+
}
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Function invoking the tracing for an object of type T.
|
81
|
+
*
|
82
|
+
* \param visitor The visitor to dispatch to.
|
83
|
+
* \param self The object to invoke tracing on.
|
84
|
+
*/
|
85
|
+
static void Trace(Visitor* visitor, const void* self) {
|
86
|
+
static_cast<const T*>(self)->Trace(visitor);
|
87
|
+
}
|
88
|
+
};
|
89
|
+
|
90
|
+
} // namespace internal
|
91
|
+
|
92
|
+
template <typename T>
|
93
|
+
struct TraceTrait : public internal::TraceTraitBase<T> {};
|
94
|
+
|
95
|
+
namespace internal {
|
96
|
+
|
97
|
+
template <typename T>
|
98
|
+
struct TraceTraitImpl<T, false> {
|
99
|
+
static_assert(IsGarbageCollectedTypeV<T>,
|
100
|
+
"T must be of type GarbageCollected or GarbageCollectedMixin");
|
101
|
+
static TraceDescriptor GetTraceDescriptor(const void* self) {
|
102
|
+
return {self, TraceTrait<T>::Trace};
|
103
|
+
}
|
104
|
+
};
|
105
|
+
|
106
|
+
template <typename T>
|
107
|
+
struct TraceTraitImpl<T, true> {
|
108
|
+
static TraceDescriptor GetTraceDescriptor(const void* self) {
|
109
|
+
return internal::TraceTraitFromInnerAddressImpl::GetTraceDescriptor(self);
|
110
|
+
}
|
111
|
+
};
|
112
|
+
|
113
|
+
} // namespace internal
|
114
|
+
} // namespace cppgc
|
115
|
+
|
116
|
+
#endif // INCLUDE_CPPGC_TRACE_TRAIT_H_
|
@@ -0,0 +1,228 @@
|
|
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_TYPE_TRAITS_H_
|
6
|
+
#define INCLUDE_CPPGC_TYPE_TRAITS_H_
|
7
|
+
|
8
|
+
// This file should stay with minimal dependencies to allow embedder to check
|
9
|
+
// against Oilpan types without including any other parts.
|
10
|
+
#include <type_traits>
|
11
|
+
|
12
|
+
namespace cppgc {
|
13
|
+
|
14
|
+
class Visitor;
|
15
|
+
|
16
|
+
namespace internal {
|
17
|
+
template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
|
18
|
+
typename CheckingPolicy>
|
19
|
+
class BasicMember;
|
20
|
+
struct DijkstraWriteBarrierPolicy;
|
21
|
+
struct NoWriteBarrierPolicy;
|
22
|
+
class StrongMemberTag;
|
23
|
+
class UntracedMemberTag;
|
24
|
+
class WeakMemberTag;
|
25
|
+
|
26
|
+
// Pre-C++17 custom implementation of std::void_t.
|
27
|
+
template <typename... Ts>
|
28
|
+
struct make_void {
|
29
|
+
typedef void type;
|
30
|
+
};
|
31
|
+
template <typename... Ts>
|
32
|
+
using void_t = typename make_void<Ts...>::type;
|
33
|
+
|
34
|
+
// Not supposed to be specialized by the user.
|
35
|
+
template <typename T>
|
36
|
+
struct IsWeak : std::false_type {};
|
37
|
+
|
38
|
+
// IsTraceMethodConst is used to verify that all Trace methods are marked as
|
39
|
+
// const. It is equivalent to IsTraceable but for a non-const object.
|
40
|
+
template <typename T, typename = void>
|
41
|
+
struct IsTraceMethodConst : std::false_type {};
|
42
|
+
|
43
|
+
template <typename T>
|
44
|
+
struct IsTraceMethodConst<T, void_t<decltype(std::declval<const T>().Trace(
|
45
|
+
std::declval<Visitor*>()))>> : std::true_type {
|
46
|
+
};
|
47
|
+
|
48
|
+
template <typename T, typename = void>
|
49
|
+
struct IsTraceable : std::false_type {
|
50
|
+
static_assert(sizeof(T), "T must be fully defined");
|
51
|
+
};
|
52
|
+
|
53
|
+
template <typename T>
|
54
|
+
struct IsTraceable<
|
55
|
+
T, void_t<decltype(std::declval<T>().Trace(std::declval<Visitor*>()))>>
|
56
|
+
: std::true_type {
|
57
|
+
// All Trace methods should be marked as const. If an object of type
|
58
|
+
// 'T' is traceable then any object of type 'const T' should also
|
59
|
+
// be traceable.
|
60
|
+
static_assert(IsTraceMethodConst<T>(),
|
61
|
+
"Trace methods should be marked as const.");
|
62
|
+
};
|
63
|
+
|
64
|
+
template <typename T>
|
65
|
+
constexpr bool IsTraceableV = IsTraceable<T>::value;
|
66
|
+
|
67
|
+
template <typename T, typename = void>
|
68
|
+
struct HasGarbageCollectedMixinTypeMarker : std::false_type {
|
69
|
+
static_assert(sizeof(T), "T must be fully defined");
|
70
|
+
};
|
71
|
+
|
72
|
+
template <typename T>
|
73
|
+
struct HasGarbageCollectedMixinTypeMarker<
|
74
|
+
T,
|
75
|
+
void_t<typename std::remove_const_t<T>::IsGarbageCollectedMixinTypeMarker>>
|
76
|
+
: std::true_type {
|
77
|
+
static_assert(sizeof(T), "T must be fully defined");
|
78
|
+
};
|
79
|
+
|
80
|
+
template <typename T, typename = void>
|
81
|
+
struct HasGarbageCollectedTypeMarker : std::false_type {
|
82
|
+
static_assert(sizeof(T), "T must be fully defined");
|
83
|
+
};
|
84
|
+
|
85
|
+
template <typename T>
|
86
|
+
struct HasGarbageCollectedTypeMarker<
|
87
|
+
T, void_t<typename std::remove_const_t<T>::IsGarbageCollectedTypeMarker>>
|
88
|
+
: std::true_type {
|
89
|
+
static_assert(sizeof(T), "T must be fully defined");
|
90
|
+
};
|
91
|
+
|
92
|
+
template <typename T, bool = HasGarbageCollectedTypeMarker<T>::value,
|
93
|
+
bool = HasGarbageCollectedMixinTypeMarker<T>::value>
|
94
|
+
struct IsGarbageCollectedMixinType : std::false_type {
|
95
|
+
static_assert(sizeof(T), "T must be fully defined");
|
96
|
+
};
|
97
|
+
|
98
|
+
template <typename T>
|
99
|
+
struct IsGarbageCollectedMixinType<T, false, true> : std::true_type {
|
100
|
+
static_assert(sizeof(T), "T must be fully defined");
|
101
|
+
};
|
102
|
+
|
103
|
+
template <typename T, bool = HasGarbageCollectedTypeMarker<T>::value>
|
104
|
+
struct IsGarbageCollectedType : std::false_type {
|
105
|
+
static_assert(sizeof(T), "T must be fully defined");
|
106
|
+
};
|
107
|
+
|
108
|
+
template <typename T>
|
109
|
+
struct IsGarbageCollectedType<T, true> : std::true_type {
|
110
|
+
static_assert(sizeof(T), "T must be fully defined");
|
111
|
+
};
|
112
|
+
|
113
|
+
template <typename T>
|
114
|
+
struct IsGarbageCollectedOrMixinType
|
115
|
+
: std::integral_constant<bool, IsGarbageCollectedType<T>::value ||
|
116
|
+
IsGarbageCollectedMixinType<T>::value> {
|
117
|
+
static_assert(sizeof(T), "T must be fully defined");
|
118
|
+
};
|
119
|
+
|
120
|
+
template <typename T, bool = (HasGarbageCollectedTypeMarker<T>::value &&
|
121
|
+
HasGarbageCollectedMixinTypeMarker<T>::value)>
|
122
|
+
struct IsGarbageCollectedWithMixinType : std::false_type {
|
123
|
+
static_assert(sizeof(T), "T must be fully defined");
|
124
|
+
};
|
125
|
+
|
126
|
+
template <typename T>
|
127
|
+
struct IsGarbageCollectedWithMixinType<T, true> : std::true_type {
|
128
|
+
static_assert(sizeof(T), "T must be fully defined");
|
129
|
+
};
|
130
|
+
|
131
|
+
template <typename BasicMemberCandidate, typename WeaknessTag,
|
132
|
+
typename WriteBarrierPolicy>
|
133
|
+
struct IsSubclassOfBasicMemberTemplate {
|
134
|
+
private:
|
135
|
+
template <typename T, typename CheckingPolicy>
|
136
|
+
static std::true_type SubclassCheck(
|
137
|
+
BasicMember<T, WeaknessTag, WriteBarrierPolicy, CheckingPolicy>*);
|
138
|
+
static std::false_type SubclassCheck(...);
|
139
|
+
|
140
|
+
public:
|
141
|
+
static constexpr bool value =
|
142
|
+
decltype(SubclassCheck(std::declval<BasicMemberCandidate*>()))::value;
|
143
|
+
};
|
144
|
+
|
145
|
+
template <typename T,
|
146
|
+
bool = IsSubclassOfBasicMemberTemplate<
|
147
|
+
T, StrongMemberTag, DijkstraWriteBarrierPolicy>::value>
|
148
|
+
struct IsMemberType : std::false_type {};
|
149
|
+
|
150
|
+
template <typename T>
|
151
|
+
struct IsMemberType<T, true> : std::true_type {};
|
152
|
+
|
153
|
+
template <typename T, bool = IsSubclassOfBasicMemberTemplate<
|
154
|
+
T, WeakMemberTag, DijkstraWriteBarrierPolicy>::value>
|
155
|
+
struct IsWeakMemberType : std::false_type {};
|
156
|
+
|
157
|
+
template <typename T>
|
158
|
+
struct IsWeakMemberType<T, true> : std::true_type {};
|
159
|
+
|
160
|
+
template <typename T, bool = IsSubclassOfBasicMemberTemplate<
|
161
|
+
T, UntracedMemberTag, NoWriteBarrierPolicy>::value>
|
162
|
+
struct IsUntracedMemberType : std::false_type {};
|
163
|
+
|
164
|
+
template <typename T>
|
165
|
+
struct IsUntracedMemberType<T, true> : std::true_type {};
|
166
|
+
|
167
|
+
} // namespace internal
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Value is true for types that inherit from `GarbageCollectedMixin` but not
|
171
|
+
* `GarbageCollected<T>` (i.e., they are free mixins), and false otherwise.
|
172
|
+
*/
|
173
|
+
template <typename T>
|
174
|
+
constexpr bool IsGarbageCollectedMixinTypeV =
|
175
|
+
internal::IsGarbageCollectedMixinType<T>::value;
|
176
|
+
|
177
|
+
/**
|
178
|
+
* Value is true for types that inherit from `GarbageCollected<T>`, and false
|
179
|
+
* otherwise.
|
180
|
+
*/
|
181
|
+
template <typename T>
|
182
|
+
constexpr bool IsGarbageCollectedTypeV =
|
183
|
+
internal::IsGarbageCollectedType<T>::value;
|
184
|
+
|
185
|
+
/**
|
186
|
+
* Value is true for types that inherit from either `GarbageCollected<T>` or
|
187
|
+
* `GarbageCollectedMixin`, and false otherwise.
|
188
|
+
*/
|
189
|
+
template <typename T>
|
190
|
+
constexpr bool IsGarbageCollectedOrMixinTypeV =
|
191
|
+
internal::IsGarbageCollectedOrMixinType<T>::value;
|
192
|
+
|
193
|
+
/**
|
194
|
+
* Value is true for types that inherit from `GarbageCollected<T>` and
|
195
|
+
* `GarbageCollectedMixin`, and false otherwise.
|
196
|
+
*/
|
197
|
+
template <typename T>
|
198
|
+
constexpr bool IsGarbageCollectedWithMixinTypeV =
|
199
|
+
internal::IsGarbageCollectedWithMixinType<T>::value;
|
200
|
+
|
201
|
+
/**
|
202
|
+
* Value is true for types of type `Member<T>`, and false otherwise.
|
203
|
+
*/
|
204
|
+
template <typename T>
|
205
|
+
constexpr bool IsMemberTypeV = internal::IsMemberType<T>::value;
|
206
|
+
|
207
|
+
/**
|
208
|
+
* Value is true for types of type `UntracedMember<T>`, and false otherwise.
|
209
|
+
*/
|
210
|
+
template <typename T>
|
211
|
+
constexpr bool IsUntracedMemberTypeV = internal::IsUntracedMemberType<T>::value;
|
212
|
+
|
213
|
+
/**
|
214
|
+
* Value is true for types of type `WeakMember<T>`, and false otherwise.
|
215
|
+
*/
|
216
|
+
template <typename T>
|
217
|
+
constexpr bool IsWeakMemberTypeV = internal::IsWeakMemberType<T>::value;
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Value is true for types that are considered weak references, and false
|
221
|
+
* otherwise.
|
222
|
+
*/
|
223
|
+
template <typename T>
|
224
|
+
constexpr bool IsWeakV = internal::IsWeak<T>::value;
|
225
|
+
|
226
|
+
} // namespace cppgc
|
227
|
+
|
228
|
+
#endif // INCLUDE_CPPGC_TYPE_TRAITS_H_
|