[vmkit-commits] [vmkit] r116160 - /vmkit/branches/release_028/lib/Mvm/Runtime/Object.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sat Oct 9 16:26:19 PDT 2010


Author: geoffray
Date: Sat Oct  9 18:26:19 2010
New Revision: 116160

URL: http://llvm.org/viewvc/llvm-project?rev=116160&view=rev
Log:
Move the TRY statement out of the function to avoid clobbering variables. GCC gets really confused about it (but not llvm-gcc).


Modified:
    vmkit/branches/release_028/lib/Mvm/Runtime/Object.cpp

Modified: vmkit/branches/release_028/lib/Mvm/Runtime/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/release_028/lib/Mvm/Runtime/Object.cpp?rev=116160&r1=116159&r2=116160&view=diff
==============================================================================
--- vmkit/branches/release_028/lib/Mvm/Runtime/Object.cpp (original)
+++ vmkit/branches/release_028/lib/Mvm/Runtime/Object.cpp Sat Oct  9 18:26:19 2010
@@ -61,6 +61,21 @@
 
 typedef void (*destructor_t)(void*);
 
+void invokeFinalize(mvm::Thread* th, gc* res) {
+  llvm_gcroot(res, 0);
+  TRY {
+    th->MyVM->invokeFinalizer(res);
+  } IGNORE;
+  th->clearException();
+}
+
+void invokeEnqueue(mvm::Thread* th, gc* res) {
+  llvm_gcroot(res, 0);
+  TRY {
+    th->MyVM->enqueueReference(res);
+  } IGNORE;
+  th->clearException();
+}
 
 void VirtualMachine::finalizerStart(mvm::Thread* th) {
   VirtualMachine* vm = th->MyVM;
@@ -83,17 +98,14 @@
       vm->FinalizationQueueLock.release();
       if (!res) break;
 
-      TRY {
-        VirtualTable* VT = res->getVirtualTable();
-        if (VT->operatorDelete) {
-          destructor_t dest = (destructor_t)VT->destructor;
-          dest(res);
-        } else {
-          vm->invokeFinalizer(res);
-        }
-      } IGNORE;
+      VirtualTable* VT = res->getVirtualTable();
+      if (VT->operatorDelete) {
+        destructor_t dest = (destructor_t)VT->destructor;
+        dest(res);
+      } else {
+        invokeFinalize(th, res);
+      }
       res = 0;
-      th->clearException();
     }
   }
 }
@@ -119,11 +131,8 @@
       vm->ToEnqueueLock.release();
       if (!res) break;
 
-      TRY {
-        vm->enqueueReference(res);
-      } IGNORE;
+      invokeEnqueue(th, res);
       res = 0;
-      th->clearException();
     }
   }
 }





More information about the vmkit-commits mailing list