libv8-node 22.7.0.4-aarch64-linux → 24.1.0.0-aarch64-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.
- checksums.yaml +4 -4
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/aarch64-linux/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/allocation.h +11 -13
- data/vendor/v8/include/cppgc/default-platform.h +3 -2
- data/vendor/v8/include/cppgc/garbage-collected.h +8 -0
- data/vendor/v8/include/cppgc/heap-consistency.h +1 -1
- data/vendor/v8/include/cppgc/heap-statistics.h +2 -0
- data/vendor/v8/include/cppgc/internal/api-constants.h +2 -14
- data/vendor/v8/include/cppgc/internal/base-page-handle.h +2 -4
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +0 -4
- data/vendor/v8/include/cppgc/internal/caged-heap.h +0 -4
- data/vendor/v8/include/cppgc/internal/compiler-specific.h +9 -1
- data/vendor/v8/include/cppgc/internal/conditional-stack-allocated.h +41 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +12 -10
- data/vendor/v8/include/cppgc/internal/logging.h +3 -3
- data/vendor/v8/include/cppgc/internal/member-storage.h +69 -20
- data/vendor/v8/include/cppgc/internal/name-trait.h +5 -1
- data/vendor/v8/include/cppgc/internal/persistent-node.h +8 -3
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +48 -11
- data/vendor/v8/include/cppgc/macros.h +21 -0
- data/vendor/v8/include/cppgc/member.h +70 -36
- data/vendor/v8/include/cppgc/name-provider.h +10 -0
- data/vendor/v8/include/cppgc/platform.h +11 -0
- data/vendor/v8/include/cppgc/type-traits.h +1 -0
- data/vendor/v8/include/cppgc/visitor.h +25 -1
- data/vendor/v8/include/libplatform/libplatform-export.h +2 -2
- data/vendor/v8/include/libplatform/v8-tracing.h +0 -1
- data/vendor/v8/include/v8-array-buffer.h +143 -46
- data/vendor/v8/include/v8-callbacks.h +94 -31
- data/vendor/v8/include/v8-context.h +48 -15
- data/vendor/v8/include/v8-cppgc.h +5 -56
- data/vendor/v8/include/v8-data.h +5 -0
- data/vendor/v8/include/v8-date.h +9 -0
- data/vendor/v8/include/v8-debug.h +11 -0
- data/vendor/v8/include/v8-embedder-heap.h +1 -29
- data/vendor/v8/include/v8-exception.h +72 -0
- data/vendor/v8/include/v8-external-memory-accounter.h +60 -0
- data/vendor/v8/include/v8-fast-api-calls.h +41 -206
- data/vendor/v8/include/v8-function-callback.h +190 -78
- data/vendor/v8/include/v8-function.h +11 -3
- data/vendor/v8/include/v8-handle-base.h +20 -2
- data/vendor/v8/include/v8-initialization.h +26 -1
- data/vendor/v8/include/v8-inspector.h +10 -3
- data/vendor/v8/include/v8-internal.h +638 -315
- data/vendor/v8/include/v8-isolate.h +275 -189
- data/vendor/v8/include/v8-local-handle.h +69 -42
- data/vendor/v8/include/v8-maybe.h +2 -1
- data/vendor/v8/include/v8-memory-span.h +149 -24
- data/vendor/v8/include/v8-message.h +9 -22
- data/vendor/v8/include/v8-metrics.h +14 -0
- data/vendor/v8/include/v8-microtask-queue.h +0 -5
- data/vendor/v8/include/v8-object.h +291 -37
- data/vendor/v8/include/v8-persistent-handle.h +17 -36
- data/vendor/v8/include/v8-platform.h +66 -45
- data/vendor/v8/include/v8-primitive.h +221 -5
- data/vendor/v8/include/v8-profiler.h +51 -2
- data/vendor/v8/include/v8-promise.h +2 -2
- data/vendor/v8/include/v8-proxy.h +0 -1
- data/vendor/v8/include/v8-regexp.h +0 -1
- data/vendor/v8/include/v8-sandbox.h +173 -0
- data/vendor/v8/include/v8-script.h +65 -17
- data/vendor/v8/include/v8-snapshot.h +38 -2
- data/vendor/v8/include/v8-source-location.h +6 -1
- data/vendor/v8/include/v8-template.h +111 -263
- data/vendor/v8/include/v8-trace-categories.h +23 -0
- data/vendor/v8/include/v8-traced-handle.h +20 -32
- data/vendor/v8/include/v8-typed-array.h +6 -10
- data/vendor/v8/include/v8-unwinder-state.h +2 -3
- data/vendor/v8/include/v8-unwinder.h +2 -1
- data/vendor/v8/include/v8-util.h +1 -117
- data/vendor/v8/include/v8-value-serializer-version.h +3 -3
- data/vendor/v8/include/v8-value.h +21 -2
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm.h +27 -0
- data/vendor/v8/include/v8-weak-callback-info.h +20 -12
- data/vendor/v8/include/v8.h +3 -3
- data/vendor/v8/include/v8config.h +83 -45
- metadata +6 -3
- data/vendor/v8/include/cppgc/ephemeron-pair.h +0 -30
@@ -0,0 +1,173 @@
|
|
1
|
+
// Copyright 2024 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_SANDBOX_H_
|
6
|
+
#define INCLUDE_V8_SANDBOX_H_
|
7
|
+
|
8
|
+
#include <cstdint>
|
9
|
+
|
10
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
11
|
+
#include "v8config.h" // NOLINT(build/include_directory)
|
12
|
+
|
13
|
+
namespace v8 {
|
14
|
+
|
15
|
+
/**
|
16
|
+
* A pointer tag used for wrapping and unwrapping `CppHeap` pointers as used
|
17
|
+
* with JS API wrapper objects that rely on `v8::Object::Wrap()` and
|
18
|
+
* `v8::Object::Unwrap()`.
|
19
|
+
*
|
20
|
+
* The CppHeapPointers use a range-based type checking scheme, where on access
|
21
|
+
* to a pointer, the actual type of the pointer is checked to be within a
|
22
|
+
* specified range of types. This allows supporting type hierarchies, where a
|
23
|
+
* type check for a supertype must succeed for any subtype.
|
24
|
+
*
|
25
|
+
* The tag is currently in practice limited to 15 bits since it needs to fit
|
26
|
+
* together with a marking bit into the unused parts of a pointer.
|
27
|
+
*/
|
28
|
+
enum class CppHeapPointerTag : uint16_t {
|
29
|
+
kFirstTag = 0,
|
30
|
+
kNullTag = 0,
|
31
|
+
|
32
|
+
/**
|
33
|
+
* The lower type ids are reserved for the embedder to assign. For that, the
|
34
|
+
* main requirement is that all (transitive) child classes of a given parent
|
35
|
+
* class have type ids in the same range, and that there are no unrelated
|
36
|
+
* types in that range. For example, given the following type hierarchy:
|
37
|
+
*
|
38
|
+
* A F
|
39
|
+
* / \
|
40
|
+
* B E
|
41
|
+
* / \
|
42
|
+
* C D
|
43
|
+
*
|
44
|
+
* a potential type id assignment that satistifes these requirements is
|
45
|
+
* {C: 0, D: 1, B: 2, A: 3, E: 4, F: 5}. With that, the type check for type A
|
46
|
+
* would check for the range [0, 4], while the check for B would check range
|
47
|
+
* [0, 2], and for F it would simply check [5, 5].
|
48
|
+
*
|
49
|
+
* In addition, there is an option for performance tweaks: if the size of the
|
50
|
+
* type range corresponding to a supertype is a power of two and starts at a
|
51
|
+
* power of two (e.g. [0x100, 0x13f]), then the compiler can often optimize
|
52
|
+
* the type check to use even fewer instructions (essentially replace a AND +
|
53
|
+
* SUB with a single AND).
|
54
|
+
*/
|
55
|
+
|
56
|
+
kDefaultTag = 0x7000,
|
57
|
+
|
58
|
+
kZappedEntryTag = 0x7ffd,
|
59
|
+
kEvacuationEntryTag = 0x7ffe,
|
60
|
+
kFreeEntryTag = 0x7fff,
|
61
|
+
// The tags are limited to 15 bits, so the last tag is 0x7fff.
|
62
|
+
kLastTag = 0x7fff,
|
63
|
+
};
|
64
|
+
|
65
|
+
// Convenience struct to represent tag ranges. This is used for type checks
|
66
|
+
// against supertypes, which cover a range of types (their subtypes).
|
67
|
+
// Both the lower- and the upper bound are inclusive. In other words, this
|
68
|
+
// struct represents the range [lower_bound, upper_bound].
|
69
|
+
// TODO(saelo): reuse internal::TagRange here.
|
70
|
+
struct CppHeapPointerTagRange {
|
71
|
+
constexpr CppHeapPointerTagRange(CppHeapPointerTag lower,
|
72
|
+
CppHeapPointerTag upper)
|
73
|
+
: lower_bound(lower), upper_bound(upper) {}
|
74
|
+
CppHeapPointerTag lower_bound;
|
75
|
+
CppHeapPointerTag upper_bound;
|
76
|
+
|
77
|
+
// Check whether the tag of the given CppHeapPointerTable entry is within
|
78
|
+
// this range. This method encodes implementation details of the
|
79
|
+
// CppHeapPointerTable, which is necessary as it is used by
|
80
|
+
// ReadCppHeapPointerField below.
|
81
|
+
// Returns true if the check is successful and the tag of the given entry is
|
82
|
+
// within this range, false otherwise.
|
83
|
+
bool CheckTagOf(uint64_t entry) {
|
84
|
+
// Note: the cast to uint32_t is important here. Otherwise, the uint16_t's
|
85
|
+
// would be promoted to int in the range check below, which would result in
|
86
|
+
// undefined behavior (signed integer undeflow) if the actual value is less
|
87
|
+
// than the lower bound. Then, the compiler would take advantage of the
|
88
|
+
// undefined behavior and turn the range check into a simple
|
89
|
+
// `actual_tag <= last_tag` comparison, which is incorrect.
|
90
|
+
uint32_t actual_tag = static_cast<uint16_t>(entry);
|
91
|
+
// The actual_tag is shifted to the left by one and contains the marking
|
92
|
+
// bit in the LSB. To ignore that during the type check, simply add one to
|
93
|
+
// the (shifted) range.
|
94
|
+
constexpr int kTagShift = internal::kCppHeapPointerTagShift;
|
95
|
+
uint32_t first_tag = static_cast<uint32_t>(lower_bound) << kTagShift;
|
96
|
+
uint32_t last_tag = (static_cast<uint32_t>(upper_bound) << kTagShift) + 1;
|
97
|
+
return actual_tag >= first_tag && actual_tag <= last_tag;
|
98
|
+
}
|
99
|
+
};
|
100
|
+
|
101
|
+
constexpr CppHeapPointerTagRange kAnyCppHeapPointer(
|
102
|
+
CppHeapPointerTag::kFirstTag, CppHeapPointerTag::kLastTag);
|
103
|
+
|
104
|
+
class SandboxHardwareSupport {
|
105
|
+
public:
|
106
|
+
/**
|
107
|
+
* Initialize sandbox hardware support. This needs to be called before
|
108
|
+
* creating any thread that might access sandbox memory since it sets up
|
109
|
+
* hardware permissions to the memory that will be inherited on clone.
|
110
|
+
*/
|
111
|
+
V8_EXPORT static void InitializeBeforeThreadCreation();
|
112
|
+
};
|
113
|
+
|
114
|
+
namespace internal {
|
115
|
+
|
116
|
+
#ifdef V8_COMPRESS_POINTERS
|
117
|
+
V8_INLINE static Address* GetCppHeapPointerTableBase(v8::Isolate* isolate) {
|
118
|
+
Address addr = reinterpret_cast<Address>(isolate) +
|
119
|
+
Internals::kIsolateCppHeapPointerTableOffset +
|
120
|
+
Internals::kExternalPointerTableBasePointerOffset;
|
121
|
+
return *reinterpret_cast<Address**>(addr);
|
122
|
+
}
|
123
|
+
#endif // V8_COMPRESS_POINTERS
|
124
|
+
|
125
|
+
template <typename T>
|
126
|
+
V8_INLINE static T* ReadCppHeapPointerField(v8::Isolate* isolate,
|
127
|
+
Address heap_object_ptr, int offset,
|
128
|
+
CppHeapPointerTagRange tag_range) {
|
129
|
+
#ifdef V8_COMPRESS_POINTERS
|
130
|
+
// See src/sandbox/cppheap-pointer-table-inl.h. Logic duplicated here so
|
131
|
+
// it can be inlined and doesn't require an additional call.
|
132
|
+
const CppHeapPointerHandle handle =
|
133
|
+
Internals::ReadRawField<CppHeapPointerHandle>(heap_object_ptr, offset);
|
134
|
+
const uint32_t index = handle >> kExternalPointerIndexShift;
|
135
|
+
const Address* table = GetCppHeapPointerTableBase(isolate);
|
136
|
+
const std::atomic<Address>* ptr =
|
137
|
+
reinterpret_cast<const std::atomic<Address>*>(&table[index]);
|
138
|
+
Address entry = std::atomic_load_explicit(ptr, std::memory_order_relaxed);
|
139
|
+
|
140
|
+
Address pointer = entry;
|
141
|
+
if (V8_LIKELY(tag_range.CheckTagOf(entry))) {
|
142
|
+
pointer = entry >> kCppHeapPointerPayloadShift;
|
143
|
+
} else {
|
144
|
+
// If the type check failed, we simply return nullptr here. That way:
|
145
|
+
// 1. The null handle always results in nullptr being returned here, which
|
146
|
+
// is a desired property. Otherwise, we would need an explicit check for
|
147
|
+
// the null handle above, and therefore an additional branch. This
|
148
|
+
// works because the 0th entry of the table always contains nullptr
|
149
|
+
// tagged with the null tag (i.e. an all-zeros entry). As such,
|
150
|
+
// regardless of whether the type check succeeds, the result will
|
151
|
+
// always be nullptr.
|
152
|
+
// 2. The returned pointer is guaranteed to crash even on platforms with
|
153
|
+
// top byte ignore (TBI), such as Arm64. The alternative would be to
|
154
|
+
// simply return the original entry with the left-shifted payload.
|
155
|
+
// However, due to TBI, an access to that may not always result in a
|
156
|
+
// crash (specifically, if the second most significant byte happens to
|
157
|
+
// be zero). In addition, there shouldn't be a difference on Arm64
|
158
|
+
// between returning nullptr or the original entry, since it will
|
159
|
+
// simply compile to a `csel x0, x8, xzr, lo` instead of a
|
160
|
+
// `csel x0, x10, x8, lo` instruction.
|
161
|
+
pointer = 0;
|
162
|
+
}
|
163
|
+
return reinterpret_cast<T*>(pointer);
|
164
|
+
#else // !V8_COMPRESS_POINTERS
|
165
|
+
return reinterpret_cast<T*>(
|
166
|
+
Internals::ReadRawField<Address>(heap_object_ptr, offset));
|
167
|
+
#endif // !V8_COMPRESS_POINTERS
|
168
|
+
}
|
169
|
+
|
170
|
+
} // namespace internal
|
171
|
+
} // namespace v8
|
172
|
+
|
173
|
+
#endif // INCLUDE_V8_SANDBOX_H_
|
@@ -129,6 +129,11 @@ class V8_EXPORT ModuleRequest : public Data {
|
|
129
129
|
*/
|
130
130
|
Local<String> GetSpecifier() const;
|
131
131
|
|
132
|
+
/**
|
133
|
+
* Returns the module import phase for this ModuleRequest.
|
134
|
+
*/
|
135
|
+
ModuleImportPhase GetPhase() const;
|
136
|
+
|
132
137
|
/**
|
133
138
|
* Returns the source code offset of this module request.
|
134
139
|
* Use Module::SourceOffsetToLocation to convert this to line/column numbers.
|
@@ -150,7 +155,7 @@ class V8_EXPORT ModuleRequest : public Data {
|
|
150
155
|
*/
|
151
156
|
Local<FixedArray> GetImportAttributes() const;
|
152
157
|
|
153
|
-
|
158
|
+
V8_DEPRECATED("Use GetImportAttributes instead")
|
154
159
|
Local<FixedArray> GetImportAssertions() const {
|
155
160
|
return GetImportAttributes();
|
156
161
|
}
|
@@ -210,7 +215,10 @@ class V8_EXPORT Module : public Data {
|
|
210
215
|
|
211
216
|
using ResolveModuleCallback = MaybeLocal<Module> (*)(
|
212
217
|
Local<Context> context, Local<String> specifier,
|
213
|
-
Local<FixedArray>
|
218
|
+
Local<FixedArray> import_attributes, Local<Module> referrer);
|
219
|
+
using ResolveSourceCallback = MaybeLocal<Object> (*)(
|
220
|
+
Local<Context> context, Local<String> specifier,
|
221
|
+
Local<FixedArray> import_attributes, Local<Module> referrer);
|
214
222
|
|
215
223
|
/**
|
216
224
|
* Instantiates the module and its dependencies.
|
@@ -220,7 +228,8 @@ class V8_EXPORT Module : public Data {
|
|
220
228
|
* exception is propagated.)
|
221
229
|
*/
|
222
230
|
V8_WARN_UNUSED_RESULT Maybe<bool> InstantiateModule(
|
223
|
-
Local<Context> context, ResolveModuleCallback
|
231
|
+
Local<Context> context, ResolveModuleCallback module_callback,
|
232
|
+
ResolveSourceCallback source_callback = nullptr);
|
224
233
|
|
225
234
|
/**
|
226
235
|
* Evaluates the module and its dependencies.
|
@@ -264,6 +273,13 @@ class V8_EXPORT Module : public Data {
|
|
264
273
|
*/
|
265
274
|
bool IsGraphAsync() const;
|
266
275
|
|
276
|
+
/**
|
277
|
+
* Returns whether this module is individually asynchronous (for example,
|
278
|
+
* if it's a Source Text Module Record containing a top-level await).
|
279
|
+
* See [[HasTLA]] in https://tc39.es/ecma262/#sec-cyclic-module-records
|
280
|
+
*/
|
281
|
+
bool HasTopLevelAwait() const;
|
282
|
+
|
267
283
|
/**
|
268
284
|
* Returns whether the module is a SourceTextModule.
|
269
285
|
*/
|
@@ -322,6 +338,14 @@ class V8_EXPORT Module : public Data {
|
|
322
338
|
static void CheckCast(Data* obj);
|
323
339
|
};
|
324
340
|
|
341
|
+
class V8_EXPORT CompileHintsCollector : public Data {
|
342
|
+
public:
|
343
|
+
/**
|
344
|
+
* Returns the positions of lazy functions which were compiled and executed.
|
345
|
+
*/
|
346
|
+
std::vector<int> GetCompileHints(Isolate* isolate) const;
|
347
|
+
};
|
348
|
+
|
325
349
|
/**
|
326
350
|
* A compiled JavaScript script, tied to a Context which was active when the
|
327
351
|
* script was compiled.
|
@@ -359,7 +383,15 @@ class V8_EXPORT Script : public Data {
|
|
359
383
|
* If the script was compiled, returns the positions of lazy functions which
|
360
384
|
* were eventually compiled and executed.
|
361
385
|
*/
|
386
|
+
V8_DEPRECATE_SOON("Use GetCompileHintsCollector instead")
|
362
387
|
std::vector<int> GetProducedCompileHints() const;
|
388
|
+
|
389
|
+
/**
|
390
|
+
* Get a compile hints collector object which we can use later for retrieving
|
391
|
+
* compile hints (= positions of lazy functions which were compiled and
|
392
|
+
* executed).
|
393
|
+
*/
|
394
|
+
Local<CompileHintsCollector> GetCompileHintsCollector() const;
|
363
395
|
};
|
364
396
|
|
365
397
|
enum class ScriptType { kClassic, kModule };
|
@@ -640,12 +672,34 @@ class V8_EXPORT ScriptCompiler {
|
|
640
672
|
|
641
673
|
enum CompileOptions {
|
642
674
|
kNoCompileOptions = 0,
|
643
|
-
kConsumeCodeCache,
|
644
|
-
kEagerCompile,
|
645
|
-
kProduceCompileHints,
|
646
|
-
kConsumeCompileHints
|
675
|
+
kConsumeCodeCache = 1 << 0,
|
676
|
+
kEagerCompile = 1 << 1,
|
677
|
+
kProduceCompileHints = 1 << 2,
|
678
|
+
kConsumeCompileHints = 1 << 3,
|
679
|
+
kFollowCompileHintsMagicComment = 1 << 4,
|
680
|
+
kFollowCompileHintsPerFunctionMagicComment = 1 << 5,
|
647
681
|
};
|
648
682
|
|
683
|
+
static inline bool CompileOptionsIsValid(CompileOptions compile_options) {
|
684
|
+
// kConsumeCodeCache is mutually exclusive with all other flag bits.
|
685
|
+
if ((compile_options & kConsumeCodeCache) &&
|
686
|
+
compile_options != kConsumeCodeCache) {
|
687
|
+
return false;
|
688
|
+
}
|
689
|
+
// kEagerCompile is mutually exclusive with all other flag bits.
|
690
|
+
if ((compile_options & kEagerCompile) && compile_options != kEagerCompile) {
|
691
|
+
return false;
|
692
|
+
}
|
693
|
+
// We don't currently support producing and consuming compile hints at the
|
694
|
+
// same time.
|
695
|
+
constexpr int produce_and_consume = CompileOptions::kProduceCompileHints |
|
696
|
+
CompileOptions::kConsumeCompileHints;
|
697
|
+
if ((compile_options & produce_and_consume) == produce_and_consume) {
|
698
|
+
return false;
|
699
|
+
}
|
700
|
+
return true;
|
701
|
+
}
|
702
|
+
|
649
703
|
/**
|
650
704
|
* The reason for which we are not requesting or providing a code cache.
|
651
705
|
*/
|
@@ -664,7 +718,8 @@ class V8_EXPORT ScriptCompiler {
|
|
664
718
|
kNoCacheBecausePacScript,
|
665
719
|
kNoCacheBecauseInDocumentWrite,
|
666
720
|
kNoCacheBecauseResourceWithNoCacheHandler,
|
667
|
-
kNoCacheBecauseDeferredProduceCodeCache
|
721
|
+
kNoCacheBecauseDeferredProduceCodeCache,
|
722
|
+
kNoCacheBecauseStaticCodeCache,
|
668
723
|
};
|
669
724
|
|
670
725
|
/**
|
@@ -722,6 +777,8 @@ class V8_EXPORT ScriptCompiler {
|
|
722
777
|
|
723
778
|
static ConsumeCodeCacheTask* StartConsumingCodeCache(
|
724
779
|
Isolate* isolate, std::unique_ptr<CachedData> source);
|
780
|
+
static ConsumeCodeCacheTask* StartConsumingCodeCacheOnBackground(
|
781
|
+
Isolate* isolate, std::unique_ptr<CachedData> source);
|
725
782
|
|
726
783
|
/**
|
727
784
|
* Compiles a streamed script (bound to current context).
|
@@ -787,15 +844,6 @@ class V8_EXPORT ScriptCompiler {
|
|
787
844
|
* It is possible to specify multiple context extensions (obj in the above
|
788
845
|
* example).
|
789
846
|
*/
|
790
|
-
V8_DEPRECATED("Use CompileFunction")
|
791
|
-
static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInContext(
|
792
|
-
Local<Context> context, Source* source, size_t arguments_count,
|
793
|
-
Local<String> arguments[], size_t context_extension_count,
|
794
|
-
Local<Object> context_extensions[],
|
795
|
-
CompileOptions options = kNoCompileOptions,
|
796
|
-
NoCacheReason no_cache_reason = kNoCacheNoReason,
|
797
|
-
Local<ScriptOrModule>* script_or_module_out = nullptr);
|
798
|
-
|
799
847
|
static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunction(
|
800
848
|
Local<Context> context, Source* source, size_t arguments_count = 0,
|
801
849
|
Local<String> arguments[] = nullptr, size_t context_extension_count = 0,
|
@@ -68,6 +68,22 @@ struct SerializeContextDataCallback {
|
|
68
68
|
void* data;
|
69
69
|
};
|
70
70
|
|
71
|
+
/**
|
72
|
+
* Similar to `SerializeInternalFieldsCallback`, but is used exclusively to
|
73
|
+
* serialize API wrappers. The pointers for API wrappers always point into the
|
74
|
+
* CppHeap.
|
75
|
+
*/
|
76
|
+
struct SerializeAPIWrapperCallback {
|
77
|
+
using CallbackFunction = StartupData (*)(Local<Object> holder,
|
78
|
+
void* cpp_heap_pointer, void* data);
|
79
|
+
explicit SerializeAPIWrapperCallback(CallbackFunction function = nullptr,
|
80
|
+
void* data = nullptr)
|
81
|
+
: callback(function), data(data) {}
|
82
|
+
|
83
|
+
CallbackFunction callback;
|
84
|
+
void* data;
|
85
|
+
};
|
86
|
+
|
71
87
|
/**
|
72
88
|
* Callback and supporting data used to implement embedder logic to deserialize
|
73
89
|
* internal fields of v8::Objects.
|
@@ -97,6 +113,17 @@ struct DeserializeContextDataCallback {
|
|
97
113
|
void* data;
|
98
114
|
};
|
99
115
|
|
116
|
+
struct DeserializeAPIWrapperCallback {
|
117
|
+
using CallbackFunction = void (*)(Local<Object> holder, StartupData payload,
|
118
|
+
void* data);
|
119
|
+
explicit DeserializeAPIWrapperCallback(CallbackFunction function = nullptr,
|
120
|
+
void* data = nullptr)
|
121
|
+
: callback(function), data(data) {}
|
122
|
+
|
123
|
+
CallbackFunction callback;
|
124
|
+
void* data;
|
125
|
+
};
|
126
|
+
|
100
127
|
/**
|
101
128
|
* Helper class to create a snapshot data blob.
|
102
129
|
*
|
@@ -187,13 +214,17 @@ class V8_EXPORT SnapshotCreator {
|
|
187
214
|
* context embedder data set by
|
188
215
|
* v8::Context::SetAlignedPointerInEmbedderData().
|
189
216
|
*
|
217
|
+
* \param api_wrapper_serializer An optional callback used to serialize API
|
218
|
+
* wrapper references set via `v8::Object::Wrap()`.
|
190
219
|
*/
|
191
220
|
void SetDefaultContext(
|
192
221
|
Local<Context> context,
|
193
222
|
SerializeInternalFieldsCallback internal_fields_serializer =
|
194
223
|
SerializeInternalFieldsCallback(),
|
195
224
|
SerializeContextDataCallback context_data_serializer =
|
196
|
-
SerializeContextDataCallback()
|
225
|
+
SerializeContextDataCallback(),
|
226
|
+
SerializeAPIWrapperCallback api_wrapper_serializer =
|
227
|
+
SerializeAPIWrapperCallback());
|
197
228
|
|
198
229
|
/**
|
199
230
|
* Add additional context to be included in the snapshot blob.
|
@@ -204,12 +235,17 @@ class V8_EXPORT SnapshotCreator {
|
|
204
235
|
*
|
205
236
|
* \param context_data_serializer Similar to context_data_serializer
|
206
237
|
* in SetDefaultContext() but only applies to the context being added.
|
238
|
+
*
|
239
|
+
* \param api_wrapper_serializer Similar to api_wrapper_serializer
|
240
|
+
* in SetDefaultContext() but only applies to the context being added.
|
207
241
|
*/
|
208
242
|
size_t AddContext(Local<Context> context,
|
209
243
|
SerializeInternalFieldsCallback internal_fields_serializer =
|
210
244
|
SerializeInternalFieldsCallback(),
|
211
245
|
SerializeContextDataCallback context_data_serializer =
|
212
|
-
SerializeContextDataCallback()
|
246
|
+
SerializeContextDataCallback(),
|
247
|
+
SerializeAPIWrapperCallback api_wrapper_serializer =
|
248
|
+
SerializeAPIWrapperCallback());
|
213
249
|
|
214
250
|
/**
|
215
251
|
* Attach arbitrary V8::Data to the context snapshot, which can be retrieved
|
@@ -76,7 +76,12 @@ class V8_EXPORT SourceLocation final {
|
|
76
76
|
*
|
77
77
|
* \returns a human-readable string representing source location information.
|
78
78
|
*/
|
79
|
-
std::string ToString() const
|
79
|
+
std::string ToString() const {
|
80
|
+
if (!file_) {
|
81
|
+
return {};
|
82
|
+
}
|
83
|
+
return std::string(function_) + "@" + file_ + ":" + std::to_string(line_);
|
84
|
+
}
|
80
85
|
|
81
86
|
private:
|
82
87
|
constexpr SourceLocation(const char* function, const char* file, size_t line)
|