diff options
Diffstat (limited to 'deps/v8/src/heap/cppgc/object-allocator.h')
-rw-r--r-- | deps/v8/src/heap/cppgc/object-allocator.h | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/deps/v8/src/heap/cppgc/object-allocator.h b/deps/v8/src/heap/cppgc/object-allocator.h new file mode 100644 index 00000000000..510a935f565 --- /dev/null +++ b/deps/v8/src/heap/cppgc/object-allocator.h @@ -0,0 +1,40 @@ +// Copyright 2020 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_HEAP_CPPGC_OBJECT_ALLOCATOR_H_ +#define V8_HEAP_CPPGC_OBJECT_ALLOCATOR_H_ + +#include "include/cppgc/internal/gc-info.h" +#include "src/heap/cppgc/heap-space.h" +#include "src/heap/cppgc/raw-heap.h" + +namespace cppgc { +namespace internal { + +class V8_EXPORT_PRIVATE ObjectAllocator final { + public: + explicit ObjectAllocator(RawHeap* heap); + + inline void* AllocateObject(size_t size, GCInfoIndex gcinfo); + inline void* AllocateObject(size_t size, GCInfoIndex gcinfo, + CustomSpaceIndex space_index); + + private: + // Returns the initially tried SpaceType to allocate an object of |size| bytes + // on. Returns the largest regular object size bucket for large objects. + inline static RawHeap::RegularSpaceType GetInitialSpaceIndexForSize( + size_t size); + + inline void* AllocateObjectOnSpace(NormalPageSpace* space, size_t size, + GCInfoIndex gcinfo); + void* OutOfLineAllocate(NormalPageSpace*, size_t, GCInfoIndex); + void* AllocateFromFreeList(NormalPageSpace*, size_t, GCInfoIndex); + + RawHeap* raw_heap_; +}; + +} // namespace internal +} // namespace cppgc + +#endif // V8_HEAP_CPPGC_OBJECT_ALLOCATOR_H_ |