Author: Remi Meier
Branch: c7
Changeset: r661:c44a0c4106ec
Date: 2014-01-22 09:44 +0100
http://bitbucket.org/pypy/stmgc/changeset/c44a0c4106ec/

Log:    add and fix test

diff --git a/c7/core.c b/c7/core.c
--- a/c7/core.c
+++ b/c7/core.c
@@ -453,6 +453,7 @@
 
 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);
@@ -486,6 +487,8 @@
 
 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
@@ -867,6 +870,8 @@
         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 */
@@ -1021,13 +1026,12 @@
 
     /* 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);
diff --git a/c7/test/test_basic.py b/c7/test/test_basic.py
--- a/c7/test/test_basic.py
+++ b/c7/test/test_basic.py
@@ -423,7 +423,23 @@
         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()
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to