Author: Armin Rigo <[email protected]>
Branch: stm-thread-2
Changeset: r57216:02b3e6c6cf7e
Date: 2012-09-07 16:35 +0200
http://bitbucket.org/pypy/pypy/changeset/02b3e6c6cf7e/

Log:    Tweak

diff --git a/pypy/rpython/memory/gc/stmgc.py b/pypy/rpython/memory/gc/stmgc.py
--- a/pypy/rpython/memory/gc/stmgc.py
+++ b/pypy/rpython/memory/gc/stmgc.py
@@ -57,6 +57,7 @@
 #   - GCFLAG_POSSIBLY_OUTDATED: see stmimpl.rst.  Used by C.
 #   - GCFLAG_NOT_WRITTEN: see stmimpl.rst.  Used by C.
 #   - GCFLAG_LOCAL_COPY: see stmimpl.rst.  Used by C.
+#     Note that GCFLAG_LOCAL_COPY and GCFLAG_GLOBAL are exclusive.
 #
 #   - GCFLAG_VISITED: used temporarily to mark local objects found to be
 #     surviving during a collection.  Between collections, it is set on
@@ -381,7 +382,7 @@
             #
             obj = fixedobj
             #
-        elif hdr.tid & (GCFLAG_GLOBAL|GCFLAG_LOCAL_COPY) == GCFLAG_LOCAL_COPY:
+        elif hdr.tid & GCFLAG_LOCAL_COPY:
             #
             # The object is the local copy of a LOCAL-GLOBAL pair.
             obj = hdr_revision(hdr)
diff --git a/pypy/translator/stm/src_stm/et.c b/pypy/translator/stm/src_stm/et.c
--- a/pypy/translator/stm/src_stm/et.c
+++ b/pypy/translator/stm/src_stm/et.c
@@ -488,26 +488,29 @@
     }
 }
 
-static gcptr *FindRootsForLocalCollect(struct tx_descriptor *d)
+static void FindRootsForLocalCollect(struct tx_descriptor *d)
 {
   wlog_t *item;
-  if (d->gcroots.size != 0)
-    return d->gcroots.items;
+  assert(d->gcroots.size == 0);
 
   G2L_LOOP_FORWARD(d->global_to_local, item)
     {
       gcptr R = item->addr;
       gcptr L = item->val;
       assert(L->h_revision == (revision_t)R);
+      L->h_tid &= ~GCFLAG_LOCAL_COPY;
       if (L->h_tid & GCFLAG_NOT_WRITTEN)
         {
           L->h_tid |= GCFLAG_GLOBAL | GCFLAG_POSSIBLY_OUTDATED;
-          continue;
         }
-      gcptrlist_insert2(&d->gcroots, L, (gcptr)0);
+      else
+        {
+          L->h_tid |= GCFLAG_GLOBAL | GCFLAG_NOT_WRITTEN;
+          gcptrlist_insert2(&d->gcroots, L, (gcptr)0);
+        }
     } G2L_LOOP_END;
   gcptrlist_insert(&d->gcroots, NULL);
-  return d->gcroots.items;
+  g2l_clear(&d->global_to_local);
 }
 
 int _FakeReach(gcptr P)
@@ -517,6 +520,8 @@
   P->h_tid |= GCFLAG_GLOBAL | GCFLAG_NOT_WRITTEN;
   if ((P->h_tid & GCFLAG_LOCAL_COPY) == 0)
     P->h_revision = 1;
+  else
+    P->h_tid &= ~GCFLAG_LOCAL_COPY;
   return 1;
 }
 
@@ -525,9 +530,8 @@
   revision_t cur_time;
   struct tx_descriptor *d = thread_descriptor;
   assert(d->active != 0);
-  if (d->gcroots.size == 0)
-    FindRootsForLocalCollect(d);   /* for tests */
 
+  FindRootsForLocalCollect(d);
   AcquireLocks(d);
 
   if (is_inevitable(d))
@@ -565,7 +569,6 @@
   /* we cannot abort any more from here */
   d->setjmp_buf = NULL;
   gcptrlist_clear(&d->list_of_read_objects);
-  g2l_clear(&d->global_to_local);
   fxcache_clear(&d->recent_reads_cache);
 
   UpdateChainHeads(d, cur_time);
diff --git a/pypy/translator/stm/src_stm/rpyintf.c 
b/pypy/translator/stm/src_stm/rpyintf.c
--- a/pypy/translator/stm/src_stm/rpyintf.c
+++ b/pypy/translator/stm/src_stm/rpyintf.c
@@ -39,13 +39,15 @@
   struct tx_descriptor *d = thread_descriptor;
   wlog_t *item;
   void *tls = stm_get_tls();
-  gcptr *gcroots = FindRootsForLocalCollect(d);
 
-  while (gcroots[0] != NULL)
+  G2L_LOOP_FORWARD(d->global_to_local, item)
     {
-      pypy_g__stm_enum_callback(tls, gcroots[0]);
-      gcroots += 2;
-    }
+      gcptr R = item->addr;
+      gcptr L = item->val;
+      assert(L->h_revision == (revision_t)R);
+      if ((L->h_tid & GCFLAG_NOT_WRITTEN) == 0)
+        pypy_g__stm_enum_callback(tls, L);
+    } G2L_LOOP_END;
 }
 
 long stm_in_transaction(void)
@@ -203,7 +205,6 @@
 }
 void stm_nogc_stop_transaction(void)
 {
-    gcptr *gcroots;
     gcptr W = stm_nogc_chained_list;
     stm_nogc_chained_list = NULL;
     while (W) {
@@ -215,16 +216,6 @@
         W->h_revision = 1;
         W = W_next;
     }
-
-    gcroots = FindRootsForLocalCollect(thread_descriptor);
-    while (gcroots[0] != NULL) {
-        W = gcroots[0];
-        assert((W->h_tid & (GCFLAG_GLOBAL |
-                            GCFLAG_NOT_WRITTEN |
-                            GCFLAG_LOCAL_COPY)) == GCFLAG_LOCAL_COPY);
-        W->h_tid |= GCFLAG_GLOBAL | GCFLAG_NOT_WRITTEN;
-        gcroots += 2;
-    }
 }
 void *pypy_g__stm_duplicate(void *src)
 {
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to