[pypy-commit] stmgc default: demo_random should not use the writeables cache anymore, since that is invalid again

Raemi noreply at buildbot.pypy.org
Fri Jul 19 12:06:57 CEST 2013


Author: Remi Meier <remi.meier at gmail.com>
Branch: 
Changeset: r421:5f6c08c9274a
Date: 2013-07-19 12:06 +0200
http://bitbucket.org/pypy/stmgc/changeset/5f6c08c9274a/

Log:	demo_random should not use the writeables cache anymore, since that
	is invalid again

diff --git a/c4/demo_random.c b/c4/demo_random.c
--- a/c4/demo_random.c
+++ b/c4/demo_random.c
@@ -53,11 +53,6 @@
 time_t default_seed;
 gcptr shared_roots[SHARED_ROOTS];
 
-#define CACHE_MASK 65535
-#define CACHE_ENTRIES ((CACHE_MASK + 1) / sizeof(char *))
-#define CACHE_AT(cache, obj) (*(gcptr *)((char *)(cache)               \
-                                         + ((revision_t)(obj) & CACHE_MASK)))
-
 struct thread_data {
     unsigned int thread_seed;
     gcptr roots[MAXROOTS];
@@ -67,7 +62,6 @@
     int steps_left;
     int interruptible;
     int atomic;
-    revision_t writeable[CACHE_ENTRIES];
 };
 __thread struct thread_data td;
 
@@ -137,7 +131,7 @@
     return x;
 }
 
-void push_roots(int with_cache)
+void push_roots()
 {
     int i;
     for (i = 0; i < td.num_roots; i++) {
@@ -145,30 +139,11 @@
         if (td.roots[i])
             stm_push_root(td.roots[i]);
     }
-
-    if (with_cache) {
-        stm_push_root(NULL);
-        for (i = 0; i < CACHE_ENTRIES; i++) {
-            if (td.writeable[i])
-                stm_push_root((gcptr)td.writeable[i]);
-        }
-    }
 }
 
-void pop_roots(int with_cache)
+void pop_roots()
 {
     int i;
-    /* some objects may have changed positions */
-    memset(td.writeable, 0, sizeof(td.writeable));
-
-    if (with_cache) {
-        gcptr obj = stm_pop_root();
-        while (obj) {
-            CACHE_AT(td.writeable, obj) = obj;
-            obj = stm_pop_root();
-        }
-    }
-
     for (i = td.num_roots - 1; i >= 0; i--) {
         if (td.roots[i])
             td.roots[i] = stm_pop_root();
@@ -186,9 +161,9 @@
 nodeptr allocate_node()
 {
     nodeptr r;
-    push_roots(1);
+    push_roots();
     r = (nodeptr)stm_allocate(sizeof(struct node), GCTID_STRUCT_NODE);
-    pop_roots(1);
+    pop_roots();
     return r;
 }
 
@@ -252,7 +227,6 @@
     if (p != NULL) {
         check(p);
         w = stm_write_barrier(p);
-        CACHE_AT(td.writeable, w) = w;
         check(w);
         assert(is_private(w));
     }
@@ -369,22 +343,22 @@
 {
     int k = get_rand(100);
     if (k < 10) {
-        push_roots(1);
+        push_roots();
         stm_push_root(p);
         stm_become_inevitable("fun");
         p = stm_pop_root();
-        pop_roots(1);
+        pop_roots();
     } 
     else if (k < 40) {
-        push_roots(1);
+        push_roots();
         stmgc_minor_collect();
-        pop_roots(1);
+        pop_roots();
         p = NULL;
     } else if (k < 41 && DO_MAJOR_COLLECTS) {
         fprintf(stdout, "major collect\n");
-        push_roots(1);
+        push_roots();
         stmgcpage_possibly_major_collect(1);
-        pop_roots(1);
+        pop_roots();
         p = NULL;
     }
     return p;
@@ -423,10 +397,7 @@
         break;
     case 7: // set 'p' as *next in one of the roots
         check(_r);
-        if (CACHE_AT(td.writeable, _r) == _r)
-            w_r = (nodeptr)_r;
-        else
-            w_r = (nodeptr)write_barrier(_r);
+        w_r = (nodeptr)write_barrier(_r);
         check((gcptr)w_r);
         check(p);
         w_r->next = (struct node*)p;
@@ -485,10 +456,7 @@
             assert(w_t->id == stm_id((gcptr)_t));
         }
         else {
-            if (CACHE_AT(td.writeable, _t) == _t)
-                w_t = (nodeptr)_t;
-            else
-                w_t = (nodeptr)write_barrier(_t);
+            w_t = (nodeptr)write_barrier(_t);
             w_t->id = stm_id((gcptr)w_t);
             assert(w_t->id == stm_id((gcptr)_t));
         }
@@ -504,10 +472,7 @@
             assert(w_t->hash == stm_hash((gcptr)_t));
         }
         else {
-            if (CACHE_AT(td.writeable, _t) == _t)
-                w_t = (nodeptr)_t;
-            else
-                w_t = (nodeptr)write_barrier(_t);
+            w_t = (nodeptr)write_barrier(_t);
             w_t->hash = stm_hash((gcptr)w_t);
             assert(w_t->hash == stm_hash((gcptr)_t));
         }
@@ -563,7 +528,7 @@
 
 void transaction_break()
 {
-    push_roots(0);
+    push_roots();
     td.interruptible = 1;
     
     copy_roots(td.roots, td.roots_outside_perform, td.num_roots);
@@ -575,9 +540,7 @@
     copy_roots(td.roots_outside_perform, td.roots, td.num_roots);
     
     td.interruptible = 0;
-    pop_roots(0);
-
-    /* done by pop_roots() memset(&td.writeable, 0, sizeof(td.writeable)); */
+    pop_roots();
 }
 
 
@@ -592,8 +555,8 @@
     assert(end_marker == END_MARKER_ON || end_marker == END_MARKER_OFF);
     arg1 = stm_pop_root();
     assert(arg1 == NULL);
-    pop_roots(0);
-    push_roots(0);
+    pop_roots();
+    push_roots();
     stm_push_root(arg1);
     stm_push_root(end_marker);
 
@@ -609,9 +572,6 @@
 {
     gcptr p = NULL;
 
-    // clear cache of writeables:
-    memset(&td.writeable, 0, sizeof(td.writeable));
-
     while (td.steps_left-->0 || td.atomic) {
         if (td.steps_left % 8 == 0)
             fprintf(stdout, "#");
diff --git a/c4/test/test_et.py b/c4/test/test_et.py
--- a/c4/test/test_et.py
+++ b/c4/test/test_et.py
@@ -206,6 +206,7 @@
 
 def test_write_barrier_after_minor_collect():
     # should fail
+    py.test.skip("should fail now")
     p = oalloc_refs(1)
     pw = lib.stm_write_barrier(p)
 
@@ -243,6 +244,7 @@
     assert getptr(pr, 0) == r2
 
 def test_write_barrier_after_minor_collect_young_to_old():
+    py.test.skip("should fail now")
     p = nalloc_refs(1)
     pw = lib.stm_write_barrier(p)
 


More information about the pypy-commit mailing list