libv8-node 18.19.1.0-arm64-darwin → 19.9.0.0-arm64-darwin
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.
- checksums.yaml +4 -4
- data/lib/libv8/node/version.rb +3 -3
- data/vendor/v8/arm64-darwin/libv8/obj/libv8_monolith.a +0 -0
- data/vendor/v8/include/cppgc/common.h +0 -1
- data/vendor/v8/include/cppgc/cross-thread-persistent.h +7 -8
- data/vendor/v8/include/cppgc/heap-consistency.h +46 -3
- data/vendor/v8/include/cppgc/heap-handle.h +43 -0
- data/vendor/v8/include/cppgc/heap-statistics.h +2 -2
- data/vendor/v8/include/cppgc/heap.h +3 -7
- data/vendor/v8/include/cppgc/internal/api-constants.h +11 -1
- data/vendor/v8/include/cppgc/internal/base-page-handle.h +45 -0
- data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +40 -8
- data/vendor/v8/include/cppgc/internal/caged-heap.h +61 -0
- data/vendor/v8/include/cppgc/internal/gc-info.h +0 -1
- data/vendor/v8/include/cppgc/internal/member-storage.h +236 -0
- data/vendor/v8/include/cppgc/internal/name-trait.h +21 -6
- data/vendor/v8/include/cppgc/internal/persistent-node.h +11 -13
- data/vendor/v8/include/cppgc/internal/pointer-policies.h +28 -7
- data/vendor/v8/include/cppgc/internal/write-barrier.h +143 -101
- data/vendor/v8/include/cppgc/liveness-broker.h +8 -7
- data/vendor/v8/include/cppgc/member.h +364 -89
- data/vendor/v8/include/cppgc/name-provider.h +4 -4
- data/vendor/v8/include/cppgc/persistent.h +5 -9
- data/vendor/v8/include/cppgc/platform.h +2 -2
- data/vendor/v8/include/cppgc/sentinel-pointer.h +1 -1
- data/vendor/v8/include/cppgc/trace-trait.h +4 -0
- data/vendor/v8/include/cppgc/type-traits.h +9 -0
- data/vendor/v8/include/cppgc/visitor.h +89 -57
- data/vendor/v8/include/v8-callbacks.h +19 -5
- data/vendor/v8/include/v8-context.h +13 -8
- data/vendor/v8/include/v8-cppgc.h +12 -0
- data/vendor/v8/include/v8-date.h +5 -0
- data/vendor/v8/include/v8-embedder-heap.h +8 -3
- data/vendor/v8/include/v8-exception.h +1 -1
- data/vendor/v8/include/v8-fast-api-calls.h +46 -32
- data/vendor/v8/include/v8-function.h +8 -0
- data/vendor/v8/include/v8-initialization.h +23 -49
- data/vendor/v8/include/v8-inspector.h +13 -7
- data/vendor/v8/include/v8-internal.h +328 -123
- data/vendor/v8/include/v8-isolate.h +27 -42
- data/vendor/v8/include/v8-local-handle.h +5 -5
- data/vendor/v8/include/v8-locker.h +0 -11
- data/vendor/v8/include/v8-maybe.h +24 -1
- data/vendor/v8/include/v8-message.h +2 -4
- data/vendor/v8/include/v8-metrics.h +20 -38
- data/vendor/v8/include/v8-microtask-queue.h +1 -1
- data/vendor/v8/include/v8-object.h +8 -15
- data/vendor/v8/include/v8-persistent-handle.h +0 -2
- data/vendor/v8/include/v8-platform.h +54 -25
- data/vendor/v8/include/v8-primitive.h +8 -8
- data/vendor/v8/include/v8-profiler.h +84 -22
- data/vendor/v8/include/v8-regexp.h +2 -1
- data/vendor/v8/include/v8-script.h +62 -6
- data/vendor/v8/include/v8-template.h +13 -76
- data/vendor/v8/include/v8-unwinder-state.h +4 -4
- data/vendor/v8/include/v8-util.h +2 -4
- data/vendor/v8/include/v8-value-serializer.h +46 -23
- data/vendor/v8/include/v8-version.h +3 -3
- data/vendor/v8/include/v8-wasm.h +5 -62
- data/vendor/v8/include/v8-weak-callback-info.h +0 -7
- data/vendor/v8/include/v8config.h +280 -13
- metadata +7 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 99bd3e56beaa9208feb5c3c6a05d535cd6bf96d32843ba81e07f5c8741d9752f
         | 
| 4 | 
            +
              data.tar.gz: 6dbec573960a44c65e711a2f9fd7f8e417b8c4a09cb7e773d500e22c7a607007
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 86134b99155bcb5639d843834311b0fc3f60ac6637bd4d279d3095587446a832dab1a25b193991cdf6d2172e16c62e5b273c0d7e8a2d1219614637b806fa6544
         | 
| 7 | 
            +
              data.tar.gz: 4ddd1dddf93b4d69ffac915a024c15568063c9293c08140a0eaac6a5be940b715934108b621bcbf2c3edf9a4c00c0aef17d80af8cb25c4a282d16f685ddd68fb
         | 
    
        data/lib/libv8/node/version.rb
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            module Libv8; end
         | 
| 2 2 |  | 
| 3 3 | 
             
            module Libv8::Node
         | 
| 4 | 
            -
              VERSION = ' | 
| 5 | 
            -
              NODE_VERSION = ' | 
| 6 | 
            -
              LIBV8_VERSION = '10. | 
| 4 | 
            +
              VERSION = '19.9.0.0'.freeze
         | 
| 5 | 
            +
              NODE_VERSION = '19.9.0'.freeze
         | 
| 6 | 
            +
              LIBV8_VERSION = '10.8.168.25'.freeze # from v8/include/v8-version.h
         | 
| 7 7 | 
             
            end
         | 
| Binary file | 
| @@ -120,7 +120,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase, | |
| 120 120 | 
             
                if (!IsValid(raw)) return;
         | 
| 121 121 | 
             
                PersistentRegionLock guard;
         | 
| 122 122 | 
             
                CrossThreadPersistentRegion& region = this->GetPersistentRegion(raw);
         | 
| 123 | 
            -
                SetNode(region.AllocateNode(this, & | 
| 123 | 
            +
                SetNode(region.AllocateNode(this, &TraceAsRoot));
         | 
| 124 124 | 
             
                this->CheckPointer(raw);
         | 
| 125 125 | 
             
              }
         | 
| 126 126 |  | 
| @@ -138,7 +138,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase, | |
| 138 138 | 
             
                  : CrossThreadPersistentBase(raw), LocationPolicy(loc) {
         | 
| 139 139 | 
             
                if (!IsValid(raw)) return;
         | 
| 140 140 | 
             
                CrossThreadPersistentRegion& region = this->GetPersistentRegion(raw);
         | 
| 141 | 
            -
                SetNode(region.AllocateNode(this, & | 
| 141 | 
            +
                SetNode(region.AllocateNode(this, &TraceAsRoot));
         | 
| 142 142 | 
             
                this->CheckPointer(raw);
         | 
| 143 143 | 
             
              }
         | 
| 144 144 |  | 
| @@ -349,9 +349,8 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase, | |
| 349 349 | 
             
                return ptr && ptr != kSentinelPointer;
         | 
| 350 350 | 
             
              }
         | 
| 351 351 |  | 
| 352 | 
            -
              static void  | 
| 353 | 
            -
                 | 
| 354 | 
            -
                v->TraceRoot(*handle, handle->Location());
         | 
| 352 | 
            +
              static void TraceAsRoot(RootVisitor& root_visitor, const void* ptr) {
         | 
| 353 | 
            +
                root_visitor.Trace(*static_cast<const BasicCrossThreadPersistent*>(ptr));
         | 
| 355 354 | 
             
              }
         | 
| 356 355 |  | 
| 357 356 | 
             
              void AssignUnsafe(T* ptr) {
         | 
| @@ -378,7 +377,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase, | |
| 378 377 | 
             
                SetValue(ptr);
         | 
| 379 378 | 
             
                if (!IsValid(ptr)) return;
         | 
| 380 379 | 
             
                PersistentRegionLock guard;
         | 
| 381 | 
            -
                SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, & | 
| 380 | 
            +
                SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, &TraceAsRoot));
         | 
| 382 381 | 
             
                this->CheckPointer(ptr);
         | 
| 383 382 | 
             
              }
         | 
| 384 383 |  | 
| @@ -398,7 +397,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase, | |
| 398 397 | 
             
                }
         | 
| 399 398 | 
             
                SetValue(ptr);
         | 
| 400 399 | 
             
                if (!IsValid(ptr)) return;
         | 
| 401 | 
            -
                SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, & | 
| 400 | 
            +
                SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, &TraceAsRoot));
         | 
| 402 401 | 
             
                this->CheckPointer(ptr);
         | 
| 403 402 | 
             
              }
         | 
| 404 403 |  | 
| @@ -416,7 +415,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase, | |
| 416 415 | 
             
                return static_cast<T*>(const_cast<void*>(GetValueFromGC()));
         | 
| 417 416 | 
             
              }
         | 
| 418 417 |  | 
| 419 | 
            -
              friend class  | 
| 418 | 
            +
              friend class internal::RootVisitor;
         | 
| 420 419 | 
             
            };
         | 
| 421 420 |  | 
| 422 421 | 
             
            template <typename T, typename LocationPolicy, typename CheckingPolicy>
         | 
| @@ -9,6 +9,7 @@ | |
| 9 9 |  | 
| 10 10 | 
             
            #include "cppgc/internal/write-barrier.h"
         | 
| 11 11 | 
             
            #include "cppgc/macros.h"
         | 
| 12 | 
            +
            #include "cppgc/member.h"
         | 
| 12 13 | 
             
            #include "cppgc/trace-trait.h"
         | 
| 13 14 | 
             
            #include "v8config.h"  // NOLINT(build/include_directory)
         | 
| 14 15 |  | 
| @@ -47,6 +48,29 @@ class HeapConsistency final { | |
| 47 48 | 
             
                return internal::WriteBarrier::GetWriteBarrierType(slot, value, params);
         | 
| 48 49 | 
             
              }
         | 
| 49 50 |  | 
| 51 | 
            +
              /**
         | 
| 52 | 
            +
               * Gets the required write barrier type for a specific write. This override is
         | 
| 53 | 
            +
               * only used for all the BasicMember types.
         | 
| 54 | 
            +
               *
         | 
| 55 | 
            +
               * \param slot Slot containing the pointer to the object. The slot itself
         | 
| 56 | 
            +
               *   must reside in an object that has been allocated using
         | 
| 57 | 
            +
               *   `MakeGarbageCollected()`.
         | 
| 58 | 
            +
               * \param value The pointer to the object held via `BasicMember`.
         | 
| 59 | 
            +
               * \param params Parameters that may be used for actual write barrier calls.
         | 
| 60 | 
            +
               *   Only filled if return value indicates that a write barrier is needed. The
         | 
| 61 | 
            +
               *   contents of the `params` are an implementation detail.
         | 
| 62 | 
            +
               * \returns whether a write barrier is needed and which barrier to invoke.
         | 
| 63 | 
            +
               */
         | 
| 64 | 
            +
              template <typename T, typename WeaknessTag, typename WriteBarrierPolicy,
         | 
| 65 | 
            +
                        typename CheckingPolicy>
         | 
| 66 | 
            +
              static V8_INLINE WriteBarrierType GetWriteBarrierType(
         | 
| 67 | 
            +
                  const internal::BasicMember<T, WeaknessTag, WriteBarrierPolicy,
         | 
| 68 | 
            +
                                              CheckingPolicy>& value,
         | 
| 69 | 
            +
                  WriteBarrierParams& params) {
         | 
| 70 | 
            +
                return internal::WriteBarrier::GetWriteBarrierType(
         | 
| 71 | 
            +
                    value.GetRawSlot(), value.GetRawStorage(), params);
         | 
| 72 | 
            +
              }
         | 
| 73 | 
            +
             | 
| 50 74 | 
             
              /**
         | 
| 51 75 | 
             
               * Gets the required write barrier type for a specific write.
         | 
| 52 76 | 
             
               *
         | 
| @@ -146,7 +170,25 @@ class HeapConsistency final { | |
| 146 170 | 
             
               */
         | 
| 147 171 | 
             
              static V8_INLINE void GenerationalBarrier(const WriteBarrierParams& params,
         | 
| 148 172 | 
             
                                                        const void* slot) {
         | 
| 149 | 
            -
                internal::WriteBarrier::GenerationalBarrier | 
| 173 | 
            +
                internal::WriteBarrier::GenerationalBarrier<
         | 
| 174 | 
            +
                    internal::WriteBarrier::GenerationalBarrierType::kPreciseSlot>(params,
         | 
| 175 | 
            +
                                                                                   slot);
         | 
| 176 | 
            +
              }
         | 
| 177 | 
            +
             | 
| 178 | 
            +
              /**
         | 
| 179 | 
            +
               * Generational barrier for maintaining consistency when running with multiple
         | 
| 180 | 
            +
               * generations. This version is used when slot contains uncompressed pointer.
         | 
| 181 | 
            +
               *
         | 
| 182 | 
            +
               * \param params The parameters retrieved from `GetWriteBarrierType()`.
         | 
| 183 | 
            +
               * \param slot Uncompressed slot containing the direct pointer to the object.
         | 
| 184 | 
            +
               * The slot itself must reside in an object that has been allocated using
         | 
| 185 | 
            +
               *   `MakeGarbageCollected()`.
         | 
| 186 | 
            +
               */
         | 
| 187 | 
            +
              static V8_INLINE void GenerationalBarrierForUncompressedSlot(
         | 
| 188 | 
            +
                  const WriteBarrierParams& params, const void* uncompressed_slot) {
         | 
| 189 | 
            +
                internal::WriteBarrier::GenerationalBarrier<
         | 
| 190 | 
            +
                    internal::WriteBarrier::GenerationalBarrierType::
         | 
| 191 | 
            +
                        kPreciseUncompressedSlot>(params, uncompressed_slot);
         | 
| 150 192 | 
             
              }
         | 
| 151 193 |  | 
| 152 194 | 
             
              /**
         | 
| @@ -158,8 +200,9 @@ class HeapConsistency final { | |
| 158 200 | 
             
               */
         | 
| 159 201 | 
             
              static V8_INLINE void GenerationalBarrierForSourceObject(
         | 
| 160 202 | 
             
                  const WriteBarrierParams& params, const void* inner_pointer) {
         | 
| 161 | 
            -
                internal::WriteBarrier:: | 
| 162 | 
            -
             | 
| 203 | 
            +
                internal::WriteBarrier::GenerationalBarrier<
         | 
| 204 | 
            +
                    internal::WriteBarrier::GenerationalBarrierType::kImpreciseSlot>(
         | 
| 205 | 
            +
                    params, inner_pointer);
         | 
| 163 206 | 
             
              }
         | 
| 164 207 |  | 
| 165 208 | 
             
             private:
         | 
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            // Copyright 2022 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_CPPGC_HEAP_HANDLE_H_
         | 
| 6 | 
            +
            #define INCLUDE_CPPGC_HEAP_HANDLE_H_
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            #include "v8config.h"  // NOLINT(build/include_directory)
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            namespace cppgc {
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            namespace internal {
         | 
| 13 | 
            +
            class HeapBase;
         | 
| 14 | 
            +
            class WriteBarrierTypeForCagedHeapPolicy;
         | 
| 15 | 
            +
            class WriteBarrierTypeForNonCagedHeapPolicy;
         | 
| 16 | 
            +
            }  // namespace internal
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            /**
         | 
| 19 | 
            +
             * Opaque handle used for additional heap APIs.
         | 
| 20 | 
            +
             */
         | 
| 21 | 
            +
            class HeapHandle {
         | 
| 22 | 
            +
             private:
         | 
| 23 | 
            +
              HeapHandle() = default;
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              V8_INLINE bool is_incremental_marking_in_progress() const {
         | 
| 26 | 
            +
                return is_incremental_marking_in_progress_;
         | 
| 27 | 
            +
              }
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              V8_INLINE bool is_young_generation_enabled() const {
         | 
| 30 | 
            +
                return is_young_generation_enabled_;
         | 
| 31 | 
            +
              }
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              bool is_incremental_marking_in_progress_ = false;
         | 
| 34 | 
            +
              bool is_young_generation_enabled_ = false;
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              friend class internal::HeapBase;
         | 
| 37 | 
            +
              friend class internal::WriteBarrierTypeForCagedHeapPolicy;
         | 
| 38 | 
            +
              friend class internal::WriteBarrierTypeForNonCagedHeapPolicy;
         | 
| 39 | 
            +
            };
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            }  // namespace cppgc
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            #endif  // INCLUDE_CPPGC_HEAP_HANDLE_H_
         | 
| @@ -56,7 +56,7 @@ struct HeapStatistics final { | |
| 56 56 | 
             
                /** Amount of memory actually used on the page. */
         | 
| 57 57 | 
             
                size_t used_size_bytes = 0;
         | 
| 58 58 | 
             
                /** Statistics for object allocated on the page. Filled only when
         | 
| 59 | 
            -
                 * NameProvider:: | 
| 59 | 
            +
                 * NameProvider::SupportsCppClassNamesAsObjectNames() is true. */
         | 
| 60 60 | 
             
                std::vector<ObjectStatsEntry> object_statistics;
         | 
| 61 61 | 
             
              };
         | 
| 62 62 |  | 
| @@ -98,7 +98,7 @@ struct HeapStatistics final { | |
| 98 98 |  | 
| 99 99 | 
             
              /** Overall committed amount of memory for the heap. */
         | 
| 100 100 | 
             
              size_t committed_size_bytes = 0;
         | 
| 101 | 
            -
              /** Resident amount of memory  | 
| 101 | 
            +
              /** Resident amount of memory held by the heap. */
         | 
| 102 102 | 
             
              size_t resident_size_bytes = 0;
         | 
| 103 103 | 
             
              /** Amount of memory actually used on the heap. */
         | 
| 104 104 | 
             
              size_t used_size_bytes = 0;
         | 
| @@ -21,6 +21,7 @@ | |
| 21 21 | 
             
            namespace cppgc {
         | 
| 22 22 |  | 
| 23 23 | 
             
            class AllocationHandle;
         | 
| 24 | 
            +
            class HeapHandle;
         | 
| 24 25 |  | 
| 25 26 | 
             
            /**
         | 
| 26 27 | 
             
             * Implementation details of cppgc. Those details are considered internal and
         | 
| @@ -31,11 +32,6 @@ namespace internal { | |
| 31 32 | 
             
            class Heap;
         | 
| 32 33 | 
             
            }  // namespace internal
         | 
| 33 34 |  | 
| 34 | 
            -
            /**
         | 
| 35 | 
            -
             * Used for additional heap APIs.
         | 
| 36 | 
            -
             */
         | 
| 37 | 
            -
            class HeapHandle;
         | 
| 38 | 
            -
             | 
| 39 35 | 
             
            class V8_EXPORT Heap {
         | 
| 40 36 | 
             
             public:
         | 
| 41 37 | 
             
              /**
         | 
| @@ -59,7 +55,7 @@ class V8_EXPORT Heap { | |
| 59 55 | 
             
              };
         | 
| 60 56 |  | 
| 61 57 | 
             
              /**
         | 
| 62 | 
            -
               * Specifies supported marking types
         | 
| 58 | 
            +
               * Specifies supported marking types.
         | 
| 63 59 | 
             
               */
         | 
| 64 60 | 
             
              enum class MarkingType : uint8_t {
         | 
| 65 61 | 
             
                /**
         | 
| @@ -79,7 +75,7 @@ class V8_EXPORT Heap { | |
| 79 75 | 
             
              };
         | 
| 80 76 |  | 
| 81 77 | 
             
              /**
         | 
| 82 | 
            -
               * Specifies supported sweeping types
         | 
| 78 | 
            +
               * Specifies supported sweeping types.
         | 
| 83 79 | 
             
               */
         | 
| 84 80 | 
             
              enum class SweepingType : uint8_t {
         | 
| 85 81 | 
             
                /**
         | 
| @@ -32,12 +32,22 @@ static constexpr uint16_t kFullyConstructedBitMask = uint16_t{1}; | |
| 32 32 |  | 
| 33 33 | 
             
            static constexpr size_t kPageSize = size_t{1} << 17;
         | 
| 34 34 |  | 
| 35 | 
            +
            #if defined(V8_TARGET_ARCH_ARM64) && defined(V8_OS_MACOS)
         | 
| 36 | 
            +
            constexpr size_t kGuardPageSize = 0;
         | 
| 37 | 
            +
            #else
         | 
| 38 | 
            +
            constexpr size_t kGuardPageSize = 4096;
         | 
| 39 | 
            +
            #endif
         | 
| 40 | 
            +
             | 
| 35 41 | 
             
            static constexpr size_t kLargeObjectSizeThreshold = kPageSize / 2;
         | 
| 36 42 |  | 
| 37 43 | 
             
            #if defined(CPPGC_CAGED_HEAP)
         | 
| 44 | 
            +
            #if defined(CPPGC_2GB_CAGE)
         | 
| 45 | 
            +
            constexpr size_t kCagedHeapReservationSize = static_cast<size_t>(2) * kGB;
         | 
| 46 | 
            +
            #else   // !defined(CPPGC_2GB_CAGE)
         | 
| 38 47 | 
             
            constexpr size_t kCagedHeapReservationSize = static_cast<size_t>(4) * kGB;
         | 
| 48 | 
            +
            #endif  // !defined(CPPGC_2GB_CAGE)
         | 
| 39 49 | 
             
            constexpr size_t kCagedHeapReservationAlignment = kCagedHeapReservationSize;
         | 
| 40 | 
            -
            #endif
         | 
| 50 | 
            +
            #endif  // defined(CPPGC_CAGED_HEAP)
         | 
| 41 51 |  | 
| 42 52 | 
             
            static constexpr size_t kDefaultAlignment = sizeof(void*);
         | 
| 43 53 |  | 
| @@ -0,0 +1,45 @@ | |
| 1 | 
            +
            // Copyright 2022 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_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
         | 
| 6 | 
            +
            #define INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            #include "cppgc/heap-handle.h"
         | 
| 9 | 
            +
            #include "cppgc/internal/api-constants.h"
         | 
| 10 | 
            +
            #include "cppgc/internal/logging.h"
         | 
| 11 | 
            +
            #include "v8config.h"  // NOLINT(build/include_directory)
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            namespace cppgc {
         | 
| 14 | 
            +
            namespace internal {
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            // The class is needed in the header to allow for fast access to HeapHandle in
         | 
| 17 | 
            +
            // the write barrier.
         | 
| 18 | 
            +
            class BasePageHandle {
         | 
| 19 | 
            +
             public:
         | 
| 20 | 
            +
              static V8_INLINE BasePageHandle* FromPayload(void* payload) {
         | 
| 21 | 
            +
                return reinterpret_cast<BasePageHandle*>(
         | 
| 22 | 
            +
                    (reinterpret_cast<uintptr_t>(payload) &
         | 
| 23 | 
            +
                     ~(api_constants::kPageSize - 1)) +
         | 
| 24 | 
            +
                    api_constants::kGuardPageSize);
         | 
| 25 | 
            +
              }
         | 
| 26 | 
            +
              static V8_INLINE const BasePageHandle* FromPayload(const void* payload) {
         | 
| 27 | 
            +
                return FromPayload(const_cast<void*>(payload));
         | 
| 28 | 
            +
              }
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              HeapHandle& heap_handle() { return heap_handle_; }
         | 
| 31 | 
            +
              const HeapHandle& heap_handle() const { return heap_handle_; }
         | 
| 32 | 
            +
             | 
| 33 | 
            +
             protected:
         | 
| 34 | 
            +
              explicit BasePageHandle(HeapHandle& heap_handle) : heap_handle_(heap_handle) {
         | 
| 35 | 
            +
                CPPGC_DCHECK(reinterpret_cast<uintptr_t>(this) % api_constants::kPageSize ==
         | 
| 36 | 
            +
                             api_constants::kGuardPageSize);
         | 
| 37 | 
            +
              }
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              HeapHandle& heap_handle_;
         | 
| 40 | 
            +
            };
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            }  // namespace internal
         | 
| 43 | 
            +
            }  // namespace cppgc
         | 
| 44 | 
            +
             | 
| 45 | 
            +
            #endif  // INCLUDE_CPPGC_INTERNAL_BASE_PAGE_HANDLE_H_
         | 
| @@ -10,46 +10,76 @@ | |
| 10 10 | 
             
            #include <cstdint>
         | 
| 11 11 |  | 
| 12 12 | 
             
            #include "cppgc/internal/api-constants.h"
         | 
| 13 | 
            +
            #include "cppgc/internal/caged-heap.h"
         | 
| 13 14 | 
             
            #include "cppgc/internal/logging.h"
         | 
| 14 15 | 
             
            #include "cppgc/platform.h"
         | 
| 15 16 | 
             
            #include "v8config.h"  // NOLINT(build/include_directory)
         | 
| 16 17 |  | 
| 18 | 
            +
            #if __cpp_lib_bitopts
         | 
| 19 | 
            +
            #include <bit>
         | 
| 20 | 
            +
            #endif  // __cpp_lib_bitopts
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            #if defined(CPPGC_CAGED_HEAP)
         | 
| 23 | 
            +
             | 
| 17 24 | 
             
            namespace cppgc {
         | 
| 18 25 | 
             
            namespace internal {
         | 
| 19 26 |  | 
| 20 27 | 
             
            class HeapBase;
         | 
| 28 | 
            +
            class HeapBaseHandle;
         | 
| 21 29 |  | 
| 22 30 | 
             
            #if defined(CPPGC_YOUNG_GENERATION)
         | 
| 23 31 |  | 
| 24 32 | 
             
            // AgeTable is the bytemap needed for the fast generation check in the write
         | 
| 25 | 
            -
            // barrier. AgeTable contains entries that correspond to  | 
| 33 | 
            +
            // barrier. AgeTable contains entries that correspond to 4096 bytes memory
         | 
| 26 34 | 
             
            // regions (cards). Each entry in the table represents generation of the objects
         | 
| 27 35 | 
             
            // that reside on the corresponding card (young, old or mixed).
         | 
| 28 | 
            -
            class AgeTable final {
         | 
| 36 | 
            +
            class V8_EXPORT AgeTable final {
         | 
| 29 37 | 
             
              static constexpr size_t kRequiredSize = 1 * api_constants::kMB;
         | 
| 30 38 | 
             
              static constexpr size_t kAllocationGranularity =
         | 
| 31 39 | 
             
                  api_constants::kAllocationGranularity;
         | 
| 32 40 |  | 
| 33 41 | 
             
             public:
         | 
| 42 | 
            +
              // Represents age of the objects living on a single card.
         | 
| 34 43 | 
             
              enum class Age : uint8_t { kOld, kYoung, kMixed };
         | 
| 44 | 
            +
              // When setting age for a range, consider or ignore ages of the adjacent
         | 
| 45 | 
            +
              // cards.
         | 
| 46 | 
            +
              enum class AdjacentCardsPolicy : uint8_t { kConsider, kIgnore };
         | 
| 35 47 |  | 
| 36 48 | 
             
              static constexpr size_t kCardSizeInBytes =
         | 
| 37 | 
            -
                   | 
| 38 | 
            -
                  kRequiredSize;
         | 
| 49 | 
            +
                  api_constants::kCagedHeapReservationSize / kRequiredSize;
         | 
| 39 50 |  | 
| 40 51 | 
             
              void SetAge(uintptr_t cage_offset, Age age) {
         | 
| 41 52 | 
             
                table_[card(cage_offset)] = age;
         | 
| 42 53 | 
             
              }
         | 
| 54 | 
            +
             | 
| 43 55 | 
             
              V8_INLINE Age GetAge(uintptr_t cage_offset) const {
         | 
| 44 56 | 
             
                return table_[card(cage_offset)];
         | 
| 45 57 | 
             
              }
         | 
| 46 58 |  | 
| 47 | 
            -
              void  | 
| 59 | 
            +
              void SetAgeForRange(uintptr_t cage_offset_begin, uintptr_t cage_offset_end,
         | 
| 60 | 
            +
                                  Age age, AdjacentCardsPolicy adjacent_cards_policy);
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              Age GetAgeForRange(uintptr_t cage_offset_begin,
         | 
| 63 | 
            +
                                 uintptr_t cage_offset_end) const;
         | 
| 64 | 
            +
             | 
| 65 | 
            +
              void ResetForTesting();
         | 
| 48 66 |  | 
| 49 67 | 
             
             private:
         | 
| 50 68 | 
             
              V8_INLINE size_t card(uintptr_t offset) const {
         | 
| 51 69 | 
             
                constexpr size_t kGranularityBits =
         | 
| 70 | 
            +
            #if __cpp_lib_bitopts
         | 
| 71 | 
            +
                    std::countr_zero(static_cast<uint32_t>(kCardSizeInBytes));
         | 
| 72 | 
            +
            #elif V8_HAS_BUILTIN_CTZ
         | 
| 52 73 | 
             
                    __builtin_ctz(static_cast<uint32_t>(kCardSizeInBytes));
         | 
| 74 | 
            +
            #else   //! V8_HAS_BUILTIN_CTZ
         | 
| 75 | 
            +
                    // Hardcode and check with assert.
         | 
| 76 | 
            +
            #if defined(CPPGC_2GB_CAGE)
         | 
| 77 | 
            +
                    11;
         | 
| 78 | 
            +
            #else   // !defined(CPPGC_2GB_CAGE)
         | 
| 79 | 
            +
                    12;
         | 
| 80 | 
            +
            #endif  // !defined(CPPGC_2GB_CAGE)
         | 
| 81 | 
            +
            #endif  // !V8_HAS_BUILTIN_CTZ
         | 
| 82 | 
            +
                static_assert((1 << kGranularityBits) == kCardSizeInBytes);
         | 
| 53 83 | 
             
                const size_t entry = offset >> kGranularityBits;
         | 
| 54 84 | 
             
                CPPGC_DCHECK(table_.size() > entry);
         | 
| 55 85 | 
             
                return entry;
         | 
| @@ -64,10 +94,10 @@ static_assert(sizeof(AgeTable) == 1 * api_constants::kMB, | |
| 64 94 | 
             
            #endif  // CPPGC_YOUNG_GENERATION
         | 
| 65 95 |  | 
| 66 96 | 
             
            struct CagedHeapLocalData final {
         | 
| 67 | 
            -
              CagedHeapLocalData( | 
| 97 | 
            +
              V8_INLINE static CagedHeapLocalData& Get() {
         | 
| 98 | 
            +
                return *reinterpret_cast<CagedHeapLocalData*>(CagedHeapBase::GetBase());
         | 
| 99 | 
            +
              }
         | 
| 68 100 |  | 
| 69 | 
            -
              bool is_incremental_marking_in_progress = false;
         | 
| 70 | 
            -
              HeapBase& heap_base;
         | 
| 71 101 | 
             
            #if defined(CPPGC_YOUNG_GENERATION)
         | 
| 72 102 | 
             
              AgeTable age_table;
         | 
| 73 103 | 
             
            #endif
         | 
| @@ -76,4 +106,6 @@ struct CagedHeapLocalData final { | |
| 76 106 | 
             
            }  // namespace internal
         | 
| 77 107 | 
             
            }  // namespace cppgc
         | 
| 78 108 |  | 
| 109 | 
            +
            #endif  // defined(CPPGC_CAGED_HEAP)
         | 
| 110 | 
            +
             | 
| 79 111 | 
             
            #endif  // INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_LOCAL_DATA_H_
         | 
| @@ -0,0 +1,61 @@ | |
| 1 | 
            +
            // Copyright 2022 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_CPPGC_INTERNAL_CAGED_HEAP_H_
         | 
| 6 | 
            +
            #define INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_H_
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            #include <climits>
         | 
| 9 | 
            +
            #include <cstddef>
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            #include "cppgc/internal/api-constants.h"
         | 
| 12 | 
            +
            #include "cppgc/internal/base-page-handle.h"
         | 
| 13 | 
            +
            #include "v8config.h"  // NOLINT(build/include_directory)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            #if defined(CPPGC_CAGED_HEAP)
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            namespace cppgc {
         | 
| 18 | 
            +
            namespace internal {
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            class V8_EXPORT CagedHeapBase {
         | 
| 21 | 
            +
             public:
         | 
| 22 | 
            +
              V8_INLINE static uintptr_t OffsetFromAddress(const void* address) {
         | 
| 23 | 
            +
                return reinterpret_cast<uintptr_t>(address) &
         | 
| 24 | 
            +
                       (api_constants::kCagedHeapReservationAlignment - 1);
         | 
| 25 | 
            +
              }
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              V8_INLINE static bool IsWithinCage(const void* address) {
         | 
| 28 | 
            +
                CPPGC_DCHECK(g_heap_base_);
         | 
| 29 | 
            +
                return (reinterpret_cast<uintptr_t>(address) &
         | 
| 30 | 
            +
                        ~(api_constants::kCagedHeapReservationAlignment - 1)) ==
         | 
| 31 | 
            +
                       g_heap_base_;
         | 
| 32 | 
            +
              }
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              V8_INLINE static bool AreWithinCage(const void* addr1, const void* addr2) {
         | 
| 35 | 
            +
            #if defined(CPPGC_2GB_CAGE)
         | 
| 36 | 
            +
                static constexpr size_t kHalfWordShift = sizeof(uint32_t) * CHAR_BIT - 1;
         | 
| 37 | 
            +
            #else   //! defined(CPPGC_2GB_CAGE)
         | 
| 38 | 
            +
                static constexpr size_t kHalfWordShift = sizeof(uint32_t) * CHAR_BIT;
         | 
| 39 | 
            +
            #endif  //! defined(CPPGC_2GB_CAGE)
         | 
| 40 | 
            +
                static_assert((static_cast<size_t>(1) << kHalfWordShift) ==
         | 
| 41 | 
            +
                              api_constants::kCagedHeapReservationSize);
         | 
| 42 | 
            +
                CPPGC_DCHECK(g_heap_base_);
         | 
| 43 | 
            +
                return !(((reinterpret_cast<uintptr_t>(addr1) ^ g_heap_base_) |
         | 
| 44 | 
            +
                          (reinterpret_cast<uintptr_t>(addr2) ^ g_heap_base_)) >>
         | 
| 45 | 
            +
                         kHalfWordShift);
         | 
| 46 | 
            +
              }
         | 
| 47 | 
            +
             | 
| 48 | 
            +
              V8_INLINE static uintptr_t GetBase() { return g_heap_base_; }
         | 
| 49 | 
            +
             | 
| 50 | 
            +
             private:
         | 
| 51 | 
            +
              friend class CagedHeap;
         | 
| 52 | 
            +
             | 
| 53 | 
            +
              static uintptr_t g_heap_base_;
         | 
| 54 | 
            +
            };
         | 
| 55 | 
            +
             | 
| 56 | 
            +
            }  // namespace internal
         | 
| 57 | 
            +
            }  // namespace cppgc
         | 
| 58 | 
            +
             | 
| 59 | 
            +
            #endif  // defined(CPPGC_CAGED_HEAP)
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            #endif  // INCLUDE_CPPGC_INTERNAL_CAGED_HEAP_H_
         | 
| @@ -48,7 +48,6 @@ struct V8_EXPORT EnsureGCInfoIndexTrait final { | |
| 48 48 | 
             
              static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
         | 
| 49 49 | 
             
                                                                 TraceCallback,
         | 
| 50 50 | 
             
                                                                 FinalizationCallback,
         | 
| 51 | 
            -
             | 
| 52 51 | 
             
                                                                 NameCallback);
         | 
| 53 52 | 
             
              static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
         | 
| 54 53 | 
             
                                                                 TraceCallback,
         |