[vmkit-commits] [vmkit] r121364 - in /vmkit/branches/multi-vm: find-it.sh include/mvm/VirtualMachine.h lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/Jnjvm.h lib/Mvm/Runtime/VMKit.cpp lib/Mvm/Runtime/VirtualMachine.cpp

Gael Thomas gael.thomas at lip6.fr
Thu Dec 9 02:40:40 PST 2010


Author: gthomas
Date: Thu Dec  9 04:40:40 2010
New Revision: 121364

URL: http://llvm.org/viewvc/llvm-project?rev=121364&view=rev
Log:
add functions to bootstrap a vm directly in virtual machine

Modified:
    vmkit/branches/multi-vm/find-it.sh
    vmkit/branches/multi-vm/include/mvm/VirtualMachine.h
    vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
    vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h
    vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp
    vmkit/branches/multi-vm/lib/Mvm/Runtime/VirtualMachine.cpp

Modified: vmkit/branches/multi-vm/find-it.sh
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/find-it.sh?rev=121364&r1=121363&r2=121364&view=diff
==============================================================================
--- vmkit/branches/multi-vm/find-it.sh (original)
+++ vmkit/branches/multi-vm/find-it.sh Thu Dec  9 04:40:40 2010
@@ -6,6 +6,6 @@
 
 else
 
-		grep --exclude find-it.sh --exclude-dir IJvm --exclude-dir Isolate --exclude *.txt --exclude-dir autoconf --exclude config.status --exclude config.log --exclude configure --exclude *.xml --exclude *.html --exclude *.jar --exclude *.bc --exclude MMTkInline.inc --exclude-dir patches --exclude-dir N3 --exclude *.java --exclude *.class -R --exclude-dir .svn --exclude-dir Release --exclude *.s "$1" .
+		grep -w --exclude find-it.sh --exclude-dir IJvm --exclude-dir Isolate --exclude *.txt --exclude-dir autoconf --exclude config.status --exclude config.log --exclude configure --exclude *.xml --exclude *.html --exclude *.jar --exclude *.bc --exclude MMTkInline.inc --exclude-dir patches --exclude-dir N3 --exclude *.java --exclude *.class -R --exclude-dir .svn --exclude-dir Release --exclude *.s "$1" .
 
 fi
\ No newline at end of file

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=121364&r1=121363&r2=121364&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/VirtualMachine.h (original)
+++ vmkit/branches/multi-vm/include/mvm/VirtualMachine.h Thu Dec  9 04:40:40 2010
@@ -52,21 +52,17 @@
 	///
 	virtual VMThreadData* buildVMThreadData(Thread* mut) = 0; //{ return new VMThreadData(this, mut); }
 
-	virtual void runApplicationImpl(int argc, char** argv) {};
-
-//   /// runInNonDeamonThread - start a non deamon thread a begin the code with start if != 0 and runApplicationImpl otherwise
-// 	/// the thread leaves the deamon mode when it finishs.
-// 	void runInNonDeamonThread(void (*start)(VirtualMachine*, int, char**), int argc, char** argv);
-
-//   /// runInNonDeamonThread - start a non deamon thread a begin the code with runApplicationImpl, 
-// 	void runInNonDeamonThread(int argc, char **argv) { runInNonDeamonThread(0, argc, argv); }
+	/// runApplicationImpl - code executed after a runApplication in a vmkit thread
+	///
+	virtual void runApplicationImpl(int argc, char** argv) {}
 
-//   /// waitNonDeamonThreads - wait until all the non deamon threads are terminated.
-// 	void waitForNonDeamonThreads();
+	/// runApplication - launch runApplicationImpl in a vmkit thread. The vmData is not allocated.
+	///
+	void runApplication0(int argc, char** argv);
 
-//   /// runApplication - Run an application. The application name is in
-//   /// the arguments, hence it is the virtual machine's job to parse them.
-//   virtual void runApplication(int argc, char** argv) = 0;
+	/// runApplication - launch starter in a vmkit thread. The vmData is not allocated.
+	///
+	void runApplication0(void (*starter)(VirtualMachine* vm, int argc, char** argv), int argc, char** argv);
   
 //===----------------------------------------------------------------------===//
 // (2) GC-related methods.

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=121364&r1=121363&r2=121364&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp Thu Dec  9 04:40:40 2010
@@ -1302,6 +1302,20 @@
   }
 }
 
+void Jnjvm::associateBootstrapJavaThread() {
+	mvm::Thread* mut = mvm::Thread::get();
+	JavaThread *th   = new JavaThread(this, mut);
+	mut->allVmsData[vmID] = th;
+	mut->attach(this);
+}
+
+void Jnjvm::runApplicationImpl(int argc, char** argv) {
+	associateBootstrapJavaThread();
+  argumentsInfo.argc = argc;
+  argumentsInfo.argv = argv;
+	mainJavaStart(mvm::Thread::get());
+}
+
 void Jnjvm::runApplication(int argc, char** argv) {
   argumentsInfo.argc = argc;
   argumentsInfo.argv = argv;

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=121364&r1=121363&r2=121364&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h Thu Dec  9 04:40:40 2010
@@ -280,12 +280,20 @@
   /// Jnjvm - Allocates a new JVM.
   ///
   Jnjvm(mvm::BumpPtrAllocator& Alloc, mvm::VMKit* vmkit, JavaCompiler* Comp, bool dlLoad);
+
+  /// runApplicationImpl - function executed in a thread after a call to runApplication
+	///
+  virtual void runApplicationImpl(int argc, char** argv);
   
   /// runApplication - Runs the application with the given command line.
   /// User-visible function, inherited by the VirtualMachine class.
   ///
   virtual void runApplication(int argc, char** argv);
 
+	/// associateBootstrapJavaThread - allocate a bootstrap java thread for the underlying mutator during bootstrap. 
+	///
+	void associateBootstrapJavaThread();
+
 	/// 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);

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=121364&r1=121363&r2=121364&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp Thu Dec  9 04:40:40 2010
@@ -205,7 +205,6 @@
 	nonDaemonThreadsManager.waitNonDaemonThreads();
 }
 
-
 void NonDaemonThreadManager::leaveNonDaemonMode() {
   nonDaemonLock.lock();
   --nonDaemonThreads;

Modified: vmkit/branches/multi-vm/lib/Mvm/Runtime/VirtualMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/Mvm/Runtime/VirtualMachine.cpp?rev=121364&r1=121363&r2=121364&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/Runtime/VirtualMachine.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/Runtime/VirtualMachine.cpp Thu Dec  9 04:40:40 2010
@@ -12,31 +12,32 @@
 	vmkit->removeVM(vmID);
 }
 
+class LauncherThread : public Thread {
+public:
+ 	void (*realStart)(VirtualMachine*, int, char**);
+ 	VirtualMachine *vm;
+ 	int argc;
+ 	char** argv;
 
-// class LauncherThread : public Thread {
-// public:
-// 	void (*realStart)(VirtualMachine*, int, char**);
-// 	VirtualMachine *vm;
-// 	int argc;
-// 	char** argv;
+ 	LauncherThread(VMKit* vmkit, void (*s)(VirtualMachine*, int, char**), VirtualMachine* v, int ac, char** av) : Thread(vmkit) {
+ 		realStart = s;
+ 		vm = v;
+ 		argc = ac;
+ 		argv = av;
+ 	}
 
-// 	LauncherThread(VMKit* vmkit, void (*s)(VirtualMachine*, int, char**), VirtualMachine* v, int ac, char** av) : Thread(vmkit) {
-// 		realStart = s;
-// 		vm = v;
-// 		argc = ac;
-// 		argv = av;
-// 	}
+ 	static void launch(LauncherThread* th) {
+ 		if(th->realStart)
+ 			th->realStart(th->vm, th->argc, th->argv);
+ 		else
+ 			th->vm->runApplicationImpl(th->argc, th->argv);
+ 	}
+};
 
-// 	static void launch(LauncherThread* th) {
-// 		if(th->realStart)
-// 			th->realStart(th->vm, th->argc, th->argv);
-// 		else
-// 			th->vm->runApplicationImpl(th->argc, th->argv);
-// 		th->vm->leaveNonDeamonMode();
-// 	}
-// };
+void VirtualMachine::runApplication0(void (*starter)(VirtualMachine*, int, char**), int argc, char **argv) {
+	(new LauncherThread(vmkit, starter, this, argc, argv))->start((void (*)(Thread*))LauncherThread::launch);
+}
 
-// void VirtualMachine::runInNonDeamonThread(void (*start)(VirtualMachine*, int, char**), int argc, char **argv) {
-//   enterNonDeamonMode();
-//   (new LauncherThread(vmkit, start, this, argc, argv))->start((void (*)(Thread*))LauncherThread::launch);
-// }
+void VirtualMachine::runApplication0(int argc, char** argv) {
+	runApplication0(0, argc, argv);
+}





More information about the vmkit-commits mailing list