[vmkit-commits] [vmkit] r120944 - in /vmkit/branches/multi-vm: include/mvm/Threads/Thread.h include/mvm/VirtualMachine.h lib/J3/Classpath/JavaUpcalls.cpp lib/J3/Classpath/JavaUpcalls.h lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/Jnjvm.h lib/J3/VMCore/ReferenceQueue.cpp
Gael Thomas
gael.thomas at lip6.fr
Sun Dec 5 10:51:31 PST 2010
Author: gthomas
Date: Sun Dec 5 12:51:31 2010
New Revision: 120944
URL: http://llvm.org/viewvc/llvm-project?rev=120944&view=rev
Log:
allocate the vm finalizer thread specific data with a new function buildVMThreadData
Modified:
vmkit/branches/multi-vm/include/mvm/Threads/Thread.h
vmkit/branches/multi-vm/include/mvm/VirtualMachine.h
vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.cpp
vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.h
vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h
vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.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=120944&r1=120943&r2=120944&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/Threads/Thread.h (original)
+++ vmkit/branches/multi-vm/include/mvm/Threads/Thread.h Sun Dec 5 12:51:31 2010
@@ -146,7 +146,7 @@
this->vm = v;
}
- virtual void tracer(uintptr_t closure) = 0;
+ virtual void tracer(uintptr_t closure) {};
virtual ~VMThreadData() {} // force the construction of a VT
};
Modified: vmkit/branches/multi-vm/include/mvm/VirtualMachine.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/VirtualMachine.h?rev=120944&r1=120943&r2=120944&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/VirtualMachine.h (original)
+++ vmkit/branches/multi-vm/include/mvm/VirtualMachine.h Sun Dec 5 12:51:31 2010
@@ -46,6 +46,13 @@
size_t vmID;
//===----------------------------------------------------------------------===//
+// (1) thread-related methods.
+//===----------------------------------------------------------------------===//
+ /// buildVMThreadData - allocate a java thread for the underlying mutator. Called when the java thread is a foreign thread.
+ ///
+ virtual VMThreadData* buildVMThreadData(Thread* mut) { return new VMThreadData(this, mut); }
+
+//===----------------------------------------------------------------------===//
// (2) GC-related methods.
//===----------------------------------------------------------------------===//
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.cpp?rev=120944&r1=120943&r2=120944&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.cpp Sun Dec 5 12:51:31 2010
@@ -257,6 +257,16 @@
finaliseCreateInitialThread->invokeIntStatic(vm, inheritableThreadLocal, &th);
}
+
+void Classpath::CreateForeignJavaThread(Jnjvm* vm, JavaThread* myth) {
+ JavaObject* RG = 0;
+ llvm_gcroot(RG, 0);
+
+ RG = rootGroup->getStaticObjectField(); // should be system group or a special group for foreign threads
+ CreateJavaThread(vm, myth, "foreign thread", RG);
+}
+
+
void Classpath::InitializeThreading(Jnjvm* vm) {
JavaObject* RG = 0;
@@ -288,10 +298,6 @@
systemName = vm->asciizToStr("system");
groupName->setInstanceObjectField(SystemGroup, systemName);
- // Create the finalizer thread.
- assert(vm->getFinalizerThread() && "VM did not set its finalizer thread");
- CreateJavaThread(vm, vm->javaFinalizerThread, "Finalizer", SystemGroup);
-
// Create the enqueue thread.
assert(vm->getReferenceThread() && "VM did not set its enqueue thread");
CreateJavaThread(vm, vm->javaReferenceThread, "Reference", SystemGroup);
Modified: vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.h?rev=120944&r1=120943&r2=120944&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.h (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/JavaUpcalls.h Sun Dec 5 12:51:31 2010
@@ -267,6 +267,8 @@
public:
ISOLATE_STATIC void InitializeThreading(Jnjvm* vm);
+
+ ISOLATE_STATIC void CreateForeignJavaThread(Jnjvm* vm, JavaThread* myth);
};
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=120944&r1=120943&r2=120944&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp Sun Dec 5 12:51:31 2010
@@ -1061,6 +1061,14 @@
return appClassLoader;
}
+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
+ bootstrapLoader->upcalls->CreateForeignJavaThread(this, th);
+ return th;
+}
+
void Jnjvm::loadBootstrap() {
JavaObject* obj = NULL;
JavaObject* javaLoader = NULL;
@@ -1070,11 +1078,7 @@
// First create system threads.
finalizerThread = new FinalizerThread(this);
- javaFinalizerThread = new JavaThread(this, finalizerThread);
- finalizerThread->allVmsData[vmID] = javaFinalizerThread;
- finalizerThread->attach(this);
- finalizerThread->start(
- (void (*)(mvm::Thread*))FinalizerThread::finalizerStart);
+ finalizerThread->start((void (*)(mvm::Thread*))FinalizerThread::finalizerStart);
referenceThread = new ReferenceThread(this);
javaReferenceThread = new JavaThread(this, referenceThread);
@@ -1119,6 +1123,8 @@
// 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/J3/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h?rev=120944&r1=120943&r2=120944&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h Sun Dec 5 12:51:31 2010
@@ -253,9 +253,6 @@
/// javaMainThread - the java main thread
JavaThread* javaMainThread;
- /// javaFinalizerThread - the java finalizer thread
- JavaThread* javaFinalizerThread;
-
/// javaReferenceThread - the java reference thread
JavaThread* javaReferenceThread;
@@ -368,6 +365,10 @@
///
virtual void waitForExit();
+ /// buildVMThreadData - allocate a java thread for the underlying mutator. Called when the java thread is a foreign thread.
+ ///
+ virtual mvm::VMThreadData* buildVMThreadData(mvm::Thread* mut);
+
/// loadBootstrap - Bootstraps the JVM, getting the class loader, initializing
/// bootstrap classes (e.g. java/lang/Class, java/lang/Exception) and
/// mapping the initial thread.
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=120944&r1=120943&r2=120944&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp Sun Dec 5 12:51:31 2010
@@ -242,6 +242,7 @@
JavaObject* obj = (JavaObject*)_obj;
llvm_gcroot(obj, 0);
Jnjvm* vm = (Jnjvm*)obj->getVirtualTable()->vm; //JavaThread::get()->getJVM();
+ mvm::Thread::get()->attach(vm);
vm->finalizeObject(obj);
}
More information about the vmkit-commits
mailing list