[vmkit-commits] [vmkit] r104457 - in /vmkit/trunk: include/mvm/Threads/Thread.h lib/J3/Classpath/ClasspathReflect.h lib/Mvm/CommonThread/ctthread.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun May 23 01:40:44 PDT 2010


Author: geoffray
Date: Sun May 23 03:40:43 2010
New Revision: 104457

URL: http://llvm.org/viewvc/llvm-project?rev=104457&view=rev
Log:
We don't know what the pthread library does with the stack after a thread exits
(Apparently now it zeroes the memory). So delete the thread before it exits.
The GC will still make the stack available during finalization.


Modified:
    vmkit/trunk/include/mvm/Threads/Thread.h
    vmkit/trunk/lib/J3/Classpath/ClasspathReflect.h
    vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp

Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=104457&r1=104456&r2=104457&view=diff
==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Sun May 23 03:40:43 2010
@@ -349,10 +349,11 @@
   /// Thread. The thread object is inlined in the stack.
   ///
   void* operator new(size_t sz);
+  void operator delete(void* th) {}
   
-  /// operator delete - Free the stack so that another thread can use it.
+  /// releaseThread - Free the stack so that another thread can use it.
   ///
-  void operator delete(void* obj);
+  static void releaseThread(void* th);
 
   /// routine - The function to invoke when the thread starts.
   ///

Modified: vmkit/trunk/lib/J3/Classpath/ClasspathReflect.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/ClasspathReflect.h?rev=104457&r1=104456&r2=104457&view=diff
==============================================================================
--- vmkit/trunk/lib/J3/Classpath/ClasspathReflect.h (original)
+++ vmkit/trunk/lib/J3/Classpath/ClasspathReflect.h Sun May 23 03:40:43 2010
@@ -118,12 +118,11 @@
 private:
   JavaObject* thread;
   bool running;
-  JavaObject* vmdata;
+  void* vmdata;
 
 public:
   static void staticDestructor(JavaObjectVMThread* obj) {
-    mvm::Thread* th = (mvm::Thread*)obj->vmdata;
-    delete th;
+    mvm::Thread::releaseThread(obj->vmdata);
   }
   
   static void staticTracer(JavaObjectVMThread* obj) {

Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=104457&r1=104456&r2=104457&view=diff
==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Sun May 23 03:40:43 2010
@@ -309,7 +309,7 @@
   th->MyVM->addThread(th); 
   th->routine(th);
   th->MyVM->removeThread(th);
-
+  delete th;
 }
 
 
@@ -344,11 +344,10 @@
   return res;
 }
 
-/// operator delete - Remove the stack of the thread from the list of stacks
+/// releaseThread - Remove the stack of the thread from the list of stacks
 /// in use.
-void Thread::operator delete(void* th) {
-  Thread* Th = (Thread*)th;
-  uintptr_t index = ((uintptr_t)Th->baseSP & Thread::IDMask);
+void Thread::releaseThread(void* th) {
+  uintptr_t index = ((uintptr_t)th & Thread::IDMask);
   index = (index & ~TheStackManager.baseAddr) >> 20;
   TheStackManager.used[index] = 0;
 }





More information about the vmkit-commits mailing list