libv8-node 18.13.0.1-aarch64-linux → 20.2.0.0-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/lib/libv8/node/version.rb +3 -3
  3. data/vendor/v8/aarch64-linux/libv8/obj/libv8_monolith.a +0 -0
  4. data/vendor/v8/include/cppgc/common.h +0 -1
  5. data/vendor/v8/include/cppgc/cross-thread-persistent.h +11 -10
  6. data/vendor/v8/include/cppgc/heap-consistency.h +46 -3
  7. data/vendor/v8/include/cppgc/heap-handle.h +48 -0
  8. data/vendor/v8/include/cppgc/heap-statistics.h +2 -2
  9. data/vendor/v8/include/cppgc/heap.h +3 -7
  10. data/vendor/v8/include/cppgc/internal/api-constants.h +14 -1
  11. data/vendor/v8/include/cppgc/internal/base-page-handle.h +45 -0
  12. data/vendor/v8/include/cppgc/internal/caged-heap-local-data.h +40 -8
  13. data/vendor/v8/include/cppgc/internal/caged-heap.h +61 -0
  14. data/vendor/v8/include/cppgc/internal/gc-info.h +35 -34
  15. data/vendor/v8/include/cppgc/internal/member-storage.h +248 -0
  16. data/vendor/v8/include/cppgc/internal/name-trait.h +21 -6
  17. data/vendor/v8/include/cppgc/internal/persistent-node.h +11 -13
  18. data/vendor/v8/include/cppgc/internal/pointer-policies.h +65 -8
  19. data/vendor/v8/include/cppgc/internal/write-barrier.h +153 -101
  20. data/vendor/v8/include/cppgc/liveness-broker.h +8 -7
  21. data/vendor/v8/include/cppgc/macros.h +10 -1
  22. data/vendor/v8/include/cppgc/member.h +424 -111
  23. data/vendor/v8/include/cppgc/name-provider.h +4 -4
  24. data/vendor/v8/include/cppgc/persistent.h +27 -24
  25. data/vendor/v8/include/cppgc/platform.h +7 -5
  26. data/vendor/v8/include/cppgc/sentinel-pointer.h +1 -1
  27. data/vendor/v8/include/cppgc/trace-trait.h +4 -0
  28. data/vendor/v8/include/cppgc/type-traits.h +13 -3
  29. data/vendor/v8/include/cppgc/visitor.h +104 -57
  30. data/vendor/v8/include/libplatform/v8-tracing.h +2 -2
  31. data/vendor/v8/include/v8-array-buffer.h +59 -0
  32. data/vendor/v8/include/v8-callbacks.h +32 -5
  33. data/vendor/v8/include/v8-context.h +63 -11
  34. data/vendor/v8/include/v8-cppgc.h +22 -0
  35. data/vendor/v8/include/v8-data.h +1 -1
  36. data/vendor/v8/include/v8-date.h +5 -0
  37. data/vendor/v8/include/v8-embedder-heap.h +0 -164
  38. data/vendor/v8/include/v8-exception.h +1 -1
  39. data/vendor/v8/include/v8-fast-api-calls.h +49 -31
  40. data/vendor/v8/include/v8-function-callback.h +69 -42
  41. data/vendor/v8/include/v8-function.h +9 -0
  42. data/vendor/v8/include/v8-initialization.h +23 -49
  43. data/vendor/v8/include/v8-inspector.h +32 -11
  44. data/vendor/v8/include/v8-internal.h +480 -183
  45. data/vendor/v8/include/v8-isolate.h +52 -77
  46. data/vendor/v8/include/v8-local-handle.h +86 -53
  47. data/vendor/v8/include/v8-locker.h +0 -11
  48. data/vendor/v8/include/v8-maybe.h +24 -1
  49. data/vendor/v8/include/v8-message.h +2 -4
  50. data/vendor/v8/include/v8-metrics.h +48 -40
  51. data/vendor/v8/include/v8-microtask-queue.h +6 -1
  52. data/vendor/v8/include/v8-object.h +29 -18
  53. data/vendor/v8/include/v8-persistent-handle.h +25 -18
  54. data/vendor/v8/include/v8-platform.h +133 -35
  55. data/vendor/v8/include/v8-primitive.h +27 -20
  56. data/vendor/v8/include/v8-profiler.h +133 -53
  57. data/vendor/v8/include/v8-regexp.h +2 -1
  58. data/vendor/v8/include/v8-script.h +91 -7
  59. data/vendor/v8/include/v8-snapshot.h +4 -8
  60. data/vendor/v8/include/v8-template.h +16 -77
  61. data/vendor/v8/include/v8-traced-handle.h +22 -28
  62. data/vendor/v8/include/v8-unwinder-state.h +4 -4
  63. data/vendor/v8/include/v8-util.h +11 -7
  64. data/vendor/v8/include/v8-value-serializer.h +46 -23
  65. data/vendor/v8/include/v8-value.h +31 -4
  66. data/vendor/v8/include/v8-version.h +4 -4
  67. data/vendor/v8/include/v8-wasm.h +7 -63
  68. data/vendor/v8/include/v8-weak-callback-info.h +0 -7
  69. data/vendor/v8/include/v8config.h +353 -15
  70. metadata +5 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 100307c5fef4bee4084554862ef0dbd82403dd5fb7dc2076e20518f1a959ca40
4
- data.tar.gz: cce7a47411133a4017f503e7cd725fb60fc8dccaf65b90e9919e2ad47d597ea3
3
+ metadata.gz: 0052cdf9c7c198d0eea6eb25f9cfeb5056e138b6706a751b7f2fc0bf5ce8462a
4
+ data.tar.gz: 95fdbd200afd1a849157d57a20e67aad88fd9bac1148f9d6c7e64f50692ab8b4
5
5
  SHA512:
6
- metadata.gz: ee42e308cbfe8608c33f0ba3fd2ace1a90f377e87c2d70ca25a1b1d47f0a995e3e8fccbd4599fe6fb8838762f4fb3612b2b9a8567ec27c7162b9c1840693257d
7
- data.tar.gz: 978ce17c7bc1e59db59e2fa32ab8fe990ea5f47aebd38c90b38a8b4d87f203f4df6660dfa0e887b130abb93dc5325ea944b15779948371fdc3a4f26443829154
6
+ metadata.gz: a28d870af08ab4793194d53fbd8f6d7896c544d473e66700537a8966a0928f405c762ffad6f5cb452d386ebbaf6387c161c46cada2b730969887bc50478cb4d4
7
+ data.tar.gz: b39c069f4136c1691c7a1a0c9220250ef86c24cb00926044893b7ede9b44e15a4a8f4b9b7efb96db6e54adc356e5ae4fdc8d7ed86c0f937f4ed59a7beba97019
@@ -1,7 +1,7 @@
1
1
  module Libv8; end
2
2
 
3
3
  module Libv8::Node
4
- VERSION = '18.13.0.1'.freeze
5
- NODE_VERSION = '18.13.0'.freeze
6
- LIBV8_VERSION = '10.2.154.23'.freeze # from v8/include/v8-version.h
4
+ VERSION = '20.2.0.0'.freeze
5
+ NODE_VERSION = '20.2.0'.freeze
6
+ LIBV8_VERSION = '11.3.244.8'.freeze # from v8/include/v8-version.h
7
7
  end
@@ -5,7 +5,6 @@
5
5
  #ifndef INCLUDE_CPPGC_COMMON_H_
6
6
  #define INCLUDE_CPPGC_COMMON_H_
7
7
 
8
- // TODO(chromium:1056170): Remove dependency on v8.
9
8
  #include "v8config.h" // NOLINT(build/include_directory)
10
9
 
11
10
  namespace cppgc {
@@ -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, &Trace));
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, &Trace));
141
+ SetNode(region.AllocateNode(this, &TraceAsRoot));
142
142
  this->CheckPointer(raw);
143
143
  }
144
144
 
@@ -148,10 +148,11 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
148
148
 
149
149
  template <typename U, typename MemberBarrierPolicy,
150
150
  typename MemberWeaknessTag, typename MemberCheckingPolicy,
151
+ typename MemberStorageType,
151
152
  typename = std::enable_if_t<std::is_base_of<T, U>::value>>
152
153
  BasicCrossThreadPersistent(
153
154
  internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
154
- MemberCheckingPolicy>
155
+ MemberCheckingPolicy, MemberStorageType>
155
156
  member,
156
157
  const SourceLocation& loc = SourceLocation::Current())
157
158
  : BasicCrossThreadPersistent(member.Get(), loc) {}
@@ -230,10 +231,11 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
230
231
  // Assignment from member.
231
232
  template <typename U, typename MemberBarrierPolicy,
232
233
  typename MemberWeaknessTag, typename MemberCheckingPolicy,
234
+ typename MemberStorageType,
233
235
  typename = std::enable_if_t<std::is_base_of<T, U>::value>>
234
236
  BasicCrossThreadPersistent& operator=(
235
237
  internal::BasicMember<U, MemberBarrierPolicy, MemberWeaknessTag,
236
- MemberCheckingPolicy>
238
+ MemberCheckingPolicy, MemberStorageType>
237
239
  member) {
238
240
  return operator=(member.Get());
239
241
  }
@@ -349,9 +351,8 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
349
351
  return ptr && ptr != kSentinelPointer;
350
352
  }
351
353
 
352
- static void Trace(Visitor* v, const void* ptr) {
353
- const auto* handle = static_cast<const BasicCrossThreadPersistent*>(ptr);
354
- v->TraceRoot(*handle, handle->Location());
354
+ static void TraceAsRoot(RootVisitor& root_visitor, const void* ptr) {
355
+ root_visitor.Trace(*static_cast<const BasicCrossThreadPersistent*>(ptr));
355
356
  }
356
357
 
357
358
  void AssignUnsafe(T* ptr) {
@@ -378,7 +379,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
378
379
  SetValue(ptr);
379
380
  if (!IsValid(ptr)) return;
380
381
  PersistentRegionLock guard;
381
- SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, &Trace));
382
+ SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, &TraceAsRoot));
382
383
  this->CheckPointer(ptr);
383
384
  }
384
385
 
@@ -398,7 +399,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
398
399
  }
399
400
  SetValue(ptr);
400
401
  if (!IsValid(ptr)) return;
401
- SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, &Trace));
402
+ SetNode(this->GetPersistentRegion(ptr).AllocateNode(this, &TraceAsRoot));
402
403
  this->CheckPointer(ptr);
403
404
  }
404
405
 
@@ -416,7 +417,7 @@ class BasicCrossThreadPersistent final : public CrossThreadPersistentBase,
416
417
  return static_cast<T*>(const_cast<void*>(GetValueFromGC()));
417
418
  }
418
419
 
419
- friend class cppgc::Visitor;
420
+ friend class internal::RootVisitor;
420
421
  };
421
422
 
422
423
  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, typename StorageType>
66
+ static V8_INLINE WriteBarrierType GetWriteBarrierType(
67
+ const internal::BasicMember<T, WeaknessTag, WriteBarrierPolicy,
68
+ CheckingPolicy, StorageType>& 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(params, slot);
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::GenerationalBarrierForSourceObject(params,
162
- inner_pointer);
203
+ internal::WriteBarrier::GenerationalBarrier<
204
+ internal::WriteBarrier::GenerationalBarrierType::kImpreciseSlot>(
205
+ params, inner_pointer);
163
206
  }
164
207
 
165
208
  private:
@@ -0,0 +1,48 @@
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
+ public:
23
+ // Deleted copy ctor to avoid treating the type by value.
24
+ HeapHandle(const HeapHandle&) = delete;
25
+ HeapHandle& operator=(const HeapHandle&) = delete;
26
+
27
+ private:
28
+ HeapHandle() = default;
29
+
30
+ V8_INLINE bool is_incremental_marking_in_progress() const {
31
+ return is_incremental_marking_in_progress_;
32
+ }
33
+
34
+ V8_INLINE bool is_young_generation_enabled() const {
35
+ return is_young_generation_enabled_;
36
+ }
37
+
38
+ bool is_incremental_marking_in_progress_ = false;
39
+ bool is_young_generation_enabled_ = false;
40
+
41
+ friend class internal::HeapBase;
42
+ friend class internal::WriteBarrierTypeForCagedHeapPolicy;
43
+ friend class internal::WriteBarrierTypeForNonCagedHeapPolicy;
44
+ };
45
+
46
+ } // namespace cppgc
47
+
48
+ #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::HideInternalNames() is false. */
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 help by the heap. */
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_DARWIN)
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
 
@@ -47,6 +57,9 @@ static constexpr size_t kMaxSupportedAlignment = 2 * kDefaultAlignment;
47
57
  // Granularity of heap allocations.
48
58
  constexpr size_t kAllocationGranularity = sizeof(void*);
49
59
 
60
+ // Default cacheline size.
61
+ constexpr size_t kCachelineSize = 64;
62
+
50
63
  } // namespace api_constants
51
64
 
52
65
  } // namespace internal
@@ -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 512 bytes memory
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
- (api_constants::kCagedHeapReservationSize / kAllocationGranularity) /
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 Reset(PageAllocator* allocator);
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(HeapBase&, PageAllocator&);
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_
@@ -10,6 +10,7 @@
10
10
  #include <type_traits>
11
11
 
12
12
  #include "cppgc/internal/finalizer-trait.h"
13
+ #include "cppgc/internal/logging.h"
13
14
  #include "cppgc/internal/name-trait.h"
14
15
  #include "cppgc/trace-trait.h"
15
16
  #include "v8config.h" // NOLINT(build/include_directory)
@@ -20,12 +21,12 @@ namespace internal {
20
21
  using GCInfoIndex = uint16_t;
21
22
 
22
23
  struct V8_EXPORT EnsureGCInfoIndexTrait final {
23
- // Acquires a new GC info object and returns the index. In addition, also
24
- // updates `registered_index` atomically.
24
+ // Acquires a new GC info object and updates `registered_index` with the index
25
+ // that identifies that new info accordingly.
25
26
  template <typename T>
26
- V8_INLINE static GCInfoIndex EnsureIndex(
27
+ V8_INLINE static void EnsureIndex(
27
28
  std::atomic<GCInfoIndex>& registered_index) {
28
- return EnsureGCInfoIndexTraitDispatch<T>{}(registered_index);
29
+ EnsureGCInfoIndexTraitDispatch<T>{}(registered_index);
29
30
  }
30
31
 
31
32
  private:
@@ -34,39 +35,32 @@ struct V8_EXPORT EnsureGCInfoIndexTrait final {
34
35
  bool = NameTrait<T>::HasNonHiddenName()>
35
36
  struct EnsureGCInfoIndexTraitDispatch;
36
37
 
37
- static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic<GCInfoIndex>&,
38
- TraceCallback,
39
- FinalizationCallback,
40
- NameCallback);
41
- static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic<GCInfoIndex>&,
42
- TraceCallback,
43
- FinalizationCallback);
44
- static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic<GCInfoIndex>&,
45
- TraceCallback, NameCallback);
46
- static GCInfoIndex EnsureGCInfoIndexPolymorphic(std::atomic<GCInfoIndex>&,
47
- TraceCallback);
48
- static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
49
- TraceCallback,
50
- FinalizationCallback,
51
-
52
- NameCallback);
53
- static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
54
- TraceCallback,
55
- FinalizationCallback);
56
- static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
57
- TraceCallback,
58
- NameCallback);
59
- static GCInfoIndex EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&,
60
- TraceCallback);
38
+ static void V8_PRESERVE_MOST
39
+ EnsureGCInfoIndexPolymorphic(std::atomic<GCInfoIndex>&, TraceCallback,
40
+ FinalizationCallback, NameCallback);
41
+ static void V8_PRESERVE_MOST EnsureGCInfoIndexPolymorphic(
42
+ std::atomic<GCInfoIndex>&, TraceCallback, FinalizationCallback);
43
+ static void V8_PRESERVE_MOST EnsureGCInfoIndexPolymorphic(
44
+ std::atomic<GCInfoIndex>&, TraceCallback, NameCallback);
45
+ static void V8_PRESERVE_MOST
46
+ EnsureGCInfoIndexPolymorphic(std::atomic<GCInfoIndex>&, TraceCallback);
47
+ static void V8_PRESERVE_MOST
48
+ EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&, TraceCallback,
49
+ FinalizationCallback, NameCallback);
50
+ static void V8_PRESERVE_MOST EnsureGCInfoIndexNonPolymorphic(
51
+ std::atomic<GCInfoIndex>&, TraceCallback, FinalizationCallback);
52
+ static void V8_PRESERVE_MOST EnsureGCInfoIndexNonPolymorphic(
53
+ std::atomic<GCInfoIndex>&, TraceCallback, NameCallback);
54
+ static void V8_PRESERVE_MOST
55
+ EnsureGCInfoIndexNonPolymorphic(std::atomic<GCInfoIndex>&, TraceCallback);
61
56
  };
62
57
 
63
58
  #define DISPATCH(is_polymorphic, has_finalizer, has_non_hidden_name, function) \
64
59
  template <typename T> \
65
60
  struct EnsureGCInfoIndexTrait::EnsureGCInfoIndexTraitDispatch< \
66
61
  T, is_polymorphic, has_finalizer, has_non_hidden_name> { \
67
- V8_INLINE GCInfoIndex \
68
- operator()(std::atomic<GCInfoIndex>& registered_index) { \
69
- return function; \
62
+ V8_INLINE void operator()(std::atomic<GCInfoIndex>& registered_index) { \
63
+ function; \
70
64
  } \
71
65
  };
72
66
 
@@ -144,9 +138,16 @@ struct GCInfoTrait final {
144
138
  static_assert(sizeof(T), "T must be fully defined");
145
139
  static std::atomic<GCInfoIndex>
146
140
  registered_index; // Uses zero initialization.
147
- const GCInfoIndex index = registered_index.load(std::memory_order_acquire);
148
- return index ? index
149
- : EnsureGCInfoIndexTrait::EnsureIndex<T>(registered_index);
141
+ GCInfoIndex index = registered_index.load(std::memory_order_acquire);
142
+ if (V8_UNLIKELY(!index)) {
143
+ EnsureGCInfoIndexTrait::EnsureIndex<T>(registered_index);
144
+ // Slow path call uses V8_PRESERVE_MOST which does not support return
145
+ // values (also preserves RAX). Avoid out parameter by just reloading the
146
+ // value here which at this point is guaranteed to be set.
147
+ index = registered_index.load(std::memory_order_acquire);
148
+ CPPGC_DCHECK(index != 0);
149
+ }
150
+ return index;
150
151
  }
151
152
  };
152
153