[vmkit-commits] [vmkit] r121304 - in /vmkit/branches/multi-vm: lib/J3/Classpath/ClasspathVMThread.inc lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/Jnjvm.h tools/Makefile

Gael Thomas gael.thomas at lip6.fr
Wed Dec 8 14:47:24 PST 2010


Author: gthomas
Date: Wed Dec  8 16:47:23 2010
New Revision: 121304

URL: http://llvm.org/viewvc/llvm-project?rev=121304&view=rev
Log:
Remove the threadSystem class and insert it in Jnjvm. Don't try to compile toy-vm.

Modified:
    vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThread.inc
    vmkit/branches/multi-vm/lib/J3/Compiler/JavaAOTCompiler.cpp
    vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp
    vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h
    vmkit/branches/multi-vm/tools/Makefile

Modified: vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThread.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThread.inc?rev=121304&r1=121303&r2=121304&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThread.inc (original)
+++ vmkit/branches/multi-vm/lib/J3/Classpath/ClasspathVMThread.inc Wed Dec  8 16:47:23 2010
@@ -61,7 +61,7 @@
   bool isDaemon = vm->upcalls->daemon->getInstanceInt8Field(javaThread);
 
   if (!isDaemon) {
-    vm->threadSystem.enter();
+    vm->enterNonDaemonMode();
   }
  
   assert(vmThread->getVirtualTable());
@@ -71,7 +71,7 @@
  
   // Remove the thread from the list.
   if (!isDaemon) {
-    vm->threadSystem.leave();
+    vm->leaveNonDaemonMode();
   }
 }
 

Modified: vmkit/branches/multi-vm/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=121304&r1=121303&r2=121304&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/Compiler/JavaAOTCompiler.cpp Wed Dec  8 16:47:23 2010
@@ -2084,13 +2084,7 @@
     M->CreateStaticInitializer();
 
 end:
-
-  vm->threadSystem.nonDaemonLock.lock();
-  --(vm->threadSystem.nonDaemonThreads);
-  if (vm->threadSystem.nonDaemonThreads == 0)
-      vm->threadSystem.nonDaemonVar.signal();
-  vm->threadSystem.nonDaemonLock.unlock();  
-  
+	vm->leaveNonDaemonMode();
 }
 
 void JavaAOTCompiler::compileFile(Jnjvm* vm, const char* n) {

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=121304&r1=121303&r2=121304&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.cpp Wed Dec  8 16:47:23 2010
@@ -1247,15 +1247,13 @@
 
 void Jnjvm::waitForExit() { 
   
-  threadSystem.nonDaemonLock.lock();
+  nonDaemonLock.lock();
   
-  while (threadSystem.nonDaemonThreads) {
-    threadSystem.nonDaemonVar.wait(&threadSystem.nonDaemonLock);
+  while (nonDaemonThreads) {
+    nonDaemonVar.wait(&nonDaemonLock);
   }
   
-  threadSystem.nonDaemonLock.unlock();
-
-  return;
+  nonDaemonLock.unlock();
 }
 
 void Jnjvm::mainJavaStart(mvm::Thread* thread) {
@@ -1276,7 +1274,7 @@
   vm->bootstrapLoader->analyseClasspathEnv(vm->bootstrapLoader->bootClasspathEnv);
   vm->argumentsInfo.readArgs(vm);
   if (vm->argumentsInfo.className == NULL) {
-    vm->threadSystem.leave();
+    vm->leaveNonDaemonMode();
     return;
   }
 
@@ -1315,17 +1313,17 @@
 
     vm->executeClass(info.className, args);
   }
-  vm->threadSystem.leave();
+  vm->leaveNonDaemonMode();
 }
 
-void ThreadSystem::leave() {
+void Jnjvm::leaveNonDaemonMode() {
   nonDaemonLock.lock();
   --nonDaemonThreads;
   if (nonDaemonThreads == 0) nonDaemonVar.signal();
   nonDaemonLock.unlock();  
 }
 
-void ThreadSystem::enter() {
+void Jnjvm::enterNonDaemonMode() {
   nonDaemonLock.lock();
   ++nonDaemonThreads;
   nonDaemonLock.unlock();  
@@ -1342,6 +1340,7 @@
 	VirtualMachine(Alloc, vmkit), 
 	lockSystem(Alloc) {
 
+	nonDaemonThreads = 1;
   bootstrapLoader = new(Alloc, "bootstrap loader") JnjvmBootstrapLoader(Alloc, this, Comp);
   
   upcalls = new(allocator, "Classpath") Classpath(bootstrapLoader, dlLoad);

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=121304&r1=121303&r2=121304&view=diff
==============================================================================
--- vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h (original)
+++ vmkit/branches/multi-vm/lib/J3/VMCore/Jnjvm.h Wed Dec  8 16:47:23 2010
@@ -47,52 +47,6 @@
 class UserClassPrimitive;
 class UserCommonClass;
 
-/// ThreadSystem - Thread management of a JVM. Each JVM has one thread
-/// management system to count the number of non-daemon threads it owns.
-/// The initial thread of the JVM is a non-daemon thread. When there are
-/// no more non-daemon threads, the JVM stops executing.
-///
-class ThreadSystem {
-public:
-  /// nonDaemonThreads - Number of threads in the system that are not daemon
-  /// threads.
-  //
-  uint16 nonDaemonThreads;
-
-  /// nonDaemonLock - Protection lock for the nonDaemonThreads variable.
-  ///
-  mvm::LockNormal nonDaemonLock;
-
-  /// nonDaemonVar - Condition variable to wake up the initial thread when it
-  /// waits for other non-daemon threads to end. The non-daemon thread that
-  /// decrements the nonDaemonThreads variable to zero wakes up the initial
-  /// thread.
-  ///
-  mvm::Cond nonDaemonVar;
-  
-  /// ThreadSystem - Allocates a thread system management, initializing the
-  /// lock, the condition variable and setting the initial number of non
-  /// daemon threads to one, for the initial thread.
-  ///
-  ThreadSystem() {
-    nonDaemonThreads = 1;
-  }
-
-  /// ~ThreadSystem - Destroys the thread system manager. Destroys the lock and
-  /// the condition variable.
-  ///
-  ~ThreadSystem() {}
-
-  /// leave - A thread calls this function when it leaves the thread system.
-  ///
-  void leave();
-
-  /// enter - A thread calls this function when it enters the thread system.
-  ///
-  void enter();
-
-};
-
 class ClArgumentsInfo {
 public:
   int argc;
@@ -162,6 +116,31 @@
   static void mainJavaStart(mvm::Thread* thread);
   
 public:
+
+  /// nonDaemonThreads - Number of threads in the system that are not daemon
+  /// threads.
+  //
+  uint16 nonDaemonThreads;
+
+  /// nonDaemonLock - Protection lock for the nonDaemonThreads variable.
+  ///
+  mvm::LockNormal nonDaemonLock;
+
+  /// nonDaemonVar - Condition variable to wake up the initial thread when it
+  /// waits for other non-daemon threads to end. The non-daemon thread that
+  /// decrements the nonDaemonThreads variable to zero wakes up the initial
+  /// thread.
+  ///
+  mvm::Cond nonDaemonVar;
+  
+  /// leave - A thread calls this function when it leaves the thread system.
+  ///
+  void leaveNonDaemonMode();
+
+  /// enter - A thread calls this function when it enters the thread system.
+  ///
+  void enterNonDaemonMode();
+
   
   /// tracer - Traces instances of this class.
   ///
@@ -188,11 +167,6 @@
   /// upcalls - Upcalls to call Java methods and access Java fields.
   ///
   Classpath* upcalls;
-
-  /// threadSystem - The thread system to manage non-daemon threads and
-  /// control the end of the JVM's execution.
-  ///
-  ThreadSystem threadSystem;
   
   /// lockSystem - The lock system to allocate and manage Java locks.
   ///

Modified: vmkit/branches/multi-vm/tools/Makefile
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/multi-vm/tools/Makefile?rev=121304&r1=121303&r2=121304&view=diff
==============================================================================
--- vmkit/branches/multi-vm/tools/Makefile (original)
+++ vmkit/branches/multi-vm/tools/Makefile Wed Dec  8 16:47:23 2010
@@ -27,7 +27,7 @@
 endif
 
 ifeq ($(WITH_J3), 1)
-  PARALLEL_DIRS += toy-vm
+  PARALLEL_DIRS += #toy-vm
 endif
 
 include $(LEVEL)/Makefile.common





More information about the vmkit-commits mailing list