node-aix-ppc64 20.9.0 → 21.1.0
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.
- package/CHANGELOG.md +354 -1654
- package/LICENSE +21 -10
- package/README.md +7 -5
- package/bin/node +0 -0
- package/include/node/common.gypi +3 -3
- package/include/node/config.gypi +5 -3
- package/include/node/cppgc/internal/api-constants.h +23 -4
- package/include/node/cppgc/internal/caged-heap-local-data.h +16 -6
- package/include/node/cppgc/internal/caged-heap.h +12 -5
- package/include/node/cppgc/internal/gc-info.h +82 -91
- package/include/node/cppgc/internal/member-storage.h +16 -8
- package/include/node/cppgc/member.h +25 -0
- package/include/node/cppgc/persistent.h +4 -0
- package/include/node/cppgc/platform.h +6 -1
- package/include/node/cppgc/sentinel-pointer.h +7 -0
- package/include/node/cppgc/source-location.h +2 -78
- package/include/node/cppgc/trace-trait.h +8 -0
- package/include/node/cppgc/visitor.h +82 -4
- package/include/node/js_native_api.h +11 -1
- package/include/node/libplatform/libplatform.h +7 -1
- package/include/node/node.exp +11941 -4880
- package/include/node/node.h +2 -0
- package/include/node/node_api.h +8 -7
- package/include/node/node_version.h +9 -8
- package/include/node/v8-callbacks.h +52 -8
- package/include/node/v8-context.h +10 -13
- package/include/node/v8-embedder-heap.h +12 -0
- package/include/node/v8-function-callback.h +11 -15
- package/include/node/v8-function.h +6 -0
- package/include/node/v8-handle-base.h +185 -0
- package/include/node/v8-internal.h +109 -77
- package/include/node/v8-isolate.h +130 -89
- package/include/node/v8-local-handle.h +134 -89
- package/include/node/v8-object.h +71 -69
- package/include/node/v8-persistent-handle.h +65 -89
- package/include/node/v8-platform.h +140 -9
- package/include/node/v8-primitive.h +12 -8
- package/include/node/v8-profiler.h +16 -2
- package/include/node/v8-script.h +9 -7
- package/include/node/v8-snapshot.h +4 -1
- package/include/node/v8-source-location.h +92 -0
- package/include/node/v8-statistics.h +36 -1
- package/include/node/v8-traced-handle.h +37 -54
- package/include/node/v8-unwinder.h +1 -1
- package/include/node/v8-value-serializer.h +14 -0
- package/include/node/v8-value.h +14 -0
- package/include/node/v8-version.h +3 -3
- package/include/node/v8config.h +19 -10
- package/package.json +1 -1
- package/share/doc/node/gdbinit +60 -6
- package/share/doc/node/lldb_commands.py +73 -10
- package/share/man/man1/node.1 +12 -0
package/include/node/node.h
CHANGED
|
@@ -265,6 +265,8 @@ enum Flags : uint32_t {
|
|
|
265
265
|
// cppgc::InitializeProcess() before creating a Node.js environment
|
|
266
266
|
// and call cppgc::ShutdownProcess() before process shutdown.
|
|
267
267
|
kNoInitializeCppgc = 1 << 13,
|
|
268
|
+
// Initialize the process for predictable snapshot generation.
|
|
269
|
+
kGeneratePredictableSnapshot = 1 << 14,
|
|
268
270
|
|
|
269
271
|
// Emulate the behavior of InitializeNodeWithArgs() when passing
|
|
270
272
|
// a flags argument to the InitializeOncePerProcess() replacement
|
package/include/node/node_api.h
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#ifndef SRC_NODE_API_H_
|
|
2
2
|
#define SRC_NODE_API_H_
|
|
3
3
|
|
|
4
|
-
#
|
|
4
|
+
#if defined(BUILDING_NODE_EXTENSION) && !defined(NAPI_EXTERN)
|
|
5
5
|
#ifdef _WIN32
|
|
6
6
|
// Building native addon against node
|
|
7
7
|
#define NAPI_EXTERN __declspec(dllimport)
|
|
8
|
-
#elif defined(
|
|
8
|
+
#elif defined(__wasm__)
|
|
9
9
|
#define NAPI_EXTERN __attribute__((__import_module__("napi")))
|
|
10
10
|
#endif
|
|
11
11
|
#endif
|
|
@@ -17,8 +17,13 @@ struct uv_loop_s; // Forward declaration.
|
|
|
17
17
|
#ifdef _WIN32
|
|
18
18
|
#define NAPI_MODULE_EXPORT __declspec(dllexport)
|
|
19
19
|
#else
|
|
20
|
+
#ifdef __EMSCRIPTEN__
|
|
21
|
+
#define NAPI_MODULE_EXPORT \
|
|
22
|
+
__attribute__((visibility("default"))) __attribute__((used))
|
|
23
|
+
#else
|
|
20
24
|
#define NAPI_MODULE_EXPORT __attribute__((visibility("default")))
|
|
21
25
|
#endif
|
|
26
|
+
#endif
|
|
22
27
|
|
|
23
28
|
#if defined(__GNUC__)
|
|
24
29
|
#define NAPI_NO_RETURN __attribute__((noreturn))
|
|
@@ -49,7 +54,7 @@ typedef struct napi_module {
|
|
|
49
54
|
NAPI_MODULE_INITIALIZER_X_HELPER(base, version)
|
|
50
55
|
#define NAPI_MODULE_INITIALIZER_X_HELPER(base, version) base##version
|
|
51
56
|
|
|
52
|
-
#ifdef
|
|
57
|
+
#ifdef __wasm__
|
|
53
58
|
#define NAPI_MODULE_INITIALIZER_BASE napi_register_wasm_v
|
|
54
59
|
#else
|
|
55
60
|
#define NAPI_MODULE_INITIALIZER_BASE napi_register_module_v
|
|
@@ -143,7 +148,6 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_get_buffer_info(napi_env env,
|
|
|
143
148
|
void** data,
|
|
144
149
|
size_t* length);
|
|
145
150
|
|
|
146
|
-
#ifndef __wasm32__
|
|
147
151
|
// Methods to manage simple async operations
|
|
148
152
|
NAPI_EXTERN napi_status NAPI_CDECL
|
|
149
153
|
napi_create_async_work(napi_env env,
|
|
@@ -159,7 +163,6 @@ NAPI_EXTERN napi_status NAPI_CDECL napi_queue_async_work(napi_env env,
|
|
|
159
163
|
napi_async_work work);
|
|
160
164
|
NAPI_EXTERN napi_status NAPI_CDECL napi_cancel_async_work(napi_env env,
|
|
161
165
|
napi_async_work work);
|
|
162
|
-
#endif // __wasm32__
|
|
163
166
|
|
|
164
167
|
// version management
|
|
165
168
|
NAPI_EXTERN napi_status NAPI_CDECL
|
|
@@ -197,7 +200,6 @@ napi_close_callback_scope(napi_env env, napi_callback_scope scope);
|
|
|
197
200
|
|
|
198
201
|
#if NAPI_VERSION >= 4
|
|
199
202
|
|
|
200
|
-
#ifndef __wasm32__
|
|
201
203
|
// Calling into JS from other threads
|
|
202
204
|
NAPI_EXTERN napi_status NAPI_CDECL
|
|
203
205
|
napi_create_threadsafe_function(napi_env env,
|
|
@@ -231,7 +233,6 @@ napi_unref_threadsafe_function(napi_env env, napi_threadsafe_function func);
|
|
|
231
233
|
|
|
232
234
|
NAPI_EXTERN napi_status NAPI_CDECL
|
|
233
235
|
napi_ref_threadsafe_function(napi_env env, napi_threadsafe_function func);
|
|
234
|
-
#endif // __wasm32__
|
|
235
236
|
|
|
236
237
|
#endif // NAPI_VERSION >= 4
|
|
237
238
|
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
#ifndef SRC_NODE_VERSION_H_
|
|
23
23
|
#define SRC_NODE_VERSION_H_
|
|
24
24
|
|
|
25
|
-
#define NODE_MAJOR_VERSION
|
|
26
|
-
#define NODE_MINOR_VERSION
|
|
25
|
+
#define NODE_MAJOR_VERSION 21
|
|
26
|
+
#define NODE_MINOR_VERSION 1
|
|
27
27
|
#define NODE_PATCH_VERSION 0
|
|
28
28
|
|
|
29
|
-
#define NODE_VERSION_IS_LTS
|
|
30
|
-
#define NODE_VERSION_LTS_CODENAME "
|
|
29
|
+
#define NODE_VERSION_IS_LTS 0
|
|
30
|
+
#define NODE_VERSION_LTS_CODENAME ""
|
|
31
31
|
|
|
32
32
|
#define NODE_VERSION_IS_RELEASE 1
|
|
33
33
|
|
|
@@ -95,12 +95,13 @@
|
|
|
95
95
|
#if defined(NODE_EMBEDDER_MODULE_VERSION)
|
|
96
96
|
#define NODE_MODULE_VERSION NODE_EMBEDDER_MODULE_VERSION
|
|
97
97
|
#else
|
|
98
|
-
#define NODE_MODULE_VERSION
|
|
98
|
+
#define NODE_MODULE_VERSION 120
|
|
99
99
|
#endif
|
|
100
100
|
|
|
101
|
-
// The NAPI_VERSION
|
|
102
|
-
// which the Node binary being built supports.
|
|
103
|
-
#define
|
|
101
|
+
// The NAPI_VERSION supported by the runtime. This is the inclusive range of
|
|
102
|
+
// versions which the Node.js binary being built supports.
|
|
103
|
+
#define NODE_API_SUPPORTED_VERSION_MAX 9
|
|
104
|
+
#define NODE_API_SUPPORTED_VERSION_MIN 1
|
|
104
105
|
|
|
105
106
|
// Node API modules use NAPI_VERSION 8 by default if it is not explicitly
|
|
106
107
|
// specified. It must be always 8.
|
|
@@ -147,14 +147,18 @@ using JitCodeEventHandler = void (*)(const JitCodeEvent* event);
|
|
|
147
147
|
* the callback functions, you therefore cannot manipulate objects (set or
|
|
148
148
|
* delete properties for example) since it is possible such operations will
|
|
149
149
|
* result in the allocation of objects.
|
|
150
|
+
* TODO(v8:12612): Deprecate kGCTypeMinorMarkSweep after updating blink.
|
|
150
151
|
*/
|
|
151
152
|
enum GCType {
|
|
152
153
|
kGCTypeScavenge = 1 << 0,
|
|
153
|
-
|
|
154
|
+
kGCTypeMinorMarkSweep = 1 << 1,
|
|
155
|
+
kGCTypeMinorMarkCompact V8_DEPRECATE_SOON(
|
|
156
|
+
"Use kGCTypeMinorMarkSweep instead of kGCTypeMinorMarkCompact.") =
|
|
157
|
+
kGCTypeMinorMarkSweep,
|
|
154
158
|
kGCTypeMarkSweepCompact = 1 << 2,
|
|
155
159
|
kGCTypeIncrementalMarking = 1 << 3,
|
|
156
160
|
kGCTypeProcessWeakCallbacks = 1 << 4,
|
|
157
|
-
kGCTypeAll = kGCTypeScavenge |
|
|
161
|
+
kGCTypeAll = kGCTypeScavenge | kGCTypeMinorMarkSweep |
|
|
158
162
|
kGCTypeMarkSweepCompact | kGCTypeIncrementalMarking |
|
|
159
163
|
kGCTypeProcessWeakCallbacks
|
|
160
164
|
};
|
|
@@ -323,20 +327,21 @@ using WasmAsyncResolvePromiseCallback = void (*)(
|
|
|
323
327
|
using WasmLoadSourceMapCallback = Local<String> (*)(Isolate* isolate,
|
|
324
328
|
const char* name);
|
|
325
329
|
|
|
326
|
-
// --- Callback for checking if WebAssembly Simd is enabled ---
|
|
327
|
-
using WasmSimdEnabledCallback = bool (*)(Local<Context> context);
|
|
328
|
-
|
|
329
|
-
// --- Callback for checking if WebAssembly exceptions are enabled ---
|
|
330
|
-
using WasmExceptionsEnabledCallback = bool (*)(Local<Context> context);
|
|
331
|
-
|
|
332
330
|
// --- Callback for checking if WebAssembly GC is enabled ---
|
|
333
331
|
// If the callback returns true, it will also enable Wasm stringrefs.
|
|
334
332
|
using WasmGCEnabledCallback = bool (*)(Local<Context> context);
|
|
335
333
|
|
|
334
|
+
// --- Callback for checking if WebAssembly imported strings are enabled ---
|
|
335
|
+
using WasmImportedStringsEnabledCallback = bool (*)(Local<Context> context);
|
|
336
|
+
|
|
336
337
|
// --- Callback for checking if the SharedArrayBuffer constructor is enabled ---
|
|
337
338
|
using SharedArrayBufferConstructorEnabledCallback =
|
|
338
339
|
bool (*)(Local<Context> context);
|
|
339
340
|
|
|
341
|
+
// --- Callback for checking if the compile hints magic comments are enabled ---
|
|
342
|
+
using JavaScriptCompileHintsMagicEnabledCallback =
|
|
343
|
+
bool (*)(Local<Context> context);
|
|
344
|
+
|
|
340
345
|
/**
|
|
341
346
|
* HostImportModuleDynamicallyCallback is called when we
|
|
342
347
|
* require the embedder to load a module. This is used as part of the dynamic
|
|
@@ -419,6 +424,45 @@ using PrepareStackTraceCallback = MaybeLocal<Value> (*)(Local<Context> context,
|
|
|
419
424
|
Local<Value> error,
|
|
420
425
|
Local<Array> sites);
|
|
421
426
|
|
|
427
|
+
#if defined(V8_OS_WIN)
|
|
428
|
+
/**
|
|
429
|
+
* Callback to selectively enable ETW tracing based on the document URL.
|
|
430
|
+
* Implemented by the embedder, it should never call back into V8.
|
|
431
|
+
*
|
|
432
|
+
* Windows allows passing additional data to the ETW EnableCallback:
|
|
433
|
+
* https://learn.microsoft.com/en-us/windows/win32/api/evntprov/nc-evntprov-penablecallback
|
|
434
|
+
*
|
|
435
|
+
* This data can be configured in a WPR (Windows Performance Recorder)
|
|
436
|
+
* profile, adding a CustomFilter to an EventProvider like the following:
|
|
437
|
+
*
|
|
438
|
+
* <EventProvider Id=".." Name="57277741-3638-4A4B-BDBA-0AC6E45DA56C" Level="5">
|
|
439
|
+
* <CustomFilter Type="0x80000000" Value="AQABAAAAAAA..." />
|
|
440
|
+
* </EventProvider>
|
|
441
|
+
*
|
|
442
|
+
* Where:
|
|
443
|
+
* - Name="57277741-3638-4A4B-BDBA-0AC6E45DA56C" is the GUID of the V8
|
|
444
|
+
* ETW provider, (see src/libplatform/etw/etw-provider-win.h),
|
|
445
|
+
* - Type="0x80000000" is EVENT_FILTER_TYPE_SCHEMATIZED,
|
|
446
|
+
* - Value="AQABAAAAAA..." is a base64-encoded byte array that is
|
|
447
|
+
* base64-decoded by Windows and passed to the ETW enable callback in
|
|
448
|
+
* the 'PEVENT_FILTER_DESCRIPTOR FilterData' argument; see:
|
|
449
|
+
* https://learn.microsoft.com/en-us/windows/win32/api/evntprov/ns-evntprov-event_filter_descriptor.
|
|
450
|
+
*
|
|
451
|
+
* This array contains a struct EVENT_FILTER_HEADER followed by a
|
|
452
|
+
* variable length payload, and as payload we pass a string in JSON format,
|
|
453
|
+
* with a list of regular expressions that should match the document URL
|
|
454
|
+
* in order to enable ETW tracing:
|
|
455
|
+
* {
|
|
456
|
+
* "version": "1.0",
|
|
457
|
+
* "filtered_urls": [
|
|
458
|
+
* "https:\/\/.*\.chromium\.org\/.*", "https://v8.dev/";, "..."
|
|
459
|
+
* ]
|
|
460
|
+
* }
|
|
461
|
+
*/
|
|
462
|
+
using FilterETWSessionByURLCallback =
|
|
463
|
+
bool (*)(Local<Context> context, const std::string& etw_filter_payload);
|
|
464
|
+
#endif // V8_OS_WIN
|
|
465
|
+
|
|
422
466
|
} // namespace v8
|
|
423
467
|
|
|
424
468
|
#endif // INCLUDE_V8_ISOLATE_CALLBACKS_H_
|
|
@@ -395,7 +395,7 @@ Local<Value> Context::GetEmbedderData(int index) {
|
|
|
395
395
|
#ifndef V8_ENABLE_CHECKS
|
|
396
396
|
using A = internal::Address;
|
|
397
397
|
using I = internal::Internals;
|
|
398
|
-
A ctx =
|
|
398
|
+
A ctx = internal::ValueHelper::ValueAsAddress(this);
|
|
399
399
|
A embedder_data =
|
|
400
400
|
I::ReadTaggedPointerField(ctx, I::kNativeContextEmbedderDataOffset);
|
|
401
401
|
int value_offset =
|
|
@@ -407,15 +407,9 @@ Local<Value> Context::GetEmbedderData(int index) {
|
|
|
407
407
|
value = I::DecompressTaggedField(embedder_data, static_cast<uint32_t>(value));
|
|
408
408
|
#endif
|
|
409
409
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
internal::Isolate* isolate = internal::IsolateFromNeverReadOnlySpaceObject(
|
|
414
|
-
*reinterpret_cast<A*>(this));
|
|
415
|
-
A* result = HandleScope::CreateHandle(isolate, value);
|
|
416
|
-
return Local<Value>(reinterpret_cast<Value*>(result));
|
|
417
|
-
#endif
|
|
418
|
-
|
|
410
|
+
auto isolate = reinterpret_cast<v8::Isolate*>(
|
|
411
|
+
internal::IsolateFromNeverReadOnlySpaceObject(ctx));
|
|
412
|
+
return Local<Value>::New(isolate, value);
|
|
419
413
|
#else
|
|
420
414
|
return SlowGetEmbedderData(index);
|
|
421
415
|
#endif
|
|
@@ -442,9 +436,12 @@ void* Context::GetAlignedPointerFromEmbedderData(int index) {
|
|
|
442
436
|
|
|
443
437
|
template <class T>
|
|
444
438
|
MaybeLocal<T> Context::GetDataFromSnapshotOnce(size_t index) {
|
|
445
|
-
|
|
446
|
-
if (
|
|
447
|
-
|
|
439
|
+
auto slot = GetDataFromSnapshotOnce(index);
|
|
440
|
+
if (slot) {
|
|
441
|
+
internal::PerformCastCheck(
|
|
442
|
+
internal::ValueHelper::SlotAsValue<T, false>(slot));
|
|
443
|
+
}
|
|
444
|
+
return Local<T>::FromSlot(slot);
|
|
448
445
|
}
|
|
449
446
|
|
|
450
447
|
Context* Context::Cast(v8::Data* data) {
|
|
@@ -34,6 +34,8 @@ class V8_EXPORT EmbedderRootsHandler {
|
|
|
34
34
|
* for retaining the object. The embedder may use |WrapperClassId()| to
|
|
35
35
|
* distinguish cases where it wants handles to be treated as roots from not
|
|
36
36
|
* being treated as roots.
|
|
37
|
+
*
|
|
38
|
+
* The concrete implementations must be thread-safe.
|
|
37
39
|
*/
|
|
38
40
|
virtual bool IsRoot(const v8::TracedReference<v8::Value>& handle) = 0;
|
|
39
41
|
|
|
@@ -47,6 +49,16 @@ class V8_EXPORT EmbedderRootsHandler {
|
|
|
47
49
|
* handle via the object or class id.
|
|
48
50
|
*/
|
|
49
51
|
virtual void ResetRoot(const v8::TracedReference<v8::Value>& handle) = 0;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Similar to |ResetRoot()|, but opportunistic. The function is called in
|
|
55
|
+
* parallel for different handles and as such must be thread-safe. In case,
|
|
56
|
+
* |false| is returned, |ResetRoot()| will be recalled for the same handle.
|
|
57
|
+
*/
|
|
58
|
+
virtual bool TryResetRoot(const v8::TracedReference<v8::Value>& handle) {
|
|
59
|
+
ResetRoot(handle);
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
50
62
|
};
|
|
51
63
|
|
|
52
64
|
} // namespace v8
|
|
@@ -78,7 +78,6 @@ class ReturnValue {
|
|
|
78
78
|
|
|
79
79
|
// See FunctionCallbackInfo.
|
|
80
80
|
static constexpr int kIsolateValueIndex = -2;
|
|
81
|
-
static constexpr int kDefaultValueValueIndex = -1;
|
|
82
81
|
|
|
83
82
|
internal::Address* value_;
|
|
84
83
|
};
|
|
@@ -127,16 +126,16 @@ class FunctionCallbackInfo {
|
|
|
127
126
|
friend class internal::FunctionCallbackArguments;
|
|
128
127
|
friend class internal::CustomArguments<FunctionCallbackInfo>;
|
|
129
128
|
friend class debug::ConsoleCallArguments;
|
|
130
|
-
|
|
129
|
+
|
|
131
130
|
static constexpr int kHolderIndex = 0;
|
|
132
131
|
static constexpr int kIsolateIndex = 1;
|
|
133
|
-
static constexpr int
|
|
132
|
+
static constexpr int kUnusedIndex = 2;
|
|
134
133
|
static constexpr int kReturnValueIndex = 3;
|
|
135
134
|
static constexpr int kDataIndex = 4;
|
|
136
135
|
static constexpr int kNewTargetIndex = 5;
|
|
137
|
-
|
|
138
136
|
static constexpr int kArgsLength = 6;
|
|
139
|
-
|
|
137
|
+
|
|
138
|
+
static constexpr int kArgsLengthWithReceiver = kArgsLength + 1;
|
|
140
139
|
|
|
141
140
|
// Codegen constants:
|
|
142
141
|
static constexpr int kSize = 3 * internal::kApiSystemPointerSize;
|
|
@@ -147,8 +146,6 @@ class FunctionCallbackInfo {
|
|
|
147
146
|
kValuesOffset + internal::kApiSystemPointerSize;
|
|
148
147
|
|
|
149
148
|
static constexpr int kThisValuesIndex = -1;
|
|
150
|
-
static_assert(ReturnValue<Value>::kDefaultValueValueIndex ==
|
|
151
|
-
kReturnValueDefaultValueIndex - kReturnValueIndex);
|
|
152
149
|
static_assert(ReturnValue<Value>::kIsolateValueIndex ==
|
|
153
150
|
kIsolateIndex - kReturnValueIndex);
|
|
154
151
|
|
|
@@ -258,17 +255,17 @@ class PropertyCallbackInfo {
|
|
|
258
255
|
static constexpr int kShouldThrowOnErrorIndex = 0;
|
|
259
256
|
static constexpr int kHolderIndex = 1;
|
|
260
257
|
static constexpr int kIsolateIndex = 2;
|
|
261
|
-
static constexpr int
|
|
258
|
+
static constexpr int kUnusedIndex = 3;
|
|
262
259
|
static constexpr int kReturnValueIndex = 4;
|
|
263
260
|
static constexpr int kDataIndex = 5;
|
|
264
261
|
static constexpr int kThisIndex = 6;
|
|
265
|
-
|
|
266
262
|
static constexpr int kArgsLength = 7;
|
|
267
263
|
|
|
268
264
|
static constexpr int kSize = 1 * internal::kApiSystemPointerSize;
|
|
269
265
|
|
|
270
266
|
V8_INLINE explicit PropertyCallbackInfo(internal::Address* args)
|
|
271
267
|
: args_(args) {}
|
|
268
|
+
|
|
272
269
|
internal::Address* args_;
|
|
273
270
|
};
|
|
274
271
|
|
|
@@ -286,7 +283,7 @@ void ReturnValue<T>::Set(const Global<S>& handle) {
|
|
|
286
283
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
|
287
284
|
*value_ = GetDefaultValue();
|
|
288
285
|
} else {
|
|
289
|
-
*value_ =
|
|
286
|
+
*value_ = handle.ptr();
|
|
290
287
|
}
|
|
291
288
|
}
|
|
292
289
|
|
|
@@ -297,7 +294,7 @@ void ReturnValue<T>::Set(const BasicTracedReference<S>& handle) {
|
|
|
297
294
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
|
298
295
|
*value_ = GetDefaultValue();
|
|
299
296
|
} else {
|
|
300
|
-
*value_ =
|
|
297
|
+
*value_ = handle.ptr();
|
|
301
298
|
}
|
|
302
299
|
}
|
|
303
300
|
|
|
@@ -309,7 +306,7 @@ void ReturnValue<T>::Set(const Local<S> handle) {
|
|
|
309
306
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
|
310
307
|
*value_ = GetDefaultValue();
|
|
311
308
|
} else {
|
|
312
|
-
*value_ =
|
|
309
|
+
*value_ = handle.ptr();
|
|
313
310
|
}
|
|
314
311
|
}
|
|
315
312
|
|
|
@@ -378,7 +375,6 @@ void ReturnValue<T>::SetEmptyString() {
|
|
|
378
375
|
|
|
379
376
|
template <typename T>
|
|
380
377
|
Isolate* ReturnValue<T>::GetIsolate() const {
|
|
381
|
-
// Isolate is always the pointer below the default value on the stack.
|
|
382
378
|
return *reinterpret_cast<Isolate**>(&value_[kIsolateValueIndex]);
|
|
383
379
|
}
|
|
384
380
|
|
|
@@ -403,8 +399,8 @@ void ReturnValue<T>::Set(S* whatever) {
|
|
|
403
399
|
|
|
404
400
|
template <typename T>
|
|
405
401
|
internal::Address ReturnValue<T>::GetDefaultValue() {
|
|
406
|
-
|
|
407
|
-
return
|
|
402
|
+
using I = internal::Internals;
|
|
403
|
+
return I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex);
|
|
408
404
|
}
|
|
409
405
|
|
|
410
406
|
template <typename T>
|
|
@@ -87,6 +87,12 @@ class V8_EXPORT Function : public Object {
|
|
|
87
87
|
*/
|
|
88
88
|
int GetScriptColumnNumber() const;
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Returns zero based start position (character offset) of function body and
|
|
92
|
+
* kLineOffsetNotFound if no information available.
|
|
93
|
+
*/
|
|
94
|
+
int GetScriptStartPosition() const;
|
|
95
|
+
|
|
90
96
|
/**
|
|
91
97
|
* Returns scriptId.
|
|
92
98
|
*/
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// Copyright 2023 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_HANDLE_BASE_H_
|
|
6
|
+
#define INCLUDE_V8_HANDLE_BASE_H_
|
|
7
|
+
|
|
8
|
+
#include "v8-internal.h" // NOLINT(build/include_directory)
|
|
9
|
+
|
|
10
|
+
namespace v8 {
|
|
11
|
+
|
|
12
|
+
namespace internal {
|
|
13
|
+
|
|
14
|
+
// Helper functions about values contained in handles.
|
|
15
|
+
// A value is either an indirect pointer or a direct pointer, depending on
|
|
16
|
+
// whether direct local support is enabled.
|
|
17
|
+
class ValueHelper final {
|
|
18
|
+
public:
|
|
19
|
+
#ifdef V8_ENABLE_DIRECT_LOCAL
|
|
20
|
+
static constexpr Address kTaggedNullAddress = 1;
|
|
21
|
+
static constexpr Address kEmpty = kTaggedNullAddress;
|
|
22
|
+
#else
|
|
23
|
+
static constexpr Address kEmpty = kNullAddress;
|
|
24
|
+
#endif // V8_ENABLE_DIRECT_LOCAL
|
|
25
|
+
|
|
26
|
+
template <typename T>
|
|
27
|
+
V8_INLINE static bool IsEmpty(T* value) {
|
|
28
|
+
return reinterpret_cast<Address>(value) == kEmpty;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Returns a handle's "value" for all kinds of abstract handles. For Local,
|
|
32
|
+
// it is equivalent to `*handle`. The variadic parameters support handle
|
|
33
|
+
// types with extra type parameters, like `Persistent<T, M>`.
|
|
34
|
+
template <template <typename T, typename... Ms> typename H, typename T,
|
|
35
|
+
typename... Ms>
|
|
36
|
+
V8_INLINE static T* HandleAsValue(const H<T, Ms...>& handle) {
|
|
37
|
+
return handle.template value<T>();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#ifdef V8_ENABLE_DIRECT_LOCAL
|
|
41
|
+
|
|
42
|
+
template <typename T>
|
|
43
|
+
V8_INLINE static Address ValueAsAddress(const T* value) {
|
|
44
|
+
return reinterpret_cast<Address>(value);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
template <typename T, bool check_null = true, typename S>
|
|
48
|
+
V8_INLINE static T* SlotAsValue(S* slot) {
|
|
49
|
+
if (check_null && slot == nullptr) {
|
|
50
|
+
return reinterpret_cast<T*>(kTaggedNullAddress);
|
|
51
|
+
}
|
|
52
|
+
return *reinterpret_cast<T**>(slot);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
#else // !V8_ENABLE_DIRECT_LOCAL
|
|
56
|
+
|
|
57
|
+
template <typename T>
|
|
58
|
+
V8_INLINE static Address ValueAsAddress(const T* value) {
|
|
59
|
+
return *reinterpret_cast<const Address*>(value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
template <typename T, bool check_null = true, typename S>
|
|
63
|
+
V8_INLINE static T* SlotAsValue(S* slot) {
|
|
64
|
+
return reinterpret_cast<T*>(slot);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
#endif // V8_ENABLE_DIRECT_LOCAL
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Helper functions about handles.
|
|
72
|
+
*/
|
|
73
|
+
class HandleHelper final {
|
|
74
|
+
public:
|
|
75
|
+
/**
|
|
76
|
+
* Checks whether two handles are equal.
|
|
77
|
+
* They are equal iff they are both empty or they are both non-empty and the
|
|
78
|
+
* objects to which they refer are physically equal.
|
|
79
|
+
*
|
|
80
|
+
* If both handles refer to JS objects, this is the same as strict equality.
|
|
81
|
+
* For primitives, such as numbers or strings, a `false` return value does not
|
|
82
|
+
* indicate that the values aren't equal in the JavaScript sense.
|
|
83
|
+
* Use `Value::StrictEquals()` to check primitives for equality.
|
|
84
|
+
*/
|
|
85
|
+
template <typename T1, typename T2>
|
|
86
|
+
V8_INLINE static bool EqualHandles(const T1& lhs, const T2& rhs) {
|
|
87
|
+
if (lhs.IsEmpty()) return rhs.IsEmpty();
|
|
88
|
+
if (rhs.IsEmpty()) return false;
|
|
89
|
+
return lhs.ptr() == rhs.ptr();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
static V8_EXPORT void VerifyOnStack(const void* ptr);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
} // namespace internal
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* A base class for abstract handles containing indirect pointers.
|
|
99
|
+
* These are useful regardless of whether direct local support is enabled.
|
|
100
|
+
*/
|
|
101
|
+
class IndirectHandleBase {
|
|
102
|
+
public:
|
|
103
|
+
// Returns true if the handle is empty.
|
|
104
|
+
V8_INLINE bool IsEmpty() const { return location_ == nullptr; }
|
|
105
|
+
|
|
106
|
+
// Sets the handle to be empty. IsEmpty() will then return true.
|
|
107
|
+
V8_INLINE void Clear() { location_ = nullptr; }
|
|
108
|
+
|
|
109
|
+
protected:
|
|
110
|
+
friend class internal::ValueHelper;
|
|
111
|
+
friend class internal::HandleHelper;
|
|
112
|
+
|
|
113
|
+
V8_INLINE IndirectHandleBase() = default;
|
|
114
|
+
V8_INLINE IndirectHandleBase(const IndirectHandleBase& other) = default;
|
|
115
|
+
V8_INLINE IndirectHandleBase& operator=(const IndirectHandleBase& that) =
|
|
116
|
+
default;
|
|
117
|
+
|
|
118
|
+
V8_INLINE explicit IndirectHandleBase(internal::Address* location)
|
|
119
|
+
: location_(location) {}
|
|
120
|
+
|
|
121
|
+
// Returns the address of the actual heap object (tagged).
|
|
122
|
+
// This method must be called only if the handle is not empty, otherwise it
|
|
123
|
+
// will crash.
|
|
124
|
+
V8_INLINE internal::Address ptr() const { return *location_; }
|
|
125
|
+
|
|
126
|
+
// Returns a reference to the slot (indirect pointer).
|
|
127
|
+
V8_INLINE internal::Address* const& slot() const { return location_; }
|
|
128
|
+
V8_INLINE internal::Address*& slot() { return location_; }
|
|
129
|
+
|
|
130
|
+
// Returns the handler's "value" (direct or indirect pointer, depending on
|
|
131
|
+
// whether direct local support is enabled).
|
|
132
|
+
template <typename T>
|
|
133
|
+
V8_INLINE T* value() const {
|
|
134
|
+
return internal::ValueHelper::SlotAsValue<T, false>(slot());
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private:
|
|
138
|
+
internal::Address* location_ = nullptr;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
#ifdef V8_ENABLE_DIRECT_LOCAL
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* A base class for abstract handles containing direct pointers.
|
|
145
|
+
* These are only possible when conservative stack scanning is enabled.
|
|
146
|
+
*/
|
|
147
|
+
class DirectHandleBase {
|
|
148
|
+
public:
|
|
149
|
+
// Returns true if the handle is empty.
|
|
150
|
+
V8_INLINE bool IsEmpty() const {
|
|
151
|
+
return ptr_ == internal::ValueHelper::kEmpty;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Sets the handle to be empty. IsEmpty() will then return true.
|
|
155
|
+
V8_INLINE void Clear() { ptr_ = internal::ValueHelper::kEmpty; }
|
|
156
|
+
|
|
157
|
+
protected:
|
|
158
|
+
friend class internal::ValueHelper;
|
|
159
|
+
friend class internal::HandleHelper;
|
|
160
|
+
|
|
161
|
+
V8_INLINE DirectHandleBase() = default;
|
|
162
|
+
V8_INLINE DirectHandleBase(const DirectHandleBase& other) = default;
|
|
163
|
+
V8_INLINE DirectHandleBase& operator=(const DirectHandleBase& that) = default;
|
|
164
|
+
|
|
165
|
+
V8_INLINE explicit DirectHandleBase(internal::Address ptr) : ptr_(ptr) {}
|
|
166
|
+
|
|
167
|
+
// Returns the address of the referenced object.
|
|
168
|
+
V8_INLINE internal::Address ptr() const { return ptr_; }
|
|
169
|
+
|
|
170
|
+
// Returns the handler's "value" (direct pointer, as direct local support
|
|
171
|
+
// is guaranteed to be enabled here).
|
|
172
|
+
template <typename T>
|
|
173
|
+
V8_INLINE T* value() const {
|
|
174
|
+
return reinterpret_cast<T*>(ptr_);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
private:
|
|
178
|
+
internal::Address ptr_ = internal::ValueHelper::kEmpty;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
#endif // V8_ENABLE_DIRECT_LOCAL
|
|
182
|
+
|
|
183
|
+
} // namespace v8
|
|
184
|
+
|
|
185
|
+
#endif // INCLUDE_V8_HANDLE_BASE_H_
|