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

#include <bounded-page-allocator.h>

Inheritance diagram for v8::base::BoundedPageAllocator:
Collaboration diagram for v8::base::BoundedPageAllocator:

Public Types

enum class  AllocationStatus { kSuccess , kFailedToCommit , kRanOutOfReservation , kHintedAddressTakenOrNotFound }
 
using Address = uintptr_t
 
- Public Types inherited from v8::PageAllocator
enum  Permission {
  kNoAccess , kRead , kReadWrite , kReadWriteExecute ,
  kReadExecute , kNoAccessWillJitLater
}
 

Public Member Functions

 BoundedPageAllocator (v8::PageAllocator *page_allocator, Address start, size_t size, size_t allocate_page_size, PageInitializationMode page_initialization_mode, PageFreeingMode page_freeing_mode)
 
 BoundedPageAllocator (const BoundedPageAllocator &)=delete
 
BoundedPageAllocatoroperator= (const BoundedPageAllocator &)=delete
 
 ~BoundedPageAllocator () override=default
 
Address begin () const
 
size_t size () const
 
bool contains (Address address) const
 
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 ReserveForSharedMemoryMapping (void *address, size_t size) override
 
bool AllocatePagesAt (Address address, size_t size, Permission access)
 
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
 
AllocationStatus get_last_allocation_status () const
 
- Public Member Functions inherited from v8::PageAllocator
virtual ~PageAllocator ()=default
 
virtual std::unique_ptr< SharedMemoryAllocateSharedPages (size_t length, const void *original_address)
 
virtual bool CanAllocateSharedPages ()
 

Static Public Member Functions

static const char * AllocationStatusToString (AllocationStatus)
 

Private Attributes

v8::base::Mutex mutex_
 
const size_t allocate_page_size_
 
const size_t commit_page_size_
 
v8::PageAllocator *const page_allocator_
 
v8::base::RegionAllocator region_allocator_
 
const PageInitializationMode page_initialization_mode_
 
const PageFreeingMode page_freeing_mode_
 
AllocationStatus allocation_status_ = AllocationStatus::kSuccess
 

Detailed Description

Definition at line 58 of file bounded-page-allocator.h.

Member Typedef Documentation

◆ Address

Definition at line 67 of file bounded-page-allocator.h.

Member Enumeration Documentation

◆ AllocationStatus

Enumerator
kSuccess 
kFailedToCommit 
kRanOutOfReservation 
kHintedAddressTakenOrNotFound 

Definition at line 60 of file bounded-page-allocator.h.

Constructor & Destructor Documentation

◆ BoundedPageAllocator() [1/2]

v8::base::BoundedPageAllocator::BoundedPageAllocator ( v8::PageAllocator * page_allocator,
Address start,
size_t size,
size_t allocate_page_size,
PageInitializationMode page_initialization_mode,
PageFreeingMode page_freeing_mode )

Definition at line 10 of file bounded-page-allocator.cc.

Here is the call graph for this function:

◆ BoundedPageAllocator() [2/2]

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

◆ ~BoundedPageAllocator()

v8::base::BoundedPageAllocator::~BoundedPageAllocator ( )
overridedefault

Member Function Documentation

◆ AllocatePages()

void * v8::base::BoundedPageAllocator::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 31 of file bounded-page-allocator.cc.

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

◆ AllocatePagesAt()

bool v8::base::BoundedPageAllocator::AllocatePagesAt ( Address address,
size_t size,
PageAllocator::Permission access )

Definition at line 89 of file bounded-page-allocator.cc.

Here is the call graph for this function:

◆ AllocatePageSize()

size_t v8::base::BoundedPageAllocator::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 89 of file bounded-page-allocator.h.

Here is the caller graph for this function:

◆ AllocationStatusToString()

const char * v8::base::BoundedPageAllocator::AllocationStatusToString ( AllocationStatus allocation_status)
static

Definition at line 262 of file bounded-page-allocator.cc.

Here is the caller graph for this function:

◆ begin()

BoundedPageAllocator::Address v8::base::BoundedPageAllocator::begin ( ) const

Definition at line 25 of file bounded-page-allocator.cc.

Here is the call graph for this function:

◆ CommitPageSize()

size_t v8::base::BoundedPageAllocator::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 91 of file bounded-page-allocator.h.

Here is the caller graph for this function:

◆ contains()

bool v8::base::BoundedPageAllocator::contains ( Address address) const
inline

Definition at line 85 of file bounded-page-allocator.h.

◆ DecommitPages()

bool v8::base::BoundedPageAllocator::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 254 of file bounded-page-allocator.cc.

Here is the call graph for this function:

◆ DiscardSystemPages()

bool v8::base::BoundedPageAllocator::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 250 of file bounded-page-allocator.cc.

Here is the call graph for this function:

◆ FreePages()

bool v8::base::BoundedPageAllocator::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 144 of file bounded-page-allocator.cc.

Here is the call graph for this function:

◆ get_last_allocation_status()

AllocationStatus v8::base::BoundedPageAllocator::get_last_allocation_status ( ) const
inline

Definition at line 124 of file bounded-page-allocator.h.

Here is the caller graph for this function:

◆ GetRandomMmapAddr()

void * v8::base::BoundedPageAllocator::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 97 of file bounded-page-allocator.h.

Here is the call graph for this function:

◆ operator=()

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

◆ RecommitPages()

bool v8::base::BoundedPageAllocator::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 238 of file bounded-page-allocator.cc.

Here is the call graph for this function:

◆ ReleasePages()

bool v8::base::BoundedPageAllocator::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 180 of file bounded-page-allocator.cc.

Here is the call graph for this function:

◆ ReserveForSharedMemoryMapping()

bool v8::base::BoundedPageAllocator::ReserveForSharedMemoryMapping ( void * address,
size_t size )
overridevirtual

INTERNAL ONLY: This interface has not been stabilised and may change without notice from one release to another without being deprecated first.

Reserve pages at a fixed address returning whether the reservation is possible. The reserved memory is detached from the PageAllocator and so should not be freed by it. It's intended for use with SharedMemory::RemapTo, where ~SharedMemoryMapping would free the memory.

Reimplemented from v8::PageAllocator.

Definition at line 115 of file bounded-page-allocator.cc.

Here is the call graph for this function:

◆ SealPages()

bool v8::base::BoundedPageAllocator::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 258 of file bounded-page-allocator.cc.

Here is the call graph for this function:

◆ SetPermissions()

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

Sets permissions on pages in an allocated range.

Implements v8::PageAllocator.

Definition at line 226 of file bounded-page-allocator.cc.

Here is the call graph for this function:

◆ SetRandomMmapSeed()

void v8::base::BoundedPageAllocator::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 93 of file bounded-page-allocator.h.

Here is the call graph for this function:

◆ size()

size_t v8::base::BoundedPageAllocator::size ( ) const

Definition at line 29 of file bounded-page-allocator.cc.

Here is the call graph for this function:

Member Data Documentation

◆ allocate_page_size_

const size_t v8::base::BoundedPageAllocator::allocate_page_size_
private

Definition at line 130 of file bounded-page-allocator.h.

◆ allocation_status_

AllocationStatus v8::base::BoundedPageAllocator::allocation_status_ = AllocationStatus::kSuccess
private

Definition at line 136 of file bounded-page-allocator.h.

◆ commit_page_size_

const size_t v8::base::BoundedPageAllocator::commit_page_size_
private

Definition at line 131 of file bounded-page-allocator.h.

◆ mutex_

v8::base::Mutex v8::base::BoundedPageAllocator::mutex_
private

Definition at line 129 of file bounded-page-allocator.h.

◆ page_allocator_

v8::PageAllocator* const v8::base::BoundedPageAllocator::page_allocator_
private

Definition at line 132 of file bounded-page-allocator.h.

◆ page_freeing_mode_

const PageFreeingMode v8::base::BoundedPageAllocator::page_freeing_mode_
private

Definition at line 135 of file bounded-page-allocator.h.

◆ page_initialization_mode_

const PageInitializationMode v8::base::BoundedPageAllocator::page_initialization_mode_
private

Definition at line 134 of file bounded-page-allocator.h.

◆ region_allocator_

v8::base::RegionAllocator v8::base::BoundedPageAllocator::region_allocator_
private

Definition at line 133 of file bounded-page-allocator.h.


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