Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
wvm.cpp File Reference
#include "precompiled.h"
#include "lib/sysdep/vm.h"
#include "lib/alignment.h"
#include "lib/bits.h"
#include "lib/module_init.h"
#include "lib/sysdep/numa.h"
#include "lib/sysdep/os/win/wutil.h"
#include "lib/timer.h"
#include <atomic>
#include <excpt.h>
Include dependency graph for wvm.cpp:

Namespaces

namespace  vm
 

Functions

 vm::CACHE_ALIGNED (struct Statistics)
 
void vm::DumpStatistics ()
 
static bool vm::ShouldUseLargePages (size_t allocationSize, DWORD allocationType, PageType pageType)
 
static void * vm::AllocateLargeOrSmallPages (uintptr_t address, size_t size, DWORD allocationType, PageType pageType=kDefault, int prot=PROT_READ|PROT_WRITE)
 
 vm::CACHE_ALIGNED (struct AddressRangeDescriptor)
 
static AddressRangeDescriptor * vm::FindDescriptor (uintptr_t address)
 
void * vm::ReserveAddressSpace (size_t size, size_t commitSize=g_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 vm::ReleaseAddressSpace (void *p, size_t size=0)
 release address space and decommit any memory. More...
 
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. More...
 
bool vm::Decommit (uintptr_t address, size_t size)
 unmap physical memory. More...
 
bool vm::Protect (uintptr_t address, size_t size, int prot)
 set the memory protection flags for all pages that intersect the given interval. More...
 
void * vm::Allocate (size_t size, PageType pageType=kDefault, int prot=PROT_READ|PROT_WRITE)
 reserve address space and commit memory. More...
 
void vm::Free (void *p, size_t size=0)
 decommit memory and release address space. More...
 
static LONG CALLBACK vm::VectoredHandler (const PEXCEPTION_POINTERS ep)
 
static Status vm::InitHandler ()
 
static void vm::ShutdownHandler ()
 
void vm::BeginOnDemandCommits ()
 install a handler that attempts to commit memory whenever a read/write page fault is encountered. More...
 
void vm::EndOnDemandCommits ()
 decrements the reference count begun by BeginOnDemandCommit and removes the page fault handler when it reaches 0. More...
 

Variables

static bool vm::largePageAllocationTookTooLong = false
 
static AddressRangeDescriptor vm::ranges [2 *os_cpu_MaxProcessors]
 
static PVOID vm::handler
 
static ModuleInitState vm::initState { 0 }
 
static std::atomic< intptr_t > vm::references { 0 }