v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
v8::internal::MemoryAllocator Class Reference

#include <memory-allocator.h>

Collaboration diagram for v8::internal::MemoryAllocator:

Classes

struct  MemoryChunkAllocationResult
 

Public Types

enum class  AllocationMode { kRegular , kUsePool }
 
enum class  FreeMode { kImmediately , kPostpone , kPool }
 

Public Member Functions

V8_EXPORT_PRIVATE MemoryAllocator (Isolate *isolate, v8::PageAllocator *code_page_allocator, v8::PageAllocator *trusted_page_allocator, size_t max_capacity)
 
V8_EXPORT_PRIVATE void TearDown ()
 
V8_EXPORT_PRIVATE PageMetadataAllocatePage (MemoryAllocator::AllocationMode alloc_mode, Space *space, Executability executable)
 
V8_EXPORT_PRIVATE LargePageMetadataAllocateLargePage (LargeObjectSpace *space, size_t object_size, Executability executable)
 
ReadOnlyPageMetadataAllocateReadOnlyPage (ReadOnlySpace *space, Address hint=kNullAddress)
 
std::unique_ptr<::v8::PageAllocator::SharedMemoryMappingRemapSharedPage (::v8::PageAllocator::SharedMemory *shared_memory, Address new_address)
 
V8_EXPORT_PRIVATE void Free (MemoryAllocator::FreeMode mode, MutablePageMetadata *chunk)
 
void FreeReadOnlyPage (ReadOnlyPageMetadata *chunk)
 
size_t Size () const
 
size_t SizeExecutable () const
 
size_t Available () const
 
V8_INLINE bool IsOutsideAllocatedSpace (Address address) const
 
V8_INLINE bool IsOutsideAllocatedSpace (Address address, Executability executable) const
 
void PartialFreeMemory (MemoryChunkMetadata *chunk, Address start_free, size_t bytes_to_free, Address new_area_end)
 
v8::PageAllocatordata_page_allocator ()
 
v8::PageAllocatorcode_page_allocator ()
 
v8::PageAllocatortrusted_page_allocator ()
 
v8::PageAllocatorpage_allocator (AllocationSpace space)
 
PagePoolpool ()
 
void UnregisterReadOnlyPage (ReadOnlyPageMetadata *page)
 
Address HandleAllocationFailure (Executability executable)
 
V8_EXPORT_PRIVATE const MemoryChunkLookupChunkContainingAddress (Address addr) const
 
V8_EXPORT_PRIVATE const MemoryChunkLookupChunkContainingAddressInSafepoint (Address addr) const
 
void RecordMemoryChunkCreated (const MemoryChunk *chunk)
 
void RecordMemoryChunkDestroyed (const MemoryChunk *chunk)
 
void ReleaseQueuedPages ()
 
V8_EXPORT_PRIVATE size_t GetPooledChunksCount ()
 
V8_EXPORT_PRIVATE size_t GetSharedPooledChunksCount ()
 
V8_EXPORT_PRIVATE size_t GetTotalPooledChunksCount ()
 
V8_EXPORT_PRIVATE void ReleasePooledChunksImmediately ()
 

Static Public Member Functions

static void InitializeOncePerProcess ()
 
static V8_INLINE intptr_t GetCommitPageSize ()
 
static V8_INLINE intptr_t GetCommitPageSizeBits ()
 
static void DeleteMemoryChunk (MutablePageMetadata *metadata)
 

Private Member Functions

V8_WARN_UNUSED_RESULT std::optional< MemoryChunkAllocationResultAllocateUninitializedChunk (BaseSpace *space, size_t area_size, Executability executable, PageSize page_size)
 
V8_WARN_UNUSED_RESULT std::optional< MemoryChunkAllocationResultAllocateUninitializedChunkAt (BaseSpace *space, size_t area_size, Executability executable, Address hint, PageSize page_size)
 
Address AllocateAlignedMemory (size_t chunk_size, size_t area_size, size_t alignment, AllocationSpace space, Executability executable, void *hint, VirtualMemory *controller)
 
bool CommitMemory (VirtualMemory *reservation, Executability executable)
 
V8_WARN_UNUSED_RESULT bool SetPermissionsOnExecutableMemoryChunk (VirtualMemory *vm, Address start, size_t reserved_size)
 
bool UncommitMemory (VirtualMemory *reservation)
 
void FreeMemoryRegion (v8::PageAllocator *page_allocator, Address addr, size_t size)
 
void PreFreeMemory (MutablePageMetadata *chunk)
 
void PerformFreeMemory (MutablePageMetadata *chunk)
 
std::optional< MemoryChunkAllocationResultAllocateUninitializedPageFromPool (Space *space)
 
PageMetadataInitializePagesInChunk (int chunk_id, int pages_in_chunk, PagedSpace *space)
 
void UpdateAllocatedSpaceLimits (Address low, Address high, Executability executable)
 
void UnregisterMutableMemoryChunk (MutablePageMetadata *chunk)
 
void UnregisterSharedMemoryChunk (MemoryChunkMetadata *chunk)
 
void UnregisterMemoryChunk (MemoryChunkMetadata *chunk, Executability executable=NOT_EXECUTABLE)
 
void RegisterReadOnlyMemory (ReadOnlyPageMetadata *page)
 
 DISALLOW_IMPLICIT_CONSTRUCTORS (MemoryAllocator)
 

Static Private Member Functions

static size_t ComputeChunkSize (size_t area_size, AllocationSpace space)
 

Private Attributes

Isolateisolate_
 
v8::PageAllocatordata_page_allocator_
 
v8::PageAllocatorcode_page_allocator_
 
v8::PageAllocatortrusted_page_allocator_
 
size_t capacity_
 
std::atomic< size_tsize_ = 0
 
std::atomic< size_tsize_executable_ = 0
 
std::atomic< Addresslowest_not_executable_ever_allocated_
 
std::atomic< Addresshighest_not_executable_ever_allocated_ {kNullAddress}
 
std::atomic< Addresslowest_executable_ever_allocated_
 
std::atomic< Addresshighest_executable_ever_allocated_ {kNullAddress}
 
std::optional< VirtualMemoryreserved_chunk_at_virtual_memory_limit_
 
PagePoolpool_
 
std::vector< MutablePageMetadata * > queued_pages_to_be_freed_
 
std::unordered_set< const MemoryChunk *, base::hash< const MemoryChunk * > > normal_pages_
 
std::set< const MemoryChunk * > large_pages_
 
base::Mutex chunks_mutex_
 

Static Private Attributes

static V8_EXPORT_PRIVATE size_t commit_page_size_ = 0
 
static V8_EXPORT_PRIVATE size_t commit_page_size_bits_ = 0
 

Friends

class heap::TestCodePageAllocatorScope
 
class heap::TestMemoryAllocatorScope
 

Detailed Description

Definition at line 46 of file memory-allocator.h.

Member Enumeration Documentation

◆ AllocationMode

Enumerator
kRegular 
kUsePool 

Definition at line 48 of file memory-allocator.h.

◆ FreeMode

Enumerator
kImmediately 
kPostpone 
kPool 

Definition at line 56 of file memory-allocator.h.

Constructor & Destructor Documentation

◆ MemoryAllocator()

v8::internal::MemoryAllocator::MemoryAllocator ( Isolate * isolate,
v8::PageAllocator * code_page_allocator,
v8::PageAllocator * trusted_page_allocator,
size_t max_capacity )

Definition at line 37 of file memory-allocator.cc.

Here is the call graph for this function:

Member Function Documentation

◆ AllocateAlignedMemory()

Address v8::internal::MemoryAllocator::AllocateAlignedMemory ( size_t chunk_size,
size_t area_size,
size_t alignment,
AllocationSpace space,
Executability executable,
void * hint,
VirtualMemory * controller )
private

Definition at line 111 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AllocateLargePage()

LargePageMetadata * v8::internal::MemoryAllocator::AllocateLargePage ( LargeObjectSpace * space,
size_t object_size,
Executability executable )

Definition at line 478 of file memory-allocator.cc.

Here is the call graph for this function:

◆ AllocatePage()

PageMetadata * v8::internal::MemoryAllocator::AllocatePage ( MemoryAllocator::AllocationMode alloc_mode,
Space * space,
Executability executable )

Definition at line 387 of file memory-allocator.cc.

Here is the call graph for this function:

◆ AllocateReadOnlyPage()

ReadOnlyPageMetadata * v8::internal::MemoryAllocator::AllocateReadOnlyPage ( ReadOnlySpace * space,
Address hint = kNullAddress )

Definition at line 448 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AllocateUninitializedChunk()

V8_WARN_UNUSED_RESULT std::optional< MemoryChunkAllocationResult > v8::internal::MemoryAllocator::AllocateUninitializedChunk ( BaseSpace * space,
size_t area_size,
Executability executable,
PageSize page_size )
inlineprivate

Definition at line 248 of file memory-allocator.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AllocateUninitializedChunkAt()

std::optional< MemoryAllocator::MemoryChunkAllocationResult > v8::internal::MemoryAllocator::AllocateUninitializedChunkAt ( BaseSpace * space,
size_t area_size,
Executability executable,
Address hint,
PageSize page_size )
private

Definition at line 183 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ AllocateUninitializedPageFromPool()

std::optional< MemoryAllocator::MemoryChunkAllocationResult > v8::internal::MemoryAllocator::AllocateUninitializedPageFromPool ( Space * space)
private

Definition at line 514 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Available()

size_t v8::internal::MemoryAllocator::Available ( ) const
inline

Definition at line 116 of file memory-allocator.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ code_page_allocator()

v8::PageAllocator * v8::internal::MemoryAllocator::code_page_allocator ( )
inline

Definition at line 164 of file memory-allocator.h.

◆ CommitMemory()

bool v8::internal::MemoryAllocator::CommitMemory ( VirtualMemory * reservation,
Executability executable )
private

Definition at line 86 of file memory-allocator.cc.

Here is the call graph for this function:

◆ ComputeChunkSize()

size_t v8::internal::MemoryAllocator::ComputeChunkSize ( size_t area_size,
AllocationSpace space )
staticprivate

Definition at line 165 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ data_page_allocator()

v8::PageAllocator * v8::internal::MemoryAllocator::data_page_allocator ( )
inline

Definition at line 160 of file memory-allocator.h.

Here is the caller graph for this function:

◆ DeleteMemoryChunk()

void v8::internal::MemoryAllocator::DeleteMemoryChunk ( MutablePageMetadata * metadata)
static

Definition at line 635 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DISALLOW_IMPLICIT_CONSTRUCTORS()

v8::internal::MemoryAllocator::DISALLOW_IMPLICIT_CONSTRUCTORS ( MemoryAllocator )
private

◆ Free()

void v8::internal::MemoryAllocator::Free ( MemoryAllocator::FreeMode mode,
MutablePageMetadata * chunk )

Definition at line 358 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FreeMemoryRegion()

void v8::internal::MemoryAllocator::FreeMemoryRegion ( v8::PageAllocator * page_allocator,
Address addr,
size_t size )
private

Definition at line 106 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FreeReadOnlyPage()

void v8::internal::MemoryAllocator::FreeReadOnlyPage ( ReadOnlyPageMetadata * chunk)

Definition at line 316 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetCommitPageSize()

static V8_INLINE intptr_t v8::internal::MemoryAllocator::GetCommitPageSize ( )
inlinestatic

Definition at line 72 of file memory-allocator.h.

Here is the caller graph for this function:

◆ GetCommitPageSizeBits()

static V8_INLINE intptr_t v8::internal::MemoryAllocator::GetCommitPageSizeBits ( )
inlinestatic

Definition at line 77 of file memory-allocator.h.

Here is the caller graph for this function:

◆ GetPooledChunksCount()

size_t v8::internal::MemoryAllocator::GetPooledChunksCount ( )

Definition at line 70 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSharedPooledChunksCount()

size_t v8::internal::MemoryAllocator::GetSharedPooledChunksCount ( )

Definition at line 74 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTotalPooledChunksCount()

size_t v8::internal::MemoryAllocator::GetTotalPooledChunksCount ( )

Definition at line 78 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ HandleAllocationFailure()

Address v8::internal::MemoryAllocator::HandleAllocationFailure ( Executability executable)

Definition at line 154 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializeOncePerProcess()

void v8::internal::MemoryAllocator::InitializeOncePerProcess ( )
static

Definition at line 539 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InitializePagesInChunk()

PageMetadata * v8::internal::MemoryAllocator::InitializePagesInChunk ( int chunk_id,
int pages_in_chunk,
PagedSpace * space )
private

◆ IsOutsideAllocatedSpace() [1/2]

V8_INLINE bool v8::internal::MemoryAllocator::IsOutsideAllocatedSpace ( Address address) const
inline

Definition at line 126 of file memory-allocator.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsOutsideAllocatedSpace() [2/2]

V8_INLINE bool v8::internal::MemoryAllocator::IsOutsideAllocatedSpace ( Address address,
Executability executable ) const
inline

Definition at line 130 of file memory-allocator.h.

◆ LookupChunkContainingAddress()

const MemoryChunk * v8::internal::MemoryAllocator::LookupChunkContainingAddress ( Address addr) const

Definition at line 566 of file memory-allocator.cc.

Here is the call graph for this function:

◆ LookupChunkContainingAddressInSafepoint()

const MemoryChunk * v8::internal::MemoryAllocator::LookupChunkContainingAddressInSafepoint ( Address addr) const

Definition at line 572 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ page_allocator()

v8::PageAllocator * v8::internal::MemoryAllocator::page_allocator ( AllocationSpace space)
inline

Definition at line 175 of file memory-allocator.h.

Here is the caller graph for this function:

◆ PartialFreeMemory()

void v8::internal::MemoryAllocator::PartialFreeMemory ( MemoryChunkMetadata * chunk,
Address start_free,
size_t bytes_to_free,
Address new_area_end )

Definition at line 242 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PerformFreeMemory()

void v8::internal::MemoryAllocator::PerformFreeMemory ( MutablePageMetadata * chunk)
private

Definition at line 348 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pool()

PagePool * v8::internal::MemoryAllocator::pool ( )
inline

Definition at line 190 of file memory-allocator.h.

Here is the caller graph for this function:

◆ PreFreeMemory()

void v8::internal::MemoryAllocator::PreFreeMemory ( MutablePageMetadata * chunk)
private

Definition at line 337 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecordMemoryChunkCreated()

void v8::internal::MemoryAllocator::RecordMemoryChunkCreated ( const MemoryChunk * chunk)

Definition at line 601 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecordMemoryChunkDestroyed()

void v8::internal::MemoryAllocator::RecordMemoryChunkDestroyed ( const MemoryChunk * chunk)

Definition at line 614 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RegisterReadOnlyMemory()

void v8::internal::MemoryAllocator::RegisterReadOnlyMemory ( ReadOnlyPageMetadata * page)
private

◆ ReleasePooledChunksImmediately()

void v8::internal::MemoryAllocator::ReleasePooledChunksImmediately ( )

Definition at line 82 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReleaseQueuedPages()

void v8::internal::MemoryAllocator::ReleaseQueuedPages ( )

Definition at line 627 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemapSharedPage()

std::unique_ptr<::v8::PageAllocator::SharedMemoryMapping > v8::internal::MemoryAllocator::RemapSharedPage ( ::v8::PageAllocator::SharedMemory * shared_memory,
Address new_address )

Definition at line 473 of file memory-allocator.cc.

Here is the call graph for this function:

◆ SetPermissionsOnExecutableMemoryChunk()

bool v8::internal::MemoryAllocator::SetPermissionsOnExecutableMemoryChunk ( VirtualMemory * vm,
Address start,
size_t reserved_size )
private

Definition at line 547 of file memory-allocator.cc.

Here is the call graph for this function:

◆ Size()

size_t v8::internal::MemoryAllocator::Size ( ) const
inline

Definition at line 110 of file memory-allocator.h.

Here is the caller graph for this function:

◆ SizeExecutable()

size_t v8::internal::MemoryAllocator::SizeExecutable ( ) const
inline

Definition at line 113 of file memory-allocator.h.

Here is the caller graph for this function:

◆ TearDown()

void v8::internal::MemoryAllocator::TearDown ( )

Definition at line 52 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ trusted_page_allocator()

v8::PageAllocator * v8::internal::MemoryAllocator::trusted_page_allocator ( )
inline

Definition at line 170 of file memory-allocator.h.

◆ UncommitMemory()

bool v8::internal::MemoryAllocator::UncommitMemory ( VirtualMemory * reservation)
private

Definition at line 97 of file memory-allocator.cc.

Here is the call graph for this function:

◆ UnregisterMemoryChunk()

void v8::internal::MemoryAllocator::UnregisterMemoryChunk ( MemoryChunkMetadata * chunk,
Executability executable = NOT_EXECUTABLE )
private

Definition at line 283 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnregisterMutableMemoryChunk()

void v8::internal::MemoryAllocator::UnregisterMutableMemoryChunk ( MutablePageMetadata * chunk)
private

Definition at line 307 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnregisterReadOnlyPage()

void v8::internal::MemoryAllocator::UnregisterReadOnlyPage ( ReadOnlyPageMetadata * page)

Definition at line 311 of file memory-allocator.cc.

Here is the call graph for this function:

◆ UnregisterSharedMemoryChunk()

void v8::internal::MemoryAllocator::UnregisterSharedMemoryChunk ( MemoryChunkMetadata * chunk)
private

Definition at line 275 of file memory-allocator.cc.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateAllocatedSpaceLimits()

void v8::internal::MemoryAllocator::UpdateAllocatedSpaceLimits ( Address low,
Address high,
Executability executable )
inlineprivate

Definition at line 304 of file memory-allocator.h.

Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ heap::TestCodePageAllocatorScope

friend class heap::TestCodePageAllocatorScope
friend

Definition at line 430 of file memory-allocator.h.

◆ heap::TestMemoryAllocatorScope

friend class heap::TestMemoryAllocatorScope
friend

Definition at line 431 of file memory-allocator.h.

Member Data Documentation

◆ capacity_

size_t v8::internal::MemoryAllocator::capacity_
private

Definition at line 386 of file memory-allocator.h.

◆ chunks_mutex_

base::Mutex v8::internal::MemoryAllocator::chunks_mutex_
mutableprivate

Definition at line 425 of file memory-allocator.h.

◆ code_page_allocator_

v8::PageAllocator* v8::internal::MemoryAllocator::code_page_allocator_
private

Definition at line 377 of file memory-allocator.h.

◆ commit_page_size_

size_t v8::internal::MemoryAllocator::commit_page_size_ = 0
staticprivate

Definition at line 427 of file memory-allocator.h.

◆ commit_page_size_bits_

size_t v8::internal::MemoryAllocator::commit_page_size_bits_ = 0
staticprivate

Definition at line 428 of file memory-allocator.h.

◆ data_page_allocator_

v8::PageAllocator* v8::internal::MemoryAllocator::data_page_allocator_
private

Definition at line 370 of file memory-allocator.h.

◆ highest_executable_ever_allocated_

std::atomic<Address> v8::internal::MemoryAllocator::highest_executable_ever_allocated_ {kNullAddress}
private

Definition at line 405 of file memory-allocator.h.

◆ highest_not_executable_ever_allocated_

std::atomic<Address> v8::internal::MemoryAllocator::highest_not_executable_ever_allocated_ {kNullAddress}
private

Definition at line 402 of file memory-allocator.h.

◆ isolate_

Isolate* v8::internal::MemoryAllocator::isolate_
private

Definition at line 365 of file memory-allocator.h.

◆ large_pages_

std::set<const MemoryChunk*> v8::internal::MemoryAllocator::large_pages_
private

Definition at line 423 of file memory-allocator.h.

◆ lowest_executable_ever_allocated_

std::atomic<Address> v8::internal::MemoryAllocator::lowest_executable_ever_allocated_
private
Initial value:
{
static_cast<Address>(-1ll)}

Definition at line 403 of file memory-allocator.h.

◆ lowest_not_executable_ever_allocated_

std::atomic<Address> v8::internal::MemoryAllocator::lowest_not_executable_ever_allocated_
private
Initial value:
{
static_cast<Address>(-1ll)}

Definition at line 400 of file memory-allocator.h.

◆ normal_pages_

std::unordered_set<const MemoryChunk*, base::hash<const MemoryChunk*> > v8::internal::MemoryAllocator::normal_pages_
private

Definition at line 422 of file memory-allocator.h.

◆ pool_

PagePool* v8::internal::MemoryAllocator::pool_
private

Definition at line 408 of file memory-allocator.h.

◆ queued_pages_to_be_freed_

std::vector<MutablePageMetadata*> v8::internal::MemoryAllocator::queued_pages_to_be_freed_
private

Definition at line 409 of file memory-allocator.h.

◆ reserved_chunk_at_virtual_memory_limit_

std::optional<VirtualMemory> v8::internal::MemoryAllocator::reserved_chunk_at_virtual_memory_limit_
private

Definition at line 407 of file memory-allocator.h.

◆ size_

std::atomic<size_t> v8::internal::MemoryAllocator::size_ = 0
private

Definition at line 389 of file memory-allocator.h.

◆ size_executable_

std::atomic<size_t> v8::internal::MemoryAllocator::size_executable_ = 0
private

Definition at line 391 of file memory-allocator.h.

◆ trusted_page_allocator_

v8::PageAllocator* v8::internal::MemoryAllocator::trusted_page_allocator_
private

Definition at line 383 of file memory-allocator.h.


The documentation for this class was generated from the following files: