Commits

Armin Rigo committed 6ee3fa0

Remove "struct gcroot_s".

Comments (0)

Files changed (3)

pypy/translator/stm/src_stm/et.c

 
   CancelLocks(d);
 
+  gcptrlist_clear(&d->list_of_read_objects);
+  gcptrlist_clear(&d->gcroots);
+  g2l_clear(&d->global_to_local);
+  fxcache_clear(&d->recent_reads_cache);
+
 #ifdef RPY_STM_DEBUG_PRINT
   PYPY_DEBUG_START("stm-abort");
   if (PYPY_HAVE_DEBUG_PRINTS)
 static void init_transaction(struct tx_descriptor *d)
 {
   assert(d->active == 0);
-  gcptrlist_clear(&d->list_of_read_objects);
-  gcptrlist_clear(&d->gcroots);
-  g2l_clear(&d->global_to_local);
-  fxcache_clear(&d->recent_reads_cache);
+  assert(d->list_of_read_objects.size == 0);
+  assert(d->gcroots.size == 0);
+  assert(!g2l_any_entry(&d->global_to_local));
+  assert(fxcache_is_clear(&d->recent_reads_cache));
 }
 
 void BeginTransaction(jmp_buf* buf)
   gcptr *items = d->gcroots.items;
   for (i=0; i<=lastitem; i+=2)
     {
-      gcptr R = items[i];
+      gcptr R = items[i]->h_revision;
       revision_t v = (revision_t)items[i+1];
-      if (v != 0)
-        {
-          R->h_revision = v;
-          // if we're going to retry later, and abort,
-          // then we must not re-cancel the same entries
-          items[i+1] = 0;
-        }
+      if (v == 0)
+        break;
+      R->h_revision = v;
+      // if we're going to retry later, and abort,
+      // then we must not re-cancel the same entries
+      items[i+1] = (gcptr)0;
     }
 }
 
     }
 }
 
-static gcptr *FindRootsForLocalCollect(void)
+static gcptr *FindRootsForLocalCollect(struct tx_descriptor *d)
 {
-  struct tx_descriptor *d = thread_descriptor;
   wlog_t *item;
+  if (d->gcroots.size != 0)
+    return d->gcroots.items;
+
   G2L_LOOP_FORWARD(d->global_to_local, item)
     {
       gcptr R = item->addr;
   struct tx_descriptor *d = thread_descriptor;
   assert(d->active != 0);
   if (d->gcroots.size == 0)
-    FindRootsForLocalCollect();   /* for tests */
+    FindRootsForLocalCollect(d);   /* for tests */
 
   AcquireLocks(d);
 
         if (!ValidateDuringCommit(d))
           AbortTransaction(2);
     }
+  /* 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);
 
+  gcptrlist_clear(&d->gcroots);
   d->num_commits++;
   d->active = 0;
 }

pypy/translator/stm/src_stm/lists.c

     }
 }
 
-#if 0
 static int g2l_any_entry(struct G2L *g2l)
 {
   return g2l->raw_current != g2l->raw_start;
 }
-#endif
 
 #define _G2L_LOOP(g2l, item, INITIAL, _PLUS_)                           \
 {                                                                       \
   revision_t cache[FX_ENTRIES];
 };
 
+static int fxcache_is_clear(struct FXCache *fxcache)
+{
+  int i;
+  for (i=0; i<FX_ENTRIES; i++)
+    if (fxcache->cache[i])
+      return 0;
+  return 1;
+}
+
 static void fxcache_clear(struct FXCache *fxcache)
 {
   memset(fxcache, 0, sizeof(struct FXCache));

pypy/translator/stm/src_stm/rpyintf.c

   struct tx_descriptor *d = thread_descriptor;
   wlog_t *item;
   void *tls = stm_get_tls();
-  gcptr *gcroots = FindRootsForLocalCollect();
+  gcptr *gcroots = FindRootsForLocalCollect(d);
 
   while (gcroots[0] != NULL)
     {
 }
 void stm_nogc_stop_transaction(void)
 {
-    struct gcroot_s *gcroots;
+    gcptr *gcroots;
     gcptr W = stm_nogc_chained_list;
     stm_nogc_chained_list = NULL;
     while (W) {
         W = W_next;
     }
 
-    gcroots = FindRootsForLocalCollect();
-    while (gcroots->R != NULL) {
-        W = gcroots->L;
+    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++;
+        gcroots += 2;
     }
 }
 void *pypy_g__stm_duplicate(void *src)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.