From sanxiyn at gmail.com Sat Aug 1 19:41:33 2009 From: sanxiyn at gmail.com (Seo Sanghyeon) Date: Sun, 02 Aug 2009 02:41:33 -0000 Subject: [vmkit-commits] [vmkit] r77851 - in /vmkit/trunk: ./ lib/JnJVM/Classpath/ lib/JnJVM/Compiler/ lib/JnJVM/VMCore/ lib/Mvm/Allocator/ lib/Mvm/CommonThread/ lib/Mvm/Compiler/ lib/Mvm/GCMmap2/ lib/Mvm/Runtime/ tools/jnjvm/ tools/llcj/ tools/vmjc/ tools/vmkit/ Message-ID: <200908020241.n722fYlS023795@zion.cs.uiuc.edu> Author: sanxiyn Date: Sat Aug 1 21:41:33 2009 New Revision: 77851 URL: http://llvm.org/viewvc/llvm-project?rev=77851&view=rev Log: svn:ignore Debug and Release Modified: vmkit/trunk/ (props changed) vmkit/trunk/lib/JnJVM/Classpath/ (props changed) vmkit/trunk/lib/JnJVM/Compiler/ (props changed) vmkit/trunk/lib/JnJVM/VMCore/ (props changed) vmkit/trunk/lib/Mvm/Allocator/ (props changed) vmkit/trunk/lib/Mvm/CommonThread/ (props changed) vmkit/trunk/lib/Mvm/Compiler/ (props changed) vmkit/trunk/lib/Mvm/GCMmap2/ (props changed) vmkit/trunk/lib/Mvm/Runtime/ (props changed) vmkit/trunk/tools/jnjvm/ (props changed) vmkit/trunk/tools/llcj/ (props changed) vmkit/trunk/tools/vmjc/ (props changed) vmkit/trunk/tools/vmkit/ (props changed) Propchange: vmkit/trunk/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/lib/JnJVM/Classpath/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/lib/JnJVM/Compiler/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/lib/JnJVM/VMCore/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/lib/Mvm/Allocator/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/lib/Mvm/CommonThread/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/lib/Mvm/Compiler/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/lib/Mvm/GCMmap2/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/lib/Mvm/Runtime/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/tools/jnjvm/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/tools/llcj/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/tools/vmjc/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release Propchange: vmkit/trunk/tools/vmkit/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Sat Aug 1 21:41:33 2009 @@ -0,0 +1,2 @@ +Debug +Release From nicolas.geoffray at lip6.fr Mon Aug 3 02:27:09 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 03 Aug 2009 09:27:09 -0000 Subject: [vmkit-commits] [vmkit] r77970 - in /vmkit/trunk/lib: JnJVM/Compiler/ExceptionsCheck.inc JnJVM/Compiler/JavaAOTCompiler.cpp JnJVM/Compiler/JavaJIT.cpp JnJVM/Compiler/JnjvmModule.cpp Mvm/Compiler/JIT.cpp Message-ID: <200908030927.n739RSal001179@zion.cs.uiuc.edu> Author: geoffray Date: Mon Aug 3 04:26:51 2009 New Revision: 77970 URL: http://llvm.org/viewvc/llvm-project?rev=77970&view=rev Log: Move to new LLVM API. Modified: vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Modified: vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc?rev=77970&r1=77969&r2=77970&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc (original) +++ vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc Mon Aug 3 04:26:51 2009 @@ -214,7 +214,7 @@ BranchInst::Create(currentExceptionBlock, currentBlock); } else { if (endNode) { - endNode->addIncoming(llvmContext->getNullValue(endNode->getType()), + endNode->addIncoming(Constant::getNullValue(endNode->getType()), currentBlock); } BranchInst::Create(endBlock, currentBlock); @@ -237,7 +237,7 @@ BranchInst::Create(currentExceptionBlock, currentBlock); } else { if (endNode) { - endNode->addIncoming(llvmContext->getNullValue(endNode->getType()), + endNode->addIncoming(Constant::getNullValue(endNode->getType()), currentBlock); } BranchInst::Create(endBlock, currentBlock); @@ -254,7 +254,7 @@ BranchInst::Create(currentExceptionBlock, currentBlock); } else { if (endNode) { - endNode->addIncoming(llvmContext->getNullValue(endNode->getType()), + endNode->addIncoming(Constant::getNullValue(endNode->getType()), currentBlock); } BranchInst::Create(endBlock, currentBlock); @@ -534,7 +534,7 @@ endExceptionBlock->eraseFromParent(); } else { if (endNode) { - endNode->addIncoming(llvmContext->getNullValue(endNode->getType()), + endNode->addIncoming(Constant::getNullValue(endNode->getType()), endExceptionBlock); } BranchInst::Create(endBlock, endExceptionBlock); @@ -557,7 +557,7 @@ Instruction* insn = BI->begin(); PHINode* node = dyn_cast(insn); if (node) { - node->replaceAllUsesWith(llvmContext->getNullValue(node->getType())); + node->replaceAllUsesWith(Constant::getNullValue(node->getType())); node->eraseFromParent(); } } Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp?rev=77970&r1=77969&r2=77970&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp Mon Aug 3 04:26:51 2009 @@ -97,7 +97,7 @@ GlobalVariable* varGV = new GlobalVariable(Mod, Ty, false, GlobalValue::InternalLinkage, - Mod.getContext().getNullValue(Ty), + Constant::getNullValue(Ty), UTF8Buffer(classDef->name).toCompileName()->cString()); arrayClasses.insert(std::make_pair(classDef->asArrayClass(), varGV)); @@ -121,7 +121,7 @@ varGV = new GlobalVariable(Mod, Ty, false, GlobalValue::InternalLinkage, - Mod.getContext().getNullValue(Ty), ""); + Constant::getNullValue(Ty), ""); constantPools.insert(std::make_pair(ctp, varGV)); return varGV; } else { @@ -325,7 +325,6 @@ LLVMClassInfo* LCI = getClassInfo(cl); const Type* Ty = LCI->getStaticType(); const StructType* STy = dyn_cast(Ty->getContainedType(0)); - Module& Mod = *getLLVMModule(); std::vector Elts; @@ -375,11 +374,11 @@ Constant* CO = getFinalObject(val); Elts.push_back(CO); } else { - Elts.push_back(Mod.getContext().getNullValue(Ty)); + Elts.push_back(Constant::getNullValue(Ty)); } } } else { - Elts.push_back(Mod.getContext().getNullValue(Ty)); + Elts.push_back(Constant::getNullValue(Ty)); } } else { Reader reader(attribut, &(cl->bytes)); @@ -500,7 +499,7 @@ Module& Mod = *getLLVMModule(); varGV = new GlobalVariable(Mod, valPtrType, true, GlobalValue::InternalLinkage, - Mod.getContext().getNullValue(valPtrType), ""); + Constant::getNullValue(valPtrType), ""); nativeFunctions.insert(std::make_pair(meth, varGV)); return varGV; @@ -528,10 +527,8 @@ Constant* JavaAOTCompiler::CreateConstantFromJavaClass(CommonClass* cl) { Class* javaClass = cl->classLoader->bootstrapLoader->upcalls->newClass; LLVMClassInfo* LCI = getClassInfo(javaClass); - Module& Mod = *getLLVMModule(); const StructType* STy = dyn_cast(LCI->getVirtualType()->getContainedType(0)); - LLVMContext& Context = Mod.getContext(); std::vector Elmts; @@ -539,10 +536,10 @@ Elmts.push_back(CreateConstantForBaseObject(javaClass)); // signers - Elmts.push_back(Context.getNullValue(JnjvmModule::JavaObjectType)); + Elmts.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType)); // pd - Elmts.push_back(Context.getNullValue(JnjvmModule::JavaObjectType)); + Elmts.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType)); // vmdata Constant* Cl = getNativeClass(cl); @@ -551,14 +548,13 @@ Elmts.push_back(Cl); // constructor - Elmts.push_back(Context.getNullValue(JnjvmModule::JavaObjectType)); + Elmts.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType)); return ConstantStruct::get(STy, Elmts); } Constant* JavaAOTCompiler::CreateConstantFromJavaObject(JavaObject* obj) { CommonClass* cl = obj->getClass(); - Module& Mod = *getLLVMModule(); if (cl->isArray()) { Classpath* upcalls = cl->classLoader->bootstrapLoader->upcalls; @@ -650,7 +646,7 @@ TempElts.push_back(C); } else { const llvm::Type* Ty = JnjvmModule::JavaObjectType; - TempElts.push_back(Mod.getContext().getNullValue(Ty)); + TempElts.push_back(Constant::getNullValue(Ty)); } } } @@ -694,12 +690,11 @@ Constant* JavaAOTCompiler::CreateConstantFromCacheNode(CacheNode* CN) { const StructType* STy = dyn_cast(JnjvmModule::CacheNodeType->getContainedType(0)); - LLVMContext& Context = getLLVMModule()->getContext(); std::vector Elmts; - Elmts.push_back(Context.getNullValue(STy->getContainedType(0))); - Elmts.push_back(Context.getNullValue(STy->getContainedType(1))); - Elmts.push_back(Context.getNullValue(STy->getContainedType(2))); + Elmts.push_back(Constant::getNullValue(STy->getContainedType(0))); + Elmts.push_back(Constant::getNullValue(STy->getContainedType(1))); + Elmts.push_back(Constant::getNullValue(STy->getContainedType(2))); Elmts.push_back(getEnveloppe(CN->enveloppe)); return ConstantStruct::get(STy, Elmts); @@ -711,8 +706,6 @@ dyn_cast(JnjvmModule::EnveloppeType->getContainedType(0)); const StructType* CNTy = dyn_cast(JnjvmModule::CacheNodeType->getContainedType(0)); - Module& Mod = *getLLVMModule(); - LLVMContext& Context = Mod.getContext(); std::vector Elmts; @@ -723,7 +716,7 @@ Elmts.push_back(getUTF8(val->methodName)); Elmts.push_back(getUTF8(val->methodSign)); - Elmts.push_back(Context.getNullValue(Type::Int32Ty)); + Elmts.push_back(Constant::getNullValue(Type::Int32Ty)); Elmts.push_back(getNativeClass(val->classDef)); Elmts.push_back(firstCache); @@ -754,7 +747,6 @@ const StructType* STy = dyn_cast(JnjvmModule::JavaCommonClassType->getContainedType(0)); Module& Mod = *getLLVMModule(); - LLVMContext& Context = getLLVMModule()->getContext(); const llvm::Type* TempTy = 0; @@ -788,7 +780,7 @@ CommonClassElts.push_back(interfaces); } else { const Type* Ty = PointerType::getUnqual(JnjvmModule::JavaClassType); - CommonClassElts.push_back(Context.getNullValue(Ty)); + CommonClassElts.push_back(Constant::getNullValue(Ty)); } // nbInterfaces @@ -802,7 +794,7 @@ CommonClassElts.push_back(getNativeClass(cl->super)); } else { TempTy = JnjvmModule::JavaClassType; - CommonClassElts.push_back(Mod.getContext().getNullValue(TempTy)); + CommonClassElts.push_back(Constant::getNullValue(TempTy)); } // classLoader: store the static initializer, it will be overriden once @@ -816,7 +808,7 @@ CommonClassElts.push_back(getVirtualTable(cl->virtualVT)); } else { TempTy = JnjvmModule::VTType; - CommonClassElts.push_back(Mod.getContext().getNullValue(TempTy)); + CommonClassElts.push_back(Constant::getNullValue(TempTy)); } return ConstantStruct::get(STy, CommonClassElts); } @@ -824,13 +816,12 @@ Constant* JavaAOTCompiler::CreateConstantFromJavaField(JavaField& field) { const StructType* STy = dyn_cast(JnjvmModule::JavaFieldType->getContainedType(0)); - Module& Mod = *getLLVMModule(); std::vector FieldElts; std::vector TempElts; // signature - FieldElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType)); + FieldElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); // access FieldElts.push_back(ConstantInt::get(Type::Int16Ty, field.access)); @@ -859,7 +850,7 @@ FieldElts.push_back(attributs); } else { - FieldElts.push_back(Mod.getContext().getNullValue(JnjvmModule::AttributType)); + FieldElts.push_back(Constant::getNullValue(JnjvmModule::AttributType)); } // nbAttributs @@ -875,7 +866,7 @@ FieldElts.push_back(ConstantInt::get(Type::Int16Ty, field.num)); //JInfo - FieldElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType)); + FieldElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); return ConstantStruct::get(STy, FieldElts); } @@ -884,13 +875,12 @@ const StructType* STy = dyn_cast(JnjvmModule::JavaMethodType->getContainedType(0)); Module& Mod = *getLLVMModule(); - LLVMContext& Context = Mod.getContext(); std::vector MethodElts; std::vector TempElts; // signature - MethodElts.push_back(Context.getNullValue(JnjvmModule::ptrType)); + MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); // access MethodElts.push_back(ConstantInt::get(Type::Int16Ty, method.access)); @@ -913,7 +903,7 @@ MethodElts.push_back(attributs); } else { - MethodElts.push_back(Context.getNullValue(JnjvmModule::AttributType)); + MethodElts.push_back(Constant::getNullValue(JnjvmModule::AttributType)); } // nbAttributs @@ -921,7 +911,7 @@ // enveloppes // already allocated by the JIT, don't reallocate them. - MethodElts.push_back(Context.getNullValue(JnjvmModule::EnveloppeType)); + MethodElts.push_back(Constant::getNullValue(JnjvmModule::EnveloppeType)); // nbEnveloppes // 0 because we're not allocating here. @@ -941,7 +931,7 @@ // code if (isAbstract(method.access)) { - MethodElts.push_back(Context.getNullValue(JnjvmModule::ptrType)); + MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); } else { LLVMMethodInfo* LMI = getMethodInfo(&method); Function* func = LMI->getMethod(); @@ -953,7 +943,7 @@ MethodElts.push_back(ConstantInt::get(Type::Int32Ty, method.offset)); //JInfo - MethodElts.push_back(Context.getNullValue(JnjvmModule::ptrType)); + MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); return ConstantStruct::get(STy, MethodElts); } @@ -999,7 +989,6 @@ const StructType* STy = dyn_cast(JnjvmModule::JavaClassType->getContainedType(0)); Module& Mod = *getLLVMModule(); - LLVMContext& Context = getLLVMModule()->getContext(); std::vector ClassElts; std::vector TempElts; @@ -1026,7 +1015,7 @@ ClassElts.push_back(ConstantArray::get(ATy, CStr, 1)); // thinlock - ClassElts.push_back(Context.getNullValue(JnjvmModule::ptrType)); + ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); if (cl->nbVirtualFields + cl->nbStaticFields) { ATy = ArrayType::get(JnjvmModule::JavaFieldType->getContainedType(0), @@ -1062,7 +1051,7 @@ fields = ConstantExpr::getCast(Instruction::BitCast, fields, JnjvmModule::JavaFieldType); } else { - fields = Context.getNullValue(JnjvmModule::JavaFieldType); + fields = Constant::getNullValue(JnjvmModule::JavaFieldType); } // virtualFields @@ -1076,7 +1065,7 @@ // staticFields // Output null, getLLVMModule() will be set in the initializer. Otherwise, the // assembly emitter of LLVM will try to align the data. - ClassElts.push_back(Context.getNullValue(JnjvmModule::JavaFieldType)); + ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaFieldType)); // nbStaticFields ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbStaticFields)); @@ -1110,7 +1099,7 @@ methods = ConstantExpr::getCast(Instruction::BitCast, GV, JnjvmModule::JavaMethodType); } else { - methods = Context.getNullValue(JnjvmModule::JavaMethodType); + methods = Constant::getNullValue(JnjvmModule::JavaMethodType); } // virtualMethods @@ -1123,19 +1112,19 @@ // staticMethods // Output null, getLLVMModule() will be set in the initializer. - ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::JavaMethodType)); + ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaMethodType)); // nbStaticMethods ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbStaticMethods)); // ownerClass - ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType)); + ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); // bytes - ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::JavaArrayUInt8Type)); + ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaArrayUInt8Type)); // ctpInfo - ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType)); + ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); // attributs if (cl->nbAttributs) { @@ -1155,7 +1144,7 @@ JnjvmModule::AttributType); ClassElts.push_back(attributs); } else { - ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::AttributType)); + ClassElts.push_back(Constant::getNullValue(JnjvmModule::AttributType)); } // nbAttributs @@ -1179,7 +1168,7 @@ ClassElts.push_back(innerClasses); } else { const Type* Ty = PointerType::getUnqual(JnjvmModule::JavaClassType); - ClassElts.push_back(Mod.getContext().getNullValue(Ty)); + ClassElts.push_back(Constant::getNullValue(Ty)); } // nbInnerClasses @@ -1189,7 +1178,7 @@ if (cl->outerClass) { ClassElts.push_back(getNativeClass(cl->outerClass)); } else { - ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::JavaClassType)); + ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaClassType)); } // innerAccess @@ -1208,14 +1197,13 @@ ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->staticSize)); // JInfo - ClassElts.push_back(Mod.getContext().getNullValue(JnjvmModule::ptrType)); + ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); return ConstantStruct::get(STy, ClassElts); } template Constant* JavaAOTCompiler::CreateConstantFromArray(const T* val, const Type* Ty) { - Module& Mod = *getLLVMModule(); std::vector Elemts; const ArrayType* ATy = ArrayType::get(Ty, val->size); Elemts.push_back(JnjvmModule::JavaObjectType->getContainedType(0)); @@ -1240,7 +1228,7 @@ if (val->elements[i]) { Vals.push_back(getFinalObject((JavaObject*)(size_t)val->elements[i])); } else { - Vals.push_back(Mod.getContext().getNullValue(JnjvmModule::JavaObjectType)); + Vals.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType)); } } } @@ -1294,7 +1282,6 @@ } Constant* JavaAOTCompiler::CreateConstantFromVT(JavaVirtualTable* VT) { - Module& Mod = *getLLVMModule(); CommonClass* classDef = VT->cl; uint32 size = classDef->isClass() ? classDef->asClass()->virtualTableSize : JavaVirtualTable::getBaseSize(); @@ -1360,7 +1347,7 @@ Temp = ConstantExpr::getBitCast(Temp, PTy); Elemts.push_back(Temp); } else { - Elemts.push_back(Mod.getContext().getNullValue(PTy)); + Elemts.push_back(Constant::getNullValue(PTy)); } } @@ -1395,7 +1382,7 @@ Temp = ConstantExpr::getBitCast(Temp, PTy); Elemts.push_back(Temp); } else { - Elemts.push_back(Mod.getContext().getNullValue(PTy)); + Elemts.push_back(Constant::getNullValue(PTy)); } @@ -1405,7 +1392,7 @@ LLVMMethodInfo* LMI = getMethodInfo(meth); Function* F = LMI->getMethod(); if (isAbstract(meth->access)) { - Elemts.push_back(Mod.getContext().getNullValue(PTy)); + Elemts.push_back(Constant::getNullValue(PTy)); } else { Elemts.push_back(ConstantExpr::getCast(Instruction::BitCast, F, PTy)); } Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp?rev=77970&r1=77969&r2=77970&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp Mon Aug 3 04:26:51 2009 @@ -255,7 +255,7 @@ currentBlock = createBasicBlock("start"); CallInst::Create(module->ThrowExceptionFromJITFunction, "", currentBlock); if (returnType != Type::VoidTy) - ReturnInst::Create(llvmContext->getNullValue(returnType), currentBlock); + ReturnInst::Create(Constant::getNullValue(returnType), currentBlock); else ReturnInst::Create(currentBlock); @@ -302,7 +302,7 @@ if (returnType != Type::VoidTy) { endNode = PHINode::Create(returnType, "", endBlock); - endNode->addIncoming(llvmContext->getNullValue(returnType), + endNode->addIncoming(Constant::getNullValue(returnType), currentBlock); } @@ -352,7 +352,7 @@ test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, i, module->JavaObjectNullConstant, ""); - node->addIncoming(llvmContext->getNullValue(Ty), currentBlock); + node->addIncoming(Constant::getNullValue(Ty), currentBlock); BranchInst::Create(BB, NotZero, test, currentBlock); currentBlock = NotZero; @@ -395,7 +395,7 @@ PHINode* node = PHINode::Create(Ty, "", endBlock); node->addIncoming(test, currentBlock); Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, test, - llvmContext->getNullValue(Ty), ""); + Constant::getNullValue(Ty), ""); BranchInst::Create(unloadedBlock, endBlock, cmp, currentBlock); currentBlock = unloadedBlock; @@ -430,7 +430,7 @@ if (returnType == module->JavaObjectType) { const Type* Ty = PointerType::getUnqual(module->JavaObjectType); - Constant* C = llvmContext->getNullValue(Ty); + Constant* C = Constant::getNullValue(Ty); Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, result, C, ""); BasicBlock* loadBlock = createBasicBlock(""); @@ -1105,11 +1105,11 @@ if (isa(I)) { I->eraseFromParent(); BranchInst::Create(endBlock, currentBlock); - endNode->addIncoming(llvmContext->getNullValue(returnType), + endNode->addIncoming(Constant::getNullValue(returnType), currentBlock); } else if (InvokeInst* II = dyn_cast(I)) { II->setNormalDest(endBlock); - endNode->addIncoming(llvmContext->getNullValue(returnType), + endNode->addIncoming(Constant::getNullValue(returnType), currentBlock); } @@ -1360,27 +1360,27 @@ switch (*i) { case Int : { PHINode* node = PHINode::Create(Type::Int32Ty, "", dest); - node->addIncoming(llvmContext->getNullValue(Type::Int32Ty), insert); + node->addIncoming(Constant::getNullValue(Type::Int32Ty), insert); break; } case Float : { PHINode* node = PHINode::Create(Type::FloatTy, "", dest); - node->addIncoming(llvmContext->getNullValue(Type::FloatTy), insert); + node->addIncoming(Constant::getNullValue(Type::FloatTy), insert); break; } case Double : { PHINode* node = PHINode::Create(Type::DoubleTy, "", dest); - node->addIncoming(llvmContext->getNullValue(Type::DoubleTy), insert); + node->addIncoming(Constant::getNullValue(Type::DoubleTy), insert); break; } case Long : { PHINode* node = PHINode::Create(Type::Int64Ty, "", dest); - node->addIncoming(llvmContext->getNullValue(Type::Int64Ty), insert); + node->addIncoming(Constant::getNullValue(Type::Int64Ty), insert); break; } case Object : { PHINode* node = PHINode::Create(module->JavaObjectType, "", dest); - node->addIncoming(llvmContext->getNullValue(module->JavaObjectType), + node->addIncoming(Constant::getNullValue(module->JavaObjectType), insert); break; } @@ -1391,7 +1391,7 @@ } else { for (BasicBlock::iterator i = dest->begin(), e = dest->end(); i != e; ++i) { if (PHINode* node = dyn_cast(i)) { - node->addIncoming(llvmContext->getNullValue(node->getType()), insert); + node->addIncoming(Constant::getNullValue(node->getType()), insert); } else { break; } @@ -1558,7 +1558,7 @@ #if defined(ISOLATE_SHARING) const Type* Ty = module->ConstantPoolType; - Constant* Nil = llvmContext->getNullValue(Ty); + Constant* Nil = Constant::getNullValue(Ty); GlobalVariable* GV = new GlobalVariable(Ty, false, GlobalValue::ExternalLinkage, Nil, "", module); Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp?rev=77970&r1=77969&r2=77970&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp Mon Aug 3 04:26:51 2009 @@ -174,7 +174,7 @@ } JavaObjectNullConstant = - module->getContext().getNullValue(JnjvmModule::JavaObjectType); + Constant::getNullValue(JnjvmModule::JavaObjectType); MaxArraySizeConstant = ConstantInt::get(Type::Int32Ty, JavaArray::MaxArraySize); JavaArraySizeConstant = Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=77970&r1=77969&r2=77970&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Mon Aug 3 04:26:51 2009 @@ -94,7 +94,6 @@ module->setDataLayout(globalModule->getDataLayout()); module->setTargetTriple(globalModule->getTargetTriple()); - LLVMContext* globalContext = &(module->getContext()); // Constant declaration @@ -144,7 +143,7 @@ constantPtrOne = ConstantInt::get(pointerSizeType, 1); constantPtrZero = ConstantInt::get(pointerSizeType, 0); - constantPtrNull = globalContext->getNullValue(ptrType); + constantPtrNull = Constant::getNullValue(ptrType); constantPtrLogSize = ConstantInt::get(Type::Int32Ty, sizeof(void*) == 8 ? 3 : 2); arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::Int8Ty, 0)); From nicolas.geoffray at lip6.fr Mon Aug 3 14:18:35 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 03 Aug 2009 21:18:35 -0000 Subject: [vmkit-commits] [vmkit] r77997 - /vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp Message-ID: <200908032118.n73LIbwH026094@zion.cs.uiuc.edu> Author: geoffray Date: Mon Aug 3 16:18:27 2009 New Revision: 77997 URL: http://llvm.org/viewvc/llvm-project?rev=77997&view=rev Log: Move to new llvm API. Modified: vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp Modified: vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp?rev=77997&r1=77996&r2=77997&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp Mon Aug 3 16:18:27 2009 @@ -134,7 +134,7 @@ Value* Arg = Cmp->getOperand(0); if (isVirtual(meth->access) && Arg == F.arg_begin()) { Changed = true; - Cmp->replaceAllUsesWith(Context->getFalse()); + Cmp->replaceAllUsesWith(ConstantInt::getFalse(*Context)); Cmp->eraseFromParent(); break; } @@ -143,7 +143,7 @@ Instruction* CI = Ca.getInstruction(); if (CI && Ca.getCalledValue() == module->JavaObjectAllocateFunction) { Changed = true; - Cmp->replaceAllUsesWith(Context->getFalse()); + Cmp->replaceAllUsesWith(ConstantInt::getFalse(*Context)); Cmp->eraseFromParent(); break; } @@ -474,13 +474,13 @@ } else if (V == module->GetArrayClassFunction) { const llvm::Type* Ty = PointerType::getUnqual(module->JavaCommonClassType); - Constant* nullValue = Context->getNullValue(Ty); + Constant* nullValue = Constant::getNullValue(Ty); // Check if we have already proceed this call. if (Call.getArgument(1) == nullValue) { BasicBlock* NBB = II->getParent()->splitBasicBlock(II); I->getParent()->getTerminator()->eraseFromParent(); - Constant* init = Context->getNullValue(module->JavaClassArrayType); + Constant* init = Constant::getNullValue(module->JavaClassArrayType); GlobalVariable* GV = new GlobalVariable(*(F.getParent()), module->JavaClassArrayType, false, GlobalValue::ExternalLinkage, @@ -552,7 +552,7 @@ Value* res = new ICmpInst(CI, ICmpInst::ICMP_EQ, CurVT, VT2, ""); - node->addIncoming(Context->getTrue(), CI->getParent()); + node->addIncoming(ConstantInt::getTrue(*Context), CI->getParent()); BranchInst::Create(CurEndBlock, FailedBlock, res, CI); Value* Args[2] = { VT1, VT2 }; @@ -671,9 +671,9 @@ // Final block, that gets the result. PHINode* node = PHINode::Create(Type::Int1Ty, "", BB9); node->reserveOperandSpace(3); - node->addIncoming(Context->getTrue(), CI->getParent()); - node->addIncoming(Context->getFalse(), BB7); - node->addIncoming(Context->getTrue(), BB5); + node->addIncoming(ConstantInt::getTrue(*Context), CI->getParent()); + node->addIncoming(ConstantInt::getFalse(*Context), BB7); + node->addIncoming(ConstantInt::getTrue(*Context), BB5); // Don't forget to jump to the next block. BranchInst::Create(EndBlock, BB9); From nicolas.geoffray at lip6.fr Tue Aug 4 06:46:26 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 04 Aug 2009 13:46:26 -0000 Subject: [vmkit-commits] [vmkit] r78062 - /vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Message-ID: <200908041346.n74DkTT6005956@zion.cs.uiuc.edu> Author: geoffray Date: Tue Aug 4 08:46:15 2009 New Revision: 78062 URL: http://llvm.org/viewvc/llvm-project?rev=78062&view=rev Log: Move to new LLVM API. Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp?rev=78062&r1=78061&r2=78062&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Tue Aug 4 08:46:15 2009 @@ -1549,7 +1549,7 @@ Value* op = pop(); const Type* type = op->getType(); - Constant* val = llvmContext->getNullValue(type); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, op, val, ""); BasicBlock* ifFalse = createBasicBlock("false IFEQ"); @@ -1564,7 +1564,7 @@ Value* op = pop(); const Type* type = op->getType(); - Constant* val = llvmContext->getNullValue(type); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, op, val, ""); BasicBlock* ifFalse = createBasicBlock("false IFNE"); @@ -1578,7 +1578,7 @@ BasicBlock* ifTrue = opcodeInfos[tmp + readS2(bytecodes, i)].newBlock; Value* op = pop(); const Type* type = op->getType(); - Constant* val = llvmContext->getNullValue(type); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT, op, val, ""); BasicBlock* ifFalse = createBasicBlock("false IFLT"); @@ -1592,7 +1592,7 @@ BasicBlock* ifTrue = opcodeInfos[tmp + readS2(bytecodes, i)].newBlock; Value* op = pop(); const Type* type = op->getType(); - Constant* val = llvmContext->getNullValue(type); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGE, op, val, ""); BasicBlock* ifFalse = createBasicBlock("false IFGE"); @@ -1606,7 +1606,7 @@ BasicBlock* ifTrue = opcodeInfos[tmp + readS2(bytecodes, i)].newBlock; Value* op = pop(); const Type* type = op->getType(); - Constant* val = llvmContext->getNullValue(type); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGT, op, val, ""); BasicBlock* ifFalse = createBasicBlock("false IFGT"); @@ -1620,7 +1620,7 @@ BasicBlock* ifTrue = opcodeInfos[tmp + readS2(bytecodes, i)].newBlock; Value* op = pop(); const Type* type = op->getType(); - Constant* val = llvmContext->getNullValue(type); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLE, op, val, ""); BasicBlock* ifFalse = createBasicBlock("false IFLE"); @@ -1975,7 +1975,7 @@ } else { const llvm::Type* Ty = PointerType::getUnqual(module->JavaClassArrayType); - Value* args[2]= { valCl, llvmContext->getNullValue(Ty) }; + Value* args[2]= { valCl, Constant::getNullValue(Ty) }; valCl = CallInst::Create(module->GetArrayClassFunction, args, args + 2, "", currentBlock); TheVT = CallInst::Create(module->GetVTFromClassArrayFunction, valCl, "", @@ -2084,7 +2084,7 @@ } else { BasicBlock* ifFalse = createBasicBlock("false type compare"); BranchInst::Create(endBlock, ifFalse, cmp, currentBlock); - node->addIncoming(llvmContext->getFalse(), currentBlock); + node->addIncoming(ConstantInt::getFalse(*llvmContext), currentBlock); currentBlock = ifFalse; } @@ -2188,7 +2188,7 @@ case IFNULL : { uint32 tmp = i; llvm::Value* val = pop(); - Constant* nil = llvmContext->getNullValue(val->getType()); + Constant* nil = Constant::getNullValue(val->getType()); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, nil, ""); BasicBlock* ifFalse = createBasicBlock("true IFNULL"); @@ -2201,7 +2201,7 @@ case IFNONNULL : { uint32 tmp = i; llvm::Value* val = pop(); - Constant* nil = llvmContext->getNullValue(val->getType()); + Constant* nil = Constant::getNullValue(val->getType()); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, val, nil, ""); BasicBlock* ifFalse = createBasicBlock("false IFNONNULL"); From nicolas.geoffray at lip6.fr Tue Aug 4 08:22:28 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 04 Aug 2009 15:22:28 -0000 Subject: [vmkit-commits] [vmkit] r78063 - in /vmkit/trunk: include/jnjvm/JnjvmModule.h include/jnjvm/JnjvmModuleProvider.h lib/JnJVM/Compiler/JITInfo.cpp lib/JnJVM/Compiler/JavaJITCompiler.cpp lib/JnJVM/Compiler/JnjvmModule.cpp lib/JnJVM/Compiler/JnjvmModuleProvider.cpp lib/JnJVM/Compiler/LowerConstantCalls.cpp Message-ID: <200908041522.n74FMTWi008883@zion.cs.uiuc.edu> Author: geoffray Date: Tue Aug 4 10:22:20 2009 New Revision: 78063 URL: http://llvm.org/viewvc/llvm-project?rev=78063&view=rev Log: Use maps instead of annotations to find JavaMethod out of a llvm::Function. Modified: vmkit/trunk/include/jnjvm/JnjvmModule.h vmkit/trunk/include/jnjvm/JnjvmModuleProvider.h vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp Modified: vmkit/trunk/include/jnjvm/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/jnjvm/JnjvmModule.h?rev=78063&r1=78062&r2=78063&view=diff ============================================================================== --- vmkit/trunk/include/jnjvm/JnjvmModule.h (original) +++ vmkit/trunk/include/jnjvm/JnjvmModule.h Tue Aug 4 10:22:20 2009 @@ -16,8 +16,6 @@ #include "mvm/Allocator.h" #include "mvm/JIT.h" -#include "llvm/Support/Annotation.h" - #include "JavaCompiler.h" namespace llvm { @@ -102,7 +100,7 @@ } }; -class LLVMMethodInfo : public mvm::JITInfo, private llvm::Annotation { +class LLVMMethodInfo : public mvm::JITInfo { private: JavaMethod* methodDef; @@ -110,15 +108,16 @@ llvm::Constant* offsetConstant; const llvm::FunctionType* functionType; + public: llvm::Function* getMethod(); llvm::Constant* getOffset(); const llvm::FunctionType* getFunctionType(); - LLVMMethodInfo(JavaMethod* M); + LLVMMethodInfo(JavaMethod* M) : methodDef(M), methodFunction(0), + offsetConstant(0), functionType(0) {} + - static JavaMethod* get(const llvm::Function* F); - virtual void clear() { methodFunction = 0; offsetConstant = 0; @@ -126,6 +125,7 @@ } }; + class LLVMFieldInfo : public mvm::JITInfo { private: JavaField* fieldDef; @@ -361,6 +361,7 @@ class JavaLLVMCompiler : public JavaCompiler { friend class LLVMClassInfo; + friend class LLVMMethodInfo; protected: @@ -379,10 +380,11 @@ virtual void makeVT(Class* cl) = 0; - + std::map functions; + typedef std::map::iterator function_iterator; public: - + JavaLLVMCompiler(const std::string &ModuleID); virtual bool isStaticCompiling() = 0; @@ -416,6 +418,9 @@ virtual ~JavaLLVMCompiler(); + + JavaMethod* getJavaMethod(llvm::Function*); + void resolveVirtualClass(Class* cl); void resolveStaticClass(Class* cl); static llvm::Function* getMethod(JavaMethod* meth); @@ -477,9 +482,25 @@ }; +struct CallbackInfo { + Class* cl; + uint16 index; + bool stat; + + CallbackInfo(Class* c, uint32 i, bool s) : + cl(c), index(i), stat(s) {} + +}; + + class JavaJITCompiler : public JavaLLVMCompiler { public: + std::map callbacks; + + typedef std::map::iterator callback_iterator; + + bool EmitFunctionName; JavaJITCompiler(const std::string &ModuleID); Modified: vmkit/trunk/include/jnjvm/JnjvmModuleProvider.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/jnjvm/JnjvmModuleProvider.h?rev=78063&r1=78062&r2=78063&view=diff ============================================================================== --- vmkit/trunk/include/jnjvm/JnjvmModuleProvider.h (original) +++ vmkit/trunk/include/jnjvm/JnjvmModuleProvider.h Tue Aug 4 10:22:20 2009 @@ -14,10 +14,14 @@ namespace jnjvm { +class JavaJITCompiler; + class JnjvmModuleProvider : public llvm::ModuleProvider { public: - - JnjvmModuleProvider(llvm::Module* M); + + JavaJITCompiler* Comp; + + JnjvmModuleProvider(llvm::Module* M, JavaJITCompiler* C); ~JnjvmModuleProvider(); bool materializeFunction(llvm::Function *F, std::string *ErrInfo = 0); Modified: vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp?rev=78063&r1=78062&r2=78063&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp Tue Aug 4 10:22:20 2009 @@ -165,7 +165,7 @@ "", Mod->getLLVMModule()); } - methodFunction->addAnnotation(this); + Mod->functions.insert(std::make_pair(methodFunction, methodDef)); } return methodFunction; } @@ -599,20 +599,6 @@ return LLVMAssessorInfo::AssessorInfo[type->getKey()->elements[0]]; } -static AnnotationID JavaMethod_ID( - AnnotationManager::getID("Java::JavaMethod")); - - -LLVMMethodInfo::LLVMMethodInfo(JavaMethod* M) : - llvm::Annotation(JavaMethod_ID), methodDef(M), methodFunction(0), - offsetConstant(0), functionType(0) {} - -JavaMethod* LLVMMethodInfo::get(const llvm::Function* F) { - LLVMMethodInfo *MI = (LLVMMethodInfo*)F->getAnnotation(JavaMethod_ID); - if (MI) return MI->methodDef; - return 0; -} - LLVMSignatureInfo* JavaLLVMCompiler::getSignatureInfo(Signdef* sign) { return sign->getInfo(); } Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp?rev=78063&r1=78062&r2=78063&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp Tue Aug 4 10:22:20 2009 @@ -144,7 +144,7 @@ #else EmitFunctionName = false; #endif - TheModuleProvider = new JnjvmModuleProvider(TheModule); + TheModuleProvider = new JnjvmModuleProvider(TheModule, this); addJavaPasses(); } Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp?rev=78063&r1=78062&r2=78063&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp Tue Aug 4 10:22:20 2009 @@ -348,6 +348,13 @@ return func; } +JavaMethod* JavaLLVMCompiler::getJavaMethod(llvm::Function* F) { + function_iterator E = functions.end(); + function_iterator I = functions.find(F); + if (I == E) return 0; + return I->second; +} + JavaLLVMCompiler::~JavaLLVMCompiler() { delete JavaFunctionPasses; delete JavaNativeFunctionPasses; @@ -360,7 +367,7 @@ } namespace jnjvm { - llvm::FunctionPass* createLowerConstantCallsPass(); + llvm::FunctionPass* createLowerConstantCallsPass(JnjvmModule* M); } void JavaLLVMCompiler::addJavaPasses() { @@ -368,7 +375,7 @@ JavaNativeFunctionPasses->add(new TargetData(TheModule)); // Lower constant calls to lower things like getClass used // on synchronized methods. - JavaNativeFunctionPasses->add(createLowerConstantCallsPass()); + JavaNativeFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics())); JavaFunctionPasses = new FunctionPassManager(TheModuleProvider); JavaFunctionPasses->add(new TargetData(TheModule)); @@ -376,5 +383,5 @@ JavaFunctionPasses->add(mvm::createLoopSafePointsPass()); JavaFunctionPasses->add(mvm::createEscapeAnalysisPass()); - JavaFunctionPasses->add(createLowerConstantCallsPass()); + JavaFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics())); } Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp?rev=78063&r1=78062&r2=78063&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Tue Aug 4 10:22:20 2009 @@ -27,25 +27,10 @@ using namespace jnjvm; -static AnnotationID JavaCallback_ID( - AnnotationManager::getID("Java::Callback")); - -class CallbackInfo: public Annotation { -public: - Class* cl; - uint16 index; - bool stat; - - CallbackInfo(Class* c, uint32 i, bool s) : Annotation(JavaCallback_ID), - cl(c), index(i), stat(s) {} -}; - -static JavaMethod* staticLookup(Function* F) { - CallbackInfo* CI = (CallbackInfo*)F->getAnnotation(JavaCallback_ID); - assert(CI && "No callback where there should be one"); - Class* caller = CI->cl; - uint16 index = CI->index; - bool isStatic = CI->stat; +static JavaMethod* staticLookup(CallbackInfo& F) { + Class* caller = F.cl; + uint16 index = F.index; + bool isStatic = F.stat; JavaConstantPool* ctpInfo = caller->getConstantPool(); CommonClass* cl = 0; @@ -67,7 +52,7 @@ Function* JavaJITCompiler::addCallback(Class* cl, uint16 index, Signdef* sign, bool stat) { - Function* func = 0; + Function* F = 0; LLVMSignatureInfo* LSI = getSignatureInfo(sign); const UTF8* name = cl->name; @@ -75,18 +60,18 @@ for (sint32 i = 0; i < name->size; ++i) key[i] = name->elements[i]; sprintf(key + name->size, "%d", index); - Function* F = TheModule->getFunction(key); + F = TheModule->getFunction(key); if (F) return F; const FunctionType* type = stat ? LSI->getStaticType() : LSI->getVirtualType(); - func = Function::Create(type, GlobalValue::GhostLinkage, key, TheModule); + F = Function::Create(type, GlobalValue::GhostLinkage, key, TheModule); - CallbackInfo* A = new CallbackInfo(cl, index, stat); - func->addAnnotation(A); + CallbackInfo A(cl, index, stat); + callbacks.insert(std::make_pair(F, A)); - return func; + return F; } @@ -99,11 +84,13 @@ if (mvm::MvmModule::executionEngine->getPointerToGlobalIfAvailable(F)) return false; - JavaMethod* meth = LLVMMethodInfo::get(F); + JavaMethod* meth = Comp->getJavaMethod(F); if (!meth) { // It's a callback - meth = staticLookup(F); + JavaJITCompiler::callback_iterator I = Comp->callbacks.find(F); + assert(I != Comp->callbacks.end() && "No callbacks found"); + meth = staticLookup(I->second); } void* val = meth->compiledPtr(); @@ -130,7 +117,9 @@ return false; } -JnjvmModuleProvider::JnjvmModuleProvider(llvm::Module* m) { +JnjvmModuleProvider::JnjvmModuleProvider(llvm::Module* m, + JavaJITCompiler* C) { + Comp = C; TheModule = m; JnjvmModule::protectEngine.lock(); JnjvmModule::executionEngine->addModuleProvider(this); Modified: vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp?rev=78063&r1=78062&r2=78063&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp Tue Aug 4 10:22:20 2009 @@ -26,14 +26,19 @@ class VISIBILITY_HIDDEN LowerConstantCalls : public FunctionPass { public: static char ID; - LowerConstantCalls() : FunctionPass((intptr_t)&ID) { } + JnjvmModule* module; + LowerConstantCalls(JnjvmModule* M) : FunctionPass((intptr_t)&ID), + module(M) { } virtual bool runOnFunction(Function &F); private: }; char LowerConstantCalls::ID = 0; + +#if 0 static RegisterPass X("LowerConstantCalls", "Lower Constant calls"); +#endif #ifdef ISOLATE @@ -117,10 +122,6 @@ #endif bool LowerConstantCalls::runOnFunction(Function& F) { - JavaMethod* meth = LLVMMethodInfo::get(&F); - JavaLLVMCompiler* TheCompiler = - (JavaLLVMCompiler*)meth->classDef->classLoader->getCompiler(); - JnjvmModule* module = TheCompiler->getIntrinsics(); LLVMContext* Context = &F.getContext(); bool Changed = false; for (Function::iterator BI = F.begin(), BE = F.end(); BI != BE; BI++) { @@ -132,12 +133,16 @@ if (ICmpInst* Cmp = dyn_cast(I)) { if (Cmp->getOperand(1) == module->JavaObjectNullConstant) { Value* Arg = Cmp->getOperand(0); + +#if 0 + // Re-enable this once we can get access of the JavaMethod again. if (isVirtual(meth->access) && Arg == F.arg_begin()) { Changed = true; Cmp->replaceAllUsesWith(ConstantInt::getFalse(*Context)); Cmp->eraseFromParent(); break; } +#endif CallSite Ca = CallSite::get(Arg); Instruction* CI = Ca.getInstruction(); @@ -735,8 +740,8 @@ } -FunctionPass* createLowerConstantCallsPass() { - return new LowerConstantCalls(); +FunctionPass* createLowerConstantCallsPass(JnjvmModule* M) { + return new LowerConstantCalls(M); } } From nicolas.geoffray at lip6.fr Tue Aug 4 08:33:19 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 04 Aug 2009 15:33:19 -0000 Subject: [vmkit-commits] [vmkit] r78064 - in /vmkit/trunk/lib/N3/VMCore: CLIJit.cpp CLIJit.h Opcodes.cpp Message-ID: <200908041533.n74FXKcK009171@zion.cs.uiuc.edu> Author: geoffray Date: Tue Aug 4 10:33:11 2009 New Revision: 78064 URL: http://llvm.org/viewvc/llvm-project?rev=78064&view=rev Log: Move to new LLVM API and use maps instead of annotations to attach per-function information. Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp vmkit/trunk/lib/N3/VMCore/CLIJit.h vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=78064&r1=78063&r2=78064&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Tue Aug 4 10:33:11 2009 @@ -744,7 +744,7 @@ } else { type = field->signature->naturalType; if (val == constantVMObjectNull) { - val = llvmFunction->getContext().getNullValue(type); + val = Constant::getNullValue(type); } else if (type != valType) { val = changeType(val, type); } @@ -770,7 +770,7 @@ const Type* type = field->signature->naturalType; const Type* valType = val->getType(); if (val == constantVMObjectNull) { - val = llvmFunction->getContext().getNullValue(type); + val = Constant::getNullValue(type); } else if (type != valType) { val = changeType(val, type); } @@ -779,7 +779,7 @@ void CLIJit::JITVerifyNull(Value* obj) { CLIJit* jit = this; - Constant* zero = llvmFunction->getContext().getNullValue(obj->getType()); + Constant* zero = Constant::getNullValue(obj->getType()); Value* test = new ICmpInst(*jit->currentBlock, ICmpInst::ICMP_EQ, obj, zero, ""); @@ -1224,7 +1224,7 @@ cl->resolveType(false, false, genMethod); AllocaInst* alloc = new AllocaInst(cl->naturalType, "", currentBlock); if (cl->naturalType->isSingleValueType()) { - new StoreInst(llvmFunction->getContext().getNullValue(cl->naturalType), alloc, false, + new StoreInst(Constant::getNullValue(cl->naturalType), alloc, false, currentBlock); } else { uint64 size = module->getTypeSize(cl->naturalType); @@ -1401,7 +1401,7 @@ cl->resolveType(false, false, genMethod); AllocaInst* alloc = new AllocaInst(cl->naturalType, "", currentBlock); if (cl->naturalType->isSingleValueType()) { - new StoreInst(llvmFunction->getContext().getNullValue(cl->naturalType), alloc, false, + new StoreInst(Constant::getNullValue(cl->naturalType), alloc, false, currentBlock); } else { uint64 size = module->getTypeSize(cl->naturalType); @@ -1464,17 +1464,6 @@ return func; } -static AnnotationID CLIMethod_ID( - AnnotationManager::getID("CLI::VMMethod")); - - -class N3Annotation: public llvm::Annotation { -public: - VMMethod* meth; - - N3Annotation(VMMethod* M) : llvm::Annotation(CLIMethod_ID), meth(M) {} -}; - llvm::Function *VMMethod::compiledPtr(VMGenericMethod* genMethod) { if (methPtr != 0) return methPtr; @@ -1484,18 +1473,15 @@ methPtr = Function::Create(getSignature(genMethod), GlobalValue::GhostLinkage, printString(), classDef->vm->getLLVMModule()); classDef->vm->functions->hash(methPtr, this); - N3Annotation* A = new N3Annotation(this); - methPtr->addAnnotation(A); } classDef->release(); return methPtr; } } -VMMethod* CLIJit::getMethod(const llvm::Function* F) { - N3Annotation* A = (N3Annotation*)F->getAnnotation(CLIMethod_ID); - if (A) return A->meth; - return 0; +VMMethod* CLIJit::getMethod(llvm::Function* F) { + VMMethod* meth = VMThread::get()->vm->functions->lookup(F); + return meth; } void VMField::initField(VMObject* obj) { @@ -1602,7 +1588,7 @@ - constantVMObjectNull = module->getContext().getNullValue(VMObject::llvmType); + constantVMObjectNull = Constant::getNullValue(VMObject::llvmType); } Constant* CLIJit::constantVMObjectNull; Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.h?rev=78064&r1=78063&r2=78064&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJit.h (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJit.h Tue Aug 4 10:33:11 2009 @@ -222,7 +222,7 @@ llvm::Instruction* invokeInline(VMMethod* meth, std::vector& args, VMGenericClass* genClass, VMGenericMethod* genMethod); - static VMMethod* getMethod(const llvm::Function* F); + static VMMethod* getMethod(llvm::Function* F); }; enum Opcode { Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=78064&r1=78063&r2=78064&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Tue Aug 4 10:33:11 2009 @@ -341,7 +341,7 @@ #define TEST(name, read, cmpf, cmpi, offset) case name : { \ uint32 tmp = i; \ Value* val2 = pop(); \ - Value* val1 = llvmFunction->getContext().getNullValue(val2->getType()); \ + Value* val1 = Constant::getNullValue(val2->getType()); \ BasicBlock* ifTrue = opcodeInfos[tmp + offset + read(bytecodes, i)].newBlock; \ Value* test = 0; \ if (val1->getType()->isFloatingPoint()) { \ @@ -1020,7 +1020,7 @@ case NEG : { Value* val = pop(); push(BinaryOperator::CreateSub( - llvmFunction->getContext().getNullValue(val->getType()), + Constant::getNullValue(val->getType()), val, "", currentBlock)); break; } @@ -1383,8 +1383,8 @@ Value* obj = pop(); Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj, - llvmFunction->getContext().getNullValue(obj->getType()), ""); - Constant* nullVirtual = llvmFunction->getContext().getNullValue(dcl->virtualType); + Constant::getNullValue(obj->getType()), ""); + Constant* nullVirtual = Constant::getNullValue(dcl->virtualType); BasicBlock* isInstEndBlock = createBasicBlock("end isinst"); From nicolas.geoffray at lip6.fr Tue Aug 4 10:07:30 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 04 Aug 2009 17:07:30 -0000 Subject: [vmkit-commits] [vmkit] r78080 - in /vmkit/trunk: include/mvm/JIT.h lib/JnJVM/Compiler/JavaJIT.cpp lib/JnJVM/Compiler/JavaJITCompiler.cpp lib/JnJVM/Compiler/JnjvmModule.cpp lib/JnJVM/Compiler/JnjvmModuleProvider.cpp lib/Mvm/Compiler/JIT.cpp Message-ID: <200908041707.n74H7Vkm012569@zion.cs.uiuc.edu> Author: geoffray Date: Tue Aug 4 12:07:28 2009 New Revision: 78080 URL: http://llvm.org/viewvc/llvm-project?rev=78080&view=rev Log: Wrap the llvm JIT lock with an internal VMKit lock. From now on, the JIT lock can not be used while vmkit is working and potentially using other locks. The VMKit lock must be held before jitting a function, both in llvm and vmkit. Modified: vmkit/trunk/include/mvm/JIT.h vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Modified: vmkit/trunk/include/mvm/JIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=78080&r1=78079&r2=78080&view=diff ============================================================================== --- vmkit/trunk/include/mvm/JIT.h (original) +++ vmkit/trunk/include/mvm/JIT.h Tue Aug 4 12:07:28 2009 @@ -169,7 +169,7 @@ static const llvm::Type* pointerSizeType; static llvm::ExecutionEngine* executionEngine; - static mvm::LockNormal protectEngine; + static mvm::LockRecursive protectEngine; static llvm::Module *globalModule; static llvm::ExistingModuleProvider *globalModuleProvider; static llvm::FunctionPassManager* globalFunctionPasses; Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp?rev=78080&r1=78079&r2=78080&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp Tue Aug 4 12:07:28 2009 @@ -263,7 +263,6 @@ UTF8Buffer(compilingClass->name).cString(), UTF8Buffer(compilingMethod->name).cString()); - llvmFunction->setLinkage(GlobalValue::ExternalLinkage); return llvmFunction; } @@ -466,7 +465,6 @@ UTF8Buffer(compilingClass->name).cString(), UTF8Buffer(compilingMethod->name).cString()); - func->setLinkage(GlobalValue::ExternalLinkage); return llvmFunction; } @@ -1175,8 +1173,6 @@ removeUnusedObjects(objectLocals, module, TheCompiler->useCooperativeGC()); removeUnusedObjects(objectStack, module, TheCompiler->useCooperativeGC()); - func->setLinkage(GlobalValue::ExternalLinkage); - PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "--> end compiling %s.%s\n", UTF8Buffer(compilingClass->name).cString(), UTF8Buffer(compilingMethod->name).cString()); Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp?rev=78080&r1=78079&r2=78080&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp Tue Aug 4 12:07:28 2009 @@ -207,9 +207,8 @@ } void* JavaJITCompiler::materializeFunction(JavaMethod* meth) { - Function* func = parseFunction(meth); - mvm::MvmModule::protectIR(); + Function* func = parseFunction(meth); void* res = mvm::MvmModule::executionEngine->getPointerToGlobal(func); func->deleteBody(); mvm::MvmModule::unprotectIR(); Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp?rev=78080&r1=78079&r2=78080&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp Tue Aug 4 12:07:28 2009 @@ -329,22 +329,23 @@ Function* JavaLLVMCompiler::parseFunction(JavaMethod* meth) { LLVMMethodInfo* LMI = getMethodInfo(meth); Function* func = LMI->getMethod(); + + // We are jitting. Take the lock. + JnjvmModule::protectIR(); if (func->hasNotBeenReadFromBitcode()) { - // We are jitting. Take the lock. - JnjvmModule::protectIR(); - if (func->hasNotBeenReadFromBitcode()) { - JavaJIT jit(this, meth, func); - if (isNative(meth->access)) { - jit.nativeCompile(); - JnjvmModule::runPasses(func, JavaNativeFunctionPasses); - } else { - jit.javaCompile(); - JnjvmModule::runPasses(func, JnjvmModule::globalFunctionPasses); - JnjvmModule::runPasses(func, JavaFunctionPasses); - } + JavaJIT jit(this, meth, func); + if (isNative(meth->access)) { + jit.nativeCompile(); + JnjvmModule::runPasses(func, JavaNativeFunctionPasses); + } else { + jit.javaCompile(); + JnjvmModule::runPasses(func, JnjvmModule::globalFunctionPasses); + JnjvmModule::runPasses(func, JavaFunctionPasses); } - JnjvmModule::unprotectIR(); + func->setLinkage(GlobalValue::ExternalLinkage); } + JnjvmModule::unprotectIR(); + return func; } Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp?rev=78080&r1=78079&r2=78080&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Tue Aug 4 12:07:28 2009 @@ -78,11 +78,29 @@ bool JnjvmModuleProvider::materializeFunction(Function *F, std::string *ErrInfo) { - if (!(F->hasNotBeenReadFromBitcode())) + // The caller of materializeFunction *must* always hold the JIT lock. + // Because we are materializing a function here, we must release the + // JIT lock and get the global vmkit lock to be thread-safe. + // This prevents jitting the function while someone else is doing it. + mvm::MvmModule::executionEngine->lock.release(); + mvm::MvmModule::protectIR(); + + // Don't use hasNotBeenReadFromBitcode: materializeFunction is called + // by the pass manager, and we don't want another thread to JIT the + // function while all passes have not been run. + if (!(F->isDeclaration())) { + mvm::MvmModule::unprotectIR(); + // Reacquire and go back to the JIT function. + mvm::MvmModule::executionEngine->lock.acquire(); return false; - - if (mvm::MvmModule::executionEngine->getPointerToGlobalIfAvailable(F)) + } + + if (mvm::MvmModule::executionEngine->getPointerToGlobalIfAvailable(F)) { + mvm::MvmModule::unprotectIR(); + // Reacquire and go back to the JIT function. + mvm::MvmModule::executionEngine->lock.acquire(); return false; + } JavaMethod* meth = Comp->getJavaMethod(F); @@ -95,10 +113,6 @@ void* val = meth->compiledPtr(); - - if (F->isDeclaration()) - mvm::MvmModule::executionEngine->updateGlobalMapping(F, val); - if (isVirtual(meth->access)) { LLVMMethodInfo* LMI = JavaLLVMCompiler::getMethodInfo(meth); uint64_t offset = dyn_cast(LMI->getOffset())->getZExtValue(); @@ -114,6 +128,15 @@ assert(meth->classDef->isInitializing() && "Class not ready"); } + mvm::MvmModule::unprotectIR(); + + // Reacquire to go back to the JIT function. + mvm::MvmModule::executionEngine->lock.acquire(); + + if (F->isDeclaration()) + mvm::MvmModule::executionEngine->updateGlobalMapping(F, val); + + return false; } Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=78080&r1=78079&r2=78080&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Tue Aug 4 12:07:28 2009 @@ -227,7 +227,7 @@ llvm::ExistingModuleProvider *MvmModule::globalModuleProvider; llvm::FunctionPassManager* MvmModule::globalFunctionPasses; llvm::ExecutionEngine* MvmModule::executionEngine; -mvm::LockNormal MvmModule::protectEngine; +mvm::LockRecursive MvmModule::protectEngine; uint64 MvmModule::getTypeSize(const llvm::Type* type) { @@ -236,7 +236,13 @@ void MvmModule::runPasses(llvm::Function* func, llvm::FunctionPassManager* pm) { + // Take the lock because the pass manager will call materializeFunction. + // Our implementation of materializeFunction requires that the lock is held + // by the caller. This is due to LLVM's JIT subsystem where the call to + // materializeFunction is guarded. + if (executionEngine) executionEngine->lock.acquire(); pm->run(*func); + if (executionEngine) executionEngine->lock.release(); } static void addPass(FunctionPassManager *PM, Pass *P) { @@ -301,15 +307,14 @@ // codegen'ing a function may also create IR objects. void MvmModule::protectIR() { if (executionEngine) { - mvm::Thread* th = mvm::Thread::get(); - th->enterUncooperativeCode(); - executionEngine->lock.acquire(); - th->leaveUncooperativeCode(); + protectEngine.lock(); } } void MvmModule::unprotectIR() { - if (executionEngine) executionEngine->lock.release(); + if (executionEngine) { + protectEngine.unlock(); + } } From nicolas.geoffray at lip6.fr Tue Aug 4 15:21:54 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 04 Aug 2009 22:21:54 -0000 Subject: [vmkit-commits] [vmkit] r78112 - /vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Message-ID: <200908042222.n74MMJET022815@zion.cs.uiuc.edu> Author: geoffray Date: Tue Aug 4 17:20:39 2009 New Revision: 78112 URL: http://llvm.org/viewvc/llvm-project?rev=78112&view=rev Log: Call llvm_multithtreaded function when intializing LLVM. Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=78112&r1=78111&r2=78112&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Tue Aug 4 17:20:39 2009 @@ -48,6 +48,9 @@ void MvmModule::initialise(CodeGenOpt::Level level, Module* M, TargetMachine* T) { + + llvm_start_multithreaded(); + llvm::NoFramePointerElim = true; llvm::DisablePrettyStackTrace = true; #if DWARF_EXCEPTIONS From nicolas.geoffray at lip6.fr Wed Aug 5 02:58:34 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Wed, 05 Aug 2009 09:58:34 -0000 Subject: [vmkit-commits] [vmkit] r78186 - /vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Message-ID: <200908050958.n759wawk027583@zion.cs.uiuc.edu> Author: geoffray Date: Wed Aug 5 04:58:03 2009 New Revision: 78186 URL: http://llvm.org/viewvc/llvm-project?rev=78186&view=rev Log: Start looking at offset 0 instead of last offset when looking for a stack, so that we don't end up using all the virtual memory mapped for thread stacks. Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=78186&r1=78185&r2=78186&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original) +++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Wed Aug 5 04:58:03 2009 @@ -112,19 +112,18 @@ uintptr_t allocate() { stackLock.lock(); - uint32 start = allocPtr; uint32 myIndex = 0; do { - if (!used[allocPtr]) { - used[allocPtr] = 1; - myIndex = allocPtr; + if (!used[myIndex]) { + used[myIndex] = 1; + break; } - if (++allocPtr == NR_THREADS) allocPtr = 0; - } while (!myIndex && allocPtr != start); + ++myIndex; + } while (myIndex != NR_THREADS); stackLock.unlock(); - if (myIndex) + if (myIndex != NR_THREADS) return baseAddr + myIndex * STACK_SIZE; return 0; From nicolas.geoffray at lip6.fr Thu Aug 6 14:32:24 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 06 Aug 2009 21:32:24 -0000 Subject: [vmkit-commits] [vmkit] r78341 - in /vmkit/trunk/lib: JnJVM/Compiler/JITInfo.cpp JnJVM/Compiler/JavaAOTCompiler.cpp N3/VMCore/VMClass.cpp Message-ID: <200908062132.n76LWOmk011846@zion.cs.uiuc.edu> Author: geoffray Date: Thu Aug 6 16:32:24 2009 New Revision: 78341 URL: http://llvm.org/viewvc/llvm-project?rev=78341&view=rev Log: Move to new LLVM API. Modified: vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/N3/VMCore/VMClass.cpp Modified: vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp?rev=78341&r1=78340&r2=78341&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp Thu Aug 6 16:32:24 2009 @@ -44,7 +44,8 @@ const StructType* structType = 0; JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)classDef->classLoader->getCompiler(); - + LLVMContext& context = Mod->getLLVMModule()->getContext(); + if (classDef->super) { LLVMClassInfo* CLI = JavaLLVMCompiler::getClassInfo(classDef->super); const llvm::Type* Ty = CLI->getVirtualType()->getContainedType(0); @@ -59,7 +60,7 @@ } - structType = StructType::get(fields, false); + structType = StructType::get(context, fields, false); virtualType = PointerType::getUnqual(structType); sl = targetData->getStructLayout(structType); @@ -91,6 +92,10 @@ if (!staticType) { Class* cl = (Class*)classDef; std::vector fields; + + JavaLLVMCompiler* Mod = + (JavaLLVMCompiler*)classDef->classLoader->getCompiler(); + LLVMContext& context = Mod->getLLVMModule()->getContext(); for (uint32 i = 0; i < classDef->nbStaticFields; ++i) { JavaField& field = classDef->staticFields[i]; @@ -100,7 +105,7 @@ fields.push_back(LAI.llvmType); } - StructType* structType = StructType::get(fields, false); + StructType* structType = StructType::get(context, fields, false); staticType = PointerType::getUnqual(structType); const TargetData* targetData = JnjvmModule::TheTargetData; const StructLayout* sl = targetData->getStructLayout(structType); Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp?rev=78341&r1=78340&r2=78341&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp Thu Aug 6 16:32:24 2009 @@ -291,7 +291,7 @@ Elemts.push_back(JnjvmModule::JavaObjectType->getContainedType(0)); Elemts.push_back(JnjvmModule::pointerSizeType); Elemts.push_back(ATy); - Ty = StructType::get(Elemts); + Ty = StructType::get(getLLVMModule()->getContext(), Elemts); } else { LLVMClassInfo* LCI = getClassInfo(cl->asClass()); @@ -1212,7 +1212,7 @@ Elemts.push_back(ATy); - const StructType* STy = StructType::get(Elemts); + const StructType* STy = StructType::get(getLLVMModule()->getContext(), Elemts); std::vector Cts; Cts.push_back(CreateConstantForBaseObject(val->getClass())); @@ -1245,7 +1245,8 @@ Elemts.push_back(ATy); - const StructType* STy = StructType::get(Elemts); + const StructType* STy = StructType::get(getLLVMModule()->getContext(), + Elemts); std::vector Cts; Cts.push_back(ConstantInt::get(JnjvmModule::pointerSizeType, val->size)); Modified: vmkit/trunk/lib/N3/VMCore/VMClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.cpp?rev=78341&r1=78340&r2=78341&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/VMClass.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/VMClass.cpp Thu Aug 6 16:32:24 2009 @@ -287,7 +287,7 @@ fields.push_back((*i)->signature->naturalType); } - cl->staticType = llvm::PointerType::getUnqual(llvm::StructType::get(fields, false)); + cl->staticType = llvm::PointerType::getUnqual(llvm::StructType::get(vm->LLVMModule->getContext(), fields, false)); VirtualTable* VT = CLIJit::makeVT(cl, true); @@ -333,7 +333,7 @@ const llvm::Type* type = (*i)->signature->naturalType; Elts.push_back(type); } - ResultTy = llvm::StructType::get(Elts); + ResultTy = llvm::StructType::get(vm->LLVMModule->getContext(), Elts); } } else if (super == MSCorlib::pEnum) { ResultTy = llvm::Type::Int32Ty; // TODO find max @@ -347,7 +347,7 @@ const llvm::Type* type = (*i)->signature->naturalType; Elts.push_back(type); } - ResultTy = llvm::PointerType::getUnqual(llvm::StructType::get(Elts)); + ResultTy = llvm::PointerType::getUnqual(llvm::StructType::get(vm->LLVMModule->getContext(), Elts)); } } else { ResultTy = VMObject::llvmType; @@ -372,7 +372,7 @@ e = virtualFields.end(); i!= e; ++i) { Elts.push_back((*i)->signature->naturalType); } - virtualType = llvm::PointerType::getUnqual(llvm::StructType::get(Elts)); + virtualType = llvm::PointerType::getUnqual(llvm::StructType::get(vm->LLVMModule->getContext(), Elts)); } else { virtualType = naturalType; } @@ -386,7 +386,7 @@ arrayFields.push_back(VMObject::llvmType->getContainedType(0)); arrayFields.push_back(llvm::Type::Int32Ty); arrayFields.push_back(llvm::ArrayType::get(baseClass->naturalType, 0)); - const llvm::Type* type = llvm::PointerType::getUnqual(llvm::StructType::get(arrayFields, false)); + const llvm::Type* type = llvm::PointerType::getUnqual(llvm::StructType::get(vm->LLVMModule->getContext(), arrayFields, false)); ((llvm::OpaqueType*)naturalType)->refineAbstractTypeTo(type); naturalType = type; virtualType = naturalType; From nicolas.geoffray at lip6.fr Fri Aug 7 01:49:05 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 07 Aug 2009 08:49:05 -0000 Subject: [vmkit-commits] [vmkit] r78380 - in /vmkit/trunk/lib/JnJVM/Compiler: JavaAOTCompiler.cpp JavaJITOpcodes.cpp Message-ID: <200908070849.n778n51Y012829@zion.cs.uiuc.edu> Author: geoffray Date: Fri Aug 7 03:49:05 2009 New Revision: 78380 URL: http://llvm.org/viewvc/llvm-project?rev=78380&view=rev Log: Don't compile arrays during AOT, unless we're comiling rt.jar. Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp?rev=78380&r1=78379&r2=78380&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp Fri Aug 7 03:49:05 2009 @@ -39,7 +39,8 @@ // A class is being static compiled if owner class is not null. return cl->asClass()->getOwnerClass() != 0; } else if (cl->isArray()) { - return isCompiling(cl->asArrayClass()->baseClass()); + // Only compile an aray if we are compiling rt.jar. + return compileRT; } else if (cl->isPrimitive() && compileRT) { return true; } else { Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp?rev=78380&r1=78379&r2=78380&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Fri Aug 7 03:49:05 2009 @@ -2089,7 +2089,7 @@ } Value* TheVT = 0; - if (!cl) { + if (!cl || TheCompiler->isStaticCompiling()) { TheVT = CallInst::Create(module->GetVTFromCommonClassFunction, clVar, "", currentBlock); } else { From nicolas.geoffray at lip6.fr Fri Aug 7 10:09:03 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 07 Aug 2009 17:09:03 -0000 Subject: [vmkit-commits] [vmkit] r78386 - /vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Message-ID: <200908071709.n77H93LV013999@zion.cs.uiuc.edu> Author: geoffray Date: Fri Aug 7 12:09:02 2009 New Revision: 78386 URL: http://llvm.org/viewvc/llvm-project?rev=78386&view=rev Log: Workaround for a javac bug that may generated an unreachable return. Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp?rev=78386&r1=78385&r2=78386&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Fri Aug 7 12:09:02 2009 @@ -1856,9 +1856,15 @@ BranchInst::Create(endBlock, currentBlock); break; - case RETURN : + case RETURN : { + // Prevent a javac bug. + if (endNode != 0) { + endNode->addIncoming(Constant::getNullValue(endNode->getType()), + currentBlock); + } BranchInst::Create(endBlock, currentBlock); break; + } case GETSTATIC : { uint16 index = readU2(bytecodes, i); From nicolas.geoffray at lip6.fr Fri Aug 7 10:09:48 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 07 Aug 2009 17:09:48 -0000 Subject: [vmkit-commits] [vmkit] r78387 - in /vmkit/trunk: include/jnjvm/JnjvmModule.h lib/JnJVM/Compiler/JavaAOTCompiler.cpp lib/JnJVM/Compiler/JavaJIT.cpp lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Message-ID: <200908071709.n77H9nXd014128@zion.cs.uiuc.edu> Author: geoffray Date: Fri Aug 7 12:09:48 2009 New Revision: 78387 URL: http://llvm.org/viewvc/llvm-project?rev=78387&view=rev Log: For AOT, make staticCallback a unique function called by callbacks. Modified: vmkit/trunk/include/jnjvm/JnjvmModule.h vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Modified: vmkit/trunk/include/jnjvm/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/jnjvm/JnjvmModule.h?rev=78387&r1=78386&r2=78387&view=diff ============================================================================== --- vmkit/trunk/include/jnjvm/JnjvmModule.h (original) +++ vmkit/trunk/include/jnjvm/JnjvmModule.h Fri Aug 7 12:09:48 2009 @@ -459,8 +459,8 @@ llvm::FunctionPassManager* JavaFunctionPasses; llvm::FunctionPassManager* JavaNativeFunctionPasses; - virtual llvm::Function* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat) = 0; + virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, + bool stat) = 0; virtual void staticCallBuf(Signdef* sign) { getSignatureInfo(sign)->getStaticBuf(); @@ -545,8 +545,8 @@ virtual ~JavaJITCompiler() {} - virtual llvm::Function* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat); + virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, + bool stat); }; @@ -572,8 +572,8 @@ abort(); } - virtual llvm::Function* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat); + virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, + bool stat); virtual void makeVT(Class* cl); @@ -690,6 +690,7 @@ public: llvm::Function* StaticInitializer; llvm::Function* ObjectPrinter; + llvm::Function* Callback; bool generateStubs; bool assumeCompiled; Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp?rev=78387&r1=78386&r2=78387&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp Fri Aug 7 12:09:48 2009 @@ -1426,6 +1426,11 @@ StaticInitializer = Function::Create(FTy, GlobalValue::InternalLinkage, "Init", getLLVMModule()); + + llvmArgs.clear(); + FTy = FunctionType::get(Type::VoidTy, llvmArgs, false); + Callback = Function::Create(FTy, GlobalValue::ExternalLinkage, + "staticCallback", getLLVMModule()); llvmArgs.clear(); llvmArgs.push_back(JnjvmModule::JavaMethodType); @@ -1643,7 +1648,7 @@ func->setLinkage(GlobalValue::ExternalLinkage); } -Function* JavaAOTCompiler::addCallback(Class* cl, uint16 index, +Value* JavaAOTCompiler::addCallback(Class* cl, uint16 index, Signdef* sign, bool stat) { JavaConstantPool* ctpInfo = cl->ctpInfo; @@ -1657,14 +1662,13 @@ UTF8Buffer(cl->name).cString(), UTF8Buffer(methCl).cString(), UTF8Buffer(name).cString()); - Function* func = 0; LLVMSignatureInfo* LSI = getSignatureInfo(sign); const FunctionType* type = stat ? LSI->getStaticType() : LSI->getVirtualType(); - func = Function::Create(type, GlobalValue::ExternalLinkage, "staticCallback", - TheModule); + Value* func = ConstantExpr::getBitCast(Callback, + PointerType::getUnqual(type)); return func; } Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp?rev=78387&r1=78386&r2=78387&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp Fri Aug 7 12:09:48 2009 @@ -1534,7 +1534,7 @@ std::vector args; FunctionType::param_iterator it = virtualType->param_end(); makeArgs(it, index, args, signature->nbArguments + 1); - Function* func = 0; + Value* func = 0; if (finalCl) { Class* lookup = finalCl->isArray() ? finalCl->super : finalCl->asClass(); @@ -1635,7 +1635,7 @@ JavaMethod* meth = ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_STATIC, signature); - Function* func = 0; + Value* func = 0; if (meth) { func = TheCompiler->getMethod(meth); } else { Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp?rev=78387&r1=78386&r2=78387&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Fri Aug 7 12:09:48 2009 @@ -48,9 +48,8 @@ } - -Function* JavaJITCompiler::addCallback(Class* cl, uint16 index, - Signdef* sign, bool stat) { +Value* JavaJITCompiler::addCallback(Class* cl, uint16 index, + Signdef* sign, bool stat) { Function* F = 0; LLVMSignatureInfo* LSI = getSignatureInfo(sign); From nicolas.geoffray at lip6.fr Fri Aug 7 10:26:57 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 07 Aug 2009 17:26:57 -0000 Subject: [vmkit-commits] [vmkit] r78389 - /vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Message-ID: <200908071726.n77HQvG8016436@zion.cs.uiuc.edu> Author: geoffray Date: Fri Aug 7 12:26:57 2009 New Revision: 78389 URL: http://llvm.org/viewvc/llvm-project?rev=78389&view=rev Log: Fix bugs when loading a class from forName: - [Ljava/lang/Object; is invalid. - an offset of two must be applied to array names to get the component name. Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=78389&r1=78388&r2=78389&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Fri Aug 7 12:26:57 2009 @@ -468,9 +468,9 @@ uint32 bufLen = len - 2; const UTF8* componentName = hashUTF8->lookupReader(buf, bufLen); if (!componentName && holder) { - holder->size = len - 1; - for (uint32 i = 0; i < len - 1; ++i) { - holder->elements[i] = name->elements[start + i]; + holder->size = len - 2; + for (uint32 i = 0; i < len - 2; ++i) { + holder->elements[i] = name->elements[start + 1 + i]; } componentName = holder; } @@ -593,6 +593,7 @@ for (sint32 i = 0; i < str->count; ++i) { uint16 cur = str->value->elements[str->offset + i]; if (cur == '.') name->elements[i] = '/'; + else if (cur == '/') return 0; else name->elements[i] = cur; } } From nicolas.geoffray at lip6.fr Sun Aug 9 12:01:36 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 09 Aug 2009 19:01:36 -0000 Subject: [vmkit-commits] [vmkit] r78539 - /vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Message-ID: <200908091901.n79J1a4G015775@zion.cs.uiuc.edu> Author: geoffray Date: Sun Aug 9 14:01:35 2009 New Revision: 78539 URL: http://llvm.org/viewvc/llvm-project?rev=78539&view=rev Log: Fix memory leak. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp?rev=78539&r1=78538&r2=78539&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.cpp Sun Aug 9 14:01:35 2009 @@ -48,6 +48,7 @@ } JavaThread::~JavaThread() { + delete localJNIRefs; #ifdef SERVICE delete replacedEIPs; #endif From nicolas.geoffray at lip6.fr Sat Aug 15 02:53:20 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 15 Aug 2009 09:53:20 -0000 Subject: [vmkit-commits] [vmkit] r79089 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaConstantPool.cpp JnjvmClassLoader.cpp Message-ID: <200908150953.n7F9rKMk025710@zion.cs.uiuc.edu> Author: geoffray Date: Sat Aug 15 04:53:19 2009 New Revision: 79089 URL: http://llvm.org/viewvc/llvm-project?rev=79089&view=rev Log: Output some informative message when a class can not be found while static compiling. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=79089&r1=79088&r2=79089&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Sat Aug 15 04:53:19 2009 @@ -291,6 +291,11 @@ // Put into ctpRes because there is only one representation of the class temp = loader->loadName(name, resolve, false); } + if (!temp && classDef->classLoader->getCompiler()->isStaticCompiling()) { + fprintf(stderr, "Could not find class %s while static compiling\n", + UTF8Buffer(name).cString()); + abort(); + } ctpRes[index] = temp; } #endif Modified: vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=79089&r1=79088&r2=79089&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Sat Aug 15 04:53:19 2009 @@ -427,6 +427,11 @@ fprintf(stderr, "Unable to load NoClassDefFoundError"); abort(); } + if (TheCompiler->isStaticCompiling()) { + fprintf(stderr, "Could not find %s, needed for static compiling\n", + UTF8Buffer(name).cString()); + abort(); + } vm->noClassDefFoundError(name); } From nicolas.geoffray at lip6.fr Sat Aug 15 08:54:15 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 15 Aug 2009 15:54:15 -0000 Subject: [vmkit-commits] [vmkit] r79108 - in /vmkit/trunk/lib: JnJVM/Compiler/ JnJVM/VMCore/ Mvm/Compiler/ N3/Mono/ N3/VMCore/ Message-ID: <200908151554.n7FFsFhr005516@zion.cs.uiuc.edu> Author: geoffray Date: Sat Aug 15 10:54:14 2009 New Revision: 79108 URL: http://llvm.org/viewvc/llvm-project?rev=79108&view=rev Log: Move to new LLVM API for creating types. Modified: vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp vmkit/trunk/lib/Mvm/Compiler/JIT.cpp vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp vmkit/trunk/lib/N3/Mono/MonoString.cpp vmkit/trunk/lib/N3/VMCore/CLIJit.cpp vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp vmkit/trunk/lib/N3/VMCore/Opcodes.cpp vmkit/trunk/lib/N3/VMCore/VMCache.cpp vmkit/trunk/lib/N3/VMCore/VMClass.cpp Modified: vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc (original) +++ vmkit/trunk/lib/JnJVM/Compiler/ExceptionsCheck.inc Sat Aug 15 10:54:14 2009 @@ -432,7 +432,7 @@ currentBlock); uint32 depth = cur->catchClass->virtualVT->depth; - Value* depthCl = ConstantInt::get(Type::Int32Ty, depth); + Value* depthCl = ConstantInt::get(Type::getInt32Ty(*llvmContext), depth); Value* cmp = 0; if (depth >= JavaVirtualTable::getDisplayLength()) { @@ -546,7 +546,7 @@ if (PI == PE) { unifiedUnreachable->eraseFromParent(); } else { - new UnreachableInst(unifiedUnreachable); + new UnreachableInst(*llvmContext, unifiedUnreachable); } for (Function::iterator BI = llvmFunction->begin(), BE = llvmFunction->end(); Modified: vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JITInfo.cpp Sat Aug 15 10:54:14 2009 @@ -10,8 +10,9 @@ #include "llvm/BasicBlock.h" #include "llvm/CallingConv.h" #include "llvm/Constants.h" -#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/Instructions.h" +#include "llvm/Module.h" +#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/Support/MutexGuard.h" #include "llvm/Target/TargetData.h" @@ -79,7 +80,7 @@ uint64 size = JnjvmModule::getTypeSize(structType); classDef->virtualSize = (uint32)size; - virtualSizeConstant = ConstantInt::get(Type::Int32Ty, size); + virtualSizeConstant = ConstantInt::get(Type::getInt32Ty(context), size); Mod->makeVT(classDef); } @@ -125,9 +126,7 @@ Value* LLVMClassInfo::getVirtualSize() { if (!virtualSizeConstant) { getVirtualType(); - assert(classDef->virtualSize && "Zero size for a class?"); - virtualSizeConstant = - ConstantInt::get(Type::Int32Ty, classDef->virtualSize); + assert(virtualSizeConstant && "No size for a class?"); } return virtualSizeConstant; } @@ -193,9 +192,11 @@ if (!offsetConstant) { JnjvmClassLoader* JCL = methodDef->classDef->classLoader; JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)JCL->getCompiler(); + LLVMContext& context = Mod->getLLVMModule()->getContext(); Mod->resolveVirtualClass(methodDef->classDef); - offsetConstant = ConstantInt::get(Type::Int32Ty, methodDef->offset); + offsetConstant = ConstantInt::get(Type::getInt32Ty(context), + methodDef->offset); } return offsetConstant; } @@ -204,6 +205,7 @@ if (!offsetConstant) { JnjvmClassLoader* JCL = fieldDef->classDef->classLoader; JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)JCL->getCompiler(); + LLVMContext& context = Mod->getLLVMModule()->getContext(); if (isStatic(fieldDef->access)) { Mod->resolveStaticClass(fieldDef->classDef); @@ -211,7 +213,7 @@ Mod->resolveVirtualClass(fieldDef->classDef); } - offsetConstant = ConstantInt::get(Type::Int32Ty, fieldDef->num); + offsetConstant = ConstantInt::get(Type::getInt32Ty(context), fieldDef->num); } return offsetConstant; } @@ -315,6 +317,7 @@ JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); + LLVMContext& context = Mod->getLLVMModule()->getContext(); Function* res = 0; if (Mod->isStaticCompiling()) { const char* type = virt ? "virtual_buf" : "static_buf"; @@ -331,7 +334,7 @@ Mod->getLLVMModule()); } - BasicBlock* currentBlock = BasicBlock::Create("enter", res); + BasicBlock* currentBlock = BasicBlock::Create(context, "enter", res); Function::arg_iterator i = res->arg_begin(); Value *obj, *ptr, *func; #if defined(ISOLATE_SHARING) @@ -364,10 +367,10 @@ Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock); - if (res->getFunctionType()->getReturnType() != Type::VoidTy) - ReturnInst::Create(val, currentBlock); + if (!signature->getReturnType()->isVoid()) + ReturnInst::Create(context, val, currentBlock); else - ReturnInst::Create(currentBlock); + ReturnInst::Create(context, currentBlock); return res; } @@ -390,8 +393,9 @@ getStaticBufType(), GlobalValue::InternalLinkage, name, Mod->getLLVMModule()); + LLVMContext& context = Mod->getLLVMModule()->getContext(); - BasicBlock* currentBlock = BasicBlock::Create("enter", res); + BasicBlock* currentBlock = BasicBlock::Create(context, "enter", res); Function::arg_iterator i = res->arg_begin(); Value *obj, *ap, *func; #if defined(ISOLATE_SHARING) @@ -419,10 +423,10 @@ Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock); - if (res->getFunctionType()->getReturnType() != Type::VoidTy) - ReturnInst::Create(val, currentBlock); + if (!signature->getReturnType()->isVoid()) + ReturnInst::Create(context, val, currentBlock); else - ReturnInst::Create(currentBlock); + ReturnInst::Create(context, currentBlock); return res; } @@ -551,40 +555,48 @@ } void LLVMAssessorInfo::initialise() { - AssessorInfo[I_VOID].llvmType = Type::VoidTy; + AssessorInfo[I_VOID].llvmType = Type::getVoidTy(getGlobalContext()); AssessorInfo[I_VOID].llvmTypePtr = 0; AssessorInfo[I_VOID].logSizeInBytesConstant = 0; - AssessorInfo[I_BOOL].llvmType = Type::Int8Ty; - AssessorInfo[I_BOOL].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty); + AssessorInfo[I_BOOL].llvmType = Type::getInt8Ty(getGlobalContext()); + AssessorInfo[I_BOOL].llvmTypePtr = + PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())); AssessorInfo[I_BOOL].logSizeInBytesConstant = 0; - AssessorInfo[I_BYTE].llvmType = Type::Int8Ty; - AssessorInfo[I_BYTE].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty); + AssessorInfo[I_BYTE].llvmType = Type::getInt8Ty(getGlobalContext()); + AssessorInfo[I_BYTE].llvmTypePtr = + PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())); AssessorInfo[I_BYTE].logSizeInBytesConstant = 0; - AssessorInfo[I_SHORT].llvmType = Type::Int16Ty; - AssessorInfo[I_SHORT].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty); + AssessorInfo[I_SHORT].llvmType = Type::getInt16Ty(getGlobalContext()); + AssessorInfo[I_SHORT].llvmTypePtr = + PointerType::getUnqual(Type::getInt16Ty(getGlobalContext())); AssessorInfo[I_SHORT].logSizeInBytesConstant = 1; - AssessorInfo[I_CHAR].llvmType = Type::Int16Ty; - AssessorInfo[I_CHAR].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty); + AssessorInfo[I_CHAR].llvmType = Type::getInt16Ty(getGlobalContext()); + AssessorInfo[I_CHAR].llvmTypePtr = + PointerType::getUnqual(Type::getInt16Ty(getGlobalContext())); AssessorInfo[I_CHAR].logSizeInBytesConstant = 1; - AssessorInfo[I_INT].llvmType = Type::Int32Ty; - AssessorInfo[I_INT].llvmTypePtr = PointerType::getUnqual(Type::Int32Ty); + AssessorInfo[I_INT].llvmType = Type::getInt32Ty(getGlobalContext()); + AssessorInfo[I_INT].llvmTypePtr = + PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())); AssessorInfo[I_INT].logSizeInBytesConstant = 2; - AssessorInfo[I_FLOAT].llvmType = Type::FloatTy; - AssessorInfo[I_FLOAT].llvmTypePtr = PointerType::getUnqual(Type::FloatTy); + AssessorInfo[I_FLOAT].llvmType = Type::getFloatTy(getGlobalContext()); + AssessorInfo[I_FLOAT].llvmTypePtr = + PointerType::getUnqual(Type::getFloatTy(getGlobalContext())); AssessorInfo[I_FLOAT].logSizeInBytesConstant = 2; - AssessorInfo[I_LONG].llvmType = Type::Int64Ty; - AssessorInfo[I_LONG].llvmTypePtr = PointerType::getUnqual(Type::Int64Ty); + AssessorInfo[I_LONG].llvmType = Type::getInt64Ty(getGlobalContext()); + AssessorInfo[I_LONG].llvmTypePtr = + PointerType::getUnqual(Type::getInt64Ty(getGlobalContext())); AssessorInfo[I_LONG].logSizeInBytesConstant = 3; - AssessorInfo[I_DOUBLE].llvmType = Type::DoubleTy; - AssessorInfo[I_DOUBLE].llvmTypePtr = PointerType::getUnqual(Type::DoubleTy); + AssessorInfo[I_DOUBLE].llvmType = Type::getDoubleTy(getGlobalContext()); + AssessorInfo[I_DOUBLE].llvmTypePtr = + PointerType::getUnqual(Type::getDoubleTy(getGlobalContext())); AssessorInfo[I_DOUBLE].logSizeInBytesConstant = 3; AssessorInfo[I_TAB].llvmType = JnjvmModule::JavaObjectType; Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaAOTCompiler.cpp Sat Aug 15 10:54:14 2009 @@ -137,7 +137,7 @@ method_iterator SI = virtualMethods.find(cl); for (uint32 i = 0; i < cl->nbVirtualMethods + cl->nbStaticMethods; ++i) { if (&cl->virtualMethods[i] == meth) { - MOffset = ConstantInt::get(Type::Int32Ty, i); + MOffset = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), i); break; } } @@ -265,21 +265,21 @@ CommonClass* subClass = cl->asArrayClass()->baseClass(); if (subClass->isPrimitive()) { if (subClass == upcalls->OfBool) { - Ty = Type::Int8Ty; + Ty = Type::getInt8Ty(getGlobalContext()); } else if (subClass == upcalls->OfByte) { - Ty = Type::Int8Ty; + Ty = Type::getInt8Ty(getGlobalContext()); } else if (subClass == upcalls->OfShort) { - Ty = Type::Int16Ty; + Ty = Type::getInt16Ty(getGlobalContext()); } else if (subClass == upcalls->OfChar) { - Ty = Type::Int16Ty; + Ty = Type::getInt16Ty(getGlobalContext()); } else if (subClass == upcalls->OfInt) { - Ty = Type::Int32Ty; + Ty = Type::getInt32Ty(getGlobalContext()); } else if (subClass == upcalls->OfFloat) { - Ty = Type::FloatTy; + Ty = Type::getFloatTy(getGlobalContext()); } else if (subClass == upcalls->OfLong) { - Ty = Type::Int64Ty; + Ty = Type::getInt64Ty(getGlobalContext()); } else if (subClass == upcalls->OfDouble) { - Ty = Type::DoubleTy; + Ty = Type::getDoubleTy(getGlobalContext()); } else { abort(); } @@ -312,7 +312,8 @@ varGV->setInitializer(CreateConstantFromJavaObject(obj)); return C; } else { - Constant* CI = ConstantInt::get(Type::Int64Ty, uint64_t(obj)); + Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64_t(obj)); CI = ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType); finalObjects.insert(std::make_pair(obj, CI)); return CI; @@ -343,28 +344,34 @@ if (type->isPrimitive()) { const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; if (prim->isBool() || prim->isByte()) { - ConstantInt* CI = ConstantInt::get(Type::Int8Ty, - field.getInt8Field(obj)); + ConstantInt* CI = ConstantInt::get( + Type::getInt8Ty(getGlobalContext()), + field.getInt8Field(obj)); Elts.push_back(CI); } else if (prim->isShort() || prim->isChar()) { - ConstantInt* CI = ConstantInt::get(Type::Int16Ty, - field.getInt16Field(obj)); + ConstantInt* CI = ConstantInt::get( + Type::getInt16Ty(getGlobalContext()), + field.getInt16Field(obj)); Elts.push_back(CI); } else if (prim->isInt()) { - ConstantInt* CI = ConstantInt::get(Type::Int32Ty, - field.getInt32Field(obj)); + ConstantInt* CI = ConstantInt::get( + Type::getInt32Ty(getGlobalContext()), + field.getInt32Field(obj)); Elts.push_back(CI); } else if (prim->isLong()) { - ConstantInt* CI = ConstantInt::get(Type::Int64Ty, - field.getLongField(obj)); + ConstantInt* CI = ConstantInt::get( + Type::getInt64Ty(getGlobalContext()), + field.getLongField(obj)); Elts.push_back(CI); } else if (prim->isFloat()) { - Constant* CF = ConstantFP::get(Type::FloatTy, - field.getFloatField(obj)); + Constant* CF = ConstantFP::get( + Type::getFloatTy(getGlobalContext()), + field.getFloatField(obj)); Elts.push_back(CF); } else if (prim->isDouble()) { - Constant* CF = ConstantFP::get(Type::DoubleTy, - field.getDoubleField(obj)); + Constant* CF = ConstantFP::get( + Type::getDoubleTy(getGlobalContext()), + field.getDoubleField(obj)); Elts.push_back(CF); } else { abort(); @@ -386,11 +393,11 @@ JavaConstantPool * ctpInfo = cl->ctpInfo; uint16 idx = reader.readU2(); if (type->isPrimitive()) { - if (Ty == Type::Int64Ty) { + if (Ty == Type::getInt64Ty(getGlobalContext())) { Elts.push_back(ConstantInt::get(Ty, (uint64)ctpInfo->LongAt(idx))); - } else if (Ty == Type::DoubleTy) { + } else if (Ty == Type::getDoubleTy(getGlobalContext())) { Elts.push_back(ConstantFP::get(Ty, ctpInfo->DoubleAt(idx))); - } else if (Ty == Type::FloatTy) { + } else if (Ty == Type::getFloatTy(getGlobalContext())) { Elts.push_back(ConstantFP::get(Ty, ctpInfo->FloatAt(idx))); } else { Elts.push_back(ConstantInt::get(Ty, (uint64)ctpInfo->IntegerAt(idx))); @@ -519,7 +526,7 @@ Elmts.push_back(getVirtualTable(cl->virtualVT)); // lock - Constant* L = ConstantInt::get(Type::Int64Ty, 0); + Constant* L = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), 0); Elmts.push_back(ConstantExpr::getIntToPtr(L, JnjvmModule::ptrType)); return ConstantStruct::get(STy, Elmts); @@ -563,28 +570,28 @@ if (subClass->isPrimitive()) { if (subClass == upcalls->OfBool) { return CreateConstantFromArray((ArrayUInt8*)obj, - Type::Int8Ty); + Type::getInt8Ty(getGlobalContext())); } else if (subClass == upcalls->OfByte) { return CreateConstantFromArray((ArraySInt8*)obj, - Type::Int8Ty); + Type::getInt8Ty(getGlobalContext())); } else if (subClass == upcalls->OfShort) { return CreateConstantFromArray((ArraySInt16*)obj, - Type::Int16Ty); + Type::getInt16Ty(getGlobalContext())); } else if (subClass == upcalls->OfChar) { return CreateConstantFromArray((ArrayUInt16*)obj, - Type::Int16Ty); + Type::getInt16Ty(getGlobalContext())); } else if (subClass == upcalls->OfInt) { return CreateConstantFromArray((ArraySInt32*)obj, - Type::Int32Ty); + Type::getInt32Ty(getGlobalContext())); } else if (subClass == upcalls->OfFloat) { return CreateConstantFromArray((ArrayFloat*)obj, - Type::FloatTy); + Type::getFloatTy(getGlobalContext())); } else if (subClass == upcalls->OfLong) { return CreateConstantFromArray((ArrayLong*)obj, - Type::Int64Ty); + Type::getInt64Ty(getGlobalContext())); } else if (subClass == upcalls->OfDouble) { return CreateConstantFromArray((ArrayDouble*)obj, - Type::DoubleTy); + Type::getDoubleTy(getGlobalContext())); } else { abort(); } @@ -614,27 +621,27 @@ if (type->isPrimitive()) { const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; if (prim->isBool() || prim->isByte()) { - ConstantInt* CI = ConstantInt::get(Type::Int8Ty, + ConstantInt* CI = ConstantInt::get(Type::getInt8Ty(getGlobalContext()), field.getInt8Field(obj)); TempElts.push_back(CI); } else if (prim->isShort() || prim->isChar()) { - ConstantInt* CI = ConstantInt::get(Type::Int16Ty, + ConstantInt* CI = ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.getInt16Field(obj)); TempElts.push_back(CI); } else if (prim->isInt()) { - ConstantInt* CI = ConstantInt::get(Type::Int32Ty, + ConstantInt* CI = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), field.getInt32Field(obj)); TempElts.push_back(CI); } else if (prim->isLong()) { - ConstantInt* CI = ConstantInt::get(Type::Int64Ty, + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), field.getLongField(obj)); TempElts.push_back(CI); } else if (prim->isFloat()) { - Constant* CF = ConstantFP::get(Type::FloatTy, + Constant* CF = ConstantFP::get(Type::getFloatTy(getGlobalContext()), field.getFloatField(obj)); TempElts.push_back(CF); } else if (prim->isDouble()) { - Constant* CF = ConstantFP::get(Type::DoubleTy, + Constant* CF = ConstantFP::get(Type::getDoubleTy(getGlobalContext()), field.getDoubleField(obj)); TempElts.push_back(CF); } else { @@ -669,7 +676,7 @@ Elmts.push_back(CreateConstantForBaseObject(cl)); Constant* Array = - CreateConstantFromArray(str->value, Type::Int16Ty); + CreateConstantFromArray(str->value, Type::getInt16Ty(getGlobalContext())); Module& Mod = *getLLVMModule(); @@ -680,9 +687,12 @@ Array = ConstantExpr::getBitCast(varGV, JnjvmModule::JavaObjectType); Elmts.push_back(Array); - Elmts.push_back(ConstantInt::get(Type::Int32Ty, str->count)); - Elmts.push_back(ConstantInt::get(Type::Int32Ty, str->cachedHashCode)); - Elmts.push_back(ConstantInt::get(Type::Int32Ty, str->offset)); + Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + str->count)); + Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + str->cachedHashCode)); + Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + str->offset)); return ConstantStruct::get(STy, Elmts); } @@ -717,7 +727,7 @@ Elmts.push_back(getUTF8(val->methodName)); Elmts.push_back(getUTF8(val->methodSign)); - Elmts.push_back(Constant::getNullValue(Type::Int32Ty)); + Elmts.push_back(Constant::getNullValue(Type::getInt32Ty(getGlobalContext()))); Elmts.push_back(getNativeClass(val->classDef)); Elmts.push_back(firstCache); @@ -736,10 +746,10 @@ Elmts.push_back(getUTF8(attribut.name)); // start - Elmts.push_back(ConstantInt::get(Type::Int32Ty, attribut.start)); + Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), attribut.start)); // nbb - Elmts.push_back(ConstantInt::get(Type::Int32Ty, attribut.nbb)); + Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), attribut.nbb)); return ConstantStruct::get(STy, Elmts); } @@ -762,7 +772,7 @@ CommonClassElts.push_back(ConstantArray::get(ATy, TCM, 1)); // access - CommonClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->access)); + CommonClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->access)); // interfaces if (cl->nbInterfaces) { @@ -785,7 +795,7 @@ } // nbInterfaces - CommonClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbInterfaces)); + CommonClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbInterfaces)); // name CommonClassElts.push_back(getUTF8(cl->name)); @@ -825,7 +835,7 @@ FieldElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); // access - FieldElts.push_back(ConstantInt::get(Type::Int16Ty, field.access)); + FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.access)); // name FieldElts.push_back(getUTF8(field.name)); @@ -855,16 +865,16 @@ } // nbAttributs - FieldElts.push_back(ConstantInt::get(Type::Int16Ty, field.nbAttributs)); + FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.nbAttributs)); // classDef FieldElts.push_back(getNativeClass(field.classDef)); // ptrOffset - FieldElts.push_back(ConstantInt::get(Type::Int32Ty, field.ptrOffset)); + FieldElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), field.ptrOffset)); // num - FieldElts.push_back(ConstantInt::get(Type::Int16Ty, field.num)); + FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.num)); //JInfo FieldElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); @@ -884,7 +894,7 @@ MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); // access - MethodElts.push_back(ConstantInt::get(Type::Int16Ty, method.access)); + MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), method.access)); // attributs if (method.nbAttributs) { @@ -908,7 +918,7 @@ } // nbAttributs - MethodElts.push_back(ConstantInt::get(Type::Int16Ty, method.nbAttributs)); + MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), method.nbAttributs)); // enveloppes // already allocated by the JIT, don't reallocate them. @@ -916,7 +926,7 @@ // nbEnveloppes // 0 because we're not allocating here. - MethodElts.push_back(ConstantInt::get(Type::Int16Ty, 0)); + MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), 0)); // classDef MethodElts.push_back(getNativeClass(method.classDef)); @@ -928,7 +938,7 @@ MethodElts.push_back(getUTF8(method.type)); // canBeInlined - MethodElts.push_back(ConstantInt::get(Type::Int8Ty, method.canBeInlined)); + MethodElts.push_back(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), method.canBeInlined)); // code if (isAbstract(method.access)) { @@ -941,7 +951,7 @@ } // offset - MethodElts.push_back(ConstantInt::get(Type::Int32Ty, method.offset)); + MethodElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), method.offset)); //JInfo MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); @@ -960,7 +970,7 @@ ClassElts.push_back(CreateConstantFromCommonClass(cl)); // primSize - ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->logSize)); + ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->logSize)); return ConstantStruct::get(STy, ClassElts); } @@ -998,7 +1008,8 @@ ClassElts.push_back(CreateConstantFromCommonClass(cl)); // virtualSize - ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->virtualSize)); + ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + cl->virtualSize)); // IsolateInfo const ArrayType* ATy = dyn_cast(STy->getContainedType(2)); @@ -1008,8 +1019,10 @@ assert(TCMTy && "Malformed type"); uint32 status = cl->needsInitialisationCheck() ? vmjc : ready; - TempElts.push_back(ConstantInt::get(Type::Int8Ty, status)); - TempElts.push_back(ConstantInt::get(Type::Int1Ty, status == ready ? 1 : 0)); + TempElts.push_back(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), + status)); + TempElts.push_back(ConstantInt::get(Type::getInt1Ty(getGlobalContext()), + status == ready ? 1 : 0)); TempElts.push_back(getStaticInstance(cl)); Constant* CStr[1] = { ConstantStruct::get(TCMTy, TempElts) }; TempElts.clear(); @@ -1059,7 +1072,7 @@ ClassElts.push_back(fields); ConstantInt* nbVirtualFields = - ConstantInt::get(Type::Int16Ty, cl->nbVirtualFields); + ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbVirtualFields); // nbVirtualFields ClassElts.push_back(nbVirtualFields); @@ -1069,7 +1082,7 @@ ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaFieldType)); // nbStaticFields - ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbStaticFields)); + ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticFields)); // virtualMethods if (cl->nbVirtualMethods + cl->nbStaticMethods) { @@ -1107,7 +1120,7 @@ ClassElts.push_back(methods); ConstantInt* nbVirtualMethods = - ConstantInt::get(Type::Int16Ty, cl->nbVirtualMethods); + ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbVirtualMethods); // nbVirtualMethods ClassElts.push_back(nbVirtualMethods); @@ -1116,7 +1129,7 @@ ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaMethodType)); // nbStaticMethods - ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbStaticMethods)); + ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticMethods)); // ownerClass ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); @@ -1149,7 +1162,7 @@ } // nbAttributs - ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbAttributs)); + ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbAttributs)); // innerClasses if (cl->nbInnerClasses) { @@ -1173,7 +1186,7 @@ } // nbInnerClasses - ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->nbInnerClasses)); + ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbInnerClasses)); // outerClass if (cl->outerClass) { @@ -1183,19 +1196,19 @@ } // innerAccess - ClassElts.push_back(ConstantInt::get(Type::Int16Ty, cl->innerAccess)); + ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->innerAccess)); // innerOuterResolved - ClassElts.push_back(ConstantInt::get(Type::Int8Ty, cl->innerOuterResolved)); + ClassElts.push_back(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), cl->innerOuterResolved)); // isAnonymous - ClassElts.push_back(ConstantInt::get(Type::Int8Ty, cl->isAnonymous)); + ClassElts.push_back(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), cl->isAnonymous)); // virtualTableSize - ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->virtualTableSize)); + ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->virtualTableSize)); // staticSize - ClassElts.push_back(ConstantInt::get(Type::Int32Ty, cl->staticSize)); + ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->staticSize)); // JInfo ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); @@ -1241,7 +1254,7 @@ Constant* JavaAOTCompiler::CreateConstantFromUTF8(const UTF8* val) { std::vector Elemts; - const ArrayType* ATy = ArrayType::get(Type::Int16Ty, val->size); + const ArrayType* ATy = ArrayType::get(Type::getInt16Ty(getGlobalContext()), val->size); Elemts.push_back(JnjvmModule::pointerSizeType); Elemts.push_back(ATy); @@ -1254,7 +1267,7 @@ std::vector Vals; for (sint32 i = 0; i < val->size; ++i) { - Vals.push_back(ConstantInt::get(Type::Int16Ty, val->elements[i])); + Vals.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), val->elements[i])); } Cts.push_back(ConstantArray::get(ATy, Vals)); @@ -1333,11 +1346,11 @@ // depth Elemts.push_back(ConstantExpr::getIntToPtr( - ConstantInt::get(Type::Int64Ty, VT->depth), PTy)); + ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->depth), PTy)); // offset Elemts.push_back(ConstantExpr::getIntToPtr( - ConstantInt::get(Type::Int64Ty, VT->offset), PTy)); + ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->offset), PTy)); // cache Elemts.push_back(N); @@ -1355,7 +1368,7 @@ // nbSecondaryTypes Elemts.push_back(ConstantExpr::getIntToPtr( - ConstantInt::get(Type::Int64Ty, VT->nbSecondaryTypes), PTy)); + ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->nbSecondaryTypes), PTy)); // secondaryTypes const ArrayType* DTy = ArrayType::get(JnjvmModule::VTType, @@ -1422,13 +1435,13 @@ std::vector llvmArgs; llvmArgs.push_back(JnjvmModule::ptrType); // class loader. - const FunctionType* FTy = FunctionType::get(Type::VoidTy, llvmArgs, false); + const FunctionType* FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); StaticInitializer = Function::Create(FTy, GlobalValue::InternalLinkage, "Init", getLLVMModule()); llvmArgs.clear(); - FTy = FunctionType::get(Type::VoidTy, llvmArgs, false); + FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); Callback = Function::Create(FTy, GlobalValue::ExternalLinkage, "staticCallback", getLLVMModule()); @@ -1441,7 +1454,7 @@ "vmjcNativeLoader", getLLVMModule()); llvmArgs.clear(); - FTy = FunctionType::get(Type::VoidTy, llvmArgs, false); + FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); ObjectPrinter = Function::Create(FTy, GlobalValue::ExternalLinkage, "printJavaObject", getLLVMModule()); @@ -1490,7 +1503,7 @@ Constant* cons = - ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, + ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(isolate)), ptrType); @@ -1517,10 +1530,12 @@ std::vector llvmArgs; llvmArgs.push_back(JnjvmModule::ptrType); // class loader llvmArgs.push_back(JnjvmModule::JavaCommonClassType); // cl - const FunctionType* FTy = FunctionType::get(Type::VoidTy, llvmArgs, false); + const FunctionType* FTy = + FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); Function* AddClass = Function::Create(FTy, GlobalValue::ExternalLinkage, - "vmjcAddPreCompiledClass", getLLVMModule()); + "vmjcAddPreCompiledClass", + getLLVMModule()); llvmArgs.clear(); // class loader @@ -1529,12 +1544,13 @@ llvmArgs.push_back(PointerType::getUnqual(JnjvmModule::JavaClassArrayType)); // name llvmArgs.push_back(JnjvmModule::UTF8Type); - FTy = FunctionType::get(Type::VoidTy, llvmArgs, false); + FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); Function* GetClassArray = Function::Create(FTy, GlobalValue::ExternalLinkage, "vmjcGetClassArray", getLLVMModule()); - BasicBlock* currentBlock = BasicBlock::Create("enter", StaticInitializer); + BasicBlock* currentBlock = BasicBlock::Create(getGlobalContext(), "enter", + StaticInitializer); Function::arg_iterator loader = StaticInitializer->arg_begin(); Value* Args[3]; @@ -1543,7 +1559,7 @@ llvmArgs.clear(); llvmArgs.push_back(JnjvmModule::ptrType); // class loader llvmArgs.push_back(strings.begin()->second->getType()); // val - FTy = FunctionType::get(Type::VoidTy, llvmArgs, false); + FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); Function* AddString = Function::Create(FTy, GlobalValue::ExternalLinkage, "vmjcAddString", getLLVMModule()); @@ -1564,7 +1580,7 @@ llvmArgs.clear(); llvmArgs.push_back(JnjvmModule::ptrType); // class loader llvmArgs.push_back(utf8s.begin()->second->getType()); // val - FTy = FunctionType::get(Type::VoidTy, llvmArgs, false); + FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); Function* AddUTF8 = Function::Create(FTy, GlobalValue::ExternalLinkage, "vmjcAddUTF8", getLLVMModule()); @@ -1598,7 +1614,7 @@ } - ReturnInst::Create(currentBlock); + ReturnInst::Create(getGlobalContext(), currentBlock); } void JavaAOTCompiler::setNoInline(Class* cl) { @@ -1941,21 +1957,24 @@ // Type Definitions std::vector FuncArgs; - FuncArgs.push_back(Type::Int32Ty); + FuncArgs.push_back(Type::getInt32Ty(getGlobalContext())); FuncArgs.push_back(PointerType::getUnqual(JavaIntrinsics.ptrType)); - FunctionType* FuncTy = FunctionType::get(Type::Int32Ty, FuncArgs, false); + FunctionType* FuncTy = FunctionType::get(Type::getInt32Ty(getGlobalContext()), + FuncArgs, false); Function* MainFunc = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "main", TheModule); - BasicBlock* currentBlock = BasicBlock::Create("enter", MainFunc); + BasicBlock* currentBlock = BasicBlock::Create(getGlobalContext(), "enter", + MainFunc); GlobalVariable* GvarArrayStr = new GlobalVariable( - *TheModule, ArrayType::get(Type::Int8Ty, strlen(name) + 1), true, - GlobalValue::InternalLinkage, 0, "mainClass"); + *TheModule, ArrayType::get(Type::getInt8Ty(getGlobalContext()), + strlen(name) + 1), + true, GlobalValue::InternalLinkage, 0, "mainClass"); - Constant* NameArray = ConstantArray::get(name, true); + Constant* NameArray = ConstantArray::get(getGlobalContext(), name, true); GvarArrayStr->setInitializer(NameArray); Value* Indices[2] = { JavaIntrinsics.constantZero, JavaIntrinsics.constantZero }; @@ -1968,7 +1987,7 @@ FuncArgs.push_back(Args[2]->getType()); - FuncTy = FunctionType::get(Type::Int32Ty, FuncArgs, false); + FuncTy = FunctionType::get(Type::getInt32Ty(getGlobalContext()), FuncArgs, false); Function* CalledFunc = Function::Create(FuncTy, GlobalValue::ExternalLinkage, @@ -1976,6 +1995,6 @@ TheModule); Value* res = CallInst::Create(CalledFunc, Args, Args + 3, "", currentBlock); - ReturnInst::Create(res, currentBlock); + ReturnInst::Create(getGlobalContext(), res, currentBlock); } Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.cpp Sat Aug 15 10:54:14 2009 @@ -137,7 +137,7 @@ res = invoke(func, args, "", currentBlock); } BranchInst::Create(endBlock, currentBlock); - if (retType != Type::VoidTy) { + if (retType != Type::getVoidTy(getGlobalContext())) { node = PHINode::Create(virtualType->getReturnType(), "", endBlock); node->addIncoming(res, currentBlock); } @@ -158,13 +158,13 @@ Constant* Offset = LMI->getOffset(); indexes2[1] = Offset; #ifdef ISOLATE_SHARING - indexesCtp = ConstantInt::get(Type::Int32Ty, + indexesCtp = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), Offset->getZExtValue() * -1); #endif } else { Value* val = getConstantPoolAt(index, module->VirtualLookupFunction, - Type::Int32Ty, args[0], true); + Type::getInt32Ty(getGlobalContext()), args[0], true); indexes2[1] = val; #ifdef ISOLATE_SHARING Value* mul = BinaryOperator::CreateMul(val, module->constantMinusOne, @@ -197,9 +197,9 @@ currentBlock = endBlock; } - if (retType != Type::VoidTy) { + if (retType != Type::getVoidTy(getGlobalContext())) { push(val, retTypedef->isUnsigned()); - if (retType == Type::DoubleTy || retType == Type::Int64Ty) { + if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) { push(module->constantZero, false); } } @@ -254,10 +254,10 @@ if (!natPtr && !TheCompiler->isStaticCompiling()) { currentBlock = createBasicBlock("start"); CallInst::Create(module->ThrowExceptionFromJITFunction, "", currentBlock); - if (returnType != Type::VoidTy) - ReturnInst::Create(Constant::getNullValue(returnType), currentBlock); + if (returnType != Type::getVoidTy(getGlobalContext())) + ReturnInst::Create(*llvmContext, Constant::getNullValue(returnType), currentBlock); else - ReturnInst::Create(currentBlock); + ReturnInst::Create(*llvmContext, currentBlock); PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "end native compile %s.%s\n", UTF8Buffer(compilingClass->name).cString(), @@ -279,17 +279,17 @@ BasicBlock* executeBlock = createBasicBlock("execute"); endBlock = createBasicBlock("end block"); - Constant* sizeB = ConstantInt::get(Type::Int32Ty, sizeof(jmp_buf)); + Constant* sizeB = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), sizeof(jmp_buf)); Value* oldJB = new AllocaInst(module->ptrType, "", currentBlock); - Value* newJB = new AllocaInst(Type::Int8Ty, sizeB, "", currentBlock); + Value* newJB = new AllocaInst(Type::getInt8Ty(getGlobalContext()), sizeB, "", currentBlock); // Allocate currentLocalIndexNumber pointer - Value* temp = new AllocaInst(Type::Int32Ty, "", + Value* temp = new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", currentBlock); new StoreInst(module->constantZero, temp, false, currentBlock); // Allocate oldCurrentLocalIndexNumber pointer - Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::Int32Ty), "", + Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "", currentBlock); Value* test = CallInst::Create(module->setjmpLLVM, newJB, "", @@ -299,7 +299,7 @@ module->constantZero, ""); BranchInst::Create(executeBlock, endBlock, test, currentBlock); - if (returnType != Type::VoidTy) { + if (returnType != Type::getVoidTy(getGlobalContext())) { endNode = PHINode::Create(returnType, "", endBlock); endNode->addIncoming(Constant::getNullValue(returnType), currentBlock); @@ -441,7 +441,7 @@ endNode->addIncoming(result, currentBlock); - } else if (returnType != Type::VoidTy) { + } else if (returnType != Type::getVoidTy(getGlobalContext())) { endNode->addIncoming(result, currentBlock); } @@ -456,10 +456,10 @@ CallInst::Create(module->EndJNIFunction, Args2, Args2 + 2, "", currentBlock); - if (returnType != Type::VoidTy) - ReturnInst::Create(endNode, currentBlock); + if (returnType != Type::getVoidTy(getGlobalContext())) + ReturnInst::Create(*llvmContext, endNode, currentBlock); else - ReturnInst::Create(currentBlock); + ReturnInst::Create(*llvmContext, currentBlock); PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "end native compile %s.%s\n", UTF8Buffer(compilingClass->name).cString(), @@ -735,30 +735,30 @@ Instruction* firstInstruction = firstBB->begin(); for (int i = 0; i < maxLocals; i++) { - intLocals.push_back(new AllocaInst(Type::Int32Ty, "", firstInstruction)); - doubleLocals.push_back(new AllocaInst(Type::DoubleTy, "", + intLocals.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstInstruction)); + doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", firstInstruction)); - longLocals.push_back(new AllocaInst(Type::Int64Ty, "", firstInstruction)); - floatLocals.push_back(new AllocaInst(Type::FloatTy, "", firstInstruction)); + longLocals.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", firstInstruction)); + floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstInstruction)); objectLocals.push_back(new AllocaInst(module->JavaObjectType, "", firstInstruction)); } for (int i = 0; i < maxStack; i++) { objectStack.push_back(new AllocaInst(module->JavaObjectType, "", firstInstruction)); - intStack.push_back(new AllocaInst(Type::Int32Ty, "", firstInstruction)); - doubleStack.push_back(new AllocaInst(Type::DoubleTy, "", + intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstInstruction)); + doubleStack.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", firstInstruction)); - longStack.push_back(new AllocaInst(Type::Int64Ty, "", firstInstruction)); - floatStack.push_back(new AllocaInst(Type::FloatTy, "", firstInstruction)); + longStack.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", firstInstruction)); + floatStack.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstInstruction)); } } else { for (int i = 0; i < maxLocals; i++) { - intLocals.push_back(new AllocaInst(Type::Int32Ty, "", firstBB)); - doubleLocals.push_back(new AllocaInst(Type::DoubleTy, "", firstBB)); - longLocals.push_back(new AllocaInst(Type::Int64Ty, "", firstBB)); - floatLocals.push_back(new AllocaInst(Type::FloatTy, "", firstBB)); + intLocals.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstBB)); + doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", firstBB)); + longLocals.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", firstBB)); + floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstBB)); objectLocals.push_back(new AllocaInst(module->JavaObjectType, "", firstBB)); } @@ -766,10 +766,10 @@ for (int i = 0; i < maxStack; i++) { objectStack.push_back(new AllocaInst(module->JavaObjectType, "", firstBB)); - intStack.push_back(new AllocaInst(Type::Int32Ty, "", firstBB)); - doubleStack.push_back(new AllocaInst(Type::DoubleTy, "", firstBB)); - longStack.push_back(new AllocaInst(Type::Int64Ty, "", firstBB)); - floatStack.push_back(new AllocaInst(Type::FloatTy, "", firstBB)); + intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstBB)); + doubleStack.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", firstBB)); + longStack.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", firstBB)); + floatStack.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstBB)); } } @@ -799,21 +799,21 @@ const Typedef* cur = arguments[type]; const Type* curType = (*i)->getType(); - if (curType == Type::Int64Ty){ + if (curType == Type::getInt64Ty(getGlobalContext())){ new StoreInst(*i, longLocals[index], false, currentBlock); ++index; } else if (cur->isUnsigned()) { - new StoreInst(new ZExtInst(*i, Type::Int32Ty, "", currentBlock), + new StoreInst(new ZExtInst(*i, Type::getInt32Ty(getGlobalContext()), "", currentBlock), intLocals[index], false, currentBlock); - } else if (curType == Type::Int8Ty || curType == Type::Int16Ty) { - new StoreInst(new SExtInst(*i, Type::Int32Ty, "", currentBlock), + } else if (curType == Type::getInt8Ty(getGlobalContext()) || curType == Type::getInt16Ty(getGlobalContext())) { + new StoreInst(new SExtInst(*i, Type::getInt32Ty(getGlobalContext()), "", currentBlock), intLocals[index], false, currentBlock); - } else if (curType == Type::Int32Ty) { + } else if (curType == Type::getInt32Ty(getGlobalContext())) { new StoreInst(*i, intLocals[index], false, currentBlock); - } else if (curType == Type::DoubleTy) { + } else if (curType == Type::getDoubleTy(getGlobalContext())) { new StoreInst(*i, doubleLocals[index], false, currentBlock); ++index; - } else if (curType == Type::FloatTy) { + } else if (curType == Type::getFloatTy(getGlobalContext())) { new StoreInst(*i, floatLocals[index], false, currentBlock); } else { new StoreInst(*i, objectLocals[index], false, currentBlock); @@ -825,7 +825,7 @@ exploreOpcodes(&compilingClass->bytes->elements[start], codeLen); nbEnveloppes = 0; - if (returnType != Type::VoidTy) { + if (returnType != Type::getVoidTy(getGlobalContext())) { endNode = PHINode::Create(returnType, "", endBlock); } @@ -907,10 +907,10 @@ for (int i = 0; i < maxLocals; i++) { - intLocals.push_back(new AllocaInst(Type::Int32Ty, "", currentBlock)); - doubleLocals.push_back(new AllocaInst(Type::DoubleTy, "", currentBlock)); - longLocals.push_back(new AllocaInst(Type::Int64Ty, "", currentBlock)); - floatLocals.push_back(new AllocaInst(Type::FloatTy, "", currentBlock)); + intLocals.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", currentBlock)); + doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", currentBlock)); + longLocals.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", currentBlock)); + floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", currentBlock)); objectLocals.push_back(new AllocaInst(module->JavaObjectType, "", currentBlock)); } @@ -918,10 +918,10 @@ for (int i = 0; i < maxStack; i++) { objectStack.push_back(new AllocaInst(module->JavaObjectType, "", currentBlock)); - intStack.push_back(new AllocaInst(Type::Int32Ty, "", currentBlock)); - doubleStack.push_back(new AllocaInst(Type::DoubleTy, "", currentBlock)); - longStack.push_back(new AllocaInst(Type::Int64Ty, "", currentBlock)); - floatStack.push_back(new AllocaInst(Type::FloatTy, "", currentBlock)); + intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", currentBlock)); + doubleStack.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", currentBlock)); + longStack.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", currentBlock)); + floatStack.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", currentBlock)); } uint32 index = 0; @@ -948,21 +948,21 @@ const Typedef* cur = arguments[type]; const llvm::Type* curType = i->getType(); - if (curType == Type::Int64Ty){ + if (curType == Type::getInt64Ty(getGlobalContext())){ new StoreInst(i, longLocals[index], false, currentBlock); ++index; } else if (cur->isUnsigned()) { - new StoreInst(new ZExtInst(i, Type::Int32Ty, "", currentBlock), + new StoreInst(new ZExtInst(i, Type::getInt32Ty(getGlobalContext()), "", currentBlock), intLocals[index], false, currentBlock); - } else if (curType == Type::Int8Ty || curType == Type::Int16Ty) { - new StoreInst(new SExtInst(i, Type::Int32Ty, "", currentBlock), + } else if (curType == Type::getInt8Ty(getGlobalContext()) || curType == Type::getInt16Ty(getGlobalContext())) { + new StoreInst(new SExtInst(i, Type::getInt32Ty(getGlobalContext()), "", currentBlock), intLocals[index], false, currentBlock); - } else if (curType == Type::Int32Ty) { + } else if (curType == Type::getInt32Ty(getGlobalContext())) { new StoreInst(i, intLocals[index], false, currentBlock); - } else if (curType == Type::DoubleTy) { + } else if (curType == Type::getDoubleTy(getGlobalContext())) { new StoreInst(i, doubleLocals[index], false, currentBlock); ++index; - } else if (curType == Type::FloatTy) { + } else if (curType == Type::getFloatTy(getGlobalContext())) { new StoreInst(i, floatLocals[index], false, currentBlock); } else { new StoreInst(i, objectLocals[index], false, currentBlock); @@ -1038,7 +1038,7 @@ endBlock = createBasicBlock("end"); - if (returnType != Type::VoidTy) { + if (returnType != Type::getVoidTy(getGlobalContext())) { endNode = llvm::PHINode::Create(returnType, "", endBlock); } @@ -1097,7 +1097,7 @@ // not return. pred_iterator PI = pred_begin(endBlock); pred_iterator PE = pred_end(endBlock); - if (PI == PE && returnType != Type::VoidTy) { + if (PI == PE && returnType != Type::getVoidTy(getGlobalContext())) { Instruction* I = currentBlock->getTerminator(); if (isa(I)) { @@ -1151,10 +1151,10 @@ if (PI == PE) { currentBlock->eraseFromParent(); } else { - if (returnType != Type::VoidTy) - ReturnInst::Create(endNode, currentBlock); + if (returnType != Type::getVoidTy(getGlobalContext())) + ReturnInst::Create(*llvmContext, endNode, currentBlock); else - ReturnInst::Create(currentBlock); + ReturnInst::Create(*llvmContext, currentBlock); } currentBlock = endExceptionBlock; @@ -1232,16 +1232,16 @@ } #endif } else if (type == JavaConstantPool::ConstantLong) { - push(ConstantInt::get(Type::Int64Ty, ctpInfo->LongAt(index)), + push(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), ctpInfo->LongAt(index)), false); } else if (type == JavaConstantPool::ConstantDouble) { - push(ConstantFP::get(Type::DoubleTy, ctpInfo->DoubleAt(index)), + push(ConstantFP::get(Type::getDoubleTy(getGlobalContext()), ctpInfo->DoubleAt(index)), false); } else if (type == JavaConstantPool::ConstantInteger) { - push(ConstantInt::get(Type::Int32Ty, ctpInfo->IntegerAt(index)), + push(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), ctpInfo->IntegerAt(index)), false); } else if (type == JavaConstantPool::ConstantFloat) { - push(ConstantFP::get(Type::FloatTy, ctpInfo->FloatAt(index)), + push(ConstantFP::get(Type::getFloatTy(getGlobalContext()), ctpInfo->FloatAt(index)), false); } else if (type == JavaConstantPool::ConstantClass) { UserCommonClass* cl = 0; @@ -1280,8 +1280,8 @@ const Type* arrayType, bool verif) { JITVerifyNull(obj); - if (index->getType() != Type::Int32Ty) { - index = new SExtInst(index, Type::Int32Ty, "", currentBlock); + if (index->getType() != Type::getInt32Ty(getGlobalContext())) { + index = new SExtInst(index, Type::getInt32Ty(getGlobalContext()), "", currentBlock); } if (TheCompiler->hasExceptionsEnabled()) { @@ -1329,7 +1329,7 @@ #endif for (sint32 i = start; i >= 0; --i) { it--; - if (it->get() == Type::Int64Ty || it->get() == Type::DoubleTy) { + if (it->get() == Type::getInt64Ty(getGlobalContext()) || it->get() == Type::getDoubleTy(getGlobalContext())) { pop(); } bool unsign = topIsUnsigned(); @@ -1355,23 +1355,23 @@ e = stack.end(); i!= e; ++i) { switch (*i) { case Int : { - PHINode* node = PHINode::Create(Type::Int32Ty, "", dest); - node->addIncoming(Constant::getNullValue(Type::Int32Ty), insert); + PHINode* node = PHINode::Create(Type::getInt32Ty(getGlobalContext()), "", dest); + node->addIncoming(Constant::getNullValue(Type::getInt32Ty(getGlobalContext())), insert); break; } case Float : { - PHINode* node = PHINode::Create(Type::FloatTy, "", dest); - node->addIncoming(Constant::getNullValue(Type::FloatTy), insert); + PHINode* node = PHINode::Create(Type::getFloatTy(getGlobalContext()), "", dest); + node->addIncoming(Constant::getNullValue(Type::getFloatTy(getGlobalContext())), insert); break; } case Double : { - PHINode* node = PHINode::Create(Type::DoubleTy, "", dest); - node->addIncoming(Constant::getNullValue(Type::DoubleTy), insert); + PHINode* node = PHINode::Create(Type::getDoubleTy(getGlobalContext()), "", dest); + node->addIncoming(Constant::getNullValue(Type::getDoubleTy(getGlobalContext())), insert); break; } case Long : { - PHINode* node = PHINode::Create(Type::Int64Ty, "", dest); - node->addIncoming(Constant::getNullValue(Type::Int64Ty), insert); + PHINode* node = PHINode::Create(Type::getInt64Ty(getGlobalContext()), "", dest); + node->addIncoming(Constant::getNullValue(Type::getInt64Ty(getGlobalContext())), insert); break; } case Object : { @@ -1401,7 +1401,7 @@ JnjvmBootstrapLoader* loader = compilingClass->classLoader->bootstrapLoader; if (name->equals(loader->abs)) { const Type* Ty = args[0]->getType(); - if (Ty == Type::Int32Ty) { + if (Ty == Type::getInt32Ty(getGlobalContext())) { Constant* const_int32_9 = module->constantZero; Constant* const_int32_10 = module->constantMinusOne; BinaryOperator* int32_tmpneg = @@ -1412,7 +1412,7 @@ "abscond"); return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg, "abs", currentBlock); - } else if (Ty == Type::Int64Ty) { + } else if (Ty == Type::getInt64Ty(getGlobalContext())) { Constant* const_int64_9 = module->constantLongZero; Constant* const_int64_10 = module->constantLongMinusOne; @@ -1425,10 +1425,10 @@ return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg, "abs", currentBlock); - } else if (Ty == Type::FloatTy) { + } else if (Ty == Type::getFloatTy(getGlobalContext())) { return llvm::CallInst::Create(module->func_llvm_fabs_f32, args[0], "tmp1", currentBlock); - } else if (Ty == Type::DoubleTy) { + } else if (Ty == Type::getDoubleTy(getGlobalContext())) { return llvm::CallInst::Create(module->func_llvm_fabs_f64, args[0], "tmp1", currentBlock); } @@ -1568,7 +1568,7 @@ BranchInst::Create(falseCl, trueCl, test, currentBlock); std::vector Args; Args.push_back(ctpCache); - Args.push_back(ConstantInt::get(Type::Int32Ty, index)); + Args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), index)); Args.push_back(GV); res = CallInst::Create(module->SpecialCtpLookupFunction, Args.begin(), Args.end(), "", falseCl); @@ -1598,9 +1598,9 @@ } const llvm::Type* retType = virtualType->getReturnType(); - if (retType != Type::VoidTy) { + if (retType != Type::getVoidTy(getGlobalContext())) { push(val, signature->getReturnType()->isUnsigned()); - if (retType == Type::DoubleTy || retType == Type::Int64Ty) { + if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) { push(module->constantZero, false); } } @@ -1667,9 +1667,9 @@ } const llvm::Type* retType = staticType->getReturnType(); - if (retType != Type::VoidTy) { + if (retType != Type::getVoidTy(getGlobalContext())) { push(val, signature->getReturnType()->isUnsigned()); - if (retType == Type::DoubleTy || retType == Type::Int64Ty) { + if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) { push(module->constantZero, false); } } @@ -1696,7 +1696,7 @@ Args.push_back(resolver); Args.push_back(CTP); Args.push_back(Cl); - Args.push_back(ConstantInt::get(Type::Int32Ty, index)); + Args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), index)); if (additionalArg) Args.push_back(additionalArg); Value* res = 0; @@ -1710,8 +1710,8 @@ const Type* realType = module->GetConstantPoolAtFunction->getReturnType(); - if (returnType == Type::Int32Ty) { - return new PtrToIntInst(res, Type::Int32Ty, "", currentBlock); + if (returnType == Type::getInt32Ty(getGlobalContext())) { + return new PtrToIntInst(res, Type::getInt32Ty(getGlobalContext()), "", currentBlock); } else if (returnType != realType) { return new BitCastInst(res, returnType, "", currentBlock); } @@ -1859,7 +1859,7 @@ if (stat) returnType = module->ptrType; else - returnType = Type::Int32Ty; + returnType = Type::getInt32Ty(getGlobalContext()); Value* ptr = getConstantPoolAt(index, func, returnType, 0, true); if (!stat) { @@ -1906,7 +1906,7 @@ LLVMAssessorInfo& LAI = TheCompiler->getTypedefInfo(sign); const Type* type = LAI.llvmType; - if (type == Type::Int64Ty || type == Type::DoubleTy) { + if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) { val = pop(); } @@ -1938,28 +1938,28 @@ const PrimitiveTypedef* prim = (PrimitiveTypedef*)sign; if (prim->isInt()) { sint32 val = field->getInt32Field(Obj); - push(ConstantInt::get(Type::Int32Ty, val), false); + push(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), val), false); } else if (prim->isByte()) { sint8 val = (sint8)field->getInt8Field(Obj); - push(ConstantInt::get(Type::Int8Ty, val), false); + push(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), val), false); } else if (prim->isBool()) { uint8 val = (uint8)field->getInt8Field(Obj); - push(ConstantInt::get(Type::Int8Ty, val), true); + push(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), val), true); } else if (prim->isShort()) { sint16 val = (sint16)field->getInt16Field(Obj); - push(ConstantInt::get(Type::Int16Ty, val), false); + push(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), val), false); } else if (prim->isChar()) { uint16 val = (uint16)field->getInt16Field(Obj); - push(ConstantInt::get(Type::Int16Ty, val), true); + push(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), val), true); } else if (prim->isLong()) { sint64 val = (sint64)field->getLongField(Obj); - push(ConstantInt::get(Type::Int64Ty, val), false); + push(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), val), false); } else if (prim->isFloat()) { float val = (float)field->getFloatField(Obj); - push(ConstantFP::get(Type::FloatTy, val), false); + push(ConstantFP::get(Type::getFloatTy(getGlobalContext()), val), false); } else if (prim->isDouble()) { double val = (double)field->getDoubleField(Obj); - push(ConstantFP::get(Type::DoubleTy, val), false); + push(ConstantFP::get(Type::getDoubleTy(getGlobalContext()), val), false); } else { abort(); } @@ -1980,7 +1980,7 @@ #endif if (!final) push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned()); - if (type == Type::Int64Ty || type == Type::DoubleTy) { + if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) { push(module->constantZero, false); } } @@ -1992,7 +1992,7 @@ LLVMAssessorInfo& LAI = TheCompiler->getTypedefInfo(sign); const Type* type = LAI.llvmType; - if (type == Type::Int64Ty || type == Type::DoubleTy) { + if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) { val = pop(); } @@ -2052,7 +2052,7 @@ } if (!final) push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned()); - if (type == Type::Int64Ty || type == Type::DoubleTy) { + if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) { push(module->constantZero, false); } } @@ -2077,7 +2077,7 @@ const llvm::Type* retType = virtualType->getReturnType(); BasicBlock* endBlock = createBasicBlock("end virtual invoke"); PHINode * node = 0; - if (retType != Type::VoidTy) { + if (retType != Type::getVoidTy(getGlobalContext())) { node = PHINode::Create(retType, "", endBlock); } @@ -2162,7 +2162,8 @@ currentBlock = endBlock; if (node) { push(node, signature->getReturnType()->isUnsigned()); - if (retType == Type::DoubleTy || retType == Type::Int64Ty) { + if (retType == Type::getDoubleTy(getGlobalContext()) || + retType == Type::getInt64Ty(getGlobalContext())) { push(module->constantZero, false); } } Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJIT.h Sat Aug 15 10:54:14 2009 @@ -212,28 +212,30 @@ void push(llvm::Value* val, bool unsign) { const llvm::Type* type = val->getType(); if (unsign) { - val = new llvm::ZExtInst(val, llvm::Type::Int32Ty, "", currentBlock); + val = new llvm::ZExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "", currentBlock); new llvm::StoreInst(val, intStack[currentStackIndex++], false, currentBlock); stack.push_back(Int); - } else if (type == llvm::Type::Int8Ty || type == llvm::Type::Int16Ty) { - val = new llvm::SExtInst(val, llvm::Type::Int32Ty, "", currentBlock); + } else if (type == llvm::Type::getInt8Ty(*llvmContext) || + type == llvm::Type::getInt16Ty(*llvmContext)) { + val = new llvm::SExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "", + currentBlock); new llvm::StoreInst(val, intStack[currentStackIndex++], false, currentBlock); stack.push_back(Int); - } else if (type == llvm::Type::Int32Ty) { + } else if (type == llvm::Type::getInt32Ty(*llvmContext)) { new llvm::StoreInst(val, intStack[currentStackIndex++], false, currentBlock); stack.push_back(Int); - } else if (type == llvm::Type::Int64Ty) { + } else if (type == llvm::Type::getInt64Ty(*llvmContext)) { new llvm::StoreInst(val, longStack[currentStackIndex++], false, currentBlock); stack.push_back(Long); - } else if (type == llvm::Type::FloatTy) { + } else if (type == llvm::Type::getFloatTy(*llvmContext)) { new llvm::StoreInst(val, floatStack[currentStackIndex++], false, currentBlock); stack.push_back(Float); - } else if (type == llvm::Type::DoubleTy) { + } else if (type == llvm::Type::getDoubleTy(*llvmContext)) { new llvm::StoreInst(val, doubleStack[currentStackIndex++], false, currentBlock); stack.push_back(Double); @@ -335,7 +337,7 @@ /// createBasicBlock - Create a new basic block. llvm::BasicBlock* createBasicBlock(const char* name = "") { - return llvm::BasicBlock::Create(name, llvmFunction); + return llvm::BasicBlock::Create(*llvmContext, name, llvmFunction); } /// branch - Branch based on a boolean value. Update PHI nodes accordingly. Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITCompiler.cpp Sat Aug 15 10:54:14 2009 @@ -32,45 +32,52 @@ const llvm::Type* Ty = classDef->isClass() ? JnjvmModule::JavaClassType : JnjvmModule::JavaCommonClassType; - ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(classDef)); + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64_t(classDef)); return ConstantExpr::getIntToPtr(CI, Ty); } Constant* JavaJITCompiler::getConstantPool(JavaConstantPool* ctp) { void* ptr = ctp->ctpRes; assert(ptr && "No constant pool found"); - ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(ptr)); + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64_t(ptr)); return ConstantExpr::getIntToPtr(CI, JnjvmModule::ConstantPoolType); } Constant* JavaJITCompiler::getMethodInClass(JavaMethod* meth) { - ConstantInt* CI = ConstantInt::get(Type::Int64Ty, (int64_t)meth); + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + (int64_t)meth); return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaMethodType); } Constant* JavaJITCompiler::getString(JavaString* str) { assert(str && "No string given"); - ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64(str)); + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64(str)); return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType); } Constant* JavaJITCompiler::getStringPtr(JavaString** str) { assert(str && "No string given"); const llvm::Type* Ty = PointerType::getUnqual(JnjvmModule::JavaObjectType); - ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64(str)); + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64(str)); return ConstantExpr::getIntToPtr(CI, Ty); } Constant* JavaJITCompiler::getEnveloppe(Enveloppe* enveloppe) { assert(enveloppe && "No enveloppe given"); - ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64(enveloppe)); + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64(enveloppe)); return ConstantExpr::getIntToPtr(CI, JnjvmModule::EnveloppeType); } Constant* JavaJITCompiler::getJavaClass(CommonClass* cl) { JavaObject* obj = cl->getClassDelegatee(JavaThread::get()->getJVM()); assert(obj && "Delegatee not created"); - Constant* CI = ConstantInt::get(Type::Int64Ty, uint64(obj)); + Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64(obj)); return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType); } @@ -78,7 +85,8 @@ Jnjvm* vm = JavaThread::get()->getJVM(); JavaObject* const* obj = cl->getClassDelegateePtr(vm); assert(obj && "Delegatee not created"); - Constant* CI = ConstantInt::get(Type::Int64Ty, uint64(obj)); + Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64(obj)); const Type* Ty = PointerType::getUnqual(JnjvmModule::JavaObjectType); return ConstantExpr::getIntToPtr(CI, Ty); } @@ -93,7 +101,8 @@ } Constant* JavaJITCompiler::getFinalObject(JavaObject* obj) { - Constant* CI = ConstantInt::get(Type::Int64Ty, uint64(obj)); + Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64(obj)); return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType); } @@ -112,7 +121,8 @@ } classDef->release(); } - Constant* CI = ConstantInt::get(Type::Int64Ty, (uint64_t(obj))); + Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + (uint64_t(obj))); return ConstantExpr::getIntToPtr(CI, JnjvmModule::ptrType); } @@ -122,7 +132,8 @@ LCI->getVirtualType(); } - ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(VT)); + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64_t(VT)); return ConstantExpr::getIntToPtr(CI, JnjvmModule::VTType); } @@ -132,7 +143,8 @@ assert(ptr && "No native function given"); - Constant* CI = ConstantInt::get(Type::Int64Ty, uint64_t(ptr)); + Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64_t(ptr)); return ConstantExpr::getIntToPtr(CI, valPtrType); } @@ -150,7 +162,8 @@ #ifdef SERVICE Value* JavaJITCompiler::getIsolate(Jnjvm* isolate, Value* Where) { - ConstantInt* CI = ConstantInt::get(Type::Int64Ty, uint64_t(isolate)); + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + uint64_t(isolate)); return ConstantExpr::getIntToPtr(CI, JnjvmModule::ptrType); } #endif Modified: vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JavaJITOpcodes.cpp Sat Aug 15 10:54:14 2009 @@ -152,13 +152,13 @@ } else { ++currentStackIndex; const Type* Ty = i->getType(); - if (Ty == Type::Int32Ty) { + if (Ty == Type::getInt32Ty(*llvmContext)) { stack.push_back(Int); - } else if (Ty == Type::Int64Ty) { + } else if (Ty == Type::getInt64Ty(*llvmContext)) { stack.push_back(Long); - } else if (Ty == Type::FloatTy) { + } else if (Ty == Type::getFloatTy(*llvmContext)) { stack.push_back(Float); - } else if (Ty == Type::DoubleTy) { + } else if (Ty == Type::getDoubleTy(*llvmContext)) { stack.push_back(Double); } else if (Ty == module->JavaObjectType) { stack.push_back(Object); @@ -182,8 +182,8 @@ #if JNJVM_EXECUTE > 1 { Value* args[3] = { - ConstantInt::get(Type::Int32Ty, (int64_t)bytecodes[i]), - ConstantInt::get(Type::Int32Ty, (int64_t)i), + ConstantInt::get(Type::getInt32Ty(*llvmContext), (int64_t)bytecodes[i]), + ConstantInt::get(Type::getInt32Ty(*llvmContext), (int64_t)i), TheCompiler->getMethodInClass(compilingMethod) }; @@ -262,15 +262,15 @@ break; case BIPUSH : - push(ConstantExpr::getSExt(ConstantInt::get(Type::Int8Ty, + push(ConstantExpr::getSExt(ConstantInt::get(Type::getInt8Ty(*llvmContext), bytecodes[++i]), - Type::Int32Ty), false); + Type::getInt32Ty(*llvmContext)), false); break; case SIPUSH : - push(ConstantExpr::getSExt(ConstantInt::get(Type::Int16Ty, + push(ConstantExpr::getSExt(ConstantInt::get(Type::getInt16Ty(*llvmContext), readS2(bytecodes, i)), - Type::Int32Ty), false); + Type::getInt32Ty(*llvmContext)), false); break; case LDC : @@ -470,7 +470,7 @@ Value* ptr = verifyAndComputePtr(obj, index, module->JavaArraySInt8Type); Value* val = new LoadInst(ptr, "", currentBlock); - push(new SExtInst(val, Type::Int32Ty, "", currentBlock), + push(new SExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock), false); break; } @@ -481,7 +481,7 @@ Value* ptr = verifyAndComputePtr(obj, index, module->JavaArrayUInt16Type); Value* val = new LoadInst(ptr, "", currentBlock); - push(new ZExtInst(val, Type::Int32Ty, "", currentBlock), + push(new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock), false); break; } @@ -492,7 +492,7 @@ Value* ptr = verifyAndComputePtr(obj, index, module->JavaArraySInt16Type); Value* val = new LoadInst(ptr, "", currentBlock); - push(new SExtInst(val, Type::Int32Ty, "", currentBlock), + push(new SExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock), false); break; } @@ -528,32 +528,32 @@ case ISTORE_0 : { Value* val = pop(); - if (val->getType() != Type::Int32Ty) // int8 and int16 - val = new ZExtInst(val, Type::Int32Ty, "", currentBlock); + if (val->getType() != Type::getInt32Ty(*llvmContext)) // int8 and int16 + val = new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock); new StoreInst(val, intLocals[0], false, currentBlock); break; } case ISTORE_1 : { Value* val = pop(); - if (val->getType() != Type::Int32Ty) // int8 and int16 - val = new ZExtInst(val, Type::Int32Ty, "", currentBlock); + if (val->getType() != Type::getInt32Ty(*llvmContext)) // int8 and int16 + val = new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock); new StoreInst(val, intLocals[1], false, currentBlock); break; } case ISTORE_2 : { Value* val = pop(); - if (val->getType() != Type::Int32Ty) // int8 and int16 - val = new ZExtInst(val, Type::Int32Ty, "", currentBlock); + if (val->getType() != Type::getInt32Ty(*llvmContext)) // int8 and int16 + val = new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock); new StoreInst(val, intLocals[2], false, currentBlock); break; } case ISTORE_3 : { Value* val = pop(); - if (val->getType() != Type::Int32Ty) // int8 and int16 - val = new ZExtInst(val, Type::Int32Ty, "", currentBlock); + if (val->getType() != Type::getInt32Ty(*llvmContext)) // int8 and int16 + val = new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock); new StoreInst(val, intLocals[3], false, currentBlock); break; } @@ -718,8 +718,8 @@ case BASTORE : { Value* val = pop(); - if (val->getType() != Type::Int8Ty) { - val = new TruncInst(val, Type::Int8Ty, "", currentBlock); + if (val->getType() != Type::getInt8Ty(*llvmContext)) { + val = new TruncInst(val, Type::getInt8Ty(*llvmContext), "", currentBlock); } Value* index = pop(); Value* obj = pop(); @@ -732,10 +732,10 @@ case CASTORE : { Value* val = pop(); const Type* type = val->getType(); - if (type == Type::Int32Ty) { - val = new TruncInst(val, Type::Int16Ty, "", currentBlock); - } else if (type == Type::Int8Ty) { - val = new ZExtInst(val, Type::Int16Ty, "", currentBlock); + if (type == Type::getInt32Ty(*llvmContext)) { + val = new TruncInst(val, Type::getInt16Ty(*llvmContext), "", currentBlock); + } else if (type == Type::getInt8Ty(*llvmContext)) { + val = new ZExtInst(val, Type::getInt16Ty(*llvmContext), "", currentBlock); } Value* index = pop(); Value* obj = pop(); @@ -748,10 +748,10 @@ case SASTORE : { Value* val = pop(); const Type* type = val->getType(); - if (type == Type::Int32Ty) { - val = new TruncInst(val, Type::Int16Ty, "", currentBlock); - } else if (type == Type::Int8Ty) { - val = new SExtInst(val, Type::Int16Ty, "", currentBlock); + if (type == Type::getInt32Ty(*llvmContext)) { + val = new TruncInst(val, Type::getInt16Ty(*llvmContext), "", currentBlock); + } else if (type == Type::getInt8Ty(*llvmContext)) { + val = new SExtInst(val, Type::getInt16Ty(*llvmContext), "", currentBlock); } Value* index = pop(); Value* obj = pop(); @@ -1096,7 +1096,7 @@ } case LSHL : { - Value* val2 = new ZExtInst(pop(), Type::Int64Ty, "", currentBlock); + Value* val2 = new ZExtInst(pop(), Type::getInt64Ty(*llvmContext), "", currentBlock); pop(); // remove the 0 on the stack Value* val1 = pop(); push(BinaryOperator::CreateShl(val1, val2, "", currentBlock), @@ -1114,7 +1114,7 @@ } case LSHR : { - Value* val2 = new ZExtInst(pop(), Type::Int64Ty, "", currentBlock); + Value* val2 = new ZExtInst(pop(), Type::getInt64Ty(*llvmContext), "", currentBlock); pop(); // remove the 0 on the stack Value* val1 = pop(); push(BinaryOperator::CreateAShr(val1, val2, "", currentBlock), @@ -1126,7 +1126,7 @@ case IUSHR : { Value* val2 = popAsInt(); Value* val1 = popAsInt(); - Value* mask = ConstantInt::get(Type::Int32Ty, 0x1F); + Value* mask = ConstantInt::get(Type::getInt32Ty(*llvmContext), 0x1F); val2 = BinaryOperator::CreateAnd(val2, mask, "", currentBlock); push(BinaryOperator::CreateLShr(val1, val2, "", currentBlock), false); @@ -1134,8 +1134,8 @@ } case LUSHR : { - Value* val2 = new ZExtInst(pop(), Type::Int64Ty, "", currentBlock); - Value* mask = ConstantInt::get(Type::Int64Ty, 0x3F); + Value* val2 = new ZExtInst(pop(), Type::getInt64Ty(*llvmContext), "", currentBlock); + Value* mask = ConstantInt::get(Type::getInt64Ty(*llvmContext), 0x3F); val2 = BinaryOperator::CreateAnd(val2, mask, "", currentBlock); pop(); // remove the 0 on the stack Value* val1 = pop(); @@ -1207,44 +1207,44 @@ sint16 val = WREAD_S1(bytecodes, false, i, wide); llvm::Value* add = BinaryOperator::CreateAdd( new LoadInst(intLocals[idx], "", currentBlock), - ConstantInt::get(Type::Int32Ty, val), "", + ConstantInt::get(Type::getInt32Ty(*llvmContext), val), "", currentBlock); new StoreInst(add, intLocals[idx], false, currentBlock); break; } case I2L : - push(new SExtInst(pop(), llvm::Type::Int64Ty, "", currentBlock), + push(new SExtInst(pop(), llvm::Type::getInt64Ty(*llvmContext), "", currentBlock), false); push(module->constantZero, false); break; case I2F : - push(new SIToFPInst(pop(), llvm::Type::FloatTy, "", currentBlock), + push(new SIToFPInst(pop(), llvm::Type::getFloatTy(*llvmContext), "", currentBlock), false); break; case I2D : - push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock), + push(new SIToFPInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock), false); push(module->constantZero, false); break; case L2I : pop(); - push(new TruncInst(pop(), llvm::Type::Int32Ty, "", currentBlock), + push(new TruncInst(pop(), llvm::Type::getInt32Ty(*llvmContext), "", currentBlock), false); break; case L2F : pop(); - push(new SIToFPInst(pop(), llvm::Type::FloatTy, "", currentBlock), + push(new SIToFPInst(pop(), llvm::Type::getFloatTy(*llvmContext), "", currentBlock), false); break; case L2D : pop(); - push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock), + push(new SIToFPInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock), false); push(module->constantZero, false); break; @@ -1255,7 +1255,7 @@ val, val, ""); BasicBlock* res = createBasicBlock("F2I"); - PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res); + PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res); node->addIncoming(module->constantZero, currentBlock); BasicBlock* cont = createBasicBlock("F2I"); @@ -1283,7 +1283,7 @@ node->addIncoming(module->constantMinInt, currentBlock); currentBlock = cont; - llvm::Value* newVal = new FPToSIInst(val, Type::Int32Ty, "", + llvm::Value* newVal = new FPToSIInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock); BranchInst::Create(res, currentBlock); @@ -1301,7 +1301,7 @@ val, val, ""); BasicBlock* res = createBasicBlock("F2L"); - PHINode* node = PHINode::Create(llvm::Type::Int64Ty, "", res); + PHINode* node = PHINode::Create(llvm::Type::getInt64Ty(*llvmContext), "", res); node->addIncoming(module->constantLongZero, currentBlock); BasicBlock* cont = createBasicBlock("F2L"); @@ -1328,7 +1328,7 @@ node->addIncoming(module->constantMinLong, currentBlock); currentBlock = cont; - llvm::Value* newVal = new FPToSIInst(val, Type::Int64Ty, "", + llvm::Value* newVal = new FPToSIInst(val, Type::getInt64Ty(*llvmContext), "", currentBlock); BranchInst::Create(res, currentBlock); @@ -1342,7 +1342,7 @@ } case F2D : - push(new FPExtInst(pop(), llvm::Type::DoubleTy, "", currentBlock), + push(new FPExtInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock), false); push(module->constantZero, false); break; @@ -1354,7 +1354,7 @@ val, val, ""); BasicBlock* res = createBasicBlock("D2I"); - PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res); + PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res); node->addIncoming(module->constantZero, currentBlock); BasicBlock* cont = createBasicBlock("D2I"); @@ -1381,7 +1381,7 @@ node->addIncoming(module->constantMinInt, currentBlock); currentBlock = cont; - llvm::Value* newVal = new FPToSIInst(val, Type::Int32Ty, "", + llvm::Value* newVal = new FPToSIInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock); BranchInst::Create(res, currentBlock); @@ -1401,7 +1401,7 @@ val, val, ""); BasicBlock* res = createBasicBlock("D2L"); - PHINode* node = PHINode::Create(llvm::Type::Int64Ty, "", res); + PHINode* node = PHINode::Create(llvm::Type::getInt64Ty(*llvmContext), "", res); node->addIncoming(module->constantLongZero, currentBlock); BasicBlock* cont = createBasicBlock("D2L"); @@ -1429,7 +1429,7 @@ node->addIncoming(module->constantMinLong, currentBlock); currentBlock = cont; - llvm::Value* newVal = new FPToSIInst(val, Type::Int64Ty, "", + llvm::Value* newVal = new FPToSIInst(val, Type::getInt64Ty(*llvmContext), "", currentBlock); BranchInst::Create(res, currentBlock); @@ -1444,36 +1444,36 @@ case D2F : pop(); // remove the 0 on the stack - push(new FPTruncInst(pop(), llvm::Type::FloatTy, "", currentBlock), + push(new FPTruncInst(pop(), llvm::Type::getFloatTy(*llvmContext), "", currentBlock), false); break; case I2B : { Value* val = pop(); - if (val->getType() == Type::Int32Ty) { - val = new TruncInst(val, llvm::Type::Int8Ty, "", currentBlock); + if (val->getType() == Type::getInt32Ty(*llvmContext)) { + val = new TruncInst(val, llvm::Type::getInt8Ty(*llvmContext), "", currentBlock); } - push(new SExtInst(val, llvm::Type::Int32Ty, "", currentBlock), + push(new SExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "", currentBlock), false); break; } case I2C : { Value* val = pop(); - if (val->getType() == Type::Int32Ty) { - val = new TruncInst(val, llvm::Type::Int16Ty, "", currentBlock); + if (val->getType() == Type::getInt32Ty(*llvmContext)) { + val = new TruncInst(val, llvm::Type::getInt16Ty(*llvmContext), "", currentBlock); } - push(new ZExtInst(val, llvm::Type::Int32Ty, "", currentBlock), + push(new ZExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "", currentBlock), false); break; } case I2S : { Value* val = pop(); - if (val->getType() == Type::Int32Ty) { - val = new TruncInst(val, llvm::Type::Int16Ty, "", currentBlock); + if (val->getType() == Type::getInt32Ty(*llvmContext)) { + val = new TruncInst(val, llvm::Type::getInt16Ty(*llvmContext), "", currentBlock); } - push(new SExtInst(val, llvm::Type::Int32Ty, "", currentBlock), + push(new SExtInst(val, llvm::Type::getInt32Ty(*llvmContext), "", currentBlock), false); break; } @@ -1489,7 +1489,7 @@ BasicBlock* cont = createBasicBlock("LCMP"); BasicBlock* res = createBasicBlock("LCMP"); - PHINode* node = PHINode::Create(llvm::Type::Int32Ty, "", res); + PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res); node->addIncoming(module->constantZero, currentBlock); BranchInst::Create(res, cont, test, currentBlock); @@ -1512,14 +1512,14 @@ case FCMPL : { llvm::Value* val2 = pop(); llvm::Value* val1 = pop(); - compareFP(val1, val2, Type::FloatTy, false); + compareFP(val1, val2, Type::getFloatTy(*llvmContext), false); break; } case FCMPG : { llvm::Value* val2 = pop(); llvm::Value* val1 = pop(); - compareFP(val1, val2, Type::FloatTy, true); + compareFP(val1, val2, Type::getFloatTy(*llvmContext), true); break; } @@ -1529,7 +1529,7 @@ pop(); llvm::Value* val1 = pop(); - compareFP(val1, val2, Type::DoubleTy, false); + compareFP(val1, val2, Type::getDoubleTy(*llvmContext), false); break; } @@ -1539,7 +1539,7 @@ pop(); llvm::Value* val1 = pop(); - compareFP(val1, val2, Type::DoubleTy, false); + compareFP(val1, val2, Type::getDoubleTy(*llvmContext), false); break; } @@ -1743,7 +1743,7 @@ case JSR : { uint32 tmp = i; Value* expr = ConstantExpr::getIntToPtr( - ConstantInt::get(Type::Int64Ty, + ConstantInt::get(Type::getInt64Ty(*llvmContext), uint64_t (jsrIndex++)), module->JavaObjectType); push(expr, false); @@ -1755,14 +1755,14 @@ case RET : { uint8 local = readU1(bytecodes, i); Value* _val = new LoadInst(objectLocals[local], "", currentBlock); - Value* val = new PtrToIntInst(_val, Type::Int32Ty, "", currentBlock); + Value* val = new PtrToIntInst(_val, Type::getInt32Ty(*llvmContext), "", currentBlock); SwitchInst* inst = SwitchInst::Create(val, jsrs[0], jsrs.size(), currentBlock); uint32 index = 0; for (std::vector::iterator i = jsrs.begin(), e = jsrs.end(); i!= e; ++i, ++index) { - inst->addCase(ConstantInt::get(Type::Int32Ty, index), *i); + inst->addCase(ConstantInt::get(Type::getInt32Ty(*llvmContext), index), *i); } break; @@ -1808,12 +1808,12 @@ Value* key = pop(); const Type* type = key->getType(); if (unsign) { - key = new ZExtInst(key, Type::Int32Ty, "", currentBlock); - } else if (type == Type::Int8Ty || type == Type::Int16Ty) { - key = new SExtInst(key, Type::Int32Ty, "", currentBlock); + key = new ZExtInst(key, Type::getInt32Ty(*llvmContext), "", currentBlock); + } else if (type == Type::getInt8Ty(*llvmContext) || type == Type::getInt16Ty(*llvmContext)) { + key = new SExtInst(key, Type::getInt32Ty(*llvmContext), "", currentBlock); } for (uint32 cur = 0; cur < nbs; ++cur) { - Value* val = ConstantInt::get(Type::Int32Ty, readU4(bytecodes, i)); + Value* val = ConstantInt::get(Type::getInt32Ty(*llvmContext), readU4(bytecodes, i)); Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, key, ""); BasicBlock* falseBlock = createBasicBlock("continue lookupswitch"); @@ -1938,13 +1938,13 @@ valCl = TheCompiler->getNativeClass(dcl); #else Value* args[2] = { isolateLocal, - ConstantInt::get(Type::Int32Ty, id - 4) }; + ConstantInt::get(Type::getInt32Ty(*llvmContext), id - 4) }; valCl = CallInst::Create(module->GetJnjvmArrayClassFunction, args, args + 2, "", currentBlock); #endif LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[charId]; - sizeElement = ConstantInt::get(Type::Int32Ty, + sizeElement = ConstantInt::get(Type::getInt32Ty(*llvmContext), LAI.logSizeInBytesConstant); if (TheCompiler->isStaticCompiling() && valCl->getType() != module->JavaClassArrayType) { @@ -2074,7 +2074,7 @@ Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj, module->JavaObjectNullConstant, ""); BasicBlock* endBlock = createBasicBlock("end type compare"); - PHINode* node = PHINode::Create(Type::Int1Ty, "", endBlock); + PHINode* node = PHINode::Create(Type::getInt1Ty(*llvmContext), "", endBlock); if (checkcast) { exceptionCheckcast = createBasicBlock("false checkcast"); @@ -2118,7 +2118,7 @@ objVT, "", currentBlock); uint32 depth = cl->virtualVT->depth; - ConstantInt* CI = ConstantInt::get(Type::Int32Ty, depth); + ConstantInt* CI = ConstantInt::get(Type::getInt32Ty(*llvmContext), depth); Value* displayArgs[2] = { inDisplay, CI }; Value* VTInDisplay = CallInst::Create(module->GetVTInDisplayFunction, @@ -2144,7 +2144,7 @@ currentBlock = endCheckcast; } else { pop(); - push(new ZExtInst(node, Type::Int32Ty, "", currentBlock), + push(new ZExtInst(node, Type::getInt32Ty(*llvmContext), "", currentBlock), false); } @@ -2173,7 +2173,7 @@ Value* valCl = getResolvedCommonClass(index, true, 0); Value** args = (Value**)alloca(sizeof(Value*) * (dim + 2)); args[0] = valCl; - args[1] = ConstantInt::get(Type::Int32Ty, dim); + args[1] = ConstantInt::get(Type::getInt32Ty(*llvmContext), dim); for (int cur = dim + 1; cur >= 2; --cur) args[cur] = pop(); Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModule.cpp Sat Aug 15 10:54:14 2009 @@ -175,10 +175,10 @@ JavaObjectNullConstant = Constant::getNullValue(JnjvmModule::JavaObjectType); - MaxArraySizeConstant = ConstantInt::get(Type::Int32Ty, + MaxArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), JavaArray::MaxArraySize); - JavaArraySizeConstant = - ConstantInt::get(Type::Int32Ty, sizeof(JavaObject) + sizeof(ssize_t)); + JavaArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + sizeof(JavaObject) + sizeof(ssize_t)); JavaArrayElementsOffsetConstant = constantTwo; @@ -188,22 +188,30 @@ OffsetClassInVTConstant = constantThree; OffsetDepthInVTConstant = constantFour; OffsetDisplayInVTConstant = constantSeven; - OffsetBaseClassVTInVTConstant = ConstantInt::get(Type::Int32Ty, 17); + OffsetBaseClassVTInVTConstant = + ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 17); OffsetObjectSizeInClassConstant = constantOne; - OffsetVTInClassConstant = ConstantInt::get(Type::Int32Ty, 7); + OffsetVTInClassConstant = + ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 7); OffsetTaskClassMirrorInClassConstant = constantTwo; OffsetStaticInstanceInTaskClassMirrorConstant = constantTwo; OffsetStatusInTaskClassMirrorConstant = constantZero; OffsetInitializedInTaskClassMirrorConstant = constantOne; - OffsetIsolateInThreadConstant = ConstantInt::get(Type::Int32Ty, 3); - OffsetDoYieldInThreadConstant = ConstantInt::get(Type::Int32Ty, 6); - OffsetJNIInThreadConstant = ConstantInt::get(Type::Int32Ty, 12); - OffsetJavaExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 13); - OffsetCXXExceptionInThreadConstant = ConstantInt::get(Type::Int32Ty, 14); + OffsetIsolateInThreadConstant = + ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 3); + OffsetDoYieldInThreadConstant = + ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 6); + OffsetJNIInThreadConstant = + ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 12); + OffsetJavaExceptionInThreadConstant = + ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 13); + OffsetCXXExceptionInThreadConstant = + ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 14); - ClassReadyConstant = ConstantInt::get(Type::Int8Ty, ready); + ClassReadyConstant = + ConstantInt::get(Type::getInt8Ty(getGlobalContext()), ready); module->addTypeName("JavaObject", JavaObjectType->getContainedType(0)); module->addTypeName("JavaArray", JavaArrayType->getContainedType(0)); Modified: vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/LowerConstantCalls.cpp Sat Aug 15 10:54:14 2009 @@ -169,7 +169,7 @@ Value* ptr = GetElementPtrInst::Create(array, args, args + 2, "", CI); Value* load = new LoadInst(ptr, "", CI); - load = new PtrToIntInst(load, Type::Int32Ty, "", CI); + load = new PtrToIntInst(load, Type::getInt32Ty(*Context), "", CI); CI->replaceAllUsesWith(load); CI->eraseFromParent(); } else if (V == module->GetVTFunction) { @@ -265,7 +265,7 @@ Value* DepthPtr = GetElementPtrInst::Create(val, indexes, indexes + 2, "", CI); Value* Depth = new LoadInst(DepthPtr, "", CI); - Depth = new PtrToIntInst(Depth, Type::Int32Ty, "", CI); + Depth = new PtrToIntInst(Depth, Type::getInt32Ty(*Context), "", CI); CI->replaceAllUsesWith(Depth); CI->eraseFromParent(); } else if (V == module->GetDisplayFunction) { @@ -307,8 +307,8 @@ Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, Del, module->JavaObjectNullConstant, ""); - BasicBlock* NoDelegatee = BasicBlock::Create("No delegatee", &F); - BasicBlock* DelegateeOK = BasicBlock::Create("Delegatee OK", &F); + BasicBlock* NoDelegatee = BasicBlock::Create(*Context, "No delegatee", &F); + BasicBlock* DelegateeOK = BasicBlock::Create(*Context, "Delegatee OK", &F); BranchInst::Create(NoDelegatee, DelegateeOK, cmp, CI); PHINode* phi = PHINode::Create(module->JavaObjectType, "", DelegateeOK); phi->addIncoming(Del, CI->getParent()); @@ -346,8 +346,8 @@ Value* test = new LoadInst(StatusPtr, "", CI); - BasicBlock* trueCl = BasicBlock::Create("Initialized", &F); - BasicBlock* falseCl = BasicBlock::Create("Uninitialized", &F); + BasicBlock* trueCl = BasicBlock::Create(*Context, "Initialized", &F); + BasicBlock* falseCl = BasicBlock::Create(*Context, "Uninitialized", &F); PHINode* node = llvm::PHINode::Create(JnjvmModule::JavaClassType, "", trueCl); node->addIncoming(Cl, CI->getParent()); BranchInst::Create(trueCl, falseCl, test, CI); @@ -416,7 +416,7 @@ ConstantInt* Cons = dyn_cast(Index); assert(CI && "Wrong use of GetConstantPoolAt"); uint64 val = Cons->getZExtValue(); - Value* indexes = ConstantInt::get(Type::Int32Ty, val + 1); + Value* indexes = ConstantInt::get(Type::getInt32Ty(*Context), val + 1); #else Value* indexes = Index; #endif @@ -425,8 +425,8 @@ Value* test = new ICmpInst(CI, ICmpInst::ICMP_EQ, arg1, module->constantPtrNull, ""); - BasicBlock* trueCl = BasicBlock::Create("Ctp OK", &F); - BasicBlock* falseCl = BasicBlock::Create("Ctp Not OK", &F); + BasicBlock* trueCl = BasicBlock::Create(*Context, "Ctp OK", &F); + BasicBlock* falseCl = BasicBlock::Create(*Context, "Ctp Not OK", &F); PHINode* node = llvm::PHINode::Create(returnType, "", trueCl); node->addIncoming(arg1, CI->getParent()); BranchInst::Create(falseCl, trueCl, test, CI); @@ -495,8 +495,8 @@ Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, LoadedGV, init, ""); - BasicBlock* OKBlock = BasicBlock::Create("", &F); - BasicBlock* NotOKBlock = BasicBlock::Create("", &F); + BasicBlock* OKBlock = BasicBlock::Create(*Context, "", &F); + BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "", &F); PHINode* node = PHINode::Create(module->JavaClassArrayType, "", OKBlock); node->addIncoming(LoadedGV, CI->getParent()); @@ -538,17 +538,17 @@ BasicBlock* EndBlock = II->getParent()->splitBasicBlock(II); I->getParent()->getTerminator()->eraseFromParent(); - BasicBlock* CurEndBlock = BasicBlock::Create("", &F); - BasicBlock* FailedBlock = BasicBlock::Create("", &F); - PHINode* node = PHINode::Create(Type::Int1Ty, "", CurEndBlock); + BasicBlock* CurEndBlock = BasicBlock::Create(*Context, "", &F); + BasicBlock* FailedBlock = BasicBlock::Create(*Context, "", &F); + PHINode* node = PHINode::Create(Type::getInt1Ty(*Context), "", CurEndBlock); - ConstantInt* CC = ConstantInt::get(Type::Int32Ty, + ConstantInt* CC = ConstantInt::get(Type::getInt32Ty(*Context), JavaVirtualTable::getOffsetIndex()); Value* indices[2] = { module->constantZero, CC }; Value* Offset = GetElementPtrInst::Create(VT2, indices, indices + 2, "", CI); Offset = new LoadInst(Offset, "", false, CI); - Offset = new PtrToIntInst(Offset, Type::Int32Ty, "", CI); + Offset = new PtrToIntInst(Offset, Type::getInt32Ty(*Context), "", CI); indices[1] = Offset; Value* CurVT = GetElementPtrInst::Create(VT1, indices, indices + 2, "", CI); @@ -586,21 +586,21 @@ I->getParent()->getTerminator()->eraseFromParent(); - BasicBlock* Preheader = BasicBlock::Create("preheader", &F); - BasicBlock* BB4 = BasicBlock::Create("BB4", &F); - BasicBlock* BB5 = BasicBlock::Create("BB5", &F); - BasicBlock* BB6 = BasicBlock::Create("BB6", &F); - BasicBlock* BB7 = BasicBlock::Create("BB7", &F); - BasicBlock* BB9 = BasicBlock::Create("BB9", &F); + BasicBlock* Preheader = BasicBlock::Create(*Context, "preheader", &F); + BasicBlock* BB4 = BasicBlock::Create(*Context, "BB4", &F); + BasicBlock* BB5 = BasicBlock::Create(*Context, "BB5", &F); + BasicBlock* BB6 = BasicBlock::Create(*Context, "BB6", &F); + BasicBlock* BB7 = BasicBlock::Create(*Context, "BB7", &F); + BasicBlock* BB9 = BasicBlock::Create(*Context, "BB9", &F); const Type* Ty = PointerType::getUnqual(module->VTType); - PHINode* resFwd = PHINode::Create(Type::Int32Ty, "", BB7); + PHINode* resFwd = PHINode::Create(Type::getInt32Ty(*Context), "", BB7); // This corresponds to: // if (VT1.cache == VT2 || VT1 == VT2) goto end with true; // else goto headerLoop; ConstantInt* cacheIndex = - ConstantInt::get(Type::Int32Ty, JavaVirtualTable::getCacheIndex()); + ConstantInt::get(Type::getInt32Ty(*Context), JavaVirtualTable::getCacheIndex()); Value* indices[2] = { module->constantZero, cacheIndex }; Instruction* CachePtr = GetElementPtrInst::Create(VT1, indices, indices + 2, "", CI); @@ -618,16 +618,16 @@ // size = VT1->nbSecondaryTypes; // i = 0; // goto test; - ConstantInt* sizeIndex = ConstantInt::get(Type::Int32Ty, + ConstantInt* sizeIndex = ConstantInt::get(Type::getInt32Ty(*Context), JavaVirtualTable::getNumSecondaryTypesIndex()); indices[1] = sizeIndex; Instruction* Size = GetElementPtrInst::Create(VT1, indices, indices + 2, "", Preheader); Size = new LoadInst(Size, "", false, Preheader); - Size = new PtrToIntInst(Size, Type::Int32Ty, "", Preheader); + Size = new PtrToIntInst(Size, Type::getInt32Ty(*Context), "", Preheader); - ConstantInt* secondaryTypesIndex = ConstantInt::get(Type::Int32Ty, + ConstantInt* secondaryTypesIndex = ConstantInt::get(Type::getInt32Ty(*Context), JavaVirtualTable::getSecondaryTypesIndex()); indices[1] = secondaryTypesIndex; Instruction* secondaryTypes = @@ -674,7 +674,7 @@ BranchInst::Create(BB9, BB5); // Final block, that gets the result. - PHINode* node = PHINode::Create(Type::Int1Ty, "", BB9); + PHINode* node = PHINode::Create(Type::getInt1Ty(*Context), "", BB9); node->reserveOperandSpace(3); node->addIncoming(ConstantInt::getTrue(*Context), CI->getParent()); node->addIncoming(ConstantInt::getFalse(*Context), BB7); Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaTypes.h Sat Aug 15 10:54:14 2009 @@ -91,6 +91,42 @@ virtual bool isUnsigned() const { return false; } + + virtual bool isVoid() const { + return false; + } + + virtual bool isLong() const { + return false; + } + + virtual bool isInt() const { + return false; + } + + virtual bool isChar() const { + return false; + } + + virtual bool isShort() const { + return false; + } + + virtual bool isByte() const { + return false; + } + + virtual bool isBool() const { + return false; + } + + virtual bool isFloat() const { + return false; + } + + virtual bool isDouble() const { + return false; + } /// getName - Get the name of the type, i.e. java.lang.String or /// I. @@ -142,39 +178,39 @@ charId = i; } - bool isVoid() const { + virtual bool isVoid() const { return charId == I_VOID; } - bool isLong() const { + virtual bool isLong() const { return charId == I_LONG; } - bool isInt() const { + virtual bool isInt() const { return charId == I_INT; } - bool isChar() const { + virtual bool isChar() const { return charId == I_CHAR; } - bool isShort() const { + virtual bool isShort() const { return charId == I_SHORT; } - bool isByte() const { + virtual bool isByte() const { return charId == I_BYTE; } - bool isBool() const { + virtual bool isBool() const { return charId == I_BOOL; } - bool isFloat() const { + virtual bool isFloat() const { return charId == I_FLOAT; } - bool isDouble() const { + virtual bool isDouble() const { return charId == I_DOUBLE; } Modified: vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp Sat Aug 15 10:54:14 2009 @@ -168,7 +168,8 @@ bool EscapeAnalysis::processMalloc(Instruction* I, Value* Size, Value* VT, Loop* CurLoop) { Instruction* Alloc = I; - + LLVMContext& Context = Alloc->getParent()->getContext(); + ConstantInt* CI = dyn_cast(Size); bool hasFinalizer = true; @@ -219,7 +220,8 @@ BB->getInstList().insert(BB->getTerminator(), Alloc); } - AllocaInst* AI = new AllocaInst(Type::Int8Ty, Size, "", Alloc); + AllocaInst* AI = new AllocaInst(Type::getInt8Ty(Context), Size, "", + Alloc); BitCastInst* BI = new BitCastInst(AI, Alloc->getType(), "", Alloc); DOUT << "escape" << Alloc->getParent()->getParent()->getNameStr() << "\n"; Alloc->replaceAllUsesWith(BI); Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sat Aug 15 10:54:14 2009 @@ -54,9 +54,9 @@ llvm::NoFramePointerElim = true; llvm::DisablePrettyStackTrace = true; #if DWARF_EXCEPTIONS - llvm::ExceptionHandling = true; + llvm::DwarfExceptionHandling = true; #else - llvm::ExceptionHandling = false; + llvm::DwarfExceptionHandling = false; #endif if (!M) { globalModule = new Module("bootstrap module", getGlobalContext()); @@ -83,12 +83,13 @@ mvm::llvm_runtime::makeLLVMModuleContents(globalModule); + LLVMContext& Context = globalModule->getContext(); // Type declaration - ptrType = PointerType::getUnqual(Type::Int8Ty); - ptr32Type = PointerType::getUnqual(Type::Int32Ty); + ptrType = PointerType::getUnqual(Type::getInt8Ty(Context)); + ptr32Type = PointerType::getUnqual(Type::getInt32Ty(Context)); ptrPtrType = PointerType::getUnqual(ptrType); pointerSizeType = globalModule->getPointerSize() == Module::Pointer32 ? - Type::Int32Ty : Type::Int64Ty; + Type::getInt32Ty(Context) : Type::getInt64Ty(Context); } @@ -97,59 +98,59 @@ module->setDataLayout(globalModule->getDataLayout()); module->setTargetTriple(globalModule->getTargetTriple()); - + LLVMContext& Context = module->getContext(); // Constant declaration - constantLongMinusOne = ConstantInt::get(Type::Int64Ty, (uint64_t)-1); - constantLongZero = ConstantInt::get(Type::Int64Ty, 0); - constantLongOne = ConstantInt::get(Type::Int64Ty, 1); - constantZero = ConstantInt::get(Type::Int32Ty, 0); - constantInt8Zero = ConstantInt::get(Type::Int8Ty, 0); - constantOne = ConstantInt::get(Type::Int32Ty, 1); - constantTwo = ConstantInt::get(Type::Int32Ty, 2); - constantThree = ConstantInt::get(Type::Int32Ty, 3); - constantFour = ConstantInt::get(Type::Int32Ty, 4); - constantFive = ConstantInt::get(Type::Int32Ty, 5); - constantSix = ConstantInt::get(Type::Int32Ty, 6); - constantSeven = ConstantInt::get(Type::Int32Ty, 7); - constantEight = ConstantInt::get(Type::Int32Ty, 8); - constantMinusOne = ConstantInt::get(Type::Int32Ty, (uint64_t)-1); - constantMinInt = ConstantInt::get(Type::Int32Ty, MinInt); - constantMaxInt = ConstantInt::get(Type::Int32Ty, MaxInt); - constantMinLong = ConstantInt::get(Type::Int64Ty, MinLong); - constantMaxLong = ConstantInt::get(Type::Int64Ty, MaxLong); - constantFloatZero = ConstantFP::get(Type::FloatTy, 0.0f); - constantFloatOne = ConstantFP::get(Type::FloatTy, 1.0f); - constantFloatTwo = ConstantFP::get(Type::FloatTy, 2.0f); - constantDoubleZero = ConstantFP::get(Type::DoubleTy, 0.0); - constantDoubleOne = ConstantFP::get(Type::DoubleTy, 1.0); - constantMaxIntFloat = ConstantFP::get(Type::FloatTy, MaxIntFloat); - constantMinIntFloat = ConstantFP::get(Type::FloatTy, MinIntFloat); - constantMinLongFloat = ConstantFP::get(Type::FloatTy, MinLongFloat); - constantMinLongDouble = ConstantFP::get(Type::DoubleTy, MinLongDouble); - constantMaxLongFloat = ConstantFP::get(Type::FloatTy, MaxLongFloat); - constantMaxIntDouble = ConstantFP::get(Type::DoubleTy, MaxIntDouble); - constantMinIntDouble = ConstantFP::get(Type::DoubleTy, MinIntDouble); - constantMaxLongDouble = ConstantFP::get(Type::DoubleTy, MaxLongDouble); - constantMaxLongDouble = ConstantFP::get(Type::DoubleTy, MaxLongDouble); - constantFloatInfinity = ConstantFP::get(Type::FloatTy, MaxFloat); - constantFloatMinusInfinity = ConstantFP::get(Type::FloatTy, MinFloat); - constantDoubleInfinity = ConstantFP::get(Type::DoubleTy, MaxDouble); - constantDoubleMinusInfinity = ConstantFP::get(Type::DoubleTy, MinDouble); - constantDoubleMinusZero = ConstantFP::get(Type::DoubleTy, -0.0); - constantFloatMinusZero = ConstantFP::get(Type::FloatTy, -0.0f); + constantLongMinusOne = ConstantInt::get(Type::getInt64Ty(Context), (uint64_t)-1); + constantLongZero = ConstantInt::get(Type::getInt64Ty(Context), 0); + constantLongOne = ConstantInt::get(Type::getInt64Ty(Context), 1); + constantZero = ConstantInt::get(Type::getInt32Ty(Context), 0); + constantInt8Zero = ConstantInt::get(Type::getInt8Ty(Context), 0); + constantOne = ConstantInt::get(Type::getInt32Ty(Context), 1); + constantTwo = ConstantInt::get(Type::getInt32Ty(Context), 2); + constantThree = ConstantInt::get(Type::getInt32Ty(Context), 3); + constantFour = ConstantInt::get(Type::getInt32Ty(Context), 4); + constantFive = ConstantInt::get(Type::getInt32Ty(Context), 5); + constantSix = ConstantInt::get(Type::getInt32Ty(Context), 6); + constantSeven = ConstantInt::get(Type::getInt32Ty(Context), 7); + constantEight = ConstantInt::get(Type::getInt32Ty(Context), 8); + constantMinusOne = ConstantInt::get(Type::getInt32Ty(Context), (uint64_t)-1); + constantMinInt = ConstantInt::get(Type::getInt32Ty(Context), MinInt); + constantMaxInt = ConstantInt::get(Type::getInt32Ty(Context), MaxInt); + constantMinLong = ConstantInt::get(Type::getInt64Ty(Context), MinLong); + constantMaxLong = ConstantInt::get(Type::getInt64Ty(Context), MaxLong); + constantFloatZero = ConstantFP::get(Type::getFloatTy(Context), 0.0f); + constantFloatOne = ConstantFP::get(Type::getFloatTy(Context), 1.0f); + constantFloatTwo = ConstantFP::get(Type::getFloatTy(Context), 2.0f); + constantDoubleZero = ConstantFP::get(Type::getDoubleTy(Context), 0.0); + constantDoubleOne = ConstantFP::get(Type::getDoubleTy(Context), 1.0); + constantMaxIntFloat = ConstantFP::get(Type::getFloatTy(Context), MaxIntFloat); + constantMinIntFloat = ConstantFP::get(Type::getFloatTy(Context), MinIntFloat); + constantMinLongFloat = ConstantFP::get(Type::getFloatTy(Context), MinLongFloat); + constantMinLongDouble = ConstantFP::get(Type::getDoubleTy(Context), MinLongDouble); + constantMaxLongFloat = ConstantFP::get(Type::getFloatTy(Context), MaxLongFloat); + constantMaxIntDouble = ConstantFP::get(Type::getDoubleTy(Context), MaxIntDouble); + constantMinIntDouble = ConstantFP::get(Type::getDoubleTy(Context), MinIntDouble); + constantMaxLongDouble = ConstantFP::get(Type::getDoubleTy(Context), MaxLongDouble); + constantMaxLongDouble = ConstantFP::get(Type::getDoubleTy(Context), MaxLongDouble); + constantFloatInfinity = ConstantFP::get(Type::getFloatTy(Context), MaxFloat); + constantFloatMinusInfinity = ConstantFP::get(Type::getFloatTy(Context), MinFloat); + constantDoubleInfinity = ConstantFP::get(Type::getDoubleTy(Context), MaxDouble); + constantDoubleMinusInfinity = ConstantFP::get(Type::getDoubleTy(Context), MinDouble); + constantDoubleMinusZero = ConstantFP::get(Type::getDoubleTy(Context), -0.0); + constantFloatMinusZero = ConstantFP::get(Type::getFloatTy(Context), -0.0f); constantThreadIDMask = ConstantInt::get(pointerSizeType, mvm::Thread::IDMask); constantStackOverflowMask = ConstantInt::get(pointerSizeType, mvm::Thread::StackOverflowMask); constantFatMask = ConstantInt::get(pointerSizeType, - pointerSizeType == Type::Int32Ty ? 0x80000000 : 0x8000000000000000LL); + pointerSizeType == Type::getInt32Ty(Context) ? 0x80000000 : 0x8000000000000000LL); constantPtrOne = ConstantInt::get(pointerSizeType, 1); constantPtrZero = ConstantInt::get(pointerSizeType, 0); constantPtrNull = Constant::getNullValue(ptrType); constantPtrLogSize = - ConstantInt::get(Type::Int32Ty, sizeof(void*) == 8 ? 3 : 2); - arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::Int8Ty, 0)); + ConstantInt::get(Type::getInt32Ty(Context), sizeof(void*) == 8 ? 3 : 2); + arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::getInt8Ty(Context), 0)); copyDefinitions(module, globalModule); @@ -211,7 +212,7 @@ llvm_atomic_lcs_i32 = module->getFunction("llvm.atomic.cmp.swap.i32.p0i32"); llvm_atomic_lcs_i64 = module->getFunction("llvm.atomic.cmp.swap.i64.p0i64"); - llvm_atomic_lcs_ptr = pointerSizeType == Type::Int32Ty ? llvm_atomic_lcs_i32 : + llvm_atomic_lcs_ptr = pointerSizeType == Type::getInt32Ty(Context) ? llvm_atomic_lcs_i32 : llvm_atomic_lcs_i64; unconditionalSafePoint = module->getFunction("unconditionalSafePoint"); Modified: vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp Sat Aug 15 10:54:14 2009 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// +#include "llvm/Module.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/Compiler.h" @@ -44,7 +45,8 @@ I->eraseFromParent(); Value* Ld = new LoadInst(YieldPtr, "", NBB); - BasicBlock* yield = BasicBlock::Create("", BB->getParent()); + BasicBlock* yield = BasicBlock::Create(SafeFunction->getContext(), "", + BB->getParent()); BranchInst::Create(yield, SU, Ld, NBB); CallInst::Create(SafeFunction, "", yield); Modified: vmkit/trunk/lib/N3/Mono/MonoString.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Mono/MonoString.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/N3/Mono/MonoString.cpp (original) +++ vmkit/trunk/lib/N3/Mono/MonoString.cpp Sat Aug 15 10:54:14 2009 @@ -53,7 +53,7 @@ const Type* pty = mvm::MvmModule::ptrType; Module* Mod = vm->getLLVMModule(); Constant* cons = - ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)), + ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)), pty); str->_llvmVar = new GlobalVariable(*Mod, pty, true, GlobalValue::ExternalLinkage, Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Sat Aug 15 10:54:14 2009 @@ -112,7 +112,7 @@ args.push_back(zero); if (boxed) { ConstantInt* CI = dyn_cast(field->offset); - args.push_back(ConstantInt::get(Type::Int32Ty, CI->getValue() + 1)); + args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), CI->getValue() + 1)); } else { args.push_back(field->offset); } @@ -124,7 +124,7 @@ args.push_back(zero); if (boxed) { ConstantInt* CI = dyn_cast(field->offset); - args.push_back(ConstantInt::get(Type::Int32Ty, CI->getValue() + 1)); + args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), CI->getValue() + 1)); } else { args.push_back(field->offset); } @@ -167,9 +167,9 @@ // Function Definitions { - BasicBlock* label_entry = BasicBlock::Create("entry",func,0); - BasicBlock* label_bb = BasicBlock::Create("bb",func,0); - BasicBlock* label_return = BasicBlock::Create("return",func,0); + BasicBlock* label_entry = BasicBlock::Create(getGlobalContext(), "entry",func,0); + BasicBlock* label_bb = BasicBlock::Create(getGlobalContext(), "bb",func,0); + BasicBlock* label_return = BasicBlock::Create(getGlobalContext(), "return",func,0); Value* ptr_v = new BitCastInst(arg, cl->naturalType, "", label_entry); @@ -191,8 +191,8 @@ BranchInst::Create(label_bb, label_return, int1_tmp1221, label_entry); // Block bb (label_bb) - Argument* fwdref_12 = new Argument(IntegerType::get(32)); - PHINode* int32_i_015_0 = PHINode::Create(Type::Int32Ty, "i.015.0", + Argument* fwdref_12 = new Argument(IntegerType::get(getGlobalContext(), 32)); + PHINode* int32_i_015_0 = PHINode::Create(Type::getInt32Ty(getGlobalContext()), "i.015.0", label_bb); int32_i_015_0->reserveOperandSpace(2); int32_i_015_0->addIncoming(fwdref_12, label_bb); @@ -230,7 +230,7 @@ BranchInst::Create(label_bb, label_return, int1_tmp12, label_bb); // Block return (label_return) - ReturnInst::Create(label_return); + ReturnInst::Create(getGlobalContext(), label_return); // Resolve Forward References fwdref_12->replaceAllUsesWith(int32_tmp6); delete fwdref_12; @@ -261,7 +261,7 @@ #ifdef MULTIPLE_GC Argument* GC = ++(func->arg_begin()); #endif - BasicBlock* block = BasicBlock::Create("", func); + BasicBlock* block = BasicBlock::Create(getGlobalContext(), "", func); llvm::Value* realArg = new BitCastInst(arg, type, "", block); #ifdef MULTIPLE_GC @@ -283,7 +283,7 @@ #endif traceClass(cl, block, realArg, fields, (cl->super == MSCorlib::pValue && !stat)); - ReturnInst::Create(block); + ReturnInst::Create(getGlobalContext(), block); void* tracer = mvm::MvmModule::executionEngine->getPointerToGlobal(func); ((void**)res)[VT_TRACER_OFFSET] = tracer; @@ -298,7 +298,7 @@ } BasicBlock* CLIJit::createBasicBlock(const char* name) { - return BasicBlock::Create(name, llvmFunction); + return BasicBlock::Create(getGlobalContext(), name, llvmFunction); } void CLIJit::setCurrentBlock(BasicBlock* newBlock) { @@ -386,9 +386,9 @@ } else { val = new SExtInst(val, type, "", currentBlock); } - } else if (type == Type::FloatTy) { + } else if (type == Type::getFloatTy(getGlobalContext())) { val = new FPTruncInst(val, type, "", currentBlock); - } else if (type == Type::DoubleTy) { + } else if (type == Type::getDoubleTy(getGlobalContext())) { val = new FPExtInst(val, type, "", currentBlock); } else { val = new BitCastInst(val, type, "", currentBlock); @@ -542,7 +542,7 @@ BasicBlock* endBlock = createBasicBlock("end test infinity"); BasicBlock* minusInfinity = createBasicBlock("- infinity"); BasicBlock* noInfinity = createBasicBlock("no infinity"); - PHINode* node = PHINode::Create(Type::Int32Ty, "", endBlock); + PHINode* node = PHINode::Create(Type::getInt32Ty(getGlobalContext()), "", endBlock); node->addIncoming(module->constantOne, currentBlock); node->addIncoming(module->constantMinusOne, minusInfinity); node->addIncoming(module->constantZero, noInfinity); @@ -567,7 +567,7 @@ BasicBlock* endBlock = createBasicBlock("end test infinity"); BasicBlock* minusInfinity = createBasicBlock("- infinity"); BasicBlock* noInfinity = createBasicBlock("no infinity"); - PHINode* node = PHINode::Create(Type::Int32Ty, "", endBlock); + PHINode* node = PHINode::Create(Type::getInt32Ty(getGlobalContext()), "", endBlock); node->addIncoming(module->constantOne, currentBlock); node->addIncoming(module->constantMinusOne, minusInfinity); node->addIncoming(module->constantZero, noInfinity); @@ -630,7 +630,7 @@ std::vector params; params.push_back(new BitCastInst(obj, module->ptrType, "", currentBlock)); params.push_back(module->constantInt8Zero); - params.push_back(ConstantInt::get(Type::Int32Ty, size)); + params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size)); params.push_back(module->constantZero); CallInst::Create(module->llvm_memset_i32, params.begin(), params.end(), "", currentBlock); @@ -735,9 +735,9 @@ uint64 size = module->getTypeSize(field->signature->naturalType); std::vector params; - params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); - params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); - params.push_back(ConstantInt::get(Type::Int32Ty, size)); + params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); + params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); + params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size)); params.push_back(module->constantZero); CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); @@ -796,7 +796,7 @@ } else { CallInst::Create(CLIJit::nullPointerExceptionLLVM, args.begin(), args.end(), "", exit); - new UnreachableInst(exit); + new UnreachableInst(getGlobalContext(), exit); } @@ -808,8 +808,8 @@ bool verif) { JITVerifyNull(obj); - if (index->getType() != Type::Int32Ty) { - index = changeType(index, Type::Int32Ty); + if (index->getType() != Type::getInt32Ty(getGlobalContext())) { + index = changeType(index, Type::getInt32Ty(getGlobalContext())); } if (true) { @@ -834,7 +834,7 @@ } else { CallInst::Create(CLIJit::indexOutOfBoundsExceptionLLVM, args.begin(), args.end(), "", ifFalse); - new UnreachableInst(ifFalse); + new UnreachableInst(getGlobalContext(), ifFalse); } currentBlock = ifTrue; @@ -899,7 +899,7 @@ new StoreInst(target, targetPtr, false, entry); new StoreInst(handle, handlePtr, false, entry); - ReturnInst::Create(entry); + ReturnInst::Create(getGlobalContext(), entry); return func; } @@ -949,17 +949,17 @@ void* natPtr = NativeUtil::nativeLookup(compilingClass, compilingMethod); Value* valPtr = - ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, (uint64)natPtr), + ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), (uint64)natPtr), PointerType::getUnqual(funcType)); Value* result = CallInst::Create(valPtr, nativeArgs.begin(), nativeArgs.end(), "", currentBlock); - if (result->getType() != Type::VoidTy) - ReturnInst::Create(result, currentBlock); + if (result->getType() != Type::getVoidTy(getGlobalContext())) + ReturnInst::Create(getGlobalContext(), result, currentBlock); else - ReturnInst::Create(currentBlock); + ReturnInst::Create(getGlobalContext(), currentBlock); return llvmFunction; @@ -1128,18 +1128,18 @@ e = args.end(); i!= e; ++i) { llvm::Value* arg = *i; const llvm::Type* type = arg->getType(); - if (type == Type::Int8Ty || type == Type::Int16Ty || type == Type::Int1Ty) { - CallInst::Create(module->printIntLLVM, new ZExtInst(arg, Type::Int32Ty, "", insertAt), "", insertAt); - } else if (type == Type::Int32Ty) { + if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext()) || type == Type::getInt1Ty(getGlobalContext())) { + CallInst::Create(module->printIntLLVM, new ZExtInst(arg, Type::getInt32Ty(getGlobalContext()), "", insertAt), "", insertAt); + } else if (type == Type::getInt32Ty(getGlobalContext())) { CallInst::Create(module->printIntLLVM, arg, "", insertAt); - } else if (type == Type::Int64Ty) { + } else if (type == Type::getInt64Ty(getGlobalContext())) { CallInst::Create(module->printLongLLVM, arg, "", insertAt); - } else if (type == Type::FloatTy) { + } else if (type == Type::getFloatTy(getGlobalContext())) { CallInst::Create(module->printFloatLLVM, arg, "", insertAt); - } else if (type == Type::DoubleTy) { + } else if (type == Type::getDoubleTy(getGlobalContext())) { CallInst::Create(module->printDoubleLLVM, arg, "", insertAt); } else { - CallInst::Create(module->printIntLLVM, new PtrToIntInst(arg, Type::Int32Ty, "", insertAt), "", insertAt); + CallInst::Create(module->printIntLLVM, new PtrToIntInst(arg, Type::getInt32Ty(getGlobalContext()), "", insertAt), "", insertAt); } } @@ -1233,7 +1233,7 @@ params.push_back(new BitCastInst(alloc, module->ptrType, "", currentBlock)); params.push_back(module->constantInt8Zero); - params.push_back(ConstantInt::get(Type::Int32Ty, size)); + params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size)); params.push_back(module->constantZero); CallInst::Create(module->llvm_memset_i32, params.begin(), params.end(), "", currentBlock); @@ -1248,7 +1248,7 @@ endBlock = createBasicBlock("end"); const Type* endType = funcType->getReturnType(); - if (endType != Type::VoidTy) { + if (endType != Type::getVoidTy(getGlobalContext())) { endNode = PHINode::Create(endType, "", endBlock); } else if (compilingMethod->structReturn) { const Type* lastType = @@ -1264,13 +1264,13 @@ if (PI == PE) { endBlock->eraseFromParent(); } else { - if (endType != Type::VoidTy) { + if (endType != Type::getVoidTy(getGlobalContext())) { #if N3_EXECUTE > 1 std::vector args; args.push_back(endNode); printArgs(args, endBlock); #endif - ReturnInst::Create(endNode, endBlock); + ReturnInst::Create(getGlobalContext(), endNode, endBlock); } else if (compilingMethod->structReturn) { const Type* lastType = funcType->getContainedType(funcType->getNumContainedTypes() - 1); @@ -1281,13 +1281,13 @@ currentBlock)); params.push_back(new BitCastInst(endNode, module->ptrType, "", currentBlock)); - params.push_back(ConstantInt::get(Type::Int32Ty, size)); + params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size)); params.push_back(module->constantFour); CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); - ReturnInst::Create(currentBlock); + ReturnInst::Create(getGlobalContext(), currentBlock); } else { - ReturnInst::Create(endBlock); + ReturnInst::Create(getGlobalContext(), endBlock); } } @@ -1299,7 +1299,7 @@ CallInst* ptr_eh_ptr = CallInst::Create(getCppExceptionLLVM, "eh_ptr", endExceptionBlock); CallInst::Create(module->unwindResume, ptr_eh_ptr, "", endExceptionBlock); - new UnreachableInst(endExceptionBlock); + new UnreachableInst(getGlobalContext(), endExceptionBlock); } PI = pred_begin(unifiedUnreachable); @@ -1307,7 +1307,7 @@ if (PI == PE) { unifiedUnreachable->eraseFromParent(); } else { - new UnreachableInst(unifiedUnreachable); + new UnreachableInst(getGlobalContext(), unifiedUnreachable); } module->runPasses(llvmFunction, VMThread::get()->perFunctionPasses); @@ -1410,7 +1410,7 @@ params.push_back(new BitCastInst(alloc, module->ptrType, "", currentBlock)); params.push_back(module->constantInt8Zero); - params.push_back(ConstantInt::get(Type::Int32Ty, size)); + params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size)); params.push_back(module->constantZero); CallInst::Create(module->llvm_memset_i32, params.begin(), params.end(), "", currentBlock); @@ -1425,7 +1425,7 @@ endBlock = createBasicBlock("end"); const Type* endType = funcType->getReturnType(); - if (endType != Type::VoidTy) { + if (endType != Type::getVoidTy(getGlobalContext())) { endNode = PHINode::Create(endType, "", endBlock); } else if (compilingMethod->structReturn) { const Type* lastType = Modified: vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp Sat Aug 15 10:54:14 2009 @@ -42,7 +42,7 @@ if (stat) obj = classDef->staticInstance; void* ptr = (void*)((uint64)obj + ptrOffset); - if (signature->naturalType == Type::FloatTy) { + if (signature->naturalType == Type::getFloatTy(getGlobalContext())) { ((float*)ptr)[0] = val; } else { VMThread::get()->vm->unknownError("wrong type in field assignment"); @@ -60,7 +60,7 @@ if (stat) obj = classDef->staticInstance; void* ptr = (void*)((uint64)obj + ptrOffset); - if (signature->naturalType == Type::DoubleTy) { + if (signature->naturalType == Type::getDoubleTy(getGlobalContext())) { ((double*)ptr)[0] = val; } else { VMThread::get()->vm->unknownError("wrong type in field assignment"); @@ -78,7 +78,7 @@ if (stat) obj = classDef->staticInstance; void* ptr = (void*)((uint64)obj + ptrOffset); - if (signature->naturalType == Type::Int64Ty) { + if (signature->naturalType == Type::getInt64Ty(getGlobalContext())) { ((uint64*)ptr)[0] = val; } else { VMThread::get()->vm->unknownError("wrong type in field assignment"); @@ -96,7 +96,7 @@ if (stat) obj = classDef->staticInstance; void* ptr = (void*)((uint64)obj + ptrOffset); - if (signature->naturalType == Type::Int32Ty) { + if (signature->naturalType == Type::getInt32Ty(getGlobalContext())) { ((uint32*)ptr)[0] = val; } else { VMThread::get()->vm->unknownError("wrong type in field assignment"); @@ -131,7 +131,7 @@ if (stat) obj = classDef->staticInstance; void* ptr = (void*)((uint64)obj + ptrOffset); - if (signature->naturalType == Type::Int1Ty) { + if (signature->naturalType == Type::getInt1Ty(getGlobalContext())) { ((bool*)ptr)[0] = val; } else { VMThread::get()->vm->unknownError("wrong type in field assignment"); @@ -160,27 +160,27 @@ void* ptr = (void*)((uint64)obj + ptrOffset); const Type* type = signature->naturalType; - if (type == Type::Int8Ty) { + if (type == Type::getInt8Ty(getGlobalContext())) { GenericValue gv; gv.IntVal = APInt(8, ((uint8*)ptr)[0]); return gv; - } else if (type == Type::Int16Ty) { + } else if (type == Type::getInt16Ty(getGlobalContext())) { GenericValue gv; gv.IntVal = APInt(16, ((uint16*)ptr)[0]); return gv; - } else if (type == Type::Int32Ty) { + } else if (type == Type::getInt32Ty(getGlobalContext())) { GenericValue gv; gv.IntVal = APInt(32, ((uint32*)ptr)[0]); return gv; - } else if (type == Type::Int64Ty) { + } else if (type == Type::getInt64Ty(getGlobalContext())) { GenericValue gv; gv.IntVal = APInt(64, ((uint64*)ptr)[0]); return gv; - } else if (type == Type::DoubleTy) { + } else if (type == Type::getDoubleTy(getGlobalContext())) { GenericValue gv; gv.DoubleVal = ((double*)ptr)[0]; return gv; - } else if (type == Type::FloatTy) { + } else if (type == Type::getFloatTy(getGlobalContext())) { GenericValue gv; gv.FloatVal = ((float*)ptr)[0]; return gv; @@ -201,27 +201,27 @@ for (Function::arg_iterator i = func->arg_begin(), e = func->arg_end(); i != e; ++i) { const Type* type = i->getType(); - if (type == Type::Int8Ty) { + if (type == Type::getInt8Ty(getGlobalContext())) { GenericValue gv; gv.IntVal = APInt(8, va_arg(ap, int)); args.push_back(gv); - } else if (type == Type::Int16Ty) { + } else if (type == Type::getInt16Ty(getGlobalContext())) { GenericValue gv; gv.IntVal = APInt(16, va_arg(ap, int)); args.push_back(gv); - } else if (type == Type::Int32Ty) { + } else if (type == Type::getInt32Ty(getGlobalContext())) { GenericValue gv; gv.IntVal = APInt(32, va_arg(ap, int)); args.push_back(gv); - } else if (type == Type::Int64Ty) { + } else if (type == Type::getInt64Ty(getGlobalContext())) { GenericValue gv1; gv1.IntVal = APInt(64, va_arg(ap, uint64)); args.push_back(gv1); - } else if (type == Type::DoubleTy) { + } else if (type == Type::getDoubleTy(getGlobalContext())) { GenericValue gv1; gv1.DoubleVal = va_arg(ap, double); args.push_back(gv1); - } else if (type == Type::FloatTy) { + } else if (type == Type::getFloatTy(getGlobalContext())) { GenericValue gv; gv.FloatVal = (float)(va_arg(ap, double)); args.push_back(gv); @@ -248,27 +248,27 @@ for (Function::arg_iterator i = ++(func->arg_begin()), e = func->arg_end(); i != e; ++i) { const Type* type = i->getType(); - if (type == Type::Int8Ty) { + if (type == Type::getInt8Ty(getGlobalContext())) { GenericValue gv; gv.IntVal = APInt(8, va_arg(ap, int)); args.push_back(gv); - } else if (type == Type::Int16Ty) { + } else if (type == Type::getInt16Ty(getGlobalContext())) { GenericValue gv; gv.IntVal = APInt(16, va_arg(ap, int)); args.push_back(gv); - } else if (type == Type::Int32Ty) { + } else if (type == Type::getInt32Ty(getGlobalContext())) { GenericValue gv; gv.IntVal = APInt(32, va_arg(ap, int)); args.push_back(gv); - } else if (type == Type::Int64Ty) { + } else if (type == Type::getInt64Ty(getGlobalContext())) { GenericValue gv1; gv1.IntVal = APInt(64, va_arg(ap, uint64)); args.push_back(gv1); - } else if (type == Type::DoubleTy) { + } else if (type == Type::getDoubleTy(getGlobalContext())) { GenericValue gv1; gv1.DoubleVal = va_arg(ap, double); args.push_back(gv1); - } else if (type == Type::FloatTy) { + } else if (type == Type::getFloatTy(getGlobalContext())) { GenericValue gv; gv.FloatVal = (float)(va_arg(ap, double)); args.push_back(gv); @@ -367,7 +367,7 @@ Module* Mod = vm->getLLVMModule(); const Type* pty = mvm::MvmModule::ptrType; Constant* cons = - ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)), + ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)), pty); _llvmVar = new GlobalVariable(*Mod, pty, true, @@ -387,7 +387,7 @@ const Type* pty = mvm::MvmModule::ptrType; Module* Mod = classDef->vm->getLLVMModule(); Constant* cons = - ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)), + ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)), pty); _llvmVar = new GlobalVariable(*Mod, pty, true, @@ -406,7 +406,7 @@ Module* Mod = classDef->vm->getLLVMModule(); const Type* pty = mvm::MvmModule::ptrType; Constant* cons = - ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (this)), + ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)), pty); _llvmVar = new GlobalVariable(*Mod, pty, true, Modified: vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/LowerArrayLength.cpp Sat Aug 15 10:54:14 2009 @@ -46,7 +46,7 @@ Changed = true; Value* val = CI->getOperand(1); // get the array std::vector args; //size= 2 - args.push_back(ConstantInt::get(Type::Int32Ty, 0)); + args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 0)); args.push_back(n3::VMArray::sizeOffset()); Value* ptr = GetElementPtrInst::Create(val, args.begin(), args.end(), "", CI); Modified: vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/N3Initialise.cpp Sat Aug 15 10:54:14 2009 @@ -267,22 +267,22 @@ INIT(MSCorlib::pObject, "System", "Object", VMObject::llvmType, false); INIT(MSCorlib::pValue, "System", "ValueType", 0, false); - INIT(MSCorlib::pVoid, "System", "Void", llvm::Type::VoidTy, true); - INIT(MSCorlib::pBoolean, "System", "Boolean", llvm::Type::Int1Ty, true); - INIT(MSCorlib::pUInt8, "System", "Byte", llvm::Type::Int8Ty, true); - INIT(MSCorlib::pSInt8, "System", "SByte", llvm::Type::Int8Ty, true); - INIT(MSCorlib::pChar, "System", "Char", llvm::Type::Int16Ty, true); - INIT(MSCorlib::pSInt16, "System", "Int16", llvm::Type::Int16Ty, true); - INIT(MSCorlib::pUInt16, "System", "UInt16", llvm::Type::Int16Ty, true); - INIT(MSCorlib::pSInt32, "System", "Int32", llvm::Type::Int32Ty, true); - INIT(MSCorlib::pUInt32, "System", "UInt32", llvm::Type::Int32Ty, true); - INIT(MSCorlib::pSInt64, "System", "Int64", llvm::Type::Int64Ty, true); - INIT(MSCorlib::pUInt64, "System", "UInt64", llvm::Type::Int64Ty, true); - INIT(MSCorlib::pIntPtr, "System", "IntPtr", llvm::PointerType::getUnqual(llvm::Type::Int8Ty), true); - INIT(MSCorlib::pUIntPtr, "System", "UIntPtr", llvm::PointerType::getUnqual(llvm::Type::Int8Ty), true); - INIT(MSCorlib::pDouble, "System", "Double", llvm::Type::DoubleTy, true); - INIT(MSCorlib::pFloat, "System", "Single", llvm::Type::FloatTy, true); - INIT(MSCorlib::pEnum, "System", "Enum", llvm::Type::Int32Ty, true); + INIT(MSCorlib::pVoid, "System", "Void", llvm::Type::getVoidTy(getGlobalContext()), true); + INIT(MSCorlib::pBoolean, "System", "Boolean", llvm::Type::getInt1Ty(getGlobalContext()), true); + INIT(MSCorlib::pUInt8, "System", "Byte", llvm::Type::getInt8Ty(getGlobalContext()), true); + INIT(MSCorlib::pSInt8, "System", "SByte", llvm::Type::getInt8Ty(getGlobalContext()), true); + INIT(MSCorlib::pChar, "System", "Char", llvm::Type::getInt16Ty(getGlobalContext()), true); + INIT(MSCorlib::pSInt16, "System", "Int16", llvm::Type::getInt16Ty(getGlobalContext()), true); + INIT(MSCorlib::pUInt16, "System", "UInt16", llvm::Type::getInt16Ty(getGlobalContext()), true); + INIT(MSCorlib::pSInt32, "System", "Int32", llvm::Type::getInt32Ty(getGlobalContext()), true); + INIT(MSCorlib::pUInt32, "System", "UInt32", llvm::Type::getInt32Ty(getGlobalContext()), true); + INIT(MSCorlib::pSInt64, "System", "Int64", llvm::Type::getInt64Ty(getGlobalContext()), true); + INIT(MSCorlib::pUInt64, "System", "UInt64", llvm::Type::getInt64Ty(getGlobalContext()), true); + INIT(MSCorlib::pIntPtr, "System", "IntPtr", llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(getGlobalContext())), true); + INIT(MSCorlib::pUIntPtr, "System", "UIntPtr", llvm::PointerType::getUnqual(llvm::Type::getInt8Ty(getGlobalContext())), true); + INIT(MSCorlib::pDouble, "System", "Double", llvm::Type::getDoubleTy(getGlobalContext()), true); + INIT(MSCorlib::pFloat, "System", "Single", llvm::Type::getFloatTy(getGlobalContext()), true); + INIT(MSCorlib::pEnum, "System", "Enum", llvm::Type::getInt32Ty(getGlobalContext()), true); INIT(MSCorlib::pArray, "System", "Array", 0, true); INIT(MSCorlib::pException,"System", "Exception", 0, false); INIT(MSCorlib::pDelegate, "System", "Delegate", 0, false); Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Sat Aug 15 10:54:14 2009 @@ -130,10 +130,10 @@ } else if (isa(t1) && isa(t2)) { val1 = new BitCastInst(val1, VMObject::llvmType, "", currentBlock); val2 = new BitCastInst(val2, VMObject::llvmType, "", currentBlock); - } else if (t1->isInteger() && t2 == PointerType::getUnqual(Type::Int8Ty)) { + } else if (t1->isInteger() && t2 == PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))) { // CLI says that this is fine for some operation val2 = new PtrToIntInst(val2, t1, "", currentBlock); - } else if (t2->isInteger() && t1 == PointerType::getUnqual(Type::Int8Ty)) { + } else if (t2->isInteger() && t1 == PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))) { // CLI says that this is fine for some operation val1 = new PtrToIntInst(val1, t2, "", currentBlock); } @@ -173,9 +173,9 @@ uint64 size = module->getTypeSize(contained); std::vector params; - params.push_back(new BitCastInst(local, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); - params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); - params.push_back(ConstantInt::get(Type::Int32Ty, size)); + params.push_back(new BitCastInst(local, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); + params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); + params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size)); params.push_back(module->constantZero); CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); } else { @@ -191,9 +191,9 @@ uint64 size = module->getTypeSize(contained); Value* ret = new AllocaInst(contained, "", currentBlock); std::vector params; - params.push_back(new BitCastInst(ret, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); - params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); - params.push_back(ConstantInt::get(Type::Int32Ty, size)); + params.push_back(new BitCastInst(ret, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); + params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); + params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size)); params.push_back(module->constantZero); CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); return ret; @@ -228,13 +228,13 @@ #if N3_EXECUTE > 1 if (bytecodes[i] == 0xFE) { std::vector args; - args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)OpcodeNamesFE[bytecodes[i + 1]])); - args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod)); + args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), (int64_t)OpcodeNamesFE[bytecodes[i + 1]])); + args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), (int64_t)compilingMethod)); CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", currentBlock); } else { std::vector args; - args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)OpcodeNames[bytecodes[i]])); - args.push_back(ConstantInt::get(Type::Int32Ty, (int64_t)compilingMethod)); + args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), (int64_t)OpcodeNames[bytecodes[i]])); + args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), (int64_t)compilingMethod)); CallInst::Create(printExecutionLLVM, args.begin(), args.end(), "", currentBlock); } #endif @@ -382,10 +382,10 @@ Value* val = pop(); const Type* type = val->getType(); if (type->isFloatingPoint()) { - push(new FPToSIInst(val, Type::Int8Ty, "", currentBlock)); - } else if (type == Type::Int16Ty || type == Type::Int32Ty || - type == Type::Int64Ty) { - push(new TruncInst(val, Type::Int8Ty, "", currentBlock)); + push(new FPToSIInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt16Ty(getGlobalContext()) || type == Type::getInt32Ty(getGlobalContext()) || + type == Type::getInt64Ty(getGlobalContext())) { + push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock)); } else { VMThread::get()->vm->unknownError("implement me"); } @@ -396,11 +396,11 @@ Value* val = pop(); const Type* type = val->getType(); if (type->isFloatingPoint()) { - push(new FPToSIInst(val, Type::Int16Ty, "", currentBlock)); - } else if (type == Type::Int32Ty || type == Type::Int64Ty) { - push(new TruncInst(val, Type::Int16Ty, "", currentBlock)); - } else if (type == Type::Int8Ty) { - push(new SExtInst(val, Type::Int16Ty, "", currentBlock)); + push(new FPToSIInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt32Ty(getGlobalContext()) || type == Type::getInt64Ty(getGlobalContext())) { + push(new TruncInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt8Ty(getGlobalContext())) { + push(new SExtInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock)); } else { VMThread::get()->vm->unknownError("implement me"); } @@ -411,12 +411,12 @@ Value* val = pop(); const Type* type = val->getType(); if (type->isFloatingPoint()) { - push(new FPToSIInst(val, Type::Int32Ty, "", currentBlock)); - } else if (type == Type::Int64Ty) { - push(new TruncInst(val, Type::Int32Ty, "", currentBlock)); - } else if (type == Type::Int8Ty || type == Type::Int16Ty) { - push(new SExtInst(val, Type::Int32Ty, "", currentBlock)); - } else if (type == Type::Int32Ty) { + push(new FPToSIInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt64Ty(getGlobalContext())) { + push(new TruncInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext())) { + push(new SExtInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt32Ty(getGlobalContext())) { push(val); } else { VMThread::get()->vm->unknownError("implement me"); @@ -428,10 +428,10 @@ Value* val = pop(); const Type* type = val->getType(); if (type->isFloatingPoint()) { - push(new FPToSIInst(val, Type::Int64Ty, "", currentBlock)); - } else if (type == Type::Int8Ty || type == Type::Int16Ty || - type == Type::Int32Ty) { - push(new SExtInst(val, Type::Int64Ty, "", currentBlock)); + push(new FPToSIInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext()) || + type == Type::getInt32Ty(getGlobalContext())) { + push(new SExtInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock)); } else { VMThread::get()->vm->unknownError("implement me"); } @@ -441,10 +441,10 @@ case CONV_R4 : { Value* val = pop(); const Type* type = val->getType(); - if (type == Type::DoubleTy) { - push(new FPTruncInst(val, Type::FloatTy, "", currentBlock)); + if (type == Type::getDoubleTy(getGlobalContext())) { + push(new FPTruncInst(val, Type::getFloatTy(getGlobalContext()), "", currentBlock)); } else if (type->isInteger()) { - push(new SIToFPInst(val, Type::FloatTy, "", currentBlock)); + push(new SIToFPInst(val, Type::getFloatTy(getGlobalContext()), "", currentBlock)); } else { VMThread::get()->vm->unknownError("implement me"); } @@ -454,11 +454,11 @@ case CONV_R8 : { Value* val = pop(); const Type* type = val->getType(); - if (type == Type::FloatTy) { - push(new FPExtInst(val, Type::DoubleTy, "", currentBlock)); + if (type == Type::getFloatTy(getGlobalContext())) { + push(new FPExtInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock)); } else if (type->isInteger()) { - push(new SIToFPInst(val, Type::DoubleTy, "", currentBlock)); - } else if (type == Type::DoubleTy) { + push(new SIToFPInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getDoubleTy(getGlobalContext())) { push(val); } else { VMThread::get()->vm->unknownError("implement me"); @@ -470,10 +470,10 @@ Value* val = pop(); const Type* type = val->getType(); if (type->isFloatingPoint()) { - push(new FPToUIInst(val, Type::Int8Ty, "", currentBlock)); - } else if (type == Type::Int16Ty || type == Type::Int32Ty || - type == Type::Int64Ty) { - push(new TruncInst(val, Type::Int8Ty, "", currentBlock)); + push(new FPToUIInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt16Ty(getGlobalContext()) || type == Type::getInt32Ty(getGlobalContext()) || + type == Type::getInt64Ty(getGlobalContext())) { + push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock)); } else { VMThread::get()->vm->unknownError("implement me"); } @@ -484,11 +484,11 @@ Value* val = pop(); const Type* type = val->getType(); if (type->isFloatingPoint()) { - push(new FPToUIInst(val, Type::Int16Ty, "", currentBlock)); - } else if (type == Type::Int32Ty || type == Type::Int64Ty) { - push(new TruncInst(val, Type::Int8Ty, "", currentBlock)); - } else if (type == Type::Int8Ty) { - push(new ZExtInst(val, Type::Int16Ty, "", currentBlock)); + push(new FPToUIInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt32Ty(getGlobalContext()) || type == Type::getInt64Ty(getGlobalContext())) { + push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt8Ty(getGlobalContext())) { + push(new ZExtInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock)); } else { VMThread::get()->vm->unknownError("implement me"); } @@ -499,11 +499,11 @@ Value* val = pop(); const Type* type = val->getType(); if (type->isFloatingPoint()) { - push(new FPToUIInst(val, Type::Int32Ty, "", currentBlock)); - } else if (type == Type::Int64Ty) { - push(new TruncInst(val, Type::Int8Ty, "", currentBlock)); - } else if (type == Type::Int8Ty || type == Type::Int16Ty) { - push(new ZExtInst(val, Type::Int16Ty, "", currentBlock)); + push(new FPToUIInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt64Ty(getGlobalContext())) { + push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext())) { + push(new ZExtInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock)); } else { VMThread::get()->vm->unknownError("implement me"); } @@ -514,10 +514,10 @@ Value* val = pop(); const Type* type = val->getType(); if (type->isFloatingPoint()) { - push(new FPToUIInst(val, Type::Int64Ty, "", currentBlock)); - } else if (type == Type::Int8Ty || type == Type::Int16Ty || - type == Type::Int32Ty) { - push(new ZExtInst(val, Type::Int64Ty, "", currentBlock)); + push(new FPToUIInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext()) || + type == Type::getInt32Ty(getGlobalContext())) { + push(new ZExtInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock)); } else { VMThread::get()->vm->unknownError("implement me"); } @@ -529,12 +529,12 @@ Value* res = 0; if (val->getType()->isInteger()) { - if (val->getType() != Type::Int64Ty) { - val = new ZExtInst(val, Type::Int64Ty, "", currentBlock); + if (val->getType() != Type::getInt64Ty(getGlobalContext())) { + val = new ZExtInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock); } - res = new IntToPtrInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock); + res = new IntToPtrInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock); } else if (!val->getType()->isFloatingPoint()) { - res = new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock); + res = new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock); } else { VMThread::get()->vm->unknownError("implement me"); } @@ -551,11 +551,11 @@ case CONV_R_UN : { Value* val = pop(); const Type* type = val->getType(); - if (type == Type::FloatTy) { - push(new FPExtInst(val, Type::DoubleTy, "", currentBlock)); + if (type == Type::getFloatTy(getGlobalContext())) { + push(new FPExtInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock)); } else if (type->isInteger()) { - push(new UIToFPInst(val, Type::DoubleTy, "", currentBlock)); - } else if (type == Type::DoubleTy) { + push(new UIToFPInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getDoubleTy(getGlobalContext())) { push(val); } else { VMThread::get()->vm->unknownError("implement me"); @@ -627,12 +627,12 @@ Value* val = pop(); const Type* type = val->getType(); if (type->isFloatingPoint()) { - push(new FPToUIInst(val, Type::Int32Ty, "", currentBlock)); - } else if (type == Type::Int64Ty) { - push(new TruncInst(val, Type::Int8Ty, "", currentBlock)); - } else if (type == Type::Int8Ty || type == Type::Int16Ty) { - push(new ZExtInst(val, Type::Int16Ty, "", currentBlock)); - } else if (type == Type::Int32Ty) { + push(new FPToUIInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt64Ty(getGlobalContext())) { + push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext())) { + push(new ZExtInst(val, Type::getInt16Ty(getGlobalContext()), "", currentBlock)); + } else if (type == Type::getInt32Ty(getGlobalContext())) { push(val); } else { VMThread::get()->vm->unknownError("implement me"); @@ -696,14 +696,14 @@ case ENDFINALLY : { Value* val = new LoadInst(supplLocal, "", currentBlock); - val = new PtrToIntInst(val, Type::Int32Ty, "", currentBlock); + val = new PtrToIntInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock); SwitchInst* inst = SwitchInst::Create(val, leaves[0], leaves.size(), currentBlock); uint32 index = 0; for (std::vector::iterator i = leaves.begin(), e = leaves.end(); i!= e; ++i, ++index) { - inst->addCase(ConstantInt::get(Type::Int32Ty, index), *i); + inst->addCase(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), index), *i); } //currentBlock = bb2; @@ -747,22 +747,22 @@ } case LDC_I4 : { - push(ConstantInt::get(Type::Int32Ty, readS4(bytecodes, i))); + push(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), readS4(bytecodes, i))); break; } case LDC_I8 : { - push(ConstantInt::get(Type::Int64Ty, readS8(bytecodes, i))); + push(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), readS8(bytecodes, i))); break; } case LDC_R4 : { - push(ConstantFP::get(Type::FloatTy, readFloat(bytecodes, i))); + push(ConstantFP::get(Type::getFloatTy(getGlobalContext()), readFloat(bytecodes, i))); break; } case LDC_R8 : { - push(ConstantFP::get(Type::DoubleTy, readDouble(bytecodes, i))); + push(ConstantFP::get(Type::getDoubleTy(getGlobalContext()), readDouble(bytecodes, i))); break; } @@ -817,14 +817,14 @@ } case LDC_I4_S : { - push(ConstantInt::get(Type::Int32Ty, readS1(bytecodes, i))); + push(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), readS1(bytecodes, i))); break; } case LDIND_U1 : case LDIND_I1 : { Value* _val = pop(); - Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock); + Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock); push(new LoadInst(val, "", isVolatile, currentBlock)); isVolatile = false; break; @@ -833,7 +833,7 @@ case LDIND_U2 : case LDIND_I2 : { Value* _val = pop(); - Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::Int16Ty), "", currentBlock); + Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::getInt16Ty(getGlobalContext())), "", currentBlock); push(new LoadInst(val, "", isVolatile, currentBlock)); isVolatile = false; break; @@ -843,9 +843,9 @@ case LDIND_I4 : { Value* val = pop(); if (val->getType()->isInteger()) { - val = new IntToPtrInst(val, PointerType::getUnqual(Type::Int32Ty), "", currentBlock); + val = new IntToPtrInst(val, PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "", currentBlock); } else { - val = new BitCastInst(val, PointerType::getUnqual(Type::Int32Ty), "", currentBlock); + val = new BitCastInst(val, PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "", currentBlock); } push(new LoadInst(val, "", isVolatile, currentBlock)); isVolatile = false; @@ -854,7 +854,7 @@ case LDIND_I8 : { Value* _val = pop(); - Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::Int64Ty), "", currentBlock); + Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::getInt64Ty(getGlobalContext())), "", currentBlock); push(new LoadInst(val, "", isVolatile, currentBlock)); isVolatile = false; break; @@ -862,7 +862,7 @@ case LDIND_R4 : { Value* _val = pop(); - Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::FloatTy), "", currentBlock); + Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::getFloatTy(getGlobalContext())), "", currentBlock); push(new LoadInst(val, "", isVolatile, currentBlock)); isVolatile = false; break; @@ -870,7 +870,7 @@ case LDIND_R8 : { Value* _val = pop(); - Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::DoubleTy), "", currentBlock); + Value* val = new BitCastInst(_val, PointerType::getUnqual(Type::getDoubleTy(getGlobalContext())), "", currentBlock); push(new LoadInst(val, "", isVolatile, currentBlock)); isVolatile = false; break; @@ -879,7 +879,7 @@ case LDIND_I : { Value* _val = pop(); Value* val = new BitCastInst(_val, PointerType::getUnqual( - PointerType::getUnqual(Type::Int8Ty)), "", currentBlock); + PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))), "", currentBlock); push(new LoadInst(val, "", isVolatile, currentBlock)); isVolatile = false; break; @@ -952,7 +952,7 @@ } if (res) { Value* expr = ConstantExpr::getIntToPtr( - ConstantInt::get(Type::Int64Ty, + ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (leaveIndex++)), VMObject::llvmType); @@ -984,7 +984,7 @@ } if (res) { Value* expr = ConstantExpr::getIntToPtr( - ConstantInt::get(Type::Int64Ty, + ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (leaveIndex++)), VMObject::llvmType); @@ -1028,7 +1028,7 @@ case NOP : break; case NOT : { - push(BinaryOperator::CreateNot(llvmFunction->getContext(), pop(), "", currentBlock)); + push(BinaryOperator::CreateNot(pop(), "", currentBlock)); break; } @@ -1067,7 +1067,7 @@ } case RET : { - if (compilingMethod->getSignature(genMethod)->getReturnType() != Type::VoidTy) { + if (compilingMethod->getSignature(genMethod)->getReturnType() != Type::getVoidTy(getGlobalContext())) { Value* val = pop(); if (val->getType() == PointerType::getUnqual(endNode->getType())) { // In case it's a struct @@ -1118,9 +1118,9 @@ case STIND_I1 : { Value* val = pop(); Value* _addr = pop(); - Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::Int8Ty), "", + Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock); - convertValue(val, Type::Int8Ty, currentBlock); + convertValue(val, Type::getInt8Ty(getGlobalContext()), currentBlock); new StoreInst(val, addr, isVolatile, currentBlock); isVolatile = false; break; @@ -1129,7 +1129,7 @@ case STIND_I2 : { Value* val = pop(); Value* _addr = pop(); - Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::Int16Ty), + Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getInt16Ty(getGlobalContext())), "", currentBlock); new StoreInst(val, addr, isVolatile, currentBlock); isVolatile = false; @@ -1139,7 +1139,7 @@ case STIND_I4 : { Value* val = pop(); Value* _addr = pop(); - Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::Int32Ty), + Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "", currentBlock); new StoreInst(val, addr, isVolatile, currentBlock); isVolatile = false; @@ -1149,7 +1149,7 @@ case STIND_I8 : { Value* val = pop(); Value* _addr = pop(); - Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::Int64Ty), + Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getInt64Ty(getGlobalContext())), "", currentBlock); new StoreInst(val, addr, isVolatile, currentBlock); isVolatile = false; @@ -1159,7 +1159,7 @@ case STIND_R4 : { Value* val = pop(); Value* _addr = pop(); - Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::FloatTy), + Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getFloatTy(getGlobalContext())), "", currentBlock); new StoreInst(val, addr, isVolatile, currentBlock); isVolatile = false; @@ -1169,7 +1169,7 @@ case STIND_R8 : { Value* val = pop(); Value* _addr = pop(); - Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::DoubleTy), + Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getDoubleTy(getGlobalContext())), "", currentBlock); new StoreInst(val, addr, isVolatile, currentBlock); isVolatile = false; @@ -1179,7 +1179,7 @@ case STIND_I : { Value* val = pop(); Value* _addr = pop(); - Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::Int32Ty), + Value* addr = new BitCastInst(_addr, PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "", currentBlock); new StoreInst(val, addr, isVolatile, currentBlock); isVolatile = false; @@ -1260,7 +1260,7 @@ sint32 index = next + offset; assert(index > 0); BasicBlock* BB = opcodeInfos[index].newBlock; - SI->addCase(ConstantInt::get(Type::Int32Ty, t), BB); + SI->addCase(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), t), BB); } break; } @@ -1309,9 +1309,9 @@ uint64 size = module->getTypeSize(type->naturalType); std::vector params; - params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); - params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); - params.push_back(ConstantInt::get(Type::Int32Ty, size)); + params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); + params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); + params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size)); params.push_back(module->constantZero); CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); @@ -1360,7 +1360,7 @@ InvokeInst::Create(classCastExceptionLLVM, unifiedUnreachable, currentExceptionBlock, exArgs.begin(), exArgs.end(), "", ex); } else { CallInst::Create(classCastExceptionLLVM, exArgs.begin(), exArgs.end(), "", ex); - new UnreachableInst(ex); + new UnreachableInst(getGlobalContext(), ex); } currentBlock = ifTrue; @@ -1578,7 +1578,7 @@ uint32 value = readU4(bytecodes, i); uint32 index = value & 0xfffffff; const UTF8* utf8 = compilingClass->assembly->readUserString(index); - Value* val = ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, (int64_t)utf8), + Value* val = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), (int64_t)utf8), module->ptrType); Value* res = CallInst::Create(newStringLLVM, val, "", currentBlock); /*CLIString * str = @@ -1680,7 +1680,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, ArraySInt8::llvmType); - convertValue(val, Type::Int8Ty, currentBlock); + convertValue(val, Type::getInt8Ty(getGlobalContext()), currentBlock); new StoreInst(val, ptr, false, currentBlock); break; } @@ -1690,7 +1690,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, ArraySInt16::llvmType); - convertValue(val, Type::Int16Ty, currentBlock); + convertValue(val, Type::getInt16Ty(getGlobalContext()), currentBlock); new StoreInst(val, ptr, false, currentBlock); break; } @@ -1700,7 +1700,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, ArraySInt32::llvmType); - convertValue(val, Type::Int32Ty, currentBlock); + convertValue(val, Type::getInt32Ty(getGlobalContext()), currentBlock); new StoreInst(val, ptr, false, currentBlock); break; } @@ -1710,7 +1710,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, ArrayLong::llvmType); - convertValue(val, Type::Int64Ty, currentBlock); + convertValue(val, Type::getInt64Ty(getGlobalContext()), currentBlock); new StoreInst(val, ptr, false, currentBlock); break; } @@ -1720,7 +1720,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, ArrayFloat::llvmType); - convertValue(val, Type::FloatTy, currentBlock); + convertValue(val, Type::getFloatTy(getGlobalContext()), currentBlock); new StoreInst(val, ptr, false, currentBlock); break; } @@ -1730,7 +1730,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, ArrayDouble::llvmType); - convertValue(val, Type::DoubleTy, currentBlock); + convertValue(val, Type::getDoubleTy(getGlobalContext()), currentBlock); new StoreInst(val, ptr, false, currentBlock); break; } @@ -1779,7 +1779,7 @@ InvokeInst::Create(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock); } else { CallInst::Create(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock); - new UnreachableInst(currentBlock); + new UnreachableInst(getGlobalContext(), currentBlock); } break; } @@ -1808,9 +1808,9 @@ uint64 size = module->getTypeSize(type->naturalType); std::vector params; - params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); - params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::Int8Ty), "", currentBlock)); - params.push_back(ConstantInt::get(Type::Int32Ty, size)); + params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); + params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); + params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size)); params.push_back(module->constantZero); CallInst::Create(module->llvm_memcpy_i32, params.begin(), params.end(), "", currentBlock); @@ -1922,7 +1922,7 @@ } case LOCALLOC : { - push(new AllocaInst(Type::Int8Ty, pop(), "", currentBlock)); + push(new AllocaInst(Type::getInt8Ty(getGlobalContext()), pop(), "", currentBlock)); break; } @@ -1961,7 +1961,7 @@ params.push_back(new BitCastInst(pop(), module->ptrType, "", currentBlock)); params.push_back(module->constantInt8Zero); - params.push_back(ConstantInt::get(Type::Int32Ty, size)); + params.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), size)); params.push_back(module->constantZero); CallInst::Create(module->llvm_memset_i32, params.begin(), params.end(), "", currentBlock); @@ -1991,7 +1991,7 @@ InvokeInst::Create(throwExceptionLLVM, unifiedUnreachable, currentExceptionBlock, args.begin(), args.end(), "", currentBlock); } else { CallInst::Create(throwExceptionLLVM, args.begin(), args.end(), "", currentBlock); - new UnreachableInst(currentBlock); + new UnreachableInst(getGlobalContext(), currentBlock); } break; } Modified: vmkit/trunk/lib/N3/VMCore/VMCache.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMCache.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/VMCache.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/VMCache.cpp Sat Aug 15 10:54:14 2009 @@ -92,7 +92,7 @@ Value* five = module->constantFive; Value* llvmEnv = - ConstantExpr::getIntToPtr(ConstantInt::get(Type::Int64Ty, uint64_t (enveloppe)), + ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (enveloppe)), Enveloppe::llvmType); std::vector args1; @@ -152,7 +152,7 @@ Value* ret = invoke(meth, args, "", currentBlock, origMeth->structReturn); - if (ret->getType() != Type::VoidTy) { + if (ret->getType() != Type::getVoidTy(getGlobalContext())) { push(ret); } } Modified: vmkit/trunk/lib/N3/VMCore/VMClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/VMClass.cpp?rev=79108&r1=79107&r2=79108&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/VMClass.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/VMClass.cpp Sat Aug 15 10:54:14 2009 @@ -11,6 +11,7 @@ #include #include "llvm/DerivedTypes.h" +#include "llvm/Module.h" #include "debug.h" #include "types.h" @@ -168,7 +169,7 @@ this->isArray = isArray; this->isPointer = false; this->isPrimitive = false; - this->naturalType = llvm::OpaqueType::get(); + this->naturalType = llvm::OpaqueType::get(llvm::getGlobalContext()); } const UTF8* VMClassArray::constructArrayName(const UTF8* name, uint32 dims) { @@ -279,7 +280,7 @@ for (std::vector::iterator i = cl->staticFields.begin(), e = cl->staticFields.end(); i!= e; ++i) { // preincrement because 0 is VMObject - (*i)->offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, ++offset); + (*i)->offset = llvm::ConstantInt::get(llvm::Type::getInt32Ty(llvm::getGlobalContext()), ++offset); } for (std::vector::iterator i = cl->staticFields.begin(), e = cl->staticFields.end(); i!= e; ++i) { @@ -315,7 +316,7 @@ const llvm::Type* ResultTy = 0; if (hasExplicitLayout(flags)) { explicitLayoutSize = assembly->getExplicitLayout(token); - ResultTy = llvm::IntegerType::get(explicitLayoutSize); + ResultTy = llvm::IntegerType::get(llvm::getGlobalContext(), explicitLayoutSize); } else if (super != 0) { if (super == MSCorlib::pValue) { uint32 size = virtualFields.size(); @@ -323,27 +324,27 @@ virtualFields[0]->offset = VMThread::get()->vm->module->constantZero; ResultTy = virtualFields[0]->signature->naturalType; } else if (size == 0) { - ResultTy = llvm::Type::VoidTy; + ResultTy = llvm::Type::getVoidTy(llvm::getGlobalContext()); } else { std::vector Elts; uint32 offset = -1; for (std::vector::iterator i = virtualFields.begin(), e = virtualFields.end(); i!= e; ++i) { - (*i)->offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, ++offset); + (*i)->offset = llvm::ConstantInt::get(llvm::Type::getInt32Ty(llvm::getGlobalContext()), ++offset); const llvm::Type* type = (*i)->signature->naturalType; Elts.push_back(type); } ResultTy = llvm::StructType::get(vm->LLVMModule->getContext(), Elts); } } else if (super == MSCorlib::pEnum) { - ResultTy = llvm::Type::Int32Ty; // TODO find max + ResultTy = llvm::Type::getInt32Ty(llvm::getGlobalContext()); // TODO find max } else { std::vector Elts; Elts.push_back(super->naturalType->getContainedType(0)); uint32 offset = 0; for (std::vector::iterator i = virtualFields.begin(), e = virtualFields.end(); i!= e; ++i) { - (*i)->offset = llvm::ConstantInt::get(llvm::Type::Int32Ty, ++offset); + (*i)->offset = llvm::ConstantInt::get(llvm::Type::getInt32Ty(llvm::getGlobalContext()), ++offset); const llvm::Type* type = (*i)->signature->naturalType; Elts.push_back(type); } @@ -384,7 +385,7 @@ void VMClassArray::makeType() { std::vector arrayFields; arrayFields.push_back(VMObject::llvmType->getContainedType(0)); - arrayFields.push_back(llvm::Type::Int32Ty); + arrayFields.push_back(llvm::Type::getInt32Ty(llvm::getGlobalContext())); arrayFields.push_back(llvm::ArrayType::get(baseClass->naturalType, 0)); const llvm::Type* type = llvm::PointerType::getUnqual(llvm::StructType::get(vm->LLVMModule->getContext(), arrayFields, false)); ((llvm::OpaqueType*)naturalType)->refineAbstractTypeTo(type); @@ -393,7 +394,7 @@ } void VMClassPointer::makeType() { - const llvm::Type* type = (baseClass->naturalType == llvm::Type::VoidTy) ? llvm::Type::Int8Ty : baseClass->naturalType; + const llvm::Type* type = (baseClass->naturalType == llvm::Type::getVoidTy(llvm::getGlobalContext())) ? llvm::Type::getInt8Ty(llvm::getGlobalContext()) : baseClass->naturalType; const llvm::Type* pType = llvm::PointerType::getUnqual(type); ((llvm::OpaqueType*)naturalType)->refineAbstractTypeTo(pType); naturalType = pType; @@ -691,9 +692,9 @@ } } - if (!(ret->isSingleValueType()) && ret != llvm::Type::VoidTy) { + if (!(ret->isSingleValueType()) && ret != llvm::Type::getVoidTy(llvm::getGlobalContext())) { args.push_back(llvm::PointerType::getUnqual(ret)); - ret = llvm::Type::VoidTy; + ret = llvm::Type::getVoidTy(llvm::getGlobalContext()); structRet = true; } else { structRet = false; From nicolas.geoffray at lip6.fr Sat Aug 15 17:16:50 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 16 Aug 2009 00:16:50 -0000 Subject: [vmkit-commits] [vmkit] r79155 - in /vmkit/trunk/lib/JnJVM/VMCore: JavaClass.cpp JavaClass.h Message-ID: <200908160016.n7G0GoUX003516@zion.cs.uiuc.edu> Author: geoffray Date: Sat Aug 15 19:16:50 2009 New Revision: 79155 URL: http://llvm.org/viewvc/llvm-project?rev=79155&view=rev Log: Bugfix when a class can not be resolved: set it erroneous and throw an exception. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp?rev=79155&r1=79154&r2=79155&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.cpp Sat Aug 15 19:16:50 2009 @@ -817,6 +817,8 @@ void Class::readClass() { + assert(getInitializationState() == loaded && "Wrong init state"); + PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "; ", 0); PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "reading ", 0); PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "%s\n", printString()); @@ -850,16 +852,45 @@ #ifndef ISOLATE_SHARING void Class::resolveClass() { - if (!isResolved()) { + if (!isResolved() && !isErroneous()) { acquire(); - if (isResolved()) { + if (isResolved() || isErroneous()) { release(); } else if (!isResolving()) { setOwnerClass(JavaThread::get()); - readClass(); + + JavaObject* exc = 0; + try { + readClass(); + } catch (...) { + exc = JavaThread::get()->pendingException; + JavaThread::get()->clearException(); + } + + if (exc) { + setErroneous(); + setOwnerClass(0); + broadcastClass(); + release(); + JavaThread::get()->throwException(exc); + } + release(); + + try { + loadParents(); + } catch (...) { + setInitializationState(loaded); + exc = JavaThread::get()->pendingException; + JavaThread::get()->clearException(); + } + + if (exc) { + setErroneous(); + setOwnerClass(0); + JavaThread::get()->throwException(exc); + } - loadParents(); makeVT(); JavaCompiler *Comp = classLoader->getCompiler(); Comp->resolveVirtualClass(this); @@ -881,10 +912,21 @@ } else if (JavaThread::get() != getOwnerClass()) { while (!isResolved()) { waitClass(); + if (isErroneous()) break; } release(); + } } + + if (isErroneous()) { + JavaThread* th = JavaThread::get(); + JavaObject* exc = th->getJVM()->CreateLinkageError(""); + th->throwException(exc); + + } + + assert(virtualVT && "No virtual VT after resolution"); } #else void Class::resolveClass() { @@ -1029,6 +1071,7 @@ llvm_gcroot(clazz, 0); UserCommonClass* cl = ((JavaObjectClass*)clazz)->getClass(); + assert(cl && "No class in Class object"); if (cl->isClass()) { cl->asClass()->resolveClass(); if (doClinit) cl->asClass()->initialiseClass(vm); @@ -1315,6 +1358,8 @@ JavaVirtualTable::JavaVirtualTable(Class* C) { if (C->super) { + + assert(C->super->virtualVT && "Super has no VT"); // Set the regular object tracer, destructor and delete. tracer = (uintptr_t)RegularObjectTracer; Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h?rev=79155&r1=79154&r2=79155&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaClass.h Sat Aug 15 19:16:50 2009 @@ -851,7 +851,8 @@ /// isResolved - Has this class been resolved? /// bool isResolved() { - return getCurrentTaskClassMirror().status >= resolved; + uint8 stat = getCurrentTaskClassMirror().status; + return (stat >= resolved && stat != erroneous); } /// isErroneous - Is the class in an erroneous state. From nicolas.geoffray at lip6.fr Sun Aug 16 04:51:21 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 16 Aug 2009 11:51:21 -0000 Subject: [vmkit-commits] [vmkit] r79188 - /vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Message-ID: <200908161151.n7GBpLAf026313@zion.cs.uiuc.edu> Author: geoffray Date: Sun Aug 16 06:51:21 2009 New Revision: 79188 URL: http://llvm.org/viewvc/llvm-project?rev=79188&view=rev Log: No need to abort after all: vmjc will insert a callback if it can't find the class. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=79188&r1=79187&r2=79188&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaConstantPool.cpp Sun Aug 16 06:51:21 2009 @@ -291,11 +291,7 @@ // Put into ctpRes because there is only one representation of the class temp = loader->loadName(name, resolve, false); } - if (!temp && classDef->classLoader->getCompiler()->isStaticCompiling()) { - fprintf(stderr, "Could not find class %s while static compiling\n", - UTF8Buffer(name).cString()); - abort(); - } + ctpRes[index] = temp; } #endif From nicolas.geoffray at lip6.fr Thu Aug 27 06:35:45 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 27 Aug 2009 13:35:45 -0000 Subject: [vmkit-commits] [vmkit] r80241 - /vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Message-ID: <200908271335.n7RDZjuV024723@zion.cs.uiuc.edu> Author: geoffray Date: Thu Aug 27 08:35:44 2009 New Revision: 80241 URL: http://llvm.org/viewvc/llvm-project?rev=80241&view=rev Log: Add a isNative method to know if the thread is currently executing in native mode. Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Modified: vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h?rev=80241&r1=80240&r2=80241&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h (original) +++ vmkit/trunk/lib/JnJVM/VMCore/JavaThread.h Thu Aug 27 08:35:44 2009 @@ -252,6 +252,9 @@ addresses.pop_back(); } + bool isInNative() { + return !(addresses.size() % 2); + } /// getCallingClass - Get the Java class that called the last Java /// method that called the Java getCallingClass method. /// From nicolas.geoffray at lip6.fr Thu Aug 27 06:37:15 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 27 Aug 2009 13:37:15 -0000 Subject: [vmkit-commits] [vmkit] r80242 - /vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Message-ID: <200908271337.n7RDbFbD024921@zion.cs.uiuc.edu> Author: geoffray Date: Thu Aug 27 08:37:14 2009 New Revision: 80242 URL: http://llvm.org/viewvc/llvm-project?rev=80242&view=rev Log: Put the thread state consistent, whether matierializeFunction is called by the jit or the pass manager. Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Modified: vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp?rev=80242&r1=80241&r2=80242&view=diff ============================================================================== --- vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp (original) +++ vmkit/trunk/lib/JnJVM/Compiler/JnjvmModuleProvider.cpp Thu Aug 27 08:37:14 2009 @@ -77,6 +77,15 @@ bool JnjvmModuleProvider::materializeFunction(Function *F, std::string *ErrInfo) { + // materializeFunction is called by the LLVM JIT, which does not know + // about the call stack of jnjvm. Update the call stack if this + // function was called by the LLVM JIT. The other place where + // materializeFunction is called is in the pass managers; in such + // a case, jnjvm has already settled the call stack. + JavaThread* th = JavaThread::get(); + bool isNative = th->isInNative(); + if (!isNative) th->startNative(5); + // The caller of materializeFunction *must* always hold the JIT lock. // Because we are materializing a function here, we must release the // JIT lock and get the global vmkit lock to be thread-safe. @@ -91,6 +100,7 @@ mvm::MvmModule::unprotectIR(); // Reacquire and go back to the JIT function. mvm::MvmModule::executionEngine->lock.acquire(); + if (!isNative) th->endNative(); return false; } @@ -98,8 +108,10 @@ mvm::MvmModule::unprotectIR(); // Reacquire and go back to the JIT function. mvm::MvmModule::executionEngine->lock.acquire(); + if (!isNative) th->endNative(); return false; } + JavaMethod* meth = Comp->getJavaMethod(F); @@ -134,7 +146,8 @@ if (F->isDeclaration()) mvm::MvmModule::executionEngine->updateGlobalMapping(F, val); - + + if (!isNative) th->endNative(); return false; } From nicolas.geoffray at lip6.fr Thu Aug 27 06:38:58 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 27 Aug 2009 13:38:58 -0000 Subject: [vmkit-commits] [vmkit] r80243 - in /vmkit/trunk: lib/Mvm/Compiler/EscapeAnalysis.cpp lib/N3/VMCore/CLIJit.cpp lib/N3/VMCore/CLIJit.h tools/llcj/llcj.cpp tools/vmjc/vmjc.cpp tools/vmkit/Launcher.cpp Message-ID: <200908271338.n7RDcwtw025168@zion.cs.uiuc.edu> Author: geoffray Date: Thu Aug 27 08:38:57 2009 New Revision: 80243 URL: http://llvm.org/viewvc/llvm-project?rev=80243&view=rev Log: Fix includes and use of streams. Modified: vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp vmkit/trunk/lib/N3/VMCore/CLIJit.cpp vmkit/trunk/lib/N3/VMCore/CLIJit.h vmkit/trunk/tools/llcj/llcj.cpp vmkit/trunk/tools/vmjc/vmjc.cpp vmkit/trunk/tools/vmkit/Launcher.cpp Modified: vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp?rev=80243&r1=80242&r2=80243&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp Thu Aug 27 08:38:57 2009 @@ -196,7 +196,7 @@ // The object does not have a finalizer and is never used. Remove the // allocation as it will not have side effects. if (!hasFinalizer && !Alloc->getNumUses()) { - DOUT << "Escape analysis removes instruction " << *Alloc << ": "; + DEBUG(errs() << "Escape analysis removes instruction " << *Alloc << ": "); Alloc->eraseFromParent(); return true; } @@ -214,8 +214,9 @@ // we don't end up with tons of allocations on the stack. BasicBlock* BB = CurLoop->getLoopPreheader(); assert(BB && "No Preheader!"); - DOUT << "Escape analysis hoisting to " << BB->getNameStr() << ": "; - DOUT << *Alloc; + DEBUG(errs() << "Escape analysis hoisting to " << BB->getNameStr()); + DEBUG(errs() << ": "); + DEBUG(errs() << *Alloc); Alloc->removeFromParent(); BB->getInstList().insert(BB->getTerminator(), Alloc); } @@ -223,7 +224,8 @@ AllocaInst* AI = new AllocaInst(Type::getInt8Ty(Context), Size, "", Alloc); BitCastInst* BI = new BitCastInst(AI, Alloc->getType(), "", Alloc); - DOUT << "escape" << Alloc->getParent()->getParent()->getNameStr() << "\n"; + DEBUG(errs() << "escape"); + DEBUG(errs() << Alloc->getParent()->getParent()->getNameStr() << "\n"); Alloc->replaceAllUsesWith(BI); // If it's an invoke, replace the invoke with a direct branch. if (InvokeInst *CI = dyn_cast(Alloc)) { Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=80243&r1=80242&r2=80243&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Thu Aug 27 08:38:57 2009 @@ -11,20 +11,7 @@ #define N3_COMPILE 0 #define N3_EXECUTE 0 -#include "debug.h" -#include "types.h" -#include "llvm/CallingConv.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include @@ -44,6 +31,21 @@ #include "VMClass.h" #include "VMThread.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "debug.h" +#include "types.h" + using namespace llvm; using namespace n3; Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.h?rev=80243&r1=80242&r2=80243&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJit.h (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJit.h Thu Aug 27 08:38:57 2009 @@ -19,11 +19,11 @@ #include "llvm/DerivedTypes.h" #include "llvm/Function.h" #include "llvm/Instructions.h" +#include "llvm/PassManager.h" +#include "llvm/Type.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/GenericValue.h" -#include "llvm/PassManager.h" #include "llvm/Target/TargetData.h" -#include "llvm/Type.h" #include "types.h" Modified: vmkit/trunk/tools/llcj/llcj.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/llcj/llcj.cpp?rev=80243&r1=80242&r2=80243&view=diff ============================================================================== --- vmkit/trunk/tools/llcj/llcj.cpp (original) +++ vmkit/trunk/tools/llcj/llcj.cpp Thu Aug 27 08:38:57 2009 @@ -131,10 +131,10 @@ Out.appendComponent(className); Out.appendSuffix("bc"); - vmjcArgv[0] = Prog.toString().c_str(); + vmjcArgv[0] = Prog.c_str(); vmjcArgv[vmjcArgc++] = "-f"; vmjcArgv[vmjcArgc++] = "-o"; - vmjcArgv[vmjcArgc++] = Out.toString().c_str(); + vmjcArgv[vmjcArgc++] = Out.c_str(); res = sys::Program::ExecuteAndWait(Prog, vmjcArgv); @@ -151,11 +151,11 @@ } const char* optArgv[7]; - optArgv[0] = Prog.toString().c_str(); - optArgv[1] = Out.toString().c_str(); + optArgv[0] = Prog.c_str(); + optArgv[1] = Out.c_str(); optArgv[2] = "-f"; optArgv[3] = "-o"; - optArgv[4] = OptOut.toString().c_str(); + optArgv[4] = OptOut.c_str(); if (opt) { optArgv[5] = opt; optArgv[6] = 0; @@ -187,13 +187,13 @@ const char* llcArgv[8]; int i = 0; - llcArgv[i++] = Prog.toString().c_str(); - llcArgv[i++] = Out.toString().c_str(); + llcArgv[i++] = Prog.c_str(); + llcArgv[i++] = Out.c_str(); if (shared) llcArgv[i++] = "-relocation-model=pic"; llcArgv[i++] = "-disable-fp-elim"; llcArgv[i++] = "-f"; llcArgv[i++] = "-o"; - llcArgv[i++] = LlcOut.toString().c_str(); + llcArgv[i++] = LlcOut.c_str(); llcArgv[i++] = 0; res = sys::Program::ExecuteAndWait(Prog, llcArgv); @@ -208,8 +208,8 @@ goto cleanup; } - gccArgv[0] = Prog.toString().c_str(); - gccArgv[gccArgc++] = Out.toString().c_str(); + gccArgv[0] = Prog.c_str(); + gccArgv[gccArgc++] = Out.c_str(); gccArgv[gccArgc++] = LLVMLibs; gccArgv[gccArgc++] = VMKITLibs1; gccArgv[gccArgc++] = VMKITLibs2; Modified: vmkit/trunk/tools/vmjc/vmjc.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=80243&r1=80242&r2=80243&view=diff ============================================================================== --- vmkit/trunk/tools/vmjc/vmjc.cpp (original) +++ vmkit/trunk/tools/vmjc/vmjc.cpp Thu Aug 27 08:38:57 2009 @@ -30,7 +30,6 @@ #include "llvm/Support/PassNameParser.h" #include "llvm/Support/PluginLoader.h" #include "llvm/Support/RegistryParser.h" -#include "llvm/Support/Streams.h" #include "llvm/Support/SystemUtils.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Signals.h" @@ -75,7 +74,7 @@ WithJIT("with-jit", cl::desc("Generate main function with JIT support")); static cl::opt -DontPrint("disable-output", cl::desc("Don't output the .ll file"), cl::Hidden); +DisableOutput("disable-output", cl::desc("Disable output"), cl::init(false)); // The OptimizationList is automatically populated with registered Passes by the @@ -146,12 +145,12 @@ if (PassInf->getNormalCtor()) P = PassInf->getNormalCtor()(); else - cerr << argv[0] << ": cannot create pass: " + errs() << argv[0] << ": cannot create pass: " << PassInf->getPassName() << "\n"; if (P) { bool isModulePass = dynamic_cast(P) != 0; if (isModulePass) - cerr << argv[0] << ": vmkit does not support module pass: " + errs() << argv[0] << ": vmkit does not support module pass: " << PassInf->getPassName() << "\n"; else addPass(Passes, P); @@ -173,7 +172,6 @@ cl::ParseCommandLineOptions(argc, argv, "vmkit .class -> .ll compiler\n"); sys::PrintStackTraceOnErrorSignal(); - std::ostream *Out = &std::cout; // Default to printing to stdout. std::string ErrorMessage; @@ -275,63 +273,48 @@ if (PrintStats) Comp->printStats(); - if (DontPrint) { - // Just use stdout. We won't actually print anything on it. - } else if (OutputFilename != "") { // Specified an output filename? - if (OutputFilename != "-") { // Not stdout? - if (!Force && std::ifstream(OutputFilename.c_str())) { - // If force is not specified, make sure not to overwrite a file! - cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists! Sending to standard output.\n"; - } else { - Out = new std::ofstream(OutputFilename.c_str()); - } - } - } else { + // Infer the output filename if needed. + if (OutputFilename.empty()) { if (InputFilename == "-") { OutputFilename = "-"; } else { std::string IFN = InputFilename; int Len = IFN.length(); - if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') { - // Source ends in .bc - OutputFilename = std::string(IFN.begin(), IFN.end()-3)+".bc"; + if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') { + // Source ends in .ll + OutputFilename = std::string(IFN.begin(), IFN.end()-3); } else { - OutputFilename = IFN+".bc"; - } - - if (!Force && std::ifstream(OutputFilename.c_str())) { - // If force is not specified, make sure not to overwrite a file! - cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists! Sending to standard output.\n"; - } else { - Out = new std::ofstream(OutputFilename.c_str()); - - // Make sure that the Out file gets unlinked from the disk if we get a - // SIGINT - sys::RemoveFileOnSignal(sys::Path(OutputFilename)); - } - } + OutputFilename = IFN; // Append a .bc to it + } + OutputFilename += ".bc"; + } } - - if (!Out->good()) { - cerr << argv[0] << ": error opening " << OutputFilename - << ": sending to stdout instead!\n"; - Out = &std::cout; + + std::string ErrorInfo; + std::auto_ptr Out + (new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo, + raw_fd_ostream::F_Binary)); + if (!ErrorInfo.empty()) { + errs() << ErrorInfo << '\n'; + return 1; } - - if (Force || !CheckBitcodeOutputToConsole(Out,true)) - WriteBitcodeToFile(Comp->getLLVMModule(), *Out); + + + // Make sure that the Out file gets unlinked from the disk if we get a + // SIGINT. + if (OutputFilename != "-") + sys::RemoveFileOnSignal(sys::Path(OutputFilename)); + + if (!DisableOutput) + if (Force || !CheckBitcodeOutputToConsole(*Out, true)) + WriteBitcodeToFile(Comp->getLLVMModule(), *Out); - if (Out != &std::cout) { - ((std::ofstream*)Out)->close(); - delete Out; - } return 0; + } catch (const std::string& msg) { - cerr << argv[0] << ": " << msg << "\n"; + errs() << argv[0] << ": " << msg << "\n"; } catch (...) { - cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; + errs() << argv[0] << ": Unexpected unknown exception occurred.\n"; } return 1; } Modified: vmkit/trunk/tools/vmkit/Launcher.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=80243&r1=80242&r2=80243&view=diff ============================================================================== --- vmkit/trunk/tools/vmkit/Launcher.cpp (original) +++ vmkit/trunk/tools/vmkit/Launcher.cpp Thu Aug 27 08:38:57 2009 @@ -90,12 +90,12 @@ if (PassInf->getNormalCtor()) P = PassInf->getNormalCtor()(); else - cerr << argv[0] << ": cannot create pass: " + errs() << argv[0] << ": cannot create pass: " << PassInf->getPassName() << "\n"; if (P) { bool isModulePass = dynamic_cast(P) != 0; if (isModulePass) - cerr << argv[0] << ": vmkit does not support module pass: " + errs() << argv[0] << ": vmkit does not support module pass: " << PassInf->getPassName() << "\n"; else addPass(Passes, P); From nicolas.geoffray at lip6.fr Mon Aug 31 01:40:16 2009 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 31 Aug 2009 08:40:16 -0000 Subject: [vmkit-commits] [vmkit] r80580 - /vmkit/trunk/lib/N3/VMCore/N3.cpp Message-ID: <200908310840.n7V8eGbR004108@zion.cs.uiuc.edu> Author: geoffray Date: Mon Aug 31 03:40:15 2009 New Revision: 80580 URL: http://llvm.org/viewvc/llvm-project?rev=80580&view=rev Log: Only use one LLVMContext for now. Modified: vmkit/trunk/lib/N3/VMCore/N3.cpp Modified: vmkit/trunk/lib/N3/VMCore/N3.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3.cpp?rev=80580&r1=80579&r2=80580&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/N3.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/N3.cpp Mon Aug 31 03:40:15 2009 @@ -66,7 +66,7 @@ std::string str = mvm::MvmModule::executionEngine->getTargetData()->getStringRepresentation(); - vm->LLVMModule = new llvm::Module("Bootstrap N3", *(new llvm::LLVMContext())); + vm->LLVMModule = new llvm::Module("Bootstrap N3", llvm::getGlobalContext()); vm->module = new mvm::MvmModule(vm->LLVMModule); vm->getLLVMModule()->setDataLayout(str); vm->protectModule = new mvm::LockNormal(); @@ -90,7 +90,7 @@ std::string str = mvm::MvmModule::executionEngine->getTargetData()->getStringRepresentation(); - vm->LLVMModule = new llvm::Module("Bootstrap N3", *(new llvm::LLVMContext())); + vm->LLVMModule = new llvm::Module("Bootstrap N3", llvm::getGlobalContext()); vm->module = new mvm::MvmModule(vm->LLVMModule); vm->LLVMModule->setDataLayout(str); vm->protectModule = new mvm::LockNormal();