#include "src/heap/memory-allocator.h"
#include <cinttypes>
#include <optional>
#include "src/base/address-region.h"
#include "src/common/globals.h"
#include "src/execution/isolate.h"
#include "src/flags/flags.h"
#include "src/heap/gc-tracer-inl.h"
#include "src/heap/gc-tracer.h"
#include "src/heap/heap-inl.h"
#include "src/heap/heap.h"
#include "src/heap/memory-chunk-metadata.h"
#include "src/heap/mutable-page-metadata.h"
#include "src/heap/read-only-spaces.h"
#include "src/heap/zapping.h"
#include "src/logging/log.h"
#include "src/sandbox/hardware-support.h"
#include "src/utils/allocation.h"
namespace v8 {
namespace internal {
namespace {
void DeleteMemoryChunk(MemoryChunkMetadata* metadata) { … }
}
size_t MemoryAllocator::commit_page_size_ = …;
size_t MemoryAllocator::commit_page_size_bits_ = …;
MemoryAllocator::MemoryAllocator(Isolate* isolate,
v8::PageAllocator* code_page_allocator,
v8::PageAllocator* trusted_page_allocator,
size_t capacity)
: … { … }
void MemoryAllocator::TearDown() { … }
void MemoryAllocator::Pool::ReleasePooledChunks() { … }
size_t MemoryAllocator::Pool::NumberOfCommittedChunks() const { … }
size_t MemoryAllocator::Pool::CommittedBufferedMemory() const { … }
bool MemoryAllocator::CommitMemory(VirtualMemory* reservation,
Executability executable) { … }
bool MemoryAllocator::UncommitMemory(VirtualMemory* reservation) { … }
void MemoryAllocator::FreeMemoryRegion(v8::PageAllocator* page_allocator,
Address base, size_t size) { … }
Address MemoryAllocator::AllocateAlignedMemory(
size_t chunk_size, size_t area_size, size_t alignment,
AllocationSpace space, Executability executable, void* hint,
VirtualMemory* controller) { … }
Address MemoryAllocator::HandleAllocationFailure(Executability executable) { … }
size_t MemoryAllocator::ComputeChunkSize(size_t area_size,
AllocationSpace space) { … }
std::optional<MemoryAllocator::MemoryChunkAllocationResult>
MemoryAllocator::AllocateUninitializedChunkAt(BaseSpace* space,
size_t area_size,
Executability executable,
Address hint,
PageSize page_size) { … }
void MemoryAllocator::PartialFreeMemory(MemoryChunkMetadata* chunk,
Address start_free,
size_t bytes_to_free,
Address new_area_end) { … }
void MemoryAllocator::UnregisterSharedMemoryChunk(MemoryChunkMetadata* chunk) { … }
void MemoryAllocator::UnregisterMemoryChunk(MemoryChunkMetadata* chunk_metadata,
Executability executable) { … }
void MemoryAllocator::UnregisterMutableMemoryChunk(MutablePageMetadata* chunk) { … }
void MemoryAllocator::UnregisterReadOnlyPage(ReadOnlyPageMetadata* page) { … }
void MemoryAllocator::FreeReadOnlyPage(ReadOnlyPageMetadata* chunk) { … }
void MemoryAllocator::PreFreeMemory(MutablePageMetadata* chunk_metadata) { … }
void MemoryAllocator::PerformFreeMemory(MutablePageMetadata* chunk_metadata) { … }
void MemoryAllocator::Free(MemoryAllocator::FreeMode mode,
MutablePageMetadata* chunk_metadata) { … }
PageMetadata* MemoryAllocator::AllocatePage(
MemoryAllocator::AllocationMode alloc_mode, Space* space,
Executability executable) { … }
ReadOnlyPageMetadata* MemoryAllocator::AllocateReadOnlyPage(
ReadOnlySpace* space, Address hint) { … }
std::unique_ptr<::v8::PageAllocator::SharedMemoryMapping>
MemoryAllocator::RemapSharedPage(
::v8::PageAllocator::SharedMemory* shared_memory, Address new_address) { … }
LargePageMetadata* MemoryAllocator::AllocateLargePage(
LargeObjectSpace* space, size_t object_size, Executability executable) { … }
std::optional<MemoryAllocator::MemoryChunkAllocationResult>
MemoryAllocator::AllocateUninitializedPageFromPool(Space* space) { … }
void MemoryAllocator::InitializeOncePerProcess() { … }
base::AddressRegion MemoryAllocator::ComputeDiscardMemoryArea(Address addr,
size_t size) { … }
bool MemoryAllocator::SetPermissionsOnExecutableMemoryChunk(VirtualMemory* vm,
Address start,
size_t chunk_size) { … }
#if defined(V8_ENABLE_CONSERVATIVE_STACK_SCANNING) || defined(DEBUG)
const MemoryChunk* MemoryAllocator::LookupChunkContainingAddress(
Address addr) const { … }
#endif
void MemoryAllocator::RecordMemoryChunkCreated(const MemoryChunk* chunk) { … }
void MemoryAllocator::RecordMemoryChunkDestroyed(const MemoryChunk* chunk) { … }
void MemoryAllocator::ReleaseQueuedPages() { … }
}
}