[vmkit-commits] [vmkit] r120567 - in /vmkit/branches/multi-vm: include/mvm/VMKit.h include/mvm/VirtualMachine.h lib/J3/Classpath/ClasspathConstructor.inc lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/Jnjvm.h tools/j3/Main.cpp tools/vmjc/vmjc.cpp tools/vmkit/Launcher.cpp

Gael Thomas gael.thomas at lip6.fr
Wed Dec 1 02:06:57 PST 2010


Author: gthomas
Date: Wed Dec  1 04:06:57 2010
New Revision: 120567

URL: http://llvm.org/viewvc/llvm-project?rev=120567&view=rev
Log:
add a new class VMKit that will hold all the global data. VirtualMachine will only hold vm specific data

Added:
    vmkit/branches/multi-vm/include/mvm/VMKit.h
Modified:
    vmkit/branches/multi-vm/include/mvm/VirtualMachine.h
    vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc
    vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp
    vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
    vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h
    vmkit/branches/multi-vm/tools/j3/Main.cpp
    vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp
    vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp

Added: vmkit/branches/multi-vm/include/mvm/VMKit.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/include/mvm/VMKit.h?rev=120567&view=auto
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/VMKit.h (added)
+++ vmkit/branches/multi-vm/include/mvm/VMKit.h Wed Dec  1 04:06:57 2010
@@ -0,0 +1,19 @@
+#ifndef _VMKIT_H_
+#define _VMKIT_H_
+
+#include "mvm/Allocator.h"
+
+namespace mvm {
+
+class VMKit : public mvm::PermanentObject {
+public:
+  /// allocator - Bump pointer allocator to allocate permanent memory of VMKit
+  ///
+  mvm::BumpPtrAllocator& allocator;
+
+  VMKit(mvm::BumpPtrAllocator &Alloc) : allocator(Alloc) {}
+};
+
+}
+
+#endif

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=120567&r1=120566&r2=120567&view=diff
==============================================================================
--- vmkit/branches/multi-vm/include/mvm/VirtualMachine.h (original)
+++ vmkit/branches/multi-vm/include/mvm/VirtualMachine.h Wed Dec  1 04:06:57 2010
@@ -21,6 +21,7 @@
 namespace mvm {
 
 class MethodInfo;
+class VMKit;
 
 class FunctionMap {
 public:
@@ -53,10 +54,11 @@
 ///
 class VirtualMachine : public mvm::PermanentObject {
 protected:
-  VirtualMachine(mvm::BumpPtrAllocator &Alloc) :
+  VirtualMachine(mvm::BumpPtrAllocator &Alloc, mvm::VMKit* vmk) :
 		  allocator(Alloc) {
     mainThread = 0;
     NumberOfThreads = 0;
+		vmkit = vmk;
   }
 
   virtual ~VirtualMachine() {
@@ -84,6 +86,9 @@
   /// ThreadLock - Lock to create or destroy a new thread.
   ///
   mvm::SpinLock ThreadLock;
+
+	/// vmkit - a pointer to vmkit that contains information on all the vms
+	mvm::VMKit* vmkit;
   
   /// setMainThread - Set the main thread of this VM.
   ///

Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc?rev=120567&r1=120566&r2=120567&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathConstructor.inc Wed Dec  1 04:06:57 2010
@@ -79,12 +79,14 @@
                                JavaObject* Clazz, jint index) {
   JavaObject* res = 0;
   gc* excp = 0;
-
+	JavaObject* jexcp;
+	
   llvm_gcroot(cons, 0);
   llvm_gcroot(args, 0);
   llvm_gcroot(Clazz, 0);
   llvm_gcroot(res, 0);
   llvm_gcroot(excp, 0);
+	llvm_gcroot(jexcp, 0);
 
   Jnjvm* vm = JavaThread::get()->getJVM();
   JavaMethod* meth = JavaObjectConstructor::getInternalMethod(cons);
@@ -124,8 +126,6 @@
       } END_CATCH;
 			mvm::Thread* mut = mvm::Thread::get();
       if (excp) {
-				JavaObject* jexcp;
-				llvm_gcroot(jexcp, 0);
 				jexcp = Jnjvm::asJavaException(excp);
         if (jexcp && JavaObject::getClass(jexcp)->isAssignableFrom(vm->upcalls->newException)) {
           mut->clearPendingException();

Modified: vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp?rev=120567&r1=120566&r2=120567&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp Wed Dec  1 04:06:57 2010
@@ -26,6 +26,7 @@
 
 #include "MvmGC.h"
 #include "mvm/VirtualMachine.h"
+#include "mvm/VMKit.h"
 
 #include "JavaClass.h"
 #include "JavaConstantPool.h"
@@ -417,7 +418,6 @@
    
   mvm::MvmModule::initialise();
   mvm::Collector::initialise();
- 
   mvm::ThreadAllocator allocator;
   char** newArgv = (char**)allocator.Allocate((argc + 1) * sizeof(char*));
   memcpy(newArgv + 1, argv, argc * sizeof(void*));
@@ -425,10 +425,11 @@
   newArgv[1] = mainClass;
 
   mvm::BumpPtrAllocator Allocator;
+	mvm::VMKit* vmkit = new(Allocator, "VMKit") mvm::VMKit(Allocator);
   JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule");
   JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader")
     JnjvmBootstrapLoader(Allocator, Comp, true);
-  Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, loader);
+  Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, vmkit, loader);
   vm->runApplication(argc + 1, newArgv);
   vm->waitForExit();
   

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=120567&r1=120566&r2=120567&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp Wed Dec  1 04:06:57 2010
@@ -19,6 +19,7 @@
 #include "debug.h"
 
 #include "mvm/Threads/Thread.h"
+#include "mvm/VMKit.h"
 #include "MvmGC.h"
 
 #include "ClasspathReflect.h"
@@ -48,6 +49,9 @@
 void UserClass::initialiseClass(Jnjvm* vm) {
   gc* exc = NULL;
   JavaObject* obj = NULL;
+	JavaObject* jexc;
+	
+	llvm_gcroot(jexc, 0);
   llvm_gcroot(exc, 0);
   llvm_gcroot(obj, 0);
   
@@ -208,8 +212,6 @@
     //     ExceptionInInitializerError cannot be created because an
     //     OutOfMemoryError occurs, then instead use an OutOfMemoryError object
     //     in place of E in the following step.
-		JavaObject* jexc;
-		llvm_gcroot(jexc, 0);
 		jexc = Jnjvm::asJavaException(exc);
     if (jexc && JavaObject::getClass(jexc)->isAssignableFrom(vm->upcalls->newException)) {
       Classpath* upcalls = classLoader->bootstrapLoader->upcalls;
@@ -1265,7 +1267,9 @@
   JavaObject* instrumenter = NULL;
   ArrayObject* args = NULL;
   gc* exc = NULL;
-
+	JavaObject *jexc;
+	
+	llvm_gcroot(jexc, 0);
   llvm_gcroot(str, 0);
   llvm_gcroot(instrumenter, 0);
   llvm_gcroot(args, 0);
@@ -1292,8 +1296,6 @@
   } END_CATCH;
 
   if (exc != NULL) {
-		JavaObject *jexc;
-		llvm_gcroot(jexc, 0);
 		jexc = Jnjvm::asJavaException(exc);
     fprintf(stderr, "Exception %s while bootstrapping VM.",
 						exc ? UTF8Buffer(JavaObject::getClass(jexc)->name).cString() : " foreign exception");
@@ -1341,8 +1343,8 @@
   mainThread->start((void (*)(mvm::Thread*))mainJavaStart);
 }
 
-Jnjvm::Jnjvm(mvm::BumpPtrAllocator& Alloc, JnjvmBootstrapLoader* loader) : 
-  VirtualMachine(Alloc), lockSystem(Alloc) {
+Jnjvm::Jnjvm(mvm::BumpPtrAllocator& Alloc, mvm::VMKit* vmkit, JnjvmBootstrapLoader* loader) : 
+  VirtualMachine(Alloc, vmkit), lockSystem(Alloc) {
 
   classpath = getenv("CLASSPATH");
   if (!classpath) classpath = ".";
@@ -1464,7 +1466,6 @@
 // Helper function to run J3 without JIT.
 extern "C" int StartJnjvmWithoutJIT(int argc, char** argv, char* mainClass) {
   mvm::Collector::initialise();
- 
   mvm::ThreadAllocator allocator; 
   char** newArgv = (char**)allocator.Allocate((argc + 1) * sizeof(char*));
   memcpy(newArgv + 1, argv, argc * sizeof(char*));
@@ -1472,10 +1473,11 @@
   newArgv[1] = mainClass;
  
   mvm::BumpPtrAllocator Allocator;
+	mvm::VMKit* vmkit = new(Allocator, "VMKit") mvm::VMKit(Allocator);
   JavaCompiler* Comp = new JavaCompiler();
   JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader")
     JnjvmBootstrapLoader(Allocator, Comp, true);
-  Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, loader);
+  Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, vmkit, loader);
 
   vm->runApplication(argc + 1, newArgv);
   vm->waitForExit();

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=120567&r1=120566&r2=120567&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h Wed Dec  1 04:06:57 2010
@@ -340,7 +340,7 @@
 
   /// Jnjvm - Allocates a new JVM.
   ///
-  Jnjvm(mvm::BumpPtrAllocator& Alloc, JnjvmBootstrapLoader* loader);
+  Jnjvm(mvm::BumpPtrAllocator& Alloc, mvm::VMKit* vmkit, JnjvmBootstrapLoader* loader);
   
   /// runApplication - Runs the application with the given command line.
   /// User-visible function, inherited by the VirtualMachine class.

Modified: vmkit/branches/multi-vm/tools/j3/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/tools/j3/Main.cpp?rev=120567&r1=120566&r2=120567&view=diff
==============================================================================
--- vmkit/branches/multi-vm/tools/j3/Main.cpp (original)
+++ vmkit/branches/multi-vm/tools/j3/Main.cpp Wed Dec  1 04:06:57 2010
@@ -9,6 +9,7 @@
 
 #include "MvmGC.h"
 #include "mvm/JIT.h"
+#include "mvm/VMKit.h"
 #include "mvm/VirtualMachine.h"
 #include "mvm/Threads/Thread.h"
 
@@ -39,7 +40,8 @@
   JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule");
   JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader")
     JnjvmBootstrapLoader(Allocator, Comp, true);
-  Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, loader);
+	mvm::VMKit* vmkit = new(Allocator, "VMKit") mvm::VMKit(Allocator);
+  Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, vmkit, loader);
  
   // Run the application. 
   vm->runApplication(argc, argv);

Modified: vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp?rev=120567&r1=120566&r2=120567&view=diff
==============================================================================
--- vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp (original)
+++ vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp Wed Dec  1 04:06:57 2010
@@ -38,6 +38,7 @@
 
 #include "MvmGC.h"
 #include "mvm/JIT.h"
+#include "mvm/VMKit.h"
 #include "mvm/VirtualMachine.h"
 #include "mvm/Threads/Thread.h"
 
@@ -185,8 +186,9 @@
   if (DisableStubs) Comp->generateStubs = false;
   if (AssumeCompiled) Comp->assumeCompiled = true;
   if (DisableCooperativeGC) Comp->disableCooperativeGC();
-    
-  Jnjvm* vm = new(allocator, "Bootstrap loader") Jnjvm(allocator, loader);
+	
+	mvm::VMKit* vmkit = new(allocator, "VMKit") mvm::VMKit(allocator);
+  Jnjvm* vm = new(allocator, "Bootstrap loader") Jnjvm(allocator, vmkit, loader);
   
   for (std::vector<std::string>::iterator i = Properties.begin(),
        e = Properties.end(); i != e; ++i) {

Modified: vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp?rev=120567&r1=120566&r2=120567&view=diff
==============================================================================
--- vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp (original)
+++ vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp Wed Dec  1 04:06:57 2010
@@ -21,6 +21,7 @@
 #include "MvmGC.h"
 #include "mvm/Config/config.h"
 #include "mvm/JIT.h"
+#include "mvm/VMKit.h"
 #include "mvm/VirtualMachine.h"
 #include "mvm/Threads/Thread.h"
 
@@ -73,7 +74,8 @@
     JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule");
     JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader")
         JnjvmBootstrapLoader(Allocator, Comp, true);
-    Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, loader);
+		mvm::VMKit* vmkit = new(Allocator, "VMKit") mvm::VMKit(Allocator);
+    Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, vmkit, loader);
     vm->runApplication(argc, argv);
     vm->waitForExit();
   }





More information about the vmkit-commits mailing list