libv8-node 15.14.0.1-x86_64-linux → 17.9.1.0-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/libv8-node/location.rb +1 -1
- data/ext/libv8-node/paths.rb +5 -1
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/include/cppgc/allocation.h +110 -44
- data/vendor/v8/include/cppgc/common.h +9 -6
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +465 -0
- data/vendor/v8/include/cppgc/custom-space.h +37 -2
- data/vendor/v8/include/cppgc/default-platform.h +47 -48
- data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
- data/vendor/v8/include/cppgc/explicit-management.h +82 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +4 -3
- data/vendor/v8/include/cppgc/heap-consistency.h +253 -0
- data/vendor/v8/include/cppgc/heap-state.h +70 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
- data/vendor/v8/include/cppgc/heap.h +68 -6
- data/vendor/v8/include/cppgc/internal/api-constants.h +3 -3
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +4 -3
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +2 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +124 -13
- data/vendor/v8/include/cppgc/internal/name-trait.h +122 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +94 -6
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +81 -29
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +1 -1
- data/vendor/v8/include/cppgc/internal/write-barrier.h +398 -35
- data/vendor/v8/include/cppgc/liveness-broker.h +11 -2
- data/vendor/v8/include/cppgc/macros.h +2 -0
- data/vendor/v8/include/cppgc/member.h +87 -25
- 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 +41 -11
- data/vendor/v8/include/cppgc/platform.h +49 -25
- data/vendor/v8/include/cppgc/prefinalizer.h +2 -2
- data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
- data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
- data/vendor/v8/include/cppgc/source-location.h +2 -1
- data/vendor/v8/include/cppgc/testing.h +99 -0
- data/vendor/v8/include/cppgc/trace-trait.h +8 -3
- data/vendor/v8/include/cppgc/type-traits.h +157 -19
- data/vendor/v8/include/cppgc/visitor.h +194 -28
- data/vendor/v8/include/libplatform/libplatform.h +11 -0
- data/vendor/v8/include/libplatform/v8-tracing.h +2 -0
- data/vendor/v8/include/v8-array-buffer.h +433 -0
- data/vendor/v8/include/v8-callbacks.h +377 -0
- data/vendor/v8/include/v8-container.h +129 -0
- data/vendor/v8/include/v8-context.h +418 -0
- data/vendor/v8/include/v8-cppgc.h +261 -159
- data/vendor/v8/include/v8-data.h +65 -0
- data/vendor/v8/include/v8-date.h +43 -0
- data/vendor/v8/include/v8-debug.h +151 -0
- data/vendor/v8/include/v8-embedder-heap.h +238 -0
- data/vendor/v8/include/v8-exception.h +224 -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 +652 -152
- data/vendor/v8/include/v8-forward.h +81 -0
- data/vendor/v8/include/v8-function-callback.h +475 -0
- data/vendor/v8/include/v8-function.h +122 -0
- data/vendor/v8/include/v8-initialization.h +282 -0
- data/vendor/v8/include/v8-inspector.h +33 -25
- data/vendor/v8/include/v8-internal.h +178 -31
- data/vendor/v8/include/v8-isolate.h +1662 -0
- data/vendor/v8/include/v8-json.h +47 -0
- data/vendor/v8/include/v8-local-handle.h +459 -0
- data/vendor/v8/include/v8-locker.h +148 -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 +241 -0
- data/vendor/v8/include/v8-metrics.h +114 -9
- data/vendor/v8/include/v8-microtask-queue.h +152 -0
- data/vendor/v8/include/v8-microtask.h +28 -0
- data/vendor/v8/include/v8-object.h +770 -0
- data/vendor/v8/include/v8-persistent-handle.h +590 -0
- data/vendor/v8/include/v8-platform.h +74 -25
- data/vendor/v8/include/v8-primitive-object.h +118 -0
- data/vendor/v8/include/v8-primitive.h +858 -0
- data/vendor/v8/include/v8-profiler.h +72 -9
- 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 +771 -0
- data/vendor/v8/include/v8-snapshot.h +198 -0
- data/vendor/v8/include/v8-statistics.h +215 -0
- data/vendor/v8/include/v8-template.h +1052 -0
- data/vendor/v8/include/v8-traced-handle.h +605 -0
- data/vendor/v8/include/v8-typed-array.h +282 -0
- data/vendor/v8/include/v8-unwinder-state.h +31 -0
- data/vendor/v8/include/v8-unwinder.h +129 -0
- data/vendor/v8/include/v8-util.h +8 -2
- data/vendor/v8/include/v8-value-serializer.h +249 -0
- data/vendor/v8/include/v8-value.h +526 -0
- data/vendor/v8/include/v8-version.h +3 -3
- data/vendor/v8/include/v8-wasm.h +245 -0
- data/vendor/v8/include/v8-weak-callback-info.h +73 -0
- data/vendor/v8/include/v8.h +41 -12050
- data/vendor/v8/include/v8config.h +87 -11
- data/vendor/v8/{out.gn → x86_64-linux}/libv8/obj/libv8_monolith.a +0 -0
- metadata +60 -6
- data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -5,209 +5,311 @@
|
|
5
5
|
#ifndef INCLUDE_V8_CPPGC_H_
|
6
6
|
#define INCLUDE_V8_CPPGC_H_
|
7
7
|
|
8
|
+
#include <cstdint>
|
9
|
+
#include <memory>
|
10
|
+
#include <vector>
|
11
|
+
|
12
|
+
#include "cppgc/common.h"
|
13
|
+
#include "cppgc/custom-space.h"
|
14
|
+
#include "cppgc/heap-statistics.h"
|
15
|
+
#include "cppgc/internal/write-barrier.h"
|
8
16
|
#include "cppgc/visitor.h"
|
9
|
-
#include "v8-internal.h"
|
10
|
-
#include "v8.h"
|
17
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
18
|
+
#include "v8-platform.h" // NOLINT(build/include_directory)
|
19
|
+
#include "v8-traced-handle.h" // NOLINT(build/include_directory)
|
20
|
+
|
21
|
+
namespace cppgc {
|
22
|
+
class AllocationHandle;
|
23
|
+
class HeapHandle;
|
24
|
+
} // namespace cppgc
|
11
25
|
|
12
26
|
namespace v8 {
|
13
27
|
|
14
|
-
class
|
15
|
-
template <typename T>
|
16
|
-
class JSMember;
|
28
|
+
class Object;
|
17
29
|
|
18
30
|
namespace internal {
|
31
|
+
class CppHeap;
|
32
|
+
} // namespace internal
|
19
33
|
|
20
|
-
class
|
34
|
+
class CustomSpaceStatisticsReceiver;
|
21
35
|
|
22
|
-
|
23
|
-
|
36
|
+
/**
|
37
|
+
* Describes how V8 wrapper objects maintain references to garbage-collected C++
|
38
|
+
* objects.
|
39
|
+
*/
|
40
|
+
struct WrapperDescriptor final {
|
24
41
|
/**
|
25
|
-
*
|
26
|
-
* object
|
42
|
+
* The index used on `v8::Ojbect::SetAlignedPointerFromInternalField()` and
|
43
|
+
* related APIs to add additional data to an object which is used to identify
|
44
|
+
* JS->C++ references.
|
27
45
|
*/
|
28
|
-
|
46
|
+
using InternalFieldIndex = int;
|
29
47
|
|
30
48
|
/**
|
31
|
-
*
|
49
|
+
* Unknown embedder id. The value is reserved for internal usages and must not
|
50
|
+
* be used with `CppHeap`.
|
32
51
|
*/
|
33
|
-
|
34
|
-
|
35
|
-
private:
|
36
|
-
static internal::Address* New(v8::Isolate* isolate,
|
37
|
-
internal::Address* object_slot,
|
38
|
-
internal::Address** this_slot);
|
39
|
-
static void Delete(internal::Address* object);
|
40
|
-
static void Copy(const internal::Address* const* from_slot,
|
41
|
-
internal::Address** to_slot);
|
42
|
-
static void Move(internal::Address** from_slot, internal::Address** to_slot);
|
43
|
-
|
44
|
-
JSMemberBase() = default;
|
52
|
+
static constexpr uint16_t kUnknownEmbedderId = UINT16_MAX;
|
45
53
|
|
46
|
-
|
47
|
-
|
54
|
+
constexpr WrapperDescriptor(InternalFieldIndex wrappable_type_index,
|
55
|
+
InternalFieldIndex wrappable_instance_index,
|
56
|
+
uint16_t embedder_id_for_garbage_collected)
|
57
|
+
: wrappable_type_index(wrappable_type_index),
|
58
|
+
wrappable_instance_index(wrappable_instance_index),
|
59
|
+
embedder_id_for_garbage_collected(embedder_id_for_garbage_collected) {}
|
48
60
|
|
49
|
-
|
50
|
-
|
61
|
+
/**
|
62
|
+
* Index of the wrappable type.
|
63
|
+
*/
|
64
|
+
InternalFieldIndex wrappable_type_index;
|
51
65
|
|
52
|
-
|
53
|
-
|
66
|
+
/**
|
67
|
+
* Index of the wrappable instance.
|
68
|
+
*/
|
69
|
+
InternalFieldIndex wrappable_instance_index;
|
54
70
|
|
55
|
-
|
56
|
-
|
57
|
-
|
71
|
+
/**
|
72
|
+
* Embedder id identifying instances of garbage-collected objects. It is
|
73
|
+
* expected that the first field of the wrappable type is a uint16_t holding
|
74
|
+
* the id. Only references to instances of wrappables types with an id of
|
75
|
+
* `embedder_id_for_garbage_collected` will be considered by CppHeap.
|
76
|
+
*/
|
77
|
+
uint16_t embedder_id_for_garbage_collected;
|
58
78
|
};
|
59
79
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
if (!other.IsEmpty()) {
|
64
|
-
Copy(&other.val_, &val_);
|
65
|
-
}
|
66
|
-
}
|
67
|
-
return *this;
|
68
|
-
}
|
69
|
-
|
70
|
-
JSMemberBase& JSMemberBase::MoveImpl(JSMemberBase&& other) {
|
71
|
-
if (this != &other) {
|
72
|
-
// No call to Reset() as Move() will conditionally reset itself when needed,
|
73
|
-
// and otherwise reuse the internal meta data.
|
74
|
-
Move(&other.val_, &val_);
|
75
|
-
}
|
76
|
-
return *this;
|
77
|
-
}
|
80
|
+
struct V8_EXPORT CppHeapCreateParams {
|
81
|
+
CppHeapCreateParams(const CppHeapCreateParams&) = delete;
|
82
|
+
CppHeapCreateParams& operator=(const CppHeapCreateParams&) = delete;
|
78
83
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
val_ = nullptr;
|
83
|
-
}
|
84
|
-
|
85
|
-
} // namespace internal
|
84
|
+
std::vector<std::unique_ptr<cppgc::CustomSpaceBase>> custom_spaces;
|
85
|
+
WrapperDescriptor wrapper_descriptor;
|
86
|
+
};
|
86
87
|
|
87
88
|
/**
|
88
|
-
* A
|
89
|
-
* only be used in GarbageCollected objects and must be processed in a Trace()
|
90
|
-
* method.
|
89
|
+
* A heap for allocating managed C++ objects.
|
91
90
|
*/
|
92
|
-
|
93
|
-
class V8_EXPORT JSMember : public internal::JSMemberBase {
|
94
|
-
static_assert(std::is_base_of<v8::Value, T>::value,
|
95
|
-
"JSMember only supports references to v8::Value");
|
96
|
-
|
91
|
+
class V8_EXPORT CppHeap {
|
97
92
|
public:
|
98
|
-
|
93
|
+
static std::unique_ptr<CppHeap> Create(v8::Platform* platform,
|
94
|
+
const CppHeapCreateParams& params);
|
99
95
|
|
100
|
-
|
101
|
-
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
102
|
-
JSMember(Isolate* isolate, Local<U> that)
|
103
|
-
: internal::JSMemberBase(isolate,
|
104
|
-
reinterpret_cast<internal::Address*>(*that)) {}
|
105
|
-
|
106
|
-
JSMember(const JSMember& other) { CopyImpl(other); }
|
107
|
-
|
108
|
-
template <typename U,
|
109
|
-
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
110
|
-
JSMember(const JSMember<U>& other) { // NOLINT
|
111
|
-
CopyImpl(other);
|
112
|
-
}
|
96
|
+
virtual ~CppHeap() = default;
|
113
97
|
|
114
|
-
|
98
|
+
/**
|
99
|
+
* \returns the opaque handle for allocating objects using
|
100
|
+
* `MakeGarbageCollected()`.
|
101
|
+
*/
|
102
|
+
cppgc::AllocationHandle& GetAllocationHandle();
|
115
103
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
104
|
+
/**
|
105
|
+
* \returns the opaque heap handle which may be used to refer to this heap in
|
106
|
+
* other APIs. Valid as long as the underlying `CppHeap` is alive.
|
107
|
+
*/
|
108
|
+
cppgc::HeapHandle& GetHeapHandle();
|
121
109
|
|
122
|
-
|
110
|
+
/**
|
111
|
+
* Terminate clears all roots and performs multiple garbage collections to
|
112
|
+
* reclaim potentially newly created objects in destructors.
|
113
|
+
*
|
114
|
+
* After this call, object allocation is prohibited.
|
115
|
+
*/
|
116
|
+
void Terminate();
|
123
117
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
118
|
+
/**
|
119
|
+
* \param detail_level specifies whether should return detailed
|
120
|
+
* statistics or only brief summary statistics.
|
121
|
+
* \returns current CppHeap statistics regarding memory consumption
|
122
|
+
* and utilization.
|
123
|
+
*/
|
124
|
+
cppgc::HeapStatistics CollectStatistics(
|
125
|
+
cppgc::HeapStatistics::DetailLevel detail_level);
|
129
126
|
|
130
|
-
|
127
|
+
/**
|
128
|
+
* Collects statistics for the given spaces and reports them to the receiver.
|
129
|
+
*
|
130
|
+
* \param custom_spaces a collection of custom space indicies.
|
131
|
+
* \param receiver an object that gets the results.
|
132
|
+
*/
|
133
|
+
void CollectCustomSpaceStatisticsAtLastGC(
|
134
|
+
std::vector<cppgc::CustomSpaceIndex> custom_spaces,
|
135
|
+
std::unique_ptr<CustomSpaceStatisticsReceiver> receiver);
|
131
136
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
+
/**
|
138
|
+
* Enables a detached mode that allows testing garbage collection using
|
139
|
+
* `cppgc::testing` APIs. Once used, the heap cannot be attached to an
|
140
|
+
* `Isolate` anymore.
|
141
|
+
*/
|
142
|
+
void EnableDetachedGarbageCollectionsForTesting();
|
137
143
|
|
138
|
-
|
139
|
-
|
144
|
+
/**
|
145
|
+
* Performs a stop-the-world garbage collection for testing purposes.
|
146
|
+
*
|
147
|
+
* \param stack_state The stack state to assume for the garbage collection.
|
148
|
+
*/
|
149
|
+
void CollectGarbageForTesting(cppgc::EmbedderStackState stack_state);
|
140
150
|
|
141
|
-
|
151
|
+
private:
|
152
|
+
CppHeap() = default;
|
142
153
|
|
143
|
-
|
144
|
-
typename = std::enable_if_t<std::is_base_of<T, U>::value>>
|
145
|
-
void Set(v8::Isolate* isolate, Local<U> that) {
|
146
|
-
Reset();
|
147
|
-
val_ = New(isolate, reinterpret_cast<internal::Address*>(*that), &val_);
|
148
|
-
}
|
154
|
+
friend class internal::CppHeap;
|
149
155
|
};
|
150
156
|
|
151
|
-
template <typename T1, typename T2,
|
152
|
-
typename = std::enable_if_t<std::is_base_of<T2, T1>::value ||
|
153
|
-
std::is_base_of<T1, T2>::value>>
|
154
|
-
inline bool operator==(const JSMember<T1>& lhs, const JSMember<T2>& rhs) {
|
155
|
-
v8::internal::Address* a = reinterpret_cast<v8::internal::Address*>(*lhs);
|
156
|
-
v8::internal::Address* b = reinterpret_cast<v8::internal::Address*>(*rhs);
|
157
|
-
if (a == nullptr) return b == nullptr;
|
158
|
-
if (b == nullptr) return false;
|
159
|
-
return *a == *b;
|
160
|
-
}
|
161
|
-
|
162
|
-
template <typename T1, typename T2,
|
163
|
-
typename = std::enable_if_t<std::is_base_of<T2, T1>::value ||
|
164
|
-
std::is_base_of<T1, T2>::value>>
|
165
|
-
inline bool operator!=(const JSMember<T1>& lhs, const JSMember<T2>& rhs) {
|
166
|
-
return !(lhs == rhs);
|
167
|
-
}
|
168
|
-
|
169
|
-
template <typename T1, typename T2,
|
170
|
-
typename = std::enable_if_t<std::is_base_of<T2, T1>::value ||
|
171
|
-
std::is_base_of<T1, T2>::value>>
|
172
|
-
inline bool operator==(const JSMember<T1>& lhs, const Local<T2>& rhs) {
|
173
|
-
v8::internal::Address* a = reinterpret_cast<v8::internal::Address*>(*lhs);
|
174
|
-
v8::internal::Address* b = reinterpret_cast<v8::internal::Address*>(*rhs);
|
175
|
-
if (a == nullptr) return b == nullptr;
|
176
|
-
if (b == nullptr) return false;
|
177
|
-
return *a == *b;
|
178
|
-
}
|
179
|
-
|
180
|
-
template <typename T1, typename T2,
|
181
|
-
typename = std::enable_if_t<std::is_base_of<T2, T1>::value ||
|
182
|
-
std::is_base_of<T1, T2>::value>>
|
183
|
-
inline bool operator==(const Local<T1>& lhs, const JSMember<T2> rhs) {
|
184
|
-
return rhs == lhs;
|
185
|
-
}
|
186
|
-
|
187
|
-
template <typename T1, typename T2>
|
188
|
-
inline bool operator!=(const JSMember<T1>& lhs, const T2& rhs) {
|
189
|
-
return !(lhs == rhs);
|
190
|
-
}
|
191
|
-
|
192
|
-
template <typename T1, typename T2>
|
193
|
-
inline bool operator!=(const T1& lhs, const JSMember<T2>& rhs) {
|
194
|
-
return !(lhs == rhs);
|
195
|
-
}
|
196
|
-
|
197
157
|
class JSVisitor : public cppgc::Visitor {
|
198
158
|
public:
|
199
159
|
explicit JSVisitor(cppgc::Visitor::Key key) : cppgc::Visitor(key) {}
|
200
160
|
|
201
|
-
|
202
|
-
|
203
|
-
if (ref.IsEmpty()) return;
|
161
|
+
void Trace(const TracedReferenceBase& ref) {
|
162
|
+
if (ref.IsEmptyThreadSafe()) return;
|
204
163
|
Visit(ref);
|
205
164
|
}
|
206
165
|
|
207
166
|
protected:
|
208
167
|
using cppgc::Visitor::Visit;
|
209
168
|
|
210
|
-
virtual void Visit(const
|
169
|
+
virtual void Visit(const TracedReferenceBase& ref) {}
|
170
|
+
};
|
171
|
+
|
172
|
+
/**
|
173
|
+
* **DO NOT USE: Use the appropriate managed types.**
|
174
|
+
*
|
175
|
+
* Consistency helpers that aid in maintaining a consistent internal state of
|
176
|
+
* the garbage collector.
|
177
|
+
*/
|
178
|
+
class V8_EXPORT JSHeapConsistency final {
|
179
|
+
public:
|
180
|
+
using WriteBarrierParams = cppgc::internal::WriteBarrier::Params;
|
181
|
+
using WriteBarrierType = cppgc::internal::WriteBarrier::Type;
|
182
|
+
|
183
|
+
/**
|
184
|
+
* Gets the required write barrier type for a specific write.
|
185
|
+
*
|
186
|
+
* Note: Handling for C++ to JS references.
|
187
|
+
*
|
188
|
+
* \param ref The reference being written to.
|
189
|
+
* \param params Parameters that may be used for actual write barrier calls.
|
190
|
+
* Only filled if return value indicates that a write barrier is needed. The
|
191
|
+
* contents of the `params` are an implementation detail.
|
192
|
+
* \param callback Callback returning the corresponding heap handle. The
|
193
|
+
* callback is only invoked if the heap cannot otherwise be figured out. The
|
194
|
+
* callback must not allocate.
|
195
|
+
* \returns whether a write barrier is needed and which barrier to invoke.
|
196
|
+
*/
|
197
|
+
template <typename HeapHandleCallback>
|
198
|
+
static V8_INLINE WriteBarrierType
|
199
|
+
GetWriteBarrierType(const TracedReferenceBase& ref,
|
200
|
+
WriteBarrierParams& params, HeapHandleCallback callback) {
|
201
|
+
if (ref.IsEmpty()) return WriteBarrierType::kNone;
|
202
|
+
|
203
|
+
if (V8_LIKELY(!cppgc::internal::WriteBarrier::
|
204
|
+
IsAnyIncrementalOrConcurrentMarking())) {
|
205
|
+
return cppgc::internal::WriteBarrier::Type::kNone;
|
206
|
+
}
|
207
|
+
cppgc::HeapHandle& handle = callback();
|
208
|
+
if (!cppgc::subtle::HeapState::IsMarking(handle)) {
|
209
|
+
return cppgc::internal::WriteBarrier::Type::kNone;
|
210
|
+
}
|
211
|
+
params.heap = &handle;
|
212
|
+
#if V8_ENABLE_CHECKS
|
213
|
+
params.type = cppgc::internal::WriteBarrier::Type::kMarking;
|
214
|
+
#endif // !V8_ENABLE_CHECKS
|
215
|
+
return cppgc::internal::WriteBarrier::Type::kMarking;
|
216
|
+
}
|
217
|
+
|
218
|
+
/**
|
219
|
+
* Gets the required write barrier type for a specific write.
|
220
|
+
*
|
221
|
+
* Note: Handling for JS to C++ references.
|
222
|
+
*
|
223
|
+
* \param wrapper The wrapper that has been written into.
|
224
|
+
* \param wrapper_index The wrapper index in `wrapper` that has been written
|
225
|
+
* into.
|
226
|
+
* \param wrappable The value that was written.
|
227
|
+
* \param params Parameters that may be used for actual write barrier calls.
|
228
|
+
* Only filled if return value indicates that a write barrier is needed. The
|
229
|
+
* contents of the `params` are an implementation detail.
|
230
|
+
* \param callback Callback returning the corresponding heap handle. The
|
231
|
+
* callback is only invoked if the heap cannot otherwise be figured out. The
|
232
|
+
* callback must not allocate.
|
233
|
+
* \returns whether a write barrier is needed and which barrier to invoke.
|
234
|
+
*/
|
235
|
+
template <typename HeapHandleCallback>
|
236
|
+
static V8_INLINE WriteBarrierType GetWriteBarrierType(
|
237
|
+
v8::Local<v8::Object>& wrapper, int wrapper_index, const void* wrappable,
|
238
|
+
WriteBarrierParams& params, HeapHandleCallback callback) {
|
239
|
+
#if V8_ENABLE_CHECKS
|
240
|
+
CheckWrapper(wrapper, wrapper_index, wrappable);
|
241
|
+
#endif // V8_ENABLE_CHECKS
|
242
|
+
return cppgc::internal::WriteBarrier::
|
243
|
+
GetWriteBarrierTypeForExternallyReferencedObject(wrappable, params,
|
244
|
+
callback);
|
245
|
+
}
|
246
|
+
|
247
|
+
/**
|
248
|
+
* Conservative Dijkstra-style write barrier that processes an object if it
|
249
|
+
* has not yet been processed.
|
250
|
+
*
|
251
|
+
* \param params The parameters retrieved from `GetWriteBarrierType()`.
|
252
|
+
* \param ref The reference being written to.
|
253
|
+
*/
|
254
|
+
static V8_INLINE void DijkstraMarkingBarrier(const WriteBarrierParams& params,
|
255
|
+
cppgc::HeapHandle& heap_handle,
|
256
|
+
const TracedReferenceBase& ref) {
|
257
|
+
cppgc::internal::WriteBarrier::CheckParams(WriteBarrierType::kMarking,
|
258
|
+
params);
|
259
|
+
DijkstraMarkingBarrierSlow(heap_handle, ref);
|
260
|
+
}
|
261
|
+
|
262
|
+
/**
|
263
|
+
* Conservative Dijkstra-style write barrier that processes an object if it
|
264
|
+
* has not yet been processed.
|
265
|
+
*
|
266
|
+
* \param params The parameters retrieved from `GetWriteBarrierType()`.
|
267
|
+
* \param object The pointer to the object. May be an interior pointer to a
|
268
|
+
* an interface of the actual object.
|
269
|
+
*/
|
270
|
+
static V8_INLINE void DijkstraMarkingBarrier(const WriteBarrierParams& params,
|
271
|
+
cppgc::HeapHandle& heap_handle,
|
272
|
+
const void* object) {
|
273
|
+
cppgc::internal::WriteBarrier::DijkstraMarkingBarrier(params, object);
|
274
|
+
}
|
275
|
+
|
276
|
+
/**
|
277
|
+
* Generational barrier for maintaining consistency when running with multiple
|
278
|
+
* generations.
|
279
|
+
*
|
280
|
+
* \param params The parameters retrieved from `GetWriteBarrierType()`.
|
281
|
+
* \param ref The reference being written to.
|
282
|
+
*/
|
283
|
+
static V8_INLINE void GenerationalBarrier(const WriteBarrierParams& params,
|
284
|
+
const TracedReferenceBase& ref) {}
|
285
|
+
|
286
|
+
private:
|
287
|
+
JSHeapConsistency() = delete;
|
288
|
+
|
289
|
+
static void CheckWrapper(v8::Local<v8::Object>&, int, const void*);
|
290
|
+
|
291
|
+
static void DijkstraMarkingBarrierSlow(cppgc::HeapHandle&,
|
292
|
+
const TracedReferenceBase& ref);
|
293
|
+
};
|
294
|
+
|
295
|
+
/**
|
296
|
+
* Provided as input to `CppHeap::CollectCustomSpaceStatisticsAtLastGC()`.
|
297
|
+
*
|
298
|
+
* Its method is invoked with the results of the statistic collection.
|
299
|
+
*/
|
300
|
+
class CustomSpaceStatisticsReceiver {
|
301
|
+
public:
|
302
|
+
virtual ~CustomSpaceStatisticsReceiver() = default;
|
303
|
+
/**
|
304
|
+
* Reports the size of a space at the last GC. It is called for each space
|
305
|
+
* that was requested in `CollectCustomSpaceStatisticsAtLastGC()`.
|
306
|
+
*
|
307
|
+
* \param space_index The index of the space.
|
308
|
+
* \param bytes The total size of live objects in the space at the last GC.
|
309
|
+
* It is zero if there was no GC yet.
|
310
|
+
*/
|
311
|
+
virtual void AllocatedBytes(cppgc::CustomSpaceIndex space_index,
|
312
|
+
size_t bytes) = 0;
|
211
313
|
};
|
212
314
|
|
213
315
|
} // namespace v8
|
@@ -215,8 +317,8 @@ class JSVisitor : public cppgc::Visitor {
|
|
215
317
|
namespace cppgc {
|
216
318
|
|
217
319
|
template <typename T>
|
218
|
-
struct TraceTrait<v8::
|
219
|
-
static void Trace(Visitor* visitor, const v8::
|
320
|
+
struct TraceTrait<v8::TracedReference<T>> {
|
321
|
+
static void Trace(Visitor* visitor, const v8::TracedReference<T>* self) {
|
220
322
|
static_cast<v8::JSVisitor*>(visitor)->Trace(*self);
|
221
323
|
}
|
222
324
|
};
|
@@ -0,0 +1,65 @@
|
|
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_V8_DATA_H_
|
6
|
+
#define INCLUDE_V8_DATA_H_
|
7
|
+
|
8
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
9
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
10
|
+
|
11
|
+
namespace v8 {
|
12
|
+
|
13
|
+
class Context;
|
14
|
+
|
15
|
+
/**
|
16
|
+
* The superclass of objects that can reside on V8's heap.
|
17
|
+
*/
|
18
|
+
class V8_EXPORT Data {
|
19
|
+
public:
|
20
|
+
/**
|
21
|
+
* Returns true if this data is a |v8::Value|.
|
22
|
+
*/
|
23
|
+
bool IsValue() const;
|
24
|
+
|
25
|
+
/**
|
26
|
+
* Returns true if this data is a |v8::Module|.
|
27
|
+
*/
|
28
|
+
bool IsModule() const;
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Returns true if this data is a |v8::Private|.
|
32
|
+
*/
|
33
|
+
bool IsPrivate() const;
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Returns true if this data is a |v8::ObjectTemplate|.
|
37
|
+
*/
|
38
|
+
bool IsObjectTemplate() const;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Returns true if this data is a |v8::FunctionTemplate|.
|
42
|
+
*/
|
43
|
+
bool IsFunctionTemplate() const;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Returns true if this data is a |v8::Context|.
|
47
|
+
*/
|
48
|
+
bool IsContext() const;
|
49
|
+
|
50
|
+
private:
|
51
|
+
Data();
|
52
|
+
};
|
53
|
+
|
54
|
+
/**
|
55
|
+
* A fixed-sized array with elements of type Data.
|
56
|
+
*/
|
57
|
+
class V8_EXPORT FixedArray : public Data {
|
58
|
+
public:
|
59
|
+
int Length() const;
|
60
|
+
Local<Data> Get(Local<Context> context, int i) const;
|
61
|
+
};
|
62
|
+
|
63
|
+
} // namespace v8
|
64
|
+
|
65
|
+
#endif // INCLUDE_V8_DATA_H_
|
@@ -0,0 +1,43 @@
|
|
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_V8_DATE_H_
|
6
|
+
#define INCLUDE_V8_DATE_H_
|
7
|
+
|
8
|
+
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
9
|
+
#include "v8-object.h" // NOLINT(build/include_directory)
|
10
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
11
|
+
|
12
|
+
namespace v8 {
|
13
|
+
|
14
|
+
class Context;
|
15
|
+
|
16
|
+
/**
|
17
|
+
* An instance of the built-in Date constructor (ECMA-262, 15.9).
|
18
|
+
*/
|
19
|
+
class V8_EXPORT Date : public Object {
|
20
|
+
public:
|
21
|
+
static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context,
|
22
|
+
double time);
|
23
|
+
|
24
|
+
/**
|
25
|
+
* A specialization of Value::NumberValue that is more efficient
|
26
|
+
* because we know the structure of this object.
|
27
|
+
*/
|
28
|
+
double ValueOf() const;
|
29
|
+
|
30
|
+
V8_INLINE static Date* Cast(Value* value) {
|
31
|
+
#ifdef V8_ENABLE_CHECKS
|
32
|
+
CheckCast(value);
|
33
|
+
#endif
|
34
|
+
return static_cast<Date*>(value);
|
35
|
+
}
|
36
|
+
|
37
|
+
private:
|
38
|
+
static void CheckCast(Value* obj);
|
39
|
+
};
|
40
|
+
|
41
|
+
} // namespace v8
|
42
|
+
|
43
|
+
#endif // INCLUDE_V8_DATE_H_
|