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

#include <virtual-address-space-page-allocator.h>

Inheritance diagram for v8::base::VirtualAddressSpacePageAllocator:
Collaboration diagram for v8::base::VirtualAddressSpacePageAllocator:

Public Types

using Address = uintptr_t
 
- Public Types inherited from v8::PageAllocator
enum  Permission {
  kNoAccess , kRead , kReadWrite , kReadWriteExecute ,
  kReadExecute , kNoAccessWillJitLater
}
 

Public Member Functions

 VirtualAddressSpacePageAllocator (v8::VirtualAddressSpace *vas)
 
 VirtualAddressSpacePageAllocator (const VirtualAddressSpacePageAllocator &)=delete
 
VirtualAddressSpacePageAllocatoroperator= (const VirtualAddressSpacePageAllocator &)=delete
 
 ~VirtualAddressSpacePageAllocator () override=default
 
size_t AllocatePageSize () override
 
size_t CommitPageSize () override
 
void SetRandomMmapSeed (int64_t seed) override
 
void * GetRandomMmapAddr () override
 
void * AllocatePages (void *hint, size_t size, size_t alignment, Permission access) override
 
bool FreePages (void *address, size_t size) override
 
bool ReleasePages (void *address, size_t size, size_t new_size) override
 
bool SetPermissions (void *address, size_t size, Permission access) override
 
bool RecommitPages (void *address, size_t size, PageAllocator::Permission access) override
 
bool DiscardSystemPages (void *address, size_t size) override
 
bool DecommitPages (void *address, size_t size) override
 
bool SealPages (void *address, size_t size) override
 
- Public Member Functions inherited from v8::PageAllocator
virtual ~PageAllocator ()=default
 
virtual bool ReserveForSharedMemoryMapping (void *address, size_t size)
 
virtual std::unique_ptr< SharedMemoryAllocateSharedPages (size_t length, const void *original_address)
 
virtual bool CanAllocateSharedPages ()
 

Private Attributes

v8::VirtualAddressSpacevas_
 
std::unordered_map< Address, size_t > resized_allocations_
 
Mutex mutex_
 

Detailed Description

Definition at line 20 of file virtual-address-space-page-allocator.h.

Member Typedef Documentation

◆ Address

Constructor & Destructor Documentation

◆ VirtualAddressSpacePageAllocator() [1/2]

v8::base::VirtualAddressSpacePageAllocator::VirtualAddressSpacePageAllocator ( v8::VirtualAddressSpace * vas)
explicit

Definition at line 10 of file virtual-address-space-page-allocator.cc.

◆ VirtualAddressSpacePageAllocator() [2/2]

v8::base::VirtualAddressSpacePageAllocator::VirtualAddressSpacePageAllocator ( const VirtualAddressSpacePageAllocator & )
delete

◆ ~VirtualAddressSpacePageAllocator()

v8::base::VirtualAddressSpacePageAllocator::~VirtualAddressSpacePageAllocator ( )
overridedefault

Member Function Documentation

◆ AllocatePages()

void * v8::base::VirtualAddressSpacePageAllocator::AllocatePages ( void * address,
size_t length,
size_t alignment,
Permission permissions )
overridevirtual

Allocates memory in range with the given alignment and permission.

Implements v8::PageAllocator.

Definition at line 14 of file virtual-address-space-page-allocator.cc.

Here is the call graph for this function:

◆ AllocatePageSize()

size_t v8::base::VirtualAddressSpacePageAllocator::AllocatePageSize ( )
inlineoverridevirtual

Gets the page granularity for AllocatePages and FreePages. Addresses and lengths for those calls should be multiples of AllocatePageSize().

Implements v8::PageAllocator.

Definition at line 33 of file virtual-address-space-page-allocator.h.

◆ CommitPageSize()

size_t v8::base::VirtualAddressSpacePageAllocator::CommitPageSize ( )
inlineoverridevirtual

Gets the page granularity for SetPermissions and ReleasePages. Addresses and lengths for those calls should be multiples of CommitPageSize().

Implements v8::PageAllocator.

Definition at line 35 of file virtual-address-space-page-allocator.h.

◆ DecommitPages()

bool v8::base::VirtualAddressSpacePageAllocator::DecommitPages ( void * address,
size_t size )
overridevirtual

Decommits any wired memory pages in the given range, allowing the OS to reclaim them, and marks the region as inacessible (kNoAccess). The address range stays reserved and can be accessed again later by changing its permissions. However, in that case the memory content is guaranteed to be zero-initialized again. The memory must have been previously allocated by a call to AllocatePages. Returns true on success, false otherwise.

Implements v8::PageAllocator.

Definition at line 71 of file virtual-address-space-page-allocator.cc.

Here is the call graph for this function:

◆ DiscardSystemPages()

bool v8::base::VirtualAddressSpacePageAllocator::DiscardSystemPages ( void * address,
size_t size )
overridevirtual

Frees memory in the given [address, address + size) range. address and size should be operating system page-aligned. The next write to this memory area brings the memory transparently back. This should be treated as a hint to the OS that the pages are no longer needed. It does not guarantee that the pages will be discarded immediately or at all.

Reimplemented from v8::PageAllocator.

Definition at line 66 of file virtual-address-space-page-allocator.cc.

Here is the call graph for this function:

◆ FreePages()

bool v8::base::VirtualAddressSpacePageAllocator::FreePages ( void * address,
size_t length )
overridevirtual

Frees memory in a range that was allocated by a call to AllocatePages.

Implements v8::PageAllocator.

Definition at line 22 of file virtual-address-space-page-allocator.cc.

Here is the call graph for this function:

◆ GetRandomMmapAddr()

void * v8::base::VirtualAddressSpacePageAllocator::GetRandomMmapAddr ( )
inlineoverridevirtual

Returns a randomized address, suitable for memory allocation under ASLR. The address will be aligned to AllocatePageSize.

Implements v8::PageAllocator.

Definition at line 39 of file virtual-address-space-page-allocator.h.

◆ operator=()

VirtualAddressSpacePageAllocator & v8::base::VirtualAddressSpacePageAllocator::operator= ( const VirtualAddressSpacePageAllocator & )
delete

◆ RecommitPages()

bool v8::base::VirtualAddressSpacePageAllocator::RecommitPages ( void * address,
size_t length,
PageAllocator::Permission permissions )
overridevirtual

Recommits discarded pages in the given range with given permissions. Discarded pages must be recommitted with their original permissions before they are used again.

Reimplemented from v8::PageAllocator.

Definition at line 60 of file virtual-address-space-page-allocator.cc.

Here is the call graph for this function:

◆ ReleasePages()

bool v8::base::VirtualAddressSpacePageAllocator::ReleasePages ( void * address,
size_t length,
size_t new_length )
overridevirtual

Releases memory in a range that was allocated by a call to AllocatePages.

Implements v8::PageAllocator.

Definition at line 35 of file virtual-address-space-page-allocator.cc.

Here is the call graph for this function:

◆ SealPages()

bool v8::base::VirtualAddressSpacePageAllocator::SealPages ( void * address,
size_t length )
overridevirtual

Block any modifications to the given mapping such as changing permissions or unmapping the pages on supported platforms. The address space reservation will exist until the process ends, but it's possible to release the memory using DiscardSystemPages. Note that this might require write permissions to the page as e.g. on Linux, mseal will block discarding sealed anonymous memory.

Reimplemented from v8::PageAllocator.

Definition at line 76 of file virtual-address-space-page-allocator.cc.

◆ SetPermissions()

bool v8::base::VirtualAddressSpacePageAllocator::SetPermissions ( void * address,
size_t length,
Permission permissions )
overridevirtual

Sets permissions on pages in an allocated range.

Implements v8::PageAllocator.

Definition at line 54 of file virtual-address-space-page-allocator.cc.

Here is the call graph for this function:

◆ SetRandomMmapSeed()

void v8::base::VirtualAddressSpacePageAllocator::SetRandomMmapSeed ( int64_t seed)
inlineoverridevirtual

Sets the random seed so that GetRandomMmapAddr() will generate repeatable sequences of random mmap addresses.

Implements v8::PageAllocator.

Definition at line 37 of file virtual-address-space-page-allocator.h.

Member Data Documentation

◆ mutex_

Mutex v8::base::VirtualAddressSpacePageAllocator::mutex_
private

Definition at line 72 of file virtual-address-space-page-allocator.h.

◆ resized_allocations_

std::unordered_map<Address, size_t> v8::base::VirtualAddressSpacePageAllocator::resized_allocations_
private

Definition at line 69 of file virtual-address-space-page-allocator.h.

◆ vas_

v8::VirtualAddressSpace* v8::base::VirtualAddressSpacePageAllocator::vas_
private

Definition at line 64 of file virtual-address-space-page-allocator.h.


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