[llvm-commits] [vmkit] r49388 - in /vmkit/trunk: include/mvm/ include/mvm/Threads/ lib/JnJVM/ lib/JnJVM/Classpath/ lib/JnJVM/VMCore/ lib/Mvm/ lib/Mvm/Allocator/ lib/Mvm/CommonThread/ lib/Mvm/GCMmap2/ lib/N3/ lib/N3/VMCore/

Nicolas Geoffray nicolas.geoffray at lip6.fr
Tue Apr 8 10:06:22 PDT 2008


Author: geoffray
Date: Tue Apr  8 12:06:22 2008
New Revision: 49388

URL: http://llvm.org/viewvc/llvm-project?rev=49388&view=rev
Log:
Many cleanups:
- Use -DMULTIPLE_VM to run isolates
- Fix LLVM include list in .h files
- Code cleanup
- 80-Col violation
- Remove unused file VMLet.h



Removed:
    vmkit/trunk/include/mvm/VMLet.h
Modified:
    vmkit/trunk/include/mvm/JIT.h
    vmkit/trunk/include/mvm/Object.h
    vmkit/trunk/include/mvm/Threads/Thread.h
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp
    vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp
    vmkit/trunk/lib/JnJVM/Classpath/Makefile.am
    vmkit/trunk/lib/JnJVM/Main.cpp
    vmkit/trunk/lib/JnJVM/Makefile.am
    vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
    vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h
    vmkit/trunk/lib/JnJVM/VMCore/Makefile.am
    vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp
    vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
    vmkit/trunk/lib/Mvm/Allocator/Makefile.am
    vmkit/trunk/lib/Mvm/CommonThread/Makefile.am
    vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h
    vmkit/trunk/lib/Mvm/JIT.cpp
    vmkit/trunk/lib/Mvm/Main.cpp
    vmkit/trunk/lib/Mvm/Makefile.am
    vmkit/trunk/lib/Mvm/Object.cpp
    vmkit/trunk/lib/Mvm/Sigsegv.cpp
    vmkit/trunk/lib/N3/Main.cpp
    vmkit/trunk/lib/N3/Makefile.am
    vmkit/trunk/lib/N3/VMCore/Makefile.am
    vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp
    vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp
    vmkit/trunk/lib/N3/VMCore/VMThread.cpp
    vmkit/trunk/lib/N3/VMCore/VMThread.h

Modified: vmkit/trunk/include/mvm/JIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/JIT.h (original)
+++ vmkit/trunk/include/mvm/JIT.h Tue Apr  8 12:06:22 2008
@@ -96,11 +96,10 @@
 extern llvm::ExecutionEngine* executionEngine;
 
 extern uint64 getTypeSize(const llvm::Type* type);
-
 extern void AddStandardCompilePasses(llvm::FunctionPassManager*);
-
 extern void runPasses(llvm::Function* func, llvm::FunctionPassManager*);
-extern void* runCompilation(llvm::Function*);
+extern void initialise();
+
 
 //extern mvm::Lock* protectTypes;
 //extern mvm::Lock* protectConstants;

Modified: vmkit/trunk/include/mvm/Object.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Object.h?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/Object.h (original)
+++ vmkit/trunk/include/mvm/Object.h Tue Apr  8 12:06:22 2008
@@ -87,7 +87,7 @@
   }
 
   static void markAndTraceRoots(void);
-  static void initialise(void *sp);
+  static void initialise();
 
 };
 

Modified: vmkit/trunk/include/mvm/Threads/Thread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Thread.h?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/include/mvm/Threads/Thread.h (original)
+++ vmkit/trunk/include/mvm/Threads/Thread.h Tue Apr  8 12:06:22 2008
@@ -10,10 +10,14 @@
 #ifndef MVM_THREAD_H
 #define MVM_THREAD_H
 
-#include "mvm/GC/GC.h"
+#include "mvm/Object.h"
+#include "mvm/Threads/Key.h"
+
+class Collector;
 
 namespace mvm {
-class Thread {
+
+class Thread : public Object{
 public:
   static void yield(void);
   static void yield(unsigned int *);
@@ -22,6 +26,12 @@
   static int kill(int tid, int signo);
   static void exit(int value);
   static int start(int *tid, int (*fct)(void *), void *arg);
+  
+  static mvm::Key<Thread>* threadKey;
+#ifdef MULTIPLE_VM
+  Collector* GC;
+#endif
+  static Thread* get();
 
 };
 

Removed: vmkit/trunk/include/mvm/VMLet.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/VMLet.h?rev=49387&view=auto

==============================================================================
--- vmkit/trunk/include/mvm/VMLet.h (original)
+++ vmkit/trunk/include/mvm/VMLet.h (removed)
@@ -1,38 +0,0 @@
-//===--------------- VMLet.h - Definition of VMLets -----------------------===//
-//
-//                     The Micro Virtual Machine
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef MVM_VMLET_H
-#define MVM_VMLET_H
-
-#include "mvm/Object.h"
-#include "mvm/Threads/Key.h"
-
-namespace llvm {
-  class Module;
-  class ExistingModuleProvider;
-  class ExecutionEngine;
-  class FunctionPassManager;
-  class JITMemoryManager;
-}
-
-namespace mvm {
-
-class VMLet : public Object {
-public:
-  static VirtualTable *VT;
-  //GC_defass(String, name);
-
-  static void register_sigsegv_handler(void (*fct)(int, void *));
-
-  static void initialise();
-};
-
-} // end namespace mvm
-
-#endif // MVM_VMLET_H

Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp Tue Apr  8 12:06:22 2008
@@ -100,7 +100,7 @@
     if (cl->status == hashed) {
       cl->bytes = (ArrayUInt8*)bytes;
       cl->status = loaded;
-#ifdef SINGLE_VM
+#ifndef MULTIPLE_VM
       cl->delegatee = (JavaObject*)pd;
 #else
       vm->delegatees->hash(cl, (JavaObject*)pd);

Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMRuntime.cpp Tue Apr  8 12:06:22 2008
@@ -115,7 +115,7 @@
 jclass clazz,
 #endif
 jint par1) {
-#ifdef SINGLE_VM
+#ifndef MULTIPLE_VM
   exit(par1);
 #else
   // TODO: do a longjmp

Modified: vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/ClasspathVMThread.cpp Tue Apr  8 12:06:22 2008
@@ -50,7 +50,7 @@
   JavaObject* vmThread = arg->vmThread;
   JavaThread* intern = arg->intern;
   delete arg;
-  JavaThread::threadKey->set(intern);
+  mvm::Thread::threadKey->set(intern);
   CommonClass* vmthClass = vmThread->classOf;
   JavaObject* thread = (JavaObject*)((*ClasspathThread::assocThread)(vmThread).PointerVal);
   JavaIsolate* isolate = (JavaIsolate*)(intern->isolate);
@@ -86,7 +86,8 @@
   JavaObject* javaThread = (JavaObject*)(*ClasspathThread::assocThread)(vmThread).PointerVal;
   assert(javaThread);
 
-  JavaThread* th = JavaThread::allocate(javaThread, JavaThread::get()->isolate);
+  JavaThread* th = gc_new(JavaThread)();
+  th->initialise(javaThread, JavaThread::get()->isolate);
   (*ClasspathThread::vmdata)(vmThread, (JavaObject*)th);
   int tid = 0;
   arg_thread_t* arg = (arg_thread_t*)malloc(sizeof(arg_thread_t));

Modified: vmkit/trunk/lib/JnJVM/Classpath/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Classpath/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Classpath/Makefile.am (original)
+++ vmkit/trunk/lib/JnJVM/Classpath/Makefile.am Tue Apr  8 12:06:22 2008
@@ -17,4 +17,4 @@
 	ClasspathVMThrowable.h ClasspathVMThrowable.cpp ClasspathMethod.h ClasspathMethod.cpp \
 	ClasspathVMField.h ClasspathVMField.cpp ClasspathVMStackWalker.cpp ClasspathVMStackWalker.h
 
-libClasspath_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -DSINGLE_VM -O2 -g -Werror
+libClasspath_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -O2 -g -Werror

Modified: vmkit/trunk/lib/JnJVM/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Main.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Main.cpp (original)
+++ vmkit/trunk/lib/JnJVM/Main.cpp Tue Apr  8 12:06:22 2008
@@ -7,77 +7,27 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "mvm/JIT.h"
+#include "mvm/Object.h"
 #include "mvm/GC/GC.h"
-#include "mvm/PrintBuffer.h"
-#include "mvm/VMLet.h"
-
-
-#include <dlfcn.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <stdio.h>
 
 #include "llvm/Support/ManagedStatic.h"
 
-#include "mvm/Threads/Thread.h"
-
 using namespace mvm;
 
 
-static void clearSignals(void) {
-  signal(SIGINT,  SIG_DFL);
-  signal(SIGILL,  SIG_DFL);
-#if !defined(WIN32)
-  signal(SIGIOT,  SIG_DFL);
-  signal(SIGBUS,  SIG_DFL);
-#endif
-  signal(SIGSEGV, SIG_DFL);
-}
-
 extern "C" int boot();
 extern "C" int start_app(int, char**);
-extern "C" int ClasspathBoot(int, char**, char**);
-
-#include "VMCore/JavaJIT.h"
-
-void handler2(int n, void *context) {
-  printf("[%d] crashed\n", (int)mvm::Thread::self());
-  jnjvm::JavaJIT::printBacktrace();
-  assert(0);
-}
-
-void handler(int n, siginfo_t *_info, void *context) {
-  printf("[%d] crashed\n", (int)mvm::Thread::self());
-  jnjvm::JavaJIT::printBacktrace();
-  assert(0);
-}
 
 int main(int argc, char **argv, char **envp) {
   llvm::llvm_shutdown_obj X;  
   int base;
-  
-  struct sigaction sa;
-
-  sigaction(SIGINT, 0, &sa);
-  sa.sa_sigaction = handler;
-  sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER);
-  sigaction(SIGINT, &sa, 0);
-  
-  sigaction(SIGILL, 0, &sa);
-  sa.sa_sigaction = handler;
-  sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER);
-  sigaction(SIGILL, &sa, 0);
-  
-  
-  VMLet::register_sigsegv_handler(handler2);
-
-  Object::initialise(&base);
-  VMLet::initialise();
-  ClasspathBoot(argc, argv, envp);
+    
+  jit::initialise();
+  Object::initialise();
+  Collector::initialise(Object::markAndTraceRoots, &base);
   boot();
   start_app(argc, argv);
 
-  clearSignals();
-    
   return 0;
 }

Modified: vmkit/trunk/lib/JnJVM/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/Makefile.am (original)
+++ vmkit/trunk/lib/JnJVM/Makefile.am Tue Apr  8 12:06:22 2008
@@ -17,7 +17,7 @@
 main_SOURCES = ../Mvm/Object.cpp ../Mvm/Sigsegv.cpp Main.cpp ../Mvm/MvmMemoryManager.cpp ../Mvm/JIT.cpp ../Mvm/EscapeAnalysis.cpp
 
 
-main_CXXFLAGS = $(libJnJVM_la_CXXFLAGS)
+main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2
 main_LDADD = VMCore/.libs/libJnJVM.a Classpath/.libs/libClasspath.a $(LIBSUVM) @LLVMDYLIB@
 main_LDFLAGS = @rdynamic@
 

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.cpp Tue Apr  8 12:06:22 2008
@@ -30,6 +30,17 @@
 const unsigned int JavaArray::T_INT = 10;
 const unsigned int JavaArray::T_LONG = 11;
 
+ClassArray* JavaArray::ofByte = 0;
+ClassArray* JavaArray::ofChar = 0;
+ClassArray* JavaArray::ofInt = 0;
+ClassArray* JavaArray::ofShort = 0;
+ClassArray* JavaArray::ofBool = 0;
+ClassArray* JavaArray::ofLong = 0;
+ClassArray* JavaArray::ofFloat = 0;
+ClassArray* JavaArray::ofDouble = 0;
+ClassArray* JavaArray::ofString = 0;
+ClassArray* JavaArray::ofObject = 0;
+
 #define ACONS(name, elmt, primSize)                                         \
   name *name::acons(sint32 n, ClassArray* atype) {                          \
     if (n < 0)                                                              \

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h Tue Apr  8 12:06:22 2008
@@ -125,7 +125,7 @@
 
   const UTF8* extract(Jnjvm *vm, uint32 start, uint32 len) const;
 
-#ifdef SINGLE_VM
+#ifndef MULTIPLE_VM
   bool equals(const UTF8* other) const {
     return this == other;
   }

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Tue Apr  8 12:06:22 2008
@@ -35,6 +35,22 @@
 
 const int CommonClass::MaxDisplay = 6;
 
+const UTF8* Attribut::codeAttribut = 0;
+const UTF8* Attribut::exceptionsAttribut = 0;
+const UTF8* Attribut::constantAttribut = 0;
+const UTF8* Attribut::lineNumberTableAttribut = 0;
+const UTF8* Attribut::innerClassesAttribut = 0;
+const UTF8* Attribut::sourceFileAttribut = 0;
+
+JavaObject* CommonClass::jnjvmClassLoader = 0;
+
+CommonClass* ClassArray::SuperArray = 0;
+std::vector<Class*> ClassArray::InterfacesArray;
+std::vector<JavaMethod*> ClassArray::VirtualMethodsArray;
+std::vector<JavaMethod*> ClassArray::StaticMethodsArray;
+std::vector<JavaField*> ClassArray::VirtualFieldsArray;
+std::vector<JavaField*> ClassArray::StaticFieldsArray;
+
 void Attribut::print(mvm::PrintBuffer* buf) const {
   buf->write("Attribut<");
   buf->writeObj(name);
@@ -116,7 +132,7 @@
   this->dim = -1;
   this->isArray = isArray;
   this->_llvmVar = 0;
-#ifdef SINGLE_VM
+#ifndef MULTIPLE_VM
   this->_llvmDelegatee = 0;
   this->delegatee = 0;
 #endif
@@ -357,16 +373,6 @@
   return res;
 }
 
-#ifndef SINGLE_VM
-JavaObject* Class::doNewIsolate() {
-  if (!isReady())
-    initialiseClass();
-  JavaObject* res = (JavaObject*)gc::operator new(virtualSize, virtualVT);
-  memcpy(res, virtualInstance, virtualSize);  
-  return res;
-}
-#endif
-
 bool CommonClass::inheritName(const UTF8* Tname) {
   if (name->equals(Tname)) {
     return true;
@@ -515,21 +521,19 @@
   VirtualTable* VT = JavaJIT::makeVT(cl, true);
 
   uint64 size = mvm::jit::getTypeSize(cl->staticType->getContainedType(0));
-#ifndef SINGLE_VM
   cl->staticSize = size;
   cl->staticVT = VT;
-  if (cl->isolate != Jnjvm::bootstrapVM) {
-#endif
-  JavaObject* val = (JavaObject*)gc::operator new(size, VT);
-  cl->setStaticInstance(val);
+
+#ifndef MULTIPLE_VM
+  JavaObject* val = (JavaObject*)gc::operator new(cl->staticSize, cl->staticVT);
   val->initialise(cl);
   for (std::vector<JavaField*>::iterator i = cl->staticFields.begin(),
             e = cl->staticFields.end(); i!= e; ++i) {
     
     (*i)->initField(val);
   }
-#ifndef SINGLE_VM
-  }
+  
+  cl->_staticInstance = val;
 #endif
 }
 
@@ -589,11 +593,7 @@
   return isolate->initialiseClass(this);
 }
 
-#ifndef SINGLE_VM
-void Class::setStaticInstance(JavaObject* val) {
-  _staticInstance = val;
-}
-
+#ifdef MULTIPLE_VM
 JavaObject* Class::staticInstance() {
   if (isolate == Jnjvm::bootstrapVM) {
     Class* cl = this;
@@ -606,7 +606,7 @@
   }
 }
 
-JavaObject* Class::createStaticInstance() {
+void Class::createStaticInstance() {
   JavaObject* val = (JavaObject*)gc::operator new(staticSize, staticVT);
   val->initialise(this);
   for (std::vector<JavaField*>::iterator i = this->staticFields.begin(),
@@ -614,7 +614,13 @@
     
     (*i)->initField(val);
   }
-  return val;
+  if (isolate == Jnjvm::bootstrapVM) {
+    std::pair<uint8, JavaObject*>* v = 
+      new std::pair<uint8, JavaObject*>(0, val);
+    JavaThread::get()->isolate->statics->hash(this, v);
+  } else {
+    _staticInstance = val;
+  }
 }
 
 bool CommonClass::isReady() {
@@ -629,4 +635,14 @@
   }
 }
 
+void CommonClass::setReady() {
+  if (isolate == Jnjvm::bootstrapVM && !this->isArray &&
+      !AssessorDesc::bogusClassToPrimitive(this)) {
+    std::pair<uint8, JavaObject*>* val = 
+      JavaThread::get()->isolate->statics->lookup((Class*)this);
+    val->first = 1;
+  } else {
+    status = ready;
+  }
+}
 #endif

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Tue Apr  8 12:06:22 2008
@@ -76,7 +76,7 @@
 class CommonClass : public mvm::Object {
 private:
   llvm::GlobalVariable* _llvmVar;
-#ifdef SINGLE_VM
+#ifndef MULTIPLE_VM
   llvm::GlobalVariable* _llvmDelegatee;
 #endif
 public:
@@ -95,7 +95,7 @@
   std::vector<JavaField*>  virtualFields;
   std::vector<JavaField*>  staticFields;
   JavaObject* classLoader;
-#ifdef SINGLE_VM
+#ifndef MULTIPLE_VM
   JavaObject* delegatee;
 #endif
   std::vector<CommonClass*> display;
@@ -111,9 +111,8 @@
   static JavaObject* jnjvmClassLoader;
 
   llvm::GlobalVariable* llvmVar(llvm::Module* compilingModule);
-#ifdef SINGLE_VM
-  llvm::GlobalVariable* llvmDelegatee();
-#endif
+  llvm::Value* llvmDelegatee(llvm::Module* M, llvm::BasicBlock* BB);
+  
   static void printClassName(const UTF8* name, mvm::PrintBuffer* buf);
   void initialise(Jnjvm* isolate, bool array);
   void aquire(); 
@@ -148,12 +147,16 @@
   void initialiseClass();
   void resolveClass(bool doClinit);
 
-#ifdef SINGLE_VM
+#ifndef MULTIPLE_VM
   bool isReady() {
     return status == ready;
   }
+  void setReady() {
+    status = ready;
+  }
 #else
   bool isReady();
+  void setReady();
 #endif
 
 };
@@ -181,15 +184,12 @@
   bool innerOuterResolved;
   
   void resolveFields();
-  llvm::GlobalVariable* staticVar(llvm::Module* compilingModule);
+  llvm::Value* staticVar(llvm::Module* compilingModule, llvm::BasicBlock* BB);
   
   uint64 virtualSize;
   VirtualTable* virtualVT;
-#ifndef SINGLE_VM
   uint64 staticSize;
   VirtualTable* staticVT;
-  JavaObject* doNewIsolate();
-#endif
   JavaObject* doNew();
   JavaObject* doNewUnknown();
   JavaObject* initialiseObject(JavaObject* obj);
@@ -198,17 +198,14 @@
 
   JavaObject* operator()();
 
-#ifdef SINGLE_VM
-  void setStaticInstance(JavaObject* val) {
-    _staticInstance = val;
-  }
+#ifndef MULTIPLE_VM
   JavaObject* staticInstance() {
     return _staticInstance;
   }
+  void createStaticInstance() { }
 #else
-  void setStaticInstance(JavaObject* val);
   JavaObject* staticInstance();
-  JavaObject* createStaticInstance();
+  void createStaticInstance();
 #endif
 
 };

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Tue Apr  8 12:06:22 2008
@@ -7,10 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
-
+#include <signal.h>
 #include <vector>
 
-#include "mvm/VMLet.h"
 #include "mvm/Threads/Locks.h"
 
 #include "JavaArray.h"
@@ -31,143 +30,8 @@
 #include "LockedMap.h"
 #include "Zip.h"
 
-
-
-
 using namespace jnjvm;
 
-ClassArray* JavaArray::ofByte = 0;
-ClassArray* JavaArray::ofChar = 0;
-ClassArray* JavaArray::ofInt = 0;
-ClassArray* JavaArray::ofShort = 0;
-ClassArray* JavaArray::ofBool = 0;
-ClassArray* JavaArray::ofLong = 0;
-ClassArray* JavaArray::ofFloat = 0;
-ClassArray* JavaArray::ofDouble = 0;
-ClassArray* JavaArray::ofString = 0;
-ClassArray* JavaArray::ofObject = 0;
-
-const UTF8* Attribut::codeAttribut = 0;
-const UTF8* Attribut::exceptionsAttribut = 0;
-const UTF8* Attribut::constantAttribut = 0;
-const UTF8* Attribut::lineNumberTableAttribut = 0;
-const UTF8* Attribut::innerClassesAttribut = 0;
-const UTF8* Attribut::sourceFileAttribut = 0;
-
-JavaObject* CommonClass::jnjvmClassLoader = 0;
-
-CommonClass* ClassArray::SuperArray = 0;
-std::vector<Class*> ClassArray::InterfacesArray;
-std::vector<JavaMethod*> ClassArray::VirtualMethodsArray;
-std::vector<JavaMethod*> ClassArray::StaticMethodsArray;
-std::vector<JavaField*> ClassArray::VirtualFieldsArray;
-std::vector<JavaField*> ClassArray::StaticFieldsArray;
-
-
-llvm::Function* JavaJIT::getSJLJBufferLLVM = 0;
-llvm::Function* JavaJIT::throwExceptionLLVM = 0;
-llvm::Function* JavaJIT::getExceptionLLVM = 0;
-llvm::Function* JavaJIT::getJavaExceptionLLVM = 0;
-llvm::Function* JavaJIT::clearExceptionLLVM = 0;
-llvm::Function* JavaJIT::compareExceptionLLVM = 0;
-llvm::Function* JavaJIT::nullPointerExceptionLLVM = 0;
-llvm::Function* JavaJIT::classCastExceptionLLVM = 0;
-llvm::Function* JavaJIT::indexOutOfBoundsExceptionLLVM = 0;
-llvm::Function* JavaJIT::markAndTraceLLVM = 0;
-llvm::Function* JavaJIT::javaObjectTracerLLVM = 0;
-llvm::Function* JavaJIT::virtualLookupLLVM = 0;
-llvm::Function* JavaJIT::fieldLookupLLVM = 0;
-llvm::Function* JavaJIT::UTF8AconsLLVM = 0;
-llvm::Function* JavaJIT::Int8AconsLLVM = 0;
-llvm::Function* JavaJIT::Int32AconsLLVM = 0;
-llvm::Function* JavaJIT::Int16AconsLLVM = 0;
-llvm::Function* JavaJIT::FloatAconsLLVM = 0;
-llvm::Function* JavaJIT::DoubleAconsLLVM = 0;
-llvm::Function* JavaJIT::LongAconsLLVM = 0;
-llvm::Function* JavaJIT::ObjectAconsLLVM = 0;
-llvm::Function* JavaJIT::printExecutionLLVM = 0;
-llvm::Function* JavaJIT::printMethodStartLLVM = 0;
-llvm::Function* JavaJIT::printMethodEndLLVM = 0;
-llvm::Function* JavaJIT::jniProceedPendingExceptionLLVM = 0;
-llvm::Function* JavaJIT::doNewLLVM = 0;
-llvm::Function* JavaJIT::doNewUnknownLLVM = 0;
-llvm::Function* JavaJIT::initialiseObjectLLVM = 0;
-llvm::Function* JavaJIT::newLookupLLVM = 0;
-llvm::Function* JavaJIT::instanceOfLLVM = 0;
-llvm::Function* JavaJIT::aquireObjectLLVM = 0;
-llvm::Function* JavaJIT::releaseObjectLLVM = 0;
-llvm::Function* JavaJIT::multiCallNewLLVM = 0;
-llvm::Function* JavaJIT::runtimeUTF8ToStrLLVM = 0;
-llvm::Function* JavaJIT::getStaticInstanceLLVM = 0;
-llvm::Function* JavaJIT::getClassDelegateeLLVM = 0;
-llvm::Function* JavaJIT::arrayLengthLLVM = 0;
-#ifndef SINGLE_VM
-llvm::Function* JavaJIT::doNewIsolateLLVM = 0;
-#endif
-
-
-const llvm::FunctionType* JavaJIT::markAndTraceLLVMType = 0;
-
-mvm::Lock* JavaObject::globalLock = 0;
-const llvm::Type* JavaObject::llvmType = 0;
-const llvm::Type* JavaArray::llvmType = 0;
-const llvm::Type* ArrayUInt8::llvmType = 0;
-const llvm::Type* ArraySInt8::llvmType = 0;
-const llvm::Type* ArrayUInt16::llvmType = 0;
-const llvm::Type* ArraySInt16::llvmType = 0;
-const llvm::Type* ArrayUInt32::llvmType = 0;
-const llvm::Type* ArraySInt32::llvmType = 0;
-const llvm::Type* ArrayFloat::llvmType = 0;
-const llvm::Type* ArrayDouble::llvmType = 0;
-const llvm::Type* ArrayLong::llvmType = 0;
-const llvm::Type* ArrayObject::llvmType = 0;
-const llvm::Type* UTF8::llvmType = 0;
-const llvm::Type* CacheNode::llvmType = 0;
-const llvm::Type* Enveloppe::llvmType = 0;
-
-
-mvm::Key<JavaThread>* JavaThread::threadKey = 0;
-
-
-Jnjvm* Jnjvm::bootstrapVM = 0;
-const UTF8* Jnjvm::initName = 0;
-const UTF8* Jnjvm::clinitName = 0;
-const UTF8* Jnjvm::clinitType = 0;
-const UTF8* Jnjvm::runName = 0;
-const UTF8* Jnjvm::prelib = 0;
-const UTF8* Jnjvm::postlib = 0;
-const UTF8* Jnjvm::mathName = 0;
-
-#define DEF_UTF8(var) \
-  const UTF8* Jnjvm::var = 0;
-  
-  DEF_UTF8(abs);
-  DEF_UTF8(sqrt);
-  DEF_UTF8(sin);
-  DEF_UTF8(cos);
-  DEF_UTF8(tan);
-  DEF_UTF8(asin);
-  DEF_UTF8(acos);
-  DEF_UTF8(atan);
-  DEF_UTF8(atan2);
-  DEF_UTF8(exp);
-  DEF_UTF8(log);
-  DEF_UTF8(pow);
-  DEF_UTF8(ceil);
-  DEF_UTF8(floor);
-  DEF_UTF8(rint);
-  DEF_UTF8(cbrt);
-  DEF_UTF8(cosh);
-  DEF_UTF8(expm1);
-  DEF_UTF8(hypot);
-  DEF_UTF8(log10);
-  DEF_UTF8(log1p);
-  DEF_UTF8(sinh);
-  DEF_UTF8(tanh);
-
-#undef DEF_UTF8
-
-
 static void initialiseVT() {
 
 # define INIT(X) { \
@@ -199,7 +63,6 @@
   INIT(LockObj);
   INIT(JavaObject);
   INIT(JavaThread);
-  //mvm::Key<JavaThread>::VT = mvm::ThreadKey::VT;
   INIT(AssessorDesc);
   INIT(Typedef);
   INIT(Signdef);
@@ -227,10 +90,6 @@
   JavaObject::globalLock = mvm::Lock::allocNormal();
   //mvm::Object::pushRoot((mvm::Object*)JavaObject::globalLock);
 
-  JavaThread::threadKey = new mvm::Key<JavaThread>();
-  //JavaThread::threadKey = gc_new(mvm::Key<JavaThread>);
-  //mvm::Object::pushRoot((mvm::Object*)JavaThread::threadKey);
-  
   Jnjvm* vm = JavaIsolate::bootstrapVM = JavaIsolate::allocateBootstrap();
   mvm::Object::pushRoot((mvm::Object*)JavaIsolate::bootstrapVM);
   
@@ -336,24 +195,43 @@
  
 }
 
-extern "C" void sigsegv_handler(int val, void* addr) {
-  printf("SIGSEGV in JnJVM at %p\n", addr);
+extern "C" void ClasspathBoot();
+
+void handler(int val, siginfo_t* info, void* addr) {
+  printf("Crash in JnJVM at %p\n", addr);
   JavaJIT::printBacktrace();
   assert(0);
 }
 
-
 extern "C" int boot() {
+  struct sigaction sa;
+  
+  sigaction(SIGINT, 0, &sa);
+  sa.sa_sigaction = handler;
+  sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER);
+  sigaction(SIGINT, &sa, 0);
+  
+  sigaction(SIGILL, 0, &sa);
+  sa.sa_sigaction = handler;
+  sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER);
+  sigaction(SIGILL, &sa, 0);
+  
+  sigaction(SIGSEGV, 0, &sa);
+  sa.sa_sigaction = handler;
+  sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER);
+  sigaction(SIGSEGV, &sa, 0);
+  
   JavaJIT::initialise();
   initialiseVT();
   initialiseStatics();
+  
+  ClasspathBoot();
   Classpath::initialiseClasspath(JavaIsolate::bootstrapVM);
-  //mvm::VMLet::register_sigsegv_handler(sigsegv_handler);
   return 0; 
 }
 
 extern "C" int start_app(int argc, char** argv) {
-#if defined(SINGLE_VM) || defined(SERVICE_VM)
+#if defined(SERVICE_VM) || !defined(MULTIPLE_VM)
   JavaIsolate* vm = (JavaIsolate*)JavaIsolate::bootstrapVM;
 #else
   JavaIsolate* vm = JavaIsolate::allocateIsolate(JavaIsolate::bootstrapVM);

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Tue Apr  8 12:06:22 2008
@@ -433,7 +433,9 @@
                                                        isolate->functions);  
   JavaJIT::initialiseJITIsolateVM(isolate);
   
-  isolate->bootstrapThread = JavaThread::allocate(0, isolate);
+
+  isolate->bootstrapThread = gc_new(JavaThread)();
+  isolate->bootstrapThread->initialise(0, isolate);
   JavaThread::threadKey->set(isolate->bootstrapThread);
 
   
@@ -451,7 +453,7 @@
   isolate->loadedFields = FieldMap::allocate();
   isolate->javaTypes = jnjvm::TypeMap::allocate(); 
   isolate->globalRefsLock = mvm::Lock::allocNormal();
-#ifndef SINGLE_VM
+#ifdef MULTIPLE_VM
   isolate->statics = StaticInstanceMap::allocate();  
   isolate->delegatees = DelegateeMap::allocate(); 
 #endif
@@ -484,7 +486,8 @@
                                                        isolate->functions);  
   JavaJIT::initialiseJITBootstrapVM(isolate);
   
-  isolate->bootstrapThread = JavaThread::allocate(0, isolate);
+  isolate->bootstrapThread = gc_new(JavaThread)();
+  isolate->bootstrapThread->initialise(0, isolate);
   JavaThread::threadKey->set(isolate->bootstrapThread);
 
   isolate->name = "bootstrapVM";
@@ -498,11 +501,13 @@
   isolate->javavmEnv = &JNI_JavaVMTable;
   isolate->globalRefsLock = mvm::Lock::allocNormal();
   isolate->javaTypes = jnjvm::TypeMap::allocate();  
-#ifndef SINGLE_VM
+
+#ifdef MULTIPLE_VM
   isolate->statics = StaticInstanceMap::allocate();  
   isolate->delegatees = DelegateeMap::allocate(); 
 #endif
-#if defined(SINGLE_VM) || defined(SERVICE_VM)
+
+#if defined(SERVICE_VM) || !defined(MULTIPLE_VM)
   isolate->threadSystem = ThreadSystem::allocateThreadSystem();
 #endif
   

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Tue Apr  8 12:06:22 2008
@@ -170,15 +170,8 @@
 
   uint32 index = 0;
   if (stat) {
-#ifdef SINGLE_VM
-    nativeArgs.push_back(new LoadInst(compilingClass->llvmDelegatee(), "",
-                                      currentBlock));
-#else
     Module* M = compilingClass->isolate->module;
-    Value* ld = new LoadInst(compilingClass->llvmVar(M), "", currentBlock);
-    nativeArgs.push_back(llvm::CallInst::Create(getClassDelegateeLLVM, ld, "",
-                                      currentBlock));
-#endif
+    nativeArgs.push_back(compilingClass->llvmDelegatee(M, currentBlock));
     index = 2;
   } else {
     index = 1;
@@ -227,15 +220,11 @@
     argsSync.push_back(llvmFunction->arg_begin());
   } else {
     Module* M = compilingClass->isolate->module;
-    Value* arg = new LoadInst(compilingClass->staticVar(M), "", currentBlock);
-#ifndef SINGLE_VM
-    if (compilingClass->isolate == Jnjvm::bootstrapVM) {
-      arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock);
-    }
-#endif
+    Value* arg = compilingClass->staticVar(M, currentBlock);
     argsSync.push_back(arg);
   }
-  llvm::CallInst::Create(aquireObjectLLVM, argsSync.begin(), argsSync.end(), "", currentBlock);
+  llvm::CallInst::Create(aquireObjectLLVM, argsSync.begin(), argsSync.end(),
+                         "", currentBlock);
 }
 
 void JavaJIT::endSynchronize() {
@@ -244,12 +233,7 @@
     argsSync.push_back(llvmFunction->arg_begin());
   } else {
     Module* M = compilingClass->isolate->module;
-    Value* arg = new LoadInst(compilingClass->staticVar(M), "", currentBlock);
-#ifndef SINGLE_VM
-    if (compilingClass->isolate == Jnjvm::bootstrapVM) {
-      arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock);
-    }
-#endif
+    Value* arg = compilingClass->staticVar(M, currentBlock);
     argsSync.push_back(arg);
   }
   llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "",
@@ -401,7 +385,8 @@
     mvm::jit::protectConstants();//->lock();
     args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
     mvm::jit::unprotectConstants();//->unlock();
-    llvm::CallInst::Create(printMethodStartLLVM, args.begin(), args.end(), "", currentBlock);
+    llvm::CallInst::Create(printMethodStartLLVM, args.begin(), args.end(), "",
+                           currentBlock);
     }
 #endif
 
@@ -472,7 +457,8 @@
     mvm::jit::protectConstants();//->lock();
     args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
     mvm::jit::unprotectConstants();//->unlock();
-    llvm::CallInst::Create(printMethodEndLLVM, args.begin(), args.end(), "", currentBlock);
+    llvm::CallInst::Create(printMethodEndLLVM, args.begin(), args.end(), "",
+                           currentBlock);
     }
 #endif
 
@@ -488,7 +474,8 @@
   } else {
     CallInst* ptr_eh_ptr = llvm::CallInst::Create(getExceptionLLVM, "eh_ptr", 
                                         endExceptionBlock);
-    llvm::CallInst::Create(mvm::jit::unwindResume, ptr_eh_ptr, "", endExceptionBlock);
+    llvm::CallInst::Create(mvm::jit::unwindResume, ptr_eh_ptr, "",
+                           endExceptionBlock);
     new UnreachableInst(endExceptionBlock);
   }
   
@@ -540,32 +527,41 @@
   
   BasicBlock* realEndExceptionBlock = endExceptionBlock;
   if (sync) {
-    BasicBlock* synchronizeExceptionBlock = createBasicBlock("synchronizeExceptionBlock");
-    BasicBlock* trySynchronizeExceptionBlock = createBasicBlock("trySynchronizeExceptionBlock");
+    BasicBlock* synchronizeExceptionBlock = 
+          createBasicBlock("synchronizeExceptionBlock");
+    BasicBlock* trySynchronizeExceptionBlock = 
+          createBasicBlock("trySynchronizeExceptionBlock");
     realEndExceptionBlock = synchronizeExceptionBlock;
     std::vector<Value*> argsSync;
     if (isVirtual(compilingMethod->access)) {
       argsSync.push_back(llvmFunction->arg_begin());
     } else {
-      Value* arg = new LoadInst(compilingClass->staticVar(compilingClass->isolate->module), "", currentBlock);
-#ifndef SINGLE_VM
-      if (compilingClass->isolate == Jnjvm::bootstrapVM) {
-        arg = llvm::CallInst::Create(getStaticInstanceLLVM, arg, "", currentBlock);
-      }
-#endif
+      Value* arg = compilingClass->staticVar(compilingClass->isolate->module,
+                                             currentBlock);
       argsSync.push_back(arg);
     }
-    llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "", synchronizeExceptionBlock);
+    llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(),
+                           "", synchronizeExceptionBlock);
+
     llvm::BranchInst::Create(endExceptionBlock, synchronizeExceptionBlock);
     
     const PointerType* PointerTy_0 = mvm::jit::ptrType;
     std::vector<Value*> int32_eh_select_params;
-    Instruction* ptr_eh_ptr = llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", trySynchronizeExceptionBlock);
+    Instruction* ptr_eh_ptr = 
+      llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr",
+                             trySynchronizeExceptionBlock);
     int32_eh_select_params.push_back(ptr_eh_ptr);
-    int32_eh_select_params.push_back(ConstantExpr::getCast(Instruction::BitCast, mvm::jit::personality, PointerTy_0));
+    Constant* C = ConstantExpr::getCast(Instruction::BitCast,
+                                        mvm::jit::personality, PointerTy_0);
+    int32_eh_select_params.push_back(C);
     int32_eh_select_params.push_back(mvm::jit::constantPtrNull);
-    llvm::CallInst::Create(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", trySynchronizeExceptionBlock);
-    llvm::BranchInst::Create(synchronizeExceptionBlock, trySynchronizeExceptionBlock);
+    llvm::CallInst::Create(mvm::jit::exceptionSelector,
+                           int32_eh_select_params.begin(), 
+                           int32_eh_select_params.end(), 
+                           "eh_select", trySynchronizeExceptionBlock);
+
+    llvm::BranchInst::Create(synchronizeExceptionBlock,
+                             trySynchronizeExceptionBlock);
 
     for (uint16 i = 0; i < codeLen; ++i) {
       if (opcodeInfos[i].exceptionBlock == endExceptionBlock) {
@@ -599,7 +595,8 @@
     }
 
     if (!(opcodeInfos[ex->handlerpc].newBlock)) {
-      opcodeInfos[ex->handlerpc].newBlock = createBasicBlock("handlerException");
+      opcodeInfos[ex->handlerpc].newBlock = 
+                    createBasicBlock("handlerException");
     }
     
     ex->handler = opcodeInfos[ex->handlerpc].newBlock;
@@ -624,7 +621,8 @@
       cur->realTest = cur->test;
     }
     
-    cur->exceptionPHI = llvm::PHINode::Create(mvm::jit::ptrType, "", cur->realTest);
+    cur->exceptionPHI = llvm::PHINode::Create(mvm::jit::ptrType, "",
+                                              cur->realTest);
 
     if (next && cur->startpc == next->startpc && cur->endpc == next->endpc)
       first = false;
@@ -655,29 +653,42 @@
     if (cur->realTest != cur->test) {
       const PointerType* PointerTy_0 = mvm::jit::ptrType;
       std::vector<Value*> int32_eh_select_params;
-      Instruction* ptr_eh_ptr = llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", cur->test);
+      Instruction* ptr_eh_ptr = 
+        llvm::CallInst::Create(mvm::jit::llvmGetException, "eh_ptr", cur->test);
       int32_eh_select_params.push_back(ptr_eh_ptr);
-      int32_eh_select_params.push_back(ConstantExpr::getCast(Instruction::BitCast, mvm::jit::personality, PointerTy_0));
+      Constant* C = ConstantExpr::getCast(Instruction::BitCast,
+                                          mvm::jit::personality, PointerTy_0);
+      int32_eh_select_params.push_back(C);
       int32_eh_select_params.push_back(mvm::jit::constantPtrNull);
-      llvm::CallInst::Create(mvm::jit::exceptionSelector, int32_eh_select_params.begin(), int32_eh_select_params.end(), "eh_select", cur->test);
+      llvm::CallInst::Create(mvm::jit::exceptionSelector,
+                             int32_eh_select_params.begin(),
+                             int32_eh_select_params.end(), "eh_select",
+                             cur->test);
       llvm::BranchInst::Create(cur->realTest, cur->test);
       cur->exceptionPHI->addIncoming(ptr_eh_ptr, cur->test);
     } 
-
-    Value* cl = new LoadInst(cur->catchClass->llvmVar(compilingClass->isolate->module), "", cur->realTest);
-    Value* cmp = llvm::CallInst::Create(compareExceptionLLVM, cl, "", cur->realTest);
+    
+    Module* M = compilingClass->isolate->module;
+    Value* cl = new LoadInst(cur->catchClass->llvmVar(M), "", cur->realTest);
+    Value* cmp = llvm::CallInst::Create(compareExceptionLLVM, cl, "",
+                                        cur->realTest);
     llvm::BranchInst::Create(cur->handler, bbNext, cmp, cur->realTest);
     if (nodeNext)
       nodeNext->addIncoming(cur->exceptionPHI, cur->realTest);
     
     if (cur->handler->empty()) {
-      cur->handlerPHI = llvm::PHINode::Create(mvm::jit::ptrType, "", cur->handler);
+      cur->handlerPHI = llvm::PHINode::Create(mvm::jit::ptrType, "",
+                                              cur->handler);
       cur->handlerPHI->addIncoming(cur->exceptionPHI, cur->realTest);
-      Value* exc = llvm::CallInst::Create(getJavaExceptionLLVM, "", cur->handler);
+      Value* exc = llvm::CallInst::Create(getJavaExceptionLLVM, "",
+                                          cur->handler);
       llvm::CallInst::Create(clearExceptionLLVM, "", cur->handler);
-      llvm::CallInst::Create(mvm::jit::exceptionBeginCatch, cur->handlerPHI, "tmp8", cur->handler);
+      llvm::CallInst::Create(mvm::jit::exceptionBeginCatch, cur->handlerPHI,
+                             "tmp8", cur->handler);
       std::vector<Value*> void_28_params;
-      llvm::CallInst::Create(mvm::jit::exceptionEndCatch, void_28_params.begin(), void_28_params.end(), "", cur->handler);
+      llvm::CallInst::Create(mvm::jit::exceptionEndCatch,
+                             void_28_params.begin(), void_28_params.end(), "",
+                             cur->handler);
       new StoreInst(exc, supplLocal, false, cur->handler);
     } else {
       Instruction* insn = cur->handler->begin();
@@ -718,7 +729,7 @@
         const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]);
         void* val = 0;
         GlobalVariable* gv = 0;
-#ifndef SINGLE_VM
+#ifdef MULTIPLE_VM
         if (compilingClass->isolate != Jnjvm::bootstrapVM) {
 #endif
         val = compilingClass->isolate->UTF8ToStr(utf8);
@@ -729,7 +740,7 @@
                              constantJavaObjectNull, "",
                              compilingClass->isolate->module);
         compilingClass->isolate->protectModule->unlock();
-#ifndef SINGLE_VM
+#ifdef MULTIPLE_VM
         } else {
           val = (void*)utf8;
           compilingClass->isolate->protectModule->lock();
@@ -746,38 +757,47 @@
         void* ptr = mvm::jit::executionEngine->getPointerToGlobal(gv);
         GenericValue Val = GenericValue(val);
         llvm::GenericValue * Ptr = (llvm::GenericValue*)ptr;
-        mvm::jit::executionEngine->StoreValueToMemory(Val, Ptr, JavaObject::llvmType);
+        mvm::jit::executionEngine->StoreValueToMemory(Val, Ptr,
+                                                      JavaObject::llvmType);
         toPush = new LoadInst(gv, "", currentBlock);
         ctpInfo->ctpRes[index] = gv;
         compilingClass->release();
       } else {
         compilingClass->release();
-        toPush = new LoadInst((GlobalVariable*)ctpInfo->ctpRes[index], "", currentBlock);
+        toPush = new LoadInst((GlobalVariable*)ctpInfo->ctpRes[index], "",
+                              currentBlock);
       }
     } else {
-      toPush = new LoadInst((GlobalVariable*)ctpInfo->ctpRes[index], "", currentBlock);
+      toPush = new LoadInst((GlobalVariable*)ctpInfo->ctpRes[index], "",
+                            currentBlock);
     }
-#ifndef SINGLE_VM
-    if (compilingClass->isolate == Jnjvm::bootstrapVM)
-      push(llvm::CallInst::Create(runtimeUTF8ToStrLLVM, toPush, "", currentBlock), AssessorDesc::dRef);
-    else 
+#ifdef MULTIPLE_VM
+    if (compilingClass->isolate == Jnjvm::bootstrapVM) {
+      CallInst* C = llvm::CallInst::Create(runtimeUTF8ToStrLLVM, toPush, "",
+                                           currentBlock);
+      push(C, AssessorDesc::dRef);
+    } else 
 #endif
     push(toPush, AssessorDesc::dRef);
   } else if (type == JavaCtpInfo::ConstantLong) {
     mvm::jit::protectConstants();//->lock();
-    push(ConstantInt::get(Type::Int64Ty, ctpInfo->LongAt(index)), AssessorDesc::dLong);
+    push(ConstantInt::get(Type::Int64Ty, ctpInfo->LongAt(index)),
+         AssessorDesc::dLong);
     mvm::jit::unprotectConstants();//->unlock();
   } else if (type == JavaCtpInfo::ConstantDouble) {
     mvm::jit::protectConstants();//->lock();
-    push(ConstantFP::get(Type::DoubleTy, APFloat(ctpInfo->DoubleAt(index))), AssessorDesc::dDouble);
+    push(ConstantFP::get(Type::DoubleTy, APFloat(ctpInfo->DoubleAt(index))),
+         AssessorDesc::dDouble);
     mvm::jit::unprotectConstants();//->unlock();
   } else if (type == JavaCtpInfo::ConstantInteger) {
     mvm::jit::protectConstants();//->lock();
-    push(ConstantInt::get(Type::Int32Ty, ctpInfo->IntegerAt(index)), AssessorDesc::dInt);
+    push(ConstantInt::get(Type::Int32Ty, ctpInfo->IntegerAt(index)),
+         AssessorDesc::dInt);
     mvm::jit::unprotectConstants();//->unlock();
   } else if (type == JavaCtpInfo::ConstantFloat) {
     mvm::jit::protectConstants();//->lock();
-    push(ConstantFP::get(Type::FloatTy, APFloat(ctpInfo->FloatAt(index))), AssessorDesc::dFloat);
+    push(ConstantFP::get(Type::FloatTy, APFloat(ctpInfo->FloatAt(index))),
+         AssessorDesc::dFloat);
     mvm::jit::unprotectConstants();//->unlock();
   } else if (type == JavaCtpInfo::ConstantClass) {
     assert(0 && "implement ConstantClass in ldc!");
@@ -799,9 +819,10 @@
   llvm::BranchInst::Create(exit, cont, test, jit->currentBlock);
   std::vector<Value*> args;
   if (currentExceptionBlock != endExceptionBlock) {
-    llvm::InvokeInst::Create(JavaJIT::nullPointerExceptionLLVM, unifiedUnreachable,
-                   currentExceptionBlock, args.begin(),
-                   args.end(), "", exit);
+    llvm::InvokeInst::Create(JavaJIT::nullPointerExceptionLLVM,
+                             unifiedUnreachable,
+                             currentExceptionBlock, args.begin(),
+                             args.end(), "", exit);
   } else {
     llvm::CallInst::Create(JavaJIT::nullPointerExceptionLLVM, args.begin(),
                  args.end(), "", exit);
@@ -824,7 +845,8 @@
   if (true) {
     Value* size = arraySize(obj);
     
-    Value* cmp = new ICmpInst(ICmpInst::ICMP_ULT, index, size, "", currentBlock);
+    Value* cmp = new ICmpInst(ICmpInst::ICMP_ULT, index, size, "",
+                              currentBlock);
 
     BasicBlock* ifTrue =  createBasicBlock("true verifyAndComputePtr");
     BasicBlock* ifFalse = createBasicBlock("false verifyAndComputePtr");
@@ -835,12 +857,13 @@
     args.push_back(obj);
     args.push_back(index);
     if (currentExceptionBlock != endExceptionBlock) {
-      llvm::InvokeInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM, unifiedUnreachable,
-                     currentExceptionBlock, args.begin(),
-                     args.end(), "", ifFalse);
+      llvm::InvokeInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM,
+                               unifiedUnreachable,
+                               currentExceptionBlock, args.begin(),
+                               args.end(), "", ifFalse);
     } else {
-      llvm::CallInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM, args.begin(),
-                   args.end(), "", ifFalse);
+      llvm::CallInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM,
+                             args.begin(), args.end(), "", ifFalse);
       new UnreachableInst(ifFalse);
     }
   
@@ -854,8 +877,9 @@
   indexes.push_back(zero);
   indexes.push_back(JavaArray::elementsOffset());
   indexes.push_back(index);
-  Value* ptr = llvm::GetElementPtrInst::Create(val, indexes.begin(), indexes.end(), 
-                                     "", currentBlock);
+  Value* ptr = llvm::GetElementPtrInst::Create(val, indexes.begin(),
+                                               indexes.end(), 
+                                               "", currentBlock);
 
   return ptr;
 
@@ -887,7 +911,8 @@
 
 static void testPHINodes(BasicBlock* dest, BasicBlock* insert, JavaJIT* jit) {
   if(dest->empty()) {
-    for (std::vector< std::pair<Value*, const AssessorDesc*> >::iterator i = jit->stack.begin(),
+    for (std::vector< std::pair<Value*, const AssessorDesc*> >::iterator i =
+              jit->stack.begin(),
             e = jit->stack.end(); i!= e; ++i) {
       Value* cur = i->first;
       const AssessorDesc* func = i->second;
@@ -904,7 +929,8 @@
       node->addIncoming(cur, insert);
     }
   } else {
-    std::vector< std::pair<Value*, const AssessorDesc*> >::iterator stackit = jit->stack.begin();
+    std::vector< std::pair<Value*, const AssessorDesc*> >::iterator stackit = 
+      jit->stack.begin();
     for (BasicBlock::iterator i = dest->begin(), e = dest->end(); i != e;
          ++i) {
       if (!(isa<PHINode>(i))) {
@@ -990,64 +1016,102 @@
     if (Ty == Type::Int32Ty) {
       Constant* const_int32_9 = mvm::jit::constantZero;
       ConstantInt* const_int32_10 = mvm::jit::constantMinusOne;
-      BinaryOperator* int32_tmpneg = BinaryOperator::create(Instruction::Sub, const_int32_9, args[0], "tmpneg", currentBlock);
-      ICmpInst* int1_abscond = new ICmpInst(ICmpInst::ICMP_SGT, args[0], const_int32_10, "abscond", currentBlock);
-      return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg, "abs", currentBlock);
+      BinaryOperator* int32_tmpneg = 
+        BinaryOperator::create(Instruction::Sub, const_int32_9, args[0],
+                               "tmpneg", currentBlock);
+      ICmpInst* int1_abscond = 
+        new ICmpInst(ICmpInst::ICMP_SGT, args[0], const_int32_10, "abscond", 
+                     currentBlock);
+      return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg,
+                                      "abs", currentBlock);
     } else if (Ty == Type::Int64Ty) {
       Constant* const_int64_9 = mvm::jit::constantLongZero;
       ConstantInt* const_int64_10 = mvm::jit::constantLongMinusOne;
-      BinaryOperator* int64_tmpneg = BinaryOperator::create(Instruction::Sub, const_int64_9, args[0], "tmpneg", currentBlock);
-      ICmpInst* int1_abscond = new ICmpInst(ICmpInst::ICMP_SGT, args[0], const_int64_10, "abscond", currentBlock);
-      return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg, "abs", currentBlock);
+      
+      BinaryOperator* int64_tmpneg = 
+        BinaryOperator::create(Instruction::Sub, const_int64_9, args[0],
+                               "tmpneg", currentBlock);
+
+      ICmpInst* int1_abscond = new ICmpInst(ICmpInst::ICMP_SGT, args[0],
+                                            const_int64_10, "abscond",
+                                            currentBlock);
+      
+      return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg,
+                                      "abs", currentBlock);
     } else if (Ty == Type::FloatTy) {
-      return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f32, args[0], "tmp1", currentBlock);
+      return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f32, args[0],
+                                    "tmp1", currentBlock);
     } else if (Ty == Type::DoubleTy) {
-      return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f64, args[0], "tmp1", currentBlock);
+      return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f64, args[0],
+                                    "tmp1", currentBlock);
     }
   } else if (name == Jnjvm::sqrt) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_sqrt_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_sqrt_f64, args[0],
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::sin) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_sin_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_sin_f64, args[0], 
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::cos) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_cos_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_cos_f64, args[0], 
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::tan) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_tan_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_tan_f64, args[0], 
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::asin) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_asin_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_asin_f64, args[0], 
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::acos) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_acos_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_acos_f64, args[0], 
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::atan) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_atan_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_atan_f64, args[0],
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::atan2) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_atan2_f64, args.begin(), args.end(), "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_atan2_f64, 
+                                  args.begin(), args.end(), "tmp1",
+                                  currentBlock);
   } else if (name == Jnjvm::exp) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_exp_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_exp_f64, args[0],
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::log) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_log_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_log_f64, args[0],
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::pow) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_pow_f64, args.begin(), args.end(), "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_pow_f64, args.begin(),
+                                  args.end(), "tmp1", currentBlock);
   } else if (name == Jnjvm::ceil) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_ceil_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_ceil_f64, args[0], "tmp1",
+                                  currentBlock);
   } else if (name == Jnjvm::floor) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_floor_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_floor_f64, args[0],
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::rint) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_rint_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_rint_f64, args[0],
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::cbrt) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_cbrt_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_cbrt_f64, args[0], "tmp1",
+                                  currentBlock);
   } else if (name == Jnjvm::cosh) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_cosh_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_cosh_f64, args[0], "tmp1",
+                                  currentBlock);
   } else if (name == Jnjvm::expm1) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_expm1_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_expm1_f64, args[0],
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::hypot) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_hypot_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_hypot_f64, args[0],
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::log10) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_log10_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_log10_f64, args[0],
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::log1p) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_log1p_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_log1p_f64, args[0],
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::sinh) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_sinh_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_sinh_f64, args[0],
+                                  "tmp1", currentBlock);
   } else if (name == Jnjvm::tanh) {
-    return llvm::CallInst::Create(mvm::jit::func_llvm_tanh_f64, args[0], "tmp1", currentBlock);
+    return llvm::CallInst::Create(mvm::jit::func_llvm_tanh_f64, args[0],
+                                  "tmp1", currentBlock);
   }
   
   return 0;
@@ -1200,7 +1264,8 @@
     Value* node = getInitializedClass(index);
     val = invoke(doNewUnknownLLVM, node, "", currentBlock);
   } else {
-    Value* load = new LoadInst(cl->llvmVar(compilingClass->isolate->module), "", currentBlock);
+    Value* load = new LoadInst(cl->llvmVar(compilingClass->isolate->module),
+                               "", currentBlock);
     val = invoke(doNewLLVM, load, "", currentBlock);
     // give the real type info, escape analysis uses it
     new BitCastInst(val, cl->virtualType, "", currentBlock);
@@ -1231,8 +1296,10 @@
   std::vector<Value*> args; // size = 2
   args.push_back(zero);
   args.push_back(offset);
-  llvm::Value* ptr = llvm::GetElementPtrInst::Create(objectConvert, args.begin(),
-                                           args.end(), "", jit->currentBlock);
+  llvm::Value* ptr = llvm::GetElementPtrInst::Create(objectConvert,
+                                                     args.begin(),
+                                                     args.end(), "",
+                                                     jit->currentBlock);
   return ptr;  
 }
 
@@ -1242,16 +1309,11 @@
   
   JavaField* field = info->lookupField(index, stat);
   if (field && field->classDef->isReady()) {
-    if (stat) object = new LoadInst(field->classDef->staticVar(compilingClass->isolate->module), "",
-                                    currentBlock);
+    Module* M = compilingClass->isolate->module;
+    if (stat) object = field->classDef->staticVar(M, currentBlock);
     const Type* type = stat ? field->classDef->staticType :
                               field->classDef->virtualType;
 
-#ifndef SINGLE_VM
-    if (stat && field->classDef->isolate == Jnjvm::bootstrapVM) {
-      object = llvm::CallInst::Create(getStaticInstanceLLVM, object, "", currentBlock);
-    }
-#endif
     return fieldGetter(this, type, object, field->offset);
   } else {
     const Type* Pty = mvm::jit::arrayPtrType;
@@ -1304,8 +1366,8 @@
     } else {
       args.push_back(constantJavaObjectNull);
     }
-    args.push_back(new LoadInst(compilingClass->llvmVar(compilingClass->isolate->module), "",
-                                currentBlock));
+    Module* M = compilingClass->isolate->module;
+    args.push_back(new LoadInst(compilingClass->llvmVar(M), "", currentBlock));
     mvm::jit::protectConstants();//->lock();
     args.push_back(ConstantInt::get(Type::Int32Ty, index));
     mvm::jit::unprotectConstants();//->unlock();
@@ -1321,7 +1383,8 @@
   }
 }
 
-extern void convertValue(Value*& val, const Type* t1, BasicBlock* currentBlock, bool usign);
+extern void convertValue(Value*& val, const Type* t1, BasicBlock* currentBlock,
+                         bool usign);
  
 
 void JavaJIT::setStaticField(uint16 index) {
@@ -1398,8 +1461,9 @@
   if (currentExceptionBlock != endExceptionBlock) {
     BasicBlock* ifNormal = createBasicBlock("no exception block");
     currentBlock = ifNormal;
-    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(), 
-                          args.end(), Name, InsertAtEnd);
+    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock,
+                                    args.begin(), 
+                                    args.end(), Name, InsertAtEnd);
   } else {
     return llvm::CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd);
   }
@@ -1414,8 +1478,8 @@
     currentBlock = ifNormal;
     std::vector<Value*> arg;
     arg.push_back(arg1);
-    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, arg.begin(),
-                          arg.end(), Name, InsertAtEnd);
+    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock,
+                                    arg.begin(), arg.end(), Name, InsertAtEnd);
   } else {
     return llvm::CallInst::Create(F, arg1, Name, InsertAtEnd);
   }
@@ -1432,8 +1496,9 @@
   if (currentExceptionBlock != endExceptionBlock) {
     BasicBlock* ifNormal = createBasicBlock("no exception block");
     currentBlock = ifNormal;
-    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(),
-                          args.end(), Name, InsertAtEnd);
+    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock,
+                                    args.begin(), args.end(), Name,
+                                    InsertAtEnd);
   } else {
     return llvm::CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd);
   }
@@ -1446,8 +1511,9 @@
     BasicBlock* ifNormal = createBasicBlock("no exception block");
     currentBlock = ifNormal;
     std::vector<Value*> args;
-    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock, args.begin(),
-                          args.end(), Name, InsertAtEnd);
+    return llvm::InvokeInst::Create(F, ifNormal, currentExceptionBlock,
+                                    args.begin(), args.end(), Name,
+                                    InsertAtEnd);
   } else {
     return llvm::CallInst::Create(F, Name, InsertAtEnd);
   }

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Tue Apr  8 12:06:22 2008
@@ -268,10 +268,6 @@
   static llvm::Function* getStaticInstanceLLVM;
   static llvm::Function* getClassDelegateeLLVM;
   static llvm::Function* arrayLengthLLVM;
-#ifndef SINGLE_VM
-  static llvm::Function* doNewIsolateLLVM;
-#endif
-  static void runtimeInitialise();
   
 
   static Class* getCallingClass();

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Tue Apr  8 12:06:22 2008
@@ -7,62 +7,15 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <llvm/Type.h>
-#include <llvm/Support/CFG.h>
-#include <llvm/Module.h>
-#include <llvm/Constants.h>
-#include <llvm/Type.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/Instructions.h>
-#include <llvm/ModuleProvider.h>
-#include <llvm/ExecutionEngine/JIT.h>
-#include <llvm/ExecutionEngine/GenericValue.h>
-#include <llvm/PassManager.h>
-#include <llvm/Analysis/Verifier.h>
-#include <llvm/Transforms/Scalar.h>
-#include <llvm/Target/TargetData.h>
-#include <llvm/Assembly/PrintModulePass.h>
-#include <llvm/Target/TargetOptions.h>
-#include <llvm/CodeGen/MachineCodeEmitter.h>
-#include <llvm/CodeGen/MachineBasicBlock.h>
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
+#include "llvm/Instructions.h"
+#include "llvm/LinkAllPasses.h"
 #include "llvm/Module.h"
-#include "llvm/ModuleProvider.h"
-#include "llvm/ParameterAttributes.h"
-#include "llvm/PassManager.h"
-#include "llvm/ValueSymbolTable.h"
-#include "llvm/Analysis/LoadValueNumbering.h"
 #include "llvm/Analysis/LoopPass.h"
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/Assembly/Writer.h"
-#include "llvm/Assembly/PrintModulePass.h"
-#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/CodeGen/RegAllocRegistry.h"
-#include "llvm/CodeGen/SchedulerRegistry.h"
-#include "llvm/CodeGen/ScheduleDAG.h"
-#include "llvm/Target/SubtargetFeature.h"
-#include "llvm/Target/TargetData.h"
-#include "llvm/Target/TargetLowering.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetMachineRegistry.h"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Transforms/IPO.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/Support/Streams.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/MutexGuard.h"
 
-#include <llvm/Transforms/IPO.h>
-
-#include <setjmp.h>
 
 #include "mvm/JIT.h"
 #include "mvm/Method.h"
-#include "mvm/VMLet.h"
 
 #include "JavaArray.h"
 #include "JavaCache.h"
@@ -75,9 +28,23 @@
 using namespace jnjvm;
 using namespace llvm;
 
-void JavaJIT::initialise() {
-  runtimeInitialise();
-}
+const llvm::FunctionType* JavaJIT::markAndTraceLLVMType = 0;
+
+const llvm::Type* JavaObject::llvmType = 0;
+const llvm::Type* JavaArray::llvmType = 0;
+const llvm::Type* ArrayUInt8::llvmType = 0;
+const llvm::Type* ArraySInt8::llvmType = 0;
+const llvm::Type* ArrayUInt16::llvmType = 0;
+const llvm::Type* ArraySInt16::llvmType = 0;
+const llvm::Type* ArrayUInt32::llvmType = 0;
+const llvm::Type* ArraySInt32::llvmType = 0;
+const llvm::Type* ArrayFloat::llvmType = 0;
+const llvm::Type* ArrayDouble::llvmType = 0;
+const llvm::Type* ArrayLong::llvmType = 0;
+const llvm::Type* ArrayObject::llvmType = 0;
+const llvm::Type* UTF8::llvmType = 0;
+const llvm::Type* CacheNode::llvmType = 0;
+const llvm::Type* Enveloppe::llvmType = 0;
 
 void JavaJIT::initialiseJITIsolateVM(Jnjvm* vm) {
   mvm::jit::protectEngine->lock();
@@ -274,20 +241,6 @@
                      module);
   }
 
-#ifndef SINGLE_VM
-  // Create doNewIsolateLLVM
-  {
-  std::vector<const Type*> args;
-  args.push_back(mvm::jit::ptrType);
-  const FunctionType* type = FunctionType::get(JavaObject::llvmType, args,
-                                               false);
-
-  doNewIsolateLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
-                     "_ZN5jnjvm5Class12doNewIsolateEv",
-                     module);
-  }
-#endif
-  
   // Create fieldLookupLLVM
   {
   std::vector<const Type*> args;

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Tue Apr  8 12:06:22 2008
@@ -13,27 +13,12 @@
 
 #include <string.h>
 
-#include <llvm/Type.h>
-#include <llvm/Module.h>
 #include <llvm/Constants.h>
-#include <llvm/Type.h>
 #include <llvm/DerivedTypes.h>
 #include <llvm/Function.h>
 #include <llvm/Instructions.h>
-#include <llvm/ModuleProvider.h>
-#include <llvm/ExecutionEngine/JIT.h>
-#include <llvm/ExecutionEngine/GenericValue.h>
-#include <llvm/PassManager.h>
-#include <llvm/Analysis/Verifier.h>
-#include <llvm/Transforms/Scalar.h>
-#include <llvm/Target/TargetData.h>
-#include <llvm/Assembly/PrintModulePass.h>
-#include <llvm/Target/TargetOptions.h>
-#include <llvm/CodeGen/MachineCodeEmitter.h>
-#include <llvm/CodeGen/MachineBasicBlock.h>
-
-#include <llvm/Transforms/IPO.h>
-
+#include <llvm/Module.h>
+#include <llvm/Type.h>
 
 #include "mvm/JIT.h"
 #include "mvm/Method.h"
@@ -48,7 +33,6 @@
 #include "JavaThread.h"
 #include "JavaTypes.h"
 #include "Jnjvm.h"
-#include "Reader.h"
 
 #include "OpcodeNames.def"
 

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Tue Apr  8 12:06:22 2008
@@ -7,145 +7,79 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include <stdarg.h>
 #include <string.h>
 
-#include <llvm/Type.h>
-#include <llvm/Support/CFG.h>
+#include <llvm/BasicBlock.h>
+#include <llvm/GlobalVariable.h>
+#include <llvm/Instructions.h>
 #include <llvm/Module.h>
-#include <llvm/Constants.h>
 #include <llvm/Type.h>
-#include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/Instructions.h>
-#include <llvm/ModuleProvider.h>
-#include <llvm/ExecutionEngine/JIT.h>
-#include <llvm/ExecutionEngine/GenericValue.h>
-#include <llvm/PassManager.h>
-#include <llvm/Analysis/Verifier.h>
-#include <llvm/Transforms/Scalar.h>
-#include <llvm/Target/TargetData.h>
-#include <llvm/Assembly/PrintModulePass.h>
-#include <llvm/Target/TargetOptions.h>
-#include <llvm/CodeGen/MachineCodeEmitter.h>
-#include <llvm/CodeGen/MachineBasicBlock.h>
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Module.h"
-#include "llvm/ModuleProvider.h"
-#include "llvm/PassManager.h"
-#include "llvm/ValueSymbolTable.h"
-#include "llvm/Analysis/LoadValueNumbering.h"
-#include "llvm/Analysis/LoopPass.h"
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/Assembly/Writer.h"
-#include "llvm/Assembly/PrintModulePass.h"
-#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/CodeGen/RegAllocRegistry.h"
-#include "llvm/CodeGen/SchedulerRegistry.h"
-#include "llvm/CodeGen/ScheduleDAG.h"
-#include "llvm/Target/SubtargetFeature.h"
-#include "llvm/Target/TargetData.h"
-#include "llvm/Target/TargetLowering.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetMachineRegistry.h"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Transforms/IPO.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/Support/Streams.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/MemoryBuffer.h"
-
-#include <llvm/Transforms/IPO.h>
-
+#include "llvm/ExecutionEngine/GenericValue.h"
 
 #include "mvm/JIT.h"
 #include "mvm/Method.h"
 
 #include "debug.h"
 #include "JavaArray.h"
-#include "JavaCache.h"
 #include "JavaClass.h"
-#include "JavaConstantPool.h"
-#include "JavaObject.h"
 #include "JavaJIT.h"
-#include "JavaString.h"
+#include "JavaObject.h"
 #include "JavaThread.h"
 #include "JavaTypes.h"
-#include "JavaUpcalls.h"
 #include "Jnjvm.h"
-#include "JnjvmModuleProvider.h"
-#include "NativeUtil.h"
-#include "Reader.h"
-#include "Zip.h"
-
-#include <iostream>
-
 
 using namespace jnjvm;
 using namespace llvm;
 
-#ifndef SINGLE_VM
-GlobalVariable* Class::staticVar(llvm::Module* compilingModule) {
+Value* Class::staticVar(Module* compilingModule,  BasicBlock* currentBlock) {
+
   if (!_staticVar) {
     aquire();
     if (!_staticVar) {
+#ifdef MULTIPLE_VM
       if (isolate == Jnjvm::bootstrapVM) {
         _staticVar = llvmVar(compilingModule);
-        release();
-        return _staticVar;
       } else {
-        isolate->protectModule->lock();
-        _staticVar = new GlobalVariable(JavaObject::llvmType, false,
-                                        GlobalValue::ExternalLinkage,
-                                        JavaJIT::constantJavaObjectNull, "",
-                                        isolate->module);
-        isolate->protectModule->unlock();
-    
-        // TODO: put an initializer in here
-        void* ptr = mvm::jit::executionEngine->getPointerToGlobal(_staticVar);
-        GenericValue Val = GenericValue((void*)staticInstance());
-        llvm::GenericValue * Ptr = (llvm::GenericValue*)ptr;
-        mvm::jit::executionEngine->StoreValueToMemory(Val, Ptr, staticType); 
-      }
-    }
-  release();
-  }
-
-  return _staticVar;
-}
-#else
-GlobalVariable* Class::staticVar(llvm::Module* compilingModule) {
-  if (!_staticVar) {
-    aquire();
-    if (!_staticVar) {
-      
-      JavaObject* obj = staticInstance();
-      mvm::jit::protectConstants();//->lock();
-      Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (obj)),
-                                  JavaObject::llvmType);
-      mvm::jit::unprotectConstants();//->unlock();
+#endif
+        JavaObject* obj = staticInstance();
+        mvm::jit::protectConstants();//->lock();
+        Constant* cons = 
+          ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+                                    uint64_t (obj)), JavaObject::llvmType);
+        mvm::jit::unprotectConstants();//->unlock();
       
-      isolate->protectModule->lock();
-      _staticVar = new GlobalVariable(JavaObject::llvmType, true,
+        isolate->protectModule->lock();
+        _staticVar = new GlobalVariable(JavaObject::llvmType, true,
                                       GlobalValue::ExternalLinkage,
                                       cons, "",
                                       isolate->module);
-      isolate->protectModule->unlock();
-    
+        isolate->protectModule->unlock();
+      }
+#ifdef MULTIPLE_VM
     }
+#endif
     release();
   }
-  return _staticVar;
-}
+
+#ifdef MULTIPLE_VM
+  if (isolate == Jnjvm::bootstrapVM) {
+    Value* ld = new LoadInst(_staticVar, "", currentBlock);
+    return llvm::CallInst::Create(JavaJIT::getStaticInstanceLLVM, ld, "",
+                                  currentBlock);
+  } else {
+#endif
+    return new LoadInst(_staticVar, "", currentBlock);
+#ifdef MULTIPLE_VM
+  }
 #endif
+}
 
 GlobalVariable* CommonClass::llvmVar(llvm::Module* compilingModule) {
   if (!_llvmVar) {
     aquire();
     if (!_llvmVar) {
-#ifndef SINGLE_VM
+#ifdef MULTIPLE_VM
       if (compilingModule == Jnjvm::bootstrapVM->module && isArray && isolate != Jnjvm::bootstrapVM) {
         // We know the array class can belong to bootstrap
         _llvmVar = Jnjvm::bootstrapVM->constructArray(this->name, 0)->llvmVar(compilingModule);
@@ -173,8 +107,8 @@
   return _llvmVar;
 }
 
-#ifdef SINGLE_VM
-GlobalVariable* CommonClass::llvmDelegatee() {
+Value* CommonClass::llvmDelegatee(llvm::Module* M, llvm::BasicBlock* BB) {
+#ifndef MULTIPLE_VM
   if (!_llvmDelegatee) {
     aquire();
     if (!_llvmDelegatee) {
@@ -183,7 +117,7 @@
       JavaObject* obj = getClassDelegatee();
       mvm::jit::protectConstants();//->lock();
       Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (obj)),
+        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(obj)),
                                     pty);
       mvm::jit::unprotectConstants();//->unlock();
 
@@ -196,9 +130,12 @@
     }
     release();
   }
-  return _llvmDelegatee;
-}
+  return new LoadInst(_llvmDelegatee, "", BB);
+#else
+  Value* ld = new LoadInst(llvmVar(M), "", BB);
+  return llvm::CallInst::Create(JavaJIT::getClassDelegateeLLVM, ld, "", BB);
 #endif
+}
 
 ConstantInt* JavaObject::classOffset() {
   return mvm::jit::constantOne;

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.cpp Tue Apr  8 12:06:22 2008
@@ -18,6 +18,8 @@
 
 using namespace jnjvm;
 
+mvm::Lock* JavaObject::globalLock = 0;
+
 JavaCond* JavaCond::allocate() {
   return gc_new(JavaCond)();
 }

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Tue Apr  8 12:06:22 2008
@@ -26,6 +26,44 @@
 
 using namespace jnjvm;
 
+llvm::Function* JavaJIT::getSJLJBufferLLVM = 0;
+llvm::Function* JavaJIT::throwExceptionLLVM = 0;
+llvm::Function* JavaJIT::getExceptionLLVM = 0;
+llvm::Function* JavaJIT::getJavaExceptionLLVM = 0;
+llvm::Function* JavaJIT::clearExceptionLLVM = 0;
+llvm::Function* JavaJIT::compareExceptionLLVM = 0;
+llvm::Function* JavaJIT::nullPointerExceptionLLVM = 0;
+llvm::Function* JavaJIT::classCastExceptionLLVM = 0;
+llvm::Function* JavaJIT::indexOutOfBoundsExceptionLLVM = 0;
+llvm::Function* JavaJIT::markAndTraceLLVM = 0;
+llvm::Function* JavaJIT::javaObjectTracerLLVM = 0;
+llvm::Function* JavaJIT::virtualLookupLLVM = 0;
+llvm::Function* JavaJIT::fieldLookupLLVM = 0;
+llvm::Function* JavaJIT::UTF8AconsLLVM = 0;
+llvm::Function* JavaJIT::Int8AconsLLVM = 0;
+llvm::Function* JavaJIT::Int32AconsLLVM = 0;
+llvm::Function* JavaJIT::Int16AconsLLVM = 0;
+llvm::Function* JavaJIT::FloatAconsLLVM = 0;
+llvm::Function* JavaJIT::DoubleAconsLLVM = 0;
+llvm::Function* JavaJIT::LongAconsLLVM = 0;
+llvm::Function* JavaJIT::ObjectAconsLLVM = 0;
+llvm::Function* JavaJIT::printExecutionLLVM = 0;
+llvm::Function* JavaJIT::printMethodStartLLVM = 0;
+llvm::Function* JavaJIT::printMethodEndLLVM = 0;
+llvm::Function* JavaJIT::jniProceedPendingExceptionLLVM = 0;
+llvm::Function* JavaJIT::doNewLLVM = 0;
+llvm::Function* JavaJIT::doNewUnknownLLVM = 0;
+llvm::Function* JavaJIT::initialiseObjectLLVM = 0;
+llvm::Function* JavaJIT::newLookupLLVM = 0;
+llvm::Function* JavaJIT::instanceOfLLVM = 0;
+llvm::Function* JavaJIT::aquireObjectLLVM = 0;
+llvm::Function* JavaJIT::releaseObjectLLVM = 0;
+llvm::Function* JavaJIT::multiCallNewLLVM = 0;
+llvm::Function* JavaJIT::runtimeUTF8ToStrLLVM = 0;
+llvm::Function* JavaJIT::getStaticInstanceLLVM = 0;
+llvm::Function* JavaJIT::getClassDelegateeLLVM = 0;
+llvm::Function* JavaJIT::arrayLengthLLVM = 0;
+
 extern "C" JavaString* runtimeUTF8ToStr(const UTF8* val) {
   Jnjvm* vm = JavaThread::get()->isolate;
   return vm->UTF8ToStr(val);
@@ -161,7 +199,7 @@
   JavaThread::get()->isolate->indexOutOfBounds(obj, index);
 }
 
-#ifndef SINGLE_VM
+#ifdef MULTIPLE_VM
 extern "C" JavaObject* getStaticInstance(Class* cl) {
   if (cl->isolate == Jnjvm::bootstrapVM) {
     Jnjvm* vm = JavaThread::get()->isolate;
@@ -182,20 +220,9 @@
 }
 #endif
 
-void JavaJIT::runtimeInitialise() {
+void JavaJIT::initialise() {
   void* p;
   p = (void*)&runtimeUTF8ToStr;
-  p = (void*)&fieldLookup;
-  p = (void*)&virtualLookup;
-  p = (void*)&printExecution;
-  p = (void*)&jniProceedPendingException;
-  p = (void*)&nullPointerException;
-  p = (void*)&classCastException;
-  p = (void*)&indexOutOfBoundsException;
-#ifndef SINGLE_VM
-  p = (void*)&getStaticInstance;
-  p = (void*)&getClassDelegatee;
-#endif
 }
 
 extern "C" Class* newLookup(Class* caller, uint32 index, Class** toAlloc) { 

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Tue Apr  8 12:06:22 2008
@@ -40,25 +40,24 @@
 }
 
 JavaThread* JavaThread::get() {
-  return threadKey->get();
+  return (JavaThread*)Thread::threadKey->get();
 }
 
 extern void AddStandardCompilePasses(llvm::FunctionPassManager*);
 
-JavaThread* JavaThread::allocate(JavaObject* thread, Jnjvm* isolate) {
-  JavaThread* key = gc_new(JavaThread)();
-  key->javaThread = thread;
-  key->isolate = isolate;
-  key->lock = mvm::Lock::allocNormal();
-  key->varcond = mvm::Cond::allocCond();
-  key->interruptFlag = 0;
-  key->state = StateRunning;
-  key->self = mvm::Thread::self();
-  key->pendingException = 0;
-  key->perFunctionPasses = new llvm::FunctionPassManager(isolate->TheModuleProvider);
-  key->perFunctionPasses->add(new llvm::TargetData(isolate->module)); 
-  AddStandardCompilePasses(key->perFunctionPasses);
-  return key;
+void JavaThread::initialise(JavaObject* thread, Jnjvm* isolate) {
+  this->javaThread = thread;
+  this->isolate = isolate;
+  this->lock = mvm::Lock::allocNormal();
+  this->varcond = mvm::Cond::allocCond();
+  this->interruptFlag = 0;
+  this->state = StateRunning;
+  this->self = mvm::Thread::self();
+  this->pendingException = 0;
+  ModuleProvider* MP = isolate->TheModuleProvider;
+  this->perFunctionPasses = new llvm::FunctionPassManager(MP);
+  this->perFunctionPasses->add(new llvm::TargetData(isolate->module));
+  AddStandardCompilePasses(this->perFunctionPasses);
 }
 
 JavaObject* JavaThread::currentThread() {

Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Tue Apr  8 12:06:22 2008
@@ -18,6 +18,7 @@
 #include "mvm/Threads/Cond.h"
 #include "mvm/Threads/Key.h"
 #include "mvm/Threads/Locks.h"
+#include "mvm/Threads/Thread.h"
 
 namespace jnjvm {
 
@@ -25,7 +26,7 @@
 class JavaObject;
 class Jnjvm;
 
-class JavaThread : public mvm::Object {
+class JavaThread : public mvm::Thread {
 public:
   static VirtualTable *VT;
   JavaObject* javaThread;
@@ -50,10 +51,8 @@
   virtual void tracer(size_t sz);
   virtual void destroyer(size_t sz);
   
-  static mvm::Key<JavaThread>* threadKey;
-
+  void initialise(JavaObject* thread, Jnjvm* isolate);
   static JavaThread* get();
-  static JavaThread* allocate(JavaObject* thread, Jnjvm* isolate);
   static JavaObject* currentThread();
   
   static void* getException();

Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Tue Apr  8 12:06:22 2008
@@ -7,12 +7,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-// realpath
-#include <limits.h>
-#include <stdlib.h>
-
 #include <float.h>
-
+#include <limits.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -41,6 +37,44 @@
 
 using namespace jnjvm;
 
+Jnjvm* Jnjvm::bootstrapVM = 0;
+
+#define DEF_UTF8(var) \
+  const UTF8* Jnjvm::var = 0;
+  
+  DEF_UTF8(initName);
+  DEF_UTF8(clinitName);
+  DEF_UTF8(clinitType);
+  DEF_UTF8(runName);
+  DEF_UTF8(prelib);
+  DEF_UTF8(postlib);
+  DEF_UTF8(mathName);
+  DEF_UTF8(abs);
+  DEF_UTF8(sqrt);
+  DEF_UTF8(sin);
+  DEF_UTF8(cos);
+  DEF_UTF8(tan);
+  DEF_UTF8(asin);
+  DEF_UTF8(acos);
+  DEF_UTF8(atan);
+  DEF_UTF8(atan2);
+  DEF_UTF8(exp);
+  DEF_UTF8(log);
+  DEF_UTF8(pow);
+  DEF_UTF8(ceil);
+  DEF_UTF8(floor);
+  DEF_UTF8(rint);
+  DEF_UTF8(cbrt);
+  DEF_UTF8(cosh);
+  DEF_UTF8(expm1);
+  DEF_UTF8(hypot);
+  DEF_UTF8(log10);
+  DEF_UTF8(log1p);
+  DEF_UTF8(sinh);
+  DEF_UTF8(tanh);
+
+#undef DEF_UTF8
+
 const char* Jnjvm::dirSeparator = "/";
 const char* Jnjvm::envSeparator = ":";
 const unsigned int Jnjvm::Magic = 0xcafebabe;
@@ -265,17 +299,15 @@
 typedef void (*clinit_t)(void);
 
 void Jnjvm::initialiseClass(CommonClass* cl) {
-start:
-  if (!((Class*)cl)->isReady()) {
+  if (cl->isArray || AssessorDesc::bogusClassToPrimitive(cl)) {
+    cl->status = ready;
+  } else if (!(cl->isReady())) {
     cl->aquire();
     int status = cl->status;
-#ifdef SINGLE_VM
-    if (status == ready) {
-#else
-    if (((Class*)cl)->isReady()) {
-#endif
+    if (cl->isReady()) {
       cl->release();
-    } else if (status >= resolved && status != clinitParent && status != inClinit) {
+    } else if (status >= resolved && status != clinitParent &&
+               status != inClinit) {
       cl->status = clinitParent;
       cl->release();
       if (cl->super) {
@@ -292,15 +324,9 @@
       PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "clinit ");
       PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s::%s\n", printString(),
                   cl->printString());
-
-#ifndef SINGLE_VM
-      std::pair<uint8, JavaObject*>* val = 0;
-      if (this == bootstrapVM && !AssessorDesc::bogusClassToPrimitive(cl) && !cl->isArray) {
-        JavaObject* staticVar = ((Class*)cl)->createStaticInstance();
-        val = new std::pair<uint8, JavaObject*>(0, staticVar);
-        JavaThread::get()->isolate->statics->hash((Class*)cl, val);
-      }
-#endif
+      
+      ((Class*)cl)->createStaticInstance();
+      
       if (meth) {
         JavaObject* exc = 0;
         try{
@@ -319,13 +345,8 @@
           }
         }
       }
-
-      cl->status = ready;
-#ifndef SINGLE_VM
-      if (this == bootstrapVM && !AssessorDesc::bogusClassToPrimitive(cl) && !cl->isArray) {
-        val->first = 1;
-      }
-#endif
+      
+      cl->setReady();
       cl->broadcastClass();
     } else if (status < resolved) {
       cl->release();
@@ -334,7 +355,7 @@
       if (!cl->ownerClass()) {
         while (status < ready) cl->waitClass();
         cl->release();
-        goto start;
+        initialiseClass(cl);
       } 
       cl->release();
     }
@@ -770,22 +791,10 @@
 }
 
 const UTF8* Jnjvm::asciizConstructUTF8(const char* asciiz) {
-#ifndef SINGLE_VM
-  if (this != bootstrapVM) {
-    const UTF8* existing = bootstrapVM->hashUTF8->lookupAsciiz(asciiz);
-    if (existing) return existing;
-  }
-#endif
   return hashUTF8->lookupOrCreateAsciiz(asciiz);
 }
 
 const UTF8* Jnjvm::readerConstructUTF8(const uint16* buf, uint32 size) {
-#ifndef SINGLE_VM
-  if (this != bootstrapVM) {
-    const UTF8* existing = bootstrapVM->hashUTF8->lookupReader(buf, size);
-    if (existing) return existing;
-  }
-#endif
   return hashUTF8->lookupOrCreateReader(buf, size);
 }
 
@@ -803,18 +812,13 @@
 }
 
 CommonClass* Jnjvm::loadInClassLoader(const UTF8* name, JavaObject* loader) {
+  JavaString* str = this->UTF8ToStr(name);
   JavaObject* obj = (JavaObject*)
-    Classpath::loadInClassLoader->invokeJavaObjectVirtual(loader, this->UTF8ToStr(name));
+    Classpath::loadInClassLoader->invokeJavaObjectVirtual(loader, str);
   return (CommonClass*)((*Classpath::vmdataClass)(obj).PointerVal);
 }
 
 JavaString* Jnjvm::UTF8ToStr(const UTF8* utf8) { 
-#ifndef SINGLE_VM
-  if (this != bootstrapVM) {
-    JavaString* existing = bootstrapVM->hashStr->lookup(utf8);
-    if (existing) return existing;
-  }
-#endif
   JavaString* res = hashStr->lookupOrCreate(utf8, this, JavaString::stringDup);
   return res;
 }
@@ -828,7 +832,7 @@
   postProperties.push_back(std::make_pair(key, value));
 }
 
-#ifdef SINGLE_VM
+#ifndef MULTIPLE_VM
 JavaObject* Jnjvm::getClassDelegatee(CommonClass* cl) {
   if (!(cl->delegatee)) {
     JavaObject* delegatee = (*Classpath::newClass)();
@@ -838,7 +842,8 @@
     JavaObject* pd = cl->delegatee;
     JavaObject* delegatee = (*Classpath::newClass)();
     cl->delegatee = delegatee;;
-    Classpath::initClassWithProtectionDomain->invokeIntSpecial(delegatee, cl, pd);
+    Classpath::initClassWithProtectionDomain->invokeIntSpecial(delegatee, cl,
+                                                               pd);
   }
   return cl->delegatee;
 }

Modified: vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h Tue Apr  8 12:06:22 2008
@@ -241,7 +241,7 @@
   MethodMap* loadedMethods;
   FieldMap* loadedFields;
   TypeMap* javaTypes;
-#ifndef SINGLE_VM
+#ifdef MULTIPLE_VM
   StaticInstanceMap* statics;
   DelegateeMap* delegatees;
 #endif

Modified: vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LockedMap.h Tue Apr  8 12:06:22 2008
@@ -33,7 +33,7 @@
 
 struct ltutf8
 {
-#ifndef SINGLE_VM
+#ifdef MULTIPLE_VM
   bool operator()(const UTF8* s1, const UTF8* s2) const
   {
     if (s1->size < s2->size) return true;
@@ -327,8 +327,6 @@
     //lock->markAndTrace();
     for (iterator i = map.begin(), e = map.end(); i!= e; ++i) {
       i->first->markAndTrace();
-      printf("i->second = %p\n", i->second);
-      printf("second again = %p\n", i->second->second);
       i->second->second->markAndTrace();
     }
   }

Modified: vmkit/trunk/lib/JnJVM/VMCore/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Makefile.am (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Makefile.am Tue Apr  8 12:06:22 2008
@@ -18,6 +18,6 @@
 	JavaBacktrace.cpp NativeUtil.h NativeUtil.cpp Jni.cpp \
 	JavaCache.h JavaCache.cpp JavaUpcalls.h JavaUpcalls.cpp \
 	JnjvmModuleProvider.h JnjvmModuleProvider.cpp JavaRuntimeJIT.cpp JavaMetaJIT.cpp JavaJITInitialise.cpp \
-	LowerArrayLength.cpp
+	LowerArrayLength.cpp ServiceDomain.cpp
 
-libJnJVM_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -DSINGLE_VM -Werror -O2
+libJnJVM_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2

Modified: vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.cpp Tue Apr  8 12:06:22 2008
@@ -53,8 +53,10 @@
   service->loadedFields = FieldMap::allocate();
   service->javaTypes = jnjvm::TypeMap::allocate(); 
   service->globalRefsLock = mvm::Lock::allocNormal();
+#ifdef MULTIPLE_VM
   service->statics = StaticInstanceMap::allocate();  
   service->delegatees = DelegateeMap::allocate();  
+#endif
   
   // A service is related to a class loader
   // Here are the classes it loaded

Modified: vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/VirtualTables.cpp Tue Apr  8 12:06:22 2008
@@ -138,7 +138,7 @@
   TRACE_VECTOR(JavaField*, virtualFields);
   TRACE_VECTOR(JavaField*, staticFields);
   classLoader->markAndTrace();
-#ifdef SINGLE_VM
+#ifndef MULTIPLE_VM
   delegatee->markAndTrace();
 #endif
   TRACE_VECTOR(CommonClass*, display);
@@ -263,7 +263,7 @@
   TRACE_VECTOR(JavaObject*, globalRefs);
   //globalRefsLock->markAndTrace();
   functions->markAndTrace();
-#ifndef SINGLE_VM
+#ifdef MULTIPLE_VM
   statics->markAndTrace();
   delegatees->markAndTrace();
 #endif

Modified: vmkit/trunk/lib/Mvm/Allocator/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Allocator/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Allocator/Makefile.am (original)
+++ vmkit/trunk/lib/Mvm/Allocator/Makefile.am Tue Apr  8 12:06:22 2008
@@ -2,7 +2,7 @@
 noinst_PROGRAMS = mainuvm_alloc
 
 libuvm_alloc_a_SOURCES = gcalloc.cpp gcalloc.h gcchunk.cpp gcchunk.h gcerror.cpp gcerror.h gcmapper.cpp gcmapper.h osdep.h
-libuvm_alloc_a_CXXFLAGS = -O2 -W -Wall -Werror -ansi -pedantic -Wno-variadic-macros -Wno-unused-parameter
+libuvm_alloc_a_CXXFLAGS = -O2 -W -Wall -Werror -ansi -pedantic -Wno-variadic-macros -Wno-unused-parameter -DSERVICE_VM
 
 mainuvm_alloc_SOURCES = main.cpp
 mainuvm_alloc_CXXFLAGS =

Modified: vmkit/trunk/lib/Mvm/CommonThread/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/CommonThread/Makefile.am (original)
+++ vmkit/trunk/lib/Mvm/CommonThread/Makefile.am Tue Apr  8 12:06:22 2008
@@ -6,6 +6,6 @@
 ALLOCLIBS = $(ALLOCDIR)/libuvm_alloc.a
 
 libuvm_common_thread_a_SOURCES = cterror.h ctthread.cpp cterror.cpp ctlock.cpp
-libuvm_common_thread_a_CXXFLAGS = -frepo -O2 -W -Wall -Werror -ansi -pedantic -Wno-unused-parameter
+libuvm_common_thread_a_CXXFLAGS = -frepo -O2 -W -Wall -Werror -ansi -pedantic -Wno-unused-parameter -DSERVICE_VM
 
 CLEANFILES = *~ *.bak .*.sw?

Modified: vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h (original)
+++ vmkit/trunk/lib/Mvm/GCMmap2/gccollector.h Tue Apr  8 12:06:22 2008
@@ -19,7 +19,7 @@
 
 namespace mvm {
 
-class GCCollector {
+class GCCollector : public Collector {
 #ifdef HAVE_PTHREAD
   friend class GCThread;
 #endif

Modified: vmkit/trunk/lib/Mvm/JIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/JIT.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/JIT.cpp (original)
+++ vmkit/trunk/lib/Mvm/JIT.cpp Tue Apr  8 12:06:22 2008
@@ -7,60 +7,16 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <llvm/Type.h>
-#include <llvm/Support/CFG.h>
-#include <llvm/Module.h>
 #include <llvm/Constants.h>
-#include <llvm/Type.h>
 #include <llvm/DerivedTypes.h>
-#include <llvm/Function.h>
-#include <llvm/Instructions.h>
-#include <llvm/ModuleProvider.h>
-#include <llvm/ExecutionEngine/JIT.h>
-#include <llvm/ExecutionEngine/GenericValue.h>
-#include <llvm/PassManager.h>
-#include <llvm/Analysis/Verifier.h>
-#include <llvm/Transforms/Scalar.h>
-#include <llvm/Target/TargetData.h>
-#include <llvm/Assembly/PrintModulePass.h>
-#include <llvm/Target/TargetOptions.h>
-#include <llvm/CodeGen/MachineCodeEmitter.h>
-#include <llvm/CodeGen/MachineBasicBlock.h>
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Module.h"
-#include "llvm/ModuleProvider.h"
-#include "llvm/PassManager.h"
-#include "llvm/ValueSymbolTable.h"
-#include "llvm/Analysis/LoopPass.h"
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/Assembly/Writer.h"
-#include "llvm/Assembly/PrintModulePass.h"
-#include "llvm/Bitcode/ReaderWriter.h"
-#include "llvm/CodeGen/RegAllocRegistry.h"
-#include "llvm/CodeGen/SchedulerRegistry.h"
-#include "llvm/CodeGen/ScheduleDAG.h"
-#include "llvm/Target/SubtargetFeature.h"
-#include "llvm/Target/TargetData.h"
-#include "llvm/Target/TargetLowering.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetMachineRegistry.h"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Transforms/IPO.h"
-#include "llvm/ADT/StringExtras.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/Support/Streams.h"
-#include "llvm/Support/ManagedStatic.h"
-#include "llvm/Support/MemoryBuffer.h"
+#include <llvm/Type.h>
 #include "llvm/Support/MutexGuard.h"
-
-#include <llvm/Transforms/IPO.h>
+#include "llvm/Target/TargetOptions.h"
 
 #include <stdio.h>
 
 #include "mvm/JIT.h"
 #include "mvm/Method.h"
-#include "mvm/VMLet.h"
 
 #include "MvmMemoryManager.h"
 
@@ -89,61 +45,6 @@
   printf("%s\n", obj->printString());
 }
 
-static void addPass(FunctionPassManager *PM, Pass *P) {
-  // Add the pass to the pass manager...
-  PM->add(P);
-}
-
-void jit::AddStandardCompilePasses(FunctionPassManager *PM) {
-  llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
-  // LLVM does not allow calling functions from other modules in verifier
-  //PM->add(createVerifierPass());                  // Verify that input is correct
-  
-  addPass(PM, createCFGSimplificationPass());    // Clean up disgusting code
-  addPass(PM, createScalarReplAggregatesPass());// Kill useless allocas
-  addPass(PM, createInstructionCombiningPass()); // Clean up after IPCP & DAE
-  addPass(PM, createCFGSimplificationPass());    // Clean up after IPCP & DAE
-  addPass(PM, createPromoteMemoryToRegisterPass());// Kill useless allocas
-  addPass(PM, createInstructionCombiningPass()); // Clean up after IPCP & DAE
-  addPass(PM, createCFGSimplificationPass());    // Clean up after IPCP & DAE
-  
-  addPass(PM, createTailDuplicationPass());      // Simplify cfg by copying code
-  addPass(PM, createInstructionCombiningPass()); // Cleanup for scalarrepl.
-  addPass(PM, createCFGSimplificationPass());    // Merge & remove BBs
-  addPass(PM, createScalarReplAggregatesPass()); // Break up aggregate allocas
-  addPass(PM, createInstructionCombiningPass()); // Combine silly seq's
-  addPass(PM, createCondPropagationPass());      // Propagate conditionals
-  
-   
-  addPass(PM, createTailCallEliminationPass());  // Eliminate tail calls
-  addPass(PM, createCFGSimplificationPass());    // Merge & remove BBs
-  addPass(PM, createReassociatePass());          // Reassociate expressions
-  addPass(PM, createLoopRotatePass());
-  addPass(PM, createLICMPass());                 // Hoist loop invariants
-  addPass(PM, createLoopUnswitchPass());         // Unswitch loops.
-  addPass(PM, createInstructionCombiningPass()); // Clean up after LICM/reassoc
-  addPass(PM, createIndVarSimplifyPass());       // Canonicalize indvars
-  addPass(PM, createLoopUnrollPass());           // Unroll small loops
-  addPass(PM, createInstructionCombiningPass()); // Clean up after the unroller
-  addPass(PM, createGVNPass());                  // GVN for load instructions
-  addPass(PM, createGCSEPass());                 // Remove common subexprs
-  addPass(PM, createSCCPPass());                 // Constant prop with SCCP
-  
-  
-  // Run instcombine after redundancy elimination to exploit opportunities
-  // opened up by them.
-  addPass(PM, createInstructionCombiningPass());
-  addPass(PM, createCondPropagationPass());      // Propagate conditionals
-
-  addPass(PM, createDeadStoreEliminationPass()); // Delete dead stores
-  addPass(PM, createAggressiveDCEPass());        // SSA based 'Aggressive DCE'
-  addPass(PM, createCFGSimplificationPass());    // Merge & remove BBs
-  
-}
-
-
-
-
 static void initialiseTypes(llvm::Module* mod) {
   {
   // llvm::Type Definitions
@@ -317,7 +218,7 @@
 
 extern "C" void __register_frame(void*);
 
-void VMLet::initialise() {
+void mvm::jit::initialise() {
   llvm::SizedMemoryCode = true;
   llvm::NoFramePointerElim = true;
   llvm::ExceptionHandling = true;

Modified: vmkit/trunk/lib/Mvm/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Main.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Main.cpp (original)
+++ vmkit/trunk/lib/Mvm/Main.cpp Tue Apr  8 12:06:22 2008
@@ -8,10 +8,9 @@
 //===----------------------------------------------------------------------===//
 
 #include "mvm/GC/GC.h"
+#include "mvm/JIT.h"
 #include "mvm/PrintBuffer.h"
 #include "mvm/Threads/Thread.h"
-#include "mvm/Sigsegv.h"
-#include "mvm/VMLet.h"
 
 
 #include <dlfcn.h>
@@ -44,14 +43,15 @@
   int base;
   llvm::cl::ParseCommandLineOptions(argc, argv,
                                     " VMKit: a virtual machine launcher\n");
-  Object::initialise(&base);
-  VMLet::initialise();
+  jit::initialise();
+  Object::initialise();
+  Collector::initialise(Object::markAndTraceRoots, &base);
   
   CommandLine cl;
   cl.start();
    
   clearSignals();
-	Thread::exit(0);
+  Thread::exit(0);
     
   return 0;
 }

Modified: vmkit/trunk/lib/Mvm/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Makefile.am (original)
+++ vmkit/trunk/lib/Mvm/Makefile.am Tue Apr  8 12:06:22 2008
@@ -15,6 +15,6 @@
 PREFIX=@prefix@
 
 main_SOURCES = Main.cpp Object.cpp Sigsegv.cpp JIT.cpp CommandLine.cpp CommandLine.h MvmMemoryManager.h MvmMemoryManager.cpp EscapeAnalysis.cpp Disassembler.cpp
-main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -pedantic -Wno-long-long -fno-omit-frame-pointer -O2 -g
+main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -pedantic -Wno-long-long -fno-omit-frame-pointer -O2 -g -DSERVICE_VM
 main_LDFLAGS=@rdynamic@
 main_LDADD = $(LIBSUVM) @LLVMDYLIB@

Modified: vmkit/trunk/lib/Mvm/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Object.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Object.cpp (original)
+++ vmkit/trunk/lib/Mvm/Object.cpp Tue Apr  8 12:06:22 2008
@@ -13,6 +13,8 @@
 #include "mvm/Object.h"
 #include "mvm/PrintBuffer.h"
 #include "mvm/GC/GC.h"
+#include "mvm/Threads/Key.h"
+#include "mvm/Threads/Thread.h"
 
 using namespace mvm;
 
@@ -23,10 +25,12 @@
 VirtualTable *NativeString::VT = 0;
 VirtualTable *PrintBuffer::VT = 0;
 
+mvm::Key<mvm::Thread>* mvm::Thread::threadKey = 0;
+
 
 Object **Object::rootTable= 0;
-int	  Object::rootTableSize= 0;
-int	  Object::rootTableLimit= 0;
+int    Object::rootTableSize= 0;
+int    Object::rootTableLimit= 0;
 
 void Object::growRootTable(void) {
   if (rootTableLimit != 0) {
@@ -46,7 +50,7 @@
     rootTable[i]->markAndTrace();
 }
 
-void Object::initialise(void *b_sp) {
+void Object::initialise() {
 # define INIT(X) { \
   X fake; \
   X::VT = ((void**)(void*)(&fake))[0]; }
@@ -59,16 +63,15 @@
   INIT(ExceptionTable);
   
 #undef INIT
-
-  Collector::initialise(Object::markAndTraceRoots, b_sp);
+  Thread::threadKey = new mvm::Key<Thread>();
 }
 
 void Code::tracer(size_t sz) {
-	((Code *)this)->method(sz)->markAndTrace();
+  this->method(sz)->markAndTrace();
 }
 
 void Method::tracer(size_t sz) {
-	Method *const self= (Method *)this;
+  Method *const self= (Method *)this;
   self->definition()->markAndTrace();
   self->literals()->markAndTrace();
   self->name()->markAndTrace();
@@ -77,7 +80,7 @@
 }
 
 void PrintBuffer::tracer(size_t sz) {
-	((PrintBuffer *)this)->contents()->markAndTrace();
+  ((PrintBuffer *)this)->contents()->markAndTrace();
 }
 
 PrintBuffer *PrintBuffer::alloc(void) {
@@ -86,24 +89,24 @@
 
 
 PrintBuffer *PrintBuffer::writeObj(const Object *obj) {
-	Object *beg = (Object*)Collector::begOf(obj);
-	
-	if(beg) {
-		if(beg == obj)
-			obj->print((mvm::PrintBuffer*)this);
-		else {
-			write("<In Object [");
-			beg->print(this);
-			write("] -- offset ");
-			writeS4((intptr_t)obj - (intptr_t)beg);
-			write(">");
-		}
-	} else {
-		write("<DirectValue: ");
-		writeS4((intptr_t)obj);
-		write(">");
-	}
-	return this;
+  Object *beg = (Object*)Collector::begOf(obj);
+  
+  if(beg) {
+    if(beg == obj) {
+      obj->print((mvm::PrintBuffer*)this);
+    } else {
+      write("<In Object [");
+      beg->print(this);
+      write("] -- offset ");
+      writeS4((intptr_t)obj - (intptr_t)beg);
+      write(">");
+    }
+  } else {
+    write("<DirectValue: ");
+    writeS4((intptr_t)obj);
+    write(">");
+  }
+  return this;
 }
 
 extern "C" void write_ptr(PrintBuffer* buf, void* obj) {
@@ -120,30 +123,30 @@
 
 char *Object::printString(void) const {
   PrintBuffer *buf= PrintBuffer::alloc();
-	buf->writeObj(this);
+  buf->writeObj(this);
   return buf->contents()->cString();
 }
 
 void Object::print(PrintBuffer *buf) const {
-	buf->write("<Object@");
-	buf->writePtr((void*)this);
+  buf->write("<Object@");
+  buf->writePtr((void*)this);
   buf->write(">");
 }
 
 void Code::print(PrintBuffer *buf) const {
-	buf->write("Code<");
-	buf->write(">");
+  buf->write("Code<");
+  buf->write(">");
 }
 
 void Method::print(PrintBuffer *buf) const {
   Method *const self= (Method *)this;
-	buf->write("Method<");
+  buf->write("Method<");
   if (self->name()) {
-	  self->name()->print(buf);
+    self->name()->print(buf);
   } else {
     buf->write("lambda");
   }
-	buf->write(">");
+  buf->write(">");
 }
 
 void NativeString::print(PrintBuffer *buf) const {
@@ -152,23 +155,27 @@
   for (size_t i= 0; i < strlen(self->cString()); ++i) {
     int c= self->cString()[i];
     switch (c) {
-	    case '\b': buf->write("\\b"); break;
-	    case '\f': buf->write("\\f"); break;
-	    case '\n': buf->write("\\n"); break;
-	    case '\r': buf->write("\\r"); break;
-	    case '\t': buf->write("\\t"); break;
-	    case '"':  buf->write("\\\""); break;
-	    default: {
-	      char esc[32];
-	      if (c < 32)
-	        sprintf(esc, "\\x%02x", c);
-	      else
-	        sprintf(esc, "%c", c);
-	      buf->write(esc);
-	    }
-	  }
+      case '\b': buf->write("\\b"); break;
+      case '\f': buf->write("\\f"); break;
+      case '\n': buf->write("\\n"); break;
+      case '\r': buf->write("\\r"); break;
+      case '\t': buf->write("\\t"); break;
+      case '"':  buf->write("\\\""); break;
+      default: {
+        char esc[32];
+        if (c < 32)
+          sprintf(esc, "\\x%02x", c);
+        else
+          sprintf(esc, "%c", c);
+        buf->write(esc);
+      }
+    }
   }
   buf->write("\"");
 }
 
 NativeString *PrintBuffer::getContents() { return contents(); }
+
+Thread* Thread::get() {
+  return (Thread*)Thread::threadKey->get();
+}

Modified: vmkit/trunk/lib/Mvm/Sigsegv.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Sigsegv.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/Mvm/Sigsegv.cpp (original)
+++ vmkit/trunk/lib/Mvm/Sigsegv.cpp Tue Apr  8 12:06:22 2008
@@ -10,7 +10,6 @@
 
 #include "mvm/GC/GC.h"
 #include "mvm/Sigsegv.h"
-#include "mvm/VMLet.h"
 
 #include <signal.h>
 #include <stdio.h>
@@ -24,49 +23,41 @@
 #endif
 
 void sigsegv_handler(int n, siginfo_t *_info, void *context) {
-	void *addr = _info->si_addr;
+  void *addr = _info->si_addr;
 #if defined(__i386__)
-	struct frame {
-		struct frame *caller;
-		void         *ip;
-	};
-
-	struct frame *fp;	/* my frame */
-  asm ("mov %%ebp, %0" : "=&r"(fp)); /* get it */
-	struct frame *caller = fp->caller; /* my caller */
+  struct frame {
+    struct frame *caller;
+    void         *ip;
+  };
+  
+  /* my frame */
+  struct frame *fp;
+  /* get it */
+  asm ("mov %%ebp, %0" : "=&r"(fp));
+  /* my caller */
+  struct frame *caller = fp->caller; 
   /* preserve my caller if I return from the handler */
-	void *caller_ip = caller->ip; 
+  void *caller_ip = caller->ip; 
 
-# if defined(__MACH__)
+#if defined(__MACH__)
   //.gregs[REG_EIP]; /* just like it's on the stack.. */
-	caller->ip = (void *)((ucontext_t*)context)->uc_mcontext->__ss.__eip;
-# else
-  /* comme si c'├ętait lui qui ├ętait sur la pile... */
-	caller->ip = (void *)((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP]; 
-# endif
+  caller->ip = (void *)((ucontext_t*)context)->uc_mcontext->__ss.__eip;
+#else
+  /* just like it's on the stack... */
+  caller->ip = (void *)((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP]; 
+#endif
 #endif
 	
-	/* Free the GC if it sisgegv'd. No other collection is possible */
-	Collector::die_if_sigsegv_occured_during_collection(addr);
+  /* Free the GC if it sisgegv'd. No other collection is possible */
+  Collector::die_if_sigsegv_occured_during_collection(addr);
 	
-	//	sys_exit(0);
-	if(client_sigsegv_handler)
-		client_sigsegv_handler(n, addr);
-	else
-		signal(SIGSEGV, SIG_DFL);
+  //	sys_exit(0);
+  if(client_sigsegv_handler)
+    client_sigsegv_handler(n, addr);
+  else
+    signal(SIGSEGV, SIG_DFL);
 	
 #if defined(__i386__)
-	caller->ip = caller_ip; /* restore the caller ip */
+  caller->ip = caller_ip; /* restore the caller ip */
 #endif
 }
-
-void VMLet::register_sigsegv_handler(void (*fct)(int, void *)) {
-	struct sigaction sa;
-
-	sigaction(SIGSEGV, 0, &sa);
-	sa.sa_sigaction = sigsegv_handler;
-	sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER);
-	sigaction(SIGSEGV, &sa, 0);
-	client_sigsegv_handler = fct;
-}
-

Modified: vmkit/trunk/lib/N3/Main.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Main.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/Main.cpp (original)
+++ vmkit/trunk/lib/N3/Main.cpp Tue Apr  8 12:06:22 2008
@@ -7,76 +7,28 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "mvm/JIT.h"
 #include "mvm/GC/GC.h"
 #include "mvm/PrintBuffer.h"
-#include "mvm/VMLet.h"
-#include "mvm/Threads/Thread.h"
-
-
-#include <dlfcn.h>
-#include <setjmp.h>
-#include <signal.h>
-#include <stdio.h>
 
 #include "llvm/Support/ManagedStatic.h"
 
 using namespace mvm;
 
 
-typedef int (*boot_t)(int, char**, char**);
-
-static void clearSignals(void) {
-  signal(SIGINT,  SIG_DFL);
-  signal(SIGILL,  SIG_DFL);
-#if !defined(WIN32)
-  signal(SIGIOT,  SIG_DFL);
-  signal(SIGBUS,  SIG_DFL);
-#endif
-  signal(SIGSEGV, SIG_DFL);
-}
-
 extern "C" int boot();
 extern "C" int start_app(int, char**);
 
-#include "VMCore/CLIJit.h"
-
-void handler2(int n, void *context) {
-  printf("[%d] crashed\n", (int)mvm::Thread::self());
-  n3::CLIJit::printBacktrace();
-  assert(0);
-}
-
-void handler(int n, siginfo_t *_info, void *context) {
-  printf("[%d] crashed\n", (int)mvm::Thread::self());
-  n3::CLIJit::printBacktrace();
-  assert(0);
-}
 
 int main(int argc, char **argv, char **envp) {
   llvm::llvm_shutdown_obj X;  
   int base;
   
-  struct sigaction sa;
-
-  sigaction(SIGINT, 0, &sa);
-  sa.sa_sigaction = handler;
-  sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER);
-  sigaction(SIGINT, &sa, 0);
-  
-  sigaction(SIGILL, 0, &sa);
-  sa.sa_sigaction = handler;
-  sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER);
-  sigaction(SIGILL, &sa, 0);
-  
-  
-  VMLet::register_sigsegv_handler(handler2);
-
-  Object::initialise(&base);
-  VMLet::initialise();
+  jit::initialise();
+  Object::initialise();
+  Collector::initialise(Object::markAndTraceRoots, &base);
   boot();
   start_app(argc, argv);
 
-  clearSignals();
-    
   return 0;
 }

Modified: vmkit/trunk/lib/N3/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/Makefile.am (original)
+++ vmkit/trunk/lib/N3/Makefile.am Tue Apr  8 12:06:22 2008
@@ -14,6 +14,6 @@
 
 main_SOURCES = ../Mvm/Object.cpp ../Mvm/Sigsegv.cpp Main.cpp ../Mvm/MvmMemoryManager.cpp ../Mvm/JIT.cpp ../Mvm/EscapeAnalysis.cpp
 
-main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2
+main_CXXFLAGS = $(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -Werror -O2 -DSINGLE_VM
 main_LDADD = VMCore/.libs/libN3.a $(LIBSUVM) @LLVMDYLIB@
 main_LDFLAGS = @rdynamic@

Modified: vmkit/trunk/lib/N3/VMCore/Makefile.am
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Makefile.am?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/Makefile.am (original)
+++ vmkit/trunk/lib/N3/VMCore/Makefile.am Tue Apr  8 12:06:22 2008
@@ -16,4 +16,4 @@
 	Opcodes.cpp NativeUtil.h NativeUtil.cpp PNetLib.cpp N3ModuleProvider.cpp N3ModuleProvider.h \
 	PNetLib.h BackTrace.cpp LowerArrayLength.cpp
 
-libN3_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -O2
+libN3_la_CXXFLAGS =$(INCLUDEDIRS) -DPREFIX=\"$(PREFIX)\" -W -Wall -ansi -Wno-unused-parameter -Wno-long-long -Wno-unused-function -fno-omit-frame-pointer -g -O2 -DSINGLE_VM

Modified: vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp Tue Apr  8 12:06:22 2008
@@ -32,7 +32,6 @@
 
 N3* N3::bootstrapVM = 0;
 mvm::Lock* VMObject::globalLock = 0;
-mvm::Key<VMThread>* VMThread::threadKey = 0;
 
 VMCommonClass* VMClassArray::SuperArray = 0;
 std::vector<VMClass*> VMClassArray::InterfacesArray;
@@ -237,9 +236,6 @@
   VMObject::globalLock = mvm::Lock::allocNormal();
   //mvm::Object::pushRoot((mvm::Object*)VMObject::globalLock);
 
-  VMThread::threadKey = new mvm::Key<VMThread>();
-  //mvm::Object::pushRoot((mvm::Object*)VMThread::threadKey);
-  
   N3* vm = N3::bootstrapVM = N3::allocateBootstrap();
   mvm::Object::pushRoot((mvm::Object*)N3::bootstrapVM);
 

Modified: vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/N3ModuleProvider.cpp Tue Apr  8 12:06:22 2008
@@ -11,7 +11,6 @@
 #include <llvm/ModuleProvider.h>
 
 #include "mvm/JIT.h"
-#include "mvm/VMLet.h"
 
 #include "Assembly.h"
 #include "CLIJit.h"

Modified: vmkit/trunk/lib/N3/VMCore/VMThread.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMThread.cpp?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMThread.cpp (original)
+++ vmkit/trunk/lib/N3/VMCore/VMThread.cpp Tue Apr  8 12:06:22 2008
@@ -40,7 +40,7 @@
 }
 
 VMThread* VMThread::get() {
-  return threadKey->get();
+  return (VMThread*)threadKey->get();
 }
 
 extern void AddStandardCompilePasses(llvm::FunctionPassManager*);

Modified: vmkit/trunk/lib/N3/VMCore/VMThread.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMThread.h?rev=49388&r1=49387&r2=49388&view=diff

==============================================================================
--- vmkit/trunk/lib/N3/VMCore/VMThread.h (original)
+++ vmkit/trunk/lib/N3/VMCore/VMThread.h Tue Apr  8 12:06:22 2008
@@ -18,6 +18,7 @@
 #include "mvm/Threads/Cond.h"
 #include "mvm/Threads/Key.h"
 #include "mvm/Threads/Locks.h"
+#include "mvm/Threads/Thread.h"
 
 namespace n3 {
 
@@ -25,7 +26,7 @@
 class VMClass;
 class VMObject;
 
-class VMThread : public mvm::Object {
+class VMThread : public mvm::Thread {
 public:
   static VirtualTable *VT;
   VMObject* vmThread;
@@ -46,8 +47,6 @@
   virtual void tracer(size_t sz);
   virtual void destroyer(size_t sz);
   
-  static mvm::Key<VMThread>* threadKey;
-
   static VMThread* get();
   static VMThread* allocate(VMObject* thread, VirtualMachine* vm);
   static VMObject* currentThread();





More information about the llvm-commits mailing list