libv8-node 16.10.0.0-x86_64-darwin → 18.8.0.0-x86_64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8-node/paths.rb +1 -1
  3. data/lib/libv8/node/version.rb +3 -3
  4. data/vendor/v8/include/cppgc/allocation.h +100 -22
  5. data/vendor/v8/include/cppgc/cross-thread-persistent.h +114 -33
  6. data/vendor/v8/include/cppgc/default-platform.h +2 -10
  7. data/vendor/v8/include/cppgc/explicit-management.h +22 -4
  8. data/vendor/v8/include/cppgc/garbage-collected.h +15 -26
  9. data/vendor/v8/include/cppgc/heap-consistency.h +30 -0
  10. data/vendor/v8/include/cppgc/heap-state.h +12 -0
  11. data/vendor/v8/include/cppgc/heap.h +7 -2
  12. data/vendor/v8/include/cppgc/internal/api-constants.h +8 -0
  13. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +25 -14
  14. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +4 -1
  15. data/vendor/v8/include/cppgc/internal/gc-info.h +90 -10
  16. data/vendor/v8/include/cppgc/internal/logging.h +3 -3
  17. data/vendor/v8/include/cppgc/internal/name-trait.h +11 -0
  18. data/vendor/v8/include/cppgc/internal/persistent-node.h +73 -29
  19. data/vendor/v8/include/cppgc/internal/pointer-policies.h +26 -15
  20. data/vendor/v8/include/cppgc/internal/write-barrier.h +62 -23
  21. data/vendor/v8/include/cppgc/liveness-broker.h +4 -1
  22. data/vendor/v8/include/cppgc/member.h +7 -2
  23. data/vendor/v8/include/cppgc/persistent.h +38 -33
  24. data/vendor/v8/include/cppgc/platform.h +4 -1
  25. data/vendor/v8/include/cppgc/prefinalizer.h +35 -12
  26. data/vendor/v8/include/cppgc/testing.h +9 -2
  27. data/vendor/v8/include/cppgc/type-traits.h +6 -13
  28. data/vendor/v8/include/cppgc/visitor.h +9 -7
  29. data/vendor/v8/include/libplatform/libplatform.h +0 -11
  30. data/vendor/v8/include/libplatform/v8-tracing.h +0 -1
  31. data/vendor/v8/include/v8-array-buffer.h +445 -0
  32. data/vendor/v8/include/v8-callbacks.h +397 -0
  33. data/vendor/v8/include/v8-container.h +129 -0
  34. data/vendor/v8/include/v8-context.h +407 -0
  35. data/vendor/v8/include/v8-cppgc.h +21 -128
  36. data/vendor/v8/include/v8-data.h +80 -0
  37. data/vendor/v8/include/v8-date.h +43 -0
  38. data/vendor/v8/include/v8-debug.h +168 -0
  39. data/vendor/v8/include/v8-embedder-heap.h +218 -0
  40. data/vendor/v8/include/v8-embedder-state-scope.h +51 -0
  41. data/vendor/v8/include/v8-exception.h +217 -0
  42. data/vendor/v8/include/v8-extension.h +62 -0
  43. data/vendor/v8/include/v8-external.h +37 -0
  44. data/vendor/v8/include/v8-fast-api-calls.h +172 -24
  45. data/vendor/v8/include/v8-forward.h +81 -0
  46. data/vendor/v8/include/v8-function-callback.h +475 -0
  47. data/vendor/v8/include/v8-function.h +125 -0
  48. data/vendor/v8/include/v8-initialization.h +315 -0
  49. data/vendor/v8/include/v8-inspector.h +56 -28
  50. data/vendor/v8/include/v8-internal.h +217 -55
  51. data/vendor/v8/include/v8-isolate.h +1709 -0
  52. data/vendor/v8/include/v8-json.h +47 -0
  53. data/vendor/v8/include/v8-local-handle.h +455 -0
  54. data/vendor/v8/include/v8-locker.h +149 -0
  55. data/vendor/v8/include/v8-maybe.h +137 -0
  56. data/vendor/v8/include/v8-memory-span.h +43 -0
  57. data/vendor/v8/include/v8-message.h +216 -0
  58. data/vendor/v8/include/v8-metrics.h +69 -16
  59. data/vendor/v8/include/v8-microtask-queue.h +152 -0
  60. data/vendor/v8/include/v8-microtask.h +28 -0
  61. data/vendor/v8/include/v8-object.h +775 -0
  62. data/vendor/v8/include/v8-persistent-handle.h +590 -0
  63. data/vendor/v8/include/v8-platform.h +400 -17
  64. data/vendor/v8/include/v8-primitive-object.h +118 -0
  65. data/vendor/v8/include/v8-primitive.h +866 -0
  66. data/vendor/v8/include/v8-profiler.h +88 -13
  67. data/vendor/v8/include/v8-promise.h +174 -0
  68. data/vendor/v8/include/v8-proxy.h +50 -0
  69. data/vendor/v8/include/v8-regexp.h +105 -0
  70. data/vendor/v8/include/v8-script.h +747 -0
  71. data/vendor/v8/include/v8-snapshot.h +196 -0
  72. data/vendor/v8/include/v8-statistics.h +217 -0
  73. data/vendor/v8/include/v8-template.h +1079 -0
  74. data/vendor/v8/include/v8-traced-handle.h +420 -0
  75. data/vendor/v8/include/v8-typed-array.h +282 -0
  76. data/vendor/v8/include/v8-unwinder-state.h +4 -3
  77. data/vendor/v8/include/v8-unwinder.h +132 -0
  78. data/vendor/v8/include/v8-util.h +7 -1
  79. data/vendor/v8/include/v8-value-serializer-version.h +1 -1
  80. data/vendor/v8/include/v8-value-serializer.h +279 -0
  81. data/vendor/v8/include/v8-value.h +526 -0
  82. data/vendor/v8/include/v8-version.h +4 -4
  83. data/vendor/v8/include/v8-wasm.h +257 -0
  84. data/vendor/v8/include/v8-weak-callback-info.h +87 -0
  85. data/vendor/v8/include/v8.h +41 -12601
  86. data/vendor/v8/include/v8config.h +102 -12
  87. data/vendor/v8/x86_64-darwin/libv8/obj/libv8_monolith.a +0 -0
  88. metadata +47 -5
  89. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +0 -30
@@ -181,9 +181,8 @@ class JobDelegate {
181
181
  /**
182
182
  * Returns true if the current task is called from the thread currently
183
183
  * running JobHandle::Join().
184
- * TODO(etiennep): Make pure virtual once custom embedders implement it.
185
184
  */
186
- virtual bool IsJoiningThread() const { return false; }
185
+ virtual bool IsJoiningThread() const = 0;
187
186
  };
188
187
 
189
188
  /**
@@ -220,19 +219,14 @@ class JobHandle {
220
219
  * Forces all existing workers to yield ASAP but doesn’t wait for them.
221
220
  * Warning, this is dangerous if the Job's callback is bound to or has access
222
221
  * to state which may be deleted after this call.
223
- * TODO(etiennep): Cleanup once implemented by all embedders.
224
222
  */
225
- virtual void CancelAndDetach() { Cancel(); }
223
+ virtual void CancelAndDetach() = 0;
226
224
 
227
225
  /**
228
226
  * Returns true if there's any work pending or any worker running.
229
227
  */
230
228
  virtual bool IsActive() = 0;
231
229
 
232
- // TODO(etiennep): Clean up once all overrides are removed.
233
- V8_DEPRECATED("Use !IsActive() instead.")
234
- virtual bool IsCompleted() { return !IsActive(); }
235
-
236
230
  /**
237
231
  * Returns true if associated with a Job and other methods may be called.
238
232
  * Returns false after Join() or Cancel() was called. This may return true
@@ -240,10 +234,6 @@ class JobHandle {
240
234
  */
241
235
  virtual bool IsValid() = 0;
242
236
 
243
- // TODO(etiennep): Clean up once all overrides are removed.
244
- V8_DEPRECATED("Use IsValid() instead.")
245
- virtual bool IsRunning() { return IsValid(); }
246
-
247
237
  /**
248
238
  * Returns true if job priority can be changed.
249
239
  */
@@ -272,10 +262,6 @@ class JobTask {
272
262
  * it must not call back any JobHandle methods.
273
263
  */
274
264
  virtual size_t GetMaxConcurrency(size_t worker_count) const = 0;
275
-
276
- // TODO(1114823): Clean up once all overrides are removed.
277
- V8_DEPRECATED("Use the version that takes |worker_count|.")
278
- virtual size_t GetMaxConcurrency() const { return 0; }
279
265
  };
280
266
 
281
267
  /**
@@ -415,6 +401,8 @@ class PageAllocator {
415
401
  // this is used to set the MAP_JIT flag on Apple Silicon.
416
402
  // TODO(jkummerow): Remove this when Wasm has a platform-independent
417
403
  // w^x implementation.
404
+ // TODO(saelo): Remove this once all JIT pages are allocated through the
405
+ // VirtualAddressSpace API.
418
406
  kNoAccessWillJitLater
419
407
  };
420
408
 
@@ -444,10 +432,22 @@ class PageAllocator {
444
432
  /**
445
433
  * Frees memory in the given [address, address + size) range. address and size
446
434
  * should be operating system page-aligned. The next write to this
447
- * 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.
448
438
  */
449
439
  virtual bool DiscardSystemPages(void* address, size_t size) { return true; }
450
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
+
451
451
  /**
452
452
  * INTERNAL ONLY: This interface has not been stabilised and may change
453
453
  * without notice from one release to another without being deprecated first.
@@ -512,6 +512,371 @@ class PageAllocator {
512
512
  virtual bool CanAllocateSharedPages() { return false; }
513
513
  };
514
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
+
515
880
  /**
516
881
  * V8 Platform abstraction layer.
517
882
  *
@@ -530,6 +895,14 @@ class Platform {
530
895
  return nullptr;
531
896
  }
532
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
+
533
906
  /**
534
907
  * Enables the embedder to respond in cases where V8 can't allocate large
535
908
  * blocks of memory. V8 retries the failed allocation once after calling this
@@ -695,6 +1068,16 @@ class Platform {
695
1068
  */
696
1069
  virtual void DumpWithoutCrashing() {}
697
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
+
698
1081
  protected:
699
1082
  /**
700
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_