[vmkit-commits] [vmkit] r61132 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaJIT.cpp JavaJIT.h JavaJITOpcodes.cpp LowerConstantCalls.cpp

Nicolas Geoffray nicolas.geoffray at lip6.fr
Wed Dec 17 05:47:41 PST 2008


Author: geoffray
Date: Wed Dec 17 07:47:32 2008
New Revision: 61132

URL: http://llvm.org/viewvc/llvm-project?rev=61132&view=rev
Log:
Testing on ConstantExpr in the lower constant calls pass
could not be used by the static compiler, so move the
optimizations directly into the JIT.


Modified:
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp
    vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h
    vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp
    vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.cpp Wed Dec 17 07:47:32 2008
@@ -985,7 +985,7 @@
 #ifdef ISOLATE_SHARING
     // We're dealing with exceptions, don't catch the exception if the class can
     // not be found.
-    if (cur->catche) cl = getResolvedClass(cur->catche, false, false);
+    if (cur->catche) cl = getResolvedClass(cur->catche, false, false, 0);
     else cl = CallInst::Create(module->GetJnjvmExceptionClassFunction,
                                isolateLocal, "", currentBlock);
 #else
@@ -1168,20 +1168,17 @@
     push(ConstantFP::get(Type::FloatTy, ctpInfo->FloatAt(index)),
          false);
   } else if (type == JavaConstantPool::ConstantClass) {
-#if !defined(ISOLATE)
-    if (ctpInfo->ctpRes[index]) {
-      CommonClass* cl = (CommonClass*)(ctpInfo->ctpRes[index]);
-      Value* Val = module->getJavaClass(cl, currentBlock);
-      push(Val, false);
-    } else {
-#endif
-      Value* val = getResolvedCommonClass(index, false);
-      Value* res = CallInst::Create(module->GetClassDelegateeFunction,
-                                    val, "", currentBlock);
-      push(res, false);
-#if !defined(ISOLATE)
-    }
+    UserCommonClass* cl = 0;
+    Value* res = getResolvedCommonClass(index, false, &cl);
+
+#ifndef ISOLATE
+    if (cl) res = module->getJavaClass(cl, currentBlock);
+    else
 #endif
+    
+    res = CallInst::Create(module->GetClassDelegateeFunction, res, "",
+                           currentBlock);
+    push(res, false);
   } else {
     JavaThread::get()->getJVM()->unknownError("unknown type %d", type);
   }
@@ -1599,8 +1596,9 @@
     if (module->isStaticCompiling()) {
 #endif
       uint32 clIndex = ctpInfo->getClassIndexFromMethod(index);
-      Value* Cl = getResolvedClass(clIndex, true); 
-      if (!meth || needsInitialisationCheck(meth->classDef, compilingClass)) {
+      UserClass* cl = 0;
+      Value* Cl = getResolvedClass(clIndex, true, true, &cl);
+      if (!meth || (cl && needsInitialisationCheck(cl, compilingClass))) {
         CallInst::Create(module->ForceInitialisationCheckFunction, Cl, "",
                          currentBlock);
       }
@@ -1669,12 +1667,14 @@
   return res;
 }
 
-Value* JavaJIT::getResolvedCommonClass(uint16 index, bool doThrow) {
+Value* JavaJIT::getResolvedCommonClass(uint16 index, bool doThrow,
+                                       UserCommonClass** alreadyResolved) {
     
   JavaConstantPool* ctpInfo = compilingClass->ctpInfo;
   CommonClass* cl = ctpInfo->getMethodClassIfLoaded(index);
   Value* node = 0;
   if (cl && (!cl->isClass() || cl->asClass()->isResolved())) {
+    if (alreadyResolved) *alreadyResolved = cl;
     node = module->getNativeClass(cl, currentBlock);
     if (node->getType() != module->JavaCommonClassType) {
       node = new BitCastInst(node, module->JavaCommonClassType, "",
@@ -1688,12 +1688,14 @@
   return node;
 }
 
-Value* JavaJIT::getResolvedClass(uint16 index, bool clinit, bool doThrow) {
+Value* JavaJIT::getResolvedClass(uint16 index, bool clinit, bool doThrow,
+                                 Class** alreadyResolved) {
     
   JavaConstantPool* ctpInfo = compilingClass->ctpInfo;
   Class* cl = (Class*)(ctpInfo->getMethodClassIfLoaded(index));
   Value* node = 0;
   if (cl && cl->isResolved()) {
+    if (alreadyResolved) (*alreadyResolved) = cl;
     node = module->getNativeClass(cl, currentBlock);
   } else {
     node = getConstantPoolAt(index, module->ClassLookupFunction,
@@ -1713,11 +1715,22 @@
 
 void JavaJIT::invokeNew(uint16 index) {
   
-  Value* Cl = getResolvedClass(index, true);
-  Value* Size = CallInst::Create(module->GetObjectSizeFromClassFunction, Cl,
-                                 "", currentBlock);
-  Value* VT = CallInst::Create(module->GetVTFromClassFunction, Cl, "",
-                               currentBlock);
+  Class* cl = 0;
+  Value* Cl = getResolvedClass(index, true, true, &cl);
+          
+  Value* VT = 0;
+  Value* Size = 0;
+  
+  if (cl) {
+    VT = module->getVirtualTable(cl, currentBlock);
+    LLVMClassInfo* LCI = module->getClassInfo(cl);
+    Size = LCI->getVirtualSize();
+  } else {
+    VT = CallInst::Create(module->GetVTFromClassFunction, Cl, "",
+                          currentBlock);
+    Size = CallInst::Create(module->GetObjectSizeFromClassFunction, Cl,
+                            "", currentBlock);
+  }
   
   Value* val = invoke(module->JavaObjectAllocateFunction, Size, VT, "",
                       currentBlock);
@@ -1775,12 +1788,23 @@
     if (stat) {
       type = LCI->getStaticType();
       Value* Cl = module->getNativeClass(field->classDef, currentBlock);
-      if (needsInitialisationCheck(field->classDef, compilingClass)) {
+      bool needsCheck = needsInitialisationCheck(field->classDef,
+                                                 compilingClass);
+      if (needsCheck) {
         Cl = invoke(module->InitialisationCheckFunction, Cl, "",
                     currentBlock);
       }
+#if !defined(ISOLATE) && !defined(ISOLATE_SHARING)
+      if (needsCheck) {
+        CallInst::Create(module->ForceInitialisationCheckFunction, Cl, "",
+                         currentBlock);
+      }
+
+      object = module->getStaticInstance(field->classDef, currentBlock);
+#else
       object = CallInst::Create(module->GetStaticInstanceFunction, Cl, "",
                                 currentBlock); 
+#endif
     } else {
       type = LCI->getVirtualType();
     }

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJIT.h Wed Dec 17 07:47:32 2008
@@ -214,8 +214,10 @@
   llvm::Value* ldResolved(uint16 index, bool stat, llvm::Value* object,
                           const llvm::Type* fieldType, 
                           const llvm::Type* fieldTypePtr);
-  llvm::Value* getResolvedClass(uint16 index, bool clinit, bool doThrow = true);
-  llvm::Value* getResolvedCommonClass(uint16 index, bool doThrow = true);
+  llvm::Value* getResolvedClass(uint16 index, bool clinit, bool doThrow,
+                                UserClass** alreadyResolved);
+  llvm::Value* getResolvedCommonClass(uint16 index, bool doThrow,
+                                      UserCommonClass** alreadyResolved);
   
   // methods invoke
   void makeArgs(llvm::FunctionType::param_iterator it,

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Wed Dec 17 07:47:32 2008
@@ -1851,12 +1851,24 @@
           TheVT = module->getPrimitiveArrayVT(currentBlock);
         } else {
           uint16 index = readU2(bytecodes, i);
-          valCl = getResolvedCommonClass(index);
-          const llvm::Type* Ty = 
-            PointerType::getUnqual(module->JavaCommonClassType);
-          Value* args[2]= { valCl, Constant::getNullValue(Ty) };
-          valCl = CallInst::Create(module->GetArrayClassFunction, args,
-                                   args + 2, "", currentBlock);
+          CommonClass* cl = 0;
+          valCl = getResolvedCommonClass(index, true, &cl);
+
+          if (cl) {
+            JnjvmClassLoader* JCL = cl->classLoader;
+            const UTF8* arrayName = JCL->constructArrayName(1, cl->name);
+          
+            UserCommonClass* dcl = JCL->constructArray(arrayName);
+            valCl = module->getNativeClass(dcl, currentBlock);
+
+          } else {
+            const llvm::Type* Ty = 
+              PointerType::getUnqual(module->JavaCommonClassType);
+            Value* args[2]= { valCl, Constant::getNullValue(Ty) };
+            valCl = CallInst::Create(module->GetArrayClassFunction, args,
+                                     args + 2, "", currentBlock);
+          }
+
           sizeElement = module->constantPtrSize;
           TheVT = module->getReferenceArrayVT(currentBlock);
         }
@@ -1975,52 +1987,132 @@
         break;
       }
 
-      case CHECKCAST : {
-        uint16 index = readU2(bytecodes, i);
+      case CHECKCAST :
+      case INSTANCEOF : {
         
-        Value* obj = top();
+        bool checkcast = (bytecodes[i] == CHECKCAST);
+        
+        BasicBlock* exceptionCheckcast = 0;
+        BasicBlock* endCheckcast = 0;
+        Value* result = 0;
 
+        uint16 index = readU2(bytecodes, i);
+        UserCommonClass* cl = 0;
+        Value* clVar = getResolvedCommonClass(index, true, &cl);
+        Value* obj = top();
+        Value* args[2] = { obj, clVar };
         Value* cmp = new ICmpInst(ICmpInst::ICMP_EQ, obj,
                                   module->JavaObjectNullConstant,
                                   "", currentBlock);
         
-        BasicBlock* ifTrue = createBasicBlock("null checkcast");
-        BasicBlock* ifFalse = createBasicBlock("non null checkcast");
+        if (checkcast) {
+          exceptionCheckcast = createBasicBlock("false checkcast");
 
-        BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
-        currentBlock = ifFalse;
-        Value* clVar = getResolvedCommonClass(index);
         
-        Value* args[2] = { obj, clVar };
-        Value* call = CallInst::Create(module->InstanceOfFunction, args,
-                                       args + 2, "", currentBlock);
+          endCheckcast = createBasicBlock("null checkcast");
+          BasicBlock* ifFalse = createBasicBlock("non null checkcast");
+
+          BranchInst::Create(endCheckcast, ifFalse, cmp, currentBlock);
+          
+          if (currentExceptionBlock != endExceptionBlock) {
+            InvokeInst::Create(module->ClassCastExceptionFunction,
+                               unifiedUnreachable,
+                               currentExceptionBlock, args, args + 2, "", 
+                               exceptionCheckcast);
+          } else {
+            CallInst::Create(module->ClassCastExceptionFunction,
+                             args, args + 2, "", exceptionCheckcast);
+            new UnreachableInst(exceptionCheckcast);
+          }
+          currentBlock = ifFalse;
+        }
         
-        BasicBlock* ex = createBasicBlock("false checkcast");
-        BranchInst::Create(ifTrue, ex, call, currentBlock);
+        if (cl) {
+
+          BasicBlock* ifTrue = createBasicBlock("true type compare");
+          BasicBlock* ifFalse = createBasicBlock("false type compare");
+          BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock);
+          PHINode* node = PHINode::Create(Type::Int1Ty, "", ifTrue);
+          node->addIncoming(ConstantInt::getFalse(), currentBlock);
+          Value* objCl = CallInst::Create(module->GetClassFunction, obj, "",
+                                          ifFalse);
+          Value* classArgs[2] = { objCl, clVar };            
+            
+          if (isInterface(cl->access)) {
+            Value* res = CallInst::Create(module->ImplementsFunction,
+                                          classArgs, classArgs + 2, "",
+                                          ifFalse);
+            node->addIncoming(res, ifFalse);
+            BranchInst::Create(ifTrue, ifFalse);
+          } else {
+            cmp = new ICmpInst(ICmpInst::ICMP_EQ, objCl, clVar, "", ifFalse);
+            BasicBlock* notEquals = createBasicBlock("false compare");
+            BranchInst::Create(ifTrue, notEquals, cmp, ifFalse);
+            node->addIncoming(ConstantInt::getTrue(), ifFalse);
+              
+            if (cl->isPrimitive()) {
+              fprintf(stderr, "implement me");
+              abort();
+            } else if (cl->isArray()) {
+              Value* res = 
+                CallInst::Create(module->InstantiationOfArrayFunction,
+                                 classArgs, classArgs + 2, "", notEquals);
+              node->addIncoming(res, notEquals);
+              BranchInst::Create(ifTrue, notEquals);
+            } else {
+              Value* depthCl;
+              if (cl->asClass()->isResolved()) {
+                depthCl = ConstantInt::get(Type::Int32Ty, cl->depth);
+              } else {
+                depthCl = CallInst::Create(module->GetDepthFunction,
+                                           clVar, "", notEquals);
+              }
+              
+              Value* depthClObj = CallInst::Create(module->GetDepthFunction,
+                                                   objCl, "", notEquals);
+              Value* cmp = new ICmpInst(ICmpInst::ICMP_ULE, depthCl, depthClObj,
+                                        "", notEquals);
+            
+              BasicBlock* supDepth = createBasicBlock("superior depth");
+            
+              BranchInst::Create(supDepth, ifTrue, cmp, notEquals);
+              node->addIncoming(ConstantInt::getFalse(), notEquals);
+  
+              Value* inDisplay = CallInst::Create(module->GetDisplayFunction,
+                                                objCl, "", supDepth);
+            
+              Value* displayArgs[2] = { inDisplay, depthCl };
+              Value* clInDisplay = 
+                CallInst::Create(module->GetClassInDisplayFunction, displayArgs,
+                                 displayArgs + 2, "", supDepth);
+             
+              cmp = new ICmpInst(ICmpInst::ICMP_EQ, clInDisplay, clVar, "",
+                                   supDepth);
+             BranchInst::Create(ifTrue, supDepth); 
+            
+             node->addIncoming(cmp, supDepth);
+            }
+          }
+
+          currentBlock = ifTrue;
+          result = node;
 
-        if (currentExceptionBlock != endExceptionBlock) {
-          InvokeInst::Create(module->ClassCastExceptionFunction,
-                             unifiedUnreachable,
-                             currentExceptionBlock, args, args + 2, "", ex);
         } else {
-          CallInst::Create(module->ClassCastExceptionFunction,
-                           args, args + 2, "", ex);
-          new UnreachableInst(ex);
+          result = CallInst::Create(module->InstanceOfFunction, args,
+                                    args + 2, "", currentBlock);
+
+        }
+
+        if (checkcast) {
+          BranchInst::Create(endCheckcast, exceptionCheckcast, result,
+                             currentBlock);
+          currentBlock = endCheckcast;
+        } else {
+          pop();
+          push(new ZExtInst(result, Type::Int32Ty, "", currentBlock),
+               false);
         }
-        
-        currentBlock = ifTrue;
-        break;
-      }
 
-      case INSTANCEOF : {
-        uint16 index = readU2(bytecodes, i);
-        Value* clVar = getResolvedCommonClass(index);
-        
-        Value* args[2] = { pop(), clVar };
-        Value* val = CallInst::Create(module->InstanceOfFunction,
-                                      args, args + 2, "", currentBlock);
-        push(new ZExtInst(val, Type::Int32Ty, "", currentBlock),
-             false);
         break;
       }
 
@@ -2043,7 +2135,7 @@
         uint8 dim = readU1(bytecodes, i);
         
         
-        Value* valCl = getResolvedCommonClass(index);
+        Value* valCl = getResolvedCommonClass(index, true, 0);
         Value** args = (Value**)alloca(sizeof(Value*) * (dim + 2));
         args[0] = valCl;
         args[1] = ConstantInt::get(Type::Int32Ty, dim);

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

==============================================================================
--- vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original)
+++ vmkit/trunk/lib/JnJVM/VMCore/LowerConstantCalls.cpp Wed Dec 17 07:47:32 2008
@@ -36,37 +36,6 @@
                                             "Lower Constant calls");
 
 
-static ConstantExpr* getClass(JnjvmModule* Mod, Value* obj) {
-  ConstantExpr* CE = 0;
-  if (Mod->isStaticCompiling()) {
-    LoadInst* LI = dyn_cast<LoadInst>(obj);
-    if (!LI) {
-      PHINode* node = dyn_cast<PHINode>(obj);
-      if (node) {
-        LI = dyn_cast<LoadInst>(node->getIncomingValue(0));
-      } else {
-        GetElementPtrInst* GEP = dyn_cast<GetElementPtrInst>(obj);
-        if (GEP) {
-          return getClass(Mod, GEP->getOperand(0));
-        }
-      }
-    }
-
-    if (LI) {
-      GlobalVariable* GV = dyn_cast<GlobalVariable>(LI->getOperand(0));
-      CE = dyn_cast<ConstantExpr>(GV->getInitializer());
-    }
-  } else {
-    CE = dyn_cast<ConstantExpr>(obj);
-    if (!CE) {
-      // It has to be a phi for intialization check.
-      PHINode* node = dyn_cast<PHINode>(obj);
-      if (node) CE = dyn_cast<ConstantExpr>(node->getIncomingValue(0));
-    }
-  }
-  return CE;
-}
-
 #ifdef ISOLATE
 static Value* getTCM(JnjvmModule* module, Value* Arg, Instruction* CI) {
   Value* GEP[2] = { module->constantZero,
@@ -91,22 +60,7 @@
                                          CI);
   return TCM;
 }
-#else
-static Value* getTCM(JnjvmModule* module, Value* Arg, Instruction* CI) {
-  Value* GEP[2] = { module->constantZero,
-                    module->OffsetTaskClassMirrorInClassConstant };
-  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 TCM;
-
-}
-#endif
 
-#ifdef ISOLATE
 static Value* getDelegatee(JnjvmModule* module, Value* Arg, Instruction* CI) {
   Value* GEP[2] = { module->constantZero,
                     module->constantTwo };
@@ -130,7 +84,22 @@
                                          CI);
   return new LoadInst(TCM, "", CI);
 }
+
 #else
+
+static Value* getTCM(JnjvmModule* module, Value* Arg, Instruction* CI) {
+  Value* GEP[2] = { module->constantZero,
+                    module->OffsetTaskClassMirrorInClassConstant };
+  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 TCM;
+
+}
+
 static Value* getDelegatee(JnjvmModule* module, Value* Arg, Instruction* CI) {
   Value* GEP[2] = { module->constantZero,
                     module->constantTwo };
@@ -206,18 +175,6 @@
         } else if (V == module->GetVTFromClassFunction) {
           Changed = true;
           
-          ConstantExpr* CE = getClass(module, Call.getArgument(0));
-          if (CE) {
-            ConstantInt* C = (ConstantInt*)CE->getOperand(0);
-            Class* cl = (Class*)C->getZExtValue();
-            if (cl->isResolved()) {
-              Value* VT = module->getVirtualTable(cl, CI);
-              CI->replaceAllUsesWith(VT);
-              CI->eraseFromParent();
-              continue;
-            }
-          }
-          
           Value* val = Call.getArgument(0);
           Value* indexes[2] = { module->constantZero, 
                                 module->OffsetVTInClassConstant };
@@ -229,19 +186,6 @@
         } else if (V == module->GetObjectSizeFromClassFunction) {
           Changed = true;
           
-          ConstantExpr* CE = getClass(module, Call.getArgument(0));
-          if (CE) {
-            ConstantInt* C = (ConstantInt*)CE->getOperand(0);
-            Class* cl = (Class*)C->getZExtValue();
-            if (cl->isResolved()) {
-              LLVMClassInfo* LCI = module->getClassInfo(cl);
-              Value* Size = LCI->getVirtualSize();
-              CI->replaceAllUsesWith(Size);
-              CI->eraseFromParent();
-              continue;
-            }
-          }
-          
           Value* val = Call.getArgument(0); 
           Value* indexes[2] = { module->constantZero, 
                                 module->OffsetObjectSizeInClassConstant };
@@ -278,104 +222,10 @@
           Value* Class = new LoadInst(ClassPtr, "", CI);
           CI->replaceAllUsesWith(Class);
           CI->eraseFromParent();
-        } else if (V == module->InstanceOfFunction) {
-          ConstantExpr* CE = dyn_cast<ConstantExpr>(Call.getArgument(1));
-          if (CE) {
-            ConstantInt* C = (ConstantInt*)CE->getOperand(0);
-            CommonClass* cl = (CommonClass*)C->getZExtValue();
-            Changed = true;
-            BasicBlock* NBB = II->getParent()->splitBasicBlock(II);
-            I->getParent()->getTerminator()->eraseFromParent();
-            Value* obj = Call.getArgument(0);
-            Instruction* cmp = new ICmpInst(ICmpInst::ICMP_EQ, obj,
-                                            module->JavaObjectNullConstant,
-                                            "", CI);
-            BasicBlock* ifTrue = BasicBlock::Create("", &F);
-            BasicBlock* ifFalse = BasicBlock::Create("", &F);
-            BranchInst::Create(ifTrue, ifFalse, cmp, CI);
-            PHINode* node = PHINode::Create(Type::Int1Ty, "", ifTrue);
-            node->addIncoming(ConstantInt::getFalse(), CI->getParent());
-            Value* objCl = CallInst::Create(module->GetClassFunction, obj,
-                                            "", ifFalse);
-            
-            if (isInterface(cl->access)) {
-              Value* args[2] = { objCl, CE };
-              Value* res = CallInst::Create(module->ImplementsFunction,
-                                            args, args + 2, "", ifFalse);
-              node->addIncoming(res, ifFalse);
-              BranchInst::Create(ifTrue, ifFalse);
-            } else {
-              cmp = new ICmpInst(ICmpInst::ICMP_EQ, objCl, CE, "", ifFalse);
-              BasicBlock* notEquals = BasicBlock::Create("", &F);
-              BranchInst::Create(ifTrue, notEquals, cmp, ifFalse);
-              node->addIncoming(ConstantInt::getTrue(), ifFalse);
-              
-              if (cl->isPrimitive()) {
-                fprintf(stderr, "implement me");
-                abort();
-              } else if (cl->isArray()) {
-                Value* args[2] = { objCl, CE };
-                Value* res = 
-                  CallInst::Create(module->InstantiationOfArrayFunction,
-                                   args, args + 2, "", notEquals);
-                node->addIncoming(res, notEquals);
-                BranchInst::Create(ifTrue, notEquals);
-              } else {
-                Value* depthCl;
-                if (cl->asClass()->isResolved()) {
-                  depthCl = ConstantInt::get(Type::Int32Ty, cl->depth);
-                } else {
-                  depthCl = CallInst::Create(module->GetDepthFunction,
-                                             CE, "", notEquals);
-                }
-                Value* depthClObj = CallInst::Create(module->GetDepthFunction,
-                                                     objCl, "", notEquals);
-                Value* cmp = new ICmpInst(ICmpInst::ICMP_ULE, depthCl, depthClObj, "",
-                                          notEquals);
-            
-                BasicBlock* supDepth = BasicBlock::Create("superior depth", &F);
-            
-                BranchInst::Create(supDepth, ifTrue, cmp, notEquals);
-                node->addIncoming(ConstantInt::getFalse(), notEquals);
-  
-                Value* inDisplay = 
-                  CallInst::Create(module->GetDisplayFunction, objCl,
-                                   "", supDepth);
-            
-                Value* args[2] = { inDisplay, depthCl };
-                Value* clInDisplay = 
-                  CallInst::Create(module->GetClassInDisplayFunction,
-                                   args, args + 2, "", supDepth);
-             
-                cmp = new ICmpInst(ICmpInst::ICMP_EQ, clInDisplay, CE, "",
-                                   supDepth);
-                BranchInst::Create(ifTrue, supDepth); 
-                node->addIncoming(cmp, supDepth);
-              }
-            }
-            CI->replaceAllUsesWith(node);
-            CI->eraseFromParent();
-            BranchInst::Create(NBB, ifTrue);
-            break;
-          }
+#if defined(ISOLATE)
         } else if (V == module->GetStaticInstanceFunction) {
           Changed = true;
-#if !defined(ISOLATE_SHARING) && !defined(ISOLATE)
-          ConstantExpr* CE = getClass(module, Call.getArgument(0));
-          assert(CE && "Wrong use of GetStaticInstanceFunction");
-          
-          ConstantInt* C = (ConstantInt*)CE->getOperand(0);
-          Class* cl = (Class*)C->getZExtValue();
-          
-          Instruction* R = dyn_cast<Instruction>(Call.getArgument(0));
-          Value* Replace = module->getStaticInstance(cl, CI);
-          CI->replaceAllUsesWith(Replace);
-          CI->eraseFromParent();
-          
-          if (R && !R->getNumUses()) R->eraseFromParent();
-         
 
-#elif defined(ISOLATE)
           Value* TCM = getTCM(module, Call.getArgument(0), CI);
           Constant* C = module->OffsetStaticInstanceInTaskClassMirrorConstant;
           Value* GEP[2] = { module->constantZero, C };
@@ -383,8 +233,6 @@
           Replace = new LoadInst(Replace, "", CI);
           CI->replaceAllUsesWith(Replace);
           CI->eraseFromParent();
-#else
-          abort();
 #endif
         } else if (V == module->GetClassDelegateeFunction) {
           Changed = true;
@@ -569,33 +417,7 @@
             PointerType::getUnqual(module->JavaCommonClassType);
           Constant* nullValue = Constant::getNullValue(Ty);
           // Check if we have already proceed this call.
-          if (Call.getArgument(1) == nullValue) {
-            Changed = true;
-            ConstantExpr* CE = getClass(module, Call.getArgument(0));
-            if (CE) {
-              ConstantInt* C = (ConstantInt*)CE->getOperand(0);
-              Class* cl = (Class*)C->getZExtValue();
-              if (cl->isResolved()) {
-                JnjvmClassLoader* JCL = cl->classLoader;
-                const UTF8* arrayName = JCL->constructArrayName(1, cl->name);
-          
-                UserCommonClass* dcl = JCL->constructArray(arrayName);
-                Value* valCl = module->getNativeClass(dcl, CI);
-                
-                Instruction* V = dyn_cast<Instruction>(Call.getArgument(0));
-                CI->replaceAllUsesWith(valCl);
-                CI->eraseFromParent();
-
-                if (V) {
-                  Instruction* Op = dyn_cast<Instruction>(V->getOperand(0));
-                  if (!V->getNumUses()) V->eraseFromParent();
-                  if (Op && !Op->getNumUses()) Op->eraseFromParent();
-                }
-                
-                continue;
-              }
-            }
-            
+          if (Call.getArgument(1) == nullValue) { 
             BasicBlock* NBB = II->getParent()->splitBasicBlock(II);
             I->getParent()->getTerminator()->eraseFromParent();
 





More information about the vmkit-commits mailing list