From nicolas.geoffray at lip6.fr Sat Feb 6 08:47:25 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 06 Feb 2010 16:47:25 -0000 Subject: [vmkit-commits] [vmkit] r95499 - in /vmkit/trunk: include/j3/JnjvmModule.h include/mvm/JIT.h lib/J3/Classpath/ClasspathVMThrowable.inc lib/J3/Compiler/ExceptionsCheck.inc lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/JavaJIT.cpp lib/J3/Compiler/JavaJIT.h lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/JavaJITOpcodes.cpp lib/J3/Compiler/JnjvmModule.cpp lib/J3/LLVMRuntime/runtime-default.ll lib/J3/VMCore/JavaClass.cpp lib/J3/VMCore/JavaClass.h lib/Mvm/Compiler/JIT.cpp Message-ID: <201002061647.o16GlQV8032535@zion.cs.uiuc.edu> Author: geoffray Date: Sat Feb 6 10:47:24 2010 New Revision: 95499 URL: http://llvm.org/viewvc/llvm-project?rev=95499&view=rev Log: Print line number information in J3! Modified: vmkit/trunk/include/j3/JnjvmModule.h vmkit/trunk/include/mvm/JIT.h vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp vmkit/trunk/lib/J3/Compiler/JavaJIT.h vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll vmkit/trunk/lib/J3/VMCore/JavaClass.cpp vmkit/trunk/lib/J3/VMCore/JavaClass.h vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Modified: vmkit/trunk/include/j3/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/include/j3/JnjvmModule.h (original) +++ vmkit/trunk/include/j3/JnjvmModule.h Sat Feb 6 10:47:24 2010 @@ -29,6 +29,7 @@ class GlobalVariable; class GCFunctionInfo; class GVMaterializer; + class MDNode; class Module; class Type; class Value; @@ -110,6 +111,7 @@ llvm::Function* methodFunction; llvm::Constant* offsetConstant; const llvm::FunctionType* functionType; + llvm::MDNode* DbgSubprogram; public: @@ -119,14 +121,17 @@ const llvm::FunctionType* getFunctionType(); LLVMMethodInfo(JavaMethod* M) : methodDef(M), methodFunction(0), - offsetConstant(0), functionType(0), GCInfo(0) {} + offsetConstant(0), functionType(0), DbgSubprogram(0), GCInfo(0) {} + void setDbgSubprogram(llvm::MDNode* node) { DbgSubprogram = node; } + llvm::MDNode* getDbgSubprogram() { return DbgSubprogram; } virtual void clear() { GCInfo = 0; methodFunction = 0; offsetConstant = 0; functionType = 0; + DbgSubprogram = 0; } }; @@ -230,8 +235,8 @@ static const llvm::Type* JavaClassType; static const llvm::Type* JavaClassArrayType; static const llvm::Type* JavaClassPrimitiveType; - static const llvm::Type* JavaCacheType; static const llvm::Type* ConstantPoolType; + static const llvm::Type* CodeLineInfoType; static const llvm::Type* UTF8Type; static const llvm::Type* JavaMethodType; static const llvm::Type* JavaFieldType; @@ -375,16 +380,13 @@ protected: - llvm::Module* TheModule; llvm::GVMaterializer* TheModuleProvider; JnjvmModule JavaIntrinsics; void addJavaPasses(); -private: - - +private: bool enabledException; bool cooperativeGC; @@ -393,9 +395,11 @@ std::map functions; typedef std::map::iterator function_iterator; - -public: + std::map DbgInfos; + typedef std::map::iterator dbg_iterator; + +public: JavaLLVMCompiler(const std::string &ModuleID); virtual bool isStaticCompiling() = 0; @@ -424,13 +428,13 @@ void disableCooperativeGC() { cooperativeGC = false; } - + virtual JavaCompiler* Create(const std::string& ModuleID) = 0; virtual ~JavaLLVMCompiler(); - JavaMethod* getJavaMethod(llvm::Function*); + llvm::MDNode* GetDbgSubprogram(JavaMethod* meth); void resolveVirtualClass(Class* cl); void resolveStaticClass(Class* cl); @@ -442,7 +446,6 @@ static LLVMMethodInfo* getMethodInfo(JavaMethod* method); static LLVMAssessorInfo& getTypedefInfo(const Typedef* type); - virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl) = 0; virtual JavaObject* getFinalObject(llvm::Value* C) = 0; virtual llvm::Constant* getNativeClass(CommonClass* cl) = 0; Modified: vmkit/trunk/include/mvm/JIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/include/mvm/JIT.h (original) +++ vmkit/trunk/include/mvm/JIT.h Sat Feb 6 10:47:24 2010 @@ -25,8 +25,8 @@ class Constant; class ConstantFP; class ConstantInt; + class DIFactory; class ExecutionEngine; - class ExistingModuleProvider; class Function; class FunctionPassManager; class GCFunctionInfo; @@ -171,6 +171,9 @@ llvm::Constant* constantFatMask; llvm::Constant* constantPtrOne; llvm::Constant* constantPtrZero; + + llvm::DIFactory* DebugFactory; + static const llvm::PointerType* ptrType; static const llvm::PointerType* ptr32Type; static const llvm::PointerType* ptrPtrType; @@ -181,7 +184,6 @@ static llvm::GCStrategy* GC; static mvm::LockRecursive protectEngine; static llvm::Module *globalModule; - static llvm::ExistingModuleProvider *globalModuleProvider; static llvm::FunctionPassManager* globalFunctionPasses; static const llvm::TargetData* TheTargetData; static mvm::BumpPtrAllocator* Allocator; Modified: vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc (original) +++ vmkit/trunk/lib/J3/Classpath/ClasspathVMThrowable.inc Sat Feb 6 10:47:24 2010 @@ -98,12 +98,13 @@ } bool native = isNative(meth->access); + uint16 lineNumber = meth->lookupLineNumber(reinterpret_cast(ip)); UserClass* newS = vm->upcalls->newStackTraceElement; res = newS->doNew(vm); vm->upcalls->initStackTraceElement->invokeIntSpecial(vm, newS, res, &sourceName, - 0, // source line + lineNumber, &className, &methodName, native); return res; Modified: vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc (original) +++ vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc Sat Feb 6 10:47:24 2010 @@ -5,6 +5,11 @@ Instruction* res = CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd); + DILocation Location = + module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, + DIScope(DbgSubprogram)); + res->setMetadata("dbg", Location.getNode()); + if (TheCompiler->hasExceptionsEnabled()) { Value* threadId = getCurrentThread(module->JavaThreadType); Value* geps[2] = { module->constantZero, @@ -61,6 +66,10 @@ BasicBlock *InsertAtEnd) { Instruction* res = CallInst::Create(F, arg1, Name, InsertAtEnd); + DILocation Location = + module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, + DIScope(DbgSubprogram)); + res->setMetadata("dbg", Location.getNode()); if (TheCompiler->hasExceptionsEnabled()) { Value* threadId = getCurrentThread(module->JavaThreadType); @@ -112,6 +121,10 @@ Value* args[2] = { arg1, arg2 }; Instruction* res = CallInst::Create(F, args, args + 2, Name, InsertAtEnd); + DILocation Location = + module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, + DIScope(DbgSubprogram)); + res->setMetadata("dbg", Location.getNode()); if (TheCompiler->hasExceptionsEnabled()) { Value* threadId = getCurrentThread(module->JavaThreadType); @@ -160,6 +173,10 @@ Instruction* JavaJIT::invoke(Value *F, const char* Name, BasicBlock *InsertAtEnd) { Instruction* res = llvm::CallInst::Create(F, Name, InsertAtEnd); + DILocation Location = + module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, + DIScope(DbgSubprogram)); + res->setMetadata("dbg", Location.getNode()); if (TheCompiler->hasExceptionsEnabled()) { Value* threadId = getCurrentThread(module->JavaThreadType); @@ -206,7 +223,11 @@ } void JavaJIT::throwException(llvm::Function* F, Value* arg1) { - Value* obj = CallInst::Create(F, arg1, "", currentBlock); + Instruction* obj = CallInst::Create(F, arg1, "", currentBlock); + DILocation Location = + module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, + DIScope(DbgSubprogram)); + obj->setMetadata("dbg", Location.getNode()); if (currentExceptionBlock != endExceptionBlock) { Instruction* insn = currentExceptionBlock->begin(); PHINode* node = dyn_cast(insn); @@ -246,7 +267,11 @@ void JavaJIT::throwException(llvm::Function* F, Value** args, uint32 nbArgs) { - Value* obj = CallInst::Create(F, args, args + nbArgs, "", currentBlock); + Instruction* obj = CallInst::Create(F, args, args + nbArgs, "", currentBlock); + DILocation Location = + module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, + DIScope(DbgSubprogram)); + obj->setMetadata("dbg", Location.getNode()); if (currentExceptionBlock != endExceptionBlock) { Instruction* insn = currentExceptionBlock->begin(); PHINode* node = dyn_cast(insn); Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sat Feb 6 10:47:24 2010 @@ -956,11 +956,17 @@ MethodElts.push_back(ConstantExpr::getCast(Instruction::BitCast, func, JnjvmModule::ptrType)); } + + // codeInfo + MethodElts.push_back(Constant::getNullValue(JnjvmModule::CodeLineInfoType)); + + // codeInfoLength + MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), 0)); // offset MethodElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), method.offset)); - //JInfo + // JInfo MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); return ConstantStruct::get(STy, MethodElts); Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sat Feb 6 10:47:24 2010 @@ -755,6 +755,9 @@ Instruction* JavaJIT::inlineCompile(BasicBlock*& curBB, BasicBlock* endExBlock, std::vector& args) { + + DbgSubprogram = TheCompiler->GetDbgSubprogram(compilingMethod); + PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "inline compile %s.%s\n", UTF8Buffer(compilingClass->name).cString(), UTF8Buffer(compilingMethod->name).cString()); @@ -792,7 +795,7 @@ for (uint32 i = 0; i < codeLen; ++i) { opcodeInfos[i].exceptionBlock = endExBlock; } - + BasicBlock* firstBB = llvmFunction->begin(); if (firstBB->begin() != firstBB->end()) { @@ -904,7 +907,24 @@ } readExceptionTable(reader, codeLen); - + + // Lookup line number table attribute. + uint16 nba = reader.readU2(); + for (uint16 i = 0; i < nba; ++i) { + const UTF8* attName = compilingClass->ctpInfo->UTF8At(reader.readU2()); + uint32 attLen = reader.readU4(); + if (attName->equals(Attribut::lineNumberTableAttribut)) { + uint16 lineLength = reader.readU2(); + for (uint16 i = 0; i < lineLength; ++i) { + uint16 pc = reader.readU2(); + uint16 ln = reader.readU2(); + opcodeInfos[pc].lineNumber = ln; + } + } else { + reader.seek(attLen, Reader::SeekCur); + } + } + exploreOpcodes(&compilingClass->bytes->elements[start], codeLen); if (returnType != Type::getVoidTy(getGlobalContext())) { @@ -944,17 +964,17 @@ UTF8Buffer(compilingClass->name).cString(), UTF8Buffer(compilingMethod->name).cString()); - + DbgSubprogram = TheCompiler->GetDbgSubprogram(compilingMethod); + Attribut* codeAtt = compilingMethod->lookupAttribut(Attribut::codeAttribut); if (!codeAtt) { fprintf(stderr, "I haven't verified your class file and it's malformed:" - " no code attribut found for %s.%s!\n", + " no code attribute found for %s.%s!\n", UTF8Buffer(compilingClass->name).cString(), UTF8Buffer(compilingMethod->name).cString()); abort(); - } - + } Reader reader(codeAtt, &(compilingClass->bytes)); uint16 maxStack = reader.readU2(); @@ -971,14 +991,14 @@ currentBlock = createBasicBlock("start"); endExceptionBlock = createBasicBlock("endExceptionBlock"); - unifiedUnreachable = createBasicBlock("unifiedUnreachable"); + unifiedUnreachable = createBasicBlock("unifiedUnreachable"); opcodeInfos = new Opinfo[codeLen]; memset(opcodeInfos, 0, codeLen * sizeof(Opinfo)); for (uint32 i = 0; i < codeLen; ++i) { opcodeInfos[i].exceptionBlock = endExceptionBlock; } - + #if JNJVM_EXECUTE > 0 { Value* arg = TheCompiler->getMethodInClass(compilingMethod); @@ -1123,6 +1143,23 @@ readExceptionTable(reader, codeLen); + // Lookup line number table attribute. + uint16 nba = reader.readU2(); + for (uint16 i = 0; i < nba; ++i) { + const UTF8* attName = compilingClass->ctpInfo->UTF8At(reader.readU2()); + uint32 attLen = reader.readU4(); + if (attName->equals(Attribut::lineNumberTableAttribut)) { + uint16 lineLength = reader.readU2(); + for (uint16 i = 0; i < lineLength; ++i) { + uint16 pc = reader.readU2(); + uint16 ln = reader.readU2(); + opcodeInfos[pc].lineNumber = ln; + } + } else { + reader.seek(attLen, Reader::SeekCur); + } + } + exploreOpcodes(&compilingClass->bytes->elements[start], codeLen); endBlock = createBasicBlock("end"); Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Sat Feb 6 10:47:24 2010 @@ -20,6 +20,7 @@ #include "llvm/Metadata.h" #include "llvm/Type.h" #include "llvm/Value.h" +#include "llvm/Analysis/DebugInfo.h" #include "types.h" @@ -56,10 +57,13 @@ /// stack - The stack at this location if there is a new block /// std::vector stack; + + /// lineNumber - The line number of this bytecode. + uint16 lineNumber; }; -/// JavaJIT - The compilation engine of VMKit. Parses the bycode and returns +/// JavaJIT - The compilation engine of J3. Parses the bycode and returns /// its LLVM representation. /// class JavaJIT { @@ -78,6 +82,8 @@ callsStackWalker = false; endNode = 0; currentStackIndex = 0; + currentLineNumber = 0; + currentCtpIndex = -1; } /// javaCompile - Compile the Java method. @@ -136,6 +142,16 @@ /// getCurrentThread - Emit code to get the current thread. llvm::Value* getCurrentThread(const llvm::Type* Ty); +//===------------------------- Debugging support --------------------------===// + + llvm::MDNode* DbgSubprogram; + + /// currentLineIndex - The current line being processed. + uint32 currentLineNumber; + + /// currentCtpIndex - The constant pool index being processed. + uint16 currentCtpIndex; + //===--------------------------- Inline support ---------------------------===// /// inlineCompile - Parse the method and start its LLVM representation Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sat Feb 6 10:47:24 2010 @@ -13,7 +13,9 @@ #include "llvm/Instructions.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" +#include "llvm/Analysis/DebugInfo.h" #include "llvm/CodeGen/GCStrategy.h" +#include "llvm/CodeGen/MachineFunction.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/JITEventListener.h" #include "llvm/Support/ManagedStatic.h" @@ -60,6 +62,19 @@ JavaJITMethodInfo(GFI, currentCompiledMethod); vm->RuntimeFunctions.addMethodInfo(MI, Code, (void*)((uintptr_t)Code + Size)); + uint32 infoLength = Details.LineStarts.size(); + currentCompiledMethod->codeInfoLength = infoLength; + if (infoLength) { + currentCompiledMethod->codeInfo = + new(Alloc, "CodeLineInfo") CodeLineInfo[infoLength]; + for (uint32 i = 0; i < infoLength; ++i) { + DILocation DLT = Details.MF->getDILocation(Details.LineStarts[i].Loc); + currentCompiledMethod->codeInfo[i].address = + Details.LineStarts[i].Address; + currentCompiledMethod->codeInfo[i].lineNumber = DLT.getLineNumber(); + currentCompiledMethod->codeInfo[i].ctpIndex = DLT.getColumnNumber(); + } + } } } Modified: vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Sat Feb 6 10:47:24 2010 @@ -167,6 +167,10 @@ currentExceptionBlock = opinfo->exceptionBlock; + // Update the line number information. + if (opinfo->lineNumber) + currentLineNumber = opinfo->lineNumber; + // To prevent a gcj bug with useless goto if (currentBlock->getTerminator() != 0) { currentBlock = createBasicBlock("gcj bug"); @@ -1932,24 +1936,28 @@ case INVOKEVIRTUAL : { uint16 index = readU2(bytecodes, i); + currentCtpIndex = index; invokeVirtual(index); break; } case INVOKESPECIAL : { uint16 index = readU2(bytecodes, i); + currentCtpIndex = index; invokeSpecial(index); break; } case INVOKESTATIC : { uint16 index = readU2(bytecodes, i); + currentCtpIndex = index; invokeStatic(index); break; } case INVOKEINTERFACE : { uint16 index = readU2(bytecodes, i); + currentCtpIndex = index; invokeInterface(index); i += 2; break; Modified: vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp Sat Feb 6 10:47:24 2010 @@ -42,6 +42,7 @@ const llvm::Type* JnjvmModule::JavaArrayDoubleType = 0; const llvm::Type* JnjvmModule::JavaArrayLongType = 0; const llvm::Type* JnjvmModule::JavaArrayObjectType = 0; +const llvm::Type* JnjvmModule::CodeLineInfoType = 0; const llvm::Type* JnjvmModule::ConstantPoolType = 0; const llvm::Type* JnjvmModule::UTF8Type = 0; const llvm::Type* JnjvmModule::JavaFieldType = 0; @@ -158,6 +159,9 @@ PointerType::getUnqual(module->getTypeByName("JavaThread")); MutatorThreadType = PointerType::getUnqual(module->getTypeByName("MutatorThread")); + + CodeLineInfoType = + PointerType::getUnqual(module->getTypeByName("CodeLineInfo")); LLVMAssessorInfo::initialise(); } @@ -374,6 +378,19 @@ return I->second; } +MDNode* JavaLLVMCompiler::GetDbgSubprogram(JavaMethod* meth) { + if (getMethodInfo(meth)->getDbgSubprogram() == NULL) { + MDNode* node = + JavaIntrinsics.DebugFactory->CreateSubprogram(DIDescriptor(), "", "", + "", DICompileUnit(), 0, + DIType(), false, + false).getNode(); + DbgInfos.insert(std::make_pair(node, meth)); + getMethodInfo(meth)->setDbgSubprogram(node); + } + return getMethodInfo(meth)->getDbgSubprogram(); +} + JavaLLVMCompiler::~JavaLLVMCompiler() { delete JavaFunctionPasses; delete JavaNativeFunctionPasses; Modified: vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll (original) +++ vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll Sat Feb 6 10:47:24 2010 @@ -38,8 +38,10 @@ %JavaField = type { i8*, i16, %UTF8*, %UTF8*, %Attribut*, i16, %JavaClass*, i32, i16, i8* } +%CodeLineInfo = type { i8*, i16, i16, %JavaMethod*, %CodeLineInfo* } + %JavaMethod = type { i8*, i16, %Attribut*, i16, %JavaClass*, - %UTF8*, %UTF8*, i8, i8*, i32, i8* } + %UTF8*, %UTF8*, i8, i8*, %CodeLineInfo*, i16, i32, i8* } %JavaClassPrimitive = type { %JavaCommonClass, i32 } %JavaClassArray = type { %JavaCommonClass, %JavaCommonClass* } Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Sat Feb 6 10:47:24 2010 @@ -1730,3 +1730,14 @@ } } } + +uint16 JavaMethod::lookupLineNumber(uintptr_t ip) { + for(uint16 i = 0; i < codeInfoLength; ++i) { + if (codeInfo[i].address > ip) { + assert(i > 0 && "Wrong ip address for method"); + return codeInfo[i - 1].lineNumber; + } + } + if (codeInfoLength) return codeInfo[codeInfoLength - 1].lineNumber; + return 0; +} Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.h?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.h Sat Feb 6 10:47:24 2010 @@ -989,6 +989,17 @@ } }; +class CodeLineInfo : public mvm::PermanentObject { +public: + uintptr_t address; + uint16 lineNumber; + uint16 ctpIndex; + // TODO: Use these fields when inlining. + JavaMethod* executingMethod; + // The code where the inlined method starts. + CodeLineInfo* inlineLocation; +}; + /// JavaMethod - This class represents Java methods. /// class JavaMethod : public mvm::PermanentObject { @@ -1049,7 +1060,15 @@ /// code - Pointer to the compiled code of this method. /// void* code; - + + /// codeInfo - Array of CodeLineInfo objects. + /// + CodeLineInfo* codeInfo; + + /// codeInfoLength - Number of entries in the codeInfo field. + /// + uint16 codeInfoLength; + /// offset - The index of the method in the virtual table. /// uint32 offset; @@ -1059,6 +1078,11 @@ /// Attribut* lookupAttribut(const UTF8* key); + /// lookupLineNumber - Find the line number based on the given instruction + /// pointer. + /// + uint16 lookupLineNumber(uintptr_t ip); + /// getSignature - Get the signature of thes method, resolving it if /// necessary. /// Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=95499&r1=95498&r2=95499&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sat Feb 6 10:47:24 2010 @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -307,7 +308,8 @@ module->setDataLayout(globalModule->getDataLayout()); module->setTargetTriple(globalModule->getTargetTriple()); - LLVMContext& Context = module->getContext(); + LLVMContext& Context = module->getContext(); + DebugFactory = new DIFactory(*module); // Constant declaration constantLongMinusOne = ConstantInt::get(Type::getInt64Ty(Context), (uint64_t)-1); From nicolas.geoffray at lip6.fr Sun Feb 7 05:34:25 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 07 Feb 2010 13:34:25 -0000 Subject: [vmkit-commits] [vmkit] r95520 - /vmkit/trunk/lib/J3/Classpath/ClasspathVMSystem.inc Message-ID: <201002071334.o17DYP4a030110@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 7 07:34:25 2010 New Revision: 95520 URL: http://llvm.org/viewvc/llvm-project?rev=95520&view=rev Log: Return hash code 0 for NULL. Modified: vmkit/trunk/lib/J3/Classpath/ClasspathVMSystem.inc Modified: vmkit/trunk/lib/J3/Classpath/ClasspathVMSystem.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/ClasspathVMSystem.inc?rev=95520&r1=95519&r2=95520&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Classpath/ClasspathVMSystem.inc (original) +++ vmkit/trunk/lib/J3/Classpath/ClasspathVMSystem.inc Sun Feb 7 07:34:25 2010 @@ -109,6 +109,7 @@ JavaObject* obj) { llvm_gcroot(obj, 0); + if (obj == NULL) return 0; return obj->hashCode(); } From nicolas.geoffray at lip6.fr Sun Feb 7 05:41:57 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 07 Feb 2010 13:41:57 -0000 Subject: [vmkit-commits] [vmkit] r95521 - in /vmkit/trunk/lib/J3: Compiler/JavaJIT.cpp LLVMRuntime/runtime-default.ll VMCore/JavaRuntimeJIT.cpp VMCore/JavaThread.cpp VMCore/JavaThread.h VMCore/Jni.cpp Message-ID: <201002071341.o17DfwVb030419@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 7 07:41:57 2010 New Revision: 95521 URL: http://llvm.org/viewvc/llvm-project?rev=95521&view=rev Log: Correctly handle JNI exceptions: we have been living with JNI exceptions going back to Java for so long, I wonder how we were able to run all these applications :). Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/J3/VMCore/JavaThread.cpp vmkit/trunk/lib/J3/VMCore/JavaThread.h vmkit/trunk/lib/J3/VMCore/Jni.cpp Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=95521&r1=95520&r2=95521&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sun Feb 7 07:41:57 2010 @@ -285,13 +285,12 @@ currentExceptionBlock = endExceptionBlock = 0; currentBlock = createBasicBlock("start"); - BasicBlock* executeBlock = createBasicBlock("execute"); endBlock = createBasicBlock("end block"); - Constant* sizeB = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), sizeof(jmp_buf)); - Value* oldJB = new AllocaInst(module->ptrType, "", currentBlock); - Value* newJB = new AllocaInst(Type::getInt8Ty(getGlobalContext()), sizeB, "", currentBlock); - + if (returnType != Type::getVoidTy(getGlobalContext())) { + endNode = PHINode::Create(returnType, "", endBlock); + } + // Allocate currentLocalIndexNumber pointer Value* temp = new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", currentBlock); @@ -308,22 +307,6 @@ if (isSynchro(compilingMethod->access)) beginSynchronize(); - Value* test = CallInst::Create(module->setjmpLLVM, newJB, "", - currentBlock); - - test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, test, - module->constantZero, ""); - BranchInst::Create(executeBlock, endBlock, test, currentBlock); - - if (returnType != Type::getVoidTy(getGlobalContext())) { - endNode = PHINode::Create(returnType, "", endBlock); - endNode->addIncoming(Constant::getNullValue(returnType), - currentBlock); - } - - currentBlock = executeBlock; - - uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); std::vector nativeArgs; @@ -363,8 +346,8 @@ const Type* Ty = PointerType::getUnqual(module->JavaObjectType); PHINode* node = PHINode::Create(Ty, "", BB); - test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, i, - module->JavaObjectNullConstant, ""); + Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, i, + module->JavaObjectNullConstant, ""); node->addIncoming(Constant::getNullValue(Ty), currentBlock); BranchInst::Create(BB, NotZero, test, currentBlock); @@ -446,9 +429,9 @@ nativeFunc = node; } - Value* Args4[5] = { temp, oldCLIN, newJB, oldJB, Frame }; + Value* Args4[3] = { temp, oldCLIN, Frame }; - CallInst::Create(module->StartJNIFunction, Args4, Args4 + 5, "", + CallInst::Create(module->StartJNIFunction, Args4, Args4 + 3, "", currentBlock); @@ -490,9 +473,9 @@ currentBlock = endBlock; - Value* Args2[2] = { oldCLIN, oldJB }; + Value* Args2[1] = { oldCLIN }; - CallInst::Create(module->EndJNIFunction, Args2, Args2 + 2, "", currentBlock); + CallInst::Create(module->EndJNIFunction, Args2, Args2 + 1, "", currentBlock); // Synchronize after leaving native. if (isSynchro(compilingMethod->access)) Modified: vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll?rev=95521&r1=95520&r2=95521&view=diff ============================================================================== --- vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll (original) +++ vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll Sun Feb 7 07:41:57 2010 @@ -211,8 +211,8 @@ declare void @j3ThrowException(%JavaObject*) declare void @j3ThrowExceptionFromJIT() -declare void @j3EndJNI(i32**, i8**) -declare void @j3StartJNI(i32*, i32**, i8*, i8**, i8*) +declare void @j3EndJNI(i32**) +declare void @j3StartJNI(i32*, i32**, i8*) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=95521&r1=95520&r2=95521&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Sun Feb 7 07:41:57 2010 @@ -327,15 +327,12 @@ } // Does not call Java code. Can not yield a GC. -extern "C" void j3EndJNI(uint32** oldLRN, void** oldBuffer) { +extern "C" void j3EndJNI(uint32** oldLRN) { JavaThread* th = JavaThread::get(); // We're going back to Java th->endJNI(); - // Update the buffer. - th->currentSjljBuffer = *oldBuffer; - // Update the number of references. th->currentAddedReferences = *oldLRN; @@ -344,21 +341,16 @@ extern "C" void* j3StartJNI(uint32* localReferencesNumber, uint32** oldLocalReferencesNumber, - void* newBuffer, void** oldBuffer, mvm::KnownFrame* Frame) __attribute__((noinline)); // Never throws. Does not call Java code. Can not yied a GC. extern "C" void* j3StartJNI(uint32* localReferencesNumber, - uint32** oldLocalReferencesNumber, - void* newBuffer, void** oldBuffer, - mvm::KnownFrame* Frame) { + uint32** oldLocalReferencesNumber, + mvm::KnownFrame* Frame) { JavaThread* th = JavaThread::get(); - *oldBuffer = th->currentSjljBuffer; - th->currentSjljBuffer = newBuffer; - *oldLocalReferencesNumber = th->currentAddedReferences; th->currentAddedReferences = localReferencesNumber; th->startKnownFrame(*Frame); Modified: vmkit/trunk/lib/J3/VMCore/JavaThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaThread.cpp?rev=95521&r1=95520&r2=95521&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaThread.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaThread.cpp Sun Feb 7 07:41:57 2010 @@ -38,7 +38,6 @@ jniEnv = isolate->jniEnv; localJNIRefs = new JNILocalReferences(); currentAddedReferences = 0; - currentSjljBuffer = 0; #ifdef SERVICE eipIndex = 0; Modified: vmkit/trunk/lib/J3/VMCore/JavaThread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaThread.h?rev=95521&r1=95520&r2=95521&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaThread.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaThread.h Sun Feb 7 07:41:57 2010 @@ -10,8 +10,6 @@ #ifndef JNJVM_JAVA_THREAD_H #define JNJVM_JAVA_THREAD_H -#include - #include "mvm/Object.h" #include "mvm/Threads/Cond.h" #include "mvm/Threads/Locks.h" @@ -118,12 +116,6 @@ /// state - The current state of this thread: Running, Waiting or Interrupted. uint32 state; - /// currentSjljBuffers - Current buffer pushed when entering a non-JVM native - /// function and popped when leaving the function. The buffer is used when - /// the native function throws an exception through a JNI throwException call. - /// - void* currentSjljBuffer; - /// currentAddedReferences - Current number of added local references. /// uint32_t* currentAddedReferences; @@ -196,15 +188,8 @@ /// throwFromJNI - Throw an exception after executing JNI code. /// void throwFromJNI(void* SP) { - assert(currentSjljBuffer); endKnownFrame(); enterUncooperativeCode(SP); - internalPendingException = 0; -#if defined(__MACH__) - longjmp((int*)currentSjljBuffer, 1); -#else - longjmp((__jmp_buf_tag*)currentSjljBuffer, 1); -#endif } /// throwFromNative - Throw an exception after executing Native code. Modified: vmkit/trunk/lib/J3/VMCore/Jni.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jni.cpp?rev=95521&r1=95520&r2=95521&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/Jni.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/Jni.cpp Sun Feb 7 07:41:57 2010 @@ -171,8 +171,6 @@ init->invokeIntSpecial(vm, realCl, res, &str); th->pendingException = res; - th->throwFromJNI(SP); - RETURN_FROM_JNI(1); END_JNI_EXCEPTION @@ -187,6 +185,7 @@ JavaObject* obj = JavaThread::get()->pendingException; llvm_gcroot(obj, 0); + if (obj == NULL) RETURN_FROM_JNI(NULL); jthrowable res = (jthrowable)th->pushJNIRef(obj); RETURN_FROM_JNI(res); From nicolas.geoffray at lip6.fr Sun Feb 7 08:45:48 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 07 Feb 2010 16:45:48 -0000 Subject: [vmkit-commits] [vmkit] r95522 - /vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h Message-ID: <201002071645.o17GjnpC007190@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 7 10:45:48 2010 New Revision: 95522 URL: http://llvm.org/viewvc/llvm-project?rev=95522&view=rev Log: Fix signature of j3StartJNI and j3EndJNI. Modified: vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h Modified: vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h?rev=95522&r1=95521&r2=95522&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h (original) +++ vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h Sun Feb 7 10:45:48 2010 @@ -23,6 +23,10 @@ class Jnjvm; } +namespace mvm { + class KnownFrame; +} + using namespace j3; extern "C" void* j3InterfaceLookup(UserClass* caller, uint32 index); @@ -36,8 +40,8 @@ extern "C" JavaArray* j3MultiCallNew(UserClassArray* cl, uint32 len, ...); extern "C" UserClassArray* j3GetArrayClass(UserCommonClass*, UserClassArray**); -extern "C" void j3EndJNI(); -extern "C" void* j3StartJNI(); +extern "C" void j3EndJNI(uint32**); +extern "C" void* j3StartJNI(uint32*, uint32**, mvm::KnownFrame*); extern "C" void j3JavaObjectAquire(JavaObject* obj); extern "C" void j3JavaObjectRelease(JavaObject* obj); extern "C" void j3ThrowException(JavaObject* obj); @@ -96,8 +100,8 @@ (void) j3RuntimeDelegatee(0); (void) j3MultiCallNew(0, 0); (void) j3GetArrayClass(0, 0); - (void) j3EndJNI(); - (void) j3StartJNI(); + (void) j3EndJNI(0); + (void) j3StartJNI(0, 0, 0); (void) j3JavaObjectAquire(0); (void) j3JavaObjectRelease(0); (void) j3ThrowException(0); From nicolas.geoffray at lip6.fr Sat Feb 13 09:45:01 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 13 Feb 2010 17:45:01 -0000 Subject: [vmkit-commits] [vmkit] r96102 - in /vmkit/trunk/lib/J3: Classpath/ClasspathVMRuntime.inc VMCore/JavaRuntimeJIT.cpp Message-ID: <201002131745.o1DHj1bm003755@zion.cs.uiuc.edu> Author: geoffray Date: Sat Feb 13 11:45:00 2010 New Revision: 96102 URL: http://llvm.org/viewvc/llvm-project?rev=96102&view=rev Log: Fix calls to startJNI and endJNI from Classpath. Modified: vmkit/trunk/lib/J3/Classpath/ClasspathVMRuntime.inc vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Modified: vmkit/trunk/lib/J3/Classpath/ClasspathVMRuntime.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/ClasspathVMRuntime.inc?rev=96102&r1=96101&r2=96102&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Classpath/ClasspathVMRuntime.inc (original) +++ vmkit/trunk/lib/J3/Classpath/ClasspathVMRuntime.inc Sat Feb 13 11:45:00 2010 @@ -81,9 +81,8 @@ #endif typedef int (*onLoad_t)(const void**, void*); -extern "C" void j3EndJNI(uint32** old, void** oldBuf); -extern "C" void j3StartJNI(uint32* num, uint32** old, void* newBuf, - void** oldBuf, mvm::KnownFrame* Frame); +extern "C" void j3EndJNI(uint32** old); +extern "C" void j3StartJNI(uint32* num, uint32** old, mvm::KnownFrame* Frame); extern "C" void callOnLoad(void* res, JnjvmClassLoader* loader, Jnjvm* vm) __attribute__ ((noinline)); @@ -96,18 +95,11 @@ if (onLoad) { uint32 num = 0; uint32* old = 0; - void* oldBuf = 0; mvm::KnownFrame Frame; - jmp_buf buf; - if (setjmp(buf) == 0) { - // Push an unmeaningful value in the addresses field to let the - // stack consistent with Java frames/native frames. - j3StartJNI(&num, &old, (void*)&buf, &oldBuf, &Frame); - onLoad(&vm->javavmEnv, res); - } - - j3EndJNI(&old, &oldBuf); + j3StartJNI(&num, &old, &Frame); + onLoad(&vm->javavmEnv, res); + j3EndJNI(&old); } } Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=96102&r1=96101&r2=96102&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Sat Feb 13 11:45:00 2010 @@ -340,8 +340,8 @@ } extern "C" void* j3StartJNI(uint32* localReferencesNumber, - uint32** oldLocalReferencesNumber, - mvm::KnownFrame* Frame) + uint32** oldLocalReferencesNumber, + mvm::KnownFrame* Frame) __attribute__((noinline)); // Never throws. Does not call Java code. Can not yied a GC. From nicolas.geoffray at lip6.fr Sat Feb 13 10:26:03 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 13 Feb 2010 18:26:03 -0000 Subject: [vmkit-commits] [vmkit] r96104 - /vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Message-ID: <201002131826.o1DIQ3ok006610@zion.cs.uiuc.edu> Author: geoffray Date: Sat Feb 13 12:26:02 2010 New Revision: 96104 URL: http://llvm.org/viewvc/llvm-project?rev=96104&view=rev Log: Put gc_root call properly in a native method. Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=96104&r1=96103&r2=96104&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sat Feb 13 12:26:02 2010 @@ -355,16 +355,17 @@ currentBlock = NotZero; Instruction* temp = new AllocaInst(module->JavaObjectType, "", - func->begin()->begin()); + func->begin()->getTerminator()); if (TheCompiler->useCooperativeGC()) { Value* GCArgs[2] = { - new BitCastInst(temp, module->ptrPtrType, "", currentBlock), + new BitCastInst(temp, module->ptrPtrType, "", + func->begin()->getTerminator()), module->constantPtrNull }; CallInst::Create(module->llvm_gc_gcroot, GCArgs, GCArgs + 2, "", - temp); + func->begin()->getTerminator()); } new StoreInst(i, temp, false, currentBlock); @@ -434,19 +435,6 @@ CallInst::Create(module->StartJNIFunction, Args4, Args4 + 3, "", currentBlock); - - // FIXME: Is this still needed? - // - // When calling a native method, it may do whatever it wants with the - // frame pointer. Therefore make sure it's on the stack. x86_64 has - // this problem because it passes first arguments in registers. - // Therefore, it was overwriting the frame pointer when entering the - // native method. - //Value* FrameAddr = CallInst::Create(module->llvm_frameaddress, - // module->constantZero, "", currentBlock); - //Value* Temp = new AllocaInst(module->ptrType, "", currentBlock); - //new StoreInst(FrameAddr, Temp, currentBlock); - Value* result = llvm::CallInst::Create(nativeFunc, nativeArgs.begin(), nativeArgs.end(), "", currentBlock); @@ -490,9 +478,10 @@ UTF8Buffer(compilingClass->name).cString(), UTF8Buffer(compilingMethod->name).cString()); - + return llvmFunction; } + void JavaJIT::monitorEnter(Value* obj) { std::vector gep; gep.push_back(module->constantZero); From nicolas.geoffray at lip6.fr Sat Feb 13 11:00:01 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 13 Feb 2010 19:00:01 -0000 Subject: [vmkit-commits] [vmkit] r96108 - in /vmkit/trunk: include/mvm/Threads/Locks.h mmtk/mmtk-j3/ObjectModel.cpp Message-ID: <201002131900.o1DJ01iH008527@zion.cs.uiuc.edu> Author: geoffray Date: Sat Feb 13 13:00:01 2010 New Revision: 96108 URL: http://llvm.org/viewvc/llvm-project?rev=96108&view=rev Log: Fix mask when updating GC bits. Modified: vmkit/trunk/include/mvm/Threads/Locks.h vmkit/trunk/mmtk/mmtk-j3/ObjectModel.cpp Modified: vmkit/trunk/include/mvm/Threads/Locks.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/Threads/Locks.h?rev=96108&r1=96107&r2=96108&view=diff ============================================================================== --- vmkit/trunk/include/mvm/Threads/Locks.h (original) +++ vmkit/trunk/include/mvm/Threads/Locks.h Sat Feb 13 13:00:01 2010 @@ -186,8 +186,12 @@ static const uint64_t ThinCountMask = 0xFF000; static const uint64_t ThinCountShift = 12; static const uint64_t ThinCountAdd = 0x1000; + // Mask for all GC objects. static const uint64_t GCMask = 0xFFF; + // Mask for the hash code bits. static const uint64_t HashMask = 0xFFC; + // Mask for the GC bits. + static const uint64_t GCBitMask = 0x3; Modified: vmkit/trunk/mmtk/mmtk-j3/ObjectModel.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/mmtk-j3/ObjectModel.cpp?rev=96108&r1=96107&r2=96108&view=diff ============================================================================== --- vmkit/trunk/mmtk/mmtk-j3/ObjectModel.cpp (original) +++ vmkit/trunk/mmtk/mmtk-j3/ObjectModel.cpp Sat Feb 13 13:00:01 2010 @@ -21,16 +21,16 @@ } extern "C" uintptr_t Java_org_j3_mmtk_ObjectModel_readAvailableBitsWord__Lorg_vmmagic_unboxed_ObjectReference_2 (JavaObject* OM, JavaObject* obj) { - return ((uintptr_t*)obj)[1] & mvm::GCMask; + return ((uintptr_t*)obj)[1] & mvm::GCBitMask; } extern "C" void Java_org_j3_mmtk_ObjectModel_writeAvailableBitsWord__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Word_2 (JavaObject* OM, JavaObject* obj, uintptr_t val) { assert((val & ~mvm::GCMask) == (((uintptr_t*)obj)[1] & ~mvm::GCMask) && "GC bits do not fit"); #if defined(__PPC__) - ((uint8_t*)obj)[7] &= ~mvm::GCMask; + ((uint8_t*)obj)[7] &= ~mvm::GCBitMask; ((uint8_t*)obj)[7] |= val; #else - ((uint8_t*)obj)[4] &= ~mvm::GCMask; + ((uint8_t*)obj)[4] &= ~mvm::GCBitMask; ((uint8_t*)obj)[4] |= val; #endif } @@ -45,19 +45,19 @@ extern "C" uint8_t Java_org_j3_mmtk_ObjectModel_readAvailableByte__Lorg_vmmagic_unboxed_ObjectReference_2 (JavaObject* OM, JavaObject* obj) { #if defined(__PPC__) - return ((uint8_t*)obj)[7] & mvm::GCMask; + return ((uint8_t*)obj)[7] & mvm::GCBitMask; #else - return ((uint8_t*)obj)[4] & mvm::GCMask; + return ((uint8_t*)obj)[4] & mvm::GCBitMask; #endif } extern "C" void Java_org_j3_mmtk_ObjectModel_writeAvailableByte__Lorg_vmmagic_unboxed_ObjectReference_2B (JavaObject* OM, JavaObject* obj, uint8_t val) { assert((val & mvm::GCMask) == val && "GC bits do not fit"); #if defined(__PPC__) - ((uint8_t*)obj)[7] &= ~mvm::GCMask; + ((uint8_t*)obj)[7] &= ~mvm::GCBitMask; ((uint8_t*)obj)[7] |= val; #else - ((uint8_t*)obj)[4] &= ~mvm::GCMask; + ((uint8_t*)obj)[4] &= ~mvm::GCBitMask; ((uint8_t*)obj)[4] |= val; #endif } @@ -74,7 +74,7 @@ Java_org_j3_mmtk_ObjectModel_attemptAvailableBits__Lorg_vmmagic_unboxed_ObjectReference_2Lorg_vmmagic_unboxed_Word_2Lorg_vmmagic_unboxed_Word_2( JavaObject* OM, JavaObject* obj, intptr_t oldValue, intptr_t newValue) { - assert(((oldValue & ~mvm::GCMask) == (newValue & ~mvm::GCMask)) && + assert(((oldValue & ~mvm::GCBitMask) == (newValue & ~mvm::GCBitMask)) && "GC bits do not fit"); return __sync_bool_compare_and_swap(((intptr_t*)obj) + 1, oldValue, newValue); } From nicolas.geoffray at lip6.fr Sat Feb 13 13:48:31 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 13 Feb 2010 21:48:31 -0000 Subject: [vmkit-commits] [vmkit] r96122 - in /vmkit/trunk: include/j3/JnjvmModuleProvider.h include/j3/LLVMMaterializer.h lib/J3/Compiler/JITInfo.cpp lib/J3/Compiler/JavaJIT.cpp lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/JnjvmModule.cpp lib/J3/Compiler/JnjvmModuleProvider.cpp lib/J3/Compiler/LLVMMaterializer.cpp tools/j3/Main.cpp tools/vmjc/vmjc.cpp tools/vmkit/Launcher.cpp Message-ID: <201002132148.o1DLmWex016609@zion.cs.uiuc.edu> Author: geoffray Date: Sat Feb 13 15:48:31 2010 New Revision: 96122 URL: http://llvm.org/viewvc/llvm-project?rev=96122&view=rev Log: Rename JnjvmModuleProvider into LLVMMaterializer. Added: vmkit/trunk/include/j3/LLVMMaterializer.h - copied, changed from r96100, vmkit/trunk/include/j3/JnjvmModuleProvider.h vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp - copied, changed from r96100, vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp Removed: vmkit/trunk/include/j3/JnjvmModuleProvider.h vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp Modified: vmkit/trunk/lib/J3/Compiler/JITInfo.cpp vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp vmkit/trunk/tools/j3/Main.cpp vmkit/trunk/tools/vmjc/vmjc.cpp vmkit/trunk/tools/vmkit/Launcher.cpp Removed: vmkit/trunk/include/j3/JnjvmModuleProvider.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModuleProvider.h?rev=96121&view=auto ============================================================================== --- vmkit/trunk/include/j3/JnjvmModuleProvider.h (original) +++ vmkit/trunk/include/j3/JnjvmModuleProvider.h (removed) @@ -1,38 +0,0 @@ -//===-------- JnjvmModuleProvider.h - LLVM Module Provider for J3 ---------===// -// -// The VMKit project -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef JNJVM_MODULE_PROVIDER_H -#define JNJVM_MODULE_PROVIDER_H - -#include - -namespace j3 { - -class JavaJITCompiler; - -class JnjvmModuleProvider : public llvm::GVMaterializer { -public: - - JavaJITCompiler* Comp; - llvm::Module* TheModule; - - JnjvmModuleProvider(llvm::Module* M, JavaJITCompiler* C); - ~JnjvmModuleProvider(); - - virtual bool Materialize(llvm::GlobalValue *GV, std::string *ErrInfo = 0); - virtual bool isMaterializable(const llvm::GlobalValue*) const; - virtual bool isDematerializable(const llvm::GlobalValue*) const { - return false; - } - virtual bool MaterializeModule(llvm::Module*, std::string*) { return true; } -}; - -} // End j3 namespace - -#endif Copied: vmkit/trunk/include/j3/LLVMMaterializer.h (from r96100, vmkit/trunk/include/j3/JnjvmModuleProvider.h) URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMMaterializer.h?p2=vmkit/trunk/include/j3/LLVMMaterializer.h&p1=vmkit/trunk/include/j3/JnjvmModuleProvider.h&r1=96100&r2=96122&rev=96122&view=diff ============================================================================== --- vmkit/trunk/include/j3/JnjvmModuleProvider.h (original) +++ vmkit/trunk/include/j3/LLVMMaterializer.h Sat Feb 13 15:48:31 2010 @@ -1,4 +1,4 @@ -//===-------- JnjvmModuleProvider.h - LLVM Module Provider for J3 ---------===// +//===---------- LLVMMaterializer.h - LLVM Materializer for J3 -------------===// // // The VMKit project // @@ -16,14 +16,13 @@ class JavaJITCompiler; -class JnjvmModuleProvider : public llvm::GVMaterializer { +class LLVMMaterializer : public llvm::GVMaterializer { public: JavaJITCompiler* Comp; llvm::Module* TheModule; - JnjvmModuleProvider(llvm::Module* M, JavaJITCompiler* C); - ~JnjvmModuleProvider(); + LLVMMaterializer(llvm::Module* M, JavaJITCompiler* C); virtual bool Materialize(llvm::GlobalValue *GV, std::string *ErrInfo = 0); virtual bool isMaterializable(const llvm::GlobalValue*) const; Modified: vmkit/trunk/lib/J3/Compiler/JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JITInfo.cpp?rev=96122&r1=96121&r2=96122&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JITInfo.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JITInfo.cpp Sat Feb 13 15:48:31 2010 @@ -29,7 +29,6 @@ #include "Reader.h" #include "j3/JnjvmModule.h" -#include "j3/JnjvmModuleProvider.h" #include Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=96122&r1=96121&r2=96122&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sat Feb 13 15:48:31 2010 @@ -38,7 +38,6 @@ #include "Reader.h" #include "j3/JnjvmModule.h" -#include "j3/JnjvmModuleProvider.h" using namespace j3; using namespace llvm; Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96122&r1=96121&r2=96122&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sat Feb 13 15:48:31 2010 @@ -31,7 +31,7 @@ #include "Jnjvm.h" #include "j3/JnjvmModule.h" -#include "j3/JnjvmModuleProvider.h" +#include "j3/LLVMMaterializer.h" using namespace j3; using namespace llvm; @@ -210,7 +210,12 @@ #else EmitFunctionName = false; #endif - TheModuleProvider = new JnjvmModuleProvider(TheModule, this); + TheModuleProvider = new LLVMMaterializer(TheModule, this); + + JnjvmModule::protectEngine.lock(); + JnjvmModule::executionEngine->addModule(TheModule); + JnjvmModule::protectEngine.unlock(); + addJavaPasses(); if (!JITListener) { Modified: vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp?rev=96122&r1=96121&r2=96122&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp Sat Feb 13 15:48:31 2010 @@ -25,7 +25,7 @@ #include "JavaTypes.h" #include "j3/JnjvmModule.h" -#include "j3/JnjvmModuleProvider.h" +#include "j3/LLVMMaterializer.h" using namespace j3; using namespace llvm; Removed: vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp?rev=96121&view=auto ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp (removed) @@ -1,164 +0,0 @@ -//===--- JnjvmModuleProvider.cpp - LLVM Module Provider for Jnjvm ---------===// -// -// The VMKit project -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/Constants.h" -#include "llvm/Module.h" -#include "llvm/ExecutionEngine/ExecutionEngine.h" - -#include "mvm/JIT.h" - -#include "JavaAccess.h" -#include "JavaClass.h" -#include "JavaConstantPool.h" -#include "JavaThread.h" -#include "JavaTypes.h" -#include "Jnjvm.h" - -#include "j3/JnjvmModule.h" -#include "j3/JnjvmModuleProvider.h" - -using namespace llvm; -using namespace j3; - - -static JavaMethod* staticLookup(CallbackInfo& F) { - Class* caller = F.cl; - uint16 index = F.index; - bool isStatic = F.stat; - JavaConstantPool* ctpInfo = caller->getConstantPool(); - - CommonClass* cl = 0; - const UTF8* utf8 = 0; - Signdef* sign = 0; - - ctpInfo->resolveMethod(index, cl, utf8, sign); - UserClass* lookup = cl->isArray() ? cl->super : cl->asClass(); - JavaMethod* meth = lookup->lookupMethod(utf8, sign->keyName, isStatic, true, - 0); - - assert(lookup->isInitializing() && "Class not ready"); - - return meth; -} - - -Value* JavaJITCompiler::addCallback(Class* cl, uint16 index, - Signdef* sign, bool stat) { - - Function* F = 0; - LLVMSignatureInfo* LSI = getSignatureInfo(sign); - - const UTF8* name = cl->name; - char* key = (char*)alloca(name->size + 16); - for (sint32 i = 0; i < name->size; ++i) - key[i] = name->elements[i]; - sprintf(key + name->size, "%d", index); - F = TheModule->getFunction(key); - if (F) return F; - - const FunctionType* type = stat ? LSI->getStaticType() : - LSI->getVirtualType(); - - F = Function::Create(type, GlobalValue::ExternalWeakLinkage, key, TheModule); - - CallbackInfo A(cl, index, stat); - callbacks.insert(std::make_pair(F, A)); - - return F; -} - - -bool JnjvmModuleProvider::Materialize(GlobalValue *GV, - std::string *ErrInfo) { - - Function* F = dyn_cast(GV); - assert(F && "Not a function"); - if (F->getLinkage() == GlobalValue::ExternalLinkage) return false; - - // 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)) { - mvm::MvmModule::unprotectIR(); - // Reacquire and go back to the JIT function. - mvm::MvmModule::executionEngine->lock.acquire(); - return false; - } - - JavaMethod* meth = Comp->getJavaMethod(F); - - if (!meth) { - // It's a callback - JavaJITCompiler::callback_iterator I = Comp->callbacks.find(F); - assert(I != Comp->callbacks.end() && "No callbacks found"); - meth = staticLookup(I->second); - } - - void* val = meth->compiledPtr(); - - if (isVirtual(meth->access)) { - LLVMMethodInfo* LMI = JavaLLVMCompiler::getMethodInfo(meth); - uint64_t offset = dyn_cast(LMI->getOffset())->getZExtValue(); - assert(meth->classDef->isResolved() && "Class not resolved"); -#if !defined(ISOLATE_SHARING) && !defined(SERVICE) - assert(meth->classDef->isInitializing() && "Class not ready"); -#endif - assert(meth->classDef->virtualVT && "Class has no VT"); - assert(meth->classDef->virtualTableSize > offset && - "The method's offset is greater than the virtual table size"); - ((void**)meth->classDef->virtualVT)[offset] = val; - } else { - 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; -} - -bool JnjvmModuleProvider::isMaterializable(const llvm::GlobalValue* GV) const { - return GV->getLinkage() == GlobalValue::ExternalWeakLinkage; -} - - -JnjvmModuleProvider::JnjvmModuleProvider(llvm::Module* m, - JavaJITCompiler* C) { - Comp = C; - TheModule = m; - m->setMaterializer(this); - JnjvmModule::protectEngine.lock(); - JnjvmModule::executionEngine->addModule(TheModule); - JnjvmModule::protectEngine.unlock(); -} - -JnjvmModuleProvider::~JnjvmModuleProvider() { - JnjvmModule::protectEngine.lock(); - JnjvmModule::executionEngine->removeModule(TheModule); - JnjvmModule::protectEngine.unlock(); -} Copied: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (from r96100, vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp) URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?p2=vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp&p1=vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp&r1=96100&r2=96122&rev=96122&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JnjvmModuleProvider.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Sat Feb 13 15:48:31 2010 @@ -1,4 +1,4 @@ -//===--- JnjvmModuleProvider.cpp - LLVM Module Provider for Jnjvm ---------===// +//===-------- LLVMMaterializer.cpp - LLVM Materializer for J3 -------------===// // // The VMKit project // @@ -21,7 +21,7 @@ #include "Jnjvm.h" #include "j3/JnjvmModule.h" -#include "j3/JnjvmModuleProvider.h" +#include "j3/LLVMMaterializer.h" using namespace llvm; using namespace j3; @@ -74,8 +74,7 @@ } -bool JnjvmModuleProvider::Materialize(GlobalValue *GV, - std::string *ErrInfo) { +bool LLVMMaterializer::Materialize(GlobalValue *GV, std::string *ErrInfo) { Function* F = dyn_cast(GV); assert(F && "Not a function"); @@ -142,23 +141,13 @@ return false; } -bool JnjvmModuleProvider::isMaterializable(const llvm::GlobalValue* GV) const { +bool LLVMMaterializer::isMaterializable(const llvm::GlobalValue* GV) const { return GV->getLinkage() == GlobalValue::ExternalWeakLinkage; } -JnjvmModuleProvider::JnjvmModuleProvider(llvm::Module* m, - JavaJITCompiler* C) { +LLVMMaterializer::LLVMMaterializer(llvm::Module* m, JavaJITCompiler* C) { Comp = C; TheModule = m; m->setMaterializer(this); - JnjvmModule::protectEngine.lock(); - JnjvmModule::executionEngine->addModule(TheModule); - JnjvmModule::protectEngine.unlock(); -} - -JnjvmModuleProvider::~JnjvmModuleProvider() { - JnjvmModule::protectEngine.lock(); - JnjvmModule::executionEngine->removeModule(TheModule); - JnjvmModule::protectEngine.unlock(); } Modified: vmkit/trunk/tools/j3/Main.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/j3/Main.cpp?rev=96122&r1=96121&r2=96122&view=diff ============================================================================== --- vmkit/trunk/tools/j3/Main.cpp (original) +++ vmkit/trunk/tools/j3/Main.cpp Sat Feb 13 15:48:31 2010 @@ -14,7 +14,6 @@ #include "mvm/Threads/Thread.h" #include "j3/JnjvmModule.h" -#include "j3/JnjvmModuleProvider.h" #include "llvm/Support/ManagedStatic.h" Modified: vmkit/trunk/tools/vmjc/vmjc.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=96122&r1=96121&r2=96122&view=diff ============================================================================== --- vmkit/trunk/tools/vmjc/vmjc.cpp (original) +++ vmkit/trunk/tools/vmjc/vmjc.cpp Sat Feb 13 15:48:31 2010 @@ -43,7 +43,6 @@ #include "mvm/Threads/Thread.h" #include "j3/JnjvmModule.h" -#include "j3/JnjvmModuleProvider.h" #include "../../lib/J3/VMCore/JnjvmClassLoader.h" #include "../../lib/J3/VMCore/Jnjvm.h" Modified: vmkit/trunk/tools/vmkit/Launcher.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=96122&r1=96121&r2=96122&view=diff ============================================================================== --- vmkit/trunk/tools/vmkit/Launcher.cpp (original) +++ vmkit/trunk/tools/vmkit/Launcher.cpp Sat Feb 13 15:48:31 2010 @@ -26,7 +26,6 @@ #include "mvm/Threads/Thread.h" #include "j3/JnjvmModule.h" -#include "j3/JnjvmModuleProvider.h" #include "CommandLine.h" From nicolas.geoffray at lip6.fr Sat Feb 13 15:09:12 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 13 Feb 2010 23:09:12 -0000 Subject: [vmkit-commits] [vmkit] r96132 - in /vmkit/trunk: include/j3/JnjvmModule.h lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/JavaJIT.cpp lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/VMCore/JavaClass.h Message-ID: <201002132309.o1DN9CHo020717@zion.cs.uiuc.edu> Author: geoffray Date: Sat Feb 13 17:09:12 2010 New Revision: 96132 URL: http://llvm.org/viewvc/llvm-project?rev=96132&view=rev Log: New Interface for creating stubs. No functionality changes. Modified: vmkit/trunk/include/j3/JnjvmModule.h vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/VMCore/JavaClass.h Modified: vmkit/trunk/include/j3/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=96132&r1=96131&r2=96132&view=diff ============================================================================== --- vmkit/trunk/include/j3/JnjvmModule.h (original) +++ vmkit/trunk/include/j3/JnjvmModule.h Sat Feb 13 17:09:12 2010 @@ -472,6 +472,10 @@ llvm::FunctionPassManager* JavaFunctionPasses; llvm::FunctionPassManager* JavaNativeFunctionPasses; + virtual bool needsCallback(JavaMethod* meth, bool* needsInit) { + *needsInit = true; + return meth == NULL; + } virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, bool stat) = 0; @@ -577,6 +581,7 @@ virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, bool stat); + virtual uintptr_t getPointerOrStub(JavaMethod& meth, int type); #ifdef WITH_LLVM_GCC virtual mvm::StackScanner* createStackScanner() { Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=96132&r1=96131&r2=96132&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sat Feb 13 17:09:12 2010 @@ -1829,7 +1829,7 @@ } Value* JavaAOTCompiler::addCallback(Class* cl, uint16 index, - Signdef* sign, bool stat) { + Signdef* sign, bool stat) { JavaConstantPool* ctpInfo = cl->ctpInfo; Signdef* signature = 0; Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=96132&r1=96131&r2=96132&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sat Feb 13 17:09:12 2010 @@ -1604,7 +1604,6 @@ std::vector args; FunctionType::param_iterator it = virtualType->param_end(); makeArgs(it, index, args, signature->nbArguments + 1); - Value* func = 0; if (finalCl) { Class* lookup = finalCl->isArray() ? finalCl->super : finalCl->asClass(); @@ -1648,22 +1647,25 @@ args.push_back(node); #endif - if (!meth) { - // Make sure the class is loaded before materializing the method. - uint32 clIndex = ctpInfo->getClassIndexFromMethod(index); - UserCommonClass* cl = 0; - Value* Cl = getResolvedCommonClass(clIndex, false, &cl); - if (!cl) { - CallInst::Create(module->ForceLoadedCheckFunction, Cl, "", currentBlock); - } - func = TheCompiler->addCallback(compilingClass, index, signature, false); - } else { - func = TheCompiler->getMethod(meth); - } - if (meth && canBeInlined(meth)) { val = invokeInline(meth, args); } else { + Value* func = 0; + bool needsInit = false; + if (TheCompiler->needsCallback(meth, &needsInit)) { + if (needsInit) { + // Make sure the class is loaded before materializing the method. + uint32 clIndex = ctpInfo->getClassIndexFromMethod(index); + UserCommonClass* cl = 0; + Value* Cl = getResolvedCommonClass(clIndex, false, &cl); + if (!cl) { + CallInst::Create(module->ForceLoadedCheckFunction, Cl, "",currentBlock); + } + } + func = TheCompiler->addCallback(compilingClass, index, signature, false); + } else { + func = TheCompiler->getMethod(meth); + } val = invoke(func, args, "", currentBlock); } @@ -1727,24 +1729,23 @@ currentBlock); } - Value* func = 0; - if (meth) { - /*if (meth == upcalls->SystemArraycopy || - meth == upcalls->VMSystemArraycopy) { - lowerArraycopy(args); - return; - }*/ - func = TheCompiler->getMethod(meth); - } else { - func = TheCompiler->addCallback(compilingClass, index, signature, true); - } - if (meth && canBeInlined(meth)) { val = invokeInline(meth, args); } else { + Value* func = 0; + bool needsInit = false; + if (TheCompiler->needsCallback(meth, &needsInit)) { + func = TheCompiler->addCallback(compilingClass, index, signature, true); + } else { + /*if (meth == upcalls->SystemArraycopy || + meth == upcalls->VMSystemArraycopy) { + lowerArraycopy(args); + return; + }*/ + func = TheCompiler->getMethod(meth); + } val = invoke(func, args, "", currentBlock); } - } const llvm::Type* retType = staticType->getReturnType(); Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96132&r1=96131&r2=96132&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sat Feb 13 17:09:12 2010 @@ -253,11 +253,8 @@ // Fill the virtual table with function pointers. - ExecutionEngine* EE = mvm::MvmModule::executionEngine; for (uint32 i = 0; i < cl->nbVirtualMethods; ++i) { JavaMethod& meth = cl->virtualMethods[i]; - LLVMMethodInfo* LMI = getMethodInfo(&meth); - Function* func = LMI->getMethod(); // Special handling for finalize method. Don't put a finalizer // if there is none, or if it is empty. @@ -265,11 +262,11 @@ if (!cl->super) { meth.canBeInlined = true; } else { - VT->destructor = (uintptr_t)EE->getPointerToFunctionOrStub(func); + VT->destructor = getPointerOrStub(meth, JavaMethod::Virtual); } } else { - VT->getFunctions()[meth.offset] = - (uintptr_t)EE->getPointerToFunctionOrStub(func); + VT->getFunctions()[meth.offset] = getPointerOrStub(meth, + JavaMethod::Virtual); } } @@ -286,8 +283,6 @@ std::set contents[InterfaceMethodTable::NumIndexes]; cl->fillIMT(contents); - ExecutionEngine* EE = mvm::MvmModule::executionEngine; - for (uint32_t i = 0; i < InterfaceMethodTable::NumIndexes; ++i) { std::set& atIndex = contents[i]; uint32_t size = atIndex.size(); @@ -297,10 +292,7 @@ Imeth->type, false, true, 0); if (meth) { - LLVMMethodInfo* LMI = getMethodInfo(meth); - Function* func = LMI->getMethod(); - uintptr_t res = (uintptr_t)EE->getPointerToFunctionOrStub(func); - IMT->contents[i] = res; + IMT->contents[i] = getPointerOrStub(*meth, JavaMethod::Interface); } else { IMT->contents[i] = (uintptr_t)ThrowUnfoundInterface; } @@ -323,10 +315,8 @@ if (SameMethod) { if (methods[0]) { - LLVMMethodInfo* LMI = getMethodInfo(methods[0]); - Function* func = LMI->getMethod(); - uintptr_t res = (uintptr_t)EE->getPointerToFunctionOrStub(func); - IMT->contents[i] = res; + IMT->contents[i] = getPointerOrStub(*(methods[0]), + JavaMethod::Interface); } else { IMT->contents[i] = (uintptr_t)ThrowUnfoundInterface; } @@ -348,10 +338,7 @@ table[j] = (uintptr_t)Imeth; if (Cmeth) { - LLVMMethodInfo* LMI = getMethodInfo(Cmeth); - Function* func = LMI->getMethod(); - uintptr_t res = (uintptr_t)EE->getPointerToFunctionOrStub(func); - table[j + 1] = res; + table[j + 1] = getPointerOrStub(*Cmeth, JavaMethod::Interface); } else { table[j + 1] = (uintptr_t)ThrowUnfoundInterface; } @@ -428,3 +415,10 @@ return JavaCompiler::loadMethod(handle, symbol); } +uintptr_t JavaJITCompiler::getPointerOrStub(JavaMethod& meth, + int side) { + ExecutionEngine* EE = mvm::MvmModule::executionEngine; + LLVMMethodInfo* LMI = getMethodInfo(&meth); + Function* func = LMI->getMethod(); + return (uintptr_t)EE->getPointerToFunctionOrStub(func); +} Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.h?rev=96132&r1=96131&r2=96132&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.h Sat Feb 13 17:09:12 2010 @@ -1011,6 +1011,13 @@ public: + enum Type { + Static, + Special, + Interface, + Virtual + }; + /// constructMethod - Create a new method. /// void initialise(Class* cl, const UTF8* name, const UTF8* type, uint16 access); From nicolas.geoffray at lip6.fr Sat Feb 13 17:06:48 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 01:06:48 -0000 Subject: [vmkit-commits] [vmkit] r96142 - in /vmkit/trunk: include/j3/ lib/J3/Compiler/ lib/J3/LLVMRuntime/ lib/J3/VMCore/ lib/Mvm/Compiler/ Message-ID: <201002140106.o1E16mOw026274@zion.cs.uiuc.edu> Author: geoffray Date: Sat Feb 13 19:06:47 2010 New Revision: 96142 URL: http://llvm.org/viewvc/llvm-project?rev=96142&view=rev Log: Add a new framework for creating stubs, that does not depend on LLVM stub and callback system. Modified: vmkit/trunk/include/j3/JavaCompiler.h vmkit/trunk/include/j3/JnjvmModule.h vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc vmkit/trunk/lib/J3/Compiler/JITInfo.cpp vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp vmkit/trunk/lib/J3/Compiler/JavaJIT.h vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll vmkit/trunk/lib/J3/VMCore/JavaClass.cpp vmkit/trunk/lib/J3/VMCore/JavaClass.h vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/J3/VMCore/JavaTypes.cpp vmkit/trunk/lib/J3/VMCore/JavaTypes.h vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Modified: vmkit/trunk/include/j3/JavaCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaCompiler.h?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/include/j3/JavaCompiler.h (original) +++ vmkit/trunk/include/j3/JavaCompiler.h Sat Feb 13 19:06:47 2010 @@ -84,6 +84,21 @@ abort(); } + virtual void virtualCallStub(Signdef* sign) { + fprintf(stderr, "Asking for a callback in an empty compiler"); + abort(); + } + + virtual void specialCallStub(Signdef* sign) { + fprintf(stderr, "Asking for a callback in an empty compiler"); + abort(); + } + + virtual void staticCallStub(Signdef* sign) { + fprintf(stderr, "Asking for a callback in an empty compiler"); + abort(); + } + virtual ~JavaCompiler() {} virtual mvm::StackScanner* createStackScanner() { Modified: vmkit/trunk/include/j3/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/include/j3/JnjvmModule.h (original) +++ vmkit/trunk/include/j3/JnjvmModule.h Sat Feb 13 19:06:47 2010 @@ -172,13 +172,17 @@ llvm::Function* staticBufFunction; llvm::Function* staticAPFunction; + llvm::Function* staticStubFunction; + llvm::Function* specialStubFunction; + llvm::Function* virtualStubFunction; + Signdef* signature; llvm::Function* createFunctionCallBuf(bool virt); llvm::Function* createFunctionCallAP(bool virt); + llvm::Function* createFunctionStub(bool special, bool virt); - public: const llvm::FunctionType* getVirtualType(); const llvm::FunctionType* getStaticType(); @@ -196,6 +200,10 @@ llvm::Function* getStaticBuf(); llvm::Function* getStaticAP(); + llvm::Function* getStaticStub(); + llvm::Function* getSpecialStub(); + llvm::Function* getVirtualStub(); + LLVMSignatureInfo(Signdef* sign) : staticType(0), virtualType(0), @@ -209,6 +217,9 @@ virtualAPFunction(0), staticBufFunction(0), staticAPFunction(0), + staticStubFunction(0), + specialStubFunction(0), + virtualStubFunction(0), signature(sign) {} }; @@ -268,6 +279,11 @@ llvm::Function* ForceLoadedCheckFunction; llvm::Function* ClassLookupFunction; llvm::Function* StringLookupFunction; + + llvm::Function* ResolveVirtualStubFunction; + llvm::Function* ResolveSpecialStubFunction; + llvm::Function* ResolveStaticStubFunction; + #ifndef WITHOUT_VTABLE llvm::Function* VirtualLookupFunction; #endif @@ -477,7 +493,7 @@ return meth == NULL; } virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat) = 0; + bool stat, llvm::BasicBlock* insert) = 0; virtual void staticCallBuf(Signdef* sign) { getSignatureInfo(sign)->getStaticBuf(); @@ -494,6 +510,18 @@ virtual void virtualCallAP(Signdef* sign) { getSignatureInfo(sign)->getVirtualAP(); } + + virtual void virtualCallStub(Signdef* sign) { + getSignatureInfo(sign)->getVirtualStub(); + } + + virtual void specialCallStub(Signdef* sign) { + getSignatureInfo(sign)->getSpecialStub(); + } + + virtual void staticCallStub(Signdef* sign) { + getSignatureInfo(sign)->getStaticStub(); + } llvm::Function* NativeLoader; @@ -580,7 +608,7 @@ virtual ~JavaJITCompiler() {} virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat); + bool stat, llvm::BasicBlock* insert); virtual uintptr_t getPointerOrStub(JavaMethod& meth, int type); #ifdef WITH_LLVM_GCC @@ -596,6 +624,21 @@ }; +class JavaJ3LazyJITCompiler : public JavaJITCompiler { +public: + virtual bool needsCallback(JavaMethod* meth, bool* needsInit); + virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, + bool stat, llvm::BasicBlock* insert); + virtual uintptr_t getPointerOrStub(JavaMethod& meth, int side); + + virtual JavaCompiler* Create(const std::string& ModuleID) { + return new JavaJ3LazyJITCompiler(ModuleID); + } + + JavaJ3LazyJITCompiler(const std::string& ModuleID) + : JavaJITCompiler(ModuleID) {} +}; + class JavaAOTCompiler : public JavaLLVMCompiler { public: @@ -619,7 +662,7 @@ } virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat); + bool stat, llvm::BasicBlock* insert); virtual void makeVT(Class* cl); virtual void makeIMT(Class* cl); Modified: vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc (original) +++ vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc Sat Feb 13 19:06:47 2010 @@ -5,10 +5,7 @@ Instruction* res = CallInst::Create(F, args.begin(), args.end(), Name, InsertAtEnd); - DILocation Location = - module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, - DIScope(DbgSubprogram)); - res->setMetadata("dbg", Location.getNode()); + res->setMetadata("dbg", CreateLocation()); if (TheCompiler->hasExceptionsEnabled()) { Value* threadId = getCurrentThread(module->JavaThreadType); @@ -66,10 +63,7 @@ BasicBlock *InsertAtEnd) { Instruction* res = CallInst::Create(F, arg1, Name, InsertAtEnd); - DILocation Location = - module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, - DIScope(DbgSubprogram)); - res->setMetadata("dbg", Location.getNode()); + res->setMetadata("dbg", CreateLocation()); if (TheCompiler->hasExceptionsEnabled()) { Value* threadId = getCurrentThread(module->JavaThreadType); @@ -121,10 +115,7 @@ Value* args[2] = { arg1, arg2 }; Instruction* res = CallInst::Create(F, args, args + 2, Name, InsertAtEnd); - DILocation Location = - module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, - DIScope(DbgSubprogram)); - res->setMetadata("dbg", Location.getNode()); + res->setMetadata("dbg", CreateLocation()); if (TheCompiler->hasExceptionsEnabled()) { Value* threadId = getCurrentThread(module->JavaThreadType); @@ -173,10 +164,7 @@ Instruction* JavaJIT::invoke(Value *F, const char* Name, BasicBlock *InsertAtEnd) { Instruction* res = llvm::CallInst::Create(F, Name, InsertAtEnd); - DILocation Location = - module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, - DIScope(DbgSubprogram)); - res->setMetadata("dbg", Location.getNode()); + res->setMetadata("dbg", CreateLocation()); if (TheCompiler->hasExceptionsEnabled()) { Value* threadId = getCurrentThread(module->JavaThreadType); @@ -224,10 +212,8 @@ void JavaJIT::throwException(llvm::Function* F, Value* arg1) { Instruction* obj = CallInst::Create(F, arg1, "", currentBlock); - DILocation Location = - module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, - DIScope(DbgSubprogram)); - obj->setMetadata("dbg", Location.getNode()); + obj->setMetadata("dbg", CreateLocation()); + if (currentExceptionBlock != endExceptionBlock) { Instruction* insn = currentExceptionBlock->begin(); PHINode* node = dyn_cast(insn); @@ -268,10 +254,8 @@ void JavaJIT::throwException(llvm::Function* F, Value** args, uint32 nbArgs) { Instruction* obj = CallInst::Create(F, args, args + nbArgs, "", currentBlock); - DILocation Location = - module->DebugFactory->CreateLocation(currentLineNumber, currentCtpIndex, - DIScope(DbgSubprogram)); - obj->setMetadata("dbg", Location.getNode()); + obj->setMetadata("dbg", CreateLocation()); + if (currentExceptionBlock != endExceptionBlock) { Instruction* insn = currentExceptionBlock->begin(); PHINode* node = dyn_cast(insn); Modified: vmkit/trunk/lib/J3/Compiler/JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JITInfo.cpp?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JITInfo.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JITInfo.cpp Sat Feb 13 19:06:47 2010 @@ -498,6 +498,87 @@ return res; } +Function* LLVMSignatureInfo::createFunctionStub(bool special, bool virt) { + + std::vector Args; + std::vector FunctionArgs; + + JavaLLVMCompiler* Mod = + (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); + JnjvmModule& Intrinsics = *Mod->getIntrinsics(); + std::string name; + if (Mod->isStaticCompiling()) { + name += UTF8Buffer(signature->keyName).cString(); + name += virt ? "virtual_stub" : special ? "special_stub" : "static_stub"; + } else { + name = ""; + } + + Function* stub = Function::Create((virt || special) ? getVirtualType() : + getStaticType(), + GlobalValue::InternalLinkage, name, + Mod->getLLVMModule()); + LLVMContext& context = Mod->getLLVMModule()->getContext(); + + BasicBlock* currentBlock = BasicBlock::Create(context, "enter", stub); + BasicBlock* endBlock = BasicBlock::Create(context, "end", stub); + BasicBlock* callBlock = BasicBlock::Create(context, "call", stub); + PHINode* node = NULL; + if (!signature->getReturnType()->isVoid()) { + node = PHINode::Create(stub->getReturnType(), "", endBlock); + } + + Function::arg_iterator arg = stub->arg_begin(); + Value *obj = NULL; + if (virt) { + obj = arg; + Args.push_back(obj); + } + + for (; arg != stub->arg_end() ; ++arg) { + FunctionArgs.push_back(arg); + if (Mod->useCooperativeGC()) { + if (arg->getType() == Intrinsics.JavaObjectType) { + Value* GCArgs[2] = { + new BitCastInst(arg, Intrinsics.ptrPtrType, "", currentBlock), + Intrinsics.constantPtrNull + }; + + CallInst::Create(Intrinsics.llvm_gc_gcroot, GCArgs, GCArgs + 2, "", + currentBlock); + } + } + } + + Value* val = CallInst::Create(virt ? Intrinsics.ResolveVirtualStubFunction : + special ? Intrinsics.ResolveSpecialStubFunction: + Intrinsics.ResolveStaticStubFunction, + Args.begin(), Args.end(), "", currentBlock); + + Constant* nullValue = Constant::getNullValue(val->getType()); + Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, + nullValue, val, ""); + BranchInst::Create(endBlock, callBlock, cmp, currentBlock); + if (node) node->addIncoming(Constant::getNullValue(node->getType()), + currentBlock); + + currentBlock = callBlock; + Value* Func = new BitCastInst(val, stub->getType(), "", currentBlock); + Value* res = CallInst::Create(Func, FunctionArgs.begin(), FunctionArgs.end(), + "", currentBlock); + if (node) node->addIncoming(res, currentBlock); + BranchInst::Create(endBlock, currentBlock); + + currentBlock = endBlock; + if (node) { + ReturnInst::Create(context, node, currentBlock); + } else { + ReturnInst::Create(context, currentBlock); + } + + return stub; +} + const PointerType* LLVMSignatureInfo::getStaticPtrType() { if (!staticPtrType) { staticPtrType = PointerType::getUnqual(getStaticType()); @@ -621,6 +702,57 @@ return staticAPFunction; } +Function* LLVMSignatureInfo::getStaticStub() { + // Lock here because we are called by arbitrary code. Also put that here + // because we are waiting on staticStubFunction to have an address. + mvm::MvmModule::protectIR(); + if (!staticStubFunction) { + staticStubFunction = createFunctionStub(false, false); + if (!signature->initialLoader->getCompiler()->isStaticCompiling()) { + signature->setStaticCallStub((intptr_t) + mvm::MvmModule::executionEngine->getPointerToGlobal(staticStubFunction)); + // Now that it's compiled, we don't need the IR anymore + staticStubFunction->deleteBody(); + } + } + mvm::MvmModule::unprotectIR(); + return staticStubFunction; +} + +Function* LLVMSignatureInfo::getSpecialStub() { + // Lock here because we are called by arbitrary code. Also put that here + // because we are waiting on specialStubFunction to have an address. + mvm::MvmModule::protectIR(); + if (!specialStubFunction) { + specialStubFunction = createFunctionStub(true, false); + if (!signature->initialLoader->getCompiler()->isStaticCompiling()) { + signature->setSpecialCallStub((intptr_t) + mvm::MvmModule::executionEngine->getPointerToGlobal(specialStubFunction)); + // Now that it's compiled, we don't need the IR anymore + specialStubFunction->deleteBody(); + } + } + mvm::MvmModule::unprotectIR(); + return specialStubFunction; +} + +Function* LLVMSignatureInfo::getVirtualStub() { + // Lock here because we are called by arbitrary code. Also put that here + // because we are waiting on virtualStubFunction to have an address. + mvm::MvmModule::protectIR(); + if (!virtualStubFunction) { + virtualStubFunction = createFunctionStub(false, true); + if (!signature->initialLoader->getCompiler()->isStaticCompiling()) { + signature->setVirtualCallStub((intptr_t) + mvm::MvmModule::executionEngine->getPointerToGlobal(virtualStubFunction)); + // Now that it's compiled, we don't need the IR anymore + virtualStubFunction->deleteBody(); + } + } + mvm::MvmModule::unprotectIR(); + return virtualStubFunction; +} + void LLVMAssessorInfo::initialise() { AssessorInfo[I_VOID].llvmType = Type::getVoidTy(getGlobalContext()); AssessorInfo[I_VOID].llvmTypePtr = 0; Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sat Feb 13 19:06:47 2010 @@ -1829,7 +1829,8 @@ } Value* JavaAOTCompiler::addCallback(Class* cl, uint16 index, - Signdef* sign, bool stat) { + Signdef* sign, bool stat, + BasicBlock* insert) { JavaConstantPool* ctpInfo = cl->ctpInfo; Signdef* signature = 0; Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sat Feb 13 19:06:47 2010 @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "mvm/JIT.h" @@ -161,21 +162,46 @@ Constant* Offset = LMI->getOffset(); indexes2[1] = Offset; #ifdef ISOLATE_SHARING - indexesCtp = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + indexesCtp = ConstantInt::get(Type::getInt32Ty(*llvmContext), Offset->getZExtValue() * -1); #endif } else { - - Value* val = getConstantPoolAt(index, module->VirtualLookupFunction, - Type::getInt32Ty(getGlobalContext()), args[0], true); - indexes2[1] = val; + + GlobalVariable* GV = new GlobalVariable(*llvmFunction->getParent(), + Type::getInt32Ty(*llvmContext), + false, + GlobalValue::ExternalLinkage, + module->constantZero, ""); + + BasicBlock* resolveVirtual = createBasicBlock("resolveVirtual"); + BasicBlock* endResolveVirtual = createBasicBlock("endResolveVirtual"); + PHINode* node = PHINode::Create(Type::getInt32Ty(*llvmContext), "", + endResolveVirtual); + + Value* load = new LoadInst(GV, "", false, currentBlock); + Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, load, + module->constantZero, ""); + BranchInst::Create(resolveVirtual, endResolveVirtual, test, currentBlock); + node->addIncoming(load, currentBlock); + currentBlock = resolveVirtual; + std::vector Args; + Args.push_back(TheCompiler->getNativeClass(compilingClass)); + Args.push_back(ConstantInt::get(Type::getInt32Ty(*llvmContext), index)); + Args.push_back(GV); + Args.push_back(args[0]); + load = invoke(module->VirtualLookupFunction, Args, "", currentBlock); + node->addIncoming(load, currentBlock); + BranchInst::Create(endResolveVirtual, currentBlock); + currentBlock = endResolveVirtual; + + indexes2[1] = node; #ifdef ISOLATE_SHARING Value* mul = BinaryOperator::CreateMul(val, module->constantMinusOne, "", currentBlock); indexesCtp = mul; #endif } - + Value* FuncPtr = GetElementPtrInst::Create(VT, indexes2, indexes2 + 2, "", currentBlock); @@ -1624,9 +1650,9 @@ #if defined(ISOLATE_SHARING) const Type* Ty = module->ConstantPoolType; Constant* Nil = Constant::getNullValue(Ty); - GlobalVariable* GV = new GlobalVariable(Ty, false, + GlobalVariable* GV = new GlobalVariable(*llvmFunction->getParent(),Ty, false, GlobalValue::ExternalLinkage, Nil, - "", module); + ""); Value* res = new LoadInst(GV, "", false, currentBlock); Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, res, Nil, ""); @@ -1659,10 +1685,12 @@ UserCommonClass* cl = 0; Value* Cl = getResolvedCommonClass(clIndex, false, &cl); if (!cl) { - CallInst::Create(module->ForceLoadedCheckFunction, Cl, "",currentBlock); + CallInst::Create(module->ForceLoadedCheckFunction, Cl, "", + currentBlock); } } - func = TheCompiler->addCallback(compilingClass, index, signature, false); + func = TheCompiler->addCallback(compilingClass, index, signature, false, + currentBlock); } else { func = TheCompiler->getMethod(meth); } @@ -1676,7 +1704,8 @@ push(val, false, signature->getReturnType()->findAssocClass(JCL)); } else { push(val, signature->getReturnType()->isUnsigned()); - if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) { + if (retType == Type::getDoubleTy(getGlobalContext()) || + retType == Type::getInt64Ty(getGlobalContext())) { push(module->constantZero, false); } } @@ -1735,7 +1764,8 @@ Value* func = 0; bool needsInit = false; if (TheCompiler->needsCallback(meth, &needsInit)) { - func = TheCompiler->addCallback(compilingClass, index, signature, true); + func = TheCompiler->addCallback(compilingClass, index, signature, + true, currentBlock); } else { /*if (meth == upcalls->SystemArraycopy || meth == upcalls->VMSystemArraycopy) { @@ -1755,7 +1785,8 @@ push(val, false, signature->getReturnType()->findAssocClass(JCL)); } else { push(val, signature->getReturnType()->isUnsigned()); - if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) { + if (retType == Type::getDoubleTy(getGlobalContext()) || + retType == Type::getInt64Ty(getGlobalContext())) { push(module->constantZero, false); } } @@ -2543,6 +2574,14 @@ currentBlock = label_return; } +MDNode* JavaJIT::CreateLocation() { + uint32_t first = currentLineNumber | (currentBytecodeIndex << 16); + uint32_t second = currentCtpIndex | (callNumber << 16); + DILocation Location = module->DebugFactory->CreateLocation( + first, second, DIScope(DbgSubprogram)); + callNumber++; + return Location.getNode(); +} #ifdef DWARF_EXCEPTIONS #include "ExceptionsDwarf.inc" Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Sat Feb 13 19:06:47 2010 @@ -83,7 +83,9 @@ endNode = 0; currentStackIndex = 0; currentLineNumber = 0; + currentBytecodeIndex = 0; currentCtpIndex = -1; + callNumber = 0; } /// javaCompile - Compile the Java method. @@ -147,10 +149,19 @@ llvm::MDNode* DbgSubprogram; /// currentLineIndex - The current line being processed. - uint32 currentLineNumber; + uint16 currentLineNumber; + + /// currentBytecodeIndex - The current bytecode being processed. + uint16 currentBytecodeIndex; /// currentCtpIndex - The constant pool index being processed. uint16 currentCtpIndex; + + /// callNumber - The number of a call for a single opcode. + uint16 callNumber; + + /// CreateLocation - Create debug information for a call. + llvm::MDNode* CreateLocation(); //===--------------------------- Inline support ---------------------------===// Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sat Feb 13 19:06:47 2010 @@ -28,6 +28,7 @@ #include "JavaClass.h" #include "JavaConstantPool.h" #include "JavaThread.h" +#include "JavaTypes.h" #include "Jnjvm.h" #include "j3/JnjvmModule.h" @@ -69,10 +70,13 @@ new(Alloc, "CodeLineInfo") CodeLineInfo[infoLength]; for (uint32 i = 0; i < infoLength; ++i) { DILocation DLT = Details.MF->getDILocation(Details.LineStarts[i].Loc); + uint32_t first = DLT.getLineNumber(); + uint32_t second = DLT.getColumnNumber(); currentCompiledMethod->codeInfo[i].address = Details.LineStarts[i].Address; - currentCompiledMethod->codeInfo[i].lineNumber = DLT.getLineNumber(); - currentCompiledMethod->codeInfo[i].ctpIndex = DLT.getColumnNumber(); + currentCompiledMethod->codeInfo[i].lineNumber = first & 0xFFFF; + currentCompiledMethod->codeInfo[i].bytecodeIndex = first >> 16; + currentCompiledMethod->codeInfo[i].ctpIndex = second & 0xFFFF; } } } @@ -422,3 +426,35 @@ Function* func = LMI->getMethod(); return (uintptr_t)EE->getPointerToFunctionOrStub(func); } + + +uintptr_t JavaJ3LazyJITCompiler::getPointerOrStub(JavaMethod& meth, + int side) { + return meth.getSignature()->getVirtualCallStub(); +} + +Value* JavaJ3LazyJITCompiler::addCallback(Class* cl, uint16 index, + Signdef* sign, bool stat, + llvm::BasicBlock* insert) { + LLVMSignatureInfo* LSI = getSignatureInfo(sign); + // Set the stub in the constant pool. + JavaConstantPool* ctpInfo = cl->ctpInfo; + intptr_t stub = stat ? sign->getStaticCallStub() : sign->getSpecialCallStub(); + __sync_val_compare_and_swap(&(ctpInfo->ctpRes[index]), NULL, stub); + // Load the constant pool. + Value* CTP = getConstantPool(ctpInfo); + Value* Index = ConstantInt::get(Type::getInt32Ty(insert->getContext()), + index); + Value* func = GetElementPtrInst::Create(CTP, Index, "", insert); + func = new LoadInst(func, "", false, insert); + // Bitcast it to the LLVM function. + func = new BitCastInst(func, stat ? LSI->getStaticPtrType() : + LSI->getVirtualPtrType(), + "", insert); + return func; +} + +bool JavaJ3LazyJITCompiler::needsCallback(JavaMethod* meth, bool* needsInit) { + *needsInit = true; + return (meth == NULL || meth->code == NULL); +} Modified: vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Sat Feb 13 19:06:47 2010 @@ -170,7 +170,11 @@ // Update the line number information. if (opinfo->lineNumber) currentLineNumber = opinfo->lineNumber; - + + currentCtpIndex = -1; + currentBytecodeIndex = i; + callNumber = 0; + // To prevent a gcj bug with useless goto if (currentBlock->getTerminator() != 0) { currentBlock = createBasicBlock("gcj bug"); Modified: vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp Sat Feb 13 19:06:47 2010 @@ -290,6 +290,10 @@ StartJNIFunction = module->getFunction("j3StartJNI"); EndJNIFunction = module->getFunction("j3EndJNI"); + ResolveVirtualStubFunction = module->getFunction("j3ResolveVirtualStub"); + ResolveStaticStubFunction = module->getFunction("j3ResolveStaticStub"); + ResolveSpecialStubFunction = module->getFunction("j3ResolveSpecialStub"); + NullPointerExceptionFunction = module->getFunction("j3NullPointerException"); ClassCastExceptionFunction = module->getFunction("j3ClassCastException"); @@ -427,9 +431,10 @@ void JavaJITMethodInfo::print(void* ip, void* addr) { void* new_ip = NULL; if (ip) new_ip = isStub(ip, addr); - fprintf(stderr, "; %p in %s.%s", new_ip, + uint16 line = meth->lookupLineNumber((uintptr_t)ip); + fprintf(stderr, "; %p in %s.%s (line %d)", new_ip, UTF8Buffer(meth->classDef->name).cString(), - UTF8Buffer(meth->name).cString()); + UTF8Buffer(meth->name).cString(), line); if (ip != new_ip) fprintf(stderr, " (from stub)"); fprintf(stderr, "\n"); } Modified: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Sat Feb 13 19:06:47 2010 @@ -49,7 +49,8 @@ Value* JavaJITCompiler::addCallback(Class* cl, uint16 index, - Signdef* sign, bool stat) { + Signdef* sign, bool stat, + BasicBlock* insert) { Function* F = 0; LLVMSignatureInfo* LSI = getSignatureInfo(sign); Modified: vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll (original) +++ vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll Sat Feb 13 19:06:47 2010 @@ -136,9 +136,8 @@ %JavaClass*, i32, ...) readnone ;;; j3VirtualTableLookup - Look up the offset in a virtual table of a -;;; specific function. This function takes a class and an index to lookup in the -;;; constant pool and returns and stores it in the constant pool cache. -declare i8* @j3VirtualTableLookup(%JavaClass*, i32, ...) +;;; specific function. +declare i32 @j3VirtualTableLookup(%JavaClass*, i32, i32*, %JavaObject*) ;;; j3ClassLookup - Look up a specific class. The function takes a class and ;;; an index to lookup in the constant pool and returns and stores it in the @@ -196,6 +195,10 @@ declare float @getFinalFloatField(float*) readnone declare %JavaObject* @getFinalObjectField(%JavaObject**) readnone +declare i8* @j3ResolveVirtualStub(%JavaObject*) +declare i8* @j3ResolveSpecialStub() +declare i8* @j3ResolveStaticStub() + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Exception methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Sat Feb 13 19:06:47 2010 @@ -1741,3 +1741,14 @@ if (codeInfoLength) return codeInfo[codeInfoLength - 1].lineNumber; return 0; } + +uint16 JavaMethod::lookupCtpIndex(uintptr_t ip) { + for(uint16 i = 0; i < codeInfoLength; ++i) { + if (codeInfo[i].address > ip) { + assert(i > 0 && "Wrong ip address for method"); + return codeInfo[i - 1].ctpIndex; + } + } + if (codeInfoLength) return codeInfo[codeInfoLength - 1].ctpIndex; + return 0; +} Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.h?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.h Sat Feb 13 19:06:47 2010 @@ -994,6 +994,7 @@ uintptr_t address; uint16 lineNumber; uint16 ctpIndex; + uint16 bytecodeIndex; // TODO: Use these fields when inlining. JavaMethod* executingMethod; // The code where the inlined method starts. @@ -1089,6 +1090,11 @@ /// pointer. /// uint16 lookupLineNumber(uintptr_t ip); + + /// lookupCtpIndex - Lookup the constant pool index pointed by the opcode + /// related to the given instruction pointer. + /// + uint16 lookupCtpIndex(uintptr_t ip); /// getSignature - Get the signature of thes method, resolving it if /// necessary. Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Sat Feb 13 19:06:47 2010 @@ -140,9 +140,10 @@ #ifndef WITHOUT_VTABLE // Throws if the method is not found. -extern "C" void* j3VirtualTableLookup(UserClass* caller, uint32 index, ...) { - - void* res = 0; +extern "C" uint32 j3VirtualTableLookup(UserClass* caller, uint32 index, + uint32* offset, JavaObject* obj) { + llvm_gcroot(obj, 0); + uint32 res = 0; BEGIN_NATIVE_EXCEPTION(1) @@ -155,10 +156,6 @@ JavaMethod* dmeth = lookup->lookupMethodDontThrow(utf8, sign->keyName, false, true, 0); if (!dmeth) { - va_list ap; - va_start(ap, index); - JavaObject* obj = va_arg(ap, JavaObject*); - va_end(ap); assert((obj->getClass()->isClass() && obj->getClass()->asClass()->isInitializing()) && "Class not ready in a virtual lookup."); @@ -168,7 +165,7 @@ obj->getClass()->asClass(); dmeth = lookup->lookupMethod(utf8, sign->keyName, false, true, 0); } else { - caller->getConstantPool()->ctpRes[index] = (void*)dmeth->offset; + *offset = dmeth->offset; } #if !defined(ISOLATE_SHARING) && !defined(SERVICE) @@ -176,15 +173,10 @@ "Class not ready in a virtual lookup."); #endif - res = (void*)dmeth->offset; + res = dmeth->offset; END_NATIVE_EXCEPTION - // Since the function is marked readnone, LLVM may move it after the - // exception check. Therefore, we trick LLVM to check the return value of the - // function. - JavaObject* obj = JavaThread::get()->pendingException; - if (obj) return (void*)obj; return res; } #endif @@ -392,7 +384,8 @@ // Creates a Java object and then throws it. extern "C" JavaObject* j3NullPointerException() { - + JavaThread::get()->printBacktrace(); + abort(); JavaObject *exc = 0; JavaThread *th = JavaThread::get(); @@ -597,6 +590,146 @@ return (void*)str; } +extern "C" void* j3ResolveVirtualStub(JavaObject* obj) { + llvm_gcroot(obj, 0); + JavaThread *th = JavaThread::get(); + UserCommonClass* cl = obj->getClass(); + void* result = NULL; + + BEGIN_NATIVE_EXCEPTION(1) + + // Lookup the caller of this class. + mvm::StackWalker Walker(th); + ++Walker; + mvm::MethodInfo* MI = Walker.get(); + assert(MI->MethodType == 1 && "Wrong call to stub"); + JavaMethod* meth = (JavaMethod*)MI->getMetaInfo(); + void* ip = *Walker; + + // Lookup the method info in the constant pool of the caller. + uint16 ctpIndex = meth->lookupCtpIndex(reinterpret_cast(ip)); + assert(ctpIndex && "No constant pool index"); + JavaConstantPool* ctpInfo = meth->classDef->getConstantPool(); + CommonClass* ctpCl = 0; + const UTF8* utf8 = 0; + Signdef* sign = 0; + + ctpInfo->resolveMethod(ctpIndex, ctpCl, utf8, sign); + assert(cl->isAssignableFrom(ctpCl) && "Wrong call object"); + UserClass* lookup = cl->isArray() ? cl->super : cl->asClass(); + JavaMethod* Virt = lookup->lookupMethod(utf8, sign->keyName, false, true, 0); + + // Compile the found method. + result = Virt->compiledPtr(); + + // Update the virtual table. + assert(lookup->isResolved() && "Class not resolved"); +#if !defined(ISOLATE_SHARING) && !defined(SERVICE) + assert(lookup->isInitializing() && "Class not ready"); +#endif + assert(lookup->virtualVT && "Class has no VT"); + assert(lookup->virtualTableSize > Virt->offset && + "The method's offset is greater than the virtual table size"); + ((void**)obj->getVirtualTable())[Virt->offset] = result; + + if (ctpCl->isInterface()) { + InterfaceMethodTable* IMT = cl->virtualVT->IMT; + uint32_t index = InterfaceMethodTable::getIndex(Virt->name, Virt->type); + if ((IMT->contents[index] & 1) == 0) { + IMT->contents[index] = (uintptr_t)result; + } else { + + JavaMethod* Imeth = + ctpCl->asClass()->lookupInterfaceMethodDontThrow(utf8, sign->keyName); + assert(Imeth && "Method not in hierarchy?"); + uintptr_t* table = (uintptr_t*)(IMT->contents[index] & ~1); + uint32 i = 0; + while (table[i] != (uintptr_t)Imeth) { i += 2; } + table[i + 1] = (uintptr_t)result; + } + } + + END_NATIVE_EXCEPTION + + return result; +} + +extern "C" void* j3ResolveStaticStub() { + JavaThread *th = JavaThread::get(); + void* result = NULL; + + BEGIN_NATIVE_EXCEPTION(1) + + // Lookup the caller of this class. + mvm::StackWalker Walker(th); + ++Walker; + mvm::MethodInfo* MI = Walker.get(); + assert(MI->MethodType == 1 && "Wrong call to stub"); + JavaMethod* caller = (JavaMethod*)MI->getMetaInfo(); + void* ip = *Walker; + + // Lookup the method info in the constant pool of the caller. + uint16 ctpIndex = caller->lookupCtpIndex(reinterpret_cast(ip)); + assert(ctpIndex && "No constant pool index"); + JavaConstantPool* ctpInfo = caller->classDef->getConstantPool(); + CommonClass* cl = 0; + const UTF8* utf8 = 0; + Signdef* sign = 0; + + ctpInfo->resolveMethod(ctpIndex, cl, utf8, sign); + UserClass* lookup = cl->isArray() ? cl->super : cl->asClass(); + assert(lookup->isInitializing() && "Class not ready"); + JavaMethod* callee = lookup->lookupMethod(utf8, sign->keyName, true, true, 0); + + // Compile the found method. + result = callee->compiledPtr(); + + // Update the entry in the constant pool. + ctpInfo->ctpRes[ctpIndex] = result; + + END_NATIVE_EXCEPTION + + return result; +} + +extern "C" void* j3ResolveSpecialStub() { + JavaThread *th = JavaThread::get(); + void* result = NULL; + + BEGIN_NATIVE_EXCEPTION(1) + + // Lookup the caller of this class. + mvm::StackWalker Walker(th); + ++Walker; + mvm::MethodInfo* MI = Walker.get(); + assert(MI->MethodType == 1 && "Wrong call to stub"); + JavaMethod* caller = (JavaMethod*)MI->getMetaInfo(); + void* ip = *Walker; + + // Lookup the method info in the constant pool of the caller. + uint16 ctpIndex = caller->lookupCtpIndex(reinterpret_cast(ip)); + assert(ctpIndex && "No constant pool index"); + JavaConstantPool* ctpInfo = caller->classDef->getConstantPool(); + CommonClass* cl = 0; + const UTF8* utf8 = 0; + Signdef* sign = 0; + + ctpInfo->resolveMethod(ctpIndex, cl, utf8, sign); + UserClass* lookup = cl->isArray() ? cl->super : cl->asClass(); + assert(lookup->isInitializing() && "Class not ready"); + JavaMethod* callee = lookup->lookupMethod(utf8, sign->keyName, false, true,0); + + // Compile the found method. + result = callee->compiledPtr(); + + // Update the entry in the constant pool. + ctpInfo->ctpRes[ctpIndex] = result; + + END_NATIVE_EXCEPTION + + return result; +} + extern "C" void j3PrintMethodStart(JavaMethod* meth) { fprintf(stderr, "[%p] executing %s.%s\n", (void*)mvm::Thread::get(), UTF8Buffer(meth->classDef->name).cString(), Modified: vmkit/trunk/lib/J3/VMCore/JavaTypes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaTypes.cpp?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaTypes.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaTypes.cpp Sat Feb 13 19:06:47 2010 @@ -114,6 +114,50 @@ return _virtualCallAP; } +intptr_t Signdef::virtualCallStub() { + if (!_virtualCallAP) { + char* buf = (char*)alloca((keyName->size << 1) + 1 + 11); + nativeName(buf, "virtual_stub"); + bool unused = false; + intptr_t res = initialLoader->loadInLib(buf, unused); + if (res) { + _virtualCallStub = res; + } else { + initialLoader->getCompiler()->virtualCallStub(this); + } + } + return _virtualCallStub; +} + +intptr_t Signdef::specialCallStub() { + if (!_specialCallStub) { + char* buf = (char*)alloca((keyName->size << 1) + 1 + 11); + nativeName(buf, "special_stub"); + bool unused = false; + intptr_t res = initialLoader->loadInLib(buf, unused); + if (res) { + _specialCallStub = res; + } else { + initialLoader->getCompiler()->specialCallStub(this); + } + } + return _specialCallStub; +} + +intptr_t Signdef::staticCallStub() { + if (!_staticCallStub) { + char* buf = (char*)alloca((keyName->size << 1) + 1 + 11); + nativeName(buf, "static_stub"); + bool unused = false; + intptr_t res = initialLoader->loadInLib(buf, unused); + if (res) { + _staticCallStub = res; + } else { + initialLoader->getCompiler()->staticCallStub(this); + } + } + return _staticCallStub; +} void Signdef::nativeName(char* ptr, const char* ext) const { sint32 i = 0; Modified: vmkit/trunk/lib/J3/VMCore/JavaTypes.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaTypes.h?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaTypes.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaTypes.h Sat Feb 13 19:06:47 2010 @@ -291,6 +291,15 @@ intptr_t _virtualCallAP; intptr_t virtualCallAP(); + intptr_t _virtualCallStub; + intptr_t virtualCallStub(); + + intptr_t _specialCallStub; + intptr_t specialCallStub(); + + intptr_t _staticCallStub; + intptr_t staticCallStub(); + public: /// initialLoader - The loader that first loaded this signdef. @@ -347,6 +356,21 @@ return _virtualCallAP; } + intptr_t getVirtualCallStub() { + if (!_virtualCallStub) return virtualCallStub(); + return _virtualCallStub; + } + + intptr_t getSpecialCallStub() { + if (!_specialCallStub) return specialCallStub(); + return _specialCallStub; + } + + intptr_t getStaticCallStub() { + if (!_staticCallStub) return staticCallStub(); + return _staticCallStub; + } + void setStaticCallBuf(intptr_t code) { _staticCallBuf = code; } @@ -362,6 +386,18 @@ void setVirtualCallAP(intptr_t code) { _virtualCallAP = code; } + + void setVirtualCallStub(intptr_t code) { + _virtualCallStub = code; + } + + void setSpecialCallStub(intptr_t code) { + _specialCallStub = code; + } + + void setStaticCallStub(intptr_t code) { + _staticCallStub = code; + } //===----------------------------------------------------------------------===// // Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=96142&r1=96141&r2=96142&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sat Feb 13 19:06:47 2010 @@ -118,6 +118,11 @@ #else llvm::DwarfExceptionHandling = false; #endif + + // Disable branch fold for accurate line numbers. + char* commands[2] = { (char*)"vmkit", (char*)"-disable-branch-fold" }; + llvm::cl::ParseCommandLineOptions(2, commands); + if (!M) { globalModule = new Module("bootstrap module", getGlobalContext()); From nicolas.geoffray at lip6.fr Sun Feb 14 02:16:39 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 10:16:39 -0000 Subject: [vmkit-commits] [vmkit] r96163 - in /vmkit/trunk: include/j3/JnjvmModule.h include/j3/LLVMMaterializer.h lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/JnjvmModule.cpp lib/J3/Compiler/LLVMMaterializer.cpp lib/Mvm/Compiler/JIT.cpp tools/j3/Main.cpp tools/vmkit/Launcher.cpp Message-ID: <201002141016.o1EAGdm6000526@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 04:16:38 2010 New Revision: 96163 URL: http://llvm.org/viewvc/llvm-project?rev=96163&view=rev Log: Use J3 lazy compilation mechanism by default instead of LLVM's. Modified: vmkit/trunk/include/j3/JnjvmModule.h vmkit/trunk/include/j3/LLVMMaterializer.h vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp vmkit/trunk/lib/Mvm/Compiler/JIT.cpp vmkit/trunk/tools/j3/Main.cpp vmkit/trunk/tools/vmkit/Launcher.cpp Modified: vmkit/trunk/include/j3/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=96163&r1=96162&r2=96163&view=diff ============================================================================== --- vmkit/trunk/include/j3/JnjvmModule.h (original) +++ vmkit/trunk/include/j3/JnjvmModule.h Sun Feb 14 04:16:38 2010 @@ -397,7 +397,6 @@ protected: llvm::Module* TheModule; - llvm::GVMaterializer* TheModuleProvider; JnjvmModule JavaIntrinsics; void addJavaPasses(); @@ -578,10 +577,6 @@ virtual void makeVT(Class* cl); virtual void makeIMT(Class* cl); - virtual JavaCompiler* Create(const std::string& ModuleID) { - return new JavaJITCompiler(ModuleID); - } - virtual void* materializeFunction(JavaMethod* meth); virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl); @@ -604,12 +599,10 @@ #ifdef SERVICE virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where); #endif - - virtual ~JavaJITCompiler() {} - + virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat, llvm::BasicBlock* insert); - virtual uintptr_t getPointerOrStub(JavaMethod& meth, int type); + bool stat, llvm::BasicBlock* insert) = 0; + virtual uintptr_t getPointerOrStub(JavaMethod& meth, int type) = 0; #ifdef WITH_LLVM_GCC virtual mvm::StackScanner* createStackScanner() { @@ -621,6 +614,8 @@ #endif virtual void* loadMethod(void* handle, const char* symbol); + + static JavaJITCompiler* CreateCompiler(const std::string& ModuleID); }; @@ -635,8 +630,24 @@ return new JavaJ3LazyJITCompiler(ModuleID); } - JavaJ3LazyJITCompiler(const std::string& ModuleID) - : JavaJITCompiler(ModuleID) {} + JavaJ3LazyJITCompiler(const std::string& ModuleID); +}; + +class JavaLLVMLazyJITCompiler : public JavaJITCompiler { +public: + llvm::GVMaterializer* TheMaterializer; + + virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, + bool stat, llvm::BasicBlock* insert); + virtual uintptr_t getPointerOrStub(JavaMethod& meth, int side); + + virtual JavaCompiler* Create(const std::string& ModuleID) { + return new JavaLLVMLazyJITCompiler(ModuleID); + } + + JavaLLVMLazyJITCompiler(const std::string& ModuleID); + + virtual ~JavaLLVMLazyJITCompiler(); }; class JavaAOTCompiler : public JavaLLVMCompiler { Modified: vmkit/trunk/include/j3/LLVMMaterializer.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMMaterializer.h?rev=96163&r1=96162&r2=96163&view=diff ============================================================================== --- vmkit/trunk/include/j3/LLVMMaterializer.h (original) +++ vmkit/trunk/include/j3/LLVMMaterializer.h Sun Feb 14 04:16:38 2010 @@ -7,22 +7,22 @@ // //===----------------------------------------------------------------------===// -#ifndef JNJVM_MODULE_PROVIDER_H -#define JNJVM_MODULE_PROVIDER_H +#ifndef J3_LLVM_MATERIALIZER_H +#define J3_LLVM_MATERIALIZER_H #include namespace j3 { -class JavaJITCompiler; +class JavaLLVMLazyJITCompiler; class LLVMMaterializer : public llvm::GVMaterializer { public: - JavaJITCompiler* Comp; + JavaLLVMLazyJITCompiler* Comp; llvm::Module* TheModule; - LLVMMaterializer(llvm::Module* M, JavaJITCompiler* C); + LLVMMaterializer(llvm::Module* M, JavaLLVMLazyJITCompiler* C); virtual bool Materialize(llvm::GlobalValue *GV, std::string *ErrInfo = 0); virtual bool isMaterializable(const llvm::GlobalValue*) const; Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=96163&r1=96162&r2=96163&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sun Feb 14 04:16:38 2010 @@ -1926,7 +1926,7 @@ try { if (!M->clinits->empty()) { - Comp = new JavaJITCompiler("JIT"); + Comp = JavaJITCompiler::CreateCompiler("JIT"); Comp->EmitFunctionName = true; bootstrapLoader->setCompiler(Comp); bootstrapLoader->analyseClasspathEnv(vm->classpath); Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96163&r1=96162&r2=96163&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sun Feb 14 04:16:38 2010 @@ -18,6 +18,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/JITEventListener.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -214,7 +215,6 @@ #else EmitFunctionName = false; #endif - TheModuleProvider = new LLVMMaterializer(TheModule, this); JnjvmModule::protectEngine.lock(); JnjvmModule::executionEngine->addModule(TheModule); @@ -398,7 +398,7 @@ newArgv[0] = newArgv[1]; newArgv[1] = mainClass; - JavaJITCompiler* Comp = new JavaJITCompiler("JITModule"); + JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule"); mvm::MvmModule::AddStandardCompilePasses(); JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp); mvm::VirtualMachine* vm = mvm::VirtualMachine::createJVM(JCL); @@ -412,15 +412,15 @@ void* JavaJITCompiler::loadMethod(void* handle, const char* symbol) { Function* F = mvm::MvmModule::globalModule->getFunction(symbol); if (F) { - void* res = mvm::MvmModule::executionEngine->getPointerToFunctionOrStub(F); + void* res = mvm::MvmModule::executionEngine->getPointerToFunction(F); return res; } return JavaCompiler::loadMethod(handle, symbol); } -uintptr_t JavaJITCompiler::getPointerOrStub(JavaMethod& meth, - int side) { +uintptr_t JavaLLVMLazyJITCompiler::getPointerOrStub(JavaMethod& meth, + int side) { ExecutionEngine* EE = mvm::MvmModule::executionEngine; LLVMMethodInfo* LMI = getMethodInfo(&meth); Function* func = LMI->getMethod(); @@ -458,3 +458,27 @@ *needsInit = true; return (meth == NULL || meth->code == NULL); } + +JavaJ3LazyJITCompiler::JavaJ3LazyJITCompiler(const std::string& ModuleID) + : JavaJITCompiler(ModuleID) {} + +JavaLLVMLazyJITCompiler::JavaLLVMLazyJITCompiler(const std::string& ModuleID) + : JavaJITCompiler(ModuleID) { + TheMaterializer = new LLVMMaterializer(TheModule, this); +} + +JavaLLVMLazyJITCompiler::~JavaLLVMLazyJITCompiler() { + delete TheMaterializer; +} + +static llvm::cl::opt LLVMLazy("llvm-lazy", + cl::desc("Use LLVM lazy stubs"), + cl::init(false)); + +JavaJITCompiler* JavaJITCompiler::CreateCompiler(const std::string& ModuleID) { + if (LLVMLazy) { + JnjvmModule::executionEngine->DisableLazyCompilation(false); + return new JavaLLVMLazyJITCompiler(ModuleID); + } + return new JavaJ3LazyJITCompiler(ModuleID); +} Modified: vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp?rev=96163&r1=96162&r2=96163&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp Sun Feb 14 04:16:38 2010 @@ -398,7 +398,6 @@ JavaLLVMCompiler::~JavaLLVMCompiler() { delete JavaFunctionPasses; delete JavaNativeFunctionPasses; - delete TheModuleProvider; } namespace mvm { Modified: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?rev=96163&r1=96162&r2=96163&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Sun Feb 14 04:16:38 2010 @@ -48,9 +48,9 @@ } -Value* JavaJITCompiler::addCallback(Class* cl, uint16 index, - Signdef* sign, bool stat, - BasicBlock* insert) { +Value* JavaLLVMLazyJITCompiler::addCallback(Class* cl, uint16 index, + Signdef* sign, bool stat, + BasicBlock* insert) { Function* F = 0; LLVMSignatureInfo* LSI = getSignatureInfo(sign); @@ -147,7 +147,8 @@ } -LLVMMaterializer::LLVMMaterializer(llvm::Module* m, JavaJITCompiler* C) { +LLVMMaterializer::LLVMMaterializer( + llvm::Module* m, JavaLLVMLazyJITCompiler* C) { Comp = C; TheModule = m; m->setMaterializer(this); Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=96163&r1=96162&r2=96163&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sun Feb 14 04:16:38 2010 @@ -133,7 +133,6 @@ Allocator = new BumpPtrAllocator(); executionEngine->RegisterJITEventListener(&JITListener); - executionEngine->DisableLazyCompilation(false); std::string str = executionEngine->getTargetData()->getStringRepresentation(); globalModule->setDataLayout(str); Modified: vmkit/trunk/tools/j3/Main.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/j3/Main.cpp?rev=96163&r1=96162&r2=96163&view=diff ============================================================================== --- vmkit/trunk/tools/j3/Main.cpp (original) +++ vmkit/trunk/tools/j3/Main.cpp Sun Feb 14 04:16:38 2010 @@ -28,7 +28,7 @@ MvmModule::initialise(); Collector::initialise(); - JavaJITCompiler* Comp = new JavaJITCompiler("JITModule"); + JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule"); mvm::MvmModule::AddStandardCompilePasses(); JnjvmClassLoader* JCL = VirtualMachine::initialiseJVM(Comp); VirtualMachine* vm = VirtualMachine::createJVM(JCL); Modified: vmkit/trunk/tools/vmkit/Launcher.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=96163&r1=96162&r2=96163&view=diff ============================================================================== --- vmkit/trunk/tools/vmkit/Launcher.cpp (original) +++ vmkit/trunk/tools/vmkit/Launcher.cpp Sun Feb 14 04:16:38 2010 @@ -56,7 +56,6 @@ "potentially sacrificing code quality"), cl::init(false)); - static cl::opt DisableOptimizations("disable-opt", cl::desc("Do not run any optimization passes")); @@ -140,7 +139,7 @@ if (VMToRun == RunJava) { #if WITH_J3 - JavaJITCompiler* Comp = new JavaJITCompiler("JITModule"); + JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule"); JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp); addCommandLinePass(argv); mvm::VirtualMachine* vm = mvm::VirtualMachine::createJVM(JCL); @@ -157,7 +156,7 @@ } else { mvm::CommandLine MyCl; #if WITH_J3 - JavaJITCompiler* Comp = new JavaJITCompiler("JITModule"); + JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule"); JnjvmClassLoader* JCL = mvm::VirtualMachine::initialiseJVM(Comp); addCommandLinePass(argv); MyCl.vmlets["java"] = (create_vm_t)(mvm::VirtualMachine::createJVM); From nicolas.geoffray at lip6.fr Sun Feb 14 07:40:01 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 15:40:01 -0000 Subject: [vmkit-commits] [vmkit] r96166 - in /vmkit/trunk: include/j3/JavaAOTCompiler.h include/j3/JnjvmModule.h include/j3/LLVMMaterializer.h lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/LLVMMaterializer.cpp tools/vmjc/vmjc.cpp Message-ID: <201002141540.o1EFe12i010348@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 09:40:01 2010 New Revision: 96166 URL: http://llvm.org/viewvc/llvm-project?rev=96166&view=rev Log: Code refactoring. No functionality change. Added: vmkit/trunk/include/j3/JavaAOTCompiler.h Modified: vmkit/trunk/include/j3/JnjvmModule.h vmkit/trunk/include/j3/LLVMMaterializer.h vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp vmkit/trunk/tools/vmjc/vmjc.cpp Added: vmkit/trunk/include/j3/JavaAOTCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaAOTCompiler.h?rev=96166&view=auto ============================================================================== --- vmkit/trunk/include/j3/JavaAOTCompiler.h (added) +++ vmkit/trunk/include/j3/JavaAOTCompiler.h Sun Feb 14 09:40:01 2010 @@ -0,0 +1,186 @@ +//===------ JavaAOTCompiler.h - The J3 ahead of time compiler -------------===// +// +// The VMKit project +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef J3_AOT_COMPILER_H +#define J3_AOT_COMPILER_H + +#include "j3/JnjvmModule.h" + +namespace j3 { + +class JavaAOTCompiler : public JavaLLVMCompiler { + +public: + JavaAOTCompiler(const std::string &ModuleID); + + virtual bool isStaticCompiling() { + return true; + } + + virtual bool emitFunctionName() { + return true; + } + + virtual JavaCompiler* Create(const std::string& ModuleID) { + return new JavaAOTCompiler(ModuleID); + } + + virtual void* materializeFunction(JavaMethod* meth) { + fprintf(stderr, "Can not materiale a function in AOT mode."); + abort(); + } + + virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, + bool stat, llvm::BasicBlock* insert); + + virtual void makeVT(Class* cl); + virtual void makeIMT(Class* cl); + + llvm::Constant* HandleMagic(JavaObject* obj, CommonClass* cl); + virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl); + virtual JavaObject* getFinalObject(llvm::Value* C); + virtual llvm::Constant* getNativeClass(CommonClass* cl); + virtual llvm::Constant* getJavaClass(CommonClass* cl); + virtual llvm::Constant* getJavaClassPtr(CommonClass* cl); + virtual llvm::Constant* getStaticInstance(Class* cl); + virtual llvm::Constant* getVirtualTable(JavaVirtualTable*); + virtual llvm::Constant* getMethodInClass(JavaMethod* meth); + + virtual llvm::Constant* getString(JavaString* str); + virtual llvm::Constant* getStringPtr(JavaString** str); + virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp); + virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr); + + virtual void setMethod(JavaMethod* meth, void* ptr, const char* name); + + +#ifdef SERVICE + virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where); +#endif + + virtual ~JavaAOTCompiler() {} + + virtual void* loadMethod(void* handle, const char* symbol); + + virtual CommonClass* getUniqueBaseClass(CommonClass* cl); + +private: + + //--------------- Static compiler specific functions -----------------------// + llvm::Constant* CreateConstantFromVT(JavaVirtualTable* VT); + llvm::Constant* CreateConstantFromUTF8(const UTF8* val); + llvm::Constant* CreateConstantFromCommonClass(CommonClass* cl); + llvm::Constant* CreateConstantFromClass(Class* cl); + llvm::Constant* CreateConstantFromClassPrimitive(ClassPrimitive* cl); + llvm::Constant* CreateConstantFromClassArray(ClassArray* cl); + llvm::Constant* CreateConstantFromAttribut(Attribut& attribut); + llvm::Constant* CreateConstantFromJavaField(JavaField& field); + llvm::Constant* CreateConstantFromJavaMethod(JavaMethod& method); + llvm::Constant* CreateConstantFromStaticInstance(Class* cl); + llvm::Constant* CreateConstantFromJavaString(JavaString* str); + llvm::Constant* CreateConstantFromJavaClass(CommonClass* cl); + llvm::Constant* CreateConstantForBaseObject(CommonClass* cl); + llvm::Constant* CreateConstantFromJavaObject(JavaObject* obj); + llvm::Constant* getUTF8(const UTF8* val); + + template + llvm::Constant* CreateConstantFromIntArray(const T* val, const llvm::Type* Ty); + + template + llvm::Constant* CreateConstantFromFPArray(const T* val, const llvm::Type* Ty); + + llvm::Constant* CreateConstantFromObjectArray(const ArrayObject* val); + + std::map nativeClasses; + std::map arrayClasses; + std::map javaClasses; + std::map virtualTables; + std::map staticInstances; + std::map constantPools; + std::map strings; + std::map nativeFunctions; + std::map utf8s; + std::map virtualMethods; + std::map finalObjects; + std::map reverseFinalObjects; + + typedef std::map::iterator + final_object_iterator; + + typedef std::map::iterator + reverse_final_object_iterator; + + typedef std::map::iterator + method_iterator; + + typedef std::map::iterator + native_class_iterator; + + typedef std::map::iterator + array_class_iterator; + + typedef std::map::iterator + java_class_iterator; + + typedef std::map::iterator + virtual_table_iterator; + + typedef std::map::iterator + static_instance_iterator; + + typedef std::map::iterator + constant_pool_iterator; + + typedef std::map::iterator + string_iterator; + + typedef std::map::iterator + native_function_iterator; + + typedef std::map::iterator + utf8_iterator; + +#ifdef SERVICE + virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where); + std::map isolates; + typedef std::map::iterator + isolate_iterator; +#endif + + bool isCompiling(const CommonClass* cl) const; + +public: + llvm::Function* StaticInitializer; + llvm::Function* ObjectPrinter; + llvm::Function* Callback; + + bool generateStubs; + bool assumeCompiled; + bool compileRT; + + std::vector* clinits; + + + void CreateStaticInitializer(); + + static void setNoInline(Class* cl); + + void printStats(); + + void compileFile(Jnjvm* vm, const char* name); + void compileClass(Class* cl); + void generateMain(const char* name, bool jit); + +private: + void compileAllStubs(Signdef* sign); +}; + +} // end namespace j3 + +#endif Modified: vmkit/trunk/include/j3/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=96166&r1=96165&r2=96166&view=diff ============================================================================== --- vmkit/trunk/include/j3/JnjvmModule.h (original) +++ vmkit/trunk/include/j3/JnjvmModule.h Sun Feb 14 09:40:01 2010 @@ -526,16 +526,6 @@ }; -struct CallbackInfo { - Class* cl; - uint16 index; - bool stat; - - CallbackInfo(Class* c, uint32 i, bool s) : - cl(c), index(i), stat(s) {} - -}; - class JavaJITMethodInfo : public mvm::JITMethodInfo { protected: JavaMethod* meth; @@ -557,11 +547,6 @@ class JavaJITCompiler : public JavaLLVMCompiler { public: - std::map callbacks; - - typedef std::map::iterator callback_iterator; - - bool EmitFunctionName; JavaJITCompiler(const std::string &ModuleID); @@ -633,190 +618,6 @@ JavaJ3LazyJITCompiler(const std::string& ModuleID); }; -class JavaLLVMLazyJITCompiler : public JavaJITCompiler { -public: - llvm::GVMaterializer* TheMaterializer; - - virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat, llvm::BasicBlock* insert); - virtual uintptr_t getPointerOrStub(JavaMethod& meth, int side); - - virtual JavaCompiler* Create(const std::string& ModuleID) { - return new JavaLLVMLazyJITCompiler(ModuleID); - } - - JavaLLVMLazyJITCompiler(const std::string& ModuleID); - - virtual ~JavaLLVMLazyJITCompiler(); -}; - -class JavaAOTCompiler : public JavaLLVMCompiler { - -public: - JavaAOTCompiler(const std::string &ModuleID); - - virtual bool isStaticCompiling() { - return true; - } - - virtual bool emitFunctionName() { - return true; - } - - virtual JavaCompiler* Create(const std::string& ModuleID) { - return new JavaAOTCompiler(ModuleID); - } - - virtual void* materializeFunction(JavaMethod* meth) { - fprintf(stderr, "Can not materiale a function in AOT mode."); - abort(); - } - - virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat, llvm::BasicBlock* insert); - - virtual void makeVT(Class* cl); - virtual void makeIMT(Class* cl); - - llvm::Constant* HandleMagic(JavaObject* obj, CommonClass* cl); - virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl); - virtual JavaObject* getFinalObject(llvm::Value* C); - virtual llvm::Constant* getNativeClass(CommonClass* cl); - virtual llvm::Constant* getJavaClass(CommonClass* cl); - virtual llvm::Constant* getJavaClassPtr(CommonClass* cl); - virtual llvm::Constant* getStaticInstance(Class* cl); - virtual llvm::Constant* getVirtualTable(JavaVirtualTable*); - virtual llvm::Constant* getMethodInClass(JavaMethod* meth); - - virtual llvm::Constant* getString(JavaString* str); - virtual llvm::Constant* getStringPtr(JavaString** str); - virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp); - virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr); - - virtual void setMethod(JavaMethod* meth, void* ptr, const char* name); - - -#ifdef SERVICE - virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where); -#endif - - virtual ~JavaAOTCompiler() {} - - virtual void* loadMethod(void* handle, const char* symbol); - - virtual CommonClass* getUniqueBaseClass(CommonClass* cl); - -private: - - //--------------- Static compiler specific functions -----------------------// - llvm::Constant* CreateConstantFromVT(JavaVirtualTable* VT); - llvm::Constant* CreateConstantFromUTF8(const UTF8* val); - llvm::Constant* CreateConstantFromCommonClass(CommonClass* cl); - llvm::Constant* CreateConstantFromClass(Class* cl); - llvm::Constant* CreateConstantFromClassPrimitive(ClassPrimitive* cl); - llvm::Constant* CreateConstantFromClassArray(ClassArray* cl); - llvm::Constant* CreateConstantFromAttribut(Attribut& attribut); - llvm::Constant* CreateConstantFromJavaField(JavaField& field); - llvm::Constant* CreateConstantFromJavaMethod(JavaMethod& method); - llvm::Constant* CreateConstantFromStaticInstance(Class* cl); - llvm::Constant* CreateConstantFromJavaString(JavaString* str); - llvm::Constant* CreateConstantFromJavaClass(CommonClass* cl); - llvm::Constant* CreateConstantForBaseObject(CommonClass* cl); - llvm::Constant* CreateConstantFromJavaObject(JavaObject* obj); - llvm::Constant* getUTF8(const UTF8* val); - - template - llvm::Constant* CreateConstantFromIntArray(const T* val, const llvm::Type* Ty); - - template - llvm::Constant* CreateConstantFromFPArray(const T* val, const llvm::Type* Ty); - - llvm::Constant* CreateConstantFromObjectArray(const ArrayObject* val); - - std::map nativeClasses; - std::map arrayClasses; - std::map javaClasses; - std::map virtualTables; - std::map staticInstances; - std::map constantPools; - std::map strings; - std::map nativeFunctions; - std::map utf8s; - std::map virtualMethods; - std::map finalObjects; - std::map reverseFinalObjects; - - typedef std::map::iterator - final_object_iterator; - - typedef std::map::iterator - reverse_final_object_iterator; - - typedef std::map::iterator - method_iterator; - - typedef std::map::iterator - native_class_iterator; - - typedef std::map::iterator - array_class_iterator; - - typedef std::map::iterator - java_class_iterator; - - typedef std::map::iterator - virtual_table_iterator; - - typedef std::map::iterator - static_instance_iterator; - - typedef std::map::iterator - constant_pool_iterator; - - typedef std::map::iterator - string_iterator; - - typedef std::map::iterator - native_function_iterator; - - typedef std::map::iterator - utf8_iterator; - -#ifdef SERVICE - virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where); - std::map isolates; - typedef std::map::iterator - isolate_iterator; -#endif - - bool isCompiling(const CommonClass* cl) const; - -public: - llvm::Function* StaticInitializer; - llvm::Function* ObjectPrinter; - llvm::Function* Callback; - - bool generateStubs; - bool assumeCompiled; - bool compileRT; - - std::vector* clinits; - - - void CreateStaticInitializer(); - - static void setNoInline(Class* cl); - - void printStats(); - - void compileFile(Jnjvm* vm, const char* name); - void compileClass(Class* cl); - void generateMain(const char* name, bool jit); - -private: - void compileAllStubs(Signdef* sign); -}; - } #endif Modified: vmkit/trunk/include/j3/LLVMMaterializer.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMMaterializer.h?rev=96166&r1=96165&r2=96166&view=diff ============================================================================== --- vmkit/trunk/include/j3/LLVMMaterializer.h (original) +++ vmkit/trunk/include/j3/LLVMMaterializer.h Sun Feb 14 09:40:01 2010 @@ -14,7 +14,40 @@ namespace j3 { -class JavaLLVMLazyJITCompiler; +class LLVMMaterializer; + +struct CallbackInfo { + Class* cl; + uint16 index; + bool stat; + + CallbackInfo(Class* c, uint32 i, bool s) : + cl(c), index(i), stat(s) {} + +}; + +class JavaLLVMLazyJITCompiler : public JavaJITCompiler { +private: + std::map callbacks; + typedef std::map::iterator callback_iterator; + +public: + llvm::GVMaterializer* TheMaterializer; + + virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, + bool stat, llvm::BasicBlock* insert); + virtual uintptr_t getPointerOrStub(JavaMethod& meth, int side); + + virtual JavaCompiler* Create(const std::string& ModuleID) { + return new JavaLLVMLazyJITCompiler(ModuleID); + } + + JavaLLVMLazyJITCompiler(const std::string& ModuleID); + + virtual ~JavaLLVMLazyJITCompiler(); + + friend class LLVMMaterializer; +}; class LLVMMaterializer : public llvm::GVMaterializer { public: Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=96166&r1=96165&r2=96166&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sun Feb 14 09:40:01 2010 @@ -18,6 +18,7 @@ #include "mvm/Threads/Thread.h" #include "j3/JnjvmModule.h" +#include "j3/JavaAOTCompiler.h" #include "JavaArray.h" #include "JavaConstantPool.h" Modified: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?rev=96166&r1=96165&r2=96166&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Sun Feb 14 09:40:01 2010 @@ -109,7 +109,7 @@ if (!meth) { // It's a callback - JavaJITCompiler::callback_iterator I = Comp->callbacks.find(F); + JavaLLVMLazyJITCompiler::callback_iterator I = Comp->callbacks.find(F); assert(I != Comp->callbacks.end() && "No callbacks found"); meth = staticLookup(I->second); } Modified: vmkit/trunk/tools/vmjc/vmjc.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=96166&r1=96165&r2=96166&view=diff ============================================================================== --- vmkit/trunk/tools/vmjc/vmjc.cpp (original) +++ vmkit/trunk/tools/vmjc/vmjc.cpp Sun Feb 14 09:40:01 2010 @@ -42,6 +42,7 @@ #include "mvm/VirtualMachine.h" #include "mvm/Threads/Thread.h" +#include "j3/JavaAOTCompiler.h" #include "j3/JnjvmModule.h" #include "../../lib/J3/VMCore/JnjvmClassLoader.h" From nicolas.geoffray at lip6.fr Sun Feb 14 07:51:34 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 15:51:34 -0000 Subject: [vmkit-commits] [vmkit] r96167 - /vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Message-ID: <201002141551.o1EFpYH0011220@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 09:51:34 2010 New Revision: 96167 URL: http://llvm.org/viewvc/llvm-project?rev=96167&view=rev Log: Remove unintentional change. Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=96167&r1=96166&r2=96167&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Sun Feb 14 09:51:34 2010 @@ -384,8 +384,6 @@ // Creates a Java object and then throws it. extern "C" JavaObject* j3NullPointerException() { - JavaThread::get()->printBacktrace(); - abort(); JavaObject *exc = 0; JavaThread *th = JavaThread::get(); From nicolas.geoffray at lip6.fr Sun Feb 14 08:20:26 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 16:20:26 -0000 Subject: [vmkit-commits] [vmkit] r96169 - in /vmkit/trunk/lib/J3/Compiler: JavaJITCompiler.cpp LLVMMaterializer.cpp Message-ID: <201002141620.o1EGKQ1Y013626@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 10:20:25 2010 New Revision: 96169 URL: http://llvm.org/viewvc/llvm-project?rev=96169&view=rev Log: Code refactoring. Fix warning on unsed computed value. Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96169&r1=96168&r2=96169&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sun Feb 14 10:20:25 2010 @@ -419,15 +419,6 @@ return JavaCompiler::loadMethod(handle, symbol); } -uintptr_t JavaLLVMLazyJITCompiler::getPointerOrStub(JavaMethod& meth, - int side) { - ExecutionEngine* EE = mvm::MvmModule::executionEngine; - LLVMMethodInfo* LMI = getMethodInfo(&meth); - Function* func = LMI->getMethod(); - return (uintptr_t)EE->getPointerToFunctionOrStub(func); -} - - uintptr_t JavaJ3LazyJITCompiler::getPointerOrStub(JavaMethod& meth, int side) { return meth.getSignature()->getVirtualCallStub(); @@ -439,8 +430,20 @@ LLVMSignatureInfo* LSI = getSignatureInfo(sign); // Set the stub in the constant pool. JavaConstantPool* ctpInfo = cl->ctpInfo; - intptr_t stub = stat ? sign->getStaticCallStub() : sign->getSpecialCallStub(); - __sync_val_compare_and_swap(&(ctpInfo->ctpRes[index]), NULL, stub); + uintptr_t stub = stat ? sign->getStaticCallStub() : sign->getSpecialCallStub(); + if (!ctpInfo->ctpRes[index]) { + // Do a compare and swap, so that we do not overwrtie what a stub might + // have just updated. + uintptr_t val = + __sync_val_compare_and_swap(&(ctpInfo->ctpRes[index]), NULL, stub); + // If there is something in the the constant pool that is not NULL nor + // the stub, then it's the method. + if (val != 0 && val != stub) { + return ConstantExpr::getIntToPtr( + ConstantInt::get(Type::getInt64Ty(insert->getContext()), val), + stat ? LSI->getStaticPtrType() : LSI->getVirtualPtrType()); + } + } // Load the constant pool. Value* CTP = getConstantPool(ctpInfo); Value* Index = ConstantInt::get(Type::getInt32Ty(insert->getContext()), @@ -462,15 +465,6 @@ JavaJ3LazyJITCompiler::JavaJ3LazyJITCompiler(const std::string& ModuleID) : JavaJITCompiler(ModuleID) {} -JavaLLVMLazyJITCompiler::JavaLLVMLazyJITCompiler(const std::string& ModuleID) - : JavaJITCompiler(ModuleID) { - TheMaterializer = new LLVMMaterializer(TheModule, this); -} - -JavaLLVMLazyJITCompiler::~JavaLLVMLazyJITCompiler() { - delete TheMaterializer; -} - static llvm::cl::opt LLVMLazy("llvm-lazy", cl::desc("Use LLVM lazy stubs"), cl::init(false)); Modified: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?rev=96169&r1=96168&r2=96169&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Sun Feb 14 10:20:25 2010 @@ -27,6 +27,23 @@ using namespace j3; +JavaLLVMLazyJITCompiler::JavaLLVMLazyJITCompiler(const std::string& ModuleID) + : JavaJITCompiler(ModuleID) { + TheMaterializer = new LLVMMaterializer(TheModule, this); +} + +JavaLLVMLazyJITCompiler::~JavaLLVMLazyJITCompiler() { + delete TheMaterializer; +} + +uintptr_t JavaLLVMLazyJITCompiler::getPointerOrStub(JavaMethod& meth, + int side) { + ExecutionEngine* EE = mvm::MvmModule::executionEngine; + LLVMMethodInfo* LMI = getMethodInfo(&meth); + Function* func = LMI->getMethod(); + return (uintptr_t)EE->getPointerToFunctionOrStub(func); +} + static JavaMethod* staticLookup(CallbackInfo& F) { Class* caller = F.cl; uint16 index = F.index; From nicolas.geoffray at lip6.fr Sun Feb 14 08:24:55 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 16:24:55 -0000 Subject: [vmkit-commits] [vmkit] r96170 - /vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Message-ID: <201002141624.o1EGOt1d014046@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 10:24:55 2010 New Revision: 96170 URL: http://llvm.org/viewvc/llvm-project?rev=96170&view=rev Log: Fix compilation error on llvm-gcc. Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96170&r1=96169&r2=96170&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sun Feb 14 10:24:55 2010 @@ -434,7 +434,7 @@ if (!ctpInfo->ctpRes[index]) { // Do a compare and swap, so that we do not overwrtie what a stub might // have just updated. - uintptr_t val = + uintptr_t val = (uintptr_t) __sync_val_compare_and_swap(&(ctpInfo->ctpRes[index]), NULL, stub); // If there is something in the the constant pool that is not NULL nor // the stub, then it's the method. From nicolas.geoffray at lip6.fr Sun Feb 14 11:57:50 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 19:57:50 -0000 Subject: [vmkit-commits] [vmkit] r96185 - in /vmkit/trunk: Makefile.rules include/j3/JnjvmModule.h include/j3/LLVMMaterializer.h lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/LLVMMaterializer.cpp Message-ID: <201002141957.o1EJvoYe029841@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 13:57:49 2010 New Revision: 96185 URL: http://llvm.org/viewvc/llvm-project?rev=96185&view=rev Log: Compile lazily when compiling MMTk. Modified: vmkit/trunk/Makefile.rules vmkit/trunk/include/j3/JnjvmModule.h vmkit/trunk/include/j3/LLVMMaterializer.h vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Modified: vmkit/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/Makefile.rules?rev=96185&r1=96184&r2=96185&view=diff ============================================================================== --- vmkit/trunk/Makefile.rules (original) +++ vmkit/trunk/Makefile.rules Sun Feb 14 13:57:49 2010 @@ -133,7 +133,7 @@ $(Verb) $(ANT) $(Echo) Building $(BuildMode) $(JARNAME).jar $(notdir $@) $(Verb) $(LOPT) -load=$(LibDir)/JITGCPass$(SHLIBEXT) -std-compile-opts -JITGCPass -f $(LibDir)/MMTKAlloc.bc -o $(LibDir)/MMTKAlloc.bc - $(Verb) $(VMJC) -std-compile-opts $(ADDITIONAL_ARGS) -load=$(LibDir)/MMTKFake$(SHLIBEXT) -load=$(LibDir)/MMTKMagic$(SHLIBEXT) -LowerMagic -verify $(JARNAME).jar -disable-exceptions -disable-cooperativegc -with-clinit=org/mmtk/vm/VM,org/mmtk/utility/*,org/mmtk/policy/*,org/j3/config/* -Dmmtk.hostjvm=org.j3.mmtk.Factory -o $(JARNAME).bc -Dmmtk.properties=vmkit.properties -disable-stubs -assume-compiled + $(Verb) $(VMJC) -std-compile-opts $(ADDITIONAL_ARGS) -load=$(LibDir)/MMTKFake$(SHLIBEXT) -load=$(LibDir)/MMTKMagic$(SHLIBEXT) -LowerMagic -verify $(JARNAME).jar -disable-exceptions -disable-cooperativegc -with-clinit=org/mmtk/vm/VM,org/mmtk/utility/*,org/mmtk/policy/*,org/j3/config/* -Dmmtk.hostjvm=org.j3.mmtk.Factory -o $(JARNAME).bc -Dmmtk.properties=vmkit.properties -disable-stubs -assume-compiled -llvm-lazy $(Verb) $(LOPT) -load=$(LibDir)/MMTKMagic$(SHLIBEXT) -std-compile-opts -LowerJavaRT -f $(JARNAME).bc -o $(JARNAME)-optimized.bc $(Verb) $(LLVMLD) -r -o $(LibDir)/FinalMMTk.bc $(LibDir)/MMTKAlloc.bc $(JARNAME)-optimized.bc $(LibDir)/MMTKRuntime.bc $(Verb) $(LOPT) -std-compile-opts $(LibDir)/FinalMMTk.bc -o $(LibDir)/FinalMMTk.bc Modified: vmkit/trunk/include/j3/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=96185&r1=96184&r2=96185&view=diff ============================================================================== --- vmkit/trunk/include/j3/JnjvmModule.h (original) +++ vmkit/trunk/include/j3/JnjvmModule.h Sun Feb 14 13:57:49 2010 @@ -597,9 +597,7 @@ return new mvm::UnpreciseStackScanner(); } #endif - - virtual void* loadMethod(void* handle, const char* symbol); - + static JavaJITCompiler* CreateCompiler(const std::string& ModuleID); }; Modified: vmkit/trunk/include/j3/LLVMMaterializer.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMMaterializer.h?rev=96185&r1=96184&r2=96185&view=diff ============================================================================== --- vmkit/trunk/include/j3/LLVMMaterializer.h (original) +++ vmkit/trunk/include/j3/LLVMMaterializer.h Sun Feb 14 13:57:49 2010 @@ -45,6 +45,8 @@ JavaLLVMLazyJITCompiler(const std::string& ModuleID); virtual ~JavaLLVMLazyJITCompiler(); + + virtual void* loadMethod(void* handle, const char* symbol); friend class LLVMMaterializer; }; Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96185&r1=96184&r2=96185&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sun Feb 14 13:57:49 2010 @@ -409,16 +409,6 @@ return 0; } -void* JavaJITCompiler::loadMethod(void* handle, const char* symbol) { - Function* F = mvm::MvmModule::globalModule->getFunction(symbol); - if (F) { - void* res = mvm::MvmModule::executionEngine->getPointerToFunction(F); - return res; - } - - return JavaCompiler::loadMethod(handle, symbol); -} - uintptr_t JavaJ3LazyJITCompiler::getPointerOrStub(JavaMethod& meth, int side) { return meth.getSignature()->getVirtualCallStub(); Modified: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?rev=96185&r1=96184&r2=96185&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Sun Feb 14 13:57:49 2010 @@ -36,6 +36,16 @@ delete TheMaterializer; } +void* JavaLLVMLazyJITCompiler::loadMethod(void* handle, const char* symbol) { + Function* F = mvm::MvmModule::globalModule->getFunction(symbol); + if (F) { + void* res = mvm::MvmModule::executionEngine->getPointerToFunctionOrStub(F); + return res; + } + + return JavaCompiler::loadMethod(handle, symbol); +} + uintptr_t JavaLLVMLazyJITCompiler::getPointerOrStub(JavaMethod& meth, int side) { ExecutionEngine* EE = mvm::MvmModule::executionEngine; From nicolas.geoffray at lip6.fr Sun Feb 14 13:12:57 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 21:12:57 -0000 Subject: [vmkit-commits] [vmkit] r96189 - in /vmkit/trunk: include/j3/JavaJITCompiler.h include/j3/JnjvmModule.h include/j3/LLVMMaterializer.h lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/JnjvmModule.cpp tools/j3/Main.cpp tools/vmkit/Launcher.cpp Message-ID: <201002142112.o1ELCvwf000965@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 15:12:57 2010 New Revision: 96189 URL: http://llvm.org/viewvc/llvm-project?rev=96189&view=rev Log: Continue code refactoring. No functionality change. Added: vmkit/trunk/include/j3/JavaJITCompiler.h Modified: vmkit/trunk/include/j3/JnjvmModule.h vmkit/trunk/include/j3/LLVMMaterializer.h vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp vmkit/trunk/tools/j3/Main.cpp vmkit/trunk/tools/vmkit/Launcher.cpp Added: vmkit/trunk/include/j3/JavaJITCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaJITCompiler.h?rev=96189&view=auto ============================================================================== --- vmkit/trunk/include/j3/JavaJITCompiler.h (added) +++ vmkit/trunk/include/j3/JavaJITCompiler.h Sun Feb 14 15:12:57 2010 @@ -0,0 +1,91 @@ +//===------- JavaJITCompiler.h - The J3 just in time compiler -------------===// +// +// The VMKit project +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef J3_JIT_COMPILER_H +#define J3_JIT_COMPILER_H + +#include "j3/JnjvmModule.h" + +namespace j3 { + +class JavaJITCompiler : public JavaLLVMCompiler { +public: + + bool EmitFunctionName; + + JavaJITCompiler(const std::string &ModuleID); + + virtual bool isStaticCompiling() { + return false; + } + + virtual bool emitFunctionName() { + return EmitFunctionName; + } + + virtual void makeVT(Class* cl); + virtual void makeIMT(Class* cl); + + virtual void* materializeFunction(JavaMethod* meth); + + virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl); + virtual JavaObject* getFinalObject(llvm::Value* C); + virtual llvm::Constant* getNativeClass(CommonClass* cl); + virtual llvm::Constant* getJavaClass(CommonClass* cl); + virtual llvm::Constant* getJavaClassPtr(CommonClass* cl); + virtual llvm::Constant* getStaticInstance(Class* cl); + virtual llvm::Constant* getVirtualTable(JavaVirtualTable*); + virtual llvm::Constant* getMethodInClass(JavaMethod* meth); + + virtual llvm::Constant* getString(JavaString* str); + virtual llvm::Constant* getStringPtr(JavaString** str); + virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp); + virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr); + + virtual void setMethod(JavaMethod* meth, void* ptr, const char* name); + + +#ifdef SERVICE + virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where); +#endif + + virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, + bool stat, llvm::BasicBlock* insert) = 0; + virtual uintptr_t getPointerOrStub(JavaMethod& meth, int type) = 0; + +#ifdef WITH_LLVM_GCC + virtual mvm::StackScanner* createStackScanner() { + if (useCooperativeGC()) + return new mvm::PreciseStackScanner(); + + return new mvm::UnpreciseStackScanner(); + } +#endif + + static JavaJITCompiler* CreateCompiler(const std::string& ModuleID); + +}; + +class JavaJ3LazyJITCompiler : public JavaJITCompiler { +public: + virtual bool needsCallback(JavaMethod* meth, bool* needsInit); + virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, + bool stat, llvm::BasicBlock* insert); + virtual uintptr_t getPointerOrStub(JavaMethod& meth, int side); + + virtual JavaCompiler* Create(const std::string& ModuleID) { + return new JavaJ3LazyJITCompiler(ModuleID); + } + + JavaJ3LazyJITCompiler(const std::string& ModuleID); +}; + +} // end namespace j3 + +#endif Modified: vmkit/trunk/include/j3/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=96189&r1=96188&r2=96189&view=diff ============================================================================== --- vmkit/trunk/include/j3/JnjvmModule.h (original) +++ vmkit/trunk/include/j3/JnjvmModule.h Sun Feb 14 15:12:57 2010 @@ -526,96 +526,6 @@ }; -class JavaJITMethodInfo : public mvm::JITMethodInfo { -protected: - JavaMethod* meth; -public: - virtual void print(void* ip, void* addr); - - JavaJITMethodInfo(llvm::GCFunctionInfo* GFI, JavaMethod* m) : - mvm::JITMethodInfo(GFI) { - meth = m; - MethodType = 1; - } - - virtual void* getMetaInfo() { - return meth; - } - -}; - -class JavaJITCompiler : public JavaLLVMCompiler { -public: - - bool EmitFunctionName; - - JavaJITCompiler(const std::string &ModuleID); - - virtual bool isStaticCompiling() { - return false; - } - - virtual bool emitFunctionName() { - return EmitFunctionName; - } - - virtual void makeVT(Class* cl); - virtual void makeIMT(Class* cl); - - virtual void* materializeFunction(JavaMethod* meth); - - virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl); - virtual JavaObject* getFinalObject(llvm::Value* C); - virtual llvm::Constant* getNativeClass(CommonClass* cl); - virtual llvm::Constant* getJavaClass(CommonClass* cl); - virtual llvm::Constant* getJavaClassPtr(CommonClass* cl); - virtual llvm::Constant* getStaticInstance(Class* cl); - virtual llvm::Constant* getVirtualTable(JavaVirtualTable*); - virtual llvm::Constant* getMethodInClass(JavaMethod* meth); - - virtual llvm::Constant* getString(JavaString* str); - virtual llvm::Constant* getStringPtr(JavaString** str); - virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp); - virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr); - - virtual void setMethod(JavaMethod* meth, void* ptr, const char* name); - - -#ifdef SERVICE - virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where); -#endif - - virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat, llvm::BasicBlock* insert) = 0; - virtual uintptr_t getPointerOrStub(JavaMethod& meth, int type) = 0; - -#ifdef WITH_LLVM_GCC - virtual mvm::StackScanner* createStackScanner() { - if (useCooperativeGC()) - return new mvm::PreciseStackScanner(); - - return new mvm::UnpreciseStackScanner(); - } -#endif - - static JavaJITCompiler* CreateCompiler(const std::string& ModuleID); - -}; - -class JavaJ3LazyJITCompiler : public JavaJITCompiler { -public: - virtual bool needsCallback(JavaMethod* meth, bool* needsInit); - virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat, llvm::BasicBlock* insert); - virtual uintptr_t getPointerOrStub(JavaMethod& meth, int side); - - virtual JavaCompiler* Create(const std::string& ModuleID) { - return new JavaJ3LazyJITCompiler(ModuleID); - } - - JavaJ3LazyJITCompiler(const std::string& ModuleID); -}; - } #endif Modified: vmkit/trunk/include/j3/LLVMMaterializer.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMMaterializer.h?rev=96189&r1=96188&r2=96189&view=diff ============================================================================== --- vmkit/trunk/include/j3/LLVMMaterializer.h (original) +++ vmkit/trunk/include/j3/LLVMMaterializer.h Sun Feb 14 15:12:57 2010 @@ -12,6 +12,8 @@ #include +#include + namespace j3 { class LLVMMaterializer; Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=96189&r1=96188&r2=96189&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sun Feb 14 15:12:57 2010 @@ -19,6 +19,7 @@ #include "j3/JnjvmModule.h" #include "j3/JavaAOTCompiler.h" +#include "j3/JavaJITCompiler.h" #include "JavaArray.h" #include "JavaConstantPool.h" Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96189&r1=96188&r2=96189&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sun Feb 14 15:12:57 2010 @@ -32,12 +32,44 @@ #include "JavaTypes.h" #include "Jnjvm.h" +#include "j3/JavaJITCompiler.h" #include "j3/JnjvmModule.h" #include "j3/LLVMMaterializer.h" using namespace j3; using namespace llvm; + +class JavaJITMethodInfo : public mvm::JITMethodInfo { +protected: + JavaMethod* meth; +public: + virtual void print(void* ip, void* addr); + + JavaJITMethodInfo(llvm::GCFunctionInfo* GFI, JavaMethod* m) : + mvm::JITMethodInfo(GFI) { + meth = m; + MethodType = 1; + } + + virtual void* getMetaInfo() { + return meth; + } + +}; + +void JavaJITMethodInfo::print(void* ip, void* addr) { + void* new_ip = NULL; + if (ip) new_ip = isStub(ip, addr); + uint16 line = meth->lookupLineNumber((uintptr_t)ip); + fprintf(stderr, "; %p in %s.%s (line %d)", new_ip, + UTF8Buffer(meth->classDef->name).cString(), + UTF8Buffer(meth->name).cString(), line); + if (ip != new_ip) fprintf(stderr, " (from stub)"); + fprintf(stderr, "\n"); +} + + class JavaJITListener : public llvm::JITEventListener { JavaMethod* currentCompiledMethod; public: @@ -455,6 +487,7 @@ JavaJ3LazyJITCompiler::JavaJ3LazyJITCompiler(const std::string& ModuleID) : JavaJITCompiler(ModuleID) {} + static llvm::cl::opt LLVMLazy("llvm-lazy", cl::desc("Use LLVM lazy stubs"), cl::init(false)); Modified: vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp?rev=96189&r1=96188&r2=96189&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp Sun Feb 14 15:12:57 2010 @@ -426,14 +426,3 @@ //JavaFunctionPasses->add(mvm::createEscapeAnalysisPass()); JavaFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics())); } - -void JavaJITMethodInfo::print(void* ip, void* addr) { - void* new_ip = NULL; - if (ip) new_ip = isStub(ip, addr); - uint16 line = meth->lookupLineNumber((uintptr_t)ip); - fprintf(stderr, "; %p in %s.%s (line %d)", new_ip, - UTF8Buffer(meth->classDef->name).cString(), - UTF8Buffer(meth->name).cString(), line); - if (ip != new_ip) fprintf(stderr, " (from stub)"); - fprintf(stderr, "\n"); -} Modified: vmkit/trunk/tools/j3/Main.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/j3/Main.cpp?rev=96189&r1=96188&r2=96189&view=diff ============================================================================== --- vmkit/trunk/tools/j3/Main.cpp (original) +++ vmkit/trunk/tools/j3/Main.cpp Sun Feb 14 15:12:57 2010 @@ -13,7 +13,7 @@ #include "mvm/VirtualMachine.h" #include "mvm/Threads/Thread.h" -#include "j3/JnjvmModule.h" +#include "j3/JavaJITCompiler.h" #include "llvm/Support/ManagedStatic.h" Modified: vmkit/trunk/tools/vmkit/Launcher.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=96189&r1=96188&r2=96189&view=diff ============================================================================== --- vmkit/trunk/tools/vmkit/Launcher.cpp (original) +++ vmkit/trunk/tools/vmkit/Launcher.cpp Sun Feb 14 15:12:57 2010 @@ -25,6 +25,7 @@ #include "mvm/VirtualMachine.h" #include "mvm/Threads/Thread.h" +#include "j3/JavaJITCompiler.h" #include "j3/JnjvmModule.h" #include "CommandLine.h" From nicolas.geoffray at lip6.fr Sun Feb 14 13:22:41 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 21:22:41 -0000 Subject: [vmkit-commits] [vmkit] r96190 - in /vmkit/trunk: include/j3/JavaAOTCompiler.h include/j3/JavaJITCompiler.h include/j3/JavaLLVMCompiler.h include/j3/JnjvmModule.h lib/J3/Compiler/JavaJIT.h Message-ID: <201002142122.o1ELMfI7001482@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 15:22:41 2010 New Revision: 96190 URL: http://llvm.org/viewvc/llvm-project?rev=96190&view=rev Log: More refactoring - no functionality change. Added: vmkit/trunk/include/j3/JavaLLVMCompiler.h Modified: vmkit/trunk/include/j3/JavaAOTCompiler.h vmkit/trunk/include/j3/JavaJITCompiler.h vmkit/trunk/include/j3/JnjvmModule.h vmkit/trunk/lib/J3/Compiler/JavaJIT.h Modified: vmkit/trunk/include/j3/JavaAOTCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaAOTCompiler.h?rev=96190&r1=96189&r2=96190&view=diff ============================================================================== --- vmkit/trunk/include/j3/JavaAOTCompiler.h (original) +++ vmkit/trunk/include/j3/JavaAOTCompiler.h Sun Feb 14 15:22:41 2010 @@ -10,7 +10,7 @@ #ifndef J3_AOT_COMPILER_H #define J3_AOT_COMPILER_H -#include "j3/JnjvmModule.h" +#include "j3/JavaLLVMCompiler.h" namespace j3 { Modified: vmkit/trunk/include/j3/JavaJITCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaJITCompiler.h?rev=96190&r1=96189&r2=96190&view=diff ============================================================================== --- vmkit/trunk/include/j3/JavaJITCompiler.h (original) +++ vmkit/trunk/include/j3/JavaJITCompiler.h Sun Feb 14 15:22:41 2010 @@ -10,7 +10,7 @@ #ifndef J3_JIT_COMPILER_H #define J3_JIT_COMPILER_H -#include "j3/JnjvmModule.h" +#include "j3/JavaLLVMCompiler.h" namespace j3 { @@ -68,7 +68,7 @@ } #endif - static JavaJITCompiler* CreateCompiler(const std::string& ModuleID); + static JavaJITCompiler* CreateCompiler(const std::string& ModuleID); }; Added: vmkit/trunk/include/j3/JavaLLVMCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaLLVMCompiler.h?rev=96190&view=auto ============================================================================== --- vmkit/trunk/include/j3/JavaLLVMCompiler.h (added) +++ vmkit/trunk/include/j3/JavaLLVMCompiler.h Sun Feb 14 15:22:41 2010 @@ -0,0 +1,156 @@ +//===---==---- JavaLLVMCompiler.h - A LLVM Compiler for J3 ----------------===// +// +// The VMKit project +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef J3_LLVM_COMPILER_H +#define J3_LLVM_COMPILER_H + +#include "j3/JnjvmModule.h" + +namespace j3 { + +class JavaLLVMCompiler : public JavaCompiler { + friend class LLVMClassInfo; + friend class LLVMMethodInfo; + +protected: + llvm::Module* TheModule; + JnjvmModule JavaIntrinsics; + + void addJavaPasses(); + +private: + bool enabledException; + bool cooperativeGC; + + virtual void makeVT(Class* cl) = 0; + virtual void makeIMT(Class* cl) = 0; + + std::map functions; + typedef std::map::iterator function_iterator; + + std::map DbgInfos; + typedef std::map::iterator dbg_iterator; + +public: + JavaLLVMCompiler(const std::string &ModuleID); + + virtual bool isStaticCompiling() = 0; + virtual bool emitFunctionName() = 0; + + llvm::Module* getLLVMModule() { + return TheModule; + } + + JnjvmModule* getIntrinsics() { + return &JavaIntrinsics; + } + + bool hasExceptionsEnabled() { + return enabledException; + } + + bool useCooperativeGC() { + return cooperativeGC; + } + + void disableExceptions() { + enabledException = false; + } + + void disableCooperativeGC() { + cooperativeGC = false; + } + + virtual JavaCompiler* Create(const std::string& ModuleID) = 0; + + virtual ~JavaLLVMCompiler(); + + JavaMethod* getJavaMethod(llvm::Function*); + llvm::MDNode* GetDbgSubprogram(JavaMethod* meth); + + void resolveVirtualClass(Class* cl); + void resolveStaticClass(Class* cl); + static llvm::Function* getMethod(JavaMethod* meth); + + static LLVMSignatureInfo* getSignatureInfo(Signdef* sign); + static LLVMClassInfo* getClassInfo(Class* cl); + static LLVMFieldInfo* getFieldInfo(JavaField* field); + static LLVMMethodInfo* getMethodInfo(JavaMethod* method); + static LLVMAssessorInfo& getTypedefInfo(const Typedef* type); + + virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl) = 0; + virtual JavaObject* getFinalObject(llvm::Value* C) = 0; + virtual llvm::Constant* getNativeClass(CommonClass* cl) = 0; + virtual llvm::Constant* getJavaClass(CommonClass* cl) = 0; + virtual llvm::Constant* getJavaClassPtr(CommonClass* cl) = 0; + virtual llvm::Constant* getStaticInstance(Class* cl) = 0; + virtual llvm::Constant* getVirtualTable(JavaVirtualTable*) = 0; + virtual llvm::Constant* getMethodInClass(JavaMethod* meth) = 0; + + virtual llvm::Constant* getString(JavaString* str) = 0; + virtual llvm::Constant* getStringPtr(JavaString** str) = 0; + virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp) = 0; + virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr) = 0; + + virtual void setMethod(JavaMethod* meth, void* ptr, const char* name) = 0; + +#ifdef SERVICE + virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where) = 0; +#endif + + virtual void* materializeFunction(JavaMethod* meth) = 0; + llvm::Function* parseFunction(JavaMethod* meth); + + llvm::FunctionPassManager* JavaFunctionPasses; + llvm::FunctionPassManager* JavaNativeFunctionPasses; + + virtual bool needsCallback(JavaMethod* meth, bool* needsInit) { + *needsInit = true; + return meth == NULL; + } + virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, + bool stat, llvm::BasicBlock* insert) = 0; + + virtual void staticCallBuf(Signdef* sign) { + getSignatureInfo(sign)->getStaticBuf(); + } + + virtual void virtualCallBuf(Signdef* sign) { + getSignatureInfo(sign)->getVirtualBuf(); + } + + virtual void staticCallAP(Signdef* sign) { + getSignatureInfo(sign)->getStaticAP(); + } + + virtual void virtualCallAP(Signdef* sign) { + getSignatureInfo(sign)->getVirtualAP(); + } + + virtual void virtualCallStub(Signdef* sign) { + getSignatureInfo(sign)->getVirtualStub(); + } + + virtual void specialCallStub(Signdef* sign) { + getSignatureInfo(sign)->getSpecialStub(); + } + + virtual void staticCallStub(Signdef* sign) { + getSignatureInfo(sign)->getStaticStub(); + } + + llvm::Function* NativeLoader; + +}; + + + +} // end namespace j3 + +#endif Modified: vmkit/trunk/include/j3/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=96190&r1=96189&r2=96190&view=diff ============================================================================== --- vmkit/trunk/include/j3/JnjvmModule.h (original) +++ vmkit/trunk/include/j3/JnjvmModule.h Sun Feb 14 15:22:41 2010 @@ -390,142 +390,6 @@ }; -class JavaLLVMCompiler : public JavaCompiler { - friend class LLVMClassInfo; - friend class LLVMMethodInfo; - - -protected: - llvm::Module* TheModule; - JnjvmModule JavaIntrinsics; - - void addJavaPasses(); - -private: - bool enabledException; - bool cooperativeGC; - - virtual void makeVT(Class* cl) = 0; - virtual void makeIMT(Class* cl) = 0; - - std::map functions; - typedef std::map::iterator function_iterator; - - std::map DbgInfos; - typedef std::map::iterator dbg_iterator; - -public: - JavaLLVMCompiler(const std::string &ModuleID); - - virtual bool isStaticCompiling() = 0; - virtual bool emitFunctionName() = 0; - - llvm::Module* getLLVMModule() { - return TheModule; - } - - JnjvmModule* getIntrinsics() { - return &JavaIntrinsics; - } - - bool hasExceptionsEnabled() { - return enabledException; - } - - bool useCooperativeGC() { - return cooperativeGC; - } - - void disableExceptions() { - enabledException = false; - } - - void disableCooperativeGC() { - cooperativeGC = false; - } - - virtual JavaCompiler* Create(const std::string& ModuleID) = 0; - - virtual ~JavaLLVMCompiler(); - - JavaMethod* getJavaMethod(llvm::Function*); - llvm::MDNode* GetDbgSubprogram(JavaMethod* meth); - - void resolveVirtualClass(Class* cl); - void resolveStaticClass(Class* cl); - static llvm::Function* getMethod(JavaMethod* meth); - - static LLVMSignatureInfo* getSignatureInfo(Signdef* sign); - static LLVMClassInfo* getClassInfo(Class* cl); - static LLVMFieldInfo* getFieldInfo(JavaField* field); - static LLVMMethodInfo* getMethodInfo(JavaMethod* method); - static LLVMAssessorInfo& getTypedefInfo(const Typedef* type); - - virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl) = 0; - virtual JavaObject* getFinalObject(llvm::Value* C) = 0; - virtual llvm::Constant* getNativeClass(CommonClass* cl) = 0; - virtual llvm::Constant* getJavaClass(CommonClass* cl) = 0; - virtual llvm::Constant* getJavaClassPtr(CommonClass* cl) = 0; - virtual llvm::Constant* getStaticInstance(Class* cl) = 0; - virtual llvm::Constant* getVirtualTable(JavaVirtualTable*) = 0; - virtual llvm::Constant* getMethodInClass(JavaMethod* meth) = 0; - - virtual llvm::Constant* getString(JavaString* str) = 0; - virtual llvm::Constant* getStringPtr(JavaString** str) = 0; - virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp) = 0; - virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr) = 0; - - virtual void setMethod(JavaMethod* meth, void* ptr, const char* name) = 0; - -#ifdef SERVICE - virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where) = 0; -#endif - - virtual void* materializeFunction(JavaMethod* meth) = 0; - llvm::Function* parseFunction(JavaMethod* meth); - - llvm::FunctionPassManager* JavaFunctionPasses; - llvm::FunctionPassManager* JavaNativeFunctionPasses; - - virtual bool needsCallback(JavaMethod* meth, bool* needsInit) { - *needsInit = true; - return meth == NULL; - } - virtual llvm::Value* addCallback(Class* cl, uint16 index, Signdef* sign, - bool stat, llvm::BasicBlock* insert) = 0; - - virtual void staticCallBuf(Signdef* sign) { - getSignatureInfo(sign)->getStaticBuf(); - } - - virtual void virtualCallBuf(Signdef* sign) { - getSignatureInfo(sign)->getVirtualBuf(); - } - - virtual void staticCallAP(Signdef* sign) { - getSignatureInfo(sign)->getStaticAP(); - } - - virtual void virtualCallAP(Signdef* sign) { - getSignatureInfo(sign)->getVirtualAP(); - } - - virtual void virtualCallStub(Signdef* sign) { - getSignatureInfo(sign)->getVirtualStub(); - } - - virtual void specialCallStub(Signdef* sign) { - getSignatureInfo(sign)->getSpecialStub(); - } - - virtual void staticCallStub(Signdef* sign) { - getSignatureInfo(sign)->getStaticStub(); - } - - llvm::Function* NativeLoader; - -}; - } #endif Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=96190&r1=96189&r2=96190&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Sun Feb 14 15:22:41 2010 @@ -26,6 +26,7 @@ #include "JavaClass.h" #include "JavaUpcalls.h" +#include "j3/JavaLLVMCompiler.h" #include "j3/JnjvmModule.h" namespace j3 { From nicolas.geoffray at lip6.fr Sun Feb 14 13:43:54 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 21:43:54 -0000 Subject: [vmkit-commits] [vmkit] r96191 - in /vmkit/trunk: include/j3/JavaAOTCompiler.h include/j3/JavaLLVMCompiler.h include/j3/JnjvmModule.h include/j3/LLVMInfo.h lib/J3/Compiler/JITInfo.cpp Message-ID: <201002142143.o1ELhspR002537@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 15:43:54 2010 New Revision: 96191 URL: http://llvm.org/viewvc/llvm-project?rev=96191&view=rev Log: More and more refactoring - no functionality change. Added: vmkit/trunk/include/j3/LLVMInfo.h Modified: vmkit/trunk/include/j3/JavaAOTCompiler.h vmkit/trunk/include/j3/JavaLLVMCompiler.h vmkit/trunk/include/j3/JnjvmModule.h vmkit/trunk/lib/J3/Compiler/JITInfo.cpp Modified: vmkit/trunk/include/j3/JavaAOTCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaAOTCompiler.h?rev=96191&r1=96190&r2=96191&view=diff ============================================================================== --- vmkit/trunk/include/j3/JavaAOTCompiler.h (original) +++ vmkit/trunk/include/j3/JavaAOTCompiler.h Sun Feb 14 15:43:54 2010 @@ -14,6 +14,11 @@ namespace j3 { +class ArrayObject; +class Attribut; + +using mvm::UTF8; + class JavaAOTCompiler : public JavaLLVMCompiler { public: Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaLLVMCompiler.h?rev=96191&r1=96190&r2=96191&view=diff ============================================================================== --- vmkit/trunk/include/j3/JavaLLVMCompiler.h (original) +++ vmkit/trunk/include/j3/JavaLLVMCompiler.h Sun Feb 14 15:43:54 2010 @@ -10,10 +10,30 @@ #ifndef J3_LLVM_COMPILER_H #define J3_LLVM_COMPILER_H +#include "j3/JavaCompiler.h" #include "j3/JnjvmModule.h" +#include "j3/LLVMInfo.h" + +namespace llvm { + class BasicBlock; +} namespace j3 { +class CommonClass; +class Class; +class ClassArray; +class ClassPrimitive; +class JavaConstantPool; +class JavaField; +class JavaMethod; +class JavaObject; +class JavaString; +class JavaVirtualTable; +class Jnjvm; +class Typedef; +class Signdef; + class JavaLLVMCompiler : public JavaCompiler { friend class LLVMClassInfo; friend class LLVMMethodInfo; @@ -149,8 +169,6 @@ }; - - } // end namespace j3 #endif Modified: vmkit/trunk/include/j3/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=96191&r1=96190&r2=96191&view=diff ============================================================================== --- vmkit/trunk/include/j3/JnjvmModule.h (original) +++ vmkit/trunk/include/j3/JnjvmModule.h Sun Feb 14 15:43:54 2010 @@ -10,220 +10,10 @@ #ifndef JNJVM_MODULE_H #define JNJVM_MODULE_H -#include -#include - -#include "mvm/Allocator.h" #include "mvm/JIT.h" -#include "mvm/UTF8.h" - -#include "JavaCompiler.h" - -namespace llvm { - class BasicBlock; - class Constant; - class ConstantInt; - class Function; - class FunctionPassManager; - class FunctionType; - class GlobalVariable; - class GCFunctionInfo; - class GVMaterializer; - class MDNode; - class Module; - class Type; - class Value; -} namespace j3 { -class ArrayObject; -class Attribut; -class CommonClass; -class Class; -class ClassArray; -class ClassPrimitive; -class JavaConstantPool; -class JavaField; -class JavaMethod; -class JavaObject; -class JavaString; -class JavaVirtualTable; -class Jnjvm; -class JnjvmClassLoader; -class JnjvmModule; -class Typedef; -class Signdef; - -using mvm::UTF8; - -class LLVMAssessorInfo { -public: - const llvm::Type* llvmType; - const llvm::Type* llvmTypePtr; - uint8_t logSizeInBytesConstant; - - static void initialise(); - static std::map AssessorInfo; - -}; - - -class LLVMClassInfo : public mvm::JITInfo { - friend class JavaAOTCompiler; - friend class JavaJITCompiler; - friend class JavaLLVMCompiler; -private: - Class* classDef; - /// virtualSizeLLVM - The LLVM constant size of instances of this class. - /// - llvm::Constant* virtualSizeConstant; - /// virtualType - The LLVM type of instance of this class. - /// - const llvm::Type * virtualType; - - /// staticType - The LLVM type of the static instance of this class. - /// - const llvm::Type * staticType; -public: - - llvm::Value* getVirtualSize(); - const llvm::Type* getVirtualType(); - const llvm::Type* getStaticType(); - - LLVMClassInfo(Class* cl) : - classDef(cl), - virtualSizeConstant(0), - virtualType(0), - staticType(0) {} - - virtual void clear() { - virtualType = 0; - staticType = 0; - virtualSizeConstant = 0; - } -}; - -class LLVMMethodInfo : public mvm::JITInfo { -private: - JavaMethod* methodDef; - - llvm::Function* methodFunction; - llvm::Constant* offsetConstant; - const llvm::FunctionType* functionType; - llvm::MDNode* DbgSubprogram; - - -public: - llvm::GCFunctionInfo* GCInfo; - llvm::Function* getMethod(); - llvm::Constant* getOffset(); - const llvm::FunctionType* getFunctionType(); - - LLVMMethodInfo(JavaMethod* M) : methodDef(M), methodFunction(0), - offsetConstant(0), functionType(0), DbgSubprogram(0), GCInfo(0) {} - - void setDbgSubprogram(llvm::MDNode* node) { DbgSubprogram = node; } - llvm::MDNode* getDbgSubprogram() { return DbgSubprogram; } - - virtual void clear() { - GCInfo = 0; - methodFunction = 0; - offsetConstant = 0; - functionType = 0; - DbgSubprogram = 0; - } -}; - - -class LLVMFieldInfo : public mvm::JITInfo { -private: - JavaField* fieldDef; - - llvm::Constant* offsetConstant; - -public: - llvm::Constant* getOffset(); - - LLVMFieldInfo(JavaField* F) : - fieldDef(F), - offsetConstant(0) {} - - virtual void clear() { - offsetConstant = 0; - } -}; - -class LLVMSignatureInfo : public mvm::JITInfo { -private: - const llvm::FunctionType* staticType; - const llvm::FunctionType* virtualType; - const llvm::FunctionType* nativeType; - - const llvm::FunctionType* virtualBufType; - const llvm::FunctionType* staticBufType; - - const llvm::PointerType* staticPtrType; - const llvm::PointerType* virtualPtrType; - const llvm::PointerType* nativePtrType; - - llvm::Function* virtualBufFunction; - llvm::Function* virtualAPFunction; - llvm::Function* staticBufFunction; - llvm::Function* staticAPFunction; - - llvm::Function* staticStubFunction; - llvm::Function* specialStubFunction; - llvm::Function* virtualStubFunction; - - Signdef* signature; - - llvm::Function* createFunctionCallBuf(bool virt); - llvm::Function* createFunctionCallAP(bool virt); - llvm::Function* createFunctionStub(bool special, bool virt); - - -public: - const llvm::FunctionType* getVirtualType(); - const llvm::FunctionType* getStaticType(); - const llvm::FunctionType* getNativeType(); - - const llvm::FunctionType* getVirtualBufType(); - const llvm::FunctionType* getStaticBufType(); - - const llvm::PointerType* getStaticPtrType(); - const llvm::PointerType* getNativePtrType(); - const llvm::PointerType* getVirtualPtrType(); - - llvm::Function* getVirtualBuf(); - llvm::Function* getVirtualAP(); - llvm::Function* getStaticBuf(); - llvm::Function* getStaticAP(); - - llvm::Function* getStaticStub(); - llvm::Function* getSpecialStub(); - llvm::Function* getVirtualStub(); - - LLVMSignatureInfo(Signdef* sign) : - staticType(0), - virtualType(0), - nativeType(0), - virtualBufType(0), - staticBufType(0), - staticPtrType(0), - virtualPtrType(0), - nativePtrType(0), - virtualBufFunction(0), - virtualAPFunction(0), - staticBufFunction(0), - staticAPFunction(0), - staticStubFunction(0), - specialStubFunction(0), - virtualStubFunction(0), - signature(sign) {} - -}; - class JnjvmModule : public mvm::MvmModule { public: Added: vmkit/trunk/include/j3/LLVMInfo.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMInfo.h?rev=96191&view=auto ============================================================================== --- vmkit/trunk/include/j3/LLVMInfo.h (added) +++ vmkit/trunk/include/j3/LLVMInfo.h Sun Feb 14 15:43:54 2010 @@ -0,0 +1,199 @@ +//===------------- LLVMInfo.h - Compiler info for LLVM --------------------===// +// +// The VMKit project +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef J3_LLVM_INFO_H +#define J3_LLVM_INFO_H + +namespace llvm { + class Constant; + class Function; + class FunctionType; + class GCFunctionInfo; + class MDNode; + class Module; + class Type; + class Value; +} + +namespace j3 { + +class Class; +class JavaField; +class JavaMethod; +class Signdef; + +class LLVMAssessorInfo { +public: + const llvm::Type* llvmType; + const llvm::Type* llvmTypePtr; + uint8_t logSizeInBytesConstant; + + static void initialise(); + static std::map AssessorInfo; + +}; + +class LLVMClassInfo : public mvm::JITInfo { + friend class JavaAOTCompiler; + friend class JavaJITCompiler; + friend class JavaLLVMCompiler; +private: + Class* classDef; + /// virtualSizeLLVM - The LLVM constant size of instances of this class. + /// + llvm::Constant* virtualSizeConstant; + /// virtualType - The LLVM type of instance of this class. + /// + const llvm::Type * virtualType; + + /// staticType - The LLVM type of the static instance of this class. + /// + const llvm::Type * staticType; +public: + + llvm::Value* getVirtualSize(); + const llvm::Type* getVirtualType(); + const llvm::Type* getStaticType(); + + LLVMClassInfo(Class* cl) : + classDef(cl), + virtualSizeConstant(0), + virtualType(0), + staticType(0) {} + + virtual void clear() { + virtualType = 0; + staticType = 0; + virtualSizeConstant = 0; + } +}; + +class LLVMMethodInfo : public mvm::JITInfo { +private: + JavaMethod* methodDef; + + llvm::Function* methodFunction; + llvm::Constant* offsetConstant; + const llvm::FunctionType* functionType; + llvm::MDNode* DbgSubprogram; + + +public: + llvm::GCFunctionInfo* GCInfo; + llvm::Function* getMethod(); + llvm::Constant* getOffset(); + const llvm::FunctionType* getFunctionType(); + + LLVMMethodInfo(JavaMethod* M) : methodDef(M), methodFunction(0), + offsetConstant(0), functionType(0), DbgSubprogram(0), GCInfo(0) {} + + void setDbgSubprogram(llvm::MDNode* node) { DbgSubprogram = node; } + llvm::MDNode* getDbgSubprogram() { return DbgSubprogram; } + + virtual void clear() { + GCInfo = 0; + methodFunction = 0; + offsetConstant = 0; + functionType = 0; + DbgSubprogram = 0; + } +}; + + +class LLVMFieldInfo : public mvm::JITInfo { +private: + JavaField* fieldDef; + + llvm::Constant* offsetConstant; + +public: + llvm::Constant* getOffset(); + + LLVMFieldInfo(JavaField* F) : + fieldDef(F), + offsetConstant(0) {} + + virtual void clear() { + offsetConstant = 0; + } +}; + +class LLVMSignatureInfo : public mvm::JITInfo { +private: + const llvm::FunctionType* staticType; + const llvm::FunctionType* virtualType; + const llvm::FunctionType* nativeType; + + const llvm::FunctionType* virtualBufType; + const llvm::FunctionType* staticBufType; + + const llvm::PointerType* staticPtrType; + const llvm::PointerType* virtualPtrType; + const llvm::PointerType* nativePtrType; + + llvm::Function* virtualBufFunction; + llvm::Function* virtualAPFunction; + llvm::Function* staticBufFunction; + llvm::Function* staticAPFunction; + + llvm::Function* staticStubFunction; + llvm::Function* specialStubFunction; + llvm::Function* virtualStubFunction; + + Signdef* signature; + + llvm::Function* createFunctionCallBuf(bool virt); + llvm::Function* createFunctionCallAP(bool virt); + llvm::Function* createFunctionStub(bool special, bool virt); + + +public: + const llvm::FunctionType* getVirtualType(); + const llvm::FunctionType* getStaticType(); + const llvm::FunctionType* getNativeType(); + + const llvm::FunctionType* getVirtualBufType(); + const llvm::FunctionType* getStaticBufType(); + + const llvm::PointerType* getStaticPtrType(); + const llvm::PointerType* getNativePtrType(); + const llvm::PointerType* getVirtualPtrType(); + + llvm::Function* getVirtualBuf(); + llvm::Function* getVirtualAP(); + llvm::Function* getStaticBuf(); + llvm::Function* getStaticAP(); + + llvm::Function* getStaticStub(); + llvm::Function* getSpecialStub(); + llvm::Function* getVirtualStub(); + + LLVMSignatureInfo(Signdef* sign) : + staticType(0), + virtualType(0), + nativeType(0), + virtualBufType(0), + staticBufType(0), + staticPtrType(0), + virtualPtrType(0), + nativePtrType(0), + virtualBufFunction(0), + virtualAPFunction(0), + staticBufFunction(0), + staticAPFunction(0), + staticStubFunction(0), + specialStubFunction(0), + virtualStubFunction(0), + signature(sign) {} + +}; + +} // end namespace j3 + +#endif Modified: vmkit/trunk/lib/J3/Compiler/JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JITInfo.cpp?rev=96191&r1=96190&r2=96191&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JITInfo.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JITInfo.cpp Sun Feb 14 15:43:54 2010 @@ -28,7 +28,8 @@ #include "Jnjvm.h" #include "Reader.h" -#include "j3/JnjvmModule.h" +#include "j3/JavaCompiler.h" +#include "j3/LLVMInfo.h" #include From nicolas.geoffray at lip6.fr Sun Feb 14 13:46:10 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 21:46:10 -0000 Subject: [vmkit-commits] [vmkit] r96192 - in /vmkit/trunk/lib/J3/Compiler: JITInfo.cpp LLVMInfo.cpp Message-ID: <201002142146.o1ELkA5X002637@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 15:46:09 2010 New Revision: 96192 URL: http://llvm.org/viewvc/llvm-project?rev=96192&view=rev Log: Rename file. Added: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp - copied, changed from r96191, vmkit/trunk/lib/J3/Compiler/JITInfo.cpp Removed: vmkit/trunk/lib/J3/Compiler/JITInfo.cpp Removed: vmkit/trunk/lib/J3/Compiler/JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JITInfo.cpp?rev=96191&view=auto ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JITInfo.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JITInfo.cpp (removed) @@ -1,833 +0,0 @@ -//===--------- JnjvmModule.cpp - Definition of a Jnjvm module -------------===// -// -// The VMKit project -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/BasicBlock.h" -#include "llvm/CallingConv.h" -#include "llvm/Constants.h" -#include "llvm/Instructions.h" -#include "llvm/Module.h" -#include "llvm/ExecutionEngine/ExecutionEngine.h" -#include "llvm/Support/MutexGuard.h" -#include "llvm/Target/TargetData.h" - - -#include "mvm/JIT.h" - -#include "JavaConstantPool.h" -#include "JavaJIT.h" -#include "JavaString.h" -#include "JavaThread.h" -#include "JavaTypes.h" -#include "JavaUpcalls.h" -#include "Jnjvm.h" -#include "Reader.h" - -#include "j3/JavaCompiler.h" -#include "j3/LLVMInfo.h" - -#include - -using namespace j3; -using namespace llvm; - -const Type* LLVMClassInfo::getVirtualType() { - if (!virtualType) { - std::vector fields; - const TargetData* targetData = JnjvmModule::TheTargetData; - const StructLayout* sl = 0; - 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); - fields.push_back(Ty); - - for (uint32 i = 0; i < classDef->nbVirtualFields; ++i) { - JavaField& field = classDef->virtualFields[i]; - field.num = i + 1; - Typedef* type = field.getSignature(); - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); - fields.push_back(LAI.llvmType); - } - - - structType = StructType::get(context, fields, false); - virtualType = PointerType::getUnqual(structType); - sl = targetData->getStructLayout(structType); - - } else { - virtualType = JnjvmModule::JavaObjectType; - structType = dyn_cast(virtualType->getContainedType(0)); - sl = targetData->getStructLayout(structType); - - } - - - for (uint32 i = 0; i < classDef->nbVirtualFields; ++i) { - JavaField& field = classDef->virtualFields[i]; - field.ptrOffset = sl->getElementOffset(i + 1); - } - - uint64 size = JnjvmModule::getTypeSize(structType); - classDef->virtualSize = (uint32)size; - classDef->alignment = sl->getAlignment(); - virtualSizeConstant = ConstantInt::get(Type::getInt32Ty(context), size); - - Mod->makeVT(classDef); - Mod->makeIMT(classDef); - } - - return virtualType; -} - -const Type* LLVMClassInfo::getStaticType() { - - 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]; - field.num = i; - Typedef* type = field.getSignature(); - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); - fields.push_back(LAI.llvmType); - } - - StructType* structType = StructType::get(context, fields, false); - staticType = PointerType::getUnqual(structType); - const TargetData* targetData = JnjvmModule::TheTargetData; - const StructLayout* sl = targetData->getStructLayout(structType); - - for (uint32 i = 0; i < classDef->nbStaticFields; ++i) { - JavaField& field = classDef->staticFields[i]; - field.ptrOffset = sl->getElementOffset(i); - } - - uint64 size = JnjvmModule::getTypeSize(structType); - cl->staticSize = size; - } - return staticType; -} - - -Value* LLVMClassInfo::getVirtualSize() { - if (!virtualSizeConstant) { - getVirtualType(); - assert(virtualSizeConstant && "No size for a class?"); - } - return virtualSizeConstant; -} - -Function* LLVMMethodInfo::getMethod() { - if (!methodFunction) { - JnjvmClassLoader* JCL = methodDef->classDef->classLoader; - JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)JCL->getCompiler(); - if (Mod->emitFunctionName()) { - - const UTF8* jniConsClName = methodDef->classDef->name; - const UTF8* jniConsName = methodDef->name; - const UTF8* jniConsType = methodDef->type; - sint32 clen = jniConsClName->size; - sint32 mnlen = jniConsName->size; - sint32 mtlen = jniConsType->size; - - char* buf = (char*)alloca(3 + JNI_NAME_PRE_LEN + 1 + - ((mnlen + clen + mtlen) << 3)); - - bool j3 = false; - if (isNative(methodDef->access)) { - // Verify if it's defined by JnJVM - JCL->nativeLookup(methodDef, j3, buf); - } - - if (!j3) { - methodDef->jniConsFromMethOverloaded(buf + 1); - memcpy(buf, "JnJVM", 5); - } - - methodFunction = Mod->getLLVMModule()->getFunction(buf); - if (!methodFunction) { - methodFunction = Function::Create(getFunctionType(), - GlobalValue::ExternalWeakLinkage, buf, - Mod->getLLVMModule()); - } else { - assert(methodFunction->getFunctionType() == getFunctionType() && - "Type mismatch"); - if (methodFunction->isDeclaration()) { - methodFunction->setLinkage(GlobalValue::ExternalWeakLinkage); - } - } - - } else { - - methodFunction = Function::Create(getFunctionType(), - GlobalValue::ExternalWeakLinkage, - "", Mod->getLLVMModule()); - - } - - if (Mod->useCooperativeGC()) { - methodFunction->setGC("vmkit"); - } - - Mod->functions.insert(std::make_pair(methodFunction, methodDef)); - } - return methodFunction; -} - -const FunctionType* LLVMMethodInfo::getFunctionType() { - if (!functionType) { - Signdef* sign = methodDef->getSignature(); - LLVMSignatureInfo* LSI = JavaLLVMCompiler::getSignatureInfo(sign); - assert(LSI); - if (isStatic(methodDef->access)) { - functionType = LSI->getStaticType(); - } else { - functionType = LSI->getVirtualType(); - } - } - return functionType; -} - -Constant* LLVMMethodInfo::getOffset() { - 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::getInt32Ty(context), - methodDef->offset); - } - return offsetConstant; -} - -Constant* LLVMFieldInfo::getOffset() { - 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); - } else { - Mod->resolveVirtualClass(fieldDef->classDef); - } - - offsetConstant = ConstantInt::get(Type::getInt32Ty(context), fieldDef->num); - } - return offsetConstant; -} - -const llvm::FunctionType* LLVMSignatureInfo::getVirtualType() { - if (!virtualType) { - // Lock here because we are called by arbitrary code - mvm::MvmModule::protectIR(); - std::vector llvmArgs; - uint32 size = signature->nbArguments; - Typedef* const* arguments = signature->getArgumentsType(); - - llvmArgs.push_back(JnjvmModule::JavaObjectType); - - for (uint32 i = 0; i < size; ++i) { - Typedef* type = arguments[i]; - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); - llvmArgs.push_back(LAI.llvmType); - } - -#if defined(ISOLATE_SHARING) - llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool -#endif - - LLVMAssessorInfo& LAI = - JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); - virtualType = FunctionType::get(LAI.llvmType, llvmArgs, false); - mvm::MvmModule::unprotectIR(); - } - return virtualType; -} - -const llvm::FunctionType* LLVMSignatureInfo::getStaticType() { - if (!staticType) { - // Lock here because we are called by arbitrary code - mvm::MvmModule::protectIR(); - std::vector llvmArgs; - uint32 size = signature->nbArguments; - Typedef* const* arguments = signature->getArgumentsType(); - - for (uint32 i = 0; i < size; ++i) { - Typedef* type = arguments[i]; - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); - llvmArgs.push_back(LAI.llvmType); - } - -#if defined(ISOLATE_SHARING) - llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool -#endif - - LLVMAssessorInfo& LAI = - JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); - staticType = FunctionType::get(LAI.llvmType, llvmArgs, false); - mvm::MvmModule::unprotectIR(); - } - return staticType; -} - -const llvm::FunctionType* LLVMSignatureInfo::getNativeType() { - if (!nativeType) { - // Lock here because we are called by arbitrary code - mvm::MvmModule::protectIR(); - std::vector llvmArgs; - uint32 size = signature->nbArguments; - Typedef* const* arguments = signature->getArgumentsType(); - - const llvm::Type* Ty = PointerType::getUnqual(JnjvmModule::JavaObjectType); - - llvmArgs.push_back(mvm::MvmModule::ptrType); // JNIEnv - llvmArgs.push_back(Ty); // Class - - for (uint32 i = 0; i < size; ++i) { - Typedef* type = arguments[i]; - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); - const llvm::Type* Ty = LAI.llvmType; - if (Ty == JnjvmModule::JavaObjectType) { - llvmArgs.push_back(LAI.llvmTypePtr); - } else { - llvmArgs.push_back(LAI.llvmType); - } - } - -#if defined(ISOLATE_SHARING) - llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool -#endif - - LLVMAssessorInfo& LAI = - JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); - const llvm::Type* RetType = LAI.llvmType == JnjvmModule::JavaObjectType ? - LAI.llvmTypePtr : LAI.llvmType; - nativeType = FunctionType::get(RetType, llvmArgs, false); - mvm::MvmModule::unprotectIR(); - } - return nativeType; -} - - -Function* LLVMSignatureInfo::createFunctionCallBuf(bool virt) { - - std::vector Args; - - JavaLLVMCompiler* Mod = - (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); - LLVMContext& context = Mod->getLLVMModule()->getContext(); - JnjvmModule& Intrinsics = *Mod->getIntrinsics(); - Function* res = 0; - if (Mod->isStaticCompiling()) { - const char* type = virt ? "virtual_buf" : "static_buf"; - char* buf = (char*)alloca((signature->keyName->size << 1) + 1 + 11); - signature->nativeName(buf, type); - res = Function::Create(virt ? getVirtualBufType() : getStaticBufType(), - GlobalValue::ExternalLinkage, buf, - Mod->getLLVMModule()); - - - } else { - res = Function::Create(virt ? getVirtualBufType() : getStaticBufType(), - GlobalValue::ExternalLinkage, "", - Mod->getLLVMModule()); - } - - BasicBlock* currentBlock = BasicBlock::Create(context, "enter", res); - Function::arg_iterator i = res->arg_begin(); - Value *obj, *ptr, *func; -#if defined(ISOLATE_SHARING) - Value* ctp = i; -#endif - ++i; - func = i; - ++i; - if (virt) { - obj = i; - ++i; - Args.push_back(obj); - } - ptr = i; - - Typedef* const* arguments = signature->getArgumentsType(); - for (uint32 i = 0; i < signature->nbArguments; ++i) { - - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(arguments[i]); - Value* arg = new LoadInst(ptr, "", currentBlock); - - if (arguments[i]->isReference()) { - arg = new IntToPtrInst(arg, Intrinsics.JavaObjectType, "", currentBlock); - Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, - Intrinsics.JavaObjectNullConstant, - arg, ""); - BasicBlock* endBlock = BasicBlock::Create(context, "end", res); - BasicBlock* loadBlock = BasicBlock::Create(context, "load", res); - PHINode* node = PHINode::Create(Intrinsics.JavaObjectType, "", - endBlock); - node->addIncoming(Intrinsics.JavaObjectNullConstant, currentBlock); - BranchInst::Create(endBlock, loadBlock, cmp, currentBlock); - currentBlock = loadBlock; - arg = new BitCastInst(arg, - PointerType::getUnqual(Intrinsics.JavaObjectType), - "", currentBlock); - arg = new LoadInst(arg, "", false, currentBlock); - node->addIncoming(arg, currentBlock); - BranchInst::Create(endBlock, currentBlock); - currentBlock = endBlock; - arg = node; - } else if (arguments[i]->isFloat()) { - arg = new TruncInst(arg, LLVMAssessorInfo::AssessorInfo[I_INT].llvmType, - "", currentBlock); - arg = new BitCastInst(arg, LAI.llvmType, "", currentBlock); - } else if (arguments[i]->isDouble()) { - arg = new BitCastInst(arg, LAI.llvmType, "", currentBlock); - } else if (!arguments[i]->isLong()){ - arg = new TruncInst(arg, LAI.llvmType, "", currentBlock); - } - Args.push_back(arg); - ptr = GetElementPtrInst::Create(ptr, Mod->getIntrinsics()->constantOne,"", - currentBlock); - } - -#if defined(ISOLATE_SHARING) - Args.push_back(ctp); -#endif - - Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", - currentBlock); - if (!signature->getReturnType()->isVoid()) - ReturnInst::Create(context, val, currentBlock); - else - ReturnInst::Create(context, currentBlock); - - return res; -} - -Function* LLVMSignatureInfo::createFunctionCallAP(bool virt) { - - std::vector Args; - - JavaLLVMCompiler* Mod = - (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); - JnjvmModule& Intrinsics = *Mod->getIntrinsics(); - std::string name; - if (Mod->isStaticCompiling()) { - name += UTF8Buffer(signature->keyName).cString(); - name += virt ? "virtual_ap" : "static_ap"; - } else { - name = ""; - } - - Function* res = Function::Create(virt ? getVirtualBufType() : - getStaticBufType(), - GlobalValue::InternalLinkage, name, - Mod->getLLVMModule()); - LLVMContext& context = Mod->getLLVMModule()->getContext(); - - BasicBlock* currentBlock = BasicBlock::Create(context, "enter", res); - Function::arg_iterator i = res->arg_begin(); - Value *obj, *ap, *func; -#if defined(ISOLATE_SHARING) - Value* ctp = i; -#endif - ++i; - func = i; - ++i; - if (virt) { - obj = i; - Args.push_back(obj); - ++i; - } - ap = i; - - Typedef* const* arguments = signature->getArgumentsType(); - for (uint32 i = 0; i < signature->nbArguments; ++i) { - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(arguments[i]); - Value* arg = new VAArgInst(ap, LAI.llvmType, "", currentBlock); - if (arguments[i]->isReference()) { - arg = new IntToPtrInst(arg, Intrinsics.JavaObjectType, "", currentBlock); - Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, - Intrinsics.JavaObjectNullConstant, - arg, ""); - BasicBlock* endBlock = BasicBlock::Create(context, "end", res); - BasicBlock* loadBlock = BasicBlock::Create(context, "load", res); - PHINode* node = PHINode::Create(Intrinsics.JavaObjectType, "", - endBlock); - node->addIncoming(Intrinsics.JavaObjectNullConstant, currentBlock); - BranchInst::Create(endBlock, loadBlock, cmp, currentBlock); - currentBlock = loadBlock; - arg = new BitCastInst(arg, - PointerType::getUnqual(Intrinsics.JavaObjectType), - "", currentBlock); - arg = new LoadInst(arg, "", false, currentBlock); - node->addIncoming(arg, currentBlock); - BranchInst::Create(endBlock, currentBlock); - currentBlock = endBlock; - arg = node; - } - Args.push_back(arg); - } - -#if defined(ISOLATE_SHARING) - Args.push_back(ctp); -#endif - - Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", - currentBlock); - if (!signature->getReturnType()->isVoid()) - ReturnInst::Create(context, val, currentBlock); - else - ReturnInst::Create(context, currentBlock); - - return res; -} - -Function* LLVMSignatureInfo::createFunctionStub(bool special, bool virt) { - - std::vector Args; - std::vector FunctionArgs; - - JavaLLVMCompiler* Mod = - (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); - JnjvmModule& Intrinsics = *Mod->getIntrinsics(); - std::string name; - if (Mod->isStaticCompiling()) { - name += UTF8Buffer(signature->keyName).cString(); - name += virt ? "virtual_stub" : special ? "special_stub" : "static_stub"; - } else { - name = ""; - } - - Function* stub = Function::Create((virt || special) ? getVirtualType() : - getStaticType(), - GlobalValue::InternalLinkage, name, - Mod->getLLVMModule()); - LLVMContext& context = Mod->getLLVMModule()->getContext(); - - BasicBlock* currentBlock = BasicBlock::Create(context, "enter", stub); - BasicBlock* endBlock = BasicBlock::Create(context, "end", stub); - BasicBlock* callBlock = BasicBlock::Create(context, "call", stub); - PHINode* node = NULL; - if (!signature->getReturnType()->isVoid()) { - node = PHINode::Create(stub->getReturnType(), "", endBlock); - } - - Function::arg_iterator arg = stub->arg_begin(); - Value *obj = NULL; - if (virt) { - obj = arg; - Args.push_back(obj); - } - - for (; arg != stub->arg_end() ; ++arg) { - FunctionArgs.push_back(arg); - if (Mod->useCooperativeGC()) { - if (arg->getType() == Intrinsics.JavaObjectType) { - Value* GCArgs[2] = { - new BitCastInst(arg, Intrinsics.ptrPtrType, "", currentBlock), - Intrinsics.constantPtrNull - }; - - CallInst::Create(Intrinsics.llvm_gc_gcroot, GCArgs, GCArgs + 2, "", - currentBlock); - } - } - } - - Value* val = CallInst::Create(virt ? Intrinsics.ResolveVirtualStubFunction : - special ? Intrinsics.ResolveSpecialStubFunction: - Intrinsics.ResolveStaticStubFunction, - Args.begin(), Args.end(), "", currentBlock); - - Constant* nullValue = Constant::getNullValue(val->getType()); - Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, - nullValue, val, ""); - BranchInst::Create(endBlock, callBlock, cmp, currentBlock); - if (node) node->addIncoming(Constant::getNullValue(node->getType()), - currentBlock); - - currentBlock = callBlock; - Value* Func = new BitCastInst(val, stub->getType(), "", currentBlock); - Value* res = CallInst::Create(Func, FunctionArgs.begin(), FunctionArgs.end(), - "", currentBlock); - if (node) node->addIncoming(res, currentBlock); - BranchInst::Create(endBlock, currentBlock); - - currentBlock = endBlock; - if (node) { - ReturnInst::Create(context, node, currentBlock); - } else { - ReturnInst::Create(context, currentBlock); - } - - return stub; -} - -const PointerType* LLVMSignatureInfo::getStaticPtrType() { - if (!staticPtrType) { - staticPtrType = PointerType::getUnqual(getStaticType()); - } - return staticPtrType; -} - -const PointerType* LLVMSignatureInfo::getVirtualPtrType() { - if (!virtualPtrType) { - virtualPtrType = PointerType::getUnqual(getVirtualType()); - } - return virtualPtrType; -} - -const PointerType* LLVMSignatureInfo::getNativePtrType() { - if (!nativePtrType) { - nativePtrType = PointerType::getUnqual(getNativeType()); - } - return nativePtrType; -} - - -const FunctionType* LLVMSignatureInfo::getVirtualBufType() { - if (!virtualBufType) { - // Lock here because we are called by arbitrary code - mvm::MvmModule::protectIR(); - std::vector Args; - Args.push_back(JnjvmModule::ConstantPoolType); // ctp - Args.push_back(getVirtualPtrType()); - Args.push_back(JnjvmModule::JavaObjectType); - Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr); - LLVMAssessorInfo& LAI = - JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); - virtualBufType = FunctionType::get(LAI.llvmType, Args, false); - mvm::MvmModule::unprotectIR(); - } - return virtualBufType; -} - -const FunctionType* LLVMSignatureInfo::getStaticBufType() { - if (!staticBufType) { - // Lock here because we are called by arbitrary code - mvm::MvmModule::protectIR(); - std::vector Args; - Args.push_back(JnjvmModule::ConstantPoolType); // ctp - Args.push_back(getStaticPtrType()); - Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr); - LLVMAssessorInfo& LAI = - JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); - staticBufType = FunctionType::get(LAI.llvmType, Args, false); - mvm::MvmModule::unprotectIR(); - } - return staticBufType; -} - -Function* LLVMSignatureInfo::getVirtualBuf() { - // Lock here because we are called by arbitrary code. Also put that here - // because we are waiting on virtualBufFunction to have an address. - mvm::MvmModule::protectIR(); - if (!virtualBufFunction) { - virtualBufFunction = createFunctionCallBuf(true); - if (!signature->initialLoader->getCompiler()->isStaticCompiling()) { - signature->setVirtualCallBuf((intptr_t) - mvm::MvmModule::executionEngine->getPointerToGlobal(virtualBufFunction)); - // Now that it's compiled, we don't need the IR anymore - virtualBufFunction->deleteBody(); - } - } - mvm::MvmModule::unprotectIR(); - return virtualBufFunction; -} - -Function* LLVMSignatureInfo::getVirtualAP() { - // Lock here because we are called by arbitrary code. Also put that here - // because we are waiting on virtualAPFunction to have an address. - mvm::MvmModule::protectIR(); - if (!virtualAPFunction) { - virtualAPFunction = createFunctionCallAP(true); - if (!signature->initialLoader->getCompiler()->isStaticCompiling()) { - signature->setVirtualCallAP((intptr_t) - mvm::MvmModule::executionEngine->getPointerToGlobal(virtualAPFunction)); - // Now that it's compiled, we don't need the IR anymore - virtualAPFunction->deleteBody(); - } - } - mvm::MvmModule::unprotectIR(); - return virtualAPFunction; -} - -Function* LLVMSignatureInfo::getStaticBuf() { - // Lock here because we are called by arbitrary code. Also put that here - // because we are waiting on staticBufFunction to have an address. - mvm::MvmModule::protectIR(); - if (!staticBufFunction) { - staticBufFunction = createFunctionCallBuf(false); - if (!signature->initialLoader->getCompiler()->isStaticCompiling()) { - signature->setStaticCallBuf((intptr_t) - mvm::MvmModule::executionEngine->getPointerToGlobal(staticBufFunction)); - // Now that it's compiled, we don't need the IR anymore - staticBufFunction->deleteBody(); - } - } - mvm::MvmModule::unprotectIR(); - return staticBufFunction; -} - -Function* LLVMSignatureInfo::getStaticAP() { - // Lock here because we are called by arbitrary code. Also put that here - // because we are waiting on staticAPFunction to have an address. - mvm::MvmModule::protectIR(); - if (!staticAPFunction) { - staticAPFunction = createFunctionCallAP(false); - if (!signature->initialLoader->getCompiler()->isStaticCompiling()) { - signature->setStaticCallAP((intptr_t) - mvm::MvmModule::executionEngine->getPointerToGlobal(staticAPFunction)); - // Now that it's compiled, we don't need the IR anymore - staticAPFunction->deleteBody(); - } - } - mvm::MvmModule::unprotectIR(); - return staticAPFunction; -} - -Function* LLVMSignatureInfo::getStaticStub() { - // Lock here because we are called by arbitrary code. Also put that here - // because we are waiting on staticStubFunction to have an address. - mvm::MvmModule::protectIR(); - if (!staticStubFunction) { - staticStubFunction = createFunctionStub(false, false); - if (!signature->initialLoader->getCompiler()->isStaticCompiling()) { - signature->setStaticCallStub((intptr_t) - mvm::MvmModule::executionEngine->getPointerToGlobal(staticStubFunction)); - // Now that it's compiled, we don't need the IR anymore - staticStubFunction->deleteBody(); - } - } - mvm::MvmModule::unprotectIR(); - return staticStubFunction; -} - -Function* LLVMSignatureInfo::getSpecialStub() { - // Lock here because we are called by arbitrary code. Also put that here - // because we are waiting on specialStubFunction to have an address. - mvm::MvmModule::protectIR(); - if (!specialStubFunction) { - specialStubFunction = createFunctionStub(true, false); - if (!signature->initialLoader->getCompiler()->isStaticCompiling()) { - signature->setSpecialCallStub((intptr_t) - mvm::MvmModule::executionEngine->getPointerToGlobal(specialStubFunction)); - // Now that it's compiled, we don't need the IR anymore - specialStubFunction->deleteBody(); - } - } - mvm::MvmModule::unprotectIR(); - return specialStubFunction; -} - -Function* LLVMSignatureInfo::getVirtualStub() { - // Lock here because we are called by arbitrary code. Also put that here - // because we are waiting on virtualStubFunction to have an address. - mvm::MvmModule::protectIR(); - if (!virtualStubFunction) { - virtualStubFunction = createFunctionStub(false, true); - if (!signature->initialLoader->getCompiler()->isStaticCompiling()) { - signature->setVirtualCallStub((intptr_t) - mvm::MvmModule::executionEngine->getPointerToGlobal(virtualStubFunction)); - // Now that it's compiled, we don't need the IR anymore - virtualStubFunction->deleteBody(); - } - } - mvm::MvmModule::unprotectIR(); - return virtualStubFunction; -} - -void LLVMAssessorInfo::initialise() { - AssessorInfo[I_VOID].llvmType = Type::getVoidTy(getGlobalContext()); - AssessorInfo[I_VOID].llvmTypePtr = 0; - AssessorInfo[I_VOID].logSizeInBytesConstant = 0; - - 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::getInt8Ty(getGlobalContext()); - AssessorInfo[I_BYTE].llvmTypePtr = - PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())); - AssessorInfo[I_BYTE].logSizeInBytesConstant = 0; - - 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::getInt16Ty(getGlobalContext()); - AssessorInfo[I_CHAR].llvmTypePtr = - PointerType::getUnqual(Type::getInt16Ty(getGlobalContext())); - AssessorInfo[I_CHAR].logSizeInBytesConstant = 1; - - 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::getFloatTy(getGlobalContext()); - AssessorInfo[I_FLOAT].llvmTypePtr = - PointerType::getUnqual(Type::getFloatTy(getGlobalContext())); - AssessorInfo[I_FLOAT].logSizeInBytesConstant = 2; - - 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::getDoubleTy(getGlobalContext()); - AssessorInfo[I_DOUBLE].llvmTypePtr = - PointerType::getUnqual(Type::getDoubleTy(getGlobalContext())); - AssessorInfo[I_DOUBLE].logSizeInBytesConstant = 3; - - AssessorInfo[I_TAB].llvmType = JnjvmModule::JavaObjectType; - AssessorInfo[I_TAB].llvmTypePtr = - PointerType::getUnqual(JnjvmModule::JavaObjectType); - AssessorInfo[I_TAB].logSizeInBytesConstant = sizeof(JavaObject*) == 8 ? 3 : 2; - - AssessorInfo[I_REF].llvmType = JnjvmModule::JavaObjectType; - AssessorInfo[I_REF].llvmTypePtr = - PointerType::getUnqual(JnjvmModule::JavaObjectType); - AssessorInfo[I_REF].logSizeInBytesConstant = sizeof(JavaObject*) == 8 ? 3 : 2; -} - -std::map LLVMAssessorInfo::AssessorInfo; - -LLVMAssessorInfo& JavaLLVMCompiler::getTypedefInfo(const Typedef* type) { - return LLVMAssessorInfo::AssessorInfo[type->getKey()->elements[0]]; -} - -LLVMSignatureInfo* JavaLLVMCompiler::getSignatureInfo(Signdef* sign) { - return sign->getInfo(); -} - -LLVMClassInfo* JavaLLVMCompiler::getClassInfo(Class* cl) { - return cl->getInfo(); -} - -LLVMFieldInfo* JavaLLVMCompiler::getFieldInfo(JavaField* field) { - return field->getInfo(); -} - -LLVMMethodInfo* JavaLLVMCompiler::getMethodInfo(JavaMethod* method) { - return method->getInfo(); -} Copied: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (from r96191, vmkit/trunk/lib/J3/Compiler/JITInfo.cpp) URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?p2=vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp&p1=vmkit/trunk/lib/J3/Compiler/JITInfo.cpp&r1=96191&r2=96192&rev=96192&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JITInfo.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Sun Feb 14 15:46:09 2010 @@ -1,4 +1,4 @@ -//===--------- JnjvmModule.cpp - Definition of a Jnjvm module -------------===// +//===--- LLVMInfo.cpp - Implementation of LLVM info objects for J3---------===// // // The VMKit project // From nicolas.geoffray at lip6.fr Sun Feb 14 14:07:43 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 22:07:43 -0000 Subject: [vmkit-commits] [vmkit] r96194 - in /vmkit/trunk: include/j3/ lib/J3/Compiler/ tools/vmjc/ tools/vmkit/ Message-ID: <201002142207.o1EM7hAR003549@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 16:07:42 2010 New Revision: 96194 URL: http://llvm.org/viewvc/llvm-project?rev=96194&view=rev Log: Refactoring. No functionality change. Added: vmkit/trunk/include/j3/J3Intrinsics.h - copied, changed from r96191, vmkit/trunk/include/j3/JnjvmModule.h vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp - copied, changed from r96189, vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp Removed: vmkit/trunk/include/j3/JnjvmModule.h vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp vmkit/trunk/lib/J3/Compiler/JavaJIT.h vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp vmkit/trunk/tools/vmjc/vmjc.cpp vmkit/trunk/tools/vmkit/Launcher.cpp Copied: vmkit/trunk/include/j3/J3Intrinsics.h (from r96191, vmkit/trunk/include/j3/JnjvmModule.h) URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/J3Intrinsics.h?p2=vmkit/trunk/include/j3/J3Intrinsics.h&p1=vmkit/trunk/include/j3/JnjvmModule.h&r1=96191&r2=96194&rev=96194&view=diff ============================================================================== --- vmkit/trunk/include/j3/JnjvmModule.h (original) +++ vmkit/trunk/include/j3/J3Intrinsics.h Sun Feb 14 16:07:42 2010 @@ -1,4 +1,4 @@ -//===---------- JnjvmModule.h - Definition of a J3 module -----------------===// +//===-------------- J3Intrinsics.h - Intrinsics of J3 ---------------------===// // // The VMKit project // @@ -7,17 +7,16 @@ // //===----------------------------------------------------------------------===// -#ifndef JNJVM_MODULE_H -#define JNJVM_MODULE_H +#ifndef J3_INTRINSICS_H +#define J3_INTRINSICS_H #include "mvm/JIT.h" namespace j3 { -class JnjvmModule : public mvm::MvmModule { +class J3Intrinsics : public mvm::MvmModule { public: - static const llvm::Type* JavaArrayUInt8Type; static const llvm::Type* JavaArraySInt8Type; static const llvm::Type* JavaArrayUInt16Type; @@ -174,7 +173,7 @@ llvm::Function* ThrowExceptionFromJITFunction; - JnjvmModule(llvm::Module*); + J3Intrinsics(llvm::Module*); static void initialise(); Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaLLVMCompiler.h?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/include/j3/JavaLLVMCompiler.h (original) +++ vmkit/trunk/include/j3/JavaLLVMCompiler.h Sun Feb 14 16:07:42 2010 @@ -11,7 +11,7 @@ #define J3_LLVM_COMPILER_H #include "j3/JavaCompiler.h" -#include "j3/JnjvmModule.h" +#include "j3/J3Intrinsics.h" #include "j3/LLVMInfo.h" namespace llvm { @@ -40,7 +40,7 @@ protected: llvm::Module* TheModule; - JnjvmModule JavaIntrinsics; + J3Intrinsics JavaIntrinsics; void addJavaPasses(); @@ -67,7 +67,7 @@ return TheModule; } - JnjvmModule* getIntrinsics() { + J3Intrinsics* getIntrinsics() { return &JavaIntrinsics; } Removed: vmkit/trunk/include/j3/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JnjvmModule.h?rev=96193&view=auto ============================================================================== --- vmkit/trunk/include/j3/JnjvmModule.h (original) +++ vmkit/trunk/include/j3/JnjvmModule.h (removed) @@ -1,185 +0,0 @@ -//===---------- JnjvmModule.h - Definition of a J3 module -----------------===// -// -// The VMKit project -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef JNJVM_MODULE_H -#define JNJVM_MODULE_H - -#include "mvm/JIT.h" - -namespace j3 { - -class JnjvmModule : public mvm::MvmModule { - -public: - - static const llvm::Type* JavaArrayUInt8Type; - static const llvm::Type* JavaArraySInt8Type; - static const llvm::Type* JavaArrayUInt16Type; - static const llvm::Type* JavaArraySInt16Type; - static const llvm::Type* JavaArrayUInt32Type; - static const llvm::Type* JavaArraySInt32Type; - static const llvm::Type* JavaArrayLongType; - static const llvm::Type* JavaArrayFloatType; - static const llvm::Type* JavaArrayDoubleType; - static const llvm::Type* JavaArrayObjectType; - - static const llvm::Type* VTType; - static const llvm::Type* JavaObjectType; - static const llvm::Type* JavaArrayType; - static const llvm::Type* JavaCommonClassType; - static const llvm::Type* JavaClassType; - static const llvm::Type* JavaClassArrayType; - static const llvm::Type* JavaClassPrimitiveType; - static const llvm::Type* ConstantPoolType; - static const llvm::Type* CodeLineInfoType; - static const llvm::Type* UTF8Type; - static const llvm::Type* JavaMethodType; - static const llvm::Type* JavaFieldType; - static const llvm::Type* AttributType; - static const llvm::Type* JavaThreadType; - static const llvm::Type* MutatorThreadType; - -#ifdef ISOLATE_SHARING - static const llvm::Type* JnjvmType; -#endif - - llvm::Function* EmptyTracerFunction; - llvm::Function* JavaObjectTracerFunction; - llvm::Function* JavaArrayTracerFunction; - llvm::Function* ArrayObjectTracerFunction; - llvm::Function* RegularObjectTracerFunction; - - llvm::Function* StartJNIFunction; - llvm::Function* EndJNIFunction; - llvm::Function* InterfaceLookupFunction; - llvm::Function* VirtualFieldLookupFunction; - llvm::Function* StaticFieldLookupFunction; - llvm::Function* PrintExecutionFunction; - llvm::Function* PrintMethodStartFunction; - llvm::Function* PrintMethodEndFunction; - llvm::Function* InitialiseClassFunction; - llvm::Function* InitialisationCheckFunction; - llvm::Function* ForceInitialisationCheckFunction; - llvm::Function* ForceLoadedCheckFunction; - llvm::Function* ClassLookupFunction; - llvm::Function* StringLookupFunction; - - llvm::Function* ResolveVirtualStubFunction; - llvm::Function* ResolveSpecialStubFunction; - llvm::Function* ResolveStaticStubFunction; - -#ifndef WITHOUT_VTABLE - llvm::Function* VirtualLookupFunction; -#endif - llvm::Function* IsAssignableFromFunction; - llvm::Function* IsSecondaryClassFunction; - llvm::Function* GetDepthFunction; - llvm::Function* GetDisplayFunction; - llvm::Function* GetVTInDisplayFunction; - llvm::Function* GetStaticInstanceFunction; - llvm::Function* AquireObjectFunction; - llvm::Function* ReleaseObjectFunction; - llvm::Function* GetConstantPoolAtFunction; - llvm::Function* MultiCallNewFunction; - llvm::Function* GetArrayClassFunction; - -#ifdef ISOLATE_SHARING - llvm::Function* GetCtpClassFunction; - llvm::Function* GetJnjvmExceptionClassFunction; - llvm::Function* GetJnjvmArrayClassFunction; - llvm::Function* StaticCtpLookupFunction; - llvm::Function* SpecialCtpLookupFunction; -#endif - -#ifdef SERVICE - llvm::Function* ServiceCallStartFunction; - llvm::Function* ServiceCallStopFunction; -#endif - - llvm::Function* GetClassDelegateeFunction; - llvm::Function* RuntimeDelegateeFunction; - llvm::Function* ArrayLengthFunction; - llvm::Function* GetVTFunction; - llvm::Function* GetIMTFunction; - llvm::Function* GetClassFunction; - llvm::Function* GetVTFromClassFunction; - llvm::Function* GetVTFromClassArrayFunction; - llvm::Function* GetVTFromCommonClassFunction; - llvm::Function* GetObjectSizeFromClassFunction; - llvm::Function* GetBaseClassVTFromVTFunction; - - llvm::Function* GetLockFunction; - llvm::Function* OverflowThinLockFunction; - - llvm::Function* GetFinalInt8FieldFunction; - llvm::Function* GetFinalInt16FieldFunction; - llvm::Function* GetFinalInt32FieldFunction; - llvm::Function* GetFinalLongFieldFunction; - llvm::Function* GetFinalFloatFieldFunction; - llvm::Function* GetFinalDoubleFieldFunction; - llvm::Function* GetFinalObjectFieldFunction; - - llvm::Constant* JavaArraySizeOffsetConstant; - llvm::Constant* JavaArrayElementsOffsetConstant; - llvm::Constant* JavaObjectLockOffsetConstant; - llvm::Constant* JavaObjectVTOffsetConstant; - - llvm::Constant* OffsetAccessInCommonClassConstant; - llvm::Constant* IsArrayConstant; - llvm::Constant* IsPrimitiveConstant; - llvm::Constant* OffsetObjectSizeInClassConstant; - llvm::Constant* OffsetVTInClassConstant; - llvm::Constant* OffsetTaskClassMirrorInClassConstant; - llvm::Constant* OffsetVirtualMethodsInClassConstant; - llvm::Constant* OffsetStaticInstanceInTaskClassMirrorConstant; - llvm::Constant* OffsetInitializedInTaskClassMirrorConstant; - llvm::Constant* OffsetStatusInTaskClassMirrorConstant; - - llvm::Constant* OffsetDoYieldInThreadConstant; - llvm::Constant* OffsetIsolateInThreadConstant; - llvm::Constant* OffsetJNIInThreadConstant; - llvm::Constant* OffsetJavaExceptionInThreadConstant; - llvm::Constant* OffsetCXXExceptionInThreadConstant; - - llvm::Constant* OffsetClassInVTConstant; - llvm::Constant* OffsetDepthInVTConstant; - llvm::Constant* OffsetDisplayInVTConstant; - llvm::Constant* OffsetBaseClassVTInVTConstant; - llvm::Constant* OffsetIMTInVTConstant; - - llvm::Constant* OffsetBaseClassInArrayClassConstant; - llvm::Constant* OffsetLogSizeInPrimitiveClassConstant; - - llvm::Constant* ClassReadyConstant; - - llvm::Constant* JavaObjectNullConstant; - llvm::Constant* MaxArraySizeConstant; - llvm::Constant* JavaArraySizeConstant; - - llvm::Function* ThrowExceptionFunction; - llvm::Function* NullPointerExceptionFunction; - llvm::Function* IndexOutOfBoundsExceptionFunction; - llvm::Function* ClassCastExceptionFunction; - llvm::Function* OutOfMemoryErrorFunction; - llvm::Function* StackOverflowErrorFunction; - llvm::Function* NegativeArraySizeExceptionFunction; - llvm::Function* ArrayStoreExceptionFunction; - llvm::Function* ArithmeticExceptionFunction; - llvm::Function* ThrowExceptionFromJITFunction; - - - JnjvmModule(llvm::Module*); - - static void initialise(); - -}; - -} - -#endif Modified: vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc (original) +++ vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc Sun Feb 14 16:07:42 2010 @@ -8,9 +8,9 @@ res->setMetadata("dbg", CreateLocation()); if (TheCompiler->hasExceptionsEnabled()) { - Value* threadId = getCurrentThread(module->JavaThreadType); - Value* geps[2] = { module->constantZero, - module->OffsetJavaExceptionInThreadConstant }; + Value* threadId = getCurrentThread(intrinsics->JavaThreadType); + Value* geps[2] = { intrinsics->constantZero, + intrinsics->OffsetJavaExceptionInThreadConstant }; Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps, geps + 2, "", @@ -22,20 +22,20 @@ BasicBlock* ifNormal = createBasicBlock("no exception block"); Value* test = 0; - Constant* zero = module->JavaObjectNullConstant; + Constant* zero = intrinsics->JavaObjectNullConstant; // If F is a runtime intrinsic that does not access memory, use a hack // that will prevent LLVM from moving the exception check: runtime // intrinsics return the exception if an exception was raised. - if (F == module->InitialisationCheckFunction || - F == module->GetConstantPoolAtFunction || - F == module->GetArrayClassFunction || - F == module->GetClassDelegateeFunction) { + if (F == intrinsics->InitialisationCheckFunction || + F == intrinsics->GetConstantPoolAtFunction || + F == intrinsics->GetArrayClassFunction || + F == intrinsics->GetClassDelegateeFunction) { // Make the load volatile to force the instruction after the call. // Otherwise, LLVM will merge the load with a previous load because // the function is readnone. obj = new LoadInst(javaExceptionPtr, "", true, currentBlock); - test = new BitCastInst(res, module->JavaObjectType, "", currentBlock); + test = new BitCastInst(res, intrinsics->JavaObjectType, "", currentBlock); test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, test, obj, ""); Value* T = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, zero, ""); test = BinaryOperator::CreateAnd(test, T, "", currentBlock); @@ -66,9 +66,9 @@ res->setMetadata("dbg", CreateLocation()); if (TheCompiler->hasExceptionsEnabled()) { - Value* threadId = getCurrentThread(module->JavaThreadType); - Value* geps[2] = { module->constantZero, - module->OffsetJavaExceptionInThreadConstant }; + Value* threadId = getCurrentThread(intrinsics->JavaThreadType); + Value* geps[2] = { intrinsics->constantZero, + intrinsics->OffsetJavaExceptionInThreadConstant }; Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps, geps + 2, "", @@ -80,13 +80,13 @@ BasicBlock* ifNormal = createBasicBlock("no exception block"); Value* test = 0; - Constant* zero = module->JavaObjectNullConstant; - if (F == module->InitialisationCheckFunction || - F == module->GetConstantPoolAtFunction || - F == module->GetArrayClassFunction || - F == module->GetClassDelegateeFunction) { + Constant* zero = intrinsics->JavaObjectNullConstant; + if (F == intrinsics->InitialisationCheckFunction || + F == intrinsics->GetConstantPoolAtFunction || + F == intrinsics->GetArrayClassFunction || + F == intrinsics->GetClassDelegateeFunction) { obj = new LoadInst(javaExceptionPtr, "", true, currentBlock); - test = new BitCastInst(res, module->JavaObjectType, "", currentBlock); + test = new BitCastInst(res, intrinsics->JavaObjectType, "", currentBlock); test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, test, obj, ""); Value* T = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, zero, ""); test = BinaryOperator::CreateAnd(test, T, "", currentBlock); @@ -118,9 +118,9 @@ res->setMetadata("dbg", CreateLocation()); if (TheCompiler->hasExceptionsEnabled()) { - Value* threadId = getCurrentThread(module->JavaThreadType); - Value* geps[2] = { module->constantZero, - module->OffsetJavaExceptionInThreadConstant }; + Value* threadId = getCurrentThread(intrinsics->JavaThreadType); + Value* geps[2] = { intrinsics->constantZero, + intrinsics->OffsetJavaExceptionInThreadConstant }; Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps, geps + 2, "", @@ -132,13 +132,13 @@ BasicBlock* ifNormal = createBasicBlock("no exception block"); Value* test = 0; - Constant* zero = module->JavaObjectNullConstant; - if (F == module->InitialisationCheckFunction || - F == module->GetConstantPoolAtFunction || - F == module->GetArrayClassFunction || - F == module->GetClassDelegateeFunction) { + Constant* zero = intrinsics->JavaObjectNullConstant; + if (F == intrinsics->InitialisationCheckFunction || + F == intrinsics->GetConstantPoolAtFunction || + F == intrinsics->GetArrayClassFunction || + F == intrinsics->GetClassDelegateeFunction) { obj = new LoadInst(javaExceptionPtr, "", true, currentBlock); - test = new BitCastInst(res, module->JavaObjectType, "", currentBlock); + test = new BitCastInst(res, intrinsics->JavaObjectType, "", currentBlock); test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, test, obj, ""); Value* T = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, zero, ""); test = BinaryOperator::CreateAnd(test, T, "", currentBlock); @@ -167,9 +167,9 @@ res->setMetadata("dbg", CreateLocation()); if (TheCompiler->hasExceptionsEnabled()) { - Value* threadId = getCurrentThread(module->JavaThreadType); - Value* geps[2] = { module->constantZero, - module->OffsetJavaExceptionInThreadConstant }; + Value* threadId = getCurrentThread(intrinsics->JavaThreadType); + Value* geps[2] = { intrinsics->constantZero, + intrinsics->OffsetJavaExceptionInThreadConstant }; Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps, geps + 2, "", @@ -181,13 +181,13 @@ BasicBlock* ifNormal = createBasicBlock("no exception block"); Value* test = 0; - Constant* zero = module->JavaObjectNullConstant; - if (F == module->InitialisationCheckFunction || - F == module->GetConstantPoolAtFunction || - F == module->GetArrayClassFunction || - F == module->GetClassDelegateeFunction) { + Constant* zero = intrinsics->JavaObjectNullConstant; + if (F == intrinsics->InitialisationCheckFunction || + F == intrinsics->GetConstantPoolAtFunction || + F == intrinsics->GetArrayClassFunction || + F == intrinsics->GetClassDelegateeFunction) { obj = new LoadInst(javaExceptionPtr, "", true, currentBlock); - test = new BitCastInst(res, module->JavaObjectType, "", currentBlock); + test = new BitCastInst(res, intrinsics->JavaObjectType, "", currentBlock); test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, test, obj, ""); Value* T = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, zero, ""); test = BinaryOperator::CreateAnd(test, T, "", currentBlock); @@ -229,9 +229,9 @@ } void JavaJIT::throwException(Value* obj) { - Value* threadId = getCurrentThread(module->JavaThreadType); - Value* geps[2] = { module->constantZero, - module->OffsetJavaExceptionInThreadConstant }; + Value* threadId = getCurrentThread(intrinsics->JavaThreadType); + Value* geps[2] = { intrinsics->constantZero, + intrinsics->OffsetJavaExceptionInThreadConstant }; Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps, geps + 2, "", @@ -343,7 +343,7 @@ ex->tester = createBasicBlock("testException"); // PHI Node for the exception object - PHINode::Create(JnjvmModule::JavaObjectType, "", ex->tester); + PHINode::Create(J3Intrinsics::JavaObjectType, "", ex->tester); // Set the unwind destination of the instructions in the range of this // handler to the test block of the handler. If an instruction already has @@ -365,7 +365,7 @@ opcodeInfos[ex->handlerpc].handler = true; if (ex->javaHandler->empty()) { - PHINode::Create(JnjvmModule::JavaObjectType, "", ex->javaHandler); + PHINode::Create(J3Intrinsics::JavaObjectType, "", ex->javaHandler); } } @@ -409,20 +409,20 @@ // catch the exception but resume unwinding. JnjvmClassLoader* loader = compilingClass->classLoader;; if (loader != loader->bootstrapLoader) { - Value* threadId = getCurrentThread(module->MutatorThreadType); + Value* threadId = getCurrentThread(intrinsics->MutatorThreadType); Value* Isolate = GetElementPtrInst::Create(threadId, - module->constantFour, "", + intrinsics->constantFour, "", currentBlock); Isolate = new LoadInst(Isolate, "", currentBlock); - Isolate = new BitCastInst(Isolate, module->ptrPtrType, "", currentBlock); - Value* Status = GetElementPtrInst::Create(Isolate, module->constantOne, "", + Isolate = new BitCastInst(Isolate, intrinsics->ptrPtrType, "", currentBlock); + Value* Status = GetElementPtrInst::Create(Isolate, intrinsics->constantOne, "", currentBlock); Status = new LoadInst(Status, "", currentBlock); Status = new PtrToIntInst(Status, Type::Int32Ty, "", currentBlock); Value* stopping = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, Status, - module->constantOne, ""); + intrinsics->constantOne, ""); BasicBlock* raiseBlock = createBasicBlock("raiseBlock"); BasicBlock* continueBlock = createBasicBlock("continueBlock"); @@ -437,7 +437,7 @@ // Get the Java exception. Value* obj = currentBlock->begin(); - Value* objVT = CallInst::Create(module->GetVTFunction, obj, "", + Value* objVT = CallInst::Create(intrinsics->GetVTFunction, obj, "", currentBlock); uint32 depth = cur->catchClass->virtualVT->depth; @@ -447,17 +447,17 @@ if (depth >= JavaVirtualTable::getDisplayLength()) { Value* classArgs[2] = { objVT, VTVar }; - cmp = CallInst::Create(module->IsSecondaryClassFunction, + cmp = CallInst::Create(intrinsics->IsSecondaryClassFunction, classArgs, classArgs + 2, "", currentBlock); } else { - Value* inDisplay = CallInst::Create(module->GetDisplayFunction, + Value* inDisplay = CallInst::Create(intrinsics->GetDisplayFunction, objVT, "", currentBlock); Value* displayArgs[2] = { inDisplay, depthCl }; - Value* VTInDisplay = CallInst::Create(module->GetVTInDisplayFunction, + Value* VTInDisplay = CallInst::Create(intrinsics->GetVTInDisplayFunction, displayArgs, displayArgs + 2, "", currentBlock); @@ -482,15 +482,15 @@ currentBlock = cur->javaHandler; // First thing in the handler: clear the exception. - Value* geps[2] = { module->constantZero, - module->OffsetJavaExceptionInThreadConstant }; - Value* threadId = getCurrentThread(module->JavaThreadType); + Value* geps[2] = { intrinsics->constantZero, + intrinsics->OffsetJavaExceptionInThreadConstant }; + Value* threadId = getCurrentThread(intrinsics->JavaThreadType); Value* javaExceptionPtr = GetElementPtrInst::Create(threadId, geps, geps + 2, "", currentBlock); // Clear exceptions. - new StoreInst(module->JavaObjectNullConstant, javaExceptionPtr, + new StoreInst(intrinsics->JavaObjectNullConstant, javaExceptionPtr, currentBlock); #if defined(SERVICE) @@ -505,24 +505,24 @@ Value* IsolatePtr = 0; currentBlock = cur->javaHandler; if (loader != loader->bootstrapLoader) { - threadId = getCurrentThread(module->MutatorThreadType); + threadId = getCurrentThread(intrinsics->MutatorThreadType); - IsolateIDPtr = GetElementPtrInst::Create(threadId, module->constantThree, + IsolateIDPtr = GetElementPtrInst::Create(threadId, intrinsics->constantThree, "", cur->javaHandler); - const Type* realType = PointerType::getUnqual(module->pointerSizeType); + const Type* realType = PointerType::getUnqual(intrinsics->pointerSizeType); IsolateIDPtr = new BitCastInst(IsolateIDPtr, realType, "", cur->javaHandler); OldIsolateID = new LoadInst(IsolateIDPtr, "", cur->javaHandler); - Value* MyID = ConstantInt::get(module->pointerSizeType, + Value* MyID = ConstantInt::get(intrinsics->pointerSizeType, loader->getIsolate()->IsolateID); new StoreInst(MyID, IsolateIDPtr, cur->javaHandler); - IsolatePtr = GetElementPtrInst::Create(threadId, module->constantFour, "", + IsolatePtr = GetElementPtrInst::Create(threadId, intrinsics->constantFour, "", cur->javaHandler); OldIsolate = new LoadInst(IsolatePtr, "", cur->javaHandler); - NewIsolate = module->getIsolate(loader->getIsolate(), currentBlock); + NewIsolate = intrinsics->getIsolate(loader->getIsolate(), currentBlock); new StoreInst(NewIsolate, IsolatePtr, cur->javaHandler); } Copied: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp (from r96189, vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp) URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp?p2=vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp&p1=vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp&r1=96189&r2=96194&rev=96194&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp Sun Feb 14 16:07:42 2010 @@ -1,4 +1,4 @@ -//===--------- JnjvmModule.cpp - Definition of a Jnjvm module -------------===// +//===------------- J3Intrinsics.cpp - Intrinsics for J3 -------------------===// // // The VMKit project // @@ -24,42 +24,42 @@ #include "JavaJIT.h" #include "JavaTypes.h" -#include "j3/JnjvmModule.h" +#include "j3/J3Intrinsics.h" #include "j3/LLVMMaterializer.h" using namespace j3; using namespace llvm; -const llvm::Type* JnjvmModule::JavaObjectType = 0; -const llvm::Type* JnjvmModule::JavaArrayType = 0; -const llvm::Type* JnjvmModule::JavaArrayUInt8Type = 0; -const llvm::Type* JnjvmModule::JavaArraySInt8Type = 0; -const llvm::Type* JnjvmModule::JavaArrayUInt16Type = 0; -const llvm::Type* JnjvmModule::JavaArraySInt16Type = 0; -const llvm::Type* JnjvmModule::JavaArrayUInt32Type = 0; -const llvm::Type* JnjvmModule::JavaArraySInt32Type = 0; -const llvm::Type* JnjvmModule::JavaArrayFloatType = 0; -const llvm::Type* JnjvmModule::JavaArrayDoubleType = 0; -const llvm::Type* JnjvmModule::JavaArrayLongType = 0; -const llvm::Type* JnjvmModule::JavaArrayObjectType = 0; -const llvm::Type* JnjvmModule::CodeLineInfoType = 0; -const llvm::Type* JnjvmModule::ConstantPoolType = 0; -const llvm::Type* JnjvmModule::UTF8Type = 0; -const llvm::Type* JnjvmModule::JavaFieldType = 0; -const llvm::Type* JnjvmModule::JavaMethodType = 0; -const llvm::Type* JnjvmModule::AttributType = 0; -const llvm::Type* JnjvmModule::JavaThreadType = 0; -const llvm::Type* JnjvmModule::MutatorThreadType = 0; +const llvm::Type* J3Intrinsics::JavaObjectType = 0; +const llvm::Type* J3Intrinsics::JavaArrayType = 0; +const llvm::Type* J3Intrinsics::JavaArrayUInt8Type = 0; +const llvm::Type* J3Intrinsics::JavaArraySInt8Type = 0; +const llvm::Type* J3Intrinsics::JavaArrayUInt16Type = 0; +const llvm::Type* J3Intrinsics::JavaArraySInt16Type = 0; +const llvm::Type* J3Intrinsics::JavaArrayUInt32Type = 0; +const llvm::Type* J3Intrinsics::JavaArraySInt32Type = 0; +const llvm::Type* J3Intrinsics::JavaArrayFloatType = 0; +const llvm::Type* J3Intrinsics::JavaArrayDoubleType = 0; +const llvm::Type* J3Intrinsics::JavaArrayLongType = 0; +const llvm::Type* J3Intrinsics::JavaArrayObjectType = 0; +const llvm::Type* J3Intrinsics::CodeLineInfoType = 0; +const llvm::Type* J3Intrinsics::ConstantPoolType = 0; +const llvm::Type* J3Intrinsics::UTF8Type = 0; +const llvm::Type* J3Intrinsics::JavaFieldType = 0; +const llvm::Type* J3Intrinsics::JavaMethodType = 0; +const llvm::Type* J3Intrinsics::AttributType = 0; +const llvm::Type* J3Intrinsics::JavaThreadType = 0; +const llvm::Type* J3Intrinsics::MutatorThreadType = 0; #ifdef ISOLATE_SHARING -const llvm::Type* JnjvmModule::JnjvmType = 0; +const llvm::Type* J3Intrinsics::JnjvmType = 0; #endif -const llvm::Type* JnjvmModule::JavaClassType; -const llvm::Type* JnjvmModule::JavaClassPrimitiveType; -const llvm::Type* JnjvmModule::JavaClassArrayType; -const llvm::Type* JnjvmModule::JavaCommonClassType; -const llvm::Type* JnjvmModule::VTType; +const llvm::Type* J3Intrinsics::JavaClassType; +const llvm::Type* J3Intrinsics::JavaClassPrimitiveType; +const llvm::Type* J3Intrinsics::JavaClassArrayType; +const llvm::Type* J3Intrinsics::JavaCommonClassType; +const llvm::Type* J3Intrinsics::VTType; JavaLLVMCompiler::JavaLLVMCompiler(const std::string& str) : @@ -97,7 +97,7 @@ } } -void JnjvmModule::initialise() { +void J3Intrinsics::initialise() { Module* module = globalModule; if (!module->getTypeByName("JavaThread")) @@ -170,7 +170,7 @@ return getMethodInfo(meth)->getMethod(); } -JnjvmModule::JnjvmModule(llvm::Module* module) : +J3Intrinsics::J3Intrinsics(llvm::Module* module) : MvmModule(module) { if (!VTType) { @@ -179,7 +179,7 @@ } JavaObjectNullConstant = - Constant::getNullValue(JnjvmModule::JavaObjectType); + Constant::getNullValue(J3Intrinsics::JavaObjectType); MaxArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), JavaArray::MaxArraySize); JavaArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), @@ -357,20 +357,20 @@ Function* func = LMI->getMethod(); // We are jitting. Take the lock. - JnjvmModule::protectIR(); + J3Intrinsics::protectIR(); if (func->getLinkage() == GlobalValue::ExternalWeakLinkage) { JavaJIT jit(this, meth, func); if (isNative(meth->access)) { jit.nativeCompile(); - JnjvmModule::runPasses(func, JavaNativeFunctionPasses); + J3Intrinsics::runPasses(func, JavaNativeFunctionPasses); } else { jit.javaCompile(); - JnjvmModule::runPasses(func, JnjvmModule::globalFunctionPasses); - JnjvmModule::runPasses(func, JavaFunctionPasses); + J3Intrinsics::runPasses(func, J3Intrinsics::globalFunctionPasses); + J3Intrinsics::runPasses(func, JavaFunctionPasses); } func->setLinkage(GlobalValue::ExternalLinkage); } - JnjvmModule::unprotectIR(); + J3Intrinsics::unprotectIR(); return func; } @@ -406,7 +406,7 @@ } namespace j3 { - llvm::FunctionPass* createLowerConstantCallsPass(JnjvmModule* M); + llvm::FunctionPass* createLowerConstantCallsPass(J3Intrinsics* M); } void JavaLLVMCompiler::addJavaPasses() { Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sun Feb 14 16:07:42 2010 @@ -17,7 +17,7 @@ #include "mvm/Threads/Thread.h" -#include "j3/JnjvmModule.h" +#include "j3/J3Intrinsics.h" #include "j3/JavaAOTCompiler.h" #include "j3/JavaJITCompiler.h" @@ -60,11 +60,11 @@ const llvm::Type* Ty = 0; if (classDef->isArray()) { - Ty = JnjvmModule::JavaClassArrayType->getContainedType(0); + Ty = J3Intrinsics::JavaClassArrayType->getContainedType(0); } else if (classDef->isPrimitive()) { - Ty = JnjvmModule::JavaClassPrimitiveType->getContainedType(0); + Ty = J3Intrinsics::JavaClassPrimitiveType->getContainedType(0); } else { - Ty = JnjvmModule::JavaClassType->getContainedType(0); + Ty = J3Intrinsics::JavaClassType->getContainedType(0); } GlobalVariable* varGV = @@ -95,7 +95,7 @@ array_class_iterator End = arrayClasses.end(); array_class_iterator I = arrayClasses.find(classDef->asArrayClass()); if (I == End) { - const llvm::Type* Ty = JnjvmModule::JavaClassArrayType; + const llvm::Type* Ty = J3Intrinsics::JavaClassArrayType; Module& Mod = *getLLVMModule(); GlobalVariable* varGV = @@ -119,7 +119,7 @@ constant_pool_iterator End = constantPools.end(); constant_pool_iterator I = constantPools.find(ctp); if (I == End) { - const Type* Ty = JnjvmModule::ConstantPoolType->getContainedType(0); + const Type* Ty = J3Intrinsics::ConstantPoolType->getContainedType(0); Module& Mod = *getLLVMModule(); varGV = new GlobalVariable(Mod, Ty, false, @@ -154,7 +154,7 @@ name += "_VirtualMethods"; Module& Mod = *getLLVMModule(); const Type* ATy = - ArrayType::get(JnjvmModule::JavaMethodType->getContainedType(0), + ArrayType::get(J3Intrinsics::JavaMethodType->getContainedType(0), cl->nbVirtualMethods + cl->nbStaticMethods); Array = new GlobalVariable(Mod, ATy, false, GlobalValue::ExternalLinkage, @@ -180,7 +180,7 @@ new GlobalVariable(Mod, Ty->getContainedType(0), false, GlobalValue::InternalLinkage, 0, ""); Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV, - JnjvmModule::JavaObjectType); + J3Intrinsics::JavaObjectType); strings.insert(std::make_pair(str, res)); Constant* C = CreateConstantFromJavaString(str); varGV->setInitializer(C); @@ -211,7 +211,7 @@ GlobalValue::InternalLinkage, 0, ""); Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV, - JnjvmModule::JavaObjectType); + J3Intrinsics::JavaObjectType); javaClasses.insert(std::make_pair(cl, res)); varGV->setInitializer(CreateConstantFromJavaClass(cl)); @@ -233,7 +233,7 @@ getJavaClass(cl); Constant* Cl = getNativeClass(cl); - Cl = ConstantExpr::getBitCast(Cl, JnjvmModule::JavaCommonClassType); + Cl = ConstantExpr::getBitCast(Cl, J3Intrinsics::JavaCommonClassType); Constant* GEP[2] = { getIntrinsics()->constantZero, getIntrinsics()->constantZero }; @@ -274,14 +274,14 @@ intptr_t* realObj = (intptr_t*)obj; intptr_t size = realObj[0]; - const ArrayType* ATy = ArrayType::get(JnjvmModule::JavaObjectType, + const ArrayType* ATy = ArrayType::get(J3Intrinsics::JavaObjectType, size + 1); std::vector Vals; for (sint32 i = 0; i < size + 1; ++i) { Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(realObj[i])); - CI = ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType); + CI = ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType); Vals.push_back(CI); } @@ -292,12 +292,12 @@ GlobalValue::InternalLinkage, CA, ""); - return ConstantExpr::getBitCast(varGV, JnjvmModule::JavaObjectType); + return ConstantExpr::getBitCast(varGV, J3Intrinsics::JavaObjectType); } else { Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(obj)); - CI = ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType); + CI = ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType); return CI; } } @@ -337,13 +337,13 @@ abort(); } } else { - Ty = JnjvmModule::JavaObjectType; + Ty = J3Intrinsics::JavaObjectType; } std::vector Elemts; const ArrayType* ATy = ArrayType::get(Ty, ((JavaArray*)obj)->size); - Elemts.push_back(JnjvmModule::JavaObjectType->getContainedType(0)); - Elemts.push_back(JnjvmModule::pointerSizeType); + Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0)); + Elemts.push_back(J3Intrinsics::pointerSizeType); Elemts.push_back(ATy); Ty = StructType::get(getLLVMModule()->getContext(), Elemts); @@ -357,7 +357,7 @@ 0, ""); Constant* C = ConstantExpr::getBitCast(varGV, - JnjvmModule::JavaObjectType); + J3Intrinsics::JavaObjectType); finalObjects.insert(std::make_pair(obj, C)); reverseFinalObjects.insert(std::make_pair(C, obj)); @@ -459,7 +459,7 @@ const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[idx]); JavaString* obj = ctpInfo->resolveString(utf8, idx); Constant* C = getString(obj); - C = ConstantExpr::getBitCast(C, JnjvmModule::JavaObjectType); + C = ConstantExpr::getBitCast(C, J3Intrinsics::JavaObjectType); Elts.push_back(C); } else { fprintf(stderr, "Implement me"); @@ -491,7 +491,7 @@ 0, name); Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV, - JnjvmModule::ptrType); + J3Intrinsics::ptrType); staticInstances.insert(std::make_pair(classDef, res)); if (isCompiling(classDef)) { @@ -521,7 +521,7 @@ if (I == End) { const ArrayType* ATy = - dyn_cast(JnjvmModule::VTType->getContainedType(0)); + dyn_cast(J3Intrinsics::VTType->getContainedType(0)); const PointerType* PTy = dyn_cast(ATy->getContainedType(0)); ATy = ArrayType::get(PTy, size); std::string name(UTF8Buffer(classDef->name).toCompileName()->cString()); @@ -534,7 +534,7 @@ 0, name); res = ConstantExpr::getCast(Instruction::BitCast, varGV, - JnjvmModule::VTType); + J3Intrinsics::VTType); virtualTables.insert(std::make_pair(VT, res)); if (isCompiling(classDef) || assumeCompiled) { @@ -571,7 +571,7 @@ Constant* JavaAOTCompiler::CreateConstantForBaseObject(CommonClass* cl) { const StructType* STy = - dyn_cast(JnjvmModule::JavaObjectType->getContainedType(0)); + dyn_cast(J3Intrinsics::JavaObjectType->getContainedType(0)); std::vector Elmts; @@ -580,7 +580,7 @@ // lock Constant* L = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), 0); - Elmts.push_back(ConstantExpr::getIntToPtr(L, JnjvmModule::ptrType)); + Elmts.push_back(ConstantExpr::getIntToPtr(L, J3Intrinsics::ptrType)); return ConstantStruct::get(STy, Elmts); } @@ -597,19 +597,19 @@ Elmts.push_back(CreateConstantForBaseObject(javaClass)); // signers - Elmts.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType)); + Elmts.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType)); // pd - Elmts.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType)); + Elmts.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType)); // vmdata Constant* Cl = getNativeClass(cl); Cl = ConstantExpr::getCast(Instruction::BitCast, Cl, - JnjvmModule::JavaObjectType); + J3Intrinsics::JavaObjectType); Elmts.push_back(Cl); // constructor - Elmts.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType)); + Elmts.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType)); return ConstantStruct::get(STy, Elmts); } @@ -707,7 +707,7 @@ Constant* C = getFinalObject(val, FieldCl); TempElts.push_back(C); } else { - const llvm::Type* Ty = JnjvmModule::JavaObjectType; + const llvm::Type* Ty = J3Intrinsics::JavaObjectType; TempElts.push_back(Constant::getNullValue(Ty)); } } @@ -738,7 +738,7 @@ GlobalValue::InternalLinkage, Array, ""); - Array = ConstantExpr::getBitCast(varGV, JnjvmModule::JavaObjectType); + Array = ConstantExpr::getBitCast(varGV, J3Intrinsics::JavaObjectType); Elmts.push_back(Array); Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), @@ -754,7 +754,7 @@ Constant* JavaAOTCompiler::CreateConstantFromAttribut(Attribut& attribut) { const StructType* STy = - dyn_cast(JnjvmModule::AttributType->getContainedType(0)); + dyn_cast(J3Intrinsics::AttributType->getContainedType(0)); std::vector Elmts; @@ -773,7 +773,7 @@ Constant* JavaAOTCompiler::CreateConstantFromCommonClass(CommonClass* cl) { const StructType* STy = - dyn_cast(JnjvmModule::JavaCommonClassType->getContainedType(0)); + dyn_cast(J3Intrinsics::JavaCommonClassType->getContainedType(0)); Module& Mod = *getLLVMModule(); const llvm::Type* TempTy = 0; @@ -797,17 +797,17 @@ TempElmts.push_back(getNativeClass(cl->interfaces[i])); } - ATy = ArrayType::get(JnjvmModule::JavaClassType, cl->nbInterfaces); + ATy = ArrayType::get(J3Intrinsics::JavaClassType, cl->nbInterfaces); Constant* interfaces = ConstantArray::get(ATy, TempElmts); interfaces = new GlobalVariable(Mod, ATy, true, GlobalValue::InternalLinkage, interfaces, ""); interfaces = ConstantExpr::getCast(Instruction::BitCast, interfaces, - PointerType::getUnqual(JnjvmModule::JavaClassType)); + PointerType::getUnqual(J3Intrinsics::JavaClassType)); CommonClassElts.push_back(interfaces); } else { - const Type* Ty = PointerType::getUnqual(JnjvmModule::JavaClassType); + const Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaClassType); CommonClassElts.push_back(Constant::getNullValue(Ty)); } @@ -821,21 +821,21 @@ if (cl->super) { CommonClassElts.push_back(getNativeClass(cl->super)); } else { - TempTy = JnjvmModule::JavaClassType; + TempTy = J3Intrinsics::JavaClassType; CommonClassElts.push_back(Constant::getNullValue(TempTy)); } // classLoader: store the static initializer, it will be overriden once // the class is loaded. Constant* loader = ConstantExpr::getBitCast(StaticInitializer, - JnjvmModule::ptrType); + J3Intrinsics::ptrType); CommonClassElts.push_back(loader); // virtualTable if (cl->virtualVT) { CommonClassElts.push_back(getVirtualTable(cl->virtualVT)); } else { - TempTy = JnjvmModule::VTType; + TempTy = J3Intrinsics::VTType; CommonClassElts.push_back(Constant::getNullValue(TempTy)); } return ConstantStruct::get(STy, CommonClassElts); @@ -843,13 +843,13 @@ Constant* JavaAOTCompiler::CreateConstantFromJavaField(JavaField& field) { const StructType* STy = - dyn_cast(JnjvmModule::JavaFieldType->getContainedType(0)); + dyn_cast(J3Intrinsics::JavaFieldType->getContainedType(0)); std::vector FieldElts; std::vector TempElts; // signature - FieldElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); + FieldElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); // access FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.access)); @@ -862,7 +862,7 @@ // attributs if (field.nbAttributs) { - const llvm::Type* AttrTy = JnjvmModule::AttributType->getContainedType(0); + const llvm::Type* AttrTy = J3Intrinsics::AttributType->getContainedType(0); const ArrayType* ATy = ArrayType::get(AttrTy, field.nbAttributs); for (uint32 i = 0; i < field.nbAttributs; ++i) { TempElts.push_back(CreateConstantFromAttribut(field.attributs[i])); @@ -874,11 +874,11 @@ GlobalValue::InternalLinkage, attributs, ""); attributs = ConstantExpr::getCast(Instruction::BitCast, attributs, - JnjvmModule::AttributType); + J3Intrinsics::AttributType); FieldElts.push_back(attributs); } else { - FieldElts.push_back(Constant::getNullValue(JnjvmModule::AttributType)); + FieldElts.push_back(Constant::getNullValue(J3Intrinsics::AttributType)); } // nbAttributs @@ -894,28 +894,28 @@ FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.num)); //JInfo - FieldElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); + FieldElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); return ConstantStruct::get(STy, FieldElts); } Constant* JavaAOTCompiler::CreateConstantFromJavaMethod(JavaMethod& method) { const StructType* STy = - dyn_cast(JnjvmModule::JavaMethodType->getContainedType(0)); + dyn_cast(J3Intrinsics::JavaMethodType->getContainedType(0)); Module& Mod = *getLLVMModule(); std::vector MethodElts; std::vector TempElts; // signature - MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); + MethodElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); // access MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), method.access)); // attributs if (method.nbAttributs) { - const llvm::Type* AttrTy = JnjvmModule::AttributType->getContainedType(0); + const llvm::Type* AttrTy = J3Intrinsics::AttributType->getContainedType(0); const ArrayType* ATy = ArrayType::get(AttrTy, method.nbAttributs); for (uint32 i = 0; i < method.nbAttributs; ++i) { TempElts.push_back(CreateConstantFromAttribut(method.attributs[i])); @@ -927,11 +927,11 @@ GlobalValue::InternalLinkage, attributs, ""); attributs = ConstantExpr::getCast(Instruction::BitCast, attributs, - JnjvmModule::AttributType); + J3Intrinsics::AttributType); MethodElts.push_back(attributs); } else { - MethodElts.push_back(Constant::getNullValue(JnjvmModule::AttributType)); + MethodElts.push_back(Constant::getNullValue(J3Intrinsics::AttributType)); } // nbAttributs @@ -951,16 +951,16 @@ // code if (isAbstract(method.access)) { - MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); + MethodElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); } else { LLVMMethodInfo* LMI = getMethodInfo(&method); Function* func = LMI->getMethod(); MethodElts.push_back(ConstantExpr::getCast(Instruction::BitCast, func, - JnjvmModule::ptrType)); + J3Intrinsics::ptrType)); } // codeInfo - MethodElts.push_back(Constant::getNullValue(JnjvmModule::CodeLineInfoType)); + MethodElts.push_back(Constant::getNullValue(J3Intrinsics::CodeLineInfoType)); // codeInfoLength MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), 0)); @@ -969,14 +969,14 @@ MethodElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), method.offset)); // JInfo - MethodElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); + MethodElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); return ConstantStruct::get(STy, MethodElts); } Constant* JavaAOTCompiler::CreateConstantFromClassPrimitive(ClassPrimitive* cl) { const llvm::Type* JCPTy = - JnjvmModule::JavaClassPrimitiveType->getContainedType(0); + J3Intrinsics::JavaClassPrimitiveType->getContainedType(0); const StructType* STy = dyn_cast(JCPTy); std::vector ClassElts; @@ -992,7 +992,7 @@ Constant* JavaAOTCompiler::CreateConstantFromClassArray(ClassArray* cl) { const StructType* STy = - dyn_cast(JnjvmModule::JavaClassArrayType->getContainedType(0)); + dyn_cast(J3Intrinsics::JavaClassArrayType->getContainedType(0)); std::vector ClassElts; Constant* ClGEPs[2] = { getIntrinsics()->constantZero, @@ -1003,7 +1003,7 @@ // baseClass Constant* Cl = getNativeClass(cl->baseClass()); - if (Cl->getType() != JnjvmModule::JavaCommonClassType) + if (Cl->getType() != J3Intrinsics::JavaCommonClassType) Cl = ConstantExpr::getGetElementPtr(Cl, ClGEPs, 2); ClassElts.push_back(Cl); @@ -1013,7 +1013,7 @@ Constant* JavaAOTCompiler::CreateConstantFromClass(Class* cl) { const StructType* STy = - dyn_cast(JnjvmModule::JavaClassType->getContainedType(0)); + dyn_cast(J3Intrinsics::JavaClassType->getContainedType(0)); Module& Mod = *getLLVMModule(); std::vector ClassElts; @@ -1048,10 +1048,10 @@ ClassElts.push_back(ConstantArray::get(ATy, CStr, 1)); // thinlock - ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); + ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); if (cl->nbVirtualFields + cl->nbStaticFields) { - ATy = ArrayType::get(JnjvmModule::JavaFieldType->getContainedType(0), + ATy = ArrayType::get(J3Intrinsics::JavaFieldType->getContainedType(0), cl->nbVirtualFields + cl->nbStaticFields); } @@ -1082,9 +1082,9 @@ GlobalValue::InternalLinkage, fields, ""); fields = ConstantExpr::getCast(Instruction::BitCast, fields, - JnjvmModule::JavaFieldType); + J3Intrinsics::JavaFieldType); } else { - fields = Constant::getNullValue(JnjvmModule::JavaFieldType); + fields = Constant::getNullValue(J3Intrinsics::JavaFieldType); } // virtualFields @@ -1098,14 +1098,14 @@ // 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(Constant::getNullValue(JnjvmModule::JavaFieldType)); + ClassElts.push_back(Constant::getNullValue(J3Intrinsics::JavaFieldType)); // nbStaticFields ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticFields)); // virtualMethods if (cl->nbVirtualMethods + cl->nbStaticMethods) { - ATy = ArrayType::get(JnjvmModule::JavaMethodType->getContainedType(0), + ATy = ArrayType::get(J3Intrinsics::JavaMethodType->getContainedType(0), cl->nbVirtualMethods + cl->nbStaticMethods); } @@ -1132,9 +1132,9 @@ methods, name); virtualMethods.insert(std::make_pair(cl, GV)); methods = ConstantExpr::getCast(Instruction::BitCast, GV, - JnjvmModule::JavaMethodType); + J3Intrinsics::JavaMethodType); } else { - methods = Constant::getNullValue(JnjvmModule::JavaMethodType); + methods = Constant::getNullValue(J3Intrinsics::JavaMethodType); } // virtualMethods @@ -1147,23 +1147,23 @@ // staticMethods // Output null, getLLVMModule() will be set in the initializer. - ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaMethodType)); + ClassElts.push_back(Constant::getNullValue(J3Intrinsics::JavaMethodType)); // nbStaticMethods ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticMethods)); // ownerClass - ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); + ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); // bytes - ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaArrayUInt8Type)); + ClassElts.push_back(Constant::getNullValue(J3Intrinsics::JavaArrayUInt8Type)); // ctpInfo - ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); + ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); // attributs if (cl->nbAttributs) { - ATy = ArrayType::get(JnjvmModule::AttributType->getContainedType(0), + ATy = ArrayType::get(J3Intrinsics::AttributType->getContainedType(0), cl->nbAttributs); for (uint32 i = 0; i < cl->nbAttributs; ++i) { @@ -1176,10 +1176,10 @@ GlobalValue::InternalLinkage, attributs, ""); attributs = ConstantExpr::getCast(Instruction::BitCast, attributs, - JnjvmModule::AttributType); + J3Intrinsics::AttributType); ClassElts.push_back(attributs); } else { - ClassElts.push_back(Constant::getNullValue(JnjvmModule::AttributType)); + ClassElts.push_back(Constant::getNullValue(J3Intrinsics::AttributType)); } // nbAttributs @@ -1191,7 +1191,7 @@ TempElts.push_back(getNativeClass(cl->innerClasses[i])); } - const llvm::Type* TempTy = JnjvmModule::JavaClassType; + const llvm::Type* TempTy = J3Intrinsics::JavaClassType; ATy = ArrayType::get(TempTy, cl->nbInnerClasses); Constant* innerClasses = ConstantArray::get(ATy, TempElts); innerClasses = new GlobalVariable(*getLLVMModule(), ATy, true, @@ -1202,7 +1202,7 @@ ClassElts.push_back(innerClasses); } else { - const Type* Ty = PointerType::getUnqual(JnjvmModule::JavaClassType); + const Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaClassType); ClassElts.push_back(Constant::getNullValue(Ty)); } @@ -1213,7 +1213,7 @@ if (cl->outerClass) { ClassElts.push_back(getNativeClass(cl->outerClass)); } else { - ClassElts.push_back(Constant::getNullValue(JnjvmModule::JavaClassType)); + ClassElts.push_back(Constant::getNullValue(J3Intrinsics::JavaClassType)); } // innerAccess @@ -1232,7 +1232,7 @@ ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->staticSize)); // JInfo - ClassElts.push_back(Constant::getNullValue(JnjvmModule::ptrType)); + ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); return ConstantStruct::get(STy, ClassElts); } @@ -1241,8 +1241,8 @@ Constant* JavaAOTCompiler::CreateConstantFromIntArray(const T* val, const Type* Ty) { std::vector Elemts; const ArrayType* ATy = ArrayType::get(Ty, val->size); - Elemts.push_back(JnjvmModule::JavaObjectType->getContainedType(0)); - Elemts.push_back(JnjvmModule::pointerSizeType); + Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0)); + Elemts.push_back(J3Intrinsics::pointerSizeType); Elemts.push_back(ATy); @@ -1251,7 +1251,7 @@ std::vector Cts; Cts.push_back(CreateConstantForBaseObject(val->getClass())); - Cts.push_back(ConstantInt::get(JnjvmModule::pointerSizeType, val->size)); + Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size)); std::vector Vals; for (sint32 i = 0; i < val->size; ++i) { @@ -1267,8 +1267,8 @@ Constant* JavaAOTCompiler::CreateConstantFromFPArray(const T* val, const Type* Ty) { std::vector Elemts; const ArrayType* ATy = ArrayType::get(Ty, val->size); - Elemts.push_back(JnjvmModule::JavaObjectType->getContainedType(0)); - Elemts.push_back(JnjvmModule::pointerSizeType); + Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0)); + Elemts.push_back(J3Intrinsics::pointerSizeType); Elemts.push_back(ATy); @@ -1277,7 +1277,7 @@ std::vector Cts; Cts.push_back(CreateConstantForBaseObject(val->getClass())); - Cts.push_back(ConstantInt::get(JnjvmModule::pointerSizeType, val->size)); + Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size)); std::vector Vals; for (sint32 i = 0; i < val->size; ++i) { @@ -1291,10 +1291,10 @@ Constant* JavaAOTCompiler::CreateConstantFromObjectArray(const ArrayObject* val) { std::vector Elemts; - const llvm::Type* Ty = JnjvmModule::JavaObjectType; + const llvm::Type* Ty = J3Intrinsics::JavaObjectType; const ArrayType* ATy = ArrayType::get(Ty, val->size); - Elemts.push_back(JnjvmModule::JavaObjectType->getContainedType(0)); - Elemts.push_back(JnjvmModule::pointerSizeType); + Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0)); + Elemts.push_back(J3Intrinsics::pointerSizeType); Elemts.push_back(ATy); @@ -1303,7 +1303,7 @@ std::vector Cts; Cts.push_back(CreateConstantForBaseObject(val->getClass())); - Cts.push_back(ConstantInt::get(JnjvmModule::pointerSizeType, val->size)); + Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size)); std::vector Vals; for (sint32 i = 0; i < val->size; ++i) { @@ -1311,7 +1311,7 @@ Vals.push_back(getFinalObject(val->elements[i], val->getClass()->asArrayClass()->baseClass())); } else { - Vals.push_back(Constant::getNullValue(JnjvmModule::JavaObjectType)); + Vals.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType)); } } @@ -1323,7 +1323,7 @@ Constant* JavaAOTCompiler::CreateConstantFromUTF8(const UTF8* val) { std::vector Elemts; const ArrayType* ATy = ArrayType::get(Type::getInt16Ty(getGlobalContext()), val->size); - Elemts.push_back(JnjvmModule::pointerSizeType); + Elemts.push_back(J3Intrinsics::pointerSizeType); Elemts.push_back(ATy); @@ -1331,7 +1331,7 @@ Elemts); std::vector Cts; - Cts.push_back(ConstantInt::get(JnjvmModule::pointerSizeType, val->size)); + Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size)); std::vector Vals; for (sint32 i = 0; i < val->size; ++i) { @@ -1355,7 +1355,7 @@ C, ""); Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV, - JnjvmModule::UTF8Type); + J3Intrinsics::UTF8Type); utf8s.insert(std::make_pair(val, res)); return res; @@ -1372,7 +1372,7 @@ VT : ClassArray::SuperArray->virtualVT; const ArrayType* ATy = - dyn_cast(JnjvmModule::VTType->getContainedType(0)); + dyn_cast(J3Intrinsics::VTType->getContainedType(0)); const PointerType* PTy = dyn_cast(ATy->getContainedType(0)); ATy = ArrayType::get(PTy, size); @@ -1439,7 +1439,7 @@ ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->nbSecondaryTypes), PTy)); // secondaryTypes - const ArrayType* DTy = ArrayType::get(JnjvmModule::VTType, + const ArrayType* DTy = ArrayType::get(J3Intrinsics::VTType, VT->nbSecondaryTypes); std::vector TempElmts; @@ -1479,7 +1479,7 @@ const ArrayType* ATy = - dyn_cast(JnjvmModule::VTType->getContainedType(0)); + dyn_cast(J3Intrinsics::VTType->getContainedType(0)); const PointerType* PTy = dyn_cast(ATy->getContainedType(0)); ATy = ArrayType::get(PTy, InterfaceMethodTable::NumIndexes); @@ -1525,7 +1525,7 @@ uint32_t length = 2 * size; const ArrayType* ATy = - dyn_cast(JnjvmModule::VTType->getContainedType(0)); + dyn_cast(J3Intrinsics::VTType->getContainedType(0)); ATy = ArrayType::get(PTy, length); std::vector InternalElemts; @@ -1600,7 +1600,7 @@ compileRT = false; std::vector llvmArgs; - llvmArgs.push_back(JnjvmModule::ptrType); // class loader. + llvmArgs.push_back(J3Intrinsics::ptrType); // class loader. const FunctionType* FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); StaticInitializer = Function::Create(FTy, GlobalValue::InternalLinkage, @@ -1612,9 +1612,9 @@ "staticCallback", getLLVMModule()); llvmArgs.clear(); - llvmArgs.push_back(JnjvmModule::JavaMethodType); + llvmArgs.push_back(J3Intrinsics::JavaMethodType); - FTy = FunctionType::get(JnjvmModule::ptrType, llvmArgs, false); + FTy = FunctionType::get(J3Intrinsics::ptrType, llvmArgs, false); NativeLoader = Function::Create(FTy, GlobalValue::ExternalLinkage, "vmjcNativeLoader", getLLVMModule()); @@ -1651,7 +1651,7 @@ Module* Mod = getLLVMModule(); for (Module::const_global_iterator i = Mod->global_begin(), e = Mod->global_end(); i != e; ++i) { - size += JnjvmModule::getTypeSize(i->getType()); + size += J3Intrinsics::getTypeSize(i->getType()); } fprintf(stderr, "%lluB\n", (unsigned long long int)size); } @@ -1691,8 +1691,8 @@ void JavaAOTCompiler::CreateStaticInitializer() { std::vector llvmArgs; - llvmArgs.push_back(JnjvmModule::ptrType); // class loader - llvmArgs.push_back(JnjvmModule::JavaCommonClassType); // cl + llvmArgs.push_back(J3Intrinsics::ptrType); // class loader + llvmArgs.push_back(J3Intrinsics::JavaCommonClassType); // cl const FunctionType* FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); @@ -1702,11 +1702,11 @@ llvmArgs.clear(); // class loader - llvmArgs.push_back(JnjvmModule::ptrType); + llvmArgs.push_back(J3Intrinsics::ptrType); // array ptr - llvmArgs.push_back(PointerType::getUnqual(JnjvmModule::JavaClassArrayType)); + llvmArgs.push_back(PointerType::getUnqual(J3Intrinsics::JavaClassArrayType)); // name - llvmArgs.push_back(JnjvmModule::UTF8Type); + llvmArgs.push_back(J3Intrinsics::UTF8Type); FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); Function* GetClassArray = Function::Create(FTy, GlobalValue::ExternalLinkage, @@ -1720,7 +1720,7 @@ // If we have defined some strings. if (strings.begin() != strings.end()) { llvmArgs.clear(); - llvmArgs.push_back(JnjvmModule::ptrType); // class loader + llvmArgs.push_back(J3Intrinsics::ptrType); // class loader llvmArgs.push_back(strings.begin()->second->getType()); // val FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); @@ -1741,7 +1741,7 @@ // If we have defined some UTF8s. if (utf8s.begin() != utf8s.end()) { llvmArgs.clear(); - llvmArgs.push_back(JnjvmModule::ptrType); // class loader + llvmArgs.push_back(J3Intrinsics::ptrType); // class loader llvmArgs.push_back(utf8s.begin()->second->getType()); // val FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); @@ -1763,7 +1763,7 @@ if (isCompiling(i->first)) { Args[0] = loader; Args[1] = ConstantExpr::getBitCast(i->second, - JnjvmModule::JavaCommonClassType); + J3Intrinsics::JavaCommonClassType); CallInst::Create(AddClass, Args, Args + 2, "", currentBlock); } } Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sun Feb 14 16:07:42 2010 @@ -38,7 +38,8 @@ #include "Jnjvm.h" #include "Reader.h" -#include "j3/JnjvmModule.h" +#include "j3/JavaLLVMCompiler.h" +#include "j3/J3Intrinsics.h" using namespace j3; using namespace llvm; @@ -119,11 +120,11 @@ PHINode* node = 0; #if 0 if (meth && !isAbstract(meth->access)) { - Value* cl = CallInst::Create(module->GetClassFunction, args[0], "", + Value* cl = CallInst::Create(intrinsics->GetClassFunction, args[0], "", currentBlock); - Value* cl2 = module->getNativeClass(meth->classDef); - if (cl2->getType() != module->JavaCommonClassType) { - cl2 = new BitCastInst(cl2, module->JavaCommonClassType, "", currentBlock); + Value* cl2 = intrinsics->getNativeClass(meth->classDef); + if (cl2->getType() != intrinsics->JavaCommonClassType) { + cl2 = new BitCastInst(cl2, intrinsics->JavaCommonClassType, "", currentBlock); } Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, cl, cl2, ""); @@ -137,7 +138,7 @@ if (canBeInlined(meth)) { res = invokeInline(meth, args); } else { - Function* func = module->getMethod(meth); + Function* func = intrinsics->getMethod(meth); res = invoke(func, args, "", currentBlock); } BranchInst::Create(endBlock, currentBlock); @@ -149,10 +150,10 @@ } #endif - Value* VT = CallInst::Create(module->GetVTFunction, args[0], "", + Value* VT = CallInst::Create(intrinsics->GetVTFunction, args[0], "", currentBlock); Value* indexes2[2]; - indexes2[0] = module->constantZero; + indexes2[0] = intrinsics->constantZero; #ifdef ISOLATE_SHARING Value* indexesCtp; //[3]; @@ -171,7 +172,7 @@ Type::getInt32Ty(*llvmContext), false, GlobalValue::ExternalLinkage, - module->constantZero, ""); + intrinsics->constantZero, ""); BasicBlock* resolveVirtual = createBasicBlock("resolveVirtual"); BasicBlock* endResolveVirtual = createBasicBlock("endResolveVirtual"); @@ -180,7 +181,7 @@ Value* load = new LoadInst(GV, "", false, currentBlock); Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, load, - module->constantZero, ""); + intrinsics->constantZero, ""); BranchInst::Create(resolveVirtual, endResolveVirtual, test, currentBlock); node->addIncoming(load, currentBlock); currentBlock = resolveVirtual; @@ -189,14 +190,14 @@ Args.push_back(ConstantInt::get(Type::getInt32Ty(*llvmContext), index)); Args.push_back(GV); Args.push_back(args[0]); - load = invoke(module->VirtualLookupFunction, Args, "", currentBlock); + load = invoke(intrinsics->VirtualLookupFunction, Args, "", currentBlock); node->addIncoming(load, currentBlock); BranchInst::Create(endResolveVirtual, currentBlock); currentBlock = endResolveVirtual; indexes2[1] = node; #ifdef ISOLATE_SHARING - Value* mul = BinaryOperator::CreateMul(val, module->constantMinusOne, + Value* mul = BinaryOperator::CreateMul(val, intrinsics->constantMinusOne, "", currentBlock); indexesCtp = mul; #endif @@ -212,7 +213,7 @@ Value* CTP = GetElementPtrInst::Create(VT, indexesCtp, "", currentBlock); CTP = new LoadInst(CTP, "", currentBlock); - CTP = new BitCastInst(CTP, module->ConstantPoolType, "", currentBlock); + CTP = new BitCastInst(CTP, intrinsics->ConstantPoolType, "", currentBlock); args.push_back(CTP); #endif Value* val = invoke(Func, args, "", currentBlock); @@ -227,13 +228,13 @@ } if (retType != Type::getVoidTy(getGlobalContext())) { - if (retType == module->JavaObjectType) { + if (retType == intrinsics->JavaObjectType) { JnjvmClassLoader* JCL = compilingClass->classLoader; push(val, false, signature->getReturnType()->findAssocClass(JCL)); } else { push(val, retTypedef->isUnsigned()); if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) { - push(module->constantZero, false); + push(intrinsics->constantZero, false); } } } @@ -244,11 +245,11 @@ } llvm::Value* JavaJIT::getCurrentThread(const llvm::Type* Ty) { - Value* FrameAddr = CallInst::Create(module->llvm_frameaddress, - module->constantZero, "", currentBlock); - Value* threadId = new PtrToIntInst(FrameAddr, module->pointerSizeType, "", + Value* FrameAddr = CallInst::Create(intrinsics->llvm_frameaddress, + intrinsics->constantZero, "", currentBlock); + Value* threadId = new PtrToIntInst(FrameAddr, intrinsics->pointerSizeType, "", currentBlock); - threadId = BinaryOperator::CreateAnd(threadId, module->constantThreadIDMask, + threadId = BinaryOperator::CreateAnd(threadId, intrinsics->constantThreadIDMask, "", currentBlock); threadId = new IntToPtrInst(threadId, Ty, "", currentBlock); @@ -286,7 +287,7 @@ if (!natPtr && !TheCompiler->isStaticCompiling()) { currentBlock = createBasicBlock("start"); - CallInst::Create(module->ThrowExceptionFromJITFunction, "", currentBlock); + CallInst::Create(intrinsics->ThrowExceptionFromJITFunction, "", currentBlock); if (returnType != Type::getVoidTy(getGlobalContext())) ReturnInst::Create(*llvmContext, Constant::getNullValue(returnType), currentBlock); else @@ -319,7 +320,7 @@ // Allocate currentLocalIndexNumber pointer Value* temp = new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", currentBlock); - new StoreInst(module->constantZero, temp, false, currentBlock); + new StoreInst(intrinsics->constantZero, temp, false, currentBlock); // Allocate oldCurrentLocalIndexNumber pointer Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "", @@ -336,15 +337,15 @@ std::vector nativeArgs; - Value* threadId = getCurrentThread(module->JavaThreadType); + Value* threadId = getCurrentThread(intrinsics->JavaThreadType); - Value* geps[2] = { module->constantZero, - module->OffsetJNIInThreadConstant }; + Value* geps[2] = { intrinsics->constantZero, + intrinsics->OffsetJNIInThreadConstant }; Value* jniEnv = GetElementPtrInst::Create(threadId, geps, geps + 2, "", currentBlock); - jniEnv = new BitCastInst(jniEnv, module->ptrType, "", currentBlock); + jniEnv = new BitCastInst(jniEnv, intrinsics->ptrType, "", currentBlock); nativeArgs.push_back(jniEnv); @@ -352,7 +353,7 @@ if (stat) { #ifdef ISOLATE_SHARING Value* val = getClassCtp(); - Value* cl = CallInst::Create(module->GetClassDelegateePtrFunction, + Value* cl = CallInst::Create(intrinsics->GetClassDelegateePtrFunction, val, "", currentBlock); #else Value* cl = TheCompiler->getJavaClassPtr(compilingClass); @@ -365,31 +366,31 @@ for (Function::arg_iterator i = func->arg_begin(); index < nargs; ++i, ++index) { - if (i->getType() == module->JavaObjectType) { + if (i->getType() == intrinsics->JavaObjectType) { BasicBlock* BB = createBasicBlock(""); BasicBlock* NotZero = createBasicBlock(""); - const Type* Ty = PointerType::getUnqual(module->JavaObjectType); + const Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType); PHINode* node = PHINode::Create(Ty, "", BB); Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, i, - module->JavaObjectNullConstant, ""); + intrinsics->JavaObjectNullConstant, ""); node->addIncoming(Constant::getNullValue(Ty), currentBlock); BranchInst::Create(BB, NotZero, test, currentBlock); currentBlock = NotZero; - Instruction* temp = new AllocaInst(module->JavaObjectType, "", + Instruction* temp = new AllocaInst(intrinsics->JavaObjectType, "", func->begin()->getTerminator()); if (TheCompiler->useCooperativeGC()) { Value* GCArgs[2] = { - new BitCastInst(temp, module->ptrPtrType, "", + new BitCastInst(temp, intrinsics->ptrPtrType, "", func->begin()->getTerminator()), - module->constantPtrNull + intrinsics->constantPtrNull }; - CallInst::Create(module->llvm_gc_gcroot, GCArgs, GCArgs + 2, "", + CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, GCArgs + 2, "", func->begin()->getTerminator()); } @@ -407,21 +408,21 @@ Instruction* ResultObject = 0; - if (returnType == module->JavaObjectType) { - ResultObject = new AllocaInst(module->JavaObjectType, "", + if (returnType == intrinsics->JavaObjectType) { + ResultObject = new AllocaInst(intrinsics->JavaObjectType, "", func->begin()->begin()); if (TheCompiler->useCooperativeGC()) { Value* GCArgs[2] = { - new BitCastInst(ResultObject, module->ptrPtrType, "", currentBlock), - module->constantPtrNull + new BitCastInst(ResultObject, intrinsics->ptrPtrType, "", currentBlock), + intrinsics->constantPtrNull }; - CallInst::Create(module->llvm_gc_gcroot, GCArgs, GCArgs + 2, "", + CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, GCArgs + 2, "", currentBlock); } else { - new StoreInst(module->JavaObjectNullConstant, ResultObject, "", + new StoreInst(intrinsics->JavaObjectNullConstant, ResultObject, "", currentBlock); } } @@ -457,19 +458,19 @@ Value* Args4[3] = { temp, oldCLIN, Frame }; - CallInst::Create(module->StartJNIFunction, Args4, Args4 + 3, "", + CallInst::Create(intrinsics->StartJNIFunction, Args4, Args4 + 3, "", currentBlock); Value* result = llvm::CallInst::Create(nativeFunc, nativeArgs.begin(), nativeArgs.end(), "", currentBlock); - if (returnType == module->JavaObjectType) { - const Type* Ty = PointerType::getUnqual(module->JavaObjectType); + if (returnType == intrinsics->JavaObjectType) { + const Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType); Constant* C = Constant::getNullValue(Ty); Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, result, C, ""); BasicBlock* loadBlock = createBasicBlock(""); - endNode->addIncoming(module->JavaObjectNullConstant, currentBlock); + endNode->addIncoming(intrinsics->JavaObjectNullConstant, currentBlock); BranchInst::Create(endBlock, loadBlock, cmp, currentBlock); currentBlock = loadBlock; @@ -488,7 +489,7 @@ Value* Args2[1] = { oldCLIN }; - CallInst::Create(module->EndJNIFunction, Args2, Args2 + 1, "", currentBlock); + CallInst::Create(intrinsics->EndJNIFunction, Args2, Args2 + 1, "", currentBlock); // Synchronize after leaving native. if (isSynchro(compilingMethod->access)) @@ -509,23 +510,23 @@ void JavaJIT::monitorEnter(Value* obj) { std::vector gep; - gep.push_back(module->constantZero); - gep.push_back(module->JavaObjectLockOffsetConstant); + gep.push_back(intrinsics->constantZero); + gep.push_back(intrinsics->JavaObjectLockOffsetConstant); Value* lockPtr = GetElementPtrInst::Create(obj, gep.begin(), gep.end(), "", currentBlock); Value* lock = new LoadInst(lockPtr, "", currentBlock); - lock = new PtrToIntInst(lock, module->pointerSizeType, "", currentBlock); - Value* GCMask = ConstantInt::get(module->pointerSizeType, + lock = new PtrToIntInst(lock, intrinsics->pointerSizeType, "", currentBlock); + Value* GCMask = ConstantInt::get(intrinsics->pointerSizeType, mvm::GCMask); lock = BinaryOperator::CreateAnd(lock, GCMask, "", currentBlock); lockPtr = new BitCastInst(lockPtr, - PointerType::getUnqual(module->pointerSizeType), + PointerType::getUnqual(intrinsics->pointerSizeType), "", currentBlock); - Value* threadId = getCurrentThread(module->MutatorThreadType); - threadId = new PtrToIntInst(threadId, module->pointerSizeType, "", + Value* threadId = getCurrentThread(intrinsics->MutatorThreadType); + threadId = new PtrToIntInst(threadId, intrinsics->pointerSizeType, "", currentBlock); Value* newValMask = BinaryOperator::CreateOr(threadId, lock, "", currentBlock); @@ -536,7 +537,7 @@ atomicArgs.push_back(newValMask); // Do the atomic compare and swap. - Value* atomic = CallInst::Create(module->llvm_atomic_lcs_ptr, + Value* atomic = CallInst::Create(intrinsics->llvm_atomic_lcs_ptr, atomicArgs.begin(), atomicArgs.end(), "", currentBlock); @@ -553,17 +554,17 @@ currentBlock = NotOK; // The compare and swap did not pass, look if it's a thin lock - Value* isThin = BinaryOperator::CreateAnd(atomic, module->constantFatMask, "", + Value* isThin = BinaryOperator::CreateAnd(atomic, intrinsics->constantFatMask, "", currentBlock); cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, isThin, - module->constantPtrZero, ""); + intrinsics->constantPtrZero, ""); BranchInst::Create(ThinLockBB, FatLockBB, cmp, currentBlock); // It's a thin lock. Look if we're the owner of this lock. currentBlock = ThinLockBB; - Value* idMask = ConstantInt::get(module->pointerSizeType, mvm::Thread::IDMask); - Value* cptMask = ConstantInt::get(module->pointerSizeType, mvm::ThinCountMask); + Value* idMask = ConstantInt::get(intrinsics->pointerSizeType, mvm::Thread::IDMask); + Value* cptMask = ConstantInt::get(intrinsics->pointerSizeType, mvm::ThinCountMask); Value* IdInLock = BinaryOperator::CreateAnd(atomic, idMask, "", currentBlock); Value* owner = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, threadId, IdInLock, ""); @@ -584,7 +585,7 @@ currentBlock = IncCounterBB; // The counter will not overflow, increment it. - Value* One = ConstantInt::get(module->pointerSizeType, mvm::ThinCountAdd); + Value* One = ConstantInt::get(intrinsics->pointerSizeType, mvm::ThinCountAdd); Value* Add = BinaryOperator::CreateAdd(One, atomic, "", currentBlock); new StoreInst(Add, lockPtr, false, currentBlock); BranchInst::Create(OK, currentBlock); @@ -593,33 +594,33 @@ // The counter will overflow, call this function to create a new lock, // lock it 0x101 times, and pass. - CallInst::Create(module->OverflowThinLockFunction, obj, "", + CallInst::Create(intrinsics->OverflowThinLockFunction, obj, "", currentBlock); BranchInst::Create(OK, currentBlock); currentBlock = FatLockBB; // Either it's a fat lock or there is contention. - CallInst::Create(module->AquireObjectFunction, obj, "", currentBlock); + CallInst::Create(intrinsics->AquireObjectFunction, obj, "", currentBlock); BranchInst::Create(OK, currentBlock); currentBlock = OK; } void JavaJIT::monitorExit(Value* obj) { std::vector gep; - gep.push_back(module->constantZero); - gep.push_back(module->JavaObjectLockOffsetConstant); + gep.push_back(intrinsics->constantZero); + gep.push_back(intrinsics->JavaObjectLockOffsetConstant); Value* lockPtr = GetElementPtrInst::Create(obj, gep.begin(), gep.end(), "", currentBlock); lockPtr = new BitCastInst(lockPtr, - PointerType::getUnqual(module->pointerSizeType), + PointerType::getUnqual(intrinsics->pointerSizeType), "", currentBlock); Value* lock = new LoadInst(lockPtr, "", currentBlock); - Value* GCMask = ConstantInt::get(module->pointerSizeType, ~mvm::GCMask); + Value* GCMask = ConstantInt::get(intrinsics->pointerSizeType, ~mvm::GCMask); Value* lockedMask = BinaryOperator::CreateAnd(lock, GCMask, "", currentBlock); - Value* threadId = getCurrentThread(module->MutatorThreadType); - threadId = new PtrToIntInst(threadId, module->pointerSizeType, "", + Value* threadId = getCurrentThread(intrinsics->MutatorThreadType); + threadId = new PtrToIntInst(threadId, intrinsics->pointerSizeType, "", currentBlock); Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, lockedMask, @@ -637,24 +638,24 @@ // Locked once, set zero currentBlock = LockedOnceBB; - GCMask = ConstantInt::get(module->pointerSizeType, mvm::GCMask); + GCMask = ConstantInt::get(intrinsics->pointerSizeType, mvm::GCMask); lockedMask = BinaryOperator::CreateAnd(lock, GCMask, "", currentBlock); new StoreInst(lockedMask, lockPtr, false, currentBlock); BranchInst::Create(EndUnlock, currentBlock); currentBlock = NotLockedOnceBB; // Look if the lock is thin. - Value* isThin = BinaryOperator::CreateAnd(lock, module->constantFatMask, "", + Value* isThin = BinaryOperator::CreateAnd(lock, intrinsics->constantFatMask, "", currentBlock); cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, isThin, - module->constantPtrZero, ""); + intrinsics->constantPtrZero, ""); BranchInst::Create(ThinLockBB, FatLockBB, cmp, currentBlock); currentBlock = ThinLockBB; // Decrement the counter. - Value* One = ConstantInt::get(module->pointerSizeType, mvm::ThinCountAdd); + Value* One = ConstantInt::get(intrinsics->pointerSizeType, mvm::ThinCountAdd); Value* Sub = BinaryOperator::CreateSub(lock, One, "", currentBlock); new StoreInst(Sub, lockPtr, false, currentBlock); BranchInst::Create(EndUnlock, currentBlock); @@ -662,7 +663,7 @@ currentBlock = FatLockBB; // Either it's a fat lock or there is contention. - CallInst::Create(module->ReleaseObjectFunction, obj, "", currentBlock); + CallInst::Create(intrinsics->ReleaseObjectFunction, obj, "", currentBlock); BranchInst::Create(EndUnlock, currentBlock); currentBlock = EndUnlock; } @@ -672,7 +673,7 @@ #ifdef ISOLATE_SHARING Value* JavaJIT::getStaticInstanceCtp() { Value* cl = getClassCtp(); - Value* indexes[2] = { module->constantZero, module->constantSeven }; + Value* indexes[2] = { intrinsics->constantZero, module->constantSeven }; Value* arg1 = GetElementPtrInst::Create(cl, indexes, indexes + 2, "", currentBlock); arg1 = new LoadInst(arg1, "", false, currentBlock); @@ -681,11 +682,11 @@ } Value* JavaJIT::getClassCtp() { - Value* indexes = module->constantOne; + Value* indexes = intrinsics->constantOne; Value* arg1 = GetElementPtrInst::Create(ctpCache, indexes.begin(), indexes.end(), "", currentBlock); arg1 = new LoadInst(arg1, "", false, currentBlock); - arg1 = new BitCastInst(arg1, module->JavaClassType, "", currentBlock); + arg1 = new BitCastInst(arg1, intrinsics->JavaClassType, "", currentBlock); return arg1; } #endif @@ -726,7 +727,7 @@ } static void removeUnusedObjects(std::vector& objects, - JnjvmModule* module, bool coop) { + J3Intrinsics* intrinsics, bool coop) { for (std::vector::iterator i = objects.begin(), e = objects.end(); i != e; ++i) { AllocaInst* temp = *i; @@ -738,10 +739,10 @@ temp->eraseFromParent(); } else { if (coop) { - Instruction* I = new BitCastInst(temp, module->ptrPtrType, ""); + Instruction* I = new BitCastInst(temp, intrinsics->ptrPtrType, ""); I->insertAfter(temp); - Value* GCArgs[2] = { I, module->constantPtrNull }; - Instruction* C = CallInst::Create(module->llvm_gc_gcroot, GCArgs, + Value* GCArgs[2] = { I, intrinsics->constantPtrNull }; + Instruction* C = CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, GCArgs + 2, ""); C->insertAfter(I); } @@ -808,15 +809,15 @@ new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, firstInstruction); floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstInstruction)); new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, firstInstruction); - objectLocals.push_back(new AllocaInst(module->JavaObjectType, "", + objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, "", firstInstruction)); // The GCStrategy will already initialize the value. if (!TheCompiler->useCooperativeGC()) - new StoreInst(Constant::getNullValue(module->JavaObjectType), objectLocals.back(), false, firstInstruction); + new StoreInst(Constant::getNullValue(intrinsics->JavaObjectType), objectLocals.back(), false, firstInstruction); } for (int i = 0; i < maxStack; i++) { - objectStack.push_back(new AllocaInst(module->JavaObjectType, "", + objectStack.push_back(new AllocaInst(intrinsics->JavaObjectType, "", firstInstruction)); addHighLevelType(objectStack.back(), upcalls->OfObject); intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstInstruction)); @@ -836,15 +837,15 @@ new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, firstBB); floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstBB)); new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, firstBB); - objectLocals.push_back(new AllocaInst(module->JavaObjectType, "", + objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, "", firstBB)); // The GCStrategy will already initialize the value. if (!TheCompiler->useCooperativeGC()) - new StoreInst(Constant::getNullValue(module->JavaObjectType), objectLocals.back(), false, firstBB); + new StoreInst(Constant::getNullValue(intrinsics->JavaObjectType), objectLocals.back(), false, firstBB); } for (int i = 0; i < maxStack; i++) { - objectStack.push_back(new AllocaInst(module->JavaObjectType, "", + objectStack.push_back(new AllocaInst(intrinsics->JavaObjectType, "", firstBB)); addHighLevelType(objectStack.back(), upcalls->OfObject); intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstBB)); @@ -947,8 +948,8 @@ removeUnusedLocals(floatStack); removeUnusedLocals(longStack); - removeUnusedObjects(objectLocals, module, TheCompiler->useCooperativeGC()); - removeUnusedObjects(objectStack, module, TheCompiler->useCooperativeGC()); + removeUnusedObjects(objectLocals, intrinsics, TheCompiler->useCooperativeGC()); + removeUnusedObjects(objectStack, intrinsics, TheCompiler->useCooperativeGC()); delete[] opcodeInfos; @@ -1000,7 +1001,7 @@ { Value* arg = TheCompiler->getMethodInClass(compilingMethod); - llvm::CallInst::Create(module->PrintMethodStartFunction, arg, "", + llvm::CallInst::Create(intrinsics->PrintMethodStartFunction, arg, "", currentBlock); } #endif @@ -1016,15 +1017,15 @@ new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, currentBlock); floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", currentBlock)); new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, currentBlock); - objectLocals.push_back(new AllocaInst(module->JavaObjectType, "", + objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, "", currentBlock)); // The GCStrategy will already initialize the value. if (!TheCompiler->useCooperativeGC()) - new StoreInst(Constant::getNullValue(module->JavaObjectType), objectLocals.back(), false, currentBlock); + new StoreInst(Constant::getNullValue(intrinsics->JavaObjectType), objectLocals.back(), false, currentBlock); } for (int i = 0; i < maxStack; i++) { - objectStack.push_back(new AllocaInst(module->JavaObjectType, "", + objectStack.push_back(new AllocaInst(intrinsics->JavaObjectType, "", currentBlock)); addHighLevelType(objectStack.back(), upcalls->OfObject); intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", currentBlock)); @@ -1082,7 +1083,7 @@ #if defined(ISOLATE_SHARING) ctpCache = i; - Value* addrCtpCache = new AllocaInst(module->ConstantPoolType, "", + Value* addrCtpCache = new AllocaInst(intrinsics->ConstantPoolType, "", currentBlock); /// make it volatile to be sure it's on the stack new StoreInst(ctpCache, addrCtpCache, true, currentBlock); @@ -1099,16 +1100,16 @@ Value* NewIsolate = 0; Value* IsolatePtr = 0; if (loader != loader->bootstrapLoader && isPublic(compilingMethod->access)) { - threadId = getCurrentThread(module->MutatorThreadType); + threadId = getCurrentThread(intrinsics->MutatorThreadType); - IsolateIDPtr = GetElementPtrInst::Create(threadId, module->constantThree, + IsolateIDPtr = GetElementPtrInst::Create(threadId, intrinsics->constantThree, "", currentBlock); - const Type* realType = PointerType::getUnqual(module->pointerSizeType); + const Type* realType = PointerType::getUnqual(intrinsics->pointerSizeType); IsolateIDPtr = new BitCastInst(IsolateIDPtr, realType, "", currentBlock); OldIsolateID = new LoadInst(IsolateIDPtr, "", currentBlock); - Value* MyID = ConstantInt::get(module->pointerSizeType, + Value* MyID = ConstantInt::get(intrinsics->pointerSizeType, loader->getIsolate()->IsolateID); Cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, OldIsolateID, MyID, ""); @@ -1121,16 +1122,16 @@ currentBlock = ServiceBB; new StoreInst(MyID, IsolateIDPtr, currentBlock); - IsolatePtr = GetElementPtrInst::Create(threadId, module->constantFour, "", + IsolatePtr = GetElementPtrInst::Create(threadId, intrinsics->constantFour, "", currentBlock); OldIsolate = new LoadInst(IsolatePtr, "", currentBlock); - NewIsolate = module->getIsolate(loader->getIsolate(), currentBlock); + NewIsolate = intrinsics->getIsolate(loader->getIsolate(), currentBlock); new StoreInst(NewIsolate, IsolatePtr, currentBlock); #if DEBUG Value* GEP[2] = { OldIsolate, NewIsolate }; - CallInst::Create(module->ServiceCallStartFunction, GEP, GEP + 2, + CallInst::Create(intrinsics->ServiceCallStartFunction, GEP, GEP + 2, "", currentBlock); #endif BranchInst::Create(EndBB, currentBlock); @@ -1172,30 +1173,30 @@ // Variables have been allocated and the lock has been taken. Do the stack // check now: if there is an exception, we will go to the lock release code. currentExceptionBlock = opcodeInfos[0].exceptionBlock; - Value* FrameAddr = CallInst::Create(module->llvm_frameaddress, - module->constantZero, "", currentBlock); - FrameAddr = new PtrToIntInst(FrameAddr, module->pointerSizeType, "", + Value* FrameAddr = CallInst::Create(intrinsics->llvm_frameaddress, + intrinsics->constantZero, "", currentBlock); + FrameAddr = new PtrToIntInst(FrameAddr, intrinsics->pointerSizeType, "", currentBlock); Value* stackCheck = - BinaryOperator::CreateAnd(FrameAddr, module->constantStackOverflowMask, + BinaryOperator::CreateAnd(FrameAddr, intrinsics->constantStackOverflowMask, "", currentBlock); stackCheck = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, stackCheck, - module->constantPtrZero, ""); + intrinsics->constantPtrZero, ""); BasicBlock* stackOverflow = createBasicBlock("stack overflow"); BasicBlock* noStackOverflow = createBasicBlock("no stack overflow"); BranchInst::Create(stackOverflow, noStackOverflow, stackCheck, currentBlock); currentBlock = stackOverflow; - throwException(module->StackOverflowErrorFunction, 0, 0); + throwException(intrinsics->StackOverflowErrorFunction, 0, 0); currentBlock = noStackOverflow; } if (TheCompiler->useCooperativeGC()) { - Value* threadId = getCurrentThread(module->MutatorThreadType); + Value* threadId = getCurrentThread(intrinsics->MutatorThreadType); - Value* GEP[2] = { module->constantZero, - module->OffsetDoYieldInThreadConstant }; + Value* GEP[2] = { intrinsics->constantZero, + intrinsics->OffsetDoYieldInThreadConstant }; Value* YieldPtr = GetElementPtrInst::Create(threadId, GEP, GEP + 2, "", currentBlock); @@ -1207,7 +1208,7 @@ BranchInst::Create(yieldBlock, continueBlock, Yield, currentBlock); currentBlock = yieldBlock; - CallInst::Create(module->conditionalSafePoint, "", currentBlock); + CallInst::Create(intrinsics->conditionalSafePoint, "", currentBlock); BranchInst::Create(continueBlock, currentBlock); currentBlock = continueBlock; @@ -1243,7 +1244,7 @@ #if JNJVM_EXECUTE > 0 { Value* arg = TheCompiler->getMethodInClass(compilingMethod); - CallInst::Create(module->PrintMethodEndFunction, arg, "", currentBlock); + CallInst::Create(intrinsics->PrintMethodEndFunction, arg, "", currentBlock); } #endif @@ -1261,7 +1262,7 @@ #if DEBUG Value* GEP[2] = { OldIsolate, NewIsolate }; - CallInst::Create(module->ServiceCallStopFunction, GEP, GEP + 2, + CallInst::Create(intrinsics->ServiceCallStopFunction, GEP, GEP + 2, "", currentBlock); #endif BranchInst::Create(EndBB, currentBlock); @@ -1293,8 +1294,8 @@ removeUnusedLocals(floatStack); removeUnusedLocals(longStack); - removeUnusedObjects(objectLocals, module, TheCompiler->useCooperativeGC()); - removeUnusedObjects(objectStack, module, TheCompiler->useCooperativeGC()); + removeUnusedObjects(objectLocals, intrinsics, TheCompiler->useCooperativeGC()); + removeUnusedObjects(objectStack, intrinsics, TheCompiler->useCooperativeGC()); delete[] opcodeInfos; @@ -1330,9 +1331,9 @@ } void JavaJIT::compareFP(Value* val1, Value* val2, const Type* ty, bool l) { - Value* one = module->constantOne; - Value* zero = module->constantZero; - Value* minus = module->constantMinusOne; + Value* one = intrinsics->constantOne; + Value* zero = intrinsics->constantZero; + Value* minus = intrinsics->constantMinusOne; Value* c = new FCmpInst(*currentBlock, FCmpInst::FCMP_UGT, val1, val2, ""); Value* r = llvm::SelectInst::Create(c, one, zero, "", currentBlock); @@ -1367,8 +1368,8 @@ push(val, false, upcalls->newString); } else { // Lookup the constant pool cache - const llvm::Type* Ty = PointerType::getUnqual(module->JavaObjectType); - Value* val = getConstantPoolAt(index, module->StringLookupFunction, + const llvm::Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType); + Value* val = getConstantPoolAt(index, intrinsics->StringLookupFunction, Ty, 0, false); val = new LoadInst(val, "", currentBlock); push(val, false, upcalls->newString); @@ -1391,7 +1392,7 @@ UserCommonClass* cl = 0; Value* res = getResolvedCommonClass(index, false, &cl); - res = CallInst::Create(module->GetClassDelegateeFunction, res, "", + res = CallInst::Create(intrinsics->GetClassDelegateeFunction, res, "", currentBlock); push(res, false, upcalls->newClass); } else { @@ -1406,7 +1407,7 @@ void JavaJIT::JITVerifyNull(Value* obj) { if (TheCompiler->hasExceptionsEnabled()) { - Constant* zero = module->JavaObjectNullConstant; + Constant* zero = intrinsics->JavaObjectNullConstant; Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj, zero, ""); BasicBlock* exit = createBasicBlock("verifyNullExit"); @@ -1414,7 +1415,7 @@ BranchInst::Create(exit, cont, test, currentBlock); currentBlock = exit; - throwException(module->NullPointerExceptionFunction, 0, 0); + throwException(intrinsics->NullPointerExceptionFunction, 0, 0); currentBlock = cont; } @@ -1441,14 +1442,14 @@ currentBlock = ifFalse; Value* args[2] = { obj, index }; - throwException(module->IndexOutOfBoundsExceptionFunction, args, 2); + throwException(intrinsics->IndexOutOfBoundsExceptionFunction, args, 2); currentBlock = ifTrue; } - Constant* zero = module->constantZero; + Constant* zero = intrinsics->constantZero; Value* val = new BitCastInst(obj, arrayType, "", currentBlock); - Value* indexes[3] = { zero, module->JavaArrayElementsOffsetConstant, index }; + Value* indexes[3] = { zero, intrinsics->JavaArrayElementsOffsetConstant, index }; Value* ptr = GetElementPtrInst::Create(val, indexes, indexes + 3, "", currentBlock); @@ -1498,8 +1499,8 @@ if (name->equals(loader->abs)) { const Type* Ty = args[0]->getType(); if (Ty == Type::getInt32Ty(getGlobalContext())) { - Constant* const_int32_9 = module->constantZero; - Constant* const_int32_10 = module->constantMinusOne; + Constant* const_int32_9 = intrinsics->constantZero; + Constant* const_int32_10 = intrinsics->constantMinusOne; BinaryOperator* int32_tmpneg = BinaryOperator::Create(Instruction::Sub, const_int32_9, args[0], "tmpneg", currentBlock); @@ -1509,8 +1510,8 @@ return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg, "abs", currentBlock); } else if (Ty == Type::getInt64Ty(getGlobalContext())) { - Constant* const_int64_9 = module->constantLongZero; - Constant* const_int64_10 = module->constantLongMinusOne; + Constant* const_int64_9 = intrinsics->constantLongZero; + Constant* const_int64_10 = intrinsics->constantLongMinusOne; BinaryOperator* int64_tmpneg = BinaryOperator::Create(Instruction::Sub, const_int64_9, args[0], @@ -1522,78 +1523,78 @@ return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg, "abs", currentBlock); } else if (Ty == Type::getFloatTy(getGlobalContext())) { - return llvm::CallInst::Create(module->func_llvm_fabs_f32, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_fabs_f32, args[0], "tmp1", currentBlock); } else if (Ty == Type::getDoubleTy(getGlobalContext())) { - return llvm::CallInst::Create(module->func_llvm_fabs_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_fabs_f64, args[0], "tmp1", currentBlock); } } else if (name->equals(loader->sqrt)) { - return llvm::CallInst::Create(module->func_llvm_sqrt_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_sqrt_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->sin)) { - return llvm::CallInst::Create(module->func_llvm_sin_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_sin_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->cos)) { - return llvm::CallInst::Create(module->func_llvm_cos_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_cos_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->tan)) { - return llvm::CallInst::Create(module->func_llvm_tan_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_tan_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->asin)) { - return llvm::CallInst::Create(module->func_llvm_asin_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_asin_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->acos)) { - return llvm::CallInst::Create(module->func_llvm_acos_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_acos_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->atan)) { - return llvm::CallInst::Create(module->func_llvm_atan_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_atan_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->atan2)) { - return llvm::CallInst::Create(module->func_llvm_atan2_f64, + return llvm::CallInst::Create(intrinsics->func_llvm_atan2_f64, args.begin(), args.end(), "tmp1", currentBlock); } else if (name->equals(loader->exp)) { - return llvm::CallInst::Create(module->func_llvm_exp_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_exp_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->log)) { - return llvm::CallInst::Create(module->func_llvm_log_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_log_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->pow)) { - return llvm::CallInst::Create(module->func_llvm_pow_f64, args.begin(), + return llvm::CallInst::Create(intrinsics->func_llvm_pow_f64, args.begin(), args.end(), "tmp1", currentBlock); } else if (name->equals(loader->ceil)) { - return llvm::CallInst::Create(module->func_llvm_ceil_f64, args[0], "tmp1", + return llvm::CallInst::Create(intrinsics->func_llvm_ceil_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->floor)) { - return llvm::CallInst::Create(module->func_llvm_floor_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_floor_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->rint)) { - return llvm::CallInst::Create(module->func_llvm_rint_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_rint_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->cbrt)) { - return llvm::CallInst::Create(module->func_llvm_cbrt_f64, args[0], "tmp1", + return llvm::CallInst::Create(intrinsics->func_llvm_cbrt_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->cosh)) { - return llvm::CallInst::Create(module->func_llvm_cosh_f64, args[0], "tmp1", + return llvm::CallInst::Create(intrinsics->func_llvm_cosh_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->expm1)) { - return llvm::CallInst::Create(module->func_llvm_expm1_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_expm1_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->hypot)) { - return llvm::CallInst::Create(module->func_llvm_hypot_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_hypot_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->log10)) { - return llvm::CallInst::Create(module->func_llvm_log10_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_log10_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->log1p)) { - return llvm::CallInst::Create(module->func_llvm_log1p_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_log1p_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->sinh)) { - return llvm::CallInst::Create(module->func_llvm_sinh_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_sinh_f64, args[0], "tmp1", currentBlock); } else if (name->equals(loader->tanh)) { - return llvm::CallInst::Create(module->func_llvm_tanh_f64, args[0], + return llvm::CallInst::Create(intrinsics->func_llvm_tanh_f64, args[0], "tmp1", currentBlock); } @@ -1648,7 +1649,7 @@ JITVerifyNull(args[0]); #if defined(ISOLATE_SHARING) - const Type* Ty = module->ConstantPoolType; + const Type* Ty = intrinsics->ConstantPoolType; Constant* Nil = Constant::getNullValue(Ty); GlobalVariable* GV = new GlobalVariable(*llvmFunction->getParent(),Ty, false, GlobalValue::ExternalLinkage, Nil, @@ -1665,7 +1666,7 @@ Args.push_back(ctpCache); Args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), index)); Args.push_back(GV); - res = CallInst::Create(module->SpecialCtpLookupFunction, Args.begin(), + res = CallInst::Create(intrinsics->SpecialCtpLookupFunction, Args.begin(), Args.end(), "", falseCl); node->addIncoming(res, falseCl); BranchInst::Create(trueCl, falseCl); @@ -1685,7 +1686,7 @@ UserCommonClass* cl = 0; Value* Cl = getResolvedCommonClass(clIndex, false, &cl); if (!cl) { - CallInst::Create(module->ForceLoadedCheckFunction, Cl, "", + CallInst::Create(intrinsics->ForceLoadedCheckFunction, Cl, "", currentBlock); } } @@ -1699,14 +1700,14 @@ const llvm::Type* retType = virtualType->getReturnType(); if (retType != Type::getVoidTy(getGlobalContext())) { - if (retType == module->JavaObjectType) { + if (retType == intrinsics->JavaObjectType) { JnjvmClassLoader* JCL = compilingClass->classLoader; push(val, false, signature->getReturnType()->findAssocClass(JCL)); } else { push(val, signature->getReturnType()->isUnsigned()); if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) { - push(module->constantZero, false); + push(intrinsics->constantZero, false); } } } @@ -1744,8 +1745,8 @@ #if defined(ISOLATE_SHARING) Value* newCtpCache = getConstantPoolAt(index, - module->StaticCtpLookupFunction, - module->ConstantPoolType, 0, + intrinsics->StaticCtpLookupFunction, + intrinsics->ConstantPoolType, 0, false); args.push_back(newCtpCache); #endif @@ -1754,7 +1755,7 @@ UserClass* cl = 0; Value* Cl = getResolvedClass(clIndex, true, true, &cl); if (!meth || (cl && needsInitialisationCheck(cl, compilingClass))) { - CallInst::Create(module->ForceInitialisationCheckFunction, Cl, "", + CallInst::Create(intrinsics->ForceInitialisationCheckFunction, Cl, "", currentBlock); } @@ -1780,14 +1781,14 @@ const llvm::Type* retType = staticType->getReturnType(); if (retType != Type::getVoidTy(getGlobalContext())) { - if (retType == module->JavaObjectType) { + if (retType == intrinsics->JavaObjectType) { JnjvmClassLoader* JCL = compilingClass->classLoader; push(val, false, signature->getReturnType()->findAssocClass(JCL)); } else { push(val, signature->getReturnType()->isUnsigned()); if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) { - push(module->constantZero, false); + push(intrinsics->constantZero, false); } } } @@ -1801,7 +1802,7 @@ // number-wise. IMO, it's better to have this than Unswitch. #ifdef ISOLATE_SHARING Value* CTP = ctpCache; - Value* Cl = GetElementPtrInst::Create(CTP, module->ConstantOne, "", + Value* Cl = GetElementPtrInst::Create(CTP, intrinsics->ConstantOne, "", currentBlock); Cl = new LoadInst(Cl, "", currentBlock); #else @@ -1819,15 +1820,15 @@ Value* res = 0; if (doThrow) { - res = invoke(module->GetConstantPoolAtFunction, Args, "", + res = invoke(intrinsics->GetConstantPoolAtFunction, Args, "", currentBlock); } else { - res = CallInst::Create(module->GetConstantPoolAtFunction, Args.begin(), + res = CallInst::Create(intrinsics->GetConstantPoolAtFunction, Args.begin(), Args.end(), "", currentBlock); } const Type* realType = - module->GetConstantPoolAtFunction->getReturnType(); + intrinsics->GetConstantPoolAtFunction->getReturnType(); if (returnType == Type::getInt32Ty(getGlobalContext())) { return new PtrToIntInst(res, Type::getInt32Ty(getGlobalContext()), "", currentBlock); } else if (returnType != realType) { @@ -1850,16 +1851,16 @@ // ony primitive arrays are already allocated, verify that the class // array is not external. if (TheCompiler->isStaticCompiling() && cl->isArray() && - node->getType() != module->JavaClassArrayType) { + node->getType() != intrinsics->JavaClassArrayType) { node = new LoadInst(node, "", currentBlock); } - if (node->getType() != module->JavaCommonClassType) { - node = new BitCastInst(node, module->JavaCommonClassType, "", + if (node->getType() != intrinsics->JavaCommonClassType) { + node = new BitCastInst(node, intrinsics->JavaCommonClassType, "", currentBlock); } } else { - node = getConstantPoolAt(index, module->ClassLookupFunction, - module->JavaCommonClassType, 0, doThrow); + node = getConstantPoolAt(index, intrinsics->ClassLookupFunction, + intrinsics->JavaCommonClassType, 0, doThrow); } return node; @@ -1877,16 +1878,16 @@ node = TheCompiler->getNativeClass(cl); needsInit = needsInitialisationCheck(cl, compilingClass); } else { - node = getConstantPoolAt(index, module->ClassLookupFunction, - module->JavaClassType, 0, doThrow); + node = getConstantPoolAt(index, intrinsics->ClassLookupFunction, + intrinsics->JavaClassType, 0, doThrow); } if (clinit && needsInit) { - if (node->getType() != module->JavaClassType) { - node = new BitCastInst(node, module->JavaClassType, "", currentBlock); + if (node->getType() != intrinsics->JavaClassType) { + node = new BitCastInst(node, intrinsics->JavaClassType, "", currentBlock); } - return invoke(module->InitialisationCheckFunction, node, "", + return invoke(intrinsics->InitialisationCheckFunction, node, "", currentBlock); } else { return node; @@ -1908,29 +1909,29 @@ bool needsCheck = needsInitialisationCheck(cl, compilingClass); if (needsCheck) { - Cl = invoke(module->ForceInitialisationCheckFunction, Cl, "", + Cl = invoke(intrinsics->ForceInitialisationCheckFunction, Cl, "", currentBlock); } } else { - VT = CallInst::Create(module->GetVTFromClassFunction, Cl, "", + VT = CallInst::Create(intrinsics->GetVTFromClassFunction, Cl, "", currentBlock); - Size = CallInst::Create(module->GetObjectSizeFromClassFunction, Cl, + Size = CallInst::Create(intrinsics->GetObjectSizeFromClassFunction, Cl, "", currentBlock); } - VT = new BitCastInst(VT, module->ptrType, "", currentBlock); - Instruction* val = invoke(cl ? module->AllocateFunction : - module->AllocateUnresolvedFunction, + VT = new BitCastInst(VT, intrinsics->ptrType, "", currentBlock); + Instruction* val = invoke(cl ? intrinsics->AllocateFunction : + intrinsics->AllocateUnresolvedFunction, Size, VT, "", currentBlock); if (cl && cl->virtualVT->destructor) { - CallInst::Create(module->AddFinalizationCandidate, val, "", currentBlock); + CallInst::Create(intrinsics->AddFinalizationCandidate, val, "", currentBlock); } addHighLevelType(val, cl ? cl : upcalls->OfObject); - val = new BitCastInst(val, module->JavaObjectType, "", currentBlock); + val = new BitCastInst(val, intrinsics->JavaObjectType, "", currentBlock); push(val, false, cl ? cl : upcalls->OfObject); } @@ -1949,18 +1950,18 @@ bool needsCheck = needsInitialisationCheck(field->classDef, compilingClass); if (needsCheck) { - Cl = invoke(module->InitialisationCheckFunction, Cl, "", + Cl = invoke(intrinsics->InitialisationCheckFunction, Cl, "", currentBlock); } #if !defined(ISOLATE) && !defined(ISOLATE_SHARING) if (needsCheck) { - CallInst::Create(module->ForceInitialisationCheckFunction, Cl, "", + CallInst::Create(intrinsics->ForceInitialisationCheckFunction, Cl, "", currentBlock); } object = TheCompiler->getStaticInstance(field->classDef); #else - object = CallInst::Create(module->GetStaticInstanceFunction, Cl, "", + object = CallInst::Create(intrinsics->GetStaticInstanceFunction, Cl, "", currentBlock); #endif } else { @@ -1969,22 +1970,22 @@ Value* objectConvert = new BitCastInst(object, type, "", currentBlock); - Value* args[2] = { module->constantZero, LFI->getOffset() }; + Value* args[2] = { intrinsics->constantZero, LFI->getOffset() }; Value* ptr = llvm::GetElementPtrInst::Create(objectConvert, args, args + 2, "", currentBlock); return ptr; } - const Type* Pty = module->arrayPtrType; - Constant* zero = module->constantZero; + const Type* Pty = intrinsics->arrayPtrType; + Constant* zero = intrinsics->constantZero; - Function* func = stat ? module->StaticFieldLookupFunction : - module->VirtualFieldLookupFunction; + Function* func = stat ? intrinsics->StaticFieldLookupFunction : + intrinsics->VirtualFieldLookupFunction; const Type* returnType = 0; if (stat) - returnType = module->ptrType; + returnType = intrinsics->ptrType; else returnType = Type::getInt32Ty(getGlobalContext()); @@ -2097,7 +2098,7 @@ CommonClass* cl = mvm::Collector::begOf(val) ? val->getClass() : NULL; push(V, false, cl); } else { - Value* V = CallInst::Create(module->GetFinalObjectFieldFunction, ptr, + Value* V = CallInst::Create(intrinsics->GetFinalObjectFieldFunction, ptr, "", currentBlock); JnjvmClassLoader* JCL = compilingClass->classLoader; @@ -2114,7 +2115,7 @@ push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned(), cl); } if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) { - push(module->constantZero, false); + push(intrinsics->constantZero, false); } } @@ -2163,26 +2164,26 @@ if (sign->isPrimitive()) { const PrimitiveTypedef* prim = (PrimitiveTypedef*)sign; if (prim->isInt()) { - F = module->GetFinalInt32FieldFunction; + F = intrinsics->GetFinalInt32FieldFunction; } else if (prim->isByte()) { - F = module->GetFinalInt8FieldFunction; + F = intrinsics->GetFinalInt8FieldFunction; } else if (prim->isBool()) { - F = module->GetFinalInt8FieldFunction; + F = intrinsics->GetFinalInt8FieldFunction; } else if (prim->isShort()) { - F = module->GetFinalInt16FieldFunction; + F = intrinsics->GetFinalInt16FieldFunction; } else if (prim->isChar()) { - F = module->GetFinalInt16FieldFunction; + F = intrinsics->GetFinalInt16FieldFunction; } else if (prim->isLong()) { - F = module->GetFinalLongFieldFunction; + F = intrinsics->GetFinalLongFieldFunction; } else if (prim->isFloat()) { - F = module->GetFinalFloatFieldFunction; + F = intrinsics->GetFinalFloatFieldFunction; } else if (prim->isDouble()) { - F = module->GetFinalDoubleFieldFunction; + F = intrinsics->GetFinalDoubleFieldFunction; } else { abort(); } } else { - F = module->GetFinalObjectFieldFunction; + F = intrinsics->GetFinalObjectFieldFunction; } push(CallInst::Create(F, ptr, "", currentBlock), sign->isUnsigned(), cl); } @@ -2191,7 +2192,7 @@ if (!final) push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned(), cl); if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) { - push(module->constantZero, false); + push(intrinsics->constantZero, false); } } @@ -2229,8 +2230,8 @@ if (meth) { Meth = TheCompiler->getMethodInClass(meth); } else { - Meth = getConstantPoolAt(index, module->InterfaceLookupFunction, - module->JavaMethodType, 0, false); + Meth = getConstantPoolAt(index, intrinsics->InterfaceLookupFunction, + intrinsics->JavaMethodType, 0, false); } BasicBlock* label_bb = createBasicBlock("bb"); @@ -2239,23 +2240,23 @@ BasicBlock* label_bb7 = createBasicBlock("bb7"); // Block entry (label_entry) - Value* VT = CallInst::Create(module->GetVTFunction, args[0], "", + Value* VT = CallInst::Create(intrinsics->GetVTFunction, args[0], "", currentBlock); - Value* IMT = CallInst::Create(module->GetIMTFunction, VT, "", + Value* IMT = CallInst::Create(intrinsics->GetIMTFunction, VT, "", currentBlock); uint32_t tableIndex = InterfaceMethodTable::getIndex(name, signature->keyName); Constant* Index = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), tableIndex); - Value* indices[2] = { module->constantZero, Index }; + Value* indices[2] = { intrinsics->constantZero, Index }; Instruction* ptr_18 = GetElementPtrInst::Create(IMT, indices, indices + 2, "", currentBlock); Instruction* int32_19 = new LoadInst(ptr_18, "", false, currentBlock); - int32_19 = new PtrToIntInst(int32_19, module->pointerSizeType, "", + int32_19 = new PtrToIntInst(int32_19, intrinsics->pointerSizeType, "", currentBlock); - Value* one = ConstantInt::get(module->pointerSizeType, 1); - Value* zero = ConstantInt::get(module->pointerSizeType, 0); + Value* one = ConstantInt::get(intrinsics->pointerSizeType, 1); + Value* zero = ConstantInt::get(intrinsics->pointerSizeType, 0); BinaryOperator* int32_20 = BinaryOperator::Create(Instruction::And, int32_19, one, "", currentBlock); ICmpInst* int1_toBool = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, @@ -2271,10 +2272,10 @@ // Block bb4 (label_bb4) currentBlock = label_bb4; - Constant* MinusTwo = ConstantInt::get(module->pointerSizeType, -2); + Constant* MinusTwo = ConstantInt::get(intrinsics->pointerSizeType, -2); BinaryOperator* int32_25 = BinaryOperator::Create(Instruction::And, int32_19, MinusTwo, "", currentBlock); - const PointerType* Ty = PointerType::getUnqual(module->JavaMethodType); + const PointerType* Ty = PointerType::getUnqual(intrinsics->JavaMethodType); CastInst* ptr_26 = new IntToPtrInst(int32_25, Ty, "", currentBlock); LoadInst* int32_27 = new LoadInst(ptr_26, "", false, currentBlock); ICmpInst* int1_28 = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, int32_27, @@ -2289,7 +2290,7 @@ ptr_table_0_lcssa->addIncoming(ptr_26, label_bb4); GetElementPtrInst* ptr_31 = GetElementPtrInst::Create(ptr_table_0_lcssa, - module->constantOne, "", + intrinsics->constantOne, "", currentBlock); LoadInst* int32_32 = new LoadInst(ptr_31, "", false, currentBlock); @@ -2304,22 +2305,22 @@ PHINode* int32_indvar = PHINode::Create(Type::getInt32Ty(*llvmContext), "indvar", currentBlock); int32_indvar->reserveOperandSpace(2); - int32_indvar->addIncoming(module->constantZero, label_bb4); + int32_indvar->addIncoming(intrinsics->constantZero, label_bb4); BinaryOperator* int32_table_010_rec = - BinaryOperator::Create(Instruction::Shl, int32_indvar, module->constantOne, + BinaryOperator::Create(Instruction::Shl, int32_indvar, intrinsics->constantOne, "table.010.rec", currentBlock); BinaryOperator* int32__rec = BinaryOperator::Create(Instruction::Add, int32_table_010_rec, - module->constantTwo, ".rec", currentBlock); + intrinsics->constantTwo, ".rec", currentBlock); GetElementPtrInst* ptr_37 = GetElementPtrInst::Create(ptr_26, int32__rec, "", currentBlock); LoadInst* int32_38 = new LoadInst(ptr_37, "", false, currentBlock); ICmpInst* int1_39 = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, int32_38, Meth, ""); BinaryOperator* int32_indvar_next = - BinaryOperator::Create(Instruction::Add, int32_indvar, module->constantOne, + BinaryOperator::Create(Instruction::Add, int32_indvar, intrinsics->constantOne, "indvar.next", currentBlock); BranchInst::Create(label_bb6, label_bb7, int1_39, currentBlock); @@ -2328,14 +2329,14 @@ currentBlock = endBlock; if (node) { - if (node->getType() == module->JavaObjectType) { + if (node->getType() == intrinsics->JavaObjectType) { JnjvmClassLoader* JCL = compilingClass->classLoader; push(node, false, signature->getReturnType()->findAssocClass(JCL)); } else { push(node, signature->getReturnType()->isUnsigned()); if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) { - push(module->constantZero, false); + push(intrinsics->constantZero, false); } } } @@ -2369,9 +2370,9 @@ BasicBlock* log_label_bb = createBasicBlock("log_bb"); // Block entry (label_entry) - CallInst* ptr_16 = CallInst::Create(module->GetVTFunction, ptr_src, "", + CallInst* ptr_16 = CallInst::Create(intrinsics->GetVTFunction, ptr_src, "", label_entry); - CallInst* ptr_17 = CallInst::Create(module->GetVTFunction, ptr_dst, "", + CallInst* ptr_17 = CallInst::Create(intrinsics->GetVTFunction, ptr_dst, "", label_entry); ICmpInst* int1_18 = new ICmpInst(*label_entry, ICmpInst::ICMP_EQ, ptr_16, @@ -2380,16 +2381,16 @@ // Block bb (label_bb) currentBlock = label_bb; - CallInst* ptr_20 = CallInst::Create(module->GetClassFunction, ptr_src, "", + CallInst* ptr_20 = CallInst::Create(intrinsics->GetClassFunction, ptr_src, "", label_bb); std::vector ptr_21_indices; - ptr_21_indices.push_back(module->constantZero); - ptr_21_indices.push_back(module->OffsetAccessInCommonClassConstant); + ptr_21_indices.push_back(intrinsics->constantZero); + ptr_21_indices.push_back(intrinsics->OffsetAccessInCommonClassConstant); Instruction* ptr_21 = GetElementPtrInst::Create(ptr_20, ptr_21_indices.begin(), ptr_21_indices.end(), "", label_bb); LoadInst* int32_22 = new LoadInst(ptr_21, "", false, label_bb); - Value* cmp = BinaryOperator::CreateAnd(int32_22, module->IsArrayConstant, "", + Value* cmp = BinaryOperator::CreateAnd(int32_22, intrinsics->IsArrayConstant, "", label_bb); Value* zero = ConstantInt::get(Type::getInt16Ty(getGlobalContext()), 0); ICmpInst* int1_23 = new ICmpInst(*label_bb, ICmpInst::ICMP_NE, cmp, zero, ""); @@ -2427,21 +2428,21 @@ // Block bb12.preheader (label_bb12_preheader) currentBlock = label_bb12_preheader; ICmpInst* int1_35 = new ICmpInst(*label_bb12_preheader, ICmpInst::ICMP_UGT, - int32_length, module->constantZero, ""); + int32_length, intrinsics->constantZero, ""); BranchInst::Create(log_label_entry, label_return, int1_35, label_bb12_preheader); // Block bb7 (label_bb7) currentBlock = label_bb7; - Value* VTArgs[1] = { Constant::getNullValue(module->VTType) }; - throwException(module->ArrayStoreExceptionFunction, VTArgs, 1); + Value* VTArgs[1] = { Constant::getNullValue(intrinsics->VTType) }; + throwException(intrinsics->ArrayStoreExceptionFunction, VTArgs, 1); // Block entry (label_entry) currentBlock = log_label_entry; - Value* ptr_10_indices[2] = { module->constantZero, - module->OffsetBaseClassInArrayClassConstant }; - Instruction* temp = new BitCastInst(ptr_20, module->JavaClassArrayType, "", + Value* ptr_10_indices[2] = { intrinsics->constantZero, + intrinsics->OffsetBaseClassInArrayClassConstant }; + Instruction* temp = new BitCastInst(ptr_20, intrinsics->JavaClassArrayType, "", log_label_entry); Instruction* ptr_10 = GetElementPtrInst::Create(temp, ptr_10_indices, ptr_10_indices + 2, "", @@ -2449,15 +2450,15 @@ LoadInst* ptr_11 = new LoadInst(ptr_10, "", false, log_label_entry); - Value* ptr_12_indices[2] = { module->constantZero, - module->OffsetAccessInCommonClassConstant }; + Value* ptr_12_indices[2] = { intrinsics->constantZero, + intrinsics->OffsetAccessInCommonClassConstant }; Instruction* ptr_12 = GetElementPtrInst::Create(ptr_11, ptr_12_indices, ptr_12_indices + 2, "", log_label_entry); LoadInst* int16_13 = new LoadInst(ptr_12, "", false, log_label_entry); BinaryOperator* int32_15 = BinaryOperator::Create(Instruction::And, int16_13, - module->IsPrimitiveConstant, + intrinsics->IsPrimitiveConstant, "", log_label_entry); ICmpInst* int1_16 = new ICmpInst(*log_label_entry, ICmpInst::ICMP_EQ, int32_15, zero, ""); @@ -2465,9 +2466,9 @@ // Block bb (log_label_bb) currentBlock = log_label_bb; - Value* ptr_11_indices[2] = { module->constantZero, - module->OffsetLogSizeInPrimitiveClassConstant }; - temp = new BitCastInst(ptr_11, module->JavaClassPrimitiveType, "", + Value* ptr_11_indices[2] = { intrinsics->constantZero, + intrinsics->OffsetLogSizeInPrimitiveClassConstant }; + temp = new BitCastInst(ptr_11, intrinsics->JavaClassPrimitiveType, "", log_label_bb); GetElementPtrInst* ptr_18 = GetElementPtrInst::Create(temp, ptr_11_indices, ptr_11_indices + 2, "", @@ -2481,14 +2482,14 @@ int32_length = BinaryOperator::CreateShl(int32_length, int32_20, "", log_label_bb); - ptr_src = new BitCastInst(ptr_src, module->JavaArrayUInt8Type, "", + ptr_src = new BitCastInst(ptr_src, intrinsics->JavaArrayUInt8Type, "", log_label_bb); - ptr_dst = new BitCastInst(ptr_dst, module->JavaArrayUInt8Type, "", + ptr_dst = new BitCastInst(ptr_dst, intrinsics->JavaArrayUInt8Type, "", log_label_bb); - Value* indexes[3] = { module->constantZero, - module->JavaArrayElementsOffsetConstant, + Value* indexes[3] = { intrinsics->constantZero, + intrinsics->JavaArrayElementsOffsetConstant, int32_start }; Instruction* ptr_42 = GetElementPtrInst::Create(ptr_src, indexes, indexes + 3, "", log_label_bb); @@ -2501,16 +2502,16 @@ // Block memmove currentBlock = label_memmove; - Value* src_int = new PtrToIntInst(ptr_42, module->pointerSizeType, "", + Value* src_int = new PtrToIntInst(ptr_42, intrinsics->pointerSizeType, "", currentBlock); - Value* dst_int = new PtrToIntInst(ptr_44, module->pointerSizeType, "", + Value* dst_int = new PtrToIntInst(ptr_44, intrinsics->pointerSizeType, "", currentBlock); cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_ULT, dst_int, src_int, ""); - Value* increment = SelectInst::Create(cmp, module->constantOne, - module->constantMinusOne, "", + Value* increment = SelectInst::Create(cmp, intrinsics->constantOne, + intrinsics->constantMinusOne, "", currentBlock); BranchInst::Create(label_bb11, label_backward, cmp, currentBlock); @@ -2528,10 +2529,10 @@ ptr_44 = GetElementPtrInst::Create(ptr_44, int32_length, "", currentBlock); - ptr_42 = GetElementPtrInst::Create(ptr_42, module->constantMinusOne, "", + ptr_42 = GetElementPtrInst::Create(ptr_42, intrinsics->constantMinusOne, "", currentBlock); - ptr_44 = GetElementPtrInst::Create(ptr_44, module->constantMinusOne, "", + ptr_44 = GetElementPtrInst::Create(ptr_44, intrinsics->constantMinusOne, "", currentBlock); phi_dst_ptr->addIncoming(ptr_44, currentBlock); @@ -2546,7 +2547,7 @@ "i.016", label_bb11); int32_i_016->reserveOperandSpace(2); int32_i_016->addIncoming(fwdref_39, label_bb11); - int32_i_016->addIncoming(module->constantZero, log_label_bb); + int32_i_016->addIncoming(intrinsics->constantZero, log_label_bb); LoadInst* ptr_43 = new LoadInst(phi_src_ptr, "", false, label_bb11); new StoreInst(ptr_43, phi_dst_ptr, false, label_bb11); @@ -2561,7 +2562,7 @@ phi_src_ptr->addIncoming(ptr_42, label_bb11); BinaryOperator* int32_indvar_next = - BinaryOperator::Create(Instruction::Add, int32_i_016, module->constantOne, + BinaryOperator::Create(Instruction::Add, int32_i_016, intrinsics->constantOne, "indvar.next", label_bb11); ICmpInst* int1_exitcond = new ICmpInst(*label_bb11, ICmpInst::ICMP_EQ, int32_indvar_next, int32_length, @@ -2577,7 +2578,7 @@ MDNode* JavaJIT::CreateLocation() { uint32_t first = currentLineNumber | (currentBytecodeIndex << 16); uint32_t second = currentCtpIndex | (callNumber << 16); - DILocation Location = module->DebugFactory->CreateLocation( + DILocation Location = intrinsics->DebugFactory->CreateLocation( first, second, DIScope(DbgSubprogram)); callNumber++; return Location.getNode(); Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Sun Feb 14 16:07:42 2010 @@ -24,16 +24,15 @@ #include "types.h" +#include "j3/JavaLLVMCompiler.h" + #include "JavaClass.h" #include "JavaUpcalls.h" -#include "j3/JavaLLVMCompiler.h" -#include "j3/JnjvmModule.h" namespace j3 { class Class; class JavaMethod; -class JnjvmModule; class Reader; /// Opinfo - This class gives for each opcode if it starts a new block and @@ -76,7 +75,7 @@ compilingClass = meth->classDef; upcalls = compilingClass->classLoader->bootstrapLoader->upcalls; TheCompiler = C; - module = TheCompiler->getIntrinsics(); + intrinsics = TheCompiler->getIntrinsics(); llvmFunction = func; llvmContext = &func->getContext(); inlining = false; @@ -112,8 +111,8 @@ /// llvmContext - The current LLVM context of compilation. llvm::LLVMContext* llvmContext; - /// module - The LLVM module where lives the compiling LLVM function. - JnjvmModule* module; + /// intrinsics - The LLVM intrinsics where lives the compiling LLVM function. + J3Intrinsics* intrinsics; /// TheCompiler - The LLVM Java compiler. /// @@ -134,7 +133,7 @@ /// arraySize - Get the size of the array. llvm::Value* arraySize(llvm::Value* obj) { - return llvm::CallInst::Create(module->ArrayLengthFunction, obj, "", + return llvm::CallInst::Create(intrinsics->ArrayLengthFunction, obj, "", currentBlock); } @@ -264,7 +263,7 @@ currentBlock); stack.push_back(upcalls->OfDouble); } else { - assert(type == module->JavaObjectType && "Can't handle this type"); + assert(type == intrinsics->JavaObjectType && "Can't handle this type"); llvm::Instruction* V = new llvm::StoreInst(val, objectStack[currentStackIndex++], false, currentBlock); @@ -282,7 +281,7 @@ llvm::Value* A[1] = { TheCompiler->getNativeClass(cl ? cl : upcalls->OfObject) }; llvm::MDNode* Node = llvm::MDNode::get(*llvmContext, A, 1); - V->setMetadata(module->MetadataTypeKind, Node); + V->setMetadata(intrinsics->MetadataTypeKind, Node); #endif } Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sun Feb 14 16:07:42 2010 @@ -33,7 +33,7 @@ #include "Jnjvm.h" #include "j3/JavaJITCompiler.h" -#include "j3/JnjvmModule.h" +#include "j3/J3Intrinsics.h" #include "j3/LLVMMaterializer.h" using namespace j3; @@ -127,8 +127,8 @@ static JavaJITListener* JITListener = 0; Constant* JavaJITCompiler::getNativeClass(CommonClass* classDef) { - const llvm::Type* Ty = classDef->isClass() ? JnjvmModule::JavaClassType : - JnjvmModule::JavaCommonClassType; + const llvm::Type* Ty = classDef->isClass() ? J3Intrinsics::JavaClassType : + J3Intrinsics::JavaCommonClassType; ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(classDef)); @@ -140,25 +140,25 @@ assert(ptr && "No constant pool found"); ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(ptr)); - return ConstantExpr::getIntToPtr(CI, JnjvmModule::ConstantPoolType); + return ConstantExpr::getIntToPtr(CI, J3Intrinsics::ConstantPoolType); } Constant* JavaJITCompiler::getMethodInClass(JavaMethod* meth) { ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), (int64_t)meth); - return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaMethodType); + return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaMethodType); } Constant* JavaJITCompiler::getString(JavaString* str) { assert(str && "No string given"); ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64(str)); - return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType); + return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType); } Constant* JavaJITCompiler::getStringPtr(JavaString** str) { assert(str && "No string given"); - const llvm::Type* Ty = PointerType::getUnqual(JnjvmModule::JavaObjectType); + const llvm::Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaObjectType); ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64(str)); return ConstantExpr::getIntToPtr(CI, Ty); @@ -169,7 +169,7 @@ assert(obj && "Delegatee not created"); Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64(obj)); - return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType); + return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType); } Constant* JavaJITCompiler::getJavaClassPtr(CommonClass* cl) { @@ -178,7 +178,7 @@ assert(obj && "Delegatee not created"); Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64(obj)); - const Type* Ty = PointerType::getUnqual(JnjvmModule::JavaObjectType); + const Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaObjectType); return ConstantExpr::getIntToPtr(CI, Ty); } @@ -194,7 +194,7 @@ Constant* JavaJITCompiler::getFinalObject(JavaObject* obj, CommonClass* cl) { Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64(obj)); - return ConstantExpr::getIntToPtr(CI, JnjvmModule::JavaObjectType); + return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType); } Constant* JavaJITCompiler::getStaticInstance(Class* classDef) { @@ -214,7 +214,7 @@ } Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), (uint64_t(obj))); - return ConstantExpr::getIntToPtr(CI, JnjvmModule::ptrType); + return ConstantExpr::getIntToPtr(CI, J3Intrinsics::ptrType); } Constant* JavaJITCompiler::getVirtualTable(JavaVirtualTable* VT) { @@ -225,7 +225,7 @@ ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(VT)); - return ConstantExpr::getIntToPtr(CI, JnjvmModule::VTType); + return ConstantExpr::getIntToPtr(CI, J3Intrinsics::VTType); } Constant* JavaJITCompiler::getNativeFunction(JavaMethod* meth, void* ptr) { @@ -248,9 +248,9 @@ EmitFunctionName = false; #endif - JnjvmModule::protectEngine.lock(); - JnjvmModule::executionEngine->addModule(TheModule); - JnjvmModule::protectEngine.unlock(); + J3Intrinsics::protectEngine.lock(); + J3Intrinsics::executionEngine->addModule(TheModule); + J3Intrinsics::protectEngine.unlock(); addJavaPasses(); @@ -264,7 +264,7 @@ Value* JavaJITCompiler::getIsolate(Jnjvm* isolate, Value* Where) { ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(isolate)); - return ConstantExpr::getIntToPtr(CI, JnjvmModule::ptrType); + return ConstantExpr::getIntToPtr(CI, J3Intrinsics::ptrType); } #endif @@ -388,7 +388,7 @@ Function* func = getMethodInfo(meth)->getMethod(); func->setName(name); assert(ptr && "No value given"); - JnjvmModule::executionEngine->updateGlobalMapping(func, ptr); + J3Intrinsics::executionEngine->updateGlobalMapping(func, ptr); func->setLinkage(GlobalValue::ExternalLinkage); } @@ -494,7 +494,7 @@ JavaJITCompiler* JavaJITCompiler::CreateCompiler(const std::string& ModuleID) { if (LLVMLazy) { - JnjvmModule::executionEngine->DisableLazyCompilation(false); + J3Intrinsics::executionEngine->DisableLazyCompilation(false); return new JavaLLVMLazyJITCompiler(ModuleID); } return new JavaJ3LazyJITCompiler(ModuleID); Modified: vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Sun Feb 14 16:07:42 2010 @@ -33,7 +33,7 @@ #include "JavaTypes.h" #include "Jnjvm.h" -#include "j3/JnjvmModule.h" +#include "j3/J3Intrinsics.h" #if DEBUG > 0 && (JNJVM_COMPILE > 0 || JNJVM_EXECUTE > 0) #include "j3/OpcodeNames.def" @@ -189,7 +189,7 @@ }; - CallInst::Create(module->PrintExecutionFunction, args, args + 3, "", + CallInst::Create(intrinsics->PrintExecutionFunction, args, args + 3, "", currentBlock); } #endif @@ -199,67 +199,67 @@ case NOP : break; case ACONST_NULL : - push(module->JavaObjectNullConstant, false); + push(intrinsics->JavaObjectNullConstant, false); break; case ICONST_M1 : - push(module->constantMinusOne, false); + push(intrinsics->constantMinusOne, false); break; case ICONST_0 : - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case ICONST_1 : - push(module->constantOne, false); + push(intrinsics->constantOne, false); break; case ICONST_2 : - push(module->constantTwo, false); + push(intrinsics->constantTwo, false); break; case ICONST_3 : - push(module->constantThree, false); + push(intrinsics->constantThree, false); break; case ICONST_4 : - push(module->constantFour, false); + push(intrinsics->constantFour, false); break; case ICONST_5 : - push(module->constantFive, false); + push(intrinsics->constantFive, false); break; case LCONST_0 : - push(module->constantLongZero, false); - push(module->constantZero, false); + push(intrinsics->constantLongZero, false); + push(intrinsics->constantZero, false); break; case LCONST_1 : - push(module->constantLongOne, false); - push(module->constantZero, false); + push(intrinsics->constantLongOne, false); + push(intrinsics->constantZero, false); break; case FCONST_0 : - push(module->constantFloatZero, false); + push(intrinsics->constantFloatZero, false); break; case FCONST_1 : - push(module->constantFloatOne, false); + push(intrinsics->constantFloatOne, false); break; case FCONST_2 : - push(module->constantFloatTwo, false); + push(intrinsics->constantFloatTwo, false); break; case DCONST_0 : - push(module->constantDoubleZero, false); - push(module->constantZero, false); + push(intrinsics->constantDoubleZero, false); + push(intrinsics->constantZero, false); break; case DCONST_1 : - push(module->constantDoubleOne, false); - push(module->constantZero, false); + push(intrinsics->constantDoubleOne, false); + push(intrinsics->constantZero, false); break; case BIPUSH : @@ -284,7 +284,7 @@ case LDC2_W : loadConstant(readS2(bytecodes, i)); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case ILOAD : @@ -295,7 +295,7 @@ case LLOAD : push(new LoadInst(longLocals[WREAD_U1(bytecodes, false, i, wide)], "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case FLOAD : @@ -306,7 +306,7 @@ case DLOAD : push(new LoadInst(doubleLocals[WREAD_U1(bytecodes, false, i, wide)], "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case ALOAD : @@ -333,25 +333,25 @@ case LLOAD_0 : push(new LoadInst(longLocals[0], "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case LLOAD_1 : push(new LoadInst(longLocals[1], "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case LLOAD_2 : push(new LoadInst(longLocals[2], "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case LLOAD_3 : push(new LoadInst(longLocals[3], "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case FLOAD_0 : @@ -377,25 +377,25 @@ case DLOAD_0 : push(new LoadInst(doubleLocals[0], "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case DLOAD_1 : push(new LoadInst(doubleLocals[1], "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case DLOAD_2 : push(new LoadInst(doubleLocals[2], "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case DLOAD_3 : push(new LoadInst(doubleLocals[3], "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case ALOAD_0 : @@ -422,7 +422,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArraySInt32Type); + intrinsics->JavaArraySInt32Type); push(new LoadInst(ptr, "", currentBlock), false); break; } @@ -431,9 +431,9 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArrayLongType); + intrinsics->JavaArrayLongType); push(new LoadInst(ptr, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -441,7 +441,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArrayFloatType); + intrinsics->JavaArrayFloatType); push(new LoadInst(ptr, "", currentBlock), false); break; } @@ -450,9 +450,9 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArrayDoubleType); + intrinsics->JavaArrayDoubleType); push(new LoadInst(ptr, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -461,7 +461,7 @@ CommonClass* cl = topTypeInfo(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArrayObjectType); + intrinsics->JavaArrayObjectType); if (cl->isArray()) cl = cl->asArrayClass()->baseClass(); push(new LoadInst(ptr, "", currentBlock), false, cl); @@ -472,7 +472,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArraySInt8Type); + intrinsics->JavaArraySInt8Type); Value* val = new LoadInst(ptr, "", currentBlock); push(new SExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock), false); @@ -483,7 +483,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArrayUInt16Type); + intrinsics->JavaArrayUInt16Type); Value* val = new LoadInst(ptr, "", currentBlock); push(new ZExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock), false); @@ -494,7 +494,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArraySInt16Type); + intrinsics->JavaArraySInt16Type); Value* val = new LoadInst(ptr, "", currentBlock); push(new SExtInst(val, Type::getInt32Ty(*llvmContext), "", currentBlock), false); @@ -658,7 +658,7 @@ Value* index = popAsInt(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArraySInt32Type); + intrinsics->JavaArraySInt32Type); new StoreInst(val, ptr, false, currentBlock); break; } @@ -669,7 +669,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArrayLongType); + intrinsics->JavaArrayLongType); new StoreInst(val, ptr, false, currentBlock); break; } @@ -679,7 +679,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArrayFloatType); + intrinsics->JavaArrayFloatType); new StoreInst(val, ptr, false, currentBlock); break; } @@ -690,7 +690,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArrayDoubleType); + intrinsics->JavaArrayDoubleType); new StoreInst(val, ptr, false, currentBlock); break; } @@ -700,12 +700,12 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArrayObjectType); + intrinsics->JavaArrayObjectType); if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, - module->JavaObjectNullConstant, ""); + intrinsics->JavaObjectNullConstant, ""); BasicBlock* endBlock = createBasicBlock("end array store check"); BasicBlock* checkBlock = createBasicBlock("array store check"); @@ -714,23 +714,23 @@ BranchInst::Create(endBlock, checkBlock, cmp, currentBlock); currentBlock = checkBlock; - Value* valVT = CallInst::Create(module->GetVTFunction, val, "", + Value* valVT = CallInst::Create(intrinsics->GetVTFunction, val, "", currentBlock); - Value* objVT = CallInst::Create(module->GetVTFunction, obj, "", + Value* objVT = CallInst::Create(intrinsics->GetVTFunction, obj, "", currentBlock); - objVT = CallInst::Create(module->GetBaseClassVTFromVTFunction, objVT, + objVT = CallInst::Create(intrinsics->GetBaseClassVTFromVTFunction, objVT, "", currentBlock); Value* VTArgs[2] = { valVT, objVT }; - Value* res = CallInst::Create(module->IsAssignableFromFunction, + Value* res = CallInst::Create(intrinsics->IsAssignableFromFunction, VTArgs, VTArgs + 2, "", currentBlock); BranchInst::Create(endBlock, exceptionBlock, res, currentBlock); currentBlock = exceptionBlock; - throwException(module->ArrayStoreExceptionFunction, VTArgs, 1); + throwException(intrinsics->ArrayStoreExceptionFunction, VTArgs, 1); currentBlock = endBlock; } @@ -747,7 +747,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArraySInt8Type); + intrinsics->JavaArraySInt8Type); new StoreInst(val, ptr, false, currentBlock); break; } @@ -763,7 +763,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArrayUInt16Type); + intrinsics->JavaArrayUInt16Type); new StoreInst(val, ptr, false, currentBlock); break; } @@ -779,7 +779,7 @@ Value* index = pop(); Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, - module->JavaArraySInt16Type); + intrinsics->JavaArraySInt16Type); new StoreInst(val, ptr, false, currentBlock); break; } @@ -900,7 +900,7 @@ llvm::Value* val1 = pop(); push(BinaryOperator::CreateAdd(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -919,7 +919,7 @@ llvm::Value* val1 = pop(); push(BinaryOperator::CreateFAdd(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -937,7 +937,7 @@ llvm::Value* val1 = pop(); push(BinaryOperator::CreateSub(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -956,7 +956,7 @@ llvm::Value* val1 = pop(); push(BinaryOperator::CreateFSub(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -975,7 +975,7 @@ llvm::Value* val1 = pop(); push(BinaryOperator::CreateMul(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -994,7 +994,7 @@ llvm::Value* val1 = pop(); push(BinaryOperator::CreateFMul(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1003,13 +1003,13 @@ Value* val1 = popAsInt(); if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, - module->constantZero, ""); + intrinsics->constantZero, ""); BasicBlock* ifFalse = createBasicBlock("non null div"); BasicBlock* ifTrue = createBasicBlock("null div"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; - throwException(module->ArithmeticExceptionFunction, 0, 0); + throwException(intrinsics->ArithmeticExceptionFunction, 0, 0); currentBlock = ifFalse; } push(BinaryOperator::CreateSDiv(val1, val2, "", currentBlock), @@ -1024,18 +1024,18 @@ llvm::Value* val1 = pop(); if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, - module->constantLongZero, ""); + intrinsics->constantLongZero, ""); BasicBlock* ifFalse = createBasicBlock("non null div"); BasicBlock* ifTrue = createBasicBlock("null div"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; - throwException(module->ArithmeticExceptionFunction, 0, 0); + throwException(intrinsics->ArithmeticExceptionFunction, 0, 0); currentBlock = ifFalse; } push(BinaryOperator::CreateSDiv(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1054,7 +1054,7 @@ llvm::Value* val1 = pop(); push(BinaryOperator::CreateFDiv(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1073,7 +1073,7 @@ llvm::Value* val1 = pop(); push(BinaryOperator::CreateSRem(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1092,13 +1092,13 @@ llvm::Value* val1 = pop(); push(BinaryOperator::CreateFRem(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } case INEG : push(BinaryOperator::CreateSub( - module->constantZero, + intrinsics->constantZero, popAsInt(), "", currentBlock), false); break; @@ -1106,24 +1106,24 @@ case LNEG : { pop(); push(BinaryOperator::CreateSub( - module->constantLongZero, + intrinsics->constantLongZero, pop(), "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } case FNEG : push(BinaryOperator::CreateSub( - module->constantFloatMinusZero, + intrinsics->constantFloatMinusZero, pop(), "", currentBlock), false); break; case DNEG : { pop(); push(BinaryOperator::CreateSub( - module->constantDoubleMinusZero, + intrinsics->constantDoubleMinusZero, pop(), "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1141,7 +1141,7 @@ Value* val1 = pop(); push(BinaryOperator::CreateShl(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1159,7 +1159,7 @@ Value* val1 = pop(); push(BinaryOperator::CreateAShr(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1181,7 +1181,7 @@ Value* val1 = pop(); push(BinaryOperator::CreateLShr(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1200,7 +1200,7 @@ Value* val1 = pop(); push(BinaryOperator::CreateAnd(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1219,7 +1219,7 @@ Value* val1 = pop(); push(BinaryOperator::CreateOr(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1238,7 +1238,7 @@ Value* val1 = pop(); push(BinaryOperator::CreateXor(val1, val2, "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1256,7 +1256,7 @@ case I2L : push(new SExtInst(pop(), llvm::Type::getInt64Ty(*llvmContext), "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case I2F : @@ -1267,7 +1267,7 @@ case I2D : push(new SIToFPInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case L2I : @@ -1286,7 +1286,7 @@ pop(); push(new SIToFPInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case F2I : { @@ -1296,7 +1296,7 @@ BasicBlock* res = createBasicBlock("F2I"); PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res); - node->addIncoming(module->constantZero, currentBlock); + node->addIncoming(intrinsics->constantZero, currentBlock); BasicBlock* cont = createBasicBlock("F2I"); BranchInst::Create(res, cont, test, currentBlock); @@ -1304,23 +1304,23 @@ currentBlock = cont; test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OGE, val, - module->constantMaxIntFloat, ""); + intrinsics->constantMaxIntFloat, ""); cont = createBasicBlock("F2I"); BranchInst::Create(res, cont, test, currentBlock); - node->addIncoming(module->constantMaxInt, + node->addIncoming(intrinsics->constantMaxInt, currentBlock); currentBlock = cont; test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OLE, val, - module->constantMinIntFloat, ""); + intrinsics->constantMinIntFloat, ""); cont = createBasicBlock("F2I"); BranchInst::Create(res, cont, test, currentBlock); - node->addIncoming(module->constantMinInt, currentBlock); + node->addIncoming(intrinsics->constantMinInt, currentBlock); currentBlock = cont; llvm::Value* newVal = new FPToSIInst(val, Type::getInt32Ty(*llvmContext), "", @@ -1342,7 +1342,7 @@ BasicBlock* res = createBasicBlock("F2L"); PHINode* node = PHINode::Create(llvm::Type::getInt64Ty(*llvmContext), "", res); - node->addIncoming(module->constantLongZero, currentBlock); + node->addIncoming(intrinsics->constantLongZero, currentBlock); BasicBlock* cont = createBasicBlock("F2L"); BranchInst::Create(res, cont, test, currentBlock); @@ -1350,22 +1350,22 @@ currentBlock = cont; test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OGE, val, - module->constantMaxLongFloat, ""); + intrinsics->constantMaxLongFloat, ""); cont = createBasicBlock("F2L"); BranchInst::Create(res, cont, test, currentBlock); - node->addIncoming(module->constantMaxLong, currentBlock); + node->addIncoming(intrinsics->constantMaxLong, currentBlock); currentBlock = cont; test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OLE, val, - module->constantMinLongFloat, ""); + intrinsics->constantMinLongFloat, ""); cont = createBasicBlock("F2L"); BranchInst::Create(res, cont, test, currentBlock); - node->addIncoming(module->constantMinLong, currentBlock); + node->addIncoming(intrinsics->constantMinLong, currentBlock); currentBlock = cont; llvm::Value* newVal = new FPToSIInst(val, Type::getInt64Ty(*llvmContext), "", @@ -1377,14 +1377,14 @@ currentBlock = res; push(node, false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } case F2D : push(new FPExtInst(pop(), llvm::Type::getDoubleTy(*llvmContext), "", currentBlock), false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; case D2I : { @@ -1395,7 +1395,7 @@ BasicBlock* res = createBasicBlock("D2I"); PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res); - node->addIncoming(module->constantZero, currentBlock); + node->addIncoming(intrinsics->constantZero, currentBlock); BasicBlock* cont = createBasicBlock("D2I"); BranchInst::Create(res, cont, test, currentBlock); @@ -1403,22 +1403,22 @@ currentBlock = cont; test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OGE, val, - module->constantMaxIntDouble, ""); + intrinsics->constantMaxIntDouble, ""); cont = createBasicBlock("D2I"); BranchInst::Create(res, cont, test, currentBlock); - node->addIncoming(module->constantMaxInt, currentBlock); + node->addIncoming(intrinsics->constantMaxInt, currentBlock); currentBlock = cont; test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OLE, val, - module->constantMinIntDouble, ""); + intrinsics->constantMinIntDouble, ""); cont = createBasicBlock("D2I"); BranchInst::Create(res, cont, test, currentBlock); - node->addIncoming(module->constantMinInt, currentBlock); + node->addIncoming(intrinsics->constantMinInt, currentBlock); currentBlock = cont; llvm::Value* newVal = new FPToSIInst(val, Type::getInt32Ty(*llvmContext), "", @@ -1442,7 +1442,7 @@ BasicBlock* res = createBasicBlock("D2L"); PHINode* node = PHINode::Create(llvm::Type::getInt64Ty(*llvmContext), "", res); - node->addIncoming(module->constantLongZero, currentBlock); + node->addIncoming(intrinsics->constantLongZero, currentBlock); BasicBlock* cont = createBasicBlock("D2L"); BranchInst::Create(res, cont, test, currentBlock); @@ -1450,23 +1450,23 @@ currentBlock = cont; test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OGE, val, - module->constantMaxLongDouble, ""); + intrinsics->constantMaxLongDouble, ""); cont = createBasicBlock("D2L"); BranchInst::Create(res, cont, test, currentBlock); - node->addIncoming(module->constantMaxLong, currentBlock); + node->addIncoming(intrinsics->constantMaxLong, currentBlock); currentBlock = cont; test = new FCmpInst(*currentBlock, FCmpInst::FCMP_OLE, val, - module->constantMinLongDouble, ""); + intrinsics->constantMinLongDouble, ""); cont = createBasicBlock("D2L"); BranchInst::Create(res, cont, test, currentBlock); - node->addIncoming(module->constantMinLong, currentBlock); + node->addIncoming(intrinsics->constantMinLong, currentBlock); currentBlock = cont; llvm::Value* newVal = new FPToSIInst(val, Type::getInt64Ty(*llvmContext), "", @@ -1478,7 +1478,7 @@ currentBlock = res; push(node, false); - push(module->constantZero, false); + push(intrinsics->constantZero, false); break; } @@ -1530,18 +1530,18 @@ BasicBlock* cont = createBasicBlock("LCMP"); BasicBlock* res = createBasicBlock("LCMP"); PHINode* node = PHINode::Create(llvm::Type::getInt32Ty(*llvmContext), "", res); - node->addIncoming(module->constantZero, currentBlock); + node->addIncoming(intrinsics->constantZero, currentBlock); BranchInst::Create(res, cont, test, currentBlock); currentBlock = cont; test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT, val1, val2, ""); - node->addIncoming(module->constantMinusOne, currentBlock); + node->addIncoming(intrinsics->constantMinusOne, currentBlock); cont = createBasicBlock("LCMP"); BranchInst::Create(res, cont, test, currentBlock); currentBlock = cont; - node->addIncoming(module->constantOne, currentBlock); + node->addIncoming(intrinsics->constantOne, currentBlock); BranchInst::Create(res, currentBlock); currentBlock = res; @@ -1801,7 +1801,7 @@ Value* expr = ConstantExpr::getIntToPtr( ConstantInt::get(Type::getInt64Ty(*llvmContext), uint64_t (index)), - module->JavaObjectType); + intrinsics->JavaObjectType); push(expr, false); branch(opcodeInfos[tmp + readS2(bytecodes, i)], currentBlock); @@ -1992,7 +1992,7 @@ #else Value* args[2] = { isolateLocal, ConstantInt::get(Type::getInt32Ty(*llvmContext), id - 4) }; - valCl = CallInst::Create(module->GetJnjvmArrayClassFunction, + valCl = CallInst::Create(intrinsics->GetJnjvmArrayClassFunction, args, args + 2, "", currentBlock); #endif @@ -2000,9 +2000,9 @@ sizeElement = ConstantInt::get(Type::getInt32Ty(*llvmContext), LAI.logSizeInBytesConstant); if (TheCompiler->isStaticCompiling() && - valCl->getType() != module->JavaClassArrayType) { + valCl->getType() != intrinsics->JavaClassArrayType) { valCl = new LoadInst(valCl, "", currentBlock); - TheVT = CallInst::Create(module->GetVTFromClassArrayFunction, + TheVT = CallInst::Create(intrinsics->GetVTFromClassArrayFunction, valCl, "", currentBlock); } else { TheVT = TheCompiler->getVirtualTable(dcl->virtualVT); @@ -2023,9 +2023,9 @@ // are compiling, the result of getNativeClass is a pointer to // the class. Load it. if (TheCompiler->isStaticCompiling() && - valCl->getType() != module->JavaClassArrayType) { + valCl->getType() != intrinsics->JavaClassArrayType) { valCl = new LoadInst(valCl, "", currentBlock); - TheVT = CallInst::Create(module->GetVTFromClassArrayFunction, + TheVT = CallInst::Create(intrinsics->GetVTFromClassArrayFunction, valCl, "", currentBlock); } else { TheVT = TheCompiler->getVirtualTable(dcl->virtualVT); @@ -2033,64 +2033,64 @@ } else { const llvm::Type* Ty = - PointerType::getUnqual(module->JavaClassArrayType); + PointerType::getUnqual(intrinsics->JavaClassArrayType); Value* args[2]= { valCl, Constant::getNullValue(Ty) }; - valCl = CallInst::Create(module->GetArrayClassFunction, args, + valCl = CallInst::Create(intrinsics->GetArrayClassFunction, args, args + 2, "", currentBlock); - TheVT = CallInst::Create(module->GetVTFromClassArrayFunction, valCl, "", + TheVT = CallInst::Create(intrinsics->GetVTFromClassArrayFunction, valCl, "", currentBlock); } - sizeElement = module->constantPtrLogSize; + sizeElement = intrinsics->constantPtrLogSize; } Value* arg1 = popAsInt(); if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT, arg1, - module->constantZero, ""); + intrinsics->constantZero, ""); BasicBlock* BB1 = createBasicBlock(""); BasicBlock* BB2 = createBasicBlock(""); BranchInst::Create(BB1, BB2, cmp, currentBlock); currentBlock = BB1; - throwException(module->NegativeArraySizeExceptionFunction, arg1); + throwException(intrinsics->NegativeArraySizeExceptionFunction, arg1); currentBlock = BB2; cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGT, arg1, - module->MaxArraySizeConstant, ""); + intrinsics->MaxArraySizeConstant, ""); BB1 = createBasicBlock(""); BB2 = createBasicBlock(""); BranchInst::Create(BB1, BB2, cmp, currentBlock); currentBlock = BB1; - throwException(module->OutOfMemoryErrorFunction, arg1); + throwException(intrinsics->OutOfMemoryErrorFunction, arg1); currentBlock = BB2; } Value* mult = BinaryOperator::CreateShl(arg1, sizeElement, "", currentBlock); Value* size = - BinaryOperator::CreateAdd(module->JavaArraySizeConstant, mult, + BinaryOperator::CreateAdd(intrinsics->JavaArraySizeConstant, mult, "", currentBlock); - TheVT = new BitCastInst(TheVT, module->ptrType, "", currentBlock); - Instruction* res = invoke(module->AllocateFunction, size, TheVT, "", + TheVT = new BitCastInst(TheVT, intrinsics->ptrType, "", currentBlock); + Instruction* res = invoke(intrinsics->AllocateFunction, size, TheVT, "", currentBlock); - Value* cast = new BitCastInst(res, module->JavaArrayType, "", + Value* cast = new BitCastInst(res, intrinsics->JavaArrayType, "", currentBlock); // Set the size - Value* gep4[2] = { module->constantZero, - module->JavaArraySizeOffsetConstant }; + Value* gep4[2] = { intrinsics->constantZero, + intrinsics->JavaArraySizeOffsetConstant }; Value* GEP = GetElementPtrInst::Create(cast, gep4, gep4 + 2, "", currentBlock); - arg1 = new IntToPtrInst(arg1, module->ptrType, "", currentBlock); + arg1 = new IntToPtrInst(arg1, intrinsics->ptrType, "", currentBlock); new StoreInst(arg1, GEP, currentBlock); addHighLevelType(res, dcl ? dcl : upcalls->ArrayOfObject); - res = new BitCastInst(res, module->JavaObjectType, "", currentBlock); + res = new BitCastInst(res, intrinsics->JavaObjectType, "", currentBlock); push(res, false, dcl ? dcl : upcalls->ArrayOfObject); break; @@ -2128,7 +2128,7 @@ Value* obj = top(); Value* args[2] = { obj, clVar }; Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj, - module->JavaObjectNullConstant, ""); + intrinsics->JavaObjectNullConstant, ""); BasicBlock* endBlock = createBasicBlock("end type compare"); PHINode* node = PHINode::Create(Type::getInt1Ty(*llvmContext), "", endBlock); @@ -2141,7 +2141,7 @@ BranchInst::Create(endCheckcast, ifFalse, cmp, currentBlock); currentBlock = exceptionCheckcast; - throwException(module->ClassCastExceptionFunction, args, 2); + throwException(intrinsics->ClassCastExceptionFunction, args, 2); currentBlock = ifFalse; } else { BasicBlock* ifFalse = createBasicBlock("false type compare"); @@ -2152,32 +2152,32 @@ Value* TheVT = 0; if (!cl || TheCompiler->isStaticCompiling()) { - TheVT = CallInst::Create(module->GetVTFromCommonClassFunction, + TheVT = CallInst::Create(intrinsics->GetVTFromCommonClassFunction, clVar, "", currentBlock); } else { TheVT = TheCompiler->getVirtualTable(cl->virtualVT); } - Value* objVT = CallInst::Create(module->GetVTFunction, obj, "", + Value* objVT = CallInst::Create(intrinsics->GetVTFunction, obj, "", currentBlock); Value* classArgs[2] = { objVT, TheVT }; Value* res = 0; if (cl) { if (cl->isSecondaryClass()) { - res = CallInst::Create(module->IsSecondaryClassFunction, + res = CallInst::Create(intrinsics->IsSecondaryClassFunction, classArgs, classArgs + 2, "", currentBlock); } else { - Value* inDisplay = CallInst::Create(module->GetDisplayFunction, + Value* inDisplay = CallInst::Create(intrinsics->GetDisplayFunction, objVT, "", currentBlock); uint32 depth = cl->virtualVT->depth; ConstantInt* CI = ConstantInt::get(Type::getInt32Ty(*llvmContext), depth); Value* displayArgs[2] = { inDisplay, CI }; Value* VTInDisplay = - CallInst::Create(module->GetVTInDisplayFunction, + CallInst::Create(intrinsics->GetVTInDisplayFunction, displayArgs, displayArgs + 2, "", currentBlock); @@ -2185,7 +2185,7 @@ TheVT, ""); } } else { - res = CallInst::Create(module->IsAssignableFromFunction, + res = CallInst::Create(intrinsics->IsAssignableFromFunction, classArgs, classArgs + 2, "", currentBlock); } @@ -2238,7 +2238,7 @@ for (sint32 v = 0; v < dim + 2; ++v) { Args.push_back(args[v]); } - push(invoke(module->MultiCallNewFunction, Args, "", currentBlock), + push(invoke(intrinsics->MultiCallNewFunction, Args, "", currentBlock), false, dcl ? dcl : upcalls->ArrayOfObject); break; } Removed: vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp?rev=96193&view=auto ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JnjvmModule.cpp (removed) @@ -1,428 +0,0 @@ -//===--------- JnjvmModule.cpp - Definition of a Jnjvm module -------------===// -// -// The VMKit project -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "llvm/BasicBlock.h" -#include "llvm/CallingConv.h" -#include "llvm/Constants.h" -#include "llvm/Instructions.h" -#include "llvm/LLVMContext.h" -#include "llvm/Module.h" -#include "llvm/PassManager.h" -#include "llvm/Analysis/LoopPass.h" -#include "llvm/Target/TargetData.h" - -#include "mvm/JIT.h" - -#include "JavaArray.h" -#include "JavaClass.h" -#include "JavaJIT.h" -#include "JavaTypes.h" - -#include "j3/JnjvmModule.h" -#include "j3/LLVMMaterializer.h" - -using namespace j3; -using namespace llvm; - -const llvm::Type* JnjvmModule::JavaObjectType = 0; -const llvm::Type* JnjvmModule::JavaArrayType = 0; -const llvm::Type* JnjvmModule::JavaArrayUInt8Type = 0; -const llvm::Type* JnjvmModule::JavaArraySInt8Type = 0; -const llvm::Type* JnjvmModule::JavaArrayUInt16Type = 0; -const llvm::Type* JnjvmModule::JavaArraySInt16Type = 0; -const llvm::Type* JnjvmModule::JavaArrayUInt32Type = 0; -const llvm::Type* JnjvmModule::JavaArraySInt32Type = 0; -const llvm::Type* JnjvmModule::JavaArrayFloatType = 0; -const llvm::Type* JnjvmModule::JavaArrayDoubleType = 0; -const llvm::Type* JnjvmModule::JavaArrayLongType = 0; -const llvm::Type* JnjvmModule::JavaArrayObjectType = 0; -const llvm::Type* JnjvmModule::CodeLineInfoType = 0; -const llvm::Type* JnjvmModule::ConstantPoolType = 0; -const llvm::Type* JnjvmModule::UTF8Type = 0; -const llvm::Type* JnjvmModule::JavaFieldType = 0; -const llvm::Type* JnjvmModule::JavaMethodType = 0; -const llvm::Type* JnjvmModule::AttributType = 0; -const llvm::Type* JnjvmModule::JavaThreadType = 0; -const llvm::Type* JnjvmModule::MutatorThreadType = 0; - -#ifdef ISOLATE_SHARING -const llvm::Type* JnjvmModule::JnjvmType = 0; -#endif - -const llvm::Type* JnjvmModule::JavaClassType; -const llvm::Type* JnjvmModule::JavaClassPrimitiveType; -const llvm::Type* JnjvmModule::JavaClassArrayType; -const llvm::Type* JnjvmModule::JavaCommonClassType; -const llvm::Type* JnjvmModule::VTType; - - -JavaLLVMCompiler::JavaLLVMCompiler(const std::string& str) : - TheModule(new llvm::Module(str, getGlobalContext())), - JavaIntrinsics(TheModule) { - - enabledException = true; -#ifdef WITH_LLVM_GCC - cooperativeGC = true; -#else - cooperativeGC = false; -#endif -} - -void JavaLLVMCompiler::resolveVirtualClass(Class* cl) { - // Lock here because we may be called by a class resolver - mvm::MvmModule::protectIR(); - LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl); - LCI->getVirtualType(); - mvm::MvmModule::unprotectIR(); -} - -void JavaLLVMCompiler::resolveStaticClass(Class* cl) { - // Lock here because we may be called by a class initializer - mvm::MvmModule::protectIR(); - LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl); - LCI->getStaticType(); - mvm::MvmModule::unprotectIR(); -} - - -namespace j3 { - namespace llvm_runtime { - #include "LLVMRuntime.inc" - } -} - -void JnjvmModule::initialise() { - Module* module = globalModule; - - if (!module->getTypeByName("JavaThread")) - j3::llvm_runtime::makeLLVMModuleContents(module); - - VTType = PointerType::getUnqual(module->getTypeByName("VT")); - -#ifdef ISOLATE_SHARING - JnjvmType = - PointerType::getUnqual(module->getTypeByName("Jnjvm")); -#endif - ConstantPoolType = ptrPtrType; - - JavaObjectType = - PointerType::getUnqual(module->getTypeByName("JavaObject")); - - JavaArrayType = - PointerType::getUnqual(module->getTypeByName("JavaArray")); - - JavaCommonClassType = - PointerType::getUnqual(module->getTypeByName("JavaCommonClass")); - JavaClassPrimitiveType = - PointerType::getUnqual(module->getTypeByName("JavaClassPrimitive")); - JavaClassArrayType = - PointerType::getUnqual(module->getTypeByName("JavaClassArray")); - JavaClassType = - PointerType::getUnqual(module->getTypeByName("JavaClass")); - - JavaArrayUInt8Type = - PointerType::getUnqual(module->getTypeByName("ArrayUInt8")); - JavaArraySInt8Type = - PointerType::getUnqual(module->getTypeByName("ArraySInt8")); - JavaArrayUInt16Type = - PointerType::getUnqual(module->getTypeByName("ArrayUInt16")); - JavaArraySInt16Type = - PointerType::getUnqual(module->getTypeByName("ArraySInt16")); - JavaArrayUInt32Type = - PointerType::getUnqual(module->getTypeByName("ArrayUInt32")); - JavaArraySInt32Type = - PointerType::getUnqual(module->getTypeByName("ArraySInt32")); - JavaArrayLongType = - PointerType::getUnqual(module->getTypeByName("ArrayLong")); - JavaArrayFloatType = - PointerType::getUnqual(module->getTypeByName("ArrayFloat")); - JavaArrayDoubleType = - PointerType::getUnqual(module->getTypeByName("ArrayDouble")); - JavaArrayObjectType = - PointerType::getUnqual(module->getTypeByName("ArrayObject")); - - JavaFieldType = - PointerType::getUnqual(module->getTypeByName("JavaField")); - JavaMethodType = - PointerType::getUnqual(module->getTypeByName("JavaMethod")); - UTF8Type = - PointerType::getUnqual(module->getTypeByName("UTF8")); - AttributType = - PointerType::getUnqual(module->getTypeByName("Attribut")); - JavaThreadType = - PointerType::getUnqual(module->getTypeByName("JavaThread")); - MutatorThreadType = - PointerType::getUnqual(module->getTypeByName("MutatorThread")); - - CodeLineInfoType = - PointerType::getUnqual(module->getTypeByName("CodeLineInfo")); - - LLVMAssessorInfo::initialise(); -} - -Function* JavaLLVMCompiler::getMethod(JavaMethod* meth) { - return getMethodInfo(meth)->getMethod(); -} - -JnjvmModule::JnjvmModule(llvm::Module* module) : - MvmModule(module) { - - if (!VTType) { - initialise(); - copyDefinitions(module, globalModule); - } - - JavaObjectNullConstant = - Constant::getNullValue(JnjvmModule::JavaObjectType); - MaxArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), - JavaArray::MaxArraySize); - JavaArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), - sizeof(JavaObject) + sizeof(ssize_t)); - - - JavaArrayElementsOffsetConstant = constantTwo; - JavaArraySizeOffsetConstant = constantOne; - JavaObjectLockOffsetConstant = constantOne; - JavaObjectVTOffsetConstant = constantZero; - OffsetClassInVTConstant = constantThree; - OffsetDepthInVTConstant = constantFour; - OffsetDisplayInVTConstant = constantSeven; - OffsetBaseClassVTInVTConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 17); - OffsetIMTInVTConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 18); - - OffsetAccessInCommonClassConstant = constantOne; - IsArrayConstant = ConstantInt::get(Type::getInt16Ty(getGlobalContext()), - JNJVM_ARRAY); - - IsPrimitiveConstant = ConstantInt::get(Type::getInt16Ty(getGlobalContext()), - JNJVM_PRIMITIVE); - - OffsetBaseClassInArrayClassConstant = constantOne; - OffsetLogSizeInPrimitiveClassConstant = constantOne; - - OffsetObjectSizeInClassConstant = constantOne; - OffsetVTInClassConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 7); - OffsetTaskClassMirrorInClassConstant = constantThree; - OffsetVirtualMethodsInClassConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 9); - OffsetStaticInstanceInTaskClassMirrorConstant = constantThree; - OffsetStatusInTaskClassMirrorConstant = constantZero; - OffsetInitializedInTaskClassMirrorConstant = constantOne; - - OffsetIsolateInThreadConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 3); - OffsetDoYieldInThreadConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 6); - OffsetJNIInThreadConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 1); - OffsetJavaExceptionInThreadConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 2); - OffsetCXXExceptionInThreadConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 3); - - ClassReadyConstant = - ConstantInt::get(Type::getInt8Ty(getGlobalContext()), ready); - - module->addTypeName("JavaObject", JavaObjectType->getContainedType(0)); - module->addTypeName("JavaArray", JavaArrayType->getContainedType(0)); - module->addTypeName("JavaCommonClass", - JavaCommonClassType->getContainedType(0)); - module->addTypeName("JavaClass", JavaClassType->getContainedType(0)); - module->addTypeName("JavaClassPrimitive", - JavaClassPrimitiveType->getContainedType(0)); - module->addTypeName("JavaClassArray", - JavaClassArrayType->getContainedType(0)); - module->addTypeName("ArrayUInt8", JavaArrayUInt8Type->getContainedType(0)); - module->addTypeName("ArraySInt8", JavaArraySInt8Type->getContainedType(0)); - module->addTypeName("ArrayUInt16", JavaArrayUInt16Type->getContainedType(0)); - module->addTypeName("ArraySInt16", JavaArraySInt16Type->getContainedType(0)); - module->addTypeName("ArraySInt32", JavaArraySInt32Type->getContainedType(0)); - module->addTypeName("ArrayLong", JavaArrayLongType->getContainedType(0)); - module->addTypeName("ArrayFloat", JavaArrayFloatType->getContainedType(0)); - module->addTypeName("ArrayDouble", JavaArrayDoubleType->getContainedType(0)); - module->addTypeName("ArrayObject", JavaArrayObjectType->getContainedType(0)); - - InterfaceLookupFunction = module->getFunction("j3InterfaceLookup"); - MultiCallNewFunction = module->getFunction("j3MultiCallNew"); - ForceLoadedCheckFunction = module->getFunction("forceLoadedCheck"); - InitialisationCheckFunction = module->getFunction("initialisationCheck"); - ForceInitialisationCheckFunction = - module->getFunction("forceInitialisationCheck"); - InitialiseClassFunction = module->getFunction("j3RuntimeInitialiseClass"); - - GetConstantPoolAtFunction = module->getFunction("getConstantPoolAt"); - ArrayLengthFunction = module->getFunction("arrayLength"); - GetVTFunction = module->getFunction("getVT"); - GetIMTFunction = module->getFunction("getIMT"); - GetClassFunction = module->getFunction("getClass"); - ClassLookupFunction = module->getFunction("j3ClassLookup"); - GetVTFromClassFunction = module->getFunction("getVTFromClass"); - GetVTFromClassArrayFunction = module->getFunction("getVTFromClassArray"); - GetVTFromCommonClassFunction = module->getFunction("getVTFromCommonClass"); - GetBaseClassVTFromVTFunction = module->getFunction("getBaseClassVTFromVT"); - GetObjectSizeFromClassFunction = - module->getFunction("getObjectSizeFromClass"); - - GetClassDelegateeFunction = module->getFunction("getClassDelegatee"); - RuntimeDelegateeFunction = module->getFunction("j3RuntimeDelegatee"); - IsAssignableFromFunction = module->getFunction("isAssignableFrom"); - IsSecondaryClassFunction = module->getFunction("isSecondaryClass"); - GetDepthFunction = module->getFunction("getDepth"); - GetStaticInstanceFunction = module->getFunction("getStaticInstance"); - GetDisplayFunction = module->getFunction("getDisplay"); - GetVTInDisplayFunction = module->getFunction("getVTInDisplay"); - AquireObjectFunction = module->getFunction("j3JavaObjectAquire"); - ReleaseObjectFunction = module->getFunction("j3JavaObjectRelease"); - OverflowThinLockFunction = module->getFunction("j3OverflowThinLock"); - - VirtualFieldLookupFunction = module->getFunction("j3VirtualFieldLookup"); - StaticFieldLookupFunction = module->getFunction("j3StaticFieldLookup"); - StringLookupFunction = module->getFunction("j3StringLookup"); - StartJNIFunction = module->getFunction("j3StartJNI"); - EndJNIFunction = module->getFunction("j3EndJNI"); - - ResolveVirtualStubFunction = module->getFunction("j3ResolveVirtualStub"); - ResolveStaticStubFunction = module->getFunction("j3ResolveStaticStub"); - ResolveSpecialStubFunction = module->getFunction("j3ResolveSpecialStub"); - - NullPointerExceptionFunction = - module->getFunction("j3NullPointerException"); - ClassCastExceptionFunction = module->getFunction("j3ClassCastException"); - IndexOutOfBoundsExceptionFunction = - module->getFunction("j3IndexOutOfBoundsException"); - NegativeArraySizeExceptionFunction = - module->getFunction("j3NegativeArraySizeException"); - OutOfMemoryErrorFunction = module->getFunction("j3OutOfMemoryError"); - StackOverflowErrorFunction = module->getFunction("j3StackOverflowError"); - ArrayStoreExceptionFunction = module->getFunction("j3ArrayStoreException"); - ArithmeticExceptionFunction = module->getFunction("j3ArithmeticException"); - - PrintExecutionFunction = module->getFunction("j3PrintExecution"); - PrintMethodStartFunction = module->getFunction("j3PrintMethodStart"); - PrintMethodEndFunction = module->getFunction("j3PrintMethodEnd"); - - ThrowExceptionFunction = module->getFunction("j3ThrowException"); - - GetArrayClassFunction = module->getFunction("j3GetArrayClass"); - - GetFinalInt8FieldFunction = module->getFunction("getFinalInt8Field"); - GetFinalInt16FieldFunction = module->getFunction("getFinalInt16Field"); - GetFinalInt32FieldFunction = module->getFunction("getFinalInt32Field"); - GetFinalLongFieldFunction = module->getFunction("getFinalLongField"); - GetFinalFloatFieldFunction = module->getFunction("getFinalFloatField"); - GetFinalDoubleFieldFunction = module->getFunction("getFinalDoubleField"); - GetFinalObjectFieldFunction = module->getFunction("getFinalObjectField"); - -#ifdef ISOLATE_SHARING - GetCtpClassFunction = module->getFunction("getCtpClass"); - GetJnjvmExceptionClassFunction = - module->getFunction("getJnjvmExceptionClass"); - GetJnjvmArrayClassFunction = module->getFunction("getJnjvmArrayClass"); - StaticCtpLookupFunction = module->getFunction("j3StaticCtpLookup"); - SpecialCtpLookupFunction = module->getFunction("j3SpecialCtpLookup"); -#endif - -#ifdef SERVICE - ServiceCallStartFunction = module->getFunction("j3ServiceCallStart"); - ServiceCallStopFunction = module->getFunction("j3ServiceCallStop"); -#endif - - JavaObjectTracerFunction = module->getFunction("JavaObjectTracer"); - EmptyTracerFunction = module->getFunction("EmptyTracer"); - JavaArrayTracerFunction = module->getFunction("JavaArrayTracer"); - ArrayObjectTracerFunction = module->getFunction("ArrayObjectTracer"); - RegularObjectTracerFunction = module->getFunction("RegularObjectTracer"); - -#ifndef WITHOUT_VTABLE - VirtualLookupFunction = module->getFunction("j3VirtualTableLookup"); -#endif - - GetLockFunction = module->getFunction("getLock"); - ThrowExceptionFromJITFunction = - module->getFunction("j3ThrowExceptionFromJIT"); - -} - -Function* JavaLLVMCompiler::parseFunction(JavaMethod* meth) { - LLVMMethodInfo* LMI = getMethodInfo(meth); - Function* func = LMI->getMethod(); - - // We are jitting. Take the lock. - JnjvmModule::protectIR(); - if (func->getLinkage() == GlobalValue::ExternalWeakLinkage) { - 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); - } - func->setLinkage(GlobalValue::ExternalLinkage); - } - JnjvmModule::unprotectIR(); - - 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; -} - -MDNode* JavaLLVMCompiler::GetDbgSubprogram(JavaMethod* meth) { - if (getMethodInfo(meth)->getDbgSubprogram() == NULL) { - MDNode* node = - JavaIntrinsics.DebugFactory->CreateSubprogram(DIDescriptor(), "", "", - "", DICompileUnit(), 0, - DIType(), false, - false).getNode(); - DbgInfos.insert(std::make_pair(node, meth)); - getMethodInfo(meth)->setDbgSubprogram(node); - } - return getMethodInfo(meth)->getDbgSubprogram(); -} - -JavaLLVMCompiler::~JavaLLVMCompiler() { - delete JavaFunctionPasses; - delete JavaNativeFunctionPasses; -} - -namespace mvm { - llvm::FunctionPass* createEscapeAnalysisPass(); - llvm::LoopPass* createLoopSafePointsPass(); -} - -namespace j3 { - llvm::FunctionPass* createLowerConstantCallsPass(JnjvmModule* M); -} - -void JavaLLVMCompiler::addJavaPasses() { - JavaNativeFunctionPasses = new FunctionPassManager(TheModule); - JavaNativeFunctionPasses->add(new TargetData(TheModule)); - // Lower constant calls to lower things like getClass used - // on synchronized methods. - JavaNativeFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics())); - - JavaFunctionPasses = new FunctionPassManager(TheModule); - JavaFunctionPasses->add(new TargetData(TheModule)); - if (cooperativeGC) - JavaFunctionPasses->add(mvm::createLoopSafePointsPass()); - - // Re-enable this when the pointers in stack-allocated objects can - // be given to the GC. - //JavaFunctionPasses->add(mvm::createEscapeAnalysisPass()); - JavaFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics())); -} Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Sun Feb 14 16:07:42 2010 @@ -39,7 +39,7 @@ const Type* LLVMClassInfo::getVirtualType() { if (!virtualType) { std::vector fields; - const TargetData* targetData = JnjvmModule::TheTargetData; + const TargetData* targetData = J3Intrinsics::TheTargetData; const StructLayout* sl = 0; const StructType* structType = 0; JavaLLVMCompiler* Mod = @@ -65,7 +65,7 @@ sl = targetData->getStructLayout(structType); } else { - virtualType = JnjvmModule::JavaObjectType; + virtualType = J3Intrinsics::JavaObjectType; structType = dyn_cast(virtualType->getContainedType(0)); sl = targetData->getStructLayout(structType); @@ -77,7 +77,7 @@ field.ptrOffset = sl->getElementOffset(i + 1); } - uint64 size = JnjvmModule::getTypeSize(structType); + uint64 size = J3Intrinsics::getTypeSize(structType); classDef->virtualSize = (uint32)size; classDef->alignment = sl->getAlignment(); virtualSizeConstant = ConstantInt::get(Type::getInt32Ty(context), size); @@ -109,7 +109,7 @@ StructType* structType = StructType::get(context, fields, false); staticType = PointerType::getUnqual(structType); - const TargetData* targetData = JnjvmModule::TheTargetData; + const TargetData* targetData = J3Intrinsics::TheTargetData; const StructLayout* sl = targetData->getStructLayout(structType); for (uint32 i = 0; i < classDef->nbStaticFields; ++i) { @@ -117,7 +117,7 @@ field.ptrOffset = sl->getElementOffset(i); } - uint64 size = JnjvmModule::getTypeSize(structType); + uint64 size = J3Intrinsics::getTypeSize(structType); cl->staticSize = size; } return staticType; @@ -241,7 +241,7 @@ uint32 size = signature->nbArguments; Typedef* const* arguments = signature->getArgumentsType(); - llvmArgs.push_back(JnjvmModule::JavaObjectType); + llvmArgs.push_back(J3Intrinsics::JavaObjectType); for (uint32 i = 0; i < size; ++i) { Typedef* type = arguments[i]; @@ -250,7 +250,7 @@ } #if defined(ISOLATE_SHARING) - llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool + llvmArgs.push_back(J3Intrinsics::ConstantPoolType); // cached constant pool #endif LLVMAssessorInfo& LAI = @@ -276,7 +276,7 @@ } #if defined(ISOLATE_SHARING) - llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool + llvmArgs.push_back(J3Intrinsics::ConstantPoolType); // cached constant pool #endif LLVMAssessorInfo& LAI = @@ -295,7 +295,7 @@ uint32 size = signature->nbArguments; Typedef* const* arguments = signature->getArgumentsType(); - const llvm::Type* Ty = PointerType::getUnqual(JnjvmModule::JavaObjectType); + const llvm::Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaObjectType); llvmArgs.push_back(mvm::MvmModule::ptrType); // JNIEnv llvmArgs.push_back(Ty); // Class @@ -304,7 +304,7 @@ Typedef* type = arguments[i]; LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); const llvm::Type* Ty = LAI.llvmType; - if (Ty == JnjvmModule::JavaObjectType) { + if (Ty == J3Intrinsics::JavaObjectType) { llvmArgs.push_back(LAI.llvmTypePtr); } else { llvmArgs.push_back(LAI.llvmType); @@ -312,12 +312,12 @@ } #if defined(ISOLATE_SHARING) - llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool + llvmArgs.push_back(J3Intrinsics::ConstantPoolType); // cached constant pool #endif LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); - const llvm::Type* RetType = LAI.llvmType == JnjvmModule::JavaObjectType ? + const llvm::Type* RetType = LAI.llvmType == J3Intrinsics::JavaObjectType ? LAI.llvmTypePtr : LAI.llvmType; nativeType = FunctionType::get(RetType, llvmArgs, false); mvm::MvmModule::unprotectIR(); @@ -333,7 +333,7 @@ JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); LLVMContext& context = Mod->getLLVMModule()->getContext(); - JnjvmModule& Intrinsics = *Mod->getIntrinsics(); + J3Intrinsics& Intrinsics = *Mod->getIntrinsics(); Function* res = 0; if (Mod->isStaticCompiling()) { const char* type = virt ? "virtual_buf" : "static_buf"; @@ -426,7 +426,7 @@ JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); - JnjvmModule& Intrinsics = *Mod->getIntrinsics(); + J3Intrinsics& Intrinsics = *Mod->getIntrinsics(); std::string name; if (Mod->isStaticCompiling()) { name += UTF8Buffer(signature->keyName).cString(); @@ -506,7 +506,7 @@ JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); - JnjvmModule& Intrinsics = *Mod->getIntrinsics(); + J3Intrinsics& Intrinsics = *Mod->getIntrinsics(); std::string name; if (Mod->isStaticCompiling()) { name += UTF8Buffer(signature->keyName).cString(); @@ -607,9 +607,9 @@ // Lock here because we are called by arbitrary code mvm::MvmModule::protectIR(); std::vector Args; - Args.push_back(JnjvmModule::ConstantPoolType); // ctp + Args.push_back(J3Intrinsics::ConstantPoolType); // ctp Args.push_back(getVirtualPtrType()); - Args.push_back(JnjvmModule::JavaObjectType); + Args.push_back(J3Intrinsics::JavaObjectType); Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr); LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); @@ -624,7 +624,7 @@ // Lock here because we are called by arbitrary code mvm::MvmModule::protectIR(); std::vector Args; - Args.push_back(JnjvmModule::ConstantPoolType); // ctp + Args.push_back(J3Intrinsics::ConstantPoolType); // ctp Args.push_back(getStaticPtrType()); Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr); LLVMAssessorInfo& LAI = @@ -799,14 +799,14 @@ PointerType::getUnqual(Type::getDoubleTy(getGlobalContext())); AssessorInfo[I_DOUBLE].logSizeInBytesConstant = 3; - AssessorInfo[I_TAB].llvmType = JnjvmModule::JavaObjectType; + AssessorInfo[I_TAB].llvmType = J3Intrinsics::JavaObjectType; AssessorInfo[I_TAB].llvmTypePtr = - PointerType::getUnqual(JnjvmModule::JavaObjectType); + PointerType::getUnqual(J3Intrinsics::JavaObjectType); AssessorInfo[I_TAB].logSizeInBytesConstant = sizeof(JavaObject*) == 8 ? 3 : 2; - AssessorInfo[I_REF].llvmType = JnjvmModule::JavaObjectType; + AssessorInfo[I_REF].llvmType = J3Intrinsics::JavaObjectType; AssessorInfo[I_REF].llvmTypePtr = - PointerType::getUnqual(JnjvmModule::JavaObjectType); + PointerType::getUnqual(J3Intrinsics::JavaObjectType); AssessorInfo[I_REF].logSizeInBytesConstant = sizeof(JavaObject*) == 8 ? 3 : 2; } Modified: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Sun Feb 14 16:07:42 2010 @@ -20,7 +20,7 @@ #include "JavaTypes.h" #include "Jnjvm.h" -#include "j3/JnjvmModule.h" +#include "j3/J3Intrinsics.h" #include "j3/LLVMMaterializer.h" using namespace llvm; Modified: vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp Sun Feb 14 16:07:42 2010 @@ -17,7 +17,7 @@ #include "llvm/Support/Debug.h" #include "JavaClass.h" -#include "j3/JnjvmModule.h" +#include "j3/J3Intrinsics.h" using namespace llvm; @@ -26,9 +26,9 @@ class VISIBILITY_HIDDEN LowerConstantCalls : public FunctionPass { public: static char ID; - JnjvmModule* module; - LowerConstantCalls(JnjvmModule* M) : FunctionPass((intptr_t)&ID), - module(M) { } + J3Intrinsics* intrinsics; + LowerConstantCalls(J3Intrinsics* I) : FunctionPass((intptr_t)&ID), + intrinsics(I) { } virtual bool runOnFunction(Function &F); private: @@ -42,50 +42,50 @@ #ifdef ISOLATE -static Value* getTCM(JnjvmModule* module, Value* Arg, Instruction* CI) { - Value* GEP[2] = { module->constantZero, - module->OffsetTaskClassMirrorInClassConstant }; +static Value* getTCM(J3Intrinsics* intrinsics, Value* Arg, Instruction* CI) { + Value* GEP[2] = { intrinsics->constantZero, + intrinsics->OffsetTaskClassMirrorInClassConstant }; Value* TCMArray = GetElementPtrInst::Create(Arg, GEP, GEP + 2, "", CI); - Value* threadId = CallInst::Create(module->llvm_frameaddress, - module->constantZero, "", CI); - threadId = new PtrToIntInst(threadId, module->pointerSizeType, "", CI); - threadId = BinaryOperator::CreateAnd(threadId, module->constantThreadIDMask, + Value* threadId = CallInst::Create(intrinsics->llvm_frameaddress, + intrinsics->constantZero, "", CI); + threadId = new PtrToIntInst(threadId, intrinsics->pointerSizeType, "", CI); + threadId = BinaryOperator::CreateAnd(threadId, intrinsics->constantThreadIDMask, "", CI); - threadId = new IntToPtrInst(threadId, module->ptr32Type, "", CI); + threadId = new IntToPtrInst(threadId, intrinsics->ptr32Type, "", CI); Value* IsolateID = GetElementPtrInst::Create(threadId, - module->OffsetIsolateInThreadConstant, "", CI); + intrinsics->OffsetIsolateInThreadConstant, "", CI); IsolateID = new LoadInst(IsolateID, "", CI); - Value* GEP2[2] = { module->constantZero, IsolateID }; + Value* GEP2[2] = { intrinsics->constantZero, IsolateID }; Value* TCM = GetElementPtrInst::Create(TCMArray, GEP2, GEP2 + 2, "", CI); return TCM; } -static Value* getDelegatee(JnjvmModule* module, Value* Arg, Instruction* CI) { - Value* GEP[2] = { module->constantZero, - module->constantTwo }; +static Value* getDelegatee(J3Intrinsics* intrinsics, Value* Arg, Instruction* CI) { + Value* GEP[2] = { intrinsics->constantZero, + intrinsics->constantTwo }; Value* TCMArray = GetElementPtrInst::Create(Arg, GEP, GEP + 2, "", CI); - Value* threadId = CallInst::Create(module->llvm_frameaddress, - module->constantZero, "", CI); - threadId = new PtrToIntInst(threadId, module->pointerSizeType, "", CI); - threadId = BinaryOperator::CreateAnd(threadId, module->constantThreadIDMask, + Value* threadId = CallInst::Create(intrinsics->llvm_frameaddress, + intrinsics->constantZero, "", CI); + threadId = new PtrToIntInst(threadId, intrinsics->pointerSizeType, "", CI); + threadId = BinaryOperator::CreateAnd(threadId, intrinsics->constantThreadIDMask, "", CI); - threadId = new IntToPtrInst(threadId, module->ptr32Type, "", CI); + threadId = new IntToPtrInst(threadId, intrinsics->ptr32Type, "", CI); Value* IsolateID = GetElementPtrInst::Create(threadId, - module->OffsetIsolateInThreadConstant, "", CI); + intrinsics->OffsetIsolateInThreadConstant, "", CI); IsolateID = new LoadInst(IsolateID, "", CI); - Value* GEP2[2] = { module->constantZero, IsolateID }; + Value* GEP2[2] = { intrinsics->constantZero, IsolateID }; Value* TCM = GetElementPtrInst::Create(TCMArray, GEP2, GEP2 + 2, "", CI); @@ -94,12 +94,12 @@ #else -static Value* getTCM(JnjvmModule* module, Value* Arg, Instruction* CI) { - Value* GEP[2] = { module->constantZero, - module->OffsetTaskClassMirrorInClassConstant }; +static Value* getTCM(J3Intrinsics* intrinsics, Value* Arg, Instruction* CI) { + Value* GEP[2] = { intrinsics->constantZero, + intrinsics->OffsetTaskClassMirrorInClassConstant }; Value* TCMArray = GetElementPtrInst::Create(Arg, GEP, GEP + 2, "", CI); - Value* GEP2[2] = { module->constantZero, module->constantZero }; + Value* GEP2[2] = { intrinsics->constantZero, intrinsics->constantZero }; Value* TCM = GetElementPtrInst::Create(TCMArray, GEP2, GEP2 + 2, "", CI); @@ -107,12 +107,12 @@ } -static Value* getDelegatee(JnjvmModule* module, Value* Arg, Instruction* CI) { - Value* GEP[2] = { module->constantZero, - module->constantZero }; +static Value* getDelegatee(J3Intrinsics* intrinsics, Value* Arg, Instruction* CI) { + Value* GEP[2] = { intrinsics->constantZero, + intrinsics->constantZero }; Value* TCMArray = GetElementPtrInst::Create(Arg, GEP, GEP + 2, "", CI); - Value* GEP2[2] = { module->constantZero, module->constantZero }; + Value* GEP2[2] = { intrinsics->constantZero, intrinsics->constantZero }; Value* TCM = GetElementPtrInst::Create(TCMArray, GEP2, GEP2 + 2, "", CI); @@ -131,7 +131,7 @@ II++; if (ICmpInst* Cmp = dyn_cast(I)) { - if (Cmp->getOperand(1) == module->JavaObjectNullConstant) { + if (Cmp->getOperand(1) == intrinsics->JavaObjectNullConstant) { Value* Arg = Cmp->getOperand(0); #if 0 @@ -146,7 +146,7 @@ CallSite Ca = CallSite::get(Arg); Instruction* CI = Ca.getInstruction(); - if (CI && Ca.getCalledValue() == module->AllocateFunction) { + if (CI && Ca.getCalledValue() == intrinsics->AllocateFunction) { Changed = true; Cmp->replaceAllUsesWith(ConstantInt::getFalse(*Context)); Cmp->eraseFromParent(); @@ -166,7 +166,7 @@ if (BI->hasOneUse()) { CallSite Call = CallSite::get(*(BI->use_begin())); Instruction* CI = Call.getInstruction(); - if (CI && Call.getCalledFunction() == module->llvm_gc_gcroot) + if (CI && Call.getCalledFunction() == intrinsics->llvm_gc_gcroot) continue; } } @@ -202,138 +202,138 @@ Instruction* CI = Call.getInstruction(); if (CI) { Value* V = Call.getCalledValue(); - if (V == module->ArrayLengthFunction) { + if (V == intrinsics->ArrayLengthFunction) { Changed = true; Value* val = Call.getArgument(0); // get the array - Value* array = new BitCastInst(val, module->JavaArrayType, + Value* array = new BitCastInst(val, intrinsics->JavaArrayType, "", CI); - Value* args[2] = { module->constantZero, - module->JavaArraySizeOffsetConstant }; + Value* args[2] = { intrinsics->constantZero, + intrinsics->JavaArraySizeOffsetConstant }; Value* ptr = GetElementPtrInst::Create(array, args, args + 2, "", CI); Value* load = new LoadInst(ptr, "", CI); load = new PtrToIntInst(load, Type::getInt32Ty(*Context), "", CI); CI->replaceAllUsesWith(load); CI->eraseFromParent(); - } else if (V == module->GetVTFunction) { + } else if (V == intrinsics->GetVTFunction) { Changed = true; Value* val = Call.getArgument(0); // get the object - Value* indexes[2] = { module->constantZero, module->constantZero }; + Value* indexes[2] = { intrinsics->constantZero, intrinsics->constantZero }; Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 2, "", CI); Value* VT = new LoadInst(VTPtr, "", CI); CI->replaceAllUsesWith(VT); CI->eraseFromParent(); - } else if (V == module->GetIMTFunction) { + } else if (V == intrinsics->GetIMTFunction) { Changed = true; Value* val = Call.getArgument(0); // get the VT - Value* indexes[2] = { module->constantZero, - module->OffsetIMTInVTConstant }; + Value* indexes[2] = { intrinsics->constantZero, + intrinsics->OffsetIMTInVTConstant }; Value* IMTPtr = GetElementPtrInst::Create(val, indexes, indexes + 2, "", CI); Value* IMT = new LoadInst(IMTPtr, "", CI); IMT = new BitCastInst(IMT, CI->getType(), "", CI); CI->replaceAllUsesWith(IMT); CI->eraseFromParent(); - } else if (V == module->GetClassFunction) { + } else if (V == intrinsics->GetClassFunction) { Changed = true; Value* val = Call.getArgument(0); // get the object - Value* args2[2] = { module->constantZero, - module->JavaObjectVTOffsetConstant }; + Value* args2[2] = { intrinsics->constantZero, + intrinsics->JavaObjectVTOffsetConstant }; Value* VTPtr = GetElementPtrInst::Create(val, args2, args2 + 2, "", CI); Value* VT = new LoadInst(VTPtr, "", CI); - Value* args3[2] = { module->constantZero, - module->OffsetClassInVTConstant }; + Value* args3[2] = { intrinsics->constantZero, + intrinsics->OffsetClassInVTConstant }; Value* clPtr = GetElementPtrInst::Create(VT, args3, args3 + 2, "", CI); Value* cl = new LoadInst(clPtr, "", CI); - cl = new BitCastInst(cl, module->JavaCommonClassType, "", CI); + cl = new BitCastInst(cl, intrinsics->JavaCommonClassType, "", CI); CI->replaceAllUsesWith(cl); CI->eraseFromParent(); - } else if (V == module->GetVTFromClassFunction) { + } else if (V == intrinsics->GetVTFromClassFunction) { Changed = true; Value* val = Call.getArgument(0); - Value* indexes[3] = { module->constantZero, - module->constantZero, - module->OffsetVTInClassConstant }; + Value* indexes[3] = { intrinsics->constantZero, + intrinsics->constantZero, + intrinsics->OffsetVTInClassConstant }; Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 3, "", CI); Value* VT = new LoadInst(VTPtr, "", CI); CI->replaceAllUsesWith(VT); CI->eraseFromParent(); - } else if (V == module->GetVTFromCommonClassFunction) { + } else if (V == intrinsics->GetVTFromCommonClassFunction) { Changed = true; Value* val = Call.getArgument(0); - Value* indexes[2] = { module->constantZero, - module->OffsetVTInClassConstant }; + Value* indexes[2] = { intrinsics->constantZero, + intrinsics->OffsetVTInClassConstant }; Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 2, "", CI); Value* VT = new LoadInst(VTPtr, "", CI); CI->replaceAllUsesWith(VT); CI->eraseFromParent(); - } else if (V == module->GetVTFromClassArrayFunction) { + } else if (V == intrinsics->GetVTFromClassArrayFunction) { Changed = true; Value* val = Call.getArgument(0); - Value* indexes[3] = { module->constantZero, - module->constantZero, - module->OffsetVTInClassConstant }; + Value* indexes[3] = { intrinsics->constantZero, + intrinsics->constantZero, + intrinsics->OffsetVTInClassConstant }; Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 3, "", CI); Value* VT = new LoadInst(VTPtr, "", CI); CI->replaceAllUsesWith(VT); CI->eraseFromParent(); - } else if (V == module->GetBaseClassVTFromVTFunction) { + } else if (V == intrinsics->GetBaseClassVTFromVTFunction) { Changed = true; Value* val = Call.getArgument(0); - Value* indexes[2] = { module->constantZero, - module->OffsetBaseClassVTInVTConstant }; + Value* indexes[2] = { intrinsics->constantZero, + intrinsics->OffsetBaseClassVTInVTConstant }; Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 2, "", CI); Value* VT = new LoadInst(VTPtr, "", CI); - VT = new BitCastInst(VT, module->VTType, "", CI); + VT = new BitCastInst(VT, intrinsics->VTType, "", CI); CI->replaceAllUsesWith(VT); CI->eraseFromParent(); - } else if (V == module->GetObjectSizeFromClassFunction) { + } else if (V == intrinsics->GetObjectSizeFromClassFunction) { Changed = true; Value* val = Call.getArgument(0); - Value* indexes[2] = { module->constantZero, - module->OffsetObjectSizeInClassConstant }; + Value* indexes[2] = { intrinsics->constantZero, + intrinsics->OffsetObjectSizeInClassConstant }; Value* SizePtr = GetElementPtrInst::Create(val, indexes, indexes + 2, "", CI); Value* Size = new LoadInst(SizePtr, "", CI); CI->replaceAllUsesWith(Size); CI->eraseFromParent(); - } else if (V == module->GetDepthFunction) { + } else if (V == intrinsics->GetDepthFunction) { Changed = true; Value* val = Call.getArgument(0); - Value* indexes[2] = { module->constantZero, - module->OffsetDepthInVTConstant }; + Value* indexes[2] = { intrinsics->constantZero, + intrinsics->OffsetDepthInVTConstant }; Value* DepthPtr = GetElementPtrInst::Create(val, indexes, indexes + 2, "", CI); Value* Depth = new LoadInst(DepthPtr, "", CI); Depth = new PtrToIntInst(Depth, Type::getInt32Ty(*Context), "", CI); CI->replaceAllUsesWith(Depth); CI->eraseFromParent(); - } else if (V == module->GetDisplayFunction) { + } else if (V == intrinsics->GetDisplayFunction) { Changed = true; Value* val = Call.getArgument(0); - Value* indexes[2] = { module->constantZero, - module->OffsetDisplayInVTConstant }; + Value* indexes[2] = { intrinsics->constantZero, + intrinsics->OffsetDisplayInVTConstant }; Value* DisplayPtr = GetElementPtrInst::Create(val, indexes, indexes + 2, "", CI); - const llvm::Type* Ty = PointerType::getUnqual(module->VTType); + const llvm::Type* Ty = PointerType::getUnqual(intrinsics->VTType); DisplayPtr = new BitCastInst(DisplayPtr, Ty, "", CI); CI->replaceAllUsesWith(DisplayPtr); CI->eraseFromParent(); - } else if (V == module->GetVTInDisplayFunction) { + } else if (V == intrinsics->GetVTInDisplayFunction) { Changed = true; Value* val = Call.getArgument(0); Value* depth = Call.getArgument(1); @@ -342,32 +342,32 @@ CI->replaceAllUsesWith(Class); CI->eraseFromParent(); #if defined(ISOLATE) - } else if (V == module->GetStaticInstanceFunction) { + } else if (V == intrinsics->GetStaticInstanceFunction) { Changed = true; - Value* TCM = getTCM(module, Call.getArgument(0), CI); - Constant* C = module->OffsetStaticInstanceInTaskClassMirrorConstant; - Value* GEP[2] = { module->constantZero, C }; + Value* TCM = getTCM(intrinsics, Call.getArgument(0), CI); + Constant* C = intrinsics->OffsetStaticInstanceInTaskClassMirrorConstant; + Value* GEP[2] = { intrinsics->constantZero, C }; Value* Replace = GetElementPtrInst::Create(TCM, GEP, GEP + 2, "", CI); Replace = new LoadInst(Replace, "", CI); CI->replaceAllUsesWith(Replace); CI->eraseFromParent(); #endif - } else if (V == module->GetClassDelegateeFunction) { + } else if (V == intrinsics->GetClassDelegateeFunction) { Changed = true; BasicBlock* NBB = II->getParent()->splitBasicBlock(II); I->getParent()->getTerminator()->eraseFromParent(); - Value* Del = getDelegatee(module, Call.getArgument(0), CI); + Value* Del = getDelegatee(intrinsics, Call.getArgument(0), CI); Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, Del, - module->JavaObjectNullConstant, ""); + intrinsics->JavaObjectNullConstant, ""); 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); + PHINode* phi = PHINode::Create(intrinsics->JavaObjectType, "", DelegateeOK); phi->addIncoming(Del, CI->getParent()); - Value* Res = CallInst::Create(module->RuntimeDelegateeFunction, + Value* Res = CallInst::Create(intrinsics->RuntimeDelegateeFunction, Call.getArgument(0), "", NoDelegatee); BranchInst::Create(DelegateeOK, NoDelegatee); phi->addIncoming(Res, NoDelegatee); @@ -377,7 +377,7 @@ BranchInst::Create(NBB, DelegateeOK); break; - } else if (V == module->InitialisationCheckFunction) { + } else if (V == intrinsics->InitialisationCheckFunction) { Changed = true; BasicBlock* NBB = 0; @@ -391,10 +391,10 @@ } Value* Cl = Call.getArgument(0); - Value* TCM = getTCM(module, Call.getArgument(0), CI); + Value* TCM = getTCM(intrinsics, Call.getArgument(0), CI); Value* GEP[2] = - { module->constantZero, - module->OffsetInitializedInTaskClassMirrorConstant }; + { intrinsics->constantZero, + intrinsics->OffsetInitializedInTaskClassMirrorConstant }; Value* StatusPtr = GetElementPtrInst::Create(TCM, GEP, GEP + 2, "", CI); @@ -402,7 +402,7 @@ BasicBlock* trueCl = BasicBlock::Create(*Context, "Initialized", &F); BasicBlock* falseCl = BasicBlock::Create(*Context, "Uninitialized", &F); - PHINode* node = llvm::PHINode::Create(JnjvmModule::JavaClassType, "", trueCl); + PHINode* node = llvm::PHINode::Create(J3Intrinsics::JavaClassType, "", trueCl); node->addIncoming(Cl, CI->getParent()); BranchInst::Create(trueCl, falseCl, test, CI); @@ -412,7 +412,7 @@ Value* Args[1] = { Cl }; BasicBlock* UI = Invoke->getUnwindDest(); - res = InvokeInst::Create(module->InitialiseClassFunction, + res = InvokeInst::Create(intrinsics->InitialiseClassFunction, trueCl, UI, Args, Args + 1, "", falseCl); @@ -437,7 +437,7 @@ } } else { - res = CallInst::Create(module->InitialiseClassFunction, + res = CallInst::Create(intrinsics->InitialiseClassFunction, Cl, "", falseCl); BranchInst::Create(trueCl, falseCl); } @@ -449,7 +449,7 @@ CI->eraseFromParent(); BranchInst::Create(NBB, trueCl); break; - } else if (V == module->GetConstantPoolAtFunction) { + } else if (V == intrinsics->GetConstantPoolAtFunction) { Function* resolver = dyn_cast(Call.getArgument(0)); assert(resolver && "Wrong use of GetConstantPoolAt"); const Type* returnType = resolver->getReturnType(); @@ -477,7 +477,7 @@ Value* arg1 = GetElementPtrInst::Create(CTP, indexes, "", CI); arg1 = new LoadInst(arg1, "", false, CI); Value* test = new ICmpInst(CI, ICmpInst::ICMP_EQ, arg1, - module->constantPtrNull, ""); + intrinsics->constantPtrNull, ""); BasicBlock* trueCl = BasicBlock::Create(*Context, "Ctp OK", &F); BasicBlock* falseCl = BasicBlock::Create(*Context, "Ctp Not OK", &F); @@ -530,18 +530,18 @@ CI->eraseFromParent(); BranchInst::Create(NBB, trueCl); break; - } else if (V == module->GetArrayClassFunction) { + } else if (V == intrinsics->GetArrayClassFunction) { const llvm::Type* Ty = - PointerType::getUnqual(module->JavaCommonClassType); + PointerType::getUnqual(intrinsics->JavaCommonClassType); 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 = Constant::getNullValue(module->JavaClassArrayType); + Constant* init = Constant::getNullValue(intrinsics->JavaClassArrayType); GlobalVariable* GV = - new GlobalVariable(*(F.getParent()), module->JavaClassArrayType, + new GlobalVariable(*(F.getParent()), intrinsics->JavaClassArrayType, false, GlobalValue::ExternalLinkage, init, ""); @@ -551,14 +551,14 @@ BasicBlock* OKBlock = BasicBlock::Create(*Context, "", &F); BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "", &F); - PHINode* node = PHINode::Create(module->JavaClassArrayType, "", + PHINode* node = PHINode::Create(intrinsics->JavaClassArrayType, "", OKBlock); node->addIncoming(LoadedGV, CI->getParent()); BranchInst::Create(NotOKBlock, OKBlock, cmp, CI); Value* args[2] = { Call.getArgument(0), GV }; - Value* res = CallInst::Create(module->GetArrayClassFunction, args, + Value* res = CallInst::Create(intrinsics->GetArrayClassFunction, args, args + 2, "", NotOKBlock); BranchInst::Create(OKBlock, NotOKBlock); node->addIncoming(res, NotOKBlock); @@ -568,23 +568,23 @@ BranchInst::Create(NBB, OKBlock); break; } - } else if (V == module->ForceInitialisationCheckFunction || - V == module->ForceLoadedCheckFunction ) { + } else if (V == intrinsics->ForceInitialisationCheckFunction || + V == intrinsics->ForceLoadedCheckFunction ) { Changed = true; CI->eraseFromParent(); - } else if (V == module->GetFinalInt8FieldFunction || - V == module->GetFinalInt16FieldFunction || - V == module->GetFinalInt32FieldFunction || - V == module->GetFinalLongFieldFunction || - V == module->GetFinalFloatFieldFunction || - V == module->GetFinalDoubleFieldFunction || - V == module->GetFinalObjectFieldFunction) { + } else if (V == intrinsics->GetFinalInt8FieldFunction || + V == intrinsics->GetFinalInt16FieldFunction || + V == intrinsics->GetFinalInt32FieldFunction || + V == intrinsics->GetFinalLongFieldFunction || + V == intrinsics->GetFinalFloatFieldFunction || + V == intrinsics->GetFinalDoubleFieldFunction || + V == intrinsics->GetFinalObjectFieldFunction) { Changed = true; Value* val = Call.getArgument(0); Value* res = new LoadInst(val, "", CI); CI->replaceAllUsesWith(res); CI->eraseFromParent(); - } else if (V == module->IsAssignableFromFunction) { + } else if (V == intrinsics->IsAssignableFromFunction) { Changed = true; Value* VT1 = Call.getArgument(0); Value* VT2 = Call.getArgument(1); @@ -598,7 +598,7 @@ ConstantInt* CC = ConstantInt::get(Type::getInt32Ty(*Context), JavaVirtualTable::getOffsetIndex()); - Value* indices[2] = { module->constantZero, CC }; + Value* indices[2] = { intrinsics->constantZero, CC }; Value* Offset = GetElementPtrInst::Create(VT2, indices, indices + 2, "", CI); Offset = new LoadInst(Offset, "", false, CI); @@ -607,7 +607,7 @@ Value* CurVT = GetElementPtrInst::Create(VT1, indices, indices + 2, "", CI); CurVT = new LoadInst(CurVT, "", false, CI); - CurVT = new BitCastInst(CurVT, module->VTType, "", CI); + CurVT = new BitCastInst(CurVT, intrinsics->VTType, "", CI); Value* res = new ICmpInst(CI, ICmpInst::ICMP_EQ, CurVT, VT2, ""); @@ -615,7 +615,7 @@ BranchInst::Create(CurEndBlock, FailedBlock, res, CI); Value* Args[2] = { VT1, VT2 }; - res = CallInst::Create(module->IsSecondaryClassFunction, Args, + res = CallInst::Create(intrinsics->IsSecondaryClassFunction, Args, Args + 2, "", FailedBlock); node->addIncoming(res, FailedBlock); @@ -631,7 +631,7 @@ // Reanalyse the current block. break; - } else if (V == module->IsSecondaryClassFunction) { + } else if (V == intrinsics->IsSecondaryClassFunction) { Changed = true; Value* VT1 = Call.getArgument(0); Value* VT2 = Call.getArgument(1); @@ -646,7 +646,7 @@ 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); + const Type* Ty = PointerType::getUnqual(intrinsics->VTType); PHINode* resFwd = PHINode::Create(Type::getInt32Ty(*Context), "", BB7); @@ -655,7 +655,7 @@ // else goto headerLoop; ConstantInt* cacheIndex = ConstantInt::get(Type::getInt32Ty(*Context), JavaVirtualTable::getCacheIndex()); - Value* indices[2] = { module->constantZero, cacheIndex }; + Value* indices[2] = { intrinsics->constantZero, cacheIndex }; Instruction* CachePtr = GetElementPtrInst::Create(VT1, indices, indices + 2, "", CI); CachePtr = new BitCastInst(CachePtr, Ty, "", CI); @@ -706,7 +706,7 @@ // ++i; // goto endLoopTest; BinaryOperator* IndVar = - BinaryOperator::CreateAdd(resFwd, module->constantOne, "", BB6); + BinaryOperator::CreateAdd(resFwd, intrinsics->constantOne, "", BB6); BranchInst::Create(BB7, BB6); // Verify that we haven't reached the end of the loop: @@ -714,7 +714,7 @@ // if (i < size) goto test // else goto end with false resFwd->reserveOperandSpace(2); - resFwd->addIncoming(module->constantZero, Preheader); + resFwd->addIncoming(intrinsics->constantZero, Preheader); resFwd->addIncoming(IndVar, BB6); cmp1 = new ICmpInst(*BB7, ICmpInst::ICMP_SGT, Size, resFwd, ""); @@ -745,31 +745,31 @@ break; } #ifdef ISOLATE_SHARING - else if (V == module->GetCtpClassFunction) { + else if (V == intrinsics->GetCtpClassFunction) { Changed = true; Value* val = Call.getArgument(0); - Value* indexes[2] = { module->constantZero, - module->OffsetCtpInClassConstant }; + Value* indexes[2] = { intrinsics->constantZero, + intrinsics->OffsetCtpInClassConstant }; Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 2, "", CI); Value* VT = new LoadInst(VTPtr, "", CI); CI->replaceAllUsesWith(VT); CI->eraseFromParent(); - } else if (V == module->GetJnjvmArrayClassFunction) { + } else if (V == intrinsics->GetJnjvmArrayClassFunction) { Changed = true; Value* val = Call.getArgument(0); Value* index = Call.getArgument(1); - Value* indexes[3] = { module->constantZero, module->constantTwo, + Value* indexes[3] = { intrinsics->constantZero, intrinsics->constantTwo, index }; Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 3, "", CI); Value* VT = new LoadInst(VTPtr, "", CI); CI->replaceAllUsesWith(VT); CI->eraseFromParent(); - } else if (V == module->GetJnjvmExceptionClassFunction) { + } else if (V == intrinsics->GetJnjvmExceptionClassFunction) { Changed = true; Value* val = Call.getArgument(0); - Value* indexes[2] = { module->constantZero, module->constantOne }; + Value* indexes[2] = { intrinsics->constantZero, intrinsics->constantOne }; Value* VTPtr = GetElementPtrInst::Create(val, indexes, indexes + 2, "", CI); Value* VT = new LoadInst(VTPtr, "", CI); @@ -785,7 +785,7 @@ } -FunctionPass* createLowerConstantCallsPass(JnjvmModule* M) { +FunctionPass* createLowerConstantCallsPass(J3Intrinsics* M) { return new LowerConstantCalls(M); } Modified: vmkit/trunk/tools/vmjc/vmjc.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmjc/vmjc.cpp?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/tools/vmjc/vmjc.cpp (original) +++ vmkit/trunk/tools/vmjc/vmjc.cpp Sun Feb 14 16:07:42 2010 @@ -43,7 +43,6 @@ #include "mvm/Threads/Thread.h" #include "j3/JavaAOTCompiler.h" -#include "j3/JnjvmModule.h" #include "../../lib/J3/VMCore/JnjvmClassLoader.h" #include "../../lib/J3/VMCore/Jnjvm.h" Modified: vmkit/trunk/tools/vmkit/Launcher.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/vmkit/Launcher.cpp?rev=96194&r1=96193&r2=96194&view=diff ============================================================================== --- vmkit/trunk/tools/vmkit/Launcher.cpp (original) +++ vmkit/trunk/tools/vmkit/Launcher.cpp Sun Feb 14 16:07:42 2010 @@ -26,7 +26,6 @@ #include "mvm/Threads/Thread.h" #include "j3/JavaJITCompiler.h" -#include "j3/JnjvmModule.h" #include "CommandLine.h" From nicolas.geoffray at lip6.fr Sun Feb 14 14:17:58 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 22:17:58 -0000 Subject: [vmkit-commits] [vmkit] r96195 - in /vmkit/trunk: include/j3/JavaLLVMCompiler.h include/mvm/JIT.h lib/J3/Compiler/J3Intrinsics.cpp lib/J3/Compiler/JavaJIT.cpp lib/Mvm/Compiler/JIT.cpp Message-ID: <201002142217.o1EMHwvo003964@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 16:17:58 2010 New Revision: 96195 URL: http://llvm.org/viewvc/llvm-project?rev=96195&view=rev Log: Refactoring - No functionality change. Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h vmkit/trunk/include/mvm/JIT.h vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaLLVMCompiler.h?rev=96195&r1=96194&r2=96195&view=diff ============================================================================== --- vmkit/trunk/include/j3/JavaLLVMCompiler.h (original) +++ vmkit/trunk/include/j3/JavaLLVMCompiler.h Sun Feb 14 16:17:58 2010 @@ -16,6 +16,7 @@ namespace llvm { class BasicBlock; + class DIFactory; } namespace j3 { @@ -40,6 +41,7 @@ protected: llvm::Module* TheModule; + llvm::DIFactory* DebugFactory; J3Intrinsics JavaIntrinsics; void addJavaPasses(); @@ -62,6 +64,10 @@ virtual bool isStaticCompiling() = 0; virtual bool emitFunctionName() = 0; + + llvm::DIFactory* getDebugFactory() { + return DebugFactory; + } llvm::Module* getLLVMModule() { return TheModule; @@ -166,7 +172,6 @@ } llvm::Function* NativeLoader; - }; } // end namespace j3 Modified: vmkit/trunk/include/mvm/JIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=96195&r1=96194&r2=96195&view=diff ============================================================================== --- vmkit/trunk/include/mvm/JIT.h (original) +++ vmkit/trunk/include/mvm/JIT.h Sun Feb 14 16:17:58 2010 @@ -25,15 +25,12 @@ class Constant; class ConstantFP; class ConstantInt; - class DIFactory; class ExecutionEngine; class Function; class FunctionPassManager; class GCFunctionInfo; class GCStrategy; - class LLVMContext; class Module; - class ModuleProvider; class PointerType; class TargetData; class TargetMachine; @@ -42,9 +39,7 @@ namespace mvm { -class LockNormal; class LockRecursive; -class VirtualMachine; const double MaxDouble = +INFINITY; //1.0 / 0.0; const double MinDouble = -INFINITY;//-1.0 / 0.0; @@ -172,8 +167,6 @@ llvm::Constant* constantPtrOne; llvm::Constant* constantPtrZero; - llvm::DIFactory* DebugFactory; - static const llvm::PointerType* ptrType; static const llvm::PointerType* ptr32Type; static const llvm::PointerType* ptrPtrType; Modified: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp?rev=96195&r1=96194&r2=96195&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp Sun Feb 14 16:17:58 2010 @@ -64,6 +64,7 @@ JavaLLVMCompiler::JavaLLVMCompiler(const std::string& str) : TheModule(new llvm::Module(str, getGlobalContext())), + DebugFactory(new DIFactory(*TheModule)), JavaIntrinsics(TheModule) { enabledException = true; @@ -384,11 +385,10 @@ MDNode* JavaLLVMCompiler::GetDbgSubprogram(JavaMethod* meth) { if (getMethodInfo(meth)->getDbgSubprogram() == NULL) { - MDNode* node = - JavaIntrinsics.DebugFactory->CreateSubprogram(DIDescriptor(), "", "", - "", DICompileUnit(), 0, - DIType(), false, - false).getNode(); + MDNode* node = DebugFactory->CreateSubprogram(DIDescriptor(), "", "", + "", DICompileUnit(), 0, + DIType(), false, + false).getNode(); DbgInfos.insert(std::make_pair(node, meth)); getMethodInfo(meth)->setDbgSubprogram(node); } Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=96195&r1=96194&r2=96195&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Sun Feb 14 16:17:58 2010 @@ -2578,7 +2578,7 @@ MDNode* JavaJIT::CreateLocation() { uint32_t first = currentLineNumber | (currentBytecodeIndex << 16); uint32_t second = currentCtpIndex | (callNumber << 16); - DILocation Location = intrinsics->DebugFactory->CreateLocation( + DILocation Location = TheCompiler->getDebugFactory()->CreateLocation( first, second, DIScope(DbgSubprogram)); callNumber++; return Location.getNode(); Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=96195&r1=96194&r2=96195&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sun Feb 14 16:17:58 2010 @@ -313,7 +313,6 @@ module->setDataLayout(globalModule->getDataLayout()); module->setTargetTriple(globalModule->getTargetTriple()); LLVMContext& Context = module->getContext(); - DebugFactory = new DIFactory(*module); // Constant declaration constantLongMinusOne = ConstantInt::get(Type::getInt64Ty(Context), (uint64_t)-1); From nicolas.geoffray at lip6.fr Sun Feb 14 14:21:43 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 22:21:43 -0000 Subject: [vmkit-commits] [vmkit] r96196 - in /vmkit/trunk/lib/J3/Compiler: J3Intrinsics.cpp JavaLLVMCompiler.cpp Message-ID: <201002142221.o1EMLh08004204@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 16:21:43 2010 New Revision: 96196 URL: http://llvm.org/viewvc/llvm-project?rev=96196&view=rev Log: Code refactoring - No functionality change. Added: vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp Modified: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp Modified: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp?rev=96196&r1=96195&r2=96196&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp Sun Feb 14 16:21:43 2010 @@ -62,36 +62,6 @@ const llvm::Type* J3Intrinsics::VTType; -JavaLLVMCompiler::JavaLLVMCompiler(const std::string& str) : - TheModule(new llvm::Module(str, getGlobalContext())), - DebugFactory(new DIFactory(*TheModule)), - JavaIntrinsics(TheModule) { - - enabledException = true; -#ifdef WITH_LLVM_GCC - cooperativeGC = true; -#else - cooperativeGC = false; -#endif -} - -void JavaLLVMCompiler::resolveVirtualClass(Class* cl) { - // Lock here because we may be called by a class resolver - mvm::MvmModule::protectIR(); - LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl); - LCI->getVirtualType(); - mvm::MvmModule::unprotectIR(); -} - -void JavaLLVMCompiler::resolveStaticClass(Class* cl) { - // Lock here because we may be called by a class initializer - mvm::MvmModule::protectIR(); - LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl); - LCI->getStaticType(); - mvm::MvmModule::unprotectIR(); -} - - namespace j3 { namespace llvm_runtime { #include "LLVMRuntime.inc" @@ -167,10 +137,6 @@ LLVMAssessorInfo::initialise(); } -Function* JavaLLVMCompiler::getMethod(JavaMethod* meth) { - return getMethodInfo(meth)->getMethod(); -} - J3Intrinsics::J3Intrinsics(llvm::Module* module) : MvmModule(module) { @@ -352,77 +318,3 @@ module->getFunction("j3ThrowExceptionFromJIT"); } - -Function* JavaLLVMCompiler::parseFunction(JavaMethod* meth) { - LLVMMethodInfo* LMI = getMethodInfo(meth); - Function* func = LMI->getMethod(); - - // We are jitting. Take the lock. - J3Intrinsics::protectIR(); - if (func->getLinkage() == GlobalValue::ExternalWeakLinkage) { - JavaJIT jit(this, meth, func); - if (isNative(meth->access)) { - jit.nativeCompile(); - J3Intrinsics::runPasses(func, JavaNativeFunctionPasses); - } else { - jit.javaCompile(); - J3Intrinsics::runPasses(func, J3Intrinsics::globalFunctionPasses); - J3Intrinsics::runPasses(func, JavaFunctionPasses); - } - func->setLinkage(GlobalValue::ExternalLinkage); - } - J3Intrinsics::unprotectIR(); - - 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; -} - -MDNode* JavaLLVMCompiler::GetDbgSubprogram(JavaMethod* meth) { - if (getMethodInfo(meth)->getDbgSubprogram() == NULL) { - MDNode* node = DebugFactory->CreateSubprogram(DIDescriptor(), "", "", - "", DICompileUnit(), 0, - DIType(), false, - false).getNode(); - DbgInfos.insert(std::make_pair(node, meth)); - getMethodInfo(meth)->setDbgSubprogram(node); - } - return getMethodInfo(meth)->getDbgSubprogram(); -} - -JavaLLVMCompiler::~JavaLLVMCompiler() { - delete JavaFunctionPasses; - delete JavaNativeFunctionPasses; -} - -namespace mvm { - llvm::FunctionPass* createEscapeAnalysisPass(); - llvm::LoopPass* createLoopSafePointsPass(); -} - -namespace j3 { - llvm::FunctionPass* createLowerConstantCallsPass(J3Intrinsics* M); -} - -void JavaLLVMCompiler::addJavaPasses() { - JavaNativeFunctionPasses = new FunctionPassManager(TheModule); - JavaNativeFunctionPasses->add(new TargetData(TheModule)); - // Lower constant calls to lower things like getClass used - // on synchronized methods. - JavaNativeFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics())); - - JavaFunctionPasses = new FunctionPassManager(TheModule); - JavaFunctionPasses->add(new TargetData(TheModule)); - if (cooperativeGC) - JavaFunctionPasses->add(mvm::createLoopSafePointsPass()); - - // Re-enable this when the pointers in stack-allocated objects can - // be given to the GC. - //JavaFunctionPasses->add(mvm::createEscapeAnalysisPass()); - JavaFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics())); -} Added: vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp?rev=96196&view=auto ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp (added) +++ vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp Sun Feb 14 16:21:43 2010 @@ -0,0 +1,138 @@ +//===-------- JavaLLVMCompiler.cpp - A LLVM Compiler for J3 ---------------===// +// +// The VMKit project +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/BasicBlock.h" +#include "llvm/CallingConv.h" +#include "llvm/Constants.h" +#include "llvm/Instructions.h" +#include "llvm/LLVMContext.h" +#include "llvm/Module.h" +#include "llvm/PassManager.h" +#include "llvm/Analysis/LoopPass.h" +#include "llvm/Target/TargetData.h" + +#include "mvm/JIT.h" + +#include "JavaArray.h" +#include "JavaClass.h" +#include "JavaJIT.h" +#include "JavaTypes.h" + +#include "j3/J3Intrinsics.h" +#include "j3/LLVMMaterializer.h" + +using namespace j3; +using namespace llvm; + +JavaLLVMCompiler::JavaLLVMCompiler(const std::string& str) : + TheModule(new llvm::Module(str, getGlobalContext())), + DebugFactory(new DIFactory(*TheModule)), + JavaIntrinsics(TheModule) { + + enabledException = true; +#ifdef WITH_LLVM_GCC + cooperativeGC = true; +#else + cooperativeGC = false; +#endif +} + +void JavaLLVMCompiler::resolveVirtualClass(Class* cl) { + // Lock here because we may be called by a class resolver + mvm::MvmModule::protectIR(); + LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl); + LCI->getVirtualType(); + mvm::MvmModule::unprotectIR(); +} + +void JavaLLVMCompiler::resolveStaticClass(Class* cl) { + // Lock here because we may be called by a class initializer + mvm::MvmModule::protectIR(); + LLVMClassInfo* LCI = (LLVMClassInfo*)getClassInfo(cl); + LCI->getStaticType(); + mvm::MvmModule::unprotectIR(); +} + +Function* JavaLLVMCompiler::getMethod(JavaMethod* meth) { + return getMethodInfo(meth)->getMethod(); +} + +Function* JavaLLVMCompiler::parseFunction(JavaMethod* meth) { + LLVMMethodInfo* LMI = getMethodInfo(meth); + Function* func = LMI->getMethod(); + + // We are jitting. Take the lock. + J3Intrinsics::protectIR(); + if (func->getLinkage() == GlobalValue::ExternalWeakLinkage) { + JavaJIT jit(this, meth, func); + if (isNative(meth->access)) { + jit.nativeCompile(); + J3Intrinsics::runPasses(func, JavaNativeFunctionPasses); + } else { + jit.javaCompile(); + J3Intrinsics::runPasses(func, J3Intrinsics::globalFunctionPasses); + J3Intrinsics::runPasses(func, JavaFunctionPasses); + } + func->setLinkage(GlobalValue::ExternalLinkage); + } + J3Intrinsics::unprotectIR(); + + 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; +} + +MDNode* JavaLLVMCompiler::GetDbgSubprogram(JavaMethod* meth) { + if (getMethodInfo(meth)->getDbgSubprogram() == NULL) { + MDNode* node = DebugFactory->CreateSubprogram(DIDescriptor(), "", "", + "", DICompileUnit(), 0, + DIType(), false, + false).getNode(); + DbgInfos.insert(std::make_pair(node, meth)); + getMethodInfo(meth)->setDbgSubprogram(node); + } + return getMethodInfo(meth)->getDbgSubprogram(); +} + +JavaLLVMCompiler::~JavaLLVMCompiler() { + delete JavaFunctionPasses; + delete JavaNativeFunctionPasses; +} + +namespace mvm { + llvm::FunctionPass* createEscapeAnalysisPass(); + llvm::LoopPass* createLoopSafePointsPass(); +} + +namespace j3 { + llvm::FunctionPass* createLowerConstantCallsPass(J3Intrinsics* I); +} + +void JavaLLVMCompiler::addJavaPasses() { + JavaNativeFunctionPasses = new FunctionPassManager(TheModule); + JavaNativeFunctionPasses->add(new TargetData(TheModule)); + // Lower constant calls to lower things like getClass used + // on synchronized methods. + JavaNativeFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics())); + + JavaFunctionPasses = new FunctionPassManager(TheModule); + JavaFunctionPasses->add(new TargetData(TheModule)); + if (cooperativeGC) + JavaFunctionPasses->add(mvm::createLoopSafePointsPass()); + + // Re-enable this when the pointers in stack-allocated objects can + // be given to the GC. + //JavaFunctionPasses->add(mvm::createEscapeAnalysisPass()); + JavaFunctionPasses->add(createLowerConstantCallsPass(getIntrinsics())); +} From nicolas.geoffray at lip6.fr Sun Feb 14 14:26:40 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 22:26:40 -0000 Subject: [vmkit-commits] [vmkit] r96198 - in /vmkit/trunk/lib/J3/Compiler: J3Intrinsics.cpp JavaLLVMCompiler.cpp Message-ID: <201002142226.o1EMQe1W004419@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 16:26:40 2010 New Revision: 96198 URL: http://llvm.org/viewvc/llvm-project?rev=96198&view=rev Log: Prune includes. Modified: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp Modified: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp?rev=96198&r1=96197&r2=96198&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp Sun Feb 14 16:26:40 2010 @@ -7,25 +7,19 @@ // //===----------------------------------------------------------------------===// -#include "llvm/BasicBlock.h" -#include "llvm/CallingConv.h" #include "llvm/Constants.h" -#include "llvm/Instructions.h" +#include "llvm/DerivedTypes.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" -#include "llvm/PassManager.h" -#include "llvm/Analysis/LoopPass.h" -#include "llvm/Target/TargetData.h" #include "mvm/JIT.h" +#include "JavaAccess.h" #include "JavaArray.h" #include "JavaClass.h" -#include "JavaJIT.h" -#include "JavaTypes.h" #include "j3/J3Intrinsics.h" -#include "j3/LLVMMaterializer.h" +#include "j3/LLVMInfo.h" using namespace j3; using namespace llvm; Modified: vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp?rev=96198&r1=96197&r2=96198&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp Sun Feb 14 16:26:40 2010 @@ -7,10 +7,6 @@ // //===----------------------------------------------------------------------===// -#include "llvm/BasicBlock.h" -#include "llvm/CallingConv.h" -#include "llvm/Constants.h" -#include "llvm/Instructions.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" #include "llvm/PassManager.h" @@ -19,13 +15,10 @@ #include "mvm/JIT.h" -#include "JavaArray.h" #include "JavaClass.h" #include "JavaJIT.h" -#include "JavaTypes.h" -#include "j3/J3Intrinsics.h" -#include "j3/LLVMMaterializer.h" +#include "j3/JavaLLVMCompiler.h" using namespace j3; using namespace llvm; From nicolas.geoffray at lip6.fr Sun Feb 14 14:39:09 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 22:39:09 -0000 Subject: [vmkit-commits] [vmkit] r96200 - in /vmkit/trunk: include/mvm/JIT.h lib/Mvm/Compiler/JIT.cpp Message-ID: <201002142239.o1EMd9NA005026@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 16:39:09 2010 New Revision: 96200 URL: http://llvm.org/viewvc/llvm-project?rev=96200&view=rev Log: Refactoring. Modified: vmkit/trunk/include/mvm/JIT.h 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=96200&r1=96199&r2=96200&view=diff ============================================================================== --- vmkit/trunk/include/mvm/JIT.h (original) +++ vmkit/trunk/include/mvm/JIT.h Sun Feb 14 16:39:09 2010 @@ -208,17 +208,6 @@ JITMethodInfo(llvm::GCFunctionInfo* GFI) : GCInfo(GFI) {} }; -class MvmJITMethodInfo : public JITMethodInfo { - const llvm::Function* Func; -public: - virtual void print(void* ip, void* addr); - MvmJITMethodInfo(llvm::GCFunctionInfo* GFI, const llvm::Function* F) : - JITMethodInfo(GFI) { - Func = F; - MethodType = 0; - } -}; - } // end namespace mvm Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=96200&r1=96199&r2=96200&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sun Feb 14 16:39:09 2010 @@ -62,6 +62,21 @@ return LLVM_HOSTTRIPLE; } +class MvmJITMethodInfo : public JITMethodInfo { + const llvm::Function* Func; +public: + virtual void print(void* ip, void* addr); + MvmJITMethodInfo(llvm::GCFunctionInfo* GFI, const llvm::Function* F) : + JITMethodInfo(GFI) { + Func = F; + MethodType = 0; + } +}; + +void MvmJITMethodInfo::print(void* ip, void* addr) { + fprintf(stderr, "; %p in %s LLVM method\n", ip, Func->getName().data()); +} + class MvmJITListener : public llvm::JITEventListener { public: virtual void NotifyFunctionEmitted(const Function &F, @@ -616,6 +631,3 @@ } } -void MvmJITMethodInfo::print(void* ip, void* addr) { - fprintf(stderr, "; %p in %s LLVM method\n", ip, Func->getName().data()); -} From nicolas.geoffray at lip6.fr Sun Feb 14 14:44:32 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 14 Feb 2010 22:44:32 -0000 Subject: [vmkit-commits] [vmkit] r96201 - /vmkit/trunk/mmtk/magic/LowerJavaRT.cpp Message-ID: <201002142244.o1EMiWKn005314@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 16:44:32 2010 New Revision: 96201 URL: http://llvm.org/viewvc/llvm-project?rev=96201&view=rev Log: Fix compilation. Modified: vmkit/trunk/mmtk/magic/LowerJavaRT.cpp Modified: vmkit/trunk/mmtk/magic/LowerJavaRT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/magic/LowerJavaRT.cpp?rev=96201&r1=96200&r2=96201&view=diff ============================================================================== --- vmkit/trunk/mmtk/magic/LowerJavaRT.cpp (original) +++ vmkit/trunk/mmtk/magic/LowerJavaRT.cpp Sun Feb 14 16:44:32 2010 @@ -18,9 +18,6 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" -#include "j3/JnjvmModule.h" - - using namespace llvm; namespace { From nicolas.geoffray at lip6.fr Sun Feb 14 17:38:31 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Feb 2010 01:38:31 -0000 Subject: [vmkit-commits] [vmkit] r96205 - /vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Message-ID: <201002150138.o1F1cVbY013642@zion.cs.uiuc.edu> Author: geoffray Date: Sun Feb 14 19:38:31 2010 New Revision: 96205 URL: http://llvm.org/viewvc/llvm-project?rev=96205&view=rev Log: Set the classpath to only the jar file when -jar is given. Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=96205&r1=96204&r2=96205&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Sun Feb 14 19:38:31 2010 @@ -797,11 +797,8 @@ void ClArgumentsInfo::extractClassFromJar(Jnjvm* vm, int argc, char** argv, int i) { jarFile = argv[i]; - uint32 size = 2 + strlen(vm->classpath) + strlen(jarFile); - char* temp = (char*)vm->allocator.Allocate(size, "jar file"); - sprintf(temp, "%s:%s", vm->classpath, jarFile); - vm->setClasspath(temp); + vm->setClasspath(jarFile); ArrayUInt8* bytes = Reader::openFile(vm->bootstrapLoader, jarFile, true); From nicolas.geoffray at lip6.fr Mon Feb 15 10:54:56 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Feb 2010 18:54:56 -0000 Subject: [vmkit-commits] [vmkit] r96247 - /vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Message-ID: <201002151854.o1FIsuup012757@zion.cs.uiuc.edu> Author: geoffray Date: Mon Feb 15 12:54:56 2010 New Revision: 96247 URL: http://llvm.org/viewvc/llvm-project?rev=96247&view=rev Log: Debug and Release mode do not agree on what is the first method on the stack. Therefore loop until we found one. Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=96247&r1=96246&r2=96247&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Mon Feb 15 12:54:56 2010 @@ -598,9 +598,8 @@ // Lookup the caller of this class. mvm::StackWalker Walker(th); - ++Walker; + while (Walker.get()->MethodType != 1) ++Walker; mvm::MethodInfo* MI = Walker.get(); - assert(MI->MethodType == 1 && "Wrong call to stub"); JavaMethod* meth = (JavaMethod*)MI->getMetaInfo(); void* ip = *Walker; @@ -660,7 +659,7 @@ // Lookup the caller of this class. mvm::StackWalker Walker(th); - ++Walker; + while (Walker.get()->MethodType != 1) ++Walker; mvm::MethodInfo* MI = Walker.get(); assert(MI->MethodType == 1 && "Wrong call to stub"); JavaMethod* caller = (JavaMethod*)MI->getMetaInfo(); @@ -698,7 +697,7 @@ // Lookup the caller of this class. mvm::StackWalker Walker(th); - ++Walker; + while (Walker.get()->MethodType != 1) ++Walker; mvm::MethodInfo* MI = Walker.get(); assert(MI->MethodType == 1 && "Wrong call to stub"); JavaMethod* caller = (JavaMethod*)MI->getMetaInfo(); From nicolas.geoffray at lip6.fr Mon Feb 15 12:16:54 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Feb 2010 20:16:54 -0000 Subject: [vmkit-commits] [vmkit] r96258 - /vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp Message-ID: <201002152016.o1FKGsEU017193@zion.cs.uiuc.edu> Author: geoffray Date: Mon Feb 15 14:16:53 2010 New Revision: 96258 URL: http://llvm.org/viewvc/llvm-project?rev=96258&view=rev Log: Fix memory errors revealed by valgrind. Modified: vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp Modified: vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp?rev=96258&r1=96257&r2=96258&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp Mon Feb 15 14:16:53 2010 @@ -184,8 +184,7 @@ if (StoreInst* SI = dyn_cast(Temp)) { if (dyn_cast(II) == SI) ++II; SI->eraseFromParent(); - } - if (BitCastInst* BI = dyn_cast(Temp)) { + } else if (BitCastInst* BI = dyn_cast(Temp)) { CallSite Call = CallSite::get(*(BI->use_begin())); Instruction* CI = Call.getInstruction(); if (dyn_cast(II) == CI) ++II; @@ -196,6 +195,7 @@ } AI->eraseFromParent(); } + continue; } CallSite Call = CallSite::get(I); From nicolas.geoffray at lip6.fr Mon Feb 15 12:26:28 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Feb 2010 20:26:28 -0000 Subject: [vmkit-commits] [vmkit] r96259 - in /vmkit/trunk/lib/J3/Compiler: JavaJIT.cpp JavaJITOpcodes.cpp Message-ID: <201002152026.o1FKQSmJ017629@zion.cs.uiuc.edu> Author: geoffray Date: Mon Feb 15 14:26:28 2010 New Revision: 96259 URL: http://llvm.org/viewvc/llvm-project?rev=96259&view=rev Log: Fix API change in LLVM. Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=96259&r1=96258&r2=96259&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Mon Feb 15 14:26:28 2010 @@ -2003,7 +2003,7 @@ bool usign) { const Type* t2 = val->getType(); if (t1 != t2) { - if (t1->isInteger() && t2->isInteger()) { + if (t1->isIntegerTy() && t2->isIntegerTy()) { if (t2->getPrimitiveSizeInBits() < t1->getPrimitiveSizeInBits()) { if (usign) { val = new ZExtInst(val, t1, "", currentBlock); @@ -2013,7 +2013,7 @@ } else { val = new TruncInst(val, t1, "", currentBlock); } - } else if (t1->isFloatingPoint() && t2->isFloatingPoint()) { + } else if (t1->isFloatTy() && t2->isFloatTy()) { if (t2->getPrimitiveSizeInBits() < t1->getPrimitiveSizeInBits()) { val = new FPExtInst(val, t1, "", currentBlock); } else { Modified: vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=96259&r1=96258&r2=96259&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Mon Feb 15 14:26:28 2010 @@ -1876,7 +1876,7 @@ } case IRETURN : { Value* val = pop(); - assert(val->getType()->isInteger()); + assert(val->getType()->isIntegerTy()); convertValue(val, endNode->getType(), currentBlock, false); endNode->addIncoming(val, currentBlock); BranchInst::Create(endBlock, currentBlock); From nicolas.geoffray at lip6.fr Mon Feb 15 12:39:36 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Feb 2010 20:39:36 -0000 Subject: [vmkit-commits] [vmkit] r96261 - /vmkit/trunk/lib/J3/VMCore/JavaObject.h Message-ID: <201002152039.o1FKdbP2018322@zion.cs.uiuc.edu> Author: geoffray Date: Mon Feb 15 14:39:36 2010 New Revision: 96261 URL: http://llvm.org/viewvc/llvm-project?rev=96261&view=rev Log: Add the class in the hashcode, for less hash code conflicts. Modified: vmkit/trunk/lib/J3/VMCore/JavaObject.h Modified: vmkit/trunk/lib/J3/VMCore/JavaObject.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaObject.h?rev=96261&r1=96260&r2=96261&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaObject.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaObject.h Mon Feb 15 14:39:36 2010 @@ -292,7 +292,7 @@ llvm_gcroot(self, 0); uintptr_t oldLock = self->lock.lock; uintptr_t val = (oldLock & mvm::HashMask) >> LockSystem::BitGC; - if (val) return val; + if (val) return val ^ (uintptr_t)getClass(); else { if (hashCodeGenerator >= (mvm::HashMask >> LockSystem::BitGC)) val = hashCodeGenerator = 1; @@ -304,7 +304,8 @@ uintptr_t newLock = (val << LockSystem::BitGC) | oldLock; __sync_val_compare_and_swap(&(self->lock.lock), oldLock, newLock); } while ((self->lock.lock & mvm::HashMask) == 0); - return (self->lock.lock & mvm::HashMask) >> LockSystem::BitGC; + return ((self->lock.lock & mvm::HashMask) >> LockSystem::BitGC) ^ + (uintptr_t)getClass(); } }; From nicolas.geoffray at lip6.fr Mon Feb 15 15:22:38 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Feb 2010 23:22:38 -0000 Subject: [vmkit-commits] [vmkit] r96296 - /vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Message-ID: <201002152322.o1FNMdHJ026946@zion.cs.uiuc.edu> Author: geoffray Date: Mon Feb 15 17:22:38 2010 New Revision: 96296 URL: http://llvm.org/viewvc/llvm-project?rev=96296&view=rev Log: Don't interact with the debugger, it leaks memory when there is none. 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=96296&r1=96295&r2=96296&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Mon Feb 15 17:22:38 2010 @@ -128,6 +128,7 @@ llvm::NoFramePointerElim = true; llvm::DisablePrettyStackTrace = true; + llvm::JITEmitDebugInfo = false; #if DWARF_EXCEPTIONS llvm::DwarfExceptionHandling = true; #else From nicolas.geoffray at lip6.fr Tue Feb 16 00:28:06 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 16 Feb 2010 08:28:06 -0000 Subject: [vmkit-commits] [vmkit] r96338 - /vmkit/trunk/tools/j3/Main.cpp Message-ID: <201002160828.o1G8S9f9020282@zion.cs.uiuc.edu> Author: geoffray Date: Tue Feb 16 02:27:58 2010 New Revision: 96338 URL: http://llvm.org/viewvc/llvm-project?rev=96338&view=rev Log: Stop being generic when creating the VM. Modified: vmkit/trunk/tools/j3/Main.cpp Modified: vmkit/trunk/tools/j3/Main.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/tools/j3/Main.cpp?rev=96338&r1=96337&r2=96338&view=diff ============================================================================== --- vmkit/trunk/tools/j3/Main.cpp (original) +++ vmkit/trunk/tools/j3/Main.cpp Tue Feb 16 02:27:58 2010 @@ -1,4 +1,4 @@ -//===--------- Main.cpp - Simple execution of JnJVM -----------------------===// +//===------------- Main.cpp - Simple execution of J3 ----------------------===// // // The VMKit project // @@ -14,26 +14,39 @@ #include "mvm/Threads/Thread.h" #include "j3/JavaJITCompiler.h" +#include "../../lib/J3/VMCore/JnjvmClassLoader.h" +#include "../../lib/J3/VMCore/Jnjvm.h" #include "llvm/Support/ManagedStatic.h" using namespace j3; -using namespace llvm; using namespace mvm; int main(int argc, char **argv, char **envp) { llvm::llvm_shutdown_obj X; - + + // Initialize base components. MvmModule::initialise(); Collector::initialise(); + + // Tell the compiler to run all optimizations. + MvmModule::AddStandardCompilePasses(); + // Create the allocator that will allocate the bootstrap loader and the JVM. + mvm::BumpPtrAllocator Allocator; JavaJITCompiler* Comp = JavaJITCompiler::CreateCompiler("JITModule"); - mvm::MvmModule::AddStandardCompilePasses(); - JnjvmClassLoader* JCL = VirtualMachine::initialiseJVM(Comp); - VirtualMachine* vm = VirtualMachine::createJVM(JCL); + JnjvmBootstrapLoader* loader = new(Allocator, "Bootstrap loader") + JnjvmBootstrapLoader(Allocator, Comp, true); + Jnjvm* vm = new(Allocator, "VM") Jnjvm(Allocator, loader); + + // Run the application. vm->runApplication(argc, argv); vm->waitForExit(); + // Destroy everyone. + vm->~Jnjvm(); + loader->~JnjvmBootstrapLoader(); + return 0; } From nicolas.geoffray at lip6.fr Tue Feb 16 00:29:27 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 16 Feb 2010 08:29:27 -0000 Subject: [vmkit-commits] [vmkit] r96339 - in /vmkit/trunk: include/mvm/VirtualMachine.h lib/J3/VMCore/JavaInitialise.cpp lib/J3/VMCore/Jnjvm.cpp Message-ID: <201002160829.o1G8TXPV020365@zion.cs.uiuc.edu> Author: geoffray Date: Tue Feb 16 02:29:27 2010 New Revision: 96339 URL: http://llvm.org/viewvc/llvm-project?rev=96339&view=rev Log: Destroy the scanner, if there is any. Modified: vmkit/trunk/include/mvm/VirtualMachine.h vmkit/trunk/lib/J3/VMCore/JavaInitialise.cpp vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Modified: vmkit/trunk/include/mvm/VirtualMachine.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/VirtualMachine.h?rev=96339&r1=96338&r2=96339&view=diff ============================================================================== --- vmkit/trunk/include/mvm/VirtualMachine.h (original) +++ vmkit/trunk/include/mvm/VirtualMachine.h Tue Feb 16 02:29:27 2010 @@ -260,7 +260,9 @@ virtual void tracer(); - virtual ~VirtualMachine() {} + virtual ~VirtualMachine() { + if (scanner) delete scanner; + } /// runApplication - Run an application. The application name is in /// the arguments, hence it is the virtual machine's job to parse them. Modified: vmkit/trunk/lib/J3/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaInitialise.cpp?rev=96339&r1=96338&r2=96339&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaInitialise.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaInitialise.cpp Tue Feb 16 02:29:27 2010 @@ -50,7 +50,6 @@ mvm::VirtualMachine* mvm::VirtualMachine::createJVM(JnjvmClassLoader* C) { mvm::BumpPtrAllocator* A = new mvm::BumpPtrAllocator(); Jnjvm* vm = new(*A, "VM") Jnjvm(*A, (JnjvmBootstrapLoader*)C); - vm->scanner = C->getCompiler()->createStackScanner(); return vm; } Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=96339&r1=96338&r2=96339&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Tue Feb 16 02:29:27 2010 @@ -1361,6 +1361,7 @@ IsolateLock.unlock(); #endif + scanner = loader->getCompiler()->createStackScanner(); } Jnjvm::~Jnjvm() { From nicolas.geoffray at lip6.fr Tue Feb 16 00:30:05 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 16 Feb 2010 08:30:05 -0000 Subject: [vmkit-commits] [vmkit] r96340 - in /vmkit/trunk/lib/N3/VMCore: CLIJit.cpp Opcodes.cpp Message-ID: <201002160830.o1G8U62Y020425@zion.cs.uiuc.edu> Author: geoffray Date: Tue Feb 16 02:29:57 2010 New Revision: 96340 URL: http://llvm.org/viewvc/llvm-project?rev=96340&view=rev Log: Change to LLVM API. Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp 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=96340&r1=96339&r2=96340&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Tue Feb 16 02:29:57 2010 @@ -401,7 +401,7 @@ Value* CLIJit::changeType(Value* val, const Type* type) { const Type* valType = val->getType(); - if (type->isInteger()) { + if (type->isIntegerTy()) { if (valType == PointerType::getUnqual(type)) { // in cast it's a struct val = new LoadInst(val, "", currentBlock); Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=96340&r1=96339&r2=96340&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Tue Feb 16 02:29:57 2010 @@ -112,13 +112,13 @@ const Type* t1 = val1->getType(); const Type* t2 = val2->getType(); if (t1 != t2) { - if (t1->isInteger() && t2->isInteger()) { + if (t1->isIntegerTy() && t2->isIntegerTy()) { if (t1->getPrimitiveSizeInBits() < t2->getPrimitiveSizeInBits()) { val1 = new SExtInst(val1, t2, "", currentBlock); } else { val2 = new SExtInst(val2, t1, "", currentBlock); } - } else if (t1->isFloatingPoint()) { + } else if (t1->isFloatTy()) { if (t1->getPrimitiveSizeInBits() < t2->getPrimitiveSizeInBits()) { val1 = new FPExtInst(val1, t2, "", currentBlock); } else { @@ -127,10 +127,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::getInt8Ty(getGlobalContext()))) { + } else if (t1->isIntegerTy() && 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::getInt8Ty(getGlobalContext()))) { + } else if (t2->isIntegerTy() && t1 == PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))) { // CLI says that this is fine for some operation val1 = new PtrToIntInst(val1, t2, "", currentBlock); } @@ -140,13 +140,13 @@ void convertValue(Value*& val, const Type* t1, BasicBlock* currentBlock) { const Type* t2 = val->getType(); if (t1 != t2) { - if (t1->isInteger() && t2->isInteger()) { + if (t1->isIntegerTy() && t2->isIntegerTy()) { if (t2->getPrimitiveSizeInBits() < t1->getPrimitiveSizeInBits()) { val = new SExtInst(val, t1, "", currentBlock); } else { val = new TruncInst(val, t1, "", currentBlock); } - } else if (t1->isFloatingPoint() && t2->isFloatingPoint()) { + } else if (t1->isFloatTy() && t2->isFloatTy()) { if (t2->getPrimitiveSizeInBits() < t1->getPrimitiveSizeInBits()) { val = new FPExtInst(val, t1, "", currentBlock); } else { @@ -280,7 +280,7 @@ BasicBlock* ifTrue = opcodeInfos[tmp + offset + read(bytecodes, i)].newBlock; \ Value* test = 0; \ verifyType(val1, val2, currentBlock); \ - if (val1->getType()->isFloatingPoint()) { \ + if (val1->getType()->isFloatTy()) { \ test = new FCmpInst(*currentBlock, FCmpInst::cmpf, val1, val2, ""); \ } else { \ test = new ICmpInst(*currentBlock, ICmpInst::cmpi, val1, val2, ""); \ @@ -341,7 +341,7 @@ Value* val1 = Constant::getNullValue(val2->getType()); \ BasicBlock* ifTrue = opcodeInfos[tmp + offset + read(bytecodes, i)].newBlock; \ Value* test = 0; \ - if (val1->getType()->isFloatingPoint()) { \ + if (val1->getType()->isFloatTy()) { \ test = new FCmpInst(*currentBlock, FCmpInst::cmpf, val1, val2, ""); \ } else { \ test = new ICmpInst(*currentBlock, ICmpInst::cmpi, val1, val2, ""); \ @@ -378,7 +378,7 @@ case CONV_I1 : { Value* val = pop(); const Type* type = val->getType(); - if (type->isFloatingPoint()) { + if (type->isFloatTy()) { push(new FPToSIInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock)); } else if (type == Type::getInt16Ty(getGlobalContext()) || type == Type::getInt32Ty(getGlobalContext()) || type == Type::getInt64Ty(getGlobalContext())) { @@ -392,7 +392,7 @@ case CONV_I2 : { Value* val = pop(); const Type* type = val->getType(); - if (type->isFloatingPoint()) { + if (type->isFloatTy()) { 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)); @@ -407,7 +407,7 @@ case CONV_I4 : { Value* val = pop(); const Type* type = val->getType(); - if (type->isFloatingPoint()) { + if (type->isFloatTy()) { push(new FPToSIInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock)); } else if (type == Type::getInt64Ty(getGlobalContext())) { push(new TruncInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock)); @@ -424,7 +424,7 @@ case CONV_I8 : { Value* val = pop(); const Type* type = val->getType(); - if (type->isFloatingPoint()) { + if (type->isFloatTy()) { push(new FPToSIInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock)); } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext()) || type == Type::getInt32Ty(getGlobalContext())) { @@ -440,7 +440,7 @@ const Type* type = val->getType(); if (type == Type::getDoubleTy(getGlobalContext())) { push(new FPTruncInst(val, Type::getFloatTy(getGlobalContext()), "", currentBlock)); - } else if (type->isInteger()) { + } else if (type->isIntegerTy()) { push(new SIToFPInst(val, Type::getFloatTy(getGlobalContext()), "", currentBlock)); } else { VMThread::get()->getVM()->unknownError("implement me"); @@ -453,7 +453,7 @@ const Type* type = val->getType(); if (type == Type::getFloatTy(getGlobalContext())) { push(new FPExtInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock)); - } else if (type->isInteger()) { + } else if (type->isIntegerTy()) { push(new SIToFPInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock)); } else if (type == Type::getDoubleTy(getGlobalContext())) { push(val); @@ -466,7 +466,7 @@ case CONV_U1 : { Value* val = pop(); const Type* type = val->getType(); - if (type->isFloatingPoint()) { + if (type->isFloatTy()) { push(new FPToUIInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock)); } else if (type == Type::getInt16Ty(getGlobalContext()) || type == Type::getInt32Ty(getGlobalContext()) || type == Type::getInt64Ty(getGlobalContext())) { @@ -480,7 +480,7 @@ case CONV_U2 : { Value* val = pop(); const Type* type = val->getType(); - if (type->isFloatingPoint()) { + if (type->isFloatTy()) { 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)); @@ -495,7 +495,7 @@ case CONV_U4 : { Value* val = pop(); const Type* type = val->getType(); - if (type->isFloatingPoint()) { + if (type->isFloatTy()) { push(new FPToUIInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock)); } else if (type == Type::getInt64Ty(getGlobalContext())) { push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock)); @@ -510,7 +510,7 @@ case CONV_U8 : { Value* val = pop(); const Type* type = val->getType(); - if (type->isFloatingPoint()) { + if (type->isFloatTy()) { push(new FPToUIInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock)); } else if (type == Type::getInt8Ty(getGlobalContext()) || type == Type::getInt16Ty(getGlobalContext()) || type == Type::getInt32Ty(getGlobalContext())) { @@ -525,12 +525,12 @@ Value* val = pop(); Value* res = 0; - if (val->getType()->isInteger()) { + if (val->getType()->isIntegerTy()) { if (val->getType() != Type::getInt64Ty(getGlobalContext())) { val = new ZExtInst(val, Type::getInt64Ty(getGlobalContext()), "", currentBlock); } res = new IntToPtrInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock); - } else if (!val->getType()->isFloatingPoint()) { + } else if (!val->getType()->isFloatTy()) { res = new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock); } else { VMThread::get()->getVM()->unknownError("implement me"); @@ -550,7 +550,7 @@ const Type* type = val->getType(); if (type == Type::getFloatTy(getGlobalContext())) { push(new FPExtInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock)); - } else if (type->isInteger()) { + } else if (type->isIntegerTy()) { push(new UIToFPInst(val, Type::getDoubleTy(getGlobalContext()), "", currentBlock)); } else if (type == Type::getDoubleTy(getGlobalContext())) { push(val); @@ -623,7 +623,7 @@ case CONV_OVF_I4_UN : { Value* val = pop(); const Type* type = val->getType(); - if (type->isFloatingPoint()) { + if (type->isFloatTy()) { push(new FPToUIInst(val, Type::getInt32Ty(getGlobalContext()), "", currentBlock)); } else if (type == Type::getInt64Ty(getGlobalContext())) { push(new TruncInst(val, Type::getInt8Ty(getGlobalContext()), "", currentBlock)); @@ -666,7 +666,7 @@ case DIV: { Value* two = pop(); Value* one = pop(); - if (one->getType()->isFloatingPoint()) { + if (one->getType()->isFloatTy()) { convertValue(one, two->getType(), currentBlock); push(BinaryOperator::CreateFDiv(one, two, "", currentBlock)); } else { @@ -678,7 +678,7 @@ case DIV_UN: { Value* two = pop(); Value* one = pop(); - if (one->getType()->isFloatingPoint()) { + if (one->getType()->isFloatTy()) { push(BinaryOperator::CreateFDiv(one, two, "", currentBlock)); } else { push(BinaryOperator::CreateUDiv(one, two, "", currentBlock)); @@ -839,7 +839,7 @@ case LDIND_U4 : case LDIND_I4 : { Value* val = pop(); - if (val->getType()->isInteger()) { + if (val->getType()->isIntegerTy()) { val = new IntToPtrInst(val, PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "", currentBlock); } else { val = new BitCastInst(val, PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "", currentBlock); @@ -1044,7 +1044,7 @@ case REM : { Value* two = pop(); Value* one = pop(); - if (one->getType()->isFloatingPoint()) { + if (one->getType()->isFloatTy()) { push(BinaryOperator::CreateFRem(one, two, "", currentBlock)); } else { push(BinaryOperator::CreateSRem(one, two, "", currentBlock)); @@ -1055,7 +1055,7 @@ case REM_UN : { Value* two = pop(); Value* one = pop(); - if (one->getType()->isFloatingPoint()) { + if (one->getType()->isFloatTy()) { push(BinaryOperator::CreateFRem(one, two, "", currentBlock)); } else { push(BinaryOperator::CreateURem(one, two, "", currentBlock)); @@ -1835,7 +1835,7 @@ Value* val2 = pop(); \ Value* val1 = pop(); \ Value* test = 0; \ - if (val1->getType()->isFloatingPoint()) { \ + if (val1->getType()->isFloatTy()) { \ test = new FCmpInst(*currentBlock, FCmpInst::cmpf, val1, val2, ""); \ } else { \ convertValue(val2, val1->getType(), currentBlock); \ From nicolas.geoffray at lip6.fr Tue Feb 16 11:59:52 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 16 Feb 2010 19:59:52 -0000 Subject: [vmkit-commits] [vmkit] r96379 - in /vmkit/trunk: include/mvm/VirtualMachine.h lib/J3/Compiler/JavaLLVMCompiler.cpp Message-ID: <201002162000.o1GK04pA004984@zion.cs.uiuc.edu> Author: geoffray Date: Tue Feb 16 13:59:21 2010 New Revision: 96379 URL: http://llvm.org/viewvc/llvm-project?rev=96379&view=rev Log: Still fixing memory leaks.... Modified: vmkit/trunk/include/mvm/VirtualMachine.h vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp Modified: vmkit/trunk/include/mvm/VirtualMachine.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/VirtualMachine.h?rev=96379&r1=96378&r2=96379&view=diff ============================================================================== --- vmkit/trunk/include/mvm/VirtualMachine.h (original) +++ vmkit/trunk/include/mvm/VirtualMachine.h Tue Feb 16 13:59:21 2010 @@ -138,6 +138,10 @@ CurrentIndex = 0; semantics = s; } + + ~ReferenceQueue() { + delete[] References; + } void addReference(gc* ref) { QueueLock.acquire(); @@ -262,6 +266,9 @@ virtual ~VirtualMachine() { if (scanner) delete scanner; + delete[] FinalizationQueue; + delete[] ToBeFinalized; + delete[] ToEnqueue; } /// runApplication - Run an application. The application name is in Modified: vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp?rev=96379&r1=96378&r2=96379&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp Tue Feb 16 13:59:21 2010 @@ -99,6 +99,8 @@ } JavaLLVMCompiler::~JavaLLVMCompiler() { + delete TheModule; + delete DebugFactory; delete JavaFunctionPasses; delete JavaNativeFunctionPasses; } From nicolas.geoffray at lip6.fr Wed Feb 17 13:04:55 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Wed, 17 Feb 2010 21:04:55 -0000 Subject: [vmkit-commits] [vmkit] r96514 - in /vmkit/trunk/lib/J3/VMCore: JavaClass.cpp JavaClass.h JavaConstantPool.cpp JavaRuntimeJIT.cpp Jnjvm.cpp Jnjvm.h Message-ID: <201002172104.o1HL4tcQ030127@zion.cs.uiuc.edu> Author: geoffray Date: Wed Feb 17 15:04:54 2010 New Revision: 96514 URL: http://llvm.org/viewvc/llvm-project?rev=96514&view=rev Log: Correctly implement invokespecial. Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp vmkit/trunk/lib/J3/VMCore/JavaClass.h vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp vmkit/trunk/lib/J3/VMCore/Jnjvm.h Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=96514&r1=96513&r2=96514&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Wed Feb 17 15:04:54 2010 @@ -363,11 +363,24 @@ return cur; } -JavaMethod* Class::lookupMethodDontThrow(const UTF8* name, - const UTF8* type, - bool isStatic, - bool recurse, - Class** methodCl) { +JavaMethod* Class::lookupSpecialMethodDontThrow(const UTF8* name, + const UTF8* type, + Class* current) { + JavaMethod* meth = lookupMethodDontThrow(name, type, false, true, NULL); + + if (isSuper(current->access) && + current != meth->classDef && + meth->classDef->isAssignableFrom(current) && + !name->equals(classLoader->bootstrapLoader->initName)) { + meth = current->super->lookupMethodDontThrow(name, type, false, true, NULL); + } + + return meth; +} + +JavaMethod* Class::lookupMethodDontThrow(const UTF8* name, const UTF8* type, + bool isStatic, bool recurse, + Class** methodCl) { JavaMethod* methods = 0; uint32 nb = 0; Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.h?rev=96514&r1=96513&r2=96514&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.h Wed Feb 17 15:04:54 2010 @@ -618,6 +618,14 @@ JavaMethod* lookupInterfaceMethodDontThrow(const UTF8* name, const UTF8* type); + /// lookupSpecialMethodDontThrow - Lookup a method following the + /// invokespecial specification. + /// Do not throw if the method is not found. + /// + JavaMethod* lookupSpecialMethodDontThrow(const UTF8* name, + const UTF8* type, + Class* current); + /// lookupMethod - Lookup a method and throw an exception if not found. /// JavaMethod* lookupMethod(const UTF8* name, const UTF8* type, bool isStatic, Modified: vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp?rev=96514&r1=96513&r2=96514&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp Wed Feb 17 15:04:54 2010 @@ -433,8 +433,13 @@ Class* lookup = cl->isArray() ? cl->super : cl->asClass(); if (lookup->isResolved()) { // lookup the method - meth = lookup->lookupMethodDontThrow(utf8, sign->keyName, - isStatic(access), true, 0); + if (isStatic(access)) { + meth = lookup->lookupMethodDontThrow(utf8, sign->keyName, + true, true, 0); + } else { + meth = lookup->lookupSpecialMethodDontThrow(utf8, sign->keyName, + classDef); + } } } Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=96514&r1=96513&r2=96514&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Wed Feb 17 15:04:54 2010 @@ -714,7 +714,12 @@ ctpInfo->resolveMethod(ctpIndex, cl, utf8, sign); UserClass* lookup = cl->isArray() ? cl->super : cl->asClass(); assert(lookup->isInitializing() && "Class not ready"); - JavaMethod* callee = lookup->lookupMethod(utf8, sign->keyName, false, true,0); + JavaMethod* callee = + lookup->lookupSpecialMethodDontThrow(utf8, sign->keyName, caller->classDef); + + if (!callee) { + th->getJVM()->abstractMethodError(lookup, utf8); + } // Compile the found method. result = callee->compiledPtr(); Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=96514&r1=96513&r2=96514&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Wed Feb 17 15:04:54 2010 @@ -526,6 +526,13 @@ upcalls->InitNoSuchMethodError, str); } +void Jnjvm::abstractMethodError(CommonClass* cl, const UTF8* name) { + JavaString* str = CreateNoSuchMsg(cl, name, this); + llvm_gcroot(str, 0); + error(upcalls->AbstractMethodError, + upcalls->InitAbstractMethodError, str); +} + static JavaString* CreateUnableToLoad(const UTF8* name, Jnjvm* vm) { ArrayUInt16* msg = (ArrayUInt16*) vm->upcalls->ArrayOfChar->doNew(15 + name->size, vm); Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.h?rev=96514&r1=96513&r2=96514&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/Jnjvm.h (original) +++ vmkit/trunk/lib/J3/VMCore/Jnjvm.h Wed Feb 17 15:04:54 2010 @@ -267,6 +267,7 @@ void classCastException(JavaObject* obj, UserCommonClass* cl); void noSuchFieldError(CommonClass* cl, const UTF8* name); void noSuchMethodError(CommonClass* cl, const UTF8* name); + void abstractMethodError(CommonClass* cl, const UTF8* name); void noClassDefFoundError(const UTF8* name); void classNotFoundException(JavaString* str); From nicolas.geoffray at lip6.fr Wed Feb 17 15:25:12 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Wed, 17 Feb 2010 23:25:12 -0000 Subject: [vmkit-commits] [vmkit] r96530 - in /vmkit/trunk/lib/J3/VMCore: JavaClass.cpp JavaClass.h JavaConstantPool.cpp JavaRuntimeJIT.cpp Jnjvm.cpp Jnjvm.h Message-ID: <201002172325.o1HNPEi9005587@zion.cs.uiuc.edu> Author: geoffray Date: Wed Feb 17 17:24:59 2010 New Revision: 96530 URL: http://llvm.org/viewvc/llvm-project?rev=96530&view=rev Log: Revert previous change. Something gets broken with MMTk. Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp vmkit/trunk/lib/J3/VMCore/JavaClass.h vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp vmkit/trunk/lib/J3/VMCore/Jnjvm.h Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=96530&r1=96529&r2=96530&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Wed Feb 17 17:24:59 2010 @@ -363,24 +363,11 @@ return cur; } -JavaMethod* Class::lookupSpecialMethodDontThrow(const UTF8* name, - const UTF8* type, - Class* current) { - JavaMethod* meth = lookupMethodDontThrow(name, type, false, true, NULL); - - if (isSuper(current->access) && - current != meth->classDef && - meth->classDef->isAssignableFrom(current) && - !name->equals(classLoader->bootstrapLoader->initName)) { - meth = current->super->lookupMethodDontThrow(name, type, false, true, NULL); - } - - return meth; -} - -JavaMethod* Class::lookupMethodDontThrow(const UTF8* name, const UTF8* type, - bool isStatic, bool recurse, - Class** methodCl) { +JavaMethod* Class::lookupMethodDontThrow(const UTF8* name, + const UTF8* type, + bool isStatic, + bool recurse, + Class** methodCl) { JavaMethod* methods = 0; uint32 nb = 0; Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.h?rev=96530&r1=96529&r2=96530&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.h Wed Feb 17 17:24:59 2010 @@ -618,14 +618,6 @@ JavaMethod* lookupInterfaceMethodDontThrow(const UTF8* name, const UTF8* type); - /// lookupSpecialMethodDontThrow - Lookup a method following the - /// invokespecial specification. - /// Do not throw if the method is not found. - /// - JavaMethod* lookupSpecialMethodDontThrow(const UTF8* name, - const UTF8* type, - Class* current); - /// lookupMethod - Lookup a method and throw an exception if not found. /// JavaMethod* lookupMethod(const UTF8* name, const UTF8* type, bool isStatic, Modified: vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp?rev=96530&r1=96529&r2=96530&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp Wed Feb 17 17:24:59 2010 @@ -433,13 +433,8 @@ Class* lookup = cl->isArray() ? cl->super : cl->asClass(); if (lookup->isResolved()) { // lookup the method - if (isStatic(access)) { - meth = lookup->lookupMethodDontThrow(utf8, sign->keyName, - true, true, 0); - } else { - meth = lookup->lookupSpecialMethodDontThrow(utf8, sign->keyName, - classDef); - } + meth = lookup->lookupMethodDontThrow(utf8, sign->keyName, + isStatic(access), true, 0); } } Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=96530&r1=96529&r2=96530&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Wed Feb 17 17:24:59 2010 @@ -714,12 +714,7 @@ ctpInfo->resolveMethod(ctpIndex, cl, utf8, sign); UserClass* lookup = cl->isArray() ? cl->super : cl->asClass(); assert(lookup->isInitializing() && "Class not ready"); - JavaMethod* callee = - lookup->lookupSpecialMethodDontThrow(utf8, sign->keyName, caller->classDef); - - if (!callee) { - th->getJVM()->abstractMethodError(lookup, utf8); - } + JavaMethod* callee = lookup->lookupMethod(utf8, sign->keyName, false, true,0); // Compile the found method. result = callee->compiledPtr(); Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=96530&r1=96529&r2=96530&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Wed Feb 17 17:24:59 2010 @@ -526,13 +526,6 @@ upcalls->InitNoSuchMethodError, str); } -void Jnjvm::abstractMethodError(CommonClass* cl, const UTF8* name) { - JavaString* str = CreateNoSuchMsg(cl, name, this); - llvm_gcroot(str, 0); - error(upcalls->AbstractMethodError, - upcalls->InitAbstractMethodError, str); -} - static JavaString* CreateUnableToLoad(const UTF8* name, Jnjvm* vm) { ArrayUInt16* msg = (ArrayUInt16*) vm->upcalls->ArrayOfChar->doNew(15 + name->size, vm); Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.h?rev=96530&r1=96529&r2=96530&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/Jnjvm.h (original) +++ vmkit/trunk/lib/J3/VMCore/Jnjvm.h Wed Feb 17 17:24:59 2010 @@ -267,7 +267,6 @@ void classCastException(JavaObject* obj, UserCommonClass* cl); void noSuchFieldError(CommonClass* cl, const UTF8* name); void noSuchMethodError(CommonClass* cl, const UTF8* name); - void abstractMethodError(CommonClass* cl, const UTF8* name); void noClassDefFoundError(const UTF8* name); void classNotFoundException(JavaString* str); From nicolas.geoffray at lip6.fr Thu Feb 18 15:20:07 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 18 Feb 2010 23:20:07 -0000 Subject: [vmkit-commits] [vmkit] r96625 - in /vmkit/trunk/lib/J3/Compiler: JavaJIT.cpp JavaJIT.h Message-ID: <201002182320.o1INK7n6022678@zion.cs.uiuc.edu> Author: geoffray Date: Thu Feb 18 17:20:01 2010 New Revision: 96625 URL: http://llvm.org/viewvc/llvm-project?rev=96625&view=rev Log: Don't use invokeSpecial to invoke things directly. Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp vmkit/trunk/lib/J3/Compiler/JavaJIT.h Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=96625&r1=96624&r2=96625&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Thu Feb 18 17:20:01 2010 @@ -79,10 +79,12 @@ CommonClass* cl = 0; JavaMethod* meth = 0; ctpInfo->infoOfMethod(index, ACC_VIRTUAL, cl, meth); + bool canBeDirect = false; + Value* val = NULL; // The return from the method. if ((cl && isFinal(cl->access)) || (meth && (isFinal(meth->access) || isPrivate(meth->access)))) { - return invokeSpecial(index); + canBeDirect = true; } // If the method is in fact a method defined in an interface, @@ -97,12 +99,22 @@ Value* obj = objectStack[stack.size() - signature->nbArguments - 1]; JavaObject* source = TheCompiler->getFinalObject(obj); if (source) { - return invokeSpecial(index, source->getClass()); + canBeDirect = true; + CommonClass* sourceClass = source->getClass(); + Class* lookup = sourceClass->isArray() ? sourceClass->super : + sourceClass->asClass(); + meth = lookup->lookupMethodDontThrow(name, signature->keyName, false, + true, 0); } if (TheCompiler->isStaticCompiling()) { CommonClass* unique = TheCompiler->getUniqueBaseClass(cl); - if (unique) return invokeSpecial(index, unique); + if (unique) { + canBeDirect = true; + Class* lookup = unique->isArray() ? unique->super : unique->asClass(); + meth = lookup->lookupMethodDontThrow(name, signature->keyName, false, + true, 0); + } } #if !defined(WITHOUT_VTABLE) @@ -116,115 +128,122 @@ JITVerifyNull(args[0]); - BasicBlock* endBlock = 0; - PHINode* node = 0; + bool needsInit = false; + if (canBeDirect && meth && !TheCompiler->needsCallback(meth, &needsInit)) { + val = invoke(TheCompiler->getMethod(meth), args, "", currentBlock); + } else { + + BasicBlock* endBlock = 0; + PHINode* node = 0; #if 0 - if (meth && !isAbstract(meth->access)) { - Value* cl = CallInst::Create(intrinsics->GetClassFunction, args[0], "", - currentBlock); - Value* cl2 = intrinsics->getNativeClass(meth->classDef); - if (cl2->getType() != intrinsics->JavaCommonClassType) { - cl2 = new BitCastInst(cl2, intrinsics->JavaCommonClassType, "", currentBlock); - } + // TODO: enable this only when inlining? + if (meth && !isAbstract(meth->access)) { + Value* cl = CallInst::Create(intrinsics->GetClassFunction, args[0], "", + currentBlock); + Value* cl2 = intrinsics->getNativeClass(meth->classDef); + if (cl2->getType() != intrinsics->JavaCommonClassType) { + cl2 = new BitCastInst(cl2, intrinsics->JavaCommonClassType, "", currentBlock); + } - Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, cl, cl2, ""); - - BasicBlock* trueBlock = createBasicBlock("true virtual invoke"); - BasicBlock* falseBlock = createBasicBlock("false virtual invoke"); - endBlock = createBasicBlock("end virtual invoke"); - BranchInst::Create(trueBlock, falseBlock, test, currentBlock); - currentBlock = trueBlock; - Value* res = 0; - if (canBeInlined(meth)) { - res = invokeInline(meth, args); - } else { - Function* func = intrinsics->getMethod(meth); - res = invoke(func, args, "", currentBlock); - } - BranchInst::Create(endBlock, currentBlock); - if (retType != Type::getVoidTy(getGlobalContext())) { - node = PHINode::Create(virtualType->getReturnType(), "", endBlock); - node->addIncoming(res, currentBlock); + Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, cl, cl2, ""); + + BasicBlock* trueBlock = createBasicBlock("true virtual invoke"); + BasicBlock* falseBlock = createBasicBlock("false virtual invoke"); + endBlock = createBasicBlock("end virtual invoke"); + BranchInst::Create(trueBlock, falseBlock, test, currentBlock); + currentBlock = trueBlock; + Value* res = 0; + if (canBeInlined(meth)) { + res = invokeInline(meth, args); + } else { + Function* func = intrinsics->getMethod(meth); + res = invoke(func, args, "", currentBlock); + } + BranchInst::Create(endBlock, currentBlock); + if (retType != Type::getVoidTy(getGlobalContext())) { + node = PHINode::Create(virtualType->getReturnType(), "", endBlock); + node->addIncoming(res, currentBlock); + } + currentBlock = falseBlock; } - currentBlock = falseBlock; - } #endif - Value* VT = CallInst::Create(intrinsics->GetVTFunction, args[0], "", - currentBlock); - Value* indexes2[2]; - indexes2[0] = intrinsics->constantZero; + Value* VT = CallInst::Create(intrinsics->GetVTFunction, args[0], "", + currentBlock); + Value* indexes2[2]; + indexes2[0] = intrinsics->constantZero; #ifdef ISOLATE_SHARING - Value* indexesCtp; //[3]; + Value* indexesCtp; //[3]; #endif - if (meth) { - LLVMMethodInfo* LMI = TheCompiler->getMethodInfo(meth); - Constant* Offset = LMI->getOffset(); - indexes2[1] = Offset; + if (meth) { + LLVMMethodInfo* LMI = TheCompiler->getMethodInfo(meth); + Constant* Offset = LMI->getOffset(); + indexes2[1] = Offset; #ifdef ISOLATE_SHARING - indexesCtp = ConstantInt::get(Type::getInt32Ty(*llvmContext), - Offset->getZExtValue() * -1); + indexesCtp = ConstantInt::get(Type::getInt32Ty(*llvmContext), + Offset->getZExtValue() * -1); #endif - } else { + } else { - GlobalVariable* GV = new GlobalVariable(*llvmFunction->getParent(), - Type::getInt32Ty(*llvmContext), - false, - GlobalValue::ExternalLinkage, - intrinsics->constantZero, ""); - - BasicBlock* resolveVirtual = createBasicBlock("resolveVirtual"); - BasicBlock* endResolveVirtual = createBasicBlock("endResolveVirtual"); - PHINode* node = PHINode::Create(Type::getInt32Ty(*llvmContext), "", - endResolveVirtual); - - Value* load = new LoadInst(GV, "", false, currentBlock); - Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, load, - intrinsics->constantZero, ""); - BranchInst::Create(resolveVirtual, endResolveVirtual, test, currentBlock); - node->addIncoming(load, currentBlock); - currentBlock = resolveVirtual; - std::vector Args; - Args.push_back(TheCompiler->getNativeClass(compilingClass)); - Args.push_back(ConstantInt::get(Type::getInt32Ty(*llvmContext), index)); - Args.push_back(GV); - Args.push_back(args[0]); - load = invoke(intrinsics->VirtualLookupFunction, Args, "", currentBlock); - node->addIncoming(load, currentBlock); - BranchInst::Create(endResolveVirtual, currentBlock); - currentBlock = endResolveVirtual; + GlobalVariable* GV = new GlobalVariable(*llvmFunction->getParent(), + Type::getInt32Ty(*llvmContext), + false, + GlobalValue::ExternalLinkage, + intrinsics->constantZero, ""); + + BasicBlock* resolveVirtual = createBasicBlock("resolveVirtual"); + BasicBlock* endResolveVirtual = createBasicBlock("endResolveVirtual"); + PHINode* node = PHINode::Create(Type::getInt32Ty(*llvmContext), "", + endResolveVirtual); + + Value* load = new LoadInst(GV, "", false, currentBlock); + Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, load, + intrinsics->constantZero, ""); + BranchInst::Create(resolveVirtual, endResolveVirtual, test, currentBlock); + node->addIncoming(load, currentBlock); + currentBlock = resolveVirtual; + std::vector Args; + Args.push_back(TheCompiler->getNativeClass(compilingClass)); + Args.push_back(ConstantInt::get(Type::getInt32Ty(*llvmContext), index)); + Args.push_back(GV); + Args.push_back(args[0]); + load = invoke(intrinsics->VirtualLookupFunction, Args, "", currentBlock); + node->addIncoming(load, currentBlock); + BranchInst::Create(endResolveVirtual, currentBlock); + currentBlock = endResolveVirtual; - indexes2[1] = node; + indexes2[1] = node; #ifdef ISOLATE_SHARING - Value* mul = BinaryOperator::CreateMul(val, intrinsics->constantMinusOne, - "", currentBlock); - indexesCtp = mul; + Value* mul = BinaryOperator::CreateMul(val, intrinsics->constantMinusOne, + "", currentBlock); + indexesCtp = mul; #endif - } + } - Value* FuncPtr = GetElementPtrInst::Create(VT, indexes2, indexes2 + 2, "", - currentBlock); + Value* FuncPtr = GetElementPtrInst::Create(VT, indexes2, indexes2 + 2, "", + currentBlock); - Value* Func = new LoadInst(FuncPtr, "", currentBlock); + Value* Func = new LoadInst(FuncPtr, "", currentBlock); - Func = new BitCastInst(Func, LSI->getVirtualPtrType(), "", currentBlock); + Func = new BitCastInst(Func, LSI->getVirtualPtrType(), "", currentBlock); #ifdef ISOLATE_SHARING - Value* CTP = GetElementPtrInst::Create(VT, indexesCtp, "", currentBlock); + Value* CTP = GetElementPtrInst::Create(VT, indexesCtp, "", currentBlock); - CTP = new LoadInst(CTP, "", currentBlock); - CTP = new BitCastInst(CTP, intrinsics->ConstantPoolType, "", currentBlock); - args.push_back(CTP); -#endif - Value* val = invoke(Func, args, "", currentBlock); - - if (endBlock) { - if (node) { - node->addIncoming(val, currentBlock); - val = node; + CTP = new LoadInst(CTP, "", currentBlock); + CTP = new BitCastInst(CTP, intrinsics->ConstantPoolType, "", currentBlock); + args.push_back(CTP); +#endif + val = invoke(Func, args, "", currentBlock); + + if (endBlock) { + if (node) { + node->addIncoming(val, currentBlock); + val = node; + } + BranchInst::Create(endBlock, currentBlock); + currentBlock = endBlock; } - BranchInst::Create(endBlock, currentBlock); - currentBlock = endBlock; } if (retType != Type::getVoidTy(getGlobalContext())) { @@ -1616,7 +1635,7 @@ return ret; } -void JavaJIT::invokeSpecial(uint16 index, CommonClass* finalCl) { +void JavaJIT::invokeSpecial(uint16 index) { JavaConstantPool* ctpInfo = compilingClass->ctpInfo; JavaMethod* meth = 0; Signdef* signature = 0; @@ -1632,13 +1651,6 @@ FunctionType::param_iterator it = virtualType->param_end(); makeArgs(it, index, args, signature->nbArguments + 1); - if (finalCl) { - Class* lookup = finalCl->isArray() ? finalCl->super : finalCl->asClass(); - - meth = lookup->lookupMethodDontThrow(name, signature->keyName, false, true, - 0); - } - if (!meth) { meth = ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_VIRTUAL, signature); } Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.h?rev=96625&r1=96624&r2=96625&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.h (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.h Thu Feb 18 17:20:01 2010 @@ -461,7 +461,7 @@ void invokeInterface(uint16 index, bool buggyVirtual = false); /// invokeSpecial - Invoke an instance Java method directly. - void invokeSpecial(uint16 index, CommonClass* finalCl = 0); + void invokeSpecial(uint16 index); /// invokeStatic - Invoke a static Java method. void invokeStatic(uint16 index); From nicolas.geoffray at lip6.fr Thu Feb 18 15:32:03 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 18 Feb 2010 23:32:03 -0000 Subject: [vmkit-commits] [vmkit] r96627 - in /vmkit/trunk/lib/J3/VMCore: JavaClass.cpp JavaClass.h JavaConstantPool.cpp JavaRuntimeJIT.cpp Jnjvm.cpp Jnjvm.h Message-ID: <201002182332.o1INW5CE023288@zion.cs.uiuc.edu> Author: geoffray Date: Thu Feb 18 17:31:45 2010 New Revision: 96627 URL: http://llvm.org/viewvc/llvm-project?rev=96627&view=rev Log: Reapply invokespecial correct implementation. Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp vmkit/trunk/lib/J3/VMCore/JavaClass.h vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp vmkit/trunk/lib/J3/VMCore/Jnjvm.h Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=96627&r1=96626&r2=96627&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Thu Feb 18 17:31:45 2010 @@ -363,11 +363,24 @@ return cur; } -JavaMethod* Class::lookupMethodDontThrow(const UTF8* name, - const UTF8* type, - bool isStatic, - bool recurse, - Class** methodCl) { +JavaMethod* Class::lookupSpecialMethodDontThrow(const UTF8* name, + const UTF8* type, + Class* current) { + JavaMethod* meth = lookupMethodDontThrow(name, type, false, true, NULL); + + if (isSuper(current->access) && + current != meth->classDef && + meth->classDef->isAssignableFrom(current) && + !name->equals(classLoader->bootstrapLoader->initName)) { + meth = current->super->lookupMethodDontThrow(name, type, false, true, NULL); + } + + return meth; +} + +JavaMethod* Class::lookupMethodDontThrow(const UTF8* name, const UTF8* type, + bool isStatic, bool recurse, + Class** methodCl) { JavaMethod* methods = 0; uint32 nb = 0; Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.h?rev=96627&r1=96626&r2=96627&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.h Thu Feb 18 17:31:45 2010 @@ -618,6 +618,14 @@ JavaMethod* lookupInterfaceMethodDontThrow(const UTF8* name, const UTF8* type); + /// lookupSpecialMethodDontThrow - Lookup a method following the + /// invokespecial specification. + /// Do not throw if the method is not found. + /// + JavaMethod* lookupSpecialMethodDontThrow(const UTF8* name, + const UTF8* type, + Class* current); + /// lookupMethod - Lookup a method and throw an exception if not found. /// JavaMethod* lookupMethod(const UTF8* name, const UTF8* type, bool isStatic, Modified: vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp?rev=96627&r1=96626&r2=96627&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaConstantPool.cpp Thu Feb 18 17:31:45 2010 @@ -433,8 +433,13 @@ Class* lookup = cl->isArray() ? cl->super : cl->asClass(); if (lookup->isResolved()) { // lookup the method - meth = lookup->lookupMethodDontThrow(utf8, sign->keyName, - isStatic(access), true, 0); + if (isStatic(access)) { + meth = lookup->lookupMethodDontThrow(utf8, sign->keyName, + true, true, 0); + } else { + meth = lookup->lookupSpecialMethodDontThrow(utf8, sign->keyName, + classDef); + } } } Modified: vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=96627&r1=96626&r2=96627&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaRuntimeJIT.cpp Thu Feb 18 17:31:45 2010 @@ -714,7 +714,12 @@ ctpInfo->resolveMethod(ctpIndex, cl, utf8, sign); UserClass* lookup = cl->isArray() ? cl->super : cl->asClass(); assert(lookup->isInitializing() && "Class not ready"); - JavaMethod* callee = lookup->lookupMethod(utf8, sign->keyName, false, true,0); + JavaMethod* callee = + lookup->lookupSpecialMethodDontThrow(utf8, sign->keyName, caller->classDef); + + if (!callee) { + th->getJVM()->abstractMethodError(lookup, utf8); + } // Compile the found method. result = callee->compiledPtr(); Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp?rev=96627&r1=96626&r2=96627&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/Jnjvm.cpp Thu Feb 18 17:31:45 2010 @@ -526,6 +526,13 @@ upcalls->InitNoSuchMethodError, str); } +void Jnjvm::abstractMethodError(CommonClass* cl, const UTF8* name) { + JavaString* str = CreateNoSuchMsg(cl, name, this); + llvm_gcroot(str, 0); + error(upcalls->AbstractMethodError, + upcalls->InitAbstractMethodError, str); +} + static JavaString* CreateUnableToLoad(const UTF8* name, Jnjvm* vm) { ArrayUInt16* msg = (ArrayUInt16*) vm->upcalls->ArrayOfChar->doNew(15 + name->size, vm); Modified: vmkit/trunk/lib/J3/VMCore/Jnjvm.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/Jnjvm.h?rev=96627&r1=96626&r2=96627&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/Jnjvm.h (original) +++ vmkit/trunk/lib/J3/VMCore/Jnjvm.h Thu Feb 18 17:31:45 2010 @@ -267,6 +267,7 @@ void classCastException(JavaObject* obj, UserCommonClass* cl); void noSuchFieldError(CommonClass* cl, const UTF8* name); void noSuchMethodError(CommonClass* cl, const UTF8* name); + void abstractMethodError(CommonClass* cl, const UTF8* name); void noClassDefFoundError(const UTF8* name); void classNotFoundException(JavaString* str); From nicolas.geoffray at lip6.fr Sun Feb 21 07:20:12 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 21 Feb 2010 15:20:12 -0000 Subject: [vmkit-commits] [vmkit] r96736 - in /vmkit/trunk: include/j3/LLVMInfo.h include/mvm/JIT.h lib/J3/Compiler/JavaJITCompiler.cpp lib/Mvm/Compiler/JIT.cpp lib/Mvm/Compiler/VmkitGC.cpp Message-ID: <20100221152012.E851F2A6C11F@llvm.org> Author: geoffray Date: Sun Feb 21 09:20:12 2010 New Revision: 96736 URL: http://llvm.org/viewvc/llvm-project?rev=96736&view=rev Log: Remove unused code anr rename the GCStrategy to something more grepable. Modified: vmkit/trunk/include/j3/LLVMInfo.h vmkit/trunk/include/mvm/JIT.h vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/Mvm/Compiler/JIT.cpp vmkit/trunk/lib/Mvm/Compiler/VmkitGC.cpp Modified: vmkit/trunk/include/j3/LLVMInfo.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMInfo.h?rev=96736&r1=96735&r2=96736&view=diff ============================================================================== --- vmkit/trunk/include/j3/LLVMInfo.h (original) +++ vmkit/trunk/include/j3/LLVMInfo.h Sun Feb 21 09:20:12 2010 @@ -85,19 +85,17 @@ public: - llvm::GCFunctionInfo* GCInfo; llvm::Function* getMethod(); llvm::Constant* getOffset(); const llvm::FunctionType* getFunctionType(); LLVMMethodInfo(JavaMethod* M) : methodDef(M), methodFunction(0), - offsetConstant(0), functionType(0), DbgSubprogram(0), GCInfo(0) {} + offsetConstant(0), functionType(0), DbgSubprogram(0) {} void setDbgSubprogram(llvm::MDNode* node) { DbgSubprogram = node; } llvm::MDNode* getDbgSubprogram() { return DbgSubprogram; } virtual void clear() { - GCInfo = 0; methodFunction = 0; offsetConstant = 0; functionType = 0; Modified: vmkit/trunk/include/mvm/JIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=96736&r1=96735&r2=96736&view=diff ============================================================================== --- vmkit/trunk/include/mvm/JIT.h (original) +++ vmkit/trunk/include/mvm/JIT.h Sun Feb 21 09:20:12 2010 @@ -174,7 +174,7 @@ static const llvm::Type* pointerSizeType; static llvm::ExecutionEngine* executionEngine; - static llvm::GCStrategy* GC; + static llvm::GCStrategy* TheGCStrategy; static mvm::LockRecursive protectEngine; static llvm::Module *globalModule; static llvm::FunctionPassManager* globalFunctionPasses; Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96736&r1=96735&r2=96736&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sun Feb 21 09:20:12 2010 @@ -84,7 +84,7 @@ llvm::GCFunctionInfo* GFI = 0; // We know the last GC info is for this method. if (F.hasGC()) { - GCStrategy::iterator I = mvm::MvmModule::GC->end(); + GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end(); I--; DEBUG(errs() << (*I)->getFunction().getName() << '\n'); DEBUG(errs() << F.getName() << '\n'); @@ -399,20 +399,6 @@ void* res = mvm::MvmModule::executionEngine->getPointerToGlobal(func); JITListener->setCurrentCompiledMethod(0); func->deleteBody(); - - // Update the GC info. - LLVMMethodInfo* LMI = getMethodInfo(meth); - // If it's not, we know the last GC info is for this method. - if (func->hasGC() && !LMI->GCInfo) { - GCStrategy::iterator I = mvm::MvmModule::GC->end(); - I--; - DEBUG(errs() << (*I)->getFunction().getName() << '\n'); - DEBUG(errs() << LMI->getMethod()->getName() << '\n'); - assert(&(*I)->getFunction() == LMI->getMethod() && - "GC Info and method do not correspond"); - LMI->GCInfo = *I; - } - mvm::MvmModule::unprotectIR(); return res; Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=96736&r1=96735&r2=96736&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sun Feb 21 09:20:12 2010 @@ -82,12 +82,14 @@ virtual void NotifyFunctionEmitted(const Function &F, void *Code, size_t Size, const EmittedFunctionDetails &Details) { - + // Functions compiled in the global module are MMTk functions and the + // interfaces with VMKit. if (F.getParent() == MvmModule::globalModule) { llvm::GCFunctionInfo* GFI = 0; // We know the last GC info is for this method. if (F.hasGC()) { - GCStrategy::iterator I = mvm::MvmModule::GC->end(); + // Only the interface functions have GC informations. + GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end(); I--; DEBUG(errs() << (*I)->getFunction().getName() << '\n'); DEBUG(errs() << F.getName() << '\n'); @@ -267,7 +269,11 @@ Boot = (BootType)(uintptr_t)executionEngine->getPointerToFunction(F); Boot(Plan); - + F = globalModule->getFunction("Java_org_j3_mmtk_Collection_triggerCollection__I"); + assert(F && "Could not find external collect"); + gc::MMTkTriggerCollection = (gc::MMTkCollectType) + (uintptr_t)executionEngine->getPointerToFunction(F); + //===-------------------- TODO: make those virtual. -------------------===// F = globalModule->getFunction("JnJVM_org_mmtk_plan_TraceLocal_reportDelayedRootEdge__Lorg_vmmagic_unboxed_Address_2"); assert(F && "Could not find reportDelayedRootEdge from TraceLocal"); @@ -314,11 +320,6 @@ gc::MMTkGetForwardedFinalizable = (gc::MMTkGetForwardedFinalizableType) (uintptr_t)executionEngine->getPointerToFunction(F); - F = globalModule->getFunction("Java_org_j3_mmtk_Collection_triggerCollection__I"); - assert(F && "Could not find external collect"); - gc::MMTkTriggerCollection = (gc::MMTkCollectType) - (uintptr_t)executionEngine->getPointerToFunction(F); - } #endif } @@ -461,7 +462,7 @@ const llvm::Type* MvmModule::arrayPtrType; const llvm::TargetData* MvmModule::TheTargetData; -llvm::GCStrategy* MvmModule::GC; +llvm::GCStrategy* MvmModule::TheGCStrategy; llvm::Module *MvmModule::globalModule; llvm::FunctionPassManager* MvmModule::globalFunctionPasses; llvm::ExecutionEngine* MvmModule::executionEngine; Modified: vmkit/trunk/lib/Mvm/Compiler/VmkitGC.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/VmkitGC.cpp?rev=96736&r1=96735&r2=96736&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/VmkitGC.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/VmkitGC.cpp Sun Feb 21 09:20:12 2010 @@ -32,5 +32,5 @@ VmkitGC::VmkitGC() { NeededSafePoints = 1 << GC::PostCall; - mvm::MvmModule::GC = this; + mvm::MvmModule::TheGCStrategy = this; } From nicolas.geoffray at lip6.fr Sun Feb 21 08:11:33 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 21 Feb 2010 16:11:33 -0000 Subject: [vmkit-commits] [vmkit] r96737 - in /vmkit/trunk: include/j3/J3Intrinsics.h include/mvm/JIT.h lib/J3/Compiler/J3Intrinsics.cpp lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/JavaLLVMCompiler.cpp lib/J3/Compiler/LLVMInfo.cpp lib/Mvm/Compiler/JIT.cpp lib/N3/Mono/MonoString.cpp lib/N3/VMCore/CLIJit.cpp lib/N3/VMCore/CLIJit.h lib/N3/VMCore/CLIJitMeta.cpp lib/N3/VMCore/N3.cpp lib/N3/VMCore/N3.h lib/N3/VMCore/Opcodes.cpp Message-ID: <20100221161133.EA8B82A6C11F@llvm.org> Author: geoffray Date: Sun Feb 21 10:11:33 2010 New Revision: 96737 URL: http://llvm.org/viewvc/llvm-project?rev=96737&view=rev Log: Separate llvm functionalities and llvm types/constants/functions. Modified: vmkit/trunk/include/j3/J3Intrinsics.h vmkit/trunk/include/mvm/JIT.h vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp vmkit/trunk/lib/Mvm/Compiler/JIT.cpp vmkit/trunk/lib/N3/Mono/MonoString.cpp vmkit/trunk/lib/N3/VMCore/CLIJit.cpp vmkit/trunk/lib/N3/VMCore/CLIJit.h vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp vmkit/trunk/lib/N3/VMCore/N3.cpp vmkit/trunk/lib/N3/VMCore/N3.h vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Modified: vmkit/trunk/include/j3/J3Intrinsics.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/J3Intrinsics.h?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/include/j3/J3Intrinsics.h (original) +++ vmkit/trunk/include/j3/J3Intrinsics.h Sun Feb 21 10:11:33 2010 @@ -14,7 +14,7 @@ namespace j3 { -class J3Intrinsics : public mvm::MvmModule { +class J3Intrinsics : public mvm::BaseIntrinsics { public: static const llvm::Type* JavaArrayUInt8Type; Modified: vmkit/trunk/include/mvm/JIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/include/mvm/JIT.h (original) +++ vmkit/trunk/include/mvm/JIT.h Sun Feb 21 10:11:33 2010 @@ -60,11 +60,11 @@ const float NaNFloat = NAN; //(float)(((float)0.0) / (float)0.0); const double NaNDouble = NAN; //0.0 / 0.0; -class MvmModule { +class BaseIntrinsics { public: - explicit MvmModule(llvm::Module*); + explicit BaseIntrinsics(llvm::Module*); llvm::Function* exceptionEndCatch; llvm::Function* exceptionBeginCatch; @@ -172,7 +172,11 @@ static const llvm::PointerType* ptrPtrType; static const llvm::Type* arrayPtrType; static const llvm::Type* pointerSizeType; +}; + +class MvmModule { +public: static llvm::ExecutionEngine* executionEngine; static llvm::GCStrategy* TheGCStrategy; static mvm::LockRecursive protectEngine; Modified: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp Sun Feb 21 10:11:33 2010 @@ -63,7 +63,7 @@ } void J3Intrinsics::initialise() { - Module* module = globalModule; + Module* module = mvm::MvmModule::globalModule; if (!module->getTypeByName("JavaThread")) j3::llvm_runtime::makeLLVMModuleContents(module); @@ -132,11 +132,11 @@ } J3Intrinsics::J3Intrinsics(llvm::Module* module) : - MvmModule(module) { + BaseIntrinsics(module) { if (!VTType) { initialise(); - copyDefinitions(module, globalModule); + mvm::MvmModule::copyDefinitions(module, mvm::MvmModule::globalModule); } JavaObjectNullConstant = Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sun Feb 21 10:11:33 2010 @@ -1651,7 +1651,7 @@ Module* Mod = getLLVMModule(); for (Module::const_global_iterator i = Mod->global_begin(), e = Mod->global_end(); i != e; ++i) { - size += J3Intrinsics::getTypeSize(i->getType()); + size += mvm::MvmModule::getTypeSize(i->getType()); } fprintf(stderr, "%lluB\n", (unsigned long long int)size); } Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sun Feb 21 10:11:33 2010 @@ -248,9 +248,9 @@ EmitFunctionName = false; #endif - J3Intrinsics::protectEngine.lock(); - J3Intrinsics::executionEngine->addModule(TheModule); - J3Intrinsics::protectEngine.unlock(); + mvm::MvmModule::protectEngine.lock(); + mvm::MvmModule::executionEngine->addModule(TheModule); + mvm::MvmModule::protectEngine.unlock(); addJavaPasses(); @@ -388,7 +388,7 @@ Function* func = getMethodInfo(meth)->getMethod(); func->setName(name); assert(ptr && "No value given"); - J3Intrinsics::executionEngine->updateGlobalMapping(func, ptr); + mvm::MvmModule::executionEngine->updateGlobalMapping(func, ptr); func->setLinkage(GlobalValue::ExternalLinkage); } @@ -480,7 +480,7 @@ JavaJITCompiler* JavaJITCompiler::CreateCompiler(const std::string& ModuleID) { if (LLVMLazy) { - J3Intrinsics::executionEngine->DisableLazyCompilation(false); + mvm::MvmModule::executionEngine->DisableLazyCompilation(false); return new JavaLLVMLazyJITCompiler(ModuleID); } return new JavaJ3LazyJITCompiler(ModuleID); Modified: vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp Sun Feb 21 10:11:33 2010 @@ -61,20 +61,20 @@ Function* func = LMI->getMethod(); // We are jitting. Take the lock. - J3Intrinsics::protectIR(); + mvm::MvmModule::protectIR(); if (func->getLinkage() == GlobalValue::ExternalWeakLinkage) { JavaJIT jit(this, meth, func); if (isNative(meth->access)) { jit.nativeCompile(); - J3Intrinsics::runPasses(func, JavaNativeFunctionPasses); + mvm::MvmModule::runPasses(func, JavaNativeFunctionPasses); } else { jit.javaCompile(); - J3Intrinsics::runPasses(func, J3Intrinsics::globalFunctionPasses); - J3Intrinsics::runPasses(func, JavaFunctionPasses); + mvm::MvmModule::runPasses(func, mvm::MvmModule::globalFunctionPasses); + mvm::MvmModule::runPasses(func, JavaFunctionPasses); } func->setLinkage(GlobalValue::ExternalLinkage); } - J3Intrinsics::unprotectIR(); + mvm::MvmModule::unprotectIR(); return func; } Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Sun Feb 21 10:11:33 2010 @@ -39,7 +39,7 @@ const Type* LLVMClassInfo::getVirtualType() { if (!virtualType) { std::vector fields; - const TargetData* targetData = J3Intrinsics::TheTargetData; + const TargetData* targetData = mvm::MvmModule::TheTargetData; const StructLayout* sl = 0; const StructType* structType = 0; JavaLLVMCompiler* Mod = @@ -77,7 +77,7 @@ field.ptrOffset = sl->getElementOffset(i + 1); } - uint64 size = J3Intrinsics::getTypeSize(structType); + uint64 size = mvm::MvmModule::getTypeSize(structType); classDef->virtualSize = (uint32)size; classDef->alignment = sl->getAlignment(); virtualSizeConstant = ConstantInt::get(Type::getInt32Ty(context), size); @@ -109,7 +109,7 @@ StructType* structType = StructType::get(context, fields, false); staticType = PointerType::getUnqual(structType); - const TargetData* targetData = J3Intrinsics::TheTargetData; + const TargetData* targetData = mvm::MvmModule::TheTargetData; const StructLayout* sl = targetData->getStructLayout(structType); for (uint32 i = 0; i < classDef->nbStaticFields; ++i) { @@ -117,7 +117,7 @@ field.ptrOffset = sl->getElementOffset(i); } - uint64 size = J3Intrinsics::getTypeSize(structType); + uint64 size = mvm::MvmModule::getTypeSize(structType); cl->staticSize = size; } return staticType; @@ -297,7 +297,7 @@ const llvm::Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaObjectType); - llvmArgs.push_back(mvm::MvmModule::ptrType); // JNIEnv + llvmArgs.push_back(J3Intrinsics::ptrType); // JNIEnv llvmArgs.push_back(Ty); // Class for (uint32 i = 0; i < size; ++i) { Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sun Feb 21 10:11:33 2010 @@ -166,14 +166,8 @@ mvm::llvm_runtime::makeLLVMModuleContents(globalModule); - LLVMContext& Context = globalModule->getContext(); + //LLVMContext& Context = globalModule->getContext(); //MetadataTypeKind = Context.getMDKindID("HighLevelType"); - // Type declaration - ptrType = PointerType::getUnqual(Type::getInt8Ty(Context)); - ptr32Type = PointerType::getUnqual(Type::getInt32Ty(Context)); - ptrPtrType = PointerType::getUnqual(ptrType); - pointerSizeType = globalModule->getPointerSize() == Module::Pointer32 ? - Type::getInt32Ty(Context) : Type::getInt64Ty(Context); for (std::vector::iterator i = LoadBytecodeFiles.begin(), e = LoadBytecodeFiles.end(); i != e; ++i) { @@ -325,12 +319,21 @@ } -MvmModule::MvmModule(llvm::Module* module) { +BaseIntrinsics::BaseIntrinsics(llvm::Module* module) { - module->setDataLayout(globalModule->getDataLayout()); - module->setTargetTriple(globalModule->getTargetTriple()); + module->setDataLayout(MvmModule::globalModule->getDataLayout()); + module->setTargetTriple(MvmModule::globalModule->getTargetTriple()); LLVMContext& Context = module->getContext(); + if (!ptrType) { + // Type declaration + ptrType = PointerType::getUnqual(Type::getInt8Ty(Context)); + ptr32Type = PointerType::getUnqual(Type::getInt32Ty(Context)); + ptrPtrType = PointerType::getUnqual(ptrType); + pointerSizeType = module->getPointerSize() == Module::Pointer32 ? + Type::getInt32Ty(Context) : Type::getInt64Ty(Context); + } + // Constant declaration constantLongMinusOne = ConstantInt::get(Type::getInt64Ty(Context), (uint64_t)-1); constantLongZero = ConstantInt::get(Type::getInt64Ty(Context), 0); @@ -384,7 +387,7 @@ arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::getInt8Ty(Context), 0)); - copyDefinitions(module, globalModule); + MvmModule::copyDefinitions(module, MvmModule::globalModule); printFloatLLVM = module->getFunction("printFloat"); printDoubleLLVM = module->getFunction("printDouble"); @@ -455,11 +458,11 @@ } -const llvm::PointerType* MvmModule::ptrType; -const llvm::PointerType* MvmModule::ptr32Type; -const llvm::PointerType* MvmModule::ptrPtrType; -const llvm::Type* MvmModule::pointerSizeType; -const llvm::Type* MvmModule::arrayPtrType; +const llvm::PointerType* BaseIntrinsics::ptrType; +const llvm::PointerType* BaseIntrinsics::ptr32Type; +const llvm::PointerType* BaseIntrinsics::ptrPtrType; +const llvm::Type* BaseIntrinsics::pointerSizeType; +const llvm::Type* BaseIntrinsics::arrayPtrType; const llvm::TargetData* MvmModule::TheTargetData; llvm::GCStrategy* MvmModule::TheGCStrategy; Modified: vmkit/trunk/lib/N3/Mono/MonoString.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Mono/MonoString.cpp?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/N3/Mono/MonoString.cpp (original) +++ vmkit/trunk/lib/N3/Mono/MonoString.cpp Sun Feb 21 10:11:33 2010 @@ -44,7 +44,7 @@ if (!str->_llvmVar) { N3* vm = VMThread::get()->getVM(); if (!str->_llvmVar) { - const Type* pty = mvm::MvmModule::ptrType; + const Type* pty = mvm::BaseIntrinsics::ptrType; Module* Mod = vm->getLLVMModule(); Constant* cons = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (self)), Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.cpp?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJit.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJit.cpp Sun Feb 21 10:11:33 2010 @@ -652,7 +652,7 @@ } else if (type->super == MSCorlib::pValue || type->super == MSCorlib::pEnum) { obj = new AllocaInst(type->naturalType, "", currentBlock); - uint64 size = module->getTypeSize(type->naturalType); + uint64 size = mvm::MvmModule::getTypeSize(type->naturalType); std::vector params; params.push_back(new BitCastInst(obj, module->ptrType, "", currentBlock)); @@ -759,7 +759,7 @@ if (field->signature->super == MSCorlib::pValue && field->signature->virtualFields.size() > 1) { - uint64 size = module->getTypeSize(field->signature->naturalType); + uint64 size = mvm::MvmModule::getTypeSize(field->signature->naturalType); std::vector params; params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); @@ -1255,7 +1255,7 @@ new StoreInst(Constant::getNullValue(cl->naturalType), alloc, false, currentBlock); } else { - uint64 size = module->getTypeSize(cl->naturalType); + uint64 size = mvm::MvmModule::getTypeSize(cl->naturalType); std::vector params; params.push_back(new BitCastInst(alloc, module->ptrType, "", @@ -1302,7 +1302,7 @@ } else if (compilingMethod->structReturn) { const Type* lastType = funcType->getContainedType(funcType->getNumContainedTypes() - 1); - uint64 size = module->getTypeSize(lastType->getContainedType(0)); + uint64 size = mvm::MvmModule::getTypeSize(lastType->getContainedType(0)); Value* obj = --llvmFunction->arg_end(); std::vector params; params.push_back(new BitCastInst(obj, module->ptrType, "", @@ -1338,7 +1338,7 @@ new UnreachableInst(getGlobalContext(), unifiedUnreachable); } - module->runPasses(llvmFunction, VMThread::get()->perFunctionPasses); + mvm::MvmModule::runPasses(llvmFunction, VMThread::get()->perFunctionPasses); if (nbe == 0 && codeLen < 50) { PRINT_DEBUG(N3_COMPILE, 1, COLOR_NORMAL, "%s can be inlined\n", @@ -1432,7 +1432,7 @@ new StoreInst(Constant::getNullValue(cl->naturalType), alloc, false, currentBlock); } else { - uint64 size = module->getTypeSize(cl->naturalType); + uint64 size = mvm::MvmModule::getTypeSize(cl->naturalType); std::vector params; params.push_back(new BitCastInst(alloc, module->ptrType, "", @@ -1548,11 +1548,10 @@ void CLIJit::initialiseBootstrapVM(N3* vm) { - mvm::MvmModule* M = vm->module; Module* module = vm->getLLVMModule(); - M->protectEngine.lock(); - M->executionEngine->addModule(module); - M->protectEngine.unlock(); + mvm::MvmModule::protectEngine.lock(); + mvm::MvmModule::executionEngine->addModule(module); + mvm::MvmModule::protectEngine.unlock(); n3::llvm_runtime::makeLLVMModuleContents(module); Modified: vmkit/trunk/lib/N3/VMCore/CLIJit.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJit.h?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJit.h (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJit.h Sun Feb 21 10:11:33 2010 @@ -91,7 +91,7 @@ llvm::Function* llvmFunction; VMMethod* compilingMethod; VMClass* compilingClass; - mvm::MvmModule* module; + mvm::BaseIntrinsics* module; std::vector arguments; std::vector locals; Modified: vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp Sun Feb 21 10:11:33 2010 @@ -264,7 +264,7 @@ aquire(); if (!_llvmVar) { Module* Mod = vm->getLLVMModule(); - const Type* pty = mvm::MvmModule::ptrType; + const Type* pty = mvm::BaseIntrinsics::ptrType; Constant* cons = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)), pty); @@ -283,7 +283,7 @@ if (!_llvmVar) { classDef->aquire(); if (!_llvmVar) { - const Type* pty = mvm::MvmModule::ptrType; + const Type* pty = mvm::BaseIntrinsics::ptrType; Module* Mod = classDef->vm->getLLVMModule(); Constant* cons = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)), @@ -303,7 +303,7 @@ classDef->aquire(); if (!_llvmVar) { Module* Mod = classDef->vm->getLLVMModule(); - const Type* pty = mvm::MvmModule::ptrType; + const Type* pty = mvm::BaseIntrinsics::ptrType; Constant* cons = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)), pty); Modified: vmkit/trunk/lib/N3/VMCore/N3.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3.cpp?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/N3.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/N3.cpp Sun Feb 21 10:11:33 2010 @@ -101,7 +101,7 @@ this->scanner = new mvm::UnpreciseStackScanner(); this->LLVMModule = new llvm::Module(name, llvm::getGlobalContext()); - this->module = new mvm::MvmModule(this->LLVMModule); + this->module = new mvm::BaseIntrinsics(this->LLVMModule); this->LLVMModule->setDataLayout(mvm::MvmModule::executionEngine->getTargetData()->getStringRepresentation()); this->protectModule = new mvm::LockNormal(); Modified: vmkit/trunk/lib/N3/VMCore/N3.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/N3.h?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/N3.h (original) +++ vmkit/trunk/lib/N3/VMCore/N3.h Sun Feb 21 10:11:33 2010 @@ -96,7 +96,7 @@ mvm::Lock* protectModule; FunctionMap* functions; - mvm::MvmModule* module; + mvm::BaseIntrinsics* module; llvm::Module* LLVMModule; N3ModuleProvider* TheModuleProvider; Modified: vmkit/trunk/lib/N3/VMCore/Opcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/Opcodes.cpp?rev=96737&r1=96736&r2=96737&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/Opcodes.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/Opcodes.cpp Sun Feb 21 10:11:33 2010 @@ -159,7 +159,7 @@ } static void store(Value* val, Value* local, bool vol, - BasicBlock* currentBlock, mvm::MvmModule* module) { + BasicBlock* currentBlock, mvm::BaseIntrinsics* module) { const Type* contained = local->getType()->getContainedType(0); if (contained->isSingleValueType()) { if (val->getType() != contained) { @@ -167,7 +167,7 @@ } new StoreInst(val, local, vol, currentBlock); } else if (isa(val->getType())) { - uint64 size = module->getTypeSize(contained); + uint64 size = mvm::MvmModule::getTypeSize(contained); std::vector params; params.push_back(new BitCastInst(local, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); @@ -180,12 +180,12 @@ } } -static Value* load(Value* val, const char* name, BasicBlock* currentBlock, mvm::MvmModule* module) { +static Value* load(Value* val, const char* name, BasicBlock* currentBlock, mvm::BaseIntrinsics* module) { const Type* contained = val->getType()->getContainedType(0); if (contained->isSingleValueType()) { return new LoadInst(val, name, currentBlock); } else { - uint64 size = module->getTypeSize(contained); + uint64 size = mvm::MvmModule::getTypeSize(contained); Value* ret = new AllocaInst(contained, "", currentBlock); std::vector params; params.push_back(new BitCastInst(ret, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); @@ -1303,7 +1303,7 @@ } - uint64 size = module->getTypeSize(type->naturalType); + uint64 size = mvm::MvmModule::getTypeSize(type->naturalType); std::vector params; params.push_back(new BitCastInst(ptr, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); @@ -1803,7 +1803,7 @@ Value* ptr = GetElementPtrInst::Create(obj, ptrs.begin(), ptrs.end(), "", currentBlock); - uint64 size = module->getTypeSize(type->naturalType); + uint64 size = mvm::MvmModule::getTypeSize(type->naturalType); std::vector params; params.push_back(new BitCastInst(val, PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())), "", currentBlock)); @@ -1953,7 +1953,7 @@ VMCommonClass* type = assembly->loadType(vm, token, true, false, false, true, genClass, genMethod); if (type->super == MSCorlib::pValue) { - uint64 size = module->getTypeSize(type->naturalType); + uint64 size = mvm::MvmModule::getTypeSize(type->naturalType); std::vector params; params.push_back(new BitCastInst(pop(), module->ptrType, "", From nicolas.geoffray at lip6.fr Sun Feb 21 11:32:50 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sun, 21 Feb 2010 19:32:50 -0000 Subject: [vmkit-commits] [vmkit] r96749 - in /vmkit/trunk: include/j3/J3Intrinsics.h include/mvm/JIT.h lib/J3/Compiler/ExceptionsCheck.inc lib/J3/Compiler/J3Intrinsics.cpp lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/LLVMInfo.cpp lib/J3/Compiler/LowerConstantCalls.cpp lib/Mvm/Compiler/JIT.cpp lib/N3/Mono/MonoString.cpp lib/N3/VMCore/CLIJitMeta.cpp Message-ID: <20100221193250.90BE62A6C124@llvm.org> Author: geoffray Date: Sun Feb 21 13:32:50 2010 New Revision: 96749 URL: http://llvm.org/viewvc/llvm-project?rev=96749&view=rev Log: Remove static types, and make them local to intrinsics. Modified: vmkit/trunk/include/j3/J3Intrinsics.h vmkit/trunk/include/mvm/JIT.h vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp vmkit/trunk/lib/Mvm/Compiler/JIT.cpp vmkit/trunk/lib/N3/Mono/MonoString.cpp vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp Modified: vmkit/trunk/include/j3/J3Intrinsics.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/J3Intrinsics.h?rev=96749&r1=96748&r2=96749&view=diff ============================================================================== --- vmkit/trunk/include/j3/J3Intrinsics.h (original) +++ vmkit/trunk/include/j3/J3Intrinsics.h Sun Feb 21 13:32:50 2010 @@ -17,35 +17,35 @@ class J3Intrinsics : public mvm::BaseIntrinsics { public: - static const llvm::Type* JavaArrayUInt8Type; - static const llvm::Type* JavaArraySInt8Type; - static const llvm::Type* JavaArrayUInt16Type; - static const llvm::Type* JavaArraySInt16Type; - static const llvm::Type* JavaArrayUInt32Type; - static const llvm::Type* JavaArraySInt32Type; - static const llvm::Type* JavaArrayLongType; - static const llvm::Type* JavaArrayFloatType; - static const llvm::Type* JavaArrayDoubleType; - static const llvm::Type* JavaArrayObjectType; - - static const llvm::Type* VTType; - static const llvm::Type* JavaObjectType; - static const llvm::Type* JavaArrayType; - static const llvm::Type* JavaCommonClassType; - static const llvm::Type* JavaClassType; - static const llvm::Type* JavaClassArrayType; - static const llvm::Type* JavaClassPrimitiveType; - static const llvm::Type* ConstantPoolType; - static const llvm::Type* CodeLineInfoType; - static const llvm::Type* UTF8Type; - static const llvm::Type* JavaMethodType; - static const llvm::Type* JavaFieldType; - static const llvm::Type* AttributType; - static const llvm::Type* JavaThreadType; - static const llvm::Type* MutatorThreadType; + const llvm::Type* JavaArrayUInt8Type; + const llvm::Type* JavaArraySInt8Type; + const llvm::Type* JavaArrayUInt16Type; + const llvm::Type* JavaArraySInt16Type; + const llvm::Type* JavaArrayUInt32Type; + const llvm::Type* JavaArraySInt32Type; + const llvm::Type* JavaArrayLongType; + const llvm::Type* JavaArrayFloatType; + const llvm::Type* JavaArrayDoubleType; + const llvm::Type* JavaArrayObjectType; + + const llvm::Type* VTType; + const llvm::Type* JavaObjectType; + const llvm::Type* JavaArrayType; + const llvm::Type* JavaCommonClassType; + const llvm::Type* JavaClassType; + const llvm::Type* JavaClassArrayType; + const llvm::Type* JavaClassPrimitiveType; + const llvm::Type* ConstantPoolType; + const llvm::Type* CodeLineInfoType; + const llvm::Type* UTF8Type; + const llvm::Type* JavaMethodType; + const llvm::Type* JavaFieldType; + const llvm::Type* AttributType; + const llvm::Type* JavaThreadType; + const llvm::Type* MutatorThreadType; #ifdef ISOLATE_SHARING - static const llvm::Type* JnjvmType; + const llvm::Type* JnjvmType; #endif llvm::Function* EmptyTracerFunction; Modified: vmkit/trunk/include/mvm/JIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/mvm/JIT.h?rev=96749&r1=96748&r2=96749&view=diff ============================================================================== --- vmkit/trunk/include/mvm/JIT.h (original) +++ vmkit/trunk/include/mvm/JIT.h Sun Feb 21 13:32:50 2010 @@ -122,56 +122,56 @@ llvm::Function* AllocateUnresolvedFunction; llvm::Function* AddFinalizationCandidate; - llvm::Constant* constantInt8Zero; - llvm::Constant* constantZero; - llvm::Constant* constantOne; - llvm::Constant* constantTwo; - llvm::Constant* constantThree; - llvm::Constant* constantFour; - llvm::Constant* constantFive; - llvm::Constant* constantSix; - llvm::Constant* constantSeven; - llvm::Constant* constantEight; - llvm::Constant* constantMinusOne; - llvm::Constant* constantLongMinusOne; - llvm::Constant* constantLongZero; - llvm::Constant* constantLongOne; - llvm::Constant* constantMinInt; - llvm::Constant* constantMaxInt; - llvm::Constant* constantMinLong; - llvm::Constant* constantMaxLong; - llvm::Constant* constantFloatZero; - llvm::Constant* constantFloatOne; - llvm::Constant* constantFloatTwo; - llvm::Constant* constantDoubleZero; - llvm::Constant* constantDoubleOne; - llvm::Constant* constantMaxIntFloat; - llvm::Constant* constantMinIntFloat; - llvm::Constant* constantMinLongFloat; - llvm::Constant* constantMinLongDouble; - llvm::Constant* constantMaxLongFloat; - llvm::Constant* constantMaxIntDouble; - llvm::Constant* constantMinIntDouble; - llvm::Constant* constantMaxLongDouble; - llvm::Constant* constantDoubleInfinity; - llvm::Constant* constantDoubleMinusInfinity; - llvm::Constant* constantFloatInfinity; - llvm::Constant* constantFloatMinusInfinity; - llvm::Constant* constantFloatMinusZero; - llvm::Constant* constantDoubleMinusZero; - llvm::Constant* constantPtrNull; - llvm::Constant* constantPtrLogSize; - llvm::Constant* constantThreadIDMask; - llvm::Constant* constantStackOverflowMask; - llvm::Constant* constantFatMask; - llvm::Constant* constantPtrOne; - llvm::Constant* constantPtrZero; + llvm::Constant* constantInt8Zero; + llvm::Constant* constantZero; + llvm::Constant* constantOne; + llvm::Constant* constantTwo; + llvm::Constant* constantThree; + llvm::Constant* constantFour; + llvm::Constant* constantFive; + llvm::Constant* constantSix; + llvm::Constant* constantSeven; + llvm::Constant* constantEight; + llvm::Constant* constantMinusOne; + llvm::Constant* constantLongMinusOne; + llvm::Constant* constantLongZero; + llvm::Constant* constantLongOne; + llvm::Constant* constantMinInt; + llvm::Constant* constantMaxInt; + llvm::Constant* constantMinLong; + llvm::Constant* constantMaxLong; + llvm::Constant* constantFloatZero; + llvm::Constant* constantFloatOne; + llvm::Constant* constantFloatTwo; + llvm::Constant* constantDoubleZero; + llvm::Constant* constantDoubleOne; + llvm::Constant* constantMaxIntFloat; + llvm::Constant* constantMinIntFloat; + llvm::Constant* constantMinLongFloat; + llvm::Constant* constantMinLongDouble; + llvm::Constant* constantMaxLongFloat; + llvm::Constant* constantMaxIntDouble; + llvm::Constant* constantMinIntDouble; + llvm::Constant* constantMaxLongDouble; + llvm::Constant* constantDoubleInfinity; + llvm::Constant* constantDoubleMinusInfinity; + llvm::Constant* constantFloatInfinity; + llvm::Constant* constantFloatMinusInfinity; + llvm::Constant* constantFloatMinusZero; + llvm::Constant* constantDoubleMinusZero; + llvm::Constant* constantPtrNull; + llvm::Constant* constantPtrLogSize; + llvm::Constant* constantThreadIDMask; + llvm::Constant* constantStackOverflowMask; + llvm::Constant* constantFatMask; + llvm::Constant* constantPtrOne; + llvm::Constant* constantPtrZero; - static const llvm::PointerType* ptrType; - static const llvm::PointerType* ptr32Type; - static const llvm::PointerType* ptrPtrType; - static const llvm::Type* arrayPtrType; - static const llvm::Type* pointerSizeType; + const llvm::PointerType* ptrType; + const llvm::PointerType* ptr32Type; + const llvm::PointerType* ptrPtrType; + const llvm::Type* arrayPtrType; + const llvm::Type* pointerSizeType; }; Modified: vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc?rev=96749&r1=96748&r2=96749&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc (original) +++ vmkit/trunk/lib/J3/Compiler/ExceptionsCheck.inc Sun Feb 21 13:32:50 2010 @@ -343,7 +343,7 @@ ex->tester = createBasicBlock("testException"); // PHI Node for the exception object - PHINode::Create(J3Intrinsics::JavaObjectType, "", ex->tester); + PHINode::Create(intrinsics->JavaObjectType, "", ex->tester); // Set the unwind destination of the instructions in the range of this // handler to the test block of the handler. If an instruction already has @@ -365,7 +365,7 @@ opcodeInfos[ex->handlerpc].handler = true; if (ex->javaHandler->empty()) { - PHINode::Create(J3Intrinsics::JavaObjectType, "", ex->javaHandler); + PHINode::Create(intrinsics->JavaObjectType, "", ex->javaHandler); } } Modified: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp?rev=96749&r1=96748&r2=96749&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp Sun Feb 21 13:32:50 2010 @@ -17,6 +17,7 @@ #include "JavaAccess.h" #include "JavaArray.h" #include "JavaClass.h" +#include "JavaTypes.h" #include "j3/J3Intrinsics.h" #include "j3/LLVMInfo.h" @@ -24,120 +25,85 @@ using namespace j3; using namespace llvm; -const llvm::Type* J3Intrinsics::JavaObjectType = 0; -const llvm::Type* J3Intrinsics::JavaArrayType = 0; -const llvm::Type* J3Intrinsics::JavaArrayUInt8Type = 0; -const llvm::Type* J3Intrinsics::JavaArraySInt8Type = 0; -const llvm::Type* J3Intrinsics::JavaArrayUInt16Type = 0; -const llvm::Type* J3Intrinsics::JavaArraySInt16Type = 0; -const llvm::Type* J3Intrinsics::JavaArrayUInt32Type = 0; -const llvm::Type* J3Intrinsics::JavaArraySInt32Type = 0; -const llvm::Type* J3Intrinsics::JavaArrayFloatType = 0; -const llvm::Type* J3Intrinsics::JavaArrayDoubleType = 0; -const llvm::Type* J3Intrinsics::JavaArrayLongType = 0; -const llvm::Type* J3Intrinsics::JavaArrayObjectType = 0; -const llvm::Type* J3Intrinsics::CodeLineInfoType = 0; -const llvm::Type* J3Intrinsics::ConstantPoolType = 0; -const llvm::Type* J3Intrinsics::UTF8Type = 0; -const llvm::Type* J3Intrinsics::JavaFieldType = 0; -const llvm::Type* J3Intrinsics::JavaMethodType = 0; -const llvm::Type* J3Intrinsics::AttributType = 0; -const llvm::Type* J3Intrinsics::JavaThreadType = 0; -const llvm::Type* J3Intrinsics::MutatorThreadType = 0; - -#ifdef ISOLATE_SHARING -const llvm::Type* J3Intrinsics::JnjvmType = 0; -#endif - -const llvm::Type* J3Intrinsics::JavaClassType; -const llvm::Type* J3Intrinsics::JavaClassPrimitiveType; -const llvm::Type* J3Intrinsics::JavaClassArrayType; -const llvm::Type* J3Intrinsics::JavaCommonClassType; -const llvm::Type* J3Intrinsics::VTType; - - namespace j3 { namespace llvm_runtime { #include "LLVMRuntime.inc" } } -void J3Intrinsics::initialise() { - Module* module = mvm::MvmModule::globalModule; +J3Intrinsics::J3Intrinsics(llvm::Module* module) : + BaseIntrinsics(module) { - if (!module->getTypeByName("JavaThread")) - j3::llvm_runtime::makeLLVMModuleContents(module); + llvm::Module* globalModule = mvm::MvmModule::globalModule; - VTType = PointerType::getUnqual(module->getTypeByName("VT")); + if (!globalModule->getTypeByName("JavaThread")) { + j3::llvm_runtime::makeLLVMModuleContents(globalModule); + mvm::MvmModule::copyDefinitions(module, mvm::MvmModule::globalModule); + } + + if (!(LLVMAssessorInfo::AssessorInfo[I_VOID].llvmType)) { + LLVMAssessorInfo::initialise(); + } + + VTType = PointerType::getUnqual(globalModule->getTypeByName("VT")); #ifdef ISOLATE_SHARING JnjvmType = - PointerType::getUnqual(module->getTypeByName("Jnjvm")); + PointerType::getUnqual(globalModule->getTypeByName("Jnjvm")); #endif ConstantPoolType = ptrPtrType; JavaObjectType = - PointerType::getUnqual(module->getTypeByName("JavaObject")); + PointerType::getUnqual(globalModule->getTypeByName("JavaObject")); JavaArrayType = - PointerType::getUnqual(module->getTypeByName("JavaArray")); + PointerType::getUnqual(globalModule->getTypeByName("JavaArray")); JavaCommonClassType = - PointerType::getUnqual(module->getTypeByName("JavaCommonClass")); + PointerType::getUnqual(globalModule->getTypeByName("JavaCommonClass")); JavaClassPrimitiveType = - PointerType::getUnqual(module->getTypeByName("JavaClassPrimitive")); + PointerType::getUnqual(globalModule->getTypeByName("JavaClassPrimitive")); JavaClassArrayType = - PointerType::getUnqual(module->getTypeByName("JavaClassArray")); + PointerType::getUnqual(globalModule->getTypeByName("JavaClassArray")); JavaClassType = - PointerType::getUnqual(module->getTypeByName("JavaClass")); + PointerType::getUnqual(globalModule->getTypeByName("JavaClass")); JavaArrayUInt8Type = - PointerType::getUnqual(module->getTypeByName("ArrayUInt8")); + PointerType::getUnqual(globalModule->getTypeByName("ArrayUInt8")); JavaArraySInt8Type = - PointerType::getUnqual(module->getTypeByName("ArraySInt8")); + PointerType::getUnqual(globalModule->getTypeByName("ArraySInt8")); JavaArrayUInt16Type = - PointerType::getUnqual(module->getTypeByName("ArrayUInt16")); + PointerType::getUnqual(globalModule->getTypeByName("ArrayUInt16")); JavaArraySInt16Type = - PointerType::getUnqual(module->getTypeByName("ArraySInt16")); + PointerType::getUnqual(globalModule->getTypeByName("ArraySInt16")); JavaArrayUInt32Type = - PointerType::getUnqual(module->getTypeByName("ArrayUInt32")); + PointerType::getUnqual(globalModule->getTypeByName("ArrayUInt32")); JavaArraySInt32Type = - PointerType::getUnqual(module->getTypeByName("ArraySInt32")); + PointerType::getUnqual(globalModule->getTypeByName("ArraySInt32")); JavaArrayLongType = - PointerType::getUnqual(module->getTypeByName("ArrayLong")); + PointerType::getUnqual(globalModule->getTypeByName("ArrayLong")); JavaArrayFloatType = - PointerType::getUnqual(module->getTypeByName("ArrayFloat")); + PointerType::getUnqual(globalModule->getTypeByName("ArrayFloat")); JavaArrayDoubleType = - PointerType::getUnqual(module->getTypeByName("ArrayDouble")); + PointerType::getUnqual(globalModule->getTypeByName("ArrayDouble")); JavaArrayObjectType = - PointerType::getUnqual(module->getTypeByName("ArrayObject")); + PointerType::getUnqual(globalModule->getTypeByName("ArrayObject")); JavaFieldType = - PointerType::getUnqual(module->getTypeByName("JavaField")); + PointerType::getUnqual(globalModule->getTypeByName("JavaField")); JavaMethodType = - PointerType::getUnqual(module->getTypeByName("JavaMethod")); + PointerType::getUnqual(globalModule->getTypeByName("JavaMethod")); UTF8Type = - PointerType::getUnqual(module->getTypeByName("UTF8")); + PointerType::getUnqual(globalModule->getTypeByName("UTF8")); AttributType = - PointerType::getUnqual(module->getTypeByName("Attribut")); + PointerType::getUnqual(globalModule->getTypeByName("Attribut")); JavaThreadType = - PointerType::getUnqual(module->getTypeByName("JavaThread")); + PointerType::getUnqual(globalModule->getTypeByName("JavaThread")); MutatorThreadType = - PointerType::getUnqual(module->getTypeByName("MutatorThread")); + PointerType::getUnqual(globalModule->getTypeByName("MutatorThread")); CodeLineInfoType = - PointerType::getUnqual(module->getTypeByName("CodeLineInfo")); - - LLVMAssessorInfo::initialise(); -} - -J3Intrinsics::J3Intrinsics(llvm::Module* module) : - BaseIntrinsics(module) { - - if (!VTType) { - initialise(); - mvm::MvmModule::copyDefinitions(module, mvm::MvmModule::globalModule); - } + PointerType::getUnqual(globalModule->getTypeByName("CodeLineInfo")); JavaObjectNullConstant = Constant::getNullValue(J3Intrinsics::JavaObjectType); @@ -193,122 +159,122 @@ ClassReadyConstant = ConstantInt::get(Type::getInt8Ty(getGlobalContext()), ready); - module->addTypeName("JavaObject", JavaObjectType->getContainedType(0)); - module->addTypeName("JavaArray", JavaArrayType->getContainedType(0)); - module->addTypeName("JavaCommonClass", + globalModule->addTypeName("JavaObject", JavaObjectType->getContainedType(0)); + globalModule->addTypeName("JavaArray", JavaArrayType->getContainedType(0)); + globalModule->addTypeName("JavaCommonClass", JavaCommonClassType->getContainedType(0)); - module->addTypeName("JavaClass", JavaClassType->getContainedType(0)); - module->addTypeName("JavaClassPrimitive", + globalModule->addTypeName("JavaClass", JavaClassType->getContainedType(0)); + globalModule->addTypeName("JavaClassPrimitive", JavaClassPrimitiveType->getContainedType(0)); - module->addTypeName("JavaClassArray", + globalModule->addTypeName("JavaClassArray", JavaClassArrayType->getContainedType(0)); - module->addTypeName("ArrayUInt8", JavaArrayUInt8Type->getContainedType(0)); - module->addTypeName("ArraySInt8", JavaArraySInt8Type->getContainedType(0)); - module->addTypeName("ArrayUInt16", JavaArrayUInt16Type->getContainedType(0)); - module->addTypeName("ArraySInt16", JavaArraySInt16Type->getContainedType(0)); - module->addTypeName("ArraySInt32", JavaArraySInt32Type->getContainedType(0)); - module->addTypeName("ArrayLong", JavaArrayLongType->getContainedType(0)); - module->addTypeName("ArrayFloat", JavaArrayFloatType->getContainedType(0)); - module->addTypeName("ArrayDouble", JavaArrayDoubleType->getContainedType(0)); - module->addTypeName("ArrayObject", JavaArrayObjectType->getContainedType(0)); + globalModule->addTypeName("ArrayUInt8", JavaArrayUInt8Type->getContainedType(0)); + globalModule->addTypeName("ArraySInt8", JavaArraySInt8Type->getContainedType(0)); + globalModule->addTypeName("ArrayUInt16", JavaArrayUInt16Type->getContainedType(0)); + globalModule->addTypeName("ArraySInt16", JavaArraySInt16Type->getContainedType(0)); + globalModule->addTypeName("ArraySInt32", JavaArraySInt32Type->getContainedType(0)); + globalModule->addTypeName("ArrayLong", JavaArrayLongType->getContainedType(0)); + globalModule->addTypeName("ArrayFloat", JavaArrayFloatType->getContainedType(0)); + globalModule->addTypeName("ArrayDouble", JavaArrayDoubleType->getContainedType(0)); + globalModule->addTypeName("ArrayObject", JavaArrayObjectType->getContainedType(0)); - InterfaceLookupFunction = module->getFunction("j3InterfaceLookup"); - MultiCallNewFunction = module->getFunction("j3MultiCallNew"); - ForceLoadedCheckFunction = module->getFunction("forceLoadedCheck"); - InitialisationCheckFunction = module->getFunction("initialisationCheck"); + InterfaceLookupFunction = globalModule->getFunction("j3InterfaceLookup"); + MultiCallNewFunction = globalModule->getFunction("j3MultiCallNew"); + ForceLoadedCheckFunction = globalModule->getFunction("forceLoadedCheck"); + InitialisationCheckFunction = globalModule->getFunction("initialisationCheck"); ForceInitialisationCheckFunction = - module->getFunction("forceInitialisationCheck"); - InitialiseClassFunction = module->getFunction("j3RuntimeInitialiseClass"); + globalModule->getFunction("forceInitialisationCheck"); + InitialiseClassFunction = globalModule->getFunction("j3RuntimeInitialiseClass"); - GetConstantPoolAtFunction = module->getFunction("getConstantPoolAt"); - ArrayLengthFunction = module->getFunction("arrayLength"); - GetVTFunction = module->getFunction("getVT"); - GetIMTFunction = module->getFunction("getIMT"); - GetClassFunction = module->getFunction("getClass"); - ClassLookupFunction = module->getFunction("j3ClassLookup"); - GetVTFromClassFunction = module->getFunction("getVTFromClass"); - GetVTFromClassArrayFunction = module->getFunction("getVTFromClassArray"); - GetVTFromCommonClassFunction = module->getFunction("getVTFromCommonClass"); - GetBaseClassVTFromVTFunction = module->getFunction("getBaseClassVTFromVT"); + GetConstantPoolAtFunction = globalModule->getFunction("getConstantPoolAt"); + ArrayLengthFunction = globalModule->getFunction("arrayLength"); + GetVTFunction = globalModule->getFunction("getVT"); + GetIMTFunction = globalModule->getFunction("getIMT"); + GetClassFunction = globalModule->getFunction("getClass"); + ClassLookupFunction = globalModule->getFunction("j3ClassLookup"); + GetVTFromClassFunction = globalModule->getFunction("getVTFromClass"); + GetVTFromClassArrayFunction = globalModule->getFunction("getVTFromClassArray"); + GetVTFromCommonClassFunction = globalModule->getFunction("getVTFromCommonClass"); + GetBaseClassVTFromVTFunction = globalModule->getFunction("getBaseClassVTFromVT"); GetObjectSizeFromClassFunction = - module->getFunction("getObjectSizeFromClass"); + globalModule->getFunction("getObjectSizeFromClass"); - GetClassDelegateeFunction = module->getFunction("getClassDelegatee"); - RuntimeDelegateeFunction = module->getFunction("j3RuntimeDelegatee"); - IsAssignableFromFunction = module->getFunction("isAssignableFrom"); - IsSecondaryClassFunction = module->getFunction("isSecondaryClass"); - GetDepthFunction = module->getFunction("getDepth"); - GetStaticInstanceFunction = module->getFunction("getStaticInstance"); - GetDisplayFunction = module->getFunction("getDisplay"); - GetVTInDisplayFunction = module->getFunction("getVTInDisplay"); - AquireObjectFunction = module->getFunction("j3JavaObjectAquire"); - ReleaseObjectFunction = module->getFunction("j3JavaObjectRelease"); - OverflowThinLockFunction = module->getFunction("j3OverflowThinLock"); - - VirtualFieldLookupFunction = module->getFunction("j3VirtualFieldLookup"); - StaticFieldLookupFunction = module->getFunction("j3StaticFieldLookup"); - StringLookupFunction = module->getFunction("j3StringLookup"); - StartJNIFunction = module->getFunction("j3StartJNI"); - EndJNIFunction = module->getFunction("j3EndJNI"); - - ResolveVirtualStubFunction = module->getFunction("j3ResolveVirtualStub"); - ResolveStaticStubFunction = module->getFunction("j3ResolveStaticStub"); - ResolveSpecialStubFunction = module->getFunction("j3ResolveSpecialStub"); + GetClassDelegateeFunction = globalModule->getFunction("getClassDelegatee"); + RuntimeDelegateeFunction = globalModule->getFunction("j3RuntimeDelegatee"); + IsAssignableFromFunction = globalModule->getFunction("isAssignableFrom"); + IsSecondaryClassFunction = globalModule->getFunction("isSecondaryClass"); + GetDepthFunction = globalModule->getFunction("getDepth"); + GetStaticInstanceFunction = globalModule->getFunction("getStaticInstance"); + GetDisplayFunction = globalModule->getFunction("getDisplay"); + GetVTInDisplayFunction = globalModule->getFunction("getVTInDisplay"); + AquireObjectFunction = globalModule->getFunction("j3JavaObjectAquire"); + ReleaseObjectFunction = globalModule->getFunction("j3JavaObjectRelease"); + OverflowThinLockFunction = globalModule->getFunction("j3OverflowThinLock"); + + VirtualFieldLookupFunction = globalModule->getFunction("j3VirtualFieldLookup"); + StaticFieldLookupFunction = globalModule->getFunction("j3StaticFieldLookup"); + StringLookupFunction = globalModule->getFunction("j3StringLookup"); + StartJNIFunction = globalModule->getFunction("j3StartJNI"); + EndJNIFunction = globalModule->getFunction("j3EndJNI"); + + ResolveVirtualStubFunction = globalModule->getFunction("j3ResolveVirtualStub"); + ResolveStaticStubFunction = globalModule->getFunction("j3ResolveStaticStub"); + ResolveSpecialStubFunction = globalModule->getFunction("j3ResolveSpecialStub"); NullPointerExceptionFunction = - module->getFunction("j3NullPointerException"); - ClassCastExceptionFunction = module->getFunction("j3ClassCastException"); + globalModule->getFunction("j3NullPointerException"); + ClassCastExceptionFunction = globalModule->getFunction("j3ClassCastException"); IndexOutOfBoundsExceptionFunction = - module->getFunction("j3IndexOutOfBoundsException"); + globalModule->getFunction("j3IndexOutOfBoundsException"); NegativeArraySizeExceptionFunction = - module->getFunction("j3NegativeArraySizeException"); - OutOfMemoryErrorFunction = module->getFunction("j3OutOfMemoryError"); - StackOverflowErrorFunction = module->getFunction("j3StackOverflowError"); - ArrayStoreExceptionFunction = module->getFunction("j3ArrayStoreException"); - ArithmeticExceptionFunction = module->getFunction("j3ArithmeticException"); - - PrintExecutionFunction = module->getFunction("j3PrintExecution"); - PrintMethodStartFunction = module->getFunction("j3PrintMethodStart"); - PrintMethodEndFunction = module->getFunction("j3PrintMethodEnd"); + globalModule->getFunction("j3NegativeArraySizeException"); + OutOfMemoryErrorFunction = globalModule->getFunction("j3OutOfMemoryError"); + StackOverflowErrorFunction = globalModule->getFunction("j3StackOverflowError"); + ArrayStoreExceptionFunction = globalModule->getFunction("j3ArrayStoreException"); + ArithmeticExceptionFunction = globalModule->getFunction("j3ArithmeticException"); + + PrintExecutionFunction = globalModule->getFunction("j3PrintExecution"); + PrintMethodStartFunction = globalModule->getFunction("j3PrintMethodStart"); + PrintMethodEndFunction = globalModule->getFunction("j3PrintMethodEnd"); - ThrowExceptionFunction = module->getFunction("j3ThrowException"); + ThrowExceptionFunction = globalModule->getFunction("j3ThrowException"); - GetArrayClassFunction = module->getFunction("j3GetArrayClass"); + GetArrayClassFunction = globalModule->getFunction("j3GetArrayClass"); - GetFinalInt8FieldFunction = module->getFunction("getFinalInt8Field"); - GetFinalInt16FieldFunction = module->getFunction("getFinalInt16Field"); - GetFinalInt32FieldFunction = module->getFunction("getFinalInt32Field"); - GetFinalLongFieldFunction = module->getFunction("getFinalLongField"); - GetFinalFloatFieldFunction = module->getFunction("getFinalFloatField"); - GetFinalDoubleFieldFunction = module->getFunction("getFinalDoubleField"); - GetFinalObjectFieldFunction = module->getFunction("getFinalObjectField"); + GetFinalInt8FieldFunction = globalModule->getFunction("getFinalInt8Field"); + GetFinalInt16FieldFunction = globalModule->getFunction("getFinalInt16Field"); + GetFinalInt32FieldFunction = globalModule->getFunction("getFinalInt32Field"); + GetFinalLongFieldFunction = globalModule->getFunction("getFinalLongField"); + GetFinalFloatFieldFunction = globalModule->getFunction("getFinalFloatField"); + GetFinalDoubleFieldFunction = globalModule->getFunction("getFinalDoubleField"); + GetFinalObjectFieldFunction = globalModule->getFunction("getFinalObjectField"); #ifdef ISOLATE_SHARING - GetCtpClassFunction = module->getFunction("getCtpClass"); + GetCtpClassFunction = globalModule->getFunction("getCtpClass"); GetJnjvmExceptionClassFunction = - module->getFunction("getJnjvmExceptionClass"); - GetJnjvmArrayClassFunction = module->getFunction("getJnjvmArrayClass"); - StaticCtpLookupFunction = module->getFunction("j3StaticCtpLookup"); - SpecialCtpLookupFunction = module->getFunction("j3SpecialCtpLookup"); + globalModule->getFunction("getJnjvmExceptionClass"); + GetJnjvmArrayClassFunction = globalModule->getFunction("getJnjvmArrayClass"); + StaticCtpLookupFunction = globalModule->getFunction("j3StaticCtpLookup"); + SpecialCtpLookupFunction = globalModule->getFunction("j3SpecialCtpLookup"); #endif #ifdef SERVICE - ServiceCallStartFunction = module->getFunction("j3ServiceCallStart"); - ServiceCallStopFunction = module->getFunction("j3ServiceCallStop"); + ServiceCallStartFunction = globalModule->getFunction("j3ServiceCallStart"); + ServiceCallStopFunction = globalModule->getFunction("j3ServiceCallStop"); #endif - JavaObjectTracerFunction = module->getFunction("JavaObjectTracer"); - EmptyTracerFunction = module->getFunction("EmptyTracer"); - JavaArrayTracerFunction = module->getFunction("JavaArrayTracer"); - ArrayObjectTracerFunction = module->getFunction("ArrayObjectTracer"); - RegularObjectTracerFunction = module->getFunction("RegularObjectTracer"); + JavaObjectTracerFunction = globalModule->getFunction("JavaObjectTracer"); + EmptyTracerFunction = globalModule->getFunction("EmptyTracer"); + JavaArrayTracerFunction = globalModule->getFunction("JavaArrayTracer"); + ArrayObjectTracerFunction = globalModule->getFunction("ArrayObjectTracer"); + RegularObjectTracerFunction = globalModule->getFunction("RegularObjectTracer"); #ifndef WITHOUT_VTABLE - VirtualLookupFunction = module->getFunction("j3VirtualTableLookup"); + VirtualLookupFunction = globalModule->getFunction("j3VirtualTableLookup"); #endif - GetLockFunction = module->getFunction("getLock"); + GetLockFunction = globalModule->getFunction("getLock"); ThrowExceptionFromJITFunction = - module->getFunction("j3ThrowExceptionFromJIT"); + globalModule->getFunction("j3ThrowExceptionFromJIT"); } Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=96749&r1=96748&r2=96749&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sun Feb 21 13:32:50 2010 @@ -60,11 +60,11 @@ const llvm::Type* Ty = 0; if (classDef->isArray()) { - Ty = J3Intrinsics::JavaClassArrayType->getContainedType(0); + Ty = JavaIntrinsics.JavaClassArrayType->getContainedType(0); } else if (classDef->isPrimitive()) { - Ty = J3Intrinsics::JavaClassPrimitiveType->getContainedType(0); + Ty = JavaIntrinsics.JavaClassPrimitiveType->getContainedType(0); } else { - Ty = J3Intrinsics::JavaClassType->getContainedType(0); + Ty = JavaIntrinsics.JavaClassType->getContainedType(0); } GlobalVariable* varGV = @@ -95,7 +95,7 @@ array_class_iterator End = arrayClasses.end(); array_class_iterator I = arrayClasses.find(classDef->asArrayClass()); if (I == End) { - const llvm::Type* Ty = J3Intrinsics::JavaClassArrayType; + const llvm::Type* Ty = JavaIntrinsics.JavaClassArrayType; Module& Mod = *getLLVMModule(); GlobalVariable* varGV = @@ -119,7 +119,7 @@ constant_pool_iterator End = constantPools.end(); constant_pool_iterator I = constantPools.find(ctp); if (I == End) { - const Type* Ty = J3Intrinsics::ConstantPoolType->getContainedType(0); + const Type* Ty = JavaIntrinsics.ConstantPoolType->getContainedType(0); Module& Mod = *getLLVMModule(); varGV = new GlobalVariable(Mod, Ty, false, @@ -154,7 +154,7 @@ name += "_VirtualMethods"; Module& Mod = *getLLVMModule(); const Type* ATy = - ArrayType::get(J3Intrinsics::JavaMethodType->getContainedType(0), + ArrayType::get(JavaIntrinsics.JavaMethodType->getContainedType(0), cl->nbVirtualMethods + cl->nbStaticMethods); Array = new GlobalVariable(Mod, ATy, false, GlobalValue::ExternalLinkage, @@ -180,7 +180,7 @@ new GlobalVariable(Mod, Ty->getContainedType(0), false, GlobalValue::InternalLinkage, 0, ""); Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV, - J3Intrinsics::JavaObjectType); + JavaIntrinsics.JavaObjectType); strings.insert(std::make_pair(str, res)); Constant* C = CreateConstantFromJavaString(str); varGV->setInitializer(C); @@ -211,7 +211,7 @@ GlobalValue::InternalLinkage, 0, ""); Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV, - J3Intrinsics::JavaObjectType); + JavaIntrinsics.JavaObjectType); javaClasses.insert(std::make_pair(cl, res)); varGV->setInitializer(CreateConstantFromJavaClass(cl)); @@ -233,7 +233,7 @@ getJavaClass(cl); Constant* Cl = getNativeClass(cl); - Cl = ConstantExpr::getBitCast(Cl, J3Intrinsics::JavaCommonClassType); + Cl = ConstantExpr::getBitCast(Cl, JavaIntrinsics.JavaCommonClassType); Constant* GEP[2] = { getIntrinsics()->constantZero, getIntrinsics()->constantZero }; @@ -274,14 +274,14 @@ intptr_t* realObj = (intptr_t*)obj; intptr_t size = realObj[0]; - const ArrayType* ATy = ArrayType::get(J3Intrinsics::JavaObjectType, + const ArrayType* ATy = ArrayType::get(JavaIntrinsics.JavaObjectType, size + 1); std::vector Vals; for (sint32 i = 0; i < size + 1; ++i) { Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(realObj[i])); - CI = ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType); + CI = ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaObjectType); Vals.push_back(CI); } @@ -292,12 +292,12 @@ GlobalValue::InternalLinkage, CA, ""); - return ConstantExpr::getBitCast(varGV, J3Intrinsics::JavaObjectType); + return ConstantExpr::getBitCast(varGV, JavaIntrinsics.JavaObjectType); } else { Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(obj)); - CI = ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType); + CI = ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaObjectType); return CI; } } @@ -337,13 +337,13 @@ abort(); } } else { - Ty = J3Intrinsics::JavaObjectType; + Ty = JavaIntrinsics.JavaObjectType; } std::vector Elemts; const ArrayType* ATy = ArrayType::get(Ty, ((JavaArray*)obj)->size); - Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0)); - Elemts.push_back(J3Intrinsics::pointerSizeType); + Elemts.push_back(JavaIntrinsics.JavaObjectType->getContainedType(0)); + Elemts.push_back(JavaIntrinsics.pointerSizeType); Elemts.push_back(ATy); Ty = StructType::get(getLLVMModule()->getContext(), Elemts); @@ -357,7 +357,7 @@ 0, ""); Constant* C = ConstantExpr::getBitCast(varGV, - J3Intrinsics::JavaObjectType); + JavaIntrinsics.JavaObjectType); finalObjects.insert(std::make_pair(obj, C)); reverseFinalObjects.insert(std::make_pair(C, obj)); @@ -459,7 +459,7 @@ const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[idx]); JavaString* obj = ctpInfo->resolveString(utf8, idx); Constant* C = getString(obj); - C = ConstantExpr::getBitCast(C, J3Intrinsics::JavaObjectType); + C = ConstantExpr::getBitCast(C, JavaIntrinsics.JavaObjectType); Elts.push_back(C); } else { fprintf(stderr, "Implement me"); @@ -491,7 +491,7 @@ 0, name); Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV, - J3Intrinsics::ptrType); + JavaIntrinsics.ptrType); staticInstances.insert(std::make_pair(classDef, res)); if (isCompiling(classDef)) { @@ -521,7 +521,7 @@ if (I == End) { const ArrayType* ATy = - dyn_cast(J3Intrinsics::VTType->getContainedType(0)); + dyn_cast(JavaIntrinsics.VTType->getContainedType(0)); const PointerType* PTy = dyn_cast(ATy->getContainedType(0)); ATy = ArrayType::get(PTy, size); std::string name(UTF8Buffer(classDef->name).toCompileName()->cString()); @@ -534,7 +534,7 @@ 0, name); res = ConstantExpr::getCast(Instruction::BitCast, varGV, - J3Intrinsics::VTType); + JavaIntrinsics.VTType); virtualTables.insert(std::make_pair(VT, res)); if (isCompiling(classDef) || assumeCompiled) { @@ -571,7 +571,7 @@ Constant* JavaAOTCompiler::CreateConstantForBaseObject(CommonClass* cl) { const StructType* STy = - dyn_cast(J3Intrinsics::JavaObjectType->getContainedType(0)); + dyn_cast(JavaIntrinsics.JavaObjectType->getContainedType(0)); std::vector Elmts; @@ -580,7 +580,7 @@ // lock Constant* L = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), 0); - Elmts.push_back(ConstantExpr::getIntToPtr(L, J3Intrinsics::ptrType)); + Elmts.push_back(ConstantExpr::getIntToPtr(L, JavaIntrinsics.ptrType)); return ConstantStruct::get(STy, Elmts); } @@ -597,19 +597,19 @@ Elmts.push_back(CreateConstantForBaseObject(javaClass)); // signers - Elmts.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType)); + Elmts.push_back(Constant::getNullValue(JavaIntrinsics.JavaObjectType)); // pd - Elmts.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType)); + Elmts.push_back(Constant::getNullValue(JavaIntrinsics.JavaObjectType)); // vmdata Constant* Cl = getNativeClass(cl); Cl = ConstantExpr::getCast(Instruction::BitCast, Cl, - J3Intrinsics::JavaObjectType); + JavaIntrinsics.JavaObjectType); Elmts.push_back(Cl); // constructor - Elmts.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType)); + Elmts.push_back(Constant::getNullValue(JavaIntrinsics.JavaObjectType)); return ConstantStruct::get(STy, Elmts); } @@ -707,7 +707,7 @@ Constant* C = getFinalObject(val, FieldCl); TempElts.push_back(C); } else { - const llvm::Type* Ty = J3Intrinsics::JavaObjectType; + const llvm::Type* Ty = JavaIntrinsics.JavaObjectType; TempElts.push_back(Constant::getNullValue(Ty)); } } @@ -738,7 +738,7 @@ GlobalValue::InternalLinkage, Array, ""); - Array = ConstantExpr::getBitCast(varGV, J3Intrinsics::JavaObjectType); + Array = ConstantExpr::getBitCast(varGV, JavaIntrinsics.JavaObjectType); Elmts.push_back(Array); Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), @@ -754,7 +754,7 @@ Constant* JavaAOTCompiler::CreateConstantFromAttribut(Attribut& attribut) { const StructType* STy = - dyn_cast(J3Intrinsics::AttributType->getContainedType(0)); + dyn_cast(JavaIntrinsics.AttributType->getContainedType(0)); std::vector Elmts; @@ -773,7 +773,7 @@ Constant* JavaAOTCompiler::CreateConstantFromCommonClass(CommonClass* cl) { const StructType* STy = - dyn_cast(J3Intrinsics::JavaCommonClassType->getContainedType(0)); + dyn_cast(JavaIntrinsics.JavaCommonClassType->getContainedType(0)); Module& Mod = *getLLVMModule(); const llvm::Type* TempTy = 0; @@ -797,17 +797,17 @@ TempElmts.push_back(getNativeClass(cl->interfaces[i])); } - ATy = ArrayType::get(J3Intrinsics::JavaClassType, cl->nbInterfaces); + ATy = ArrayType::get(JavaIntrinsics.JavaClassType, cl->nbInterfaces); Constant* interfaces = ConstantArray::get(ATy, TempElmts); interfaces = new GlobalVariable(Mod, ATy, true, GlobalValue::InternalLinkage, interfaces, ""); interfaces = ConstantExpr::getCast(Instruction::BitCast, interfaces, - PointerType::getUnqual(J3Intrinsics::JavaClassType)); + PointerType::getUnqual(JavaIntrinsics.JavaClassType)); CommonClassElts.push_back(interfaces); } else { - const Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaClassType); + const Type* Ty = PointerType::getUnqual(JavaIntrinsics.JavaClassType); CommonClassElts.push_back(Constant::getNullValue(Ty)); } @@ -821,21 +821,21 @@ if (cl->super) { CommonClassElts.push_back(getNativeClass(cl->super)); } else { - TempTy = J3Intrinsics::JavaClassType; + TempTy = JavaIntrinsics.JavaClassType; CommonClassElts.push_back(Constant::getNullValue(TempTy)); } // classLoader: store the static initializer, it will be overriden once // the class is loaded. Constant* loader = ConstantExpr::getBitCast(StaticInitializer, - J3Intrinsics::ptrType); + JavaIntrinsics.ptrType); CommonClassElts.push_back(loader); // virtualTable if (cl->virtualVT) { CommonClassElts.push_back(getVirtualTable(cl->virtualVT)); } else { - TempTy = J3Intrinsics::VTType; + TempTy = JavaIntrinsics.VTType; CommonClassElts.push_back(Constant::getNullValue(TempTy)); } return ConstantStruct::get(STy, CommonClassElts); @@ -843,13 +843,13 @@ Constant* JavaAOTCompiler::CreateConstantFromJavaField(JavaField& field) { const StructType* STy = - dyn_cast(J3Intrinsics::JavaFieldType->getContainedType(0)); + dyn_cast(JavaIntrinsics.JavaFieldType->getContainedType(0)); std::vector FieldElts; std::vector TempElts; // signature - FieldElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); + FieldElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); // access FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.access)); @@ -862,7 +862,7 @@ // attributs if (field.nbAttributs) { - const llvm::Type* AttrTy = J3Intrinsics::AttributType->getContainedType(0); + const llvm::Type* AttrTy = JavaIntrinsics.AttributType->getContainedType(0); const ArrayType* ATy = ArrayType::get(AttrTy, field.nbAttributs); for (uint32 i = 0; i < field.nbAttributs; ++i) { TempElts.push_back(CreateConstantFromAttribut(field.attributs[i])); @@ -874,11 +874,11 @@ GlobalValue::InternalLinkage, attributs, ""); attributs = ConstantExpr::getCast(Instruction::BitCast, attributs, - J3Intrinsics::AttributType); + JavaIntrinsics.AttributType); FieldElts.push_back(attributs); } else { - FieldElts.push_back(Constant::getNullValue(J3Intrinsics::AttributType)); + FieldElts.push_back(Constant::getNullValue(JavaIntrinsics.AttributType)); } // nbAttributs @@ -894,28 +894,28 @@ FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.num)); //JInfo - FieldElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); + FieldElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); return ConstantStruct::get(STy, FieldElts); } Constant* JavaAOTCompiler::CreateConstantFromJavaMethod(JavaMethod& method) { const StructType* STy = - dyn_cast(J3Intrinsics::JavaMethodType->getContainedType(0)); + dyn_cast(JavaIntrinsics.JavaMethodType->getContainedType(0)); Module& Mod = *getLLVMModule(); std::vector MethodElts; std::vector TempElts; // signature - MethodElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); + MethodElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); // access MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), method.access)); // attributs if (method.nbAttributs) { - const llvm::Type* AttrTy = J3Intrinsics::AttributType->getContainedType(0); + const llvm::Type* AttrTy = JavaIntrinsics.AttributType->getContainedType(0); const ArrayType* ATy = ArrayType::get(AttrTy, method.nbAttributs); for (uint32 i = 0; i < method.nbAttributs; ++i) { TempElts.push_back(CreateConstantFromAttribut(method.attributs[i])); @@ -927,11 +927,11 @@ GlobalValue::InternalLinkage, attributs, ""); attributs = ConstantExpr::getCast(Instruction::BitCast, attributs, - J3Intrinsics::AttributType); + JavaIntrinsics.AttributType); MethodElts.push_back(attributs); } else { - MethodElts.push_back(Constant::getNullValue(J3Intrinsics::AttributType)); + MethodElts.push_back(Constant::getNullValue(JavaIntrinsics.AttributType)); } // nbAttributs @@ -951,16 +951,16 @@ // code if (isAbstract(method.access)) { - MethodElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); + MethodElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); } else { LLVMMethodInfo* LMI = getMethodInfo(&method); Function* func = LMI->getMethod(); MethodElts.push_back(ConstantExpr::getCast(Instruction::BitCast, func, - J3Intrinsics::ptrType)); + JavaIntrinsics.ptrType)); } // codeInfo - MethodElts.push_back(Constant::getNullValue(J3Intrinsics::CodeLineInfoType)); + MethodElts.push_back(Constant::getNullValue(JavaIntrinsics.CodeLineInfoType)); // codeInfoLength MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), 0)); @@ -969,14 +969,14 @@ MethodElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), method.offset)); // JInfo - MethodElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); + MethodElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); return ConstantStruct::get(STy, MethodElts); } Constant* JavaAOTCompiler::CreateConstantFromClassPrimitive(ClassPrimitive* cl) { const llvm::Type* JCPTy = - J3Intrinsics::JavaClassPrimitiveType->getContainedType(0); + JavaIntrinsics.JavaClassPrimitiveType->getContainedType(0); const StructType* STy = dyn_cast(JCPTy); std::vector ClassElts; @@ -992,7 +992,7 @@ Constant* JavaAOTCompiler::CreateConstantFromClassArray(ClassArray* cl) { const StructType* STy = - dyn_cast(J3Intrinsics::JavaClassArrayType->getContainedType(0)); + dyn_cast(JavaIntrinsics.JavaClassArrayType->getContainedType(0)); std::vector ClassElts; Constant* ClGEPs[2] = { getIntrinsics()->constantZero, @@ -1003,7 +1003,7 @@ // baseClass Constant* Cl = getNativeClass(cl->baseClass()); - if (Cl->getType() != J3Intrinsics::JavaCommonClassType) + if (Cl->getType() != JavaIntrinsics.JavaCommonClassType) Cl = ConstantExpr::getGetElementPtr(Cl, ClGEPs, 2); ClassElts.push_back(Cl); @@ -1013,7 +1013,7 @@ Constant* JavaAOTCompiler::CreateConstantFromClass(Class* cl) { const StructType* STy = - dyn_cast(J3Intrinsics::JavaClassType->getContainedType(0)); + dyn_cast(JavaIntrinsics.JavaClassType->getContainedType(0)); Module& Mod = *getLLVMModule(); std::vector ClassElts; @@ -1048,10 +1048,10 @@ ClassElts.push_back(ConstantArray::get(ATy, CStr, 1)); // thinlock - ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); + ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); if (cl->nbVirtualFields + cl->nbStaticFields) { - ATy = ArrayType::get(J3Intrinsics::JavaFieldType->getContainedType(0), + ATy = ArrayType::get(JavaIntrinsics.JavaFieldType->getContainedType(0), cl->nbVirtualFields + cl->nbStaticFields); } @@ -1082,9 +1082,9 @@ GlobalValue::InternalLinkage, fields, ""); fields = ConstantExpr::getCast(Instruction::BitCast, fields, - J3Intrinsics::JavaFieldType); + JavaIntrinsics.JavaFieldType); } else { - fields = Constant::getNullValue(J3Intrinsics::JavaFieldType); + fields = Constant::getNullValue(JavaIntrinsics.JavaFieldType); } // virtualFields @@ -1098,14 +1098,14 @@ // 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(Constant::getNullValue(J3Intrinsics::JavaFieldType)); + ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.JavaFieldType)); // nbStaticFields ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticFields)); // virtualMethods if (cl->nbVirtualMethods + cl->nbStaticMethods) { - ATy = ArrayType::get(J3Intrinsics::JavaMethodType->getContainedType(0), + ATy = ArrayType::get(JavaIntrinsics.JavaMethodType->getContainedType(0), cl->nbVirtualMethods + cl->nbStaticMethods); } @@ -1132,9 +1132,9 @@ methods, name); virtualMethods.insert(std::make_pair(cl, GV)); methods = ConstantExpr::getCast(Instruction::BitCast, GV, - J3Intrinsics::JavaMethodType); + JavaIntrinsics.JavaMethodType); } else { - methods = Constant::getNullValue(J3Intrinsics::JavaMethodType); + methods = Constant::getNullValue(JavaIntrinsics.JavaMethodType); } // virtualMethods @@ -1147,23 +1147,23 @@ // staticMethods // Output null, getLLVMModule() will be set in the initializer. - ClassElts.push_back(Constant::getNullValue(J3Intrinsics::JavaMethodType)); + ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.JavaMethodType)); // nbStaticMethods ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticMethods)); // ownerClass - ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); + ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); // bytes - ClassElts.push_back(Constant::getNullValue(J3Intrinsics::JavaArrayUInt8Type)); + ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.JavaArrayUInt8Type)); // ctpInfo - ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); + ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); // attributs if (cl->nbAttributs) { - ATy = ArrayType::get(J3Intrinsics::AttributType->getContainedType(0), + ATy = ArrayType::get(JavaIntrinsics.AttributType->getContainedType(0), cl->nbAttributs); for (uint32 i = 0; i < cl->nbAttributs; ++i) { @@ -1176,10 +1176,10 @@ GlobalValue::InternalLinkage, attributs, ""); attributs = ConstantExpr::getCast(Instruction::BitCast, attributs, - J3Intrinsics::AttributType); + JavaIntrinsics.AttributType); ClassElts.push_back(attributs); } else { - ClassElts.push_back(Constant::getNullValue(J3Intrinsics::AttributType)); + ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.AttributType)); } // nbAttributs @@ -1191,7 +1191,7 @@ TempElts.push_back(getNativeClass(cl->innerClasses[i])); } - const llvm::Type* TempTy = J3Intrinsics::JavaClassType; + const llvm::Type* TempTy = JavaIntrinsics.JavaClassType; ATy = ArrayType::get(TempTy, cl->nbInnerClasses); Constant* innerClasses = ConstantArray::get(ATy, TempElts); innerClasses = new GlobalVariable(*getLLVMModule(), ATy, true, @@ -1202,7 +1202,7 @@ ClassElts.push_back(innerClasses); } else { - const Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaClassType); + const Type* Ty = PointerType::getUnqual(JavaIntrinsics.JavaClassType); ClassElts.push_back(Constant::getNullValue(Ty)); } @@ -1213,7 +1213,7 @@ if (cl->outerClass) { ClassElts.push_back(getNativeClass(cl->outerClass)); } else { - ClassElts.push_back(Constant::getNullValue(J3Intrinsics::JavaClassType)); + ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.JavaClassType)); } // innerAccess @@ -1232,7 +1232,7 @@ ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->staticSize)); // JInfo - ClassElts.push_back(Constant::getNullValue(J3Intrinsics::ptrType)); + ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); return ConstantStruct::get(STy, ClassElts); } @@ -1241,8 +1241,8 @@ Constant* JavaAOTCompiler::CreateConstantFromIntArray(const T* val, const Type* Ty) { std::vector Elemts; const ArrayType* ATy = ArrayType::get(Ty, val->size); - Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0)); - Elemts.push_back(J3Intrinsics::pointerSizeType); + Elemts.push_back(JavaIntrinsics.JavaObjectType->getContainedType(0)); + Elemts.push_back(JavaIntrinsics.pointerSizeType); Elemts.push_back(ATy); @@ -1251,7 +1251,7 @@ std::vector Cts; Cts.push_back(CreateConstantForBaseObject(val->getClass())); - Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size)); + Cts.push_back(ConstantInt::get(JavaIntrinsics.pointerSizeType, val->size)); std::vector Vals; for (sint32 i = 0; i < val->size; ++i) { @@ -1267,8 +1267,8 @@ Constant* JavaAOTCompiler::CreateConstantFromFPArray(const T* val, const Type* Ty) { std::vector Elemts; const ArrayType* ATy = ArrayType::get(Ty, val->size); - Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0)); - Elemts.push_back(J3Intrinsics::pointerSizeType); + Elemts.push_back(JavaIntrinsics.JavaObjectType->getContainedType(0)); + Elemts.push_back(JavaIntrinsics.pointerSizeType); Elemts.push_back(ATy); @@ -1277,7 +1277,7 @@ std::vector Cts; Cts.push_back(CreateConstantForBaseObject(val->getClass())); - Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size)); + Cts.push_back(ConstantInt::get(JavaIntrinsics.pointerSizeType, val->size)); std::vector Vals; for (sint32 i = 0; i < val->size; ++i) { @@ -1291,10 +1291,10 @@ Constant* JavaAOTCompiler::CreateConstantFromObjectArray(const ArrayObject* val) { std::vector Elemts; - const llvm::Type* Ty = J3Intrinsics::JavaObjectType; + const llvm::Type* Ty = JavaIntrinsics.JavaObjectType; const ArrayType* ATy = ArrayType::get(Ty, val->size); - Elemts.push_back(J3Intrinsics::JavaObjectType->getContainedType(0)); - Elemts.push_back(J3Intrinsics::pointerSizeType); + Elemts.push_back(JavaIntrinsics.JavaObjectType->getContainedType(0)); + Elemts.push_back(JavaIntrinsics.pointerSizeType); Elemts.push_back(ATy); @@ -1303,7 +1303,7 @@ std::vector Cts; Cts.push_back(CreateConstantForBaseObject(val->getClass())); - Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size)); + Cts.push_back(ConstantInt::get(JavaIntrinsics.pointerSizeType, val->size)); std::vector Vals; for (sint32 i = 0; i < val->size; ++i) { @@ -1311,7 +1311,7 @@ Vals.push_back(getFinalObject(val->elements[i], val->getClass()->asArrayClass()->baseClass())); } else { - Vals.push_back(Constant::getNullValue(J3Intrinsics::JavaObjectType)); + Vals.push_back(Constant::getNullValue(JavaIntrinsics.JavaObjectType)); } } @@ -1323,7 +1323,7 @@ Constant* JavaAOTCompiler::CreateConstantFromUTF8(const UTF8* val) { std::vector Elemts; const ArrayType* ATy = ArrayType::get(Type::getInt16Ty(getGlobalContext()), val->size); - Elemts.push_back(J3Intrinsics::pointerSizeType); + Elemts.push_back(JavaIntrinsics.pointerSizeType); Elemts.push_back(ATy); @@ -1331,7 +1331,7 @@ Elemts); std::vector Cts; - Cts.push_back(ConstantInt::get(J3Intrinsics::pointerSizeType, val->size)); + Cts.push_back(ConstantInt::get(JavaIntrinsics.pointerSizeType, val->size)); std::vector Vals; for (sint32 i = 0; i < val->size; ++i) { @@ -1355,7 +1355,7 @@ C, ""); Constant* res = ConstantExpr::getCast(Instruction::BitCast, varGV, - J3Intrinsics::UTF8Type); + JavaIntrinsics.UTF8Type); utf8s.insert(std::make_pair(val, res)); return res; @@ -1372,7 +1372,7 @@ VT : ClassArray::SuperArray->virtualVT; const ArrayType* ATy = - dyn_cast(J3Intrinsics::VTType->getContainedType(0)); + dyn_cast(JavaIntrinsics.VTType->getContainedType(0)); const PointerType* PTy = dyn_cast(ATy->getContainedType(0)); ATy = ArrayType::get(PTy, size); @@ -1439,7 +1439,7 @@ ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->nbSecondaryTypes), PTy)); // secondaryTypes - const ArrayType* DTy = ArrayType::get(J3Intrinsics::VTType, + const ArrayType* DTy = ArrayType::get(JavaIntrinsics.VTType, VT->nbSecondaryTypes); std::vector TempElmts; @@ -1479,7 +1479,7 @@ const ArrayType* ATy = - dyn_cast(J3Intrinsics::VTType->getContainedType(0)); + dyn_cast(JavaIntrinsics.VTType->getContainedType(0)); const PointerType* PTy = dyn_cast(ATy->getContainedType(0)); ATy = ArrayType::get(PTy, InterfaceMethodTable::NumIndexes); @@ -1525,7 +1525,7 @@ uint32_t length = 2 * size; const ArrayType* ATy = - dyn_cast(J3Intrinsics::VTType->getContainedType(0)); + dyn_cast(JavaIntrinsics.VTType->getContainedType(0)); ATy = ArrayType::get(PTy, length); std::vector InternalElemts; @@ -1600,7 +1600,7 @@ compileRT = false; std::vector llvmArgs; - llvmArgs.push_back(J3Intrinsics::ptrType); // class loader. + llvmArgs.push_back(JavaIntrinsics.ptrType); // class loader. const FunctionType* FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); StaticInitializer = Function::Create(FTy, GlobalValue::InternalLinkage, @@ -1612,9 +1612,9 @@ "staticCallback", getLLVMModule()); llvmArgs.clear(); - llvmArgs.push_back(J3Intrinsics::JavaMethodType); + llvmArgs.push_back(JavaIntrinsics.JavaMethodType); - FTy = FunctionType::get(J3Intrinsics::ptrType, llvmArgs, false); + FTy = FunctionType::get(JavaIntrinsics.ptrType, llvmArgs, false); NativeLoader = Function::Create(FTy, GlobalValue::ExternalLinkage, "vmjcNativeLoader", getLLVMModule()); @@ -1691,8 +1691,8 @@ void JavaAOTCompiler::CreateStaticInitializer() { std::vector llvmArgs; - llvmArgs.push_back(J3Intrinsics::ptrType); // class loader - llvmArgs.push_back(J3Intrinsics::JavaCommonClassType); // cl + llvmArgs.push_back(JavaIntrinsics.ptrType); // class loader + llvmArgs.push_back(JavaIntrinsics.JavaCommonClassType); // cl const FunctionType* FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); @@ -1702,11 +1702,11 @@ llvmArgs.clear(); // class loader - llvmArgs.push_back(J3Intrinsics::ptrType); + llvmArgs.push_back(JavaIntrinsics.ptrType); // array ptr - llvmArgs.push_back(PointerType::getUnqual(J3Intrinsics::JavaClassArrayType)); + llvmArgs.push_back(PointerType::getUnqual(JavaIntrinsics.JavaClassArrayType)); // name - llvmArgs.push_back(J3Intrinsics::UTF8Type); + llvmArgs.push_back(JavaIntrinsics.UTF8Type); FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); Function* GetClassArray = Function::Create(FTy, GlobalValue::ExternalLinkage, @@ -1720,7 +1720,7 @@ // If we have defined some strings. if (strings.begin() != strings.end()) { llvmArgs.clear(); - llvmArgs.push_back(J3Intrinsics::ptrType); // class loader + llvmArgs.push_back(JavaIntrinsics.ptrType); // class loader llvmArgs.push_back(strings.begin()->second->getType()); // val FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); @@ -1741,7 +1741,7 @@ // If we have defined some UTF8s. if (utf8s.begin() != utf8s.end()) { llvmArgs.clear(); - llvmArgs.push_back(J3Intrinsics::ptrType); // class loader + llvmArgs.push_back(JavaIntrinsics.ptrType); // class loader llvmArgs.push_back(utf8s.begin()->second->getType()); // val FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); @@ -1763,7 +1763,7 @@ if (isCompiling(i->first)) { Args[0] = loader; Args[1] = ConstantExpr::getBitCast(i->second, - J3Intrinsics::JavaCommonClassType); + JavaIntrinsics.JavaCommonClassType); CallInst::Create(AddClass, Args, Args + 2, "", currentBlock); } } Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96749&r1=96748&r2=96749&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sun Feb 21 13:32:50 2010 @@ -127,8 +127,8 @@ static JavaJITListener* JITListener = 0; Constant* JavaJITCompiler::getNativeClass(CommonClass* classDef) { - const llvm::Type* Ty = classDef->isClass() ? J3Intrinsics::JavaClassType : - J3Intrinsics::JavaCommonClassType; + const llvm::Type* Ty = classDef->isClass() ? JavaIntrinsics.JavaClassType : + JavaIntrinsics.JavaCommonClassType; ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(classDef)); @@ -140,25 +140,25 @@ assert(ptr && "No constant pool found"); ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(ptr)); - return ConstantExpr::getIntToPtr(CI, J3Intrinsics::ConstantPoolType); + return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.ConstantPoolType); } Constant* JavaJITCompiler::getMethodInClass(JavaMethod* meth) { ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), (int64_t)meth); - return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaMethodType); + return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaMethodType); } Constant* JavaJITCompiler::getString(JavaString* str) { assert(str && "No string given"); ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64(str)); - return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType); + return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaObjectType); } Constant* JavaJITCompiler::getStringPtr(JavaString** str) { assert(str && "No string given"); - const llvm::Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaObjectType); + const llvm::Type* Ty = PointerType::getUnqual(JavaIntrinsics.JavaObjectType); ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64(str)); return ConstantExpr::getIntToPtr(CI, Ty); @@ -169,7 +169,7 @@ assert(obj && "Delegatee not created"); Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64(obj)); - return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType); + return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaObjectType); } Constant* JavaJITCompiler::getJavaClassPtr(CommonClass* cl) { @@ -178,7 +178,7 @@ assert(obj && "Delegatee not created"); Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64(obj)); - const Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaObjectType); + const Type* Ty = PointerType::getUnqual(JavaIntrinsics.JavaObjectType); return ConstantExpr::getIntToPtr(CI, Ty); } @@ -194,7 +194,7 @@ Constant* JavaJITCompiler::getFinalObject(JavaObject* obj, CommonClass* cl) { Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64(obj)); - return ConstantExpr::getIntToPtr(CI, J3Intrinsics::JavaObjectType); + return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaObjectType); } Constant* JavaJITCompiler::getStaticInstance(Class* classDef) { @@ -214,7 +214,7 @@ } Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), (uint64_t(obj))); - return ConstantExpr::getIntToPtr(CI, J3Intrinsics::ptrType); + return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.ptrType); } Constant* JavaJITCompiler::getVirtualTable(JavaVirtualTable* VT) { @@ -225,7 +225,7 @@ ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(VT)); - return ConstantExpr::getIntToPtr(CI, J3Intrinsics::VTType); + return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.VTType); } Constant* JavaJITCompiler::getNativeFunction(JavaMethod* meth, void* ptr) { @@ -264,7 +264,7 @@ Value* JavaJITCompiler::getIsolate(Jnjvm* isolate, Value* Where) { ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t(isolate)); - return ConstantExpr::getIntToPtr(CI, J3Intrinsics::ptrType); + return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.ptrType); } #endif Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=96749&r1=96748&r2=96749&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Sun Feb 21 13:32:50 2010 @@ -65,7 +65,8 @@ sl = targetData->getStructLayout(structType); } else { - virtualType = J3Intrinsics::JavaObjectType; + virtualType = Mod->getIntrinsics()->JavaObjectType; + assert(virtualType && "intrinsics not iniitalized"); structType = dyn_cast(virtualType->getContainedType(0)); sl = targetData->getStructLayout(structType); @@ -240,8 +241,10 @@ std::vector llvmArgs; uint32 size = signature->nbArguments; Typedef* const* arguments = signature->getArgumentsType(); + JavaLLVMCompiler* Mod = + (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); - llvmArgs.push_back(J3Intrinsics::JavaObjectType); + llvmArgs.push_back(Mod->getIntrinsics()->JavaObjectType); for (uint32 i = 0; i < size; ++i) { Typedef* type = arguments[i]; @@ -276,7 +279,8 @@ } #if defined(ISOLATE_SHARING) - llvmArgs.push_back(J3Intrinsics::ConstantPoolType); // cached constant pool + // cached constant pool + llvmArgs.push_back(Mod->getIntrinsics()->ConstantPoolType); #endif LLVMAssessorInfo& LAI = @@ -294,17 +298,20 @@ std::vector llvmArgs; uint32 size = signature->nbArguments; Typedef* const* arguments = signature->getArgumentsType(); + JavaLLVMCompiler* Mod = + (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); - const llvm::Type* Ty = PointerType::getUnqual(J3Intrinsics::JavaObjectType); + const llvm::Type* Ty = + PointerType::getUnqual(Mod->getIntrinsics()->JavaObjectType); - llvmArgs.push_back(J3Intrinsics::ptrType); // JNIEnv + llvmArgs.push_back(Mod->getIntrinsics()->ptrType); // JNIEnv llvmArgs.push_back(Ty); // Class for (uint32 i = 0; i < size; ++i) { Typedef* type = arguments[i]; LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); const llvm::Type* Ty = LAI.llvmType; - if (Ty == J3Intrinsics::JavaObjectType) { + if (Ty == Mod->getIntrinsics()->JavaObjectType) { llvmArgs.push_back(LAI.llvmTypePtr); } else { llvmArgs.push_back(LAI.llvmType); @@ -312,13 +319,15 @@ } #if defined(ISOLATE_SHARING) - llvmArgs.push_back(J3Intrinsics::ConstantPoolType); // cached constant pool + // cached constant pool + llvmArgs.push_back(Mod->getIntrinsics()->ConstantPoolType); #endif LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); - const llvm::Type* RetType = LAI.llvmType == J3Intrinsics::JavaObjectType ? - LAI.llvmTypePtr : LAI.llvmType; + const llvm::Type* RetType = + LAI.llvmType == Mod->getIntrinsics()->JavaObjectType ? + LAI.llvmTypePtr : LAI.llvmType; nativeType = FunctionType::get(RetType, llvmArgs, false); mvm::MvmModule::unprotectIR(); } @@ -607,9 +616,11 @@ // Lock here because we are called by arbitrary code mvm::MvmModule::protectIR(); std::vector Args; - Args.push_back(J3Intrinsics::ConstantPoolType); // ctp + JavaLLVMCompiler* Mod = + (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); + Args.push_back(Mod->getIntrinsics()->ConstantPoolType); // ctp Args.push_back(getVirtualPtrType()); - Args.push_back(J3Intrinsics::JavaObjectType); + Args.push_back(Mod->getIntrinsics()->JavaObjectType); Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr); LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); @@ -623,8 +634,10 @@ if (!staticBufType) { // Lock here because we are called by arbitrary code mvm::MvmModule::protectIR(); + JavaLLVMCompiler* Mod = + (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); std::vector Args; - Args.push_back(J3Intrinsics::ConstantPoolType); // ctp + Args.push_back(Mod->getIntrinsics()->ConstantPoolType); // ctp Args.push_back(getStaticPtrType()); Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr); LLVMAssessorInfo& LAI = @@ -799,14 +812,14 @@ PointerType::getUnqual(Type::getDoubleTy(getGlobalContext())); AssessorInfo[I_DOUBLE].logSizeInBytesConstant = 3; - AssessorInfo[I_TAB].llvmType = J3Intrinsics::JavaObjectType; + AssessorInfo[I_TAB].llvmType = PointerType::getUnqual( + mvm::MvmModule::globalModule->getTypeByName("JavaObject")); AssessorInfo[I_TAB].llvmTypePtr = - PointerType::getUnqual(J3Intrinsics::JavaObjectType); + PointerType::getUnqual(AssessorInfo[I_TAB].llvmType); AssessorInfo[I_TAB].logSizeInBytesConstant = sizeof(JavaObject*) == 8 ? 3 : 2; - AssessorInfo[I_REF].llvmType = J3Intrinsics::JavaObjectType; - AssessorInfo[I_REF].llvmTypePtr = - PointerType::getUnqual(J3Intrinsics::JavaObjectType); + AssessorInfo[I_REF].llvmType = AssessorInfo[I_TAB].llvmType; + AssessorInfo[I_REF].llvmTypePtr = AssessorInfo[I_TAB].llvmTypePtr; AssessorInfo[I_REF].logSizeInBytesConstant = sizeof(JavaObject*) == 8 ? 3 : 2; } Modified: vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp?rev=96749&r1=96748&r2=96749&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp Sun Feb 21 13:32:50 2010 @@ -402,7 +402,7 @@ BasicBlock* trueCl = BasicBlock::Create(*Context, "Initialized", &F); BasicBlock* falseCl = BasicBlock::Create(*Context, "Uninitialized", &F); - PHINode* node = llvm::PHINode::Create(J3Intrinsics::JavaClassType, "", trueCl); + PHINode* node = llvm::PHINode::Create(intrinsics->JavaClassType, "", trueCl); node->addIncoming(Cl, CI->getParent()); BranchInst::Create(trueCl, falseCl, test, CI); Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=96749&r1=96748&r2=96749&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sun Feb 21 13:32:50 2010 @@ -325,14 +325,12 @@ module->setTargetTriple(MvmModule::globalModule->getTargetTriple()); LLVMContext& Context = module->getContext(); - if (!ptrType) { - // Type declaration - ptrType = PointerType::getUnqual(Type::getInt8Ty(Context)); - ptr32Type = PointerType::getUnqual(Type::getInt32Ty(Context)); - ptrPtrType = PointerType::getUnqual(ptrType); - pointerSizeType = module->getPointerSize() == Module::Pointer32 ? - Type::getInt32Ty(Context) : Type::getInt64Ty(Context); - } + // Type declaration + ptrType = PointerType::getUnqual(Type::getInt8Ty(Context)); + ptr32Type = PointerType::getUnqual(Type::getInt32Ty(Context)); + ptrPtrType = PointerType::getUnqual(ptrType); + pointerSizeType = module->getPointerSize() == Module::Pointer32 ? + Type::getInt32Ty(Context) : Type::getInt64Ty(Context); // Constant declaration constantLongMinusOne = ConstantInt::get(Type::getInt64Ty(Context), (uint64_t)-1); @@ -457,13 +455,6 @@ assert(AddFinalizationCandidate && "No addFinalizationCandidate function"); } - -const llvm::PointerType* BaseIntrinsics::ptrType; -const llvm::PointerType* BaseIntrinsics::ptr32Type; -const llvm::PointerType* BaseIntrinsics::ptrPtrType; -const llvm::Type* BaseIntrinsics::pointerSizeType; -const llvm::Type* BaseIntrinsics::arrayPtrType; - const llvm::TargetData* MvmModule::TheTargetData; llvm::GCStrategy* MvmModule::TheGCStrategy; llvm::Module *MvmModule::globalModule; Modified: vmkit/trunk/lib/N3/Mono/MonoString.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/Mono/MonoString.cpp?rev=96749&r1=96748&r2=96749&view=diff ============================================================================== --- vmkit/trunk/lib/N3/Mono/MonoString.cpp (original) +++ vmkit/trunk/lib/N3/Mono/MonoString.cpp Sun Feb 21 13:32:50 2010 @@ -44,7 +44,7 @@ if (!str->_llvmVar) { N3* vm = VMThread::get()->getVM(); if (!str->_llvmVar) { - const Type* pty = mvm::BaseIntrinsics::ptrType; + const Type* pty = PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())); Module* Mod = vm->getLLVMModule(); Constant* cons = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (self)), Modified: vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp?rev=96749&r1=96748&r2=96749&view=diff ============================================================================== --- vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp (original) +++ vmkit/trunk/lib/N3/VMCore/CLIJitMeta.cpp Sun Feb 21 13:32:50 2010 @@ -264,7 +264,7 @@ aquire(); if (!_llvmVar) { Module* Mod = vm->getLLVMModule(); - const Type* pty = mvm::BaseIntrinsics::ptrType; + const Type* pty = PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())); Constant* cons = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)), pty); @@ -283,7 +283,7 @@ if (!_llvmVar) { classDef->aquire(); if (!_llvmVar) { - const Type* pty = mvm::BaseIntrinsics::ptrType; + const Type* pty = PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())); Module* Mod = classDef->vm->getLLVMModule(); Constant* cons = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)), @@ -303,7 +303,7 @@ classDef->aquire(); if (!_llvmVar) { Module* Mod = classDef->vm->getLLVMModule(); - const Type* pty = mvm::BaseIntrinsics::ptrType; + const Type* pty = PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())); Constant* cons = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (this)), pty); From nicolas.geoffray at lip6.fr Mon Feb 22 12:32:35 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 22 Feb 2010 20:32:35 -0000 Subject: [vmkit-commits] [vmkit] r96797 - in /vmkit/trunk/lib: J3/Compiler/J3Intrinsics.cpp Mvm/Compiler/JIT.cpp Message-ID: <20100222203235.372052A6C124@llvm.org> Author: geoffray Date: Mon Feb 22 14:32:35 2010 New Revision: 96797 URL: http://llvm.org/viewvc/llvm-project?rev=96797&view=rev Log: Get the functions from the module, not the global module. Modified: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Modified: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp?rev=96797&r1=96796&r2=96797&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp Mon Feb 22 14:32:35 2010 @@ -38,8 +38,9 @@ if (!globalModule->getTypeByName("JavaThread")) { j3::llvm_runtime::makeLLVMModuleContents(globalModule); - mvm::MvmModule::copyDefinitions(module, mvm::MvmModule::globalModule); + mvm::MvmModule::copyDefinitions(module, globalModule); } + if (!(LLVMAssessorInfo::AssessorInfo[I_VOID].llvmType)) { LLVMAssessorInfo::initialise(); @@ -178,103 +179,103 @@ globalModule->addTypeName("ArrayDouble", JavaArrayDoubleType->getContainedType(0)); globalModule->addTypeName("ArrayObject", JavaArrayObjectType->getContainedType(0)); - InterfaceLookupFunction = globalModule->getFunction("j3InterfaceLookup"); - MultiCallNewFunction = globalModule->getFunction("j3MultiCallNew"); - ForceLoadedCheckFunction = globalModule->getFunction("forceLoadedCheck"); - InitialisationCheckFunction = globalModule->getFunction("initialisationCheck"); + InterfaceLookupFunction = module->getFunction("j3InterfaceLookup"); + MultiCallNewFunction = module->getFunction("j3MultiCallNew"); + ForceLoadedCheckFunction = module->getFunction("forceLoadedCheck"); + InitialisationCheckFunction = module->getFunction("initialisationCheck"); ForceInitialisationCheckFunction = - globalModule->getFunction("forceInitialisationCheck"); - InitialiseClassFunction = globalModule->getFunction("j3RuntimeInitialiseClass"); + module->getFunction("forceInitialisationCheck"); + InitialiseClassFunction = module->getFunction("j3RuntimeInitialiseClass"); - GetConstantPoolAtFunction = globalModule->getFunction("getConstantPoolAt"); - ArrayLengthFunction = globalModule->getFunction("arrayLength"); - GetVTFunction = globalModule->getFunction("getVT"); - GetIMTFunction = globalModule->getFunction("getIMT"); - GetClassFunction = globalModule->getFunction("getClass"); - ClassLookupFunction = globalModule->getFunction("j3ClassLookup"); - GetVTFromClassFunction = globalModule->getFunction("getVTFromClass"); - GetVTFromClassArrayFunction = globalModule->getFunction("getVTFromClassArray"); - GetVTFromCommonClassFunction = globalModule->getFunction("getVTFromCommonClass"); - GetBaseClassVTFromVTFunction = globalModule->getFunction("getBaseClassVTFromVT"); + GetConstantPoolAtFunction = module->getFunction("getConstantPoolAt"); + ArrayLengthFunction = module->getFunction("arrayLength"); + GetVTFunction = module->getFunction("getVT"); + GetIMTFunction = module->getFunction("getIMT"); + GetClassFunction = module->getFunction("getClass"); + ClassLookupFunction = module->getFunction("j3ClassLookup"); + GetVTFromClassFunction = module->getFunction("getVTFromClass"); + GetVTFromClassArrayFunction = module->getFunction("getVTFromClassArray"); + GetVTFromCommonClassFunction = module->getFunction("getVTFromCommonClass"); + GetBaseClassVTFromVTFunction = module->getFunction("getBaseClassVTFromVT"); GetObjectSizeFromClassFunction = - globalModule->getFunction("getObjectSizeFromClass"); + module->getFunction("getObjectSizeFromClass"); - GetClassDelegateeFunction = globalModule->getFunction("getClassDelegatee"); - RuntimeDelegateeFunction = globalModule->getFunction("j3RuntimeDelegatee"); - IsAssignableFromFunction = globalModule->getFunction("isAssignableFrom"); - IsSecondaryClassFunction = globalModule->getFunction("isSecondaryClass"); - GetDepthFunction = globalModule->getFunction("getDepth"); - GetStaticInstanceFunction = globalModule->getFunction("getStaticInstance"); - GetDisplayFunction = globalModule->getFunction("getDisplay"); - GetVTInDisplayFunction = globalModule->getFunction("getVTInDisplay"); - AquireObjectFunction = globalModule->getFunction("j3JavaObjectAquire"); - ReleaseObjectFunction = globalModule->getFunction("j3JavaObjectRelease"); - OverflowThinLockFunction = globalModule->getFunction("j3OverflowThinLock"); - - VirtualFieldLookupFunction = globalModule->getFunction("j3VirtualFieldLookup"); - StaticFieldLookupFunction = globalModule->getFunction("j3StaticFieldLookup"); - StringLookupFunction = globalModule->getFunction("j3StringLookup"); - StartJNIFunction = globalModule->getFunction("j3StartJNI"); - EndJNIFunction = globalModule->getFunction("j3EndJNI"); - - ResolveVirtualStubFunction = globalModule->getFunction("j3ResolveVirtualStub"); - ResolveStaticStubFunction = globalModule->getFunction("j3ResolveStaticStub"); - ResolveSpecialStubFunction = globalModule->getFunction("j3ResolveSpecialStub"); + GetClassDelegateeFunction = module->getFunction("getClassDelegatee"); + RuntimeDelegateeFunction = module->getFunction("j3RuntimeDelegatee"); + IsAssignableFromFunction = module->getFunction("isAssignableFrom"); + IsSecondaryClassFunction = module->getFunction("isSecondaryClass"); + GetDepthFunction = module->getFunction("getDepth"); + GetStaticInstanceFunction = module->getFunction("getStaticInstance"); + GetDisplayFunction = module->getFunction("getDisplay"); + GetVTInDisplayFunction = module->getFunction("getVTInDisplay"); + AquireObjectFunction = module->getFunction("j3JavaObjectAquire"); + ReleaseObjectFunction = module->getFunction("j3JavaObjectRelease"); + OverflowThinLockFunction = module->getFunction("j3OverflowThinLock"); + + VirtualFieldLookupFunction = module->getFunction("j3VirtualFieldLookup"); + StaticFieldLookupFunction = module->getFunction("j3StaticFieldLookup"); + StringLookupFunction = module->getFunction("j3StringLookup"); + StartJNIFunction = module->getFunction("j3StartJNI"); + EndJNIFunction = module->getFunction("j3EndJNI"); + + ResolveVirtualStubFunction = module->getFunction("j3ResolveVirtualStub"); + ResolveStaticStubFunction = module->getFunction("j3ResolveStaticStub"); + ResolveSpecialStubFunction = module->getFunction("j3ResolveSpecialStub"); NullPointerExceptionFunction = - globalModule->getFunction("j3NullPointerException"); - ClassCastExceptionFunction = globalModule->getFunction("j3ClassCastException"); + module->getFunction("j3NullPointerException"); + ClassCastExceptionFunction = module->getFunction("j3ClassCastException"); IndexOutOfBoundsExceptionFunction = - globalModule->getFunction("j3IndexOutOfBoundsException"); + module->getFunction("j3IndexOutOfBoundsException"); NegativeArraySizeExceptionFunction = - globalModule->getFunction("j3NegativeArraySizeException"); - OutOfMemoryErrorFunction = globalModule->getFunction("j3OutOfMemoryError"); - StackOverflowErrorFunction = globalModule->getFunction("j3StackOverflowError"); - ArrayStoreExceptionFunction = globalModule->getFunction("j3ArrayStoreException"); - ArithmeticExceptionFunction = globalModule->getFunction("j3ArithmeticException"); - - PrintExecutionFunction = globalModule->getFunction("j3PrintExecution"); - PrintMethodStartFunction = globalModule->getFunction("j3PrintMethodStart"); - PrintMethodEndFunction = globalModule->getFunction("j3PrintMethodEnd"); + module->getFunction("j3NegativeArraySizeException"); + OutOfMemoryErrorFunction = module->getFunction("j3OutOfMemoryError"); + StackOverflowErrorFunction = module->getFunction("j3StackOverflowError"); + ArrayStoreExceptionFunction = module->getFunction("j3ArrayStoreException"); + ArithmeticExceptionFunction = module->getFunction("j3ArithmeticException"); + + PrintExecutionFunction = module->getFunction("j3PrintExecution"); + PrintMethodStartFunction = module->getFunction("j3PrintMethodStart"); + PrintMethodEndFunction = module->getFunction("j3PrintMethodEnd"); - ThrowExceptionFunction = globalModule->getFunction("j3ThrowException"); + ThrowExceptionFunction = module->getFunction("j3ThrowException"); - GetArrayClassFunction = globalModule->getFunction("j3GetArrayClass"); + GetArrayClassFunction = module->getFunction("j3GetArrayClass"); - GetFinalInt8FieldFunction = globalModule->getFunction("getFinalInt8Field"); - GetFinalInt16FieldFunction = globalModule->getFunction("getFinalInt16Field"); - GetFinalInt32FieldFunction = globalModule->getFunction("getFinalInt32Field"); - GetFinalLongFieldFunction = globalModule->getFunction("getFinalLongField"); - GetFinalFloatFieldFunction = globalModule->getFunction("getFinalFloatField"); - GetFinalDoubleFieldFunction = globalModule->getFunction("getFinalDoubleField"); - GetFinalObjectFieldFunction = globalModule->getFunction("getFinalObjectField"); + GetFinalInt8FieldFunction = module->getFunction("getFinalInt8Field"); + GetFinalInt16FieldFunction = module->getFunction("getFinalInt16Field"); + GetFinalInt32FieldFunction = module->getFunction("getFinalInt32Field"); + GetFinalLongFieldFunction = module->getFunction("getFinalLongField"); + GetFinalFloatFieldFunction = module->getFunction("getFinalFloatField"); + GetFinalDoubleFieldFunction = module->getFunction("getFinalDoubleField"); + GetFinalObjectFieldFunction = module->getFunction("getFinalObjectField"); #ifdef ISOLATE_SHARING - GetCtpClassFunction = globalModule->getFunction("getCtpClass"); + GetCtpClassFunction = module->getFunction("getCtpClass"); GetJnjvmExceptionClassFunction = - globalModule->getFunction("getJnjvmExceptionClass"); - GetJnjvmArrayClassFunction = globalModule->getFunction("getJnjvmArrayClass"); - StaticCtpLookupFunction = globalModule->getFunction("j3StaticCtpLookup"); - SpecialCtpLookupFunction = globalModule->getFunction("j3SpecialCtpLookup"); + module->getFunction("getJnjvmExceptionClass"); + GetJnjvmArrayClassFunction = module->getFunction("getJnjvmArrayClass"); + StaticCtpLookupFunction = module->getFunction("j3StaticCtpLookup"); + SpecialCtpLookupFunction = module->getFunction("j3SpecialCtpLookup"); #endif #ifdef SERVICE - ServiceCallStartFunction = globalModule->getFunction("j3ServiceCallStart"); - ServiceCallStopFunction = globalModule->getFunction("j3ServiceCallStop"); + ServiceCallStartFunction = module->getFunction("j3ServiceCallStart"); + ServiceCallStopFunction = module->getFunction("j3ServiceCallStop"); #endif - JavaObjectTracerFunction = globalModule->getFunction("JavaObjectTracer"); - EmptyTracerFunction = globalModule->getFunction("EmptyTracer"); - JavaArrayTracerFunction = globalModule->getFunction("JavaArrayTracer"); - ArrayObjectTracerFunction = globalModule->getFunction("ArrayObjectTracer"); - RegularObjectTracerFunction = globalModule->getFunction("RegularObjectTracer"); + JavaObjectTracerFunction = module->getFunction("JavaObjectTracer"); + EmptyTracerFunction = module->getFunction("EmptyTracer"); + JavaArrayTracerFunction = module->getFunction("JavaArrayTracer"); + ArrayObjectTracerFunction = module->getFunction("ArrayObjectTracer"); + RegularObjectTracerFunction = module->getFunction("RegularObjectTracer"); #ifndef WITHOUT_VTABLE - VirtualLookupFunction = globalModule->getFunction("j3VirtualTableLookup"); + VirtualLookupFunction = module->getFunction("j3VirtualTableLookup"); #endif - GetLockFunction = globalModule->getFunction("getLock"); + GetLockFunction = module->getFunction("getLock"); ThrowExceptionFromJITFunction = - globalModule->getFunction("j3ThrowExceptionFromJIT"); + module->getFunction("j3ThrowExceptionFromJIT"); } Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=96797&r1=96796&r2=96797&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Mon Feb 22 14:32:35 2010 @@ -325,6 +325,8 @@ module->setTargetTriple(MvmModule::globalModule->getTargetTriple()); LLVMContext& Context = module->getContext(); + MvmModule::copyDefinitions(module, MvmModule::globalModule); + // Type declaration ptrType = PointerType::getUnqual(Type::getInt8Ty(Context)); ptr32Type = PointerType::getUnqual(Type::getInt32Ty(Context)); @@ -385,7 +387,6 @@ arrayPtrType = PointerType::getUnqual(ArrayType::get(Type::getInt8Ty(Context), 0)); - MvmModule::copyDefinitions(module, MvmModule::globalModule); printFloatLLVM = module->getFunction("printFloat"); printDoubleLLVM = module->getFunction("printDouble"); From nicolas.geoffray at lip6.fr Mon Feb 22 13:39:15 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 22 Feb 2010 21:39:15 -0000 Subject: [vmkit-commits] [vmkit] r96804 - in /vmkit/trunk: include/j3/JavaLLVMCompiler.h include/j3/LLVMInfo.h lib/J3/Compiler/J3Intrinsics.cpp lib/J3/Compiler/JavaAOTCompiler.cpp lib/J3/Compiler/JavaJIT.cpp lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/JavaJITOpcodes.cpp lib/J3/Compiler/JavaLLVMCompiler.cpp lib/J3/Compiler/LLVMInfo.cpp Message-ID: <20100222213915.AB7462A6C12E@llvm.org> Author: geoffray Date: Mon Feb 22 15:39:15 2010 New Revision: 96804 URL: http://llvm.org/viewvc/llvm-project?rev=96804&view=rev Log: Start getting rid of getGlobalContext. Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h vmkit/trunk/include/j3/LLVMInfo.h vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaLLVMCompiler.h?rev=96804&r1=96803&r2=96804&view=diff ============================================================================== --- vmkit/trunk/include/j3/JavaLLVMCompiler.h (original) +++ vmkit/trunk/include/j3/JavaLLVMCompiler.h Mon Feb 22 15:39:15 2010 @@ -14,6 +14,9 @@ #include "j3/J3Intrinsics.h" #include "j3/LLVMInfo.h" +#include "llvm/LLVMContext.h" +#include "llvm/Module.h" + namespace llvm { class BasicBlock; class DIFactory; @@ -72,6 +75,10 @@ llvm::Module* getLLVMModule() { return TheModule; } + + llvm::LLVMContext& getLLVMContext() { + return TheModule->getContext(); + } J3Intrinsics* getIntrinsics() { return &JavaIntrinsics; @@ -104,11 +111,14 @@ void resolveStaticClass(Class* cl); static llvm::Function* getMethod(JavaMethod* meth); + void initialiseAssessorInfo(); + std::map AssessorInfo; + LLVMAssessorInfo& getTypedefInfo(const Typedef* type); + static LLVMSignatureInfo* getSignatureInfo(Signdef* sign); static LLVMClassInfo* getClassInfo(Class* cl); static LLVMFieldInfo* getFieldInfo(JavaField* field); static LLVMMethodInfo* getMethodInfo(JavaMethod* method); - static LLVMAssessorInfo& getTypedefInfo(const Typedef* type); virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl) = 0; virtual JavaObject* getFinalObject(llvm::Value* C) = 0; Modified: vmkit/trunk/include/j3/LLVMInfo.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMInfo.h?rev=96804&r1=96803&r2=96804&view=diff ============================================================================== --- vmkit/trunk/include/j3/LLVMInfo.h (original) +++ vmkit/trunk/include/j3/LLVMInfo.h Mon Feb 22 15:39:15 2010 @@ -33,10 +33,6 @@ const llvm::Type* llvmType; const llvm::Type* llvmTypePtr; uint8_t logSizeInBytesConstant; - - static void initialise(); - static std::map AssessorInfo; - }; class LLVMClassInfo : public mvm::JITInfo { Modified: vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp?rev=96804&r1=96803&r2=96804&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/J3Intrinsics.cpp Mon Feb 22 15:39:15 2010 @@ -41,12 +41,8 @@ mvm::MvmModule::copyDefinitions(module, globalModule); } - - if (!(LLVMAssessorInfo::AssessorInfo[I_VOID].llvmType)) { - LLVMAssessorInfo::initialise(); - } - VTType = PointerType::getUnqual(globalModule->getTypeByName("VT")); + LLVMContext& Context = module->getContext(); #ifdef ISOLATE_SHARING JnjvmType = @@ -108,9 +104,9 @@ JavaObjectNullConstant = Constant::getNullValue(J3Intrinsics::JavaObjectType); - MaxArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + MaxArraySizeConstant = ConstantInt::get(Type::getInt32Ty(Context), JavaArray::MaxArraySize); - JavaArraySizeConstant = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + JavaArraySizeConstant = ConstantInt::get(Type::getInt32Ty(Context), sizeof(JavaObject) + sizeof(ssize_t)); @@ -122,43 +118,39 @@ OffsetDepthInVTConstant = constantFour; OffsetDisplayInVTConstant = constantSeven; OffsetBaseClassVTInVTConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 17); - OffsetIMTInVTConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 18); + ConstantInt::get(Type::getInt32Ty(Context), 17); + OffsetIMTInVTConstant = ConstantInt::get(Type::getInt32Ty(Context), 18); OffsetAccessInCommonClassConstant = constantOne; - IsArrayConstant = ConstantInt::get(Type::getInt16Ty(getGlobalContext()), + IsArrayConstant = ConstantInt::get(Type::getInt16Ty(Context), JNJVM_ARRAY); - IsPrimitiveConstant = ConstantInt::get(Type::getInt16Ty(getGlobalContext()), + IsPrimitiveConstant = ConstantInt::get(Type::getInt16Ty(Context), JNJVM_PRIMITIVE); OffsetBaseClassInArrayClassConstant = constantOne; OffsetLogSizeInPrimitiveClassConstant = constantOne; OffsetObjectSizeInClassConstant = constantOne; - OffsetVTInClassConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 7); + OffsetVTInClassConstant = ConstantInt::get(Type::getInt32Ty(Context), 7); OffsetTaskClassMirrorInClassConstant = constantThree; OffsetVirtualMethodsInClassConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 9); + ConstantInt::get(Type::getInt32Ty(Context), 9); OffsetStaticInstanceInTaskClassMirrorConstant = constantThree; OffsetStatusInTaskClassMirrorConstant = constantZero; OffsetInitializedInTaskClassMirrorConstant = constantOne; OffsetIsolateInThreadConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 3); + ConstantInt::get(Type::getInt32Ty(Context), 3); OffsetDoYieldInThreadConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 6); - OffsetJNIInThreadConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 1); + ConstantInt::get(Type::getInt32Ty(Context), 6); + OffsetJNIInThreadConstant = ConstantInt::get(Type::getInt32Ty(Context), 1); OffsetJavaExceptionInThreadConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 2); + ConstantInt::get(Type::getInt32Ty(Context), 2); OffsetCXXExceptionInThreadConstant = - ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 3); + ConstantInt::get(Type::getInt32Ty(Context), 3); - ClassReadyConstant = - ConstantInt::get(Type::getInt8Ty(getGlobalContext()), ready); + ClassReadyConstant = ConstantInt::get(Type::getInt8Ty(Context), ready); globalModule->addTypeName("JavaObject", JavaObjectType->getContainedType(0)); globalModule->addTypeName("JavaArray", JavaArrayType->getContainedType(0)); Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=96804&r1=96803&r2=96804&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Mon Feb 22 15:39:15 2010 @@ -139,7 +139,7 @@ for (uint32 i = 0; i < cl->nbVirtualMethods + cl->nbStaticMethods; ++i) { if (&cl->virtualMethods[i] == meth) { - MOffset = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), i); + MOffset = ConstantInt::get(Type::getInt32Ty(getLLVMContext()), i); break; } } @@ -279,7 +279,7 @@ std::vector Vals; for (sint32 i = 0; i < size + 1; ++i) { - Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + Constant* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64_t(realObj[i])); CI = ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaObjectType); Vals.push_back(CI); @@ -295,7 +295,7 @@ return ConstantExpr::getBitCast(varGV, JavaIntrinsics.JavaObjectType); } else { - Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + Constant* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64_t(obj)); CI = ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaObjectType); return CI; @@ -318,21 +318,21 @@ CommonClass* subClass = cl->asArrayClass()->baseClass(); if (subClass->isPrimitive()) { if (subClass == upcalls->OfBool) { - Ty = Type::getInt8Ty(getGlobalContext()); + Ty = Type::getInt8Ty(getLLVMContext()); } else if (subClass == upcalls->OfByte) { - Ty = Type::getInt8Ty(getGlobalContext()); + Ty = Type::getInt8Ty(getLLVMContext()); } else if (subClass == upcalls->OfShort) { - Ty = Type::getInt16Ty(getGlobalContext()); + Ty = Type::getInt16Ty(getLLVMContext()); } else if (subClass == upcalls->OfChar) { - Ty = Type::getInt16Ty(getGlobalContext()); + Ty = Type::getInt16Ty(getLLVMContext()); } else if (subClass == upcalls->OfInt) { - Ty = Type::getInt32Ty(getGlobalContext()); + Ty = Type::getInt32Ty(getLLVMContext()); } else if (subClass == upcalls->OfFloat) { - Ty = Type::getFloatTy(getGlobalContext()); + Ty = Type::getFloatTy(getLLVMContext()); } else if (subClass == upcalls->OfLong) { - Ty = Type::getInt64Ty(getGlobalContext()); + Ty = Type::getInt64Ty(getLLVMContext()); } else if (subClass == upcalls->OfDouble) { - Ty = Type::getDoubleTy(getGlobalContext()); + Ty = Type::getDoubleTy(getLLVMContext()); } else { abort(); } @@ -396,32 +396,32 @@ const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; if (prim->isBool() || prim->isByte()) { ConstantInt* CI = ConstantInt::get( - Type::getInt8Ty(getGlobalContext()), + Type::getInt8Ty(getLLVMContext()), field.getInt8Field(obj)); Elts.push_back(CI); } else if (prim->isShort() || prim->isChar()) { ConstantInt* CI = ConstantInt::get( - Type::getInt16Ty(getGlobalContext()), + Type::getInt16Ty(getLLVMContext()), field.getInt16Field(obj)); Elts.push_back(CI); } else if (prim->isInt()) { ConstantInt* CI = ConstantInt::get( - Type::getInt32Ty(getGlobalContext()), + Type::getInt32Ty(getLLVMContext()), field.getInt32Field(obj)); Elts.push_back(CI); } else if (prim->isLong()) { ConstantInt* CI = ConstantInt::get( - Type::getInt64Ty(getGlobalContext()), + Type::getInt64Ty(getLLVMContext()), field.getLongField(obj)); Elts.push_back(CI); } else if (prim->isFloat()) { Constant* CF = ConstantFP::get( - Type::getFloatTy(getGlobalContext()), + Type::getFloatTy(getLLVMContext()), field.getFloatField(obj)); Elts.push_back(CF); } else if (prim->isDouble()) { Constant* CF = ConstantFP::get( - Type::getDoubleTy(getGlobalContext()), + Type::getDoubleTy(getLLVMContext()), field.getDoubleField(obj)); Elts.push_back(CF); } else { @@ -446,11 +446,11 @@ JavaConstantPool * ctpInfo = cl->ctpInfo; uint16 idx = reader.readU2(); if (type->isPrimitive()) { - if (Ty == Type::getInt64Ty(getGlobalContext())) { + if (Ty == Type::getInt64Ty(getLLVMContext())) { Elts.push_back(ConstantInt::get(Ty, (uint64)ctpInfo->LongAt(idx))); - } else if (Ty == Type::getDoubleTy(getGlobalContext())) { + } else if (Ty == Type::getDoubleTy(getLLVMContext())) { Elts.push_back(ConstantFP::get(Ty, ctpInfo->DoubleAt(idx))); - } else if (Ty == Type::getFloatTy(getGlobalContext())) { + } else if (Ty == Type::getFloatTy(getLLVMContext())) { Elts.push_back(ConstantFP::get(Ty, ctpInfo->FloatAt(idx))); } else { Elts.push_back(ConstantInt::get(Ty, (uint64)ctpInfo->IntegerAt(idx))); @@ -579,7 +579,7 @@ Elmts.push_back(getVirtualTable(cl->virtualVT)); // lock - Constant* L = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), 0); + Constant* L = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), 0); Elmts.push_back(ConstantExpr::getIntToPtr(L, JavaIntrinsics.ptrType)); return ConstantStruct::get(STy, Elmts); @@ -623,28 +623,28 @@ if (subClass->isPrimitive()) { if (subClass == upcalls->OfBool) { return CreateConstantFromIntArray((ArrayUInt8*)obj, - Type::getInt8Ty(getGlobalContext())); + Type::getInt8Ty(getLLVMContext())); } else if (subClass == upcalls->OfByte) { return CreateConstantFromIntArray((ArraySInt8*)obj, - Type::getInt8Ty(getGlobalContext())); + Type::getInt8Ty(getLLVMContext())); } else if (subClass == upcalls->OfShort) { return CreateConstantFromIntArray((ArraySInt16*)obj, - Type::getInt16Ty(getGlobalContext())); + Type::getInt16Ty(getLLVMContext())); } else if (subClass == upcalls->OfChar) { return CreateConstantFromIntArray((ArrayUInt16*)obj, - Type::getInt16Ty(getGlobalContext())); + Type::getInt16Ty(getLLVMContext())); } else if (subClass == upcalls->OfInt) { return CreateConstantFromIntArray((ArraySInt32*)obj, - Type::getInt32Ty(getGlobalContext())); + Type::getInt32Ty(getLLVMContext())); } else if (subClass == upcalls->OfFloat) { return CreateConstantFromFPArray((ArrayFloat*)obj, - Type::getFloatTy(getGlobalContext())); + Type::getFloatTy(getLLVMContext())); } else if (subClass == upcalls->OfLong) { return CreateConstantFromIntArray((ArrayLong*)obj, - Type::getInt64Ty(getGlobalContext())); + Type::getInt64Ty(getLLVMContext())); } else if (subClass == upcalls->OfDouble) { return CreateConstantFromFPArray((ArrayDouble*)obj, - Type::getDoubleTy(getGlobalContext())); + Type::getDoubleTy(getLLVMContext())); } else { abort(); } @@ -673,27 +673,27 @@ if (type->isPrimitive()) { const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; if (prim->isBool() || prim->isByte()) { - ConstantInt* CI = ConstantInt::get(Type::getInt8Ty(getGlobalContext()), + ConstantInt* CI = ConstantInt::get(Type::getInt8Ty(getLLVMContext()), field.getInt8Field(obj)); TempElts.push_back(CI); } else if (prim->isShort() || prim->isChar()) { - ConstantInt* CI = ConstantInt::get(Type::getInt16Ty(getGlobalContext()), + ConstantInt* CI = ConstantInt::get(Type::getInt16Ty(getLLVMContext()), field.getInt16Field(obj)); TempElts.push_back(CI); } else if (prim->isInt()) { - ConstantInt* CI = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + ConstantInt* CI = ConstantInt::get(Type::getInt32Ty(getLLVMContext()), field.getInt32Field(obj)); TempElts.push_back(CI); } else if (prim->isLong()) { - ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), field.getLongField(obj)); TempElts.push_back(CI); } else if (prim->isFloat()) { - Constant* CF = ConstantFP::get(Type::getFloatTy(getGlobalContext()), + Constant* CF = ConstantFP::get(Type::getFloatTy(getLLVMContext()), field.getFloatField(obj)); TempElts.push_back(CF); } else if (prim->isDouble()) { - Constant* CF = ConstantFP::get(Type::getDoubleTy(getGlobalContext()), + Constant* CF = ConstantFP::get(Type::getDoubleTy(getLLVMContext()), field.getDoubleField(obj)); TempElts.push_back(CF); } else { @@ -730,7 +730,7 @@ Elmts.push_back(CreateConstantForBaseObject(cl)); Constant* Array = CreateConstantFromIntArray(str->value, - Type::getInt16Ty(getGlobalContext())); + Type::getInt16Ty(getLLVMContext())); Module& Mod = *getLLVMModule(); @@ -741,11 +741,11 @@ Array = ConstantExpr::getBitCast(varGV, JavaIntrinsics.JavaObjectType); Elmts.push_back(Array); - Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), str->count)); - Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), str->cachedHashCode)); - Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), str->offset)); return ConstantStruct::get(STy, Elmts); @@ -763,10 +763,10 @@ Elmts.push_back(getUTF8(attribut.name)); // start - Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), attribut.start)); + Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), attribut.start)); // nbb - Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), attribut.nbb)); + Elmts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), attribut.nbb)); return ConstantStruct::get(STy, Elmts); } @@ -789,7 +789,7 @@ CommonClassElts.push_back(ConstantArray::get(ATy, TCM, 1)); // access - CommonClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->access)); + CommonClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), cl->access)); // interfaces if (cl->nbInterfaces) { @@ -812,7 +812,7 @@ } // nbInterfaces - CommonClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbInterfaces)); + CommonClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), cl->nbInterfaces)); // name CommonClassElts.push_back(getUTF8(cl->name)); @@ -852,7 +852,7 @@ FieldElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); // access - FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.access)); + FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), field.access)); // name FieldElts.push_back(getUTF8(field.name)); @@ -882,16 +882,16 @@ } // nbAttributs - FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.nbAttributs)); + FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), field.nbAttributs)); // classDef FieldElts.push_back(getNativeClass(field.classDef)); // ptrOffset - FieldElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), field.ptrOffset)); + FieldElts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), field.ptrOffset)); // num - FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), field.num)); + FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), field.num)); //JInfo FieldElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); @@ -911,7 +911,7 @@ MethodElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); // access - MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), method.access)); + MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), method.access)); // attributs if (method.nbAttributs) { @@ -935,7 +935,7 @@ } // nbAttributs - MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), method.nbAttributs)); + MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), method.nbAttributs)); // classDef MethodElts.push_back(getNativeClass(method.classDef)); @@ -947,7 +947,7 @@ MethodElts.push_back(getUTF8(method.type)); // canBeInlined - MethodElts.push_back(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), method.canBeInlined)); + MethodElts.push_back(ConstantInt::get(Type::getInt8Ty(getLLVMContext()), method.canBeInlined)); // code if (isAbstract(method.access)) { @@ -963,10 +963,10 @@ MethodElts.push_back(Constant::getNullValue(JavaIntrinsics.CodeLineInfoType)); // codeInfoLength - MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), 0)); + MethodElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), 0)); // offset - MethodElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), method.offset)); + MethodElts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), method.offset)); // JInfo MethodElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); @@ -985,7 +985,7 @@ ClassElts.push_back(CreateConstantFromCommonClass(cl)); // primSize - ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->logSize)); + ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), cl->logSize)); return ConstantStruct::get(STy, ClassElts); } @@ -1023,11 +1023,11 @@ ClassElts.push_back(CreateConstantFromCommonClass(cl)); // virtualSize - ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), cl->virtualSize)); // alginment - ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), cl->alignment)); // IsolateInfo @@ -1038,9 +1038,9 @@ assert(TCMTy && "Malformed type"); uint32 status = cl->needsInitialisationCheck() ? vmjc : ready; - TempElts.push_back(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), + TempElts.push_back(ConstantInt::get(Type::getInt8Ty(getLLVMContext()), status)); - TempElts.push_back(ConstantInt::get(Type::getInt1Ty(getGlobalContext()), + TempElts.push_back(ConstantInt::get(Type::getInt1Ty(getLLVMContext()), status == ready ? 1 : 0)); TempElts.push_back(getStaticInstance(cl)); Constant* CStr[1] = { ConstantStruct::get(TCMTy, TempElts) }; @@ -1091,7 +1091,7 @@ ClassElts.push_back(fields); ConstantInt* nbVirtualFields = - ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbVirtualFields); + ConstantInt::get(Type::getInt16Ty(getLLVMContext()), cl->nbVirtualFields); // nbVirtualFields ClassElts.push_back(nbVirtualFields); @@ -1101,7 +1101,7 @@ ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.JavaFieldType)); // nbStaticFields - ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticFields)); + ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), cl->nbStaticFields)); // virtualMethods if (cl->nbVirtualMethods + cl->nbStaticMethods) { @@ -1141,7 +1141,7 @@ ClassElts.push_back(methods); ConstantInt* nbVirtualMethods = - ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbVirtualMethods); + ConstantInt::get(Type::getInt16Ty(getLLVMContext()), cl->nbVirtualMethods); // nbVirtualMethods ClassElts.push_back(nbVirtualMethods); @@ -1150,7 +1150,7 @@ ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.JavaMethodType)); // nbStaticMethods - ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbStaticMethods)); + ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), cl->nbStaticMethods)); // ownerClass ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); @@ -1183,7 +1183,7 @@ } // nbAttributs - ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbAttributs)); + ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), cl->nbAttributs)); // innerClasses if (cl->nbInnerClasses) { @@ -1207,7 +1207,7 @@ } // nbInnerClasses - ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->nbInnerClasses)); + ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), cl->nbInnerClasses)); // outerClass if (cl->outerClass) { @@ -1217,19 +1217,19 @@ } // innerAccess - ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), cl->innerAccess)); + ClassElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), cl->innerAccess)); // innerOuterResolved - ClassElts.push_back(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), cl->innerOuterResolved)); + ClassElts.push_back(ConstantInt::get(Type::getInt8Ty(getLLVMContext()), cl->innerOuterResolved)); // isAnonymous - ClassElts.push_back(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), cl->isAnonymous)); + ClassElts.push_back(ConstantInt::get(Type::getInt8Ty(getLLVMContext()), cl->isAnonymous)); // virtualTableSize - ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->virtualTableSize)); + ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), cl->virtualTableSize)); // staticSize - ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), cl->staticSize)); + ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), cl->staticSize)); // JInfo ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); @@ -1322,7 +1322,7 @@ Constant* JavaAOTCompiler::CreateConstantFromUTF8(const UTF8* val) { std::vector Elemts; - const ArrayType* ATy = ArrayType::get(Type::getInt16Ty(getGlobalContext()), val->size); + const ArrayType* ATy = ArrayType::get(Type::getInt16Ty(getLLVMContext()), val->size); Elemts.push_back(JavaIntrinsics.pointerSizeType); Elemts.push_back(ATy); @@ -1335,7 +1335,7 @@ std::vector Vals; for (sint32 i = 0; i < val->size; ++i) { - Vals.push_back(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), val->elements[i])); + Vals.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), val->elements[i])); } Cts.push_back(ConstantArray::get(ATy, Vals)); @@ -1414,11 +1414,11 @@ // depth Elemts.push_back(ConstantExpr::getIntToPtr( - ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->depth), PTy)); + ConstantInt::get(Type::getInt64Ty(getLLVMContext()), VT->depth), PTy)); // offset Elemts.push_back(ConstantExpr::getIntToPtr( - ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->offset), PTy)); + ConstantInt::get(Type::getInt64Ty(getLLVMContext()), VT->offset), PTy)); // cache Elemts.push_back(N); @@ -1436,7 +1436,7 @@ // nbSecondaryTypes Elemts.push_back(ConstantExpr::getIntToPtr( - ConstantInt::get(Type::getInt64Ty(getGlobalContext()), VT->nbSecondaryTypes), PTy)); + ConstantInt::get(Type::getInt64Ty(getLLVMContext()), VT->nbSecondaryTypes), PTy)); // secondaryTypes const ArrayType* DTy = ArrayType::get(JavaIntrinsics.VTType, @@ -1550,7 +1550,7 @@ Array, ""); Constant* CI = - ConstantExpr::getPtrToInt(GV, Type::getInt32Ty(getGlobalContext())); + ConstantExpr::getPtrToInt(GV, Type::getInt32Ty(getLLVMContext())); CI = ConstantExpr::getAdd(CI, JavaIntrinsics.constantOne); CI = ConstantExpr::getIntToPtr(CI, PTy); IElemts.push_back(CI); @@ -1601,13 +1601,13 @@ std::vector llvmArgs; llvmArgs.push_back(JavaIntrinsics.ptrType); // class loader. - const FunctionType* FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); + const FunctionType* FTy = FunctionType::get(Type::getVoidTy(getLLVMContext()), llvmArgs, false); StaticInitializer = Function::Create(FTy, GlobalValue::InternalLinkage, "Init", getLLVMModule()); llvmArgs.clear(); - FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); + FTy = FunctionType::get(Type::getVoidTy(getLLVMContext()), llvmArgs, false); Callback = Function::Create(FTy, GlobalValue::ExternalLinkage, "staticCallback", getLLVMModule()); @@ -1620,7 +1620,7 @@ "vmjcNativeLoader", getLLVMModule()); llvmArgs.clear(); - FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); + FTy = FunctionType::get(Type::getVoidTy(getLLVMContext()), llvmArgs, false); ObjectPrinter = Function::Create(FTy, GlobalValue::ExternalLinkage, "printJavaObject", getLLVMModule()); @@ -1666,7 +1666,7 @@ Constant* cons = - ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64_t(isolate)), ptrType); @@ -1694,7 +1694,7 @@ llvmArgs.push_back(JavaIntrinsics.ptrType); // class loader llvmArgs.push_back(JavaIntrinsics.JavaCommonClassType); // cl const FunctionType* FTy = - FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); + FunctionType::get(Type::getVoidTy(getLLVMContext()), llvmArgs, false); Function* AddClass = Function::Create(FTy, GlobalValue::ExternalLinkage, "vmjcAddPreCompiledClass", @@ -1707,12 +1707,12 @@ llvmArgs.push_back(PointerType::getUnqual(JavaIntrinsics.JavaClassArrayType)); // name llvmArgs.push_back(JavaIntrinsics.UTF8Type); - FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); + FTy = FunctionType::get(Type::getVoidTy(getLLVMContext()), llvmArgs, false); Function* GetClassArray = Function::Create(FTy, GlobalValue::ExternalLinkage, "vmjcGetClassArray", getLLVMModule()); - BasicBlock* currentBlock = BasicBlock::Create(getGlobalContext(), "enter", + BasicBlock* currentBlock = BasicBlock::Create(getLLVMContext(), "enter", StaticInitializer); Function::arg_iterator loader = StaticInitializer->arg_begin(); @@ -1722,7 +1722,7 @@ llvmArgs.clear(); llvmArgs.push_back(JavaIntrinsics.ptrType); // class loader llvmArgs.push_back(strings.begin()->second->getType()); // val - FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); + FTy = FunctionType::get(Type::getVoidTy(getLLVMContext()), llvmArgs, false); Function* AddString = Function::Create(FTy, GlobalValue::ExternalLinkage, "vmjcAddString", getLLVMModule()); @@ -1743,7 +1743,7 @@ llvmArgs.clear(); llvmArgs.push_back(JavaIntrinsics.ptrType); // class loader llvmArgs.push_back(utf8s.begin()->second->getType()); // val - FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), llvmArgs, false); + FTy = FunctionType::get(Type::getVoidTy(getLLVMContext()), llvmArgs, false); Function* AddUTF8 = Function::Create(FTy, GlobalValue::ExternalLinkage, "vmjcAddUTF8", getLLVMModule()); @@ -1777,7 +1777,7 @@ } - ReturnInst::Create(getGlobalContext(), currentBlock); + ReturnInst::Create(getLLVMContext(), currentBlock); } void JavaAOTCompiler::setNoInline(Class* cl) { @@ -2124,24 +2124,24 @@ // Type Definitions std::vector FuncArgs; - FuncArgs.push_back(Type::getInt32Ty(getGlobalContext())); + FuncArgs.push_back(Type::getInt32Ty(getLLVMContext())); FuncArgs.push_back(PointerType::getUnqual(JavaIntrinsics.ptrType)); - FunctionType* FuncTy = FunctionType::get(Type::getInt32Ty(getGlobalContext()), + FunctionType* FuncTy = FunctionType::get(Type::getInt32Ty(getLLVMContext()), FuncArgs, false); Function* MainFunc = Function::Create(FuncTy, GlobalValue::ExternalLinkage, "main", TheModule); - BasicBlock* currentBlock = BasicBlock::Create(getGlobalContext(), "enter", + BasicBlock* currentBlock = BasicBlock::Create(getLLVMContext(), "enter", MainFunc); GlobalVariable* GvarArrayStr = new GlobalVariable( - *TheModule, ArrayType::get(Type::getInt8Ty(getGlobalContext()), + *TheModule, ArrayType::get(Type::getInt8Ty(getLLVMContext()), strlen(name) + 1), true, GlobalValue::InternalLinkage, 0, "mainClass"); - Constant* NameArray = ConstantArray::get(getGlobalContext(), name, true); + Constant* NameArray = ConstantArray::get(getLLVMContext(), name, true); GvarArrayStr->setInitializer(NameArray); Value* Indices[2] = { JavaIntrinsics.constantZero, JavaIntrinsics.constantZero }; @@ -2154,7 +2154,7 @@ FuncArgs.push_back(Args[2]->getType()); - FuncTy = FunctionType::get(Type::getInt32Ty(getGlobalContext()), FuncArgs, false); + FuncTy = FunctionType::get(Type::getInt32Ty(getLLVMContext()), FuncArgs, false); Function* CalledFunc = Function::Create(FuncTy, GlobalValue::ExternalLinkage, @@ -2162,7 +2162,7 @@ TheModule); Value* res = CallInst::Create(CalledFunc, Args, Args + 3, "", currentBlock); - ReturnInst::Create(getGlobalContext(), res, currentBlock); + ReturnInst::Create(getLLVMContext(), res, currentBlock); } Modified: vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp?rev=96804&r1=96803&r2=96804&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJIT.cpp Mon Feb 22 15:39:15 2010 @@ -160,7 +160,7 @@ res = invoke(func, args, "", currentBlock); } BranchInst::Create(endBlock, currentBlock); - if (retType != Type::getVoidTy(getGlobalContext())) { + if (retType != Type::getVoidTy(*llvmContext)) { node = PHINode::Create(virtualType->getReturnType(), "", endBlock); node->addIncoming(res, currentBlock); } @@ -246,13 +246,13 @@ } } - if (retType != Type::getVoidTy(getGlobalContext())) { + if (retType != Type::getVoidTy(*llvmContext)) { if (retType == intrinsics->JavaObjectType) { JnjvmClassLoader* JCL = compilingClass->classLoader; push(val, false, signature->getReturnType()->findAssocClass(JCL)); } else { push(val, retTypedef->isUnsigned()); - if (retType == Type::getDoubleTy(getGlobalContext()) || retType == Type::getInt64Ty(getGlobalContext())) { + if (retType == Type::getDoubleTy(*llvmContext) || retType == Type::getInt64Ty(*llvmContext)) { push(intrinsics->constantZero, false); } } @@ -307,7 +307,7 @@ if (!natPtr && !TheCompiler->isStaticCompiling()) { currentBlock = createBasicBlock("start"); CallInst::Create(intrinsics->ThrowExceptionFromJITFunction, "", currentBlock); - if (returnType != Type::getVoidTy(getGlobalContext())) + if (returnType != Type::getVoidTy(*llvmContext)) ReturnInst::Create(*llvmContext, Constant::getNullValue(returnType), currentBlock); else ReturnInst::Create(*llvmContext, currentBlock); @@ -332,21 +332,21 @@ currentBlock = createBasicBlock("start"); endBlock = createBasicBlock("end block"); - if (returnType != Type::getVoidTy(getGlobalContext())) { + if (returnType != Type::getVoidTy(*llvmContext)) { endNode = PHINode::Create(returnType, "", endBlock); } // Allocate currentLocalIndexNumber pointer - Value* temp = new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", + Value* temp = new AllocaInst(Type::getInt32Ty(*llvmContext), "", currentBlock); new StoreInst(intrinsics->constantZero, temp, false, currentBlock); // Allocate oldCurrentLocalIndexNumber pointer - Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())), "", + Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(*llvmContext)), "", currentBlock); - Constant* sizeF = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), 2 * sizeof(void*)); - Value* Frame = new AllocaInst(Type::getInt8Ty(getGlobalContext()), sizeF, "", currentBlock); + Constant* sizeF = ConstantInt::get(Type::getInt32Ty(*llvmContext), 2 * sizeof(void*)); + Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "", currentBlock); // Synchronize before saying we're entering native if (isSynchro(compilingMethod->access)) @@ -497,7 +497,7 @@ new StoreInst(result, ResultObject, "", currentBlock); endNode->addIncoming(result, currentBlock); - } else if (returnType != Type::getVoidTy(getGlobalContext())) { + } else if (returnType != Type::getVoidTy(*llvmContext)) { endNode->addIncoming(result, currentBlock); } @@ -514,7 +514,7 @@ if (isSynchro(compilingMethod->access)) endSynchronize(); - if (returnType != Type::getVoidTy(getGlobalContext())) + if (returnType != Type::getVoidTy(*llvmContext)) ReturnInst::Create(*llvmContext, endNode, currentBlock); else ReturnInst::Create(*llvmContext, currentBlock); @@ -819,14 +819,14 @@ Instruction* firstInstruction = firstBB->begin(); for (int i = 0; i < maxLocals; i++) { - intLocals.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstInstruction)); + intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), "", firstInstruction)); new StoreInst(Constant::getNullValue(Type::getInt32Ty(*llvmContext)), intLocals.back(), false, firstInstruction); - doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", + doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), "", firstInstruction)); new StoreInst(Constant::getNullValue(Type::getDoubleTy(*llvmContext)), doubleLocals.back(), false, firstInstruction); - longLocals.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", firstInstruction)); + longLocals.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), "", firstInstruction)); new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, firstInstruction); - floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstInstruction)); + floatLocals.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), "", firstInstruction)); new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, firstInstruction); objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, "", firstInstruction)); @@ -839,22 +839,22 @@ objectStack.push_back(new AllocaInst(intrinsics->JavaObjectType, "", firstInstruction)); addHighLevelType(objectStack.back(), upcalls->OfObject); - intStack.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstInstruction)); - doubleStack.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", + intStack.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), "", firstInstruction)); + doubleStack.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), "", firstInstruction)); - longStack.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", firstInstruction)); - floatStack.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstInstruction)); + longStack.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), "", firstInstruction)); + floatStack.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), "", firstInstruction)); } } else { for (int i = 0; i < maxLocals; i++) { - intLocals.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", firstBB)); + intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), "", firstBB)); new StoreInst(Constant::getNullValue(Type::getInt32Ty(*llvmContext)), intLocals.back(), false, firstBB); - doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", firstBB)); + doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), "", firstBB)); new StoreInst(Constant::getNullValue(Type::getDoubleTy(*llvmContext)), doubleLocals.back(), false, firstBB); - longLocals.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", firstBB)); + longLocals.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), "", firstBB)); new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, firstBB); - floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", firstBB)); + floatLocals.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), "", firstBB)); new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, firstBB); objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, "", firstBB)); @@ -867,10 +867,10 @@ objectStack.push_back(new AllocaInst(intrinsics->JavaObjectType, "", firstBB)); addHighLevelType(objectStack.back(), upcalls->OfObject); - 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)); + intStack.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), "", firstBB)); + doubleStack.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), "", firstBB)); + longStack.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), "", firstBB)); + floatStack.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), "", firstBB)); } } @@ -901,21 +901,21 @@ const Typedef* cur = arguments[type]; const Type* curType = (*i)->getType(); - if (curType == Type::getInt64Ty(getGlobalContext())){ + if (curType == Type::getInt64Ty(*llvmContext)){ new StoreInst(*i, longLocals[index], false, currentBlock); ++index; } else if (cur->isUnsigned()) { - new StoreInst(new ZExtInst(*i, Type::getInt32Ty(getGlobalContext()), "", currentBlock), + new StoreInst(new ZExtInst(*i, Type::getInt32Ty(*llvmContext), "", currentBlock), intLocals[index], false, currentBlock); - } else if (curType == Type::getInt8Ty(getGlobalContext()) || curType == Type::getInt16Ty(getGlobalContext())) { - new StoreInst(new SExtInst(*i, Type::getInt32Ty(getGlobalContext()), "", currentBlock), + } else if (curType == Type::getInt8Ty(*llvmContext) || curType == Type::getInt16Ty(*llvmContext)) { + new StoreInst(new SExtInst(*i, Type::getInt32Ty(*llvmContext), "", currentBlock), intLocals[index], false, currentBlock); - } else if (curType == Type::getInt32Ty(getGlobalContext())) { + } else if (curType == Type::getInt32Ty(*llvmContext)) { new StoreInst(*i, intLocals[index], false, currentBlock); - } else if (curType == Type::getDoubleTy(getGlobalContext())) { + } else if (curType == Type::getDoubleTy(*llvmContext)) { new StoreInst(*i, doubleLocals[index], false, currentBlock); ++index; - } else if (curType == Type::getFloatTy(getGlobalContext())) { + } else if (curType == Type::getFloatTy(*llvmContext)) { new StoreInst(*i, floatLocals[index], false, currentBlock); } else { Instruction* V = new StoreInst(*i, objectLocals[index], false, currentBlock); @@ -944,7 +944,7 @@ exploreOpcodes(&compilingClass->bytes->elements[start], codeLen); - if (returnType != Type::getVoidTy(getGlobalContext())) { + if (returnType != Type::getVoidTy(*llvmContext)) { endNode = PHINode::Create(returnType, "", endBlock); } @@ -1028,13 +1028,13 @@ for (int i = 0; i < maxLocals; i++) { - intLocals.push_back(new AllocaInst(Type::getInt32Ty(getGlobalContext()), "", currentBlock)); + intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), "", currentBlock)); new StoreInst(Constant::getNullValue(Type::getInt32Ty(*llvmContext)), intLocals.back(), false, currentBlock); - doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(getGlobalContext()), "", currentBlock)); + doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), "", currentBlock)); new StoreInst(Constant::getNullValue(Type::getDoubleTy(*llvmContext)), doubleLocals.back(), false, currentBlock); - longLocals.push_back(new AllocaInst(Type::getInt64Ty(getGlobalContext()), "", currentBlock)); + longLocals.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), "", currentBlock)); new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, currentBlock); - floatLocals.push_back(new AllocaInst(Type::getFloatTy(getGlobalContext()), "", currentBlock)); + floatLocals.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), "", currentBlock)); new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, currentBlock); objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, "", currentBlock)); @@ -1047,10 +1047,10 @@ objectStack.push_back(new AllocaInst(intrinsics->JavaObjectType, "", currentBlock)); addHighLevelType(objectStack.back(), upcalls->OfObject); - 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)); + intStack.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), "", currentBlock)); + doubleStack.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), "", currentBlock)); + longStack.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), "", currentBlock)); + floatStack.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), "", currentBlock)); } uint32 index = 0; @@ -1078,21 +1078,21 @@ const Typedef* cur = arguments[type]; const llvm::Type* curType = i->getType(); - if (curType == Type::getInt64Ty(getGlobalContext())){ + if (curType == Type::getInt64Ty(*llvmContext)){ new StoreInst(i, longLocals[index], false, currentBlock); ++index; } else if (cur->isUnsigned()) { - new StoreInst(new ZExtInst(i, Type::getInt32Ty(getGlobalContext()), "", currentBlock), + new StoreInst(new ZExtInst(i, Type::getInt32Ty(*llvmContext), "", currentBlock), intLocals[index], false, currentBlock); - } else if (curType == Type::getInt8Ty(getGlobalContext()) || curType == Type::getInt16Ty(getGlobalContext())) { - new StoreInst(new SExtInst(i, Type::getInt32Ty(getGlobalContext()), "", currentBlock), + } else if (curType == Type::getInt8Ty(*llvmContext) || curType == Type::getInt16Ty(*llvmContext)) { + new StoreInst(new SExtInst(i, Type::getInt32Ty(*llvmContext), "", currentBlock), intLocals[index], false, currentBlock); - } else if (curType == Type::getInt32Ty(getGlobalContext())) { + } else if (curType == Type::getInt32Ty(*llvmContext)) { new StoreInst(i, intLocals[index], false, currentBlock); - } else if (curType == Type::getDoubleTy(getGlobalContext())) { + } else if (curType == Type::getDoubleTy(*llvmContext)) { new StoreInst(i, doubleLocals[index], false, currentBlock); ++index; - } else if (curType == Type::getFloatTy(getGlobalContext())) { + } else if (curType == Type::getFloatTy(*llvmContext)) { new StoreInst(i, floatLocals[index], false, currentBlock); } else { Instruction* V = new StoreInst(i, objectLocals[index], false, currentBlock); @@ -1181,7 +1181,7 @@ endBlock = createBasicBlock("end"); - if (returnType != Type::getVoidTy(getGlobalContext())) { + if (returnType != Type::getVoidTy(*llvmContext)) { endNode = llvm::PHINode::Create(returnType, "", endBlock); } @@ -1240,7 +1240,7 @@ // not return. pred_iterator PI = pred_begin(endBlock); pred_iterator PE = pred_end(endBlock); - if (PI == PE && returnType != Type::getVoidTy(getGlobalContext())) { + if (PI == PE && returnType != Type::getVoidTy(*llvmContext)) { Instruction* I = currentBlock->getTerminator(); if (isa(I)) { @@ -1294,7 +1294,7 @@ if (PI == PE) { currentBlock->eraseFromParent(); } else { - if (returnType != Type::getVoidTy(getGlobalContext())) + if (returnType != Type::getVoidTy(*llvmContext)) ReturnInst::Create(*llvmContext, endNode, currentBlock); else ReturnInst::Create(*llvmContext, currentBlock); @@ -1396,16 +1396,16 @@ } #endif } else if (type == JavaConstantPool::ConstantLong) { - push(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), ctpInfo->LongAt(index)), + push(ConstantInt::get(Type::getInt64Ty(*llvmContext), ctpInfo->LongAt(index)), false); } else if (type == JavaConstantPool::ConstantDouble) { - push(ConstantFP::get(Type::getDoubleTy(getGlobalContext()), ctpInfo->DoubleAt(index)), + push(ConstantFP::get(Type::getDoubleTy(*llvmContext), ctpInfo->DoubleAt(index)), false); } else if (type == JavaConstantPool::ConstantInteger) { - push(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), ctpInfo->IntegerAt(index)), + push(ConstantInt::get(Type::getInt32Ty(*llvmContext), ctpInfo->IntegerAt(index)), false); } else if (type == JavaConstantPool::ConstantFloat) { - push(ConstantFP::get(Type::getFloatTy(getGlobalContext()), ctpInfo->FloatAt(index)), + push(ConstantFP::get(Type::getFloatTy(*llvmContext), ctpInfo->FloatAt(index)), false); } else if (type == JavaConstantPool::ConstantClass) { UserCommonClass* cl = 0; @@ -1444,8 +1444,8 @@ const Type* arrayType, bool verif) { JITVerifyNull(obj); - if (index->getType() != Type::getInt32Ty(getGlobalContext())) { - index = new SExtInst(index, Type::getInt32Ty(getGlobalContext()), "", currentBlock); + if (index->getType() != Type::getInt32Ty(*llvmContext)) { + index = new SExtInst(index, Type::getInt32Ty(*llvmContext), "", currentBlock); } if (TheCompiler->hasExceptionsEnabled()) { @@ -1493,7 +1493,7 @@ #endif for (sint32 i = start; i >= 0; --i) { it--; - if (it->get() == Type::getInt64Ty(getGlobalContext()) || it->get() == Type::getDoubleTy(getGlobalContext())) { + if (it->get() == Type::getInt64Ty(*llvmContext) || it->get() == Type::getDoubleTy(*llvmContext)) { pop(); } Value* tmp = pop(); @@ -1517,7 +1517,7 @@ JnjvmBootstrapLoader* loader = compilingClass->classLoader->bootstrapLoader; if (name->equals(loader->abs)) { const Type* Ty = args[0]->getType(); - if (Ty == Type::getInt32Ty(getGlobalContext())) { + if (Ty == Type::getInt32Ty(*llvmContext)) { Constant* const_int32_9 = intrinsics->constantZero; Constant* const_int32_10 = intrinsics->constantMinusOne; BinaryOperator* int32_tmpneg = @@ -1528,7 +1528,7 @@ "abscond"); return llvm::SelectInst::Create(int1_abscond, args[0], int32_tmpneg, "abs", currentBlock); - } else if (Ty == Type::getInt64Ty(getGlobalContext())) { + } else if (Ty == Type::getInt64Ty(*llvmContext)) { Constant* const_int64_9 = intrinsics->constantLongZero; Constant* const_int64_10 = intrinsics->constantLongMinusOne; @@ -1541,10 +1541,10 @@ return llvm::SelectInst::Create(int1_abscond, args[0], int64_tmpneg, "abs", currentBlock); - } else if (Ty == Type::getFloatTy(getGlobalContext())) { + } else if (Ty == Type::getFloatTy(*llvmContext)) { return llvm::CallInst::Create(intrinsics->func_llvm_fabs_f32, args[0], "tmp1", currentBlock); - } else if (Ty == Type::getDoubleTy(getGlobalContext())) { + } else if (Ty == Type::getDoubleTy(*llvmContext)) { return llvm::CallInst::Create(intrinsics->func_llvm_fabs_f64, args[0], "tmp1", currentBlock); } @@ -1676,7 +1676,7 @@ BranchInst::Create(falseCl, trueCl, test, currentBlock); std::vector Args; Args.push_back(ctpCache); - Args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), index)); + Args.push_back(ConstantInt::get(Type::getInt32Ty(*llvmContext), index)); Args.push_back(GV); res = CallInst::Create(intrinsics->SpecialCtpLookupFunction, Args.begin(), Args.end(), "", falseCl); @@ -1711,14 +1711,14 @@ } const llvm::Type* retType = virtualType->getReturnType(); - if (retType != Type::getVoidTy(getGlobalContext())) { + if (retType != Type::getVoidTy(*llvmContext)) { if (retType == intrinsics->JavaObjectType) { JnjvmClassLoader* JCL = compilingClass->classLoader; push(val, false, signature->getReturnType()->findAssocClass(JCL)); } else { push(val, signature->getReturnType()->isUnsigned()); - if (retType == Type::getDoubleTy(getGlobalContext()) || - retType == Type::getInt64Ty(getGlobalContext())) { + if (retType == Type::getDoubleTy(*llvmContext) || + retType == Type::getInt64Ty(*llvmContext)) { push(intrinsics->constantZero, false); } } @@ -1792,14 +1792,14 @@ } const llvm::Type* retType = staticType->getReturnType(); - if (retType != Type::getVoidTy(getGlobalContext())) { + if (retType != Type::getVoidTy(*llvmContext)) { if (retType == intrinsics->JavaObjectType) { JnjvmClassLoader* JCL = compilingClass->classLoader; push(val, false, signature->getReturnType()->findAssocClass(JCL)); } else { push(val, signature->getReturnType()->isUnsigned()); - if (retType == Type::getDoubleTy(getGlobalContext()) || - retType == Type::getInt64Ty(getGlobalContext())) { + if (retType == Type::getDoubleTy(*llvmContext) || + retType == Type::getInt64Ty(*llvmContext)) { push(intrinsics->constantZero, false); } } @@ -1827,7 +1827,7 @@ Args.push_back(resolver); Args.push_back(CTP); Args.push_back(Cl); - Args.push_back(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), index)); + Args.push_back(ConstantInt::get(Type::getInt32Ty(*llvmContext), index)); if (additionalArg) Args.push_back(additionalArg); Value* res = 0; @@ -1841,8 +1841,8 @@ const Type* realType = intrinsics->GetConstantPoolAtFunction->getReturnType(); - if (returnType == Type::getInt32Ty(getGlobalContext())) { - return new PtrToIntInst(res, Type::getInt32Ty(getGlobalContext()), "", currentBlock); + if (returnType == Type::getInt32Ty(*llvmContext)) { + return new PtrToIntInst(res, Type::getInt32Ty(*llvmContext), "", currentBlock); } else if (returnType != realType) { return new BitCastInst(res, returnType, "", currentBlock); } @@ -1999,7 +1999,7 @@ if (stat) returnType = intrinsics->ptrType; else - returnType = Type::getInt32Ty(getGlobalContext()); + returnType = Type::getInt32Ty(*llvmContext); Value* ptr = getConstantPoolAt(index, func, returnType, 0, true); if (!stat) { @@ -2045,7 +2045,7 @@ LLVMAssessorInfo& LAI = TheCompiler->getTypedefInfo(sign); const Type* type = LAI.llvmType; - if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) { + if (type == Type::getInt64Ty(*llvmContext) || type == Type::getDoubleTy(*llvmContext)) { val = pop(); } @@ -2077,28 +2077,28 @@ const PrimitiveTypedef* prim = (PrimitiveTypedef*)sign; if (prim->isInt()) { sint32 val = field->getInt32Field(Obj); - push(ConstantInt::get(Type::getInt32Ty(getGlobalContext()), val), false); + push(ConstantInt::get(Type::getInt32Ty(*llvmContext), val), false); } else if (prim->isByte()) { sint8 val = (sint8)field->getInt8Field(Obj); - push(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), val), false); + push(ConstantInt::get(Type::getInt8Ty(*llvmContext), val), false); } else if (prim->isBool()) { uint8 val = (uint8)field->getInt8Field(Obj); - push(ConstantInt::get(Type::getInt8Ty(getGlobalContext()), val), true); + push(ConstantInt::get(Type::getInt8Ty(*llvmContext), val), true); } else if (prim->isShort()) { sint16 val = (sint16)field->getInt16Field(Obj); - push(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), val), false); + push(ConstantInt::get(Type::getInt16Ty(*llvmContext), val), false); } else if (prim->isChar()) { uint16 val = (uint16)field->getInt16Field(Obj); - push(ConstantInt::get(Type::getInt16Ty(getGlobalContext()), val), true); + push(ConstantInt::get(Type::getInt16Ty(*llvmContext), val), true); } else if (prim->isLong()) { sint64 val = (sint64)field->getLongField(Obj); - push(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), val), false); + push(ConstantInt::get(Type::getInt64Ty(*llvmContext), val), false); } else if (prim->isFloat()) { float val = (float)field->getFloatField(Obj); - push(ConstantFP::get(Type::getFloatTy(getGlobalContext()), val), false); + push(ConstantFP::get(Type::getFloatTy(*llvmContext), val), false); } else if (prim->isDouble()) { double val = (double)field->getDoubleField(Obj); - push(ConstantFP::get(Type::getDoubleTy(getGlobalContext()), val), false); + push(ConstantFP::get(Type::getDoubleTy(*llvmContext), val), false); } else { abort(); } @@ -2126,7 +2126,8 @@ CommonClass* cl = sign->findAssocClass(JCL); push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned(), cl); } - if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) { + if (type == Type::getInt64Ty(*llvmContext) || + type == Type::getDoubleTy(*llvmContext)) { push(intrinsics->constantZero, false); } } @@ -2137,7 +2138,8 @@ LLVMAssessorInfo& LAI = TheCompiler->getTypedefInfo(sign); const Type* type = LAI.llvmType; - if (type == Type::getInt64Ty(getGlobalContext()) || type == Type::getDoubleTy(getGlobalContext())) { + if (type == Type::getInt64Ty(*llvmContext) || + type == Type::getDoubleTy(*llvmContext)) { val = pop(); } @@ -2202,8 +2204,8 @@ } if (!final) push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned(), cl); - if (type == Type::getInt64Ty(getGlobalContext()) || - type == Type::getDoubleTy(getGlobalContext())) { + if (type == Type::getInt64Ty(*llvmContext) || + type == Type::getDoubleTy(*llvmContext)) { push(intrinsics->constantZero, false); } } @@ -2228,7 +2230,7 @@ const llvm::Type* retType = virtualType->getReturnType(); BasicBlock* endBlock = createBasicBlock("end interface invoke"); PHINode * node = 0; - if (retType != Type::getVoidTy(getGlobalContext())) { + if (retType != Type::getVoidTy(*llvmContext)) { node = PHINode::Create(retType, "", endBlock); } @@ -2258,7 +2260,7 @@ currentBlock); uint32_t tableIndex = InterfaceMethodTable::getIndex(name, signature->keyName); - Constant* Index = ConstantInt::get(Type::getInt32Ty(getGlobalContext()), + Constant* Index = ConstantInt::get(Type::getInt32Ty(*llvmContext), tableIndex); Value* indices[2] = { intrinsics->constantZero, Index }; @@ -2346,8 +2348,8 @@ push(node, false, signature->getReturnType()->findAssocClass(JCL)); } else { push(node, signature->getReturnType()->isUnsigned()); - if (retType == Type::getDoubleTy(getGlobalContext()) || - retType == Type::getInt64Ty(getGlobalContext())) { + if (retType == Type::getDoubleTy(*llvmContext) || + retType == Type::getInt64Ty(*llvmContext)) { push(intrinsics->constantZero, false); } } @@ -2404,7 +2406,7 @@ LoadInst* int32_22 = new LoadInst(ptr_21, "", false, label_bb); Value* cmp = BinaryOperator::CreateAnd(int32_22, intrinsics->IsArrayConstant, "", label_bb); - Value* zero = ConstantInt::get(Type::getInt16Ty(getGlobalContext()), 0); + Value* zero = ConstantInt::get(Type::getInt16Ty(*llvmContext), 0); ICmpInst* int1_23 = new ICmpInst(*label_bb, ICmpInst::ICMP_NE, cmp, zero, ""); BranchInst::Create(label_bb4, label_bb2, int1_23, label_bb); @@ -2554,8 +2556,8 @@ // Block bb11 (label_bb11) currentBlock = label_bb11; - Argument* fwdref_39 = new Argument(Type::getInt32Ty(getGlobalContext())); - PHINode* int32_i_016 = PHINode::Create(Type::getInt32Ty(getGlobalContext()), + Argument* fwdref_39 = new Argument(Type::getInt32Ty(*llvmContext)); + PHINode* int32_i_016 = PHINode::Create(Type::getInt32Ty(*llvmContext), "i.016", label_bb11); int32_i_016->reserveOperandSpace(2); int32_i_016->addIncoming(fwdref_39, label_bb11); Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=96804&r1=96803&r2=96804&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Mon Feb 22 15:39:15 2010 @@ -130,7 +130,7 @@ const llvm::Type* Ty = classDef->isClass() ? JavaIntrinsics.JavaClassType : JavaIntrinsics.JavaCommonClassType; - ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64_t(classDef)); return ConstantExpr::getIntToPtr(CI, Ty); } @@ -138,20 +138,20 @@ Constant* JavaJITCompiler::getConstantPool(JavaConstantPool* ctp) { void* ptr = ctp->ctpRes; assert(ptr && "No constant pool found"); - ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64_t(ptr)); return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.ConstantPoolType); } Constant* JavaJITCompiler::getMethodInClass(JavaMethod* meth) { - ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), (int64_t)meth); return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaMethodType); } Constant* JavaJITCompiler::getString(JavaString* str) { assert(str && "No string given"); - ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64(str)); return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaObjectType); } @@ -159,7 +159,7 @@ Constant* JavaJITCompiler::getStringPtr(JavaString** str) { assert(str && "No string given"); const llvm::Type* Ty = PointerType::getUnqual(JavaIntrinsics.JavaObjectType); - ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64(str)); return ConstantExpr::getIntToPtr(CI, Ty); } @@ -167,7 +167,7 @@ Constant* JavaJITCompiler::getJavaClass(CommonClass* cl) { JavaObject* obj = cl->getClassDelegatee(JavaThread::get()->getJVM()); assert(obj && "Delegatee not created"); - Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + Constant* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64(obj)); return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaObjectType); } @@ -176,7 +176,7 @@ Jnjvm* vm = JavaThread::get()->getJVM(); JavaObject* const* obj = cl->getClassDelegateePtr(vm); assert(obj && "Delegatee not created"); - Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + Constant* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64(obj)); const Type* Ty = PointerType::getUnqual(JavaIntrinsics.JavaObjectType); return ConstantExpr::getIntToPtr(CI, Ty); @@ -192,7 +192,7 @@ } Constant* JavaJITCompiler::getFinalObject(JavaObject* obj, CommonClass* cl) { - Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + Constant* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64(obj)); return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.JavaObjectType); } @@ -212,7 +212,7 @@ } classDef->release(); } - Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + Constant* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), (uint64_t(obj))); return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.ptrType); } @@ -223,7 +223,7 @@ LCI->getVirtualType(); } - ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64_t(VT)); return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.VTType); } @@ -234,7 +234,7 @@ assert(ptr && "No native function given"); - Constant* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + Constant* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64_t(ptr)); return ConstantExpr::getIntToPtr(CI, valPtrType); } @@ -262,7 +262,7 @@ #ifdef SERVICE Value* JavaJITCompiler::getIsolate(Jnjvm* isolate, Value* Where) { - ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), + ConstantInt* CI = ConstantInt::get(Type::getInt64Ty(getLLVMContext()), uint64_t(isolate)); return ConstantExpr::getIntToPtr(CI, JavaIntrinsics.ptrType); } Modified: vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=96804&r1=96803&r2=96804&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITOpcodes.cpp Mon Feb 22 15:39:15 2010 @@ -1996,7 +1996,7 @@ args, args + 2, "", currentBlock); #endif - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[charId]; + LLVMAssessorInfo& LAI = TheCompiler->AssessorInfo[charId]; sizeElement = ConstantInt::get(Type::getInt32Ty(*llvmContext), LAI.logSizeInBytesConstant); if (TheCompiler->isStaticCompiling() && Modified: vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp?rev=96804&r1=96803&r2=96804&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaLLVMCompiler.cpp Mon Feb 22 15:39:15 2010 @@ -34,6 +34,7 @@ #else cooperativeGC = false; #endif + initialiseAssessorInfo(); } void JavaLLVMCompiler::resolveVirtualClass(Class* cl) { Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=96804&r1=96803&r2=96804&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Mon Feb 22 15:39:15 2010 @@ -55,7 +55,7 @@ JavaField& field = classDef->virtualFields[i]; field.num = i + 1; Typedef* type = field.getSignature(); - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(type); fields.push_back(LAI.llvmType); } @@ -104,7 +104,7 @@ JavaField& field = classDef->staticFields[i]; field.num = i; Typedef* type = field.getSignature(); - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(type); fields.push_back(LAI.llvmType); } @@ -248,16 +248,15 @@ for (uint32 i = 0; i < size; ++i) { Typedef* type = arguments[i]; - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(type); llvmArgs.push_back(LAI.llvmType); } #if defined(ISOLATE_SHARING) - llvmArgs.push_back(J3Intrinsics::ConstantPoolType); // cached constant pool + llvmArgs.push_back(Mod->getIntrinsics()->ConstantPoolType); #endif - LLVMAssessorInfo& LAI = - JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(signature->getReturnType()); virtualType = FunctionType::get(LAI.llvmType, llvmArgs, false); mvm::MvmModule::unprotectIR(); } @@ -271,10 +270,12 @@ std::vector llvmArgs; uint32 size = signature->nbArguments; Typedef* const* arguments = signature->getArgumentsType(); + JavaLLVMCompiler* Mod = + (JavaLLVMCompiler*)signature->initialLoader->getCompiler(); for (uint32 i = 0; i < size; ++i) { Typedef* type = arguments[i]; - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(type); llvmArgs.push_back(LAI.llvmType); } @@ -283,8 +284,7 @@ llvmArgs.push_back(Mod->getIntrinsics()->ConstantPoolType); #endif - LLVMAssessorInfo& LAI = - JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(signature->getReturnType()); staticType = FunctionType::get(LAI.llvmType, llvmArgs, false); mvm::MvmModule::unprotectIR(); } @@ -309,7 +309,7 @@ for (uint32 i = 0; i < size; ++i) { Typedef* type = arguments[i]; - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(type); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(type); const llvm::Type* Ty = LAI.llvmType; if (Ty == Mod->getIntrinsics()->JavaObjectType) { llvmArgs.push_back(LAI.llvmTypePtr); @@ -323,8 +323,7 @@ llvmArgs.push_back(Mod->getIntrinsics()->ConstantPoolType); #endif - LLVMAssessorInfo& LAI = - JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(signature->getReturnType()); const llvm::Type* RetType = LAI.llvmType == Mod->getIntrinsics()->JavaObjectType ? LAI.llvmTypePtr : LAI.llvmType; @@ -378,7 +377,7 @@ Typedef* const* arguments = signature->getArgumentsType(); for (uint32 i = 0; i < signature->nbArguments; ++i) { - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(arguments[i]); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(arguments[i]); Value* arg = new LoadInst(ptr, "", currentBlock); if (arguments[i]->isReference()) { @@ -402,7 +401,7 @@ currentBlock = endBlock; arg = node; } else if (arguments[i]->isFloat()) { - arg = new TruncInst(arg, LLVMAssessorInfo::AssessorInfo[I_INT].llvmType, + arg = new TruncInst(arg, Mod->AssessorInfo[I_INT].llvmType, "", currentBlock); arg = new BitCastInst(arg, LAI.llvmType, "", currentBlock); } else if (arguments[i]->isDouble()) { @@ -468,7 +467,7 @@ Typedef* const* arguments = signature->getArgumentsType(); for (uint32 i = 0; i < signature->nbArguments; ++i) { - LLVMAssessorInfo& LAI = JavaLLVMCompiler::getTypedefInfo(arguments[i]); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(arguments[i]); Value* arg = new VAArgInst(ap, LAI.llvmType, "", currentBlock); if (arguments[i]->isReference()) { arg = new IntToPtrInst(arg, Intrinsics.JavaObjectType, "", currentBlock); @@ -621,9 +620,8 @@ Args.push_back(Mod->getIntrinsics()->ConstantPoolType); // ctp Args.push_back(getVirtualPtrType()); Args.push_back(Mod->getIntrinsics()->JavaObjectType); - Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr); - LLVMAssessorInfo& LAI = - JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); + Args.push_back(Mod->AssessorInfo[I_LONG].llvmTypePtr); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(signature->getReturnType()); virtualBufType = FunctionType::get(LAI.llvmType, Args, false); mvm::MvmModule::unprotectIR(); } @@ -639,9 +637,8 @@ std::vector Args; Args.push_back(Mod->getIntrinsics()->ConstantPoolType); // ctp Args.push_back(getStaticPtrType()); - Args.push_back(LLVMAssessorInfo::AssessorInfo[I_LONG].llvmTypePtr); - LLVMAssessorInfo& LAI = - JavaLLVMCompiler::getTypedefInfo(signature->getReturnType()); + Args.push_back(Mod->AssessorInfo[I_LONG].llvmTypePtr); + LLVMAssessorInfo& LAI = Mod->getTypedefInfo(signature->getReturnType()); staticBufType = FunctionType::get(LAI.llvmType, Args, false); mvm::MvmModule::unprotectIR(); } @@ -767,49 +764,49 @@ return virtualStubFunction; } -void LLVMAssessorInfo::initialise() { - AssessorInfo[I_VOID].llvmType = Type::getVoidTy(getGlobalContext()); +void JavaLLVMCompiler::initialiseAssessorInfo() { + AssessorInfo[I_VOID].llvmType = Type::getVoidTy(getLLVMContext()); AssessorInfo[I_VOID].llvmTypePtr = 0; AssessorInfo[I_VOID].logSizeInBytesConstant = 0; - AssessorInfo[I_BOOL].llvmType = Type::getInt8Ty(getGlobalContext()); + AssessorInfo[I_BOOL].llvmType = Type::getInt8Ty(getLLVMContext()); AssessorInfo[I_BOOL].llvmTypePtr = - PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())); + PointerType::getUnqual(Type::getInt8Ty(getLLVMContext())); AssessorInfo[I_BOOL].logSizeInBytesConstant = 0; - AssessorInfo[I_BYTE].llvmType = Type::getInt8Ty(getGlobalContext()); + AssessorInfo[I_BYTE].llvmType = Type::getInt8Ty(getLLVMContext()); AssessorInfo[I_BYTE].llvmTypePtr = - PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())); + PointerType::getUnqual(Type::getInt8Ty(getLLVMContext())); AssessorInfo[I_BYTE].logSizeInBytesConstant = 0; - AssessorInfo[I_SHORT].llvmType = Type::getInt16Ty(getGlobalContext()); + AssessorInfo[I_SHORT].llvmType = Type::getInt16Ty(getLLVMContext()); AssessorInfo[I_SHORT].llvmTypePtr = - PointerType::getUnqual(Type::getInt16Ty(getGlobalContext())); + PointerType::getUnqual(Type::getInt16Ty(getLLVMContext())); AssessorInfo[I_SHORT].logSizeInBytesConstant = 1; - AssessorInfo[I_CHAR].llvmType = Type::getInt16Ty(getGlobalContext()); + AssessorInfo[I_CHAR].llvmType = Type::getInt16Ty(getLLVMContext()); AssessorInfo[I_CHAR].llvmTypePtr = - PointerType::getUnqual(Type::getInt16Ty(getGlobalContext())); + PointerType::getUnqual(Type::getInt16Ty(getLLVMContext())); AssessorInfo[I_CHAR].logSizeInBytesConstant = 1; - AssessorInfo[I_INT].llvmType = Type::getInt32Ty(getGlobalContext()); + AssessorInfo[I_INT].llvmType = Type::getInt32Ty(getLLVMContext()); AssessorInfo[I_INT].llvmTypePtr = - PointerType::getUnqual(Type::getInt32Ty(getGlobalContext())); + PointerType::getUnqual(Type::getInt32Ty(getLLVMContext())); AssessorInfo[I_INT].logSizeInBytesConstant = 2; - AssessorInfo[I_FLOAT].llvmType = Type::getFloatTy(getGlobalContext()); + AssessorInfo[I_FLOAT].llvmType = Type::getFloatTy(getLLVMContext()); AssessorInfo[I_FLOAT].llvmTypePtr = - PointerType::getUnqual(Type::getFloatTy(getGlobalContext())); + PointerType::getUnqual(Type::getFloatTy(getLLVMContext())); AssessorInfo[I_FLOAT].logSizeInBytesConstant = 2; - AssessorInfo[I_LONG].llvmType = Type::getInt64Ty(getGlobalContext()); + AssessorInfo[I_LONG].llvmType = Type::getInt64Ty(getLLVMContext()); AssessorInfo[I_LONG].llvmTypePtr = - PointerType::getUnqual(Type::getInt64Ty(getGlobalContext())); + PointerType::getUnqual(Type::getInt64Ty(getLLVMContext())); AssessorInfo[I_LONG].logSizeInBytesConstant = 3; - AssessorInfo[I_DOUBLE].llvmType = Type::getDoubleTy(getGlobalContext()); + AssessorInfo[I_DOUBLE].llvmType = Type::getDoubleTy(getLLVMContext()); AssessorInfo[I_DOUBLE].llvmTypePtr = - PointerType::getUnqual(Type::getDoubleTy(getGlobalContext())); + PointerType::getUnqual(Type::getDoubleTy(getLLVMContext())); AssessorInfo[I_DOUBLE].logSizeInBytesConstant = 3; AssessorInfo[I_TAB].llvmType = PointerType::getUnqual( @@ -823,10 +820,8 @@ AssessorInfo[I_REF].logSizeInBytesConstant = sizeof(JavaObject*) == 8 ? 3 : 2; } -std::map LLVMAssessorInfo::AssessorInfo; - LLVMAssessorInfo& JavaLLVMCompiler::getTypedefInfo(const Typedef* type) { - return LLVMAssessorInfo::AssessorInfo[type->getKey()->elements[0]]; + return AssessorInfo[type->getKey()->elements[0]]; } LLVMSignatureInfo* JavaLLVMCompiler::getSignatureInfo(Signdef* sign) { From nicolas.geoffray at lip6.fr Tue Feb 23 22:54:21 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Wed, 24 Feb 2010 06:54:21 -0000 Subject: [vmkit-commits] [vmkit] r97026 - /vmkit/trunk/lib/N3/PNetLib/PNetString.cpp Message-ID: <20100224065421.0A18D2A6C12C@llvm.org> Author: geoffray Date: Wed Feb 24 00:54:20 2010 New Revision: 97026 URL: http://llvm.org/viewvc/llvm-project?rev=97026&view=rev Log: ptrType does not exist in MvmModule anymore. Modified: vmkit/trunk/lib/N3/PNetLib/PNetString.cpp Modified: vmkit/trunk/lib/N3/PNetLib/PNetString.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/N3/PNetLib/PNetString.cpp?rev=97026&r1=97025&r2=97026&view=diff ============================================================================== --- vmkit/trunk/lib/N3/PNetLib/PNetString.cpp (original) +++ vmkit/trunk/lib/N3/PNetLib/PNetString.cpp Wed Feb 24 00:54:20 2010 @@ -44,7 +44,7 @@ if (!str->_llvmVar) { N3* vm = VMThread::get()->getVM(); if (!str->_llvmVar) { - const Type* pty = mvm::MvmModule::ptrType; + const Type* pty = PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())); Constant* cons = ConstantExpr::getIntToPtr(ConstantInt::get(Type::getInt64Ty(getGlobalContext()), uint64_t (self)), pty); From nicolas.geoffray at lip6.fr Sat Feb 27 02:50:19 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 27 Feb 2010 10:50:19 -0000 Subject: [vmkit-commits] [vmkit] r97321 - /vmkit/trunk/Makefile.rules Message-ID: <20100227105019.A80E12A6C12C@llvm.org> Author: geoffray Date: Sat Feb 27 04:50:19 2010 New Revision: 97321 URL: http://llvm.org/viewvc/llvm-project?rev=97321&view=rev Log: LLVM change: generate a .bc library with llvm-ld. Modified: vmkit/trunk/Makefile.rules Modified: vmkit/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/Makefile.rules?rev=97321&r1=97320&r2=97321&view=diff ============================================================================== --- vmkit/trunk/Makefile.rules (original) +++ vmkit/trunk/Makefile.rules Sat Feb 27 04:50:19 2010 @@ -107,7 +107,7 @@ $(MODULESNAME).bc : $(ProjLibsPaths) $(Echo) Building $(BuildMode) Bytecode Module $(notdir $@) - $(Verb) $(LLVMLD) -L$(CFERuntimeLibDir) -r -o $@ $(ProjLibsPaths) + $(Verb) $(LLVMLD) -link-as-library -o $@ $(ProjLibsPaths) $(MODULESNAME).s : $(MODULESNAME).bc $(Echo) Building $(BuildMode) Assembly file $(notdir $@) From nicolas.geoffray at lip6.fr Sat Feb 27 06:22:35 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 27 Feb 2010 14:22:35 -0000 Subject: [vmkit-commits] [vmkit] r97325 - in /vmkit/trunk: include/j3/JavaAOTCompiler.h include/j3/JavaCompiler.h include/j3/JavaLLVMCompiler.h include/j3/LLVMInfo.h lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/LLVMInfo.cpp lib/J3/Compiler/LLVMMaterializer.cpp lib/Mvm/Compiler/JIT.cpp Message-ID: <20100227142235.F157D2A6C12C@llvm.org> Author: geoffray Date: Sat Feb 27 08:22:35 2010 New Revision: 97325 URL: http://llvm.org/viewvc/llvm-project?rev=97325&view=rev Log: Remove static methods and put all local to a compiler. Modified: vmkit/trunk/include/j3/JavaAOTCompiler.h vmkit/trunk/include/j3/JavaCompiler.h vmkit/trunk/include/j3/JavaLLVMCompiler.h vmkit/trunk/include/j3/LLVMInfo.h vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Modified: vmkit/trunk/include/j3/JavaAOTCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaAOTCompiler.h?rev=97325&r1=97324&r2=97325&view=diff ============================================================================== --- vmkit/trunk/include/j3/JavaAOTCompiler.h (original) +++ vmkit/trunk/include/j3/JavaAOTCompiler.h Sat Feb 27 08:22:35 2010 @@ -174,7 +174,7 @@ void CreateStaticInitializer(); - static void setNoInline(Class* cl); + void setNoInline(Class* cl); void printStats(); Modified: vmkit/trunk/include/j3/JavaCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaCompiler.h?rev=97325&r1=97324&r2=97325&view=diff ============================================================================== --- vmkit/trunk/include/j3/JavaCompiler.h (original) +++ vmkit/trunk/include/j3/JavaCompiler.h Sat Feb 27 08:22:35 2010 @@ -16,6 +16,7 @@ #include #include "mvm/GC/GC.h" +#include "mvm/Allocator.h" namespace mvm { class UTF8; @@ -27,11 +28,14 @@ class CommonClass; class JavaMethod; class JavaVirtualTable; +class JnjvmClassLoader; class Signdef; class JavaCompiler { public: + mvm::BumpPtrAllocator allocator; + virtual JavaCompiler* Create(const std::string&) { return this; } Modified: vmkit/trunk/include/j3/JavaLLVMCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/JavaLLVMCompiler.h?rev=97325&r1=97324&r2=97325&view=diff ============================================================================== --- vmkit/trunk/include/j3/JavaLLVMCompiler.h (original) +++ vmkit/trunk/include/j3/JavaLLVMCompiler.h Sat Feb 27 08:22:35 2010 @@ -56,8 +56,20 @@ virtual void makeVT(Class* cl) = 0; virtual void makeIMT(Class* cl) = 0; - std::map functions; + std::map functions; typedef std::map::iterator function_iterator; + + std::map method_infos; + typedef std::map::iterator method_info_iterator; + + std::map field_infos; + typedef std::map::iterator field_info_iterator; + + std::map signature_infos; + typedef std::map::iterator signature_info_iterator; + + std::map class_infos; + typedef std::map::iterator class_info_iterator; std::map DbgInfos; typedef std::map::iterator dbg_iterator; @@ -109,16 +121,63 @@ void resolveVirtualClass(Class* cl); void resolveStaticClass(Class* cl); - static llvm::Function* getMethod(JavaMethod* meth); + llvm::Function* getMethod(JavaMethod* meth); void initialiseAssessorInfo(); std::map AssessorInfo; LLVMAssessorInfo& getTypedefInfo(const Typedef* type); - static LLVMSignatureInfo* getSignatureInfo(Signdef* sign); - static LLVMClassInfo* getClassInfo(Class* cl); - static LLVMFieldInfo* getFieldInfo(JavaField* field); - static LLVMMethodInfo* getMethodInfo(JavaMethod* method); + LLVMSignatureInfo* getSignatureInfo(Signdef* sign) { + signature_info_iterator E = signature_infos.end(); + signature_info_iterator I = signature_infos.find(sign); + if (I == E) { + LLVMSignatureInfo* signInfo = + new(allocator, "LLVMSignatureInfo") LLVMSignatureInfo(sign, this); + signature_infos.insert(std::make_pair(sign, signInfo)); + return signInfo; + } else { + return I->second; + } + } + + LLVMFieldInfo* getFieldInfo(JavaField* field) { + field_info_iterator E = field_infos.end(); + field_info_iterator I = field_infos.find(field); + if (I == E) { + LLVMFieldInfo* fieldInfo = + new(allocator, "LLVMFieldInfo") LLVMFieldInfo(field, this); + field_infos.insert(std::make_pair(field, fieldInfo)); + return fieldInfo; + } else { + return I->second; + } + } + + LLVMClassInfo* getClassInfo(Class* klass) { + class_info_iterator E = class_infos.end(); + class_info_iterator I = class_infos.find(klass); + if (I == E) { + LLVMClassInfo* classInfo = + new(allocator, "LLVMClassInfo") LLVMClassInfo(klass, this); + class_infos.insert(std::make_pair(klass, classInfo)); + return classInfo; + } else { + return I->second; + } + } + + LLVMMethodInfo* getMethodInfo(JavaMethod* method) { + method_info_iterator E = method_infos.end(); + method_info_iterator I = method_infos.find(method); + if (I == E) { + LLVMMethodInfo* methodInfo = + new(allocator, "LLVMMethodInfo") LLVMMethodInfo(method, this); + method_infos.insert(std::make_pair(method, methodInfo)); + return methodInfo; + } else { + return I->second; + } + } virtual llvm::Constant* getFinalObject(JavaObject* obj, CommonClass* cl) = 0; virtual JavaObject* getFinalObject(llvm::Value* C) = 0; Modified: vmkit/trunk/include/j3/LLVMInfo.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/LLVMInfo.h?rev=97325&r1=97324&r2=97325&view=diff ============================================================================== --- vmkit/trunk/include/j3/LLVMInfo.h (original) +++ vmkit/trunk/include/j3/LLVMInfo.h Sat Feb 27 08:22:35 2010 @@ -25,6 +25,7 @@ class Class; class JavaField; +class JavaLLVMCompiler; class JavaMethod; class Signdef; @@ -40,24 +41,28 @@ friend class JavaJITCompiler; friend class JavaLLVMCompiler; private: + /// Compiler - The compiler for this class info. + JavaLLVMCompiler* Compiler; + Class* classDef; + /// virtualSizeLLVM - The LLVM constant size of instances of this class. - /// llvm::Constant* virtualSizeConstant; + /// virtualType - The LLVM type of instance of this class. - /// const llvm::Type * virtualType; /// staticType - The LLVM type of the static instance of this class. - /// const llvm::Type * staticType; + public: llvm::Value* getVirtualSize(); const llvm::Type* getVirtualType(); const llvm::Type* getStaticType(); - LLVMClassInfo(Class* cl) : + LLVMClassInfo(Class* cl, JavaLLVMCompiler* comp) : + Compiler(comp), classDef(cl), virtualSizeConstant(0), virtualType(0), @@ -72,6 +77,9 @@ class LLVMMethodInfo : public mvm::JITInfo { private: + /// Compiler - The compiler for this method info. + JavaLLVMCompiler* Compiler; + JavaMethod* methodDef; llvm::Function* methodFunction; @@ -79,14 +87,14 @@ const llvm::FunctionType* functionType; llvm::MDNode* DbgSubprogram; - public: llvm::Function* getMethod(); llvm::Constant* getOffset(); const llvm::FunctionType* getFunctionType(); - LLVMMethodInfo(JavaMethod* M) : methodDef(M), methodFunction(0), - offsetConstant(0), functionType(0), DbgSubprogram(0) {} + LLVMMethodInfo(JavaMethod* M, JavaLLVMCompiler* comp) : Compiler(comp), + methodDef(M), methodFunction(0), offsetConstant(0), functionType(0), + DbgSubprogram(0) {} void setDbgSubprogram(llvm::MDNode* node) { DbgSubprogram = node; } llvm::MDNode* getDbgSubprogram() { return DbgSubprogram; } @@ -102,6 +110,9 @@ class LLVMFieldInfo : public mvm::JITInfo { private: + /// Compiler - The compiler for this field info. + JavaLLVMCompiler* Compiler; + JavaField* fieldDef; llvm::Constant* offsetConstant; @@ -109,7 +120,8 @@ public: llvm::Constant* getOffset(); - LLVMFieldInfo(JavaField* F) : + LLVMFieldInfo(JavaField* F, JavaLLVMCompiler* comp) : + Compiler(comp), fieldDef(F), offsetConstant(0) {} @@ -120,6 +132,9 @@ class LLVMSignatureInfo : public mvm::JITInfo { private: + /// Compiler - The compiler for this signature info. + JavaLLVMCompiler* Compiler; + const llvm::FunctionType* staticType; const llvm::FunctionType* virtualType; const llvm::FunctionType* nativeType; @@ -168,7 +183,8 @@ llvm::Function* getSpecialStub(); llvm::Function* getVirtualStub(); - LLVMSignatureInfo(Signdef* sign) : + LLVMSignatureInfo(Signdef* sign, JavaLLVMCompiler* comp) : + Compiler(comp), staticType(0), virtualType(0), nativeType(0), Modified: vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp?rev=97325&r1=97324&r2=97325&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaJITCompiler.cpp Sat Feb 27 08:22:35 2010 @@ -72,12 +72,12 @@ class JavaJITListener : public llvm::JITEventListener { JavaMethod* currentCompiledMethod; + llvm::Function* currentCompiledFunction; public: virtual void NotifyFunctionEmitted(const Function &F, void *Code, size_t Size, const EmittedFunctionDetails &Details) { - if (currentCompiledMethod && - JavaLLVMCompiler::getMethod(currentCompiledMethod) == &F) { + if (currentCompiledMethod && currentCompiledFunction == &F) { Jnjvm* vm = JavaThread::get()->getJVM(); mvm::BumpPtrAllocator& Alloc = currentCompiledMethod->classDef->classLoader->allocator; @@ -115,12 +115,19 @@ } } - void setCurrentCompiledMethod(JavaMethod* meth) { + void setCurrentCompiledMethod(JavaMethod* meth, llvm::Function* func) { currentCompiledMethod = meth; + currentCompiledFunction = func; + } + + void clearCurrentCompiledMethod() { + currentCompiledMethod = NULL; + currentCompiledFunction = NULL; } JavaJITListener() { - currentCompiledMethod = 0; + currentCompiledMethod = NULL; + currentCompiledFunction = NULL; } }; @@ -395,9 +402,9 @@ void* JavaJITCompiler::materializeFunction(JavaMethod* meth) { mvm::MvmModule::protectIR(); Function* func = parseFunction(meth); - JITListener->setCurrentCompiledMethod(meth); + JITListener->setCurrentCompiledMethod(meth, func); void* res = mvm::MvmModule::executionEngine->getPointerToGlobal(func); - JITListener->setCurrentCompiledMethod(0); + JITListener->clearCurrentCompiledMethod(); func->deleteBody(); mvm::MvmModule::unprotectIR(); Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=97325&r1=97324&r2=97325&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Sat Feb 27 08:22:35 2010 @@ -47,7 +47,7 @@ LLVMContext& context = Mod->getLLVMModule()->getContext(); if (classDef->super) { - LLVMClassInfo* CLI = JavaLLVMCompiler::getClassInfo(classDef->super); + LLVMClassInfo* CLI = Compiler->getClassInfo(classDef->super); const llvm::Type* Ty = CLI->getVirtualType()->getContainedType(0); fields.push_back(Ty); @@ -136,9 +136,7 @@ Function* LLVMMethodInfo::getMethod() { if (!methodFunction) { JnjvmClassLoader* JCL = methodDef->classDef->classLoader; - JavaLLVMCompiler* Mod = (JavaLLVMCompiler*)JCL->getCompiler(); - if (Mod->emitFunctionName()) { - + if (Compiler->emitFunctionName()) { const UTF8* jniConsClName = methodDef->classDef->name; const UTF8* jniConsName = methodDef->name; const UTF8* jniConsType = methodDef->type; @@ -160,11 +158,11 @@ memcpy(buf, "JnJVM", 5); } - methodFunction = Mod->getLLVMModule()->getFunction(buf); + methodFunction = Compiler->getLLVMModule()->getFunction(buf); if (!methodFunction) { methodFunction = Function::Create(getFunctionType(), GlobalValue::ExternalWeakLinkage, buf, - Mod->getLLVMModule()); + Compiler->getLLVMModule()); } else { assert(methodFunction->getFunctionType() == getFunctionType() && "Type mismatch"); @@ -177,15 +175,24 @@ methodFunction = Function::Create(getFunctionType(), GlobalValue::ExternalWeakLinkage, - "", Mod->getLLVMModule()); + "", Compiler->getLLVMModule()); } - if (Mod->useCooperativeGC()) { + if (Compiler->useCooperativeGC()) { methodFunction->setGC("vmkit"); } - Mod->functions.insert(std::make_pair(methodFunction, methodDef)); + Compiler->functions.insert(std::make_pair(methodFunction, methodDef)); + if (Compiler != JCL->getCompiler()) { + if (mvm::MvmModule::executionEngine && + !mvm::MvmModule::executionEngine->isCompilingLazily()) { + assert(methodDef->code && "getting a not compiled method from another " + "module"); + mvm::MvmModule::executionEngine->updateGlobalMapping(methodFunction, + methodDef->code); + } + } } return methodFunction; } @@ -193,7 +200,7 @@ const FunctionType* LLVMMethodInfo::getFunctionType() { if (!functionType) { Signdef* sign = methodDef->getSignature(); - LLVMSignatureInfo* LSI = JavaLLVMCompiler::getSignatureInfo(sign); + LLVMSignatureInfo* LSI = Compiler->getSignatureInfo(sign); assert(LSI); if (isStatic(methodDef->access)) { functionType = LSI->getStaticType(); @@ -823,19 +830,3 @@ LLVMAssessorInfo& JavaLLVMCompiler::getTypedefInfo(const Typedef* type) { return AssessorInfo[type->getKey()->elements[0]]; } - -LLVMSignatureInfo* JavaLLVMCompiler::getSignatureInfo(Signdef* sign) { - return sign->getInfo(); -} - -LLVMClassInfo* JavaLLVMCompiler::getClassInfo(Class* cl) { - return cl->getInfo(); -} - -LLVMFieldInfo* JavaLLVMCompiler::getFieldInfo(JavaField* field) { - return field->getInfo(); -} - -LLVMMethodInfo* JavaLLVMCompiler::getMethodInfo(JavaMethod* method) { - return method->getInfo(); -} Modified: vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp?rev=97325&r1=97324&r2=97325&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMMaterializer.cpp Sat Feb 27 08:22:35 2010 @@ -144,7 +144,7 @@ void* val = meth->compiledPtr(); if (isVirtual(meth->access)) { - LLVMMethodInfo* LMI = JavaLLVMCompiler::getMethodInfo(meth); + LLVMMethodInfo* LMI = Comp->getMethodInfo(meth); uint64_t offset = dyn_cast(LMI->getOffset())->getZExtValue(); assert(meth->classDef->isResolved() && "Class not resolved"); #if !defined(ISOLATE_SHARING) && !defined(SERVICE) Modified: vmkit/trunk/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/JIT.cpp?rev=97325&r1=97324&r2=97325&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/JIT.cpp Sat Feb 27 08:22:35 2010 @@ -496,14 +496,11 @@ // -instcombine -gvn -sccp -simplifycfg -instcombine -condprop -dse -adce // -simplifycfg // -void MvmModule::AddStandardCompilePasses() { - // TODO: enable this when - // - each module will have its declaration of external functions - // - //PM->add(llvm::createVerifierPass()); // Verify that input is correct - +void MvmModule::AddStandardCompilePasses() { FunctionPassManager* PM = globalFunctionPasses; PM->add(new TargetData(*MvmModule::TheTargetData)); + + addPass(PM, createVerifierPass()); // Verify that input is correct #ifdef WITH_MMTK addPass(PM, createCFGSimplificationPass()); // Clean up disgusting code From nicolas.geoffray at lip6.fr Sat Feb 27 10:18:51 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 27 Feb 2010 18:18:51 -0000 Subject: [vmkit-commits] [vmkit] r97335 - in /vmkit/trunk/lib/J3: Compiler/JavaAOTCompiler.cpp Compiler/LLVMInfo.cpp LLVMRuntime/runtime-default.ll LLVMRuntime/runtime-isolate.ll LLVMRuntime/runtime-single.ll VMCore/JavaClass.cpp VMCore/JavaClass.h VMCore/JavaTypes.cpp VMCore/JavaTypes.h VMCore/JnjvmClassLoader.cpp Message-ID: <20100227181852.06A9D2A6C12C@llvm.org> Author: geoffray Date: Sat Feb 27 12:18:51 2010 New Revision: 97335 URL: http://llvm.org/viewvc/llvm-project?rev=97335&view=rev Log: Remove unused JInfo field. Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll vmkit/trunk/lib/J3/LLVMRuntime/runtime-isolate.ll vmkit/trunk/lib/J3/LLVMRuntime/runtime-single.ll vmkit/trunk/lib/J3/VMCore/JavaClass.cpp vmkit/trunk/lib/J3/VMCore/JavaClass.h vmkit/trunk/lib/J3/VMCore/JavaTypes.cpp vmkit/trunk/lib/J3/VMCore/JavaTypes.h vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=97335&r1=97334&r2=97335&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Sat Feb 27 12:18:51 2010 @@ -893,9 +893,6 @@ // num FieldElts.push_back(ConstantInt::get(Type::getInt16Ty(getLLVMContext()), field.num)); - //JInfo - FieldElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); - return ConstantStruct::get(STy, FieldElts); } @@ -968,9 +965,6 @@ // offset MethodElts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), method.offset)); - // JInfo - MethodElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); - return ConstantStruct::get(STy, MethodElts); } @@ -1231,9 +1225,6 @@ // staticSize ClassElts.push_back(ConstantInt::get(Type::getInt32Ty(getLLVMContext()), cl->staticSize)); - // JInfo - ClassElts.push_back(Constant::getNullValue(JavaIntrinsics.ptrType)); - return ConstantStruct::get(STy, ClassElts); } Modified: vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp?rev=97335&r1=97334&r2=97335&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LLVMInfo.cpp Sat Feb 27 12:18:51 2010 @@ -185,10 +185,8 @@ Compiler->functions.insert(std::make_pair(methodFunction, methodDef)); if (Compiler != JCL->getCompiler()) { - if (mvm::MvmModule::executionEngine && - !mvm::MvmModule::executionEngine->isCompilingLazily()) { - assert(methodDef->code && "getting a not compiled method from another " - "module"); + if (mvm::MvmModule::executionEngine && methodDef->code) { + methodFunction->setLinkage(GlobalValue::ExternalLinkage); mvm::MvmModule::executionEngine->updateGlobalMapping(methodFunction, methodDef->code); } Modified: vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll?rev=97335&r1=97334&r2=97335&view=diff ============================================================================== --- vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll (original) +++ vmkit/trunk/lib/J3/LLVMRuntime/runtime-default.ll Sat Feb 27 12:18:51 2010 @@ -36,12 +36,12 @@ %JavaField = type { i8*, i16, %UTF8*, %UTF8*, %Attribut*, i16, %JavaClass*, i32, - i16, i8* } + i16 } %CodeLineInfo = type { i8*, i16, i16, %JavaMethod*, %CodeLineInfo* } %JavaMethod = type { i8*, i16, %Attribut*, i16, %JavaClass*, - %UTF8*, %UTF8*, i8, i8*, %CodeLineInfo*, i16, i32, i8* } + %UTF8*, %UTF8*, i8, i8*, %CodeLineInfo*, i16, i32 } %JavaClassPrimitive = type { %JavaCommonClass, i32 } %JavaClassArray = type { %JavaCommonClass, %JavaCommonClass* } Modified: vmkit/trunk/lib/J3/LLVMRuntime/runtime-isolate.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/LLVMRuntime/runtime-isolate.ll?rev=97335&r1=97334&r2=97335&view=diff ============================================================================== --- vmkit/trunk/lib/J3/LLVMRuntime/runtime-isolate.ll (original) +++ vmkit/trunk/lib/J3/LLVMRuntime/runtime-isolate.ll Sat Feb 27 12:18:51 2010 @@ -12,8 +12,7 @@ %JavaClass = type { %JavaCommonClass, i32, i32, [32 x %TaskClassMirror], i8*, %JavaField*, i16, %JavaField*, i16, %JavaMethod*, i16, %JavaMethod*, i16, i8*, %ArrayUInt8*, i8*, %Attribut*, - i16, %JavaClass**, i16, %JavaClass*, i16, i8, i8, i32, i32, - i8* } + i16, %JavaClass**, i16, %JavaClass*, i16, i8, i8, i32, i32 } ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;; Isolate specific methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Modified: vmkit/trunk/lib/J3/LLVMRuntime/runtime-single.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/LLVMRuntime/runtime-single.ll?rev=97335&r1=97334&r2=97335&view=diff ============================================================================== --- vmkit/trunk/lib/J3/LLVMRuntime/runtime-single.ll (original) +++ vmkit/trunk/lib/J3/LLVMRuntime/runtime-single.ll Sat Feb 27 12:18:51 2010 @@ -9,5 +9,4 @@ %JavaClass = type { %JavaCommonClass, i32, i32, [1 x %TaskClassMirror], i8*, %JavaField*, i16, %JavaField*, i16, %JavaMethod*, i16, %JavaMethod*, i16, i8*, %ArrayUInt8*, i8*, %Attribut*, - i16, %JavaClass**, i16, %JavaClass*, i16, i8, i8, i32, i32, - i8*} + i16, %JavaClass**, i16, %JavaClass*, i16, i8, i8, i32, i32 } Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=97335&r1=97334&r2=97335&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Sat Feb 27 12:18:51 2010 @@ -223,7 +223,6 @@ bytes = B; super = 0; ctpInfo = 0; - JInfo = 0; outerClass = 0; innerOuterResolved = false; nbInnerClasses = 0; @@ -651,7 +650,6 @@ access = A; canBeInlined = false; offset = 0; - JInfo = 0; } void JavaField::initialise(Class* cl, const UTF8* N, const UTF8* T, uint16 A) { @@ -661,7 +659,6 @@ _signature = 0; ptrOffset = 0; access = A; - JInfo = 0; } void Class::readParents(Reader& reader) { Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.h?rev=97335&r1=97334&r2=97335&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.h Sat Feb 27 12:18:51 2010 @@ -569,10 +569,6 @@ /// uint32 staticSize; - /// JInfo - JIT specific information. - /// - mvm::JITInfo* JInfo; - /// getVirtualSize - Get the virtual size of instances of this class. /// uint32 getVirtualSize() const { return virtualSize; } @@ -737,22 +733,6 @@ /// void resolveInnerOuterClasses(); - /// getInfo - Get the JIT specific information, allocating one if it - /// does not exist. - /// - template - Ty *getInfo() { - if (!JInfo) { - JInfo = new(classLoader->allocator, "Class JIT info") Ty(this); - } - - return static_cast(JInfo); - } - - void clearInfo() { - if (JInfo) JInfo->clear(); - } - /// resolveClass - If the class has not been resolved yet, resolve it. /// void resolveClass(); @@ -1270,20 +1250,6 @@ JavaObject* invokeJavaObjectStatic(Jnjvm* vm, UserClass*, ...) __attribute__ ((noinline)); - mvm::JITInfo* JInfo; - template - Ty *getInfo() { - if (!JInfo) { - JInfo = new(classDef->classLoader->allocator, "Method JIT info") Ty(this); - } - - return static_cast(JInfo); - } - - void clearInfo() { - if (JInfo) JInfo->clear(); - } - #define JNI_NAME_PRE "Java_" #define JNI_NAME_PRE_LEN 5 @@ -1401,21 +1367,6 @@ MK_ASSESSORS(uint32, Int32); MK_ASSESSORS(sint64, Long); - mvm::JITInfo* JInfo; - template - Ty *getInfo() { - if (!JInfo) { - JInfo = new(classDef->classLoader->allocator, "Field JIT info") Ty(this); - } - - return static_cast(JInfo); - } - - void clearInfo() { - if (JInfo) JInfo->clear(); - } - - bool isReference() { uint16 val = type->elements[0]; return (val == '[' || val == 'L'); Modified: vmkit/trunk/lib/J3/VMCore/JavaTypes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaTypes.cpp?rev=97335&r1=97334&r2=97335&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaTypes.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaTypes.cpp Sat Feb 27 12:18:51 2010 @@ -41,7 +41,6 @@ } initialLoader = loader; keyName = name; - JInfo = 0; _virtualCallBuf = 0; _staticCallBuf = 0; _virtualCallAP = 0; Modified: vmkit/trunk/lib/J3/VMCore/JavaTypes.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaTypes.h?rev=97335&r1=97334&r2=97335&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaTypes.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaTypes.h Sat Feb 27 12:18:51 2010 @@ -405,21 +405,6 @@ // //===----------------------------------------------------------------------===// - /// JInfo - Holds info useful for the JIT. - /// - mvm::JITInfo* JInfo; - - /// getInfo - Get the JIT info of this signature. The info is created lazely. - /// - template - Ty *getInfo() { - if (!JInfo) { - JInfo = new(initialLoader->allocator, "Sign info") Ty(this); - } - - return static_cast(JInfo); - } - /// nbArguments - The number of arguments in the signature. /// uint32 nbArguments; Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=97335&r1=97334&r2=97335&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp Sat Feb 27 12:18:51 2010 @@ -308,34 +308,8 @@ } void JnjvmClassLoader::setCompiler(JavaCompiler* Comp) { - // Set the new compiler. TheCompiler = Comp; - - // Clean up JITInfo of all classes. - for (ClassMap::iterator i = classes->map.begin(), e = classes->map.end(); - i!= e; ++i) { - CommonClass* ccl = i->second; - if (ccl->isClass()) { - Class* cl = ccl->asClass(); - cl->clearInfo(); - - for (uint32 i = 0; i < cl->nbVirtualMethods; ++i) { - cl->virtualMethods[i].clearInfo(); - } - - for (uint32 i = 0; i < cl->nbStaticMethods; ++i) { - cl->staticMethods[i].clearInfo(); - } - - for (uint32 i = 0; i < cl->nbVirtualFields; ++i) { - cl->virtualFields[i].clearInfo(); - } - for (uint32 i = 0; i < cl->nbStaticFields; ++i) { - cl->staticFields[i].clearInfo(); - } - } - } } ArrayUInt8* JnjvmBootstrapLoader::openName(const UTF8* utf8) {