[llvm-commits] [vmkit] r50058 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.h JavaJIT.cpp JavaJIT.h JavaJITInitialise.cpp JavaRuntimeJIT.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Mon Apr 21 14:24:53 PDT 2008


Author: geoffray
Date: Mon Apr 21 16:24:53 2008
New Revision: 50058

URL: http://llvm.org/viewvc/llvm-project?rev=50058&view=rev
Log:
Place initialization barriers in a multi-vm environment.

Modified:
    vmkit/trunk/lib/JnJVM/VMCore/JavaClass.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/JavaRuntimeJIT.cpp

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Mon Apr 21 16:24:53 2008
@@ -157,7 +157,9 @@
   bool isReady();
   void setReady();
 #endif
-
+  bool isResolved() {
+    return status >= resolved;
+  }
 };
 
 class Class : public CommonClass {

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Mon Apr 21 16:24:53 2008
@@ -794,7 +794,7 @@
         }
 #endif
         
-        // TODO: put an initializer in here
+        // TODO: put an initialiser in here
         void* ptr = mvm::jit::executionEngine->getPointerToGlobal(gv);
         GenericValue Val = GenericValue(val);
         llvm::GenericValue * Ptr = (llvm::GenericValue*)ptr;
@@ -1351,6 +1351,9 @@
 
     llvm::BranchInst::Create(trueCl, currentBlock);
     currentBlock = trueCl;
+#ifdef MULTIPLE_VM
+    invoke(initialisationCheckLLVM, node, "", currentBlock);
+#endif
     
     return node;
 }
@@ -1369,7 +1372,11 @@
   }
 #endif
   Value* val = 0;
-  if (!cl || !cl->isReady()) {
+  if (!cl || !(cl->isResolved())
+#ifndef MULTIPLE_VM
+      || !cl->isReady()
+#endif
+     ) {
     Value* node = getResolvedClass(index, true);
 #ifndef MULTIPLE_VM
     val = invoke(doNewUnknownLLVM, node, "", currentBlock);
@@ -1380,6 +1387,11 @@
     Value* load = new LoadInst(cl->llvmVar(compilingClass->isolate->module),
                                "", currentBlock);
 #ifdef MULTIPLE_VM
+    if (cl->isolate == Jnjvm::bootstrapVM) {
+      Module* M = compilingClass->isolate->module;
+      Value* arg = new LoadInst(cl->llvmVar(M), "", currentBlock);
+      invoke(initialisationCheckLLVM, arg, "", currentBlock);
+    }
     val = invoke(doNewLLVM, load, isolateLocal, "", currentBlock);
 #else
     val = invoke(doNewLLVM, load, "", currentBlock);
@@ -1425,12 +1437,21 @@
   JavaCtpInfo* info = compilingClass->ctpInfo;
   
   JavaField* field = info->lookupField(index, stat);
-  if (field && field->classDef->isReady()) {
+  if (field && field->classDef->isResolved()
+#ifndef MULTIPLE_VM
+      && field->classDef->isReady()
+#endif
+     ) {
     Module* M = compilingClass->isolate->module;
     if (stat) object = field->classDef->staticVar(M, currentBlock);
     const Type* type = stat ? field->classDef->staticType :
                               field->classDef->virtualType;
-
+#ifdef MULTIPLE_VM
+    if (stat && field->classDef->isolate == Jnjvm::bootstrapVM) {
+      Value* arg = new LoadInst(field->classDef->llvmVar(M), "", currentBlock);
+      invoke(initialisationCheckLLVM, arg, "", currentBlock); 
+    }
+#endif
     return fieldGetter(this, type, object, field->offset);
   } else {
     const Type* Pty = mvm::jit::arrayPtrType;
@@ -1486,7 +1507,8 @@
     Module* M = compilingClass->isolate->module;
     args.push_back(new LoadInst(compilingClass->llvmVar(M), "", currentBlock));
     mvm::jit::protectConstants();//->lock();
-    args.push_back(ConstantInt::get(Type::Int32Ty, index));
+    Constant* CI = ConstantInt::get(Type::Int32Ty, index);
+    args.push_back(CI);
     mvm::jit::unprotectConstants();//->unlock();
     args.push_back(stat ? mvm::jit::constantOne : mvm::jit::constantZero);
     args.push_back(gvStaticInstance);
@@ -1496,6 +1518,15 @@
     llvm::BranchInst::Create(endBlock, currentBlock);
     
     currentBlock = endBlock;;
+#ifdef MULTIPLE_VM
+    if (stat) {
+      std::vector<Value*> args;
+      Value* val = new LoadInst(compilingClass->llvmVar(M), "", currentBlock);
+      args.push_back(val);
+      args.push_back(CI);
+      invoke(initialisationCheckCtpLLVM, args, "", currentBlock); 
+    }
+#endif
     return new BitCastInst(node, fieldTypePtr, "", currentBlock);
   }
 }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Mon Apr 21 16:24:53 2008
@@ -248,7 +248,11 @@
   static llvm::Function* jniProceedPendingExceptionLLVM;
   static llvm::Function* doNewLLVM;
   // this is when the type is not known at compile time (escape analysis)
-  static llvm::Function* doNewUnknownLLVM; 
+  static llvm::Function* doNewUnknownLLVM;
+#ifdef MULTIPLE_VM
+  static llvm::Function* initialisationCheckLLVM;
+  static llvm::Function* initialisationCheckCtpLLVM;
+#endif
   static llvm::Function* initialiseObjectLLVM;
   static llvm::Function* newLookupLLVM;
   static llvm::Function* instanceOfLLVM;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITInitialise.cpp Mon Apr 21 16:24:53 2008
@@ -222,6 +222,33 @@
                      "_ZN5jnjvm9JavaArray12multiCallNewEPNS_10ClassArrayEjz",
                      module);
   }
+
+#ifdef MULTIPLE_VM
+  // Create initialisationCheckLLVM
+  {
+  std::vector<const Type*> args;
+  args.push_back(mvm::jit::ptrType);
+  const FunctionType* type = FunctionType::get(Type::VoidTy, args,
+                                               false);
+
+  initialisationCheckLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
+                     "initialisationCheck",
+                     module);
+  }
+  
+  // Create initialisationCheckCtpLLVM
+  {
+  std::vector<const Type*> args;
+  args.push_back(mvm::jit::ptrType);
+  args.push_back(Type::Int32Ty);
+  const FunctionType* type = FunctionType::get(Type::VoidTy, args,
+                                               false);
+
+  initialisationCheckCtpLLVM = Function::Create(type, GlobalValue::ExternalLinkage,
+                     "initialisationCheckCtp",
+                     module);
+  }
+#endif
   
   
   

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Mon Apr 21 16:24:53 2008
@@ -55,6 +55,10 @@
 llvm::Function* JavaJIT::jniProceedPendingExceptionLLVM = 0;
 llvm::Function* JavaJIT::doNewLLVM = 0;
 llvm::Function* JavaJIT::doNewUnknownLLVM = 0;
+#ifdef MULTIPLE_VM
+llvm::Function* JavaJIT::initialisationCheckLLVM = 0;
+llvm::Function* JavaJIT::initialisationCheckCtpLLVM = 0;
+#endif
 llvm::Function* JavaJIT::initialiseObjectLLVM = 0;
 llvm::Function* JavaJIT::newLookupLLVM = 0;
 llvm::Function* JavaJIT::instanceOfLLVM = 0;
@@ -237,3 +241,16 @@
   *toAlloc = cl;
   return cl;
 }
+
+#ifdef MULTIPLE_VM
+extern "C" void initialisationCheck(CommonClass* cl) {
+  cl->isolate->initialiseClass(cl);
+}
+
+extern "C" void initialisationCheckCtp(Class* caller, uint16 index) {
+  JavaCtpInfo* ctpInfo = caller->ctpInfo;
+  JavaField* field = (JavaField*)(ctpInfo->ctpRes[index]);
+  assert(field && "checking without resolving?");  
+  field->classDef->isolate->initialiseClass(field->classDef);
+}
+#endif





More information about the llvm-commits mailing list