Pyrogenesis
trunk
|
Enumerations | |
enum | PageType { kLarge, kSmall, kDefault } |
Functions | |
void * | ReserveAddressSpace (size_t size, size_t commitSize=largePageSize, PageType pageType=kDefault, int prot=PROT_READ|PROT_WRITE) |
reserve address space and set the parameters for any later on-demand commits. More... | |
void | ReleaseAddressSpace (void *p, size_t size=0) |
release address space and decommit any memory. More... | |
bool | Commit (uintptr_t address, size_t size, PageType pageType=kDefault, int prot=PROT_READ|PROT_WRITE) |
map physical memory to previously reserved address space. More... | |
bool | Decommit (uintptr_t address, size_t size) |
unmap physical memory. More... | |
bool | Protect (uintptr_t address, size_t size, int prot) |
set the memory protection flags for all pages that intersect the given interval. More... | |
void * | Allocate (size_t size, PageType pageType=kDefault, int prot=PROT_READ|PROT_WRITE) |
reserve address space and commit memory. More... | |
void | Free (void *p, size_t size=0) |
decommit memory and release address space. More... | |
void | BeginOnDemandCommits () |
install a handler that attempts to commit memory whenever a read/write page fault is encountered. More... | |
void | EndOnDemandCommits () |
decrements the reference count begun by BeginOnDemandCommit and removes the page fault handler when it reaches 0. More... | |
void | DumpStatistics () |
CACHE_ALIGNED (struct Statistics) | |
static bool | ShouldUseLargePages (size_t allocationSize, DWORD allocationType, PageType pageType) |
static void * | AllocateLargeOrSmallPages (uintptr_t address, size_t size, DWORD allocationType, PageType pageType=kDefault, int prot=PROT_READ|PROT_WRITE) |
CACHE_ALIGNED (struct AddressRangeDescriptor) | |
static AddressRangeDescriptor * | FindDescriptor (uintptr_t address) |
TIMER_ADD_CLIENT (tc_commit) | |
static LONG CALLBACK | VectoredHandler (const PEXCEPTION_POINTERS ep) |
static Status | InitHandler () |
static void | ShutdownHandler () |
Variables | |
static bool | largePageAllocationTookTooLong = false |
static AddressRangeDescriptor | ranges [2 *os_cpu_MaxProcessors] |
static PVOID | handler |
static ModuleInitState | initState |
static volatile intptr_t | references = 0 |
enum vm::PageType |
LIB_API void * vm::Allocate | ( | size_t | size, |
PageType | pageType = kDefault , |
||
int | prot = PROT_READ|PROT_WRITE |
||
) |
reserve address space and commit memory.
size | [bytes] to allocate. |
pageType,prot | - see ReserveAddressSpace. |
|
static |
LIB_API void vm::BeginOnDemandCommits | ( | ) |
install a handler that attempts to commit memory whenever a read/write page fault is encountered.
thread-safe.
static vm::CACHE_ALIGNED | ( | struct Statistics | ) |
vm::CACHE_ALIGNED | ( | struct AddressRangeDescriptor | ) |
LIB_API bool vm::Commit | ( | uintptr_t | address, |
size_t | size, | ||
PageType | pageType = kDefault , |
||
int | prot = PROT_READ|PROT_WRITE |
||
) |
map physical memory to previously reserved address space.
address,size | need not be aligned, but this function commits any pages intersecting that interval. |
pageType,prot | - see ReserveAddressSpace. |
note: committing only maps virtual pages and does not actually allocate page frames. Windows XP uses a first-touch heuristic - the page will be taken from the node whose processor caused the fault. therefore, worker threads should be the first to write to their memory.
(this is surprisingly slow in XP, possibly due to PFN lock contention)
LIB_API bool vm::Decommit | ( | uintptr_t | address, |
size_t | size | ||
) |
unmap physical memory.
LIB_API void vm::DumpStatistics | ( | ) |
LIB_API void vm::EndOnDemandCommits | ( | ) |
decrements the reference count begun by BeginOnDemandCommit and removes the page fault handler when it reaches 0.
thread-safe.
|
static |
LIB_API void vm::Free | ( | void * | p, |
size_t | size = 0 |
||
) |
decommit memory and release address space.
p | a pointer previously returned by Allocate. |
size | is required by the POSIX implementation and ignored on Windows. it also ensures compatibility with UniqueRange. |
(this differs from ReleaseAddressSpace, which must account for extra padding/alignment to largePageSize.)
|
static |
LIB_API bool vm::Protect | ( | uintptr_t | address, |
size_t | size, | ||
int | prot | ||
) |
set the memory protection flags for all pages that intersect the given interval.
the pages must currently be committed.
prot | memory protection flags: PROT_NONE or a combination of PROT_READ, PROT_WRITE, PROT_EXEC. |
LIB_API void vm::ReleaseAddressSpace | ( | void * | p, |
size_t | size = 0 |
||
) |
release address space and decommit any memory.
p | a pointer previously returned by ReserveAddressSpace. |
size | is required by the POSIX implementation and ignored on Windows. it also ensures compatibility with UniqueRange. |
LIB_API void * vm::ReserveAddressSpace | ( | size_t | size, |
size_t | commitSize = largePageSize , |
||
PageType | pageType = kDefault , |
||
int | prot = PROT_READ|PROT_WRITE |
||
) |
reserve address space and set the parameters for any later on-demand commits.
size | desired number of bytes. any additional space in the last page is also accessible. |
commitSize | [bytes] how much to commit each time. larger values reduce the number of page faults at the cost of additional internal fragmentation. must be a multiple of largePageSize unless pageType == kSmall. |
pageType | chooses between large/small pages for commits. |
prot | memory protection flags for newly committed pages. |
|
static |
|
static |
vm::TIMER_ADD_CLIENT | ( | tc_commit | ) |
|
static |
|
static |
|
static |
|
static |
|
static |