libv8 3.16.14.19.1-x86_64-darwin → 8.4.255.0.1-x86_64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/ext/libv8/location.rb +15 -7
  3. data/ext/libv8/paths.rb +6 -19
  4. data/lib/libv8/version.rb +1 -1
  5. data/vendor/v8/include/cppgc/allocation.h +124 -0
  6. data/vendor/v8/include/cppgc/garbage-collected.h +192 -0
  7. data/vendor/v8/include/cppgc/heap.h +50 -0
  8. data/vendor/v8/include/cppgc/internal/accessors.h +26 -0
  9. data/vendor/v8/include/cppgc/internal/api-constants.h +44 -0
  10. data/vendor/v8/include/cppgc/internal/compiler-specific.h +26 -0
  11. data/vendor/v8/include/cppgc/internal/finalizer-trait.h +90 -0
  12. data/vendor/v8/include/cppgc/internal/gc-info.h +43 -0
  13. data/vendor/v8/include/cppgc/internal/logging.h +50 -0
  14. data/vendor/v8/include/cppgc/internal/persistent-node.h +109 -0
  15. data/vendor/v8/include/cppgc/internal/pointer-policies.h +133 -0
  16. data/vendor/v8/include/cppgc/internal/prefinalizer-handler.h +31 -0
  17. data/vendor/v8/include/cppgc/liveness-broker.h +50 -0
  18. data/vendor/v8/include/cppgc/macros.h +26 -0
  19. data/vendor/v8/include/cppgc/member.h +206 -0
  20. data/vendor/v8/include/cppgc/persistent.h +304 -0
  21. data/vendor/v8/include/cppgc/platform.h +31 -0
  22. data/vendor/v8/include/cppgc/prefinalizer.h +54 -0
  23. data/vendor/v8/include/cppgc/source-location.h +59 -0
  24. data/vendor/v8/include/cppgc/trace-trait.h +67 -0
  25. data/vendor/v8/include/cppgc/type-traits.h +109 -0
  26. data/vendor/v8/include/cppgc/visitor.h +137 -0
  27. data/vendor/v8/include/libplatform/libplatform-export.h +29 -0
  28. data/vendor/v8/include/libplatform/libplatform.h +85 -0
  29. data/vendor/v8/include/libplatform/v8-tracing.h +332 -0
  30. data/vendor/v8/include/v8-fast-api-calls.h +412 -0
  31. data/vendor/v8/include/v8-inspector-protocol.h +13 -0
  32. data/vendor/v8/include/v8-inspector.h +327 -0
  33. data/vendor/v8/include/v8-internal.h +389 -0
  34. data/vendor/v8/include/v8-platform.h +577 -0
  35. data/vendor/v8/include/v8-profiler.h +744 -265
  36. data/vendor/v8/include/v8-util.h +652 -0
  37. data/vendor/v8/include/v8-value-serializer-version.h +24 -0
  38. data/vendor/v8/include/v8-version-string.h +38 -0
  39. data/vendor/v8/include/v8-version.h +20 -0
  40. data/vendor/v8/include/v8-wasm-trap-handler-posix.h +31 -0
  41. data/vendor/v8/include/v8-wasm-trap-handler-win.h +28 -0
  42. data/vendor/v8/include/v8.h +10228 -3147
  43. data/vendor/v8/include/v8config.h +465 -0
  44. data/vendor/v8/out.gn/libv8/obj/libv8_libbase.a +0 -0
  45. data/vendor/v8/out.gn/libv8/obj/libv8_libplatform.a +0 -0
  46. data/vendor/v8/out.gn/libv8/obj/libv8_monolith.a +0 -0
  47. data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicui18n.a +0 -0
  48. data/vendor/v8/out.gn/libv8/obj/third_party/icu/libicuuc.a +0 -0
  49. data/vendor/v8/out.gn/libv8/obj/third_party/zlib/google/libcompression_utils_portable.a +0 -0
  50. data/vendor/v8/out.gn/libv8/obj/third_party/zlib/libchrome_zlib.a +0 -0
  51. metadata +52 -32
  52. data/ext/libv8/arch.rb +0 -43
  53. data/vendor/v8/include/v8-debug.h +0 -408
  54. data/vendor/v8/include/v8-preparser.h +0 -118
  55. data/vendor/v8/include/v8-testing.h +0 -105
  56. data/vendor/v8/include/v8stdint.h +0 -54
  57. data/vendor/v8/out/x64.release/libpreparser_lib.a +0 -0
  58. data/vendor/v8/out/x64.release/libv8_base.a +0 -0
  59. data/vendor/v8/out/x64.release/libv8_nosnapshot.a +0 -0
  60. data/vendor/v8/out/x64.release/libv8_snapshot.a +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6510fa64daec2dc562d2bcc020891ce473613965e462983ee4752cf77a2d58e3
4
- data.tar.gz: f45347090bca1ebe61f3f4a67395bec80edadfdee3cf9aa57f6704576fa114bc
3
+ metadata.gz: 918cf2ad89f08f99e2ec63f706712714c19c24aee023aad3012ac4f00bef292f
4
+ data.tar.gz: 50ff6c24ec22039d9232c26b319205aae31d1352882587522453065dd69f38a7
5
5
  SHA512:
6
- metadata.gz: 4a986f1a2f5a35645bb5ce78a7a9e463e3b56955fd45eb0b53d592d86465d85f4b806764ed553b6e195f473994158bb0d4fa925f40a13b6c2ed0a0cbb10d7417
7
- data.tar.gz: 7b11ebb6d9df100ab545c2f53e06c8ef0f13f96e449b9433d3a56635cfa72db97f212af37dcf91027459c53166c333336d5906ed0d5364858430540ff222df9a
6
+ metadata.gz: a76914bf006438d794a5ee8e36d3eb7afb48a4317a0938d9bd58767631df9e29d38dc52f8022d46734a04060458c6d85c876d036f22b3e05a545336116bbcc86
7
+ data.tar.gz: 6e51eaaac4b5c30a44adbbc75b640b7d323786ca82642be62f4c77185b61c688bb6bc3e96323343261d3baf6f1149f91190e6228402c96dca4a9700153a10639
@@ -26,17 +26,24 @@ module Libv8
26
26
  verify_installation!
27
27
  return exit_status
28
28
  end
29
+
29
30
  def configure(context = MkmfContext.new)
30
- context.incflags.insert 0, Libv8::Paths.include_paths.map{|p| "-I#{p}"}.join(" ") + " "
31
+ context.incflags.insert 0, Libv8::Paths.include_paths.map{ |p| "-I#{p}" }.join(" ") + " "
31
32
  context.ldflags.insert 0, Libv8::Paths.object_paths.join(" ") + " "
32
33
  end
33
34
 
34
35
  def verify_installation!
36
+ include_paths = Libv8::Paths.include_paths
37
+ unless include_paths.detect { |p| Pathname(p).join('v8.h').exist? }
38
+ fail HeaderNotFound, "Unable to locate 'v8.h' in the libv8 header paths: #{include_paths.inspect}"
39
+ end
35
40
  Libv8::Paths.object_paths.each do |p|
36
41
  fail ArchiveNotFound, p unless File.exist? p
37
42
  end
38
43
  end
39
44
 
45
+ class HeaderNotFound < StandardError; end
46
+
40
47
  class ArchiveNotFound < StandardError
41
48
  def initialize(filename)
42
49
  super "libv8 did not install properly, expected binary v8 archive '#{filename}'to exist, but it was not found"
@@ -48,20 +55,21 @@ module Libv8
48
55
  def configure(context = MkmfContext.new)
49
56
  context.send(:dir_config, 'v8')
50
57
  context.send(:find_header, 'v8.h') or fail NotFoundError
58
+ context.send(:find_header, 'libplatform/libplatform.h') or fail NotFoundError
51
59
  context.send(:have_library, 'v8') or fail NotFoundError
52
60
  end
53
61
 
54
62
  class NotFoundError < StandardError
55
63
  def initialize(*args)
56
64
  super(<<-EOS)
57
- By using --with-system-v8, you have chosen to use the version
58
- of V8 found on your system and *not* the one that is bundled with
59
- the libv8 rubygem.
65
+ By using --with-system-v8, you have chosen to use the version
66
+ of V8 found on your system and *not* the one that is bundled with
67
+ the libv8 rubygem.
60
68
 
61
- However, your system version of v8 could not be located.
69
+ However, your system version of v8 could not be located.
62
70
 
63
- Please make sure your system version of v8 that is compatible
64
- with #{Libv8::VERSION} installed. You may need to use the
71
+ Please make sure your system version of v8 that is compatible
72
+ with #{Libv8::VERSION} installed. You may need to use the
65
73
  --with-v8-dir option if it is installed in a non-standard location
66
74
  EOS
67
75
  end
data/ext/libv8/paths.rb CHANGED
@@ -1,39 +1,26 @@
1
1
  require 'rbconfig'
2
2
  require 'shellwords'
3
- require File.expand_path '../arch', __FILE__
4
3
 
5
4
  module Libv8
6
5
  module Paths
7
6
  module_function
8
7
 
9
8
  def include_paths
10
- [Shellwords.escape("#{vendored_source_path}/include")]
9
+ [Shellwords.escape(File.join(vendored_source_path, 'include'))]
11
10
  end
12
11
 
13
12
  def object_paths
14
- [libv8_object(:base), libv8_object(:snapshot)].map do |path|
15
- Shellwords.escape path
16
- end
13
+ [Shellwords.escape(File.join(vendored_source_path,
14
+ 'out.gn',
15
+ 'libv8',
16
+ 'obj',
17
+ "libv8_monolith.#{config['LIBEXT']}"))]
17
18
  end
18
19
 
19
20
  def config
20
21
  RbConfig::MAKEFILE_CONFIG
21
22
  end
22
23
 
23
- def libv8_object(name)
24
- filename = "#{libv8_profile}/libv8_#{name}.#{config['LIBEXT']}"
25
- unless File.exist? filename
26
- filename = "#{libv8_profile}/obj.target/tools/gyp/libv8_#{name}.#{config['LIBEXT']}"
27
- end
28
- return filename
29
- end
30
-
31
- def libv8_profile
32
- base = "#{vendored_source_path}/out/#{Libv8::Arch.libv8_arch}"
33
- debug = "#{base}.debug"
34
- File.exist?(debug) ? debug : "#{base}.release"
35
- end
36
-
37
24
  def vendored_source_path
38
25
  File.expand_path "../../../vendor/v8", __FILE__
39
26
  end
data/lib/libv8/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Libv8
2
- VERSION = "3.16.14.19.1"
2
+ VERSION = "8.4.255.0.1"
3
3
  end
@@ -0,0 +1,124 @@
1
+ // Copyright 2020 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_ALLOCATION_H_
6
+ #define INCLUDE_CPPGC_ALLOCATION_H_
7
+
8
+ #include <stdint.h>
9
+ #include <atomic>
10
+
11
+ #include "cppgc/garbage-collected.h"
12
+ #include "cppgc/heap.h"
13
+ #include "cppgc/internal/api-constants.h"
14
+ #include "cppgc/internal/gc-info.h"
15
+
16
+ namespace cppgc {
17
+
18
+ template <typename T>
19
+ class MakeGarbageCollectedTraitBase;
20
+
21
+ namespace internal {
22
+
23
+ class V8_EXPORT MakeGarbageCollectedTraitInternal {
24
+ protected:
25
+ static inline void MarkObjectAsFullyConstructed(const void* payload) {
26
+ // See api_constants for an explanation of the constants.
27
+ std::atomic<uint16_t>* atomic_mutable_bitfield =
28
+ reinterpret_cast<std::atomic<uint16_t>*>(
29
+ const_cast<uint16_t*>(reinterpret_cast<const uint16_t*>(
30
+ reinterpret_cast<const uint8_t*>(payload) -
31
+ api_constants::kFullyConstructedBitFieldOffsetFromPayload)));
32
+ uint16_t value = atomic_mutable_bitfield->load(std::memory_order_relaxed);
33
+ value = value | api_constants::kFullyConstructedBitMask;
34
+ atomic_mutable_bitfield->store(value, std::memory_order_release);
35
+ }
36
+
37
+ static void* Allocate(cppgc::Heap* heap, size_t size, GCInfoIndex index);
38
+
39
+ friend class HeapObjectHeader;
40
+ };
41
+
42
+ } // namespace internal
43
+
44
+ /**
45
+ * Base trait that provides utilities for advancers users that have custom
46
+ * allocation needs (e.g., overriding size). It's expected that users override
47
+ * MakeGarbageCollectedTrait (see below) and inherit from
48
+ * MakeGarbageCollectedTraitBase and make use of the low-level primitives
49
+ * offered to allocate and construct an object.
50
+ */
51
+ template <typename T>
52
+ class MakeGarbageCollectedTraitBase
53
+ : private internal::MakeGarbageCollectedTraitInternal {
54
+ protected:
55
+ /**
56
+ * Allocates memory for an object of type T.
57
+ *
58
+ * \param heap The heap to allocate this object on.
59
+ * \param size The size that should be reserved for the object.
60
+ * \returns the memory to construct an object of type T on.
61
+ */
62
+ static void* Allocate(Heap* heap, size_t size) {
63
+ // TODO(chromium:1056170): Allow specifying arena for specific embedder
64
+ // uses.
65
+ return internal::MakeGarbageCollectedTraitInternal::Allocate(
66
+ heap, size, internal::GCInfoTrait<T>::Index());
67
+ }
68
+
69
+ /**
70
+ * Marks an object as fully constructed, resulting in precise handling by the
71
+ * garbage collector.
72
+ *
73
+ * \param payload The base pointer the object is allocated at.
74
+ */
75
+ static void MarkObjectAsFullyConstructed(const void* payload) {
76
+ internal::MakeGarbageCollectedTraitInternal::MarkObjectAsFullyConstructed(
77
+ payload);
78
+ }
79
+ };
80
+
81
+ /**
82
+ * Default trait class that specifies how to construct an object of type T.
83
+ * Advanced users may override how an object is constructed using the utilities
84
+ * that are provided through MakeGarbageCollectedTraitBase.
85
+ *
86
+ * Any trait overriding construction must
87
+ * - allocate through MakeGarbageCollectedTraitBase<T>::Allocate;
88
+ * - mark the object as fully constructed using
89
+ * MakeGarbageCollectedTraitBase<T>::MarkObjectAsFullyConstructed;
90
+ */
91
+ template <typename T>
92
+ class MakeGarbageCollectedTrait : public MakeGarbageCollectedTraitBase<T> {
93
+ public:
94
+ template <typename... Args>
95
+ static T* Call(Heap* heap, Args&&... args) {
96
+ static_assert(internal::IsGarbageCollectedType<T>::value,
97
+ "T needs to be a garbage collected object");
98
+ static_assert(
99
+ !internal::IsGarbageCollectedMixinType<T>::value ||
100
+ sizeof(T) <= internal::api_constants::kLargeObjectSizeThreshold,
101
+ "GarbageCollectedMixin may not be a large object");
102
+ void* memory = MakeGarbageCollectedTraitBase<T>::Allocate(heap, sizeof(T));
103
+ T* object = ::new (memory) T(std::forward<Args>(args)...);
104
+ MakeGarbageCollectedTraitBase<T>::MarkObjectAsFullyConstructed(object);
105
+ return object;
106
+ }
107
+ };
108
+
109
+ /**
110
+ * Constructs a managed object of type T where T transitively inherits from
111
+ * GarbageCollected.
112
+ *
113
+ * \param args List of arguments with which an instance of T will be
114
+ * constructed.
115
+ * \returns an instance of type T.
116
+ */
117
+ template <typename T, typename... Args>
118
+ T* MakeGarbageCollected(Heap* heap, Args&&... args) {
119
+ return MakeGarbageCollectedTrait<T>::Call(heap, std::forward<Args>(args)...);
120
+ }
121
+
122
+ } // namespace cppgc
123
+
124
+ #endif // INCLUDE_CPPGC_ALLOCATION_H_
@@ -0,0 +1,192 @@
1
+ // Copyright 2020 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_GARBAGE_COLLECTED_H_
6
+ #define INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
7
+
8
+ #include <type_traits>
9
+
10
+ #include "cppgc/internal/api-constants.h"
11
+ #include "cppgc/macros.h"
12
+ #include "cppgc/platform.h"
13
+ #include "cppgc/trace-trait.h"
14
+ #include "cppgc/type-traits.h"
15
+
16
+ namespace cppgc {
17
+
18
+ class Visitor;
19
+
20
+ namespace internal {
21
+
22
+ class GarbageCollectedBase {
23
+ public:
24
+ // Must use MakeGarbageCollected.
25
+ void* operator new(size_t) = delete;
26
+ void* operator new[](size_t) = delete;
27
+ // The garbage collector is taking care of reclaiming the object. Also,
28
+ // virtual destructor requires an unambiguous, accessible 'operator delete'.
29
+ void operator delete(void*) {
30
+ #ifdef V8_ENABLE_CHECKS
31
+ internal::Abort();
32
+ #endif // V8_ENABLE_CHECKS
33
+ }
34
+ void operator delete[](void*) = delete;
35
+
36
+ protected:
37
+ GarbageCollectedBase() = default;
38
+ };
39
+
40
+ } // namespace internal
41
+
42
+ /**
43
+ * Base class for managed objects. Only descendent types of GarbageCollected
44
+ * can be constructed using MakeGarbageCollected. Must be inherited from as
45
+ * left-most base class.
46
+ *
47
+ * Types inheriting from GarbageCollected must provide a method of
48
+ * signature `void Trace(cppgc::Visitor*) const` that dispatchs all managed
49
+ * pointers to the visitor and delegates to garbage-collected base classes.
50
+ * The method must be virtual if the type is not directly a child of
51
+ * GarbageCollected and marked as final.
52
+ *
53
+ * \code
54
+ * // Example using final class.
55
+ * class FinalType final : public GarbageCollected<FinalType> {
56
+ * public:
57
+ * void Trace(cppgc::Visitor* visitor) const {
58
+ * // Dispatch using visitor->Trace(...);
59
+ * }
60
+ * };
61
+ *
62
+ * // Example using non-final base class.
63
+ * class NonFinalBase : public GarbageCollected<NonFinalBase> {
64
+ * public:
65
+ * virtual void Trace(cppgc::Visitor*) const {}
66
+ * };
67
+ *
68
+ * class FinalChild final : public NonFinalBase {
69
+ * public:
70
+ * void Trace(cppgc::Visitor* visitor) const final {
71
+ * // Dispatch using visitor->Trace(...);
72
+ * NonFinalBase::Trace(visitor);
73
+ * }
74
+ * };
75
+ * \endcode
76
+ */
77
+ template <typename>
78
+ class GarbageCollected : public internal::GarbageCollectedBase {
79
+ public:
80
+ using IsGarbageCollectedTypeMarker = void;
81
+
82
+ protected:
83
+ GarbageCollected() = default;
84
+ };
85
+
86
+ /**
87
+ * Base class for managed mixin objects. Such objects cannot be constructed
88
+ * directly but must be mixed into the inheritance hierarchy of a
89
+ * GarbageCollected object.
90
+ *
91
+ * Types inheriting from GarbageCollectedMixin must override a virtual method
92
+ * of signature `void Trace(cppgc::Visitor*) const` that dispatchs all managed
93
+ * pointers to the visitor and delegates to base classes.
94
+ *
95
+ * \code
96
+ * class Mixin : public GarbageCollectedMixin {
97
+ * public:
98
+ * void Trace(cppgc::Visitor* visitor) const override {
99
+ * // Dispatch using visitor->Trace(...);
100
+ * }
101
+ * };
102
+ * \endcode
103
+ */
104
+ class GarbageCollectedMixin : public internal::GarbageCollectedBase {
105
+ public:
106
+ using IsGarbageCollectedMixinTypeMarker = void;
107
+
108
+ // Sentinel used to mark not-fully-constructed mixins.
109
+ static constexpr void* kNotFullyConstructedObject = nullptr;
110
+
111
+ // Provide default implementation that indicate that the vtable is not yet
112
+ // set up properly. This is used to to get GCInfo objects for mixins so that
113
+ // these objects can be processed later on.
114
+ virtual TraceDescriptor GetTraceDescriptor() const {
115
+ return {kNotFullyConstructedObject, nullptr};
116
+ }
117
+
118
+ /**
119
+ * This Trace method must be overriden by objects inheriting from
120
+ * GarbageCollectedMixin.
121
+ */
122
+ virtual void Trace(cppgc::Visitor*) const {}
123
+ };
124
+
125
+ /**
126
+ * Macro defines all methods and markers needed for handling mixins. Must be
127
+ * used on the type that is inheriting from GarbageCollected *and*
128
+ * GarbageCollectedMixin.
129
+ *
130
+ * \code
131
+ * class Mixin : public GarbageCollectedMixin {
132
+ * public:
133
+ * void Trace(cppgc::Visitor* visitor) const override {
134
+ * // Dispatch using visitor->Trace(...);
135
+ * }
136
+ * };
137
+ *
138
+ * class Foo : public GarbageCollected<Foo>, public Mixin {
139
+ * USING_GARBAGE_COLLECTED_MIXIN();
140
+ * public:
141
+ * void Trace(cppgc::Visitor* visitor) const override {
142
+ * // Dispatch using visitor->Trace(...);
143
+ * Mixin::Trace(visitor);
144
+ * }
145
+ * };
146
+ * \endcode
147
+ */
148
+ #define USING_GARBAGE_COLLECTED_MIXIN() \
149
+ public: \
150
+ /* Marker is used by clang to check for proper usages of the macro. */ \
151
+ typedef int HasUsingGarbageCollectedMixinMacro; \
152
+ \
153
+ TraceDescriptor GetTraceDescriptor() const override { \
154
+ static_assert( \
155
+ internal::IsSubclassOfTemplate< \
156
+ std::remove_const_t<std::remove_pointer_t<decltype(this)>>, \
157
+ cppgc::GarbageCollected>::value, \
158
+ "Only garbage collected objects can have garbage collected mixins"); \
159
+ return {this, TraceTrait<std::remove_const_t< \
160
+ std::remove_pointer_t<decltype(this)>>>::Trace}; \
161
+ } \
162
+ \
163
+ private: \
164
+ friend class internal::__thisIsHereToForceASemicolonAfterThisMacro
165
+
166
+ /**
167
+ * Merge two or more Mixins into one.
168
+ *
169
+ * \code
170
+ * class A : public GarbageCollectedMixin {};
171
+ * class B : public GarbageCollectedMixin {};
172
+ * class C : public A, public B {
173
+ * MERGE_GARBAGE_COLLECTED_MIXINS();
174
+ * public:
175
+ * };
176
+ * \endcode
177
+ */
178
+ #define MERGE_GARBAGE_COLLECTED_MIXINS() \
179
+ public: \
180
+ /* When using multiple mixins the methods become */ \
181
+ /* ambigous. Providing additional implementations */ \
182
+ /* disambiguate them again. */ \
183
+ TraceDescriptor GetTraceDescriptor() const override { \
184
+ return {kNotFullyConstructedObject, nullptr}; \
185
+ } \
186
+ \
187
+ private: \
188
+ friend class internal::__thisIsHereToForceASemicolonAfterThisMacro
189
+
190
+ } // namespace cppgc
191
+
192
+ #endif // INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
@@ -0,0 +1,50 @@
1
+ // Copyright 2020 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_H_
6
+ #define INCLUDE_CPPGC_HEAP_H_
7
+
8
+ #include <memory>
9
+
10
+ #include "v8config.h" // NOLINT(build/include_directory)
11
+
12
+ namespace cppgc {
13
+ namespace internal {
14
+ class Heap;
15
+ } // namespace internal
16
+
17
+ class V8_EXPORT Heap {
18
+ public:
19
+ // Normal spaces are used to store objects of different size classes:
20
+ // - kNormal1: < 32 bytes
21
+ // - kNormal2: < 64 bytes
22
+ // - kNormal3: < 128 bytes
23
+ // - kNormal4: >= 128 bytes
24
+ // Objects of size greater than 2^16 get stored in the large space. Users can
25
+ // register up to 4 arenas for application specific needs.
26
+ enum class SpaceType {
27
+ kNormal1,
28
+ kNormal2,
29
+ kNormal3,
30
+ kNormal4,
31
+ kLarge,
32
+ kUserDefined1,
33
+ kUserDefined2,
34
+ kUserDefined3,
35
+ kUserDefined4,
36
+ };
37
+
38
+ static std::unique_ptr<Heap> Create();
39
+
40
+ virtual ~Heap() = default;
41
+
42
+ private:
43
+ Heap() = default;
44
+
45
+ friend class internal::Heap;
46
+ };
47
+
48
+ } // namespace cppgc
49
+
50
+ #endif // INCLUDE_CPPGC_HEAP_H_
@@ -0,0 +1,26 @@
1
+ // Copyright 2020 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_ACCESSORS_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_ACCESSORS_H_
7
+
8
+ #include "cppgc/internal/api-constants.h"
9
+
10
+ namespace cppgc {
11
+
12
+ class Heap;
13
+
14
+ namespace internal {
15
+
16
+ inline cppgc::Heap* GetHeapFromPayload(const void* payload) {
17
+ return *reinterpret_cast<cppgc::Heap**>(
18
+ ((reinterpret_cast<uintptr_t>(payload) & api_constants::kPageBaseMask) +
19
+ api_constants::kGuardPageSize) +
20
+ api_constants::kHeapOffset);
21
+ }
22
+
23
+ } // namespace internal
24
+ } // namespace cppgc
25
+
26
+ #endif // INCLUDE_CPPGC_INTERNAL_ACCESSORS_H_
@@ -0,0 +1,44 @@
1
+ // Copyright 2020 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_API_CONSTANTS_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
7
+
8
+ #include <stddef.h>
9
+ #include <stdint.h>
10
+
11
+ #include "v8config.h" // NOLINT(build/include_directory)
12
+
13
+ namespace cppgc {
14
+ namespace internal {
15
+
16
+ // Embedders should not rely on this code!
17
+
18
+ // Internal constants to avoid exposing internal types on the API surface.
19
+ namespace api_constants {
20
+ // Offset of the uint16_t bitfield from the payload contaning the
21
+ // in-construction bit. This is subtracted from the payload pointer to get
22
+ // to the right bitfield.
23
+ static constexpr size_t kFullyConstructedBitFieldOffsetFromPayload =
24
+ 2 * sizeof(uint16_t);
25
+ // Mask for in-construction bit.
26
+ static constexpr size_t kFullyConstructedBitMask = size_t{1};
27
+
28
+ // Page constants used to align pointers to page begin.
29
+ static constexpr size_t kPageSize = size_t{1} << 17;
30
+ static constexpr size_t kPageAlignment = kPageSize;
31
+ static constexpr size_t kPageBaseMask = ~(kPageAlignment - 1);
32
+ static constexpr size_t kGuardPageSize = 4096;
33
+
34
+ // Offset of the Heap backref.
35
+ static constexpr size_t kHeapOffset = 0;
36
+
37
+ static constexpr size_t kLargeObjectSizeThreshold = kPageSize / 2;
38
+
39
+ } // namespace api_constants
40
+
41
+ } // namespace internal
42
+ } // namespace cppgc
43
+
44
+ #endif // INCLUDE_CPPGC_INTERNAL_API_CONSTANTS_H_
@@ -0,0 +1,26 @@
1
+ // Copyright 2020 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_COMPILER_SPECIFIC_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_
7
+
8
+ namespace cppgc {
9
+
10
+ #if defined(__has_cpp_attribute)
11
+ #define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) __has_cpp_attribute(FEATURE)
12
+ #else
13
+ #define CPPGC_HAS_CPP_ATTRIBUTE(FEATURE) 0
14
+ #endif
15
+
16
+ // [[no_unique_address]] comes in C++20 but supported in clang with -std >=
17
+ // c++11.
18
+ #if CPPGC_HAS_CPP_ATTRIBUTE(no_unique_address) // NOLINTNEXTLINE
19
+ #define CPPGC_NO_UNIQUE_ADDRESS [[no_unique_address]]
20
+ #else
21
+ #define CPPGC_NO_UNIQUE_ADDRESS
22
+ #endif
23
+
24
+ } // namespace cppgc
25
+
26
+ #endif // INCLUDE_CPPGC_INTERNAL_COMPILER_SPECIFIC_H_
@@ -0,0 +1,90 @@
1
+ // Copyright 2020 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_FINALIZER_TRAIT_H_
6
+ #define INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_
7
+
8
+ #include <type_traits>
9
+
10
+ #include "cppgc/type-traits.h"
11
+
12
+ namespace cppgc {
13
+ namespace internal {
14
+
15
+ using FinalizationCallback = void (*)(void*);
16
+
17
+ template <typename T, typename = void>
18
+ struct HasFinalizeGarbageCollectedObject : std::false_type {};
19
+
20
+ template <typename T>
21
+ struct HasFinalizeGarbageCollectedObject<
22
+ T, void_t<decltype(std::declval<T>().FinalizeGarbageCollectedObject())>>
23
+ : std::true_type {};
24
+
25
+ // The FinalizerTraitImpl specifies how to finalize objects.
26
+ template <typename T, bool isFinalized>
27
+ struct FinalizerTraitImpl;
28
+
29
+ template <typename T>
30
+ struct FinalizerTraitImpl<T, true> {
31
+ private:
32
+ // Dispatch to custom FinalizeGarbageCollectedObject().
33
+ struct Custom {
34
+ static void Call(void* obj) {
35
+ static_cast<T*>(obj)->FinalizeGarbageCollectedObject();
36
+ }
37
+ };
38
+
39
+ // Dispatch to regular destructor.
40
+ struct Destructor {
41
+ static void Call(void* obj) { static_cast<T*>(obj)->~T(); }
42
+ };
43
+
44
+ using FinalizeImpl =
45
+ std::conditional_t<HasFinalizeGarbageCollectedObject<T>::value, Custom,
46
+ Destructor>;
47
+
48
+ public:
49
+ static void Finalize(void* obj) {
50
+ static_assert(sizeof(T), "T must be fully defined");
51
+ FinalizeImpl::Call(obj);
52
+ }
53
+ };
54
+
55
+ template <typename T>
56
+ struct FinalizerTraitImpl<T, false> {
57
+ static void Finalize(void* obj) {
58
+ static_assert(sizeof(T), "T must be fully defined");
59
+ }
60
+ };
61
+
62
+ // The FinalizerTrait is used to determine if a type requires finalization and
63
+ // what finalization means.
64
+ template <typename T>
65
+ struct FinalizerTrait {
66
+ private:
67
+ // Object has a finalizer if it has
68
+ // - a custom FinalizeGarbageCollectedObject method, or
69
+ // - a destructor.
70
+ static constexpr bool kNonTrivialFinalizer =
71
+ internal::HasFinalizeGarbageCollectedObject<T>::value ||
72
+ !std::is_trivially_destructible<typename std::remove_cv<T>::type>::value;
73
+
74
+ static void Finalize(void* obj) {
75
+ internal::FinalizerTraitImpl<T, kNonTrivialFinalizer>::Finalize(obj);
76
+ }
77
+
78
+ public:
79
+ // The callback used to finalize an object of type T.
80
+ static constexpr FinalizationCallback kCallback =
81
+ kNonTrivialFinalizer ? Finalize : nullptr;
82
+ };
83
+
84
+ template <typename T>
85
+ constexpr FinalizationCallback FinalizerTrait<T>::kCallback;
86
+
87
+ } // namespace internal
88
+ } // namespace cppgc
89
+
90
+ #endif // INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_