![]() |
v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
|
#include <virtual-address-space-page-allocator.h>
Public Types | |
using | Address = uintptr_t |
![]() | |
enum | Permission { kNoAccess , kRead , kReadWrite , kReadWriteExecute , kReadExecute , kNoAccessWillJitLater } |
Public Member Functions | |
VirtualAddressSpacePageAllocator (v8::VirtualAddressSpace *vas) | |
VirtualAddressSpacePageAllocator (const VirtualAddressSpacePageAllocator &)=delete | |
VirtualAddressSpacePageAllocator & | operator= (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 |
![]() | |
virtual | ~PageAllocator ()=default |
virtual bool | ReserveForSharedMemoryMapping (void *address, size_t size) |
virtual std::unique_ptr< SharedMemory > | AllocateSharedPages (size_t length, const void *original_address) |
virtual bool | CanAllocateSharedPages () |
Private Attributes | |
v8::VirtualAddressSpace * | vas_ |
std::unordered_map< Address, size_t > | resized_allocations_ |
Mutex | mutex_ |
Definition at line 20 of file virtual-address-space-page-allocator.h.
using v8::base::VirtualAddressSpacePageAllocator::Address = uintptr_t |
Definition at line 23 of file virtual-address-space-page-allocator.h.
|
explicit |
Definition at line 10 of file virtual-address-space-page-allocator.cc.
|
delete |
|
overridedefault |
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
delete |
|
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.
|
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.
|
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.
|
overridevirtual |
Sets permissions on pages in an allocated range.
Implements v8::PageAllocator.
Definition at line 54 of file virtual-address-space-page-allocator.cc.
|
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.
|
private |
Definition at line 72 of file virtual-address-space-page-allocator.h.
|
private |
Definition at line 69 of file virtual-address-space-page-allocator.h.
|
private |
Definition at line 64 of file virtual-address-space-page-allocator.h.