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

#include <v8-platform.h>

Inheritance diagram for v8::PageAllocator:
Collaboration diagram for v8::PageAllocator:

Classes

class  SharedMemory
 
class  SharedMemoryMapping
 

Public Types

enum  Permission {
  kNoAccess , kRead , kReadWrite , kReadWriteExecute ,
  kReadExecute , kNoAccessWillJitLater
}
 

Public Member Functions

virtual ~PageAllocator ()=default
 
virtual size_t AllocatePageSize ()=0
 
virtual size_t CommitPageSize ()=0
 
virtual void SetRandomMmapSeed (int64_t seed)=0
 
virtual void * GetRandomMmapAddr ()=0
 
virtual void * AllocatePages (void *address, size_t length, size_t alignment, Permission permissions)=0
 
virtual bool FreePages (void *address, size_t length)=0
 
virtual bool ReleasePages (void *address, size_t length, size_t new_length)=0
 
virtual bool SetPermissions (void *address, size_t length, Permission permissions)=0
 
virtual bool RecommitPages (void *address, size_t length, Permission permissions)
 
virtual bool DiscardSystemPages (void *address, size_t size)
 
virtual bool DecommitPages (void *address, size_t size)=0
 
virtual bool SealPages (void *address, size_t length)
 
virtual bool ReserveForSharedMemoryMapping (void *address, size_t size)
 
virtual std::unique_ptr< SharedMemoryAllocateSharedPages (size_t length, const void *original_address)
 
virtual bool CanAllocateSharedPages ()
 

Detailed Description

A V8 memory page allocator.

Can be implemented by an embedder to manage large host OS allocations.

Definition at line 455 of file v8-platform.h.

Member Enumeration Documentation

◆ Permission

Memory permissions.

Enumerator
kNoAccess 
kRead 
kReadWrite 
kReadWriteExecute 
kReadExecute 
kNoAccessWillJitLater 

Definition at line 486 of file v8-platform.h.

Constructor & Destructor Documentation

◆ ~PageAllocator()

virtual v8::PageAllocator::~PageAllocator ( )
virtualdefault

Member Function Documentation

◆ AllocatePages()

virtual void * v8::PageAllocator::AllocatePages ( void * address,
size_t length,
size_t alignment,
Permission permissions )
pure virtual

Allocates memory in range with the given alignment and permission.

Implemented in v8::base::BoundedPageAllocator, v8::base::LsanPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Here is the caller graph for this function:

◆ AllocatePageSize()

virtual size_t v8::PageAllocator::AllocatePageSize ( )
pure virtual

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

Implemented in v8::base::BoundedPageAllocator, v8::base::LsanPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Here is the caller graph for this function:

◆ AllocateSharedPages()

virtual std::unique_ptr< SharedMemory > v8::PageAllocator::AllocateSharedPages ( size_t length,
const void * original_address )
inlinevirtual

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

Allocates shared memory pages. Not all PageAllocators need support this and so this method need not be overridden. Allocates a new read-only shared memory region of size |length| and copies the memory at |original_address| into it.

Reimplemented in v8::base::LsanPageAllocator.

Definition at line 616 of file v8-platform.h.

Here is the caller graph for this function:

◆ CanAllocateSharedPages()

virtual bool v8::PageAllocator::CanAllocateSharedPages ( )
inlinevirtual

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

If not overridden and changed to return true, V8 will not attempt to call AllocateSharedPages or RemapSharedPages. If overridden, AllocateSharedPages and RemapSharedPages must also be overridden.

Reimplemented in v8::base::LsanPageAllocator.

Definition at line 629 of file v8-platform.h.

Here is the caller graph for this function:

◆ CommitPageSize()

virtual size_t v8::PageAllocator::CommitPageSize ( )
pure virtual

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

Implemented in v8::base::BoundedPageAllocator, v8::base::LsanPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Here is the caller graph for this function:

◆ DecommitPages()

virtual bool v8::PageAllocator::DecommitPages ( void * address,
size_t size )
pure virtual

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.

Implemented in v8::base::BoundedPageAllocator, v8::base::LsanPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Here is the caller graph for this function:

◆ DiscardSystemPages()

virtual bool v8::PageAllocator::DiscardSystemPages ( void * address,
size_t size )
inlinevirtual

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 in v8::base::BoundedPageAllocator, v8::base::LsanPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Definition at line 543 of file v8-platform.h.

Here is the caller graph for this function:

◆ FreePages()

virtual bool v8::PageAllocator::FreePages ( void * address,
size_t length )
pure virtual

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

Implemented in v8::base::BoundedPageAllocator, v8::base::LsanPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Here is the caller graph for this function:

◆ GetRandomMmapAddr()

virtual void * v8::PageAllocator::GetRandomMmapAddr ( )
pure virtual

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

Implemented in v8::base::BoundedPageAllocator, v8::base::LsanPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Here is the caller graph for this function:

◆ RecommitPages()

virtual bool v8::PageAllocator::RecommitPages ( void * address,
size_t length,
Permission permissions )
inlinevirtual

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 in v8::base::BoundedPageAllocator, v8::base::LsanPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Definition at line 530 of file v8-platform.h.

Here is the caller graph for this function:

◆ ReleasePages()

virtual bool v8::PageAllocator::ReleasePages ( void * address,
size_t length,
size_t new_length )
pure virtual

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

Implemented in v8::base::BoundedPageAllocator, v8::base::LsanPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Here is the caller graph for this function:

◆ ReserveForSharedMemoryMapping()

virtual bool v8::PageAllocator::ReserveForSharedMemoryMapping ( void * address,
size_t size )
inlinevirtual

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 in v8::base::BoundedPageAllocator.

Definition at line 603 of file v8-platform.h.

◆ SealPages()

virtual bool v8::PageAllocator::SealPages ( void * address,
size_t length )
inlinevirtual

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 in v8::base::BoundedPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Definition at line 563 of file v8-platform.h.

Here is the caller graph for this function:

◆ SetPermissions()

virtual bool v8::PageAllocator::SetPermissions ( void * address,
size_t length,
Permission permissions )
pure virtual

Sets permissions on pages in an allocated range.

Implemented in v8::base::BoundedPageAllocator, v8::base::LsanPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Here is the caller graph for this function:

◆ SetRandomMmapSeed()

virtual void v8::PageAllocator::SetRandomMmapSeed ( int64_t seed)
pure virtual

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

Implemented in v8::base::BoundedPageAllocator, v8::base::LsanPageAllocator, and v8::base::VirtualAddressSpacePageAllocator.

Here is the caller graph for this function:

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