[pypy-commit] stmgc c7-refactor: next few tests

arigo noreply at buildbot.pypy.org
Mon Feb 24 14:14:43 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: c7-refactor
Changeset: r824:806e9c1a3eb4
Date: 2014-02-24 14:14 +0100
http://bitbucket.org/pypy/stmgc/changeset/806e9c1a3eb4/

Log:	next few tests

diff --git a/c7/stm/gcpage.c b/c7/stm/gcpage.c
--- a/c7/stm/gcpage.c
+++ b/c7/stm/gcpage.c
@@ -98,23 +98,9 @@
 
 object_t *_stm_allocate_old(ssize_t size_rounded_up)
 {
-    /* XXX not thread-safe!  and only for tests, don't use when a
-       transaction might be running! */
-    assert(size_rounded_up >= 16);
-    assert((size_rounded_up & 7) == 0);
-
-    char *addr = large_malloc(size_rounded_up);
-
-    if (addr + size_rounded_up > uninitialized_page_start) {
-        uintptr_t npages;
-        npages = (addr + size_rounded_up - uninitialized_page_start) / 4096UL;
-        npages += GCPAGE_NUM_PAGES;
-        setup_N_pages(uninitialized_page_start, npages);
-        uninitialized_page_start += npages * 4096UL;
-    }
-
-    memset(addr, 0, size_rounded_up);
-
-    stm_char* o = (stm_char *)(addr - stm_object_pages);
-    return (object_t *)o;
+    /* only for tests */
+    object_t *o = allocate_outside_nursery_large(size_rounded_up);
+    memset(REAL_ADDRESS(stm_object_pages, o), 0, size_rounded_up);
+    o->stm_flags = STM_FLAGS_PREBUILT;
+    return o;
 }
diff --git a/c7/stm/pages.c b/c7/stm/pages.c
--- a/c7/stm/pages.c
+++ b/c7/stm/pages.c
@@ -22,6 +22,11 @@
     __sync_lock_release(&pages_ctl.mutex_pages);
 }
 
+static bool _has_mutex_pages(void)
+{
+    return pages_ctl.mutex_pages != 0;
+}
+
 /************************************************************/
 
 
@@ -31,7 +36,7 @@
        pagenum+count) refer to the same physical range of pages from
        segment 0. */
     uintptr_t i;
-    mutex_pages_lock();
+    assert(_has_mutex_pages());
     for (i = 1; i < NB_SEGMENTS; i++) {
         char *segment_base = get_segment_base(i);
         int res = remap_file_pages(segment_base + pagenum * 4096UL,
@@ -44,7 +49,6 @@
     }
     for (i = 0; i < count; i++)
         flag_page_private[pagenum + i] = SHARED_PAGE;
-    mutex_pages_unlock();
 }
 
 #if 0
diff --git a/c7/stmgc.h b/c7/stmgc.h
--- a/c7/stmgc.h
+++ b/c7/stmgc.h
@@ -92,7 +92,7 @@
 #define _STM_GCFLAG_WRITE_BARRIER      0x01
 #define _STM_NSE_SIGNAL                   0
 #define _STM_FAST_ALLOC           (66*1024)
-#define STM_FLAGS_PREBUILT                0
+#define STM_FLAGS_PREBUILT   _STM_GCFLAG_WRITE_BARRIER
 
 
 /* ==================== HELPERS ==================== */


More information about the pypy-commit mailing list