libv8-node 18.13.0.1-arm64-darwin → 20.2.0.0-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/arm64-darwin/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/common.h +0 -1
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +11 -10
- data/vendor/v8/include/cppgc/heap-consistency.h +46 -3
- data/vendor/v8/include/cppgc/heap-handle.h +48 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +2 -2
- data/vendor/v8/include/cppgc/heap.h +3 -7
- data/vendor/v8/include/cppgc/internal/api-constants.h +14 -1
- data/vendor/v8/include/cppgc/internal/base-page-handle.h +45 -0
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +40 -8
- data/vendor/v8/include/cppgc/internal/caged-heap.h +61 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +35 -34
- data/vendor/v8/include/cppgc/internal/member-storage.h +248 -0
- data/vendor/v8/include/cppgc/internal/name-trait.h +21 -6
- data/vendor/v8/include/cppgc/internal/persistent-node.h +11 -13
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +65 -8
- data/vendor/v8/include/cppgc/internal/write-barrier.h +153 -101
- data/vendor/v8/include/cppgc/liveness-broker.h +8 -7
- data/vendor/v8/include/cppgc/macros.h +10 -1
- data/vendor/v8/include/cppgc/member.h +424 -111
- data/vendor/v8/include/cppgc/name-provider.h +4 -4
- data/vendor/v8/include/cppgc/persistent.h +27 -24
- data/vendor/v8/include/cppgc/platform.h +7 -5
- data/vendor/v8/include/cppgc/sentinel-pointer.h +1 -1
- data/vendor/v8/include/cppgc/trace-trait.h +4 -0
- data/vendor/v8/include/cppgc/type-traits.h +13 -3
- data/vendor/v8/include/cppgc/visitor.h +104 -57
- data/vendor/v8/include/libplatform/v8-tracing.h +2 -2
- data/vendor/v8/include/v8-array-buffer.h +59 -0
- data/vendor/v8/include/v8-callbacks.h +32 -5
- data/vendor/v8/include/v8-context.h +63 -11
- data/vendor/v8/include/v8-cppgc.h +22 -0
- data/vendor/v8/include/v8-data.h +1 -1
- data/vendor/v8/include/v8-date.h +5 -0
- data/vendor/v8/include/v8-embedder-heap.h +0 -164
- data/vendor/v8/include/v8-exception.h +1 -1
- data/vendor/v8/include/v8-fast-api-calls.h +49 -31
- data/vendor/v8/include/v8-function-callback.h +69 -42
- data/vendor/v8/include/v8-function.h +9 -0
- data/vendor/v8/include/v8-initialization.h +23 -49
- data/vendor/v8/include/v8-inspector.h +32 -11
- data/vendor/v8/include/v8-internal.h +480 -183
- data/vendor/v8/include/v8-isolate.h +52 -77
- data/vendor/v8/include/v8-local-handle.h +86 -53
- data/vendor/v8/include/v8-locker.h +0 -11
- data/vendor/v8/include/v8-maybe.h +24 -1
- data/vendor/v8/include/v8-message.h +2 -4
- data/vendor/v8/include/v8-metrics.h +48 -40
- data/vendor/v8/include/v8-microtask-queue.h +6 -1
- data/vendor/v8/include/v8-object.h +29 -18
- data/vendor/v8/include/v8-persistent-handle.h +25 -18
- data/vendor/v8/include/v8-platform.h +133 -35
- data/vendor/v8/include/v8-primitive.h +27 -20
- data/vendor/v8/include/v8-profiler.h +133 -53
- data/vendor/v8/include/v8-regexp.h +2 -1
- data/vendor/v8/include/v8-script.h +91 -7
- data/vendor/v8/include/v8-snapshot.h +4 -8
- data/vendor/v8/include/v8-template.h +16 -77
- data/vendor/v8/include/v8-traced-handle.h +22 -28
- data/vendor/v8/include/v8-unwinder-state.h +4 -4
- data/vendor/v8/include/v8-util.h +11 -7
- data/vendor/v8/include/v8-value-serializer.h +46 -23
- data/vendor/v8/include/v8-value.h +31 -4
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm.h +7 -63
- data/vendor/v8/include/v8-weak-callback-info.h +0 -7
- data/vendor/v8/include/v8config.h +353 -15
- metadata +5 -1
@@ -7,11 +7,13 @@
|
|
7
7
|
|
8
8
|
#include <stddef.h>
|
9
9
|
|
10
|
+
#include <functional>
|
10
11
|
#include <string>
|
11
12
|
|
12
13
|
#include "cppgc/common.h"
|
13
14
|
#include "v8-data.h" // NOLINT(build/include_directory)
|
14
15
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
16
|
+
#include "v8-promise.h" // NOLINT(build/include_directory)
|
15
17
|
#include "v8config.h" // NOLINT(build/include_directory)
|
16
18
|
|
17
19
|
#if defined(V8_OS_WIN)
|
@@ -105,7 +107,7 @@ struct JitCodeEvent {
|
|
105
107
|
size_t line_number_table_size;
|
106
108
|
};
|
107
109
|
|
108
|
-
wasm_source_info_t* wasm_source_info;
|
110
|
+
wasm_source_info_t* wasm_source_info = nullptr;
|
109
111
|
|
110
112
|
union {
|
111
113
|
// Only valid for CODE_ADDED.
|
@@ -216,7 +218,13 @@ using AddHistogramSampleCallback = void (*)(void* histogram, int sample);
|
|
216
218
|
|
217
219
|
using FatalErrorCallback = void (*)(const char* location, const char* message);
|
218
220
|
|
219
|
-
|
221
|
+
struct OOMDetails {
|
222
|
+
bool is_heap_oom = false;
|
223
|
+
const char* detail = nullptr;
|
224
|
+
};
|
225
|
+
|
226
|
+
using OOMErrorCallback = void (*)(const char* location,
|
227
|
+
const OOMDetails& details);
|
220
228
|
|
221
229
|
using MessageCallback = void (*)(Local<Message> message, Local<Value> data);
|
222
230
|
|
@@ -230,9 +238,13 @@ using LogEventCallback = void (*)(const char* name,
|
|
230
238
|
enum class CrashKeyId {
|
231
239
|
kIsolateAddress,
|
232
240
|
kReadonlySpaceFirstPageAddress,
|
233
|
-
kMapSpaceFirstPageAddress,
|
241
|
+
kMapSpaceFirstPageAddress V8_ENUM_DEPRECATE_SOON("Map space got removed"),
|
242
|
+
kOldSpaceFirstPageAddress,
|
243
|
+
kCodeRangeBaseAddress,
|
234
244
|
kCodeSpaceFirstPageAddress,
|
235
245
|
kDumpType,
|
246
|
+
kSnapshotChecksumCalculated,
|
247
|
+
kSnapshotChecksumExpected,
|
236
248
|
};
|
237
249
|
|
238
250
|
using AddCrashKeyCallback = void (*)(CrashKeyId id, const std::string& value);
|
@@ -300,6 +312,13 @@ using ApiImplementationCallback = void (*)(const FunctionCallbackInfo<Value>&);
|
|
300
312
|
// --- Callback for WebAssembly.compileStreaming ---
|
301
313
|
using WasmStreamingCallback = void (*)(const FunctionCallbackInfo<Value>&);
|
302
314
|
|
315
|
+
enum class WasmAsyncSuccess { kSuccess, kFail };
|
316
|
+
|
317
|
+
// --- Callback called when async WebAssembly operations finish ---
|
318
|
+
using WasmAsyncResolvePromiseCallback = void (*)(
|
319
|
+
Isolate* isolate, Local<Context> context, Local<Promise::Resolver> resolver,
|
320
|
+
Local<Value> result, WasmAsyncSuccess success);
|
321
|
+
|
303
322
|
// --- Callback for loading source map file for Wasm profiling support
|
304
323
|
using WasmLoadSourceMapCallback = Local<String> (*)(Isolate* isolate,
|
305
324
|
const char* name);
|
@@ -310,8 +329,9 @@ using WasmSimdEnabledCallback = bool (*)(Local<Context> context);
|
|
310
329
|
// --- Callback for checking if WebAssembly exceptions are enabled ---
|
311
330
|
using WasmExceptionsEnabledCallback = bool (*)(Local<Context> context);
|
312
331
|
|
313
|
-
// --- Callback for checking if WebAssembly
|
314
|
-
|
332
|
+
// --- Callback for checking if WebAssembly GC is enabled ---
|
333
|
+
// If the callback returns true, it will also enable Wasm stringrefs.
|
334
|
+
using WasmGCEnabledCallback = bool (*)(Local<Context> context);
|
315
335
|
|
316
336
|
// --- Callback for checking if the SharedArrayBuffer constructor is enabled ---
|
317
337
|
using SharedArrayBufferConstructorEnabledCallback =
|
@@ -353,6 +373,13 @@ using HostImportModuleDynamicallyCallback = MaybeLocal<Promise> (*)(
|
|
353
373
|
Local<Value> resource_name, Local<String> specifier,
|
354
374
|
Local<FixedArray> import_assertions);
|
355
375
|
|
376
|
+
/**
|
377
|
+
* Callback for requesting a compile hint for a function from the embedder. The
|
378
|
+
* first parameter is the position of the function in source code and the second
|
379
|
+
* parameter is embedder data to be passed back.
|
380
|
+
*/
|
381
|
+
using CompileHintCallback = bool (*)(int, void*);
|
382
|
+
|
356
383
|
/**
|
357
384
|
* HostInitializeImportMetaObjectCallback is called the first time import.meta
|
358
385
|
* is accessed for a module. Subsequent access will reuse the same value.
|
@@ -7,8 +7,11 @@
|
|
7
7
|
|
8
8
|
#include <stdint.h>
|
9
9
|
|
10
|
+
#include <vector>
|
11
|
+
|
10
12
|
#include "v8-data.h" // NOLINT(build/include_directory)
|
11
13
|
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
14
|
+
#include "v8-maybe.h" // NOLINT(build/include_directory)
|
12
15
|
#include "v8-snapshot.h" // NOLINT(build/include_directory)
|
13
16
|
#include "v8config.h" // NOLINT(build/include_directory)
|
14
17
|
|
@@ -163,12 +166,51 @@ class V8_EXPORT Context : public Data {
|
|
163
166
|
*/
|
164
167
|
void Exit();
|
165
168
|
|
169
|
+
/**
|
170
|
+
* Delegate to help with Deep freezing embedder-specific objects (such as
|
171
|
+
* JSApiObjects) that can not be frozen natively.
|
172
|
+
*/
|
173
|
+
class DeepFreezeDelegate {
|
174
|
+
public:
|
175
|
+
/**
|
176
|
+
* Performs embedder-specific operations to freeze the provided embedder
|
177
|
+
* object. The provided object *will* be frozen by DeepFreeze after this
|
178
|
+
* function returns, so only embedder-specific objects need to be frozen.
|
179
|
+
* This function *may not* create new JS objects or perform JS allocations.
|
180
|
+
* Any v8 objects reachable from the provided embedder object that should
|
181
|
+
* also be considered for freezing should be added to the children_out
|
182
|
+
* parameter. Returns true if the operation completed successfully.
|
183
|
+
*/
|
184
|
+
virtual bool FreezeEmbedderObjectAndGetChildren(
|
185
|
+
Local<Object> obj, std::vector<Local<Object>>& children_out) = 0;
|
186
|
+
};
|
187
|
+
|
188
|
+
/**
|
189
|
+
* Attempts to recursively freeze all objects reachable from this context.
|
190
|
+
* Some objects (generators, iterators, non-const closures) can not be frozen
|
191
|
+
* and will cause this method to throw an error. An optional delegate can be
|
192
|
+
* provided to help freeze embedder-specific objects.
|
193
|
+
*
|
194
|
+
* Freezing occurs in two steps:
|
195
|
+
* 1. "Marking" where we iterate through all objects reachable by this
|
196
|
+
* context, accumulating a list of objects that need to be frozen and
|
197
|
+
* looking for objects that can't be frozen. This step is separated because
|
198
|
+
* it is more efficient when we can assume there is no garbage collection.
|
199
|
+
* 2. "Freezing" where we go through the list of objects and freezing them.
|
200
|
+
* This effectively requires copying them so it may trigger garbage
|
201
|
+
* collection.
|
202
|
+
*/
|
203
|
+
Maybe<void> DeepFreeze(DeepFreezeDelegate* delegate = nullptr);
|
204
|
+
|
166
205
|
/** Returns the isolate associated with a current context. */
|
167
206
|
Isolate* GetIsolate();
|
168
207
|
|
169
208
|
/** Returns the microtask queue associated with a current context. */
|
170
209
|
MicrotaskQueue* GetMicrotaskQueue();
|
171
210
|
|
211
|
+
/** Sets the microtask queue associated with the current context. */
|
212
|
+
void SetMicrotaskQueue(MicrotaskQueue* queue);
|
213
|
+
|
172
214
|
/**
|
173
215
|
* The field at kDebugIdIndex used to be reserved for the inspector.
|
174
216
|
* It now serves no purpose.
|
@@ -244,6 +286,12 @@ class V8_EXPORT Context : public Data {
|
|
244
286
|
*/
|
245
287
|
void SetErrorMessageForCodeGenerationFromStrings(Local<String> message);
|
246
288
|
|
289
|
+
/**
|
290
|
+
* Sets the error description for the exception that is thrown when
|
291
|
+
* wasm code generation is not allowed.
|
292
|
+
*/
|
293
|
+
void SetErrorMessageForWasmCodeGeneration(Local<String> message);
|
294
|
+
|
247
295
|
/**
|
248
296
|
* Return data that was previously attached to the context snapshot via
|
249
297
|
* SnapshotCreator, and removes the reference to it.
|
@@ -284,6 +332,7 @@ class V8_EXPORT Context : public Data {
|
|
284
332
|
Local<Function> after_hook,
|
285
333
|
Local<Function> resolve_hook);
|
286
334
|
|
335
|
+
bool HasTemplateLiteralObject(Local<Value> object);
|
287
336
|
/**
|
288
337
|
* Stack-allocated class which sets the execution context for all
|
289
338
|
* operations executed within a local scope.
|
@@ -355,13 +404,18 @@ Local<Value> Context::GetEmbedderData(int index) {
|
|
355
404
|
#ifdef V8_COMPRESS_POINTERS
|
356
405
|
// We read the full pointer value and then decompress it in order to avoid
|
357
406
|
// dealing with potential endiannes issues.
|
358
|
-
value =
|
359
|
-
I::DecompressTaggedAnyField(embedder_data, static_cast<uint32_t>(value));
|
407
|
+
value = I::DecompressTaggedField(embedder_data, static_cast<uint32_t>(value));
|
360
408
|
#endif
|
409
|
+
|
410
|
+
#ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
|
411
|
+
return Local<Value>(reinterpret_cast<Value*>(value));
|
412
|
+
#else
|
361
413
|
internal::Isolate* isolate = internal::IsolateFromNeverReadOnlySpaceObject(
|
362
414
|
*reinterpret_cast<A*>(this));
|
363
415
|
A* result = HandleScope::CreateHandle(isolate, value);
|
364
416
|
return Local<Value>(reinterpret_cast<Value*>(result));
|
417
|
+
#endif
|
418
|
+
|
365
419
|
#else
|
366
420
|
return SlowGetEmbedderData(index);
|
367
421
|
#endif
|
@@ -371,18 +425,16 @@ void* Context::GetAlignedPointerFromEmbedderData(int index) {
|
|
371
425
|
#if !defined(V8_ENABLE_CHECKS)
|
372
426
|
using A = internal::Address;
|
373
427
|
using I = internal::Internals;
|
374
|
-
A ctx =
|
428
|
+
A ctx = internal::ValueHelper::ValueAsAddress(this);
|
375
429
|
A embedder_data =
|
376
430
|
I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
|
377
|
-
int value_offset =
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
#endif
|
382
|
-
internal::Isolate* isolate = I::GetIsolateForSandbox(ctx);
|
431
|
+
int value_offset = I::kEmbedderDataArrayHeaderSize +
|
432
|
+
(I::kEmbedderDataSlotSize * index) +
|
433
|
+
I::kEmbedderDataSlotExternalPointerOffset;
|
434
|
+
Isolate* isolate = I::GetIsolateForSandbox(ctx);
|
383
435
|
return reinterpret_cast<void*>(
|
384
|
-
I::ReadExternalPointerField(
|
385
|
-
|
436
|
+
I::ReadExternalPointerField<internal::kEmbedderDataSlotPayloadTag>(
|
437
|
+
isolate, embedder_data, value_offset));
|
386
438
|
#else
|
387
439
|
return SlowGetAlignedPointerFromEmbedderData(index);
|
388
440
|
#endif
|
@@ -77,15 +77,37 @@ struct WrapperDescriptor final {
|
|
77
77
|
};
|
78
78
|
|
79
79
|
struct V8_EXPORT CppHeapCreateParams {
|
80
|
+
CppHeapCreateParams(
|
81
|
+
std::vector<std::unique_ptr<cppgc::CustomSpaceBase>> custom_spaces,
|
82
|
+
WrapperDescriptor wrapper_descriptor)
|
83
|
+
: custom_spaces(std::move(custom_spaces)),
|
84
|
+
wrapper_descriptor(wrapper_descriptor) {}
|
85
|
+
|
80
86
|
CppHeapCreateParams(const CppHeapCreateParams&) = delete;
|
81
87
|
CppHeapCreateParams& operator=(const CppHeapCreateParams&) = delete;
|
82
88
|
|
83
89
|
std::vector<std::unique_ptr<cppgc::CustomSpaceBase>> custom_spaces;
|
84
90
|
WrapperDescriptor wrapper_descriptor;
|
91
|
+
/**
|
92
|
+
* Specifies which kind of marking are supported by the heap. The type may be
|
93
|
+
* further reduced via runtime flags when attaching the heap to an Isolate.
|
94
|
+
*/
|
95
|
+
cppgc::Heap::MarkingType marking_support =
|
96
|
+
cppgc::Heap::MarkingType::kIncrementalAndConcurrent;
|
97
|
+
/**
|
98
|
+
* Specifies which kind of sweeping is supported by the heap. The type may be
|
99
|
+
* further reduced via runtime flags when attaching the heap to an Isolate.
|
100
|
+
*/
|
101
|
+
cppgc::Heap::SweepingType sweeping_support =
|
102
|
+
cppgc::Heap::SweepingType::kIncrementalAndConcurrent;
|
85
103
|
};
|
86
104
|
|
87
105
|
/**
|
88
106
|
* A heap for allocating managed C++ objects.
|
107
|
+
*
|
108
|
+
* Similar to v8::Isolate, the heap may only be accessed from one thread at a
|
109
|
+
* time. The heap may be used from different threads using the
|
110
|
+
* v8::Locker/v8::Unlocker APIs which is different from generic Oilpan.
|
89
111
|
*/
|
90
112
|
class V8_EXPORT CppHeap {
|
91
113
|
public:
|
data/vendor/v8/include/v8-data.h
CHANGED
data/vendor/v8/include/v8-date.h
CHANGED
@@ -27,6 +27,11 @@ class V8_EXPORT Date : public Object {
|
|
27
27
|
*/
|
28
28
|
double ValueOf() const;
|
29
29
|
|
30
|
+
/**
|
31
|
+
* Generates ISO string representation.
|
32
|
+
*/
|
33
|
+
v8::Local<v8::String> ToISOString() const;
|
34
|
+
|
30
35
|
V8_INLINE static Date* Cast(Value* value) {
|
31
36
|
#ifdef V8_ENABLE_CHECKS
|
32
37
|
CheckCast(value);
|
@@ -5,27 +5,14 @@
|
|
5
5
|
#ifndef INCLUDE_V8_EMBEDDER_HEAP_H_
|
6
6
|
#define INCLUDE_V8_EMBEDDER_HEAP_H_
|
7
7
|
|
8
|
-
#include <stddef.h>
|
9
|
-
#include <stdint.h>
|
10
|
-
|
11
|
-
#include <utility>
|
12
|
-
#include <vector>
|
13
|
-
|
14
|
-
#include "cppgc/common.h"
|
15
|
-
#include "v8-local-handle.h" // NOLINT(build/include_directory)
|
16
8
|
#include "v8-traced-handle.h" // NOLINT(build/include_directory)
|
17
9
|
#include "v8config.h" // NOLINT(build/include_directory)
|
18
10
|
|
19
11
|
namespace v8 {
|
20
12
|
|
21
|
-
class Data;
|
22
13
|
class Isolate;
|
23
14
|
class Value;
|
24
15
|
|
25
|
-
namespace internal {
|
26
|
-
class LocalEmbedderHeapTracer;
|
27
|
-
} // namespace internal
|
28
|
-
|
29
16
|
/**
|
30
17
|
* Handler for embedder roots on non-unified heap garbage collections.
|
31
18
|
*/
|
@@ -62,157 +49,6 @@ class V8_EXPORT EmbedderRootsHandler {
|
|
62
49
|
virtual void ResetRoot(const v8::TracedReference<v8::Value>& handle) = 0;
|
63
50
|
};
|
64
51
|
|
65
|
-
/**
|
66
|
-
* Interface for tracing through the embedder heap. During a V8 garbage
|
67
|
-
* collection, V8 collects hidden fields of all potential wrappers, and at the
|
68
|
-
* end of its marking phase iterates the collection and asks the embedder to
|
69
|
-
* trace through its heap and use reporter to report each JavaScript object
|
70
|
-
* reachable from any of the given wrappers.
|
71
|
-
*/
|
72
|
-
class V8_EXPORT EmbedderHeapTracer {
|
73
|
-
public:
|
74
|
-
using EmbedderStackState = cppgc::EmbedderStackState;
|
75
|
-
|
76
|
-
enum TraceFlags : uint64_t {
|
77
|
-
kNoFlags = 0,
|
78
|
-
kReduceMemory = 1 << 0,
|
79
|
-
kForced = 1 << 2,
|
80
|
-
};
|
81
|
-
|
82
|
-
/**
|
83
|
-
* Interface for iterating through |TracedReference| handles.
|
84
|
-
*/
|
85
|
-
class V8_EXPORT TracedGlobalHandleVisitor {
|
86
|
-
public:
|
87
|
-
virtual ~TracedGlobalHandleVisitor() = default;
|
88
|
-
virtual void VisitTracedReference(const TracedReference<Value>& handle) {}
|
89
|
-
};
|
90
|
-
|
91
|
-
/**
|
92
|
-
* Summary of a garbage collection cycle. See |TraceEpilogue| on how the
|
93
|
-
* summary is reported.
|
94
|
-
*/
|
95
|
-
struct TraceSummary {
|
96
|
-
/**
|
97
|
-
* Time spent managing the retained memory in milliseconds. This can e.g.
|
98
|
-
* include the time tracing through objects in the embedder.
|
99
|
-
*/
|
100
|
-
double time = 0.0;
|
101
|
-
|
102
|
-
/**
|
103
|
-
* Memory retained by the embedder through the |EmbedderHeapTracer|
|
104
|
-
* mechanism in bytes.
|
105
|
-
*/
|
106
|
-
size_t allocated_size = 0;
|
107
|
-
};
|
108
|
-
|
109
|
-
virtual ~EmbedderHeapTracer() = default;
|
110
|
-
|
111
|
-
/**
|
112
|
-
* Iterates all |TracedReference| handles created for the |v8::Isolate| the
|
113
|
-
* tracer is attached to.
|
114
|
-
*/
|
115
|
-
void IterateTracedGlobalHandles(TracedGlobalHandleVisitor* visitor);
|
116
|
-
|
117
|
-
/**
|
118
|
-
* Called by the embedder to set the start of the stack which is e.g. used by
|
119
|
-
* V8 to determine whether handles are used from stack or heap.
|
120
|
-
*/
|
121
|
-
void SetStackStart(void* stack_start);
|
122
|
-
|
123
|
-
/**
|
124
|
-
* Called by v8 to register internal fields of found wrappers.
|
125
|
-
*
|
126
|
-
* The embedder is expected to store them somewhere and trace reachable
|
127
|
-
* wrappers from them when called through |AdvanceTracing|.
|
128
|
-
*/
|
129
|
-
virtual void RegisterV8References(
|
130
|
-
const std::vector<std::pair<void*, void*>>& embedder_fields) = 0;
|
131
|
-
|
132
|
-
void RegisterEmbedderReference(const BasicTracedReference<v8::Data>& ref);
|
133
|
-
|
134
|
-
/**
|
135
|
-
* Called at the beginning of a GC cycle.
|
136
|
-
*/
|
137
|
-
virtual void TracePrologue(TraceFlags flags) {}
|
138
|
-
|
139
|
-
/**
|
140
|
-
* Called to advance tracing in the embedder.
|
141
|
-
*
|
142
|
-
* The embedder is expected to trace its heap starting from wrappers reported
|
143
|
-
* by RegisterV8References method, and report back all reachable wrappers.
|
144
|
-
* Furthermore, the embedder is expected to stop tracing by the given
|
145
|
-
* deadline. A deadline of infinity means that tracing should be finished.
|
146
|
-
*
|
147
|
-
* Returns |true| if tracing is done, and false otherwise.
|
148
|
-
*/
|
149
|
-
virtual bool AdvanceTracing(double deadline_in_ms) = 0;
|
150
|
-
|
151
|
-
/*
|
152
|
-
* Returns true if there no more tracing work to be done (see AdvanceTracing)
|
153
|
-
* and false otherwise.
|
154
|
-
*/
|
155
|
-
virtual bool IsTracingDone() = 0;
|
156
|
-
|
157
|
-
/**
|
158
|
-
* Called at the end of a GC cycle.
|
159
|
-
*
|
160
|
-
* Note that allocation is *not* allowed within |TraceEpilogue|. Can be
|
161
|
-
* overriden to fill a |TraceSummary| that is used by V8 to schedule future
|
162
|
-
* garbage collections.
|
163
|
-
*/
|
164
|
-
virtual void TraceEpilogue(TraceSummary* trace_summary) {}
|
165
|
-
|
166
|
-
/**
|
167
|
-
* Called upon entering the final marking pause. No more incremental marking
|
168
|
-
* steps will follow this call.
|
169
|
-
*/
|
170
|
-
virtual void EnterFinalPause(EmbedderStackState stack_state) = 0;
|
171
|
-
|
172
|
-
/*
|
173
|
-
* Called by the embedder to request immediate finalization of the currently
|
174
|
-
* running tracing phase that has been started with TracePrologue and not
|
175
|
-
* yet finished with TraceEpilogue.
|
176
|
-
*
|
177
|
-
* Will be a noop when currently not in tracing.
|
178
|
-
*
|
179
|
-
* This is an experimental feature.
|
180
|
-
*/
|
181
|
-
void FinalizeTracing();
|
182
|
-
|
183
|
-
/**
|
184
|
-
* See documentation on EmbedderRootsHandler.
|
185
|
-
*/
|
186
|
-
virtual bool IsRootForNonTracingGC(
|
187
|
-
const v8::TracedReference<v8::Value>& handle);
|
188
|
-
|
189
|
-
/**
|
190
|
-
* See documentation on EmbedderRootsHandler.
|
191
|
-
*/
|
192
|
-
virtual void ResetHandleInNonTracingGC(
|
193
|
-
const v8::TracedReference<v8::Value>& handle);
|
194
|
-
|
195
|
-
/*
|
196
|
-
* Called by the embedder to signal newly allocated or freed memory. Not bound
|
197
|
-
* to tracing phases. Embedders should trade off when increments are reported
|
198
|
-
* as V8 may consult global heuristics on whether to trigger garbage
|
199
|
-
* collection on this change.
|
200
|
-
*/
|
201
|
-
void IncreaseAllocatedSize(size_t bytes);
|
202
|
-
void DecreaseAllocatedSize(size_t bytes);
|
203
|
-
|
204
|
-
/*
|
205
|
-
* Returns the v8::Isolate this tracer is attached too and |nullptr| if it
|
206
|
-
* is not attached to any v8::Isolate.
|
207
|
-
*/
|
208
|
-
v8::Isolate* isolate() const { return isolate_; }
|
209
|
-
|
210
|
-
protected:
|
211
|
-
v8::Isolate* isolate_ = nullptr;
|
212
|
-
|
213
|
-
friend class internal::LocalEmbedderHeapTracer;
|
214
|
-
};
|
215
|
-
|
216
52
|
} // namespace v8
|
217
53
|
|
218
54
|
#endif // INCLUDE_V8_EMBEDDER_HEAP_H_
|
@@ -240,13 +240,16 @@ class CTypeInfo {
|
|
240
240
|
enum class Type : uint8_t {
|
241
241
|
kVoid,
|
242
242
|
kBool,
|
243
|
+
kUint8,
|
243
244
|
kInt32,
|
244
245
|
kUint32,
|
245
246
|
kInt64,
|
246
247
|
kUint64,
|
247
248
|
kFloat32,
|
248
249
|
kFloat64,
|
250
|
+
kPointer,
|
249
251
|
kV8Value,
|
252
|
+
kSeqOneByteString,
|
250
253
|
kApiObject, // This will be deprecated once all users have
|
251
254
|
// migrated from v8::ApiObject to v8::Local<v8::Value>.
|
252
255
|
kAny, // This is added to enable untyped representation of fast
|
@@ -302,8 +305,9 @@ class CTypeInfo {
|
|
302
305
|
constexpr Flags GetFlags() const { return flags_; }
|
303
306
|
|
304
307
|
static constexpr bool IsIntegralType(Type type) {
|
305
|
-
return type == Type::
|
306
|
-
type == Type::
|
308
|
+
return type == Type::kUint8 || type == Type::kInt32 ||
|
309
|
+
type == Type::kUint32 || type == Type::kInt64 ||
|
310
|
+
type == Type::kUint64;
|
307
311
|
}
|
308
312
|
|
309
313
|
static constexpr bool IsFloatingPointType(Type type) {
|
@@ -377,6 +381,11 @@ struct FastApiArrayBuffer {
|
|
377
381
|
size_t byte_length;
|
378
382
|
};
|
379
383
|
|
384
|
+
struct FastOneByteString {
|
385
|
+
const char* data;
|
386
|
+
uint32_t length;
|
387
|
+
};
|
388
|
+
|
380
389
|
class V8_EXPORT CFunctionInfo {
|
381
390
|
public:
|
382
391
|
// Construct a struct to hold a CFunction's type information.
|
@@ -427,14 +436,17 @@ struct AnyCType {
|
|
427
436
|
uint64_t uint64_value;
|
428
437
|
float float_value;
|
429
438
|
double double_value;
|
439
|
+
void* pointer_value;
|
430
440
|
Local<Object> object_value;
|
431
441
|
Local<Array> sequence_value;
|
442
|
+
const FastApiTypedArray<uint8_t>* uint8_ta_value;
|
432
443
|
const FastApiTypedArray<int32_t>* int32_ta_value;
|
433
444
|
const FastApiTypedArray<uint32_t>* uint32_ta_value;
|
434
445
|
const FastApiTypedArray<int64_t>* int64_ta_value;
|
435
446
|
const FastApiTypedArray<uint64_t>* uint64_ta_value;
|
436
447
|
const FastApiTypedArray<float>* float_ta_value;
|
437
448
|
const FastApiTypedArray<double>* double_ta_value;
|
449
|
+
const FastOneByteString* string_value;
|
438
450
|
FastApiCallbackOptions* options_value;
|
439
451
|
};
|
440
452
|
};
|
@@ -544,7 +556,7 @@ struct FastApiCallbackOptions {
|
|
544
556
|
* returned instance may be filled with mock data.
|
545
557
|
*/
|
546
558
|
static FastApiCallbackOptions CreateForTesting(Isolate* isolate) {
|
547
|
-
return {false, {0}};
|
559
|
+
return {false, {0}, nullptr};
|
548
560
|
}
|
549
561
|
|
550
562
|
/**
|
@@ -566,8 +578,13 @@ struct FastApiCallbackOptions {
|
|
566
578
|
*/
|
567
579
|
union {
|
568
580
|
uintptr_t data_ptr;
|
569
|
-
v8::Value data;
|
581
|
+
v8::Local<v8::Value> data;
|
570
582
|
};
|
583
|
+
|
584
|
+
/**
|
585
|
+
* When called from WebAssembly, a view of the calling module's memory.
|
586
|
+
*/
|
587
|
+
FastApiTypedArray<uint8_t>* const wasm_memory;
|
571
588
|
};
|
572
589
|
|
573
590
|
namespace internal {
|
@@ -605,8 +622,9 @@ class CFunctionInfoImpl : public CFunctionInfo {
|
|
605
622
|
kReturnType == CTypeInfo::Type::kUint32 ||
|
606
623
|
kReturnType == CTypeInfo::Type::kFloat32 ||
|
607
624
|
kReturnType == CTypeInfo::Type::kFloat64 ||
|
625
|
+
kReturnType == CTypeInfo::Type::kPointer ||
|
608
626
|
kReturnType == CTypeInfo::Type::kAny,
|
609
|
-
"64-bit int and api object values are not currently "
|
627
|
+
"64-bit int, string and api object values are not currently "
|
610
628
|
"supported return types.");
|
611
629
|
}
|
612
630
|
|
@@ -643,12 +661,14 @@ struct CTypeInfoTraits {};
|
|
643
661
|
|
644
662
|
#define PRIMITIVE_C_TYPES(V) \
|
645
663
|
V(bool, kBool) \
|
664
|
+
V(uint8_t, kUint8) \
|
646
665
|
V(int32_t, kInt32) \
|
647
666
|
V(uint32_t, kUint32) \
|
648
667
|
V(int64_t, kInt64) \
|
649
668
|
V(uint64_t, kUint64) \
|
650
669
|
V(float, kFloat32) \
|
651
|
-
V(double, kFloat64)
|
670
|
+
V(double, kFloat64) \
|
671
|
+
V(void*, kPointer)
|
652
672
|
|
653
673
|
// Same as above, but includes deprecated types for compatibility.
|
654
674
|
#define ALL_C_TYPES(V) \
|
@@ -682,6 +702,7 @@ PRIMITIVE_C_TYPES(DEFINE_TYPE_INFO_TRAITS)
|
|
682
702
|
};
|
683
703
|
|
684
704
|
#define TYPED_ARRAY_C_TYPES(V) \
|
705
|
+
V(uint8_t, kUint8) \
|
685
706
|
V(int32_t, kInt32) \
|
686
707
|
V(uint32_t, kUint32) \
|
687
708
|
V(int64_t, kInt64) \
|
@@ -725,6 +746,18 @@ struct TypeInfoHelper<FastApiCallbackOptions&> {
|
|
725
746
|
}
|
726
747
|
};
|
727
748
|
|
749
|
+
template <>
|
750
|
+
struct TypeInfoHelper<const FastOneByteString&> {
|
751
|
+
static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
|
752
|
+
|
753
|
+
static constexpr CTypeInfo::Type Type() {
|
754
|
+
return CTypeInfo::Type::kSeqOneByteString;
|
755
|
+
}
|
756
|
+
static constexpr CTypeInfo::SequenceType SequenceType() {
|
757
|
+
return CTypeInfo::SequenceType::kScalar;
|
758
|
+
}
|
759
|
+
};
|
760
|
+
|
728
761
|
#define STATIC_ASSERT_IMPLIES(COND, ASSERTION, MSG) \
|
729
762
|
static_assert(((COND) == 0) || (ASSERTION), MSG)
|
730
763
|
|
@@ -802,6 +835,16 @@ class CFunctionBuilderWithFunction {
|
|
802
835
|
std::make_index_sequence<sizeof...(ArgBuilders)>());
|
803
836
|
}
|
804
837
|
|
838
|
+
// Provided for testing purposes.
|
839
|
+
template <typename Ret, typename... Args>
|
840
|
+
auto Patch(Ret (*patching_func)(Args...)) {
|
841
|
+
static_assert(
|
842
|
+
sizeof...(Args) == sizeof...(ArgBuilders),
|
843
|
+
"The patching function must have the same number of arguments.");
|
844
|
+
fn_ = reinterpret_cast<void*>(patching_func);
|
845
|
+
return *this;
|
846
|
+
}
|
847
|
+
|
805
848
|
auto Build() {
|
806
849
|
static CFunctionInfoImpl<RetBuilder, ArgBuilders...> instance;
|
807
850
|
return CFunction(fn_, &instance);
|
@@ -881,31 +924,6 @@ static constexpr CTypeInfo kTypeInfoFloat64 =
|
|
881
924
|
* to the requested destination type, is considered unsupported. The operation
|
882
925
|
* returns true on success. `type_info` will be used for conversions.
|
883
926
|
*/
|
884
|
-
template <const CTypeInfo* type_info, typename T>
|
885
|
-
V8_DEPRECATED(
|
886
|
-
"Use TryToCopyAndConvertArrayToCppBuffer<CTypeInfo::Identifier, T>()")
|
887
|
-
bool V8_EXPORT V8_WARN_UNUSED_RESULT
|
888
|
-
TryCopyAndConvertArrayToCppBuffer(Local<Array> src, T* dst,
|
889
|
-
uint32_t max_length);
|
890
|
-
|
891
|
-
template <>
|
892
|
-
V8_DEPRECATED(
|
893
|
-
"Use TryToCopyAndConvertArrayToCppBuffer<CTypeInfo::Identifier, T>()")
|
894
|
-
inline bool V8_WARN_UNUSED_RESULT
|
895
|
-
TryCopyAndConvertArrayToCppBuffer<&kTypeInfoInt32, int32_t>(
|
896
|
-
Local<Array> src, int32_t* dst, uint32_t max_length) {
|
897
|
-
return false;
|
898
|
-
}
|
899
|
-
|
900
|
-
template <>
|
901
|
-
V8_DEPRECATED(
|
902
|
-
"Use TryToCopyAndConvertArrayToCppBuffer<CTypeInfo::Identifier, T>()")
|
903
|
-
inline bool V8_WARN_UNUSED_RESULT
|
904
|
-
TryCopyAndConvertArrayToCppBuffer<&kTypeInfoFloat64, double>(
|
905
|
-
Local<Array> src, double* dst, uint32_t max_length) {
|
906
|
-
return false;
|
907
|
-
}
|
908
|
-
|
909
927
|
template <CTypeInfo::Identifier type_info_id, typename T>
|
910
928
|
bool V8_EXPORT V8_WARN_UNUSED_RESULT TryToCopyAndConvertArrayToCppBuffer(
|
911
929
|
Local<Array> src, T* dst, uint32_t max_length);
|