*/
bool CycleGraph::checkReachable(CycleNode *from, CycleNode *to) {
std::vector<CycleNode *, MyAlloc<CycleNode *> > queue;
- HashTable<CycleNode *, CycleNode *, uintptr_t, 4, MYMALLOC, MYCALLOC, MYFREE> discovered;
+ HashTable<CycleNode *, CycleNode *, uintptr_t, 4, model_malloc, MYCALLOC, MYFREE> discovered;
queue.push_back(from);
discovered.put(from, from);
* memory in the non-snapshotting heap. */
#define MEMALLOC \
void * operator new(size_t size) { \
- return MYMALLOC(size);\
+ return model_malloc(size);\
}\
void operator delete(void *p, size_t size) { \
MYFREE( p ); \
}\
void * operator new[](size_t size) { \
- return MYMALLOC(size);\
+ return model_malloc(size);\
}\
void operator delete[](void *p, size_t size) {\
MYFREE(p);\
* memory in the snapshotting heap. */
#define SNAPSHOTALLOC
-void *MYMALLOC(size_t size);
+void *model_malloc(size_t size);
void *MYCALLOC(size_t count, size_t size);
void MYFREE(void *ptr);
// allocate but don't initialize num elements of type T
pointer allocate (size_type num, const void* = 0) {
- pointer p = ( pointer )MYMALLOC( num * sizeof( T ) );
+ pointer p = ( pointer )model_malloc( num * sizeof( T ) );
return p;
}
* structures for the mprotect based snapshot.
*/
static void initSnapShotRecord(unsigned int numbackingpages, unsigned int numsnapshots, unsigned int nummemoryregions) {
- snapshotrecord=( struct SnapShot * )MYMALLOC(sizeof(struct SnapShot));
- snapshotrecord->regionsToSnapShot=( struct MemoryRegion * )MYMALLOC(sizeof(struct MemoryRegion)*nummemoryregions);
- snapshotrecord->backingStoreBasePtr= ( struct SnapShotPage * )MYMALLOC( sizeof( struct SnapShotPage ) * (numbackingpages + 1) );
+ snapshotrecord=( struct SnapShot * )model_malloc(sizeof(struct SnapShot));
+ snapshotrecord->regionsToSnapShot=( struct MemoryRegion * )model_malloc(sizeof(struct MemoryRegion)*nummemoryregions);
+ snapshotrecord->backingStoreBasePtr= ( struct SnapShotPage * )model_malloc( sizeof( struct SnapShotPage ) * (numbackingpages + 1) );
//Page align the backingstorepages
snapshotrecord->backingStore=( struct SnapShotPage * )PageAlignAddressUpward(snapshotrecord->backingStoreBasePtr);
- snapshotrecord->backingRecords=( struct BackingPageRecord * )MYMALLOC(sizeof(struct BackingPageRecord)*numbackingpages);
- snapshotrecord->snapShots= ( struct SnapShotRecord * )MYMALLOC(sizeof(struct SnapShotRecord)*numsnapshots);
+ snapshotrecord->backingRecords=( struct BackingPageRecord * )model_malloc(sizeof(struct BackingPageRecord)*numbackingpages);
+ snapshotrecord->snapShots= ( struct SnapShotRecord * )model_malloc(sizeof(struct SnapShotRecord)*numsnapshots);
snapshotrecord->lastSnapShot=0;
snapshotrecord->lastBackingPage=0;
snapshotrecord->lastRegion=0;
unsigned int numheappages, VoidFuncPtr entryPoint) {
/* Setup a stack for our signal handler.... */
stack_t ss;
- ss.ss_sp = MYMALLOC(SIGSTACKSIZE);
+ ss.ss_sp = model_malloc(SIGSTACKSIZE);
ss.ss_size = SIGSTACKSIZE;
ss.ss_flags = 0;
sigaltstack(&ss, NULL);
HandlePF(SIGSEGV, &si, NULL);
snapshotrecord->lastBackingPage--; //remove the fake page we copied
- basemySpace=MYMALLOC((numheappages+1)*PAGESIZE);
+ basemySpace=model_malloc((numheappages+1)*PAGESIZE);
void * pagealignedbase=PageAlignAddressUpward(basemySpace);
mySpace = create_mspace_with_base(pagealignedbase, numheappages*PAGESIZE, 1 );
addMemoryRegionToSnapShot(pagealignedbase, numheappages);
*/
void rollBack( snapshot_id theID ){
#if USE_MPROTECT_SNAPSHOT
- HashTable< void *, bool, uintptr_t, 4, MYMALLOC, MYCALLOC, MYFREE> duplicateMap;
+ HashTable< void *, bool, uintptr_t, 4, model_malloc, MYCALLOC, MYFREE> duplicateMap;
for(unsigned int region=0; region<snapshotrecord->lastRegion;region++) {
if( mprotect(snapshotrecord->regionsToSnapShot[region].basePtr, snapshotrecord->regionsToSnapShot[region].sizeInPages*sizeof(struct SnapShotPage), PROT_READ | PROT_WRITE ) == -1 ){
perror("mprotect");