[vmkit-commits] [vmkit] r120958 - in /vmkit/branches/multi-vm: include/mvm/Threads/Thread.h lib/J3/VMCore/Jnjvm.cpp lib/Mvm/CommonThread/ctthread.cpp lib/Mvm/Runtime/VMKit.cpp
Gael Thomas
gael.thomas at lip6.fr
Sun Dec 5 13:37:57 PST 2010
Author: gthomas
Date: Sun Dec 5 15:37:57 2010
New Revision: 120958
URL: http://llvm.org/viewvc/llvm-project?rev=120958&view=rev
Log:
Allocate a vm thread specific data when a vm is attached to a mutator thread.
The tracer of thread calls the tracers of the vm thread specific data.
Build the java specific thread of the finalizer on demand.
Don't use ~Thread because the destructor is never called :)
For the moment, don't destroy the vm thread specific data when the thread is destroyed because I have a deadlock.
Modified:
vmkit/branches/multi-vm/include/mvm/Threads/Thread.h
vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp
vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp
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=120958&r1=120957&r2=120958&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/Threads/Thread.h (original)
+++ vmkit/branches/multi-vm/include/mvm/Threads/Thread.h Sun Dec 5 15:37:57 2010
@@ -160,7 +160,6 @@
Thread(VMKit* vmk);
public:
- ~Thread();
/// yield - Yield the processor to another thread.
///
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=120958&r1=120957&r2=120958&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp Sun Dec 5 15:37:57 2010
@@ -1063,8 +1063,8 @@
mvm::VMThreadData* Jnjvm::buildVMThreadData(mvm::Thread* mut) {
JavaThread* th = new JavaThread(this, finalizerThread);
- mut->allVmsData[vmID] = th; // will be done by my caller but I will call java code
- mut->vmData = th; // will be done by my caller but I will call java code
+ mut->allVmsData[vmID] = th; // will be done by my caller but I have to call java code before
+ mut->vmData = th; // will be done by my caller but I have to call java code before
bootstrapLoader->upcalls->CreateForeignJavaThread(this, th);
return th;
}
@@ -1123,8 +1123,6 @@
// The initialization code of the classes initialized below may require
// to get the Java thread, so we create the Java thread object first.
upcalls->InitializeThreading(this);
-
- buildVMThreadData(finalizerThread);
LOAD_CLASS(upcalls->newClass);
LOAD_CLASS(upcalls->newConstructor);
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=120958&r1=120957&r2=120958&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/CommonThread/ctthread.cpp Sun Dec 5 15:37:57 2010
@@ -44,17 +44,14 @@
vmk->registerPreparedThread(this);
}
-Thread::~Thread() {
- vmkit->unregisterPreparedThread(this);
-}
-
void Thread::attach(VirtualMachine* vm) {
MyVM = vm;
vmData = allVmsData[vm->vmID];
if(!vmData) {
- printf("should not happen yet\n");
- abort();
+ vmkit->vmkitLock.lock();
+ vmData = allVmsData[vm->vmID] = vm->buildVMThreadData(this);
+ vmkit->vmkitLock.unlock();
}
}
@@ -68,11 +65,17 @@
delete oldData;
} else
allVmsData = newData;
+ memset(allVmsData + old*sizeof(VMThreadData*), 0, (n-old)*sizeof(VMThreadData*));
}
void Thread::tracer(uintptr_t closure) {
mvm::Collector::markAndTraceRoot(&pendingException, closure);
- vmData->tracer(closure);
+
+ // should we take the vmkit lock? I suppose that all the threads are suspended during the collection...
+ for(size_t i=0; i<vmkit->numberOfVms; i++)
+ if(allVmsData[i]) {
+ allVmsData[i]->tracer(closure);
+ }
}
int Thread::kill(void* tid, int signo) {
@@ -525,6 +528,7 @@
// Wait for the thread to die.
pthread_join((pthread_t)thread_id, NULL);
}
+ // th->vmkit->unregisterPreparedThread(th);
uintptr_t index = ((uintptr_t)th & Thread::IDMask);
index = (index & ~TheStackManager.baseAddr) >> 20;
TheStackManager.used[index] = 0;
Modified: vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp?rev=120958&r1=120957&r2=120958&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp Sun Dec 5 15:37:57 2010
@@ -57,6 +57,9 @@
vmkitLock.lock();
numberOfRunningThreads--;
th->remove();
+ //for(int i=0; i<numberOfVms; i++)
+ //if(th->allVmsData[i])
+ // delete th->allVmsData[i]; -> Must make a choice for the destruction of threads...
delete th->allVmsData;
vmkitLock.unlock();
}
More information about the vmkit-commits
mailing list