[vmkit-commits] [vmkit] r121131 - in /vmkit/branches/multi-vm: lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/ReferenceQueue.cpp lib/J3/VMCore/ReferenceQueue.h lib/Mvm/Runtime/VMKit.cpp tools/vmjc/vmjc.cpp tools/vmkit/Launcher.cpp

Gael Thomas gael.thomas at lip6.fr
Tue Dec 7 04:01:55 PST 2010


Author: gthomas
Date: Tue Dec  7 06:01:55 2010
New Revision: 121131

URL: http://llvm.org/viewvc/llvm-project?rev=121131&view=rev
Log:
initialise the gc in the constructor of vmkit. Remove the old ReferenceQueue.* files

Removed:
    vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp
    vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h
Modified:
    vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp
    vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
    vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp
    vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp
    vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp

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=121131&r1=121130&r2=121131&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/JavaJITCompiler.cpp Tue Dec  7 06:01:55 2010
@@ -416,16 +416,18 @@
 extern "C" int StartJnjvmWithJIT(int argc, char** argv, char* mainClass) {
   llvm::llvm_shutdown_obj X; 
    
+
+  mvm::BumpPtrAllocator Allocator;
+
   mvm::MvmModule::initialise();
-  mvm::Collector::initialise();
-  mvm::ThreadAllocator allocator;
-  char** newArgv = (char**)allocator.Allocate((argc + 1) * sizeof(char*));
+	mvm::VMKit* vmkit = new(Allocator, "VMKit") mvm::VMKit(Allocator);
+
+  mvm::ThreadAllocator thallocator;
+  char** newArgv = (char**)thallocator.Allocate((argc + 1) * sizeof(char*));
   memcpy(newArgv + 1, argv, argc * sizeof(void*));
   newArgv[0] = newArgv[1];
   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);

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=121131&r1=121130&r2=121131&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp Tue Dec  7 06:01:55 2010
@@ -1461,20 +1461,21 @@
 
 // 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*));
-  newArgv[0] = newArgv[1];
-  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, vmkit, loader);
 
+  mvm::ThreadAllocator thallocator; 
+  char** newArgv = (char**)thallocator.Allocate((argc + 1) * sizeof(char*));
+  memcpy(newArgv + 1, argv, argc * sizeof(char*));
+  newArgv[0] = newArgv[1];
+  newArgv[1] = mainClass;
+
   vm->runApplication(argc + 1, newArgv);
   vm->waitForExit();
   

Removed: 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=121130&view=auto
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.cpp (removed)
@@ -1,14 +0,0 @@
-//===--ReferenceQueue.cpp - Implementation of soft/weak/phantom references-===//
-//
-//                            The VMKit project
-//
-// This file is distributed under the University of Pierre et Marie Curie 
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "ClasspathReflect.h"
-#include "JavaClass.h"
-#include "JavaUpcalls.h"
-#include "Jnjvm.h"
-#include "ReferenceQueue.h"

Removed: 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=121130&view=auto
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/ReferenceQueue.h (removed)
@@ -1,25 +0,0 @@
-//===---ReferenceQueue.h - Implementation of soft/weak/phantom references--===//
-//
-//                            The VMKit project
-//
-// This file is distributed under the University of Pierre et Marie Curie 
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef J3_REFERENCE_QUEUE_H
-#define J3_REFERENCE_QUEUE_H
-
-#include "mvm/Threads/Locks.h"
-
-#include "JavaThread.h"
-
-// Same values than JikesRVM
-#define INITIAL_QUEUE_SIZE 256
-#define GROW_FACTOR 2
-
-namespace j3 {
-
-} // namespace j3
-
-#endif  //J3_REFERENCE_QUEUE_H

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=121131&r1=121130&r2=121131&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp (original)
+++ vmkit/branches/multi-vm/lib/Mvm/Runtime/VMKit.cpp Tue Dec  7 06:01:55 2010
@@ -1,6 +1,7 @@
 #include "mvm/VMKit.h"
 #include "mvm/VirtualMachine.h"
 #include "mvm/SystemThreads.h"
+#include "mvm/GC.h"
 
 using namespace mvm;
 
@@ -10,7 +11,18 @@
 #define dprintf(...)
 #endif
 
+static SpinLock initedLock;
+static bool     inited = false;
+
 VMKit::VMKit(mvm::BumpPtrAllocator &Alloc) : allocator(Alloc) {
+	initedLock.lock();
+	if(!inited) {
+		inited = true;
+		//mvm::MvmModule::initialise();
+		mvm::Collector::initialise();
+	}
+	initedLock.unlock();
+
 	vms          = 0;
 	vmsArraySize = 0;
 
@@ -115,7 +127,7 @@
 		}
 
 	int res = vmsArraySize;
-	vmsArraySize = vmsArraySize ? (vmsArraySize<<1) : 4;
+	vmsArraySize = vmsArraySize ? (vmsArraySize<<1) : 1;
 	// reallocate the vms
 	VirtualMachine **newVms = new VirtualMachine*[vmsArraySize];
 

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=121131&r1=121130&r2=121131&view=diff
==============================================================================
--- vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp (original)
+++ vmkit/branches/multi-vm/tools/vmjc/vmjc.cpp Tue Dec  7 06:01:55 2010
@@ -174,11 +174,12 @@
     mvm::MvmModule::initialise();
   }
 
+  mvm::BumpPtrAllocator allocator;
+
   JavaAOTCompiler* Comp = new JavaAOTCompiler("AOT");
 
-  mvm::Collector::initialise();
+	mvm::VMKit* vmkit = new(allocator, "VMKit") mvm::VMKit(allocator);
 
-  mvm::BumpPtrAllocator allocator;
   JnjvmBootstrapLoader* loader = new(allocator, "Bootstrap loader")
     JnjvmBootstrapLoader(allocator, Comp, false);
 
@@ -187,7 +188,6 @@
   if (AssumeCompiled) Comp->assumeCompiled = true;
   if (DisableCooperativeGC) Comp->disableCooperativeGC();
 	
-	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(),

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=121131&r1=121130&r2=121131&view=diff
==============================================================================
--- vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp (original)
+++ vmkit/branches/multi-vm/tools/vmkit/Launcher.cpp Tue Dec  7 06:01:55 2010
@@ -66,15 +66,15 @@
     return 0;
   }
   
+	mvm::BumpPtrAllocator Allocator;
+
   mvm::MvmModule::initialise(Fast ? CodeGenOpt::None : CodeGenOpt::Aggressive);
-  mvm::Collector::initialise();
+	mvm::VMKit* vmkit = new(Allocator, "VMKit") mvm::VMKit(Allocator);
 
   if (VMToRun == RunJava) {
-    mvm::BumpPtrAllocator Allocator;
     JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule");
     JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader")
-        JnjvmBootstrapLoader(Allocator, Comp, true);
-		mvm::VMKit* vmkit = new(Allocator, "VMKit") mvm::VMKit(Allocator);
+			JnjvmBootstrapLoader(Allocator, Comp, true);
     Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, vmkit, loader);
     vm->runApplication(argc, argv);
     vm->waitForExit();





More information about the vmkit-commits mailing list