[llvm-commits] [vmkit] r50811 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaConstantPool.cpp JavaConstantPool.h JavaJIT.cpp JavaJIT.h JavaJITInitialise.cpp JavaMetaJIT.cpp JavaRuntimeJIT.cpp LowerConstantCalls.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed May 7 06:14:29 PDT 2008


Author: geoffray
Date: Wed May  7 08:14:14 2008
New Revision: 50811

URL: http://llvm.org/viewvc/llvm-project?rev=50811&view=rev
Log:
initialisationCheckLLVM now returns the class to make sure
it is executed. The forceInitialisationCheckLLVM function prevents
LLVM from removing it when the return val is not used.


Modified:
    vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Wed May  7 08:14:14 2008
@@ -375,6 +375,12 @@
   } 
 }
 
+uint32 JavaCtpInfo::getClassIndexFromMethod(uint32 index) {
+  sint32 entry = ctpDef[index];
+  return (uint32)(entry >> 16);
+}
+
+
 void JavaCtpInfo::nameOfStaticOrSpecialMethod(uint32 index, 
                                               const UTF8*& cl,
                                               const UTF8*& name,

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.h Wed May  7 08:14:14 2008
@@ -115,6 +115,8 @@
 
   void nameOfStaticOrSpecialMethod(uint32 index, const UTF8*& cl, 
                                    const UTF8*& name, Signdef*& sign);
+  
+  uint32 getClassIndexFromMethod(uint32 index);
 
   CommonClass* getMethodClassIfLoaded(uint32 index);
   void resolveInterfaceOrMethod(uint32 index, CommonClass*& cl,
@@ -123,7 +125,7 @@
                     JavaMethod*& meth); 
   void resolveField(uint32 index, CommonClass*& cl, const UTF8*& utf8,
                     Typedef*& sign);
-
+  
   JavaString* resolveString(const UTF8* utf8, uint16 index);
   
   JavaField* lookupField(uint32 index, bool stat);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Wed May  7 08:14:14 2008
@@ -739,8 +739,8 @@
     }
     printf("\n");
     fflush(stdout);
-  }*/
-  
+  }
+  */
 
   PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "--> end compiling %s\n",
               compilingMethod->printString());
@@ -1493,6 +1493,18 @@
     Function* func = ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_STATIC,
                                                           signature, meth);
     
+#ifdef MULTIPLE_VM
+    
+    uint32 clIndex = ctpInfo->getClassIndexFromMethod(index);
+    Class* mycl = (Class*)(ctpInfo->getMethodClassIfLoaded(clIndex));
+    if (mycl && mycl->status >= resolved) {
+      Module* M = compilingClass->isolate->module;
+      Value* arg = new LoadInst(mycl->llvmVar(M), "", currentBlock);
+      arg = invoke(initialisationCheckLLVM, arg, "", currentBlock);
+      CallInst::Create(forceInitialisationCheckLLVM, arg, "", currentBlock);
+    }
+
+#endif
 #if 0//def SERVICE_VM
     bool serviceCall = false;
     if (meth && meth->classDef->classLoader != compilingClass->classLoader &&
@@ -1581,9 +1593,10 @@
     llvm::BranchInst::Create(trueCl, currentBlock);
     currentBlock = trueCl;
 #ifdef MULTIPLE_VM
-    invoke(initialisationCheckLLVM, node, "", currentBlock);
+    if (clinit)
+      return invoke(initialisationCheckLLVM, node, "", currentBlock);
+    else
 #endif
-    
     return node;
 }
 
@@ -1610,7 +1623,7 @@
 #ifdef MULTIPLE_VM
     Module* M = compilingClass->isolate->module;
     Value* arg = new LoadInst(cl->llvmVar(M), "", currentBlock);
-    invoke(initialisationCheckLLVM, arg, "", currentBlock);
+    load = invoke(initialisationCheckLLVM, arg, "", currentBlock);
     val = invoke(doNewLLVM, load, isolateLocal, "", currentBlock);
 #else
     val = invoke(doNewLLVM, load, "", currentBlock);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Wed May  7 08:14:14 2008
@@ -252,6 +252,7 @@
   static llvm::Function* doNewUnknownLLVM;
 #ifdef MULTIPLE_VM
   static llvm::Function* initialisationCheckLLVM;
+  static llvm::Function* forceInitialisationCheckLLVM;
 #endif
   static llvm::Function* initialiseObjectLLVM;
   static llvm::Function* newLookupLLVM;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Wed May  7 08:14:14 2008
@@ -226,12 +226,30 @@
   {
   std::vector<const Type*> args;
   args.push_back(mvm::jit::ptrType);
-  const FunctionType* type = FunctionType::get(Type::VoidTy, args,
+  const FunctionType* type = FunctionType::get(mvm::jit::ptrType, args,
                                                false);
 
   initialisationCheckLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "initialisationCheck",
                      module);
+  PAListPtr func_toto_PAL;
+  SmallVector<ParamAttrsWithIndex, 4> Attrs;
+  ParamAttrsWithIndex PAWI;
+  PAWI.Index = 0; PAWI.Attrs = 0  | ParamAttr::ReadNone;
+  Attrs.push_back(PAWI);
+  func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
+  initialisationCheckLLVM->setParamAttrs(func_toto_PAL);
+  } 
+  // Create forceInitialisationCheckLLVM
+  {
+  std::vector<const Type*> args;
+  args.push_back(mvm::jit::ptrType);
+  const FunctionType* type = FunctionType::get(Type::VoidTy, args,
+                                               false);
+
+  forceInitialisationCheckLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
+                     "forceInitialisationCheck",
+                     module);
   } 
 #endif
   
@@ -370,6 +388,13 @@
   newLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "newLookup",
                      module);
+  PAListPtr func_toto_PAL;
+  SmallVector<ParamAttrsWithIndex, 4> Attrs;
+  ParamAttrsWithIndex PAWI;
+  PAWI.Index = 0; PAWI.Attrs = 0  | ParamAttr::ReadNone;
+  Attrs.push_back(PAWI);
+  func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
+  newLookupLLVM->setParamAttrs(func_toto_PAL);
   }
  
 #ifndef WITHOUT_VTABLE
@@ -384,6 +409,13 @@
 
   vtableLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                                       "vtableLookup", module);
+  PAListPtr func_toto_PAL;
+  SmallVector<ParamAttrsWithIndex, 4> Attrs;
+  ParamAttrsWithIndex PAWI;
+  PAWI.Index = 0; PAWI.Attrs = 0  | ParamAttr::ReadNone;
+  Attrs.push_back(PAWI);
+  func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
+  vtableLookupLLVM->setParamAttrs(func_toto_PAL);
   }
 #endif
 
@@ -403,6 +435,13 @@
   fieldLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "fieldLookup",
                      module);
+  PAListPtr func_toto_PAL;
+  SmallVector<ParamAttrsWithIndex, 4> Attrs;
+  ParamAttrsWithIndex PAWI;
+  PAWI.Index = 0; PAWI.Attrs = 0  | ParamAttr::ReadNone;
+  Attrs.push_back(PAWI);
+  func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
+  fieldLookupLLVM->setParamAttrs(func_toto_PAL);
   }
   
   // Create nullPointerExceptionLLVM
@@ -550,6 +589,13 @@
   getStaticInstanceLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "getStaticInstance",
                      module);
+  PAListPtr func_toto_PAL;
+  SmallVector<ParamAttrsWithIndex, 4> Attrs;
+  ParamAttrsWithIndex PAWI;
+  PAWI.Index = 0; PAWI.Attrs = 0  | ParamAttr::ReadNone;
+  Attrs.push_back(PAWI);
+  func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
+  getStaticInstanceLLVM->setParamAttrs(func_toto_PAL);
   }
   
   // Create getClassDelegateeLLVM
@@ -561,6 +607,13 @@
   getClassDelegateeLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "getClassDelegatee",
                      module);
+  PAListPtr func_toto_PAL;
+  SmallVector<ParamAttrsWithIndex, 4> Attrs;
+  ParamAttrsWithIndex PAWI;
+  PAWI.Index = 0; PAWI.Attrs = 0  | ParamAttr::ReadNone;
+  Attrs.push_back(PAWI);
+  func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
+  getClassDelegateeLLVM->setParamAttrs(func_toto_PAL);
   }
   
   // Create instanceOfLLVM
@@ -573,6 +626,13 @@
   instanceOfLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
                      "_ZN5jnjvm10JavaObject10instanceOfEPNS_11CommonClassE",
                      module);
+  PAListPtr func_toto_PAL;
+  SmallVector<ParamAttrsWithIndex, 4> Attrs;
+  ParamAttrsWithIndex PAWI;
+  PAWI.Index = 0; PAWI.Attrs = 0  | ParamAttr::ReadNone;
+  Attrs.push_back(PAWI);
+  func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end());
+  instanceOfLLVM->setParamAttrs(func_toto_PAL);
   }
   
   // Create aquireObjectLLVM

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaMetaJIT.cpp Wed May  7 08:14:14 2008
@@ -60,7 +60,7 @@
 #else
   Value* var = llvmVar(jit->compilingClass->isolate->module);
   Value* ld = new LoadInst(var, "", jit->currentBlock);
-  jit->invoke(JavaJIT::initialisationCheckLLVM, ld, "", jit->currentBlock);
+  ld = jit->invoke(JavaJIT::initialisationCheckLLVM, ld, "", jit->currentBlock);
   return jit->invoke(JavaJIT::getStaticInstanceLLVM, ld, jit->isolateLocal, 
                      "", jit->currentBlock);
 #endif

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Wed May  7 08:14:14 2008
@@ -60,6 +60,7 @@
 llvm::Function* JavaJIT::doNewUnknownLLVM = 0;
 #ifdef MULTIPLE_VM
 llvm::Function* JavaJIT::initialisationCheckLLVM = 0;
+llvm::Function* JavaJIT::forceInitialisationCheckLLVM = 0;
 #endif
 llvm::Function* JavaJIT::initialiseObjectLLVM = 0;
 llvm::Function* JavaJIT::newLookupLLVM = 0;
@@ -228,8 +229,9 @@
   return val->second;
 }
 
-extern "C" void initialisationCheck(CommonClass* cl) {
+extern "C" CommonClass* initialisationCheck(CommonClass* cl) {
   cl->isolate->initialiseClass(cl);
+  return cl;
 }
 #endif
 

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Wed May  7 08:14:14 2008
@@ -79,6 +79,11 @@
           CI->replaceAllUsesWith(cl);
           CI->eraseFromParent();
         }
+#ifdef MULTIPLE_VM
+        else if (V == jnjvm::JavaJIT::forceInitialisationCheckLLVM) {
+          CI->eraseFromParent();
+        }
+#endif
       }
     }
   }





More information about the llvm-commits mailing list