[vmkit-commits] [vmkit] r83156 - /vmkit/trunk/include/mvm/Threads/Thread.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed Sep 30 11:00:07 PDT 2009


Author: geoffray
Date: Wed Sep 30 13:00:07 2009
New Revision: 83156

URL: http://llvm.org/viewvc/llvm-project?rev=83156&view=rev
Log:
Do not enter or leave uncooperative code while in GC.


Modified:
    vmkit/trunk/include/mvm/Threads/Thread.h

Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=83156&r1=83155&r2=83156&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Wed Sep 30 13:00:07 2009
@@ -197,25 +197,40 @@
   void* getLastSP() { return lastSP; }
   void  setLastSP(void* V) { lastSP = V; }
 
-  void enterUncooperativeCode(unsigned level = 0) {
+  void enterUncooperativeCode(unsigned level = 0) __attribute__ ((noinline)) {
     if (isMvmThread()) {
-      lastSP = __builtin_frame_address(0);
-      while (level--) lastSP = ((void**)lastSP)[0];
-      if (doYield && !inGC) joinCollection();
+      if (!inGC) {
+        assert(!lastSP && "SP already set when entering uncooperative code");
+        ++level;
+        void* temp = __builtin_frame_address(0);
+        while (level--) temp = ((void**)temp)[0];
+        lastSP = temp;
+        if (doYield) joinCollection();
+        assert(lastSP && "No last SP when entering uncooperative code");
+      }
     }
   }
   
   void enterUncooperativeCode(void* SP) {
     if (isMvmThread()) {
-      lastSP = SP;
-      if (doYield && !inGC) joinCollection();
+      if (!inGC) {
+        assert(!lastSP && "SP already set when entering uncooperative code");
+        lastSP = SP;
+        if (doYield) joinCollection();
+        assert(lastSP && "No last SP when entering uncooperative code");
+      }
     }
   }
 
   void leaveUncooperativeCode() {
     if (isMvmThread()) {
-      lastSP = 0;
-      if (doYield && !inGC) joinCollection();
+      if (!inGC) {
+        assert(lastSP && "No last SP when leaving uncooperative code");
+        if (doYield) joinCollection();
+        lastSP = 0;
+        if (doYield) joinCollection();
+        assert(!lastSP && "SP has a value after leaving uncooperative code");
+      }
     }
   }
 





More information about the vmkit-commits mailing list