node-darwin-x64 25.8.2 → 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.
Files changed (50) hide show
  1. package/CHANGELOG.md +200 -1293
  2. package/bin/node +0 -0
  3. package/include/node/common.gypi +13 -1
  4. package/include/node/config.gypi +20 -10
  5. package/include/node/cppgc/allocation.h +6 -7
  6. package/include/node/cppgc/heap-statistics.h +6 -2
  7. package/include/node/cppgc/internal/api-constants.h +1 -1
  8. package/include/node/cppgc/visitor.h +1 -0
  9. package/include/node/libplatform/v8-tracing.h +13 -2
  10. package/include/node/node.h +17 -1
  11. package/include/node/node_object_wrap.h +4 -2
  12. package/include/node/node_version.h +4 -4
  13. package/include/node/uv/unix.h +1 -4
  14. package/include/node/uv/version.h +2 -2
  15. package/include/node/uv/win.h +1 -1
  16. package/include/node/uv.h +7 -8
  17. package/include/node/v8-array-buffer.h +10 -0
  18. package/include/node/v8-callbacks.h +15 -6
  19. package/include/node/v8-context.h +79 -27
  20. package/include/node/v8-data.h +7 -1
  21. package/include/node/v8-debug.h +23 -3
  22. package/include/node/v8-exception.h +7 -4
  23. package/include/node/v8-extension.h +0 -2
  24. package/include/node/v8-external.h +40 -4
  25. package/include/node/v8-function-callback.h +172 -183
  26. package/include/node/v8-function.h +2 -2
  27. package/include/node/v8-initialization.h +29 -0
  28. package/include/node/v8-internal.h +149 -142
  29. package/include/node/v8-isolate.h +35 -22
  30. package/include/node/v8-local-handle.h +1 -1
  31. package/include/node/v8-memory-span.h +4 -59
  32. package/include/node/v8-message.h +0 -8
  33. package/include/node/v8-object.h +85 -92
  34. package/include/node/v8-persistent-handle.h +2 -9
  35. package/include/node/v8-platform.h +167 -58
  36. package/include/node/v8-primitive.h +5 -57
  37. package/include/node/v8-profiler.h +69 -3
  38. package/include/node/v8-promise.h +16 -5
  39. package/include/node/v8-sandbox.h +34 -53
  40. package/include/node/v8-script.h +27 -0
  41. package/include/node/v8-source-location.h +9 -8
  42. package/include/node/v8-statistics.h +8 -0
  43. package/include/node/v8-template.h +44 -122
  44. package/include/node/v8-version.h +3 -3
  45. package/include/node/v8-wasm.h +118 -21
  46. package/include/node/v8config.h +10 -8
  47. package/package.json +1 -1
  48. package/share/doc/node/gdbinit +79 -0
  49. package/share/doc/node/lldb_commands.py +6 -0
  50. package/share/man/man1/node.1 +6 -7
@@ -52,6 +52,11 @@ class V8_EXPORT Data {
52
52
  */
53
53
  bool IsFunctionTemplate() const;
54
54
 
55
+ /**
56
+ * Returns true if this data is a |v8::DictionaryTemplate|.
57
+ */
58
+ bool IsDictionaryTemplate() const;
59
+
55
60
  /**
56
61
  * Returns true if this data is a |v8::Context|.
57
62
  */
@@ -72,7 +77,8 @@ class V8_EXPORT Data {
72
77
  class V8_EXPORT FixedArray : public Data {
73
78
  public:
74
79
  int Length() const;
75
- Local<Data> Get(Local<Context> context, int i) const;
80
+
81
+ Local<Data> Get(int i) const;
76
82
 
77
83
  V8_INLINE static FixedArray* Cast(Data* data) {
78
84
  #ifdef V8_ENABLE_CHECKS
@@ -136,6 +136,11 @@ class V8_EXPORT StackTrace {
136
136
  kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL
137
137
  };
138
138
 
139
+ struct ScriptIdAndContext {
140
+ int id;
141
+ v8::Local<v8::Context> context;
142
+ };
143
+
139
144
  /**
140
145
  * Returns the (unique) ID of this stack trace.
141
146
  */
@@ -174,15 +179,30 @@ class V8_EXPORT StackTrace {
174
179
  static Local<String> CurrentScriptNameOrSourceURL(Isolate* isolate);
175
180
 
176
181
  /**
177
- * Returns the first valid script id at the top of
178
- * the JS stack. The returned value is Message::kNoScriptIdInfo if no id
179
- * was found.
182
+ * Returns the first valid script id at the top of the JS stack. The returned
183
+ * value is Message::kNoScriptIdInfo if no id was found.
180
184
  *
181
185
  * This method is equivalent to calling StackTrace::CurrentStackTrace and
182
186
  * walking the resulting frames from the beginning until a non-empty id is
183
187
  * found. The difference is that this method won't allocate a stack trace.
184
188
  */
185
189
  static int CurrentScriptId(Isolate* isolate);
190
+
191
+ /**
192
+ * Writes up to the first `frame_data.size()` valid script ids and function
193
+ * contexts at the top of the JS stack into the given span. Returns a span
194
+ * sized to the number of frames worth of data written. It's similar to the
195
+ * CurrentStackTrace method but doesn't allocate a stack trace. Further, it
196
+ * skips frames that don't have valid script ids or function contexts. The
197
+ * final difference is that the script id written for evals or regexp is that
198
+ * of the script that ran eval() or regexp, not the current context.
199
+ *
200
+ * WARNING: This is an unfinished experimental feature. Semantics and
201
+ * implementation may change frequently.
202
+ */
203
+ static v8::MemorySpan<v8::StackTrace::ScriptIdAndContext>
204
+ CurrentScriptIdsAndContexts(Isolate* isolate,
205
+ v8::MemorySpan<ScriptIdAndContext> frame_data);
186
206
  };
187
207
 
188
208
  } // namespace v8
@@ -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
- bool is_verbose_ : 1;
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
- static Local<External> New(Isolate* isolate, void* value);
22
- V8_INLINE static External* Cast(Value* value) {
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
- void* Value() const;
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::Value* obj);
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 = -2;
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
- // TODO(ishell, http://crbug.com/326505377): in case of non-constructor
147
- // call, don't pass kNewTarget and kUnused. Add IsConstructCall flag to
148
- // kIsolate field.
149
- static constexpr int kUnusedIndex = 0;
150
- static constexpr int kIsolateIndex = 1;
151
- static constexpr int kContextIndex = 2;
152
- static constexpr int kReturnValueIndex = 3;
153
- static constexpr int kTargetIndex = 4;
154
- static constexpr int kNewTargetIndex = 5;
155
- static constexpr int kArgsLength = 6;
156
-
157
- static constexpr int kArgsLengthWithReceiver = kArgsLength + 1;
158
-
159
- // Codegen constants:
160
- static constexpr int kSize = 3 * internal::kApiSystemPointerSize;
161
- static constexpr int kImplicitArgsOffset = 0;
162
- static constexpr int kValuesOffset =
163
- kImplicitArgsOffset + internal::kApiSystemPointerSize;
164
- static constexpr int kLengthOffset =
165
- kValuesOffset + internal::kApiSystemPointerSize;
166
-
167
- static constexpr int kThisValuesIndex = -1;
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
- V8_INLINE FunctionCallbackInfo(internal::Address* implicit_args,
172
- internal::Address* values, int length);
199
+ internal::Address* address_of_first_argument() const {
200
+ return &values_[kFirstJSArgumentIndex];
201
+ }
202
+
203
+ V8_INLINE FunctionCallbackInfo() = default;
173
204
 
174
- // TODO(https://crbug.com/326505377): flatten the v8::FunctionCallbackInfo
175
- // object to avoid indirect loads through values_ and implicit_args_ and
176
- // reduce the number of instructions in the CallApiCallback builtin.
177
- internal::Address* implicit_args_;
178
- internal::Address* values_;
179
- internal::Address length_;
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 intercepting `Reflect.set()`
285
- * independent of the language mode.
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
- static constexpr int kPropertyKeyIndex = 0;
298
- static constexpr int kShouldThrowOnErrorIndex = 1;
299
- static constexpr int kHolderIndex = 2;
300
- static constexpr int kIsolateIndex = 3;
301
- static constexpr int kHolderV2Index = 4;
302
- static constexpr int kReturnValueIndex = 5;
303
- static constexpr int kDataIndex = 6;
304
- static constexpr int kThisIndex = 7;
305
- static constexpr int kArgsLength = 8;
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
- static constexpr int kSize = kArgsLength * internal::kApiSystemPointerSize;
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 internal::Address args_[kArgsLength];
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
- // "V8_DEPRECATE_SOON" this method if |T| is |void|.
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
- // "V8_DEPRECATE_SOON" this method if |T| is |void|.
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
- if constexpr (is_allowed_void) {
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
- // values_ points to the first argument (not the receiver).
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
- return Local<Value>::FromSlot(&implicit_args_[kNewTargetIndex]);
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(&implicit_args_[kTargetIndex]);
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 *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]);
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>(&implicit_args_[kReturnValueIndex]);
653
+ return ReturnValue<T>(&values_[kReturnValueIndex]);
652
654
  }
653
655
 
654
656
  template <typename T>
655
657
  bool FunctionCallbackInfo<T>::IsConstructCall() const {
656
- return !NewTarget()->IsUndefined();
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>(length_);
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
- Local<Value> PropertyCallbackInfo<T>::Data() const {
671
- return Local<Value>::FromSlot(&args_[kDataIndex]);
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
- Local<Object> PropertyCallbackInfo<T>::This() const {
676
- return Local<Object>::FromSlot(&args_[kThisIndex]);
673
+ Isolate* PropertyCallbackInfo<T>::GetIsolate() const {
674
+ return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]);
677
675
  }
678
676
 
679
677
  template <typename T>
680
- Local<Object> PropertyCallbackInfo<T>::Holder() const {
681
- return Local<Object>::FromSlot(&args_[kHolderIndex]);
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
- using I = internal::Internals;
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
- using I = internal::Internals;
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);