libv8-node 15.14.0.1-aarch64-linux-musl → 18.8.0.0-aarch64-linux-musl
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/{out.gn → aarch64-linux-musl}/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/allocation.h +184 -47
- 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 +40 -49
- data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
- data/vendor/v8/include/cppgc/explicit-management.h +100 -0
- data/vendor/v8/include/cppgc/garbage-collected.h +19 -29
- data/vendor/v8/include/cppgc/heap-consistency.h +266 -0
- data/vendor/v8/include/cppgc/heap-state.h +82 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
- data/vendor/v8/include/cppgc/heap.h +73 -6
- data/vendor/v8/include/cppgc/internal/api-constants.h +11 -3
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +27 -15
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
- data/vendor/v8/include/cppgc/internal/finalizer-trait.h +4 -1
- data/vendor/v8/include/cppgc/internal/gc-info.h +124 -13
- data/vendor/v8/include/cppgc/internal/logging.h +3 -3
- data/vendor/v8/include/cppgc/internal/name-trait.h +122 -0
- data/vendor/v8/include/cppgc/internal/persistent-node.h +116 -16
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +84 -32
- data/vendor/v8/include/cppgc/internal/write-barrier.h +392 -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 +91 -26
- 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 +70 -41
- data/vendor/v8/include/cppgc/platform.h +52 -26
- data/vendor/v8/include/cppgc/prefinalizer.h +36 -13
- 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 +106 -0
- data/vendor/v8/include/cppgc/trace-trait.h +8 -3
- data/vendor/v8/include/cppgc/type-traits.h +163 -32
- data/vendor/v8/include/cppgc/visitor.h +194 -28
- data/vendor/v8/include/libplatform/libplatform.h +11 -11
- data/vendor/v8/include/libplatform/v8-tracing.h +2 -1
- data/vendor/v8/include/v8-array-buffer.h +445 -0
- data/vendor/v8/include/v8-callbacks.h +397 -0
- data/vendor/v8/include/v8-container.h +129 -0
- data/vendor/v8/include/v8-context.h +407 -0
- data/vendor/v8/include/v8-cppgc.h +151 -159
- data/vendor/v8/include/v8-data.h +80 -0
- data/vendor/v8/include/v8-date.h +43 -0
- data/vendor/v8/include/v8-debug.h +168 -0
- data/vendor/v8/include/v8-embedder-heap.h +218 -0
- data/vendor/v8/include/v8-embedder-state-scope.h +51 -0
- data/vendor/v8/include/v8-exception.h +217 -0
- data/vendor/v8/include/v8-extension.h +62 -0
- data/vendor/v8/include/v8-external.h +37 -0
- data/vendor/v8/include/v8-fast-api-calls.h +703 -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 +125 -0
- data/vendor/v8/include/v8-initialization.h +315 -0
- data/vendor/v8/include/v8-inspector.h +76 -27
- data/vendor/v8/include/v8-internal.h +285 -51
- data/vendor/v8/include/v8-isolate.h +1709 -0
- data/vendor/v8/include/v8-json.h +47 -0
- data/vendor/v8/include/v8-local-handle.h +455 -0
- data/vendor/v8/include/v8-locker.h +149 -0
- data/vendor/v8/include/v8-maybe.h +137 -0
- data/vendor/v8/include/v8-memory-span.h +43 -0
- data/vendor/v8/include/v8-message.h +216 -0
- data/vendor/v8/include/v8-metrics.h +131 -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 +775 -0
- data/vendor/v8/include/v8-persistent-handle.h +590 -0
- data/vendor/v8/include/v8-platform.h +433 -25
- data/vendor/v8/include/v8-primitive-object.h +118 -0
- data/vendor/v8/include/v8-primitive.h +866 -0
- data/vendor/v8/include/v8-profiler.h +149 -10
- data/vendor/v8/include/v8-promise.h +174 -0
- data/vendor/v8/include/v8-proxy.h +50 -0
- data/vendor/v8/include/v8-regexp.h +105 -0
- data/vendor/v8/include/v8-script.h +747 -0
- data/vendor/v8/include/v8-snapshot.h +196 -0
- data/vendor/v8/include/v8-statistics.h +217 -0
- data/vendor/v8/include/v8-template.h +1079 -0
- data/vendor/v8/include/v8-traced-handle.h +420 -0
- data/vendor/v8/include/v8-typed-array.h +282 -0
- data/vendor/v8/include/v8-unwinder-state.h +31 -0
- data/vendor/v8/include/v8-unwinder.h +132 -0
- data/vendor/v8/include/v8-util.h +8 -2
- data/vendor/v8/include/v8-value-serializer-version.h +1 -1
- data/vendor/v8/include/v8-value-serializer.h +279 -0
- data/vendor/v8/include/v8-value.h +526 -0
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm.h +257 -0
- data/vendor/v8/include/v8-weak-callback-info.h +87 -0
- data/vendor/v8/include/v8.h +41 -12051
- data/vendor/v8/include/v8config.h +142 -21
- metadata +64 -10
- data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +0 -30
- data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -5,209 +5,196 @@
|
|
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"
|
8
15
|
#include "cppgc/visitor.h"
|
9
|
-
#include "v8-internal.h"
|
10
|
-
#include "v8.h"
|
16
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
17
|
+
#include "v8-platform.h" // NOLINT(build/include_directory)
|
18
|
+
#include "v8-traced-handle.h" // NOLINT(build/include_directory)
|
19
|
+
|
20
|
+
namespace cppgc {
|
21
|
+
class AllocationHandle;
|
22
|
+
class HeapHandle;
|
23
|
+
} // namespace cppgc
|
11
24
|
|
12
25
|
namespace v8 {
|
13
26
|
|
14
|
-
class
|
15
|
-
template <typename T>
|
16
|
-
class JSMember;
|
27
|
+
class Object;
|
17
28
|
|
18
29
|
namespace internal {
|
30
|
+
class CppHeap;
|
31
|
+
} // namespace internal
|
19
32
|
|
20
|
-
class
|
33
|
+
class CustomSpaceStatisticsReceiver;
|
21
34
|
|
22
|
-
|
23
|
-
|
35
|
+
/**
|
36
|
+
* Describes how V8 wrapper objects maintain references to garbage-collected C++
|
37
|
+
* objects.
|
38
|
+
*/
|
39
|
+
struct WrapperDescriptor final {
|
24
40
|
/**
|
25
|
-
*
|
26
|
-
* object
|
41
|
+
* The index used on `v8::Ojbect::SetAlignedPointerFromInternalField()` and
|
42
|
+
* related APIs to add additional data to an object which is used to identify
|
43
|
+
* JS->C++ references.
|
27
44
|
*/
|
28
|
-
|
45
|
+
using InternalFieldIndex = int;
|
29
46
|
|
30
47
|
/**
|
31
|
-
*
|
48
|
+
* Unknown embedder id. The value is reserved for internal usages and must not
|
49
|
+
* be used with `CppHeap`.
|
32
50
|
*/
|
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;
|
51
|
+
static constexpr uint16_t kUnknownEmbedderId = UINT16_MAX;
|
45
52
|
|
46
|
-
|
47
|
-
|
53
|
+
constexpr WrapperDescriptor(InternalFieldIndex wrappable_type_index,
|
54
|
+
InternalFieldIndex wrappable_instance_index,
|
55
|
+
uint16_t embedder_id_for_garbage_collected)
|
56
|
+
: wrappable_type_index(wrappable_type_index),
|
57
|
+
wrappable_instance_index(wrappable_instance_index),
|
58
|
+
embedder_id_for_garbage_collected(embedder_id_for_garbage_collected) {}
|
48
59
|
|
49
|
-
|
50
|
-
|
60
|
+
/**
|
61
|
+
* Index of the wrappable type.
|
62
|
+
*/
|
63
|
+
InternalFieldIndex wrappable_type_index;
|
51
64
|
|
52
|
-
|
53
|
-
|
65
|
+
/**
|
66
|
+
* Index of the wrappable instance.
|
67
|
+
*/
|
68
|
+
InternalFieldIndex wrappable_instance_index;
|
54
69
|
|
55
|
-
|
56
|
-
|
57
|
-
|
70
|
+
/**
|
71
|
+
* Embedder id identifying instances of garbage-collected objects. It is
|
72
|
+
* expected that the first field of the wrappable type is a uint16_t holding
|
73
|
+
* the id. Only references to instances of wrappables types with an id of
|
74
|
+
* `embedder_id_for_garbage_collected` will be considered by CppHeap.
|
75
|
+
*/
|
76
|
+
uint16_t embedder_id_for_garbage_collected;
|
58
77
|
};
|
59
78
|
|
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
|
-
}
|
78
|
-
|
79
|
-
void JSMemberBase::Reset() {
|
80
|
-
if (IsEmpty()) return;
|
81
|
-
Delete(val_);
|
82
|
-
val_ = nullptr;
|
83
|
-
}
|
79
|
+
struct V8_EXPORT CppHeapCreateParams {
|
80
|
+
CppHeapCreateParams(const CppHeapCreateParams&) = delete;
|
81
|
+
CppHeapCreateParams& operator=(const CppHeapCreateParams&) = delete;
|
84
82
|
|
85
|
-
|
83
|
+
std::vector<std::unique_ptr<cppgc::CustomSpaceBase>> custom_spaces;
|
84
|
+
WrapperDescriptor wrapper_descriptor;
|
85
|
+
};
|
86
86
|
|
87
87
|
/**
|
88
|
-
* A
|
89
|
-
* only be used in GarbageCollected objects and must be processed in a Trace()
|
90
|
-
* method.
|
88
|
+
* A heap for allocating managed C++ objects.
|
91
89
|
*/
|
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
|
-
|
90
|
+
class V8_EXPORT CppHeap {
|
97
91
|
public:
|
98
|
-
|
99
|
-
|
100
|
-
template <typename U,
|
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)) {}
|
92
|
+
static std::unique_ptr<CppHeap> Create(v8::Platform* platform,
|
93
|
+
const CppHeapCreateParams& params);
|
105
94
|
|
106
|
-
|
95
|
+
virtual ~CppHeap() = default;
|
107
96
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
97
|
+
/**
|
98
|
+
* \returns the opaque handle for allocating objects using
|
99
|
+
* `MakeGarbageCollected()`.
|
100
|
+
*/
|
101
|
+
cppgc::AllocationHandle& GetAllocationHandle();
|
113
102
|
|
114
|
-
|
103
|
+
/**
|
104
|
+
* \returns the opaque heap handle which may be used to refer to this heap in
|
105
|
+
* other APIs. Valid as long as the underlying `CppHeap` is alive.
|
106
|
+
*/
|
107
|
+
cppgc::HeapHandle& GetHeapHandle();
|
115
108
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
109
|
+
/**
|
110
|
+
* Terminate clears all roots and performs multiple garbage collections to
|
111
|
+
* reclaim potentially newly created objects in destructors.
|
112
|
+
*
|
113
|
+
* After this call, object allocation is prohibited.
|
114
|
+
*/
|
115
|
+
void Terminate();
|
121
116
|
|
122
|
-
|
117
|
+
/**
|
118
|
+
* \param detail_level specifies whether should return detailed
|
119
|
+
* statistics or only brief summary statistics.
|
120
|
+
* \returns current CppHeap statistics regarding memory consumption
|
121
|
+
* and utilization.
|
122
|
+
*/
|
123
|
+
cppgc::HeapStatistics CollectStatistics(
|
124
|
+
cppgc::HeapStatistics::DetailLevel detail_level);
|
123
125
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
126
|
+
/**
|
127
|
+
* Collects statistics for the given spaces and reports them to the receiver.
|
128
|
+
*
|
129
|
+
* \param custom_spaces a collection of custom space indicies.
|
130
|
+
* \param receiver an object that gets the results.
|
131
|
+
*/
|
132
|
+
void CollectCustomSpaceStatisticsAtLastGC(
|
133
|
+
std::vector<cppgc::CustomSpaceIndex> custom_spaces,
|
134
|
+
std::unique_ptr<CustomSpaceStatisticsReceiver> receiver);
|
129
135
|
|
130
|
-
|
136
|
+
/**
|
137
|
+
* Enables a detached mode that allows testing garbage collection using
|
138
|
+
* `cppgc::testing` APIs. Once used, the heap cannot be attached to an
|
139
|
+
* `Isolate` anymore.
|
140
|
+
*/
|
141
|
+
void EnableDetachedGarbageCollectionsForTesting();
|
131
142
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
143
|
+
/**
|
144
|
+
* Performs a stop-the-world garbage collection for testing purposes.
|
145
|
+
*
|
146
|
+
* \param stack_state The stack state to assume for the garbage collection.
|
147
|
+
*/
|
148
|
+
void CollectGarbageForTesting(cppgc::EmbedderStackState stack_state);
|
137
149
|
|
138
|
-
|
139
|
-
|
150
|
+
/**
|
151
|
+
* Performs a stop-the-world minor garbage collection for testing purposes.
|
152
|
+
*
|
153
|
+
* \param stack_state The stack state to assume for the garbage collection.
|
154
|
+
*/
|
155
|
+
void CollectGarbageInYoungGenerationForTesting(
|
156
|
+
cppgc::EmbedderStackState stack_state);
|
140
157
|
|
141
|
-
|
158
|
+
private:
|
159
|
+
CppHeap() = default;
|
142
160
|
|
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
|
-
}
|
161
|
+
friend class internal::CppHeap;
|
149
162
|
};
|
150
163
|
|
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
164
|
class JSVisitor : public cppgc::Visitor {
|
198
165
|
public:
|
199
166
|
explicit JSVisitor(cppgc::Visitor::Key key) : cppgc::Visitor(key) {}
|
167
|
+
~JSVisitor() override = default;
|
200
168
|
|
201
|
-
|
202
|
-
|
203
|
-
if (ref.IsEmpty()) return;
|
169
|
+
void Trace(const TracedReferenceBase& ref) {
|
170
|
+
if (ref.IsEmptyThreadSafe()) return;
|
204
171
|
Visit(ref);
|
205
172
|
}
|
206
173
|
|
207
174
|
protected:
|
208
175
|
using cppgc::Visitor::Visit;
|
209
176
|
|
210
|
-
virtual void Visit(const
|
177
|
+
virtual void Visit(const TracedReferenceBase& ref) {}
|
178
|
+
};
|
179
|
+
|
180
|
+
/**
|
181
|
+
* Provided as input to `CppHeap::CollectCustomSpaceStatisticsAtLastGC()`.
|
182
|
+
*
|
183
|
+
* Its method is invoked with the results of the statistic collection.
|
184
|
+
*/
|
185
|
+
class CustomSpaceStatisticsReceiver {
|
186
|
+
public:
|
187
|
+
virtual ~CustomSpaceStatisticsReceiver() = default;
|
188
|
+
/**
|
189
|
+
* Reports the size of a space at the last GC. It is called for each space
|
190
|
+
* that was requested in `CollectCustomSpaceStatisticsAtLastGC()`.
|
191
|
+
*
|
192
|
+
* \param space_index The index of the space.
|
193
|
+
* \param bytes The total size of live objects in the space at the last GC.
|
194
|
+
* It is zero if there was no GC yet.
|
195
|
+
*/
|
196
|
+
virtual void AllocatedBytes(cppgc::CustomSpaceIndex space_index,
|
197
|
+
size_t bytes) = 0;
|
211
198
|
};
|
212
199
|
|
213
200
|
} // namespace v8
|
@@ -215,9 +202,14 @@ class JSVisitor : public cppgc::Visitor {
|
|
215
202
|
namespace cppgc {
|
216
203
|
|
217
204
|
template <typename T>
|
218
|
-
struct TraceTrait<v8::
|
219
|
-
static
|
220
|
-
|
205
|
+
struct TraceTrait<v8::TracedReference<T>> {
|
206
|
+
static cppgc::TraceDescriptor GetTraceDescriptor(const void* self) {
|
207
|
+
return {nullptr, Trace};
|
208
|
+
}
|
209
|
+
|
210
|
+
static void Trace(Visitor* visitor, const void* self) {
|
211
|
+
static_cast<v8::JSVisitor*>(visitor)->Trace(
|
212
|
+
*static_cast<const v8::TracedReference<T>*>(self));
|
221
213
|
}
|
222
214
|
};
|
223
215
|
|
@@ -0,0 +1,80 @@
|
|
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 tru if this data is a |v8::FixedArray|
|
32
|
+
*/
|
33
|
+
bool IsFixedArray() const;
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Returns true if this data is a |v8::Private|.
|
37
|
+
*/
|
38
|
+
bool IsPrivate() const;
|
39
|
+
|
40
|
+
/**
|
41
|
+
* Returns true if this data is a |v8::ObjectTemplate|.
|
42
|
+
*/
|
43
|
+
bool IsObjectTemplate() const;
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Returns true if this data is a |v8::FunctionTemplate|.
|
47
|
+
*/
|
48
|
+
bool IsFunctionTemplate() const;
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Returns true if this data is a |v8::Context|.
|
52
|
+
*/
|
53
|
+
bool IsContext() const;
|
54
|
+
|
55
|
+
private:
|
56
|
+
Data();
|
57
|
+
};
|
58
|
+
|
59
|
+
/**
|
60
|
+
* A fixed-sized array with elements of type Data.
|
61
|
+
*/
|
62
|
+
class V8_EXPORT FixedArray : public Data {
|
63
|
+
public:
|
64
|
+
int Length() const;
|
65
|
+
Local<Data> Get(Local<Context> context, int i) const;
|
66
|
+
|
67
|
+
V8_INLINE static FixedArray* Cast(Data* data) {
|
68
|
+
#ifdef V8_ENABLE_CHECKS
|
69
|
+
CheckCast(data);
|
70
|
+
#endif
|
71
|
+
return reinterpret_cast<FixedArray*>(data);
|
72
|
+
}
|
73
|
+
|
74
|
+
private:
|
75
|
+
static void CheckCast(Data* obj);
|
76
|
+
};
|
77
|
+
|
78
|
+
} // namespace v8
|
79
|
+
|
80
|
+
#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_
|
@@ -0,0 +1,168 @@
|
|
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_DEBUG_H_
|
6
|
+
#define INCLUDE_V8_DEBUG_H_
|
7
|
+
|
8
|
+
#include <stdint.h>
|
9
|
+
|
10
|
+
#include "v8-script.h" // NOLINT(build/include_directory)
|
11
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
12
|
+
|
13
|
+
namespace v8 {
|
14
|
+
|
15
|
+
class Isolate;
|
16
|
+
class String;
|
17
|
+
|
18
|
+
/**
|
19
|
+
* A single JavaScript stack frame.
|
20
|
+
*/
|
21
|
+
class V8_EXPORT StackFrame {
|
22
|
+
public:
|
23
|
+
/**
|
24
|
+
* Returns the source location, 0-based, for the associated function call.
|
25
|
+
*/
|
26
|
+
Location GetLocation() const;
|
27
|
+
|
28
|
+
/**
|
29
|
+
* Returns the number, 1-based, of the line for the associate function call.
|
30
|
+
* This method will return Message::kNoLineNumberInfo if it is unable to
|
31
|
+
* retrieve the line number, or if kLineNumber was not passed as an option
|
32
|
+
* when capturing the StackTrace.
|
33
|
+
*/
|
34
|
+
int GetLineNumber() const { return GetLocation().GetLineNumber() + 1; }
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Returns the 1-based column offset on the line for the associated function
|
38
|
+
* call.
|
39
|
+
* This method will return Message::kNoColumnInfo if it is unable to retrieve
|
40
|
+
* the column number, or if kColumnOffset was not passed as an option when
|
41
|
+
* capturing the StackTrace.
|
42
|
+
*/
|
43
|
+
int GetColumn() const { return GetLocation().GetColumnNumber() + 1; }
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Returns the id of the script for the function for this StackFrame.
|
47
|
+
* This method will return Message::kNoScriptIdInfo if it is unable to
|
48
|
+
* retrieve the script id, or if kScriptId was not passed as an option when
|
49
|
+
* capturing the StackTrace.
|
50
|
+
*/
|
51
|
+
int GetScriptId() const;
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Returns the name of the resource that contains the script for the
|
55
|
+
* function for this StackFrame.
|
56
|
+
*/
|
57
|
+
Local<String> GetScriptName() const;
|
58
|
+
|
59
|
+
/**
|
60
|
+
* Returns the name of the resource that contains the script for the
|
61
|
+
* function for this StackFrame or sourceURL value if the script name
|
62
|
+
* is undefined and its source ends with //# sourceURL=... string or
|
63
|
+
* deprecated //@ sourceURL=... string.
|
64
|
+
*/
|
65
|
+
Local<String> GetScriptNameOrSourceURL() const;
|
66
|
+
|
67
|
+
/**
|
68
|
+
* Returns the source of the script for the function for this StackFrame.
|
69
|
+
*/
|
70
|
+
Local<String> GetScriptSource() const;
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Returns the source mapping URL (if one is present) of the script for
|
74
|
+
* the function for this StackFrame.
|
75
|
+
*/
|
76
|
+
Local<String> GetScriptSourceMappingURL() const;
|
77
|
+
|
78
|
+
/**
|
79
|
+
* Returns the name of the function associated with this stack frame.
|
80
|
+
*/
|
81
|
+
Local<String> GetFunctionName() const;
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Returns whether or not the associated function is compiled via a call to
|
85
|
+
* eval().
|
86
|
+
*/
|
87
|
+
bool IsEval() const;
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Returns whether or not the associated function is called as a
|
91
|
+
* constructor via "new".
|
92
|
+
*/
|
93
|
+
bool IsConstructor() const;
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Returns whether or not the associated functions is defined in wasm.
|
97
|
+
*/
|
98
|
+
bool IsWasm() const;
|
99
|
+
|
100
|
+
/**
|
101
|
+
* Returns whether or not the associated function is defined by the user.
|
102
|
+
*/
|
103
|
+
bool IsUserJavaScript() const;
|
104
|
+
};
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Representation of a JavaScript stack trace. The information collected is a
|
108
|
+
* snapshot of the execution stack and the information remains valid after
|
109
|
+
* execution continues.
|
110
|
+
*/
|
111
|
+
class V8_EXPORT StackTrace {
|
112
|
+
public:
|
113
|
+
/**
|
114
|
+
* Flags that determine what information is placed captured for each
|
115
|
+
* StackFrame when grabbing the current stack trace.
|
116
|
+
* Note: these options are deprecated and we always collect all available
|
117
|
+
* information (kDetailed).
|
118
|
+
*/
|
119
|
+
enum StackTraceOptions {
|
120
|
+
kLineNumber = 1,
|
121
|
+
kColumnOffset = 1 << 1 | kLineNumber,
|
122
|
+
kScriptName = 1 << 2,
|
123
|
+
kFunctionName = 1 << 3,
|
124
|
+
kIsEval = 1 << 4,
|
125
|
+
kIsConstructor = 1 << 5,
|
126
|
+
kScriptNameOrSourceURL = 1 << 6,
|
127
|
+
kScriptId = 1 << 7,
|
128
|
+
kExposeFramesAcrossSecurityOrigins = 1 << 8,
|
129
|
+
kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName,
|
130
|
+
kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
|
131
|
+
};
|
132
|
+
|
133
|
+
/**
|
134
|
+
* Returns a StackFrame at a particular index.
|
135
|
+
*/
|
136
|
+
Local<StackFrame> GetFrame(Isolate* isolate, uint32_t index) const;
|
137
|
+
|
138
|
+
/**
|
139
|
+
* Returns the number of StackFrames.
|
140
|
+
*/
|
141
|
+
int GetFrameCount() const;
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Grab a snapshot of the current JavaScript execution stack.
|
145
|
+
*
|
146
|
+
* \param frame_limit The maximum number of stack frames we want to capture.
|
147
|
+
* \param options Enumerates the set of things we will capture for each
|
148
|
+
* StackFrame.
|
149
|
+
*/
|
150
|
+
static Local<StackTrace> CurrentStackTrace(
|
151
|
+
Isolate* isolate, int frame_limit, StackTraceOptions options = kDetailed);
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Returns the first valid script name or source URL starting at the top of
|
155
|
+
* the JS stack. The returned string is either an empty handle if no script
|
156
|
+
* name/url was found or a non-zero-length string.
|
157
|
+
*
|
158
|
+
* This method is equivalent to calling StackTrace::CurrentStackTrace and
|
159
|
+
* walking the resulting frames from the beginning until a non-empty script
|
160
|
+
* name/url is found. The difference is that this method won't allocate
|
161
|
+
* a stack trace.
|
162
|
+
*/
|
163
|
+
static Local<String> CurrentScriptNameOrSourceURL(Isolate* isolate);
|
164
|
+
};
|
165
|
+
|
166
|
+
} // namespace v8
|
167
|
+
|
168
|
+
#endif // INCLUDE_V8_DEBUG_H_
|