[vmkit-commits] [vmkit] r58214 - in /vmkit/trunk/lib/JnJVM/VMCore: JnjvmModule.cpp JnjvmModule.h

Nicolas Geoffray nicolas.geoffray at lip6.fr
Sun Oct 26 16:11:15 PDT 2008


Author: geoffray
Date: Sun Oct 26 18:11:15 2008
New Revision: 58214

URL: http://llvm.org/viewvc/llvm-project?rev=58214&view=rev
Log:
Add a "staticCompilation" field to a JnjvmModule.


Modified:
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Sun Oct 26 18:11:15 2008
@@ -75,7 +75,7 @@
                                                  uint64_t (classDef)),
                                 JnjvmModule::JavaClassType);
       
-    varGV = new GlobalVariable(JnjvmModule::JavaClassType, true,
+    varGV = new GlobalVariable(JnjvmModule::JavaClassType, !staticCompilation,
                                GlobalValue::ExternalLinkage,
                                cons, "", this);
 
@@ -95,7 +95,7 @@
     Constant* cons = 
       ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(ptr)),
                                 mvm::MvmModule::ptrPtrType);
-    varGV = new GlobalVariable(mvm::MvmModule::ptrPtrType, true,
+    varGV = new GlobalVariable(mvm::MvmModule::ptrPtrType, !staticCompilation,
                                GlobalValue::ExternalLinkage,
                                cons, "", this);
     constantPools.insert(std::make_pair(ctp, varGV));
@@ -115,7 +115,7 @@
     Constant* cons = 
       ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(ptr)),
                                 JnjvmModule::JavaObjectType);
-    varGV = new GlobalVariable(JnjvmModule::JavaObjectType, true,
+    varGV = new GlobalVariable(JnjvmModule::JavaObjectType, !staticCompilation,
                                GlobalValue::ExternalLinkage,
                                cons, "", this);
     strings.insert(std::make_pair(str, varGV));
@@ -133,7 +133,7 @@
     Constant* cons = 
       ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(ptr)),
                                 JnjvmModule::EnveloppeType);
-    varGV = new GlobalVariable(JnjvmModule::EnveloppeType, true,
+    varGV = new GlobalVariable(JnjvmModule::EnveloppeType, !staticCompilation,
                                GlobalValue::ExternalLinkage,
                                cons, "", this);
     enveloppes.insert(std::make_pair(enveloppe, varGV));
@@ -151,7 +151,7 @@
     Constant* cons = 
       ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64(obj)),
                                 JnjvmModule::JavaObjectType);
-    varGV = new GlobalVariable(JnjvmModule::JavaObjectType, true,
+    varGV = new GlobalVariable(JnjvmModule::JavaObjectType, !staticCompilation,
                                GlobalValue::ExternalLinkage,
                                cons, "", this);
 
@@ -174,7 +174,7 @@
       ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
                                 uint64_t (obj)), JnjvmModule::JavaObjectType);
       
-    varGV = new GlobalVariable(JnjvmModule::JavaObjectType, true,
+    varGV = new GlobalVariable(JnjvmModule::JavaObjectType, !staticCompilation,
                                GlobalValue::ExternalLinkage,
                                cons, "", this);
 
@@ -199,7 +199,7 @@
       ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty,
                                                  uint64_t(classDef->virtualVT)),
                                 JnjvmModule::VTType);
-    varGV = new GlobalVariable(JnjvmModule::VTType, true,
+    varGV = new GlobalVariable(JnjvmModule::VTType, !staticCompilation,
                                GlobalValue::ExternalLinkage,
                                cons, "", this);
     
@@ -243,7 +243,11 @@
       } else {
         ExecutionEngine* EE = mvm::MvmModule::executionEngine;
         // LLVM does not allow recursive compilation. Create the code now.
-        ((void**)VT)[0] = EE->getPointerToFunction(func);
+        if (staticCompilation) {
+          ((void**)VT)[0] = func;
+        } else {
+          ((void**)VT)[0] = EE->getPointerToFunction(func);
+        }
       }
 #endif
     } else {
@@ -265,7 +269,11 @@
       LLVMMethodInfo* LMI = getMethodInfo(&meth);
       Function* func = LMI->getMethod();
       ExecutionEngine* EE = mvm::MvmModule::executionEngine;
-      ((void**)VT)[offset] = EE->getPointerToFunctionOrStub(func);
+      if (staticCompilation) {
+        ((void**)VT)[offset] = func;
+      } else {
+        ((void**)VT)[offset] = EE->getPointerToFunctionOrStub(func);
+      }
     }
 
     return VT;
@@ -389,11 +397,15 @@
   
 #ifdef WITH_TRACER
   llvm::Function* func = makeTracer(cl, stat);
-
-  void* codePtr = mvm::MvmModule::executionEngine->getPointerToGlobal(func);
-  ((void**)res)[VT_TRACER_OFFSET] = codePtr;
   
-  func->deleteBody();
+  if (staticCompilation) {
+    ((void**)res)[VT_TRACER_OFFSET] = func;
+  } else {
+    void* codePtr = mvm::MvmModule::executionEngine->getPointerToFunction(func);
+    ((void**)res)[VT_TRACER_OFFSET] = codePtr;
+    func->deleteBody();
+  }
+  
 
 #endif
   return res;
@@ -955,11 +967,14 @@
   return getMethodInfo(meth)->getMethod();
 }
 
-JnjvmModule::JnjvmModule(const std::string &ModuleID) : MvmModule(ModuleID) {
+JnjvmModule::JnjvmModule(const std::string &ModuleID, bool sc) : 
+  MvmModule(ModuleID) {
+  
   std::string str = 
     mvm::MvmModule::executionEngine->getTargetData()->getStringRepresentation();
   setDataLayout(str);
-  
+  staticCompilation = sc;
+
   Module* module = initialModule;
    
   InterfaceLookupFunction = module->getFunction("jnjvmVirtualLookup");

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Sun Oct 26 18:11:15 2008
@@ -208,13 +208,14 @@
     enveloppe_iterator;
   
   
+  bool staticCompilation;
 
   
   llvm::Function* makeTracer(Class* cl, bool stat);
   VirtualTable* makeVT(Class* cl, bool stat);
   VirtualTable* allocateVT(Class* cl, uint32 index);
 
-
+  
 public:
   
   static llvm::ConstantInt* JavaArraySizeOffsetConstant;
@@ -361,7 +362,7 @@
 
   static LLVMAssessorInfo& getTypedefInfo(Typedef* type);
   
-  explicit JnjvmModule(const std::string &ModuleID);
+  explicit JnjvmModule(const std::string &ModuleID, bool sc = false);
   static void initialise();
 
   llvm::Value* getNativeClass(CommonClass* cl);





More information about the vmkit-commits mailing list