libv8-node 19.9.0.0-aarch64-linux → 20.2.0.0-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/aarch64-linux/libv8/obj/libv8_monolith.a +0 -0
  4. data/vendor/v8/include/cppgc/cross-thread-persistent.h +4 -2
  5. data/vendor/v8/include/cppgc/heap-consistency.h +2 -2
  6. data/vendor/v8/include/cppgc/heap-handle.h +5 -0
  7. data/vendor/v8/include/cppgc/internal/api-constants.h +4 -1
  8. data/vendor/v8/include/cppgc/internal/gc-info.h +35 -33
  9. data/vendor/v8/include/cppgc/internal/member-storage.h +19 -7
  10. data/vendor/v8/include/cppgc/internal/pointer-policies.h +38 -2
  11. data/vendor/v8/include/cppgc/internal/write-barrier.h +15 -5
  12. data/vendor/v8/include/cppgc/macros.h +10 -1
  13. data/vendor/v8/include/cppgc/member.h +167 -129
  14. data/vendor/v8/include/cppgc/persistent.h +22 -15
  15. data/vendor/v8/include/cppgc/platform.h +6 -4
  16. data/vendor/v8/include/cppgc/type-traits.h +4 -3
  17. data/vendor/v8/include/cppgc/visitor.h +16 -1
  18. data/vendor/v8/include/libplatform/v8-tracing.h +2 -2
  19. data/vendor/v8/include/v8-array-buffer.h +59 -0
  20. data/vendor/v8/include/v8-callbacks.h +14 -1
  21. data/vendor/v8/include/v8-context.h +50 -3
  22. data/vendor/v8/include/v8-cppgc.h +10 -0
  23. data/vendor/v8/include/v8-data.h +1 -1
  24. data/vendor/v8/include/v8-embedder-heap.h +0 -169
  25. data/vendor/v8/include/v8-fast-api-calls.h +7 -3
  26. data/vendor/v8/include/v8-function-callback.h +69 -42
  27. data/vendor/v8/include/v8-function.h +1 -0
  28. data/vendor/v8/include/v8-inspector.h +20 -5
  29. data/vendor/v8/include/v8-internal.h +242 -150
  30. data/vendor/v8/include/v8-isolate.h +30 -40
  31. data/vendor/v8/include/v8-local-handle.h +81 -48
  32. data/vendor/v8/include/v8-metrics.h +28 -2
  33. data/vendor/v8/include/v8-microtask-queue.h +5 -0
  34. data/vendor/v8/include/v8-object.h +21 -3
  35. data/vendor/v8/include/v8-persistent-handle.h +25 -16
  36. data/vendor/v8/include/v8-platform.h +79 -10
  37. data/vendor/v8/include/v8-primitive.h +19 -12
  38. data/vendor/v8/include/v8-profiler.h +49 -31
  39. data/vendor/v8/include/v8-script.h +29 -1
  40. data/vendor/v8/include/v8-snapshot.h +4 -8
  41. data/vendor/v8/include/v8-template.h +3 -1
  42. data/vendor/v8/include/v8-traced-handle.h +22 -28
  43. data/vendor/v8/include/v8-util.h +9 -3
  44. data/vendor/v8/include/v8-value.h +31 -4
  45. data/vendor/v8/include/v8-version.h +4 -4
  46. data/vendor/v8/include/v8-wasm.h +2 -1
  47. data/vendor/v8/include/v8config.h +73 -2
  48. metadata +1 -1
@@ -5,9 +5,11 @@
5
5
  #ifndef V8_V8_PLATFORM_H_
6
6
  #define V8_V8_PLATFORM_H_
7
7
 
8
+ #include <math.h>
8
9
  #include <stddef.h>
9
10
  #include <stdint.h>
10
11
  #include <stdlib.h> // For abort.
12
+
11
13
  #include <memory>
12
14
  #include <string>
13
15
 
@@ -265,6 +267,38 @@ class JobTask {
265
267
  virtual size_t GetMaxConcurrency(size_t worker_count) const = 0;
266
268
  };
267
269
 
270
+ /**
271
+ * A "blocking call" refers to any call that causes the calling thread to wait
272
+ * off-CPU. It includes but is not limited to calls that wait on synchronous
273
+ * file I/O operations: read or write a file from disk, interact with a pipe or
274
+ * a socket, rename or delete a file, enumerate files in a directory, etc.
275
+ * Acquiring a low contention lock is not considered a blocking call.
276
+ */
277
+
278
+ /**
279
+ * BlockingType indicates the likelihood that a blocking call will actually
280
+ * block.
281
+ */
282
+ enum class BlockingType {
283
+ // The call might block (e.g. file I/O that might hit in memory cache).
284
+ kMayBlock,
285
+ // The call will definitely block (e.g. cache already checked and now pinging
286
+ // server synchronously).
287
+ kWillBlock
288
+ };
289
+
290
+ /**
291
+ * This class is instantiated with CreateBlockingScope() in every scope where a
292
+ * blocking call is made and serves as a precise annotation of the scope that
293
+ * may/will block. May be implemented by an embedder to adjust the thread count.
294
+ * CPU usage should be minimal within that scope. ScopedBlockingCalls can be
295
+ * nested.
296
+ */
297
+ class ScopedBlockingCall {
298
+ public:
299
+ virtual ~ScopedBlockingCall() = default;
300
+ };
301
+
268
302
  /**
269
303
  * The interface represents complex arguments to trace events.
270
304
  */
@@ -285,6 +319,8 @@ class ConvertableToTraceFormat {
285
319
  * V8 Tracing controller.
286
320
  *
287
321
  * Can be implemented by an embedder to record trace events from V8.
322
+ *
323
+ * Will become obsolete in Perfetto SDK build (v8_use_perfetto = true).
288
324
  */
289
325
  class TracingController {
290
326
  public:
@@ -348,10 +384,16 @@ class TracingController {
348
384
  virtual void OnTraceDisabled() = 0;
349
385
  };
350
386
 
351
- /** Adds tracing state change observer. */
387
+ /**
388
+ * Adds tracing state change observer.
389
+ * Does nothing in Perfetto SDK build (v8_use_perfetto = true).
390
+ */
352
391
  virtual void AddTraceStateObserver(TraceStateObserver*) {}
353
392
 
354
- /** Removes tracing state change observer. */
393
+ /**
394
+ * Removes tracing state change observer.
395
+ * Does nothing in Perfetto SDK build (v8_use_perfetto = true).
396
+ */
355
397
  virtual void RemoveTraceStateObserver(TraceStateObserver*) {}
356
398
  };
357
399
 
@@ -534,7 +576,7 @@ static constexpr PlatformSharedMemoryHandle kInvalidSharedMemoryHandle = -1;
534
576
  // to avoid pulling in large OS header files into this header file. Instead,
535
577
  // the users of these routines are expected to include the respecitve OS
536
578
  // headers in addition to this one.
537
- #if V8_OS_MACOS
579
+ #if V8_OS_DARWIN
538
580
  // Convert between a shared memory handle and a mach_port_t referencing a memory
539
581
  // entry object.
540
582
  inline PlatformSharedMemoryHandle SharedMemoryHandleFromMachMemoryEntry(
@@ -923,6 +965,7 @@ class Platform {
923
965
 
924
966
  /**
925
967
  * Allows the embedder to manage memory page allocations.
968
+ * Returning nullptr will cause V8 to use the default page allocator.
926
969
  */
927
970
  virtual PageAllocator* GetPageAllocator() = 0;
928
971
 
@@ -944,11 +987,12 @@ class Platform {
944
987
  virtual void OnCriticalMemoryPressure() {}
945
988
 
946
989
  /**
947
- * Gets the number of worker threads used by
948
- * Call(BlockingTask)OnWorkerThread(). This can be used to estimate the number
949
- * of tasks a work package should be split into. A return value of 0 means
950
- * that there are no worker threads available. Note that a value of 0 won't
951
- * prohibit V8 from posting tasks using |CallOnWorkerThread|.
990
+ * Gets the max number of worker threads that may be used to execute
991
+ * concurrent work scheduled for any single TaskPriority by
992
+ * Call(BlockingTask)OnWorkerThread() or PostJob(). This can be used to
993
+ * estimate the number of tasks a work package should be split into. A return
994
+ * value of 0 means that there are no worker threads available. Note that a
995
+ * value of 0 won't prohibit V8 from posting tasks using |CallOnWorkerThread|.
952
996
  */
953
997
  virtual int NumberOfWorkerThreads() = 0;
954
998
 
@@ -1063,6 +1107,14 @@ class Platform {
1063
1107
  virtual std::unique_ptr<JobHandle> CreateJob(
1064
1108
  TaskPriority priority, std::unique_ptr<JobTask> job_task) = 0;
1065
1109
 
1110
+ /**
1111
+ * Instantiates a ScopedBlockingCall to annotate a scope that may/will block.
1112
+ */
1113
+ virtual std::unique_ptr<ScopedBlockingCall> CreateBlockingScope(
1114
+ BlockingType blocking_type) {
1115
+ return nullptr;
1116
+ }
1117
+
1066
1118
  /**
1067
1119
  * Monotonically increasing time in seconds from an arbitrary fixed point in
1068
1120
  * the past. This function is expected to return at least
@@ -1073,11 +1125,28 @@ class Platform {
1073
1125
  virtual double MonotonicallyIncreasingTime() = 0;
1074
1126
 
1075
1127
  /**
1076
- * Current wall-clock time in milliseconds since epoch.
1077
- * This function is expected to return at least millisecond-precision values.
1128
+ * Current wall-clock time in milliseconds since epoch. Use
1129
+ * CurrentClockTimeMillisHighResolution() when higher precision is
1130
+ * required.
1131
+ */
1132
+ virtual int64_t CurrentClockTimeMilliseconds() {
1133
+ return floor(CurrentClockTimeMillis());
1134
+ }
1135
+
1136
+ /**
1137
+ * This function is deprecated and will be deleted. Use either
1138
+ * CurrentClockTimeMilliseconds() or
1139
+ * CurrentClockTimeMillisecondsHighResolution().
1078
1140
  */
1079
1141
  virtual double CurrentClockTimeMillis() = 0;
1080
1142
 
1143
+ /**
1144
+ * Same as CurrentClockTimeMilliseconds(), but with more precision.
1145
+ */
1146
+ virtual double CurrentClockTimeMillisecondsHighResolution() {
1147
+ return CurrentClockTimeMillis();
1148
+ }
1149
+
1081
1150
  typedef void (*StackTracePrinter)();
1082
1151
 
1083
1152
  /**
@@ -493,8 +493,15 @@ class V8_EXPORT String : public Name {
493
493
  /**
494
494
  * Returns true if this string can be made external.
495
495
  */
496
+ V8_DEPRECATE_SOON("Use the version that takes an encoding as argument.")
496
497
  bool CanMakeExternal() const;
497
498
 
499
+ /**
500
+ * Returns true if this string can be made external, given the encoding for
501
+ * the external string resource.
502
+ */
503
+ bool CanMakeExternal(Encoding encoding) const;
504
+
498
505
  /**
499
506
  * Returns true if the strings values are equal. Same as JS ==/===.
500
507
  */
@@ -776,14 +783,14 @@ Local<String> String::Empty(Isolate* isolate) {
776
783
  using S = internal::Address;
777
784
  using I = internal::Internals;
778
785
  I::CheckInitialized(isolate);
779
- S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex);
780
- return Local<String>(reinterpret_cast<String*>(slot));
786
+ S* slot = I::GetRootSlot(isolate, I::kEmptyStringRootIndex);
787
+ return Local<String>::FromSlot(slot);
781
788
  }
782
789
 
783
790
  String::ExternalStringResource* String::GetExternalStringResource() const {
784
791
  using A = internal::Address;
785
792
  using I = internal::Internals;
786
- A obj = *reinterpret_cast<const A*>(this);
793
+ A obj = internal::ValueHelper::ValueAsAddress(this);
787
794
 
788
795
  ExternalStringResource* result;
789
796
  if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) {
@@ -804,7 +811,7 @@ String::ExternalStringResourceBase* String::GetExternalStringResourceBase(
804
811
  String::Encoding* encoding_out) const {
805
812
  using A = internal::Address;
806
813
  using I = internal::Internals;
807
- A obj = *reinterpret_cast<const A*>(this);
814
+ A obj = internal::ValueHelper::ValueAsAddress(this);
808
815
  int type = I::GetInstanceType(obj) & I::kStringRepresentationAndEncodingMask;
809
816
  *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask);
810
817
  ExternalStringResourceBase* resource;
@@ -829,32 +836,32 @@ V8_INLINE Local<Primitive> Undefined(Isolate* isolate) {
829
836
  using S = internal::Address;
830
837
  using I = internal::Internals;
831
838
  I::CheckInitialized(isolate);
832
- S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex);
833
- return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
839
+ S* slot = I::GetRootSlot(isolate, I::kUndefinedValueRootIndex);
840
+ return Local<Primitive>::FromSlot(slot);
834
841
  }
835
842
 
836
843
  V8_INLINE Local<Primitive> Null(Isolate* isolate) {
837
844
  using S = internal::Address;
838
845
  using I = internal::Internals;
839
846
  I::CheckInitialized(isolate);
840
- S* slot = I::GetRoot(isolate, I::kNullValueRootIndex);
841
- return Local<Primitive>(reinterpret_cast<Primitive*>(slot));
847
+ S* slot = I::GetRootSlot(isolate, I::kNullValueRootIndex);
848
+ return Local<Primitive>::FromSlot(slot);
842
849
  }
843
850
 
844
851
  V8_INLINE Local<Boolean> True(Isolate* isolate) {
845
852
  using S = internal::Address;
846
853
  using I = internal::Internals;
847
854
  I::CheckInitialized(isolate);
848
- S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex);
849
- return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
855
+ S* slot = I::GetRootSlot(isolate, I::kTrueValueRootIndex);
856
+ return Local<Boolean>::FromSlot(slot);
850
857
  }
851
858
 
852
859
  V8_INLINE Local<Boolean> False(Isolate* isolate) {
853
860
  using S = internal::Address;
854
861
  using I = internal::Internals;
855
862
  I::CheckInitialized(isolate);
856
- S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex);
857
- return Local<Boolean>(reinterpret_cast<Boolean*>(slot));
863
+ S* slot = I::GetRootSlot(isolate, I::kFalseValueRootIndex);
864
+ return Local<Boolean>::FromSlot(slot);
858
865
  }
859
866
 
860
867
  Local<Boolean> Boolean::New(Isolate* isolate, bool value) {
@@ -175,6 +175,32 @@ class V8_EXPORT CpuProfileNode {
175
175
  static const int kNoColumnNumberInfo = Message::kNoColumnInfo;
176
176
  };
177
177
 
178
+ /**
179
+ * An interface for exporting data from V8, using "push" model.
180
+ */
181
+ class V8_EXPORT OutputStream {
182
+ public:
183
+ enum WriteResult { kContinue = 0, kAbort = 1 };
184
+ virtual ~OutputStream() = default;
185
+ /** Notify about the end of stream. */
186
+ virtual void EndOfStream() = 0;
187
+ /** Get preferred output chunk size. Called only once. */
188
+ virtual int GetChunkSize() { return 1024; }
189
+ /**
190
+ * Writes the next chunk of snapshot data into the stream. Writing
191
+ * can be stopped by returning kAbort as function result. EndOfStream
192
+ * will not be called in case writing was aborted.
193
+ */
194
+ virtual WriteResult WriteAsciiChunk(char* data, int size) = 0;
195
+ /**
196
+ * Writes the next chunk of heap stats data into the stream. Writing
197
+ * can be stopped by returning kAbort as function result. EndOfStream
198
+ * will not be called in case writing was aborted.
199
+ */
200
+ virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate* data, int count) {
201
+ return kAbort;
202
+ }
203
+ };
178
204
 
179
205
  /**
180
206
  * CpuProfile contains a CPU profile in a form of top-down call tree
@@ -182,6 +208,9 @@ class V8_EXPORT CpuProfileNode {
182
208
  */
183
209
  class V8_EXPORT CpuProfile {
184
210
  public:
211
+ enum SerializationFormat {
212
+ kJSON = 0 // See format description near 'Serialize' method.
213
+ };
185
214
  /** Returns CPU profile title. */
186
215
  Local<String> GetTitle() const;
187
216
 
@@ -235,6 +264,25 @@ class V8_EXPORT CpuProfile {
235
264
  * All pointers to nodes previously returned become invalid.
236
265
  */
237
266
  void Delete();
267
+
268
+ /**
269
+ * Prepare a serialized representation of the profile. The result
270
+ * is written into the stream provided in chunks of specified size.
271
+ *
272
+ * For the JSON format, heap contents are represented as an object
273
+ * with the following structure:
274
+ *
275
+ * {
276
+ * nodes: [nodes array],
277
+ * startTime: number,
278
+ * endTime: number
279
+ * samples: [strings array]
280
+ * timeDeltas: [numbers array]
281
+ * }
282
+ *
283
+ */
284
+ void Serialize(OutputStream* stream,
285
+ SerializationFormat format = kJSON) const;
238
286
  };
239
287
 
240
288
  enum CpuProfilingMode {
@@ -548,6 +596,7 @@ class V8_EXPORT HeapGraphNode {
548
596
  kBigInt = 13, // BigInt.
549
597
  kObjectShape = 14, // Internal data used for tracking the shapes (or
550
598
  // "hidden classes") of JS objects.
599
+ kWasmObject = 15, // A WasmGC struct or array.
551
600
  };
552
601
 
553
602
  /** Returns node type (see HeapGraphNode::Type). */
@@ -576,37 +625,6 @@ class V8_EXPORT HeapGraphNode {
576
625
  const HeapGraphEdge* GetChild(int index) const;
577
626
  };
578
627
 
579
-
580
- /**
581
- * An interface for exporting data from V8, using "push" model.
582
- */
583
- class V8_EXPORT OutputStream {
584
- public:
585
- enum WriteResult {
586
- kContinue = 0,
587
- kAbort = 1
588
- };
589
- virtual ~OutputStream() = default;
590
- /** Notify about the end of stream. */
591
- virtual void EndOfStream() = 0;
592
- /** Get preferred output chunk size. Called only once. */
593
- virtual int GetChunkSize() { return 1024; }
594
- /**
595
- * Writes the next chunk of snapshot data into the stream. Writing
596
- * can be stopped by returning kAbort as function result. EndOfStream
597
- * will not be called in case writing was aborted.
598
- */
599
- virtual WriteResult WriteAsciiChunk(char* data, int size) = 0;
600
- /**
601
- * Writes the next chunk of heap stats data into the stream. Writing
602
- * can be stopped by returning kAbort as function result. EndOfStream
603
- * will not be called in case writing was aborted.
604
- */
605
- virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate* data, int count) {
606
- return kAbort;
607
- }
608
- };
609
-
610
628
  /**
611
629
  * HeapSnapshots record the state of the JS heap at some moment.
612
630
  */
@@ -11,6 +11,7 @@
11
11
  #include <memory>
12
12
  #include <vector>
13
13
 
14
+ #include "v8-callbacks.h" // NOLINT(build/include_directory)
14
15
  #include "v8-data.h" // NOLINT(build/include_directory)
15
16
  #include "v8-local-handle.h" // NOLINT(build/include_directory)
16
17
  #include "v8-maybe.h" // NOLINT(build/include_directory)
@@ -347,6 +348,12 @@ class V8_EXPORT Script {
347
348
  * ScriptOrigin. This can be either a v8::String or v8::Undefined.
348
349
  */
349
350
  Local<Value> GetResourceName();
351
+
352
+ /**
353
+ * If the script was compiled, returns the positions of lazy functions which
354
+ * were eventually compiled and executed.
355
+ */
356
+ std::vector<int> GetProducedCompileHints() const;
350
357
  };
351
358
 
352
359
  enum class ScriptType { kClassic, kModule };
@@ -407,6 +414,8 @@ class V8_EXPORT ScriptCompiler {
407
414
  V8_INLINE explicit Source(
408
415
  Local<String> source_string, CachedData* cached_data = nullptr,
409
416
  ConsumeCodeCacheTask* consume_cache_task = nullptr);
417
+ V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin,
418
+ CompileHintCallback callback, void* callback_data);
410
419
  V8_INLINE ~Source() = default;
411
420
 
412
421
  // Ownership of the CachedData or its buffers is *not* transferred to the
@@ -434,6 +443,10 @@ class V8_EXPORT ScriptCompiler {
434
443
  // set when calling a compile method.
435
444
  std::unique_ptr<CachedData> cached_data;
436
445
  std::unique_ptr<ConsumeCodeCacheTask> consume_cache_task;
446
+
447
+ // For requesting compile hints from the embedder.
448
+ CompileHintCallback compile_hint_callback = nullptr;
449
+ void* compile_hint_callback_data = nullptr;
437
450
  };
438
451
 
439
452
  /**
@@ -562,7 +575,9 @@ class V8_EXPORT ScriptCompiler {
562
575
  enum CompileOptions {
563
576
  kNoCompileOptions = 0,
564
577
  kConsumeCodeCache,
565
- kEagerCompile
578
+ kEagerCompile,
579
+ kProduceCompileHints,
580
+ kConsumeCompileHints
566
581
  };
567
582
 
568
583
  /**
@@ -775,6 +790,19 @@ ScriptCompiler::Source::Source(Local<String> string, CachedData* data,
775
790
  cached_data(data),
776
791
  consume_cache_task(consume_cache_task) {}
777
792
 
793
+ ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin,
794
+ CompileHintCallback callback,
795
+ void* callback_data)
796
+ : source_string(string),
797
+ resource_name(origin.ResourceName()),
798
+ resource_line_offset(origin.LineOffset()),
799
+ resource_column_offset(origin.ColumnOffset()),
800
+ resource_options(origin.Options()),
801
+ source_map_url(origin.SourceMapUrl()),
802
+ host_defined_options(origin.GetHostDefinedOptions()),
803
+ compile_hint_callback(callback),
804
+ compile_hint_callback_data(callback_data) {}
805
+
778
806
  const ScriptCompiler::CachedData* ScriptCompiler::Source::GetCachedData()
779
807
  const {
780
808
  return cached_data.get();
@@ -91,7 +91,7 @@ class V8_EXPORT SnapshotCreator {
91
91
  */
92
92
  SnapshotCreator(Isolate* isolate,
93
93
  const intptr_t* external_references = nullptr,
94
- StartupData* existing_blob = nullptr);
94
+ const StartupData* existing_blob = nullptr);
95
95
 
96
96
  /**
97
97
  * Create and enter an isolate, and set it up for serialization.
@@ -102,7 +102,7 @@ class V8_EXPORT SnapshotCreator {
102
102
  * that must be equivalent to CreateParams::external_references.
103
103
  */
104
104
  SnapshotCreator(const intptr_t* external_references = nullptr,
105
- StartupData* existing_blob = nullptr);
105
+ const StartupData* existing_blob = nullptr);
106
106
 
107
107
  /**
108
108
  * Destroy the snapshot creator, and exit and dispose of the Isolate
@@ -179,16 +179,12 @@ class V8_EXPORT SnapshotCreator {
179
179
 
180
180
  template <class T>
181
181
  size_t SnapshotCreator::AddData(Local<Context> context, Local<T> object) {
182
- T* object_ptr = *object;
183
- internal::Address* p = reinterpret_cast<internal::Address*>(object_ptr);
184
- return AddData(context, *p);
182
+ return AddData(context, internal::ValueHelper::ValueAsAddress(*object));
185
183
  }
186
184
 
187
185
  template <class T>
188
186
  size_t SnapshotCreator::AddData(Local<T> object) {
189
- T* object_ptr = *object;
190
- internal::Address* p = reinterpret_cast<internal::Address*>(object_ptr);
191
- return AddData(*p);
187
+ return AddData(internal::ValueHelper::ValueAsAddress(*object));
192
188
  }
193
189
 
194
190
  } // namespace v8
@@ -30,7 +30,9 @@ class Signature;
30
30
  F(AsyncIteratorPrototype, initial_async_iterator_prototype) \
31
31
  F(ErrorPrototype, initial_error_prototype) \
32
32
  F(IteratorPrototype, initial_iterator_prototype) \
33
- F(ObjProto_valueOf, object_value_of_function)
33
+ F(MapIteratorPrototype, initial_map_iterator_prototype) \
34
+ F(ObjProto_valueOf, object_value_of_function) \
35
+ F(SetIteratorPrototype, initial_set_iterator_prototype)
34
36
 
35
37
  enum Intrinsic {
36
38
  #define V8_DECL_INTRINSIC(name, iname) k##name,
@@ -62,7 +62,8 @@ class TracedReferenceBase {
62
62
  */
63
63
  V8_INLINE v8::Local<v8::Value> Get(v8::Isolate* isolate) const {
64
64
  if (IsEmpty()) return Local<Value>();
65
- return Local<Value>::New(isolate, reinterpret_cast<Value*>(val_));
65
+ return Local<Value>::New(isolate,
66
+ internal::ValueHelper::SlotAsValue<Value>(val_));
66
67
  }
67
68
 
68
69
  /**
@@ -103,10 +104,13 @@ class TracedReferenceBase {
103
104
 
104
105
  V8_EXPORT void CheckValue() const;
105
106
 
107
+ V8_INLINE internal::Address address() const { return *val_; }
108
+
106
109
  // val_ points to a GlobalHandles node.
107
110
  internal::Address* val_ = nullptr;
108
111
 
109
112
  friend class internal::BasicTracedReferenceExtractor;
113
+ friend class internal::HandleHelper;
110
114
  template <typename F>
111
115
  friend class Local;
112
116
  template <typename U>
@@ -117,11 +121,11 @@ class TracedReferenceBase {
117
121
 
118
122
  /**
119
123
  * A traced handle with copy and move semantics. The handle is to be used
120
- * together with |v8::EmbedderHeapTracer| or as part of GarbageCollected objects
121
- * (see v8-cppgc.h) and specifies edges from C++ objects to JavaScript.
124
+ * together as part of GarbageCollected objects (see v8-cppgc.h) or from stack
125
+ * and specifies edges from C++ objects to JavaScript.
122
126
  *
123
127
  * The exact semantics are:
124
- * - Tracing garbage collections use |v8::EmbedderHeapTracer| or cppgc.
128
+ * - Tracing garbage collections using CppHeap.
125
129
  * - Non-tracing garbage collections refer to
126
130
  * |v8::EmbedderRootsHandler::IsRoot()| whether the handle should
127
131
  * be treated as root or not.
@@ -135,7 +139,12 @@ class BasicTracedReference : public TracedReferenceBase {
135
139
  /**
136
140
  * Construct a Local<T> from this handle.
137
141
  */
138
- Local<T> Get(Isolate* isolate) const { return Local<T>::New(isolate, *this); }
142
+ Local<T> Get(Isolate* isolate) const {
143
+ #ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
144
+ if (val_ == nullptr) return Local<T>();
145
+ #endif
146
+ return Local<T>::New(isolate, *this);
147
+ }
139
148
 
140
149
  template <class S>
141
150
  V8_INLINE BasicTracedReference<S>& As() const {
@@ -166,7 +175,6 @@ class BasicTracedReference : public TracedReferenceBase {
166
175
  Isolate* isolate, T* that, void* slot,
167
176
  internal::GlobalHandleStoreMode store_mode);
168
177
 
169
- friend class EmbedderHeapTracer;
170
178
  template <typename F>
171
179
  friend class Local;
172
180
  friend class Object;
@@ -181,13 +189,7 @@ class BasicTracedReference : public TracedReferenceBase {
181
189
  /**
182
190
  * A traced handle without destructor that clears the handle. The embedder needs
183
191
  * to ensure that the handle is not accessed once the V8 object has been
184
- * reclaimed. This can happen when the handle is not passed through the
185
- * EmbedderHeapTracer. For more details see BasicTracedReference.
186
- *
187
- * The reference assumes the embedder has precise knowledge about references at
188
- * all times. In case V8 needs to separately handle on-stack references, the
189
- * embedder is required to set the stack start through
190
- * |EmbedderHeapTracer::SetStackStart|.
192
+ * reclaimed. For more details see BasicTracedReference.
191
193
  */
192
194
  template <typename T>
193
195
  class TracedReference : public BasicTracedReference<T> {
@@ -207,7 +209,7 @@ class TracedReference : public BasicTracedReference<T> {
207
209
  */
208
210
  template <class S>
209
211
  TracedReference(Isolate* isolate, Local<S> that) : BasicTracedReference<T>() {
210
- this->val_ = this->New(isolate, that.val_, &this->val_,
212
+ this->val_ = this->New(isolate, *that, &this->val_,
211
213
  internal::GlobalHandleStoreMode::kInitializingStore);
212
214
  static_assert(std::is_base_of<T, S>::value, "type check");
213
215
  }
@@ -291,7 +293,7 @@ template <class T>
291
293
  internal::Address* BasicTracedReference<T>::New(
292
294
  Isolate* isolate, T* that, void* slot,
293
295
  internal::GlobalHandleStoreMode store_mode) {
294
- if (that == nullptr) return nullptr;
296
+ if (that == internal::ValueHelper::EmptyValue<T>()) return nullptr;
295
297
  internal::Address* p = reinterpret_cast<internal::Address*>(that);
296
298
  return internal::GlobalizeTracedReference(
297
299
  reinterpret_cast<internal::Isolate*>(isolate), p,
@@ -306,21 +308,13 @@ void TracedReferenceBase::Reset() {
306
308
 
307
309
  V8_INLINE bool operator==(const TracedReferenceBase& lhs,
308
310
  const TracedReferenceBase& rhs) {
309
- v8::internal::Address* a = reinterpret_cast<v8::internal::Address*>(lhs.val_);
310
- v8::internal::Address* b = reinterpret_cast<v8::internal::Address*>(rhs.val_);
311
- if (a == nullptr) return b == nullptr;
312
- if (b == nullptr) return false;
313
- return *a == *b;
311
+ return internal::HandleHelper::EqualHandles(lhs, rhs);
314
312
  }
315
313
 
316
314
  template <typename U>
317
315
  V8_INLINE bool operator==(const TracedReferenceBase& lhs,
318
316
  const v8::Local<U>& rhs) {
319
- v8::internal::Address* a = reinterpret_cast<v8::internal::Address*>(lhs.val_);
320
- v8::internal::Address* b = reinterpret_cast<v8::internal::Address*>(*rhs);
321
- if (a == nullptr) return b == nullptr;
322
- if (b == nullptr) return false;
323
- return *a == *b;
317
+ return internal::HandleHelper::EqualHandles(lhs, rhs);
324
318
  }
325
319
 
326
320
  template <typename U>
@@ -353,7 +347,7 @@ void TracedReference<T>::Reset(Isolate* isolate, const Local<S>& other) {
353
347
  this->Reset();
354
348
  if (other.IsEmpty()) return;
355
349
  this->SetSlotThreadSafe(
356
- this->New(isolate, other.val_, &this->val_,
350
+ this->New(isolate, *other, &this->val_,
357
351
  internal::GlobalHandleStoreMode::kAssigningStore));
358
352
  }
359
353
 
@@ -403,7 +397,7 @@ void TracedReferenceBase::SetWrapperClassId(uint16_t class_id) {
403
397
  using I = internal::Internals;
404
398
  if (IsEmpty()) return;
405
399
  internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
406
- uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
400
+ uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kTracedNodeClassIdOffset;
407
401
  *reinterpret_cast<uint16_t*>(addr) = class_id;
408
402
  }
409
403
 
@@ -411,7 +405,7 @@ uint16_t TracedReferenceBase::WrapperClassId() const {
411
405
  using I = internal::Internals;
412
406
  if (IsEmpty()) return 0;
413
407
  internal::Address* obj = reinterpret_cast<internal::Address*>(val_);
414
- uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset;
408
+ uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kTracedNodeClassIdOffset;
415
409
  return *reinterpret_cast<uint16_t*>(addr);
416
410
  }
417
411
 
@@ -181,7 +181,11 @@ class PersistentValueMapBase {
181
181
  * Get value stored in map.
182
182
  */
183
183
  Local<V> Get(const K& key) {
184
- return Local<V>::New(isolate_, FromVal(Traits::Get(&impl_, key)));
184
+ V* p = FromVal(Traits::Get(&impl_, key));
185
+ #ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
186
+ if (p == nullptr) return Local<V>();
187
+ #endif
188
+ return Local<V>::New(isolate_, p);
185
189
  }
186
190
 
187
191
  /**
@@ -236,7 +240,8 @@ class PersistentValueMapBase {
236
240
  : value_(other.value_) { }
237
241
 
238
242
  Local<V> NewLocal(Isolate* isolate) const {
239
- return Local<V>::New(isolate, FromVal(value_));
243
+ return Local<V>::New(
244
+ isolate, internal::ValueHelper::SlotAsValue<V>(FromVal(value_)));
240
245
  }
241
246
  bool IsEmpty() const {
242
247
  return value_ == kPersistentContainerNotFound;
@@ -613,7 +618,8 @@ class V8_DEPRECATE_SOON("Use std::vector<Global<V>>.") PersistentValueVector {
613
618
  * Retrieve the i-th value in the vector.
614
619
  */
615
620
  Local<V> Get(size_t index) const {
616
- return Local<V>::New(isolate_, FromVal(Traits::Get(&impl_, index)));
621
+ return Local<V>::New(isolate_, internal::ValueHelper::SlotAsValue<V>(
622
+ FromVal(Traits::Get(&impl_, index))));
617
623
  }
618
624
 
619
625
  /**