node-darwin-x64 25.9.0 → 26.0.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 +200 -1436
- package/bin/node +0 -0
- package/include/node/common.gypi +13 -1
- package/include/node/config.gypi +5 -9
- package/include/node/cppgc/allocation.h +6 -7
- package/include/node/cppgc/heap-statistics.h +6 -2
- package/include/node/cppgc/internal/api-constants.h +1 -1
- package/include/node/cppgc/visitor.h +1 -0
- package/include/node/libplatform/v8-tracing.h +13 -2
- package/include/node/node.h +1 -1
- package/include/node/node_object_wrap.h +4 -2
- package/include/node/node_version.h +3 -3
- package/include/node/uv/unix.h +1 -4
- package/include/node/uv/version.h +2 -2
- package/include/node/uv/win.h +1 -1
- package/include/node/uv.h +7 -8
- package/include/node/v8-array-buffer.h +10 -0
- package/include/node/v8-callbacks.h +15 -6
- package/include/node/v8-context.h +79 -27
- package/include/node/v8-data.h +7 -1
- package/include/node/v8-debug.h +23 -3
- package/include/node/v8-exception.h +7 -4
- package/include/node/v8-extension.h +0 -2
- package/include/node/v8-external.h +40 -4
- package/include/node/v8-function-callback.h +172 -183
- package/include/node/v8-function.h +2 -2
- package/include/node/v8-initialization.h +29 -0
- package/include/node/v8-internal.h +149 -142
- package/include/node/v8-isolate.h +35 -22
- package/include/node/v8-local-handle.h +1 -1
- package/include/node/v8-memory-span.h +4 -59
- package/include/node/v8-message.h +0 -8
- package/include/node/v8-object.h +85 -92
- package/include/node/v8-persistent-handle.h +2 -9
- package/include/node/v8-platform.h +167 -58
- package/include/node/v8-primitive.h +5 -57
- package/include/node/v8-profiler.h +69 -3
- package/include/node/v8-promise.h +16 -5
- package/include/node/v8-sandbox.h +34 -53
- package/include/node/v8-script.h +27 -0
- package/include/node/v8-source-location.h +9 -8
- package/include/node/v8-statistics.h +8 -0
- package/include/node/v8-template.h +44 -122
- package/include/node/v8-version.h +3 -3
- package/include/node/v8-wasm.h +118 -21
- package/include/node/v8config.h +10 -8
- package/package.json +1 -1
- package/share/doc/node/gdbinit +79 -0
- package/share/doc/node/lldb_commands.py +6 -0
- package/share/man/man1/node.1 +0 -6
|
@@ -276,15 +276,18 @@ class V8_EXPORT TryCatch {
|
|
|
276
276
|
|
|
277
277
|
void ResetInternal();
|
|
278
278
|
|
|
279
|
+
// Helper methods for internal::Isolate.
|
|
280
|
+
bool capture_message() const;
|
|
281
|
+
void set_can_continue(bool value);
|
|
282
|
+
bool rethrow() const;
|
|
283
|
+
void set_rethrow(bool value);
|
|
284
|
+
|
|
279
285
|
internal::Isolate* i_isolate_;
|
|
280
286
|
TryCatch* next_;
|
|
281
287
|
void* exception_;
|
|
282
288
|
void* message_obj_;
|
|
283
289
|
internal::Address js_stack_comparable_address_;
|
|
284
|
-
|
|
285
|
-
bool can_continue_ : 1;
|
|
286
|
-
bool capture_message_ : 1;
|
|
287
|
-
bool rethrow_ : 1;
|
|
290
|
+
uint8_t flags_;
|
|
288
291
|
|
|
289
292
|
friend class internal::Isolate;
|
|
290
293
|
friend class internal::ThreadLocalTop;
|
|
@@ -33,7 +33,6 @@ class V8_EXPORT Extension {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
const char* name() const { return name_; }
|
|
36
|
-
size_t source_length() const { return source_length_; }
|
|
37
36
|
const String::ExternalOneByteStringResource* source() const {
|
|
38
37
|
return source_;
|
|
39
38
|
}
|
|
@@ -48,7 +47,6 @@ class V8_EXPORT Extension {
|
|
|
48
47
|
|
|
49
48
|
private:
|
|
50
49
|
const char* name_;
|
|
51
|
-
size_t source_length_; // expected to initialize before source_
|
|
52
50
|
String::ExternalOneByteStringResource* source_;
|
|
53
51
|
int dep_count_;
|
|
54
52
|
const char** deps_;
|
|
@@ -12,24 +12,60 @@ namespace v8 {
|
|
|
12
12
|
|
|
13
13
|
class Isolate;
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* A tag for external pointers. Objects with different C++ types should use
|
|
17
|
+
* different values of ExternalPointerTypeTag when using v8::External. The
|
|
18
|
+
* allowed range is 0..V8_EXTERNAL_POINTER_TAG_COUNT - 1. If this is not
|
|
19
|
+
* sufficient, V8_EXTERNAL_POINTER_TAG_COUNT can be increased.
|
|
20
|
+
*/
|
|
21
|
+
using ExternalPointerTypeTag = uint16_t;
|
|
22
|
+
|
|
23
|
+
constexpr ExternalPointerTypeTag kExternalPointerTypeTagDefault = 0;
|
|
24
|
+
|
|
15
25
|
/**
|
|
16
26
|
* A JavaScript value that wraps a C++ void*. This type of value is mainly used
|
|
17
27
|
* to associate C++ data structures with JavaScript objects.
|
|
18
28
|
*/
|
|
19
29
|
class V8_EXPORT External : public Value {
|
|
20
30
|
public:
|
|
21
|
-
|
|
22
|
-
|
|
31
|
+
V8_DEPRECATED("Use the version with the type tag.")
|
|
32
|
+
static Local<External> New(Isolate* isolate, void* value) {
|
|
33
|
+
return New(isolate, value, kExternalPointerTypeTagDefault);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a new External object.
|
|
37
|
+
*
|
|
38
|
+
* \param isolate The isolate for the external object.
|
|
39
|
+
* \param value The C++ pointer value.
|
|
40
|
+
* \param tag The type tag of the external pointer. If type tags are not used
|
|
41
|
+
* in the embedder, the default value `kExternalPointerTypeTagDefault` can be
|
|
42
|
+
* used.
|
|
43
|
+
* \return The new External object.
|
|
44
|
+
*/
|
|
45
|
+
static Local<External> New(Isolate* isolate, void* value,
|
|
46
|
+
ExternalPointerTypeTag tag);
|
|
47
|
+
V8_INLINE static External* Cast(Data* value) {
|
|
23
48
|
#ifdef V8_ENABLE_CHECKS
|
|
24
49
|
CheckCast(value);
|
|
25
50
|
#endif
|
|
26
51
|
return static_cast<External*>(value);
|
|
27
52
|
}
|
|
28
53
|
|
|
29
|
-
|
|
54
|
+
V8_DEPRECATED("Use the version with the type tag.")
|
|
55
|
+
void* Value() const { return Value(kExternalPointerTypeTagDefault); }
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns the value of the external pointer.
|
|
59
|
+
*
|
|
60
|
+
* \param tag The type tag of the external pointer. If type tags are not used
|
|
61
|
+
* in the embedder, the default value `kExternalPointerTypeTagDefault` can be
|
|
62
|
+
* used.
|
|
63
|
+
* \return The value of the external pointer.
|
|
64
|
+
*/
|
|
65
|
+
void* Value(ExternalPointerTypeTag tag) const;
|
|
30
66
|
|
|
31
67
|
private:
|
|
32
|
-
static void CheckCast(v8::
|
|
68
|
+
static void CheckCast(v8::Data* obj);
|
|
33
69
|
};
|
|
34
70
|
|
|
35
71
|
} // namespace v8
|
|
@@ -57,6 +57,7 @@ class ReturnValue {
|
|
|
57
57
|
V8_INLINE void Set(const Local<S> handle);
|
|
58
58
|
template <typename S>
|
|
59
59
|
V8_INLINE void SetNonEmpty(const Local<S> handle);
|
|
60
|
+
|
|
60
61
|
// Fast primitive number setters.
|
|
61
62
|
V8_INLINE void Set(bool value);
|
|
62
63
|
V8_INLINE void Set(double i);
|
|
@@ -66,11 +67,13 @@ class ReturnValue {
|
|
|
66
67
|
V8_INLINE void Set(uint16_t i);
|
|
67
68
|
V8_INLINE void Set(uint32_t i);
|
|
68
69
|
V8_INLINE void Set(uint64_t i);
|
|
70
|
+
|
|
69
71
|
// Fast JS primitive setters.
|
|
70
72
|
V8_INLINE void SetNull();
|
|
71
73
|
V8_INLINE void SetUndefined();
|
|
72
74
|
V8_INLINE void SetFalse();
|
|
73
75
|
V8_INLINE void SetEmptyString();
|
|
76
|
+
|
|
74
77
|
// Convenience getter for the Isolate.
|
|
75
78
|
V8_INLINE Isolate* GetIsolate() const;
|
|
76
79
|
|
|
@@ -103,7 +106,7 @@ class ReturnValue {
|
|
|
103
106
|
V8_INLINE explicit ReturnValue(internal::Address* slot);
|
|
104
107
|
|
|
105
108
|
// See FunctionCallbackInfo.
|
|
106
|
-
static constexpr int kIsolateValueIndex = -
|
|
109
|
+
static constexpr int kIsolateValueIndex = -1;
|
|
107
110
|
|
|
108
111
|
internal::Address* value_;
|
|
109
112
|
};
|
|
@@ -142,41 +145,75 @@ class FunctionCallbackInfo {
|
|
|
142
145
|
friend class internal::CustomArguments<FunctionCallbackInfo>;
|
|
143
146
|
friend class debug::ConsoleCallArguments;
|
|
144
147
|
friend void internal::PrintFunctionCallbackInfo(void*);
|
|
148
|
+
using I = internal::Internals;
|
|
145
149
|
|
|
146
|
-
//
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
150
|
+
// Frame block, matches the layout of ApiCallbackExitFrame.
|
|
151
|
+
// See ApiCallbackExitFrameConstants.
|
|
152
|
+
enum {
|
|
153
|
+
//
|
|
154
|
+
// Optional frame arguments block (exists only for API_CONSTRUCT_EXIT
|
|
155
|
+
// frame).
|
|
156
|
+
|
|
157
|
+
// Frame arguments block.
|
|
158
|
+
kNewTargetIndex = -1,
|
|
159
|
+
|
|
160
|
+
//
|
|
161
|
+
// Mandatory part, exists for both API_CALLBACK_EXIT and API_CONSTRUCT_EXIT
|
|
162
|
+
// frames.
|
|
163
|
+
//
|
|
164
|
+
|
|
165
|
+
// Frame arguments block.
|
|
166
|
+
kArgcIndex,
|
|
167
|
+
|
|
168
|
+
// Regular ExitFrame structure.
|
|
169
|
+
kFrameSPIndex,
|
|
170
|
+
kFrameTypeIndex,
|
|
171
|
+
kFrameConstantPoolIndex, // Optional, see I::kFrameCPSlotCount.
|
|
172
|
+
kFrameFPIndex = kFrameConstantPoolIndex + I::kFrameCPSlotCount,
|
|
173
|
+
kFramePCIndex,
|
|
174
|
+
|
|
175
|
+
// Api arguments block, starts at kFirstArgumentIndex.
|
|
176
|
+
kFirstApiArgumentIndex,
|
|
177
|
+
kIsolateIndex = kFirstApiArgumentIndex,
|
|
178
|
+
kReturnValueIndex,
|
|
179
|
+
kContextIndex,
|
|
180
|
+
kTargetIndex,
|
|
181
|
+
|
|
182
|
+
// JS args block, starts at kFrameFirstImplicitArgsIndex.
|
|
183
|
+
kReceiverIndex,
|
|
184
|
+
kFirstJSArgumentIndex,
|
|
185
|
+
|
|
186
|
+
// Mandatory part includes receiver.
|
|
187
|
+
kArgsLength = kReceiverIndex + 1,
|
|
188
|
+
// Optional part size (exists only for API_CONSTRUCT_EXIT frame).
|
|
189
|
+
kOptionalArgsLength = 1,
|
|
190
|
+
|
|
191
|
+
// The length of just Api arguments part.
|
|
192
|
+
kApiArgsLength = kReceiverIndex - kFirstApiArgumentIndex,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
static_assert(kArgcIndex == 0);
|
|
168
196
|
static_assert(ReturnValue<Value>::kIsolateValueIndex ==
|
|
169
197
|
kIsolateIndex - kReturnValueIndex);
|
|
170
198
|
|
|
171
|
-
|
|
172
|
-
|
|
199
|
+
internal::Address* address_of_first_argument() const {
|
|
200
|
+
return &values_[kFirstJSArgumentIndex];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
V8_INLINE FunctionCallbackInfo() = default;
|
|
173
204
|
|
|
174
|
-
//
|
|
175
|
-
//
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
205
|
+
// FunctionCallbackInfo object provides a view of the stack area where the
|
|
206
|
+
// data is stored and thus it's not supposed to be copyable/movable.
|
|
207
|
+
FunctionCallbackInfo(const FunctionCallbackInfo&) = delete;
|
|
208
|
+
FunctionCallbackInfo& operator=(const FunctionCallbackInfo&) = delete;
|
|
209
|
+
FunctionCallbackInfo(FunctionCallbackInfo&&) = delete;
|
|
210
|
+
FunctionCallbackInfo& operator=(FunctionCallbackInfo&&) = delete;
|
|
211
|
+
|
|
212
|
+
// Declare as mutable to let GC modify the contents of the slots even though
|
|
213
|
+
// it's not possible to change values via this class.
|
|
214
|
+
// Define the array size as 1 to make it clear that we are going to access
|
|
215
|
+
// it out-of-bounds from both sides anyway.
|
|
216
|
+
mutable internal::Address values_[1];
|
|
180
217
|
};
|
|
181
218
|
|
|
182
219
|
/**
|
|
@@ -198,72 +235,13 @@ class PropertyCallbackInfo {
|
|
|
198
235
|
*/
|
|
199
236
|
V8_INLINE Local<Value> Data() const;
|
|
200
237
|
|
|
201
|
-
/**
|
|
202
|
-
* \return The receiver. In many cases, this is the object on which the
|
|
203
|
-
* property access was intercepted. When using
|
|
204
|
-
* `Reflect.get`, `Function.prototype.call`, or similar functions, it is the
|
|
205
|
-
* object passed in as receiver or thisArg.
|
|
206
|
-
*
|
|
207
|
-
* \code
|
|
208
|
-
* void GetterCallback(Local<Name> name,
|
|
209
|
-
* const v8::PropertyCallbackInfo<v8::Value>& info) {
|
|
210
|
-
* auto context = info.GetIsolate()->GetCurrentContext();
|
|
211
|
-
*
|
|
212
|
-
* v8::Local<v8::Value> a_this =
|
|
213
|
-
* info.This()
|
|
214
|
-
* ->GetRealNamedProperty(context, v8_str("a"))
|
|
215
|
-
* .ToLocalChecked();
|
|
216
|
-
* v8::Local<v8::Value> a_holder =
|
|
217
|
-
* info.Holder()
|
|
218
|
-
* ->GetRealNamedProperty(context, v8_str("a"))
|
|
219
|
-
* .ToLocalChecked();
|
|
220
|
-
*
|
|
221
|
-
* CHECK(v8_str("r")->Equals(context, a_this).FromJust());
|
|
222
|
-
* CHECK(v8_str("obj")->Equals(context, a_holder).FromJust());
|
|
223
|
-
*
|
|
224
|
-
* info.GetReturnValue().Set(name);
|
|
225
|
-
* }
|
|
226
|
-
*
|
|
227
|
-
* v8::Local<v8::FunctionTemplate> templ =
|
|
228
|
-
* v8::FunctionTemplate::New(isolate);
|
|
229
|
-
* templ->InstanceTemplate()->SetHandler(
|
|
230
|
-
* v8::NamedPropertyHandlerConfiguration(GetterCallback));
|
|
231
|
-
* LocalContext env;
|
|
232
|
-
* env->Global()
|
|
233
|
-
* ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local())
|
|
234
|
-
* .ToLocalChecked()
|
|
235
|
-
* ->NewInstance(env.local())
|
|
236
|
-
* .ToLocalChecked())
|
|
237
|
-
* .FromJust();
|
|
238
|
-
*
|
|
239
|
-
* CompileRun("obj.a = 'obj'; var r = {a: 'r'}; Reflect.get(obj, 'x', r)");
|
|
240
|
-
* \endcode
|
|
241
|
-
*/
|
|
242
|
-
V8_INLINE Local<Object> This() const;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* \return The object in the prototype chain of the receiver that has the
|
|
246
|
-
* interceptor. Suppose you have `x` and its prototype is `y`, and `y`
|
|
247
|
-
* has an interceptor. Then `info.This()` is `x` and `info.Holder()` is `y`.
|
|
248
|
-
* The Holder() could be a hidden object (the global object, rather
|
|
249
|
-
* than the global proxy).
|
|
250
|
-
*
|
|
251
|
-
* \note For security reasons, do not pass the object back into the runtime.
|
|
252
|
-
*/
|
|
253
|
-
V8_DEPRECATED(
|
|
254
|
-
"V8 will stop providing access to hidden prototype (i.e. "
|
|
255
|
-
"JSGlobalObject). Use HolderV2() instead. \n"
|
|
256
|
-
"DO NOT try to workaround this by accessing JSGlobalObject via "
|
|
257
|
-
"v8::Object::GetPrototype() - it'll be deprecated soon too. \n"
|
|
258
|
-
"See http://crbug.com/333672197. ")
|
|
259
|
-
V8_INLINE Local<Object> Holder() const;
|
|
260
|
-
|
|
261
238
|
/**
|
|
262
239
|
* \return The object in the prototype chain of the receiver that has the
|
|
263
240
|
* interceptor. Suppose you have `x` and its prototype is `y`, and `y`
|
|
264
241
|
* has an interceptor. Then `info.This()` is `x` and `info.Holder()` is `y`.
|
|
265
242
|
* In case the property is installed on the global object the Holder()
|
|
266
243
|
* would return the global proxy.
|
|
244
|
+
* TODO(http://crbug.com/333672197): rename back to Holder().
|
|
267
245
|
*/
|
|
268
246
|
V8_INLINE Local<Object> HolderV2() const;
|
|
269
247
|
|
|
@@ -278,11 +256,18 @@ class PropertyCallbackInfo {
|
|
|
278
256
|
V8_INLINE ReturnValue<T> GetReturnValue() const;
|
|
279
257
|
|
|
280
258
|
/**
|
|
259
|
+
* For [[Set]], [[DefineOwnProperty]] and [[Delete]] operations (i.e.
|
|
260
|
+
* for setter/definer/deleter callbacks) indicates whether TypeError
|
|
261
|
+
* should be thrown upon operation failure. The callback should throw
|
|
262
|
+
* TypeError only if it's necessary to provide more details than a default
|
|
263
|
+
* error thrown by V8 contains in this case.
|
|
264
|
+
*
|
|
281
265
|
* \return True if the intercepted function should throw if an error occurs.
|
|
282
|
-
* Usually, `true` corresponds to `'use strict'
|
|
266
|
+
* Usually, `true` corresponds to `'use strict'` execution mode.
|
|
283
267
|
*
|
|
284
|
-
* \note Always `false` when
|
|
285
|
-
*
|
|
268
|
+
* \note Always `false` when the operation was initiated by respecive
|
|
269
|
+
* `Reflect` call (i.e. `Reflect.set()`, `Reflect.defineProperty()` and
|
|
270
|
+
* `Reflect.deleteProperty()`).
|
|
286
271
|
*/
|
|
287
272
|
V8_INLINE bool ShouldThrowOnError() const;
|
|
288
273
|
|
|
@@ -293,22 +278,75 @@ class PropertyCallbackInfo {
|
|
|
293
278
|
friend class internal::PropertyCallbackArguments;
|
|
294
279
|
friend class internal::CustomArguments<PropertyCallbackInfo>;
|
|
295
280
|
friend void internal::PrintPropertyCallbackInfo(void*);
|
|
281
|
+
using I = internal::Internals;
|
|
296
282
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
static constexpr
|
|
305
|
-
|
|
283
|
+
// ShouldThrowOnError() can return true only for setter/definer/deleter
|
|
284
|
+
// callbacks which match [[Set]]/[[DefineOwnProperty]]/[[Delete]]
|
|
285
|
+
// operations. We detect these operations by return value type - they
|
|
286
|
+
// all return boolean value, even though setter/deleter callbacks are
|
|
287
|
+
// still using v8::PropertyCallbackInfo<void>.
|
|
288
|
+
// TODO(https://crbug.com/348660658): cleanup this, once the callbacks are
|
|
289
|
+
// migrated to a new return type.
|
|
290
|
+
static constexpr bool HasShouldThrowOnError() {
|
|
291
|
+
return std::is_same_v<T, v8::Boolean> || std::is_same_v<T, void>;
|
|
292
|
+
}
|
|
306
293
|
|
|
307
|
-
|
|
294
|
+
// Indicates whether this is a named accessor/interceptor callback call
|
|
295
|
+
// or an indexed one.
|
|
296
|
+
V8_INLINE bool IsNamed() const;
|
|
297
|
+
|
|
298
|
+
// Frame block, matches the layout of ApiAccessorExitFrame.
|
|
299
|
+
// See ApiAccessorExitFrameConstants.
|
|
300
|
+
enum {
|
|
301
|
+
// Frame arguments block.
|
|
302
|
+
kPropertyKeyIndex,
|
|
303
|
+
|
|
304
|
+
// Regular ExitFrame structure.
|
|
305
|
+
kFrameSPIndex,
|
|
306
|
+
kFrameTypeIndex,
|
|
307
|
+
kFrameConstantPoolIndex, // Optional, see I::kFrameCPSlotCount.
|
|
308
|
+
kFrameFPIndex = kFrameConstantPoolIndex + I::kFrameCPSlotCount,
|
|
309
|
+
kFramePCIndex,
|
|
310
|
+
|
|
311
|
+
// Other arguments block, starts at kFirstArgumentIndex.
|
|
312
|
+
kFirstApiArgumentIndex,
|
|
313
|
+
kIsolateIndex = kFirstApiArgumentIndex,
|
|
314
|
+
kReturnValueIndex,
|
|
315
|
+
kCallbackInfoIndex,
|
|
316
|
+
kHolderIndex,
|
|
317
|
+
|
|
318
|
+
//
|
|
319
|
+
// Optional part, used only by setter/definer/deleter callbacks.
|
|
320
|
+
//
|
|
321
|
+
kFirstOptionalArgument,
|
|
322
|
+
kShouldThrowOnErrorIndex = kFirstOptionalArgument,
|
|
323
|
+
|
|
324
|
+
// Used as value handle storage when called via CallApiSetter builtin.
|
|
325
|
+
kValueIndex,
|
|
326
|
+
|
|
327
|
+
kFullArgsLength,
|
|
328
|
+
kMandatoryArgsLength = kFirstOptionalArgument,
|
|
329
|
+
kOptionalArgsLength = kFullArgsLength - kFirstOptionalArgument,
|
|
330
|
+
|
|
331
|
+
// Various lengths of just Api arguments part.
|
|
332
|
+
kMandatoryApiArgsLength = kMandatoryArgsLength - kFirstApiArgumentIndex,
|
|
333
|
+
kFullApiArgsLength = kFullArgsLength - kFirstApiArgumentIndex,
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
// PropertyCallbackInfo object provides a view of the stack area where the
|
|
337
|
+
// data is stored and thus it's not supposed to be copyable/movable.
|
|
338
|
+
PropertyCallbackInfo(const PropertyCallbackInfo&) = delete;
|
|
339
|
+
PropertyCallbackInfo& operator=(const PropertyCallbackInfo&) = delete;
|
|
340
|
+
PropertyCallbackInfo(PropertyCallbackInfo&&) = delete;
|
|
341
|
+
PropertyCallbackInfo& operator=(PropertyCallbackInfo&&) = delete;
|
|
308
342
|
|
|
309
343
|
PropertyCallbackInfo() = default;
|
|
310
344
|
|
|
311
|
-
mutable
|
|
345
|
+
// Declare as mutable to let GC modify the contents of the slots even though
|
|
346
|
+
// it's not possible to change values via this class.
|
|
347
|
+
// Define the array size as 1 to make it clear that we are going to access
|
|
348
|
+
// it out-of-bounds anyway.
|
|
349
|
+
mutable internal::Address args_[1];
|
|
312
350
|
};
|
|
313
351
|
|
|
314
352
|
using FunctionCallback = void (*)(const FunctionCallbackInfo<Value>& info);
|
|
@@ -377,25 +415,9 @@ void ReturnValue<T>::SetNonEmpty(const BasicTracedReference<S>& handle) {
|
|
|
377
415
|
template <typename T>
|
|
378
416
|
template <typename S>
|
|
379
417
|
void ReturnValue<T>::Set(const Local<S> handle) {
|
|
380
|
-
|
|
381
|
-
#ifdef V8_IMMINENT_DEPRECATION_WARNINGS
|
|
382
|
-
static constexpr bool is_allowed_void = false;
|
|
383
|
-
static_assert(!std::is_void_v<T>,
|
|
384
|
-
"ReturnValue<void>::Set(const Local<S>) is deprecated. "
|
|
385
|
-
"Do nothing to indicate that the operation succeeded or use "
|
|
386
|
-
"SetFalse() to indicate that the operation failed (don't "
|
|
387
|
-
"forget to handle info.ShouldThrowOnError()). "
|
|
388
|
-
"See http://crbug.com/348660658 for details.");
|
|
389
|
-
#else
|
|
390
|
-
static constexpr bool is_allowed_void = std::is_void_v<T>;
|
|
391
|
-
#endif // V8_IMMINENT_DEPRECATION_WARNINGS
|
|
392
|
-
static_assert(is_allowed_void || std::is_base_of_v<T, S>, "type check");
|
|
418
|
+
static_assert(std::is_base_of_v<T, S>, "type check");
|
|
393
419
|
if (V8_UNLIKELY(handle.IsEmpty())) {
|
|
394
420
|
SetDefaultValue();
|
|
395
|
-
} else if constexpr (is_allowed_void) {
|
|
396
|
-
// Simulate old behaviour for "v8::AccessorSetterCallback" for which
|
|
397
|
-
// it was possible to set the return value even for ReturnValue<void>.
|
|
398
|
-
Set(handle->BooleanValue(GetIsolate()));
|
|
399
421
|
} else {
|
|
400
422
|
SetInternal(handle.ptr());
|
|
401
423
|
}
|
|
@@ -404,29 +426,11 @@ void ReturnValue<T>::Set(const Local<S> handle) {
|
|
|
404
426
|
template <typename T>
|
|
405
427
|
template <typename S>
|
|
406
428
|
void ReturnValue<T>::SetNonEmpty(const Local<S> handle) {
|
|
407
|
-
|
|
408
|
-
#ifdef V8_IMMINENT_DEPRECATION_WARNINGS
|
|
409
|
-
static constexpr bool is_allowed_void = false;
|
|
410
|
-
static_assert(!std::is_void_v<T>,
|
|
411
|
-
"ReturnValue<void>::SetNonEmpty(const Local<S>) is deprecated. "
|
|
412
|
-
"Do nothing to indicate that the operation succeeded or use "
|
|
413
|
-
"SetFalse() to indicate that the operation failed (don't "
|
|
414
|
-
"forget to handle info.ShouldThrowOnError()). "
|
|
415
|
-
"See http://crbug.com/348660658 for details.");
|
|
416
|
-
#else
|
|
417
|
-
static constexpr bool is_allowed_void = std::is_void_v<T>;
|
|
418
|
-
#endif // V8_IMMINENT_DEPRECATION_WARNINGS
|
|
419
|
-
static_assert(is_allowed_void || std::is_base_of_v<T, S>, "type check");
|
|
429
|
+
static_assert(std::is_base_of_v<T, S>, "type check");
|
|
420
430
|
#ifdef V8_ENABLE_CHECKS
|
|
421
431
|
internal::VerifyHandleIsNonEmpty(handle.IsEmpty());
|
|
422
432
|
#endif // V8_ENABLE_CHECKS
|
|
423
|
-
|
|
424
|
-
// Simulate old behaviour for "v8::AccessorSetterCallback" for which
|
|
425
|
-
// it was possible to set the return value even for ReturnValue<void>.
|
|
426
|
-
Set(handle->BooleanValue(GetIsolate()));
|
|
427
|
-
} else {
|
|
428
|
-
SetInternal(handle.ptr());
|
|
429
|
-
}
|
|
433
|
+
SetInternal(handle.ptr());
|
|
430
434
|
}
|
|
431
435
|
|
|
432
436
|
template <typename T>
|
|
@@ -611,91 +615,76 @@ void ReturnValue<T>::Set(S* whatever) {
|
|
|
611
615
|
static_assert(sizeof(S) < 0, "incompilable to prevent inadvertent misuse");
|
|
612
616
|
}
|
|
613
617
|
|
|
614
|
-
template <typename T>
|
|
615
|
-
FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Address* implicit_args,
|
|
616
|
-
internal::Address* values,
|
|
617
|
-
int length)
|
|
618
|
-
: implicit_args_(implicit_args), values_(values), length_(length) {}
|
|
619
|
-
|
|
620
618
|
template <typename T>
|
|
621
619
|
Local<Value> FunctionCallbackInfo<T>::operator[](int i) const {
|
|
622
|
-
// values_ points to the first argument (not the receiver).
|
|
623
620
|
if (i < 0 || Length() <= i) return Undefined(GetIsolate());
|
|
624
|
-
return Local<Value>::FromSlot(values_ + i);
|
|
621
|
+
return Local<Value>::FromSlot(&values_[kFirstJSArgumentIndex + i]);
|
|
625
622
|
}
|
|
626
623
|
|
|
627
624
|
template <typename T>
|
|
628
625
|
Local<Object> FunctionCallbackInfo<T>::This() const {
|
|
629
|
-
|
|
630
|
-
return Local<Object>::FromSlot(values_ + kThisValuesIndex);
|
|
626
|
+
return Local<Object>::FromSlot(&values_[kReceiverIndex]);
|
|
631
627
|
}
|
|
632
628
|
|
|
633
629
|
template <typename T>
|
|
634
630
|
Local<Value> FunctionCallbackInfo<T>::NewTarget() const {
|
|
635
|
-
|
|
631
|
+
if (IsConstructCall()) {
|
|
632
|
+
// Can't use &values_[kNewTargetIndex] because of "array index -1 is
|
|
633
|
+
// before the beginning of the array" error.
|
|
634
|
+
internal::Address* values = &values_[0];
|
|
635
|
+
return Local<Value>::FromSlot(values + kNewTargetIndex);
|
|
636
|
+
}
|
|
637
|
+
return Undefined(GetIsolate());
|
|
636
638
|
}
|
|
637
639
|
|
|
638
640
|
template <typename T>
|
|
639
641
|
Local<Value> FunctionCallbackInfo<T>::Data() const {
|
|
640
|
-
auto target = Local<v8::Data>::FromSlot(&
|
|
642
|
+
auto target = Local<v8::Data>::FromSlot(&values_[kTargetIndex]);
|
|
641
643
|
return api_internal::GetFunctionTemplateData(GetIsolate(), target);
|
|
642
644
|
}
|
|
643
645
|
|
|
644
646
|
template <typename T>
|
|
645
647
|
Isolate* FunctionCallbackInfo<T>::GetIsolate() const {
|
|
646
|
-
return
|
|
648
|
+
return reinterpret_cast<Isolate*>(values_[kIsolateIndex]);
|
|
647
649
|
}
|
|
648
650
|
|
|
649
651
|
template <typename T>
|
|
650
652
|
ReturnValue<T> FunctionCallbackInfo<T>::GetReturnValue() const {
|
|
651
|
-
return ReturnValue<T>(&
|
|
653
|
+
return ReturnValue<T>(&values_[kReturnValueIndex]);
|
|
652
654
|
}
|
|
653
655
|
|
|
654
656
|
template <typename T>
|
|
655
657
|
bool FunctionCallbackInfo<T>::IsConstructCall() const {
|
|
656
|
-
return
|
|
658
|
+
return I::SmiValue(values_[kFrameTypeIndex]) == I::kFrameTypeApiConstructExit;
|
|
657
659
|
}
|
|
658
660
|
|
|
659
661
|
template <typename T>
|
|
660
662
|
int FunctionCallbackInfo<T>::Length() const {
|
|
661
|
-
return static_cast<int>(
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
template <typename T>
|
|
665
|
-
Isolate* PropertyCallbackInfo<T>::GetIsolate() const {
|
|
666
|
-
return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
|
|
663
|
+
return static_cast<int>(values_[kArgcIndex]);
|
|
667
664
|
}
|
|
668
665
|
|
|
669
666
|
template <typename T>
|
|
670
|
-
|
|
671
|
-
return
|
|
667
|
+
bool PropertyCallbackInfo<T>::IsNamed() const {
|
|
668
|
+
return I::SmiValue(args_[kFrameTypeIndex]) ==
|
|
669
|
+
I::kFrameTypeApiNamedAccessorExit;
|
|
672
670
|
}
|
|
673
671
|
|
|
674
672
|
template <typename T>
|
|
675
|
-
|
|
676
|
-
return
|
|
673
|
+
Isolate* PropertyCallbackInfo<T>::GetIsolate() const {
|
|
674
|
+
return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
|
|
677
675
|
}
|
|
678
676
|
|
|
679
677
|
template <typename T>
|
|
680
|
-
Local<
|
|
681
|
-
|
|
678
|
+
Local<Value> PropertyCallbackInfo<T>::Data() const {
|
|
679
|
+
internal::Address callback_info = args_[kCallbackInfoIndex];
|
|
680
|
+
internal::Address data =
|
|
681
|
+
I::ReadTaggedPointerField(callback_info, I::kCallbackInfoDataOffset);
|
|
682
|
+
return Local<Value>::New(GetIsolate(), data);
|
|
682
683
|
}
|
|
683
684
|
|
|
684
|
-
namespace api_internal {
|
|
685
|
-
// Returns JSGlobalProxy if holder is JSGlobalObject or unmodified holder
|
|
686
|
-
// otherwise.
|
|
687
|
-
V8_EXPORT internal::Address ConvertToJSGlobalProxyIfNecessary(
|
|
688
|
-
internal::Address holder);
|
|
689
|
-
} // namespace api_internal
|
|
690
|
-
|
|
691
685
|
template <typename T>
|
|
692
686
|
Local<Object> PropertyCallbackInfo<T>::HolderV2() const {
|
|
693
|
-
|
|
694
|
-
if (!I::HasHeapObjectTag(args_[kHolderV2Index])) {
|
|
695
|
-
args_[kHolderV2Index] =
|
|
696
|
-
api_internal::ConvertToJSGlobalProxyIfNecessary(args_[kHolderIndex]);
|
|
697
|
-
}
|
|
698
|
-
return Local<Object>::FromSlot(&args_[kHolderV2Index]);
|
|
687
|
+
return Local<Object>::FromSlot(&args_[kHolderIndex]);
|
|
699
688
|
}
|
|
700
689
|
|
|
701
690
|
template <typename T>
|
|
@@ -705,7 +694,7 @@ ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const {
|
|
|
705
694
|
|
|
706
695
|
template <typename T>
|
|
707
696
|
bool PropertyCallbackInfo<T>::ShouldThrowOnError() const {
|
|
708
|
-
|
|
697
|
+
if constexpr (!HasShouldThrowOnError()) return false;
|
|
709
698
|
if (args_[kShouldThrowOnErrorIndex] !=
|
|
710
699
|
I::IntegralToSmi(I::kInferShouldThrowMode)) {
|
|
711
700
|
return args_[kShouldThrowOnErrorIndex] != I::IntegralToSmi(I::kDontThrow);
|
|
@@ -31,8 +31,8 @@ class V8_EXPORT Function : public Object {
|
|
|
31
31
|
* for a given FunctionCallback.
|
|
32
32
|
*/
|
|
33
33
|
static MaybeLocal<Function> New(
|
|
34
|
-
Local<Context> context, FunctionCallback callback,
|
|
35
|
-
|
|
34
|
+
Local<Context> context, FunctionCallback callback, Local<Data> data = {},
|
|
35
|
+
int length = 0,
|
|
36
36
|
ConstructorBehavior behavior = ConstructorBehavior::kAllow,
|
|
37
37
|
SideEffectType side_effect_type = SideEffectType::kHasSideEffect);
|
|
38
38
|
|
|
@@ -253,6 +253,35 @@ class V8_EXPORT V8 {
|
|
|
253
253
|
static size_t GetSandboxReservationSizeInBytes();
|
|
254
254
|
#endif // V8_ENABLE_SANDBOX
|
|
255
255
|
|
|
256
|
+
enum class WasmMemoryType {
|
|
257
|
+
kMemory32,
|
|
258
|
+
kMemory64,
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Returns the virtual address space reservation size (in bytes) needed
|
|
263
|
+
* for one WebAssembly memory instance of the given capacity.
|
|
264
|
+
*
|
|
265
|
+
* \param type Whether this is a memory32 or memory64 instance.
|
|
266
|
+
* \param byte_capacity The maximum size, in bytes, of the WebAssembly
|
|
267
|
+
* memory. Values exceeding the engine's maximum allocatable memory
|
|
268
|
+
* size for the given type (determined by max_mem32_pages or
|
|
269
|
+
* max_mem64_pages) are clamped.
|
|
270
|
+
*
|
|
271
|
+
* When trap-based bounds checking is enabled by
|
|
272
|
+
* EnableWebAssemblyTrapHandler(), the amount of virtual address space
|
|
273
|
+
* that V8 needs to reserve for each WebAssembly memory instance can
|
|
274
|
+
* be much bigger than the requested size. If the process does
|
|
275
|
+
* not have enough virtual memory available, WebAssembly memory allocation
|
|
276
|
+
* would fail. During the initialization of V8, embedders can use this method
|
|
277
|
+
* to estimate whether the process has enough virtual memory for their
|
|
278
|
+
* usage of WebAssembly, and decide whether to enable the trap handler
|
|
279
|
+
* via EnableWebAssemblyTrapHandler(), or to skip it and reduce the amount of
|
|
280
|
+
* virtual memory required to keep the application running.
|
|
281
|
+
*/
|
|
282
|
+
static size_t GetWasmMemoryReservationSizeInBytes(WasmMemoryType type,
|
|
283
|
+
size_t byte_capacity);
|
|
284
|
+
|
|
256
285
|
/**
|
|
257
286
|
* Activate trap-based bounds checking for WebAssembly.
|
|
258
287
|
*
|