libv8-node 23.6.1.0-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 +1 -2
- data/vendor/v8/include/cppgc/default-platform.h +3 -2
- data/vendor/v8/include/cppgc/heap-consistency.h +1 -1
- data/vendor/v8/include/cppgc/internal/api-constants.h +0 -17
- 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/conditional-stack-allocated.h +41 -0
- data/vendor/v8/include/cppgc/internal/logging.h +3 -3
- data/vendor/v8/include/cppgc/internal/member-storage.h +63 -20
- 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 +3 -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 +111 -34
- data/vendor/v8/include/v8-callbacks.h +84 -26
- data/vendor/v8/include/v8-context.h +7 -6
- data/vendor/v8/include/v8-cppgc.h +2 -1
- data/vendor/v8/include/v8-data.h +5 -0
- data/vendor/v8/include/v8-debug.h +11 -0
- data/vendor/v8/include/v8-embedder-heap.h +1 -32
- data/vendor/v8/include/v8-exception.h +2 -0
- data/vendor/v8/include/v8-external-memory-accounter.h +60 -0
- data/vendor/v8/include/v8-fast-api-calls.h +17 -175
- data/vendor/v8/include/v8-function-callback.h +4 -33
- data/vendor/v8/include/v8-function.h +7 -0
- data/vendor/v8/include/v8-handle-base.h +18 -0
- data/vendor/v8/include/v8-initialization.h +9 -1
- data/vendor/v8/include/v8-inspector.h +8 -4
- data/vendor/v8/include/v8-internal.h +477 -399
- data/vendor/v8/include/v8-isolate.h +218 -151
- data/vendor/v8/include/v8-local-handle.h +56 -28
- 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 -1
- data/vendor/v8/include/v8-metrics.h +10 -0
- data/vendor/v8/include/v8-object.h +7 -2
- data/vendor/v8/include/v8-persistent-handle.h +17 -17
- data/vendor/v8/include/v8-platform.h +48 -13
- data/vendor/v8/include/v8-primitive.h +131 -6
- data/vendor/v8/include/v8-profiler.h +13 -1
- 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 +3 -3
- data/vendor/v8/include/v8-script.h +21 -3
- data/vendor/v8/include/v8-source-location.h +6 -1
- data/vendor/v8/include/v8-template.h +8 -2
- data/vendor/v8/include/v8-trace-categories.h +23 -0
- data/vendor/v8/include/v8-traced-handle.h +16 -17
- 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-value-serializer-version.h +3 -3
- data/vendor/v8/include/v8-value.h +18 -0
- data/vendor/v8/include/v8-version.h +4 -4
- data/vendor/v8/include/v8-wasm.h +24 -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 +34 -40
- metadata +5 -3
- data/vendor/v8/include/cppgc/ephemeron-pair.h +0 -30
@@ -129,7 +129,9 @@ struct JitCodeEvent {
|
|
129
129
|
enum JitCodeEventOptions {
|
130
130
|
kJitCodeEventDefault = 0,
|
131
131
|
// Generate callbacks for already existent code.
|
132
|
-
kJitCodeEventEnumExisting = 1
|
132
|
+
kJitCodeEventEnumExisting = 1,
|
133
|
+
|
134
|
+
kLastJitCodeEventOption = kJitCodeEventEnumExisting
|
133
135
|
};
|
134
136
|
|
135
137
|
/**
|
@@ -188,6 +190,9 @@ using GCCallback = void (*)(GCType type, GCCallbackFlags flags);
|
|
188
190
|
|
189
191
|
using InterruptCallback = void (*)(Isolate* isolate, void* data);
|
190
192
|
|
193
|
+
using PrintCurrentStackTraceFilterCallback =
|
194
|
+
bool (*)(Isolate* isolate, Local<String> script_name);
|
195
|
+
|
191
196
|
/**
|
192
197
|
* This callback is invoked when the heap size is close to the heap limit and
|
193
198
|
* V8 is likely to abort with out-of-memory error.
|
@@ -254,15 +259,7 @@ using AddCrashKeyCallback = void (*)(CrashKeyId id, const std::string& value);
|
|
254
259
|
using BeforeCallEnteredCallback = void (*)(Isolate*);
|
255
260
|
using CallCompletedCallback = void (*)(Isolate*);
|
256
261
|
|
257
|
-
// ---
|
258
|
-
|
259
|
-
/**
|
260
|
-
* Callback to check if code generation from strings is allowed. See
|
261
|
-
* Context::AllowCodeGenerationFromStrings.
|
262
|
-
*/
|
263
|
-
using AllowCodeGenerationFromStringsCallback = bool (*)(Local<Context> context,
|
264
|
-
Local<String> source);
|
265
|
-
|
262
|
+
// --- Modify Code Generation From Strings Callback ---
|
266
263
|
struct ModifyCodeGenerationFromStringsResult {
|
267
264
|
// If true, proceed with the codegen algorithm. Otherwise, block it.
|
268
265
|
bool codegen_allowed = false;
|
@@ -272,6 +269,20 @@ struct ModifyCodeGenerationFromStringsResult {
|
|
272
269
|
MaybeLocal<String> modified_source;
|
273
270
|
};
|
274
271
|
|
272
|
+
/**
|
273
|
+
* Callback to check if codegen is allowed from a source object, and convert
|
274
|
+
* the source to string if necessary. See: ModifyCodeGenerationFromStrings.
|
275
|
+
*/
|
276
|
+
using ModifyCodeGenerationFromStringsCallback =
|
277
|
+
ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
|
278
|
+
Local<Value> source);
|
279
|
+
using ModifyCodeGenerationFromStringsCallback2 =
|
280
|
+
ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
|
281
|
+
Local<Value> source,
|
282
|
+
bool is_code_like);
|
283
|
+
|
284
|
+
// --- Failed Access Check Callback ---
|
285
|
+
|
275
286
|
/**
|
276
287
|
* Access type specification.
|
277
288
|
*/
|
@@ -283,23 +294,9 @@ enum AccessType {
|
|
283
294
|
ACCESS_KEYS
|
284
295
|
};
|
285
296
|
|
286
|
-
// --- Failed Access Check Callback ---
|
287
|
-
|
288
297
|
using FailedAccessCheckCallback = void (*)(Local<Object> target,
|
289
298
|
AccessType type, Local<Value> data);
|
290
299
|
|
291
|
-
/**
|
292
|
-
* Callback to check if codegen is allowed from a source object, and convert
|
293
|
-
* the source to string if necessary. See: ModifyCodeGenerationFromStrings.
|
294
|
-
*/
|
295
|
-
using ModifyCodeGenerationFromStringsCallback =
|
296
|
-
ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
|
297
|
-
Local<Value> source);
|
298
|
-
using ModifyCodeGenerationFromStringsCallback2 =
|
299
|
-
ModifyCodeGenerationFromStringsResult (*)(Local<Context> context,
|
300
|
-
Local<Value> source,
|
301
|
-
bool is_code_like);
|
302
|
-
|
303
300
|
// --- WebAssembly compilation callbacks ---
|
304
301
|
using ExtensionCallback = bool (*)(const FunctionCallbackInfo<Value>&);
|
305
302
|
|
@@ -377,6 +374,47 @@ using HostImportModuleDynamicallyCallback = MaybeLocal<Promise> (*)(
|
|
377
374
|
Local<Value> resource_name, Local<String> specifier,
|
378
375
|
Local<FixedArray> import_attributes);
|
379
376
|
|
377
|
+
/**
|
378
|
+
* HostImportModuleWithPhaseDynamicallyCallback is called when we
|
379
|
+
* require the embedder to load a module with a specific phase. This is used
|
380
|
+
* as part of the dynamic import syntax.
|
381
|
+
*
|
382
|
+
* The referrer contains metadata about the script/module that calls
|
383
|
+
* import.
|
384
|
+
*
|
385
|
+
* The specifier is the name of the module that should be imported.
|
386
|
+
*
|
387
|
+
* The phase is the phase of the import requested.
|
388
|
+
*
|
389
|
+
* The import_attributes are import attributes for this request in the form:
|
390
|
+
* [key1, value1, key2, value2, ...] where the keys and values are of type
|
391
|
+
* v8::String. Note, unlike the FixedArray passed to ResolveModuleCallback and
|
392
|
+
* returned from ModuleRequest::GetImportAttributes(), this array does not
|
393
|
+
* contain the source Locations of the attributes.
|
394
|
+
*
|
395
|
+
* The Promise returned from this function is forwarded to userland
|
396
|
+
* JavaScript. The embedder must resolve this promise according to the phase
|
397
|
+
* requested:
|
398
|
+
* - For ModuleImportPhase::kSource, the promise must be resolved with a
|
399
|
+
* compiled ModuleSource object, or rejected with a SyntaxError if the
|
400
|
+
* module does not support source representation.
|
401
|
+
* - For ModuleImportPhase::kEvaluation, the promise must be resolved with a
|
402
|
+
* ModuleNamespace object of a module that has been compiled, instantiated,
|
403
|
+
* and evaluated.
|
404
|
+
*
|
405
|
+
* In case of an exception, the embedder must reject this promise with the
|
406
|
+
* exception. If the promise creation itself fails (e.g. due to stack
|
407
|
+
* overflow), the embedder must propagate that exception by returning an empty
|
408
|
+
* MaybeLocal.
|
409
|
+
*
|
410
|
+
* This callback is still experimental and is only invoked for source phase
|
411
|
+
* imports.
|
412
|
+
*/
|
413
|
+
using HostImportModuleWithPhaseDynamicallyCallback = MaybeLocal<Promise> (*)(
|
414
|
+
Local<Context> context, Local<Data> host_defined_options,
|
415
|
+
Local<Value> resource_name, Local<String> specifier,
|
416
|
+
ModuleImportPhase phase, Local<FixedArray> import_attributes);
|
417
|
+
|
380
418
|
/**
|
381
419
|
* Callback for requesting a compile hint for a function from the embedder. The
|
382
420
|
* first parameter is the position of the function in source code and the second
|
@@ -412,6 +450,14 @@ using HostInitializeImportMetaObjectCallback = void (*)(Local<Context> context,
|
|
412
450
|
using HostCreateShadowRealmContextCallback =
|
413
451
|
MaybeLocal<Context> (*)(Local<Context> initiator_context);
|
414
452
|
|
453
|
+
/**
|
454
|
+
* IsJSApiWrapperNativeErrorCallback is called on an JSApiWrapper object to
|
455
|
+
* determine if Error.isError should return true or false. For instance, in an
|
456
|
+
* HTML embedder, DOMExceptions return true when passed to Error.isError.
|
457
|
+
*/
|
458
|
+
using IsJSApiWrapperNativeErrorCallback = bool (*)(Isolate* isolate,
|
459
|
+
Local<Object> obj);
|
460
|
+
|
415
461
|
/**
|
416
462
|
* PrepareStackTraceCallback is called when the stack property of an error is
|
417
463
|
* first accessed. The return value will be used as the stack value. If this
|
@@ -452,14 +498,26 @@ using PrepareStackTraceCallback = MaybeLocal<Value> (*)(Local<Context> context,
|
|
452
498
|
* with a list of regular expressions that should match the document URL
|
453
499
|
* in order to enable ETW tracing:
|
454
500
|
* {
|
455
|
-
* "version": "
|
501
|
+
* "version": "2.0",
|
456
502
|
* "filtered_urls": [
|
457
503
|
* "https:\/\/.*\.chromium\.org\/.*", "https://v8.dev/";, "..."
|
458
|
-
* ]
|
504
|
+
* ],
|
505
|
+
* "trace_interpreter_frames": true
|
459
506
|
* }
|
460
507
|
*/
|
508
|
+
|
461
509
|
using FilterETWSessionByURLCallback =
|
462
510
|
bool (*)(Local<Context> context, const std::string& etw_filter_payload);
|
511
|
+
|
512
|
+
struct FilterETWSessionByURLResult {
|
513
|
+
// If true, enable ETW tracing for the current isolate.
|
514
|
+
bool enable_etw_tracing;
|
515
|
+
|
516
|
+
// If true, also enables ETW tracing for interpreter stack frames.
|
517
|
+
bool trace_interpreter_frames;
|
518
|
+
};
|
519
|
+
using FilterETWSessionByURL2Callback = FilterETWSessionByURLResult (*)(
|
520
|
+
Local<Context> context, const std::string& etw_filter_payload);
|
463
521
|
#endif // V8_OS_WIN
|
464
522
|
|
465
523
|
} // namespace v8
|
@@ -320,7 +320,7 @@ class V8_EXPORT Context : public Data {
|
|
320
320
|
* 'Function' constructor are used an exception will be thrown.
|
321
321
|
*
|
322
322
|
* If code generation from strings is not allowed the
|
323
|
-
* V8::
|
323
|
+
* V8::ModifyCodeGenerationFromStringsCallback callback will be invoked if
|
324
324
|
* set before blocking the call to 'eval' or the 'Function'
|
325
325
|
* constructor. If that callback returns true, the call will be
|
326
326
|
* allowed, otherwise an exception will be thrown. If no callback is
|
@@ -427,7 +427,8 @@ class V8_EXPORT Context : public Data {
|
|
427
427
|
|
428
428
|
static void CheckCast(Data* obj);
|
429
429
|
|
430
|
-
internal::
|
430
|
+
internal::ValueHelper::InternalRepresentationType GetDataFromSnapshotOnce(
|
431
|
+
size_t index);
|
431
432
|
Local<Value> SlowGetEmbedderData(int index);
|
432
433
|
void* SlowGetAlignedPointerFromEmbedderData(int index);
|
433
434
|
};
|
@@ -497,10 +498,10 @@ void* Context::GetAlignedPointerFromEmbedderData(int index) {
|
|
497
498
|
|
498
499
|
template <class T>
|
499
500
|
MaybeLocal<T> Context::GetDataFromSnapshotOnce(size_t index) {
|
500
|
-
if (auto
|
501
|
-
|
502
|
-
|
503
|
-
return Local<T>::
|
501
|
+
if (auto repr = GetDataFromSnapshotOnce(index);
|
502
|
+
repr != internal::ValueHelper::kEmpty) {
|
503
|
+
internal::PerformCastCheck(internal::ValueHelper::ReprAsValue<T>(repr));
|
504
|
+
return Local<T>::FromRepr(repr);
|
504
505
|
}
|
505
506
|
return {};
|
506
507
|
}
|
@@ -87,6 +87,7 @@ class V8_EXPORT CppHeap {
|
|
87
87
|
*
|
88
88
|
* After this call, object allocation is prohibited.
|
89
89
|
*/
|
90
|
+
V8_DEPRECATED("Terminate gets automatically called in the CppHeap destructor")
|
90
91
|
void Terminate();
|
91
92
|
|
92
93
|
/**
|
@@ -101,7 +102,7 @@ class V8_EXPORT CppHeap {
|
|
101
102
|
/**
|
102
103
|
* Collects statistics for the given spaces and reports them to the receiver.
|
103
104
|
*
|
104
|
-
* \param custom_spaces a collection of custom space
|
105
|
+
* \param custom_spaces a collection of custom space indices.
|
105
106
|
* \param receiver an object that gets the results.
|
106
107
|
*/
|
107
108
|
void CollectCustomSpaceStatisticsAtLastGC(
|
data/vendor/v8/include/v8-data.h
CHANGED
@@ -42,6 +42,12 @@ class V8_EXPORT StackFrame {
|
|
42
42
|
*/
|
43
43
|
int GetColumn() const { return GetLocation().GetColumnNumber() + 1; }
|
44
44
|
|
45
|
+
/**
|
46
|
+
* Returns zero based source position (character offset) for the associated
|
47
|
+
* function.
|
48
|
+
*/
|
49
|
+
int GetSourcePosition() const;
|
50
|
+
|
45
51
|
/**
|
46
52
|
* Returns the id of the script for the function for this StackFrame.
|
47
53
|
* This method will return Message::kNoScriptIdInfo if it is unable to
|
@@ -130,6 +136,11 @@ class V8_EXPORT StackTrace {
|
|
130
136
|
kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
|
131
137
|
};
|
132
138
|
|
139
|
+
/**
|
140
|
+
* Returns the (unique) ID of this stack trace.
|
141
|
+
*/
|
142
|
+
int GetID() const;
|
143
|
+
|
133
144
|
/**
|
134
145
|
* Returns a StackFrame at a particular index.
|
135
146
|
*/
|
@@ -21,37 +21,10 @@ class Value;
|
|
21
21
|
*/
|
22
22
|
class V8_EXPORT EmbedderRootsHandler {
|
23
23
|
public:
|
24
|
-
enum class RootHandling {
|
25
|
-
kQueryEmbedderForNonDroppableReferences,
|
26
|
-
kDontQueryEmbedderForAnyReference,
|
27
|
-
};
|
28
|
-
|
29
24
|
virtual ~EmbedderRootsHandler() = default;
|
30
25
|
|
31
26
|
EmbedderRootsHandler() = default;
|
32
27
|
|
33
|
-
V8_DEPRECATED("Use the default constructor instead.")
|
34
|
-
explicit EmbedderRootsHandler(RootHandling default_traced_reference_handling)
|
35
|
-
: default_traced_reference_handling_(default_traced_reference_handling) {}
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Returns true if the |TracedReference| handle should be considered as root
|
39
|
-
* for the currently running non-tracing garbage collection and false
|
40
|
-
* otherwise. The default implementation will keep all |TracedReference|
|
41
|
-
* references as roots.
|
42
|
-
*
|
43
|
-
* If this returns false, then V8 may decide that the object referred to by
|
44
|
-
* such a handle is reclaimed. In that case, V8 calls |ResetRoot()| for the
|
45
|
-
* |TracedReference|.
|
46
|
-
*
|
47
|
-
* Note that the `handle` is different from the handle that the embedder holds
|
48
|
-
* for retaining the object.
|
49
|
-
*
|
50
|
-
* The concrete implementations must be thread-safe.
|
51
|
-
*/
|
52
|
-
V8_DEPRECATED("Use TracedReferenceHandling::kDroppable instead.")
|
53
|
-
virtual bool IsRoot(const v8::TracedReference<v8::Value>& handle) = 0;
|
54
|
-
|
55
28
|
/**
|
56
29
|
* Used in combination with |IsRoot|. Called by V8 when an
|
57
30
|
* object that is backed by a handle is reclaimed by a non-tracing garbage
|
@@ -69,14 +42,10 @@ class V8_EXPORT EmbedderRootsHandler {
|
|
69
42
|
* |false| is returned, |ResetRoot()| will be recalled for the same handle.
|
70
43
|
*/
|
71
44
|
virtual bool TryResetRoot(const v8::TracedReference<v8::Value>& handle) {
|
72
|
-
|
73
|
-
return true;
|
45
|
+
return false;
|
74
46
|
}
|
75
47
|
|
76
48
|
private:
|
77
|
-
const RootHandling default_traced_reference_handling_ =
|
78
|
-
RootHandling::kDontQueryEmbedderForAnyReference;
|
79
|
-
|
80
49
|
friend class internal::TracedHandles;
|
81
50
|
};
|
82
51
|
|
@@ -45,6 +45,8 @@ class V8_EXPORT Exception {
|
|
45
45
|
Local<Value> options = {});
|
46
46
|
static Local<Value> WasmRuntimeError(Local<String> message,
|
47
47
|
Local<Value> options = {});
|
48
|
+
static Local<Value> WasmSuspendError(Local<String> message,
|
49
|
+
Local<Value> options = {});
|
48
50
|
static Local<Value> Error(Local<String> message, Local<Value> options = {});
|
49
51
|
|
50
52
|
/**
|
@@ -0,0 +1,60 @@
|
|
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_EXTERNAL_MEMORY_ACCOUNTER_H_
|
6
|
+
#define INCLUDE_EXTERNAL_MEMORY_ACCOUNTER_H_
|
7
|
+
|
8
|
+
#include <stdint.h>
|
9
|
+
|
10
|
+
#include "v8-isolate.h"
|
11
|
+
|
12
|
+
namespace v8 {
|
13
|
+
|
14
|
+
/**
|
15
|
+
* This class is used to give V8 an indication of the amount of externally
|
16
|
+
* allocated memory that is kept alive by JavaScript objects. V8 uses this to
|
17
|
+
* decide when to perform garbage collections. Registering externally allocated
|
18
|
+
* memory will trigger garbage collections more often than it would otherwise in
|
19
|
+
* an attempt to garbage collect the JavaScript objects that keep the externally
|
20
|
+
* allocated memory alive. Instances of ExternalMemoryAccounter check that the
|
21
|
+
* reported external memory is back to 0 on destruction.
|
22
|
+
*/
|
23
|
+
class V8_EXPORT ExternalMemoryAccounter {
|
24
|
+
public:
|
25
|
+
/**
|
26
|
+
* Returns the amount of external memory registered for `isolate`.
|
27
|
+
*/
|
28
|
+
static int64_t GetTotalAmountOfExternalAllocatedMemoryForTesting(
|
29
|
+
const Isolate* isolate);
|
30
|
+
|
31
|
+
ExternalMemoryAccounter() = default;
|
32
|
+
~ExternalMemoryAccounter();
|
33
|
+
ExternalMemoryAccounter(ExternalMemoryAccounter&&);
|
34
|
+
ExternalMemoryAccounter& operator=(ExternalMemoryAccounter&&);
|
35
|
+
ExternalMemoryAccounter(const ExternalMemoryAccounter&) = delete;
|
36
|
+
ExternalMemoryAccounter& operator=(const ExternalMemoryAccounter&) = delete;
|
37
|
+
|
38
|
+
/**
|
39
|
+
* Reports an increase of `size` bytes of external memory.
|
40
|
+
*/
|
41
|
+
void Increase(Isolate* isolate, size_t size);
|
42
|
+
/**
|
43
|
+
* Reports an update of `delta` bytes of external memory.
|
44
|
+
*/
|
45
|
+
void Update(Isolate* isolate, int64_t delta);
|
46
|
+
/**
|
47
|
+
* Reports an decrease of `size` bytes of external memory.
|
48
|
+
*/
|
49
|
+
void Decrease(Isolate* isolate, size_t size);
|
50
|
+
|
51
|
+
private:
|
52
|
+
#ifdef V8_ENABLE_MEMORY_ACCOUNTING_CHECKS
|
53
|
+
size_t amount_of_external_memory_ = 0;
|
54
|
+
v8::Isolate* isolate_ = nullptr;
|
55
|
+
#endif
|
56
|
+
};
|
57
|
+
|
58
|
+
} // namespace v8
|
59
|
+
|
60
|
+
#endif // INCLUDE_EXTERNAL_MEMORY_ACCOUNTER_H_
|
@@ -2,6 +2,9 @@
|
|
2
2
|
// Use of this source code is governed by a BSD-style license that can be
|
3
3
|
// found in the LICENSE file.
|
4
4
|
|
5
|
+
#ifndef INCLUDE_V8_FAST_API_CALLS_H_
|
6
|
+
#define INCLUDE_V8_FAST_API_CALLS_H_
|
7
|
+
|
5
8
|
/**
|
6
9
|
* This file provides additional API on top of the default one for making
|
7
10
|
* API calls, which come from embedder C++ functions. The functions are being
|
@@ -216,9 +219,6 @@
|
|
216
219
|
* associated SlowCallback.
|
217
220
|
*/
|
218
221
|
|
219
|
-
#ifndef INCLUDE_V8_FAST_API_CALLS_H_
|
220
|
-
#define INCLUDE_V8_FAST_API_CALLS_H_
|
221
|
-
|
222
222
|
#include <stddef.h>
|
223
223
|
#include <stdint.h>
|
224
224
|
|
@@ -235,6 +235,7 @@ namespace v8 {
|
|
235
235
|
|
236
236
|
class Isolate;
|
237
237
|
|
238
|
+
START_ALLOW_USE_DEPRECATED()
|
238
239
|
class CTypeInfo {
|
239
240
|
public:
|
240
241
|
enum class Type : uint8_t {
|
@@ -268,11 +269,11 @@ class CTypeInfo {
|
|
268
269
|
// than any valid Type enum.
|
269
270
|
static constexpr Type kCallbackOptionsType = Type(255);
|
270
271
|
|
271
|
-
enum class
|
272
|
+
enum class V8_DEPRECATE_SOON(
|
273
|
+
"There is no special support in V8 anymore, there is no need to"
|
274
|
+
"use a SequenceType") SequenceType : uint8_t {
|
272
275
|
kScalar,
|
273
276
|
kIsSequence, // sequence<T>
|
274
|
-
kIsTypedArray, // TypedArray of T or any ArrayBufferView if T
|
275
|
-
// is void
|
276
277
|
kIsArrayBuffer // ArrayBuffer
|
277
278
|
};
|
278
279
|
|
@@ -284,9 +285,12 @@ class CTypeInfo {
|
|
284
285
|
kIsRestrictedBit = 1 << 3, // T must be float or double
|
285
286
|
};
|
286
287
|
|
287
|
-
explicit constexpr CTypeInfo(
|
288
|
-
|
289
|
-
|
288
|
+
explicit constexpr CTypeInfo(Type type, Flags flags = Flags::kNone)
|
289
|
+
: type_(type), sequence_type_(SequenceType::kScalar), flags_(flags) {}
|
290
|
+
|
291
|
+
V8_DEPRECATE_SOON("Use CTypeInfo(Type, Flags) instead")
|
292
|
+
constexpr CTypeInfo(Type type, SequenceType sequence_type,
|
293
|
+
Flags flags = Flags::kNone)
|
290
294
|
: type_(type), sequence_type_(sequence_type), flags_(flags) {}
|
291
295
|
|
292
296
|
typedef uint32_t Identifier;
|
@@ -301,6 +305,7 @@ class CTypeInfo {
|
|
301
305
|
}
|
302
306
|
|
303
307
|
constexpr Type GetType() const { return type_; }
|
308
|
+
V8_DEPRECATE_SOON("Use the constant SequenceType::kScalar instead")
|
304
309
|
constexpr SequenceType GetSequenceType() const { return sequence_type_; }
|
305
310
|
constexpr Flags GetFlags() const { return flags_; }
|
306
311
|
|
@@ -324,69 +329,7 @@ class CTypeInfo {
|
|
324
329
|
SequenceType sequence_type_;
|
325
330
|
Flags flags_;
|
326
331
|
};
|
327
|
-
|
328
|
-
struct FastApiTypedArrayBase {
|
329
|
-
public:
|
330
|
-
// Returns the length in number of elements.
|
331
|
-
size_t V8_EXPORT length() const { return length_; }
|
332
|
-
// Checks whether the given index is within the bounds of the collection.
|
333
|
-
void V8_EXPORT ValidateIndex(size_t index) const;
|
334
|
-
|
335
|
-
protected:
|
336
|
-
size_t length_ = 0;
|
337
|
-
};
|
338
|
-
|
339
|
-
template <typename T>
|
340
|
-
struct V8_DEPRECATE_SOON(
|
341
|
-
"When an API function expects a TypedArray as a parameter, the type in the "
|
342
|
-
"signature should be `v8::Local<v8::Value>` instead of "
|
343
|
-
"FastApiTypedArray<>. The API function then has to type-check the "
|
344
|
-
"parameter and convert it to a `v8::Local<v8::TypedArray` to access the "
|
345
|
-
"data. In essence, the parameter should be handled the same as for a "
|
346
|
-
"regular API call.") FastApiTypedArray : public FastApiTypedArrayBase {
|
347
|
-
public:
|
348
|
-
V8_INLINE T get(size_t index) const {
|
349
|
-
#ifdef DEBUG
|
350
|
-
ValidateIndex(index);
|
351
|
-
#endif // DEBUG
|
352
|
-
T tmp;
|
353
|
-
memcpy(&tmp, static_cast<void*>(reinterpret_cast<T*>(data_) + index),
|
354
|
-
sizeof(T));
|
355
|
-
return tmp;
|
356
|
-
}
|
357
|
-
|
358
|
-
bool getStorageIfAligned(T** elements) const {
|
359
|
-
if (reinterpret_cast<uintptr_t>(data_) % alignof(T) != 0) {
|
360
|
-
return false;
|
361
|
-
}
|
362
|
-
*elements = reinterpret_cast<T*>(data_);
|
363
|
-
return true;
|
364
|
-
}
|
365
|
-
|
366
|
-
private:
|
367
|
-
// This pointer should include the typed array offset applied.
|
368
|
-
// It's not guaranteed that it's aligned to sizeof(T), it's only
|
369
|
-
// guaranteed that it's 4-byte aligned, so for 8-byte types we need to
|
370
|
-
// provide a special implementation for reading from it, which hides
|
371
|
-
// the possibly unaligned read in the `get` method.
|
372
|
-
void* data_;
|
373
|
-
};
|
374
|
-
|
375
|
-
// Any TypedArray. It uses kTypedArrayBit with base type void
|
376
|
-
// Overloaded args of ArrayBufferView and TypedArray are not supported
|
377
|
-
// (for now) because the generic “any” ArrayBufferView doesn’t have its
|
378
|
-
// own instance type. It could be supported if we specify that
|
379
|
-
// TypedArray<T> always has precedence over the generic ArrayBufferView,
|
380
|
-
// but this complicates overload resolution.
|
381
|
-
struct FastApiArrayBufferView {
|
382
|
-
void* data;
|
383
|
-
size_t byte_length;
|
384
|
-
};
|
385
|
-
|
386
|
-
struct FastApiArrayBuffer {
|
387
|
-
void* data;
|
388
|
-
size_t byte_length;
|
389
|
-
};
|
332
|
+
END_ALLOW_USE_DEPRECATED()
|
390
333
|
|
391
334
|
struct FastOneByteString {
|
392
335
|
const char* data;
|
@@ -493,40 +436,6 @@ class V8_EXPORT CFunction {
|
|
493
436
|
|
494
437
|
enum class OverloadResolution { kImpossible, kAtRuntime, kAtCompileTime };
|
495
438
|
|
496
|
-
// Returns whether an overload between this and the given CFunction can
|
497
|
-
// be resolved at runtime by the RTTI available for the arguments or at
|
498
|
-
// compile time for functions with different number of arguments.
|
499
|
-
OverloadResolution GetOverloadResolution(const CFunction* other) {
|
500
|
-
// Runtime overload resolution can only deal with functions with the
|
501
|
-
// same number of arguments. Functions with different arity are handled
|
502
|
-
// by compile time overload resolution though.
|
503
|
-
if (ArgumentCount() != other->ArgumentCount()) {
|
504
|
-
return OverloadResolution::kAtCompileTime;
|
505
|
-
}
|
506
|
-
|
507
|
-
// The functions can only differ by a single argument position.
|
508
|
-
int diff_index = -1;
|
509
|
-
for (unsigned int i = 0; i < ArgumentCount(); ++i) {
|
510
|
-
if (ArgumentInfo(i).GetSequenceType() !=
|
511
|
-
other->ArgumentInfo(i).GetSequenceType()) {
|
512
|
-
if (diff_index >= 0) {
|
513
|
-
return OverloadResolution::kImpossible;
|
514
|
-
}
|
515
|
-
diff_index = i;
|
516
|
-
|
517
|
-
// We only support overload resolution between sequence types.
|
518
|
-
if (ArgumentInfo(i).GetSequenceType() ==
|
519
|
-
CTypeInfo::SequenceType::kScalar ||
|
520
|
-
other->ArgumentInfo(i).GetSequenceType() ==
|
521
|
-
CTypeInfo::SequenceType::kScalar) {
|
522
|
-
return OverloadResolution::kImpossible;
|
523
|
-
}
|
524
|
-
}
|
525
|
-
}
|
526
|
-
|
527
|
-
return OverloadResolution::kAtRuntime;
|
528
|
-
}
|
529
|
-
|
530
439
|
template <typename F>
|
531
440
|
static CFunction Make(F* func,
|
532
441
|
CFunctionInfo::Int64Representation int64_rep =
|
@@ -656,9 +565,6 @@ struct TypeInfoHelper {
|
|
656
565
|
} \
|
657
566
|
\
|
658
567
|
static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::Enum; } \
|
659
|
-
static constexpr CTypeInfo::SequenceType SequenceType() { \
|
660
|
-
return CTypeInfo::SequenceType::kScalar; \
|
661
|
-
} \
|
662
568
|
};
|
663
569
|
|
664
570
|
template <CTypeInfo::Type type>
|
@@ -687,6 +593,7 @@ struct CTypeInfoTraits {};
|
|
687
593
|
V(void, kVoid) \
|
688
594
|
V(v8::Local<v8::Value>, kV8Value) \
|
689
595
|
V(v8::Local<v8::Object>, kV8Value) \
|
596
|
+
V(v8::Local<v8::Array>, kV8Value) \
|
690
597
|
V(AnyCType, kAny)
|
691
598
|
|
692
599
|
// ApiObject was a temporary solution to wrap the pointer to the v8::Value.
|
@@ -699,52 +606,8 @@ PRIMITIVE_C_TYPES(DEFINE_TYPE_INFO_TRAITS)
|
|
699
606
|
#undef PRIMITIVE_C_TYPES
|
700
607
|
#undef ALL_C_TYPES
|
701
608
|
|
702
|
-
#define SPECIALIZE_GET_TYPE_INFO_HELPER_FOR_TA(T, Enum) \
|
703
|
-
template <> \
|
704
|
-
struct TypeInfoHelper<const FastApiTypedArray<T>&> { \
|
705
|
-
static constexpr CTypeInfo::Flags Flags() { \
|
706
|
-
return CTypeInfo::Flags::kNone; \
|
707
|
-
} \
|
708
|
-
\
|
709
|
-
static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::Enum; } \
|
710
|
-
static constexpr CTypeInfo::SequenceType SequenceType() { \
|
711
|
-
return CTypeInfo::SequenceType::kIsTypedArray; \
|
712
|
-
} \
|
713
|
-
};
|
714
|
-
|
715
|
-
#define TYPED_ARRAY_C_TYPES(V) \
|
716
|
-
V(uint8_t, kUint8) \
|
717
|
-
V(int32_t, kInt32) \
|
718
|
-
V(uint32_t, kUint32) \
|
719
|
-
V(int64_t, kInt64) \
|
720
|
-
V(uint64_t, kUint64) \
|
721
|
-
V(float, kFloat32) \
|
722
|
-
V(double, kFloat64)
|
723
|
-
|
724
|
-
TYPED_ARRAY_C_TYPES(SPECIALIZE_GET_TYPE_INFO_HELPER_FOR_TA)
|
725
|
-
|
726
609
|
#undef TYPED_ARRAY_C_TYPES
|
727
610
|
|
728
|
-
template <>
|
729
|
-
struct TypeInfoHelper<v8::Local<v8::Array>> {
|
730
|
-
static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
|
731
|
-
|
732
|
-
static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::kVoid; }
|
733
|
-
static constexpr CTypeInfo::SequenceType SequenceType() {
|
734
|
-
return CTypeInfo::SequenceType::kIsSequence;
|
735
|
-
}
|
736
|
-
};
|
737
|
-
|
738
|
-
template <>
|
739
|
-
struct TypeInfoHelper<v8::Local<v8::Uint32Array>> {
|
740
|
-
static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
|
741
|
-
|
742
|
-
static constexpr CTypeInfo::Type Type() { return CTypeInfo::Type::kUint32; }
|
743
|
-
static constexpr CTypeInfo::SequenceType SequenceType() {
|
744
|
-
return CTypeInfo::SequenceType::kIsTypedArray;
|
745
|
-
}
|
746
|
-
};
|
747
|
-
|
748
611
|
template <>
|
749
612
|
struct TypeInfoHelper<FastApiCallbackOptions&> {
|
750
613
|
static constexpr CTypeInfo::Flags Flags() { return CTypeInfo::Flags::kNone; }
|
@@ -752,9 +615,6 @@ struct TypeInfoHelper<FastApiCallbackOptions&> {
|
|
752
615
|
static constexpr CTypeInfo::Type Type() {
|
753
616
|
return CTypeInfo::kCallbackOptionsType;
|
754
617
|
}
|
755
|
-
static constexpr CTypeInfo::SequenceType SequenceType() {
|
756
|
-
return CTypeInfo::SequenceType::kScalar;
|
757
|
-
}
|
758
618
|
};
|
759
619
|
|
760
620
|
template <>
|
@@ -764,9 +624,6 @@ struct TypeInfoHelper<const FastOneByteString&> {
|
|
764
624
|
static constexpr CTypeInfo::Type Type() {
|
765
625
|
return CTypeInfo::Type::kSeqOneByteString;
|
766
626
|
}
|
767
|
-
static constexpr CTypeInfo::SequenceType SequenceType() {
|
768
|
-
return CTypeInfo::SequenceType::kScalar;
|
769
|
-
}
|
770
627
|
};
|
771
628
|
|
772
629
|
#define STATIC_ASSERT_IMPLIES(COND, ASSERTION, MSG) \
|
@@ -783,14 +640,7 @@ class V8_EXPORT CTypeInfoBuilder {
|
|
783
640
|
constexpr CTypeInfo::Flags kFlags =
|
784
641
|
MergeFlags(internal::TypeInfoHelper<T>::Flags(), Flags...);
|
785
642
|
constexpr CTypeInfo::Type kType = internal::TypeInfoHelper<T>::Type();
|
786
|
-
constexpr CTypeInfo::SequenceType kSequenceType =
|
787
|
-
internal::TypeInfoHelper<T>::SequenceType();
|
788
643
|
|
789
|
-
STATIC_ASSERT_IMPLIES(
|
790
|
-
uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kAllowSharedBit),
|
791
|
-
(kSequenceType == CTypeInfo::SequenceType::kIsTypedArray ||
|
792
|
-
kSequenceType == CTypeInfo::SequenceType::kIsArrayBuffer),
|
793
|
-
"kAllowSharedBit is only allowed for TypedArrays and ArrayBuffers.");
|
794
644
|
STATIC_ASSERT_IMPLIES(
|
795
645
|
uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kEnforceRangeBit),
|
796
646
|
CTypeInfo::IsIntegralType(kType),
|
@@ -803,17 +653,9 @@ class V8_EXPORT CTypeInfoBuilder {
|
|
803
653
|
uint8_t(kFlags) & uint8_t(CTypeInfo::Flags::kIsRestrictedBit),
|
804
654
|
CTypeInfo::IsFloatingPointType(kType),
|
805
655
|
"kIsRestrictedBit is only allowed for floating point types.");
|
806
|
-
STATIC_ASSERT_IMPLIES(kSequenceType == CTypeInfo::SequenceType::kIsSequence,
|
807
|
-
kType == CTypeInfo::Type::kVoid,
|
808
|
-
"Sequences are only supported from void type.");
|
809
|
-
STATIC_ASSERT_IMPLIES(
|
810
|
-
kSequenceType == CTypeInfo::SequenceType::kIsTypedArray,
|
811
|
-
CTypeInfo::IsPrimitive(kType) || kType == CTypeInfo::Type::kVoid,
|
812
|
-
"TypedArrays are only supported from primitive types or void.");
|
813
656
|
|
814
657
|
// Return the same type with the merged flags.
|
815
|
-
return CTypeInfo(internal::TypeInfoHelper<T>::Type(),
|
816
|
-
internal::TypeInfoHelper<T>::SequenceType(), kFlags);
|
658
|
+
return CTypeInfo(internal::TypeInfoHelper<T>::Type(), kFlags);
|
817
659
|
}
|
818
660
|
|
819
661
|
private:
|