5 #ifndef INCLUDE_CPPGC_ALLOCATION_H_ 
    6 #define INCLUDE_CPPGC_ALLOCATION_H_ 
   12 #include "cppgc/custom-space.h" 
   13 #include "cppgc/garbage-collected.h" 
   14 #include "cppgc/internal/api-constants.h" 
   15 #include "cppgc/internal/gc-info.h" 
   20 class MakeGarbageCollectedTraitBase;
 
   23 class ObjectAllocator;
 
   29 class AllocationHandle;
 
   37     std::atomic<uint16_t>* atomic_mutable_bitfield =
 
   38         reinterpret_cast<std::atomic<uint16_t>*>(
 
   39             const_cast<uint16_t*>(
reinterpret_cast<
const uint16_t*>(
 
   40                 reinterpret_cast<
const uint8_t*>(payload) -
 
   42     atomic_mutable_bitfield->fetch_or(
api_constants::kFullyConstructedBitMask,
 
   43                                       std::memory_order_release);
 
   46   static void* 
Allocate(
cppgc::AllocationHandle& handle, size_t size,
 
   48   static void* 
Allocate(
cppgc::AllocationHandle& handle, size_t size,
 
   51   friend class HeapObjectHeader;
 
   64 class MakeGarbageCollectedTraitBase
 
   68                 "T needs to be a garbage collected object");
 
   69   static_assert(!IsGarbageCollectedWithMixinTypeV<T> ||
 
   72                 "GarbageCollectedMixin may not be a large object");
 
   74   template <
typename U, 
typename CustomSpace>
 
   76     static void* Allocate(AllocationHandle& handle, size_t size) {
 
   79                     "Custom space must inherit from CustomSpaceBase.");
 
   82           CustomSpace::kSpaceIndex);
 
   87   struct SpacePolicy<U, 
void> {
 
   88     static void* Allocate(AllocationHandle& handle, size_t size) {
 
  104   static void* 
Allocate(AllocationHandle& handle, size_t size) {
 
  105     return SpacePolicy<T, 
typename SpaceTrait<T>::Space>::Allocate(handle,
 
  158 template <
typename T>
 
  161   template <
typename... Args>
 
  162   static T* 
Call(AllocationHandle& handle, Args&&... args) {
 
  164         MakeGarbageCollectedTraitBase<T>::Allocate(handle, 
sizeof(T));
 
  165     T* object = ::
new (memory) T(std::forward<Args>(args)...);
 
  166     MakeGarbageCollectedTraitBase<T>::MarkObjectAsFullyConstructed(object);
 
  170   template <
typename... Args>
 
  173     void* memory = MakeGarbageCollectedTraitBase<T>::Allocate(
 
  174         handle, 
sizeof(T) + additional_bytes
.value);
 
  175     T* object = ::
new (memory) T(std::forward<Args>(args)...);
 
  176     MakeGarbageCollectedTraitBase<T>::MarkObjectAsFullyConstructed(object);
 
  187 template <
typename T, 
typename = 
void>
 
  200 template <
typename T, 
typename... Args>
 
  218 template <
typename T, 
typename... Args>
 
  222                                                  std::forward<Args>(args)...);