[vmkit-commits] [vmkit] r60417 - in /vmkit/trunk/lib/JnJVM: LLVMRuntime/runtime-default.ll VMCore/JavaJIT.cpp VMCore/JavaRuntimeJIT.cpp VMCore/JnjvmModule.cpp VMCore/JnjvmModule.h VMCore/LowerConstantCalls.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Tue Dec 2 08:09:59 PST 2008


Author: geoffray
Date: Tue Dec  2 10:09:36 2008
New Revision: 60417

URL: http://llvm.org/viewvc/llvm-project?rev=60417&view=rev
Log:
Inline strings and java/lang/Class objects as much as possible.


Modified:
    vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h
    vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp

Modified: vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll
URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=60417&r1=60416&r2=60417&view=diff

==============================================================================
--- vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll (original)
+++ vmkit/trunk/lib/JnJVM/LLVMRuntime/runtime-default.ll Tue Dec  2 10:09:36 2008
@@ -150,9 +150,15 @@
 declare i1 @instantiationOfArray(%JavaCommonClass*, %JavaCommonClass*) readnone
 
 ;;; getClassDelegatee - Returns the java/lang/Class representation of the
-;;; class.
+;;; class. This method is lowered to the GEP to the class delegatee in
+;;; the common class.
 declare %JavaObject* @getClassDelegatee(%JavaCommonClass*) readnone 
 
+;;; jnjvmRuntimeDelegatee - Returns the java/lang/Class representation of the
+;;; class. This method is called if the class delegatee has not been created
+;;; yet.
+declare %JavaObject* @jnjvmRuntimeDelegatee(%JavaCommonClass*) readnone 
+
 ;;; getArrayClass - Get the array user class of the user class.
 declare %JavaCommonClass* @getArrayClass(%JavaCommonClass*, 
                                          %JavaCommonClass**) readnone

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Tue Dec  2 10:09:36 2008
@@ -1124,11 +1124,26 @@
   uint8 type = ctpInfo->typeAt(index);
   
   if (type == JavaConstantPool::ConstantString) {
-#if defined(ISOLATE) || defined(ISOLATE_SHARING)
+#if defined(ISOLATE) 
+    if (compilingClass->classLoader != 
+        compilingClass->classLoader->bootstrapLoader) {
+      const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]);
+      JavaString* str = compilingClass->classLoader->UTF8ToStr(utf8);
+
+      Value* val = module->getString(str, currentBlock);
+      push(val, false);
+    } else {
+    
+      // Lookup the constant pool cache
+      Value* val = getConstantPoolAt(index, module->StringLookupFunction,
+                                     module->JavaObjectType, 0, false);
+      push(val, false);
+    }
+#elif defined(ISOLATE_SHARING)
     // Lookup the constant pool cache
     Value* val = getConstantPoolAt(index, module->StringLookupFunction,
                                    module->JavaObjectType, 0, false);
-    push(val, false);  
+    push(val, false);
 #else
     const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]);
     JavaString* str = compilingClass->classLoader->UTF8ToStr(utf8);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Tue Dec  2 10:09:36 2008
@@ -314,7 +314,7 @@
   return cl;
 }
 
-extern "C" JavaObject* getClassDelegatee(UserCommonClass* cl) {
+extern "C" JavaObject* jnjvmRuntimeDelegatee(UserCommonClass* cl) {
   Jnjvm* vm = JavaThread::get()->getJVM();
   return cl->getClassDelegatee(vm);
 }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.cpp Tue Dec  2 10:09:36 2008
@@ -1210,6 +1210,7 @@
     module->getFunction("getObjectSizeFromClass");
  
   GetClassDelegateeFunction = module->getFunction("getClassDelegatee");
+  RuntimeDelegateeFunction = module->getFunction("jnjvmRuntimeDelegatee");
   InstanceOfFunction = module->getFunction("instanceOf");
   IsAssignableFromFunction = module->getFunction("isAssignableFrom");
   ImplementsFunction = module->getFunction("implements");

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmModule.h Tue Dec  2 10:09:36 2008
@@ -314,6 +314,7 @@
 #endif
 
   llvm::Function* GetClassDelegateeFunction;
+  llvm::Function* RuntimeDelegateeFunction;
   llvm::Function* ArrayLengthFunction;
   llvm::Function* GetVTFunction;
   llvm::Function* GetClassFunction;

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Tue Dec  2 10:09:36 2008
@@ -101,6 +101,45 @@
 }
 #endif
 
+#ifdef ISOLATE
+static Value* getDelegatee(JnjvmModule* module, Value* Arg, Instruction* CI) {
+  Value* GEP[2] = { module->constantZero,
+                    module->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,
+                                       "", CI);
+  
+  threadId = new IntToPtrInst(threadId, module->ptr32Type, "", CI);
+  
+  Value* IsolateID = GetElementPtrInst::Create(threadId, module->constantThree,
+                                               "", CI);
+  IsolateID = new LoadInst(IsolateID, "", CI);
+
+  Value* GEP2[2] = { module->constantZero, IsolateID };
+
+  Value* TCM = GetElementPtrInst::Create(TCMArray, GEP2, GEP2 + 2, "",
+                                         CI);
+  return new LoadInst(TCM, "", CI);
+}
+#else
+static Value* getDelegatee(JnjvmModule* module, Value* Arg, Instruction* CI) {
+  Value* GEP[2] = { module->constantZero,
+                    module->constantTwo };
+  Value* TCMArray = GetElementPtrInst::Create(Arg, GEP, GEP + 2, "", CI);
+  
+  Value* GEP2[2] = { module->constantZero, module->constantZero };
+
+  Value* TCM = GetElementPtrInst::Create(TCMArray, GEP2, GEP2 + 2, "",
+                                         CI);
+  return new LoadInst(TCM, "", CI);
+
+}
+#endif
+
 bool LowerConstantCalls::runOnFunction(Function& F) {
   JnjvmModule* module = (JnjvmModule*)F.getParent();
   bool Changed = false;
@@ -324,6 +363,29 @@
 #else
           abort();
 #endif
+        } else if (V == module->GetClassDelegateeFunction) {
+          Changed = true;
+          BasicBlock* NBB = II->getParent()->splitBasicBlock(II);
+          I->getParent()->getTerminator()->eraseFromParent();
+          Value* Del = getDelegatee(module, Call.getArgument(0), CI);
+          Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, Del, 
+                                    module->JavaObjectNullConstant, "", CI);
+          
+          BasicBlock* NoDelegatee = BasicBlock::Create("No delegatee", &F);
+          BasicBlock* DelegateeOK = BasicBlock::Create("Delegatee OK", &F);
+          BranchInst::Create(NoDelegatee, DelegateeOK, cmp, CI);
+          PHINode* phi = PHINode::Create(module->JavaObjectType, "", DelegateeOK);
+          phi->addIncoming(Del, CI->getParent());
+          
+          Value* Res = CallInst::Create(module->RuntimeDelegateeFunction,
+                                        Call.getArgument(0), "", NoDelegatee);
+          BranchInst::Create(DelegateeOK, NoDelegatee);
+          phi->addIncoming(Res, NoDelegatee);
+
+          CI->replaceAllUsesWith(phi);
+          CI->eraseFromParent();
+          BranchInst::Create(NBB, DelegateeOK);
+          break;
          
         } else if (V == module->InitialisationCheckFunction) {
           Changed = true;





More information about the vmkit-commits mailing list