[llvm-commits] [vmkit] r51189 - in /vmkit/trunk/lib/JnJVM: LLVMRuntime/ VMCore/

Nicolas Geoffray nicolas.geoffray at lip6.fr
Fri May 16 07:49:13 PDT 2008


Author: geoffray
Date: Fri May 16 09:49:12 2008
New Revision: 51189

URL: http://llvm.org/viewvc/llvm-project?rev=51189&view=rev
Log:
Clean up the mess.... Make Jnjvm meta information for LLVM
apart from Jnjvm structures (e.g. JavaField, CommonClass). This will
enable multi-threading without deadlocks with LLVM JIT.


Added:
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
Modified:
    vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile.am
    vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.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.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp
    vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.h
    vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp
    vmkit/trunk/lib/JnJVM/VMCore/Makefile.am
    vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile.am (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/Makefile.am Fri May 16 09:49:12 2008
@@ -35,4 +35,4 @@
 	cat $(LL_FILES) > LLVMRuntime.ll
 
 clean:
-	rm LLVMRuntime.ll LLVMRuntime.bc LLVMRuntime.cpp
+	rm -f LLVMRuntime.ll LLVMRuntime.bc LLVMRuntime.cpp

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaArray.h Fri May 16 09:49:12 2008
@@ -12,9 +12,6 @@
 
 #include "mvm/PrintBuffer.h"
 
-#include "llvm/Constants.h"
-#include "llvm/Type.h"
-
 #include "types.h"
 
 #include "JavaObject.h"
@@ -51,10 +48,7 @@
   static ClassArray* ofFloat;
   static ClassArray* ofDouble;
   static ClassArray* ofObject;
-  static const llvm::Type* llvmType;
 
-  static llvm::ConstantInt* sizeOffset();
-  static llvm::ConstantInt* elementsOffset();
   virtual void print(mvm::PrintBuffer* buf) const;
   virtual void TRACER;
 
@@ -66,7 +60,6 @@
 class name : public JavaArray {                                       \
 public:                                                               \
   static VirtualTable* VT;                                            \
-  static const llvm::Type* llvmType;                                  \
   elmt elements[0];                                                   \
   static name *acons(sint32 n, ClassArray* cl, Jnjvm* vm);            \
   elmt at(sint32) const;                                              \
@@ -92,8 +85,6 @@
 public:
   static VirtualTable* VT;
 
-  static const llvm::Type* llvmType;
-  
   const UTF8* internalToJava(Jnjvm *vm, unsigned int start,
                              unsigned int len) const;
   

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.cpp Fri May 16 09:49:12 2008
@@ -10,9 +10,6 @@
 #include <iostream>
 #include <vector>
 
-#include "llvm/DerivedTypes.h"
-#include "llvm/Instructions.h"
-
 #include "mvm/JIT.h"
 #include "mvm/Object.h"
 #include "mvm/PrintBuffer.h"
@@ -29,7 +26,6 @@
 #include "types.h"
 
 using namespace jnjvm;
-using namespace llvm;
 
 void Enveloppe::destroyer(size_t sz) {
   delete cacheLock;
@@ -63,93 +59,3 @@
   return enveloppe;
 }
 
-void JavaJIT::invokeInterfaceOrVirtual(uint16 index) {
-  
-  // Do the usual
-  JavaCtpInfo* ctpInfo = compilingClass->ctpInfo;
-  Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index);
-  
-  std::vector<Value*> args; // size = [signature->nbIn + 3];
-
-  FunctionType::param_iterator it  = signature->virtualType->param_end();
-  makeArgs(it, index, args, signature->nbIn + 1);
-  
-  const llvm::Type* retType = signature->virtualType->getReturnType();
-  BasicBlock* endBlock = createBasicBlock("end virtual invoke");
-  PHINode * node = 0;
-  if (retType != Type::VoidTy) {
-    node = PHINode::Create(retType, "", endBlock);
-  }
-
-  // ok now the cache
-  Enveloppe* enveloppe = Enveloppe::allocate(compilingClass->ctpInfo, index);
-  compilingMethod->caches.push_back(enveloppe);
-  
-  Value* zero = mvm::jit::constantZero;
-  Value* one = mvm::jit::constantOne;
-  Value* two = mvm::jit::constantTwo;
-  
-  mvm::jit::protectConstants();//->lock();
-  Value* llvmEnv = 
-    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
-                              uint64_t (enveloppe)),
-                              Enveloppe::llvmType);
-  mvm::jit::unprotectConstants();//->unlock();
-  
-
-  JITVerifyNull(args[0]);
-
-  std::vector<Value*> args1;
-  args1.push_back(zero);
-  args1.push_back(one);
-  Value* cachePtr = GetElementPtrInst::Create(llvmEnv, args1.begin(), args1.end(),
-                                          "", currentBlock);
-  Value* cache = new LoadInst(cachePtr, "", currentBlock);
-
-  Value* cl = CallInst::Create(getClassLLVM, args[0], "", currentBlock);
-  std::vector<Value*> args3;
-  args3.push_back(zero);
-  args3.push_back(two);
-  Value* lastCiblePtr = GetElementPtrInst::Create(cache, args3.begin(), args3.end(),
-                                              "", currentBlock);
-  Value* lastCible = new LoadInst(lastCiblePtr, "", currentBlock);
-
-  Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, cl, lastCible, "", currentBlock);
-  
-  BasicBlock* ifTrue = createBasicBlock("cache ok");
-  BasicBlock* ifFalse = createBasicBlock("cache not ok");
-  BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
-  
-  currentBlock = ifFalse;
-  Value* _meth = invoke(virtualLookupLLVM, cache, args[0], "", ifFalse);
-  Value* meth = new BitCastInst(_meth, signature->virtualTypePtr, "", 
-                                currentBlock);
-  Value* ret = invoke(meth, args, "", currentBlock);
-  if (node) {
-    node->addIncoming(ret, currentBlock);
-  }
-  BranchInst::Create(endBlock, currentBlock);
-
-  currentBlock = ifTrue;
-
-  Value* methPtr = GetElementPtrInst::Create(cache, args1.begin(), args1.end(),
-                                         "", currentBlock);
-
-  _meth = new LoadInst(methPtr, "", currentBlock);
-  meth = new BitCastInst(_meth, signature->virtualTypePtr, "", currentBlock);
-  
-  ret = invoke(meth, args, "", currentBlock);
-  BranchInst::Create(endBlock, currentBlock);
-
-  if (node) {
-    node->addIncoming(ret, currentBlock);
-  }
-
-  currentBlock = endBlock;
-  if (node) {
-    push(node, signature->ret->funcs);
-    if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
-      push(mvm::jit::constantZero, AssessorDesc::dInt);
-    }
-  }
-}

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaCache.h Fri May 16 09:49:12 2008
@@ -14,8 +14,6 @@
 #include "mvm/PrintBuffer.h"
 #include "mvm/Threads/Locks.h"
 
-#include "llvm/Type.h"
-
 #include "types.h"
 
 namespace jnjvm {
@@ -34,7 +32,6 @@
   Class* lastCible;
   CacheNode* next;
   Enveloppe* enveloppe;
-  static const llvm::Type* llvmType;
 
   void initialise();
 
@@ -51,7 +48,6 @@
   JavaCtpInfo* ctpInfo;
   mvm::Lock* cacheLock;
   uint32 index;
-  static const llvm::Type* llvmType;
 
   static Enveloppe* allocate(JavaCtpInfo* info, uint32 index);
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Fri May 16 09:49:12 2008
@@ -26,6 +26,7 @@
 #include "JavaThread.h"
 #include "JavaTypes.h"
 #include "Jnjvm.h"
+#include "JnjvmModule.h"
 #include "JnjvmModuleProvider.h"
 #include "Reader.h"
 
@@ -127,9 +128,7 @@
   this->status = hashed;
   this->isolate = isolate;
   this->isArray = isArray;
-  this->_llvmVar = 0;
 #ifndef MULTIPLE_VM
-  this->_llvmDelegatee = 0;
   this->delegatee = 0;
 #endif
 }
@@ -207,18 +206,8 @@
   else {
     classDef->aquire();
     if (code == 0) {
-      if (llvmFunction->hasNotBeenReadFromBitcode()) {
-        JavaJIT jit;
-        jit.compilingClass = classDef;
-        jit.compilingMethod = this;
-        if (isNative(access)) {
-          llvmFunction = jit.nativeCompile();
-        } else {
-          llvmFunction = jit.javaCompile();
-        }
-      }
-      // We can compile it, since if we're here, it's for a  good reason
-      void* val = mvm::jit::executionEngine->getPointerToGlobal(llvmFunction);
+      void* val = 
+        classDef->isolate->TheModuleProvider->materializeFunction(this);
 #ifndef MULTIPLE_GC
       mvm::Code* temp = (mvm::Code*)(Collector::begOf(val));
 #else
@@ -455,26 +444,26 @@
                                         Attribut::constantAttribut);
 
   if (!attribut) {
-    JavaJIT::initField(this, obj);
+    JnjvmModule::InitField(this, obj);
   } else {
     Reader* reader = attribut->toReader(classDef->isolate,
                                         classDef->bytes, attribut);
     JavaCtpInfo * ctpInfo = classDef->ctpInfo;
     uint16 idx = reader->readU2();
     if (funcs == AssessorDesc::dLong) {
-      JavaJIT::initField(this, obj, (uint64)ctpInfo->LongAt(idx));
+      JnjvmModule::InitField(this, obj, (uint64)ctpInfo->LongAt(idx));
     } else if (funcs == AssessorDesc::dDouble) {
-      JavaJIT::initField(this, obj, ctpInfo->DoubleAt(idx));
+      JnjvmModule::InitField(this, obj, ctpInfo->DoubleAt(idx));
     } else if (funcs == AssessorDesc::dFloat) {
-      JavaJIT::initField(this, obj, ctpInfo->FloatAt(idx));
+      JnjvmModule::InitField(this, obj, ctpInfo->FloatAt(idx));
     } else if (funcs == AssessorDesc::dRef) {
       const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[idx]);
-      JavaJIT::initField(this, obj,
+      JnjvmModule::InitField(this, obj,
                          (JavaObject*)ctpInfo->resolveString(utf8, idx));
     } else if (funcs == AssessorDesc::dInt || funcs == AssessorDesc::dChar ||
                funcs == AssessorDesc::dShort || funcs == AssessorDesc::dByte ||
                funcs == AssessorDesc::dBool) {
-      JavaJIT::initField(this, obj, (uint64)ctpInfo->IntegerAt(idx));
+      JnjvmModule::InitField(this, obj, (uint64)ctpInfo->IntegerAt(idx));
     } else {
       JavaThread::get()->isolate->
         unknownError("unknown constant %c", funcs->byteId);
@@ -483,88 +472,6 @@
   
 }
 
-static void resolveStaticFields(Class* cl) {
-  
-  std::vector<const llvm::Type*> fields;
-  fields.push_back(JavaObject::llvmType->getContainedType(0));
-  uint64 offset = 0;
-  mvm::jit::protectConstants();//->lock();
-  for (std::vector<JavaField*>::iterator i = cl->staticFields.begin(),
-            e = cl->staticFields.end(); i!= e; ++i) {
-    // preincrement because 0 is JavaObject
-    (*i)->offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, ++offset); 
-    fields.push_back((*i)->signature->funcs->llvmType);
-  }
-  mvm::jit::unprotectConstants();//->unlock();
-  
-  mvm::jit::protectTypes();//->lock();
-  cl->staticType = 
-    llvm::PointerType::getUnqual(llvm::StructType::get(fields, false));
-  mvm::jit::unprotectTypes();//->unlock();
-
-  VirtualTable* VT = JavaJIT::makeVT(cl, true);
-
-  uint64 size = mvm::jit::getTypeSize(cl->staticType->getContainedType(0));
-  cl->staticSize = size;
-  cl->staticVT = VT;
-
-#ifndef MULTIPLE_VM
-  JavaObject* val = (JavaObject*)cl->isolate->allocateObject(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);
-  }
-  
-  cl->_staticInstance = val;
-#endif
-}
-
-static void resolveVirtualFields(Class* cl) {
-  
-  std::vector<const llvm::Type*> fields;
-  if (cl->super) {
-    fields.push_back(cl->super->virtualType->getContainedType(0));
-  } else {
-    fields.push_back(JavaObject::llvmType->getContainedType(0));
-  }
-  uint64 offset = 0;
-  mvm::jit::protectConstants();//->lock();
-  for (std::vector<JavaField*>::iterator i = cl->virtualFields.begin(),
-            e = cl->virtualFields.end(); i!= e; ++i) {
-    // preincrement because 0 is JavaObject
-    (*i)->offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, ++offset); 
-    fields.push_back((*i)->signature->funcs->llvmType);
-  }
-  mvm::jit::unprotectConstants();//->unlock();
-  
-  mvm::jit::protectTypes();//->lock();
-  cl->virtualType = 
-    llvm::PointerType::getUnqual(llvm::StructType::get(fields, false));
-  mvm::jit::unprotectTypes();//->unlock();
-
-  VirtualTable* VT = JavaJIT::makeVT(cl, false);
-  
-  uint64 size = mvm::jit::getTypeSize(cl->virtualType->getContainedType(0));
-  cl->virtualSize = (uint32)size;
-  mvm::jit::protectConstants();
-  cl->virtualSizeLLVM = llvm::ConstantInt::get(llvm::Type::Int32Ty, size);
-  mvm::jit::unprotectConstants();
-  cl->virtualVT = VT;
-
-  for (std::vector<JavaField*>::iterator i = cl->virtualFields.begin(),
-            e = cl->virtualFields.end(); i!= e; ++i) {
-    JavaJIT::initField(*i);
-  }
-}
-
-void Class::resolveFields() {
-  resolveStaticFields(this);
-  resolveVirtualFields(this);
-}
-
 JavaObject* CommonClass::getClassDelegatee() {
   return JavaThread::get()->isolate->getClassDelegatee(this);
 }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Fri May 16 09:49:12 2008
@@ -12,13 +12,10 @@
 
 #include <vector>
 
-#include "llvm/Constants.h"
-#include "llvm/Function.h"
-#include "llvm/GlobalVariable.h"
-#include "llvm/ExecutionEngine/GenericValue.h"
-
 #include "types.h"
 
+#include "llvm/ExecutionEngine/GenericValue.h"
+
 #include "mvm/Method.h"
 #include "mvm/Object.h"
 #include "mvm/PrintBuffer.h"
@@ -88,10 +85,6 @@
   ///
   uint32 virtualTableSize;
   
-  /// virtualSizeLLVM - The LLVM constant size of instances of this class.
-  ///
-  llvm::ConstantInt* virtualSizeLLVM;
-  
   /// access - {public, private, protected}.
   ///
   uint32 access;
@@ -117,6 +110,7 @@
   CommonClass * super;
 
   /// superUTF8 - The name of the parent of this class.
+  ///
   const UTF8* superUTF8;
   
   /// interfaces - The interfaces this class implements.
@@ -140,15 +134,7 @@
   ///
   JavaObject* classLoader;
   
-  /// _llvmVar - The LLVM global variable representing this class.
-  ///
-  llvm::GlobalVariable* _llvmVar;
-
 #ifndef MULTIPLE_VM
-  /// _llvmDelegatee - The LLVM global variable representing the 
-  /// java/lang/Class instance of this class.
-  llvm::GlobalVariable* _llvmDelegatee;
-
   /// delegatee - The java/lang/Class object representing this class
   ///
   JavaObject* delegatee;
@@ -178,18 +164,6 @@
   /// display[depth - 1] contains the class.
   uint32 depth;
   
-  /// virtualType - The LLVM type of instance of this class.
-  ///
-  const llvm::Type * virtualType;
-
-  /// staticType - The LLVM type of the static instance of this class.
-  ///
-  const llvm::Type * staticType;
-
-
-  llvm::GlobalVariable* llvmVar(llvm::Module* compilingModule);
-  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(); 
@@ -247,17 +221,11 @@
 };
 
 class Class : public CommonClass {
-private:
-  llvm::GlobalVariable* _staticVar;
-  llvm::GlobalVariable* _llvmVT;
-
 public:
   static VirtualTable* VT;
   unsigned int minor;
   unsigned int major;
   ArrayUInt8* bytes;
-  llvm::Function* virtualTracer;
-  llvm::Function* staticTracer;
   mvm::Code* codeVirtualTracer;
   mvm::Code* codeStaticTracer;
   JavaCtpInfo* ctpInfo;
@@ -267,10 +235,6 @@
   uint32 innerAccess;
   bool innerOuterResolved;
   
-  void resolveFields();
-  llvm::Value* staticVar(JavaJIT* jit);
-  llvm::Value* llvmVT(JavaJIT* jit);
-  
   uint32 staticSize;
   VirtualTable* staticVT;
   JavaObject* doNew(Jnjvm* vm);
@@ -321,8 +285,6 @@
 class JavaMethod : public mvm::Object {
 public:
   static VirtualTable* VT;
-  llvm::Function* llvmFunction;
-  llvm::ConstantInt* offset;
   unsigned int access;
   Signdef* signature;
   std::vector<Attribut*, gc_allocator<Attribut*> > attributs;
@@ -332,12 +294,15 @@
   const UTF8* type;
   bool canBeInlined;
   mvm::Code* code;
+  
+  /// offset - The index of the method in the virtual table.
+  ///
+  uint32 offset;
 
   virtual void print(mvm::PrintBuffer *buf) const;
   virtual void TRACER;
 
   void* compiledPtr();
-  const llvm::FunctionType* llvmType;
 
   uint32 invokeIntSpecialAP(Jnjvm* vm, JavaObject* obj, va_list ap);
   float invokeFloatSpecialAP(Jnjvm* vm, JavaObject* obj, va_list ap);
@@ -397,7 +362,6 @@
 class JavaField : public mvm::Object {
 public:
   static VirtualTable* VT;
-  llvm::ConstantInt* offset;
   unsigned int access;
   const UTF8* name;
   Typedef* signature;
@@ -405,6 +369,9 @@
   std::vector<Attribut*, gc_allocator<Attribut*> > attributs;
   Class* classDef;
   uint64 ptrOffset;
+  /// num - The index of the field in the field list.
+  ///
+  uint32 num;
 
   void initField(JavaObject* obj);
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Fri May 16 09:49:12 2008
@@ -22,6 +22,7 @@
 #include "JavaConstantPool.h"
 #include "JavaJIT.h"
 #include "Jnjvm.h"
+#include "JnjvmModule.h"
 #include "JnjvmModuleProvider.h"
 #include "JavaThread.h"
 #include "JavaTypes.h"
@@ -416,10 +417,11 @@
     // lookup the method
     meth = cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access), false);
     if (meth) { // don't throw if no meth, the exception will be thrown just in time  
-      if (meth->llvmFunction) {
-        ctpRes[index] = (void*)meth->llvmFunction;
-        return (llvm::Function*)ctpRes[index];
-      }
+      JnjvmModule* M = classDef->isolate->module;
+      LLVMMethodInfo* LMI = M->getMethodInfo(meth);
+      llvm::Function* F = LMI->getMethod();
+      ctpRes[index] = (void*)F;
+      return F;
     }
   }
   
@@ -429,10 +431,12 @@
   } else {
     // Create the callback
     const llvm::FunctionType* type = 0;
+    JnjvmModule* M = classDef->isolate->module;
+    LLVMSignatureInfo* LSI = M->getSignatureInfo(sign);
     if (isStatic(access)) {
-      type = sign->staticType;
+      type = LSI->getStaticType();
     } else {
-      type = sign->virtualType;
+      type = LSI->getVirtualType();
     }
     llvm::Function* func = llvm::Function::Create(type, 
                                                 llvm::GlobalValue::GhostLinkage,

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h Fri May 16 09:49:12 2008
@@ -14,7 +14,7 @@
 
 #include "types.h"
 
-#include "llvm/Type.h"
+#include "llvm/Function.h"
 
 namespace jnjvm {
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaInitialise.cpp Fri May 16 09:49:12 2008
@@ -216,7 +216,6 @@
 
 void handler(int val, siginfo_t* info, void* addr) {
   printf("Crash in JnJVM at %p\n", addr);
-  JavaJIT::printBacktrace();
   assert(0);
 }
 
@@ -239,7 +238,6 @@
   sa.sa_flags |= (SA_RESTART | SA_SIGINFO | SA_NODEFER);
   sigaction(SIGSEGV, &sa, 0);
 
-  JavaJIT::initialise();
   initialiseVT();
   initialiseStatics();
   

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaIsolate.cpp Fri May 16 09:49:12 2008
@@ -25,6 +25,7 @@
 #include "JavaString.h"
 #include "JavaTypes.h"
 #include "JavaUpcalls.h"
+#include "JnjvmModule.h"
 #include "JnjvmModuleProvider.h"
 #include "LockedMap.h"
 #include "Zip.h"
@@ -448,7 +449,7 @@
 
   isolate->functions = vm_new(isolate, FunctionMap)();
   isolate->functionDefs = vm_new(isolate, FunctionDefMap)();
-  isolate->module = new llvm::Module("Isolate JnJVM");
+  isolate->module = new JnjvmModule("Isolate JnJVM");
   std::string str = 
     mvm::jit::executionEngine->getTargetData()->getStringRepresentation();
   isolate->module->setDataLayout(str);
@@ -456,7 +457,9 @@
   isolate->TheModuleProvider = new JnjvmModuleProvider(isolate->module, 
                                                        isolate->functions,
                                                        isolate->functionDefs);
-  JavaJIT::initialiseJITIsolateVM(isolate);
+  mvm::jit::protectEngine->lock();
+  mvm::jit::executionEngine->addModuleProvider(isolate->TheModuleProvider);
+  mvm::jit::protectEngine->unlock();
   
   isolate->bootstrapThread = vm_new(isolate, JavaThread)();
   isolate->bootstrapThread->initialise(0, isolate);
@@ -519,14 +522,17 @@
   isolate->functions = vm_new(isolate, FunctionMap)();
   isolate->functionDefs = vm_new(isolate, FunctionDefMap)();
   isolate->protectModule = mvm::Lock::allocNormal();
-  isolate->module = new llvm::Module("Bootstrap JnJVM");
+  isolate->module = new JnjvmModule("Bootstrap JnJVM");
   std::string str = 
     mvm::jit::executionEngine->getTargetData()->getStringRepresentation();
   isolate->module->setDataLayout(str);
   isolate->TheModuleProvider = new JnjvmModuleProvider(isolate->module, 
                                                        isolate->functions,
                                                        isolate->functionDefs); 
-  JavaJIT::initialiseJITBootstrapVM(isolate);
+  mvm::jit::protectEngine->lock();
+  mvm::jit::executionEngine->addModuleProvider(isolate->TheModuleProvider);
+  mvm::jit::protectEngine->unlock();
+  isolate->module->initialise();
   
   isolate->bootstrapThread = vm_new(isolate, JavaThread)();
   isolate->bootstrapThread->initialise(0, isolate);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Fri May 16 09:49:12 2008
@@ -38,6 +38,7 @@
 #include "JavaTypes.h"
 #include "JavaUpcalls.h"
 #include "Jnjvm.h"
+#include "JnjvmModule.h"
 #include "JnjvmModuleProvider.h"
 #include "NativeUtil.h"
 #include "Reader.h"
@@ -115,22 +116,23 @@
   Constant* zero = mvm::jit::constantZero;
   Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index);
   std::vector<Value*> args; // size = [signature->nbIn + 3];
-
-  FunctionType::param_iterator it  = signature->virtualType->param_end();
+  LLVMSignatureInfo* LSI = module->getSignatureInfo(signature);
+  const llvm::FunctionType* virtualType = LSI->getVirtualType();
+  FunctionType::param_iterator it  = virtualType->param_end();
   makeArgs(it, index, args, signature->nbIn + 1);
   
   JITVerifyNull(args[0]); 
 
-  Value* VT = CallInst::Create(getVTLLVM, args[0], "", currentBlock);
+  Value* VT = CallInst::Create(JnjvmModule::GetVTFunction, args[0], "",
+                               currentBlock);
   std::vector<Value*> indexes2; //[3];
   if (meth) {
-    indexes2.push_back(meth->offset);
+    LLVMMethodInfo* LMI = module->getMethodInfo(meth);
+    indexes2.push_back(LMI->getOffset());
   } else {
-    compilingClass->isolate->protectModule->lock();
     GlobalVariable* gv = 
       new GlobalVariable(Type::Int32Ty, false, GlobalValue::ExternalLinkage,
                          zero, "", compilingClass->isolate->module);
-    compilingClass->isolate->protectModule->unlock();
     
     // set is volatile
     Value* val = new LoadInst(gv, "", true, currentBlock);
@@ -148,14 +150,13 @@
     currentBlock = ifFalse;
     std::vector<Value*> Args;
     Args.push_back(args[0]);
-    Module* M = compilingClass->isolate->module;
-    Args.push_back(new LoadInst(compilingClass->llvmVar(M), "", currentBlock));
-    mvm::jit::protectConstants();//->lock();
+    LLVMClassInfo* LCI = 
+      (LLVMClassInfo*)module->getClassInfo(compilingClass);
+    Args.push_back(LCI->getVar(this));
     Constant* CI = ConstantInt::get(Type::Int32Ty, index);
     Args.push_back(CI);
-    mvm::jit::unprotectConstants();//->unlock();
     Args.push_back(gv);
-    val = invoke(vtableLookupLLVM, Args, "", currentBlock);
+    val = invoke(JnjvmModule::VirtualLookupFunction, Args, "", currentBlock);
     node->addIncoming(val, currentBlock);
     llvm::BranchInst::Create(endBlock, currentBlock);
     
@@ -168,11 +169,11 @@
                                              currentBlock);
     
   Value* Func = new LoadInst(FuncPtr, "", currentBlock);
-  Func = new BitCastInst(Func, signature->virtualTypePtr, "", currentBlock);
+  Func = new BitCastInst(Func, LSI->getVirtualPtrType(), "", currentBlock);
 
   Value* val = invoke(Func, args, "", currentBlock);
   
-  const llvm::Type* retType = signature->virtualType->getReturnType();
+  const llvm::Type* retType = virtualType->getReturnType();
   if (retType != Type::VoidTy) {
     push(val, signature->ret->funcs);
     if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
@@ -198,7 +199,7 @@
   
   bool stat = isStatic(compilingMethod->access);
 
-  const FunctionType *funcType = compilingMethod->llvmType;
+  const FunctionType *funcType = llvmFunction->getFunctionType();
   
   bool jnjvm = false;
   natPtr = natPtr ? natPtr :
@@ -206,7 +207,7 @@
   
   
   
-  Function* func = llvmFunction = compilingMethod->llvmFunction;
+  Function* func = llvmFunction;
   if (jnjvm) {
     mvm::jit::executionEngine->addGlobalMapping(func, natPtr);
     return llvmFunction;
@@ -241,7 +242,7 @@
     std::vector<Value*> Args;
     Args.push_back(lastArg);
     Args.push_back(isolateLocal);
-    CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(),
+    CallInst::Create(JnjvmModule::ServiceCallStartFunction, Args.begin(),
                      Args.end(), "", currentBlock);
     BranchInst::Create(endBlock, currentBlock);
     currentBlock = endBlock;
@@ -252,7 +253,8 @@
   if (funcType->getReturnType() != Type::VoidTy)
     endNode = llvm::PHINode::Create(funcType->getReturnType(), "", endBlock);
   
-  Value* buf = llvm::CallInst::Create(getSJLJBufferLLVM, "", currentBlock);
+  Value* buf = llvm::CallInst::Create(JnjvmModule::GetSJLJBufferFunction,
+                                      "", currentBlock);
   Value* test = llvm::CallInst::Create(mvm::jit::setjmpLLVM, buf, "",
                                        currentBlock);
   test = new ICmpInst(ICmpInst::ICMP_EQ, test, mvm::jit::constantZero, "",
@@ -272,17 +274,16 @@
   uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); 
   std::vector<Value*> nativeArgs;
   
-  mvm::jit::protectConstants();
   int64_t jniEnv = (int64_t)&(compilingClass->isolate->jniEnv);
   nativeArgs.push_back(
     ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, jniEnv), 
                               mvm::jit::ptrType));
-  mvm::jit::unprotectConstants();
 
   uint32 index = 0;
   if (stat) {
-    Module* M = compilingClass->isolate->module;
-    nativeArgs.push_back(compilingClass->llvmDelegatee(M, currentBlock));
+    LLVMClassInfo* LCI = 
+      (LLVMClassInfo*)module->getClassInfo(compilingClass);
+    nativeArgs.push_back(LCI->getDelegatee(this));
     index = 2;
   } else {
     index = 1;
@@ -294,12 +295,12 @@
   }
   
   
-  const llvm::Type* valPtrType = compilingMethod->signature->nativeTypePtr;
-  mvm::jit::protectConstants();//->lock();
+  LLVMSignatureInfo* LSI = 
+    module->getSignatureInfo(compilingMethod->signature);
+  const llvm::Type* valPtrType = LSI->getNativePtrType();
   Value* valPtr = 
     ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, (uint64)natPtr),
                               valPtrType);
-  mvm::jit::unprotectConstants();//->unlock();
 
   Value* result = llvm::CallInst::Create(valPtr, nativeArgs.begin(),
                                          nativeArgs.end(), "", currentBlock);
@@ -312,7 +313,8 @@
   if (isSynchro(compilingMethod->access))
     endSynchronize();
   
-  llvm::CallInst::Create(jniProceedPendingExceptionLLVM, "", currentBlock);
+  llvm::CallInst::Create(JnjvmModule::JniProceedPendingExceptionFunction, "",
+                         currentBlock);
   
   if (funcType->getReturnType() != Type::VoidTy)
     llvm::ReturnInst::Create(result, currentBlock);
@@ -332,17 +334,19 @@
   if (isVirtual(compilingMethod->access)) {
     argsSync.push_back(llvmFunction->arg_begin());
   } else {
-    Value* arg = compilingClass->staticVar(this);
+    LLVMClassInfo* LCI = 
+      (LLVMClassInfo*)module->getClassInfo(compilingClass);
+    Value* arg = LCI->getStaticVar(this);
     argsSync.push_back(arg);
   }
 #ifdef SERVICE_VM
   if (ServiceDomain::isLockableDomain(compilingClass->isolate))
-    llvm::CallInst::Create(aquireObjectInSharedDomainLLVM, argsSync.begin(),
-                           argsSync.end(), "", currentBlock);
+    llvm::CallInst::Create(JnjvmModule::AquireObjectInSharedDomainFunction,
+                           argsSync.begin(), argsSync.end(), "", currentBlock);
   else
 #endif
-  llvm::CallInst::Create(aquireObjectLLVM, argsSync.begin(), argsSync.end(),
-                         "", currentBlock);
+  llvm::CallInst::Create(JnjvmModule::AquireObjectFunction, argsSync.begin(),
+                         argsSync.end(), "", currentBlock);
 }
 
 void JavaJIT::endSynchronize() {
@@ -350,17 +354,19 @@
   if (isVirtual(compilingMethod->access)) {
     argsSync.push_back(llvmFunction->arg_begin());
   } else {
-    Value* arg = compilingClass->staticVar(this);
+    LLVMClassInfo* LCI = 
+      (LLVMClassInfo*)module->getClassInfo(compilingClass);
+    Value* arg = LCI->getStaticVar(this);
     argsSync.push_back(arg);
   }
 #ifdef SERVICE_VM
   if (ServiceDomain::isLockableDomain(compilingClass->isolate))
-    llvm::CallInst::Create(releaseObjectInSharedDomainLLVM, argsSync.begin(),
-                           argsSync.end(), "", currentBlock);
+    llvm::CallInst::Create(JnjvmModule::ReleaseObjectInSharedDomainFunction,
+                           argsSync.begin(), argsSync.end(), "", currentBlock);
   else
 #endif
-  llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(), "",
-               currentBlock);    
+  llvm::CallInst::Create(JnjvmModule::ReleaseObjectFunction, argsSync.begin(),
+                         argsSync.end(), "", currentBlock);    
 }
 
 
@@ -390,7 +396,7 @@
   
   reader->seek(codeLen, Reader::SeekCur);
   
-  const FunctionType *funcType = compilingMethod->llvmType;
+  const FunctionType *funcType = llvmFunction->getFunctionType();
   returnType = funcType->getReturnType();
   endBlock = createBasicBlock("end");
 
@@ -409,7 +415,7 @@
     doubleLocals.push_back(new AllocaInst(Type::DoubleTy, "", currentBlock));
     longLocals.push_back(new AllocaInst(Type::Int64Ty, "", currentBlock));
     floatLocals.push_back(new AllocaInst(Type::FloatTy, "", currentBlock));
-    objectLocals.push_back(new AllocaInst(JavaObject::llvmType, "",
+    objectLocals.push_back(new AllocaInst(JnjvmModule::JavaObjectType, "",
                                           currentBlock));
   }
   
@@ -475,7 +481,7 @@
     std::vector<Value*> Args;
     Args.push_back(args[args.size()-  1]);
     Args.push_back(isolateLocal);
-    CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(),
+    CallInst::Create(JnjvmModule::ServiceCallStartFunction, Args.begin(),
                      Args.end(), "", currentBlock);
     BranchInst::Create(endBlock, currentBlock);
     currentBlock = endBlock;
@@ -506,7 +512,7 @@
     std::vector<Value*> Args;
     Args.push_back(args[args.size() - 1]);
     Args.push_back(isolateLocal);
-    CallInst::Create(ServiceDomain::serviceCallStopLLVM, Args.begin(),
+    CallInst::Create(JnjvmModule::ServiceCallStopFunction, Args.begin(),
                      Args.end(), "", currentBlock);
     BranchInst::Create(newEndBlock, currentBlock);
     currentBlock = newEndBlock;
@@ -543,10 +549,10 @@
   
   reader->seek(codeLen, Reader::SeekCur);
 
-  const FunctionType *funcType = compilingMethod->llvmType;
+  const FunctionType *funcType = llvmFunction->getFunctionType();
   returnType = funcType->getReturnType();
   
-  Function* func = llvmFunction = compilingMethod->llvmFunction;
+  Function* func = llvmFunction;
 
   currentBlock = createBasicBlock("start");
   endExceptionBlock = createBasicBlock("endExceptionBlock");
@@ -561,9 +567,7 @@
 #if JNJVM_EXECUTE > 0
     {
     std::vector<llvm::Value*> args;
-    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);
     }
@@ -576,7 +580,7 @@
     doubleLocals.push_back(new AllocaInst(Type::DoubleTy, "", currentBlock));
     longLocals.push_back(new AllocaInst(Type::Int64Ty, "", currentBlock));
     floatLocals.push_back(new AllocaInst(Type::FloatTy, "", currentBlock));
-    objectLocals.push_back(new AllocaInst(JavaObject::llvmType, "",
+    objectLocals.push_back(new AllocaInst(JnjvmModule::JavaObjectType, "",
                                           currentBlock));
   }
   
@@ -641,7 +645,7 @@
     std::vector<Value*> Args;
     Args.push_back(i);
     Args.push_back(isolateLocal);
-    CallInst::Create(ServiceDomain::serviceCallStartLLVM, Args.begin(),
+    CallInst::Create(JnjvmModule::ServiceCallStartFunction, Args.begin(),
                      Args.end(), "", currentBlock);
     BranchInst::Create(endBlock, currentBlock);
     currentBlock = endBlock;
@@ -673,11 +677,9 @@
 #if JNJVM_EXECUTE > 0
     {
     std::vector<llvm::Value*> args;
-    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(JnjvmModule::PrintMethodEndFunction, args.begin(),
+                           args.end(), "", currentBlock);
     }
 #endif
   
@@ -692,7 +694,7 @@
     std::vector<Value*> Args;
     Args.push_back(i);
     Args.push_back(isolateLocal);
-    CallInst::Create(ServiceDomain::serviceCallStopLLVM, Args.begin(),
+    CallInst::Create(JnjvmModule::ServiceCallStopFunction, Args.begin(),
                      Args.end(), "", currentBlock);
     BranchInst::Create(newEndBlock, currentBlock);
     currentBlock = newEndBlock;
@@ -709,8 +711,8 @@
   if (PI == PE) {
     endExceptionBlock->eraseFromParent();
   } else {
-    CallInst* ptr_eh_ptr = llvm::CallInst::Create(getExceptionLLVM, "eh_ptr", 
-                                        endExceptionBlock);
+    CallInst* ptr_eh_ptr = CallInst::Create(JnjvmModule::GetExceptionFunction,
+                                            "eh_ptr", endExceptionBlock);
     llvm::CallInst::Create(mvm::jit::unwindResume, ptr_eh_ptr, "",
                            endExceptionBlock);
     new UnreachableInst(endExceptionBlock);
@@ -762,7 +764,7 @@
   nbe += sync;
   JavaCtpInfo* ctpInfo = compilingClass->ctpInfo;
   if (nbe) {
-    supplLocal = new AllocaInst(JavaObject::llvmType, "exceptionVar",
+    supplLocal = new AllocaInst(JnjvmModule::JavaObjectType, "exceptionVar",
                                 currentBlock);
   }
   
@@ -778,10 +780,11 @@
     if (isVirtual(compilingMethod->access)) {
       argsSync.push_back(llvmFunction->arg_begin());
     } else {
-      Value* arg = compilingClass->staticVar(this);
+      LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(compilingClass);
+      Value* arg = LCI->getStaticVar(this);
       argsSync.push_back(arg);
     }
-    llvm::CallInst::Create(releaseObjectLLVM, argsSync.begin(), argsSync.end(),
+    llvm::CallInst::Create(JnjvmModule::ReleaseObjectFunction, argsSync.begin(), argsSync.end(),
                            "", synchronizeExceptionBlock);
 
     llvm::BranchInst::Create(endExceptionBlock, synchronizeExceptionBlock);
@@ -927,12 +930,12 @@
       cur->exceptionPHI->addIncoming(ptr_eh_ptr, cur->test);
     } 
     
-    Module* M = compilingClass->isolate->module;
     Value* cl = 0;
     currentBlock = cur->realTest;
     assert(cur->catchClass);
-    cl = new LoadInst(cur->catchClass->llvmVar(M), "", currentBlock);
-    Value* cmp = llvm::CallInst::Create(compareExceptionLLVM, cl, "",
+    LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(cur->catchClass);
+    cl = LCI->getVar(this);
+    Value* cmp = llvm::CallInst::Create(JnjvmModule::CompareExceptionFunction, cl, "",
                                         currentBlock);
     llvm::BranchInst::Create(cur->handler, bbNext, cmp, currentBlock);
     if (nodeNext)
@@ -942,9 +945,10 @@
       cur->handlerPHI = llvm::PHINode::Create(mvm::jit::ptrType, "",
                                               cur->handler);
       cur->handlerPHI->addIncoming(cur->exceptionPHI, currentBlock);
-      Value* exc = llvm::CallInst::Create(getJavaExceptionLLVM, "",
-                                          cur->handler);
-      llvm::CallInst::Create(clearExceptionLLVM, "", cur->handler);
+      Value* exc = llvm::CallInst::Create(JnjvmModule::GetJavaExceptionFunction,
+                                          "", cur->handler);
+      llvm::CallInst::Create(JnjvmModule::ClearExceptionFunction, "",
+                             cur->handler);
       llvm::CallInst::Create(mvm::jit::exceptionBeginCatch, cur->handlerPHI,
                              "tmp8", cur->handler);
       std::vector<Value*> void_28_params;
@@ -999,22 +1003,18 @@
         GlobalVariable* gv = 0;
 #ifndef MULTIPLE_VM
         val = compilingClass->isolate->UTF8ToStr(utf8);
-        compilingClass->isolate->protectModule->lock();
         gv =
-          new GlobalVariable(JavaObject::llvmType, false, 
+          new GlobalVariable(JnjvmModule::JavaObjectType, false, 
                              GlobalValue::ExternalLinkage,
-                             constantJavaObjectNull, "",
-                             compilingClass->isolate->module);
-        compilingClass->isolate->protectModule->unlock();
+                             JnjvmModule::JavaObjectNullConstant, "",
+                             module);
 #else
           val = (void*)utf8;
-          compilingClass->isolate->protectModule->lock();
           gv =
-            new GlobalVariable(ArrayUInt16::llvmType, false, 
+            new GlobalVariable(JnjvmModule::ArrayUInt16Type, false, 
                                GlobalValue::ExternalLinkage,
-                               constantUTF8Null, "",
-                               compilingClass->isolate->module);
-          compilingClass->isolate->protectModule->unlock();
+                               UTF8NullConstant, "",
+                               module);
 #endif
         
         // TODO: put an initialiser in here
@@ -1022,7 +1022,7 @@
         GenericValue Val = GenericValue(val);
         llvm::GenericValue * Ptr = (llvm::GenericValue*)ptr;
         mvm::jit::executionEngine->StoreValueToMemory(Val, Ptr,
-                                                      JavaObject::llvmType);
+                                                  JnjvmModule::JavaObjectType);
         toPush = new LoadInst(gv, "", currentBlock);
         ctpInfo->ctpRes[index] = gv;
         compilingClass->release();
@@ -1036,40 +1036,32 @@
                             currentBlock);
     }
 #ifdef MULTIPLE_VM
-    CallInst* C = llvm::CallInst::Create(runtimeUTF8ToStrLLVM, toPush, "",
-                                         currentBlock);
+    CallInst* C = llvm::CallInst::Create(JnjvmModule::RuntimeUTF8ToStrFunction,
+                                         toPush, "", currentBlock);
     push(C, AssessorDesc::dRef);
 #else
     push(toPush, AssessorDesc::dRef);
 #endif
   } else if (type == JavaCtpInfo::ConstantLong) {
-    mvm::jit::protectConstants();//->lock();
     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, 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);
-    mvm::jit::unprotectConstants();//->unlock();
   } else if (type == JavaCtpInfo::ConstantFloat) {
-    mvm::jit::protectConstants();//->lock();
     push(ConstantFP::get(Type::FloatTy, ctpInfo->FloatAt(index)),
          AssessorDesc::dFloat);
-    mvm::jit::unprotectConstants();//->unlock();
   } else if (type == JavaCtpInfo::ConstantClass) {
     if (ctpInfo->ctpRes[index]) {
       CommonClass* cl = (CommonClass*)(ctpInfo->ctpRes[index]);
-      push(cl->llvmDelegatee(compilingClass->isolate->module, currentBlock),
-           AssessorDesc::dRef);
+      LLVMCommonClassInfo* LCI = module->getClassInfo(cl);
+      push(LCI->getDelegatee(this), AssessorDesc::dRef);
     } else {
       Value* val = getResolvedClass(index, false);
-      Value* res = CallInst::Create(getClassDelegateeLLVM, val, "",
+      Value* res = CallInst::Create(JnjvmModule::GetClassDelegateeFunction, val, "",
                                     currentBlock);
       push(res, AssessorDesc::dRef);
     }
@@ -1081,7 +1073,7 @@
 void JavaJIT::JITVerifyNull(Value* obj) { 
 
   JavaJIT* jit = this;
-  Constant* zero = constantJavaObjectNull;
+  Constant* zero = JnjvmModule::JavaObjectNullConstant;
   Value* test = new ICmpInst(ICmpInst::ICMP_EQ, obj, zero, "",
                              jit->currentBlock);
 
@@ -1091,13 +1083,13 @@
   llvm::BranchInst::Create(exit, cont, test, jit->currentBlock);
   std::vector<Value*> args;
   if (currentExceptionBlock != endExceptionBlock) {
-    llvm::InvokeInst::Create(JavaJIT::nullPointerExceptionLLVM,
+    llvm::InvokeInst::Create(JnjvmModule::NullPointerExceptionFunction,
                              unifiedUnreachable,
                              currentExceptionBlock, args.begin(),
                              args.end(), "", exit);
   } else {
-    llvm::CallInst::Create(JavaJIT::nullPointerExceptionLLVM, args.begin(),
-                 args.end(), "", exit);
+    llvm::CallInst::Create(JnjvmModule::NullPointerExceptionFunction,
+                           args.begin(), args.end(), "", exit);
     new UnreachableInst(exit);
   }
   
@@ -1129,12 +1121,12 @@
     args.push_back(obj);
     args.push_back(index);
     if (currentExceptionBlock != endExceptionBlock) {
-      llvm::InvokeInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM,
+      llvm::InvokeInst::Create(JnjvmModule::IndexOutOfBoundsExceptionFunction,
                                unifiedUnreachable,
                                currentExceptionBlock, args.begin(),
                                args.end(), "", ifFalse);
     } else {
-      llvm::CallInst::Create(JavaJIT::indexOutOfBoundsExceptionLLVM,
+      llvm::CallInst::Create(JnjvmModule::IndexOutOfBoundsExceptionFunction,
                              args.begin(), args.end(), "", ifFalse);
       new UnreachableInst(ifFalse);
     }
@@ -1147,7 +1139,7 @@
   
   std::vector<Value*> indexes; //[3];
   indexes.push_back(zero);
-  indexes.push_back(JavaArray::elementsOffset());
+  indexes.push_back(JnjvmModule::JavaArrayElementsOffsetConstant);
   indexes.push_back(index);
   Value* ptr = llvm::GetElementPtrInst::Create(val, indexes.begin(),
                                                indexes.end(), 
@@ -1399,6 +1391,7 @@
   jit.unifiedUnreachable = unifiedUnreachable;
   jit.inlineMethods = inlineMethods;
   jit.inlineMethods[meth] = true;
+  jit.module = module;
   Instruction* ret = jit.inlineCompile(llvmFunction, currentBlock, 
                                        currentExceptionBlock, args);
   inlineMethods[meth] = false;
@@ -1412,10 +1405,12 @@
   const UTF8* name = 0;
   const UTF8* cl = 0;
   ctpInfo->nameOfStaticOrSpecialMethod(index, cl, name, signature);
+  LLVMSignatureInfo* LSI = module->getSignatureInfo(signature);
+  const llvm::FunctionType* virtualType = LSI->getVirtualType();
   llvm::Instruction* val = 0;
-    
+  
   std::vector<Value*> args; 
-  FunctionType::param_iterator it  = signature->virtualType->param_end();
+  FunctionType::param_iterator it  = virtualType->param_end();
   makeArgs(it, index, args, signature->nbIn + 1);
   JITVerifyNull(args[0]); 
 
@@ -1437,7 +1432,7 @@
 
   }
   
-  const llvm::Type* retType = signature->virtualType->getReturnType();
+  const llvm::Type* retType = virtualType->getReturnType();
   if (retType != Type::VoidTy) {
     push(val, signature->ret->funcs);
     if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
@@ -1454,10 +1449,12 @@
   const UTF8* name = 0;
   const UTF8* cl = 0;
   ctpInfo->nameOfStaticOrSpecialMethod(index, cl, name, signature);
+  LLVMSignatureInfo* LSI = module->getSignatureInfo(signature);
+  const llvm::FunctionType* staticType = LSI->getStaticType();
   llvm::Instruction* val = 0;
   
   std::vector<Value*> args; // size = [signature->nbIn + 2]; 
-  FunctionType::param_iterator it  = signature->staticType->param_end();
+  FunctionType::param_iterator it  = staticType->param_end();
   makeArgs(it, index, args, signature->nbIn);
   ctpInfo->markAsStaticCall(index);
 
@@ -1474,10 +1471,12 @@
     uint32 clIndex = ctpInfo->getClassIndexFromMethod(index);
     Class* mycl = (Class*)(ctpInfo->getMethodClassIfLoaded(clIndex));
     if (mycl && mycl->status >= resolved) {
-      Module* M = compilingClass->isolate->module;
-      Value* arg = new LoadInst(mycl->llvmVar(M), "", currentBlock);
-      arg = invoke(initialisationCheckLLVM, arg, "", currentBlock);
-      CallInst::Create(forceInitialisationCheckLLVM, arg, "", currentBlock);
+      LLVMCommonClassInfo* LCI = module->getClassInfo(mycl);
+      Value* arg = LCI->getVar(this);
+      arg = invoke(JnjvmModule::InitialisationCheckFunction, arg, "",
+                   currentBlock);
+      CallInst::Create(JnjvmModule::ForceInitialisationCheckFunction, arg, "",
+                       currentBlock);
     }
 
 #endif
@@ -1491,7 +1490,7 @@
 
   }
 
-  const llvm::Type* retType = signature->staticType->getReturnType();
+  const llvm::Type* retType = staticType->getReturnType();
   if (retType != Type::VoidTy) {
     push(val, signature->ret->funcs);
     if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
@@ -1501,35 +1500,32 @@
 }
     
 Value* JavaJIT::getResolvedClass(uint16 index, bool clinit) {
-    compilingClass->isolate->protectModule->lock();
     GlobalVariable * gv =
-      new GlobalVariable(JavaClassType, false, 
+      new GlobalVariable(JnjvmModule::JavaClassType, false, 
                          GlobalValue::ExternalLinkage,
-                         constantJavaClassNull, "",
-                         compilingClass->isolate->module);
+                         JnjvmModule::JavaClassNullConstant, "",
+                         module);
 
-    compilingClass->isolate->protectModule->unlock();
     
     Value* arg1 = new LoadInst(gv, "", false, currentBlock);
     Value* test = new ICmpInst(ICmpInst::ICMP_EQ, arg1, 
-                               constantJavaClassNull, "", currentBlock);
+                               JnjvmModule::JavaClassNullConstant, "",
+                               currentBlock);
     
     BasicBlock* trueCl = createBasicBlock("Cl OK");
     BasicBlock* falseCl = createBasicBlock("Cl Not OK");
-    PHINode* node = llvm::PHINode::Create(JavaClassType, "", trueCl);
+    PHINode* node = llvm::PHINode::Create(JnjvmModule::JavaClassType, "",
+                                          trueCl);
     node->addIncoming(arg1, currentBlock);
     llvm::BranchInst::Create(falseCl, trueCl, test, currentBlock);
 
     currentBlock = falseCl;
 
     std::vector<Value*> Args;
-    Value* v = 
-      new LoadInst(compilingClass->llvmVar(compilingClass->isolate->module), 
-                   "", currentBlock);
+    LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(compilingClass);
+    Value* v = LCI->getVar(this);
     Args.push_back(v);
-    mvm::jit::protectConstants();
     ConstantInt* CI = ConstantInt::get(Type::Int32Ty, index);
-    mvm::jit::unprotectConstants();
     Args.push_back(CI);
     Args.push_back(gv);
     if (clinit) {
@@ -1537,14 +1533,16 @@
     } else {
       Args.push_back(mvm::jit::constantZero);
     }
-    Value* res = invoke(newLookupLLVM, Args, "", currentBlock);
+    Value* res = invoke(JnjvmModule::ClassLookupFunction, Args, "",
+                        currentBlock);
     node->addIncoming(res, currentBlock);
 
     llvm::BranchInst::Create(trueCl, currentBlock);
     currentBlock = trueCl;
 #ifdef MULTIPLE_VM
     if (clinit)
-      return invoke(initialisationCheckLLVM, node, "", currentBlock);
+      return invoke(JnjvmModule::InitialisationCheckFunction, node, "",
+                    currentBlock);
     else
 #endif
     return node;
@@ -1560,32 +1558,35 @@
   Value* Cl = 0;
   if (!cl || !cl->isResolved()) {
     Cl = getResolvedClass(index, true);
-    Size = CallInst::Create(getObjectSizeFromClassLLVM, Cl, "", currentBlock);
-    VT = CallInst::Create(getVTFromClassLLVM, Cl, "", currentBlock);
+    Size = CallInst::Create(JnjvmModule::GetObjectSizeFromClassFunction, Cl,
+                            "", currentBlock);
+    VT = CallInst::Create(JnjvmModule::GetVTFromClassFunction, Cl, "",
+                          currentBlock);
   } else {
-    Module* M = compilingClass->isolate->module;
-    Size = cl->virtualSizeLLVM;
-    VT = cl->llvmVT(this);
-    Cl = new LoadInst(cl->llvmVar(M), "", currentBlock);
+    LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(cl);
+    Size = LCI->getVirtualSize(this);
+    VT = LCI->getVirtualTable(this);
+    Cl = LCI->getVar(this);
 #ifndef MULTIPLE_VM
     if (!cl->isReady())
 #endif
-      Cl = invoke(initialisationCheckLLVM, Cl, "", currentBlock);
+      Cl = invoke(JnjvmModule::InitialisationCheckFunction, Cl, "", currentBlock);
   }
   std::vector<Value*> args;
   args.push_back(Size);
   args.push_back(VT);
 #ifdef MULTIPLE_GC
-  args.push_back(CallInst::Create(getCollectorLLVM, isolateLocal, "",
-                                  currentBlock));
+  args.push_back(CallInst::Create(JnjvmModule::GetCollectorFunction,
+                                  isolateLocal, "", currentBlock));
 #endif
-  Value* val = invoke(javaObjectAllocateLLVM, args, "", currentBlock);
+  Value* val = invoke(JnjvmModule::JavaObjectAllocateFunction, args, "",
+                      currentBlock);
   
   // Set the class
   
   std::vector<Value*> gep;
   gep.push_back(mvm::jit::constantZero);
-  gep.push_back(JavaObject::classOffset());
+  gep.push_back(JnjvmModule::JavaObjectClassOffsetConstant);
   Value* GEP = GetElementPtrInst::Create(val, gep.begin(), gep.end(), "",
                                          currentBlock);
   new StoreInst(Cl, GEP, currentBlock);
@@ -1595,15 +1596,8 @@
 }
 
 Value* JavaJIT::arraySize(Value* val) {
-  return llvm::CallInst::Create(arrayLengthLLVM, val, "", currentBlock);
-  /*
-  Value* array = new BitCastInst(val, JavaArray::llvmType, "", currentBlock);
-  std::vector<Value*> args; //size=  2
-  args.push_back(mvm::jit::constantZero);
-  args.push_back(JavaArray::sizeOffset());
-  Value* ptr = llvm::GetElementPtrInst::Create(array, args.begin(), args.end(),
-                                     "", currentBlock);
-  return new LoadInst(ptr, "", currentBlock);*/
+  return llvm::CallInst::Create(JnjvmModule::ArrayLengthFunction, val, "",
+                                currentBlock);
 }
 
 static llvm::Value* fieldGetter(JavaJIT* jit, const Type* type, Value* object,
@@ -1632,13 +1626,16 @@
       && field->classDef->isReady()
 #endif
      ) {
-    if (stat) object = field->classDef->staticVar(this);
-    const Type* type = stat ? field->classDef->staticType :
-                              field->classDef->virtualType;
-    return fieldGetter(this, type, object, field->offset);
+    LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(field->classDef);
+    if (stat) {
+      object = LCI->getStaticVar(this);
+    }
+    const Type* type = stat ? LCI->getStaticType() :
+                              LCI->getVirtualType();
+    LLVMFieldInfo* LFI = module->getFieldInfo(field);
+    return fieldGetter(this, type, object, LFI->getOffset());
   } else {
     const Type* Pty = mvm::jit::arrayPtrType;
-    compilingClass->isolate->protectModule->lock();
     GlobalVariable* gvStaticInstance = 
       new GlobalVariable(mvm::jit::ptrType, false, 
                          GlobalValue::ExternalLinkage,
@@ -1650,7 +1647,6 @@
     GlobalVariable* gv = 
       new GlobalVariable(Type::Int32Ty, false, GlobalValue::ExternalLinkage,
                          zero, "", compilingClass->isolate->module);
-    compilingClass->isolate->protectModule->unlock();
     
     // set is volatile
     Value* val = new LoadInst(gv, "", true, currentBlock);
@@ -1685,18 +1681,16 @@
     if (object) {
       args.push_back(object);
     } else {
-      args.push_back(constantJavaObjectNull);
+      args.push_back(JnjvmModule::JavaObjectNullConstant);
     }
-    Module* M = compilingClass->isolate->module;
-    args.push_back(new LoadInst(compilingClass->llvmVar(M), "", currentBlock));
-    mvm::jit::protectConstants();//->lock();
+    LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(compilingClass);
+    args.push_back(LCI->getVar(this));
     Constant* CI = ConstantInt::get(Type::Int32Ty, index);
     args.push_back(CI);
-    mvm::jit::unprotectConstants();//->unlock();
     args.push_back(stat ? mvm::jit::constantOne : mvm::jit::constantZero);
     args.push_back(gvStaticInstance);
     args.push_back(gv);
-    Value* tmp = invoke(JavaJIT::fieldLookupLLVM, args, "", currentBlock);
+    Value* tmp = invoke(JnjvmModule::FieldLookupFunction, args, "", currentBlock);
     node->addIncoming(tmp, currentBlock);
     llvm::BranchInst::Create(endBlock, currentBlock);
     
@@ -1842,3 +1836,98 @@
 }
 
 
+void JavaJIT::invokeInterfaceOrVirtual(uint16 index) {
+  
+  // Do the usual
+  JavaCtpInfo* ctpInfo = compilingClass->ctpInfo;
+  Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index);
+  
+  LLVMSignatureInfo* LSI = module->getSignatureInfo(signature);
+  const llvm::FunctionType* virtualType = LSI->getVirtualType();
+  const llvm::PointerType* virtualPtrType = LSI->getVirtualPtrType();
+
+  std::vector<Value*> args; // size = [signature->nbIn + 3];
+
+  FunctionType::param_iterator it  = virtualType->param_end();
+  makeArgs(it, index, args, signature->nbIn + 1);
+  
+  const llvm::Type* retType = virtualType->getReturnType();
+  BasicBlock* endBlock = createBasicBlock("end virtual invoke");
+  PHINode * node = 0;
+  if (retType != Type::VoidTy) {
+    node = PHINode::Create(retType, "", endBlock);
+  }
+
+  // ok now the cache
+  Enveloppe* enveloppe = Enveloppe::allocate(compilingClass->ctpInfo, index);
+  compilingMethod->caches.push_back(enveloppe);
+  
+  Value* zero = mvm::jit::constantZero;
+  Value* one = mvm::jit::constantOne;
+  Value* two = mvm::jit::constantTwo;
+  
+  Value* llvmEnv = 
+    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+                              uint64_t (enveloppe)),
+                              JnjvmModule::EnveloppeType);
+  
+
+  JITVerifyNull(args[0]);
+
+  std::vector<Value*> args1;
+  args1.push_back(zero);
+  args1.push_back(one);
+  Value* cachePtr = GetElementPtrInst::Create(llvmEnv, args1.begin(), args1.end(),
+                                          "", currentBlock);
+  Value* cache = new LoadInst(cachePtr, "", currentBlock);
+
+  Value* cl = CallInst::Create(JnjvmModule::GetClassFunction, args[0], "",
+                               currentBlock);
+  std::vector<Value*> args3;
+  args3.push_back(zero);
+  args3.push_back(two);
+  Value* lastCiblePtr = GetElementPtrInst::Create(cache, args3.begin(), 
+                                                  args3.end(), "", 
+                                                  currentBlock);
+  Value* lastCible = new LoadInst(lastCiblePtr, "", currentBlock);
+
+  Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, cl, lastCible, "", currentBlock);
+  
+  BasicBlock* ifTrue = createBasicBlock("cache ok");
+  BasicBlock* ifFalse = createBasicBlock("cache not ok");
+  BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
+  
+  currentBlock = ifFalse;
+  Value* _meth = invoke(JnjvmModule::InterfaceLookupFunction, cache, args[0],
+                        "", ifFalse);
+  Value* meth = new BitCastInst(_meth, virtualPtrType, "", 
+                                currentBlock);
+  Value* ret = invoke(meth, args, "", currentBlock);
+  if (node) {
+    node->addIncoming(ret, currentBlock);
+  }
+  BranchInst::Create(endBlock, currentBlock);
+
+  currentBlock = ifTrue;
+
+  Value* methPtr = GetElementPtrInst::Create(cache, args1.begin(), args1.end(),
+                                         "", currentBlock);
+
+  _meth = new LoadInst(methPtr, "", currentBlock);
+  meth = new BitCastInst(_meth, virtualPtrType, "", currentBlock);
+  
+  ret = invoke(meth, args, "", currentBlock);
+  BranchInst::Create(endBlock, currentBlock);
+
+  if (node) {
+    node->addIncoming(ret, currentBlock);
+  }
+
+  currentBlock = endBlock;
+  if (node) {
+    push(node, signature->ret->funcs);
+    if (retType == Type::DoubleTy || retType == Type::Int64Ty) {
+      push(mvm::jit::constantZero, AssessorDesc::dInt);
+    }
+  }
+}

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Fri May 16 09:49:12 2008
@@ -38,6 +38,7 @@
 class JavaObject;
 class JavaString;
 class Jnjvm;
+class JnjvmModule;
 class JnjvmModuleProvider;
 class Reader;
 class Signdef;
@@ -66,6 +67,8 @@
 
 class JavaJIT {
 public:
+  
+  JnjvmModule* module;
 
   static void invokeOnceVoid(Jnjvm* vm, JavaObject* loader,
                              const char* className,
@@ -114,16 +117,6 @@
   uint32 stackSize();
   
   // exceptions
-  static llvm::Function* getExceptionLLVM;
-  static llvm::Function* getJavaExceptionLLVM;
-  static llvm::Function* throwExceptionLLVM;
-  static llvm::Function* clearExceptionLLVM;
-  static llvm::Function* compareExceptionLLVM;
-  static llvm::Function* nullPointerExceptionLLVM;
-  static llvm::Function* indexOutOfBoundsExceptionLLVM;
-  static llvm::Function* classCastExceptionLLVM;
-  static llvm::Function* outOfMemoryErrorLLVM;
-  static llvm::Function* negativeArraySizeExceptionLLVM;
   std::vector<llvm::BasicBlock*> jsrs;
   // exception local
   llvm::Value* supplLocal;
@@ -220,82 +213,13 @@
 
   static const char* OpcodeNames[256];
 
-  static VirtualTable* makeVT(Class* cl, bool stat);
-                              
-  static llvm::Function* javaObjectTracerLLVM;
-
-  static void initialise();
-  static void initialiseJITBootstrapVM(Jnjvm* vm);
-  static void initialiseJITIsolateVM(Jnjvm* vm);
-
-  
-  static void initField(JavaField* field);
-  static void initField(JavaField* field, JavaObject* obj, uint64 val = 0);
-  static void initField(JavaField* field, JavaObject* obj, JavaObject* val);
-  static void initField(JavaField* field, JavaObject* obj, double val);
-  static void initField(JavaField* field, JavaObject* obj, float val);
-
-  static llvm::Function* getSJLJBufferLLVM;
-  static llvm::Function* virtualLookupLLVM;
-  static llvm::Function* fieldLookupLLVM;
-  static llvm::Function* printExecutionLLVM;
-  static llvm::Function* printMethodStartLLVM;
-  static llvm::Function* printMethodEndLLVM;
-  static llvm::Function* jniProceedPendingExceptionLLVM;
-  static llvm::Function* initialisationCheckLLVM;
-  static llvm::Function* forceInitialisationCheckLLVM;
-  static llvm::Function* newLookupLLVM;
-#ifndef WITHOUT_VTABLE
-  static llvm::Function* vtableLookupLLVM;
-#endif
-  static llvm::Function* instanceOfLLVM;
-  static llvm::Function* aquireObjectLLVM;
-  static llvm::Function* releaseObjectLLVM;
-#ifdef SERVICE_VM
-  static llvm::Function* aquireObjectInSharedDomainLLVM;
-  static llvm::Function* releaseObjectInSharedDomainLLVM;
-#endif
-  static llvm::Function* multiCallNewLLVM;
-  static llvm::Function* runtimeUTF8ToStrLLVM;
-  static llvm::Function* getStaticInstanceLLVM;
-  static llvm::Function* getClassDelegateeLLVM;
-  static llvm::Function* arrayLengthLLVM;
-  static llvm::Function* getVTLLVM;
-  static llvm::Function* getClassLLVM;
-  static llvm::Function* javaObjectAllocateLLVM;
-#ifdef MULTIPLE_GC
-  static llvm::Function* getCollectorLLVM;
-#endif
-  static llvm::Function* getVTFromClassLLVM;
-  static llvm::Function* getObjectSizeFromClassLLVM;
-  static llvm::ConstantInt* constantOffsetObjectSizeInClass;
-  static llvm::ConstantInt* constantOffsetVTInClass;
-  
-
   static Class* getCallingClass();
   static Class* getCallingClassWalker();
   static JavaObject* getCallingClassLoader();
   static void printBacktrace();
   static int getBacktrace(void** array, int size);
   static JavaMethod* IPToJavaMethod(void* ip);
-
-#ifdef WITH_TRACER
-  static llvm::Function* markAndTraceLLVM;
-  static const llvm::FunctionType* markAndTraceLLVMType;
-#endif
-  
-  static const llvm::Type* VTType;
-  static const llvm::Type* JavaClassType;
-  static llvm::Constant* constantJavaClassNull;
-
-  static llvm::Constant*    constantJavaObjectNull;
-  static llvm::Constant*    constantUTF8Null;
-  static llvm::Constant*    constantMaxArraySize;
-  static llvm::Constant*    constantJavaObjectSize;
-
-  static llvm::GlobalVariable* ArrayObjectVT;
-  static llvm::GlobalVariable* JavaObjectVT;
-
+  static void initialise();
   static void AddStandardCompilePasses(llvm::FunctionPassManager*);
 };
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Fri May 16 09:49:12 2008
@@ -36,194 +36,6 @@
 using namespace jnjvm;
 using namespace llvm;
 
-#ifdef WITH_TRACER
-const llvm::FunctionType* JavaJIT::markAndTraceLLVMType = 0;
-#endif
-
-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* CacheNode::llvmType = 0;
-const llvm::Type* Enveloppe::llvmType = 0;
-
-void JavaJIT::initialiseJITIsolateVM(Jnjvm* vm) {
-  mvm::jit::protectEngine->lock();
-  mvm::jit::executionEngine->addModuleProvider(vm->TheModuleProvider);
-  mvm::jit::protectEngine->unlock();
-}
-
-#include "LLVMRuntime.cpp"
-
-void JavaJIT::initialiseJITBootstrapVM(Jnjvm* vm) {
-  Module* module = vm->module;
-  mvm::jit::protectEngine->lock();
-  mvm::jit::executionEngine->addModuleProvider(vm->TheModuleProvider); 
-  mvm::jit::protectEngine->unlock();
-
-  mvm::jit::protectTypes();
-  makeLLVMModuleContents(module);
-  
-  VTType = module->getTypeByName("VT");
-  
-  JavaObject::llvmType = 
-    PointerType::getUnqual(module->getTypeByName("JavaObject"));
-
-  JavaArray::llvmType =
-    PointerType::getUnqual(module->getTypeByName("JavaArray"));
-  
-  JavaClassType =
-    PointerType::getUnqual(module->getTypeByName("JavaClass"));
-
-#define ARRAY_TYPE(name, type) \
-  name::llvmType = PointerType::getUnqual(module->getTypeByName(#name));
-  ARRAY_TYPE(ArrayUInt8, Type::Int8Ty);
-  ARRAY_TYPE(ArraySInt8, Type::Int8Ty);
-  ARRAY_TYPE(ArrayUInt16, Type::Int16Ty);
-  ARRAY_TYPE(ArraySInt16, Type::Int16Ty);
-  ARRAY_TYPE(ArrayUInt32, Type::Int32Ty);
-  ARRAY_TYPE(ArraySInt32, Type::Int32Ty);
-  ARRAY_TYPE(ArrayLong, Type::Int64Ty);
-  ARRAY_TYPE(ArrayDouble, Type::DoubleTy);
-  ARRAY_TYPE(ArrayFloat, Type::FloatTy);
-  ARRAY_TYPE(ArrayObject, JavaObject::llvmType);
-#undef ARRAY_TYPE
-
-  CacheNode::llvmType =
-    PointerType::getUnqual(module->getTypeByName("CacheNode"));
-  
-  Enveloppe::llvmType =
-    PointerType::getUnqual(module->getTypeByName("Enveloppe"));
-
-  mvm::jit::unprotectTypes();
-
-  virtualLookupLLVM = module->getFunction("virtualLookup");
-  multiCallNewLLVM = module->getFunction("multiCallNew");
-  initialisationCheckLLVM = module->getFunction("initialisationCheck");
-  forceInitialisationCheckLLVM = 
-    module->getFunction("forceInitialisationCheck");
-
-  arrayLengthLLVM = module->getFunction("arrayLength");
-  getVTLLVM = module->getFunction("getVT");
-  getClassLLVM = module->getFunction("getClass");
-  newLookupLLVM = module->getFunction("newLookup");
-  getVTFromClassLLVM = module->getFunction("getVTFromClass");
-  getObjectSizeFromClassLLVM = module->getFunction("getObjectSizeFromClass");
- 
-  getClassDelegateeLLVM = module->getFunction("getClassDelegatee");
-  instanceOfLLVM = module->getFunction("JavaObjectInstanceOf");
-  aquireObjectLLVM = module->getFunction("JavaObjectAquire");
-  releaseObjectLLVM = module->getFunction("JavaObjectRelease");
-
-  fieldLookupLLVM = module->getFunction("fieldLookup");
-  
-  getExceptionLLVM = module->getFunction("JavaThreadGetException");
-  getJavaExceptionLLVM = module->getFunction("JavaThreadGetJavaException");
-  compareExceptionLLVM = module->getFunction("JavaThreadCompareException");
-  jniProceedPendingExceptionLLVM = 
-    module->getFunction("jniProceedPendingException");
-  getSJLJBufferLLVM = module->getFunction("getSJLJBuffer");
-  
-  nullPointerExceptionLLVM = module->getFunction("nullPointerException");
-  classCastExceptionLLVM = module->getFunction("classCastException");
-  indexOutOfBoundsExceptionLLVM = 
-    module->getFunction("indexOutOfBoundsException");
-  negativeArraySizeExceptionLLVM = 
-    module->getFunction("negativeArraySizeException");
-  outOfMemoryErrorLLVM = module->getFunction("outOfMemoryError");
-
-  javaObjectAllocateLLVM = module->getFunction("gcmalloc");
-
-  printExecutionLLVM = module->getFunction("printExecution");
-  printMethodStartLLVM = module->getFunction("printMethodStart");
-  printMethodEndLLVM = module->getFunction("printMethodEnd");
-
-  throwExceptionLLVM = module->getFunction("JavaThreadThrowException");
-
-  clearExceptionLLVM = module->getFunction("JavaThreadClearException");
-  
-
-#ifdef MULTIPLE_VM
-  getStaticInstanceLLVM = module->getFunction("getStaticInstance");
-  runtimeUTF8ToStrLLVM = module->getFunction("runtimeUTF8ToStr");
-#endif
-  
-#ifdef SERVICE_VM
-  aquireObjectInSharedDomainLLVM = 
-    module->getFunction("JavaObjectAquireInSharedDomain");
-  releaseObjectInSharedDomainLLVM = 
-    module->getFunction("JavaObjectReleaseInSharedDomain");
-  ServiceDomain::serviceCallStartLLVM = module->getFunction("serviceCallStart");
-  ServiceDomain::serviceCallStopLLVM = module->getFunction("serviceCallStop");
-#endif
-    
-#ifdef WITH_TRACER
-  markAndTraceLLVM = module->getFunction("MarkAndTrace");
-  markAndTraceLLVMType = markAndTraceLLVM->getFunctionType();
-  javaObjectTracerLLVM = module->getFunction("JavaObjectTracer");
-#endif
-
-#ifndef WITHOUT_VTABLE
-  vtableLookupLLVM = module->getFunction("vtableLookup");
-#endif
-
-#ifdef MULTIPLE_GC
-  getCollectorLLVM = module->getFunction("getCollector");
-#endif
-
-  
-  mvm::jit::protectConstants();
-  constantUTF8Null = Constant::getNullValue(ArrayUInt16::llvmType); 
-  constantJavaClassNull = Constant::getNullValue(JavaClassType); 
-  constantJavaObjectNull = Constant::getNullValue(JavaObject::llvmType);
-  constantMaxArraySize = ConstantInt::get(Type::Int32Ty,
-                                          JavaArray::MaxArraySize);
-  constantJavaObjectSize = ConstantInt::get(Type::Int32Ty, sizeof(JavaObject));
-  
-  
-  Constant* cons = 
-    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
-                              uint64_t (JavaObject::VT)), VTType);
-      
-  JavaObjectVT = new GlobalVariable(VTType, true,
-                                    GlobalValue::ExternalLinkage,
-                                    cons, "",
-                                    module);
-  
-  cons = 
-    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
-                              uint64_t (ArrayObject::VT)), VTType);
-  
-  ArrayObjectVT = new GlobalVariable(VTType, true,
-                                    GlobalValue::ExternalLinkage,
-                                    cons, "",
-                                    module);
-  mvm::jit::unprotectConstants();
-  
-  constantOffsetObjectSizeInClass = mvm::jit::constantOne;
-  constantOffsetVTInClass = mvm::jit::constantTwo;
-  
-}
-
-llvm::Constant*    JavaJIT::constantJavaObjectNull;
-llvm::Constant*    JavaJIT::constantUTF8Null;
-llvm::Constant*    JavaJIT::constantJavaClassNull;
-llvm::Constant*    JavaJIT::constantMaxArraySize;
-llvm::Constant*    JavaJIT::constantJavaObjectSize;
-llvm::GlobalVariable*    JavaJIT::JavaObjectVT;
-llvm::GlobalVariable*    JavaJIT::ArrayObjectVT;
-llvm::ConstantInt* JavaJIT::constantOffsetObjectSizeInClass;
-llvm::ConstantInt* JavaJIT::constantOffsetVTInClass;
-const llvm::Type* JavaJIT::JavaClassType;
-
 namespace mvm {
 
 llvm::FunctionPass* createEscapeAnalysisPass(llvm::Function*, llvm::Function*);
@@ -281,6 +93,5 @@
   addPass(PM, createDeadStoreEliminationPass()); // Delete dead stores
   addPass(PM, createAggressiveDCEPass());        // SSA based 'Aggressive DCE'
   addPass(PM, createCFGSimplificationPass());    // Merge & remove BBs
-
 }
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Fri May 16 09:49:12 2008
@@ -33,6 +33,7 @@
 #include "JavaThread.h"
 #include "JavaTypes.h"
 #include "Jnjvm.h"
+#include "JnjvmModule.h"
 
 #include "OpcodeNames.def"
 
@@ -152,14 +153,12 @@
 #if JNJVM_EXECUTE > 1
     {
     std::vector<llvm::Value*> args;
-    mvm::jit::protectConstants();
     args.push_back(ConstantInt::get(Type::Int32Ty, 
                                     (int64_t)OpcodeNames[bytecodes[i]]));
     args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)i));
     args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod));
-    mvm::jit::unprotectConstants();
-    CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "",
-                     currentBlock);
+    CallInst::Create(JnjvmModule::PrintExecutionFunction, args.begin(),
+                     args.end(), "", currentBlock);
     }
 #endif
 
@@ -170,7 +169,7 @@
     switch (bytecodes[i]) {
       
       case ACONST_NULL : 
-        push(constantJavaObjectNull, AssessorDesc::dRef);
+        push(JnjvmModule::JavaObjectNullConstant, AssessorDesc::dRef);
         break;
 
       case ICONST_M1 :
@@ -234,19 +233,15 @@
         break;
 
       case BIPUSH : 
-        mvm::jit::protectConstants();//->lock();
         push(ConstantExpr::getSExt(ConstantInt::get(Type::Int8Ty,
                                                     bytecodes[++i]),
                                    Type::Int32Ty), AssessorDesc::dInt);
-        mvm::jit::unprotectConstants();//->unlock();
         break;
 
       case SIPUSH :
-        mvm::jit::protectConstants();//->lock();
         push(ConstantExpr::getSExt(ConstantInt::get(Type::Int16Ty,
                                                     readS2(bytecodes, i)),
                                    Type::Int32Ty), AssessorDesc::dInt);
-        mvm::jit::unprotectConstants();//->unlock();
         break;
 
       case LDC :
@@ -396,7 +391,8 @@
       case IALOAD : {
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArraySInt32::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index, 
+                                         JnjvmModule::JavaArraySInt32Type);
         push(new LoadInst(ptr, "", currentBlock), AssessorDesc::dInt);
         break;
       }
@@ -404,7 +400,8 @@
       case LALOAD : {
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArrayLong::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArrayLongType);
         push(new LoadInst(ptr, "", currentBlock), AssessorDesc::dLong);
         push(mvm::jit::constantZero, AssessorDesc::dInt);
         break;
@@ -413,7 +410,8 @@
       case FALOAD : {
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArrayFloat::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArrayFloatType);
         push(new LoadInst(ptr, "", currentBlock), AssessorDesc::dFloat);
         break;
       }
@@ -421,7 +419,8 @@
       case DALOAD : {
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArrayDouble::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArrayDoubleType);
         push(new LoadInst(ptr, "", currentBlock), AssessorDesc::dDouble);
         push(mvm::jit::constantZero, AssessorDesc::dInt);
         break;
@@ -430,7 +429,8 @@
       case AALOAD : {
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArrayObject::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArrayObjectType);
         push(new LoadInst(ptr, "", currentBlock), AssessorDesc::dRef);
         break;
       }
@@ -438,7 +438,8 @@
       case BALOAD : {
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArraySInt8::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArraySInt8Type);
         Value* val = new LoadInst(ptr, "", currentBlock);
         push(new SExtInst(val, Type::Int32Ty, "", currentBlock),
              AssessorDesc::dInt);
@@ -448,7 +449,8 @@
       case CALOAD : {
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArrayUInt16::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArrayUInt16Type);
         Value* val = new LoadInst(ptr, "", currentBlock);
         push(new ZExtInst(val, Type::Int32Ty, "", currentBlock),
              AssessorDesc::dInt);
@@ -458,7 +460,8 @@
       case SALOAD : {
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArraySInt16::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArraySInt16Type);
         Value* val = new LoadInst(ptr, "", currentBlock);
         push(new SExtInst(val, Type::Int32Ty, "", currentBlock),
              AssessorDesc::dInt);
@@ -602,7 +605,8 @@
         Value* val = popAsInt();
         Value* index = popAsInt();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArraySInt32::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArraySInt32Type);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -612,7 +616,8 @@
         Value* val = pop();
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArrayLong::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArrayLongType);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -621,7 +626,8 @@
         Value* val = pop();
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArrayFloat::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArrayFloatType);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -631,7 +637,8 @@
         Value* val = pop();
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArrayDouble::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArrayDoubleType);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -640,7 +647,8 @@
         Value* val = pop();
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArrayObject::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArrayObjectType);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -652,7 +660,8 @@
         }
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArraySInt8::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArraySInt8Type);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -667,7 +676,8 @@
         }
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArrayUInt16::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArrayUInt16Type);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -682,7 +692,8 @@
         }
         Value* index = pop();
         Value* obj = pop();
-        Value* ptr = verifyAndComputePtr(obj, index, ArraySInt16::llvmType);
+        Value* ptr = verifyAndComputePtr(obj, index,
+                                         JnjvmModule::JavaArraySInt16Type);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -1098,12 +1109,10 @@
       case IINC : {
         uint16 idx = WREAD_U1(bytecodes, true, i);
         sint16 val = WREAD_S1(bytecodes, false, i);
-        mvm::jit::protectConstants();
         llvm::Value* add = BinaryOperator::createAdd(
             new LoadInst(intLocals[idx], "", currentBlock), 
             ConstantInt::get(Type::Int32Ty, val), "",
             currentBlock);
-        mvm::jit::unprotectConstants();
         new StoreInst(add, intLocals[idx], false, currentBlock);
         break;
       }
@@ -1641,12 +1650,10 @@
       
       case JSR : {
         uint32 tmp = i;
-        mvm::jit::protectConstants();
         Value* expr = ConstantExpr::getIntToPtr(
                                     ConstantInt::get(Type::Int64Ty,
                                                      uint64_t (jsrIndex++)),
-                                    JavaObject::llvmType);
-        mvm::jit::unprotectConstants();
+                                    JnjvmModule::JavaObjectType);
 
         new StoreInst(expr, supplLocal, false, currentBlock);
         BranchInst::Create(opcodeInfos[tmp + readS2(bytecodes, i)].newBlock,
@@ -1662,12 +1669,10 @@
                                           currentBlock);
         
         uint32 index = 0;
-        mvm::jit::protectConstants();
         for (std::vector<BasicBlock*>::iterator i = jsrs.begin(), 
             e = jsrs.end(); i!= e; ++i, ++index) {
           inst->addCase(ConstantInt::get(Type::Int32Ty, index), *i);
         }
-        mvm::jit::unprotectConstants();
 
         break;
       }
@@ -1685,7 +1690,6 @@
         Value* index = pop(); 
         
         const llvm::Type* type = index->getType();
-        mvm::jit::protectConstants();
         for (uint32 cur = low; cur < high; ++cur) {
           Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ,
                                     ConstantInt::get(type, cur), index,
@@ -1695,7 +1699,6 @@
                  falseBlock, currentBlock);
           currentBlock = falseBlock;
         }
-        mvm::jit::unprotectConstants();
        
         
         branch(def, currentBlock);
@@ -1718,7 +1721,6 @@
         } else if (ass == AssessorDesc::dChar || ass == AssessorDesc::dBool) {
           key = new ZExtInst(key, Type::Int32Ty, "", currentBlock);
         }
-        mvm::jit::protectConstants();//->lock();
         for (uint32 cur = 0; cur < nbs; ++cur) {
           Value* val = ConstantInt::get(Type::Int32Ty, readU4(bytecodes, i));
           Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, val, key, "", currentBlock);
@@ -1727,7 +1729,6 @@
                  falseBlock, currentBlock);
           currentBlock = falseBlock;
         }
-        mvm::jit::unprotectConstants();//->unlock();
         branch(def, currentBlock);
         i = tmp + 8 + filled + (nbs << 3);
         break;
@@ -1835,7 +1836,7 @@
           uint8 id = bytecodes[++i];
           AssessorDesc* ass = AssessorDesc::arrayType(id);
           dcl = ass->arrayClass;
-          TheVT = JavaObjectVT;
+          TheVT = JnjvmModule::JavaObjectVirtualTableGV;
           sizeElement = ass->sizeInBytesConstant;
         } else {
           uint16 index = readU2(bytecodes, i);
@@ -1846,12 +1847,13 @@
             AssessorDesc::constructArrayName(vm, 0, 1, className);
         
           dcl = vm->constructArray(arrayName, compilingClass->classLoader);
-          TheVT = ArrayObjectVT;
+          TheVT = JnjvmModule::ArrayObjectVirtualTableGV;
           sizeElement = mvm::jit::constantPtrSize;
         }
         
-        llvm::Value* valCl = new LoadInst(dcl->llvmVar(vm->module), "",
-                                          currentBlock);
+        LLVMCommonClassInfo* LCI = module->getClassInfo(dcl);
+        llvm::Value* valCl = LCI->getVar(this);
+        
         llvm::Value* arg1 = popAsInt();
 
         Value* cmp = new ICmpInst(ICmpInst::ICMP_SLT, arg1,
@@ -1865,17 +1867,19 @@
         std::vector<Value*> exArgs;
         exArgs.push_back(arg1);
         if (currentExceptionBlock != endExceptionBlock) {
-          InvokeInst::Create(negativeArraySizeExceptionLLVM, unifiedUnreachable,
+          InvokeInst::Create(JnjvmModule::NegativeArraySizeExceptionFunction, 
+                             unifiedUnreachable,
                              currentExceptionBlock, exArgs.begin(),
                              exArgs.end(), "", currentBlock);
         } else {
-          CallInst::Create(negativeArraySizeExceptionLLVM, exArgs.begin(),
-                           exArgs.end(), "", currentBlock);
+          CallInst::Create(JnjvmModule::NegativeArraySizeExceptionFunction,
+                           exArgs.begin(), exArgs.end(), "", currentBlock);
           new UnreachableInst(currentBlock);
         }
         currentBlock = BB2;
         
-        cmp = new ICmpInst(ICmpInst::ICMP_SGT, arg1, constantMaxArraySize,
+        cmp = new ICmpInst(ICmpInst::ICMP_SGT, arg1,
+                           JnjvmModule::MaxArraySizeConstant,
                            "", currentBlock);
 
         BB1 = createBasicBlock("");
@@ -1884,35 +1888,38 @@
         BranchInst::Create(BB1, BB2, cmp, currentBlock);
         currentBlock = BB1;
         if (currentExceptionBlock != endExceptionBlock) {
-          InvokeInst::Create(outOfMemoryErrorLLVM, unifiedUnreachable,
+          InvokeInst::Create(JnjvmModule::OutOfMemoryErrorFunction,
+                             unifiedUnreachable,
                              currentExceptionBlock, exArgs.begin(),
                              exArgs.end(), "", currentBlock);
         } else {
-          CallInst::Create(outOfMemoryErrorLLVM, exArgs.begin(), exArgs.end(),
-                           "", currentBlock);
+          CallInst::Create(JnjvmModule::OutOfMemoryErrorFunction,
+                           exArgs.begin(), exArgs.end(), "", currentBlock);
           new UnreachableInst(currentBlock);
         }
         currentBlock = BB2;
         
         Value* mult = BinaryOperator::createMul(arg1, sizeElement, "",
                                                 currentBlock);
-        Value* size = BinaryOperator::createAdd(constantJavaObjectSize, mult,
-                                                "", currentBlock);
+        Value* size =
+          BinaryOperator::createAdd(JnjvmModule::JavaObjectSizeConstant, mult,
+                                    "", currentBlock);
         std::vector<Value*> args;
         args.push_back(size);
         args.push_back(new LoadInst(TheVT, "", currentBlock));
 #ifdef MULTIPLE_GC
-        args.push_back(CallInst::Create(getCollectorLLVM, isolateLocal, "",
-                                        currentBlock));
+        args.push_back(CallInst::Create(JnjvmModule::GetCollectorFunction,
+                                        isolateLocal, "", currentBlock));
 #endif
-        Value* res = invoke(javaObjectAllocateLLVM, args, "", currentBlock);
-        Value* cast = new BitCastInst(res, JavaArray::llvmType, "",
+        Value* res = invoke(JnjvmModule::JavaObjectAllocateFunction, args, "",
+                            currentBlock);
+        Value* cast = new BitCastInst(res, JnjvmModule::JavaArrayType, "",
                                       currentBlock);
 
         // Set the size
         std::vector<Value*> gep4;
         gep4.push_back(mvm::jit::constantZero);
-        gep4.push_back(JavaArray::sizeOffset());
+        gep4.push_back(JnjvmModule::JavaArraySizeOffsetConstant);
         Value* GEP = GetElementPtrInst::Create(cast, gep4.begin(), gep4.end(),
                                                "", currentBlock);
         new StoreInst(arg1, GEP, currentBlock);
@@ -1920,7 +1927,7 @@
         // Set the class
         std::vector<Value*> gep;
         gep.push_back(mvm::jit::constantZero);
-        gep.push_back(JavaObject::classOffset());
+        gep.push_back(JnjvmModule::JavaObjectClassOffsetConstant);
         GEP = GetElementPtrInst::Create(res, gep.begin(), gep.end(), "",
                                         currentBlock);
         new StoreInst(valCl, GEP, currentBlock);
@@ -1942,12 +1949,13 @@
         std::vector<Value*> args;
         args.push_back(arg);
         if (currentExceptionBlock != endExceptionBlock) {
-          InvokeInst::Create(throwExceptionLLVM, unifiedUnreachable,
+          InvokeInst::Create(JnjvmModule::ThrowExceptionFunction,
+                             unifiedUnreachable,
                              currentExceptionBlock, args.begin(), args.end(),
                              "", currentBlock);
         } else {
-          CallInst::Create(throwExceptionLLVM, args.begin(), args.end(), "",
-                           currentBlock);
+          CallInst::Create(JnjvmModule::ThrowExceptionFunction, args.begin(),
+                           args.end(), "", currentBlock);
           new UnreachableInst(currentBlock);
         }
         break;
@@ -1961,7 +1969,7 @@
         Value* obj = top();
 
         Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, obj,
-                                  constantJavaObjectNull,
+                                  JnjvmModule::JavaObjectNullConstant,
                                   "", currentBlock);
         
         BasicBlock* ifTrue = createBasicBlock("null checkcast");
@@ -1971,15 +1979,16 @@
         currentBlock = ifFalse;
         Value* clVar = 0;
         if (dcl) {
-          clVar = new LoadInst(dcl->llvmVar(compilingClass->isolate->module),
-                               "", ifFalse);
+          LLVMCommonClassInfo* LCI = module->getClassInfo(dcl);
+          clVar = LCI->getVar(this);
         } else {
           clVar = getResolvedClass(index, false);
         }
         std::vector<Value*> args;
         args.push_back(obj);
         args.push_back(clVar);
-        Value* call = CallInst::Create(instanceOfLLVM, args.begin(), args.end(),
+        Value* call = CallInst::Create(JnjvmModule::InstanceOfFunction,
+                                       args.begin(), args.end(),
                                        "", currentBlock);
         
         cmp = new ICmpInst(ICmpInst::ICMP_EQ, call,
@@ -1992,12 +2001,13 @@
         exArgs.push_back(obj);
         exArgs.push_back(clVar);
         if (currentExceptionBlock != endExceptionBlock) {
-          InvokeInst::Create(classCastExceptionLLVM, unifiedUnreachable,
+          InvokeInst::Create(JnjvmModule::ClassCastExceptionFunction,
+                             unifiedUnreachable,
                              currentExceptionBlock, exArgs.begin(),
                              exArgs.end(), "", ex);
         } else {
-          CallInst::Create(classCastExceptionLLVM, exArgs.begin(),
-                           exArgs.end(), "", ex);
+          CallInst::Create(JnjvmModule::ClassCastExceptionFunction,
+                           exArgs.begin(), exArgs.end(), "", ex);
           new UnreachableInst(ex);
         }
         
@@ -2012,16 +2022,16 @@
         
         Value* clVar = 0;
         if (dcl) {
-          clVar = new LoadInst(dcl->llvmVar(compilingClass->isolate->module),
-                               "", currentBlock);
+          LLVMCommonClassInfo* LCI = module->getClassInfo(dcl);
+          clVar = LCI->getVar(this);
         } else {
           clVar = getResolvedClass(index, false);
         }
         std::vector<Value*> args;
         args.push_back(pop());
         args.push_back(clVar);
-        push(CallInst::Create(instanceOfLLVM, args.begin(), args.end(), "",
-                              currentBlock),
+        push(CallInst::Create(JnjvmModule::InstanceOfFunction, args.begin(),
+                              args.end(), "", currentBlock),
              AssessorDesc::dInt);
         break;
       }
@@ -2030,10 +2040,11 @@
         Value* obj = pop();
 #ifdef SERVICE_VM
         if (ServiceDomain::isLockableDomain(compilingClass->isolate))
-        invoke(aquireObjectInSharedDomainLLVM, obj, "", currentBlock); 
+        invoke(JnjvmModule::AquireObjectInSharedDomainFunction, obj, "",
+               currentBlock); 
         else
 #endif
-        invoke(aquireObjectLLVM, obj, "", currentBlock); 
+        invoke(JnjvmModule::AquireObjectFunction, obj, "", currentBlock); 
         break;
       }
 
@@ -2041,10 +2052,11 @@
         Value* obj = pop();
 #ifdef SERVICE_VM
         if (ServiceDomain::isLockableDomain(compilingClass->isolate))
-        invoke(releaseObjectInSharedDomainLLVM, obj, "", currentBlock); 
+        invoke(JnjvmModule::ReleaseObjectInSharedDomainFunction, obj, "",
+               currentBlock); 
         else
 #endif
-        invoke(releaseObjectLLVM, obj, "", currentBlock); 
+        invoke(JnjvmModule::ReleaseObjectFunction, obj, "", currentBlock); 
         break;
       }
 
@@ -2060,13 +2072,12 @@
           vm->constructArray(className, compilingClass->classLoader);
         
         compilingClass->ctpInfo->loadClass(index);
-
-        Value* valCl = new LoadInst(dcl->llvmVar(vm->module), "", currentBlock);
+        
+        LLVMCommonClassInfo* LCI = module->getClassInfo(dcl);
+        Value* valCl = LCI->getVar(this);
         Value* args[dim + 2];
         args[0] = valCl;
-        mvm::jit::protectConstants();//->lock();
         args[1] = ConstantInt::get(Type::Int32Ty, dim);
-        mvm::jit::unprotectConstants();//->unlock();
 
         for (int cur = dim + 1; cur >= 2; --cur)
           args[cur] = pop();
@@ -2078,7 +2089,7 @@
 #ifdef MULTIPLE_VM
         Args.push_back(isolateLocal);
 #endif
-        push(invoke(multiCallNewLLVM, Args, "", currentBlock),
+        push(invoke(JnjvmModule::MultiCallNewFunction, Args, "", currentBlock),
              AssessorDesc::dRef);
         break;
       }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Fri May 16 09:49:12 2008
@@ -10,10 +10,6 @@
 #include <stdarg.h>
 #include <string.h>
 
-#include <llvm/BasicBlock.h>
-#include <llvm/GlobalVariable.h>
-#include <llvm/Instructions.h>
-#include <llvm/Module.h>
 #include <llvm/Type.h>
 #include "llvm/ExecutionEngine/GenericValue.h"
 
@@ -28,143 +24,11 @@
 #include "JavaThread.h"
 #include "JavaTypes.h"
 #include "Jnjvm.h"
+#include "JnjvmModule.h"
 
 using namespace jnjvm;
 using namespace llvm;
 
-Value* Class::staticVar(JavaJIT* jit) {
-
-#ifndef MULTIPLE_VM
-  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();
-      
-        isolate->protectModule->lock();
-        _staticVar = new GlobalVariable(JavaObject::llvmType, true,
-                                      GlobalValue::ExternalLinkage,
-                                      cons, "",
-                                      isolate->module);
-        isolate->protectModule->unlock();
-    }
-    release();
-  }
-
-  return new LoadInst(_staticVar, "", jit->currentBlock);
-
-#else
-  Value* var = llvmVar(jit->compilingClass->isolate->module);
-  Value* ld = new LoadInst(var, "", jit->currentBlock);
-  ld = jit->invoke(JavaJIT::initialisationCheckLLVM, ld, "", jit->currentBlock);
-  return jit->invoke(JavaJIT::getStaticInstanceLLVM, ld, jit->isolateLocal, 
-                     "", jit->currentBlock);
-#endif
-}
-
-GlobalVariable* CommonClass::llvmVar(llvm::Module* compilingModule) {
-  if (!_llvmVar) {
-    aquire();
-    if (!_llvmVar) {
-#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);
-        release();
-        return _llvmVar;
-      }
-#endif
-      
-      mvm::jit::protectConstants();//->lock();
-      Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)),
-                                  JavaJIT::JavaClassType);
-      mvm::jit::unprotectConstants();//->unlock();
-      
-      isolate->protectModule->lock();
-      _llvmVar = new GlobalVariable(JavaJIT::JavaClassType, true,
-                                    GlobalValue::ExternalLinkage,
-                                    cons, "",
-                                    isolate->module);
-      isolate->protectModule->unlock();
-    }
-    release();
-  }
-  return _llvmVar;
-}
-
-Value* Class::llvmVT(JavaJIT* jit) {
-  if (!_llvmVT) {
-    aquire();
-    if (!_llvmVT) {
-      mvm::jit::protectConstants();//->lock();
-      Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (virtualVT)),
-                                  JavaJIT::VTType);
-      mvm::jit::unprotectConstants();//->unlock();
-      
-      isolate->protectModule->lock();
-      _llvmVT = new GlobalVariable(JavaJIT::VTType, true,
-                                    GlobalValue::ExternalLinkage,
-                                    cons, "",
-                                    isolate->module);
-      isolate->protectModule->unlock();
-    }
-    release();
-  }
-  return new LoadInst(_llvmVT, "", jit->currentBlock);
-}
-
-Value* CommonClass::llvmDelegatee(llvm::Module* M, llvm::BasicBlock* BB) {
-#ifndef MULTIPLE_VM
-  if (!_llvmDelegatee) {
-    aquire();
-    if (!_llvmDelegatee) {
-      const Type* pty = JavaObject::llvmType;
-      
-      JavaObject* obj = getClassDelegatee();
-      mvm::jit::protectConstants();//->lock();
-      Constant* cons = 
-        ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(obj)),
-                                    pty);
-      mvm::jit::unprotectConstants();//->unlock();
-
-      isolate->protectModule->lock();
-      _llvmDelegatee = new GlobalVariable(pty, true,
-                                    GlobalValue::ExternalLinkage,
-                                    cons, "",
-                                    isolate->module);
-      isolate->protectModule->unlock();
-    }
-    release();
-  }
-  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;
-}
-
-ConstantInt* JavaObject::lockOffset() {
-  return mvm::jit::constantTwo;
-}
-
-ConstantInt* JavaArray::sizeOffset() {
-  return mvm::jit::constantOne; 
-}
-
-ConstantInt* JavaArray::elementsOffset() {
-  return mvm::jit::constantTwo; 
-}
-
 void JavaJIT::invokeOnceVoid(Jnjvm* vm, JavaObject* loader,
                              char const* className, char const* func,
                              char const* sign, int access, ...) {
@@ -187,202 +51,7 @@
   va_end(ap);
 }
 
-#ifndef WITHOUT_VTABLE
-VirtualTable* allocateVT(Class* cl, std::vector<JavaMethod*>::iterator meths) {
-  if (meths == cl->virtualMethods.end()) {
-    uint64 size = cl->virtualTableSize;
-    VirtualTable* VT = (VirtualTable*)malloc(size * sizeof(void*));
-    if (cl->super) {
-      Class* super = (Class*)cl->super;
-      memcpy(VT, super->virtualVT, cl->super->virtualTableSize * sizeof(void*));
-    } else {
-      memcpy(VT, JavaObject::VT, VT_SIZE);
-    }
-    return VT;
-  } else {
-    JavaMethod* meth = *meths;
-    JavaMethod* parent = cl->super? 
-      cl->super->lookupMethodDontThrow(meth->name, meth->type, false, true) : 0;
-
-    uint64_t offset = 0;
-    if (!parent) {
-      offset = cl->virtualTableSize++;
-      mvm::jit::protectConstants();
-      meth->offset = ConstantInt::get(Type::Int32Ty, offset);
-      mvm::jit::unprotectConstants();
-    } else {
-      offset = parent->offset->getZExtValue();
-      meth->offset = parent->offset;
-    }
-    VirtualTable* VT = allocateVT(cl, meths + 1);
-    Function* func = meth->llvmFunction;
-    ExecutionEngine* EE = mvm::jit::executionEngine;
-    ((void**)VT)[offset] = EE->getPointerToFunctionOrStub(func);
-    return VT;
-  }
-}
-#endif
-
-
-VirtualTable* JavaJIT::makeVT(Class* cl, bool stat) {
-  
-  VirtualTable* res = 0;
-#ifndef WITHOUT_VTABLE
-  if (stat) {
-#endif
-    res = (VirtualTable*)malloc(VT_SIZE);
-    memcpy(res, JavaObject::VT, VT_SIZE);
-#ifndef WITHOUT_VTABLE
-  } else {
-    res = allocateVT(cl, cl->virtualMethods.begin());
-  
-    if (!(cl->super)) {
-      // 12 = number of virtual methods in java/lang/Object (!!!)
-      uint32 size = 12 * sizeof(void*);
-#define COPY(CLASS) \
-    memcpy((void*)((unsigned)CLASS::VT + VT_SIZE), \
-           (void*)((unsigned)res + VT_SIZE), size);
-
-      COPY(ArrayUInt8)
-      COPY(ArraySInt8)
-      COPY(ArrayUInt16)
-      COPY(ArraySInt16)
-      COPY(ArrayUInt32)
-      COPY(ArraySInt32)
-      COPY(ArrayLong)
-      COPY(ArrayFloat)
-      COPY(ArrayDouble)
-      COPY(UTF8)
-      COPY(ArrayObject)
-
-#undef COPY
-    }
-  }
-#endif
- 
-#ifdef WITH_TRACER
-  const Type* type = stat ? cl->staticType : cl->virtualType;
-  std::vector<JavaField*> &fields = stat ? cl->staticFields : cl->virtualFields;
- 
-  cl->isolate->protectModule->lock();
-  Function* func = Function::Create(markAndTraceLLVMType,
-                                    GlobalValue::ExternalLinkage,
-                                    "markAndTraceObject",
-                                    cl->isolate->module);
-  cl->isolate->protectModule->unlock();
-
-  Constant* zero = mvm::jit::constantZero;
-  Argument* arg = func->arg_begin();
-  BasicBlock* block = BasicBlock::Create("", func);
-  llvm::Value* realArg = new BitCastInst(arg, type, "", block);
-
-#ifdef MULTIPLE_GC
-  Value* GC = ++func->arg_begin();
-  std::vector<Value*> Args;
-  Args.push_back(arg);
-  Args.push_back(GC);
-  if (stat || cl->super == 0) {
-    CallInst::Create(javaObjectTracerLLVM, Args.begin(), Args.end(), "", block);
-  } else {
-    CallInst::Create(((Class*)cl->super)->virtualTracer, Args.begin(),
-                     Args.end(), "", block);
-  }
-#else  
-  if (stat || cl->super == 0) {
-    CallInst::Create(javaObjectTracerLLVM, arg, "", block);
-  } else {
-    CallInst::Create(((Class*)cl->super)->virtualTracer, arg, "", block);
-  }
-#endif
-  
-  for (std::vector<JavaField*>::iterator i = fields.begin(), 
-            e = fields.end(); i!= e; ++i) {
-    if ((*i)->signature->funcs->doTrace) {
-      std::vector<Value*> args; //size = 2
-      args.push_back(zero);
-      args.push_back((*i)->offset);
-      Value* ptr = GetElementPtrInst::Create(realArg, args.begin(), args.end(), "",
-                                         block);
-      Value* val = new LoadInst(ptr, "", block);
-      Value* valCast = new BitCastInst(val, JavaObject::llvmType, "", block);
-#ifdef MULTIPLE_GC
-      std::vector<Value*> Args;
-      Args.push_back(valCast);
-      Args.push_back(GC);
-      CallInst::Create(markAndTraceLLVM, Args.begin(), Args.end(), "", block);
-#else
-      CallInst::Create(markAndTraceLLVM, valCast, "", block);
-#endif
-    }
-  }
-
-  ReturnInst::Create(block);
-
-  void* codePtr = mvm::jit::executionEngine->getPointerToGlobal(func);
-  ((void**)res)[VT_TRACER_OFFSET] = codePtr;
-  
-  if (!stat) {
-    cl->virtualTracer = func;
-    cl->codeVirtualTracer = mvm::Code::getCodeFromPointer(codePtr);
-  } else {
-    cl->staticTracer = func;
-    cl->codeStaticTracer = mvm::Code::getCodeFromPointer(codePtr);
-  }
-#endif
-  return res;
-}
-
-
-void JavaJIT::initField(JavaField* field) {
-  ConstantInt* offset = field->offset;
-  const TargetData* targetData = mvm::jit::executionEngine->getTargetData();
-  bool stat = isStatic(field->access);
-  const Type* clType = stat ? field->classDef->staticType :
-                              field->classDef->virtualType;
-  
-  const StructLayout* sl =
-    targetData->getStructLayout((StructType*)(clType->getContainedType(0)));
-  uint64 ptrOffset = sl->getElementOffset(offset->getZExtValue());
-  
-  field->ptrOffset = ptrOffset;
-}
-
-void JavaJIT::initField(JavaField* field, JavaObject* obj, uint64 val) {
-  initField(field);
-  
-  const AssessorDesc* funcs = field->signature->funcs;
-  if (funcs == AssessorDesc::dLong) {
-    ((sint64*)((uint64)obj + field->ptrOffset))[0] = val;
-  } else if (funcs == AssessorDesc::dInt) {
-    ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val;
-  } else if (funcs == AssessorDesc::dChar) {
-    ((uint16*)((uint64)obj + field->ptrOffset))[0] = (uint16)val;
-  } else if (funcs == AssessorDesc::dShort) {
-    ((sint16*)((uint64)obj + field->ptrOffset))[0] = (sint16)val;
-  } else if (funcs == AssessorDesc::dByte) {
-    ((sint8*)((uint64)obj + field->ptrOffset))[0] = (sint8)val;
-  } else if (funcs == AssessorDesc::dBool) {
-    ((uint8*)((uint64)obj + field->ptrOffset))[0] = (uint8)val;
-  } else {
-    // 0 value for everything else
-    ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val;
-  }
-}
-
-void JavaJIT::initField(JavaField* field, JavaObject* obj, JavaObject* val) {
-  initField(field);
-  ((JavaObject**)((uint64)obj + field->ptrOffset))[0] = val;
-}
-
-void JavaJIT::initField(JavaField* field, JavaObject* obj, double val) {
-  initField(field);
-  ((double*)((uint64)obj + field->ptrOffset))[0] = val;
-}
 
-void JavaJIT::initField(JavaField* field, JavaObject* obj, float val) {
-  initField(field);
-  ((float*)((uint64)obj + field->ptrOffset))[0] = val;
-}
 
 JavaObject* Class::operator()(Jnjvm* vm) {
   if (!isReady()) 
@@ -466,7 +135,8 @@
   if (stat) obj = classDef->staticInstance();
   void* ptr = (void*)((uint64)obj + ptrOffset);
   
-  if (signature->funcs->llvmType == JavaObject::llvmType) {
+  if (signature->funcs == AssessorDesc::dRef || 
+      signature->funcs == AssessorDesc::dTab) {
     ((JavaObject**)ptr)[0] = val;
   } else {
     JavaThread::get()->isolate->illegalArgumentException("wrong type in field assignment");
@@ -518,7 +188,7 @@
     GenericValue gv;
     gv.FloatVal = ((float*)ptr)[0];
     return gv;
-  } else if (type == JavaObject::llvmType) {
+  } else if (type == JnjvmModule::JavaObjectType) {
     GenericValue gv(((JavaObject**)ptr)[0]);
     return gv;
   } else {
@@ -817,137 +487,3 @@
   JavaField * field = this;
   return (*field)(0, val);
 }
-
-Function* Signdef::createFunctionCallBuf(bool virt) {
-  
-  ConstantInt* CI = mvm::jit::constantZero;
-  std::vector<Value*> Args;
-
-  isolate->protectModule->lock();
-  Function* res = Function::Create(virt ? virtualBufType : staticBufType,
-                                      GlobalValue::ExternalLinkage,
-                                      this->printString(),
-                                      isolate->module);
-  isolate->protectModule->unlock();
-  
-  BasicBlock* currentBlock = BasicBlock::Create("enter", res);
-  Function::arg_iterator i = res->arg_begin();
-  Value *obj, *ptr, *func;
-#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
-  Value* vm = i;
-#endif
-  ++i;
-  func = i;
-  ++i;
-  if (virt) {
-    obj = i;
-    ++i;
-    Args.push_back(obj);
-  }
-  ptr = i;
-
-  for (std::vector<Typedef*>::iterator i = args.begin(), 
-            e = args.end(); i!= e; ++i) {
-  
-    const AssessorDesc* funcs = (*i)->funcs;
-    ptr = GetElementPtrInst::Create(ptr, CI, "", currentBlock);
-    Value* val = new BitCastInst(ptr, funcs->llvmTypePtr, "", currentBlock);
-    Value* arg = new LoadInst(val, "", currentBlock);
-    Args.push_back(arg);
-    if (funcs == AssessorDesc::dLong || funcs == AssessorDesc::dDouble) {
-      CI = mvm::jit::constantTwo;
-    } else {
-      CI = mvm::jit::constantOne;
-    }
-  }
-
-#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
-  Args.push_back(vm);
-#endif
-
-  Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock);
-  if (ret->funcs != AssessorDesc::dVoid)
-    ReturnInst::Create(val, currentBlock);
-  else
-    ReturnInst::Create(currentBlock);
-  
-  return res;
-}
-
-Function* Signdef::createFunctionCallAP(bool virt) {
-  
-  std::vector<Value*> Args;
-
-  isolate->protectModule->lock();
-  Function* res = Function::Create(virt ? virtualBufType : staticBufType,
-                                      GlobalValue::ExternalLinkage,
-                                      this->printString(),
-                                      isolate->module);
-  isolate->protectModule->unlock();
-  
-  BasicBlock* currentBlock = BasicBlock::Create("enter", res);
-  Function::arg_iterator i = res->arg_begin();
-  Value *obj, *ap, *func;
-#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
-  Value* vm = i;
-#endif
-  ++i;
-  func = i;
-  ++i;
-  if (virt) {
-    obj = i;
-    Args.push_back(obj);
-    ++i;
-  }
-  ap = i;
-
-  for (std::vector<Typedef*>::iterator i = args.begin(), 
-            e = args.end(); i!= e; i++) {
-
-    Args.push_back(new VAArgInst(ap, (*i)->funcs->llvmType, "", currentBlock));
-  }
-
-#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
-  Args.push_back(vm);
-#endif
-
-  Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock);
-  if (ret->funcs != AssessorDesc::dVoid)
-    ReturnInst::Create(val, currentBlock);
-  else
-    ReturnInst::Create(currentBlock);
-  
-  return res;
-}
-
-void* Signdef::staticCallBuf() {
-  if (!_staticCallBuf) {
-    Function* statBuf = createFunctionCallBuf(false);
-    _staticCallBuf = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(statBuf);
-  }
-  return _staticCallBuf;
-}
-
-void* Signdef::virtualCallBuf() {
-  if (!_virtualCallBuf) {
-    Function* virtBuf = createFunctionCallBuf(true);
-    _virtualCallBuf = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(virtBuf);
-  }
-  return _virtualCallBuf;
-}
-
-void* Signdef::staticCallAP() {
-  if (!_staticCallAP) {
-    Function* statAP = createFunctionCallAP(false);
-    _staticCallAP = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(statAP);
-  }
-  return _staticCallAP;
-}
-
-void* Signdef::virtualCallAP() {
-  if (!_virtualCallAP) {
-    Function* virtAP = createFunctionCallAP(true);
-    _virtualCallAP = (mvm::Code*)mvm::jit::executionEngine->getPointerToGlobal(virtAP);
-  }
-  return _virtualCallAP;
-}

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaObject.h Fri May 16 09:49:12 2008
@@ -12,8 +12,6 @@
 
 #include <vector>
 
-#include "llvm/Constants.h"
-#include "llvm/Type.h"
 #include "llvm/ExecutionEngine/GenericValue.h"
 
 #include "mvm/Object.h"
@@ -70,7 +68,6 @@
   LockObj* lockObj;
 
   static mvm::Lock* globalLock;
-  static const llvm::Type* llvmType;
   
   virtual void print(mvm::PrintBuffer* buf) const;
   virtual void TRACER;
@@ -95,9 +92,6 @@
     else return this->classOf->isAssignableFrom(cl);
   }
 
-  static llvm::ConstantInt* classOffset();
-  static llvm::ConstantInt* lockOffset();
-
 #ifdef SIGSEGV_THROW_NULL
   #define verifyNull(obj) {}
 #else

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Fri May 16 09:49:12 2008
@@ -8,8 +8,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Function.h"
-
 #include "mvm/JIT.h"
 #include "mvm/Threads/Thread.h"
 
@@ -22,6 +20,7 @@
 #include "JavaThread.h"
 #include "JavaTypes.h"
 #include "Jnjvm.h"
+#include "JnjvmModule.h"
 #include "LockedMap.h"
 
 #ifdef SERVICE_VM
@@ -30,58 +29,6 @@
 
 using namespace jnjvm;
 
-#ifdef WITH_TRACER
-llvm::Function* JavaJIT::markAndTraceLLVM = 0;
-#endif
-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::negativeArraySizeExceptionLLVM = 0;
-llvm::Function* JavaJIT::outOfMemoryErrorLLVM = 0;
-llvm::Function* JavaJIT::javaObjectAllocateLLVM = 0;
-llvm::Function* JavaJIT::javaObjectTracerLLVM = 0;
-llvm::Function* JavaJIT::virtualLookupLLVM = 0;
-llvm::Function* JavaJIT::fieldLookupLLVM = 0;
-#ifndef WITHOUT_VTABLE
-llvm::Function* JavaJIT::vtableLookupLLVM = 0;
-#endif
-llvm::Function* JavaJIT::printExecutionLLVM = 0;
-llvm::Function* JavaJIT::printMethodStartLLVM = 0;
-llvm::Function* JavaJIT::printMethodEndLLVM = 0;
-llvm::Function* JavaJIT::jniProceedPendingExceptionLLVM = 0;
-llvm::Function* JavaJIT::initialisationCheckLLVM = 0;
-llvm::Function* JavaJIT::forceInitialisationCheckLLVM = 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;
-llvm::Function* JavaJIT::getVTLLVM = 0;
-llvm::Function* JavaJIT::getClassLLVM = 0;
-llvm::Function* JavaJIT::getVTFromClassLLVM = 0;
-llvm::Function* JavaJIT::getObjectSizeFromClassLLVM = 0;
-
-#ifdef MULTIPLE_GC
-llvm::Function* JavaJIT::getCollectorLLVM;
-#endif
-
-#ifdef SERVICE_VM
-llvm::Function* JavaJIT::aquireObjectInSharedDomainLLVM = 0;
-llvm::Function* JavaJIT::releaseObjectInSharedDomainLLVM = 0;
-#endif
-
-const llvm::Type* JavaJIT::VTType;
-
 extern "C" JavaString* runtimeUTF8ToStr(const UTF8* val) {
   Jnjvm* vm = JavaThread::get()->isolate;
   return vm->UTF8ToStr(val);
@@ -283,9 +230,9 @@
     // Arg, it should have been an invoke interface.... Perform the lookup
     // on the object class and do not update offset.
     dmeth = obj->classOf->lookupMethod(utf8, sign->keyName, false, true);
-    return (uint32)(dmeth->offset->getZExtValue());
+    return dmeth->offset;
   }
-  *offset = (uint32)(dmeth->offset->getZExtValue());
+  *offset = dmeth->offset;
   return *offset;
 }
 #endif

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Fri May 16 09:49:12 2008
@@ -22,6 +22,7 @@
 #include "JavaObject.h"
 #include "JavaThread.h"
 #include "Jnjvm.h"
+#include "JnjvmModule.h"
 #include "JnjvmModuleProvider.h"
 
 using namespace jnjvm;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.cpp Fri May 16 09:49:12 2008
@@ -9,8 +9,9 @@
 
 #include <vector>
 
+#include "llvm/Constant.h"
 #include "llvm/DerivedTypes.h"
-#include "llvm/Function.h"
+#include "llvm/Type.h"
 
 #include "mvm/JIT.h"
 
@@ -22,6 +23,7 @@
 #include "JavaThread.h"
 #include "JavaTypes.h"
 #include "Jnjvm.h"
+#include "JnjvmModule.h"
 
 
 using namespace jnjvm;
@@ -138,12 +140,12 @@
                                    JavaArray::ofDouble, mvm::jit::constantEight,
                                    (arrayCtor_t)ArrayDouble::acons);
   dTab = AssessorDesc::allocate(true, I_TAB, sizeof(void*), 1, "array", "array",
-                                vm, JavaObject::llvmType, 0, 0,
+                                vm, JnjvmModule::JavaObjectType, 0, 0,
                                 mvm::jit::constantPtrSize,
                                 (arrayCtor_t)ArrayObject::acons);
   dRef = AssessorDesc::allocate(true, I_REF, sizeof(void*), 1, "reference",
-                                "reference", vm, JavaObject::llvmType, 0, 0,
-                                mvm::jit::constantPtrSize,
+                                "reference", vm, JnjvmModule::JavaObjectType,
+                                0, 0, mvm::jit::constantPtrSize,
                                 (arrayCtor_t)ArrayObject::acons);
   
   mvm::Object::pushRoot((mvm::Object*)dParg);
@@ -468,77 +470,6 @@
   buf->write(">");
 }
 
-const llvm::FunctionType* Signdef::createVirtualType(
-            const std::vector<Typedef*>* args, Typedef* ret) {
-  std::vector<const llvm::Type*> llvmArgs;
-  unsigned int size = args->size();
-
-  llvmArgs.push_back(JavaObject::llvmType);
-
-  for (uint32 i = 0; i < size; ++i) {
-    llvmArgs.push_back(args->at(i)->funcs->llvmType);
-  }
-
-#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
-  llvmArgs.push_back(mvm::jit::ptrType); // domain
-#endif
-
-  mvm::jit::protectTypes();//->lock();
-  llvm::FunctionType* res =  llvm::FunctionType::get(ret->funcs->llvmType,
-                                                     llvmArgs, false);
-  mvm::jit::unprotectTypes();//->unlock();
-
-  return res;
-
-}
-
-const llvm::FunctionType* Signdef::createStaticType(
-            const std::vector<Typedef*>* args, Typedef* ret) {
-  std::vector<const llvm::Type*> llvmArgs;
-  unsigned int size = args->size();
-
-
-  for (uint32 i = 0; i < size; ++i) {
-    llvmArgs.push_back(args->at(i)->funcs->llvmType);
-  }
-
-#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
-  llvmArgs.push_back(mvm::jit::ptrType); // domain
-#endif
-  
-  mvm::jit::protectTypes();//->lock();
-  llvm::FunctionType* res =  llvm::FunctionType::get(ret->funcs->llvmType,
-                                                     llvmArgs, false);
-  mvm::jit::unprotectTypes();//->unlock();
-
-  return res;
-}
-
-const llvm::FunctionType* Signdef::createNativeType(
-            const std::vector<Typedef*>* args, Typedef* ret) {
-  std::vector<const llvm::Type*> llvmArgs;
-  unsigned int size = args->size();
-
-  llvmArgs.push_back(mvm::jit::ptrType); // JNIEnv
-  llvmArgs.push_back(JavaObject::llvmType); // Class
-
-  for (uint32 i = 0; i < size; ++i) {
-    llvmArgs.push_back(args->at(i)->funcs->llvmType);
-  }
-
-#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
-  llvmArgs.push_back(mvm::jit::ptrType); // domain
-#endif
-  
-
-  mvm::jit::protectTypes();//->lock();
-  llvm::FunctionType* res =  llvm::FunctionType::get(ret->funcs->llvmType,
-                                                     llvmArgs, false);
-  mvm::jit::unprotectTypes();//->unlock();
-
-  return res;
-}
-
 void Signdef::printWithSign(CommonClass* cl, const UTF8* name,
                             mvm::PrintBuffer* buf) {
   ret->tPrintBuf(buf);
@@ -591,28 +522,6 @@
   res->_staticCallBuf = 0;
   res->_virtualCallAP = 0;
   res->_staticCallAP = 0;
-  res->staticType = Signdef::createStaticType(&buf, res->ret);
-  res->virtualType = Signdef::createVirtualType(&buf, res->ret);
-  res->nativeType = Signdef::createNativeType(&buf, res->ret);
-  mvm::jit::protectTypes();//->lock();
-  res->staticTypePtr  = llvm::PointerType::getUnqual(res->staticType);
-  res->virtualTypePtr = llvm::PointerType::getUnqual(res->virtualType);
-  res->nativeTypePtr  = llvm::PointerType::getUnqual(res->nativeType);
-  
-  std::vector<const llvm::Type*> Args;
-  Args.push_back(mvm::jit::ptrType); // vm
-  Args.push_back(res->staticTypePtr);
-  Args.push_back(llvm::PointerType::getUnqual(llvm::Type::Int32Ty));
-  res->staticBufType = llvm::FunctionType::get(res->ret->funcs->llvmType, Args, false);
-  
-  std::vector<const llvm::Type*> Args2;
-  Args2.push_back(mvm::jit::ptrType); // vm
-  Args2.push_back(res->virtualTypePtr);
-  Args2.push_back(JavaObject::llvmType);
-  Args2.push_back(llvm::PointerType::getUnqual(llvm::Type::Int32Ty));
-  res->virtualBufType = llvm::FunctionType::get(res->ret->funcs->llvmType, Args2, false);
-
-  mvm::jit::unprotectTypes();//->unlock();
   return res;
   
 }
@@ -638,3 +547,35 @@
   }
 
 }
+
+void* Signdef::staticCallBuf() {
+  if (!_staticCallBuf) {
+    LLVMSignatureInfo* LSI = isolate->module->getSignatureInfo(this);
+    LSI->getStaticBuf();
+  }
+  return _staticCallBuf;
+}
+
+void* Signdef::virtualCallBuf() {
+  if (!_virtualCallBuf) {
+    LLVMSignatureInfo* LSI = isolate->module->getSignatureInfo(this);
+    LSI->getVirtualBuf();
+  }
+  return _virtualCallBuf;
+}
+
+void* Signdef::staticCallAP() {
+  if (!_staticCallAP) {
+    LLVMSignatureInfo* LSI = isolate->module->getSignatureInfo(this);
+    LSI->getStaticAP();
+  }
+  return _staticCallAP;
+}
+
+void* Signdef::virtualCallAP() {
+  if (!_virtualCallAP) {
+    LLVMSignatureInfo* LSI = isolate->module->getSignatureInfo(this);
+    LSI->getVirtualAP();
+  }
+  return _virtualCallAP;
+}

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h Fri May 16 09:49:12 2008
@@ -10,8 +10,9 @@
 #ifndef JNJVM_JAVA_TYPES_H
 #define JNJVM_JAVA_TYPES_H
 
+#include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
-#include "llvm/Function.h"
+#include "llvm/Type.h"
 
 #include "mvm/Object.h"
 
@@ -135,14 +136,6 @@
   static VirtualTable *VT;
   std::vector<Typedef*> args;
   Typedef* ret;
-  const llvm::FunctionType* staticType;
-  const llvm::FunctionType* virtualType;
-  const llvm::FunctionType* nativeType;
-  const llvm::FunctionType* virtualBufType;
-  const llvm::FunctionType* staticBufType;
-  const llvm::PointerType* staticTypePtr;
-  const llvm::PointerType* virtualTypePtr;
-  const llvm::PointerType* nativeTypePtr;
   mvm::Code* _staticCallBuf;
   mvm::Code* _virtualCallBuf;
   mvm::Code* _staticCallAP;
@@ -152,20 +145,6 @@
   virtual void print(mvm::PrintBuffer* buf) const;
   virtual void TRACER;
 
-  static const llvm::FunctionType* createVirtualType(
-                        const std::vector<Typedef*>*, Typedef*);
-  
-  static const llvm::FunctionType* createStaticType(
-                        const std::vector<Typedef*>*, Typedef*);
-  
-  static const llvm::FunctionType* createNativeType(
-                        const std::vector<Typedef*>*, Typedef*);
-  
-  llvm::Function* createFunctionCallBuf(bool virt);
-  llvm::Function* createFunctionCallAP(bool virt);
-
-  
-
   void printWithSign(CommonClass* cl, const UTF8* name, mvm::PrintBuffer* buf);
   unsigned int nbInWithThis(unsigned int flag);
   static Signdef* signDup(const UTF8* name, Jnjvm* vm);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaUpcalls.cpp Fri May 16 09:49:12 2008
@@ -9,8 +9,7 @@
 
 #include <vector>
 
-#include "llvm/DerivedTypes.h"
-#include "llvm/ExecutionEngine/GenericValue.h"
+#include "llvm/Function.h"
 
 #include "mvm/JIT.h"
 
@@ -23,6 +22,7 @@
 #include "JavaTypes.h"
 #include "JavaUpcalls.h"
 #include "Jnjvm.h"
+#include "JnjvmModule.h"
 
 #define COMPILE_METHODS(cl) \
   for (std::vector<JavaMethod*>::iterator i = cl->virtualMethods.begin(), \
@@ -219,15 +219,17 @@
   JavaMethod* internString = UPCALL_METHOD(vm, "java/lang/VMString", "intern", "(Ljava/lang/String;)Ljava/lang/String;", ACC_STATIC);
   // Create intern
   {
-    internString->llvmFunction->setName("internString");
-    internString->llvmFunction->setLinkage(llvm::GlobalValue::ExternalLinkage);
+    llvm::Function* func = vm->module->getMethodInfo(internString)->getMethod();
+    func->setName("internString");
+    func->setLinkage(llvm::GlobalValue::ExternalLinkage);
   }
   
   JavaMethod* isArray = UPCALL_METHOD(vm, "java/lang/Class", "isArray", "()Z", ACC_VIRTUAL);
   // Create intern
   {
-    isArray->llvmFunction->setName("isArray");
-    isArray->llvmFunction->setLinkage(llvm::GlobalValue::ExternalLinkage);
+    llvm::Function* func = vm->module->getMethodInfo(isArray)->getMethod();
+    func->setName("isArray");
+    func->setLinkage(llvm::GlobalValue::ExternalLinkage);
   }
 
   ClasspathThread::initialise(vm);
@@ -244,20 +246,23 @@
   
   JavaMethod* getCallingClass = UPCALL_METHOD(vm, "gnu/classpath/VMStackWalker", "getCallingClass", "()Ljava/lang/Class;", ACC_STATIC);
   {
-    getCallingClass->llvmFunction->setName("getCallingClass");
-    getCallingClass->llvmFunction->setLinkage(llvm::GlobalValue::ExternalLinkage);
+    llvm::Function* func = vm->module->getMethodInfo(getCallingClass)->getMethod();
+    func->setName("getCallingClass");
+    func->setLinkage(llvm::GlobalValue::ExternalLinkage);
   }
   
   JavaMethod* getCallingClassLoader = UPCALL_METHOD(vm, "gnu/classpath/VMStackWalker", "getCallingClassLoader", "()Ljava/lang/ClassLoader;", ACC_STATIC);
   {
-    getCallingClassLoader->llvmFunction->setName("getCallingClassLoader");
-    getCallingClassLoader->llvmFunction->setLinkage(llvm::GlobalValue::ExternalLinkage);
+    llvm::Function* func = vm->module->getMethodInfo(getCallingClassLoader)->getMethod();
+    func->setName("getCallingClassLoader");
+    func->setLinkage(llvm::GlobalValue::ExternalLinkage);
   }
   
   JavaMethod* postProperties = UPCALL_METHOD(vm, "gnu/classpath/VMSystemProperties", "postInit", "(Ljava/util/Properties;)V", ACC_STATIC);
   {
-    postProperties->llvmFunction->setName("propertiesPostInit");
-    postProperties->llvmFunction->setLinkage(llvm::GlobalValue::ExternalLinkage);
+    llvm::Function* func = vm->module->getMethodInfo(postProperties)->getMethod();
+    func->setName("propertiesPostInit");
+    func->setLinkage(llvm::GlobalValue::ExternalLinkage);
   }
 }
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.cpp Fri May 16 09:49:12 2008
@@ -28,6 +28,7 @@
 #include "JavaTypes.h"
 #include "JavaUpcalls.h"
 #include "Jnjvm.h"
+#include "JnjvmModule.h"
 #include "JnjvmModuleProvider.h"
 #include "LockedMap.h"
 #include "Reader.h"
@@ -323,6 +324,8 @@
       if (cl->super) {
         cl->super->initialiseClass();
       }
+
+      module->resolveStaticClass((Class*)cl);
       
       *status = inClinit;
       JavaMethod* meth = cl->lookupMethodDontThrow(clinitName, clinitType, true,
@@ -390,12 +393,13 @@
         cl->status = readed;
         cl->release();
         loadParents((Class*)cl);
-        cl->aquire();
+        cl->aquire(); 
         cl->status = prepared;
-        ((Class*)cl)->resolveFields();
+        module->resolveVirtualClass((Class*)cl);
         cl->status = resolved;
       }
       cl->release();
+      cl->broadcastClass();
     } else {
       while (status < resolved) {
         cl->waitClass();
@@ -768,7 +772,6 @@
   FieldCmp CC(name, cl, type, 0);
   JavaField* f = loadedFields->lookupOrCreate(CC, this, fieldDup); 
   f->access = access;
-  f->offset = 0;
   return f;
 }
 
@@ -787,18 +790,6 @@
   method->signature = (Signdef*)vm->constructType(method->type);
   method->code = 0;
   method->access = cmp.access;
-  if (isStatic(method->access)) {
-    method->llvmType =method->signature->staticType;
-  } else {
-    method->llvmType = method->signature->virtualType;
-  }
-  method->classDef->isolate->protectModule->lock();
-  method->llvmFunction = 
-    llvm::Function::Create(method->llvmType, llvm::GlobalValue::GhostLinkage,
-                           method->printString(),
-                           method->classDef->isolate->module);
-  method->classDef->isolate->protectModule->unlock();
-  method->classDef->isolate->functionDefs->hash(method->llvmFunction, method);
   return method;
 }
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Jnjvm.h Fri May 16 09:49:12 2008
@@ -39,6 +39,7 @@
 class JavaMethod;
 class JavaObject;
 class JavaString;
+class JnjvmModule;
 class JnjvmModuleProvider;
 class Reader;
 class Typedef;
@@ -261,7 +262,7 @@
 
   
   mvm::Lock* protectModule;
-  llvm::Module* module;
+  JnjvmModule* module;
   JnjvmModuleProvider* TheModuleProvider;
   FunctionMap* functions;
   FunctionDefMap* functionDefs;

Added: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=51189&view=auto

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (added)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Fri May 16 09:49:12 2008
@@ -0,0 +1,1022 @@
+//===--------- JnjvmModule.cpp - Definition of a Jnjvm module -------------===//
+//
+//                              JnJVM
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/CallingConv.h"
+#include "llvm/ParameterAttributes.h"
+#include "llvm/Support/MutexGuard.h"
+
+
+#include "mvm/JIT.h"
+
+#include "JavaJIT.h"
+#include "JavaTypes.h"
+#include "Jnjvm.h"
+#include "JnjvmModule.h"
+#include "LockedMap.h"
+
+
+using namespace jnjvm;
+using namespace llvm;
+
+
+#ifdef WITH_TRACER
+const llvm::FunctionType* JnjvmModule::MarkAndTraceType = 0;
+#endif
+
+const llvm::Type* JnjvmModule::JavaObjectType = 0;
+const llvm::Type* JnjvmModule::JavaArrayType = 0;
+const llvm::Type* JnjvmModule::JavaArrayUInt8Type = 0;
+const llvm::Type* JnjvmModule::JavaArraySInt8Type = 0;
+const llvm::Type* JnjvmModule::JavaArrayUInt16Type = 0;
+const llvm::Type* JnjvmModule::JavaArraySInt16Type = 0;
+const llvm::Type* JnjvmModule::JavaArrayUInt32Type = 0;
+const llvm::Type* JnjvmModule::JavaArraySInt32Type = 0;
+const llvm::Type* JnjvmModule::JavaArrayFloatType = 0;
+const llvm::Type* JnjvmModule::JavaArrayDoubleType = 0;
+const llvm::Type* JnjvmModule::JavaArrayLongType = 0;
+const llvm::Type* JnjvmModule::JavaArrayObjectType = 0;
+const llvm::Type* JnjvmModule::CacheNodeType = 0;
+const llvm::Type* JnjvmModule::EnveloppeType = 0;
+
+llvm::Constant*       JnjvmModule::JavaObjectNullConstant;
+llvm::Constant*       JnjvmModule::UTF8NullConstant;
+llvm::Constant*       JnjvmModule::JavaClassNullConstant;
+llvm::Constant*       JnjvmModule::MaxArraySizeConstant;
+llvm::Constant*       JnjvmModule::JavaObjectSizeConstant;
+llvm::GlobalVariable* JnjvmModule::JavaObjectVirtualTableGV;
+llvm::GlobalVariable* JnjvmModule::ArrayObjectVirtualTableGV;
+llvm::ConstantInt*    JnjvmModule::OffsetObjectSizeInClassConstant;
+llvm::ConstantInt*    JnjvmModule::OffsetVTInClassConstant;
+const llvm::Type*     JnjvmModule::JavaClassType;
+const llvm::Type*     JnjvmModule::VTType;
+llvm::ConstantInt*    JnjvmModule::JavaArrayElementsOffsetConstant;
+llvm::ConstantInt*    JnjvmModule::JavaArraySizeOffsetConstant;
+llvm::ConstantInt*    JnjvmModule::JavaObjectLockOffsetConstant;
+llvm::ConstantInt*    JnjvmModule::JavaObjectClassOffsetConstant;
+
+#ifdef WITH_TRACER
+llvm::Function* JnjvmModule::MarkAndTraceFunction = 0;
+#endif
+llvm::Function* JnjvmModule::GetSJLJBufferFunction = 0;
+llvm::Function* JnjvmModule::ThrowExceptionFunction = 0;
+llvm::Function* JnjvmModule::GetExceptionFunction = 0;
+llvm::Function* JnjvmModule::GetJavaExceptionFunction = 0;
+llvm::Function* JnjvmModule::ClearExceptionFunction = 0;
+llvm::Function* JnjvmModule::CompareExceptionFunction = 0;
+llvm::Function* JnjvmModule::NullPointerExceptionFunction = 0;
+llvm::Function* JnjvmModule::ClassCastExceptionFunction = 0;
+llvm::Function* JnjvmModule::IndexOutOfBoundsExceptionFunction = 0;
+llvm::Function* JnjvmModule::NegativeArraySizeExceptionFunction = 0;
+llvm::Function* JnjvmModule::OutOfMemoryErrorFunction = 0;
+llvm::Function* JnjvmModule::JavaObjectAllocateFunction = 0;
+llvm::Function* JnjvmModule::JavaObjectTracerFunction = 0;
+llvm::Function* JnjvmModule::InterfaceLookupFunction = 0;
+llvm::Function* JnjvmModule::FieldLookupFunction = 0;
+#ifndef WITHOUT_VTABLE
+llvm::Function* JnjvmModule::VirtualLookupFunction = 0;
+#endif
+llvm::Function* JnjvmModule::PrintExecutionFunction = 0;
+llvm::Function* JnjvmModule::PrintMethodStartFunction = 0;
+llvm::Function* JnjvmModule::PrintMethodEndFunction = 0;
+llvm::Function* JnjvmModule::JniProceedPendingExceptionFunction = 0;
+llvm::Function* JnjvmModule::InitialisationCheckFunction = 0;
+llvm::Function* JnjvmModule::ForceInitialisationCheckFunction = 0;
+llvm::Function* JnjvmModule::ClassLookupFunction = 0;
+llvm::Function* JnjvmModule::InstanceOfFunction = 0;
+llvm::Function* JnjvmModule::AquireObjectFunction = 0;
+llvm::Function* JnjvmModule::ReleaseObjectFunction = 0;
+llvm::Function* JnjvmModule::MultiCallNewFunction = 0;
+llvm::Function* JnjvmModule::RuntimeUTF8ToStrFunction = 0;
+llvm::Function* JnjvmModule::GetStaticInstanceFunction = 0;
+llvm::Function* JnjvmModule::GetClassDelegateeFunction = 0;
+llvm::Function* JnjvmModule::ArrayLengthFunction = 0;
+llvm::Function* JnjvmModule::GetVTFunction = 0;
+llvm::Function* JnjvmModule::GetClassFunction = 0;
+llvm::Function* JnjvmModule::GetVTFromClassFunction = 0;
+llvm::Function* JnjvmModule::GetObjectSizeFromClassFunction = 0;
+
+#ifdef MULTIPLE_GC
+llvm::Function* JnjvmModule::FetCollectorFunction = 0;
+#endif
+
+#ifdef SERVICE_VM
+llvm::Function* JnjvmModule::AquireObjectInSharedDomainFunction = 0;
+llvm::Function* JnjvmModule::ReleaseObjectInSharedDomainFunction = 0;
+llvm::Function* JnjvmModule::ServiceCallStartFunction = 0;
+llvm::Function* JnjvmModule::ServiceCallStopFunction = 0;
+#endif
+
+
+
+Value* LLVMCommonClassInfo::getVar(JavaJIT* jit) {
+  if (!varGV) {
+#ifdef MULTIPLE_VM
+    if (jit->compilingClass->isolate->module == Jnjvm::bootstrapVM->module &&
+        isArray && classDef->isolate != Jnjvm::bootstrapVM) {
+      // We know the array class can belong to bootstrap
+      varGV = Jnjvm::bootstrapVM->constructArray(this->name, 0)->llvmVar(compilingModule);
+    }
+#endif
+      
+    Constant* cons = 
+      ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+                                                 uint64_t (classDef)),
+                                JnjvmModule::JavaClassType);
+      
+    varGV = new GlobalVariable(JnjvmModule::JavaClassType, true,
+                               GlobalValue::ExternalLinkage,
+                               cons, "",
+                               classDef->isolate->module);
+  }
+  return new LoadInst(varGV, "", jit->currentBlock);
+}
+
+Value* LLVMCommonClassInfo::getDelegatee(JavaJIT* jit) {
+#ifndef MULTIPLE_VM
+  if (!delegateeGV) {
+    JavaObject* obj = classDef->getClassDelegatee();
+    Constant* cons = 
+      ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(obj)),
+                                JnjvmModule::JavaObjectType);
+    delegateeGV = new GlobalVariable(JnjvmModule::JavaObjectType, true,
+                                    GlobalValue::ExternalLinkage,
+                                    cons, "",
+                                    classDef->isolate->module);
+  }
+  return new LoadInst(delegateeGV, "", jit->currentBlock);
+#else
+  Value* ld = llvmVar(jit);
+  return llvm::CallInst::Create(JnjvmModule::getClassDelegateeLLVM, ld, "",
+                                jit->currentBlock);
+#endif
+}
+
+#ifndef WITHOUT_VTABLE
+VirtualTable* JnjvmModule::allocateVT(Class* cl,
+                                    std::vector<JavaMethod*>::iterator meths) {
+  if (meths == cl->virtualMethods.end()) {
+    uint64 size = cl->virtualTableSize;
+    VirtualTable* VT = (VirtualTable*)malloc(size * sizeof(void*));
+    if (cl->super) {
+      Class* super = (Class*)cl->super;
+      memcpy(VT, super->virtualVT, cl->super->virtualTableSize * sizeof(void*));
+    } else {
+      memcpy(VT, JavaObject::VT, VT_SIZE);
+    }
+    return VT;
+  } else {
+    JavaMethod* meth = *meths;
+    JavaMethod* parent = cl->super? 
+      cl->super->lookupMethodDontThrow(meth->name, meth->type, false, true) : 0;
+
+    uint64_t offset = 0;
+    if (!parent) {
+      offset = cl->virtualTableSize++;
+      meth->offset = offset;
+    } else {
+      offset = parent->offset;
+      meth->offset = parent->offset;
+    }
+    VirtualTable* VT = allocateVT(cl, meths + 1);
+    LLVMMethodInfo* LMI = getMethodInfo(meth);
+    Function* func = LMI->getMethod();
+    ExecutionEngine* EE = mvm::jit::executionEngine;
+    ((void**)VT)[offset] = EE->getPointerToFunctionOrStub(func);
+    return VT;
+  }
+}
+#endif
+
+
+VirtualTable* JnjvmModule::makeVT(Class* cl, bool stat) {
+  
+  VirtualTable* res = 0;
+#ifndef WITHOUT_VTABLE
+  if (stat) {
+#endif
+    res = (VirtualTable*)malloc(VT_SIZE);
+    memcpy(res, JavaObject::VT, VT_SIZE);
+#ifndef WITHOUT_VTABLE
+  } else {
+    res = allocateVT(cl, cl->virtualMethods.begin());
+  
+    if (!(cl->super)) {
+      // 12 = number of virtual methods in java/lang/Object (!!!)
+      uint32 size = 12 * sizeof(void*);
+#define COPY(CLASS) \
+    memcpy((void*)((unsigned)CLASS::VT + VT_SIZE), \
+           (void*)((unsigned)res + VT_SIZE), size);
+
+      COPY(ArrayUInt8)
+      COPY(ArraySInt8)
+      COPY(ArrayUInt16)
+      COPY(ArraySInt16)
+      COPY(ArrayUInt32)
+      COPY(ArraySInt32)
+      COPY(ArrayLong)
+      COPY(ArrayFloat)
+      COPY(ArrayDouble)
+      COPY(UTF8)
+      COPY(ArrayObject)
+
+#undef COPY
+    }
+  }
+#endif
+ 
+#ifdef WITH_TRACER
+  LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
+  const Type* type = stat ? LCI->getStaticType() : LCI->getVirtualType();
+  std::vector<JavaField*> &fields = stat ? cl->staticFields : cl->virtualFields;
+ 
+  Function* func = Function::Create(JnjvmModule::MarkAndTraceType,
+                                    GlobalValue::ExternalLinkage,
+                                    "markAndTraceObject",
+                                    cl->isolate->module);
+
+  Constant* zero = mvm::jit::constantZero;
+  Argument* arg = func->arg_begin();
+  BasicBlock* block = BasicBlock::Create("", func);
+  llvm::Value* realArg = new BitCastInst(arg, type, "", block);
+
+#ifdef MULTIPLE_GC
+  Value* GC = ++func->arg_begin();
+  std::vector<Value*> Args;
+  Args.push_back(arg);
+  Args.push_back(GC);
+  if (stat || cl->super == 0) {
+    CallInst::Create(JnjvmModule::JavaObjectTracer, Args.begin(), Args.end(),
+                     "", block);
+  } else {
+    CallInst::Create(((Class*)cl->super)->virtualTracer, Args.begin(),
+                     Args.end(), "", block);
+  }
+#else  
+  if (stat || cl->super == 0) {
+    CallInst::Create(JnjvmModule::JavaObjectTracerFunction, arg, "", block);
+  } else {
+    LLVMClassInfo* LCP = (LLVMClassInfo*)getClassInfo((Class*)(cl->super));
+    CallInst::Create(LCP->getVirtualTracer(), arg, "", block);
+  }
+#endif
+  
+  for (std::vector<JavaField*>::iterator i = fields.begin(), 
+            e = fields.end(); i!= e; ++i) {
+    if ((*i)->signature->funcs->doTrace) {
+      LLVMFieldInfo* LFI = getFieldInfo(*i);
+      std::vector<Value*> args; //size = 2
+      args.push_back(zero);
+      args.push_back(LFI->getOffset());
+      Value* ptr = GetElementPtrInst::Create(realArg, args.begin(), args.end(), 
+                                             "",block);
+      Value* val = new LoadInst(ptr, "", block);
+      Value* valCast = new BitCastInst(val, JnjvmModule::JavaObjectType, "",
+                                       block);
+#ifdef MULTIPLE_GC
+      std::vector<Value*> Args;
+      Args.push_back(valCast);
+      Args.push_back(GC);
+      CallInst::Create(JnjvmModule::MarkAndTraceFunction, Args.begin(),
+                       Args.end(), "", block);
+#else
+      CallInst::Create(JnjvmModule::MarkAndTraceFunction, valCast, "", block);
+#endif
+    }
+  }
+
+  ReturnInst::Create(block);
+
+  void* codePtr = mvm::jit::executionEngine->getPointerToGlobal(func);
+  ((void**)res)[VT_TRACER_OFFSET] = codePtr;
+  
+  if (!stat) {
+    LCI->virtualTracerFunction = func;
+    cl->codeVirtualTracer = mvm::Code::getCodeFromPointer(codePtr);
+  } else {
+    LCI->staticTracerFunction = func;
+    cl->codeStaticTracer = mvm::Code::getCodeFromPointer(codePtr);
+  }
+#endif
+  return res;
+}
+
+
+const Type* LLVMClassInfo::getVirtualType() {
+  if (!virtualType) {
+    std::vector<const llvm::Type*> fields;
+    if (classDef->super) {
+      LLVMClassInfo* CLI = 
+        (LLVMClassInfo*)module->getClassInfo(classDef->super);
+      fields.push_back(CLI->getVirtualType()->getContainedType(0));
+    } else {
+      fields.push_back(JnjvmModule::JavaObjectType->getContainedType(0));
+    }
+    
+    uint32 index = 0;
+    for (std::vector<JavaField*>::iterator i = classDef->virtualFields.begin(),
+         e = classDef->virtualFields.end(); i!= e; ++i) {
+      fields.push_back((*i)->signature->funcs->llvmType);
+      (*i)->num = index++;
+    }
+    
+    StructType* structType = StructType::get(fields, false);
+    virtualType = PointerType::getUnqual(structType);
+    const TargetData* targetData = mvm::jit::executionEngine->getTargetData();
+    const StructLayout* sl = targetData->getStructLayout(structType);
+    
+    for (std::vector<JavaField*>::iterator i = classDef->virtualFields.begin(),
+         e = classDef->virtualFields.end(); i!= e; ++i) {
+      (*i)->ptrOffset = sl->getElementOffset((*i)->num + 1);
+    }
+    
+    VirtualTable* VT = module->makeVT((Class*)classDef, false);
+  
+    uint64 size = mvm::jit::getTypeSize(structType);
+    classDef->virtualSize = (uint32)size;
+    classDef->virtualVT = VT;
+    virtualSizeConstant = ConstantInt::get(Type::Int32Ty, size);
+
+  }
+
+  return virtualType;
+}
+
+const Type* LLVMClassInfo::getStaticType() {
+  
+  if (!staticType) {
+    Class* cl = (Class*)classDef;
+    std::vector<const llvm::Type*> fields;
+    fields.push_back(JnjvmModule::JavaObjectType->getContainedType(0));
+
+    uint32 index = 0;
+    for (std::vector<JavaField*>::iterator i = classDef->staticFields.begin(),
+            e = classDef->staticFields.end(); i!= e; ++i) {
+      fields.push_back((*i)->signature->funcs->llvmType);
+      (*i)->num = index++;
+    }
+  
+    StructType* structType = StructType::get(fields, false);
+    staticType = PointerType::getUnqual(structType);
+    const TargetData* targetData = mvm::jit::executionEngine->getTargetData();
+    const StructLayout* sl = targetData->getStructLayout(structType);
+    
+    for (std::vector<JavaField*>::iterator i = classDef->staticFields.begin(),
+         e = classDef->staticFields.end(); i!= e; ++i) {
+      (*i)->ptrOffset = sl->getElementOffset((*i)->num + 1);
+    }
+    
+
+    VirtualTable* VT = module->makeVT((Class*)classDef, true);
+
+    uint64 size = mvm::jit::getTypeSize(structType);
+    cl->staticSize = size;
+    cl->staticVT = VT;
+
+#ifndef MULTIPLE_VM
+    JavaObject* val = 
+      (JavaObject*)classDef->isolate->allocateObject(cl->staticSize,
+                                                     cl->staticVT);
+    val->initialise(classDef);
+    for (std::vector<JavaField*>::iterator i = cl->staticFields.begin(),
+         e = cl->staticFields.end(); i!= e; ++i) {
+    
+      (*i)->initField(val);
+    }
+  
+    cl->_staticInstance = val;
+#endif
+  }
+  return staticType;
+}
+
+Value* LLVMClassInfo::getStaticVar(JavaJIT* jit) {
+#ifndef MULTIPLE_VM
+  if (!staticVarGV) {
+    getStaticType();
+    JavaObject* obj = ((Class*)classDef)->staticInstance();
+    Constant* cons = 
+      ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+                                uint64_t (obj)), JnjvmModule::JavaObjectType);
+      
+      staticVarGV = new GlobalVariable(JnjvmModule::JavaObjectType, true,
+                                       GlobalValue::ExternalLinkage,
+                                       cons, "",
+                                       classDef->isolate->module);
+  }
+
+  return new LoadInst(staticVarGV, "", jit->currentBlock);
+
+#else
+  Value* var = getVar(jit->compilingClass->isolate->module);
+  Value* ld = new LoadInst(var, "", jit->currentBlock);
+  ld = jit->invoke(JnjvmModule::InitialisationCheckFunction, ld, "",
+                   jit->currentBlock);
+  return jit->invoke(JnjvmModule::GetStaticInstanceFunction, ld,
+                     jit->isolateLocal, "", jit->currentBlock);
+#endif
+}
+
+Value* LLVMClassInfo::getVirtualTable(JavaJIT* jit) {
+  if (!virtualTableGV) {
+    getVirtualType();
+    Constant* cons = 
+      ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+                                                 uint64_t(classDef->virtualVT)),
+                                JnjvmModule::VTType);
+    virtualTableGV = new GlobalVariable(JnjvmModule::VTType, true,
+                                        GlobalValue::ExternalLinkage,
+                                        cons, "",
+                                        classDef->isolate->module);
+  }
+  return new LoadInst(virtualTableGV, "", jit->currentBlock);
+}
+
+Value* LLVMClassInfo::getVirtualSize(JavaJIT* jit) {
+  if (!virtualSizeConstant) {
+    getVirtualType();
+    virtualSizeConstant = 
+      ConstantInt::get(Type::Int32Ty, classDef->virtualSize);
+  }
+  return virtualSizeConstant;
+}
+
+Function* LLVMClassInfo::getStaticTracer() {
+  if (!staticTracerFunction) {
+    getStaticType();
+  }
+  return staticTracerFunction;
+}
+
+Function* LLVMClassInfo::getVirtualTracer() {
+  if (!virtualTracerFunction) {
+    getVirtualType();
+  }
+  return virtualTracerFunction;
+}
+
+Function* LLVMMethodInfo::getMethod() {
+  if (!methodFunction) {
+    Jnjvm* vm = methodDef->classDef->isolate;
+    methodFunction = Function::Create(getFunctionType(), 
+                                      GlobalValue::GhostLinkage,
+                                      methodDef->printString(),
+                                      vm->module);
+    vm->functionDefs->hash(methodFunction, methodDef);
+  }
+  return methodFunction;
+}
+
+const FunctionType* LLVMMethodInfo::getFunctionType() {
+  if (!functionType) {
+    LLVMSignatureInfo* LSI = module->getSignatureInfo(methodDef->signature);
+    assert(LSI);
+    if (isStatic(methodDef->access)) {
+      functionType = LSI->getStaticType();
+    } else {
+      functionType = LSI->getVirtualType();
+    }
+  }
+  return functionType;
+}
+
+ConstantInt* LLVMMethodInfo::getOffset() {
+  if (!offsetConstant) {
+    module->resolveVirtualClass(methodDef->classDef);
+    offsetConstant = ConstantInt::get(Type::Int32Ty, methodDef->offset);
+  }
+  return offsetConstant;
+}
+
+ConstantInt* LLVMFieldInfo::getOffset() {
+  if (!offsetConstant) {
+    if (isStatic(fieldDef->access)) {
+      module->resolveStaticClass(fieldDef->classDef); 
+    } else {
+      module->resolveVirtualClass(fieldDef->classDef); 
+    }
+    // Increment by one because zero is JavaObject
+    offsetConstant = ConstantInt::get(Type::Int32Ty, fieldDef->num + 1);
+  }
+  return offsetConstant;
+}
+
+const llvm::FunctionType* LLVMSignatureInfo::getVirtualType() {
+ if (!virtualType) {
+    // Lock here because we are called by arbitrary code
+    llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+    std::vector<const llvm::Type*> llvmArgs;
+    unsigned int size = signature->args.size();
+
+    llvmArgs.push_back(JnjvmModule::JavaObjectType);
+
+    for (uint32 i = 0; i < size; ++i) {
+      llvmArgs.push_back(signature->args.at(i)->funcs->llvmType);
+    }
+
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
+    llvmArgs.push_back(mvm::jit::ptrType); // domain
+#endif
+
+    virtualType = FunctionType::get(signature->ret->funcs->llvmType,
+                                    llvmArgs, false);
+  }
+  return virtualType;
+}
+
+const llvm::FunctionType* LLVMSignatureInfo::getStaticType() {
+ if (!staticType) {
+    // Lock here because we are called by arbitrary code
+    llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+    std::vector<const llvm::Type*> llvmArgs;
+    unsigned int size = signature->args.size();
+
+    for (uint32 i = 0; i < size; ++i) {
+      llvmArgs.push_back(signature->args.at(i)->funcs->llvmType);
+    }
+
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
+    llvmArgs.push_back(mvm::jit::ptrType); // domain
+#endif
+
+    staticType = FunctionType::get(signature->ret->funcs->llvmType,
+                                   llvmArgs, false);
+  }
+  return staticType;
+}
+
+const llvm::FunctionType* LLVMSignatureInfo::getNativeType() {
+  if (!nativeType) {
+    // Lock here because we are called by arbitrary code
+    llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+    std::vector<const llvm::Type*> llvmArgs;
+    unsigned int size = signature->args.size();
+    
+    llvmArgs.push_back(mvm::jit::ptrType); // JNIEnv
+    llvmArgs.push_back(JnjvmModule::JavaObjectType); // Class
+
+    for (uint32 i = 0; i < size; ++i) {
+      llvmArgs.push_back(signature->args.at(i)->funcs->llvmType);
+    }
+
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
+    llvmArgs.push_back(mvm::jit::ptrType); // domain
+#endif
+
+    nativeType = FunctionType::get(signature->ret->funcs->llvmType,
+                                   llvmArgs, false);
+  }
+  return nativeType;
+}
+
+
+Function* LLVMSignatureInfo::createFunctionCallBuf(bool virt) {
+  
+  ConstantInt* CI = mvm::jit::constantZero;
+  std::vector<Value*> Args;
+
+  Function* res = Function::Create(virt ? getVirtualBufType() : getStaticBufType(),
+                                   GlobalValue::ExternalLinkage,
+                                   signature->printString(),
+                                   signature->isolate->module);
+  
+  BasicBlock* currentBlock = BasicBlock::Create("enter", res);
+  Function::arg_iterator i = res->arg_begin();
+  Value *obj, *ptr, *func;
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
+  Value* vm = i;
+#endif
+  ++i;
+  func = i;
+  ++i;
+  if (virt) {
+    obj = i;
+    ++i;
+    Args.push_back(obj);
+  }
+  ptr = i;
+
+  for (std::vector<Typedef*>::iterator i = signature->args.begin(), 
+            e = signature->args.end(); i!= e; ++i) {
+  
+    const AssessorDesc* funcs = (*i)->funcs;
+    ptr = GetElementPtrInst::Create(ptr, CI, "", currentBlock);
+    Value* val = new BitCastInst(ptr, funcs->llvmTypePtr, "", currentBlock);
+    Value* arg = new LoadInst(val, "", currentBlock);
+    Args.push_back(arg);
+    if (funcs == AssessorDesc::dLong || funcs == AssessorDesc::dDouble) {
+      CI = mvm::jit::constantTwo;
+    } else {
+      CI = mvm::jit::constantOne;
+    }
+  }
+
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
+  Args.push_back(vm);
+#endif
+
+  Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock);
+  if (signature->ret->funcs != AssessorDesc::dVoid)
+    ReturnInst::Create(val, currentBlock);
+  else
+    ReturnInst::Create(currentBlock);
+  
+  return res;
+}
+
+Function* LLVMSignatureInfo::createFunctionCallAP(bool virt) {
+  
+  std::vector<Value*> Args;
+
+  Function* res = Function::Create(virt ? getVirtualBufType() : getStaticBufType(),
+                                      GlobalValue::ExternalLinkage,
+                                      signature->printString(),
+                                      signature->isolate->module);
+  
+  BasicBlock* currentBlock = BasicBlock::Create("enter", res);
+  Function::arg_iterator i = res->arg_begin();
+  Value *obj, *ap, *func;
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
+  Value* vm = i;
+#endif
+  ++i;
+  func = i;
+  ++i;
+  if (virt) {
+    obj = i;
+    Args.push_back(obj);
+    ++i;
+  }
+  ap = i;
+
+  for (std::vector<Typedef*>::iterator i = signature->args.begin(), 
+       e = signature->args.end(); i!= e; i++) {
+
+    Args.push_back(new VAArgInst(ap, (*i)->funcs->llvmType, "", currentBlock));
+  }
+
+#if defined(MULTIPLE_VM) || defined(MULTIPLE_GC)
+  Args.push_back(vm);
+#endif
+
+  Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock);
+  if (signature->ret->funcs != AssessorDesc::dVoid)
+    ReturnInst::Create(val, currentBlock);
+  else
+    ReturnInst::Create(currentBlock);
+  
+  return res;
+}
+
+const PointerType* LLVMSignatureInfo::getStaticPtrType() {
+  if (!staticPtrType) {
+    staticPtrType = PointerType::getUnqual(getStaticType());
+  }
+  return staticPtrType;
+}
+
+const PointerType* LLVMSignatureInfo::getVirtualPtrType() {
+  if (!virtualPtrType) {
+    virtualPtrType = PointerType::getUnqual(getVirtualType());
+  }
+  return virtualPtrType;
+}
+
+const PointerType* LLVMSignatureInfo::getNativePtrType() {
+  if (!nativePtrType) {
+    nativePtrType = PointerType::getUnqual(getNativeType());
+  }
+  return nativePtrType;
+}
+
+
+const FunctionType* LLVMSignatureInfo::getVirtualBufType() {
+  if (!virtualBufType) {
+    // Lock here because we are called by arbitrary code
+    llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+    std::vector<const llvm::Type*> Args2;
+    Args2.push_back(mvm::jit::ptrType); // vm
+    Args2.push_back(getVirtualPtrType());
+    Args2.push_back(JnjvmModule::JavaObjectType);
+    Args2.push_back(PointerType::getUnqual(Type::Int32Ty));
+    virtualBufType = FunctionType::get(signature->ret->funcs->llvmType,
+                                       Args2, false);
+  }
+  return virtualBufType;
+}
+
+const FunctionType* LLVMSignatureInfo::getStaticBufType() {
+  if (!staticBufType) {
+    // Lock here because we are called by arbitrary code
+    llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+    std::vector<const llvm::Type*> Args;
+    Args.push_back(mvm::jit::ptrType); // vm
+    Args.push_back(getStaticPtrType());
+    Args.push_back(PointerType::getUnqual(Type::Int32Ty));
+    staticBufType = FunctionType::get(signature->ret->funcs->llvmType,
+                                      Args, false);
+  }
+  return staticBufType;
+}
+
+Function* LLVMSignatureInfo::getVirtualBuf() {
+  if (!virtualBufFunction) {
+    // Lock here because we are called by arbitrary code
+    llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+    virtualBufFunction = createFunctionCallBuf(true);
+    signature->_virtualCallBuf = (mvm::Code*)
+      mvm::jit::executionEngine->getPointerToGlobal(virtualBufFunction);
+  }
+  return virtualBufFunction;
+}
+
+Function* LLVMSignatureInfo::getVirtualAP() {
+  if (!virtualAPFunction) {
+    // Lock here because we are called by arbitrary code
+    llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+    virtualAPFunction = createFunctionCallAP(true);
+    signature->_virtualCallAP = (mvm::Code*)
+      mvm::jit::executionEngine->getPointerToGlobal(virtualAPFunction);
+  }
+  return virtualAPFunction;
+}
+
+Function* LLVMSignatureInfo::getStaticBuf() {
+  if (!staticBufFunction) {
+    // Lock here because we are called by arbitrary code
+    llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+    staticBufFunction = createFunctionCallBuf(false);
+    signature->_staticCallBuf = (mvm::Code*)
+      mvm::jit::executionEngine->getPointerToGlobal(staticBufFunction);
+  }
+  return staticBufFunction;
+}
+
+Function* LLVMSignatureInfo::getStaticAP() {
+  if (!staticAPFunction) {
+    // Lock here because we are called by arbitrary code
+    llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+    staticAPFunction = createFunctionCallAP(false);
+    signature->_staticCallAP = (mvm::Code*)
+      mvm::jit::executionEngine->getPointerToGlobal(staticAPFunction);
+  }
+  return staticAPFunction;
+}
+
+void JnjvmModule::resolveVirtualClass(Class* cl) {
+  // Lock here because we may be called by a class resolver
+  llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+  LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
+  LCI->getVirtualType();
+}
+
+void JnjvmModule::resolveStaticClass(Class* cl) {
+  // Lock here because we may be called by a class initializer
+  llvm::MutexGuard locked(mvm::jit::executionEngine->lock);
+  LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
+  LCI->getStaticType();
+}
+
+LLVMCommonClassInfo* JnjvmModule::getClassInfo(CommonClass* cl) {
+  class_iterator CI = classMap.find(cl);
+  if (CI != classMap.end()) {
+    return CI->second;
+  } else {
+    if (cl->isArray) {
+      LLVMCommonClassInfo* LCI = new LLVMCommonClassInfo(cl, this);
+      classMap.insert(std::make_pair(cl, LCI));
+      return LCI;
+    } else {
+      LLVMClassInfo* LCI = new LLVMClassInfo((Class*)cl, this);
+      classMap.insert(std::make_pair(cl, LCI));
+      return LCI;
+    }
+  }
+}
+
+LLVMMethodInfo* JnjvmModule::getMethodInfo(JavaMethod* meth) {
+  method_iterator MI = methodMap.find(meth);
+  if (MI != methodMap.end()) {
+    return MI->second;
+  } else {
+    LLVMMethodInfo* LMI = new LLVMMethodInfo(meth, this);
+    methodMap.insert(std::make_pair(meth, LMI));
+    return LMI;
+  }
+}
+
+LLVMFieldInfo* JnjvmModule::getFieldInfo(JavaField* field) {
+  field_iterator FI = fieldMap.find(field);
+  if (FI != fieldMap.end()) {
+    return FI->second;
+  } else {
+    LLVMFieldInfo* LFI = new LLVMFieldInfo(field, this);
+    fieldMap.insert(std::make_pair(field, LFI));
+    return LFI;
+  }
+}
+
+LLVMSignatureInfo* JnjvmModule::getSignatureInfo(Signdef* sign) {
+  signature_iterator SI = signatureMap.find(sign);
+  if (SI != signatureMap.end()) {
+    return SI->second;
+  } else {
+    LLVMSignatureInfo* LSI = new LLVMSignatureInfo(sign);
+    signatureMap.insert(std::make_pair(sign, LSI));
+    return LSI;
+  }
+}
+
+
+#include "LLVMRuntime.cpp"
+
+void JnjvmModule::initialise() {
+  Module* module = this;
+  makeLLVMModuleContents(module);
+  
+  VTType = module->getTypeByName("VT");
+  
+  JavaObjectType = 
+    PointerType::getUnqual(module->getTypeByName("JavaObject"));
+
+  JavaArrayType =
+    PointerType::getUnqual(module->getTypeByName("JavaArray"));
+  
+  JavaClassType =
+    PointerType::getUnqual(module->getTypeByName("JavaClass"));
+  
+  JavaArrayUInt8Type =
+    PointerType::getUnqual(module->getTypeByName("ArrayUInt8"));
+  JavaArraySInt8Type =
+    PointerType::getUnqual(module->getTypeByName("ArraySInt8"));
+  JavaArrayUInt16Type =
+    PointerType::getUnqual(module->getTypeByName("ArrayUInt16"));
+  JavaArraySInt16Type =
+    PointerType::getUnqual(module->getTypeByName("ArraySInt16"));
+  JavaArrayUInt32Type =
+    PointerType::getUnqual(module->getTypeByName("ArrayUInt32"));
+  JavaArraySInt32Type =
+    PointerType::getUnqual(module->getTypeByName("ArraySInt32"));
+  JavaArrayLongType =
+    PointerType::getUnqual(module->getTypeByName("ArrayLong"));
+  JavaArrayFloatType =
+    PointerType::getUnqual(module->getTypeByName("ArrayFloat"));
+  JavaArrayDoubleType =
+    PointerType::getUnqual(module->getTypeByName("ArrayDouble"));
+  JavaArrayObjectType =
+    PointerType::getUnqual(module->getTypeByName("ArrayObject"));
+
+  CacheNodeType =
+    PointerType::getUnqual(module->getTypeByName("CacheNode"));
+  
+  EnveloppeType =
+    PointerType::getUnqual(module->getTypeByName("Enveloppe"));
+
+  InterfaceLookupFunction = module->getFunction("virtualLookup");
+  MultiCallNewFunction = module->getFunction("multiCallNew");
+  InitialisationCheckFunction = module->getFunction("initialisationCheck");
+  ForceInitialisationCheckFunction = 
+    module->getFunction("forceInitialisationCheck");
+
+  ArrayLengthFunction = module->getFunction("arrayLength");
+  GetVTFunction = module->getFunction("getVT");
+  GetClassFunction = module->getFunction("getClass");
+  ClassLookupFunction = module->getFunction("newLookup");
+  GetVTFromClassFunction = module->getFunction("getVTFromClass");
+  GetObjectSizeFromClassFunction = module->getFunction("getObjectSizeFromClass");
+ 
+  GetClassDelegateeFunction = module->getFunction("getClassDelegatee");
+  InstanceOfFunction = module->getFunction("JavaObjectInstanceOf");
+  AquireObjectFunction = module->getFunction("JavaObjectAquire");
+  ReleaseObjectFunction = module->getFunction("JavaObjectRelease");
+
+  FieldLookupFunction = module->getFunction("fieldLookup");
+  
+  GetExceptionFunction = module->getFunction("JavaThreadGetException");
+  GetJavaExceptionFunction = module->getFunction("JavaThreadGetJavaException");
+  CompareExceptionFunction = module->getFunction("JavaThreadCompareException");
+  JniProceedPendingExceptionFunction = 
+    module->getFunction("jniProceedPendingException");
+  GetSJLJBufferFunction = module->getFunction("getSJLJBuffer");
+  
+  NullPointerExceptionFunction = module->getFunction("nullPointerException");
+  ClassCastExceptionFunction = module->getFunction("classCastException");
+  IndexOutOfBoundsExceptionFunction = 
+    module->getFunction("indexOutOfBoundsException");
+  NegativeArraySizeExceptionFunction = 
+    module->getFunction("negativeArraySizeException");
+  OutOfMemoryErrorFunction = module->getFunction("outOfMemoryError");
+
+  JavaObjectAllocateFunction = module->getFunction("gcmalloc");
+
+  PrintExecutionFunction = module->getFunction("printExecution");
+  PrintMethodStartFunction = module->getFunction("printMethodStart");
+  PrintMethodEndFunction = module->getFunction("printMethodEnd");
+
+  ThrowExceptionFunction = module->getFunction("JavaThreadThrowException");
+
+  ClearExceptionFunction = module->getFunction("JavaThreadClearException");
+  
+
+#ifdef MULTIPLE_VM
+  GetStaticInstanceFunction = module->getFunction("getStaticInstance");
+  RuntimeUTF8ToStrFunction = module->getFunction("runtimeUTF8ToStr");
+#endif
+  
+#ifdef SERVICE_VM
+  AquireObjectInSharedDomainFunction = 
+    module->getFunction("JavaObjectAquireInSharedDomain");
+  ReleaseObjectInSharedDomainfunction = 
+    module->getFunction("JavaObjectReleaseInSharedDomain");
+  ServiceCallStartFunction = module->getFunction("serviceCallStart");
+  ServiceCallStopFunction = module->getFunction("serviceCallStop");
+#endif
+    
+#ifdef WITH_TRACER
+  MarkAndTraceFunction = module->getFunction("MarkAndTrace");
+  MarkAndTraceType = MarkAndTraceFunction->getFunctionType();
+  JavaObjectTracerFunction = module->getFunction("JavaObjectTracer");
+#endif
+
+#ifndef WITHOUT_VTABLE
+  VirtualLookupFunction = module->getFunction("vtableLookup");
+#endif
+
+#ifdef MULTIPLE_GC
+  GetCollectorFunction = module->getFunction("getCollector");
+#endif
+
+  
+  UTF8NullConstant = Constant::getNullValue(JavaArrayUInt16Type); 
+  JavaClassNullConstant = Constant::getNullValue(JavaClassType); 
+  JavaObjectNullConstant = Constant::getNullValue(JnjvmModule::JavaObjectType);
+  MaxArraySizeConstant = ConstantInt::get(Type::Int32Ty,
+                                          JavaArray::MaxArraySize);
+  JavaObjectSizeConstant = ConstantInt::get(Type::Int32Ty, sizeof(JavaObject));
+  
+  
+  Constant* cons = 
+    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+                              uint64_t (JavaObject::VT)), VTType);
+      
+  JavaObjectVirtualTableGV = new GlobalVariable(VTType, true,
+                                                GlobalValue::ExternalLinkage,
+                                                cons, "",
+                                                module);
+  
+  cons = 
+    ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
+                              uint64_t (ArrayObject::VT)), VTType);
+  
+  ArrayObjectVirtualTableGV = new GlobalVariable(VTType, true,
+                                          GlobalValue::ExternalLinkage,
+                                          cons, "",
+                                          module);
+  
+  OffsetObjectSizeInClassConstant = mvm::jit::constantOne;
+  OffsetVTInClassConstant = mvm::jit::constantTwo;
+  JavaArrayElementsOffsetConstant = mvm::jit::constantTwo;
+  JavaArraySizeOffsetConstant = mvm::jit::constantOne;
+  JavaObjectLockOffsetConstant = mvm::jit::constantTwo;
+  JavaObjectClassOffsetConstant = mvm::jit::constantOne;
+  
+}
+
+void JnjvmModule::InitField(JavaField* field, JavaObject* obj, uint64 val) {
+  
+  const AssessorDesc* funcs = field->signature->funcs;
+  if (funcs == AssessorDesc::dLong) {
+    ((sint64*)((uint64)obj + field->ptrOffset))[0] = val;
+  } else if (funcs == AssessorDesc::dInt) {
+    ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val;
+  } else if (funcs == AssessorDesc::dChar) {
+    ((uint16*)((uint64)obj + field->ptrOffset))[0] = (uint16)val;
+  } else if (funcs == AssessorDesc::dShort) {
+    ((sint16*)((uint64)obj + field->ptrOffset))[0] = (sint16)val;
+  } else if (funcs == AssessorDesc::dByte) {
+    ((sint8*)((uint64)obj + field->ptrOffset))[0] = (sint8)val;
+  } else if (funcs == AssessorDesc::dBool) {
+    ((uint8*)((uint64)obj + field->ptrOffset))[0] = (uint8)val;
+  } else {
+    // 0 value for everything else
+    ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val;
+  }
+}
+
+void JnjvmModule::InitField(JavaField* field, JavaObject* obj, JavaObject* val) {
+  ((JavaObject**)((uint64)obj + field->ptrOffset))[0] = val;
+}
+
+void JnjvmModule::InitField(JavaField* field, JavaObject* obj, double val) {
+  ((double*)((uint64)obj + field->ptrOffset))[0] = val;
+}
+
+void JnjvmModule::InitField(JavaField* field, JavaObject* obj, float val) {
+  ((float*)((uint64)obj + field->ptrOffset))[0] = val;
+}
+

Added: vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h?rev=51189&view=auto

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (added)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Fri May 16 09:49:12 2008
@@ -0,0 +1,330 @@
+//===------- JnjvmModule.h - Definition of a Jnjvm module -----------------===//
+//
+//                              JnJVM
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include <map>
+
+#include "llvm/Constant.h"
+#include "llvm/DerivedTypes.h"
+#include "llvm/Function.h"
+#include "llvm/GlobalVariable.h"
+#include "llvm/Module.h"
+#include "llvm/Type.h"
+#include "llvm/Value.h"
+
+namespace jnjvm {
+
+class CommonClass;
+class Class;
+class JavaField;
+class JavaMethod;
+class JavaObject;
+class JavaJIT;
+class JnjvmModule;
+class Signdef;
+
+class LLVMCommonClassInfo {
+  
+  friend class JnjvmModule;
+
+protected:
+  CommonClass* classDef;
+  JnjvmModule* module;
+
+private:
+  /// varGV - The LLVM global variable representing this class.
+  ///
+  llvm::GlobalVariable* varGV;
+
+#ifndef MULTIPLE_VM
+  /// delegateeGV - The LLVM global variable representing the 
+  /// java/lang/Class instance of this class.
+  llvm::GlobalVariable* delegateeGV;
+#endif
+
+
+public:
+  llvm::Value* getVar(JavaJIT* jit);
+  llvm::Value* getDelegatee(JavaJIT* jit);
+  
+  LLVMCommonClassInfo(CommonClass* cl, JnjvmModule* M) : 
+    classDef(cl),
+    module(M),
+    varGV(0),
+    delegateeGV(0) {}
+};
+
+class LLVMClassInfo : public LLVMCommonClassInfo {
+  friend class JnjvmModule;
+private:
+  /// virtualSizeLLVM - The LLVM constant size of instances of this class.
+  ///
+  llvm::ConstantInt* virtualSizeConstant;
+  llvm::GlobalVariable* staticVarGV;
+  llvm::GlobalVariable* virtualTableGV;
+  llvm::Function* virtualTracerFunction;
+  llvm::Function* staticTracerFunction;
+  /// virtualType - The LLVM type of instance of this class.
+  ///
+  const llvm::Type * virtualType;
+
+  /// staticType - The LLVM type of the static instance of this class.
+  ///
+  const llvm::Type * staticType;
+public:
+  
+  llvm::Value* getStaticVar(JavaJIT* jit);
+  llvm::Value* getVirtualTable(JavaJIT* jit);
+  llvm::Value* getVirtualSize(JavaJIT* jit);
+  llvm::Function* getStaticTracer();
+  llvm::Function* getVirtualTracer();
+  const llvm::Type* getVirtualType();
+  const llvm::Type* getStaticType();
+  
+  LLVMClassInfo(Class* cl, JnjvmModule* M) : 
+    LLVMCommonClassInfo((CommonClass*)cl, M),
+    virtualSizeConstant(0),
+    staticVarGV(0),
+    virtualTableGV(0),
+    virtualTracerFunction(0),
+    staticTracerFunction(0),
+    virtualType(0),
+    staticType(0) {}
+};
+
+class LLVMMethodInfo {
+private:
+  JavaMethod* methodDef;
+  JnjvmModule* module;
+
+  llvm::Function* methodFunction;
+  llvm::ConstantInt* offsetConstant;
+  const llvm::FunctionType* functionType;
+  
+public:
+  llvm::Function* getMethod();
+  llvm::ConstantInt* getOffset();
+  const llvm::FunctionType* getFunctionType();
+  
+  LLVMMethodInfo(JavaMethod* M, JnjvmModule* Mo) : 
+    methodDef(M), 
+    module(Mo),
+    methodFunction(0),
+    offsetConstant(0),
+    functionType(0) {}
+};
+
+class LLVMFieldInfo {
+private:
+  JavaField* fieldDef;
+  JnjvmModule* module;
+  
+  llvm::ConstantInt* offsetConstant;
+
+public:
+  llvm::ConstantInt* getOffset();
+
+  LLVMFieldInfo(JavaField* F, JnjvmModule* M) : 
+    fieldDef(F), 
+    module(M),
+    offsetConstant(0) {}
+};
+
+class LLVMSignatureInfo {
+private:
+  const llvm::FunctionType* staticType;
+  const llvm::FunctionType* virtualType;
+  const llvm::FunctionType* nativeType;
+  
+  const llvm::FunctionType* virtualBufType;
+  const llvm::FunctionType* staticBufType;
+
+  const llvm::PointerType* staticPtrType;
+  const llvm::PointerType* virtualPtrType;
+  const llvm::PointerType* nativePtrType;
+  
+  llvm::Function* virtualBufFunction;
+  llvm::Function* virtualAPFunction;
+  llvm::Function* staticBufFunction;
+  llvm::Function* staticAPFunction;
+  
+  Signdef* signature;
+
+  llvm::Function* createFunctionCallBuf(bool virt);
+  llvm::Function* createFunctionCallAP(bool virt);
+   
+  
+
+public:
+  const llvm::FunctionType* getVirtualType();
+  const llvm::FunctionType* getStaticType();
+  const llvm::FunctionType* getNativeType();
+
+  const llvm::FunctionType* getVirtualBufType();
+  const llvm::FunctionType* getStaticBufType();
+
+  const llvm::PointerType*  getStaticPtrType();
+  const llvm::PointerType*  getNativePtrType();
+  const llvm::PointerType*  getVirtualPtrType();
+   
+  llvm::Function* getVirtualBuf();
+  llvm::Function* getVirtualAP();
+  llvm::Function* getStaticBuf();
+  llvm::Function* getStaticAP();
+  
+  LLVMSignatureInfo(Signdef* sign) : 
+    staticType(0),
+    virtualType(0),
+    nativeType(0),
+    virtualBufType(0),
+    staticBufType(0),
+    staticPtrType(0),
+    virtualPtrType(0),
+    nativePtrType(0),
+    virtualBufFunction(0),
+    virtualAPFunction(0),
+    staticBufFunction(0),
+    staticAPFunction(0),
+    signature(sign) {}
+
+};
+
+class JnjvmModule : public llvm::Module {
+  friend class LLVMClassInfo;
+private:
+  std::map<const CommonClass*, LLVMCommonClassInfo*> classMap;
+  std::map<const Signdef*, LLVMSignatureInfo*> signatureMap;
+  std::map<const JavaField*, LLVMFieldInfo*> fieldMap;
+  std::map<const JavaMethod*, LLVMMethodInfo*> methodMap;
+  
+  typedef std::map<const CommonClass*, LLVMCommonClassInfo*>::iterator
+    class_iterator;  
+  
+  typedef std::map<const Signdef*, LLVMSignatureInfo*>::iterator
+    signature_iterator;  
+  
+  typedef std::map<const JavaMethod*, LLVMMethodInfo*>::iterator
+    method_iterator;  
+  
+  typedef std::map<const JavaField*, LLVMFieldInfo*>::iterator
+    field_iterator;  
+  
+  VirtualTable* makeVT(Class* cl, bool stat);
+  VirtualTable* allocateVT(Class* cl, std::vector<JavaMethod*>::iterator meths);
+
+
+public:
+  static llvm::ConstantInt* JavaArraySizeOffsetConstant;
+  static llvm::ConstantInt* JavaArrayElementsOffsetConstant;
+  static llvm::ConstantInt* JavaObjectLockOffsetConstant;
+  static llvm::ConstantInt* JavaObjectClassOffsetConstant;
+
+  static const llvm::Type* JavaArrayUInt8Type;
+  static const llvm::Type* JavaArraySInt8Type;
+  static const llvm::Type* JavaArrayUInt16Type;
+  static const llvm::Type* JavaArraySInt16Type;
+  static const llvm::Type* JavaArrayUInt32Type;
+  static const llvm::Type* JavaArraySInt32Type;
+  static const llvm::Type* JavaArrayLongType;
+  static const llvm::Type* JavaArrayFloatType;
+  static const llvm::Type* JavaArrayDoubleType;
+  static const llvm::Type* JavaArrayObjectType;
+  
+  static const llvm::Type* VTType;
+  static const llvm::Type* JavaObjectType;
+  static const llvm::Type* JavaArrayType;
+  static const llvm::Type* JavaClassType;
+  static const llvm::Type* JavaCacheType;
+  static const llvm::Type* EnveloppeType;
+  static const llvm::Type* CacheNodeType;
+  
+#ifdef WITH_TRACER
+  static llvm::Function* MarkAndTraceFunction;
+  static const llvm::FunctionType* MarkAndTraceType;
+  static llvm::Function* JavaObjectTracerFunction;  
+#endif
+  
+  static llvm::Function* GetSJLJBufferFunction;
+  static llvm::Function* InterfaceLookupFunction;
+  static llvm::Function* FieldLookupFunction;
+  static llvm::Function* PrintExecutionFunction;
+  static llvm::Function* PrintMethodStartFunction;
+  static llvm::Function* PrintMethodEndFunction;
+  static llvm::Function* JniProceedPendingExceptionFunction;
+  static llvm::Function* InitialisationCheckFunction;
+  static llvm::Function* ForceInitialisationCheckFunction;
+  static llvm::Function* ClassLookupFunction;
+#ifndef WITHOUT_VTABLE
+  static llvm::Function* VirtualLookupFunction;
+#endif
+  static llvm::Function* InstanceOfFunction;
+  static llvm::Function* AquireObjectFunction;
+  static llvm::Function* ReleaseObjectFunction;
+#ifdef SERVICE_VM
+  static llvm::Function* AquireObjectInSharedDomainFunction;
+  static llvm::Function* ReleaseObjectInSharedDomainFunction;
+  static llvm::Function* ServiceCallStartFunction;
+  static llvm::Function* ServiceCallStopFunction;
+#endif
+  static llvm::Function* MultiCallNewFunction;
+  static llvm::Function* RuntimeUTF8ToStrFunction;
+  static llvm::Function* GetStaticInstanceFunction;
+  static llvm::Function* GetClassDelegateeFunction;
+  static llvm::Function* ArrayLengthFunction;
+  static llvm::Function* GetVTFunction;
+  static llvm::Function* GetClassFunction;
+  static llvm::Function* JavaObjectAllocateFunction;
+#ifdef MULTIPLE_GC
+  static llvm::Function* GetCollectorFunction;
+#endif
+  static llvm::Function* GetVTFromClassFunction;
+  static llvm::Function* GetObjectSizeFromClassFunction;
+  static llvm::ConstantInt* OffsetObjectSizeInClassConstant;
+  static llvm::ConstantInt* OffsetVTInClassConstant;
+
+  static llvm::Constant* JavaClassNullConstant;
+
+  static llvm::Constant*    JavaObjectNullConstant;
+  static llvm::Constant*    UTF8NullConstant;
+  static llvm::Constant*    MaxArraySizeConstant;
+  static llvm::Constant*    JavaObjectSizeConstant;
+
+  static llvm::GlobalVariable* ArrayObjectVirtualTableGV;
+  static llvm::GlobalVariable* JavaObjectVirtualTableGV;
+  
+  static llvm::Function* GetExceptionFunction;
+  static llvm::Function* GetJavaExceptionFunction;
+  static llvm::Function* ThrowExceptionFunction;
+  static llvm::Function* ClearExceptionFunction;
+  static llvm::Function* CompareExceptionFunction;
+  static llvm::Function* NullPointerExceptionFunction;
+  static llvm::Function* IndexOutOfBoundsExceptionFunction;
+  static llvm::Function* ClassCastExceptionFunction;
+  static llvm::Function* OutOfMemoryErrorFunction;
+  static llvm::Function* NegativeArraySizeExceptionFunction;
+
+  static void InitField(JavaField* field);
+  static void InitField(JavaField* field, JavaObject* obj, uint64 val = 0);
+  static void InitField(JavaField* field, JavaObject* obj, JavaObject* val);
+  static void InitField(JavaField* field, JavaObject* obj, double val);
+  static void InitField(JavaField* field, JavaObject* obj, float val);
+
+
+  void resolveVirtualClass(Class* cl);
+  void resolveStaticClass(Class* cl);
+
+  LLVMSignatureInfo* getSignatureInfo(Signdef*);
+  LLVMCommonClassInfo* getClassInfo(CommonClass*);
+  LLVMFieldInfo* getFieldInfo(JavaField*);
+  LLVMMethodInfo* getMethodInfo(JavaMethod*);
+
+  explicit JnjvmModule(const std::string &ModuleID) : llvm::Module(ModuleID) {}
+  void initialise();
+};
+
+}

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Fri May 16 09:49:12 2008
@@ -7,23 +7,21 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <llvm/Module.h>
-#include <llvm/ModuleProvider.h>
-
 #include "mvm/JIT.h"
 
-#include "JnjvmModuleProvider.h"
-
+#include "JavaAccess.h"
 #include "JavaClass.h"
 #include "JavaConstantPool.h"
 #include "JavaJIT.h"
 #include "JavaThread.h"
 #include "Jnjvm.h"
+#include "JnjvmModule.h"
+#include "JnjvmModuleProvider.h"
 
 using namespace llvm;
 using namespace jnjvm;
 
-static JavaMethod* staticLookup(Class* caller, uint32 index) { 
+JavaMethod* JnjvmModuleProvider::staticLookup(Class* caller, uint32 index) { 
   JavaCtpInfo* ctpInfo = caller->ctpInfo;
   
 
@@ -38,8 +36,9 @@
   JavaMethod* meth = cl->lookupMethod(utf8, sign->keyName, isStatic, true);
   
   meth->compiledPtr();
-
-  ctpInfo->ctpRes[index] = meth->llvmFunction;
+  
+  LLVMMethodInfo* LMI = ((JnjvmModule*)TheModule)->getMethodInfo(meth);
+  ctpInfo->ctpRes[index] = LMI->getMethod();
 
   return meth;
 }
@@ -66,11 +65,32 @@
   if (F->isDeclaration())
     mvm::jit::executionEngine->updateGlobalMapping(F, val);
   
-  if (meth->offset) {
-    uint64_t offset = meth->offset->getZExtValue();
+  if (isVirtual(meth->access)) {
+    LLVMMethodInfo* LMI = ((JnjvmModule*)TheModule)->getMethodInfo(meth);
+    uint64_t offset = LMI->getOffset()->getZExtValue();
     ((void**)meth->classDef->virtualVT)[offset] = val;
   }
 
   return false;
 }
 
+void* JnjvmModuleProvider::materializeFunction(JavaMethod* meth) {
+  LLVMMethodInfo* LMI = ((JnjvmModule*)TheModule)->getMethodInfo(meth);
+  Function* func = LMI->getMethod();
+  if (func->hasNotBeenReadFromBitcode()) {
+    // Don't take the JIT lock yet, as Java exceptions in the bytecode must be 
+    // loaded first.
+    JavaJIT jit;
+    jit.compilingClass = meth->classDef;
+    jit.compilingMethod = meth;
+    jit.module = (JnjvmModule*)TheModule;
+    jit.llvmFunction = func;
+    if (isNative(meth->access)) {
+      jit.nativeCompile();
+    } else {
+      jit.javaCompile();
+    }
+  }
+  
+  return mvm::jit::executionEngine->getPointerToGlobal(func);
+}

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModuleProvider.h Fri May 16 09:49:12 2008
@@ -18,17 +18,24 @@
 
 namespace jnjvm {
 
+class JnjvmModule;
+
 class JnjvmModuleProvider : public ModuleProvider {
+private:
+  JavaMethod* staticLookup(Class* caller, uint32 index);
+
 public:
   FunctionMap* functions;
   FunctionDefMap* functionDefs;
-  JnjvmModuleProvider(Module *m, FunctionMap* fm, FunctionDefMap* fdm) {
-    TheModule = m;
+  JnjvmModuleProvider(JnjvmModule *m, FunctionMap* fm, FunctionDefMap* fdm) {
+    TheModule = (Module*)m;
     functions = fm;
     functionDefs= fdm;
   }
   
+
   bool materializeFunction(Function *F, std::string *ErrInfo = 0);
+  void* materializeFunction(JavaMethod* meth); 
 
   Module* materializeModule(std::string *ErrInfo = 0) { return TheModule; }
 };

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Fri May 16 09:49:12 2008
@@ -16,10 +16,10 @@
 
 #include "mvm/JIT.h"
 
-#include "JavaArray.h"
-#include "JavaJIT.h"
+#include "JnjvmModule.h"
 
 using namespace llvm;
+using namespace jnjvm;
 
 namespace mvm {
 
@@ -44,19 +44,20 @@
       II++;
       if (CallInst *CI = dyn_cast<CallInst>(I)) {
         Value* V = CI->getOperand(0);
-        if (V == jnjvm::JavaJIT::arrayLengthLLVM) {
+        if (V == jnjvm::JnjvmModule::ArrayLengthFunction) {
           Changed = true;
           Value* val = CI->getOperand(1); // get the array
-          Value* array = new BitCastInst(val, jnjvm::JavaArray::llvmType, "", CI);
+          Value* array = new BitCastInst(val, jnjvm::JnjvmModule::JavaArrayType,
+                                         "", CI);
           std::vector<Value*> args; //size=  2
           args.push_back(mvm::jit::constantZero);
-          args.push_back(jnjvm::JavaArray::sizeOffset());
+          args.push_back(jnjvm::JnjvmModule::JavaArraySizeOffsetConstant);
           Value* ptr = GetElementPtrInst::Create(array, args.begin(), args.end(),
                                          "", CI);
           Value* load = new LoadInst(ptr, "", CI);
           CI->replaceAllUsesWith(load);
           CI->eraseFromParent();
-        } else if (V == jnjvm::JavaJIT::getVTLLVM) {
+        } else if (V == jnjvm::JnjvmModule::GetVTFunction) {
           Changed = true;
           Value* val = CI->getOperand(1); // get the object
           std::vector<Value*> indexes; //[3];
@@ -67,47 +68,47 @@
           Value* VT = new LoadInst(VTPtr, "", CI);
           CI->replaceAllUsesWith(VT);
           CI->eraseFromParent();
-        } else if (V == jnjvm::JavaJIT::getClassLLVM) {
+        } else if (V == jnjvm::JnjvmModule::GetClassFunction) {
           Changed = true;
           Value* val = CI->getOperand(1); // get the object
           std::vector<Value*> args2;
           args2.push_back(mvm::jit::constantZero);
-          args2.push_back(jnjvm::JavaObject::classOffset());
+          args2.push_back(jnjvm::JnjvmModule::JavaObjectClassOffsetConstant);
           Value* classPtr = GetElementPtrInst::Create(val, args2.begin(),
                                                       args2.end(), "",
                                                       CI);
           Value* cl = new LoadInst(classPtr, "", CI);
           CI->replaceAllUsesWith(cl);
           CI->eraseFromParent();
-        } else if (V == jnjvm::JavaJIT::getVTFromClassLLVM) {
+        } else if (V == jnjvm::JnjvmModule::GetVTFromClassFunction) {
           Changed = true;
           Value* val = CI->getOperand(1); 
           std::vector<Value*> indexes; 
           indexes.push_back(mvm::jit::constantZero);
-          indexes.push_back(jnjvm::JavaJIT::constantOffsetVTInClass);
+          indexes.push_back(jnjvm::JnjvmModule::OffsetVTInClassConstant);
           Value* VTPtr = GetElementPtrInst::Create(val, indexes.begin(),
                                                    indexes.end(), "", CI);
           Value* VT = new LoadInst(VTPtr, "", CI);
           CI->replaceAllUsesWith(VT);
           CI->eraseFromParent();
-        } else if (V == jnjvm::JavaJIT::getObjectSizeFromClassLLVM) {
+        } else if (V == jnjvm::JnjvmModule::GetObjectSizeFromClassFunction) {
           Changed = true;
           Value* val = CI->getOperand(1); 
           std::vector<Value*> indexes; 
           indexes.push_back(mvm::jit::constantZero);
-          indexes.push_back(jnjvm::JavaJIT::constantOffsetObjectSizeInClass);
+          indexes.push_back(JnjvmModule::OffsetObjectSizeInClassConstant);
           Value* SizePtr = GetElementPtrInst::Create(val, indexes.begin(),
                                                    indexes.end(), "", CI);
           Value* Size = new LoadInst(SizePtr, "", CI);
           CI->replaceAllUsesWith(Size);
           CI->eraseFromParent();
         }
-        else if (V == jnjvm::JavaJIT::forceInitialisationCheckLLVM) {
+        else if (V == jnjvm::JnjvmModule::ForceInitialisationCheckFunction) {
           Changed = true;
           CI->eraseFromParent();
         }
 #ifdef MULTIPLE_GC
-        else if (V == jnjvm::JavaJIT::getCollectorLLVM) {
+        else if (V == jnjvm::JnjvmModule::GetCollectorFunction) {
           Changed = true;
           Value* val = CI->getOperand(1); 
           std::vector<Value*> indexes; 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/Makefile.am (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/Makefile.am Fri May 16 09:49:12 2008
@@ -13,7 +13,7 @@
 	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 \
-	LowerConstantCalls.cpp 
+	LowerConstantCalls.cpp JnjvmModule.h JnjvmModule.cpp
 
 if SERVICE_BUILD
 libJnJVM_la_SOURCES += ServiceDomain.cpp

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/ServiceDomain.h Fri May 16 09:49:12 2008
@@ -55,8 +55,6 @@
   DomainState state;
 
   static ServiceDomain* getDomainFromLoader(JavaObject* loader);
-  static llvm::Function* serviceCallStartLLVM;
-  static llvm::Function* serviceCallStopLLVM;
   static JavaMethod* ServiceErrorInit;
   static Class* ServiceErrorClass;
 





More information about the llvm-commits mailing list