5 #ifndef INCLUDE_CPPGC_ALLOCATION_H_
6 #define INCLUDE_CPPGC_ALLOCATION_H_
29 std::atomic<uint16_t>* atomic_mutable_bitfield =
30 reinterpret_cast<std::atomic<uint16_t>*
>(
31 const_cast<uint16_t*
>(
reinterpret_cast<const uint16_t*
>(
32 reinterpret_cast<const uint8_t*
>(payload) -
33 api_constants::kFullyConstructedBitFieldOffsetFromPayload)));
34 uint16_t value = atomic_mutable_bitfield->load(std::memory_order_relaxed);
35 value = value | api_constants::kFullyConstructedBitMask;
36 atomic_mutable_bitfield->store(value, std::memory_order_release);
43 friend class HeapObjectHeader;
59 template <
typename U,
typename CustomSpace>
63 static_assert(std::is_base_of<CustomSpaceBase, CustomSpace>::value,
64 "Custom space must inherit from CustomSpaceBase.");
67 CustomSpace::kSpaceIndex);
72 struct SpacePolicy<U, void> {
73 static void*
Allocate(Heap* heap,
size_t size) {
89 return SpacePolicy<T, typename SpaceTrait<T>::Space>
::Allocate(heap, size);
114 template <
typename T>
117 template <
typename... Args>
120 "T needs to be a garbage collected object");
123 sizeof(T) <= internal::api_constants::kLargeObjectSizeThreshold,
124 "GarbageCollectedMixin may not be a large object");
126 T*
object = ::new (memory) T(std::forward<Args>(args)...);
138 template <
typename T,
typename =
void>
151 template <
typename T,
typename... Args>
161 #endif // INCLUDE_CPPGC_ALLOCATION_H_