5#ifndef V8_HEAP_HEAP_ALLOCATOR_INL_H_
6#define V8_HEAP_HEAP_ALLOCATOR_INL_H_
73template <AllocationType type>
77 DCHECK(AllowHandleAllocation::IsAllowed());
78 DCHECK(AllowHeapAllocation::IsAllowed());
83#if V8_ENABLE_WEBASSEMBLY
96#ifdef V8_ENABLE_ALLOCATION_TIMEOUT
104 IncrementObjectCounters();
112 const bool large_object =
113 static_cast<size_t>(size_in_bytes) > large_object_threshold;
136 DCHECK(AllowCodeAllocation::IsAllowed());
157 size_in_bytes, alignment, origin);
162 if (allocation.To(&
object)) {
169 tracker->AllocationEvent(
object.address(), size_in_bytes);
213template <HeapAllocator::AllocationRetryMode mode>
248template <
typename AllocateFunction,
typename RetryFunction>
250 AllocateFunction&& Allocate, RetryFunction&& RetryAllocate,
252 if (
auto result = Allocate(allocation)) [[likely]] {
258 if (
auto result = RetryAllocate(allocation)) {
262 return RetryAllocate(allocation);
265template <
typename AllocateFunction,
typename RetryFunction>
267 AllocateFunction&& Allocate, RetryFunction&& RetryAllocate,
275 if (
auto result = RetryAllocate(allocation)) {
283template <
typename Function>
static Isolate * TryGetCurrent()
static AllocationResult Failure()
V8_WARN_UNUSED_RESULT auto AllocateRawWithLightRetrySlowPath(AllocateFunction &&Allocate, RetryFunction &&RetryAllocate, AllocationType allocation)
std::optional< MainAllocator > shared_space_allocator_
V8_INLINE PagedSpace * code_space() const
void CollectAllAvailableGarbage(AllocationType allocation)
V8_INLINE NewSpace * new_space() const
V8_WARN_UNUSED_RESULT V8_INLINE auto CustomAllocateWithRetryOrFail(Function &&Allocate, AllocationType allocation)
V8_WARN_UNUSED_RESULT AllocationResult AllocateRawLargeInternal(int size_in_bytes, AllocationType allocation, AllocationOrigin origin, AllocationAlignment alignment)
OldLargeObjectSpace * shared_lo_space_
V8_INLINE bool CanAllocateInReadOnlySpace() const
V8_INLINE PagedSpace * old_space() const
V8_INLINE ReadOnlySpace * read_only_space() const
Space * spaces_[LAST_SPACE+1]
std::optional< MainAllocator > trusted_space_allocator_
void CollectGarbage(AllocationType allocation)
ReadOnlySpace * read_only_space_
V8_INLINE OldLargeObjectSpace * shared_lo_space() const
V8_INLINE CodeLargeObjectSpace * code_lo_space() const
V8_INLINE PagedSpace * trusted_space() const
V8_INLINE OldLargeObjectSpace * lo_space() const
V8_WARN_UNUSED_RESULT auto AllocateRawWithRetryOrFailSlowPath(AllocateFunction &&Allocate, RetryFunction &&RetryAllocate, AllocationType allocation)
V8_WARN_UNUSED_RESULT V8_INLINE AllocationResult AllocateRaw(int size_in_bytes, AllocationType allocation, AllocationOrigin origin=AllocationOrigin::kRuntime, AllocationAlignment alignment=kTaggedAligned)
V8_INLINE NewLargeObjectSpace * new_lo_space() const
V8_INLINE OldLargeObjectSpace * shared_trusted_lo_space() const
bool ReachedAllocationTimeout()
std::optional< MainAllocator > old_space_allocator_
std::optional< MainAllocator > shared_trusted_space_allocator_
V8_INLINE OldLargeObjectSpace * trusted_lo_space() const
std::optional< MainAllocator > code_space_allocator_
SharedTrustedLargeObjectSpace * shared_trusted_lo_space_
std::optional< MainAllocator > new_space_allocator_
V8_WARN_UNUSED_RESULT V8_INLINE Tagged< HeapObject > AllocateRawWith(int size, AllocationType allocation, AllocationOrigin origin=AllocationOrigin::kRuntime, AllocationAlignment alignment=kTaggedAligned)
std::vector< HeapObjectAllocationTracker * > allocation_trackers_
V8_EXPORT_PRIVATE int MaxRegularHeapObjectSize(AllocationType allocation)
MarkingState * marking_state()
V8_INLINE bool CanSafepoint() const
Isolate * isolate() const
bool is_main_thread() const
V8_INLINE bool IsMarked(const Tagged< HeapObject > obj) const
static V8_EXPORT_PRIVATE bool IsAllowed()
V8_EXPORT_PRIVATE AllocationResult AllocateRaw(int size_in_bytes, AllocationAlignment alignment)
static V8_EXPORT_PRIVATE void FatalProcessOutOfMemory(Isolate *isolate, const char *location, const OOMDetails &details=kNoOOMDetails)
static V8_EXPORT_PRIVATE const OOMDetails kHeapOOM
#define ALIGN_TO_ALLOCATION_ALIGNMENT(value)
ZoneVector< RpoNumber > & result
void ZapCodeBlock(Address start, int size_in_bytes)
void AssertThreadNotInWasm()
V8_EXPORT_PRIVATE FlagValues v8_flags
#define DCHECK_IMPLIES(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define V8_WARN_UNUSED_RESULT
#define V8_UNLIKELY(condition)