libv8 7.8.279.23.0beta1-x86_64-linux → 8.4.255.0.1-x86_64-linux

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8/location.rb +1 -1
  3. data/lib/libv8/version.rb +1 -1
  4. data/vendor/v8/include/cppgc/allocation.h +124 -0
  5. data/vendor/v8/include/cppgc/garbage-collected.h +192 -0
  6. data/vendor/v8/include/cppgc/heap.h +50 -0
  7. data/vendor/v8/include/cppgc/internal/accessors.h +26 -0
  8. data/vendor/v8/include/cppgc/internal/api-constants.h +44 -0
  9. data/vendor/v8/include/cppgc/internal/compiler-specific.h +26 -0
  10. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +90 -0
  11. data/vendor/v8/include/cppgc/internal/gc-info.h +43 -0
  12. data/vendor/v8/include/cppgc/internal/logging.h +50 -0
  13. data/vendor/v8/include/cppgc/internal/persistent-node.h +109 -0
  14. data/vendor/v8/include/cppgc/internal/pointer-policies.h +133 -0
  15. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +31 -0
  16. data/vendor/v8/include/cppgc/liveness-broker.h +50 -0
  17. data/vendor/v8/include/cppgc/macros.h +26 -0
  18. data/vendor/v8/include/cppgc/member.h +206 -0
  19. data/vendor/v8/include/cppgc/persistent.h +304 -0
  20. data/vendor/v8/include/cppgc/platform.h +31 -0
  21. data/vendor/v8/include/cppgc/prefinalizer.h +54 -0
  22. data/vendor/v8/include/cppgc/source-location.h +59 -0
  23. data/vendor/v8/include/cppgc/trace-trait.h +67 -0
  24. data/vendor/v8/include/cppgc/type-traits.h +109 -0
  25. data/vendor/v8/include/cppgc/visitor.h +137 -0
  26. data/vendor/v8/include/libplatform/libplatform.h +13 -10
  27. data/vendor/v8/include/libplatform/v8-tracing.h +36 -22
  28. data/vendor/v8/include/v8-fast-api-calls.h +412 -0
  29. data/vendor/v8/include/v8-inspector-protocol.h +4 -4
  30. data/vendor/v8/include/v8-inspector.h +57 -27
  31. data/vendor/v8/include/v8-internal.h +23 -21
  32. data/vendor/v8/include/v8-platform.h +164 -40
  33. data/vendor/v8/include/v8-profiler.h +27 -23
  34. data/vendor/v8/include/v8-util.h +1 -1
  35. data/vendor/v8/include/v8-version-string.h +1 -1
  36. data/vendor/v8/include/v8-version.h +4 -4
  37. data/vendor/v8/include/v8-wasm-trap-handler-posix.h +1 -1
  38. data/vendor/v8/include/v8-wasm-trap-handler-win.h +1 -1
  39. data/vendor/v8/include/v8.h +1219 -484
  40. data/vendor/v8/include/v8config.h +105 -51
  41. data/vendor/v8/out.gn/libv8/obj/libv8_libbase.a +0 -0
  42. data/vendor/v8/out.gn/libv8/obj/libv8_libplatform.a +0 -0
  43. data/vendor/v8/out.gn/libv8/obj/libv8_monolith.a +0 -0
  44. data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicui18n.a +0 -0
  45. data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicuuc.a +0 -0
  46. data/vendor/v8/out.gn/libv8/obj/third_party/zlib/google/libcompression_utils_portable.a +0 -0
  47. data/vendor/v8/out.gn/libv8/obj/third_party/zlib/libchrome_zlib.a +0 -0
  48. metadata +31 -9
  49. data/vendor/v8/include/v8-testing.h +0 -48
  50. data/vendor/v8/out.gn/libv8/obj/third_party/inspector_protocol/libbindings.a +0 -0
  51. data/vendor/v8/out.gn/libv8/obj/third_party/inspector_protocol/libencoding.a +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eddc251f5676979351efa918837c455484bf0a4608e22eda1240cf9e0b937cd4
4
- data.tar.gz: f46ed84422d5da4318218de86d88860610a2944c70580cd6be383b23f9c5992d
3
+ metadata.gz: 59d37891810b71bff4a2e5c97d9eeb918fdbb122c9454928b617d69fdb22805c
4
+ data.tar.gz: 87eeba2c5053b9d20a78a09711144ccd4e2cce0694fdf498a81dab2e631b1050
5
5
  SHA512:
6
- metadata.gz: 06610ab77411b0a2eac7499d7aebc3fa52b0408d470ddf488dc398513dd8269011b65d0eb115db714bbd7d83e9c5ddad2d58cdc7cb0d075c77faef917a93288f
7
- data.tar.gz: fe99dbcb74cdbb2f7e88c9c6a19e0e62e7e66d8ff28a0495a86ebfd046cc6ce74c2df1c3dbf89e999de879d6bd355f205625f270bc496697ee70ef5f8b2d054e
6
+ metadata.gz: c385785cb4150b8ef6e8ed639049eef914e727ed32b4b47568ed2de6393cf63f546ce2323ecff1568bf571ee90d5a2905eb31073df55e8a6aad129c195dabcee
7
+ data.tar.gz: a601c80d700444e9494384ed4cdaa4d7dfffd6a16e54fc1ea78487d2a32af3e55e4b1816eb7cabedfa61c4efc74bd3736692fe6b57a1b58b988d72cb479280aa
@@ -13,7 +13,7 @@ module Libv8
13
13
 
14
14
  def self.load!
15
15
  File.open(Pathname(__FILE__).dirname.join('.location.yml')) do |f|
16
- YAML.load f
16
+ YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(f) : YAML.load(f) # rubocop:disable Security/YAMLLoad
17
17
  end
18
18
  end
19
19
 
data/lib/libv8/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Libv8
2
- VERSION = "7.8.279.23.0beta1"
2
+ VERSION = "8.4.255.0.1"
3
3
  end
@@ -0,0 +1,124 @@
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_ALLOCATION_H_
6
+ #define INCLUDE_CPPGC_ALLOCATION_H_
7
+
8
+ #include <stdint.h>
9
+ #include <atomic>
10
+
11
+ #include "cppgc/garbage-collected.h"
12
+ #include "cppgc/heap.h"
13
+ #include "cppgc/internal/api-constants.h"
14
+ #include "cppgc/internal/gc-info.h"
15
+
16
+ namespace cppgc {
17
+
18
+ template <typename T>
19
+ class MakeGarbageCollectedTraitBase;
20
+
21
+ namespace internal {
22
+
23
+ class V8_EXPORT MakeGarbageCollectedTraitInternal {
24
+ protected:
25
+ static inline void MarkObjectAsFullyConstructed(const void* payload) {
26
+ // See api_constants for an explanation of the constants.
27
+ std::atomic<uint16_t>* atomic_mutable_bitfield =
28
+ reinterpret_cast<std::atomic<uint16_t>*>(
29
+ const_cast<uint16_t*>(reinterpret_cast<const uint16_t*>(
30
+ reinterpret_cast<const uint8_t*>(payload) -
31
+ api_constants::kFullyConstructedBitFieldOffsetFromPayload)));
32
+ uint16_t value = atomic_mutable_bitfield->load(std::memory_order_relaxed);
33
+ value = value | api_constants::kFullyConstructedBitMask;
34
+ atomic_mutable_bitfield->store(value, std::memory_order_release);
35
+ }
36
+
37
+ static void* Allocate(cppgc::Heap* heap, size_t size, GCInfoIndex index);
38
+
39
+ friend class HeapObjectHeader;
40
+ };
41
+
42
+ } // namespace internal
43
+
44
+ /**
45
+ * Base trait that provides utilities for advancers users that have custom
46
+ * allocation needs (e.g., overriding size). It's expected that users override
47
+ * MakeGarbageCollectedTrait (see below) and inherit from
48
+ * MakeGarbageCollectedTraitBase and make use of the low-level primitives
49
+ * offered to allocate and construct an object.
50
+ */
51
+ template <typename T>
52
+ class MakeGarbageCollectedTraitBase
53
+ : private internal::MakeGarbageCollectedTraitInternal {
54
+ protected:
55
+ /**
56
+ * Allocates memory for an object of type T.
57
+ *
58
+ * \param heap The heap to allocate this object on.
59
+ * \param size The size that should be reserved for the object.
60
+ * \returns the memory to construct an object of type T on.
61
+ */
62
+ static void* Allocate(Heap* heap, size_t size) {
63
+ // TODO(chromium:1056170): Allow specifying arena for specific embedder
64
+ // uses.
65
+ return internal::MakeGarbageCollectedTraitInternal::Allocate(
66
+ heap, size, internal::GCInfoTrait<T>::Index());
67
+ }
68
+
69
+ /**
70
+ * Marks an object as fully constructed, resulting in precise handling by the
71
+ * garbage collector.
72
+ *
73
+ * \param payload The base pointer the object is allocated at.
74
+ */
75
+ static void MarkObjectAsFullyConstructed(const void* payload) {
76
+ internal::MakeGarbageCollectedTraitInternal::MarkObjectAsFullyConstructed(
77
+ payload);
78
+ }
79
+ };
80
+
81
+ /**
82
+ * Default trait class that specifies how to construct an object of type T.
83
+ * Advanced users may override how an object is constructed using the utilities
84
+ * that are provided through MakeGarbageCollectedTraitBase.
85
+ *
86
+ * Any trait overriding construction must
87
+ * - allocate through MakeGarbageCollectedTraitBase<T>::Allocate;
88
+ * - mark the object as fully constructed using
89
+ * MakeGarbageCollectedTraitBase<T>::MarkObjectAsFullyConstructed;
90
+ */
91
+ template <typename T>
92
+ class MakeGarbageCollectedTrait : public MakeGarbageCollectedTraitBase<T> {
93
+ public:
94
+ template <typename... Args>
95
+ static T* Call(Heap* heap, Args&&... args) {
96
+ static_assert(internal::IsGarbageCollectedType<T>::value,
97
+ "T needs to be a garbage collected object");
98
+ static_assert(
99
+ !internal::IsGarbageCollectedMixinType<T>::value ||
100
+ sizeof(T) <= internal::api_constants::kLargeObjectSizeThreshold,
101
+ "GarbageCollectedMixin may not be a large object");
102
+ void* memory = MakeGarbageCollectedTraitBase<T>::Allocate(heap, sizeof(T));
103
+ T* object = ::new (memory) T(std::forward<Args>(args)...);
104
+ MakeGarbageCollectedTraitBase<T>::MarkObjectAsFullyConstructed(object);
105
+ return object;
106
+ }
107
+ };
108
+
109
+ /**
110
+ * Constructs a managed object of type T where T transitively inherits from
111
+ * GarbageCollected.
112
+ *
113
+ * \param args List of arguments with which an instance of T will be
114
+ * constructed.
115
+ * \returns an instance of type T.
116
+ */
117
+ template <typename T, typename... Args>
118
+ T* MakeGarbageCollected(Heap* heap, Args&&... args) {
119
+ return MakeGarbageCollectedTrait<T>::Call(heap, std::forward<Args>(args)...);
120
+ }
121
+
122
+ } // namespace cppgc
123
+
124
+ #endif // INCLUDE_CPPGC_ALLOCATION_H_
@@ -0,0 +1,192 @@
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_GARBAGE_COLLECTED_H_
6
+ #define INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
7
+
8
+ #include <type_traits>
9
+
10
+ #include "cppgc/internal/api-constants.h"
11
+ #include "cppgc/macros.h"
12
+ #include "cppgc/platform.h"
13
+ #include "cppgc/trace-trait.h"
14
+ #include "cppgc/type-traits.h"
15
+
16
+ namespace cppgc {
17
+
18
+ class Visitor;
19
+
20
+ namespace internal {
21
+
22
+ class GarbageCollectedBase {
23
+ public:
24
+ // Must use MakeGarbageCollected.
25
+ void* operator new(size_t) = delete;
26
+ void* operator new[](size_t) = delete;
27
+ // The garbage collector is taking care of reclaiming the object. Also,
28
+ // virtual destructor requires an unambiguous, accessible 'operator delete'.
29
+ void operator delete(void*) {
30
+ #ifdef V8_ENABLE_CHECKS
31
+ internal::Abort();
32
+ #endif // V8_ENABLE_CHECKS
33
+ }
34
+ void operator delete[](void*) = delete;
35
+
36
+ protected:
37
+ GarbageCollectedBase() = default;
38
+ };
39
+
40
+ } // namespace internal
41
+
42
+ /**
43
+ * Base class for managed objects. Only descendent types of GarbageCollected
44
+ * can be constructed using MakeGarbageCollected. Must be inherited from as
45
+ * left-most base class.
46
+ *
47
+ * Types inheriting from GarbageCollected must provide a method of
48
+ * signature `void Trace(cppgc::Visitor*) const` that dispatchs all managed
49
+ * pointers to the visitor and delegates to garbage-collected base classes.
50
+ * The method must be virtual if the type is not directly a child of
51
+ * GarbageCollected and marked as final.
52
+ *
53
+ * \code
54
+ * // Example using final class.
55
+ * class FinalType final : public GarbageCollected<FinalType> {
56
+ * public:
57
+ * void Trace(cppgc::Visitor* visitor) const {
58
+ * // Dispatch using visitor->Trace(...);
59
+ * }
60
+ * };
61
+ *
62
+ * // Example using non-final base class.
63
+ * class NonFinalBase : public GarbageCollected<NonFinalBase> {
64
+ * public:
65
+ * virtual void Trace(cppgc::Visitor*) const {}
66
+ * };
67
+ *
68
+ * class FinalChild final : public NonFinalBase {
69
+ * public:
70
+ * void Trace(cppgc::Visitor* visitor) const final {
71
+ * // Dispatch using visitor->Trace(...);
72
+ * NonFinalBase::Trace(visitor);
73
+ * }
74
+ * };
75
+ * \endcode
76
+ */
77
+ template <typename>
78
+ class GarbageCollected : public internal::GarbageCollectedBase {
79
+ public:
80
+ using IsGarbageCollectedTypeMarker = void;
81
+
82
+ protected:
83
+ GarbageCollected() = default;
84
+ };
85
+
86
+ /**
87
+ * Base class for managed mixin objects. Such objects cannot be constructed
88
+ * directly but must be mixed into the inheritance hierarchy of a
89
+ * GarbageCollected object.
90
+ *
91
+ * Types inheriting from GarbageCollectedMixin must override a virtual method
92
+ * of signature `void Trace(cppgc::Visitor*) const` that dispatchs all managed
93
+ * pointers to the visitor and delegates to base classes.
94
+ *
95
+ * \code
96
+ * class Mixin : public GarbageCollectedMixin {
97
+ * public:
98
+ * void Trace(cppgc::Visitor* visitor) const override {
99
+ * // Dispatch using visitor->Trace(...);
100
+ * }
101
+ * };
102
+ * \endcode
103
+ */
104
+ class GarbageCollectedMixin : public internal::GarbageCollectedBase {
105
+ public:
106
+ using IsGarbageCollectedMixinTypeMarker = void;
107
+
108
+ // Sentinel used to mark not-fully-constructed mixins.
109
+ static constexpr void* kNotFullyConstructedObject = nullptr;
110
+
111
+ // Provide default implementation that indicate that the vtable is not yet
112
+ // set up properly. This is used to to get GCInfo objects for mixins so that
113
+ // these objects can be processed later on.
114
+ virtual TraceDescriptor GetTraceDescriptor() const {
115
+ return {kNotFullyConstructedObject, nullptr};
116
+ }
117
+
118
+ /**
119
+ * This Trace method must be overriden by objects inheriting from
120
+ * GarbageCollectedMixin.
121
+ */
122
+ virtual void Trace(cppgc::Visitor*) const {}
123
+ };
124
+
125
+ /**
126
+ * Macro defines all methods and markers needed for handling mixins. Must be
127
+ * used on the type that is inheriting from GarbageCollected *and*
128
+ * GarbageCollectedMixin.
129
+ *
130
+ * \code
131
+ * class Mixin : public GarbageCollectedMixin {
132
+ * public:
133
+ * void Trace(cppgc::Visitor* visitor) const override {
134
+ * // Dispatch using visitor->Trace(...);
135
+ * }
136
+ * };
137
+ *
138
+ * class Foo : public GarbageCollected<Foo>, public Mixin {
139
+ * USING_GARBAGE_COLLECTED_MIXIN();
140
+ * public:
141
+ * void Trace(cppgc::Visitor* visitor) const override {
142
+ * // Dispatch using visitor->Trace(...);
143
+ * Mixin::Trace(visitor);
144
+ * }
145
+ * };
146
+ * \endcode
147
+ */
148
+ #define USING_GARBAGE_COLLECTED_MIXIN() \
149
+ public: \
150
+ /* Marker is used by clang to check for proper usages of the macro. */ \
151
+ typedef int HasUsingGarbageCollectedMixinMacro; \
152
+ \
153
+ TraceDescriptor GetTraceDescriptor() const override { \
154
+ static_assert( \
155
+ internal::IsSubclassOfTemplate< \
156
+ std::remove_const_t<std::remove_pointer_t<decltype(this)>>, \
157
+ cppgc::GarbageCollected>::value, \
158
+ "Only garbage collected objects can have garbage collected mixins"); \
159
+ return {this, TraceTrait<std::remove_const_t< \
160
+ std::remove_pointer_t<decltype(this)>>>::Trace}; \
161
+ } \
162
+ \
163
+ private: \
164
+ friend class internal::__thisIsHereToForceASemicolonAfterThisMacro
165
+
166
+ /**
167
+ * Merge two or more Mixins into one.
168
+ *
169
+ * \code
170
+ * class A : public GarbageCollectedMixin {};
171
+ * class B : public GarbageCollectedMixin {};
172
+ * class C : public A, public B {
173
+ * MERGE_GARBAGE_COLLECTED_MIXINS();
174
+ * public:
175
+ * };
176
+ * \endcode
177
+ */
178
+ #define MERGE_GARBAGE_COLLECTED_MIXINS() \
179
+ public: \
180
+ /* When using multiple mixins the methods become */ \
181
+ /* ambigous. Providing additional implementations */ \
182
+ /* disambiguate them again. */ \
183
+ TraceDescriptor GetTraceDescriptor() const override { \
184
+ return {kNotFullyConstructedObject, nullptr}; \
185
+ } \
186
+ \
187
+ private: \
188
+ friend class internal::__thisIsHereToForceASemicolonAfterThisMacro
189
+
190
+ } // namespace cppgc
191
+
192
+ #endif // INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
@@ -0,0 +1,50 @@
1
+ // Copyright 2020 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_CPPGC_HEAP_H_
6
+ #define INCLUDE_CPPGC_HEAP_H_
7
+
8
+ #include <memory>
9
+
10
+ #include "v8config.h" // NOLINT(build/include_directory)
11
+
12
+ namespace cppgc {
13
+ namespace internal {
14
+ class Heap;
15
+ } // namespace internal
16
+
17
+ class V8_EXPORT Heap {
18
+ public:
19
+ // Normal spaces are used to store objects of different size classes:
20
+ // - kNormal1: < 32 bytes
21
+ // - kNormal2: < 64 bytes
22
+ // - kNormal3: < 128 bytes
23
+ // - kNormal4: >= 128 bytes
24
+ // Objects of size greater than 2^16 get stored in the large space. Users can
25
+ // register up to 4 arenas for application specific needs.
26
+ enum class SpaceType {
27
+ kNormal1,
28
+ kNormal2,
29
+ kNormal3,
30
+ kNormal4,
31
+ kLarge,
32
+ kUserDefined1,
33
+ kUserDefined2,
34
+ kUserDefined3,
35
+ kUserDefined4,
36
+ };
37
+
38
+ static std::unique_ptr<Heap> Create();
39
+
40
+ virtual ~Heap() = default;
41
+
42
+ private:
43
+ Heap() = default;
44
+
45
+ friend class internal::Heap;
46
+ };
47
+
48
+ } // namespace cppgc
49
+
50
+ #endif // INCLUDE_CPPGC_HEAP_H_
@@ -0,0 +1,26 @@
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_ACCESSORS_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_ACCESSORS_H_
7
+
8
+ #include "cppgc/internal/api-constants.h"
9
+
10
+ namespace cppgc {
11
+
12
+ class Heap;
13
+
14
+ namespace internal {
15
+
16
+ inline cppgc::Heap* GetHeapFromPayload(const void* payload) {
17
+ return *reinterpret_cast<cppgc::Heap**>(
18
+ ((reinterpret_cast<uintptr_t>(payload) & api_constants::kPageBaseMask) +
19
+ api_constants::kGuardPageSize) +
20
+ api_constants::kHeapOffset);
21
+ }
22
+
23
+ } // namespace internal
24
+ } // namespace cppgc
25
+
26
+ #endif // INCLUDE_CPPGC_INTERNAL_ACCESSORS_H_
@@ -0,0 +1,44 @@
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_API_CONSTANTS_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
7
+
8
+ #include <stddef.h>
9
+ #include <stdint.h>
10
+
11
+ #include "v8config.h" // NOLINT(build/include_directory)
12
+
13
+ namespace cppgc {
14
+ namespace internal {
15
+
16
+ // Embedders should not rely on this code!
17
+
18
+ // Internal constants to avoid exposing internal types on the API surface.
19
+ namespace api_constants {
20
+ // Offset of the uint16_t bitfield from the payload contaning the
21
+ // in-construction bit. This is subtracted from the payload pointer to get
22
+ // to the right bitfield.
23
+ static constexpr size_t kFullyConstructedBitFieldOffsetFromPayload =
24
+ 2 * sizeof(uint16_t);
25
+ // Mask for in-construction bit.
26
+ static constexpr size_t kFullyConstructedBitMask = size_t{1};
27
+
28
+ // Page constants used to align pointers to page begin.
29
+ static constexpr size_t kPageSize = size_t{1} << 17;
30
+ static constexpr size_t kPageAlignment = kPageSize;
31
+ static constexpr size_t kPageBaseMask = ~(kPageAlignment - 1);
32
+ static constexpr size_t kGuardPageSize = 4096;
33
+
34
+ // Offset of the Heap backref.
35
+ static constexpr size_t kHeapOffset = 0;
36
+
37
+ static constexpr size_t kLargeObjectSizeThreshold = kPageSize / 2;
38
+
39
+ } // namespace api_constants
40
+
41
+ } // namespace internal
42
+ } // namespace cppgc
43
+
44
+ #endif // INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
@@ -0,0 +1,26 @@
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_COMPILER_SPECIFIC_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_
7
+
8
+ namespace cppgc {
9
+
10
+ #if defined(__has_cpp_attribute)
11
+ #define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) __has_cpp_attribute(FEATURE)
12
+ #else
13
+ #define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) 0
14
+ #endif
15
+
16
+ // [[no_unique_address]] comes in C++20 but supported in clang with -std >=
17
+ // c++11.
18
+ #if CPPGC_HAS_CPP_ATTRIBUTE(no_unique_address) // NOLINTNEXTLINE
19
+ #define CPPGC_NO_UNIQUE_ADDRESS [[no_unique_address]]
20
+ #else
21
+ #define CPPGC_NO_UNIQUE_ADDRESS
22
+ #endif
23
+
24
+ } // namespace cppgc
25
+
26
+ #endif // INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_
@@ -0,0 +1,90 @@
1
+ // Copyright 2020 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_
7
+
8
+ #include <type_traits>
9
+
10
+ #include "cppgc/type-traits.h"
11
+
12
+ namespace cppgc {
13
+ namespace internal {
14
+
15
+ using FinalizationCallback = void (*)(void*);
16
+
17
+ template <typename T, typename = void>
18
+ struct HasFinalizeGarbageCollectedObject : std::false_type {};
19
+
20
+ template <typename T>
21
+ struct HasFinalizeGarbageCollectedObject<
22
+ T, void_t<decltype(std::declval<T>().FinalizeGarbageCollectedObject())>>
23
+ : std::true_type {};
24
+
25
+ // The FinalizerTraitImpl specifies how to finalize objects.
26
+ template <typename T, bool isFinalized>
27
+ struct FinalizerTraitImpl;
28
+
29
+ template <typename T>
30
+ struct FinalizerTraitImpl<T, true> {
31
+ private:
32
+ // Dispatch to custom FinalizeGarbageCollectedObject().
33
+ struct Custom {
34
+ static void Call(void* obj) {
35
+ static_cast<T*>(obj)->FinalizeGarbageCollectedObject();
36
+ }
37
+ };
38
+
39
+ // Dispatch to regular destructor.
40
+ struct Destructor {
41
+ static void Call(void* obj) { static_cast<T*>(obj)->~T(); }
42
+ };
43
+
44
+ using FinalizeImpl =
45
+ std::conditional_t<HasFinalizeGarbageCollectedObject<T>::value, Custom,
46
+ Destructor>;
47
+
48
+ public:
49
+ static void Finalize(void* obj) {
50
+ static_assert(sizeof(T), "T must be fully defined");
51
+ FinalizeImpl::Call(obj);
52
+ }
53
+ };
54
+
55
+ template <typename T>
56
+ struct FinalizerTraitImpl<T, false> {
57
+ static void Finalize(void* obj) {
58
+ static_assert(sizeof(T), "T must be fully defined");
59
+ }
60
+ };
61
+
62
+ // The FinalizerTrait is used to determine if a type requires finalization and
63
+ // what finalization means.
64
+ template <typename T>
65
+ struct FinalizerTrait {
66
+ private:
67
+ // Object has a finalizer if it has
68
+ // - a custom FinalizeGarbageCollectedObject method, or
69
+ // - a destructor.
70
+ static constexpr bool kNonTrivialFinalizer =
71
+ internal::HasFinalizeGarbageCollectedObject<T>::value ||
72
+ !std::is_trivially_destructible<typename std::remove_cv<T>::type>::value;
73
+
74
+ static void Finalize(void* obj) {
75
+ internal::FinalizerTraitImpl<T, kNonTrivialFinalizer>::Finalize(obj);
76
+ }
77
+
78
+ public:
79
+ // The callback used to finalize an object of type T.
80
+ static constexpr FinalizationCallback kCallback =
81
+ kNonTrivialFinalizer ? Finalize : nullptr;
82
+ };
83
+
84
+ template <typename T>
85
+ constexpr FinalizationCallback FinalizerTrait<T>::kCallback;
86
+
87
+ } // namespace internal
88
+ } // namespace cppgc
89
+
90
+ #endif // INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_
@@ -0,0 +1,43 @@
1
+ // Copyright 2020 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
7
+
8
+ #include <stdint.h>
9
+
10
+ #include "cppgc/internal/finalizer-trait.h"
11
+ #include "v8config.h" // NOLINT(build/include_directory)
12
+
13
+ namespace cppgc {
14
+ namespace internal {
15
+
16
+ using GCInfoIndex = uint16_t;
17
+
18
+ class V8_EXPORT RegisteredGCInfoIndex final {
19
+ public:
20
+ RegisteredGCInfoIndex(FinalizationCallback finalization_callback,
21
+ bool has_v_table);
22
+ GCInfoIndex GetIndex() const { return index_; }
23
+
24
+ private:
25
+ const GCInfoIndex index_;
26
+ };
27
+
28
+ // Trait determines how the garbage collector treats objects wrt. to traversing,
29
+ // finalization, and naming.
30
+ template <typename T>
31
+ struct GCInfoTrait {
32
+ static GCInfoIndex Index() {
33
+ static_assert(sizeof(T), "T must be fully defined");
34
+ static const RegisteredGCInfoIndex registered_index(
35
+ FinalizerTrait<T>::kCallback, std::is_polymorphic<T>::value);
36
+ return registered_index.GetIndex();
37
+ }
38
+ };
39
+
40
+ } // namespace internal
41
+ } // namespace cppgc
42
+
43
+ #endif // INCLUDE_CPPGC_INTERNAL_GC_INFO_H_
@@ -0,0 +1,50 @@
1
+ // Copyright 2020 the V8 project authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ #ifndef INCLUDE_CPPGC_INTERNAL_LOGGING_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_LOGGING_H_
7
+
8
+ #include "cppgc/source-location.h"
9
+ #include "v8config.h" // NOLINT(build/include_directory)
10
+
11
+ namespace cppgc {
12
+ namespace internal {
13
+
14
+ void V8_EXPORT DCheckImpl(const char*,
15
+ const SourceLocation& = SourceLocation::Current());
16
+ [[noreturn]] void V8_EXPORT
17
+ FatalImpl(const char*, const SourceLocation& = SourceLocation::Current());
18
+
19
+ // Used to ignore -Wunused-variable.
20
+ template <typename>
21
+ struct EatParams {};
22
+
23
+ #if DEBUG
24
+ #define CPPGC_DCHECK_MSG(condition, message) \
25
+ do { \
26
+ if (V8_UNLIKELY(!(condition))) { \
27
+ ::cppgc::internal::DCheckImpl(message); \
28
+ } \
29
+ } while (false)
30
+ #else
31
+ #define CPPGC_DCHECK_MSG(condition, message) \
32
+ (static_cast<void>(::cppgc::internal::EatParams<decltype( \
33
+ static_cast<void>(condition), message)>{}))
34
+ #endif
35
+
36
+ #define CPPGC_DCHECK(condition) CPPGC_DCHECK_MSG(condition, #condition)
37
+
38
+ #define CPPGC_CHECK_MSG(condition, message) \
39
+ do { \
40
+ if (V8_UNLIKELY(!(condition))) { \
41
+ ::cppgc::internal::FatalImpl(message); \
42
+ } \
43
+ } while (false)
44
+
45
+ #define CPPGC_CHECK(condition) CPPGC_CHECK_MSG(condition, #condition)
46
+
47
+ } // namespace internal
48
+ } // namespace cppgc
49
+
50
+ #endif // INCLUDE_CPPGC_INTERNAL_LOGGING_H_