[vmkit-commits] [vmkit] r121129 - in /vmkit/branches/multi-vm: include/mvm/SystemThreads.h include/mvm/Threads/Thread.h lib/J3/Classpath/ClasspathReflect.h lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/ReferenceQueue.cpp lib/J3/VMCore/ReferenceQueue.h lib/Mvm/CommonThread/ctthread.cpp
Gael Thomas
gael.thomas at lip6.fr
Tue Dec 7 02:49:30 PST 2010
Author: gthomas
Date: Tue Dec 7 04:49:30 2010
New Revision: 121129
URL: http://llvm.org/viewvc/llvm-project?rev=121129&view=rev
Log:
uses operator delete/destructor to release a thread
Modified:
vmkit/branches/multi-vm/include/mvm/SystemThreads.h
vmkit/branches/multi-vm/include/mvm/Threads/Thread.h
vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathReflect.h
vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h
vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp
Modified: vmkit/branches/multi-vm/include/mvm/SystemThreads.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/SystemThreads.h?rev=121129&r1=121128&r2=121129&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/SystemThreads.h (original)
+++ vmkit/branches/multi-vm/include/mvm/SystemThreads.h Tue Dec 7 04:49:30 2010
@@ -74,7 +74,7 @@
FinalizerThread(VMKit* vmkit);
- virtual void localDestroy() {
+ ~FinalizerThread() {
delete[] FinalizationQueue;
delete[] ToBeFinalized;
}
Modified: vmkit/branches/multi-vm/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/Threads/Thread.h?rev=121129&r1=121128&r2=121129&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/Threads/Thread.h (original)
+++ vmkit/branches/multi-vm/include/mvm/Threads/Thread.h Tue Dec 7 04:49:30 2010
@@ -311,15 +311,8 @@
/// Thread. The thread object is inlined in the stack.
///
void* operator new(size_t sz);
- void operator delete(void* th) { UNREACHABLE(); }
-
- /// localDestroy - call by releaseThread. Used for sub classes.
- ///
- virtual void localDestroy() {}
-
- /// releaseThread - Free the stack so that another thread can use it.
- ///
- static void releaseThread(mvm::Thread* th);
+ void operator delete(void* th);
+ virtual ~Thread();
/// routine - The function to invoke when the thread starts.
///
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathReflect.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathReflect.h?rev=121129&r1=121128&r2=121129&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathReflect.h (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathReflect.h Tue Dec 7 04:49:30 2010
@@ -151,7 +151,7 @@
public:
static void staticDestructor(JavaObjectVMThread* obj) {
llvm_gcroot(obj, 0);
- mvm::Thread::releaseThread(obj->vmdata->mut);
+ delete obj->vmdata->mut;
}
static void staticTracer(JavaObjectVMThread* obj, uintptr_t closure) {
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp?rev=121129&r1=121128&r2=121129&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp Tue Dec 7 04:49:30 2010
@@ -1077,9 +1077,6 @@
JnjvmClassLoader* loader = bootstrapLoader;
referenceThread = new ReferenceThread(vmkit);
- //javaReferenceThread = new JavaThread(this, referenceThread);
- //referenceThread->allVmsData[vmID] = javaReferenceThread;
- //referenceThread->attach(this);
referenceThread->start(
(void (*)(mvm::Thread*))ReferenceThread::enqueueStart);
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp?rev=121129&r1=121128&r2=121129&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp Tue Dec 7 04:49:30 2010
@@ -48,6 +48,7 @@
mvm::VirtualMachine* vm = obj->getVirtualTable()->vm;
mvm::Thread::get()->attach(vm);
+ printf("enqueue reference: %p\n", obj);
vm->enqueueReference(obj);
} IGNORE;
mvm::Thread::get()->clearPendingException();
Modified: vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h?rev=121129&r1=121128&r2=121129&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h Tue Dec 7 04:49:30 2010
@@ -133,7 +133,7 @@
ReferenceThread(mvm::VMKit* vmkit);
- virtual void localDestroy() {
+ virtual ~ReferenceThread() {
delete[] ToEnqueue;
}
};
Modified: vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp?rev=121129&r1=121128&r2=121129&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp Tue Dec 7 04:49:30 2010
@@ -517,21 +517,23 @@
return res;
}
-/// releaseThread - Remove the stack of the thread from the list of stacks
-/// in use.
-void Thread::releaseThread(mvm::Thread* th) {
+void Thread::operator delete(void* th) {
+ printf("deleting %p\n", th);
+ uintptr_t index = ((uintptr_t)th & Thread::IDMask);
+ index = (index & ~TheStackManager.baseAddr) >> 20;
+ TheStackManager.used[index] = 0;
+}
+
+Thread::~Thread() {
+ printf("destroying %p\n", this);
// It seems like the pthread implementation in Linux is clearing with NULL
// the stack of the thread. So we have to get the thread id before
// calling pthread_join.
- void* thread_id = th->internalThreadID;
+ void* thread_id = internalThreadID;
if (thread_id != NULL) {
// Wait for the thread to die.
pthread_join((pthread_t)thread_id, NULL);
}
- th->localDestroy();
- th->vmkit->unregisterPreparedThread(th);
- uintptr_t index = ((uintptr_t)th & Thread::IDMask);
- index = (index & ~TheStackManager.baseAddr) >> 20;
- TheStackManager.used[index] = 0;
+ vmkit->unregisterPreparedThread(this);
}
More information about the vmkit-commits
mailing list