5#ifndef V8_COMMON_SEGMENTED_TABLE_INL_H_
6#define V8_COMMON_SEGMENTED_TABLE_INL_H_
18template <
typename Entry,
size_t size>
19typename SegmentedTable<Entry, size>::Segment
26template <
typename Entry,
size_t size>
33template <
typename Entry,
size_t size>
38template <
typename Entry,
size_t size>
43template <
typename Entry,
size_t size>
49template <
typename Entry,
size_t size>
52 return vas_ !=
nullptr;
55template <
typename Entry,
size_t size>
61template <
typename Entry,
size_t size>
68#ifdef V8_TARGET_ARCH_64_BIT
76 vas_ = subspace.release();
84 if (reservation_base) {
86 root_space, reservation_base, kReservationSize, kReservationSize);
91 nullptr,
"SegmentedTable::InitializeTable (subspace allocation)");
106template <
typename Entry,
size_t size>
111#ifdef V8_TARGET_ARCH_64_BIT
117template <
typename Entry,
size_t size>
120 uint32_t start_offset) {
124 uint32_t first = segment.
first_entry() + start_offset;
128 while (it.index() != last) {
129 it->MakeFreelistEntry(it.index() + 1);
132 it->MakeFreelistEntry(0);
135 return FreelistHead(first, num_entries);
138template <
typename Entry,
size_t size>
139std::pair<typename SegmentedTable<Entry, size>::Segment,
146 "SegmentedTable::AllocateAndInitializeSegment");
149template <
typename Entry,
size_t size>
150std::optional<std::pair<typename SegmentedTable<Entry, size>::Segment,
164 return {{segment, freelist}};
167template <
typename Entry,
size_t size>
173template <
typename Entry,
size_t size>
virtual bool CanAllocateSubspaces()=0
virtual void FreePages(Address address, size_t size)=0
static constexpr Address kNoHint
virtual V8_WARN_UNUSED_RESULT Address AllocatePages(Address hint, size_t size, size_t alignment, PagePermissions permissions)=0
size_t allocation_granularity() const
virtual std::unique_ptr< VirtualAddressSpace > AllocateSubspace(Address hint, size_t size, size_t alignment, PagePermissions max_page_permissions)=0
WriteIterator(Entry *base, uint32_t index)
static constexpr size_t kSegmentSize
static constexpr size_t kEntriesPerSegment
std::optional< std::pair< Segment, FreelistHead > > TryAllocateAndInitializeSegment()
VirtualAddressSpace * vas_
FreelistHead InitializeFreeList(Segment segment, uint32_t start_offset=0)
Entry & at(uint32_t index)
bool is_initialized() const
static constexpr bool kIsWriteProtected
void FreeTableSegment(Segment segment)
std::pair< Segment, FreelistHead > AllocateAndInitializeSegment()
WriteIterator iter_at(uint32_t index)
static constexpr bool kUseContiguousMemory
static V8_NODISCARD bool WriteProtectMemory(Address addr, size_t size, PageAllocator::Permission page_permissions)
static V8_EXPORT_PRIVATE void FatalProcessOutOfMemory(Isolate *isolate, const char *location, const OOMDetails &details=kNoOOMDetails)
v8::VirtualAddressSpace * GetPlatformVirtualAddressSpace()
const Address segment_start
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
constexpr bool IsAligned(T value, U alignment)
uint32_t first_entry() const
static Segment At(uint32_t offset)
static Segment Containing(uint32_t entry_index)
uint32_t last_entry() const