[vmkit-commits] [vmkit] r73061 - in /vmkit/trunk/lib/Mvm/GCMmap2: MvmGC.h gccollector.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Mon Jun 8 01:17:51 PDT 2009


Author: geoffray
Date: Mon Jun  8 03:17:50 2009
New Revision: 73061

URL: http://llvm.org/viewvc/llvm-project?rev=73061&view=rev
Log:
Objects added by queues were not traced. After having scanned the queues, trace
the new objects.


Modified:
    vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h
    vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp

Modified: vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h?rev=73061&r1=73060&r2=73061&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/MvmGC.h Mon Jun  8 03:17:50 2009
@@ -56,7 +56,7 @@
   static int  status;
   
   
-  enum { stat_collect, stat_finalize, stat_alloc, stat_broken };
+  enum { stat_collect, stat_alloc, stat_broken };
 
 #ifdef HAVE_PTHREAD
   static void  siggc_handler(int);

Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp?rev=73061&r1=73060&r2=73061&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.cpp Mon Jun  8 03:17:50 2009
@@ -61,9 +61,12 @@
   } while (tcur != th);
 
   // (3) Trace stack objects.
-  for(cur=used_nodes->next(); cur!=used_nodes; cur=cur->next())
+  for(cur = used_nodes->next(); cur != used_nodes; cur = cur->next())
     trace(cur);
 
+  // Go back to the previous node.
+  cur = cur->prev();
+
   // (4) Trace the weak reference queue.
   th->MyVM->scanWeakReferencesQueue();
 
@@ -76,26 +79,31 @@
   // (7) Trace the phantom reference queue.
   th->MyVM->scanPhantomReferencesQueue();
 
-  status = stat_finalize;
+  // (8) Trace the new objects added by queues.
+  for(cur = cur->next(); cur != used_nodes; cur = cur->next())
+    trace(cur);
+
 
-  /* finalize */
-  GCChunkNode  finalizable;
+  // Finalize.
+  GCChunkNode finalizable;
   finalizable.attrape(unused_nodes);
 
+  // We have stopped collecting, go back to alloc state.
+  status = stat_alloc;
   
-  /* kill everyone */
+  // Wake up all threads.
+  th->MyVM->endCollection();
+  threads->collectionFinished();
+  th->MyVM->wakeUpFinalizers();
+  th->MyVM->wakeUpEnqueue();
+  
+  // Kill unreachable objects.
   GCChunkNode *next = 0;
   for(cur=finalizable.next(); cur!=&finalizable; cur=next) {
     next = cur->next();
     allocator->reject_chunk(cur);
   }
 
-  status = stat_alloc;
-
-  th->MyVM->endCollection();
-  threads->collectionFinished();
-  th->MyVM->wakeUpFinalizers();
-  th->MyVM->wakeUpEnqueue();
 }
 
 void Collector::collect_unprotect() {





More information about the vmkit-commits mailing list