[vmkit-commits] [vmkit] r96194 - in /vmkit/trunk: include/j3/ lib/J3/Compiler/ tools/vmjc/ tools/vmkit/

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun Feb 14 14:07:43 PST 2010


Author: geoffray
Date: Sun Feb 14 16:07:42 2010
New Revision: 96194

URL: http://llvm.org/viewvc/llvm-project?rev=96194&view=rev
Log:
Refactoring. No functionality change.


Added:
    vmkit/trunk/include/j3/J3Intrinsics.h
      - copied, changed from r96191, vmkit/trunk/include/j3/JnjvmModule.h
    vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp
      - copied, changed from r96189, vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp
Removed:
    vmkit/trunk/include/j3/JnjvmModule.h
    vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp
Modified:
    vmkit/trunk/include/j3/JavaLLVMCompiler.h
    vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc
    vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJIT.h
    vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
    vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp
    vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
    vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp
    vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp
    vmkit/trunk/tools/vmjc/vmjc.cpp
    vmkit/trunk/tools/vmkit/Launcher.cpp

Copied: vmkit/trunk/include/j3/J3Intrinsics.h (from r96191, vmkit/trunk/include/j3/JnjvmModule.h)
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/J3Intrinsics.h?p2=vmkit/trunk/include/j3/J3Intrinsics.h&p1=vmkit/trunk/include/j3/JnjvmModule.h&r1=96191&r2=96194&rev=96194&view=diff

==============================================================================
--- vmkit/trunk/include/j3/JnjvmModule.h (original)
+++ vmkit/trunk/include/j3/J3Intrinsics.h Sun Feb 14 16:07:42 2010
@@ -1,4 +1,4 @@
-//===---------- JnjvmModule.h - Definition of a J3 module -----------------===//
+//===-------------- J3Intrinsics.h - Intrinsics of J3 ---------------------===//
 //
 //                            The VMKit project
 //
@@ -7,17 +7,16 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef JNJVM_MODULE_H
-#define JNJVM_MODULE_H
+#ifndef J3_INTRINSICS_H
+#define J3_INTRINSICS_H
 
 #include "mvm/JIT.h"
 
 namespace j3 {
 
-class JnjvmModule : public mvm::MvmModule {
+class J3Intrinsics : public mvm::MvmModule {
 
 public:
-
   static const llvm::Type* JavaArrayUInt8Type;
   static const llvm::Type* JavaArraySInt8Type;
   static const llvm::Type* JavaArrayUInt16Type;
@@ -174,7 +173,7 @@
   llvm::Function* ThrowExceptionFromJITFunction;
   
 
-  JnjvmModule(llvm::Module*);
+  J3Intrinsics(llvm::Module*);
   
   static void initialise();
 

Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaLLVMCompiler.h?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/include/j3/JavaLLVMCompiler.h (original)
+++ vmkit/trunk/include/j3/JavaLLVMCompiler.h Sun Feb 14 16:07:42 2010
@@ -11,7 +11,7 @@
 #define J3_LLVM_COMPILER_H
 
 #include "j3/JavaCompiler.h"
-#include "j3/JnjvmModule.h"
+#include "j3/J3Intrinsics.h"
 #include "j3/LLVMInfo.h"
 
 namespace llvm {
@@ -40,7 +40,7 @@
 
 protected:
   llvm::Module* TheModule;
-  JnjvmModule JavaIntrinsics;
+  J3Intrinsics JavaIntrinsics;
 
   void addJavaPasses();
 
@@ -67,7 +67,7 @@
     return TheModule;
   }
 
-  JnjvmModule* getIntrinsics() {
+  J3Intrinsics* getIntrinsics() {
     return &JavaIntrinsics;
   }
 

Removed: vmkit/trunk/include/j3/JnjvmModule.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=96193&view=auto

==============================================================================
--- vmkit/trunk/include/j3/JnjvmModule.h (original)
+++ vmkit/trunk/include/j3/JnjvmModule.h (removed)
@@ -1,185 +0,0 @@
-//===---------- JnjvmModule.h - Definition of a J3 module -----------------===//
-//
-//                            The VMKit project
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef JNJVM_MODULE_H
-#define JNJVM_MODULE_H
-
-#include "mvm/JIT.h"
-
-namespace j3 {
-
-class JnjvmModule : public mvm::MvmModule {
-
-public:
-
-  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* JavaCommonClassType;
-  static const llvm::Type* JavaClassType;
-  static const llvm::Type* JavaClassArrayType;
-  static const llvm::Type* JavaClassPrimitiveType;
-  static const llvm::Type* ConstantPoolType;
-  static const llvm::Type* CodeLineInfoType;
-  static const llvm::Type* UTF8Type;
-  static const llvm::Type* JavaMethodType;
-  static const llvm::Type* JavaFieldType;
-  static const llvm::Type* AttributType;
-  static const llvm::Type* JavaThreadType;
-  static const llvm::Type* MutatorThreadType;
-  
-#ifdef ISOLATE_SHARING
-  static const llvm::Type* JnjvmType;
-#endif
-  
-  llvm::Function* EmptyTracerFunction;
-  llvm::Function* JavaObjectTracerFunction;
-  llvm::Function* JavaArrayTracerFunction;
-  llvm::Function* ArrayObjectTracerFunction;
-  llvm::Function* RegularObjectTracerFunction;
-  
-  llvm::Function* StartJNIFunction;
-  llvm::Function* EndJNIFunction;
-  llvm::Function* InterfaceLookupFunction;
-  llvm::Function* VirtualFieldLookupFunction;
-  llvm::Function* StaticFieldLookupFunction;
-  llvm::Function* PrintExecutionFunction;
-  llvm::Function* PrintMethodStartFunction;
-  llvm::Function* PrintMethodEndFunction;
-  llvm::Function* InitialiseClassFunction;
-  llvm::Function* InitialisationCheckFunction;
-  llvm::Function* ForceInitialisationCheckFunction;
-  llvm::Function* ForceLoadedCheckFunction;
-  llvm::Function* ClassLookupFunction;
-  llvm::Function* StringLookupFunction;
-  
-  llvm::Function* ResolveVirtualStubFunction;
-  llvm::Function* ResolveSpecialStubFunction;
-  llvm::Function* ResolveStaticStubFunction;
-
-#ifndef WITHOUT_VTABLE
-  llvm::Function* VirtualLookupFunction;
-#endif
-  llvm::Function* IsAssignableFromFunction;
-  llvm::Function* IsSecondaryClassFunction;
-  llvm::Function* GetDepthFunction;
-  llvm::Function* GetDisplayFunction;
-  llvm::Function* GetVTInDisplayFunction;
-  llvm::Function* GetStaticInstanceFunction;
-  llvm::Function* AquireObjectFunction;
-  llvm::Function* ReleaseObjectFunction;
-  llvm::Function* GetConstantPoolAtFunction;
-  llvm::Function* MultiCallNewFunction;
-  llvm::Function* GetArrayClassFunction;
-
-#ifdef ISOLATE_SHARING
-  llvm::Function* GetCtpClassFunction;
-  llvm::Function* GetJnjvmExceptionClassFunction;
-  llvm::Function* GetJnjvmArrayClassFunction;
-  llvm::Function* StaticCtpLookupFunction;
-  llvm::Function* SpecialCtpLookupFunction;
-#endif
-
-#ifdef SERVICE
-  llvm::Function* ServiceCallStartFunction;
-  llvm::Function* ServiceCallStopFunction;
-#endif
-
-  llvm::Function* GetClassDelegateeFunction;
-  llvm::Function* RuntimeDelegateeFunction;
-  llvm::Function* ArrayLengthFunction;
-  llvm::Function* GetVTFunction;
-  llvm::Function* GetIMTFunction;
-  llvm::Function* GetClassFunction;
-  llvm::Function* GetVTFromClassFunction;
-  llvm::Function* GetVTFromClassArrayFunction;
-  llvm::Function* GetVTFromCommonClassFunction;
-  llvm::Function* GetObjectSizeFromClassFunction;
-  llvm::Function* GetBaseClassVTFromVTFunction;
-
-  llvm::Function* GetLockFunction;
-  llvm::Function* OverflowThinLockFunction;
-  
-  llvm::Function* GetFinalInt8FieldFunction;
-  llvm::Function* GetFinalInt16FieldFunction;
-  llvm::Function* GetFinalInt32FieldFunction;
-  llvm::Function* GetFinalLongFieldFunction;
-  llvm::Function* GetFinalFloatFieldFunction;
-  llvm::Function* GetFinalDoubleFieldFunction;
-  llvm::Function* GetFinalObjectFieldFunction;
-  
-  llvm::Constant* JavaArraySizeOffsetConstant;
-  llvm::Constant* JavaArrayElementsOffsetConstant;
-  llvm::Constant* JavaObjectLockOffsetConstant;
-  llvm::Constant* JavaObjectVTOffsetConstant;
-
-  llvm::Constant* OffsetAccessInCommonClassConstant;
-  llvm::Constant* IsArrayConstant;
-  llvm::Constant* IsPrimitiveConstant;
-  llvm::Constant* OffsetObjectSizeInClassConstant;
-  llvm::Constant* OffsetVTInClassConstant;
-  llvm::Constant* OffsetTaskClassMirrorInClassConstant;
-  llvm::Constant* OffsetVirtualMethodsInClassConstant;
-  llvm::Constant* OffsetStaticInstanceInTaskClassMirrorConstant;
-  llvm::Constant* OffsetInitializedInTaskClassMirrorConstant;
-  llvm::Constant* OffsetStatusInTaskClassMirrorConstant;
-  
-  llvm::Constant* OffsetDoYieldInThreadConstant;
-  llvm::Constant* OffsetIsolateInThreadConstant;
-  llvm::Constant* OffsetJNIInThreadConstant;
-  llvm::Constant* OffsetJavaExceptionInThreadConstant;
-  llvm::Constant* OffsetCXXExceptionInThreadConstant;
-  
-  llvm::Constant* OffsetClassInVTConstant;
-  llvm::Constant* OffsetDepthInVTConstant;
-  llvm::Constant* OffsetDisplayInVTConstant;
-  llvm::Constant* OffsetBaseClassVTInVTConstant;
-  llvm::Constant* OffsetIMTInVTConstant;
-  
-  llvm::Constant* OffsetBaseClassInArrayClassConstant;
-  llvm::Constant* OffsetLogSizeInPrimitiveClassConstant;
-  
-  llvm::Constant* ClassReadyConstant;
-
-  llvm::Constant* JavaObjectNullConstant;
-  llvm::Constant* MaxArraySizeConstant;
-  llvm::Constant* JavaArraySizeConstant;
-
-  llvm::Function* ThrowExceptionFunction;
-  llvm::Function* NullPointerExceptionFunction;
-  llvm::Function* IndexOutOfBoundsExceptionFunction;
-  llvm::Function* ClassCastExceptionFunction;
-  llvm::Function* OutOfMemoryErrorFunction;
-  llvm::Function* StackOverflowErrorFunction;
-  llvm::Function* NegativeArraySizeExceptionFunction;
-  llvm::Function* ArrayStoreExceptionFunction;
-  llvm::Function* ArithmeticExceptionFunction;
-  llvm::Function* ThrowExceptionFromJITFunction;
-  
-
-  JnjvmModule(llvm::Module*);
-  
-  static void initialise();
-
-};
-
-}
-
-#endif

Modified: vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc (original)
+++ vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc Sun Feb 14 16:07:42 2010
@@ -8,9 +8,9 @@
   res->setMetadata("dbg", CreateLocation());
   
   if (TheCompiler->hasExceptionsEnabled()) {
-    Value* threadId = getCurrentThread(module->JavaThreadType);
-    Value* geps[2] = { module->constantZero,
-                       module->OffsetJavaExceptionInThreadConstant };
+    Value* threadId = getCurrentThread(intrinsics->JavaThreadType);
+    Value* geps[2] = { intrinsics->constantZero,
+                       intrinsics->OffsetJavaExceptionInThreadConstant };
 
     Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps,
                                                         geps + 2, "",
@@ -22,20 +22,20 @@
     BasicBlock* ifNormal = createBasicBlock("no exception block");
   
     Value* test = 0;
-    Constant* zero = module->JavaObjectNullConstant;
+    Constant* zero = intrinsics->JavaObjectNullConstant;
 
     // If F is a runtime intrinsic that does not access memory, use a hack
     // that will prevent LLVM from moving the exception check: runtime
     // intrinsics return the exception if an exception was raised.
-    if (F == module->InitialisationCheckFunction || 
-        F == module->GetConstantPoolAtFunction ||
-        F == module->GetArrayClassFunction ||
-        F == module->GetClassDelegateeFunction) {
+    if (F == intrinsics->InitialisationCheckFunction || 
+        F == intrinsics->GetConstantPoolAtFunction ||
+        F == intrinsics->GetArrayClassFunction ||
+        F == intrinsics->GetClassDelegateeFunction) {
       // Make the load volatile to force the instruction after the call.
       // Otherwise, LLVM will merge the load with a previous load because
       // the function is readnone.
       obj = new LoadInst(javaExceptionPtr, "", true, currentBlock);
-      test = new BitCastInst(res, module->JavaObjectType, "", currentBlock);
+      test = new BitCastInst(res, intrinsics->JavaObjectType, "", currentBlock);
       test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, test, obj, "");
       Value* T = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, zero, "");
       test = BinaryOperator::CreateAnd(test, T, "", currentBlock);
@@ -66,9 +66,9 @@
   res->setMetadata("dbg", CreateLocation());
   
   if (TheCompiler->hasExceptionsEnabled()) {
-    Value* threadId = getCurrentThread(module->JavaThreadType);
-    Value* geps[2] = { module->constantZero,
-                       module->OffsetJavaExceptionInThreadConstant };
+    Value* threadId = getCurrentThread(intrinsics->JavaThreadType);
+    Value* geps[2] = { intrinsics->constantZero,
+                       intrinsics->OffsetJavaExceptionInThreadConstant };
 
     Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps,
                                                         geps + 2, "",
@@ -80,13 +80,13 @@
     BasicBlock* ifNormal = createBasicBlock("no exception block");
   
     Value* test = 0;
-    Constant* zero = module->JavaObjectNullConstant;
-    if (F == module->InitialisationCheckFunction || 
-        F == module->GetConstantPoolAtFunction ||
-        F == module->GetArrayClassFunction ||
-        F == module->GetClassDelegateeFunction) {
+    Constant* zero = intrinsics->JavaObjectNullConstant;
+    if (F == intrinsics->InitialisationCheckFunction || 
+        F == intrinsics->GetConstantPoolAtFunction ||
+        F == intrinsics->GetArrayClassFunction ||
+        F == intrinsics->GetClassDelegateeFunction) {
       obj = new LoadInst(javaExceptionPtr, "", true, currentBlock);
-      test = new BitCastInst(res, module->JavaObjectType, "", currentBlock);
+      test = new BitCastInst(res, intrinsics->JavaObjectType, "", currentBlock);
       test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, test, obj, "");
       Value* T = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, zero, "");
       test = BinaryOperator::CreateAnd(test, T, "", currentBlock);
@@ -118,9 +118,9 @@
   res->setMetadata("dbg", CreateLocation());
   
   if (TheCompiler->hasExceptionsEnabled()) {
-    Value* threadId = getCurrentThread(module->JavaThreadType);
-    Value* geps[2] = { module->constantZero,
-                       module->OffsetJavaExceptionInThreadConstant };
+    Value* threadId = getCurrentThread(intrinsics->JavaThreadType);
+    Value* geps[2] = { intrinsics->constantZero,
+                       intrinsics->OffsetJavaExceptionInThreadConstant };
 
     Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps,
                                                         geps + 2, "",
@@ -132,13 +132,13 @@
     BasicBlock* ifNormal = createBasicBlock("no exception block");
     
     Value* test = 0;
-    Constant* zero = module->JavaObjectNullConstant;
-    if (F == module->InitialisationCheckFunction || 
-        F == module->GetConstantPoolAtFunction ||
-        F == module->GetArrayClassFunction ||
-        F == module->GetClassDelegateeFunction) {
+    Constant* zero = intrinsics->JavaObjectNullConstant;
+    if (F == intrinsics->InitialisationCheckFunction || 
+        F == intrinsics->GetConstantPoolAtFunction ||
+        F == intrinsics->GetArrayClassFunction ||
+        F == intrinsics->GetClassDelegateeFunction) {
       obj = new LoadInst(javaExceptionPtr, "", true, currentBlock);
-      test = new BitCastInst(res, module->JavaObjectType, "", currentBlock);
+      test = new BitCastInst(res, intrinsics->JavaObjectType, "", currentBlock);
       test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, test, obj, "");
       Value* T = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, zero, "");
       test = BinaryOperator::CreateAnd(test, T, "", currentBlock);
@@ -167,9 +167,9 @@
   res->setMetadata("dbg", CreateLocation());
   
   if (TheCompiler->hasExceptionsEnabled()) {
-    Value* threadId = getCurrentThread(module->JavaThreadType);
-    Value* geps[2] = { module->constantZero,
-                       module->OffsetJavaExceptionInThreadConstant };
+    Value* threadId = getCurrentThread(intrinsics->JavaThreadType);
+    Value* geps[2] = { intrinsics->constantZero,
+                       intrinsics->OffsetJavaExceptionInThreadConstant };
 
     Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps,
                                                         geps + 2, "",
@@ -181,13 +181,13 @@
     BasicBlock* ifNormal = createBasicBlock("no exception block");
   
     Value* test = 0;
-    Constant* zero = module->JavaObjectNullConstant;
-    if (F == module->InitialisationCheckFunction || 
-        F == module->GetConstantPoolAtFunction ||
-        F == module->GetArrayClassFunction ||
-        F == module->GetClassDelegateeFunction) {
+    Constant* zero = intrinsics->JavaObjectNullConstant;
+    if (F == intrinsics->InitialisationCheckFunction || 
+        F == intrinsics->GetConstantPoolAtFunction ||
+        F == intrinsics->GetArrayClassFunction ||
+        F == intrinsics->GetClassDelegateeFunction) {
       obj = new LoadInst(javaExceptionPtr, "", true, currentBlock);
-      test = new BitCastInst(res, module->JavaObjectType, "", currentBlock);
+      test = new BitCastInst(res, intrinsics->JavaObjectType, "", currentBlock);
       test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, test, obj, "");
       Value* T = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, zero, "");
       test = BinaryOperator::CreateAnd(test, T, "", currentBlock);
@@ -229,9 +229,9 @@
 }
 
 void JavaJIT::throwException(Value* obj) {
-  Value* threadId = getCurrentThread(module->JavaThreadType);
-  Value* geps[2] = { module->constantZero,
-                     module->OffsetJavaExceptionInThreadConstant };
+  Value* threadId = getCurrentThread(intrinsics->JavaThreadType);
+  Value* geps[2] = { intrinsics->constantZero,
+                     intrinsics->OffsetJavaExceptionInThreadConstant };
 
   Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps,
                                                       geps + 2, "",
@@ -343,7 +343,7 @@
     ex->tester = createBasicBlock("testException");
     
     // PHI Node for the exception object
-    PHINode::Create(JnjvmModule::JavaObjectType, "", ex->tester);
+    PHINode::Create(J3Intrinsics::JavaObjectType, "", ex->tester);
     
     // Set the unwind destination of the instructions in the range of this
     // handler to the test block of the handler. If an instruction already has
@@ -365,7 +365,7 @@
     opcodeInfos[ex->handlerpc].handler = true;
     
     if (ex->javaHandler->empty()) {
-      PHINode::Create(JnjvmModule::JavaObjectType, "", ex->javaHandler);
+      PHINode::Create(J3Intrinsics::JavaObjectType, "", ex->javaHandler);
     }
 
   }
@@ -409,20 +409,20 @@
     // catch the exception but resume unwinding.
     JnjvmClassLoader* loader = compilingClass->classLoader;;
     if (loader != loader->bootstrapLoader) {
-      Value* threadId = getCurrentThread(module->MutatorThreadType);
+      Value* threadId = getCurrentThread(intrinsics->MutatorThreadType);
       Value* Isolate = GetElementPtrInst::Create(threadId,
-                                                 module->constantFour, "",
+                                                 intrinsics->constantFour, "",
                                                  currentBlock);
      
       Isolate = new LoadInst(Isolate, "", currentBlock);
-      Isolate = new BitCastInst(Isolate, module->ptrPtrType, "", currentBlock);
-      Value* Status = GetElementPtrInst::Create(Isolate, module->constantOne, "",
+      Isolate = new BitCastInst(Isolate, intrinsics->ptrPtrType, "", currentBlock);
+      Value* Status = GetElementPtrInst::Create(Isolate, intrinsics->constantOne, "",
                                                 currentBlock);
       Status = new LoadInst(Status, "", currentBlock);
       Status = new PtrToIntInst(Status, Type::Int32Ty, "", currentBlock);
   
       Value* stopping = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, Status,
-                                     module->constantOne, "");
+                                     intrinsics->constantOne, "");
 
       BasicBlock* raiseBlock = createBasicBlock("raiseBlock");
       BasicBlock* continueBlock = createBasicBlock("continueBlock");
@@ -437,7 +437,7 @@
     // Get the Java exception.
     Value* obj = currentBlock->begin();
     
-    Value* objVT = CallInst::Create(module->GetVTFunction, obj, "",
+    Value* objVT = CallInst::Create(intrinsics->GetVTFunction, obj, "",
                                     currentBlock);
 
     uint32 depth = cur->catchClass->virtualVT->depth;
@@ -447,17 +447,17 @@
     if (depth >= JavaVirtualTable::getDisplayLength()) {
       Value* classArgs[2] = { objVT, VTVar };
           
-      cmp = CallInst::Create(module->IsSecondaryClassFunction,
+      cmp = CallInst::Create(intrinsics->IsSecondaryClassFunction,
                              classArgs, classArgs + 2, "",
                              currentBlock);
 
     } else {
      
-      Value* inDisplay = CallInst::Create(module->GetDisplayFunction,
+      Value* inDisplay = CallInst::Create(intrinsics->GetDisplayFunction,
                                           objVT, "", currentBlock);
             
       Value* displayArgs[2] = { inDisplay, depthCl };
-      Value* VTInDisplay = CallInst::Create(module->GetVTInDisplayFunction,
+      Value* VTInDisplay = CallInst::Create(intrinsics->GetVTInDisplayFunction,
                                             displayArgs, displayArgs + 2, "",
                                             currentBlock);
              
@@ -482,15 +482,15 @@
     currentBlock = cur->javaHandler;
 
     // First thing in the handler: clear the exception.
-    Value* geps[2] = { module->constantZero,
-                       module->OffsetJavaExceptionInThreadConstant };
-    Value* threadId = getCurrentThread(module->JavaThreadType);
+    Value* geps[2] = { intrinsics->constantZero,
+                       intrinsics->OffsetJavaExceptionInThreadConstant };
+    Value* threadId = getCurrentThread(intrinsics->JavaThreadType);
     Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps,
                                                         geps + 2, "",
                                                         currentBlock);
     
     // Clear exceptions.
-    new StoreInst(module->JavaObjectNullConstant, javaExceptionPtr,
+    new StoreInst(intrinsics->JavaObjectNullConstant, javaExceptionPtr,
                   currentBlock);
 
 #if defined(SERVICE)
@@ -505,24 +505,24 @@
     Value* IsolatePtr = 0;
     currentBlock = cur->javaHandler;
     if (loader != loader->bootstrapLoader) {
-      threadId = getCurrentThread(module->MutatorThreadType);
+      threadId = getCurrentThread(intrinsics->MutatorThreadType);
      
-      IsolateIDPtr = GetElementPtrInst::Create(threadId, module->constantThree,
+      IsolateIDPtr = GetElementPtrInst::Create(threadId, intrinsics->constantThree,
                                                "", cur->javaHandler);
-      const Type* realType = PointerType::getUnqual(module->pointerSizeType);
+      const Type* realType = PointerType::getUnqual(intrinsics->pointerSizeType);
       IsolateIDPtr = new BitCastInst(IsolateIDPtr, realType, "",
                                      cur->javaHandler);
       OldIsolateID = new LoadInst(IsolateIDPtr, "", cur->javaHandler);
 
-      Value* MyID = ConstantInt::get(module->pointerSizeType,
+      Value* MyID = ConstantInt::get(intrinsics->pointerSizeType,
                                      loader->getIsolate()->IsolateID);
 
       new StoreInst(MyID, IsolateIDPtr, cur->javaHandler);
-      IsolatePtr = GetElementPtrInst::Create(threadId, module->constantFour, "",
+      IsolatePtr = GetElementPtrInst::Create(threadId, intrinsics->constantFour, "",
                                              cur->javaHandler);
      
       OldIsolate = new LoadInst(IsolatePtr, "", cur->javaHandler);
-      NewIsolate = module->getIsolate(loader->getIsolate(), currentBlock);
+      NewIsolate = intrinsics->getIsolate(loader->getIsolate(), currentBlock);
       new StoreInst(NewIsolate, IsolatePtr, cur->javaHandler);
 
     }

Copied: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp (from r96189, vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp)
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp?p2=vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp&p1=vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp&r1=96189&r2=96194&rev=96194&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp Sun Feb 14 16:07:42 2010
@@ -1,4 +1,4 @@
-//===--------- JnjvmModule.cpp - Definition of a Jnjvm module -------------===//
+//===------------- J3Intrinsics.cpp - Intrinsics for J3 -------------------===//
 //
 //                            The VMKit project
 //
@@ -24,42 +24,42 @@
 #include "JavaJIT.h"
 #include "JavaTypes.h"
 
-#include "j3/JnjvmModule.h"
+#include "j3/J3Intrinsics.h"
 #include "j3/LLVMMaterializer.h"
 
 using namespace j3;
 using namespace llvm;
 
-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::CodeLineInfoType = 0;
-const llvm::Type* JnjvmModule::ConstantPoolType = 0;
-const llvm::Type* JnjvmModule::UTF8Type = 0;
-const llvm::Type* JnjvmModule::JavaFieldType = 0;
-const llvm::Type* JnjvmModule::JavaMethodType = 0;
-const llvm::Type* JnjvmModule::AttributType = 0;
-const llvm::Type* JnjvmModule::JavaThreadType = 0;
-const llvm::Type* JnjvmModule::MutatorThreadType = 0;
+const llvm::Type* J3Intrinsics::JavaObjectType = 0;
+const llvm::Type* J3Intrinsics::JavaArrayType = 0;
+const llvm::Type* J3Intrinsics::JavaArrayUInt8Type = 0;
+const llvm::Type* J3Intrinsics::JavaArraySInt8Type = 0;
+const llvm::Type* J3Intrinsics::JavaArrayUInt16Type = 0;
+const llvm::Type* J3Intrinsics::JavaArraySInt16Type = 0;
+const llvm::Type* J3Intrinsics::JavaArrayUInt32Type = 0;
+const llvm::Type* J3Intrinsics::JavaArraySInt32Type = 0;
+const llvm::Type* J3Intrinsics::JavaArrayFloatType = 0;
+const llvm::Type* J3Intrinsics::JavaArrayDoubleType = 0;
+const llvm::Type* J3Intrinsics::JavaArrayLongType = 0;
+const llvm::Type* J3Intrinsics::JavaArrayObjectType = 0;
+const llvm::Type* J3Intrinsics::CodeLineInfoType = 0;
+const llvm::Type* J3Intrinsics::ConstantPoolType = 0;
+const llvm::Type* J3Intrinsics::UTF8Type = 0;
+const llvm::Type* J3Intrinsics::JavaFieldType = 0;
+const llvm::Type* J3Intrinsics::JavaMethodType = 0;
+const llvm::Type* J3Intrinsics::AttributType = 0;
+const llvm::Type* J3Intrinsics::JavaThreadType = 0;
+const llvm::Type* J3Intrinsics::MutatorThreadType = 0;
 
 #ifdef ISOLATE_SHARING
-const llvm::Type* JnjvmModule::JnjvmType = 0;
+const llvm::Type* J3Intrinsics::JnjvmType = 0;
 #endif
 
-const llvm::Type*   JnjvmModule::JavaClassType;
-const llvm::Type*   JnjvmModule::JavaClassPrimitiveType;
-const llvm::Type*   JnjvmModule::JavaClassArrayType;
-const llvm::Type*   JnjvmModule::JavaCommonClassType;
-const llvm::Type*   JnjvmModule::VTType;
+const llvm::Type*   J3Intrinsics::JavaClassType;
+const llvm::Type*   J3Intrinsics::JavaClassPrimitiveType;
+const llvm::Type*   J3Intrinsics::JavaClassArrayType;
+const llvm::Type*   J3Intrinsics::JavaCommonClassType;
+const llvm::Type*   J3Intrinsics::VTType;
 
 
 JavaLLVMCompiler::JavaLLVMCompiler(const std::string& str) :
@@ -97,7 +97,7 @@
   }
 }
 
-void JnjvmModule::initialise() {
+void J3Intrinsics::initialise() {
   Module* module = globalModule;
   
   if (!module->getTypeByName("JavaThread"))
@@ -170,7 +170,7 @@
   return getMethodInfo(meth)->getMethod();
 }
 
-JnjvmModule::JnjvmModule(llvm::Module* module) :
+J3Intrinsics::J3Intrinsics(llvm::Module* module) :
   MvmModule(module) {
   
   if (!VTType) {
@@ -179,7 +179,7 @@
   }
   
   JavaObjectNullConstant =
-    Constant::getNullValue(JnjvmModule::JavaObjectType);
+    Constant::getNullValue(J3Intrinsics::JavaObjectType);
   MaxArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
                                           JavaArray::MaxArraySize);
   JavaArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
@@ -357,20 +357,20 @@
   Function* func = LMI->getMethod();
   
   // We are jitting. Take the lock.
-  JnjvmModule::protectIR();
+  J3Intrinsics::protectIR();
   if (func->getLinkage() == GlobalValue::ExternalWeakLinkage) {
     JavaJIT jit(this, meth, func);
     if (isNative(meth->access)) {
       jit.nativeCompile();
-      JnjvmModule::runPasses(func, JavaNativeFunctionPasses);
+      J3Intrinsics::runPasses(func, JavaNativeFunctionPasses);
     } else {
       jit.javaCompile();
-      JnjvmModule::runPasses(func, JnjvmModule::globalFunctionPasses);
-      JnjvmModule::runPasses(func, JavaFunctionPasses);
+      J3Intrinsics::runPasses(func, J3Intrinsics::globalFunctionPasses);
+      J3Intrinsics::runPasses(func, JavaFunctionPasses);
     }
     func->setLinkage(GlobalValue::ExternalLinkage);
   }
-  JnjvmModule::unprotectIR();
+  J3Intrinsics::unprotectIR();
 
   return func;
 }
@@ -406,7 +406,7 @@
 }
 
 namespace j3 {
-  llvm::FunctionPass* createLowerConstantCallsPass(JnjvmModule* M);
+  llvm::FunctionPass* createLowerConstantCallsPass(J3Intrinsics* M);
 }
 
 void JavaLLVMCompiler::addJavaPasses() {

Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sun Feb 14 16:07:42 2010
@@ -17,7 +17,7 @@
 
 #include "mvm/Threads/Thread.h"
 
-#include "j3/JnjvmModule.h"
+#include "j3/J3Intrinsics.h"
 #include "j3/JavaAOTCompiler.h"
 #include "j3/JavaJITCompiler.h"
 
@@ -60,11 +60,11 @@
       const llvm::Type* Ty = 0;
       
       if (classDef->isArray()) {
-        Ty = JnjvmModule::JavaClassArrayType->getContainedType(0); 
+        Ty = J3Intrinsics::JavaClassArrayType->getContainedType(0); 
       } else if (classDef->isPrimitive()) {
-        Ty = JnjvmModule::JavaClassPrimitiveType->getContainedType(0); 
+        Ty = J3Intrinsics::JavaClassPrimitiveType->getContainedType(0); 
       } else {
-        Ty = JnjvmModule::JavaClassType->getContainedType(0); 
+        Ty = J3Intrinsics::JavaClassType->getContainedType(0); 
       }
     
       GlobalVariable* varGV =
@@ -95,7 +95,7 @@
     array_class_iterator End = arrayClasses.end();
     array_class_iterator I = arrayClasses.find(classDef->asArrayClass());
     if (I == End) {
-      const llvm::Type* Ty = JnjvmModule::JavaClassArrayType;
+      const llvm::Type* Ty = J3Intrinsics::JavaClassArrayType;
       Module& Mod = *getLLVMModule();
     
       GlobalVariable* varGV = 
@@ -119,7 +119,7 @@
   constant_pool_iterator End = constantPools.end();
   constant_pool_iterator I = constantPools.find(ctp);
   if (I == End) {
-    const Type* Ty = JnjvmModule::ConstantPoolType->getContainedType(0);
+    const Type* Ty = J3Intrinsics::ConstantPoolType->getContainedType(0);
     Module& Mod = *getLLVMModule();
     
     varGV = new GlobalVariable(Mod, Ty, false,
@@ -154,7 +154,7 @@
     name += "_VirtualMethods";
     Module& Mod = *getLLVMModule();
     const Type* ATy =
-      ArrayType::get(JnjvmModule::JavaMethodType->getContainedType(0),
+      ArrayType::get(J3Intrinsics::JavaMethodType->getContainedType(0),
                      cl->nbVirtualMethods + cl->nbStaticMethods);
 
     Array = new GlobalVariable(Mod, ATy, false, GlobalValue::ExternalLinkage,
@@ -180,7 +180,7 @@
       new GlobalVariable(Mod, Ty->getContainedType(0), false,
                          GlobalValue::InternalLinkage, 0, "");
     Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV,
-                                          JnjvmModule::JavaObjectType);
+                                          J3Intrinsics::JavaObjectType);
     strings.insert(std::make_pair(str, res));
     Constant* C = CreateConstantFromJavaString(str);
     varGV->setInitializer(C);
@@ -211,7 +211,7 @@
                            GlobalValue::InternalLinkage, 0, "");
     
       Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV,
-                                            JnjvmModule::JavaObjectType);
+                                            J3Intrinsics::JavaObjectType);
   
       javaClasses.insert(std::make_pair(cl, res));
       varGV->setInitializer(CreateConstantFromJavaClass(cl));
@@ -233,7 +233,7 @@
   getJavaClass(cl);
 
   Constant* Cl = getNativeClass(cl);
-  Cl = ConstantExpr::getBitCast(Cl, JnjvmModule::JavaCommonClassType);
+  Cl = ConstantExpr::getBitCast(Cl, J3Intrinsics::JavaCommonClassType);
 
   Constant* GEP[2] = { getIntrinsics()->constantZero,
                        getIntrinsics()->constantZero };
@@ -274,14 +274,14 @@
     intptr_t* realObj = (intptr_t*)obj;
     intptr_t size = realObj[0];
 
-    const ArrayType* ATy = ArrayType::get(JnjvmModule::JavaObjectType,
+    const ArrayType* ATy = ArrayType::get(J3Intrinsics::JavaObjectType,
                                           size + 1);
   
     std::vector<Constant*> Vals;
     for (sint32 i = 0; i < size + 1; ++i) {
       Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                       uint64_t(realObj[i]));
-      CI = ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
+      CI = ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType);
       Vals.push_back(CI);
     }
 
@@ -292,12 +292,12 @@
                                                GlobalValue::InternalLinkage,
                                                CA, "");
  
-    return ConstantExpr::getBitCast(varGV, JnjvmModule::JavaObjectType);
+    return ConstantExpr::getBitCast(varGV, J3Intrinsics::JavaObjectType);
 
   } else {
     Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                     uint64_t(obj));
-    CI = ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
+    CI = ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType);
     return CI;
   }
 }
@@ -337,13 +337,13 @@
             abort();
           }
         } else {
-          Ty = JnjvmModule::JavaObjectType;
+          Ty = J3Intrinsics::JavaObjectType;
         }
         
         std::vector<const Type*> Elemts;
         const ArrayType* ATy = ArrayType::get(Ty, ((JavaArray*)obj)->size);
-        Elemts.push_back(JnjvmModule::JavaObjectType->getContainedType(0));
-        Elemts.push_back(JnjvmModule::pointerSizeType);
+        Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0));
+        Elemts.push_back(J3Intrinsics::pointerSizeType);
         Elemts.push_back(ATy);
         Ty = StructType::get(getLLVMModule()->getContext(), Elemts);
 
@@ -357,7 +357,7 @@
                                  0, "");
 
       Constant* C = ConstantExpr::getBitCast(varGV,
-                                             JnjvmModule::JavaObjectType);
+                                             J3Intrinsics::JavaObjectType);
   
       finalObjects.insert(std::make_pair(obj, C));
       reverseFinalObjects.insert(std::make_pair(C, obj));
@@ -459,7 +459,7 @@
         const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[idx]);
         JavaString* obj = ctpInfo->resolveString(utf8, idx);
         Constant* C = getString(obj);
-        C = ConstantExpr::getBitCast(C, JnjvmModule::JavaObjectType);
+        C = ConstantExpr::getBitCast(C, J3Intrinsics::JavaObjectType);
         Elts.push_back(C);
       } else {
         fprintf(stderr, "Implement me");
@@ -491,7 +491,7 @@
                          0, name);
 
     Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV,
-                                          JnjvmModule::ptrType);
+                                          J3Intrinsics::ptrType);
     staticInstances.insert(std::make_pair(classDef, res));
     
     if (isCompiling(classDef)) { 
@@ -521,7 +521,7 @@
   if (I == End) {
     
     const ArrayType* ATy = 
-      dyn_cast<ArrayType>(JnjvmModule::VTType->getContainedType(0));
+      dyn_cast<ArrayType>(J3Intrinsics::VTType->getContainedType(0));
     const PointerType* PTy = dyn_cast<PointerType>(ATy->getContainedType(0));
     ATy = ArrayType::get(PTy, size);
     std::string name(UTF8Buffer(classDef->name).toCompileName()->cString());
@@ -534,7 +534,7 @@
                                                0, name);
   
     res = ConstantExpr::getCast(Instruction::BitCast, varGV,
-                                JnjvmModule::VTType);
+                                J3Intrinsics::VTType);
     virtualTables.insert(std::make_pair(VT, res));
   
     if (isCompiling(classDef) || assumeCompiled) {
@@ -571,7 +571,7 @@
 
 Constant* JavaAOTCompiler::CreateConstantForBaseObject(CommonClass* cl) {
   const StructType* STy = 
-    dyn_cast<StructType>(JnjvmModule::JavaObjectType->getContainedType(0));
+    dyn_cast<StructType>(J3Intrinsics::JavaObjectType->getContainedType(0));
   
   std::vector<Constant*> Elmts;
 
@@ -580,7 +580,7 @@
   
   // lock
   Constant* L = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), 0);
-  Elmts.push_back(ConstantExpr::getIntToPtr(L, JnjvmModule::ptrType));
+  Elmts.push_back(ConstantExpr::getIntToPtr(L, J3Intrinsics::ptrType));
 
   return ConstantStruct::get(STy, Elmts);
 }
@@ -597,19 +597,19 @@
   Elmts.push_back(CreateConstantForBaseObject(javaClass));
   
   // signers
-  Elmts.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType));
+  Elmts.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType));
   
   // pd
-  Elmts.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType));
+  Elmts.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType));
   
   // vmdata
   Constant* Cl = getNativeClass(cl);
   Cl = ConstantExpr::getCast(Instruction::BitCast, Cl,
-                             JnjvmModule::JavaObjectType);
+                             J3Intrinsics::JavaObjectType);
   Elmts.push_back(Cl);
 
   // constructor
-  Elmts.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType));
+  Elmts.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType));
 
   return ConstantStruct::get(STy, Elmts);
 }
@@ -707,7 +707,7 @@
             Constant* C = getFinalObject(val, FieldCl);
             TempElts.push_back(C);
           } else {
-            const llvm::Type* Ty = JnjvmModule::JavaObjectType;
+            const llvm::Type* Ty = J3Intrinsics::JavaObjectType;
             TempElts.push_back(Constant::getNullValue(Ty));
           }
         }
@@ -738,7 +738,7 @@
                                              GlobalValue::InternalLinkage,
                                              Array, "");
  
-	Array = ConstantExpr::getBitCast(varGV, JnjvmModule::JavaObjectType);
+	Array = ConstantExpr::getBitCast(varGV, J3Intrinsics::JavaObjectType);
 
   Elmts.push_back(Array);
   Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
@@ -754,7 +754,7 @@
 
 Constant* JavaAOTCompiler::CreateConstantFromAttribut(Attribut& attribut) {
   const StructType* STy = 
-    dyn_cast<StructType>(JnjvmModule::AttributType->getContainedType(0));
+    dyn_cast<StructType>(J3Intrinsics::AttributType->getContainedType(0));
 
 
   std::vector<Constant*> Elmts;
@@ -773,7 +773,7 @@
 
 Constant* JavaAOTCompiler::CreateConstantFromCommonClass(CommonClass* cl) {
   const StructType* STy = 
-    dyn_cast<StructType>(JnjvmModule::JavaCommonClassType->getContainedType(0));
+    dyn_cast<StructType>(J3Intrinsics::JavaCommonClassType->getContainedType(0));
   Module& Mod = *getLLVMModule();
   
   const llvm::Type* TempTy = 0;
@@ -797,17 +797,17 @@
       TempElmts.push_back(getNativeClass(cl->interfaces[i]));
     }
 
-    ATy = ArrayType::get(JnjvmModule::JavaClassType, cl->nbInterfaces);
+    ATy = ArrayType::get(J3Intrinsics::JavaClassType, cl->nbInterfaces);
     Constant* interfaces = ConstantArray::get(ATy, TempElmts);
     interfaces = new GlobalVariable(Mod, ATy, true,
                                     GlobalValue::InternalLinkage,
                                     interfaces, "");
     interfaces = ConstantExpr::getCast(Instruction::BitCast, interfaces,
-                            PointerType::getUnqual(JnjvmModule::JavaClassType));
+                            PointerType::getUnqual(J3Intrinsics::JavaClassType));
 
     CommonClassElts.push_back(interfaces);
   } else {
-    const Type* Ty = PointerType::getUnqual(JnjvmModule::JavaClassType);
+    const Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaClassType);
     CommonClassElts.push_back(Constant::getNullValue(Ty));
   }
 
@@ -821,21 +821,21 @@
   if (cl->super) {
     CommonClassElts.push_back(getNativeClass(cl->super));
   } else {
-    TempTy = JnjvmModule::JavaClassType;
+    TempTy = J3Intrinsics::JavaClassType;
     CommonClassElts.push_back(Constant::getNullValue(TempTy));
   }
 
   // classLoader: store the static initializer, it will be overriden once
   // the class is loaded.
   Constant* loader = ConstantExpr::getBitCast(StaticInitializer,
-                                              JnjvmModule::ptrType);
+                                              J3Intrinsics::ptrType);
   CommonClassElts.push_back(loader);
   
   // virtualTable
   if (cl->virtualVT) {
     CommonClassElts.push_back(getVirtualTable(cl->virtualVT));
   } else {
-    TempTy = JnjvmModule::VTType;
+    TempTy = J3Intrinsics::VTType;
     CommonClassElts.push_back(Constant::getNullValue(TempTy));
   }
   return ConstantStruct::get(STy, CommonClassElts);
@@ -843,13 +843,13 @@
 
 Constant* JavaAOTCompiler::CreateConstantFromJavaField(JavaField& field) {
   const StructType* STy = 
-    dyn_cast<StructType>(JnjvmModule::JavaFieldType->getContainedType(0));
+    dyn_cast<StructType>(J3Intrinsics::JavaFieldType->getContainedType(0));
   
   std::vector<Constant*> FieldElts;
   std::vector<Constant*> TempElts;
   
   // signature
-  FieldElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
+  FieldElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType));
   
   // access
   FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.access));
@@ -862,7 +862,7 @@
   
   // attributs 
   if (field.nbAttributs) {
-    const llvm::Type* AttrTy = JnjvmModule::AttributType->getContainedType(0);
+    const llvm::Type* AttrTy = J3Intrinsics::AttributType->getContainedType(0);
     const ArrayType* ATy = ArrayType::get(AttrTy, field.nbAttributs);
     for (uint32 i = 0; i < field.nbAttributs; ++i) {
       TempElts.push_back(CreateConstantFromAttribut(field.attributs[i]));
@@ -874,11 +874,11 @@
                                    GlobalValue::InternalLinkage,
                                    attributs, "");
     attributs = ConstantExpr::getCast(Instruction::BitCast, attributs,
-                                      JnjvmModule::AttributType);
+                                      J3Intrinsics::AttributType);
   
     FieldElts.push_back(attributs);
   } else {
-    FieldElts.push_back(Constant::getNullValue(JnjvmModule::AttributType));
+    FieldElts.push_back(Constant::getNullValue(J3Intrinsics::AttributType));
   }
   
   // nbAttributs
@@ -894,28 +894,28 @@
   FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.num));
 
   //JInfo
-  FieldElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
+  FieldElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType));
   
   return ConstantStruct::get(STy, FieldElts); 
 }
 
 Constant* JavaAOTCompiler::CreateConstantFromJavaMethod(JavaMethod& method) {
   const StructType* STy = 
-    dyn_cast<StructType>(JnjvmModule::JavaMethodType->getContainedType(0));
+    dyn_cast<StructType>(J3Intrinsics::JavaMethodType->getContainedType(0));
   Module& Mod = *getLLVMModule();
   
   std::vector<Constant*> MethodElts;
   std::vector<Constant*> TempElts;
   
   // signature
-  MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
+  MethodElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType));
   
   // access
   MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), method.access));
  
   // attributs
   if (method.nbAttributs) {
-    const llvm::Type* AttrTy = JnjvmModule::AttributType->getContainedType(0);
+    const llvm::Type* AttrTy = J3Intrinsics::AttributType->getContainedType(0);
     const ArrayType* ATy = ArrayType::get(AttrTy, method.nbAttributs);
     for (uint32 i = 0; i < method.nbAttributs; ++i) {
       TempElts.push_back(CreateConstantFromAttribut(method.attributs[i]));
@@ -927,11 +927,11 @@
                                    GlobalValue::InternalLinkage,
                                    attributs, "");
     attributs = ConstantExpr::getCast(Instruction::BitCast, attributs,
-                                      JnjvmModule::AttributType);
+                                      J3Intrinsics::AttributType);
 
     MethodElts.push_back(attributs);
   } else {
-    MethodElts.push_back(Constant::getNullValue(JnjvmModule::AttributType));
+    MethodElts.push_back(Constant::getNullValue(J3Intrinsics::AttributType));
   }
   
   // nbAttributs
@@ -951,16 +951,16 @@
 
   // code
   if (isAbstract(method.access)) {
-    MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
+    MethodElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType));
   } else {
     LLVMMethodInfo* LMI = getMethodInfo(&method);
     Function* func = LMI->getMethod();
     MethodElts.push_back(ConstantExpr::getCast(Instruction::BitCast, func,
-                                               JnjvmModule::ptrType));
+                                               J3Intrinsics::ptrType));
   }
   
   // codeInfo
-  MethodElts.push_back(Constant::getNullValue(JnjvmModule::CodeLineInfoType));
+  MethodElts.push_back(Constant::getNullValue(J3Intrinsics::CodeLineInfoType));
   
   // codeInfoLength
   MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), 0));
@@ -969,14 +969,14 @@
   MethodElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), method.offset));
 
   // JInfo
-  MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
+  MethodElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType));
   
   return ConstantStruct::get(STy, MethodElts); 
 }
 
 Constant* JavaAOTCompiler::CreateConstantFromClassPrimitive(ClassPrimitive* cl) {
   const llvm::Type* JCPTy = 
-    JnjvmModule::JavaClassPrimitiveType->getContainedType(0);
+    J3Intrinsics::JavaClassPrimitiveType->getContainedType(0);
   const StructType* STy = dyn_cast<StructType>(JCPTy);
   
   std::vector<Constant*> ClassElts;
@@ -992,7 +992,7 @@
 
 Constant* JavaAOTCompiler::CreateConstantFromClassArray(ClassArray* cl) {
   const StructType* STy = 
-    dyn_cast<StructType>(JnjvmModule::JavaClassArrayType->getContainedType(0));
+    dyn_cast<StructType>(J3Intrinsics::JavaClassArrayType->getContainedType(0));
   
   std::vector<Constant*> ClassElts;
   Constant* ClGEPs[2] = { getIntrinsics()->constantZero,
@@ -1003,7 +1003,7 @@
 
   // baseClass
   Constant* Cl = getNativeClass(cl->baseClass());
-  if (Cl->getType() != JnjvmModule::JavaCommonClassType)
+  if (Cl->getType() != J3Intrinsics::JavaCommonClassType)
     Cl = ConstantExpr::getGetElementPtr(Cl, ClGEPs, 2);
     
   ClassElts.push_back(Cl);
@@ -1013,7 +1013,7 @@
 
 Constant* JavaAOTCompiler::CreateConstantFromClass(Class* cl) {
   const StructType* STy = 
-    dyn_cast<StructType>(JnjvmModule::JavaClassType->getContainedType(0));
+    dyn_cast<StructType>(J3Intrinsics::JavaClassType->getContainedType(0));
   Module& Mod = *getLLVMModule();
   
   std::vector<Constant*> ClassElts;
@@ -1048,10 +1048,10 @@
   ClassElts.push_back(ConstantArray::get(ATy, CStr, 1));
 
   // thinlock
-  ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
+  ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType));
 
   if (cl->nbVirtualFields + cl->nbStaticFields) {
-    ATy = ArrayType::get(JnjvmModule::JavaFieldType->getContainedType(0),
+    ATy = ArrayType::get(J3Intrinsics::JavaFieldType->getContainedType(0),
                          cl->nbVirtualFields + cl->nbStaticFields);
   }
 
@@ -1082,9 +1082,9 @@
                                 GlobalValue::InternalLinkage,
                                 fields, "");
     fields = ConstantExpr::getCast(Instruction::BitCast, fields,
-                                   JnjvmModule::JavaFieldType);
+                                   J3Intrinsics::JavaFieldType);
   } else {
-    fields = Constant::getNullValue(JnjvmModule::JavaFieldType);
+    fields = Constant::getNullValue(J3Intrinsics::JavaFieldType);
   }
 
   // virtualFields
@@ -1098,14 +1098,14 @@
   // staticFields
   // Output null, getLLVMModule() will be set in  the initializer. Otherwise, the
   // assembly emitter of LLVM will try to align the data.
-  ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaFieldType));
+  ClassElts.push_back(Constant::getNullValue(J3Intrinsics::JavaFieldType));
 
   // nbStaticFields
   ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticFields));
   
   // virtualMethods
   if (cl->nbVirtualMethods + cl->nbStaticMethods) {
-    ATy = ArrayType::get(JnjvmModule::JavaMethodType->getContainedType(0),
+    ATy = ArrayType::get(J3Intrinsics::JavaMethodType->getContainedType(0),
                          cl->nbVirtualMethods + cl->nbStaticMethods);
   }
 
@@ -1132,9 +1132,9 @@
                                             methods, name);
     virtualMethods.insert(std::make_pair(cl, GV));
     methods = ConstantExpr::getCast(Instruction::BitCast, GV,
-                                    JnjvmModule::JavaMethodType);
+                                    J3Intrinsics::JavaMethodType);
   } else {
-    methods = Constant::getNullValue(JnjvmModule::JavaMethodType);
+    methods = Constant::getNullValue(J3Intrinsics::JavaMethodType);
   }
 
   // virtualMethods
@@ -1147,23 +1147,23 @@
   
   // staticMethods
   // Output null, getLLVMModule() will be set in  the initializer.
-  ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaMethodType));
+  ClassElts.push_back(Constant::getNullValue(J3Intrinsics::JavaMethodType));
 
   // nbStaticMethods
   ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticMethods));
 
   // ownerClass
-  ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
+  ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType));
   
   // bytes
-  ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaArrayUInt8Type));
+  ClassElts.push_back(Constant::getNullValue(J3Intrinsics::JavaArrayUInt8Type));
 
   // ctpInfo
-  ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
+  ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType));
 
   // attributs
   if (cl->nbAttributs) {
-    ATy = ArrayType::get(JnjvmModule::AttributType->getContainedType(0),
+    ATy = ArrayType::get(J3Intrinsics::AttributType->getContainedType(0),
                          cl->nbAttributs);
 
     for (uint32 i = 0; i < cl->nbAttributs; ++i) {
@@ -1176,10 +1176,10 @@
                                    GlobalValue::InternalLinkage,
                                    attributs, "");
     attributs = ConstantExpr::getCast(Instruction::BitCast, attributs,
-                                      JnjvmModule::AttributType);
+                                      J3Intrinsics::AttributType);
     ClassElts.push_back(attributs);
   } else {
-    ClassElts.push_back(Constant::getNullValue(JnjvmModule::AttributType));
+    ClassElts.push_back(Constant::getNullValue(J3Intrinsics::AttributType));
   }
   
   // nbAttributs
@@ -1191,7 +1191,7 @@
       TempElts.push_back(getNativeClass(cl->innerClasses[i]));
     }
 
-    const llvm::Type* TempTy = JnjvmModule::JavaClassType;
+    const llvm::Type* TempTy = J3Intrinsics::JavaClassType;
     ATy = ArrayType::get(TempTy, cl->nbInnerClasses);
     Constant* innerClasses = ConstantArray::get(ATy, TempElts);
     innerClasses = new GlobalVariable(*getLLVMModule(), ATy, true,
@@ -1202,7 +1202,7 @@
 
     ClassElts.push_back(innerClasses);
   } else {
-    const Type* Ty = PointerType::getUnqual(JnjvmModule::JavaClassType);
+    const Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaClassType);
     ClassElts.push_back(Constant::getNullValue(Ty));
   }
 
@@ -1213,7 +1213,7 @@
   if (cl->outerClass) {
     ClassElts.push_back(getNativeClass(cl->outerClass));
   } else {
-    ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaClassType));
+    ClassElts.push_back(Constant::getNullValue(J3Intrinsics::JavaClassType));
   }
 
   // innerAccess
@@ -1232,7 +1232,7 @@
   ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->staticSize));
 
   // JInfo
-  ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType));
+  ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType));
 
   return ConstantStruct::get(STy, ClassElts);
 }
@@ -1241,8 +1241,8 @@
 Constant* JavaAOTCompiler::CreateConstantFromIntArray(const T* val, const Type* Ty) {
   std::vector<const Type*> Elemts;
   const ArrayType* ATy = ArrayType::get(Ty, val->size);
-  Elemts.push_back(JnjvmModule::JavaObjectType->getContainedType(0));
-  Elemts.push_back(JnjvmModule::pointerSizeType);
+  Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0));
+  Elemts.push_back(J3Intrinsics::pointerSizeType);
   
 
   Elemts.push_back(ATy);
@@ -1251,7 +1251,7 @@
   
   std::vector<Constant*> Cts;
   Cts.push_back(CreateConstantForBaseObject(val->getClass()));
-  Cts.push_back(ConstantInt::get(JnjvmModule::pointerSizeType, val->size));
+  Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size));
   
   std::vector<Constant*> Vals;
   for (sint32 i = 0; i < val->size; ++i) {
@@ -1267,8 +1267,8 @@
 Constant* JavaAOTCompiler::CreateConstantFromFPArray(const T* val, const Type* Ty) {
   std::vector<const Type*> Elemts;
   const ArrayType* ATy = ArrayType::get(Ty, val->size);
-  Elemts.push_back(JnjvmModule::JavaObjectType->getContainedType(0));
-  Elemts.push_back(JnjvmModule::pointerSizeType);
+  Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0));
+  Elemts.push_back(J3Intrinsics::pointerSizeType);
   
 
   Elemts.push_back(ATy);
@@ -1277,7 +1277,7 @@
   
   std::vector<Constant*> Cts;
   Cts.push_back(CreateConstantForBaseObject(val->getClass()));
-  Cts.push_back(ConstantInt::get(JnjvmModule::pointerSizeType, val->size));
+  Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size));
   
   std::vector<Constant*> Vals;
   for (sint32 i = 0; i < val->size; ++i) {
@@ -1291,10 +1291,10 @@
 
 Constant* JavaAOTCompiler::CreateConstantFromObjectArray(const ArrayObject* val) {
   std::vector<const Type*> Elemts;
-  const llvm::Type* Ty = JnjvmModule::JavaObjectType;
+  const llvm::Type* Ty = J3Intrinsics::JavaObjectType;
   const ArrayType* ATy = ArrayType::get(Ty, val->size);
-  Elemts.push_back(JnjvmModule::JavaObjectType->getContainedType(0));
-  Elemts.push_back(JnjvmModule::pointerSizeType);
+  Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0));
+  Elemts.push_back(J3Intrinsics::pointerSizeType);
   
 
   Elemts.push_back(ATy);
@@ -1303,7 +1303,7 @@
   
   std::vector<Constant*> Cts;
   Cts.push_back(CreateConstantForBaseObject(val->getClass()));
-  Cts.push_back(ConstantInt::get(JnjvmModule::pointerSizeType, val->size));
+  Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size));
   
   std::vector<Constant*> Vals;
   for (sint32 i = 0; i < val->size; ++i) {
@@ -1311,7 +1311,7 @@
       Vals.push_back(getFinalObject(val->elements[i],
                                 val->getClass()->asArrayClass()->baseClass()));
     } else {
-      Vals.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType));
+      Vals.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType));
     }
   }
 
@@ -1323,7 +1323,7 @@
 Constant* JavaAOTCompiler::CreateConstantFromUTF8(const UTF8* val) {
   std::vector<const Type*> Elemts;
   const ArrayType* ATy = ArrayType::get(Type::getInt16Ty(getGlobalContext()), val->size);
-  Elemts.push_back(JnjvmModule::pointerSizeType);
+  Elemts.push_back(J3Intrinsics::pointerSizeType);
 
   Elemts.push_back(ATy);
 
@@ -1331,7 +1331,7 @@
                                           Elemts);
   
   std::vector<Constant*> Cts;
-  Cts.push_back(ConstantInt::get(JnjvmModule::pointerSizeType, val->size));
+  Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size));
   
   std::vector<Constant*> Vals;
   for (sint32 i = 0; i < val->size; ++i) {
@@ -1355,7 +1355,7 @@
                                                C, "");
     
     Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV,
-                                          JnjvmModule::UTF8Type);
+                                          J3Intrinsics::UTF8Type);
     utf8s.insert(std::make_pair(val, res));
 
     return res;
@@ -1372,7 +1372,7 @@
     VT : ClassArray::SuperArray->virtualVT;
 
   const ArrayType* ATy = 
-    dyn_cast<ArrayType>(JnjvmModule::VTType->getContainedType(0));
+    dyn_cast<ArrayType>(J3Intrinsics::VTType->getContainedType(0));
   const PointerType* PTy = dyn_cast<PointerType>(ATy->getContainedType(0));
   ATy = ArrayType::get(PTy, size);
 
@@ -1439,7 +1439,7 @@
         ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->nbSecondaryTypes), PTy));
   
   // secondaryTypes
-  const ArrayType* DTy = ArrayType::get(JnjvmModule::VTType,
+  const ArrayType* DTy = ArrayType::get(J3Intrinsics::VTType,
                                         VT->nbSecondaryTypes);
   
   std::vector<Constant*> TempElmts;
@@ -1479,7 +1479,7 @@
   
 
     const ArrayType* ATy = 
-      dyn_cast<ArrayType>(JnjvmModule::VTType->getContainedType(0));
+      dyn_cast<ArrayType>(J3Intrinsics::VTType->getContainedType(0));
     const PointerType* PTy = dyn_cast<PointerType>(ATy->getContainedType(0));
     ATy = ArrayType::get(PTy, InterfaceMethodTable::NumIndexes);
   
@@ -1525,7 +1525,7 @@
           uint32_t length = 2 * size;
         
           const ArrayType* ATy = 
-            dyn_cast<ArrayType>(JnjvmModule::VTType->getContainedType(0));
+            dyn_cast<ArrayType>(J3Intrinsics::VTType->getContainedType(0));
           ATy = ArrayType::get(PTy, length);
           std::vector<Constant*> InternalElemts;
      
@@ -1600,7 +1600,7 @@
   compileRT = false;
 
   std::vector<const llvm::Type*> llvmArgs;
-  llvmArgs.push_back(JnjvmModule::ptrType); // class loader.
+  llvmArgs.push_back(J3Intrinsics::ptrType); // class loader.
   const FunctionType* FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
 
   StaticInitializer = Function::Create(FTy, GlobalValue::InternalLinkage,
@@ -1612,9 +1612,9 @@
                               "staticCallback", getLLVMModule());
 
   llvmArgs.clear();
-  llvmArgs.push_back(JnjvmModule::JavaMethodType);
+  llvmArgs.push_back(J3Intrinsics::JavaMethodType);
   
-  FTy = FunctionType::get(JnjvmModule::ptrType, llvmArgs, false);
+  FTy = FunctionType::get(J3Intrinsics::ptrType, llvmArgs, false);
 
   NativeLoader = Function::Create(FTy, GlobalValue::ExternalLinkage,
                                   "vmjcNativeLoader", getLLVMModule());
@@ -1651,7 +1651,7 @@
   Module* Mod = getLLVMModule();
   for (Module::const_global_iterator i = Mod->global_begin(),
        e = Mod->global_end(); i != e; ++i) {
-    size += JnjvmModule::getTypeSize(i->getType());
+    size += J3Intrinsics::getTypeSize(i->getType());
   }
   fprintf(stderr, "%lluB\n", (unsigned long long int)size);
 }
@@ -1691,8 +1691,8 @@
 void JavaAOTCompiler::CreateStaticInitializer() {
 
   std::vector<const llvm::Type*> llvmArgs;
-  llvmArgs.push_back(JnjvmModule::ptrType); // class loader
-  llvmArgs.push_back(JnjvmModule::JavaCommonClassType); // cl
+  llvmArgs.push_back(J3Intrinsics::ptrType); // class loader
+  llvmArgs.push_back(J3Intrinsics::JavaCommonClassType); // cl
   const FunctionType* FTy =
     FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
 
@@ -1702,11 +1702,11 @@
  
   llvmArgs.clear();
   // class loader
-  llvmArgs.push_back(JnjvmModule::ptrType);
+  llvmArgs.push_back(J3Intrinsics::ptrType);
   // array ptr
-  llvmArgs.push_back(PointerType::getUnqual(JnjvmModule::JavaClassArrayType));
+  llvmArgs.push_back(PointerType::getUnqual(J3Intrinsics::JavaClassArrayType));
   // name
-  llvmArgs.push_back(JnjvmModule::UTF8Type);
+  llvmArgs.push_back(J3Intrinsics::UTF8Type);
   FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
   
   Function* GetClassArray = Function::Create(FTy, GlobalValue::ExternalLinkage,
@@ -1720,7 +1720,7 @@
   // If we have defined some strings.
   if (strings.begin() != strings.end()) {
     llvmArgs.clear();
-    llvmArgs.push_back(JnjvmModule::ptrType); // class loader
+    llvmArgs.push_back(J3Intrinsics::ptrType); // class loader
     llvmArgs.push_back(strings.begin()->second->getType()); // val
     FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
   
@@ -1741,7 +1741,7 @@
   // If we have defined some UTF8s.
   if (utf8s.begin() != utf8s.end()) {
     llvmArgs.clear();
-    llvmArgs.push_back(JnjvmModule::ptrType); // class loader
+    llvmArgs.push_back(J3Intrinsics::ptrType); // class loader
     llvmArgs.push_back(utf8s.begin()->second->getType()); // val
     FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false);
   
@@ -1763,7 +1763,7 @@
     if (isCompiling(i->first)) {
       Args[0] = loader;
       Args[1] = ConstantExpr::getBitCast(i->second,
-                                         JnjvmModule::JavaCommonClassType);
+                                         J3Intrinsics::JavaCommonClassType);
       CallInst::Create(AddClass, Args, Args + 2, "", currentBlock);
     }
   }

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sun Feb 14 16:07:42 2010
@@ -38,7 +38,8 @@
 #include "Jnjvm.h"
 #include "Reader.h"
 
-#include "j3/JnjvmModule.h"
+#include "j3/JavaLLVMCompiler.h"
+#include "j3/J3Intrinsics.h"
 
 using namespace j3;
 using namespace llvm;
@@ -119,11 +120,11 @@
   PHINode* node = 0;
 #if 0
   if (meth && !isAbstract(meth->access)) {
-    Value* cl = CallInst::Create(module->GetClassFunction, args[0], "",
+    Value* cl = CallInst::Create(intrinsics->GetClassFunction, args[0], "",
                                   currentBlock);
-    Value* cl2 = module->getNativeClass(meth->classDef);
-    if (cl2->getType() != module->JavaCommonClassType) {
-      cl2 = new BitCastInst(cl2, module->JavaCommonClassType, "", currentBlock);
+    Value* cl2 = intrinsics->getNativeClass(meth->classDef);
+    if (cl2->getType() != intrinsics->JavaCommonClassType) {
+      cl2 = new BitCastInst(cl2, intrinsics->JavaCommonClassType, "", currentBlock);
     }
 
     Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, cl, cl2, "");
@@ -137,7 +138,7 @@
     if (canBeInlined(meth)) {
       res = invokeInline(meth, args);
     } else {
-      Function* func = module->getMethod(meth);
+      Function* func = intrinsics->getMethod(meth);
       res = invoke(func, args, "", currentBlock);
     }
     BranchInst::Create(endBlock, currentBlock);
@@ -149,10 +150,10 @@
   }
 #endif
 
-  Value* VT = CallInst::Create(module->GetVTFunction, args[0], "",
+  Value* VT = CallInst::Create(intrinsics->GetVTFunction, args[0], "",
                                currentBlock);
   Value* indexes2[2];
-  indexes2[0] = module->constantZero;
+  indexes2[0] = intrinsics->constantZero;
 
 #ifdef ISOLATE_SHARING
   Value* indexesCtp; //[3];
@@ -171,7 +172,7 @@
                                             Type::getInt32Ty(*llvmContext),
                                             false,
                                             GlobalValue::ExternalLinkage,
-                                            module->constantZero, "");
+                                            intrinsics->constantZero, "");
     
     BasicBlock* resolveVirtual = createBasicBlock("resolveVirtual");
     BasicBlock* endResolveVirtual = createBasicBlock("endResolveVirtual");
@@ -180,7 +181,7 @@
 
     Value* load = new LoadInst(GV, "", false, currentBlock);
     Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, load,
-                               module->constantZero, "");
+                               intrinsics->constantZero, "");
     BranchInst::Create(resolveVirtual, endResolveVirtual, test, currentBlock);
     node->addIncoming(load, currentBlock);
     currentBlock = resolveVirtual;
@@ -189,14 +190,14 @@
     Args.push_back(ConstantInt::get(Type::getInt32Ty(*llvmContext), index));
     Args.push_back(GV);
     Args.push_back(args[0]);
-    load = invoke(module->VirtualLookupFunction, Args, "", currentBlock);
+    load = invoke(intrinsics->VirtualLookupFunction, Args, "", currentBlock);
     node->addIncoming(load, currentBlock);
     BranchInst::Create(endResolveVirtual, currentBlock);
     currentBlock = endResolveVirtual;
 
     indexes2[1] = node;
 #ifdef ISOLATE_SHARING
-    Value* mul = BinaryOperator::CreateMul(val, module->constantMinusOne,
+    Value* mul = BinaryOperator::CreateMul(val, intrinsics->constantMinusOne,
                                            "", currentBlock);
     indexesCtp = mul;
 #endif
@@ -212,7 +213,7 @@
   Value* CTP = GetElementPtrInst::Create(VT, indexesCtp, "", currentBlock);
     
   CTP = new LoadInst(CTP, "", currentBlock);
-  CTP = new BitCastInst(CTP, module->ConstantPoolType, "", currentBlock);
+  CTP = new BitCastInst(CTP, intrinsics->ConstantPoolType, "", currentBlock);
   args.push_back(CTP);
 #endif
   Value* val = invoke(Func, args, "", currentBlock);
@@ -227,13 +228,13 @@
   }
 
   if (retType != Type::getVoidTy(getGlobalContext())) {
-    if (retType == module->JavaObjectType) {
+    if (retType == intrinsics->JavaObjectType) {
       JnjvmClassLoader* JCL = compilingClass->classLoader;
       push(val, false, signature->getReturnType()->findAssocClass(JCL));
     } else {
       push(val, retTypedef->isUnsigned());
       if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) {
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
       }
     }
   }
@@ -244,11 +245,11 @@
 }
 
 llvm::Value* JavaJIT::getCurrentThread(const llvm::Type* Ty) {
-  Value* FrameAddr = CallInst::Create(module->llvm_frameaddress,
-                                     	module->constantZero, "", currentBlock);
-  Value* threadId = new PtrToIntInst(FrameAddr, module->pointerSizeType, "",
+  Value* FrameAddr = CallInst::Create(intrinsics->llvm_frameaddress,
+                                     	intrinsics->constantZero, "", currentBlock);
+  Value* threadId = new PtrToIntInst(FrameAddr, intrinsics->pointerSizeType, "",
                               			 currentBlock);
-  threadId = BinaryOperator::CreateAnd(threadId, module->constantThreadIDMask,
+  threadId = BinaryOperator::CreateAnd(threadId, intrinsics->constantThreadIDMask,
                                        "", currentBlock);
   threadId = new IntToPtrInst(threadId, Ty, "", currentBlock);
 
@@ -286,7 +287,7 @@
   
   if (!natPtr && !TheCompiler->isStaticCompiling()) {
     currentBlock = createBasicBlock("start");
-    CallInst::Create(module->ThrowExceptionFromJITFunction, "", currentBlock);
+    CallInst::Create(intrinsics->ThrowExceptionFromJITFunction, "", currentBlock);
     if (returnType != Type::getVoidTy(getGlobalContext()))
       ReturnInst::Create(*llvmContext, Constant::getNullValue(returnType), currentBlock);
     else
@@ -319,7 +320,7 @@
   // Allocate currentLocalIndexNumber pointer
   Value* temp = new AllocaInst(Type::getInt32Ty(getGlobalContext()), "",
                                currentBlock);
-  new StoreInst(module->constantZero, temp, false, currentBlock);
+  new StoreInst(intrinsics->constantZero, temp, false, currentBlock);
   
   // Allocate oldCurrentLocalIndexNumber pointer
   Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "",
@@ -336,15 +337,15 @@
   std::vector<Value*> nativeArgs;
   
   
-  Value* threadId = getCurrentThread(module->JavaThreadType);
+  Value* threadId = getCurrentThread(intrinsics->JavaThreadType);
 
-  Value* geps[2] = { module->constantZero,
-                     module->OffsetJNIInThreadConstant };
+  Value* geps[2] = { intrinsics->constantZero,
+                     intrinsics->OffsetJNIInThreadConstant };
 
   Value* jniEnv = GetElementPtrInst::Create(threadId, geps, geps + 2, "",
                                             currentBlock);
  
-  jniEnv = new BitCastInst(jniEnv, module->ptrType, "", currentBlock);
+  jniEnv = new BitCastInst(jniEnv, intrinsics->ptrType, "", currentBlock);
 
   nativeArgs.push_back(jniEnv);
 
@@ -352,7 +353,7 @@
   if (stat) {
 #ifdef ISOLATE_SHARING
     Value* val = getClassCtp();
-    Value* cl = CallInst::Create(module->GetClassDelegateePtrFunction,
+    Value* cl = CallInst::Create(intrinsics->GetClassDelegateePtrFunction,
                                  val, "", currentBlock);
 #else
     Value* cl = TheCompiler->getJavaClassPtr(compilingClass);
@@ -365,31 +366,31 @@
   for (Function::arg_iterator i = func->arg_begin(); 
        index < nargs; ++i, ++index) {
     
-    if (i->getType() == module->JavaObjectType) {
+    if (i->getType() == intrinsics->JavaObjectType) {
       BasicBlock* BB = createBasicBlock("");
       BasicBlock* NotZero = createBasicBlock("");
-      const Type* Ty = PointerType::getUnqual(module->JavaObjectType);
+      const Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType);
       PHINode* node = PHINode::Create(Ty, "", BB);
 
       Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, i,
-                                 module->JavaObjectNullConstant, "");
+                                 intrinsics->JavaObjectNullConstant, "");
 
       node->addIncoming(Constant::getNullValue(Ty), currentBlock);
       BranchInst::Create(BB, NotZero, test, currentBlock);
 
       currentBlock = NotZero;
 
-      Instruction* temp = new AllocaInst(module->JavaObjectType, "",
+      Instruction* temp = new AllocaInst(intrinsics->JavaObjectType, "",
                                          func->begin()->getTerminator());
       
       if (TheCompiler->useCooperativeGC()) {
         Value* GCArgs[2] = { 
-          new BitCastInst(temp, module->ptrPtrType, "",
+          new BitCastInst(temp, intrinsics->ptrPtrType, "",
                           func->begin()->getTerminator()),
-          module->constantPtrNull
+          intrinsics->constantPtrNull
         };
         
-        CallInst::Create(module->llvm_gc_gcroot, GCArgs, GCArgs + 2, "",
+        CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, GCArgs + 2, "",
                          func->begin()->getTerminator());
       }
       
@@ -407,21 +408,21 @@
   
   
   Instruction* ResultObject = 0;
-  if (returnType == module->JavaObjectType) {
-    ResultObject = new AllocaInst(module->JavaObjectType, "",
+  if (returnType == intrinsics->JavaObjectType) {
+    ResultObject = new AllocaInst(intrinsics->JavaObjectType, "",
                                   func->begin()->begin());
     
     if (TheCompiler->useCooperativeGC()) {
       
       Value* GCArgs[2] = { 
-        new BitCastInst(ResultObject, module->ptrPtrType, "", currentBlock),
-        module->constantPtrNull
+        new BitCastInst(ResultObject, intrinsics->ptrPtrType, "", currentBlock),
+        intrinsics->constantPtrNull
       };
       
-      CallInst::Create(module->llvm_gc_gcroot, GCArgs, GCArgs + 2, "",
+      CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, GCArgs + 2, "",
                        currentBlock);
     } else {
-      new StoreInst(module->JavaObjectNullConstant, ResultObject, "",
+      new StoreInst(intrinsics->JavaObjectNullConstant, ResultObject, "",
                     currentBlock);
     }
   }
@@ -457,19 +458,19 @@
   
   Value* Args4[3] = { temp, oldCLIN, Frame };
 
-  CallInst::Create(module->StartJNIFunction, Args4, Args4 + 3, "",
+  CallInst::Create(intrinsics->StartJNIFunction, Args4, Args4 + 3, "",
                    currentBlock);
   
   Value* result = llvm::CallInst::Create(nativeFunc, nativeArgs.begin(),
                                          nativeArgs.end(), "", currentBlock);
 
-  if (returnType == module->JavaObjectType) {
-    const Type* Ty = PointerType::getUnqual(module->JavaObjectType);
+  if (returnType == intrinsics->JavaObjectType) {
+    const Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType);
     Constant* C = Constant::getNullValue(Ty);
     Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, result, C, "");
     BasicBlock* loadBlock = createBasicBlock("");
 
-    endNode->addIncoming(module->JavaObjectNullConstant, currentBlock);
+    endNode->addIncoming(intrinsics->JavaObjectNullConstant, currentBlock);
     BranchInst::Create(endBlock, loadBlock, cmp, currentBlock);
 
     currentBlock = loadBlock;
@@ -488,7 +489,7 @@
  
   Value* Args2[1] = { oldCLIN };
 
-  CallInst::Create(module->EndJNIFunction, Args2, Args2 + 1, "", currentBlock);
+  CallInst::Create(intrinsics->EndJNIFunction, Args2, Args2 + 1, "", currentBlock);
   
   // Synchronize after leaving native.
   if (isSynchro(compilingMethod->access))
@@ -509,23 +510,23 @@
 
 void JavaJIT::monitorEnter(Value* obj) {
   std::vector<Value*> gep;
-  gep.push_back(module->constantZero);
-  gep.push_back(module->JavaObjectLockOffsetConstant);
+  gep.push_back(intrinsics->constantZero);
+  gep.push_back(intrinsics->JavaObjectLockOffsetConstant);
   Value* lockPtr = GetElementPtrInst::Create(obj, gep.begin(), gep.end(), "",
                                              currentBlock);
   
   Value* lock = new LoadInst(lockPtr, "", currentBlock);
-  lock = new PtrToIntInst(lock, module->pointerSizeType, "", currentBlock);
-  Value* GCMask = ConstantInt::get(module->pointerSizeType,
+  lock = new PtrToIntInst(lock, intrinsics->pointerSizeType, "", currentBlock);
+  Value* GCMask = ConstantInt::get(intrinsics->pointerSizeType,
                                    mvm::GCMask);
 
   lock = BinaryOperator::CreateAnd(lock, GCMask, "", currentBlock);
 
   lockPtr = new BitCastInst(lockPtr, 
-                            PointerType::getUnqual(module->pointerSizeType),
+                            PointerType::getUnqual(intrinsics->pointerSizeType),
                             "", currentBlock);
-  Value* threadId = getCurrentThread(module->MutatorThreadType);
-  threadId = new PtrToIntInst(threadId, module->pointerSizeType, "",
+  Value* threadId = getCurrentThread(intrinsics->MutatorThreadType);
+  threadId = new PtrToIntInst(threadId, intrinsics->pointerSizeType, "",
                               currentBlock);
   Value* newValMask = BinaryOperator::CreateOr(threadId, lock, "",
                                                currentBlock);
@@ -536,7 +537,7 @@
   atomicArgs.push_back(newValMask);
 
   // Do the atomic compare and swap.
-  Value* atomic = CallInst::Create(module->llvm_atomic_lcs_ptr,
+  Value* atomic = CallInst::Create(intrinsics->llvm_atomic_lcs_ptr,
                                    atomicArgs.begin(), atomicArgs.end(), "",
                                    currentBlock);
   
@@ -553,17 +554,17 @@
   currentBlock = NotOK;
   
   // The compare and swap did not pass, look if it's a thin lock
-  Value* isThin = BinaryOperator::CreateAnd(atomic, module->constantFatMask, "",
+  Value* isThin = BinaryOperator::CreateAnd(atomic, intrinsics->constantFatMask, "",
                                             currentBlock);
   cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, isThin,
-                     module->constantPtrZero, "");
+                     intrinsics->constantPtrZero, "");
   
   BranchInst::Create(ThinLockBB, FatLockBB, cmp, currentBlock);
 
   // It's a thin lock. Look if we're the owner of this lock.
   currentBlock = ThinLockBB;
-  Value* idMask = ConstantInt::get(module->pointerSizeType, mvm::Thread::IDMask);
-  Value* cptMask = ConstantInt::get(module->pointerSizeType, mvm::ThinCountMask);
+  Value* idMask = ConstantInt::get(intrinsics->pointerSizeType, mvm::Thread::IDMask);
+  Value* cptMask = ConstantInt::get(intrinsics->pointerSizeType, mvm::ThinCountMask);
   Value* IdInLock = BinaryOperator::CreateAnd(atomic, idMask, "", currentBlock);
   Value* owner = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, threadId,
                               IdInLock, "");
@@ -584,7 +585,7 @@
   currentBlock = IncCounterBB;
   
   // The counter will not overflow, increment it.
-  Value* One = ConstantInt::get(module->pointerSizeType, mvm::ThinCountAdd);
+  Value* One = ConstantInt::get(intrinsics->pointerSizeType, mvm::ThinCountAdd);
   Value* Add = BinaryOperator::CreateAdd(One, atomic, "", currentBlock);
   new StoreInst(Add, lockPtr, false, currentBlock);
   BranchInst::Create(OK, currentBlock);
@@ -593,33 +594,33 @@
 
   // The counter will overflow, call this function to create a new lock,
   // lock it 0x101 times, and pass.
-  CallInst::Create(module->OverflowThinLockFunction, obj, "",
+  CallInst::Create(intrinsics->OverflowThinLockFunction, obj, "",
                    currentBlock);
   BranchInst::Create(OK, currentBlock);
   
   currentBlock = FatLockBB;
   // Either it's a fat lock or there is contention.
-  CallInst::Create(module->AquireObjectFunction, obj, "", currentBlock);
+  CallInst::Create(intrinsics->AquireObjectFunction, obj, "", currentBlock);
   BranchInst::Create(OK, currentBlock);
   currentBlock = OK;
 }
 
 void JavaJIT::monitorExit(Value* obj) {
   std::vector<Value*> gep;
-  gep.push_back(module->constantZero);
-  gep.push_back(module->JavaObjectLockOffsetConstant);
+  gep.push_back(intrinsics->constantZero);
+  gep.push_back(intrinsics->JavaObjectLockOffsetConstant);
   Value* lockPtr = GetElementPtrInst::Create(obj, gep.begin(), gep.end(), "",
                                              currentBlock);
   lockPtr = new BitCastInst(lockPtr, 
-                            PointerType::getUnqual(module->pointerSizeType),
+                            PointerType::getUnqual(intrinsics->pointerSizeType),
                             "", currentBlock);
   Value* lock = new LoadInst(lockPtr, "", currentBlock);
-  Value* GCMask = ConstantInt::get(module->pointerSizeType, ~mvm::GCMask);
+  Value* GCMask = ConstantInt::get(intrinsics->pointerSizeType, ~mvm::GCMask);
 
   Value* lockedMask = BinaryOperator::CreateAnd(lock, GCMask, "", currentBlock);
   
-  Value* threadId = getCurrentThread(module->MutatorThreadType);
-  threadId = new PtrToIntInst(threadId, module->pointerSizeType, "",
+  Value* threadId = getCurrentThread(intrinsics->MutatorThreadType);
+  threadId = new PtrToIntInst(threadId, intrinsics->pointerSizeType, "",
                               currentBlock);
   
   Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, lockedMask,
@@ -637,24 +638,24 @@
   
   // Locked once, set zero
   currentBlock = LockedOnceBB;
-  GCMask = ConstantInt::get(module->pointerSizeType, mvm::GCMask);
+  GCMask = ConstantInt::get(intrinsics->pointerSizeType, mvm::GCMask);
   lockedMask = BinaryOperator::CreateAnd(lock, GCMask, "", currentBlock);
   new StoreInst(lockedMask, lockPtr, false, currentBlock);
   BranchInst::Create(EndUnlock, currentBlock);
 
   currentBlock = NotLockedOnceBB;
   // Look if the lock is thin.
-  Value* isThin = BinaryOperator::CreateAnd(lock, module->constantFatMask, "",
+  Value* isThin = BinaryOperator::CreateAnd(lock, intrinsics->constantFatMask, "",
                                             currentBlock);
   cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, isThin,
-                     module->constantPtrZero, "");
+                     intrinsics->constantPtrZero, "");
   
   BranchInst::Create(ThinLockBB, FatLockBB, cmp, currentBlock);
   
   currentBlock = ThinLockBB;
 
   // Decrement the counter.
-  Value* One = ConstantInt::get(module->pointerSizeType, mvm::ThinCountAdd);
+  Value* One = ConstantInt::get(intrinsics->pointerSizeType, mvm::ThinCountAdd);
   Value* Sub = BinaryOperator::CreateSub(lock, One, "", currentBlock);
   new StoreInst(Sub, lockPtr, false, currentBlock);
   BranchInst::Create(EndUnlock, currentBlock);
@@ -662,7 +663,7 @@
   currentBlock = FatLockBB;
 
   // Either it's a fat lock or there is contention.
-  CallInst::Create(module->ReleaseObjectFunction, obj, "", currentBlock);
+  CallInst::Create(intrinsics->ReleaseObjectFunction, obj, "", currentBlock);
   BranchInst::Create(EndUnlock, currentBlock);
   currentBlock = EndUnlock;
 }
@@ -672,7 +673,7 @@
 #ifdef ISOLATE_SHARING
 Value* JavaJIT::getStaticInstanceCtp() {
   Value* cl = getClassCtp();
-  Value* indexes[2] = { module->constantZero, module->constantSeven };
+  Value* indexes[2] = { intrinsics->constantZero, module->constantSeven };
   Value* arg1 = GetElementPtrInst::Create(cl, indexes, indexes + 2,
                                           "", currentBlock);
   arg1 = new LoadInst(arg1, "", false, currentBlock);
@@ -681,11 +682,11 @@
 }
 
 Value* JavaJIT::getClassCtp() {
-  Value* indexes = module->constantOne;
+  Value* indexes = intrinsics->constantOne;
   Value* arg1 = GetElementPtrInst::Create(ctpCache, indexes.begin(),
                                           indexes.end(),  "", currentBlock);
   arg1 = new LoadInst(arg1, "", false, currentBlock);
-  arg1 = new BitCastInst(arg1, module->JavaClassType, "", currentBlock);
+  arg1 = new BitCastInst(arg1, intrinsics->JavaClassType, "", currentBlock);
   return arg1;
 }
 #endif
@@ -726,7 +727,7 @@
 }
   
 static void removeUnusedObjects(std::vector<AllocaInst*>& objects,
-                                JnjvmModule* module, bool coop) {
+                                J3Intrinsics* intrinsics, bool coop) {
   for (std::vector<AllocaInst*>::iterator i = objects.begin(),
        e = objects.end(); i != e; ++i) {
     AllocaInst* temp = *i;
@@ -738,10 +739,10 @@
       temp->eraseFromParent();
     } else {
       if (coop) {
-        Instruction* I = new BitCastInst(temp, module->ptrPtrType, "");
+        Instruction* I = new BitCastInst(temp, intrinsics->ptrPtrType, "");
         I->insertAfter(temp);
-        Value* GCArgs[2] = { I, module->constantPtrNull };
-        Instruction* C = CallInst::Create(module->llvm_gc_gcroot, GCArgs,
+        Value* GCArgs[2] = { I, intrinsics->constantPtrNull };
+        Instruction* C = CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs,
                                           GCArgs + 2, "");
         C->insertAfter(I);
       }
@@ -808,15 +809,15 @@
       new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, firstInstruction);
       floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstInstruction));
       new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, firstInstruction);
-      objectLocals.push_back(new AllocaInst(module->JavaObjectType, "",
+      objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, "",
                                           firstInstruction));
      
       // The GCStrategy will already initialize the value.
       if (!TheCompiler->useCooperativeGC())
-        new StoreInst(Constant::getNullValue(module->JavaObjectType), objectLocals.back(), false, firstInstruction);
+        new StoreInst(Constant::getNullValue(intrinsics->JavaObjectType), objectLocals.back(), false, firstInstruction);
     }
     for (int i = 0; i < maxStack; i++) {
-      objectStack.push_back(new AllocaInst(module->JavaObjectType, "",
+      objectStack.push_back(new AllocaInst(intrinsics->JavaObjectType, "",
                                            firstInstruction));
       addHighLevelType(objectStack.back(), upcalls->OfObject);
       intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstInstruction));
@@ -836,15 +837,15 @@
       new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, firstBB);
       floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstBB));
       new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, firstBB);
-      objectLocals.push_back(new AllocaInst(module->JavaObjectType, "",
+      objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, "",
                                             firstBB));
       // The GCStrategy will already initialize the value.
       if (!TheCompiler->useCooperativeGC())
-        new StoreInst(Constant::getNullValue(module->JavaObjectType), objectLocals.back(), false, firstBB);
+        new StoreInst(Constant::getNullValue(intrinsics->JavaObjectType), objectLocals.back(), false, firstBB);
     }
     
     for (int i = 0; i < maxStack; i++) {
-      objectStack.push_back(new AllocaInst(module->JavaObjectType, "",
+      objectStack.push_back(new AllocaInst(intrinsics->JavaObjectType, "",
                                            firstBB));
       addHighLevelType(objectStack.back(), upcalls->OfObject);
       intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstBB));
@@ -947,8 +948,8 @@
   removeUnusedLocals(floatStack);
   removeUnusedLocals(longStack);
   
-  removeUnusedObjects(objectLocals, module, TheCompiler->useCooperativeGC());
-  removeUnusedObjects(objectStack, module, TheCompiler->useCooperativeGC());
+  removeUnusedObjects(objectLocals, intrinsics, TheCompiler->useCooperativeGC());
+  removeUnusedObjects(objectStack, intrinsics, TheCompiler->useCooperativeGC());
 
 
   delete[] opcodeInfos;
@@ -1000,7 +1001,7 @@
     {
     Value* arg = TheCompiler->getMethodInClass(compilingMethod);
 
-    llvm::CallInst::Create(module->PrintMethodStartFunction, arg, "",
+    llvm::CallInst::Create(intrinsics->PrintMethodStartFunction, arg, "",
                            currentBlock);
     }
 #endif
@@ -1016,15 +1017,15 @@
     new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, currentBlock);
     floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", currentBlock));
     new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, currentBlock);
-    objectLocals.push_back(new AllocaInst(module->JavaObjectType, "",
+    objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, "",
                                           currentBlock));
     // The GCStrategy will already initialize the value.
     if (!TheCompiler->useCooperativeGC())
-      new StoreInst(Constant::getNullValue(module->JavaObjectType), objectLocals.back(), false, currentBlock);
+      new StoreInst(Constant::getNullValue(intrinsics->JavaObjectType), objectLocals.back(), false, currentBlock);
   }
   
   for (int i = 0; i < maxStack; i++) {
-    objectStack.push_back(new AllocaInst(module->JavaObjectType, "",
+    objectStack.push_back(new AllocaInst(intrinsics->JavaObjectType, "",
                                          currentBlock));
     addHighLevelType(objectStack.back(), upcalls->OfObject);
     intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", currentBlock));
@@ -1082,7 +1083,7 @@
 
 #if defined(ISOLATE_SHARING)
   ctpCache = i;
-  Value* addrCtpCache = new AllocaInst(module->ConstantPoolType, "",
+  Value* addrCtpCache = new AllocaInst(intrinsics->ConstantPoolType, "",
                                        currentBlock);
   /// make it volatile to be sure it's on the stack
   new StoreInst(ctpCache, addrCtpCache, true, currentBlock);
@@ -1099,16 +1100,16 @@
   Value* NewIsolate = 0;
   Value* IsolatePtr = 0;
   if (loader != loader->bootstrapLoader && isPublic(compilingMethod->access)) {
-    threadId = getCurrentThread(module->MutatorThreadType);
+    threadId = getCurrentThread(intrinsics->MutatorThreadType);
      
-    IsolateIDPtr = GetElementPtrInst::Create(threadId, module->constantThree,
+    IsolateIDPtr = GetElementPtrInst::Create(threadId, intrinsics->constantThree,
                                              "", currentBlock);
-    const Type* realType = PointerType::getUnqual(module->pointerSizeType);
+    const Type* realType = PointerType::getUnqual(intrinsics->pointerSizeType);
     IsolateIDPtr = new BitCastInst(IsolateIDPtr, realType, "",
                                    currentBlock);
     OldIsolateID = new LoadInst(IsolateIDPtr, "", currentBlock);
 
-    Value* MyID = ConstantInt::get(module->pointerSizeType,
+    Value* MyID = ConstantInt::get(intrinsics->pointerSizeType,
                                    loader->getIsolate()->IsolateID);
     Cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, OldIsolateID, MyID,
                        "");
@@ -1121,16 +1122,16 @@
     currentBlock = ServiceBB;
   
     new StoreInst(MyID, IsolateIDPtr, currentBlock);
-    IsolatePtr = GetElementPtrInst::Create(threadId, module->constantFour, "",
+    IsolatePtr = GetElementPtrInst::Create(threadId, intrinsics->constantFour, "",
                                            currentBlock);
      
     OldIsolate = new LoadInst(IsolatePtr, "", currentBlock);
-    NewIsolate = module->getIsolate(loader->getIsolate(), currentBlock);
+    NewIsolate = intrinsics->getIsolate(loader->getIsolate(), currentBlock);
     new StoreInst(NewIsolate, IsolatePtr, currentBlock);
 
 #if DEBUG
     Value* GEP[2] = { OldIsolate, NewIsolate };
-    CallInst::Create(module->ServiceCallStartFunction, GEP, GEP + 2,
+    CallInst::Create(intrinsics->ServiceCallStartFunction, GEP, GEP + 2,
                      "", currentBlock);
 #endif
     BranchInst::Create(EndBB, currentBlock);
@@ -1172,30 +1173,30 @@
     // Variables have been allocated and the lock has been taken. Do the stack
     // check now: if there is an exception, we will go to the lock release code.
     currentExceptionBlock = opcodeInfos[0].exceptionBlock;
-    Value* FrameAddr = CallInst::Create(module->llvm_frameaddress,
-                                       	module->constantZero, "", currentBlock);
-    FrameAddr = new PtrToIntInst(FrameAddr, module->pointerSizeType, "",
+    Value* FrameAddr = CallInst::Create(intrinsics->llvm_frameaddress,
+                                       	intrinsics->constantZero, "", currentBlock);
+    FrameAddr = new PtrToIntInst(FrameAddr, intrinsics->pointerSizeType, "",
                                  currentBlock);
     Value* stackCheck = 
-      BinaryOperator::CreateAnd(FrameAddr, module->constantStackOverflowMask,
+      BinaryOperator::CreateAnd(FrameAddr, intrinsics->constantStackOverflowMask,
                                 "", currentBlock);
 
     stackCheck = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, stackCheck,
-                              module->constantPtrZero, "");
+                              intrinsics->constantPtrZero, "");
     BasicBlock* stackOverflow = createBasicBlock("stack overflow");
     BasicBlock* noStackOverflow = createBasicBlock("no stack overflow");
     BranchInst::Create(stackOverflow, noStackOverflow, stackCheck,
                        currentBlock);
     currentBlock = stackOverflow;
-    throwException(module->StackOverflowErrorFunction, 0, 0);
+    throwException(intrinsics->StackOverflowErrorFunction, 0, 0);
     currentBlock = noStackOverflow;
   }
   
   if (TheCompiler->useCooperativeGC()) {
-    Value* threadId = getCurrentThread(module->MutatorThreadType);
+    Value* threadId = getCurrentThread(intrinsics->MutatorThreadType);
     
-    Value* GEP[2] = { module->constantZero, 
-                      module->OffsetDoYieldInThreadConstant };
+    Value* GEP[2] = { intrinsics->constantZero, 
+                      intrinsics->OffsetDoYieldInThreadConstant };
     
     Value* YieldPtr = GetElementPtrInst::Create(threadId, GEP, GEP + 2, "",
                                                 currentBlock);
@@ -1207,7 +1208,7 @@
     BranchInst::Create(yieldBlock, continueBlock, Yield, currentBlock);
 
     currentBlock = yieldBlock;
-    CallInst::Create(module->conditionalSafePoint, "", currentBlock);
+    CallInst::Create(intrinsics->conditionalSafePoint, "", currentBlock);
     BranchInst::Create(continueBlock, currentBlock);
 
     currentBlock = continueBlock;
@@ -1243,7 +1244,7 @@
 #if JNJVM_EXECUTE > 0
     {
     Value* arg = TheCompiler->getMethodInClass(compilingMethod); 
-    CallInst::Create(module->PrintMethodEndFunction, arg, "", currentBlock);
+    CallInst::Create(intrinsics->PrintMethodEndFunction, arg, "", currentBlock);
     }
 #endif
   
@@ -1261,7 +1262,7 @@
 
 #if DEBUG
     Value* GEP[2] = { OldIsolate, NewIsolate };
-    CallInst::Create(module->ServiceCallStopFunction, GEP, GEP + 2,
+    CallInst::Create(intrinsics->ServiceCallStopFunction, GEP, GEP + 2,
                      "", currentBlock);
 #endif
     BranchInst::Create(EndBB, currentBlock);
@@ -1293,8 +1294,8 @@
   removeUnusedLocals(floatStack);
   removeUnusedLocals(longStack);
   
-  removeUnusedObjects(objectLocals, module, TheCompiler->useCooperativeGC());
-  removeUnusedObjects(objectStack, module, TheCompiler->useCooperativeGC());
+  removeUnusedObjects(objectLocals, intrinsics, TheCompiler->useCooperativeGC());
+  removeUnusedObjects(objectStack, intrinsics, TheCompiler->useCooperativeGC());
  
   delete[] opcodeInfos;
 
@@ -1330,9 +1331,9 @@
 }
 
 void JavaJIT::compareFP(Value* val1, Value* val2, const Type* ty, bool l) {
-  Value* one = module->constantOne;
-  Value* zero = module->constantZero;
-  Value* minus = module->constantMinusOne;
+  Value* one = intrinsics->constantOne;
+  Value* zero = intrinsics->constantZero;
+  Value* minus = intrinsics->constantMinusOne;
 
   Value* c = new FCmpInst(*currentBlock, FCmpInst::FCMP_UGT, val1, val2, "");
   Value* r = llvm::SelectInst::Create(c, one, zero, "", currentBlock);
@@ -1367,8 +1368,8 @@
         push(val, false, upcalls->newString);
       } else {
         // Lookup the constant pool cache
-        const llvm::Type* Ty = PointerType::getUnqual(module->JavaObjectType);
-        Value* val = getConstantPoolAt(index, module->StringLookupFunction,
+        const llvm::Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType);
+        Value* val = getConstantPoolAt(index, intrinsics->StringLookupFunction,
                                        Ty, 0, false);
         val = new LoadInst(val, "", currentBlock);
         push(val, false, upcalls->newString);
@@ -1391,7 +1392,7 @@
     UserCommonClass* cl = 0;
     Value* res = getResolvedCommonClass(index, false, &cl);
 
-    res = CallInst::Create(module->GetClassDelegateeFunction, res, "",
+    res = CallInst::Create(intrinsics->GetClassDelegateeFunction, res, "",
                            currentBlock);
     push(res, false, upcalls->newClass);
   } else {
@@ -1406,7 +1407,7 @@
 void JavaJIT::JITVerifyNull(Value* obj) {
 
   if (TheCompiler->hasExceptionsEnabled()) {
-    Constant* zero = module->JavaObjectNullConstant;
+    Constant* zero = intrinsics->JavaObjectNullConstant;
     Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj, zero, "");
 
     BasicBlock* exit = createBasicBlock("verifyNullExit");
@@ -1414,7 +1415,7 @@
 
     BranchInst::Create(exit, cont, test, currentBlock);
     currentBlock = exit;
-    throwException(module->NullPointerExceptionFunction, 0, 0);
+    throwException(intrinsics->NullPointerExceptionFunction, 0, 0);
     currentBlock = cont;
   }
  
@@ -1441,14 +1442,14 @@
     
     currentBlock = ifFalse;
     Value* args[2] = { obj, index };
-    throwException(module->IndexOutOfBoundsExceptionFunction, args, 2);
+    throwException(intrinsics->IndexOutOfBoundsExceptionFunction, args, 2);
     currentBlock = ifTrue;
   }
   
-  Constant* zero = module->constantZero;
+  Constant* zero = intrinsics->constantZero;
   Value* val = new BitCastInst(obj, arrayType, "", currentBlock);
   
-  Value* indexes[3] = { zero, module->JavaArrayElementsOffsetConstant, index };
+  Value* indexes[3] = { zero, intrinsics->JavaArrayElementsOffsetConstant, index };
   Value* ptr = GetElementPtrInst::Create(val, indexes, indexes + 3, "",
                                          currentBlock);
 
@@ -1498,8 +1499,8 @@
   if (name->equals(loader->abs)) {
     const Type* Ty = args[0]->getType();
     if (Ty == Type::getInt32Ty(getGlobalContext())) {
-      Constant* const_int32_9 = module->constantZero;
-      Constant* const_int32_10 = module->constantMinusOne;
+      Constant* const_int32_9 = intrinsics->constantZero;
+      Constant* const_int32_10 = intrinsics->constantMinusOne;
       BinaryOperator* int32_tmpneg = 
         BinaryOperator::Create(Instruction::Sub, const_int32_9, args[0],
                                "tmpneg", currentBlock);
@@ -1509,8 +1510,8 @@
       return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg,
                                       "abs", currentBlock);
     } else if (Ty == Type::getInt64Ty(getGlobalContext())) {
-      Constant* const_int64_9 = module->constantLongZero;
-      Constant* const_int64_10 = module->constantLongMinusOne;
+      Constant* const_int64_9 = intrinsics->constantLongZero;
+      Constant* const_int64_10 = intrinsics->constantLongMinusOne;
       
       BinaryOperator* int64_tmpneg = 
         BinaryOperator::Create(Instruction::Sub, const_int64_9, args[0],
@@ -1522,78 +1523,78 @@
       return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg,
                                       "abs", currentBlock);
     } else if (Ty == Type::getFloatTy(getGlobalContext())) {
-      return llvm::CallInst::Create(module->func_llvm_fabs_f32, args[0],
+      return llvm::CallInst::Create(intrinsics->func_llvm_fabs_f32, args[0],
                                     "tmp1", currentBlock);
     } else if (Ty == Type::getDoubleTy(getGlobalContext())) {
-      return llvm::CallInst::Create(module->func_llvm_fabs_f64, args[0],
+      return llvm::CallInst::Create(intrinsics->func_llvm_fabs_f64, args[0],
                                     "tmp1", currentBlock);
     }
   } else if (name->equals(loader->sqrt)) {
-    return llvm::CallInst::Create(module->func_llvm_sqrt_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_sqrt_f64, args[0],
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->sin)) {
-    return llvm::CallInst::Create(module->func_llvm_sin_f64, args[0], 
+    return llvm::CallInst::Create(intrinsics->func_llvm_sin_f64, args[0], 
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->cos)) {
-    return llvm::CallInst::Create(module->func_llvm_cos_f64, args[0], 
+    return llvm::CallInst::Create(intrinsics->func_llvm_cos_f64, args[0], 
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->tan)) {
-    return llvm::CallInst::Create(module->func_llvm_tan_f64, args[0], 
+    return llvm::CallInst::Create(intrinsics->func_llvm_tan_f64, args[0], 
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->asin)) {
-    return llvm::CallInst::Create(module->func_llvm_asin_f64, args[0], 
+    return llvm::CallInst::Create(intrinsics->func_llvm_asin_f64, args[0], 
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->acos)) {
-    return llvm::CallInst::Create(module->func_llvm_acos_f64, args[0], 
+    return llvm::CallInst::Create(intrinsics->func_llvm_acos_f64, args[0], 
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->atan)) {
-    return llvm::CallInst::Create(module->func_llvm_atan_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_atan_f64, args[0],
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->atan2)) {
-    return llvm::CallInst::Create(module->func_llvm_atan2_f64, 
+    return llvm::CallInst::Create(intrinsics->func_llvm_atan2_f64, 
                                   args.begin(), args.end(), "tmp1",
                                   currentBlock);
   } else if (name->equals(loader->exp)) {
-    return llvm::CallInst::Create(module->func_llvm_exp_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_exp_f64, args[0],
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->log)) {
-    return llvm::CallInst::Create(module->func_llvm_log_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_log_f64, args[0],
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->pow)) {
-    return llvm::CallInst::Create(module->func_llvm_pow_f64, args.begin(),
+    return llvm::CallInst::Create(intrinsics->func_llvm_pow_f64, args.begin(),
                                   args.end(), "tmp1", currentBlock);
   } else if (name->equals(loader->ceil)) {
-    return llvm::CallInst::Create(module->func_llvm_ceil_f64, args[0], "tmp1",
+    return llvm::CallInst::Create(intrinsics->func_llvm_ceil_f64, args[0], "tmp1",
                                   currentBlock);
   } else if (name->equals(loader->floor)) {
-    return llvm::CallInst::Create(module->func_llvm_floor_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_floor_f64, args[0],
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->rint)) {
-    return llvm::CallInst::Create(module->func_llvm_rint_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_rint_f64, args[0],
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->cbrt)) {
-    return llvm::CallInst::Create(module->func_llvm_cbrt_f64, args[0], "tmp1",
+    return llvm::CallInst::Create(intrinsics->func_llvm_cbrt_f64, args[0], "tmp1",
                                   currentBlock);
   } else if (name->equals(loader->cosh)) {
-    return llvm::CallInst::Create(module->func_llvm_cosh_f64, args[0], "tmp1",
+    return llvm::CallInst::Create(intrinsics->func_llvm_cosh_f64, args[0], "tmp1",
                                   currentBlock);
   } else if (name->equals(loader->expm1)) {
-    return llvm::CallInst::Create(module->func_llvm_expm1_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_expm1_f64, args[0],
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->hypot)) {
-    return llvm::CallInst::Create(module->func_llvm_hypot_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_hypot_f64, args[0],
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->log10)) {
-    return llvm::CallInst::Create(module->func_llvm_log10_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_log10_f64, args[0],
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->log1p)) {
-    return llvm::CallInst::Create(module->func_llvm_log1p_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_log1p_f64, args[0],
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->sinh)) {
-    return llvm::CallInst::Create(module->func_llvm_sinh_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_sinh_f64, args[0],
                                   "tmp1", currentBlock);
   } else if (name->equals(loader->tanh)) {
-    return llvm::CallInst::Create(module->func_llvm_tanh_f64, args[0],
+    return llvm::CallInst::Create(intrinsics->func_llvm_tanh_f64, args[0],
                                   "tmp1", currentBlock);
   }
   
@@ -1648,7 +1649,7 @@
   JITVerifyNull(args[0]); 
 
 #if defined(ISOLATE_SHARING)
-  const Type* Ty = module->ConstantPoolType;
+  const Type* Ty = intrinsics->ConstantPoolType;
   Constant* Nil = Constant::getNullValue(Ty);
   GlobalVariable* GV = new GlobalVariable(*llvmFunction->getParent(),Ty, false,
                                           GlobalValue::ExternalLinkage, Nil,
@@ -1665,7 +1666,7 @@
   Args.push_back(ctpCache);
   Args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), index));
   Args.push_back(GV);
-  res = CallInst::Create(module->SpecialCtpLookupFunction, Args.begin(),
+  res = CallInst::Create(intrinsics->SpecialCtpLookupFunction, Args.begin(),
                          Args.end(), "", falseCl);
   node->addIncoming(res, falseCl);
   BranchInst::Create(trueCl, falseCl);
@@ -1685,7 +1686,7 @@
         UserCommonClass* cl = 0;
         Value* Cl = getResolvedCommonClass(clIndex, false, &cl);
         if (!cl) {
-          CallInst::Create(module->ForceLoadedCheckFunction, Cl, "",
+          CallInst::Create(intrinsics->ForceLoadedCheckFunction, Cl, "",
                            currentBlock);
         }
       }
@@ -1699,14 +1700,14 @@
   
   const llvm::Type* retType = virtualType->getReturnType();
   if (retType != Type::getVoidTy(getGlobalContext())) {
-    if (retType == module->JavaObjectType) {
+    if (retType == intrinsics->JavaObjectType) {
       JnjvmClassLoader* JCL = compilingClass->classLoader;
       push(val, false, signature->getReturnType()->findAssocClass(JCL));
     } else {
       push(val, signature->getReturnType()->isUnsigned());
       if (retType == Type::getDoubleTy(getGlobalContext()) ||
           retType == Type::getInt64Ty(getGlobalContext())) {
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
       }
     }
   }
@@ -1744,8 +1745,8 @@
 
 #if defined(ISOLATE_SHARING)
     Value* newCtpCache = getConstantPoolAt(index,
-                                           module->StaticCtpLookupFunction,
-                                           module->ConstantPoolType, 0,
+                                           intrinsics->StaticCtpLookupFunction,
+                                           intrinsics->ConstantPoolType, 0,
                                            false);
     args.push_back(newCtpCache);
 #endif
@@ -1754,7 +1755,7 @@
     UserClass* cl = 0;
     Value* Cl = getResolvedClass(clIndex, true, true, &cl);
     if (!meth || (cl && needsInitialisationCheck(cl, compilingClass))) {
-      CallInst::Create(module->ForceInitialisationCheckFunction, Cl, "",
+      CallInst::Create(intrinsics->ForceInitialisationCheckFunction, Cl, "",
                        currentBlock);
     }
     
@@ -1780,14 +1781,14 @@
 
   const llvm::Type* retType = staticType->getReturnType();
   if (retType != Type::getVoidTy(getGlobalContext())) {
-    if (retType == module->JavaObjectType) {
+    if (retType == intrinsics->JavaObjectType) {
       JnjvmClassLoader* JCL = compilingClass->classLoader;
       push(val, false, signature->getReturnType()->findAssocClass(JCL));
     } else {
       push(val, signature->getReturnType()->isUnsigned());
       if (retType == Type::getDoubleTy(getGlobalContext()) ||
           retType == Type::getInt64Ty(getGlobalContext())) {
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
       }
     }
   }
@@ -1801,7 +1802,7 @@
 // number-wise. IMO, it's better to have this than Unswitch.
 #ifdef ISOLATE_SHARING
   Value* CTP = ctpCache;
-  Value* Cl = GetElementPtrInst::Create(CTP, module->ConstantOne, "",
+  Value* Cl = GetElementPtrInst::Create(CTP, intrinsics->ConstantOne, "",
                                         currentBlock);
   Cl = new LoadInst(Cl, "", currentBlock);
 #else
@@ -1819,15 +1820,15 @@
 
   Value* res = 0;
   if (doThrow) {
-    res = invoke(module->GetConstantPoolAtFunction, Args, "",
+    res = invoke(intrinsics->GetConstantPoolAtFunction, Args, "",
                  currentBlock);
   } else {
-    res = CallInst::Create(module->GetConstantPoolAtFunction, Args.begin(),
+    res = CallInst::Create(intrinsics->GetConstantPoolAtFunction, Args.begin(),
                            Args.end(), "", currentBlock);
   }
   
   const Type* realType = 
-    module->GetConstantPoolAtFunction->getReturnType();
+    intrinsics->GetConstantPoolAtFunction->getReturnType();
   if (returnType == Type::getInt32Ty(getGlobalContext())) {
     return new PtrToIntInst(res, Type::getInt32Ty(getGlobalContext()), "", currentBlock);
   } else if (returnType != realType) {
@@ -1850,16 +1851,16 @@
     // ony primitive arrays are already allocated, verify that the class
     // array is not external.
     if (TheCompiler->isStaticCompiling() && cl->isArray() && 
-        node->getType() != module->JavaClassArrayType) {
+        node->getType() != intrinsics->JavaClassArrayType) {
       node = new LoadInst(node, "", currentBlock);
     }
-    if (node->getType() != module->JavaCommonClassType) {
-      node = new BitCastInst(node, module->JavaCommonClassType, "",
+    if (node->getType() != intrinsics->JavaCommonClassType) {
+      node = new BitCastInst(node, intrinsics->JavaCommonClassType, "",
                              currentBlock);
     }
   } else {
-    node = getConstantPoolAt(index, module->ClassLookupFunction,
-                             module->JavaCommonClassType, 0, doThrow);
+    node = getConstantPoolAt(index, intrinsics->ClassLookupFunction,
+                             intrinsics->JavaCommonClassType, 0, doThrow);
   }
   
   return node;
@@ -1877,16 +1878,16 @@
     node = TheCompiler->getNativeClass(cl);
     needsInit = needsInitialisationCheck(cl, compilingClass);
   } else {
-    node = getConstantPoolAt(index, module->ClassLookupFunction,
-                             module->JavaClassType, 0, doThrow);
+    node = getConstantPoolAt(index, intrinsics->ClassLookupFunction,
+                             intrinsics->JavaClassType, 0, doThrow);
   }
  
 
   if (clinit && needsInit) {
-    if (node->getType() != module->JavaClassType) {
-      node = new BitCastInst(node, module->JavaClassType, "", currentBlock);
+    if (node->getType() != intrinsics->JavaClassType) {
+      node = new BitCastInst(node, intrinsics->JavaClassType, "", currentBlock);
     }
-    return invoke(module->InitialisationCheckFunction, node, "",
+    return invoke(intrinsics->InitialisationCheckFunction, node, "",
                   currentBlock);
   } else {
     return node;
@@ -1908,29 +1909,29 @@
     
     bool needsCheck = needsInitialisationCheck(cl, compilingClass);
     if (needsCheck) {
-      Cl = invoke(module->ForceInitialisationCheckFunction, Cl, "",
+      Cl = invoke(intrinsics->ForceInitialisationCheckFunction, Cl, "",
                   currentBlock);
     }
 
   } else {
-    VT = CallInst::Create(module->GetVTFromClassFunction, Cl, "",
+    VT = CallInst::Create(intrinsics->GetVTFromClassFunction, Cl, "",
                           currentBlock);
-    Size = CallInst::Create(module->GetObjectSizeFromClassFunction, Cl,
+    Size = CallInst::Create(intrinsics->GetObjectSizeFromClassFunction, Cl,
                             "", currentBlock);
   }
  
-  VT = new BitCastInst(VT, module->ptrType, "", currentBlock);
-  Instruction* val = invoke(cl ? module->AllocateFunction :
-                           module->AllocateUnresolvedFunction,
+  VT = new BitCastInst(VT, intrinsics->ptrType, "", currentBlock);
+  Instruction* val = invoke(cl ? intrinsics->AllocateFunction :
+                           intrinsics->AllocateUnresolvedFunction,
                            Size, VT, "", currentBlock);
 
   if (cl && cl->virtualVT->destructor) {
-    CallInst::Create(module->AddFinalizationCandidate, val, "", currentBlock);
+    CallInst::Create(intrinsics->AddFinalizationCandidate, val, "", currentBlock);
   }
 
 
   addHighLevelType(val, cl ? cl : upcalls->OfObject);
-  val = new BitCastInst(val, module->JavaObjectType, "", currentBlock);
+  val = new BitCastInst(val, intrinsics->JavaObjectType, "", currentBlock);
   push(val, false, cl ? cl : upcalls->OfObject);
 }
 
@@ -1949,18 +1950,18 @@
       bool needsCheck = needsInitialisationCheck(field->classDef,
                                                  compilingClass);
       if (needsCheck) {
-        Cl = invoke(module->InitialisationCheckFunction, Cl, "",
+        Cl = invoke(intrinsics->InitialisationCheckFunction, Cl, "",
                     currentBlock);
       }
 #if !defined(ISOLATE) && !defined(ISOLATE_SHARING)
       if (needsCheck) {
-        CallInst::Create(module->ForceInitialisationCheckFunction, Cl, "",
+        CallInst::Create(intrinsics->ForceInitialisationCheckFunction, Cl, "",
                          currentBlock);
       }
 
       object = TheCompiler->getStaticInstance(field->classDef);
 #else
-      object = CallInst::Create(module->GetStaticInstanceFunction, Cl, "",
+      object = CallInst::Create(intrinsics->GetStaticInstanceFunction, Cl, "",
                                 currentBlock); 
 #endif
     } else {
@@ -1969,22 +1970,22 @@
     
     Value* objectConvert = new BitCastInst(object, type, "", currentBlock);
 
-    Value* args[2] = { module->constantZero, LFI->getOffset() };
+    Value* args[2] = { intrinsics->constantZero, LFI->getOffset() };
     Value* ptr = llvm::GetElementPtrInst::Create(objectConvert,
                                                  args, args + 2, "",
                                                  currentBlock);
     return ptr;
   }
 
-  const Type* Pty = module->arrayPtrType;
-  Constant* zero = module->constantZero;
+  const Type* Pty = intrinsics->arrayPtrType;
+  Constant* zero = intrinsics->constantZero;
     
-  Function* func = stat ? module->StaticFieldLookupFunction :
-                          module->VirtualFieldLookupFunction;
+  Function* func = stat ? intrinsics->StaticFieldLookupFunction :
+                          intrinsics->VirtualFieldLookupFunction;
     
   const Type* returnType = 0;
   if (stat)
-    returnType = module->ptrType;
+    returnType = intrinsics->ptrType;
   else
     returnType = Type::getInt32Ty(getGlobalContext());
 
@@ -2097,7 +2098,7 @@
           CommonClass* cl = mvm::Collector::begOf(val) ? val->getClass() : NULL;
           push(V, false, cl);
         } else {
-          Value* V = CallInst::Create(module->GetFinalObjectFieldFunction, ptr,
+          Value* V = CallInst::Create(intrinsics->GetFinalObjectFieldFunction, ptr,
                                       "", currentBlock);
 
           JnjvmClassLoader* JCL = compilingClass->classLoader;
@@ -2114,7 +2115,7 @@
     push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned(), cl);
   }
   if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) {
-    push(module->constantZero, false);
+    push(intrinsics->constantZero, false);
   }
 }
 
@@ -2163,26 +2164,26 @@
       if (sign->isPrimitive()) {
         const PrimitiveTypedef* prim = (PrimitiveTypedef*)sign;
         if (prim->isInt()) {
-          F = module->GetFinalInt32FieldFunction;
+          F = intrinsics->GetFinalInt32FieldFunction;
         } else if (prim->isByte()) {
-          F = module->GetFinalInt8FieldFunction;
+          F = intrinsics->GetFinalInt8FieldFunction;
         } else if (prim->isBool()) {
-          F = module->GetFinalInt8FieldFunction;
+          F = intrinsics->GetFinalInt8FieldFunction;
         } else if (prim->isShort()) {
-          F = module->GetFinalInt16FieldFunction;
+          F = intrinsics->GetFinalInt16FieldFunction;
         } else if (prim->isChar()) {
-          F = module->GetFinalInt16FieldFunction;
+          F = intrinsics->GetFinalInt16FieldFunction;
         } else if (prim->isLong()) {
-          F = module->GetFinalLongFieldFunction;
+          F = intrinsics->GetFinalLongFieldFunction;
         } else if (prim->isFloat()) {
-          F = module->GetFinalFloatFieldFunction;
+          F = intrinsics->GetFinalFloatFieldFunction;
         } else if (prim->isDouble()) {
-          F = module->GetFinalDoubleFieldFunction;
+          F = intrinsics->GetFinalDoubleFieldFunction;
         } else {
           abort();
         }
       } else {
-        F = module->GetFinalObjectFieldFunction;
+        F = intrinsics->GetFinalObjectFieldFunction;
       }
       push(CallInst::Create(F, ptr, "", currentBlock), sign->isUnsigned(), cl);
     }
@@ -2191,7 +2192,7 @@
   if (!final) push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned(), cl);
   if (type == Type::getInt64Ty(getGlobalContext()) ||
       type == Type::getDoubleTy(getGlobalContext())) {
-    push(module->constantZero, false);
+    push(intrinsics->constantZero, false);
   }
 }
 
@@ -2229,8 +2230,8 @@
   if (meth) {
     Meth = TheCompiler->getMethodInClass(meth);
   } else {
-    Meth = getConstantPoolAt(index, module->InterfaceLookupFunction,
-                             module->JavaMethodType, 0, false);
+    Meth = getConstantPoolAt(index, intrinsics->InterfaceLookupFunction,
+                             intrinsics->JavaMethodType, 0, false);
   }
 
   BasicBlock* label_bb = createBasicBlock("bb");
@@ -2239,23 +2240,23 @@
   BasicBlock* label_bb7 = createBasicBlock("bb7");
     
   // Block entry (label_entry)
-  Value* VT = CallInst::Create(module->GetVTFunction, args[0], "",
+  Value* VT = CallInst::Create(intrinsics->GetVTFunction, args[0], "",
                                currentBlock);
-  Value* IMT = CallInst::Create(module->GetIMTFunction, VT, "",
+  Value* IMT = CallInst::Create(intrinsics->GetIMTFunction, VT, "",
                                 currentBlock);
 
   uint32_t tableIndex = InterfaceMethodTable::getIndex(name, signature->keyName);
   Constant* Index = ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
                                      tableIndex);
 
-  Value* indices[2] = { module->constantZero, Index };
+  Value* indices[2] = { intrinsics->constantZero, Index };
   Instruction* ptr_18 = GetElementPtrInst::Create(IMT, indices, indices + 2, "",
                                                   currentBlock);
   Instruction* int32_19 = new LoadInst(ptr_18, "", false, currentBlock);
-  int32_19 = new PtrToIntInst(int32_19, module->pointerSizeType, "",
+  int32_19 = new PtrToIntInst(int32_19, intrinsics->pointerSizeType, "",
                               currentBlock);
-  Value* one = ConstantInt::get(module->pointerSizeType, 1);
-  Value* zero = ConstantInt::get(module->pointerSizeType, 0);
+  Value* one = ConstantInt::get(intrinsics->pointerSizeType, 1);
+  Value* zero = ConstantInt::get(intrinsics->pointerSizeType, 0);
   BinaryOperator* int32_20 = BinaryOperator::Create(Instruction::And, int32_19,
                                                     one, "", currentBlock);
   ICmpInst* int1_toBool = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ,
@@ -2271,10 +2272,10 @@
     
   // Block bb4 (label_bb4)
   currentBlock = label_bb4;
-  Constant* MinusTwo = ConstantInt::get(module->pointerSizeType, -2);
+  Constant* MinusTwo = ConstantInt::get(intrinsics->pointerSizeType, -2);
   BinaryOperator* int32_25 = BinaryOperator::Create(Instruction::And, int32_19,
                                                     MinusTwo, "", currentBlock);
-  const PointerType* Ty = PointerType::getUnqual(module->JavaMethodType);
+  const PointerType* Ty = PointerType::getUnqual(intrinsics->JavaMethodType);
   CastInst* ptr_26 = new IntToPtrInst(int32_25, Ty, "", currentBlock);
   LoadInst* int32_27 = new LoadInst(ptr_26, "", false, currentBlock);
   ICmpInst* int1_28 = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, int32_27,
@@ -2289,7 +2290,7 @@
   ptr_table_0_lcssa->addIncoming(ptr_26, label_bb4);
    
   GetElementPtrInst* ptr_31 = GetElementPtrInst::Create(ptr_table_0_lcssa,
-                                                        module->constantOne, "",
+                                                        intrinsics->constantOne, "",
                                                         currentBlock);
 
   LoadInst* int32_32 = new LoadInst(ptr_31, "", false, currentBlock);
@@ -2304,22 +2305,22 @@
   PHINode* int32_indvar = PHINode::Create(Type::getInt32Ty(*llvmContext),
                                           "indvar", currentBlock);
   int32_indvar->reserveOperandSpace(2);
-  int32_indvar->addIncoming(module->constantZero, label_bb4);
+  int32_indvar->addIncoming(intrinsics->constantZero, label_bb4);
     
   BinaryOperator* int32_table_010_rec =
-    BinaryOperator::Create(Instruction::Shl, int32_indvar, module->constantOne,
+    BinaryOperator::Create(Instruction::Shl, int32_indvar, intrinsics->constantOne,
                            "table.010.rec", currentBlock);
 
   BinaryOperator* int32__rec =
     BinaryOperator::Create(Instruction::Add, int32_table_010_rec,
-                           module->constantTwo, ".rec", currentBlock);
+                           intrinsics->constantTwo, ".rec", currentBlock);
   GetElementPtrInst* ptr_37 = GetElementPtrInst::Create(ptr_26, int32__rec, "",
                                                         currentBlock);
   LoadInst* int32_38 = new LoadInst(ptr_37, "", false, currentBlock);
   ICmpInst* int1_39 = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, int32_38,
                                    Meth, "");
   BinaryOperator* int32_indvar_next =
-    BinaryOperator::Create(Instruction::Add, int32_indvar, module->constantOne,
+    BinaryOperator::Create(Instruction::Add, int32_indvar, intrinsics->constantOne,
                            "indvar.next", currentBlock);
   BranchInst::Create(label_bb6, label_bb7, int1_39, currentBlock);
   
@@ -2328,14 +2329,14 @@
       
   currentBlock = endBlock;
   if (node) {
-    if (node->getType() == module->JavaObjectType) {
+    if (node->getType() == intrinsics->JavaObjectType) {
       JnjvmClassLoader* JCL = compilingClass->classLoader;
       push(node, false, signature->getReturnType()->findAssocClass(JCL));
     } else {
       push(node, signature->getReturnType()->isUnsigned());
       if (retType == Type::getDoubleTy(getGlobalContext()) ||
           retType == Type::getInt64Ty(getGlobalContext())) {
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
       }
     }
   }
@@ -2369,9 +2370,9 @@
   BasicBlock* log_label_bb = createBasicBlock("log_bb");
     
   // Block entry (label_entry)
-  CallInst* ptr_16 = CallInst::Create(module->GetVTFunction, ptr_src, "",
+  CallInst* ptr_16 = CallInst::Create(intrinsics->GetVTFunction, ptr_src, "",
                                       label_entry);
-  CallInst* ptr_17 = CallInst::Create(module->GetVTFunction, ptr_dst, "",
+  CallInst* ptr_17 = CallInst::Create(intrinsics->GetVTFunction, ptr_dst, "",
                                       label_entry);
   
   ICmpInst* int1_18 = new ICmpInst(*label_entry, ICmpInst::ICMP_EQ, ptr_16,
@@ -2380,16 +2381,16 @@
     
   // Block bb (label_bb)
   currentBlock = label_bb;
-  CallInst* ptr_20 = CallInst::Create(module->GetClassFunction, ptr_src, "",
+  CallInst* ptr_20 = CallInst::Create(intrinsics->GetClassFunction, ptr_src, "",
                                       label_bb);
   std::vector<Value*> ptr_21_indices;
-  ptr_21_indices.push_back(module->constantZero);
-  ptr_21_indices.push_back(module->OffsetAccessInCommonClassConstant);
+  ptr_21_indices.push_back(intrinsics->constantZero);
+  ptr_21_indices.push_back(intrinsics->OffsetAccessInCommonClassConstant);
   Instruction* ptr_21 =
     GetElementPtrInst::Create(ptr_20, ptr_21_indices.begin(),
                               ptr_21_indices.end(), "", label_bb);
   LoadInst* int32_22 = new LoadInst(ptr_21, "", false, label_bb);
-  Value* cmp = BinaryOperator::CreateAnd(int32_22, module->IsArrayConstant, "",
+  Value* cmp = BinaryOperator::CreateAnd(int32_22, intrinsics->IsArrayConstant, "",
                                          label_bb);
   Value* zero = ConstantInt::get(Type::getInt16Ty(getGlobalContext()), 0);
   ICmpInst* int1_23 = new ICmpInst(*label_bb, ICmpInst::ICMP_NE, cmp, zero, "");
@@ -2427,21 +2428,21 @@
   // Block bb12.preheader (label_bb12_preheader)
   currentBlock = label_bb12_preheader;
   ICmpInst* int1_35 = new ICmpInst(*label_bb12_preheader, ICmpInst::ICMP_UGT,
-                                   int32_length, module->constantZero, "");
+                                   int32_length, intrinsics->constantZero, "");
   BranchInst::Create(log_label_entry, label_return, int1_35, label_bb12_preheader);
     
   // Block bb7 (label_bb7)
   currentBlock = label_bb7;
-  Value* VTArgs[1] = { Constant::getNullValue(module->VTType) };
-  throwException(module->ArrayStoreExceptionFunction, VTArgs, 1);
+  Value* VTArgs[1] = { Constant::getNullValue(intrinsics->VTType) };
+  throwException(intrinsics->ArrayStoreExceptionFunction, VTArgs, 1);
    
 
   
   // Block entry (label_entry)
   currentBlock = log_label_entry;
-  Value* ptr_10_indices[2] = { module->constantZero,
-                               module->OffsetBaseClassInArrayClassConstant };
-  Instruction* temp = new BitCastInst(ptr_20, module->JavaClassArrayType, "",
+  Value* ptr_10_indices[2] = { intrinsics->constantZero,
+                               intrinsics->OffsetBaseClassInArrayClassConstant };
+  Instruction* temp = new BitCastInst(ptr_20, intrinsics->JavaClassArrayType, "",
                                       log_label_entry);
   Instruction* ptr_10 = GetElementPtrInst::Create(temp, ptr_10_indices,
                                                   ptr_10_indices + 2, "",
@@ -2449,15 +2450,15 @@
 
   LoadInst* ptr_11 = new LoadInst(ptr_10, "", false, log_label_entry);
     
-  Value* ptr_12_indices[2] = { module->constantZero,
-                               module->OffsetAccessInCommonClassConstant };
+  Value* ptr_12_indices[2] = { intrinsics->constantZero,
+                               intrinsics->OffsetAccessInCommonClassConstant };
   Instruction* ptr_12 = GetElementPtrInst::Create(ptr_11, ptr_12_indices,
                                                   ptr_12_indices + 2, "",
                                                   log_label_entry);
   LoadInst* int16_13 = new LoadInst(ptr_12, "", false, log_label_entry);
 
   BinaryOperator* int32_15 = BinaryOperator::Create(Instruction::And, int16_13,
-                                                    module->IsPrimitiveConstant,
+                                                    intrinsics->IsPrimitiveConstant,
                                                     "", log_label_entry);
   ICmpInst* int1_16 = new ICmpInst(*log_label_entry, ICmpInst::ICMP_EQ,
                                    int32_15, zero, "");
@@ -2465,9 +2466,9 @@
     
   // Block bb (log_label_bb)
   currentBlock = log_label_bb;
-  Value* ptr_11_indices[2] = { module->constantZero,
-                               module->OffsetLogSizeInPrimitiveClassConstant };
-  temp = new BitCastInst(ptr_11, module->JavaClassPrimitiveType, "",
+  Value* ptr_11_indices[2] = { intrinsics->constantZero,
+                               intrinsics->OffsetLogSizeInPrimitiveClassConstant };
+  temp = new BitCastInst(ptr_11, intrinsics->JavaClassPrimitiveType, "",
                          log_label_bb);
   GetElementPtrInst* ptr_18 = GetElementPtrInst::Create(temp, ptr_11_indices,
                                                         ptr_11_indices + 2, "",
@@ -2481,14 +2482,14 @@
   int32_length = BinaryOperator::CreateShl(int32_length, int32_20, "",
                                            log_label_bb);
 
-  ptr_src = new BitCastInst(ptr_src, module->JavaArrayUInt8Type, "",
+  ptr_src = new BitCastInst(ptr_src, intrinsics->JavaArrayUInt8Type, "",
                             log_label_bb);
   
-  ptr_dst = new BitCastInst(ptr_dst, module->JavaArrayUInt8Type, "",
+  ptr_dst = new BitCastInst(ptr_dst, intrinsics->JavaArrayUInt8Type, "",
                             log_label_bb);
   
-  Value* indexes[3] = { module->constantZero,
-                        module->JavaArrayElementsOffsetConstant,
+  Value* indexes[3] = { intrinsics->constantZero,
+                        intrinsics->JavaArrayElementsOffsetConstant,
                         int32_start };
   Instruction* ptr_42 = GetElementPtrInst::Create(ptr_src, indexes, indexes + 3,
                                                   "", log_label_bb);
@@ -2501,16 +2502,16 @@
 
   // Block memmove
   currentBlock = label_memmove;
-  Value* src_int = new PtrToIntInst(ptr_42, module->pointerSizeType, "",
+  Value* src_int = new PtrToIntInst(ptr_42, intrinsics->pointerSizeType, "",
                                     currentBlock);
   
-  Value* dst_int = new PtrToIntInst(ptr_44, module->pointerSizeType, "",
+  Value* dst_int = new PtrToIntInst(ptr_44, intrinsics->pointerSizeType, "",
                                     currentBlock);
 
   cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_ULT, dst_int, src_int, "");
 
-  Value* increment = SelectInst::Create(cmp, module->constantOne,
-                                        module->constantMinusOne, "",
+  Value* increment = SelectInst::Create(cmp, intrinsics->constantOne,
+                                        intrinsics->constantMinusOne, "",
                                         currentBlock);
   BranchInst::Create(label_bb11, label_backward, cmp, currentBlock);
 
@@ -2528,10 +2529,10 @@
   ptr_44 = GetElementPtrInst::Create(ptr_44, int32_length, "",
                                      currentBlock);
   
-  ptr_42 = GetElementPtrInst::Create(ptr_42, module->constantMinusOne, "",
+  ptr_42 = GetElementPtrInst::Create(ptr_42, intrinsics->constantMinusOne, "",
                                      currentBlock);
   
-  ptr_44 = GetElementPtrInst::Create(ptr_44, module->constantMinusOne, "",
+  ptr_44 = GetElementPtrInst::Create(ptr_44, intrinsics->constantMinusOne, "",
                                      currentBlock);
   
   phi_dst_ptr->addIncoming(ptr_44, currentBlock);
@@ -2546,7 +2547,7 @@
                                          "i.016", label_bb11);
   int32_i_016->reserveOperandSpace(2);
   int32_i_016->addIncoming(fwdref_39, label_bb11);
-  int32_i_016->addIncoming(module->constantZero, log_label_bb);
+  int32_i_016->addIncoming(intrinsics->constantZero, log_label_bb);
    
   LoadInst* ptr_43 = new LoadInst(phi_src_ptr, "", false, label_bb11);
   new StoreInst(ptr_43, phi_dst_ptr, false, label_bb11);
@@ -2561,7 +2562,7 @@
   phi_src_ptr->addIncoming(ptr_42, label_bb11);
 
   BinaryOperator* int32_indvar_next =
-    BinaryOperator::Create(Instruction::Add, int32_i_016, module->constantOne,
+    BinaryOperator::Create(Instruction::Add, int32_i_016, intrinsics->constantOne,
                            "indvar.next", label_bb11);
   ICmpInst* int1_exitcond = new ICmpInst(*label_bb11, ICmpInst::ICMP_EQ,
                                          int32_indvar_next, int32_length,
@@ -2577,7 +2578,7 @@
 MDNode* JavaJIT::CreateLocation() {
   uint32_t first = currentLineNumber | (currentBytecodeIndex << 16);
   uint32_t second = currentCtpIndex | (callNumber << 16);
-  DILocation Location = module->DebugFactory->CreateLocation(
+  DILocation Location = intrinsics->DebugFactory->CreateLocation(
       first, second, DIScope(DbgSubprogram));
   callNumber++;
   return Location.getNode();

Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Sun Feb 14 16:07:42 2010
@@ -24,16 +24,15 @@
 
 #include "types.h"
 
+#include "j3/JavaLLVMCompiler.h"
+
 #include "JavaClass.h"
 #include "JavaUpcalls.h"
-#include "j3/JavaLLVMCompiler.h"
-#include "j3/JnjvmModule.h"
 
 namespace j3 {
 
 class Class;
 class JavaMethod;
-class JnjvmModule;
 class Reader;
 
 /// Opinfo - This class gives for each opcode if it starts a new block and
@@ -76,7 +75,7 @@
     compilingClass = meth->classDef;
     upcalls = compilingClass->classLoader->bootstrapLoader->upcalls;
     TheCompiler = C;
-    module = TheCompiler->getIntrinsics();
+    intrinsics = TheCompiler->getIntrinsics();
     llvmFunction = func;
     llvmContext = &func->getContext();
     inlining = false;
@@ -112,8 +111,8 @@
   /// llvmContext - The current LLVM context of compilation.
   llvm::LLVMContext* llvmContext;
   
-  /// module - The LLVM module where lives the compiling LLVM function.
-  JnjvmModule* module;
+  /// intrinsics - The LLVM intrinsics where lives the compiling LLVM function.
+  J3Intrinsics* intrinsics;
 
   /// TheCompiler - The LLVM Java compiler.
   ///
@@ -134,7 +133,7 @@
   
   /// arraySize - Get the size of the array.
   llvm::Value* arraySize(llvm::Value* obj) {
-    return llvm::CallInst::Create(module->ArrayLengthFunction, obj, "",
+    return llvm::CallInst::Create(intrinsics->ArrayLengthFunction, obj, "",
                                   currentBlock);
   }
   
@@ -264,7 +263,7 @@
                           currentBlock);
       stack.push_back(upcalls->OfDouble);
     } else {
-      assert(type == module->JavaObjectType && "Can't handle this type");
+      assert(type == intrinsics->JavaObjectType && "Can't handle this type");
       llvm::Instruction* V = new 
         llvm::StoreInst(val, objectStack[currentStackIndex++], false,
                         currentBlock);
@@ -282,7 +281,7 @@
     llvm::Value* A[1] = 
       { TheCompiler->getNativeClass(cl ? cl : upcalls->OfObject) };
     llvm::MDNode* Node = llvm::MDNode::get(*llvmContext, A, 1);
-    V->setMetadata(module->MetadataTypeKind, Node);
+    V->setMetadata(intrinsics->MetadataTypeKind, Node);
 #endif
   }
 

Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sun Feb 14 16:07:42 2010
@@ -33,7 +33,7 @@
 #include "Jnjvm.h"
 
 #include "j3/JavaJITCompiler.h"
-#include "j3/JnjvmModule.h"
+#include "j3/J3Intrinsics.h"
 #include "j3/LLVMMaterializer.h"
 
 using namespace j3;
@@ -127,8 +127,8 @@
 static JavaJITListener* JITListener = 0;
 
 Constant* JavaJITCompiler::getNativeClass(CommonClass* classDef) {
-  const llvm::Type* Ty = classDef->isClass() ? JnjvmModule::JavaClassType :
-                                               JnjvmModule::JavaCommonClassType;
+  const llvm::Type* Ty = classDef->isClass() ? J3Intrinsics::JavaClassType :
+                                               J3Intrinsics::JavaCommonClassType;
   
   ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                      uint64_t(classDef));
@@ -140,25 +140,25 @@
   assert(ptr && "No constant pool found");
   ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                      uint64_t(ptr));
-  return ConstantExpr::getIntToPtr(CI, JnjvmModule::ConstantPoolType);
+  return ConstantExpr::getIntToPtr(CI, J3Intrinsics::ConstantPoolType);
 }
 
 Constant* JavaJITCompiler::getMethodInClass(JavaMethod* meth) {
   ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                      (int64_t)meth);
-  return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaMethodType);
+  return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaMethodType);
 }
 
 Constant* JavaJITCompiler::getString(JavaString* str) {
   assert(str && "No string given");
   ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                      uint64(str));
-  return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
+  return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType);
 }
 
 Constant* JavaJITCompiler::getStringPtr(JavaString** str) {
   assert(str && "No string given");
-  const llvm::Type* Ty = PointerType::getUnqual(JnjvmModule::JavaObjectType);
+  const llvm::Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaObjectType);
   ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                      uint64(str));
   return ConstantExpr::getIntToPtr(CI, Ty);
@@ -169,7 +169,7 @@
   assert(obj && "Delegatee not created");
   Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                   uint64(obj));
-  return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
+  return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType);
 }
 
 Constant* JavaJITCompiler::getJavaClassPtr(CommonClass* cl) {
@@ -178,7 +178,7 @@
   assert(obj && "Delegatee not created");
   Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                   uint64(obj));
-  const Type* Ty = PointerType::getUnqual(JnjvmModule::JavaObjectType);
+  const Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaObjectType);
   return ConstantExpr::getIntToPtr(CI, Ty);
 }
 
@@ -194,7 +194,7 @@
 Constant* JavaJITCompiler::getFinalObject(JavaObject* obj, CommonClass* cl) {
   Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                   uint64(obj));
-  return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType);
+  return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType);
 }
 
 Constant* JavaJITCompiler::getStaticInstance(Class* classDef) {
@@ -214,7 +214,7 @@
   }
   Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                   (uint64_t(obj)));
-  return ConstantExpr::getIntToPtr(CI, JnjvmModule::ptrType);
+  return ConstantExpr::getIntToPtr(CI, J3Intrinsics::ptrType);
 }
 
 Constant* JavaJITCompiler::getVirtualTable(JavaVirtualTable* VT) {
@@ -225,7 +225,7 @@
   
   ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                      uint64_t(VT));
-  return ConstantExpr::getIntToPtr(CI, JnjvmModule::VTType);
+  return ConstantExpr::getIntToPtr(CI, J3Intrinsics::VTType);
 }
 
 Constant* JavaJITCompiler::getNativeFunction(JavaMethod* meth, void* ptr) {
@@ -248,9 +248,9 @@
   EmitFunctionName = false;
 #endif
   
-  JnjvmModule::protectEngine.lock();
-  JnjvmModule::executionEngine->addModule(TheModule);
-  JnjvmModule::protectEngine.unlock();
+  J3Intrinsics::protectEngine.lock();
+  J3Intrinsics::executionEngine->addModule(TheModule);
+  J3Intrinsics::protectEngine.unlock();
   
   addJavaPasses();
 
@@ -264,7 +264,7 @@
 Value* JavaJITCompiler::getIsolate(Jnjvm* isolate, Value* Where) {
   ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()),
                                      uint64_t(isolate));
-  return ConstantExpr::getIntToPtr(CI, JnjvmModule::ptrType);
+  return ConstantExpr::getIntToPtr(CI, J3Intrinsics::ptrType);
 }
 #endif
 
@@ -388,7 +388,7 @@
   Function* func = getMethodInfo(meth)->getMethod();
   func->setName(name);
   assert(ptr && "No value given");
-  JnjvmModule::executionEngine->updateGlobalMapping(func, ptr);
+  J3Intrinsics::executionEngine->updateGlobalMapping(func, ptr);
   func->setLinkage(GlobalValue::ExternalLinkage);
 }
 
@@ -494,7 +494,7 @@
 
 JavaJITCompiler* JavaJITCompiler::CreateCompiler(const std::string& ModuleID) {
   if (LLVMLazy) {
-    JnjvmModule::executionEngine->DisableLazyCompilation(false); 
+    J3Intrinsics::executionEngine->DisableLazyCompilation(false); 
     return new JavaLLVMLazyJITCompiler(ModuleID);
   }
   return new JavaJ3LazyJITCompiler(ModuleID);

Modified: vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Sun Feb 14 16:07:42 2010
@@ -33,7 +33,7 @@
 #include "JavaTypes.h"
 #include "Jnjvm.h"
 
-#include "j3/JnjvmModule.h"
+#include "j3/J3Intrinsics.h"
 
 #if DEBUG > 0 && (JNJVM_COMPILE > 0 || JNJVM_EXECUTE > 0)
 #include "j3/OpcodeNames.def"
@@ -189,7 +189,7 @@
       };
     
     
-      CallInst::Create(module->PrintExecutionFunction, args, args + 3, "",
+      CallInst::Create(intrinsics->PrintExecutionFunction, args, args + 3, "",
                        currentBlock);
     }
 #endif
@@ -199,67 +199,67 @@
       case NOP : break;
 
       case ACONST_NULL : 
-        push(module->JavaObjectNullConstant, false);
+        push(intrinsics->JavaObjectNullConstant, false);
         break;
 
       case ICONST_M1 :
-        push(module->constantMinusOne, false);
+        push(intrinsics->constantMinusOne, false);
         break;
 
       case ICONST_0 :
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
 
       case ICONST_1 :
-        push(module->constantOne, false);
+        push(intrinsics->constantOne, false);
         break;
 
       case ICONST_2 :
-        push(module->constantTwo, false);
+        push(intrinsics->constantTwo, false);
         break;
 
       case ICONST_3 :
-        push(module->constantThree, false);
+        push(intrinsics->constantThree, false);
         break;
 
       case ICONST_4 :
-        push(module->constantFour, false);
+        push(intrinsics->constantFour, false);
         break;
 
       case ICONST_5 :
-        push(module->constantFive, false);
+        push(intrinsics->constantFive, false);
         break;
 
       case LCONST_0 :
-        push(module->constantLongZero, false);
-        push(module->constantZero, false);
+        push(intrinsics->constantLongZero, false);
+        push(intrinsics->constantZero, false);
         break;
 
       case LCONST_1 :
-        push(module->constantLongOne, false);
-        push(module->constantZero, false);
+        push(intrinsics->constantLongOne, false);
+        push(intrinsics->constantZero, false);
         break;
 
       case FCONST_0 :
-        push(module->constantFloatZero, false);
+        push(intrinsics->constantFloatZero, false);
         break;
 
       case FCONST_1 :
-        push(module->constantFloatOne, false);
+        push(intrinsics->constantFloatOne, false);
         break;
       
       case FCONST_2 :
-        push(module->constantFloatTwo, false);
+        push(intrinsics->constantFloatTwo, false);
         break;
       
       case DCONST_0 :
-        push(module->constantDoubleZero, false);
-        push(module->constantZero, false);
+        push(intrinsics->constantDoubleZero, false);
+        push(intrinsics->constantZero, false);
         break;
       
       case DCONST_1 :
-        push(module->constantDoubleOne, false);
-        push(module->constantZero, false);
+        push(intrinsics->constantDoubleOne, false);
+        push(intrinsics->constantZero, false);
         break;
 
       case BIPUSH : 
@@ -284,7 +284,7 @@
 
       case LDC2_W :
         loadConstant(readS2(bytecodes, i));
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
 
       case ILOAD :
@@ -295,7 +295,7 @@
       case LLOAD :
         push(new LoadInst(longLocals[WREAD_U1(bytecodes, false, i, wide)], "",
                           currentBlock), false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
 
       case FLOAD :
@@ -306,7 +306,7 @@
       case DLOAD :
         push(new LoadInst(doubleLocals[WREAD_U1(bytecodes, false, i, wide)], "",
                           currentBlock), false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
 
       case ALOAD :
@@ -333,25 +333,25 @@
       case LLOAD_0 :
         push(new LoadInst(longLocals[0], "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
 
       case LLOAD_1 :
         push(new LoadInst(longLocals[1], "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       
       case LLOAD_2 :
         push(new LoadInst(longLocals[2], "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       
       case LLOAD_3 :
         push(new LoadInst(longLocals[3], "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       
       case FLOAD_0 :
@@ -377,25 +377,25 @@
       case DLOAD_0 :
         push(new LoadInst(doubleLocals[0], "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
 
       case DLOAD_1 :
         push(new LoadInst(doubleLocals[1], "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       
       case DLOAD_2 :
         push(new LoadInst(doubleLocals[2], "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       
       case DLOAD_3 :
         push(new LoadInst(doubleLocals[3], "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       
       case ALOAD_0 :
@@ -422,7 +422,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index, 
-                                         module->JavaArraySInt32Type);
+                                         intrinsics->JavaArraySInt32Type);
         push(new LoadInst(ptr, "", currentBlock), false);
         break;
       }
@@ -431,9 +431,9 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArrayLongType);
+                                         intrinsics->JavaArrayLongType);
         push(new LoadInst(ptr, "", currentBlock), false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -441,7 +441,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArrayFloatType);
+                                         intrinsics->JavaArrayFloatType);
         push(new LoadInst(ptr, "", currentBlock), false);
         break;
       }
@@ -450,9 +450,9 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArrayDoubleType);
+                                         intrinsics->JavaArrayDoubleType);
         push(new LoadInst(ptr, "", currentBlock), false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -461,7 +461,7 @@
         CommonClass* cl = topTypeInfo();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArrayObjectType);
+                                         intrinsics->JavaArrayObjectType);
         
         if (cl->isArray()) cl = cl->asArrayClass()->baseClass();
         push(new LoadInst(ptr, "", currentBlock), false, cl);
@@ -472,7 +472,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArraySInt8Type);
+                                         intrinsics->JavaArraySInt8Type);
         Value* val = new LoadInst(ptr, "", currentBlock);
         push(new SExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock),
              false);
@@ -483,7 +483,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArrayUInt16Type);
+                                         intrinsics->JavaArrayUInt16Type);
         Value* val = new LoadInst(ptr, "", currentBlock);
         push(new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock),
              false);
@@ -494,7 +494,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArraySInt16Type);
+                                         intrinsics->JavaArraySInt16Type);
         Value* val = new LoadInst(ptr, "", currentBlock);
         push(new SExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock),
              false);
@@ -658,7 +658,7 @@
         Value* index = popAsInt();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArraySInt32Type);
+                                         intrinsics->JavaArraySInt32Type);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -669,7 +669,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArrayLongType);
+                                         intrinsics->JavaArrayLongType);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -679,7 +679,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArrayFloatType);
+                                         intrinsics->JavaArrayFloatType);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -690,7 +690,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArrayDoubleType);
+                                         intrinsics->JavaArrayDoubleType);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -700,12 +700,12 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArrayObjectType);
+                                         intrinsics->JavaArrayObjectType);
 
         if (TheCompiler->hasExceptionsEnabled()) {
 
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val,
-                                    module->JavaObjectNullConstant, "");
+                                    intrinsics->JavaObjectNullConstant, "");
 
           BasicBlock* endBlock = createBasicBlock("end array store check");
           BasicBlock* checkBlock = createBasicBlock("array store check");
@@ -714,23 +714,23 @@
           BranchInst::Create(endBlock, checkBlock, cmp, currentBlock);
           currentBlock = checkBlock;
         
-          Value* valVT = CallInst::Create(module->GetVTFunction, val, "",
+          Value* valVT = CallInst::Create(intrinsics->GetVTFunction, val, "",
                                           currentBlock);
          
-          Value* objVT = CallInst::Create(module->GetVTFunction, obj, "",
+          Value* objVT = CallInst::Create(intrinsics->GetVTFunction, obj, "",
                                           currentBlock);
-          objVT = CallInst::Create(module->GetBaseClassVTFromVTFunction, objVT,
+          objVT = CallInst::Create(intrinsics->GetBaseClassVTFromVTFunction, objVT,
                                    "", currentBlock);
           
           Value* VTArgs[2] = { valVT, objVT };
           
-          Value* res = CallInst::Create(module->IsAssignableFromFunction,
+          Value* res = CallInst::Create(intrinsics->IsAssignableFromFunction,
                                         VTArgs, VTArgs + 2, "", currentBlock);
 
           BranchInst::Create(endBlock, exceptionBlock, res, currentBlock);
           
           currentBlock = exceptionBlock;
-          throwException(module->ArrayStoreExceptionFunction, VTArgs, 1);
+          throwException(intrinsics->ArrayStoreExceptionFunction, VTArgs, 1);
 
           currentBlock = endBlock;
         }
@@ -747,7 +747,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArraySInt8Type);
+                                         intrinsics->JavaArraySInt8Type);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -763,7 +763,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArrayUInt16Type);
+                                         intrinsics->JavaArrayUInt16Type);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -779,7 +779,7 @@
         Value* index = pop();
         Value* obj = pop();
         Value* ptr = verifyAndComputePtr(obj, index,
-                                         module->JavaArraySInt16Type);
+                                         intrinsics->JavaArraySInt16Type);
         new StoreInst(val, ptr, false, currentBlock);
         break;
       }
@@ -900,7 +900,7 @@
         llvm::Value* val1 = pop();
         push(BinaryOperator::CreateAdd(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -919,7 +919,7 @@
         llvm::Value* val1 = pop();
         push(BinaryOperator::CreateFAdd(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -937,7 +937,7 @@
         llvm::Value* val1 = pop();
         push(BinaryOperator::CreateSub(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -956,7 +956,7 @@
         llvm::Value* val1 = pop();
         push(BinaryOperator::CreateFSub(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -975,7 +975,7 @@
         llvm::Value* val1 = pop();
         push(BinaryOperator::CreateMul(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -994,7 +994,7 @@
         llvm::Value* val1 = pop();
         push(BinaryOperator::CreateFMul(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1003,13 +1003,13 @@
         Value* val1 = popAsInt();
         if (TheCompiler->hasExceptionsEnabled()) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
-                                    module->constantZero, "");
+                                    intrinsics->constantZero, "");
           BasicBlock* ifFalse = createBasicBlock("non null div");
           BasicBlock* ifTrue = createBasicBlock("null div");
 
           BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
           currentBlock = ifTrue;
-          throwException(module->ArithmeticExceptionFunction, 0, 0);
+          throwException(intrinsics->ArithmeticExceptionFunction, 0, 0);
           currentBlock = ifFalse;
         }
         push(BinaryOperator::CreateSDiv(val1, val2, "", currentBlock),
@@ -1024,18 +1024,18 @@
         llvm::Value* val1 = pop();
         if (TheCompiler->hasExceptionsEnabled()) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2,
-                                    module->constantLongZero, "");
+                                    intrinsics->constantLongZero, "");
           BasicBlock* ifFalse = createBasicBlock("non null div");
           BasicBlock* ifTrue = createBasicBlock("null div");
 
           BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
           currentBlock = ifTrue;
-          throwException(module->ArithmeticExceptionFunction, 0, 0);
+          throwException(intrinsics->ArithmeticExceptionFunction, 0, 0);
           currentBlock = ifFalse;
         }
         push(BinaryOperator::CreateSDiv(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1054,7 +1054,7 @@
         llvm::Value* val1 = pop();
         push(BinaryOperator::CreateFDiv(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1073,7 +1073,7 @@
         llvm::Value* val1 = pop();
         push(BinaryOperator::CreateSRem(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1092,13 +1092,13 @@
         llvm::Value* val1 = pop();
         push(BinaryOperator::CreateFRem(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
       case INEG :
         push(BinaryOperator::CreateSub(
-                              module->constantZero,
+                              intrinsics->constantZero,
                               popAsInt(), "", currentBlock),
              false);
         break;
@@ -1106,24 +1106,24 @@
       case LNEG : {
         pop();
         push(BinaryOperator::CreateSub(
-                              module->constantLongZero,
+                              intrinsics->constantLongZero,
                               pop(), "", currentBlock), false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
       case FNEG :
         push(BinaryOperator::CreateSub(
-                              module->constantFloatMinusZero,
+                              intrinsics->constantFloatMinusZero,
                               pop(), "", currentBlock), false);
         break;
       
       case DNEG : {
         pop();
         push(BinaryOperator::CreateSub(
-                              module->constantDoubleMinusZero,
+                              intrinsics->constantDoubleMinusZero,
                               pop(), "", currentBlock), false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1141,7 +1141,7 @@
         Value* val1 = pop();
         push(BinaryOperator::CreateShl(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1159,7 +1159,7 @@
         Value* val1 = pop();
         push(BinaryOperator::CreateAShr(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1181,7 +1181,7 @@
         Value* val1 = pop();
         push(BinaryOperator::CreateLShr(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1200,7 +1200,7 @@
         Value* val1 = pop();
         push(BinaryOperator::CreateAnd(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1219,7 +1219,7 @@
         Value* val1 = pop();
         push(BinaryOperator::CreateOr(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1238,7 +1238,7 @@
         Value* val1 = pop();
         push(BinaryOperator::CreateXor(val1, val2, "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1256,7 +1256,7 @@
       case I2L :
         push(new SExtInst(pop(), llvm::Type::getInt64Ty(*llvmContext), "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
 
       case I2F :
@@ -1267,7 +1267,7 @@
       case I2D :
         push(new SIToFPInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       
       case L2I :
@@ -1286,7 +1286,7 @@
         pop();
         push(new SIToFPInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       
       case F2I : {
@@ -1296,7 +1296,7 @@
         
         BasicBlock* res = createBasicBlock("F2I");
         PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res);
-        node->addIncoming(module->constantZero, currentBlock);
+        node->addIncoming(intrinsics->constantZero, currentBlock);
         BasicBlock* cont = createBasicBlock("F2I");
 
         BranchInst::Create(res, cont, test, currentBlock);
@@ -1304,23 +1304,23 @@
         currentBlock = cont;
         
         test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OGE, val, 
-                            module->constantMaxIntFloat, "");
+                            intrinsics->constantMaxIntFloat, "");
 
         cont = createBasicBlock("F2I");
 
         BranchInst::Create(res, cont, test, currentBlock);
-        node->addIncoming(module->constantMaxInt,
+        node->addIncoming(intrinsics->constantMaxInt,
                           currentBlock);
 
         currentBlock = cont;
 
         test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OLE, val,
-                            module->constantMinIntFloat, "");
+                            intrinsics->constantMinIntFloat, "");
         
         cont = createBasicBlock("F2I");
 
         BranchInst::Create(res, cont, test, currentBlock);
-        node->addIncoming(module->constantMinInt, currentBlock);
+        node->addIncoming(intrinsics->constantMinInt, currentBlock);
         
         currentBlock = cont;
         llvm::Value* newVal = new FPToSIInst(val, Type::getInt32Ty(*llvmContext), "",
@@ -1342,7 +1342,7 @@
         
         BasicBlock* res = createBasicBlock("F2L");
         PHINode* node = PHINode::Create(llvm::Type::getInt64Ty(*llvmContext), "", res);
-        node->addIncoming(module->constantLongZero, currentBlock);
+        node->addIncoming(intrinsics->constantLongZero, currentBlock);
         BasicBlock* cont = createBasicBlock("F2L");
 
         BranchInst::Create(res, cont, test, currentBlock);
@@ -1350,22 +1350,22 @@
         currentBlock = cont;
         
         test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OGE, val, 
-                            module->constantMaxLongFloat, "");
+                            intrinsics->constantMaxLongFloat, "");
 
         cont = createBasicBlock("F2L");
 
         BranchInst::Create(res, cont, test, currentBlock);
-        node->addIncoming(module->constantMaxLong, currentBlock);
+        node->addIncoming(intrinsics->constantMaxLong, currentBlock);
 
         currentBlock = cont;
 
         test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OLE, val, 
-                            module->constantMinLongFloat, "");
+                            intrinsics->constantMinLongFloat, "");
         
         cont = createBasicBlock("F2L");
 
         BranchInst::Create(res, cont, test, currentBlock);
-        node->addIncoming(module->constantMinLong, currentBlock);
+        node->addIncoming(intrinsics->constantMinLong, currentBlock);
         
         currentBlock = cont;
         llvm::Value* newVal = new FPToSIInst(val, Type::getInt64Ty(*llvmContext), "",
@@ -1377,14 +1377,14 @@
         currentBlock = res;
         
         push(node, false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
       case F2D :
         push(new FPExtInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock),
              false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       
       case D2I : {
@@ -1395,7 +1395,7 @@
         
         BasicBlock* res = createBasicBlock("D2I");
         PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res);
-        node->addIncoming(module->constantZero, currentBlock);
+        node->addIncoming(intrinsics->constantZero, currentBlock);
         BasicBlock* cont = createBasicBlock("D2I");
 
         BranchInst::Create(res, cont, test, currentBlock);
@@ -1403,22 +1403,22 @@
         currentBlock = cont;
         
         test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OGE, val,
-                            module->constantMaxIntDouble, "");
+                            intrinsics->constantMaxIntDouble, "");
 
         cont = createBasicBlock("D2I");
 
         BranchInst::Create(res, cont, test, currentBlock);
-        node->addIncoming(module->constantMaxInt, currentBlock);
+        node->addIncoming(intrinsics->constantMaxInt, currentBlock);
 
         currentBlock = cont;
 
         test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OLE, val,
-                            module->constantMinIntDouble, "");
+                            intrinsics->constantMinIntDouble, "");
         
         cont = createBasicBlock("D2I");
 
         BranchInst::Create(res, cont, test, currentBlock);
-        node->addIncoming(module->constantMinInt, currentBlock);
+        node->addIncoming(intrinsics->constantMinInt, currentBlock);
         
         currentBlock = cont;
         llvm::Value* newVal = new FPToSIInst(val, Type::getInt32Ty(*llvmContext), "",
@@ -1442,7 +1442,7 @@
         
         BasicBlock* res = createBasicBlock("D2L");
         PHINode* node = PHINode::Create(llvm::Type::getInt64Ty(*llvmContext), "", res);
-        node->addIncoming(module->constantLongZero, currentBlock);
+        node->addIncoming(intrinsics->constantLongZero, currentBlock);
         BasicBlock* cont = createBasicBlock("D2L");
 
         BranchInst::Create(res, cont, test, currentBlock);
@@ -1450,23 +1450,23 @@
         currentBlock = cont;
         
         test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OGE, val,
-                            module->constantMaxLongDouble, "");
+                            intrinsics->constantMaxLongDouble, "");
 
         cont = createBasicBlock("D2L");
 
         BranchInst::Create(res, cont, test, currentBlock);
-        node->addIncoming(module->constantMaxLong, currentBlock);
+        node->addIncoming(intrinsics->constantMaxLong, currentBlock);
 
         currentBlock = cont;
 
         test = 
           new FCmpInst(*currentBlock, FCmpInst::FCMP_OLE, val,
-                       module->constantMinLongDouble, "");
+                       intrinsics->constantMinLongDouble, "");
         
         cont = createBasicBlock("D2L");
 
         BranchInst::Create(res, cont, test, currentBlock);
-        node->addIncoming(module->constantMinLong, currentBlock);
+        node->addIncoming(intrinsics->constantMinLong, currentBlock);
         
         currentBlock = cont;
         llvm::Value* newVal = new FPToSIInst(val, Type::getInt64Ty(*llvmContext), "",
@@ -1478,7 +1478,7 @@
         currentBlock = res;
         
         push(node, false);
-        push(module->constantZero, false);
+        push(intrinsics->constantZero, false);
         break;
       }
 
@@ -1530,18 +1530,18 @@
         BasicBlock* cont = createBasicBlock("LCMP");
         BasicBlock* res = createBasicBlock("LCMP");
         PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res);
-        node->addIncoming(module->constantZero, currentBlock);
+        node->addIncoming(intrinsics->constantZero, currentBlock);
         
         BranchInst::Create(res, cont, test, currentBlock);
         currentBlock = cont;
 
         test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT, val1, val2, "");
-        node->addIncoming(module->constantMinusOne, currentBlock);
+        node->addIncoming(intrinsics->constantMinusOne, currentBlock);
 
         cont = createBasicBlock("LCMP");
         BranchInst::Create(res, cont, test, currentBlock);
         currentBlock = cont;
-        node->addIncoming(module->constantOne, currentBlock);
+        node->addIncoming(intrinsics->constantOne, currentBlock);
         BranchInst::Create(res, currentBlock);
         currentBlock = res;
         
@@ -1801,7 +1801,7 @@
         Value* expr = ConstantExpr::getIntToPtr(
                                     ConstantInt::get(Type::getInt64Ty(*llvmContext),
                                                      uint64_t (index)),
-                                    module->JavaObjectType);
+                                    intrinsics->JavaObjectType);
         push(expr, false);
         branch(opcodeInfos[tmp + readS2(bytecodes, i)],
                currentBlock);
@@ -1992,7 +1992,7 @@
 #else
           Value* args[2] = { isolateLocal,
                              ConstantInt::get(Type::getInt32Ty(*llvmContext), id - 4) };
-          valCl = CallInst::Create(module->GetJnjvmArrayClassFunction,
+          valCl = CallInst::Create(intrinsics->GetJnjvmArrayClassFunction,
                                    args, args + 2, "", currentBlock);
 #endif
 
@@ -2000,9 +2000,9 @@
           sizeElement = ConstantInt::get(Type::getInt32Ty(*llvmContext),
                                                     LAI.logSizeInBytesConstant);
           if (TheCompiler->isStaticCompiling() &&
-              valCl->getType() != module->JavaClassArrayType) {
+              valCl->getType() != intrinsics->JavaClassArrayType) {
             valCl = new LoadInst(valCl, "", currentBlock);
-            TheVT = CallInst::Create(module->GetVTFromClassArrayFunction,
+            TheVT = CallInst::Create(intrinsics->GetVTFromClassArrayFunction,
                                      valCl, "", currentBlock);
           } else {
             TheVT = TheCompiler->getVirtualTable(dcl->virtualVT);
@@ -2023,9 +2023,9 @@
             // are compiling, the result of getNativeClass is a pointer to
             // the class. Load it.
             if (TheCompiler->isStaticCompiling() && 
-                valCl->getType() != module->JavaClassArrayType) {
+                valCl->getType() != intrinsics->JavaClassArrayType) {
               valCl = new LoadInst(valCl, "", currentBlock);
-              TheVT = CallInst::Create(module->GetVTFromClassArrayFunction,
+              TheVT = CallInst::Create(intrinsics->GetVTFromClassArrayFunction,
                                        valCl, "", currentBlock);
             } else {
               TheVT = TheCompiler->getVirtualTable(dcl->virtualVT);
@@ -2033,64 +2033,64 @@
 
           } else {
             const llvm::Type* Ty = 
-              PointerType::getUnqual(module->JavaClassArrayType);
+              PointerType::getUnqual(intrinsics->JavaClassArrayType);
             Value* args[2]= { valCl, Constant::getNullValue(Ty) };
-            valCl = CallInst::Create(module->GetArrayClassFunction, args,
+            valCl = CallInst::Create(intrinsics->GetArrayClassFunction, args,
                                      args + 2, "", currentBlock);
-            TheVT = CallInst::Create(module->GetVTFromClassArrayFunction, valCl, "",
+            TheVT = CallInst::Create(intrinsics->GetVTFromClassArrayFunction, valCl, "",
                                      currentBlock);
           }
 
-          sizeElement = module->constantPtrLogSize;
+          sizeElement = intrinsics->constantPtrLogSize;
         }
         Value* arg1 = popAsInt();
 
         if (TheCompiler->hasExceptionsEnabled()) {
           Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT, arg1,
-                                    module->constantZero, "");
+                                    intrinsics->constantZero, "");
 
           BasicBlock* BB1 = createBasicBlock("");
           BasicBlock* BB2 = createBasicBlock("");
 
           BranchInst::Create(BB1, BB2, cmp, currentBlock);
           currentBlock = BB1;
-          throwException(module->NegativeArraySizeExceptionFunction, arg1);
+          throwException(intrinsics->NegativeArraySizeExceptionFunction, arg1);
           currentBlock = BB2;
         
           cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGT, arg1,
-                             module->MaxArraySizeConstant, "");
+                             intrinsics->MaxArraySizeConstant, "");
 
           BB1 = createBasicBlock("");
           BB2 = createBasicBlock("");
 
           BranchInst::Create(BB1, BB2, cmp, currentBlock);
           currentBlock = BB1;
-          throwException(module->OutOfMemoryErrorFunction, arg1);
+          throwException(intrinsics->OutOfMemoryErrorFunction, arg1);
           currentBlock = BB2;
         }
         
         Value* mult = BinaryOperator::CreateShl(arg1, sizeElement, "",
                                                 currentBlock);
         Value* size =
-          BinaryOperator::CreateAdd(module->JavaArraySizeConstant, mult,
+          BinaryOperator::CreateAdd(intrinsics->JavaArraySizeConstant, mult,
                                     "", currentBlock);
-        TheVT = new BitCastInst(TheVT, module->ptrType, "", currentBlock);
-        Instruction* res = invoke(module->AllocateFunction, size, TheVT, "",
+        TheVT = new BitCastInst(TheVT, intrinsics->ptrType, "", currentBlock);
+        Instruction* res = invoke(intrinsics->AllocateFunction, size, TheVT, "",
                                   currentBlock);
-        Value* cast = new BitCastInst(res, module->JavaArrayType, "",
+        Value* cast = new BitCastInst(res, intrinsics->JavaArrayType, "",
                                       currentBlock);
 
         // Set the size
-        Value* gep4[2] = { module->constantZero,
-                           module->JavaArraySizeOffsetConstant };
+        Value* gep4[2] = { intrinsics->constantZero,
+                           intrinsics->JavaArraySizeOffsetConstant };
         Value* GEP = GetElementPtrInst::Create(cast, gep4, gep4 + 2,
                                                "", currentBlock);
         
-        arg1 = new IntToPtrInst(arg1, module->ptrType, "", currentBlock);
+        arg1 = new IntToPtrInst(arg1, intrinsics->ptrType, "", currentBlock);
         new StoreInst(arg1, GEP, currentBlock);
        
         addHighLevelType(res, dcl ? dcl : upcalls->ArrayOfObject);
-        res = new BitCastInst(res, module->JavaObjectType, "", currentBlock);
+        res = new BitCastInst(res, intrinsics->JavaObjectType, "", currentBlock);
         push(res, false, dcl ? dcl : upcalls->ArrayOfObject);
 
         break;
@@ -2128,7 +2128,7 @@
         Value* obj = top();
         Value* args[2] = { obj, clVar };
         Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj,
-                                  module->JavaObjectNullConstant, "");
+                                  intrinsics->JavaObjectNullConstant, "");
         BasicBlock* endBlock = createBasicBlock("end type compare");
         PHINode* node = PHINode::Create(Type::getInt1Ty(*llvmContext), "", endBlock);
         
@@ -2141,7 +2141,7 @@
 
           BranchInst::Create(endCheckcast, ifFalse, cmp, currentBlock);
           currentBlock = exceptionCheckcast;
-          throwException(module->ClassCastExceptionFunction, args, 2);
+          throwException(intrinsics->ClassCastExceptionFunction, args, 2);
           currentBlock = ifFalse;
         } else {
           BasicBlock* ifFalse = createBasicBlock("false type compare");
@@ -2152,32 +2152,32 @@
 
         Value* TheVT = 0;
         if (!cl || TheCompiler->isStaticCompiling()) {
-          TheVT = CallInst::Create(module->GetVTFromCommonClassFunction,
+          TheVT = CallInst::Create(intrinsics->GetVTFromCommonClassFunction,
                                    clVar, "", currentBlock);
         } else {
           TheVT = TheCompiler->getVirtualTable(cl->virtualVT);
         }
 
         
-        Value* objVT = CallInst::Create(module->GetVTFunction, obj, "",
+        Value* objVT = CallInst::Create(intrinsics->GetVTFunction, obj, "",
                                        currentBlock);
         Value* classArgs[2] = { objVT, TheVT };
          
         Value* res = 0;
         if (cl) {
           if (cl->isSecondaryClass()) {
-            res = CallInst::Create(module->IsSecondaryClassFunction,
+            res = CallInst::Create(intrinsics->IsSecondaryClassFunction,
                                    classArgs, classArgs + 2, "",
                                    currentBlock);
           } else {
-            Value* inDisplay = CallInst::Create(module->GetDisplayFunction,
+            Value* inDisplay = CallInst::Create(intrinsics->GetDisplayFunction,
                                                 objVT, "", currentBlock);
             
             uint32 depth = cl->virtualVT->depth;
             ConstantInt* CI = ConstantInt::get(Type::getInt32Ty(*llvmContext), depth);
             Value* displayArgs[2] = { inDisplay, CI };
             Value* VTInDisplay = 
-              CallInst::Create(module->GetVTInDisplayFunction,
+              CallInst::Create(intrinsics->GetVTInDisplayFunction,
                                displayArgs, displayArgs + 2, "",
                                currentBlock);
              
@@ -2185,7 +2185,7 @@
                                TheVT, "");
           }
         } else {
-          res = CallInst::Create(module->IsAssignableFromFunction,
+          res = CallInst::Create(intrinsics->IsAssignableFromFunction,
                                  classArgs, classArgs + 2, "",
                                  currentBlock);
         }
@@ -2238,7 +2238,7 @@
         for (sint32 v = 0; v < dim + 2; ++v) {
           Args.push_back(args[v]);
         }
-        push(invoke(module->MultiCallNewFunction, Args, "", currentBlock),
+        push(invoke(intrinsics->MultiCallNewFunction, Args, "", currentBlock),
              false, dcl ? dcl : upcalls->ArrayOfObject);
         break;
       }

Removed: vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp?rev=96193&view=auto

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (removed)
@@ -1,428 +0,0 @@
-//===--------- JnjvmModule.cpp - Definition of a Jnjvm module -------------===//
-//
-//                            The VMKit project
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/BasicBlock.h"
-#include "llvm/CallingConv.h"
-#include "llvm/Constants.h"
-#include "llvm/Instructions.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Module.h"
-#include "llvm/PassManager.h"
-#include "llvm/Analysis/LoopPass.h"
-#include "llvm/Target/TargetData.h"
-
-#include "mvm/JIT.h"
-
-#include "JavaArray.h"
-#include "JavaClass.h"
-#include "JavaJIT.h"
-#include "JavaTypes.h"
-
-#include "j3/JnjvmModule.h"
-#include "j3/LLVMMaterializer.h"
-
-using namespace j3;
-using namespace llvm;
-
-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::CodeLineInfoType = 0;
-const llvm::Type* JnjvmModule::ConstantPoolType = 0;
-const llvm::Type* JnjvmModule::UTF8Type = 0;
-const llvm::Type* JnjvmModule::JavaFieldType = 0;
-const llvm::Type* JnjvmModule::JavaMethodType = 0;
-const llvm::Type* JnjvmModule::AttributType = 0;
-const llvm::Type* JnjvmModule::JavaThreadType = 0;
-const llvm::Type* JnjvmModule::MutatorThreadType = 0;
-
-#ifdef ISOLATE_SHARING
-const llvm::Type* JnjvmModule::JnjvmType = 0;
-#endif
-
-const llvm::Type*   JnjvmModule::JavaClassType;
-const llvm::Type*   JnjvmModule::JavaClassPrimitiveType;
-const llvm::Type*   JnjvmModule::JavaClassArrayType;
-const llvm::Type*   JnjvmModule::JavaCommonClassType;
-const llvm::Type*   JnjvmModule::VTType;
-
-
-JavaLLVMCompiler::JavaLLVMCompiler(const std::string& str) :
-  TheModule(new llvm::Module(str, getGlobalContext())),
-  JavaIntrinsics(TheModule) {
-
-  enabledException = true;
-#ifdef WITH_LLVM_GCC
-  cooperativeGC = true;
-#else
-  cooperativeGC = false;
-#endif
-}
-  
-void JavaLLVMCompiler::resolveVirtualClass(Class* cl) {
-  // Lock here because we may be called by a class resolver
-  mvm::MvmModule::protectIR();
-  LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
-  LCI->getVirtualType();
-  mvm::MvmModule::unprotectIR();
-}
-
-void JavaLLVMCompiler::resolveStaticClass(Class* cl) {
-  // Lock here because we may be called by a class initializer
-  mvm::MvmModule::protectIR();
-  LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl);
-  LCI->getStaticType();
-  mvm::MvmModule::unprotectIR();
-}
-
-
-namespace j3 { 
-  namespace llvm_runtime { 
-    #include "LLVMRuntime.inc"
-  }
-}
-
-void JnjvmModule::initialise() {
-  Module* module = globalModule;
-  
-  if (!module->getTypeByName("JavaThread"))
-    j3::llvm_runtime::makeLLVMModuleContents(module);
-
-  VTType = PointerType::getUnqual(module->getTypeByName("VT"));
-
-#ifdef ISOLATE_SHARING
-  JnjvmType = 
-    PointerType::getUnqual(module->getTypeByName("Jnjvm"));
-#endif
-  ConstantPoolType = ptrPtrType;
-  
-  JavaObjectType = 
-    PointerType::getUnqual(module->getTypeByName("JavaObject"));
-
-  JavaArrayType =
-    PointerType::getUnqual(module->getTypeByName("JavaArray"));
-  
-  JavaCommonClassType =
-    PointerType::getUnqual(module->getTypeByName("JavaCommonClass"));
-  JavaClassPrimitiveType =
-    PointerType::getUnqual(module->getTypeByName("JavaClassPrimitive"));
-  JavaClassArrayType =
-    PointerType::getUnqual(module->getTypeByName("JavaClassArray"));
-  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"));
-
-  JavaFieldType =
-    PointerType::getUnqual(module->getTypeByName("JavaField"));
-  JavaMethodType =
-    PointerType::getUnqual(module->getTypeByName("JavaMethod"));
-  UTF8Type =
-    PointerType::getUnqual(module->getTypeByName("UTF8"));
-  AttributType =
-    PointerType::getUnqual(module->getTypeByName("Attribut"));
-  JavaThreadType =
-    PointerType::getUnqual(module->getTypeByName("JavaThread"));
-  MutatorThreadType =
-    PointerType::getUnqual(module->getTypeByName("MutatorThread"));
-  
-  CodeLineInfoType =
-    PointerType::getUnqual(module->getTypeByName("CodeLineInfo"));
- 
-  LLVMAssessorInfo::initialise();
-}
-
-Function* JavaLLVMCompiler::getMethod(JavaMethod* meth) {
-  return getMethodInfo(meth)->getMethod();
-}
-
-JnjvmModule::JnjvmModule(llvm::Module* module) :
-  MvmModule(module) {
-  
-  if (!VTType) {
-    initialise();
-    copyDefinitions(module, globalModule);
-  }
-  
-  JavaObjectNullConstant =
-    Constant::getNullValue(JnjvmModule::JavaObjectType);
-  MaxArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
-                                          JavaArray::MaxArraySize);
-  JavaArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()),
-                                          sizeof(JavaObject) + sizeof(ssize_t));
-  
-  
-  JavaArrayElementsOffsetConstant = constantTwo;
-  JavaArraySizeOffsetConstant = constantOne;
-  JavaObjectLockOffsetConstant = constantOne;
-  JavaObjectVTOffsetConstant = constantZero;
-  OffsetClassInVTConstant = constantThree;
-  OffsetDepthInVTConstant = constantFour;
-  OffsetDisplayInVTConstant = constantSeven;
-  OffsetBaseClassVTInVTConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 17);
-  OffsetIMTInVTConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 18);
-  
-  OffsetAccessInCommonClassConstant = constantOne;
-  IsArrayConstant = ConstantInt::get(Type::getInt16Ty(getGlobalContext()),
-                                     JNJVM_ARRAY);
-  
-  IsPrimitiveConstant = ConstantInt::get(Type::getInt16Ty(getGlobalContext()),
-                                         JNJVM_PRIMITIVE);
- 
-  OffsetBaseClassInArrayClassConstant = constantOne;
-  OffsetLogSizeInPrimitiveClassConstant = constantOne;
-
-  OffsetObjectSizeInClassConstant = constantOne;
-  OffsetVTInClassConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 7);
-  OffsetTaskClassMirrorInClassConstant = constantThree;
-  OffsetVirtualMethodsInClassConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 9);
-  OffsetStaticInstanceInTaskClassMirrorConstant = constantThree;
-  OffsetStatusInTaskClassMirrorConstant = constantZero;
-  OffsetInitializedInTaskClassMirrorConstant = constantOne;
-  
-  OffsetIsolateInThreadConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 3);
-  OffsetDoYieldInThreadConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 6);
-  OffsetJNIInThreadConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 1);
-  OffsetJavaExceptionInThreadConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 2);
-  OffsetCXXExceptionInThreadConstant =
-    ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 3);
-  
-  ClassReadyConstant =
-    ConstantInt::get(Type::getInt8Ty(getGlobalContext()), ready);
-  
-  module->addTypeName("JavaObject", JavaObjectType->getContainedType(0));
-  module->addTypeName("JavaArray", JavaArrayType->getContainedType(0));
-  module->addTypeName("JavaCommonClass",
-                      JavaCommonClassType->getContainedType(0));
-  module->addTypeName("JavaClass", JavaClassType->getContainedType(0));
-  module->addTypeName("JavaClassPrimitive",
-                      JavaClassPrimitiveType->getContainedType(0));
-  module->addTypeName("JavaClassArray",
-                      JavaClassArrayType->getContainedType(0));
-  module->addTypeName("ArrayUInt8", JavaArrayUInt8Type->getContainedType(0));
-  module->addTypeName("ArraySInt8", JavaArraySInt8Type->getContainedType(0));
-  module->addTypeName("ArrayUInt16", JavaArrayUInt16Type->getContainedType(0));
-  module->addTypeName("ArraySInt16", JavaArraySInt16Type->getContainedType(0));
-  module->addTypeName("ArraySInt32", JavaArraySInt32Type->getContainedType(0));
-  module->addTypeName("ArrayLong", JavaArrayLongType->getContainedType(0));
-  module->addTypeName("ArrayFloat", JavaArrayFloatType->getContainedType(0));
-  module->addTypeName("ArrayDouble", JavaArrayDoubleType->getContainedType(0));
-  module->addTypeName("ArrayObject", JavaArrayObjectType->getContainedType(0));
-   
-  InterfaceLookupFunction = module->getFunction("j3InterfaceLookup");
-  MultiCallNewFunction = module->getFunction("j3MultiCallNew");
-  ForceLoadedCheckFunction = module->getFunction("forceLoadedCheck");
-  InitialisationCheckFunction = module->getFunction("initialisationCheck");
-  ForceInitialisationCheckFunction = 
-    module->getFunction("forceInitialisationCheck");
-  InitialiseClassFunction = module->getFunction("j3RuntimeInitialiseClass");
-  
-  GetConstantPoolAtFunction = module->getFunction("getConstantPoolAt");
-  ArrayLengthFunction = module->getFunction("arrayLength");
-  GetVTFunction = module->getFunction("getVT");
-  GetIMTFunction = module->getFunction("getIMT");
-  GetClassFunction = module->getFunction("getClass");
-  ClassLookupFunction = module->getFunction("j3ClassLookup");
-  GetVTFromClassFunction = module->getFunction("getVTFromClass");
-  GetVTFromClassArrayFunction = module->getFunction("getVTFromClassArray");
-  GetVTFromCommonClassFunction = module->getFunction("getVTFromCommonClass");
-  GetBaseClassVTFromVTFunction = module->getFunction("getBaseClassVTFromVT");
-  GetObjectSizeFromClassFunction = 
-    module->getFunction("getObjectSizeFromClass");
- 
-  GetClassDelegateeFunction = module->getFunction("getClassDelegatee");
-  RuntimeDelegateeFunction = module->getFunction("j3RuntimeDelegatee");
-  IsAssignableFromFunction = module->getFunction("isAssignableFrom");
-  IsSecondaryClassFunction = module->getFunction("isSecondaryClass");
-  GetDepthFunction = module->getFunction("getDepth");
-  GetStaticInstanceFunction = module->getFunction("getStaticInstance");
-  GetDisplayFunction = module->getFunction("getDisplay");
-  GetVTInDisplayFunction = module->getFunction("getVTInDisplay");
-  AquireObjectFunction = module->getFunction("j3JavaObjectAquire");
-  ReleaseObjectFunction = module->getFunction("j3JavaObjectRelease");
-  OverflowThinLockFunction = module->getFunction("j3OverflowThinLock");
-
-  VirtualFieldLookupFunction = module->getFunction("j3VirtualFieldLookup");
-  StaticFieldLookupFunction = module->getFunction("j3StaticFieldLookup");
-  StringLookupFunction = module->getFunction("j3StringLookup");
-  StartJNIFunction = module->getFunction("j3StartJNI");
-  EndJNIFunction = module->getFunction("j3EndJNI");
-  
-  ResolveVirtualStubFunction = module->getFunction("j3ResolveVirtualStub");
-  ResolveStaticStubFunction = module->getFunction("j3ResolveStaticStub");
-  ResolveSpecialStubFunction = module->getFunction("j3ResolveSpecialStub");
-  
-  NullPointerExceptionFunction =
-    module->getFunction("j3NullPointerException");
-  ClassCastExceptionFunction = module->getFunction("j3ClassCastException");
-  IndexOutOfBoundsExceptionFunction = 
-    module->getFunction("j3IndexOutOfBoundsException");
-  NegativeArraySizeExceptionFunction = 
-    module->getFunction("j3NegativeArraySizeException");
-  OutOfMemoryErrorFunction = module->getFunction("j3OutOfMemoryError");
-  StackOverflowErrorFunction = module->getFunction("j3StackOverflowError");
-  ArrayStoreExceptionFunction = module->getFunction("j3ArrayStoreException");
-  ArithmeticExceptionFunction = module->getFunction("j3ArithmeticException");
-
-  PrintExecutionFunction = module->getFunction("j3PrintExecution");
-  PrintMethodStartFunction = module->getFunction("j3PrintMethodStart");
-  PrintMethodEndFunction = module->getFunction("j3PrintMethodEnd");
-
-  ThrowExceptionFunction = module->getFunction("j3ThrowException");
-
-  GetArrayClassFunction = module->getFunction("j3GetArrayClass");
- 
-  GetFinalInt8FieldFunction = module->getFunction("getFinalInt8Field");
-  GetFinalInt16FieldFunction = module->getFunction("getFinalInt16Field");
-  GetFinalInt32FieldFunction = module->getFunction("getFinalInt32Field");
-  GetFinalLongFieldFunction = module->getFunction("getFinalLongField");
-  GetFinalFloatFieldFunction = module->getFunction("getFinalFloatField");
-  GetFinalDoubleFieldFunction = module->getFunction("getFinalDoubleField");
-  GetFinalObjectFieldFunction = module->getFunction("getFinalObjectField");
-
-#ifdef ISOLATE_SHARING
-  GetCtpClassFunction = module->getFunction("getCtpClass");
-  GetJnjvmExceptionClassFunction = 
-    module->getFunction("getJnjvmExceptionClass");
-  GetJnjvmArrayClassFunction = module->getFunction("getJnjvmArrayClass");
-  StaticCtpLookupFunction = module->getFunction("j3StaticCtpLookup");
-  SpecialCtpLookupFunction = module->getFunction("j3SpecialCtpLookup");
-#endif
- 
-#ifdef SERVICE
-  ServiceCallStartFunction = module->getFunction("j3ServiceCallStart");
-  ServiceCallStopFunction = module->getFunction("j3ServiceCallStop");
-#endif
-
-  JavaObjectTracerFunction = module->getFunction("JavaObjectTracer");
-  EmptyTracerFunction = module->getFunction("EmptyTracer");
-  JavaArrayTracerFunction = module->getFunction("JavaArrayTracer");
-  ArrayObjectTracerFunction = module->getFunction("ArrayObjectTracer");
-  RegularObjectTracerFunction = module->getFunction("RegularObjectTracer");
-
-#ifndef WITHOUT_VTABLE
-  VirtualLookupFunction = module->getFunction("j3VirtualTableLookup");
-#endif
-
-  GetLockFunction = module->getFunction("getLock");
-  ThrowExceptionFromJITFunction =
-    module->getFunction("j3ThrowExceptionFromJIT");
- 
-}
-
-Function* JavaLLVMCompiler::parseFunction(JavaMethod* meth) {
-  LLVMMethodInfo* LMI = getMethodInfo(meth);
-  Function* func = LMI->getMethod();
-  
-  // We are jitting. Take the lock.
-  JnjvmModule::protectIR();
-  if (func->getLinkage() == GlobalValue::ExternalWeakLinkage) {
-    JavaJIT jit(this, meth, func);
-    if (isNative(meth->access)) {
-      jit.nativeCompile();
-      JnjvmModule::runPasses(func, JavaNativeFunctionPasses);
-    } else {
-      jit.javaCompile();
-      JnjvmModule::runPasses(func, JnjvmModule::globalFunctionPasses);
-      JnjvmModule::runPasses(func, JavaFunctionPasses);
-    }
-    func->setLinkage(GlobalValue::ExternalLinkage);
-  }
-  JnjvmModule::unprotectIR();
-
-  return func;
-}
-
-JavaMethod* JavaLLVMCompiler::getJavaMethod(llvm::Function* F) {
-  function_iterator E = functions.end();
-  function_iterator I = functions.find(F);
-  if (I == E) return 0;
-  return I->second;
-}
-
-MDNode* JavaLLVMCompiler::GetDbgSubprogram(JavaMethod* meth) {
-  if (getMethodInfo(meth)->getDbgSubprogram() == NULL) {
-    MDNode* node =
-      JavaIntrinsics.DebugFactory->CreateSubprogram(DIDescriptor(), "", "",
-                                                    "", DICompileUnit(), 0,
-                                                    DIType(), false,
-                                                    false).getNode();
-    DbgInfos.insert(std::make_pair(node, meth));
-    getMethodInfo(meth)->setDbgSubprogram(node);
-  }
-  return getMethodInfo(meth)->getDbgSubprogram();
-}
-
-JavaLLVMCompiler::~JavaLLVMCompiler() {
-  delete JavaFunctionPasses;
-  delete JavaNativeFunctionPasses;
-}
-
-namespace mvm {
-  llvm::FunctionPass* createEscapeAnalysisPass();
-  llvm::LoopPass* createLoopSafePointsPass();
-}
-
-namespace j3 {
-  llvm::FunctionPass* createLowerConstantCallsPass(JnjvmModule* M);
-}
-
-void JavaLLVMCompiler::addJavaPasses() {
-  JavaNativeFunctionPasses = new FunctionPassManager(TheModule);
-  JavaNativeFunctionPasses->add(new TargetData(TheModule));
-  // Lower constant calls to lower things like getClass used
-  // on synchronized methods.
-  JavaNativeFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics()));
-  
-  JavaFunctionPasses = new FunctionPassManager(TheModule);
-  JavaFunctionPasses->add(new TargetData(TheModule));
-  if (cooperativeGC)
-    JavaFunctionPasses->add(mvm::createLoopSafePointsPass());
-
-  // Re-enable this when the pointers in stack-allocated objects can
-  // be given to the GC.
-  //JavaFunctionPasses->add(mvm::createEscapeAnalysisPass());
-  JavaFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics()));
-}

Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Sun Feb 14 16:07:42 2010
@@ -39,7 +39,7 @@
 const Type* LLVMClassInfo::getVirtualType() {
   if (!virtualType) {
     std::vector<const llvm::Type*> fields;
-    const TargetData* targetData = JnjvmModule::TheTargetData;
+    const TargetData* targetData = J3Intrinsics::TheTargetData;
     const StructLayout* sl = 0;
     const StructType* structType = 0;
     JavaLLVMCompiler* Mod = 
@@ -65,7 +65,7 @@
       sl = targetData->getStructLayout(structType);
     
     } else {
-      virtualType = JnjvmModule::JavaObjectType;
+      virtualType = J3Intrinsics::JavaObjectType;
       structType = dyn_cast<const StructType>(virtualType->getContainedType(0));
       sl = targetData->getStructLayout(structType);
       
@@ -77,7 +77,7 @@
       field.ptrOffset = sl->getElementOffset(i + 1);
     }
     
-    uint64 size = JnjvmModule::getTypeSize(structType);
+    uint64 size = J3Intrinsics::getTypeSize(structType);
     classDef->virtualSize = (uint32)size;
     classDef->alignment = sl->getAlignment();
     virtualSizeConstant = ConstantInt::get(Type::getInt32Ty(context), size);
@@ -109,7 +109,7 @@
   
     StructType* structType = StructType::get(context, fields, false);
     staticType = PointerType::getUnqual(structType);
-    const TargetData* targetData = JnjvmModule::TheTargetData;
+    const TargetData* targetData = J3Intrinsics::TheTargetData;
     const StructLayout* sl = targetData->getStructLayout(structType);
     
     for (uint32 i = 0; i < classDef->nbStaticFields; ++i) {
@@ -117,7 +117,7 @@
       field.ptrOffset = sl->getElementOffset(i);
     }
     
-    uint64 size = JnjvmModule::getTypeSize(structType);
+    uint64 size = J3Intrinsics::getTypeSize(structType);
     cl->staticSize = size;
   }
   return staticType;
@@ -241,7 +241,7 @@
     uint32 size = signature->nbArguments;
     Typedef* const* arguments = signature->getArgumentsType();
 
-    llvmArgs.push_back(JnjvmModule::JavaObjectType);
+    llvmArgs.push_back(J3Intrinsics::JavaObjectType);
 
     for (uint32 i = 0; i < size; ++i) {
       Typedef* type = arguments[i];
@@ -250,7 +250,7 @@
     }
 
 #if defined(ISOLATE_SHARING)
-    llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool
+    llvmArgs.push_back(J3Intrinsics::ConstantPoolType); // cached constant pool
 #endif
 
     LLVMAssessorInfo& LAI = 
@@ -276,7 +276,7 @@
     }
 
 #if defined(ISOLATE_SHARING)
-    llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool
+    llvmArgs.push_back(J3Intrinsics::ConstantPoolType); // cached constant pool
 #endif
 
     LLVMAssessorInfo& LAI = 
@@ -295,7 +295,7 @@
     uint32 size = signature->nbArguments;
     Typedef* const* arguments = signature->getArgumentsType();
    
-    const llvm::Type* Ty = PointerType::getUnqual(JnjvmModule::JavaObjectType);
+    const llvm::Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaObjectType);
 
     llvmArgs.push_back(mvm::MvmModule::ptrType); // JNIEnv
     llvmArgs.push_back(Ty); // Class
@@ -304,7 +304,7 @@
       Typedef* type = arguments[i];
       LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type);
       const llvm::Type* Ty = LAI.llvmType;
-      if (Ty == JnjvmModule::JavaObjectType) {
+      if (Ty == J3Intrinsics::JavaObjectType) {
         llvmArgs.push_back(LAI.llvmTypePtr);
       } else {
         llvmArgs.push_back(LAI.llvmType);
@@ -312,12 +312,12 @@
     }
 
 #if defined(ISOLATE_SHARING)
-    llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool
+    llvmArgs.push_back(J3Intrinsics::ConstantPoolType); // cached constant pool
 #endif
 
     LLVMAssessorInfo& LAI = 
       JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
-    const llvm::Type* RetType = LAI.llvmType == JnjvmModule::JavaObjectType ?
+    const llvm::Type* RetType = LAI.llvmType == J3Intrinsics::JavaObjectType ?
       LAI.llvmTypePtr : LAI.llvmType;
     nativeType = FunctionType::get(RetType, llvmArgs, false);
     mvm::MvmModule::unprotectIR();
@@ -333,7 +333,7 @@
   JavaLLVMCompiler* Mod = 
     (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
   LLVMContext& context = Mod->getLLVMModule()->getContext();
-  JnjvmModule& Intrinsics = *Mod->getIntrinsics();
+  J3Intrinsics& Intrinsics = *Mod->getIntrinsics();
   Function* res = 0;
   if (Mod->isStaticCompiling()) {
     const char* type = virt ? "virtual_buf" : "static_buf";
@@ -426,7 +426,7 @@
   
   JavaLLVMCompiler* Mod = 
     (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
-  JnjvmModule& Intrinsics = *Mod->getIntrinsics();
+  J3Intrinsics& Intrinsics = *Mod->getIntrinsics();
   std::string name;
   if (Mod->isStaticCompiling()) {
     name += UTF8Buffer(signature->keyName).cString();
@@ -506,7 +506,7 @@
   
   JavaLLVMCompiler* Mod = 
     (JavaLLVMCompiler*)signature->initialLoader->getCompiler();
-  JnjvmModule& Intrinsics = *Mod->getIntrinsics();
+  J3Intrinsics& Intrinsics = *Mod->getIntrinsics();
   std::string name;
   if (Mod->isStaticCompiling()) {
     name += UTF8Buffer(signature->keyName).cString();
@@ -607,9 +607,9 @@
     // Lock here because we are called by arbitrary code
     mvm::MvmModule::protectIR();
     std::vector<const llvm::Type*> Args;
-    Args.push_back(JnjvmModule::ConstantPoolType); // ctp
+    Args.push_back(J3Intrinsics::ConstantPoolType); // ctp
     Args.push_back(getVirtualPtrType());
-    Args.push_back(JnjvmModule::JavaObjectType);
+    Args.push_back(J3Intrinsics::JavaObjectType);
     Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr);
     LLVMAssessorInfo& LAI = 
       JavaLLVMCompiler::getTypedefInfo(signature->getReturnType());
@@ -624,7 +624,7 @@
     // Lock here because we are called by arbitrary code
     mvm::MvmModule::protectIR();
     std::vector<const llvm::Type*> Args;
-    Args.push_back(JnjvmModule::ConstantPoolType); // ctp
+    Args.push_back(J3Intrinsics::ConstantPoolType); // ctp
     Args.push_back(getStaticPtrType());
     Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr);
     LLVMAssessorInfo& LAI = 
@@ -799,14 +799,14 @@
     PointerType::getUnqual(Type::getDoubleTy(getGlobalContext()));
   AssessorInfo[I_DOUBLE].logSizeInBytesConstant = 3;
   
-  AssessorInfo[I_TAB].llvmType = JnjvmModule::JavaObjectType;
+  AssessorInfo[I_TAB].llvmType = J3Intrinsics::JavaObjectType;
   AssessorInfo[I_TAB].llvmTypePtr =
-    PointerType::getUnqual(JnjvmModule::JavaObjectType);
+    PointerType::getUnqual(J3Intrinsics::JavaObjectType);
   AssessorInfo[I_TAB].logSizeInBytesConstant = sizeof(JavaObject*) == 8 ? 3 : 2;
   
-  AssessorInfo[I_REF].llvmType = JnjvmModule::JavaObjectType;
+  AssessorInfo[I_REF].llvmType = J3Intrinsics::JavaObjectType;
   AssessorInfo[I_REF].llvmTypePtr =
-    PointerType::getUnqual(JnjvmModule::JavaObjectType);
+    PointerType::getUnqual(J3Intrinsics::JavaObjectType);
   AssessorInfo[I_REF].logSizeInBytesConstant = sizeof(JavaObject*) == 8 ? 3 : 2;
 }
 

Modified: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Sun Feb 14 16:07:42 2010
@@ -20,7 +20,7 @@
 #include "JavaTypes.h"
 #include "Jnjvm.h"
 
-#include "j3/JnjvmModule.h"
+#include "j3/J3Intrinsics.h"
 #include "j3/LLVMMaterializer.h"
 
 using namespace llvm;

Modified: vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp Sun Feb 14 16:07:42 2010
@@ -17,7 +17,7 @@
 #include "llvm/Support/Debug.h"
 
 #include "JavaClass.h"
-#include "j3/JnjvmModule.h"
+#include "j3/J3Intrinsics.h"
 
 using namespace llvm;
 
@@ -26,9 +26,9 @@
   class VISIBILITY_HIDDEN LowerConstantCalls : public FunctionPass {
   public:
     static char ID;
-    JnjvmModule* module;
-    LowerConstantCalls(JnjvmModule* M) : FunctionPass((intptr_t)&ID),
-      module(M) { }
+    J3Intrinsics* intrinsics;
+    LowerConstantCalls(J3Intrinsics* I) : FunctionPass((intptr_t)&ID),
+      intrinsics(I) { }
 
     virtual bool runOnFunction(Function &F);
   private:
@@ -42,50 +42,50 @@
 
 
 #ifdef ISOLATE
-static Value* getTCM(JnjvmModule* module, Value* Arg, Instruction* CI) {
-  Value* GEP[2] = { module->constantZero,
-                    module->OffsetTaskClassMirrorInClassConstant };
+static Value* getTCM(J3Intrinsics* intrinsics, Value* Arg, Instruction* CI) {
+  Value* GEP[2] = { intrinsics->constantZero,
+                    intrinsics->OffsetTaskClassMirrorInClassConstant };
   Value* TCMArray = GetElementPtrInst::Create(Arg, GEP, GEP + 2, "", CI);
 
-  Value* threadId = CallInst::Create(module->llvm_frameaddress,
-                                     module->constantZero, "", CI);
-  threadId = new PtrToIntInst(threadId, module->pointerSizeType, "", CI);
-  threadId = BinaryOperator::CreateAnd(threadId, module->constantThreadIDMask,
+  Value* threadId = CallInst::Create(intrinsics->llvm_frameaddress,
+                                     intrinsics->constantZero, "", CI);
+  threadId = new PtrToIntInst(threadId, intrinsics->pointerSizeType, "", CI);
+  threadId = BinaryOperator::CreateAnd(threadId, intrinsics->constantThreadIDMask,
                                        "", CI);
   
-  threadId = new IntToPtrInst(threadId, module->ptr32Type, "", CI);
+  threadId = new IntToPtrInst(threadId, intrinsics->ptr32Type, "", CI);
   
   Value* IsolateID = GetElementPtrInst::Create(threadId,
-      module->OffsetIsolateInThreadConstant, "", CI);
+      intrinsics->OffsetIsolateInThreadConstant, "", CI);
 
   IsolateID = new LoadInst(IsolateID, "", CI);
 
-  Value* GEP2[2] = { module->constantZero, IsolateID };
+  Value* GEP2[2] = { intrinsics->constantZero, IsolateID };
 
   Value* TCM = GetElementPtrInst::Create(TCMArray, GEP2, GEP2 + 2, "",
                                          CI);
   return TCM;
 }
 
-static Value* getDelegatee(JnjvmModule* module, Value* Arg, Instruction* CI) {
-  Value* GEP[2] = { module->constantZero,
-                    module->constantTwo };
+static Value* getDelegatee(J3Intrinsics* intrinsics, Value* Arg, Instruction* CI) {
+  Value* GEP[2] = { intrinsics->constantZero,
+                    intrinsics->constantTwo };
   Value* TCMArray = GetElementPtrInst::Create(Arg, GEP, GEP + 2, "", CI);
 
-  Value* threadId = CallInst::Create(module->llvm_frameaddress,
-                                     module->constantZero, "", CI);
-  threadId = new PtrToIntInst(threadId, module->pointerSizeType, "", CI);
-  threadId = BinaryOperator::CreateAnd(threadId, module->constantThreadIDMask,
+  Value* threadId = CallInst::Create(intrinsics->llvm_frameaddress,
+                                     intrinsics->constantZero, "", CI);
+  threadId = new PtrToIntInst(threadId, intrinsics->pointerSizeType, "", CI);
+  threadId = BinaryOperator::CreateAnd(threadId, intrinsics->constantThreadIDMask,
                                        "", CI);
   
-  threadId = new IntToPtrInst(threadId, module->ptr32Type, "", CI);
+  threadId = new IntToPtrInst(threadId, intrinsics->ptr32Type, "", CI);
   
   Value* IsolateID = GetElementPtrInst::Create(threadId, 
-      module->OffsetIsolateInThreadConstant, "", CI);
+      intrinsics->OffsetIsolateInThreadConstant, "", CI);
 
   IsolateID = new LoadInst(IsolateID, "", CI);
 
-  Value* GEP2[2] = { module->constantZero, IsolateID };
+  Value* GEP2[2] = { intrinsics->constantZero, IsolateID };
 
   Value* TCM = GetElementPtrInst::Create(TCMArray, GEP2, GEP2 + 2, "",
                                          CI);
@@ -94,12 +94,12 @@
 
 #else
 
-static Value* getTCM(JnjvmModule* module, Value* Arg, Instruction* CI) {
-  Value* GEP[2] = { module->constantZero,
-                    module->OffsetTaskClassMirrorInClassConstant };
+static Value* getTCM(J3Intrinsics* intrinsics, Value* Arg, Instruction* CI) {
+  Value* GEP[2] = { intrinsics->constantZero,
+                    intrinsics->OffsetTaskClassMirrorInClassConstant };
   Value* TCMArray = GetElementPtrInst::Create(Arg, GEP, GEP + 2, "", CI);
   
-  Value* GEP2[2] = { module->constantZero, module->constantZero };
+  Value* GEP2[2] = { intrinsics->constantZero, intrinsics->constantZero };
 
   Value* TCM = GetElementPtrInst::Create(TCMArray, GEP2, GEP2 + 2, "",
                                          CI);
@@ -107,12 +107,12 @@
 
 }
 
-static Value* getDelegatee(JnjvmModule* module, Value* Arg, Instruction* CI) {
-  Value* GEP[2] = { module->constantZero,
-                    module->constantZero };
+static Value* getDelegatee(J3Intrinsics* intrinsics, Value* Arg, Instruction* CI) {
+  Value* GEP[2] = { intrinsics->constantZero,
+                    intrinsics->constantZero };
   Value* TCMArray = GetElementPtrInst::Create(Arg, GEP, GEP + 2, "", CI);
   
-  Value* GEP2[2] = { module->constantZero, module->constantZero };
+  Value* GEP2[2] = { intrinsics->constantZero, intrinsics->constantZero };
 
   Value* TCM = GetElementPtrInst::Create(TCMArray, GEP2, GEP2 + 2, "",
                                          CI);
@@ -131,7 +131,7 @@
       II++;
 
       if (ICmpInst* Cmp = dyn_cast<ICmpInst>(I)) {
-        if (Cmp->getOperand(1) == module->JavaObjectNullConstant) {
+        if (Cmp->getOperand(1) == intrinsics->JavaObjectNullConstant) {
           Value* Arg = Cmp->getOperand(0);
       
 #if 0
@@ -146,7 +146,7 @@
           
           CallSite Ca = CallSite::get(Arg);
           Instruction* CI = Ca.getInstruction();
-          if (CI && Ca.getCalledValue() == module->AllocateFunction) {
+          if (CI && Ca.getCalledValue() == intrinsics->AllocateFunction) {
             Changed = true;
             Cmp->replaceAllUsesWith(ConstantInt::getFalse(*Context));
             Cmp->eraseFromParent();
@@ -166,7 +166,7 @@
             if (BI->hasOneUse()) {
               CallSite Call = CallSite::get(*(BI->use_begin()));
               Instruction* CI = Call.getInstruction();
-              if (CI && Call.getCalledFunction() == module->llvm_gc_gcroot)
+              if (CI && Call.getCalledFunction() == intrinsics->llvm_gc_gcroot)
                 continue;
             }
           }
@@ -202,138 +202,138 @@
       Instruction* CI = Call.getInstruction();
       if (CI) {
         Value* V = Call.getCalledValue();
-        if (V == module->ArrayLengthFunction) {
+        if (V == intrinsics->ArrayLengthFunction) {
           Changed = true;
           Value* val = Call.getArgument(0); // get the array
-          Value* array = new BitCastInst(val, module->JavaArrayType,
+          Value* array = new BitCastInst(val, intrinsics->JavaArrayType,
                                          "", CI);
-          Value* args[2] = { module->constantZero, 
-                             module->JavaArraySizeOffsetConstant };
+          Value* args[2] = { intrinsics->constantZero, 
+                             intrinsics->JavaArraySizeOffsetConstant };
           Value* ptr = GetElementPtrInst::Create(array, args, args + 2,
                                                  "", CI);
           Value* load = new LoadInst(ptr, "", CI);
           load = new PtrToIntInst(load, Type::getInt32Ty(*Context), "", CI);
           CI->replaceAllUsesWith(load);
           CI->eraseFromParent();
-        } else if (V == module->GetVTFunction) {
+        } else if (V == intrinsics->GetVTFunction) {
           Changed = true;
           Value* val = Call.getArgument(0); // get the object
-          Value* indexes[2] = { module->constantZero, module->constantZero };
+          Value* indexes[2] = { intrinsics->constantZero, intrinsics->constantZero };
           Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 2,
                                                    "", CI);
           Value* VT = new LoadInst(VTPtr, "", CI);
           CI->replaceAllUsesWith(VT);
           CI->eraseFromParent();
-        } else if (V == module->GetIMTFunction) {
+        } else if (V == intrinsics->GetIMTFunction) {
           Changed = true;
           Value* val = Call.getArgument(0); // get the VT
-          Value* indexes[2] = { module->constantZero,
-                                module->OffsetIMTInVTConstant };
+          Value* indexes[2] = { intrinsics->constantZero,
+                                intrinsics->OffsetIMTInVTConstant };
           Value* IMTPtr = GetElementPtrInst::Create(val, indexes, indexes + 2,
                                                     "", CI);
           Value* IMT = new LoadInst(IMTPtr, "", CI);
           IMT = new BitCastInst(IMT, CI->getType(), "", CI);
           CI->replaceAllUsesWith(IMT);
           CI->eraseFromParent();
-        } else if (V == module->GetClassFunction) {
+        } else if (V == intrinsics->GetClassFunction) {
           Changed = true;
           Value* val = Call.getArgument(0); // get the object
-          Value* args2[2] = { module->constantZero,
-                              module->JavaObjectVTOffsetConstant };
+          Value* args2[2] = { intrinsics->constantZero,
+                              intrinsics->JavaObjectVTOffsetConstant };
           Value* VTPtr = GetElementPtrInst::Create(val, args2, args2 + 2,
                                                    "", CI);
           Value* VT = new LoadInst(VTPtr, "", CI);
-          Value* args3[2] = { module->constantZero,
-                              module->OffsetClassInVTConstant };
+          Value* args3[2] = { intrinsics->constantZero,
+                              intrinsics->OffsetClassInVTConstant };
 
           Value* clPtr = GetElementPtrInst::Create(VT, args3, args3 + 2,
                                                    "", CI);
           Value* cl = new LoadInst(clPtr, "", CI);
-          cl = new BitCastInst(cl, module->JavaCommonClassType, "", CI);
+          cl = new BitCastInst(cl, intrinsics->JavaCommonClassType, "", CI);
 
           CI->replaceAllUsesWith(cl);
           CI->eraseFromParent();
-        } else if (V == module->GetVTFromClassFunction) {
+        } else if (V == intrinsics->GetVTFromClassFunction) {
           Changed = true;
           
           Value* val = Call.getArgument(0);
-          Value* indexes[3] = { module->constantZero, 
-                                module->constantZero, 
-                                module->OffsetVTInClassConstant };
+          Value* indexes[3] = { intrinsics->constantZero, 
+                                intrinsics->constantZero, 
+                                intrinsics->OffsetVTInClassConstant };
           Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 3,
                                                    "", CI);
           Value* VT = new LoadInst(VTPtr, "", CI);
           CI->replaceAllUsesWith(VT);
           CI->eraseFromParent();
-        } else if (V == module->GetVTFromCommonClassFunction) {
+        } else if (V == intrinsics->GetVTFromCommonClassFunction) {
           Changed = true;
           
           Value* val = Call.getArgument(0);
-          Value* indexes[2] = { module->constantZero, 
-                                module->OffsetVTInClassConstant };
+          Value* indexes[2] = { intrinsics->constantZero, 
+                                intrinsics->OffsetVTInClassConstant };
           Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 2,
                                                    "", CI);
           Value* VT = new LoadInst(VTPtr, "", CI);
           CI->replaceAllUsesWith(VT);
           CI->eraseFromParent();
-        } else if (V == module->GetVTFromClassArrayFunction) {
+        } else if (V == intrinsics->GetVTFromClassArrayFunction) {
           Changed = true;
           
           Value* val = Call.getArgument(0);
-          Value* indexes[3] = { module->constantZero,
-                                module->constantZero,
-                                module->OffsetVTInClassConstant };
+          Value* indexes[3] = { intrinsics->constantZero,
+                                intrinsics->constantZero,
+                                intrinsics->OffsetVTInClassConstant };
           Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 3,
                                                    "", CI);
           Value* VT = new LoadInst(VTPtr, "", CI);
           CI->replaceAllUsesWith(VT);
           CI->eraseFromParent();
-        } else if (V == module->GetBaseClassVTFromVTFunction) {
+        } else if (V == intrinsics->GetBaseClassVTFromVTFunction) {
           Changed = true;
           
           Value* val = Call.getArgument(0);
-          Value* indexes[2] = { module->constantZero,
-                                module->OffsetBaseClassVTInVTConstant };
+          Value* indexes[2] = { intrinsics->constantZero,
+                                intrinsics->OffsetBaseClassVTInVTConstant };
           Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 2,
                                                    "", CI);
           Value* VT = new LoadInst(VTPtr, "", CI);
-          VT = new BitCastInst(VT, module->VTType, "", CI);
+          VT = new BitCastInst(VT, intrinsics->VTType, "", CI);
           CI->replaceAllUsesWith(VT);
           CI->eraseFromParent();
-        } else if (V == module->GetObjectSizeFromClassFunction) {
+        } else if (V == intrinsics->GetObjectSizeFromClassFunction) {
           Changed = true;
           
           Value* val = Call.getArgument(0); 
-          Value* indexes[2] = { module->constantZero, 
-                                module->OffsetObjectSizeInClassConstant };
+          Value* indexes[2] = { intrinsics->constantZero, 
+                                intrinsics->OffsetObjectSizeInClassConstant };
           Value* SizePtr = GetElementPtrInst::Create(val, indexes, indexes + 2,
                                                      "", CI);
           Value* Size = new LoadInst(SizePtr, "", CI);
           CI->replaceAllUsesWith(Size);
           CI->eraseFromParent();
-        } else if (V == module->GetDepthFunction) {
+        } else if (V == intrinsics->GetDepthFunction) {
           Changed = true;
           Value* val = Call.getArgument(0); 
-          Value* indexes[2] = { module->constantZero,
-                                module->OffsetDepthInVTConstant };
+          Value* indexes[2] = { intrinsics->constantZero,
+                                intrinsics->OffsetDepthInVTConstant };
           Value* DepthPtr = GetElementPtrInst::Create(val, indexes,
                                                       indexes + 2, "", CI);
           Value* Depth = new LoadInst(DepthPtr, "", CI);
           Depth = new PtrToIntInst(Depth, Type::getInt32Ty(*Context), "", CI);
           CI->replaceAllUsesWith(Depth);
           CI->eraseFromParent();
-        } else if (V == module->GetDisplayFunction) {
+        } else if (V == intrinsics->GetDisplayFunction) {
           Changed = true;
           Value* val = Call.getArgument(0);
-          Value* indexes[2] = { module->constantZero,
-                                module->OffsetDisplayInVTConstant };
+          Value* indexes[2] = { intrinsics->constantZero,
+                                intrinsics->OffsetDisplayInVTConstant };
           Value* DisplayPtr = GetElementPtrInst::Create(val, indexes,
                                                         indexes + 2, "", CI);
-          const llvm::Type* Ty = PointerType::getUnqual(module->VTType);
+          const llvm::Type* Ty = PointerType::getUnqual(intrinsics->VTType);
           DisplayPtr = new BitCastInst(DisplayPtr, Ty, "", CI);
           CI->replaceAllUsesWith(DisplayPtr);
           CI->eraseFromParent();
-        } else if (V == module->GetVTInDisplayFunction) {
+        } else if (V == intrinsics->GetVTInDisplayFunction) {
           Changed = true;
           Value* val = Call.getArgument(0);
           Value* depth = Call.getArgument(1);
@@ -342,32 +342,32 @@
           CI->replaceAllUsesWith(Class);
           CI->eraseFromParent();
 #if defined(ISOLATE)
-        } else if (V == module->GetStaticInstanceFunction) {
+        } else if (V == intrinsics->GetStaticInstanceFunction) {
           Changed = true;
 
-          Value* TCM = getTCM(module, Call.getArgument(0), CI);
-          Constant* C = module->OffsetStaticInstanceInTaskClassMirrorConstant;
-          Value* GEP[2] = { module->constantZero, C };
+          Value* TCM = getTCM(intrinsics, Call.getArgument(0), CI);
+          Constant* C = intrinsics->OffsetStaticInstanceInTaskClassMirrorConstant;
+          Value* GEP[2] = { intrinsics->constantZero, C };
           Value* Replace = GetElementPtrInst::Create(TCM, GEP, GEP + 2, "", CI);
           Replace = new LoadInst(Replace, "", CI);
           CI->replaceAllUsesWith(Replace);
           CI->eraseFromParent();
 #endif
-        } else if (V == module->GetClassDelegateeFunction) {
+        } else if (V == intrinsics->GetClassDelegateeFunction) {
           Changed = true;
           BasicBlock* NBB = II->getParent()->splitBasicBlock(II);
           I->getParent()->getTerminator()->eraseFromParent();
-          Value* Del = getDelegatee(module, Call.getArgument(0), CI);
+          Value* Del = getDelegatee(intrinsics, Call.getArgument(0), CI);
           Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, Del, 
-                                    module->JavaObjectNullConstant, "");
+                                    intrinsics->JavaObjectNullConstant, "");
           
           BasicBlock* NoDelegatee = BasicBlock::Create(*Context, "No delegatee", &F);
           BasicBlock* DelegateeOK = BasicBlock::Create(*Context, "Delegatee OK", &F);
           BranchInst::Create(NoDelegatee, DelegateeOK, cmp, CI);
-          PHINode* phi = PHINode::Create(module->JavaObjectType, "", DelegateeOK);
+          PHINode* phi = PHINode::Create(intrinsics->JavaObjectType, "", DelegateeOK);
           phi->addIncoming(Del, CI->getParent());
           
-          Value* Res = CallInst::Create(module->RuntimeDelegateeFunction,
+          Value* Res = CallInst::Create(intrinsics->RuntimeDelegateeFunction,
                                         Call.getArgument(0), "", NoDelegatee);
           BranchInst::Create(DelegateeOK, NoDelegatee);
           phi->addIncoming(Res, NoDelegatee);
@@ -377,7 +377,7 @@
           BranchInst::Create(NBB, DelegateeOK);
           break;
          
-        } else if (V == module->InitialisationCheckFunction) {
+        } else if (V == intrinsics->InitialisationCheckFunction) {
           Changed = true;
           
           BasicBlock* NBB = 0;
@@ -391,10 +391,10 @@
           }
          
           Value* Cl = Call.getArgument(0); 
-          Value* TCM = getTCM(module, Call.getArgument(0), CI);
+          Value* TCM = getTCM(intrinsics, Call.getArgument(0), CI);
           Value* GEP[2] = 
-            { module->constantZero,
-              module->OffsetInitializedInTaskClassMirrorConstant };
+            { intrinsics->constantZero,
+              intrinsics->OffsetInitializedInTaskClassMirrorConstant };
           Value* StatusPtr = GetElementPtrInst::Create(TCM, GEP, GEP + 2, "",
                                                        CI);
           
@@ -402,7 +402,7 @@
           
           BasicBlock* trueCl = BasicBlock::Create(*Context, "Initialized", &F);
           BasicBlock* falseCl = BasicBlock::Create(*Context, "Uninitialized", &F);
-          PHINode* node = llvm::PHINode::Create(JnjvmModule::JavaClassType, "", trueCl);
+          PHINode* node = llvm::PHINode::Create(J3Intrinsics::JavaClassType, "", trueCl);
           node->addIncoming(Cl, CI->getParent());
           BranchInst::Create(trueCl, falseCl, test, CI);
   
@@ -412,7 +412,7 @@
             Value* Args[1] = { Cl };
             BasicBlock* UI = Invoke->getUnwindDest();
 
-            res = InvokeInst::Create(module->InitialiseClassFunction,
+            res = InvokeInst::Create(intrinsics->InitialiseClassFunction,
                                      trueCl, UI, Args, Args + 1,
                                      "", falseCl);
 
@@ -437,7 +437,7 @@
             }
 
           } else {
-            res = CallInst::Create(module->InitialiseClassFunction,
+            res = CallInst::Create(intrinsics->InitialiseClassFunction,
                                    Cl, "", falseCl);
             BranchInst::Create(trueCl, falseCl);
           }
@@ -449,7 +449,7 @@
           CI->eraseFromParent();
           BranchInst::Create(NBB, trueCl);
           break;
-        } else if (V == module->GetConstantPoolAtFunction) {
+        } else if (V == intrinsics->GetConstantPoolAtFunction) {
           Function* resolver = dyn_cast<Function>(Call.getArgument(0));
           assert(resolver && "Wrong use of GetConstantPoolAt");
           const Type* returnType = resolver->getReturnType();
@@ -477,7 +477,7 @@
           Value* arg1 = GetElementPtrInst::Create(CTP, indexes, "", CI);
           arg1 = new LoadInst(arg1, "", false, CI);
           Value* test = new ICmpInst(CI, ICmpInst::ICMP_EQ, arg1,
-                                     module->constantPtrNull, "");
+                                     intrinsics->constantPtrNull, "");
  
           BasicBlock* trueCl = BasicBlock::Create(*Context, "Ctp OK", &F);
           BasicBlock* falseCl = BasicBlock::Create(*Context, "Ctp Not OK", &F);
@@ -530,18 +530,18 @@
           CI->eraseFromParent();
           BranchInst::Create(NBB, trueCl);
           break;
-        } else if (V == module->GetArrayClassFunction) {
+        } else if (V == intrinsics->GetArrayClassFunction) {
           const llvm::Type* Ty = 
-            PointerType::getUnqual(module->JavaCommonClassType);
+            PointerType::getUnqual(intrinsics->JavaCommonClassType);
           Constant* nullValue = Constant::getNullValue(Ty);
           // Check if we have already proceed this call.
           if (Call.getArgument(1) == nullValue) { 
             BasicBlock* NBB = II->getParent()->splitBasicBlock(II);
             I->getParent()->getTerminator()->eraseFromParent();
 
-            Constant* init = Constant::getNullValue(module->JavaClassArrayType);
+            Constant* init = Constant::getNullValue(intrinsics->JavaClassArrayType);
             GlobalVariable* GV = 
-              new GlobalVariable(*(F.getParent()), module->JavaClassArrayType,
+              new GlobalVariable(*(F.getParent()), intrinsics->JavaClassArrayType,
                                  false, GlobalValue::ExternalLinkage,
                                  init, "");
 
@@ -551,14 +551,14 @@
 
             BasicBlock* OKBlock = BasicBlock::Create(*Context, "", &F);
             BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "", &F);
-            PHINode* node = PHINode::Create(module->JavaClassArrayType, "",
+            PHINode* node = PHINode::Create(intrinsics->JavaClassArrayType, "",
                                             OKBlock);
             node->addIncoming(LoadedGV, CI->getParent());
 
             BranchInst::Create(NotOKBlock, OKBlock, cmp, CI);
 
             Value* args[2] = { Call.getArgument(0), GV };
-            Value* res = CallInst::Create(module->GetArrayClassFunction, args,
+            Value* res = CallInst::Create(intrinsics->GetArrayClassFunction, args,
                                           args + 2, "", NotOKBlock);
             BranchInst::Create(OKBlock, NotOKBlock);
             node->addIncoming(res, NotOKBlock);
@@ -568,23 +568,23 @@
             BranchInst::Create(NBB, OKBlock);
             break;
           }
-        } else if (V == module->ForceInitialisationCheckFunction ||
-                   V == module->ForceLoadedCheckFunction ) {
+        } else if (V == intrinsics->ForceInitialisationCheckFunction ||
+                   V == intrinsics->ForceLoadedCheckFunction ) {
           Changed = true;
           CI->eraseFromParent();
-        } else if (V == module->GetFinalInt8FieldFunction ||
-                   V == module->GetFinalInt16FieldFunction ||
-                   V == module->GetFinalInt32FieldFunction ||
-                   V == module->GetFinalLongFieldFunction ||
-                   V == module->GetFinalFloatFieldFunction ||
-                   V == module->GetFinalDoubleFieldFunction ||
-                   V == module->GetFinalObjectFieldFunction) {
+        } else if (V == intrinsics->GetFinalInt8FieldFunction ||
+                   V == intrinsics->GetFinalInt16FieldFunction ||
+                   V == intrinsics->GetFinalInt32FieldFunction ||
+                   V == intrinsics->GetFinalLongFieldFunction ||
+                   V == intrinsics->GetFinalFloatFieldFunction ||
+                   V == intrinsics->GetFinalDoubleFieldFunction ||
+                   V == intrinsics->GetFinalObjectFieldFunction) {
           Changed = true;
           Value* val = Call.getArgument(0);
           Value* res = new LoadInst(val, "", CI);
           CI->replaceAllUsesWith(res);
           CI->eraseFromParent();
-        } else if (V == module->IsAssignableFromFunction) {
+        } else if (V == intrinsics->IsAssignableFromFunction) {
           Changed = true;
           Value* VT1 = Call.getArgument(0);
           Value* VT2 = Call.getArgument(1);
@@ -598,7 +598,7 @@
 
           ConstantInt* CC = ConstantInt::get(Type::getInt32Ty(*Context),
               JavaVirtualTable::getOffsetIndex());
-          Value* indices[2] = { module->constantZero, CC };
+          Value* indices[2] = { intrinsics->constantZero, CC };
           Value* Offset = GetElementPtrInst::Create(VT2, indices, indices + 2,
                                                     "", CI);
           Offset = new LoadInst(Offset, "", false, CI);
@@ -607,7 +607,7 @@
           Value* CurVT = GetElementPtrInst::Create(VT1, indices, indices + 2,
                                                    "", CI);
           CurVT = new LoadInst(CurVT, "", false, CI);
-          CurVT = new BitCastInst(CurVT, module->VTType, "", CI);
+          CurVT = new BitCastInst(CurVT, intrinsics->VTType, "", CI);
              
           Value* res = new ICmpInst(CI, ICmpInst::ICMP_EQ, CurVT, VT2, "");
 
@@ -615,7 +615,7 @@
           BranchInst::Create(CurEndBlock, FailedBlock, res, CI);
 
           Value* Args[2] = { VT1, VT2 };
-          res = CallInst::Create(module->IsSecondaryClassFunction, Args,
+          res = CallInst::Create(intrinsics->IsSecondaryClassFunction, Args,
                                  Args + 2, "", FailedBlock);
          
           node->addIncoming(res, FailedBlock);
@@ -631,7 +631,7 @@
           // Reanalyse the current block.
           break;
 
-        } else if (V == module->IsSecondaryClassFunction) {
+        } else if (V == intrinsics->IsSecondaryClassFunction) {
           Changed = true;
           Value* VT1 = Call.getArgument(0);
           Value* VT2 = Call.getArgument(1);
@@ -646,7 +646,7 @@
           BasicBlock* BB6 = BasicBlock::Create(*Context, "BB6", &F);
           BasicBlock* BB7 = BasicBlock::Create(*Context, "BB7", &F);
           BasicBlock* BB9 = BasicBlock::Create(*Context, "BB9", &F);
-          const Type* Ty = PointerType::getUnqual(module->VTType);
+          const Type* Ty = PointerType::getUnqual(intrinsics->VTType);
           
           PHINode* resFwd = PHINode::Create(Type::getInt32Ty(*Context), "", BB7);
    
@@ -655,7 +655,7 @@
           //    else goto headerLoop;
           ConstantInt* cacheIndex = 
             ConstantInt::get(Type::getInt32Ty(*Context), JavaVirtualTable::getCacheIndex());
-          Value* indices[2] = { module->constantZero, cacheIndex };
+          Value* indices[2] = { intrinsics->constantZero, cacheIndex };
           Instruction* CachePtr = 
             GetElementPtrInst::Create(VT1, indices, indices + 2, "", CI);
           CachePtr = new BitCastInst(CachePtr, Ty, "", CI);
@@ -706,7 +706,7 @@
           //    ++i;
           //    goto endLoopTest;
           BinaryOperator* IndVar = 
-            BinaryOperator::CreateAdd(resFwd, module->constantOne, "", BB6);
+            BinaryOperator::CreateAdd(resFwd, intrinsics->constantOne, "", BB6);
           BranchInst::Create(BB7, BB6);
     
           // Verify that we haven't reached the end of the loop:
@@ -714,7 +714,7 @@
           //    if (i < size) goto test
           //    else goto end with false
           resFwd->reserveOperandSpace(2);
-          resFwd->addIncoming(module->constantZero, Preheader);
+          resFwd->addIncoming(intrinsics->constantZero, Preheader);
           resFwd->addIncoming(IndVar, BB6);
     
           cmp1 = new ICmpInst(*BB7, ICmpInst::ICMP_SGT, Size, resFwd, "");
@@ -745,31 +745,31 @@
           break;
         }
 #ifdef ISOLATE_SHARING
-        else if (V == module->GetCtpClassFunction) {
+        else if (V == intrinsics->GetCtpClassFunction) {
           Changed = true;
           Value* val = Call.getArgument(0); 
-          Value* indexes[2] = { module->constantZero, 
-                                module->OffsetCtpInClassConstant };
+          Value* indexes[2] = { intrinsics->constantZero, 
+                                intrinsics->OffsetCtpInClassConstant };
           Value* VTPtr = GetElementPtrInst::Create(val, indexes,
                                                    indexes + 2, "", CI);
           Value* VT = new LoadInst(VTPtr, "", CI);
           CI->replaceAllUsesWith(VT);
           CI->eraseFromParent();
-        } else if (V == module->GetJnjvmArrayClassFunction) {
+        } else if (V == intrinsics->GetJnjvmArrayClassFunction) {
           Changed = true;
           Value* val = Call.getArgument(0); 
           Value* index = Call.getArgument(1); 
-          Value* indexes[3] = { module->constantZero, module->constantTwo,
+          Value* indexes[3] = { intrinsics->constantZero, intrinsics->constantTwo,
                                 index };
           Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 3,
                                                    "", CI);
           Value* VT = new LoadInst(VTPtr, "", CI);
           CI->replaceAllUsesWith(VT);
           CI->eraseFromParent();
-        } else if (V == module->GetJnjvmExceptionClassFunction) {
+        } else if (V == intrinsics->GetJnjvmExceptionClassFunction) {
           Changed = true;
           Value* val = Call.getArgument(0);
-          Value* indexes[2] = { module->constantZero, module->constantOne };
+          Value* indexes[2] = { intrinsics->constantZero, intrinsics->constantOne };
           Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 2,
                                                    "", CI);
           Value* VT = new LoadInst(VTPtr, "", CI);
@@ -785,7 +785,7 @@
 }
 
 
-FunctionPass* createLowerConstantCallsPass(JnjvmModule* M) {
+FunctionPass* createLowerConstantCallsPass(J3Intrinsics* M) {
   return new LowerConstantCalls(M);
 }
 

Modified: vmkit/trunk/tools/vmjc/vmjc.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/tools/vmjc/vmjc.cpp (original)
+++ vmkit/trunk/tools/vmjc/vmjc.cpp Sun Feb 14 16:07:42 2010
@@ -43,7 +43,6 @@
 #include "mvm/Threads/Thread.h"
 
 #include "j3/JavaAOTCompiler.h"
-#include "j3/JnjvmModule.h"
 
 #include "../../lib/J3/VMCore/JnjvmClassLoader.h"
 #include "../../lib/J3/VMCore/Jnjvm.h"

Modified: vmkit/trunk/tools/vmkit/Launcher.cpp
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=96194&r1=96193&r2=96194&view=diff

==============================================================================
--- vmkit/trunk/tools/vmkit/Launcher.cpp (original)
+++ vmkit/trunk/tools/vmkit/Launcher.cpp Sun Feb 14 16:07:42 2010
@@ -26,7 +26,6 @@
 #include "mvm/Threads/Thread.h"
 
 #include "j3/JavaJITCompiler.h"
-#include "j3/JnjvmModule.h"
 
 #include "CommandLine.h"
 





More information about the vmkit-commits mailing list