Commits

Remi Meier  committed c44a0c4

add and fix test

  • Participants
  • Parent commits 33eb0c7
  • Branches c7

Comments (0)

Files changed (2)

 
 object_t *_stm_alloc_old(size_t size)
 {
+    /* may return uninitialized objects */
     object_t *result;
     size_t size_class = size / 8;
     assert(size_class >= 2);
 
 localchar_t *_stm_alloc_next_page(size_t size_class)
 {
+    /* may return uninitialized pages */
+    
     /* 'alloc->next' points to where the next allocation should go.  The
        present function is called instead when this next allocation is
        equal to 'alloc->stop'.  As we know that 'start', 'next' and
         uint16_t cur = (uintptr_t)alloc->next;
         if (start == cur)
             continue;
+
+        alloc->start = cur;     /* next transaction starts there */
         uintptr_t pagenum = ((uintptr_t)(alloc->next - 1)) / 4096UL;
         if (flag_page_private[pagenum] == UNCOMMITTED_SHARED_PAGE) {
             /* becomes a SHARED (s.b.) partially used page */
 
     /* XXX: forget about GCFLAG_UNCOMMITTED objects  */
     
-    /* long j; */
-    /* for (j = 2; j < LARGE_OBJECT_WORDS; j++) { */
-    /*     alloc_for_size_t *alloc = &_STM_TL2->alloc[j]; */
-    /*     uint16_t num_allocated = ((uintptr_t)alloc->next) - alloc->start; */
-    /*     alloc->next -= num_allocated; */
-    /* } */
-    /* stm_list_clear(_STM_TL2->uncommitted_object_ranges); */
+    long j;
+    for (j = 2; j < LARGE_OBJECT_WORDS; j++) {
+        alloc_for_size_t *alloc = &_STM_TL2->alloc[j];
+        uint16_t num_allocated = ((uintptr_t)alloc->next) - alloc->start;
+        alloc->next -= num_allocated;
+    }
     
     
     assert(_STM_TL1->jmpbufptr != NULL);

File c7/test/test_basic.py

         assert stm_get_page_flag(stm_get_obj_pages(newer)[0]) == lib.SHARED_PAGE
         assert not (stm_get_flags(newer) & lib.GCFLAG_NOT_COMMITTED)
         
+    def test_reset_partial_alloc_pages(self):
+        stm_start_transaction()
+        new = stm_allocate(16)
+        stm_set_char(new, 'a')
+        stm_push_root(new)
+        stm_minor_collect()
+        new = stm_pop_root()
+        stm_abort_transaction()
 
+        stm_start_transaction()
+        newer = stm_allocate(16)
+        stm_push_root(newer)
+        stm_minor_collect()
+        newer = stm_pop_root()
+        assert stm_get_real_address(new) == stm_get_real_address(newer)
+        assert stm_get_char(newer) == '\0'
+        
 
     # def test_resolve_write_write_no_conflict(self):
     #     stm_start_transaction()