libv8-node 15.14.0.1-aarch64-linux-musl → 18.8.0.0-aarch64-linux-musl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8-node/location.rb +1 -1
  3. data/ext/libv8-node/paths.rb +5 -1
  4. data/lib/libv8/node/version.rb +3 -3
  5. data/vendor/v8/{out.gn → aarch64-linux-musl}/libv8/obj/libv8_monolith.a +0 -0
  6. data/vendor/v8/include/cppgc/allocation.h +184 -47
  7. data/vendor/v8/include/cppgc/common.h +9 -6
  8. data/vendor/v8/include/cppgc/cross-thread-persistent.h +465 -0
  9. data/vendor/v8/include/cppgc/custom-space.h +37 -2
  10. data/vendor/v8/include/cppgc/default-platform.h +40 -49
  11. data/vendor/v8/include/cppgc/ephemeron-pair.h +30 -0
  12. data/vendor/v8/include/cppgc/explicit-management.h +100 -0
  13. data/vendor/v8/include/cppgc/garbage-collected.h +19 -29
  14. data/vendor/v8/include/cppgc/heap-consistency.h +266 -0
  15. data/vendor/v8/include/cppgc/heap-state.h +82 -0
  16. data/vendor/v8/include/cppgc/heap-statistics.h +120 -0
  17. data/vendor/v8/include/cppgc/heap.h +73 -6
  18. data/vendor/v8/include/cppgc/internal/api-constants.h +11 -3
  19. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +27 -15
  20. data/vendor/v8/include/cppgc/internal/compiler-specific.h +2 -2
  21. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +4 -1
  22. data/vendor/v8/include/cppgc/internal/gc-info.h +124 -13
  23. data/vendor/v8/include/cppgc/internal/logging.h +3 -3
  24. data/vendor/v8/include/cppgc/internal/name-trait.h +122 -0
  25. data/vendor/v8/include/cppgc/internal/persistent-node.h +116 -16
  26. data/vendor/v8/include/cppgc/internal/pointer-policies.h +84 -32
  27. data/vendor/v8/include/cppgc/internal/write-barrier.h +392 -35
  28. data/vendor/v8/include/cppgc/liveness-broker.h +11 -2
  29. data/vendor/v8/include/cppgc/macros.h +2 -0
  30. data/vendor/v8/include/cppgc/member.h +91 -26
  31. data/vendor/v8/include/cppgc/name-provider.h +65 -0
  32. data/vendor/v8/include/cppgc/object-size-trait.h +58 -0
  33. data/vendor/v8/include/cppgc/persistent.h +70 -41
  34. data/vendor/v8/include/cppgc/platform.h +52 -26
  35. data/vendor/v8/include/cppgc/prefinalizer.h +36 -13
  36. data/vendor/v8/include/cppgc/process-heap-statistics.h +36 -0
  37. data/vendor/v8/include/cppgc/sentinel-pointer.h +32 -0
  38. data/vendor/v8/include/cppgc/source-location.h +2 -1
  39. data/vendor/v8/include/cppgc/testing.h +106 -0
  40. data/vendor/v8/include/cppgc/trace-trait.h +8 -3
  41. data/vendor/v8/include/cppgc/type-traits.h +163 -32
  42. data/vendor/v8/include/cppgc/visitor.h +194 -28
  43. data/vendor/v8/include/libplatform/libplatform.h +11 -11
  44. data/vendor/v8/include/libplatform/v8-tracing.h +2 -1
  45. data/vendor/v8/include/v8-array-buffer.h +445 -0
  46. data/vendor/v8/include/v8-callbacks.h +397 -0
  47. data/vendor/v8/include/v8-container.h +129 -0
  48. data/vendor/v8/include/v8-context.h +407 -0
  49. data/vendor/v8/include/v8-cppgc.h +151 -159
  50. data/vendor/v8/include/v8-data.h +80 -0
  51. data/vendor/v8/include/v8-date.h +43 -0
  52. data/vendor/v8/include/v8-debug.h +168 -0
  53. data/vendor/v8/include/v8-embedder-heap.h +218 -0
  54. data/vendor/v8/include/v8-embedder-state-scope.h +51 -0
  55. data/vendor/v8/include/v8-exception.h +217 -0
  56. data/vendor/v8/include/v8-extension.h +62 -0
  57. data/vendor/v8/include/v8-external.h +37 -0
  58. data/vendor/v8/include/v8-fast-api-calls.h +703 -152
  59. data/vendor/v8/include/v8-forward.h +81 -0
  60. data/vendor/v8/include/v8-function-callback.h +475 -0
  61. data/vendor/v8/include/v8-function.h +125 -0
  62. data/vendor/v8/include/v8-initialization.h +315 -0
  63. data/vendor/v8/include/v8-inspector.h +76 -27
  64. data/vendor/v8/include/v8-internal.h +285 -51
  65. data/vendor/v8/include/v8-isolate.h +1709 -0
  66. data/vendor/v8/include/v8-json.h +47 -0
  67. data/vendor/v8/include/v8-local-handle.h +455 -0
  68. data/vendor/v8/include/v8-locker.h +149 -0
  69. data/vendor/v8/include/v8-maybe.h +137 -0
  70. data/vendor/v8/include/v8-memory-span.h +43 -0
  71. data/vendor/v8/include/v8-message.h +216 -0
  72. data/vendor/v8/include/v8-metrics.h +131 -9
  73. data/vendor/v8/include/v8-microtask-queue.h +152 -0
  74. data/vendor/v8/include/v8-microtask.h +28 -0
  75. data/vendor/v8/include/v8-object.h +775 -0
  76. data/vendor/v8/include/v8-persistent-handle.h +590 -0
  77. data/vendor/v8/include/v8-platform.h +433 -25
  78. data/vendor/v8/include/v8-primitive-object.h +118 -0
  79. data/vendor/v8/include/v8-primitive.h +866 -0
  80. data/vendor/v8/include/v8-profiler.h +149 -10
  81. data/vendor/v8/include/v8-promise.h +174 -0
  82. data/vendor/v8/include/v8-proxy.h +50 -0
  83. data/vendor/v8/include/v8-regexp.h +105 -0
  84. data/vendor/v8/include/v8-script.h +747 -0
  85. data/vendor/v8/include/v8-snapshot.h +196 -0
  86. data/vendor/v8/include/v8-statistics.h +217 -0
  87. data/vendor/v8/include/v8-template.h +1079 -0
  88. data/vendor/v8/include/v8-traced-handle.h +420 -0
  89. data/vendor/v8/include/v8-typed-array.h +282 -0
  90. data/vendor/v8/include/v8-unwinder-state.h +31 -0
  91. data/vendor/v8/include/v8-unwinder.h +132 -0
  92. data/vendor/v8/include/v8-util.h +8 -2
  93. data/vendor/v8/include/v8-value-serializer-version.h +1 -1
  94. data/vendor/v8/include/v8-value-serializer.h +279 -0
  95. data/vendor/v8/include/v8-value.h +526 -0
  96. data/vendor/v8/include/v8-version.h +4 -4
  97. data/vendor/v8/include/v8-wasm.h +257 -0
  98. data/vendor/v8/include/v8-weak-callback-info.h +87 -0
  99. data/vendor/v8/include/v8.h +41 -12051
  100. data/vendor/v8/include/v8config.h +142 -21
  101. metadata +64 -10
  102. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +0 -30
  103. data/vendor/v8/include/cppgc/internal/process-heap.h +0 -34
@@ -175,9 +175,14 @@ class JobDelegate {
175
175
  * Returns a task_id unique among threads currently running this job, such
176
176
  * that GetTaskId() < worker count. To achieve this, the same task_id may be
177
177
  * reused by a different thread after a worker_task returns.
178
- * TODO(etiennep): Make pure virtual once custom embedders implement it.
179
178
  */
180
- virtual uint8_t GetTaskId() { return 0; }
179
+ virtual uint8_t GetTaskId() = 0;
180
+
181
+ /**
182
+ * Returns true if the current task is called from the thread currently
183
+ * running JobHandle::Join().
184
+ */
185
+ virtual bool IsJoiningThread() const = 0;
181
186
  };
182
187
 
183
188
  /**
@@ -210,17 +215,34 @@ class JobHandle {
210
215
  */
211
216
  virtual void Cancel() = 0;
212
217
 
218
+ /*
219
+ * Forces all existing workers to yield ASAP but doesn’t wait for them.
220
+ * Warning, this is dangerous if the Job's callback is bound to or has access
221
+ * to state which may be deleted after this call.
222
+ */
223
+ virtual void CancelAndDetach() = 0;
224
+
213
225
  /**
214
- * Returns true if there's no work pending and no worker running.
215
- * TODO(etiennep): Make pure virtual once custom embedders implement it.
226
+ * Returns true if there's any work pending or any worker running.
216
227
  */
217
- virtual bool IsCompleted() { return true; }
228
+ virtual bool IsActive() = 0;
218
229
 
219
230
  /**
220
231
  * Returns true if associated with a Job and other methods may be called.
221
- * Returns false after Join() or Cancel() was called.
232
+ * Returns false after Join() or Cancel() was called. This may return true
233
+ * even if no workers are running and IsCompleted() returns true
222
234
  */
223
- virtual bool IsRunning() = 0;
235
+ virtual bool IsValid() = 0;
236
+
237
+ /**
238
+ * Returns true if job priority can be changed.
239
+ */
240
+ virtual bool UpdatePriorityEnabled() const { return false; }
241
+
242
+ /**
243
+ * Update this Job's priority.
244
+ */
245
+ virtual void UpdatePriority(TaskPriority new_priority) {}
224
246
  };
225
247
 
226
248
  /**
@@ -233,23 +255,13 @@ class JobTask {
233
255
  virtual void Run(JobDelegate* delegate) = 0;
234
256
 
235
257
  /**
236
- * Controls the maximum number of threads calling Run() concurrently. Run() is
237
- * only invoked if the number of threads previously running Run() was less
238
- * than the value returned. Since GetMaxConcurrency() is a leaf function, it
239
- * must not call back any JobHandle methods.
258
+ * Controls the maximum number of threads calling Run() concurrently, given
259
+ * the number of threads currently assigned to this job and executing Run().
260
+ * Run() is only invoked if the number of threads previously running Run() was
261
+ * less than the value returned. Since GetMaxConcurrency() is a leaf function,
262
+ * it must not call back any JobHandle methods.
240
263
  */
241
- virtual size_t GetMaxConcurrency() const = 0;
242
-
243
- /*
244
- * Meant to replace the version above, given the number of threads currently
245
- * assigned to this job and executing Run(). This is useful when the result
246
- * must include local work items not visible globaly by other workers.
247
- * TODO(etiennep): Replace the version above by this once custom embedders are
248
- * migrated.
249
- */
250
- size_t GetMaxConcurrency(size_t worker_count) const {
251
- return GetMaxConcurrency();
252
- }
264
+ virtual size_t GetMaxConcurrency(size_t worker_count) const = 0;
253
265
  };
254
266
 
255
267
  /**
@@ -382,7 +394,6 @@ class PageAllocator {
382
394
  kNoAccess,
383
395
  kRead,
384
396
  kReadWrite,
385
- // TODO(hpayer): Remove this flag. Memory should never be rwx.
386
397
  kReadWriteExecute,
387
398
  kReadExecute,
388
399
  // Set this when reserving memory that will later require kReadWriteExecute
@@ -390,6 +401,8 @@ class PageAllocator {
390
401
  // this is used to set the MAP_JIT flag on Apple Silicon.
391
402
  // TODO(jkummerow): Remove this when Wasm has a platform-independent
392
403
  // w^x implementation.
404
+ // TODO(saelo): Remove this once all JIT pages are allocated through the
405
+ // VirtualAddressSpace API.
393
406
  kNoAccessWillJitLater
394
407
  };
395
408
 
@@ -419,10 +432,22 @@ class PageAllocator {
419
432
  /**
420
433
  * Frees memory in the given [address, address + size) range. address and size
421
434
  * should be operating system page-aligned. The next write to this
422
- * memory area brings the memory transparently back.
435
+ * memory area brings the memory transparently back. This should be treated as
436
+ * a hint to the OS that the pages are no longer needed. It does not guarantee
437
+ * that the pages will be discarded immediately or at all.
423
438
  */
424
439
  virtual bool DiscardSystemPages(void* address, size_t size) { return true; }
425
440
 
441
+ /**
442
+ * Decommits any wired memory pages in the given range, allowing the OS to
443
+ * reclaim them, and marks the region as inacessible (kNoAccess). The address
444
+ * range stays reserved and can be accessed again later by changing its
445
+ * permissions. However, in that case the memory content is guaranteed to be
446
+ * zero-initialized again. The memory must have been previously allocated by a
447
+ * call to AllocatePages. Returns true on success, false otherwise.
448
+ */
449
+ virtual bool DecommitPages(void* address, size_t size) = 0;
450
+
426
451
  /**
427
452
  * INTERNAL ONLY: This interface has not been stabilised and may change
428
453
  * without notice from one release to another without being deprecated first.
@@ -487,6 +512,371 @@ class PageAllocator {
487
512
  virtual bool CanAllocateSharedPages() { return false; }
488
513
  };
489
514
 
515
+ // Opaque type representing a handle to a shared memory region.
516
+ using PlatformSharedMemoryHandle = intptr_t;
517
+ static constexpr PlatformSharedMemoryHandle kInvalidSharedMemoryHandle = -1;
518
+
519
+ // Conversion routines from the platform-dependent shared memory identifiers
520
+ // into the opaque PlatformSharedMemoryHandle type. These use the underlying
521
+ // types (e.g. unsigned int) instead of the typedef'd ones (e.g. mach_port_t)
522
+ // to avoid pulling in large OS header files into this header file. Instead,
523
+ // the users of these routines are expected to include the respecitve OS
524
+ // headers in addition to this one.
525
+ #if V8_OS_MACOS
526
+ // Convert between a shared memory handle and a mach_port_t referencing a memory
527
+ // entry object.
528
+ inline PlatformSharedMemoryHandle SharedMemoryHandleFromMachMemoryEntry(
529
+ unsigned int port) {
530
+ return static_cast<PlatformSharedMemoryHandle>(port);
531
+ }
532
+ inline unsigned int MachMemoryEntryFromSharedMemoryHandle(
533
+ PlatformSharedMemoryHandle handle) {
534
+ return static_cast<unsigned int>(handle);
535
+ }
536
+ #elif V8_OS_FUCHSIA
537
+ // Convert between a shared memory handle and a zx_handle_t to a VMO.
538
+ inline PlatformSharedMemoryHandle SharedMemoryHandleFromVMO(uint32_t handle) {
539
+ return static_cast<PlatformSharedMemoryHandle>(handle);
540
+ }
541
+ inline uint32_t VMOFromSharedMemoryHandle(PlatformSharedMemoryHandle handle) {
542
+ return static_cast<uint32_t>(handle);
543
+ }
544
+ #elif V8_OS_WIN
545
+ // Convert between a shared memory handle and a Windows HANDLE to a file mapping
546
+ // object.
547
+ inline PlatformSharedMemoryHandle SharedMemoryHandleFromFileMapping(
548
+ void* handle) {
549
+ return reinterpret_cast<PlatformSharedMemoryHandle>(handle);
550
+ }
551
+ inline void* FileMappingFromSharedMemoryHandle(
552
+ PlatformSharedMemoryHandle handle) {
553
+ return reinterpret_cast<void*>(handle);
554
+ }
555
+ #else
556
+ // Convert between a shared memory handle and a file descriptor.
557
+ inline PlatformSharedMemoryHandle SharedMemoryHandleFromFileDescriptor(int fd) {
558
+ return static_cast<PlatformSharedMemoryHandle>(fd);
559
+ }
560
+ inline int FileDescriptorFromSharedMemoryHandle(
561
+ PlatformSharedMemoryHandle handle) {
562
+ return static_cast<int>(handle);
563
+ }
564
+ #endif
565
+
566
+ /**
567
+ * Possible permissions for memory pages.
568
+ */
569
+ enum class PagePermissions {
570
+ kNoAccess,
571
+ kRead,
572
+ kReadWrite,
573
+ kReadWriteExecute,
574
+ kReadExecute,
575
+ };
576
+
577
+ /**
578
+ * Class to manage a virtual memory address space.
579
+ *
580
+ * This class represents a contiguous region of virtual address space in which
581
+ * sub-spaces and (private or shared) memory pages can be allocated, freed, and
582
+ * modified. This interface is meant to eventually replace the PageAllocator
583
+ * interface, and can be used as an alternative in the meantime.
584
+ *
585
+ * This API is not yet stable and may change without notice!
586
+ */
587
+ class VirtualAddressSpace {
588
+ public:
589
+ using Address = uintptr_t;
590
+
591
+ VirtualAddressSpace(size_t page_size, size_t allocation_granularity,
592
+ Address base, size_t size,
593
+ PagePermissions max_page_permissions)
594
+ : page_size_(page_size),
595
+ allocation_granularity_(allocation_granularity),
596
+ base_(base),
597
+ size_(size),
598
+ max_page_permissions_(max_page_permissions) {}
599
+
600
+ virtual ~VirtualAddressSpace() = default;
601
+
602
+ /**
603
+ * The page size used inside this space. Guaranteed to be a power of two.
604
+ * Used as granularity for all page-related operations except for allocation,
605
+ * which use the allocation_granularity(), see below.
606
+ *
607
+ * \returns the page size in bytes.
608
+ */
609
+ size_t page_size() const { return page_size_; }
610
+
611
+ /**
612
+ * The granularity of page allocations and, by extension, of subspace
613
+ * allocations. This is guaranteed to be a power of two and a multiple of the
614
+ * page_size(). In practice, this is equal to the page size on most OSes, but
615
+ * on Windows it is usually 64KB, while the page size is 4KB.
616
+ *
617
+ * \returns the allocation granularity in bytes.
618
+ */
619
+ size_t allocation_granularity() const { return allocation_granularity_; }
620
+
621
+ /**
622
+ * The base address of the address space managed by this instance.
623
+ *
624
+ * \returns the base address of this address space.
625
+ */
626
+ Address base() const { return base_; }
627
+
628
+ /**
629
+ * The size of the address space managed by this instance.
630
+ *
631
+ * \returns the size of this address space in bytes.
632
+ */
633
+ size_t size() const { return size_; }
634
+
635
+ /**
636
+ * The maximum page permissions that pages allocated inside this space can
637
+ * obtain.
638
+ *
639
+ * \returns the maximum page permissions.
640
+ */
641
+ PagePermissions max_page_permissions() const { return max_page_permissions_; }
642
+
643
+ /**
644
+ * Sets the random seed so that GetRandomPageAddress() will generate
645
+ * repeatable sequences of random addresses.
646
+ *
647
+ * \param The seed for the PRNG.
648
+ */
649
+ virtual void SetRandomSeed(int64_t seed) = 0;
650
+
651
+ /**
652
+ * Returns a random address inside this address space, suitable for page
653
+ * allocations hints.
654
+ *
655
+ * \returns a random address aligned to allocation_granularity().
656
+ */
657
+ virtual Address RandomPageAddress() = 0;
658
+
659
+ /**
660
+ * Allocates private memory pages with the given alignment and permissions.
661
+ *
662
+ * \param hint If nonzero, the allocation is attempted to be placed at the
663
+ * given address first. If that fails, the allocation is attempted to be
664
+ * placed elsewhere, possibly nearby, but that is not guaranteed. Specifying
665
+ * zero for the hint always causes this function to choose a random address.
666
+ * The hint, if specified, must be aligned to the specified alignment.
667
+ *
668
+ * \param size The size of the allocation in bytes. Must be a multiple of the
669
+ * allocation_granularity().
670
+ *
671
+ * \param alignment The alignment of the allocation in bytes. Must be a
672
+ * multiple of the allocation_granularity() and should be a power of two.
673
+ *
674
+ * \param permissions The page permissions of the newly allocated pages.
675
+ *
676
+ * \returns the start address of the allocated pages on success, zero on
677
+ * failure.
678
+ */
679
+ static constexpr Address kNoHint = 0;
680
+ virtual V8_WARN_UNUSED_RESULT Address
681
+ AllocatePages(Address hint, size_t size, size_t alignment,
682
+ PagePermissions permissions) = 0;
683
+
684
+ /**
685
+ * Frees previously allocated pages.
686
+ *
687
+ * This function will terminate the process on failure as this implies a bug
688
+ * in the client. As such, there is no return value.
689
+ *
690
+ * \param address The start address of the pages to free. This address must
691
+ * have been obtained through a call to AllocatePages.
692
+ *
693
+ * \param size The size in bytes of the region to free. This must match the
694
+ * size passed to AllocatePages when the pages were allocated.
695
+ */
696
+ virtual void FreePages(Address address, size_t size) = 0;
697
+
698
+ /**
699
+ * Sets permissions of all allocated pages in the given range.
700
+ *
701
+ * \param address The start address of the range. Must be aligned to
702
+ * page_size().
703
+ *
704
+ * \param size The size in bytes of the range. Must be a multiple
705
+ * of page_size().
706
+ *
707
+ * \param permissions The new permissions for the range.
708
+ *
709
+ * \returns true on success, false otherwise.
710
+ */
711
+ virtual V8_WARN_UNUSED_RESULT bool SetPagePermissions(
712
+ Address address, size_t size, PagePermissions permissions) = 0;
713
+
714
+ /**
715
+ * Creates a guard region at the specified address.
716
+ *
717
+ * Guard regions are guaranteed to cause a fault when accessed and generally
718
+ * do not count towards any memory consumption limits. Further, allocating
719
+ * guard regions can usually not fail in subspaces if the region does not
720
+ * overlap with another region, subspace, or page allocation.
721
+ *
722
+ * \param address The start address of the guard region. Must be aligned to
723
+ * the allocation_granularity().
724
+ *
725
+ * \param size The size of the guard region in bytes. Must be a multiple of
726
+ * the allocation_granularity().
727
+ *
728
+ * \returns true on success, false otherwise.
729
+ */
730
+ virtual V8_WARN_UNUSED_RESULT bool AllocateGuardRegion(Address address,
731
+ size_t size) = 0;
732
+
733
+ /**
734
+ * Frees an existing guard region.
735
+ *
736
+ * This function will terminate the process on failure as this implies a bug
737
+ * in the client. As such, there is no return value.
738
+ *
739
+ * \param address The start address of the guard region to free. This address
740
+ * must have previously been used as address parameter in a successful
741
+ * invocation of AllocateGuardRegion.
742
+ *
743
+ * \param size The size in bytes of the guard region to free. This must match
744
+ * the size passed to AllocateGuardRegion when the region was created.
745
+ */
746
+ virtual void FreeGuardRegion(Address address, size_t size) = 0;
747
+
748
+ /**
749
+ * Allocates shared memory pages with the given permissions.
750
+ *
751
+ * \param hint Placement hint. See AllocatePages.
752
+ *
753
+ * \param size The size of the allocation in bytes. Must be a multiple of the
754
+ * allocation_granularity().
755
+ *
756
+ * \param permissions The page permissions of the newly allocated pages.
757
+ *
758
+ * \param handle A platform-specific handle to a shared memory object. See
759
+ * the SharedMemoryHandleFromX routines above for ways to obtain these.
760
+ *
761
+ * \param offset The offset in the shared memory object at which the mapping
762
+ * should start. Must be a multiple of the allocation_granularity().
763
+ *
764
+ * \returns the start address of the allocated pages on success, zero on
765
+ * failure.
766
+ */
767
+ virtual V8_WARN_UNUSED_RESULT Address
768
+ AllocateSharedPages(Address hint, size_t size, PagePermissions permissions,
769
+ PlatformSharedMemoryHandle handle, uint64_t offset) = 0;
770
+
771
+ /**
772
+ * Frees previously allocated shared pages.
773
+ *
774
+ * This function will terminate the process on failure as this implies a bug
775
+ * in the client. As such, there is no return value.
776
+ *
777
+ * \param address The start address of the pages to free. This address must
778
+ * have been obtained through a call to AllocateSharedPages.
779
+ *
780
+ * \param size The size in bytes of the region to free. This must match the
781
+ * size passed to AllocateSharedPages when the pages were allocated.
782
+ */
783
+ virtual void FreeSharedPages(Address address, size_t size) = 0;
784
+
785
+ /**
786
+ * Whether this instance can allocate subspaces or not.
787
+ *
788
+ * \returns true if subspaces can be allocated, false if not.
789
+ */
790
+ virtual bool CanAllocateSubspaces() = 0;
791
+
792
+ /*
793
+ * Allocate a subspace.
794
+ *
795
+ * The address space of a subspace stays reserved in the parent space for the
796
+ * lifetime of the subspace. As such, it is guaranteed that page allocations
797
+ * on the parent space cannot end up inside a subspace.
798
+ *
799
+ * \param hint Hints where the subspace should be allocated. See
800
+ * AllocatePages() for more details.
801
+ *
802
+ * \param size The size in bytes of the subspace. Must be a multiple of the
803
+ * allocation_granularity().
804
+ *
805
+ * \param alignment The alignment of the subspace in bytes. Must be a multiple
806
+ * of the allocation_granularity() and should be a power of two.
807
+ *
808
+ * \param max_page_permissions The maximum permissions that pages allocated in
809
+ * the subspace can obtain.
810
+ *
811
+ * \returns a new subspace or nullptr on failure.
812
+ */
813
+ virtual std::unique_ptr<VirtualAddressSpace> AllocateSubspace(
814
+ Address hint, size_t size, size_t alignment,
815
+ PagePermissions max_page_permissions) = 0;
816
+
817
+ //
818
+ // TODO(v8) maybe refactor the methods below before stabilizing the API. For
819
+ // example by combining them into some form of page operation method that
820
+ // takes a command enum as parameter.
821
+ //
822
+
823
+ /**
824
+ * Frees memory in the given [address, address + size) range. address and
825
+ * size should be aligned to the page_size(). The next write to this memory
826
+ * area brings the memory transparently back. This should be treated as a
827
+ * hint to the OS that the pages are no longer needed. It does not guarantee
828
+ * that the pages will be discarded immediately or at all.
829
+ *
830
+ * \returns true on success, false otherwise. Since this method is only a
831
+ * hint, a successful invocation does not imply that pages have been removed.
832
+ */
833
+ virtual V8_WARN_UNUSED_RESULT bool DiscardSystemPages(Address address,
834
+ size_t size) {
835
+ return true;
836
+ }
837
+ /**
838
+ * Decommits any wired memory pages in the given range, allowing the OS to
839
+ * reclaim them, and marks the region as inacessible (kNoAccess). The address
840
+ * range stays reserved and can be accessed again later by changing its
841
+ * permissions. However, in that case the memory content is guaranteed to be
842
+ * zero-initialized again. The memory must have been previously allocated by a
843
+ * call to AllocatePages.
844
+ *
845
+ * \returns true on success, false otherwise.
846
+ */
847
+ virtual V8_WARN_UNUSED_RESULT bool DecommitPages(Address address,
848
+ size_t size) = 0;
849
+
850
+ private:
851
+ const size_t page_size_;
852
+ const size_t allocation_granularity_;
853
+ const Address base_;
854
+ const size_t size_;
855
+ const PagePermissions max_page_permissions_;
856
+ };
857
+
858
+ /**
859
+ * V8 Allocator used for allocating zone backings.
860
+ */
861
+ class ZoneBackingAllocator {
862
+ public:
863
+ using MallocFn = void* (*)(size_t);
864
+ using FreeFn = void (*)(void*);
865
+
866
+ virtual MallocFn GetMallocFn() const { return ::malloc; }
867
+ virtual FreeFn GetFreeFn() const { return ::free; }
868
+ };
869
+
870
+ /**
871
+ * Observer used by V8 to notify the embedder about entering/leaving sections
872
+ * with high throughput of malloc/free operations.
873
+ */
874
+ class HighAllocationThroughputObserver {
875
+ public:
876
+ virtual void EnterSection() {}
877
+ virtual void LeaveSection() {}
878
+ };
879
+
490
880
  /**
491
881
  * V8 Platform abstraction layer.
492
882
  *
@@ -505,6 +895,14 @@ class Platform {
505
895
  return nullptr;
506
896
  }
507
897
 
898
+ /**
899
+ * Allows the embedder to specify a custom allocator used for zones.
900
+ */
901
+ virtual ZoneBackingAllocator* GetZoneBackingAllocator() {
902
+ static ZoneBackingAllocator default_allocator;
903
+ return &default_allocator;
904
+ }
905
+
508
906
  /**
509
907
  * Enables the embedder to respond in cases where V8 can't allocate large
510
908
  * blocks of memory. V8 retries the failed allocation once after calling this
@@ -670,6 +1068,16 @@ class Platform {
670
1068
  */
671
1069
  virtual void DumpWithoutCrashing() {}
672
1070
 
1071
+ /**
1072
+ * Allows the embedder to observe sections with high throughput allocation
1073
+ * operations.
1074
+ */
1075
+ virtual HighAllocationThroughputObserver*
1076
+ GetHighAllocationThroughputObserver() {
1077
+ static HighAllocationThroughputObserver default_observer;
1078
+ return &default_observer;
1079
+ }
1080
+
673
1081
  protected:
674
1082
  /**
675
1083
  * Default implementation of current wall-clock time in milliseconds
@@ -0,0 +1,118 @@
1
+ // Copyright 2021 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_PRIMITIVE_OBJECT_H_
6
+ #define INCLUDE_V8_PRIMITIVE_OBJECT_H_
7
+
8
+ #include "v8-local-handle.h" // NOLINT(build/include_directory)
9
+ #include "v8-object.h" // NOLINT(build/include_directory)
10
+ #include "v8config.h" // NOLINT(build/include_directory)
11
+
12
+ namespace v8 {
13
+
14
+ class Isolate;
15
+
16
+ /**
17
+ * A Number object (ECMA-262, 4.3.21).
18
+ */
19
+ class V8_EXPORT NumberObject : public Object {
20
+ public:
21
+ static Local<Value> New(Isolate* isolate, double value);
22
+
23
+ double ValueOf() const;
24
+
25
+ V8_INLINE static NumberObject* Cast(Value* value) {
26
+ #ifdef V8_ENABLE_CHECKS
27
+ CheckCast(value);
28
+ #endif
29
+ return static_cast<NumberObject*>(value);
30
+ }
31
+
32
+ private:
33
+ static void CheckCast(Value* obj);
34
+ };
35
+
36
+ /**
37
+ * A BigInt object (https://tc39.github.io/proposal-bigint)
38
+ */
39
+ class V8_EXPORT BigIntObject : public Object {
40
+ public:
41
+ static Local<Value> New(Isolate* isolate, int64_t value);
42
+
43
+ Local<BigInt> ValueOf() const;
44
+
45
+ V8_INLINE static BigIntObject* Cast(Value* value) {
46
+ #ifdef V8_ENABLE_CHECKS
47
+ CheckCast(value);
48
+ #endif
49
+ return static_cast<BigIntObject*>(value);
50
+ }
51
+
52
+ private:
53
+ static void CheckCast(Value* obj);
54
+ };
55
+
56
+ /**
57
+ * A Boolean object (ECMA-262, 4.3.15).
58
+ */
59
+ class V8_EXPORT BooleanObject : public Object {
60
+ public:
61
+ static Local<Value> New(Isolate* isolate, bool value);
62
+
63
+ bool ValueOf() const;
64
+
65
+ V8_INLINE static BooleanObject* Cast(Value* value) {
66
+ #ifdef V8_ENABLE_CHECKS
67
+ CheckCast(value);
68
+ #endif
69
+ return static_cast<BooleanObject*>(value);
70
+ }
71
+
72
+ private:
73
+ static void CheckCast(Value* obj);
74
+ };
75
+
76
+ /**
77
+ * A String object (ECMA-262, 4.3.18).
78
+ */
79
+ class V8_EXPORT StringObject : public Object {
80
+ public:
81
+ static Local<Value> New(Isolate* isolate, Local<String> value);
82
+
83
+ Local<String> ValueOf() const;
84
+
85
+ V8_INLINE static StringObject* Cast(Value* value) {
86
+ #ifdef V8_ENABLE_CHECKS
87
+ CheckCast(value);
88
+ #endif
89
+ return static_cast<StringObject*>(value);
90
+ }
91
+
92
+ private:
93
+ static void CheckCast(Value* obj);
94
+ };
95
+
96
+ /**
97
+ * A Symbol object (ECMA-262 edition 6).
98
+ */
99
+ class V8_EXPORT SymbolObject : public Object {
100
+ public:
101
+ static Local<Value> New(Isolate* isolate, Local<Symbol> value);
102
+
103
+ Local<Symbol> ValueOf() const;
104
+
105
+ V8_INLINE static SymbolObject* Cast(Value* value) {
106
+ #ifdef V8_ENABLE_CHECKS
107
+ CheckCast(value);
108
+ #endif
109
+ return static_cast<SymbolObject*>(value);
110
+ }
111
+
112
+ private:
113
+ static void CheckCast(Value* obj);
114
+ };
115
+
116
+ } // namespace v8
117
+
118
+ #endif // INCLUDE_V8_PRIMITIVE_OBJECT_H_