mymemory: add basic model_snapshot_space
authorBrian Norris <banorris@uci.edu>
Mon, 8 Oct 2012 20:26:07 +0000 (13:26 -0700)
committerBrian Norris <banorris@uci.edu>
Mon, 8 Oct 2012 20:29:28 +0000 (13:29 -0700)
I will begin to utilize the 'model_snapshot_space' as the
model-checker's private snapshotting heap.

mymemory.cc
mymemory.h
snapshot.cc

index f296048406abd251c0e19447aed4090ecb5a63a1..387d6de02365803b8dd33675539918b8d825ebbc 100644 (file)
@@ -132,6 +132,9 @@ void * HandleEarlyAllocationRequest(size_t sz)
        return pointer;
 }
 
+/** @brief Global mspace reference for the model-checker's snapshotting heap */
+mspace model_snapshot_space = NULL;
+
 #if USE_MPROTECT_SNAPSHOT
 
 /** @brief Global mspace reference for the user's snapshotting heap
index 0788e69f39c7beceef47a9944fb4ebee059346c7..b2242062dd765ee44f1ec1d945f8d235073aec52 100644 (file)
@@ -156,6 +156,8 @@ extern mspace create_mspace(size_t capacity, int locked);
 extern mspace user_snapshot_space;
 #endif
 
+extern mspace model_snapshot_space;
+
 #ifdef __cplusplus
 };  /* end of extern "C" */
 #endif
index 59aad7220dc2388d2337f30cedb4584ecd6720e8..e006189c44ba1741208183ea8cbddd222b381dfd 100644 (file)
 /* extern declaration definition */
 struct SnapShot * snapshotrecord = NULL;
 
+/** PageAlignedAdressUpdate return a page aligned address for the
+ * address being added as a side effect the numBytes are also changed.
+ */
+static void * PageAlignAddressUpward(void * addr) {
+       return (void *)((((uintptr_t)addr)+PAGESIZE-1)&~(PAGESIZE-1));
+}
+
 #if !USE_MPROTECT_SNAPSHOT
 /** @statics
 *   These variables are necessary because the stack is shared region and
@@ -48,13 +55,6 @@ static snapshot_id snapshotid = 0;
 
 #else /* USE_MPROTECT_SNAPSHOT */
 
-/** PageAlignedAdressUpdate return a page aligned address for the
- * address being added as a side effect the numBytes are also changed.
- */
-static void * PageAlignAddressUpward(void * addr) {
-       return (void *)((((uintptr_t)addr)+PAGESIZE-1)&~(PAGESIZE-1));
-}
-
 /** ReturnPageAlignedAddress returns a page aligned address for the
  * address being added as a side effect the numBytes are also changed.
  */
@@ -174,6 +174,12 @@ void initSnapshotLibrary(unsigned int numbackingpages,
        void * pagealignedbase=PageAlignAddressUpward(basemySpace);
        user_snapshot_space = create_mspace_with_base(pagealignedbase, numheappages * PAGESIZE, 1);
        addMemoryRegionToSnapShot(pagealignedbase, numheappages);
+
+       void *base_model_snapshot_space = model_malloc((numheappages + 1) * PAGESIZE);
+       pagealignedbase = PageAlignAddressUpward(base_model_snapshot_space);
+       model_snapshot_space = create_mspace_with_base(pagealignedbase, numheappages * PAGESIZE, 1);
+       addMemoryRegionToSnapShot(pagealignedbase, numheappages);
+
        entryPoint();
 }
 #else
@@ -183,6 +189,10 @@ void initSnapshotLibrary(unsigned int numbackingpages,
        if (!snapshotrecord)
                createSharedMemory();
 
+       void *base_model_snapshot_space = malloc((numheappages + 1) * PAGESIZE);
+       void *pagealignedbase = PageAlignAddressUpward(base_model_snapshot_space);
+       model_snapshot_space = create_mspace_with_base(pagealignedbase, numheappages * PAGESIZE, 1);
+
        //step 2 setup the stack context.
        ucontext_t newContext;
        getcontext( &newContext );