From koutheir at gmail.com Wed Nov 20 09:07:05 2013 From: koutheir at gmail.com (Koutheir Attouchi) Date: Wed, 20 Nov 2013 17:07:05 -0000 Subject: [vmkit-commits] [vmkit] r195257 - Back-porting generic new features from work done on OSGi bundles monitoring in J3. Message-ID: <20131120170705.CDF482A6C029@llvm.org> Author: koutheir Date: Wed Nov 20 11:07:04 2013 New Revision: 195257 URL: http://llvm.org/viewvc/llvm-project?rev=195257&view=rev Log: Back-porting generic new features from work done on OSGi bundles monitoring in J3. Modified: vmkit/trunk/include/j3/J3Intrinsics.h vmkit/trunk/include/vmkit/GC.h vmkit/trunk/include/vmkit/System.h vmkit/trunk/include/vmkit/Thread.h vmkit/trunk/include/vmkit/UTF8.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/JavaJIT.h vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll vmkit/trunk/lib/j3/VMCore/JavaClass.h vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/j3/VMCore/JavaString.cpp vmkit/trunk/lib/j3/VMCore/JavaString.h vmkit/trunk/lib/j3/VMCore/JavaThread.cpp vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp Modified: vmkit/trunk/include/j3/J3Intrinsics.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/J3Intrinsics.h?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/include/j3/J3Intrinsics.h (original) +++ vmkit/trunk/include/j3/J3Intrinsics.h Wed Nov 20 11:07:04 2013 @@ -45,6 +45,7 @@ public: llvm::Type* JavaMethodType; llvm::Type* JavaFieldType; llvm::Type* AttributeType; + llvm::Type* ThreadType; llvm::Type* JavaThreadType; llvm::Type* MutatorThreadType; llvm::Type* J3DenseMapType; @@ -140,6 +141,8 @@ public: llvm::Constant* OffsetBaseClassInArrayClassConstant; llvm::Constant* OffsetLogSizeInPrimitiveClassConstant; + llvm::Constant* OffsetOffsetInJavaMethodConstant; + llvm::Constant* ClassReadyConstant; llvm::Constant* JavaObjectNullConstant; Modified: vmkit/trunk/include/vmkit/GC.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/GC.h?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/include/vmkit/GC.h (original) +++ vmkit/trunk/include/vmkit/GC.h Wed Nov 20 11:07:04 2013 @@ -19,14 +19,20 @@ class gc; class gcHeader { public: word_t _header; + inline gc* toReference() { return (gc*)((uintptr_t)this + hiddenHeaderSize()); } static inline size_t hiddenHeaderSize() { return sizeof(gcHeader); } }; class gcRoot { public: - word_t& header(){return toHeader()->_header; } - inline gcHeader* toHeader() { return (gcHeader*)((uintptr_t)this - gcHeader::hiddenHeaderSize()); } + + inline word_t& header() {return toHeader()->_header; } + inline const word_t& header() const {return const_cast(this)->header(); } + + inline gcHeader* toHeader() { + return (gcHeader*)((uintptr_t)this - gcHeader::hiddenHeaderSize()); } + inline const gcHeader* toHeader() const {return const_cast(this)->toHeader(); } }; namespace vmkit { Modified: vmkit/trunk/include/vmkit/System.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/System.h?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/include/vmkit/System.h (original) +++ vmkit/trunk/include/vmkit/System.h Wed Nov 20 11:07:04 2013 @@ -17,6 +17,8 @@ #include #include +#include "vmkit/config.h" + #if defined(__linux__) || defined(__FreeBSD__) #define LINUX_OS 1 #elif defined(__APPLE__) @@ -148,7 +150,7 @@ public: return pagesize; } - static word_t GetCallerAddress() __attribute((always_inline)) { + static word_t GetCallFrameAddress() __attribute((always_inline)) { #if defined(ARCH_X86) || defined(ARCH_X64) return (word_t)__builtin_frame_address(0); #else @@ -156,15 +158,15 @@ public: #endif } - static word_t GetCallerOfAddress(word_t addr) { - return ((word_t*)addr)[0]; + static word_t GetCallerCallFrame(word_t currentCallFrame) { + return *(word_t*)currentCallFrame; } - static word_t GetIPFromCallerAddress(word_t addr) { + static word_t GetReturnAddressOfCallFrame(word_t currentCallFrame) { #if defined(MACOS_OS) && defined(ARCH_PPC) - return ((word_t*)addr)[2]; + return ((word_t*)currentCallFrame)[2]; #else - return ((word_t*)addr)[1]; + return ((word_t*)currentCallFrame)[1]; #endif } Modified: vmkit/trunk/include/vmkit/Thread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/Thread.h?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/include/vmkit/Thread.h (original) +++ vmkit/trunk/include/vmkit/Thread.h Wed Nov 20 11:07:04 2013 @@ -172,7 +172,7 @@ public: /// get - Get the thread specific data of the current thread. /// static Thread* get() { - return (Thread*)(System::GetCallerAddress() & System::GetThreadIDMask()); + return (Thread*)(System::GetCallFrameAddress() & System::GetThreadIDMask()); } private: @@ -239,7 +239,7 @@ public: /// stackOverflow - Returns if there is a stack overflow in Java land. /// bool stackOverflow() { - return (System::GetCallerAddress() & StackOverflowMask) == 0; + return (System::GetCallFrameAddress() & StackOverflowMask) == 0; } /// operator new - Allocate the Thread object as well as the stack for this @@ -331,11 +331,12 @@ public: /// class StackWalker { public: - word_t addr; - word_t ip; + word_t callFrameAddress; + word_t returnAddress; KnownFrame* frame; vmkit::Thread* thread; + StackWalker() __attribute__ ((noinline)); StackWalker(vmkit::Thread* th) __attribute__ ((noinline)); void operator++(); word_t operator*(); Modified: vmkit/trunk/include/vmkit/UTF8.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/UTF8.h?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/include/vmkit/UTF8.h (original) +++ vmkit/trunk/include/vmkit/UTF8.h Wed Nov 20 11:07:04 2013 @@ -12,6 +12,25 @@ namespace vmkit { class UTF8Map; +template +int compare_null_terminated_arrays(const T1* array1, size_t size1, const T2* array2, size_t size2) +{ + // NULL array is treated as empty + if (!array1) size1 = 0; + if (!array2) size2 = 0; + + // Compute real sizes, excluding null terminators + for (; (size1 != 0) && (array1[size1 - 1] == 0); --size1); + for (; (size2 != 0) && (array2[size2 - 1] == 0); --size2); + + int diff = size1 - size2; // Compare sizes + if (diff == 0) { // Equal sizes, compare contents + for (; (size1 != 0) && (diff == 0); --size1, ++array1, ++array2) + diff = *array1 - *array2; + } + return diff; +} + class UTF8 { friend class UTF8Map; private: @@ -36,8 +55,7 @@ public: /// equals - Are the two UTF8s equal? bool equals(const UTF8* other) const { if (other == this) return true; - else if (size != other->size) return false; - else return !memcmp(elements, other->elements, size * sizeof(uint16)); + return (*this) == (*other); } /// equals - Does the UTF8 equal to the buffer? @@ -47,12 +65,8 @@ public: } /// lessThan - strcmp-like function for UTF8s, used by hash tables. - bool lessThan(const UTF8* other) const { - if (size < other->size) return true; - else if (size > other->size) return false; - else return memcmp((const char*)elements, (const char*)other->elements, - size * sizeof(uint16)) < 0; - } + bool lessThan(const UTF8* other) const + { return (*this) < (*other); } static uint32_t readerHasher(const uint16* buf, sint32 size); @@ -64,9 +78,26 @@ public: size = n; } + friend bool operator < (const UTF8& str1, const UTF8& str2) { + return UTF8::compare(&str1, &str2) < 0; + } + friend bool operator == (const UTF8& str1, const UTF8& str2) { + return UTF8::compare(&str1, &str2) == 0; + } friend std::ostream& operator << (std::ostream&, const UTF8&); + void dump() const __attribute__((noinline)); - int compare(const char *) const; + int compare(const char *str, int length = -1) const { + return compare_null_terminated_arrays( + elements, size, str, (length == -1) ? strlen(str) : length); + } + int compare(const UTF8& str) const {return UTF8::compare(this, &str);} + static int compare(const UTF8* str1, const UTF8* str2) { + if (!str1 && !str2) return 0; + return compare_null_terminated_arrays( + (!str1 ? NULL : str1->elements), (!str1 ? 0 : str1->size), + (!str2 ? NULL : str2->elements), (!str2 ? 0 : str2->size)); + } std::string& toString(std::string& buffer) const; }; @@ -83,6 +114,13 @@ struct UTF8MapKey { } }; +class UTF8_Comparator { +public: + bool operator() (const UTF8* str1, const UTF8* str2) const { + return (*str1) < (*str2); + } +}; + // Provide VmkitDenseMapInfo for UTF8. template<> struct VmkitDenseMapInfo { Modified: vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp (original) +++ vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp Wed Nov 20 11:07:04 2013 @@ -99,6 +99,8 @@ void J3Intrinsics::init(llvm::Module* mo PointerType::getUnqual(module->getTypeByName("UTF8")); AttributeType = PointerType::getUnqual(module->getTypeByName("Attribute")); + ThreadType = + PointerType::getUnqual(module->getTypeByName("Thread")); JavaThreadType = PointerType::getUnqual(module->getTypeByName("JavaThread")); MutatorThreadType = @@ -152,6 +154,8 @@ void J3Intrinsics::init(llvm::Module* mo OffsetBaseClassInArrayClassConstant = constantOne; OffsetLogSizeInPrimitiveClassConstant = constantOne; + OffsetOffsetInJavaMethodConstant = ConstantInt::get(Type::getInt32Ty(Context), 9); + OffsetObjectSizeInClassConstant = constantOne; OffsetVTInClassConstant = ConstantInt::get(Type::getInt32Ty(Context), 7); OffsetTaskClassMirrorInClassConstant = constantThree; Modified: vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp Wed Nov 20 11:07:04 2013 @@ -2143,7 +2143,8 @@ void mainCompilerStart(JavaThread* th) { JavaJITCompiler* Comp = NULL; if (!M->clinits->empty()) { - Comp = JavaJITCompiler::CreateCompiler("JIT"); + Comp = JavaJITCompiler::CreateCompiler( + "JIT", M->isCompilingGarbageCollector()); Comp->EmitFunctionName = true; if (!M->useCooperativeGC()) { Comp->disableCooperativeGC(); Modified: vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp Wed Nov 20 11:07:04 2013 @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -47,6 +48,37 @@ using namespace j3; using namespace llvm; using namespace std; +Value* JavaJIT::allocateOnStack( + const char* name, size_t byteCount, Type* realType) +{ + std::string bufferName(name); + bufferName += "Buffer"; + + Constant* wordCount = ConstantInt::get( + Type::getInt32Ty(*llvmContext), + vmkit::System::WordAlignUp(byteCount) / sizeof(void*)); + + Value* buffer = new AllocaInst(intrinsics->ptrType, + wordCount, sizeof(void*), bufferName, currentBlock); + return new BitCastInst(buffer, realType, name, currentBlock); +} + +Value* JavaJIT::getElementPtr( + const char *name, Value* element, Value* firstIndex, ...) +{ + std::vector indexList; + indexList.push_back(firstIndex); + + va_list argList; + Value* arg; + va_start(argList, firstIndex); + while ((arg = va_arg(argList, Value*)) != NULL) + indexList.push_back(arg); + va_end(argList); + + return GetElementPtrInst::Create(element, indexList, name, currentBlock); +} + void JavaJIT::updateStackInfo(Opinfo& info) { if (stackSize()) { if (!info.stack.size()) { @@ -221,37 +253,47 @@ void JavaJIT::invokeVirtual(uint16 index indexes2[1] = Offset; } else { nullChecked = true; - GlobalVariable* GV = new GlobalVariable(*llvmFunction->getParent(), - Type::getInt32Ty(*llvmContext), - false, - GlobalValue::ExternalLinkage, - intrinsics->constantZero, ""); - + GlobalVariable* cachedMethodPtr = new GlobalVariable( + *llvmFunction->getParent(), intrinsics->JavaMethodType, + false, GlobalValue::ExternalLinkage, + Constant::getNullValue(intrinsics->JavaMethodType), "cachedMethodPtr"); + Value* cachedMethod = new LoadInst( + cachedMethodPtr, "cachedMethod", false, currentBlock); + BasicBlock* resolveVirtual = createBasicBlock("resolveVirtual"); BasicBlock* endResolveVirtual = createBasicBlock("endResolveVirtual"); - PHINode* node = PHINode::Create(Type::getInt32Ty(*llvmContext), 2, "", - endResolveVirtual); - - Value* load = new LoadInst(GV, "", false, currentBlock); - Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, load, - intrinsics->constantZero, ""); + PHINode* methodPtr = PHINode::Create( + intrinsics->JavaMethodType, 2, "methodPtr", endResolveVirtual); + methodPtr->addIncoming(cachedMethod, currentBlock); + + Value* test = new ICmpInst( + *currentBlock, ICmpInst::ICMP_EQ, cachedMethod, + Constant::getNullValue(intrinsics->JavaMethodType), "isCacheEmpty"); 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(cachedMethodPtr); Value* targetObject = getTarget(signature); - targetObject = new LoadInst(targetObject, "", false, currentBlock); + targetObject = new LoadInst( + targetObject, "targetObject", false, currentBlock); if (!thisReference) JITVerifyNull(targetObject); Args.push_back(targetObject); - load = invoke(intrinsics->VirtualLookupFunction, Args, "", currentBlock); - node->addIncoming(load, currentBlock); + Value* calculatedMethodPtr = invoke(intrinsics->VirtualLookupFunction, + Args, "calculatedMethod", currentBlock); + methodPtr->addIncoming(calculatedMethodPtr, currentBlock); + BranchInst::Create(endResolveVirtual, currentBlock); currentBlock = endResolveVirtual; - indexes2[1] = node; + Value* methodOffset = getElementPtr( + "methodOffsetPtr", methodPtr, intrinsics->constantZero, + intrinsics->OffsetOffsetInJavaMethodConstant, NULL); + methodOffset = new LoadInst(methodOffset, "methodOffset", currentBlock); + + indexes2[1] = methodOffset; } makeArgs(it, index, args, signature->nbArguments + 1); @@ -290,19 +332,32 @@ void JavaJIT::invokeVirtual(uint16 index } llvm::Value* JavaJIT::getMutatorThreadPtr() { - Value* FrameAddr = CallInst::Create(intrinsics->llvm_frameaddress, - intrinsics->constantZero, "", currentBlock); - Value* threadId = new PtrToIntInst(FrameAddr, intrinsics->pointerSizeType, "", - currentBlock); - threadId = BinaryOperator::CreateAnd(threadId, intrinsics->constantThreadIDMask, - "", currentBlock); - threadId = new IntToPtrInst(threadId, intrinsics->MutatorThreadType, "MutatorThreadPtr", currentBlock); + return new BitCastInst( + getThreadPtr(), intrinsics->MutatorThreadType, "MutatorThreadPtr", currentBlock); +} + +llvm::Value* JavaJIT::getThreadPtr() +{ + if (!currentThreadPtr) { + Value* frameAddr = CallInst::Create( + intrinsics->llvm_frameaddress, intrinsics->constantZero, + "frameAddress", currentBlock); + Value* ptr = new PtrToIntInst( + frameAddr, intrinsics->pointerSizeType, "", currentBlock); + ptr = BinaryOperator::CreateAnd( + ptr, intrinsics->constantThreadIDMask, "", currentBlock); + ptr = new IntToPtrInst( + ptr, intrinsics->ThreadType, "threadPtr", currentBlock); + + currentThreadPtr = ptr; + } - return threadId; + return currentThreadPtr; } -llvm::Value* JavaJIT::getJavaThreadPtr(llvm::Value* mutatorThreadPtr) { - return new BitCastInst(mutatorThreadPtr, intrinsics->JavaThreadType, "JavaThreadPtr", currentBlock); +llvm::Value* JavaJIT::getJavaThreadPtr() { + return new BitCastInst( + getThreadPtr(), intrinsics->JavaThreadType, "JavaThreadPtr", currentBlock); } llvm::Value* JavaJIT::getIsolateIDPtr(llvm::Value* mutatorThreadPtr) { @@ -420,7 +475,6 @@ llvm::Function* JavaJIT::nativeCompile(w return llvmFunction; } - Function* func = llvmFunction; if (j3) { Function* callee = Function::Create(llvmFunction->getFunctionType(), @@ -446,30 +500,33 @@ llvm::Function* JavaJIT::nativeCompile(w currentExceptionBlock = endExceptionBlock = 0; currentBlock = createBasicBlock("start"); - endBlock = createBasicBlock("end block"); + endBlock = createBasicBlock("endBlock"); + getThreadPtr(); + if (returnType != Type::getVoidTy(*llvmContext)) { endNode = PHINode::Create(returnType, 0, "", endBlock); } // Allocate currentLocalIndexNumber pointer - Value* temp = new AllocaInst(Type::getInt32Ty(*llvmContext), "", - currentBlock); + Value* temp = new AllocaInst( + Type::getInt32Ty(*llvmContext), "currentLocalIndexNumber", currentBlock); new StoreInst(intrinsics->constantZero, temp, false, currentBlock); // Allocate oldCurrentLocalIndexNumber pointer - Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(*llvmContext)), "", - currentBlock); + Value* oldCLIN = new AllocaInst( + PointerType::getUnqual(Type::getInt32Ty(*llvmContext)), + "oldLocalIndexNumber", currentBlock); Constant* sizeF = ConstantInt::get(Type::getInt32Ty(*llvmContext), sizeof(vmkit::KnownFrame)); - Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "", currentBlock); + Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "knownFrame", currentBlock); uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); std::vector nativeArgs; nativeArgs.push_back(NULL); // Will contain the callee - Value* jniEnv = getJNIEnvPtr(getJavaThreadPtr(getMutatorThreadPtr())); + Value* jniEnv = getJNIEnvPtr(getJavaThreadPtr()); jniEnv = new BitCastInst(jniEnv, intrinsics->ptrType, "", currentBlock); @@ -487,10 +544,10 @@ llvm::Function* JavaJIT::nativeCompile(w index < nargs; ++i, ++index) { if (i->getType() == intrinsics->JavaObjectType) { - BasicBlock* BB = createBasicBlock(""); - BasicBlock* NotZero = createBasicBlock(""); + BasicBlock* BB = createBasicBlock("continue"); + BasicBlock* NotZero = createBasicBlock("storeObjParamOnStack"); Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType); - PHINode* node = PHINode::Create(Ty, 2, "", BB); + PHINode* node = PHINode::Create(Ty, 2, "stack_obj_param_", BB); Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, i, intrinsics->JavaObjectNullConstant, ""); @@ -500,8 +557,9 @@ llvm::Function* JavaJIT::nativeCompile(w currentBlock = NotZero; - Instruction* temp = new AllocaInst(intrinsics->JavaObjectType, "", - func->begin()->getTerminator()); + Instruction* temp = new AllocaInst( + intrinsics->JavaObjectType, "nonNullObjParamOnStack", + func->begin()->getTerminator()); if (i == func->arg_begin() && !stat) { this->thisObject = temp; } @@ -529,11 +587,10 @@ llvm::Function* JavaJIT::nativeCompile(w } } - Instruction* ResultObject = 0; if (returnType == intrinsics->JavaObjectType) { - ResultObject = new AllocaInst(intrinsics->JavaObjectType, "", - func->begin()->begin()); + ResultObject = new AllocaInst( + intrinsics->JavaObjectType, "resultObjOnStack", func->begin()->begin()); if (TheCompiler->useCooperativeGC()) { @@ -555,8 +612,8 @@ llvm::Function* JavaJIT::nativeCompile(w Value* Arg = TheCompiler->getMethodInClass(compilingMethod); // If the global variable is null, then load it. - BasicBlock* unloadedBlock = createBasicBlock(""); - BasicBlock* endBlock = createBasicBlock(""); + BasicBlock* unloadedBlock = createBasicBlock("unloadedBlock"); + BasicBlock* endBlock = createBasicBlock("endBlock"); Value* test = new LoadInst(nativeFunc, "", currentBlock); Type* Ty = test->getType(); PHINode* node = PHINode::Create(Ty, 2, "", endBlock); @@ -595,7 +652,7 @@ llvm::Function* JavaJIT::nativeCompile(w Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType); Constant* C = Constant::getNullValue(Ty); Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, result, C, ""); - BasicBlock* loadBlock = createBasicBlock(""); + BasicBlock* loadBlock = createBasicBlock("loadBlock"); endNode->addIncoming(intrinsics->JavaObjectNullConstant, currentBlock); BranchInst::Create(endBlock, loadBlock, cmp, currentBlock); @@ -612,7 +669,6 @@ llvm::Function* JavaJIT::nativeCompile(w BranchInst::Create(endBlock, currentBlock); - currentBlock = endBlock; Value* Args2[1] = { oldCLIN }; @@ -623,9 +679,9 @@ llvm::Function* JavaJIT::nativeCompile(w if (isSynchro(compilingMethod->access)) endSynchronize(); - BasicBlock* ifNormal = createBasicBlock(""); - BasicBlock* ifException = createBasicBlock(""); - Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr())); + BasicBlock* ifNormal = createBasicBlock("ifNormal"); + BasicBlock* ifException = createBasicBlock("ifException"); + Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr()); Value* obj = new LoadInst(javaExceptionPtr, "", currentBlock); Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, intrinsics->JavaObjectNullConstant, ""); BranchInst::Create(ifException, ifNormal, test, currentBlock); @@ -681,8 +737,8 @@ void JavaJIT::monitorEnter(Value* obj) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, atomic, lock, ""); - BasicBlock* OK = createBasicBlock("synchronize passed"); - BasicBlock* NotOK = createBasicBlock("synchronize did not pass"); + BasicBlock* OK = createBasicBlock("synchronizePassed"); + BasicBlock* NotOK = createBasicBlock("synchronizeDidNotPass"); BranchInst::Create(OK, NotOK, cmp, currentBlock); @@ -734,7 +790,7 @@ void JavaJIT::monitorExit(Value* obj) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, atomic, oldValMask, ""); - BasicBlock* LockFreeCASFailed = createBasicBlock("Lock-Free CAS Failed"); + BasicBlock* LockFreeCASFailed = createBasicBlock("LockFreeCASFailed"); BranchInst::Create(EndBlock, LockFreeCASFailed, cmp, currentBlock); @@ -1038,28 +1094,30 @@ llvm::Function* JavaJIT::javaCompile() { opcodeInfos[i].exceptionBlock = endExceptionBlock; } + getThreadPtr(); + Instruction* returnValue = NULL; if (returnType == intrinsics->JavaObjectType && TheCompiler->useCooperativeGC()) { - returnValue = new AllocaInst(intrinsics->JavaObjectType, "returnValue", - currentBlock); - Instruction* cast = - new BitCastInst(returnValue, intrinsics->ptrPtrType, "", currentBlock); + returnValue = new AllocaInst( + intrinsics->JavaObjectType, "returnValueStorage", currentBlock); + Instruction* cast = new BitCastInst( + returnValue, intrinsics->ptrPtrType, "returnValue", currentBlock); Value* GCArgs[2] = { cast, intrinsics->constantPtrNull }; CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, "", currentBlock); } for (int i = 0; i < maxLocals; i++) { - intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), setInstructionName(instName, instNameLen, "int_%d", i), currentBlock)); + intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), setInstructionName(instName, instNameLen, "local_int_%d", i), currentBlock)); new StoreInst(Constant::getNullValue(Type::getInt32Ty(*llvmContext)), intLocals.back(), false, currentBlock); - doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), setInstructionName(instName, instNameLen, "double_%d", i), currentBlock)); + doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), setInstructionName(instName, instNameLen, "local_double_%d", i), currentBlock)); new StoreInst(Constant::getNullValue(Type::getDoubleTy(*llvmContext)), doubleLocals.back(), false, currentBlock); - longLocals.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), setInstructionName(instName, instNameLen, "long_%d", i), currentBlock)); + longLocals.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), setInstructionName(instName, instNameLen, "local_long_%d", i), currentBlock)); new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, currentBlock); - floatLocals.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), setInstructionName(instName, instNameLen, "float_%d", i), currentBlock)); + floatLocals.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), setInstructionName(instName, instNameLen, "local_float_%d", i), currentBlock)); new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, currentBlock); - objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, setInstructionName(instName, instNameLen, "object_%d", i), currentBlock)); + objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, setInstructionName(instName, instNameLen, "local_object_%d", i), currentBlock)); // The GCStrategy will already initialize the value. if (!TheCompiler->useCooperativeGC()) new StoreInst(Constant::getNullValue(intrinsics->JavaObjectType), objectLocals.back(), false, currentBlock); @@ -1131,7 +1189,7 @@ llvm::Function* JavaJIT::javaCompile() { nbHandlers = readExceptionTable(reader, codeLen); if (nbHandlers != 0) { - jmpBuffer = new AllocaInst(ArrayType::get(Type::getInt8Ty(*llvmContext), sizeof(vmkit::ExceptionBuffer)), "", currentBlock); + jmpBuffer = new AllocaInst(ArrayType::get(Type::getInt8Ty(*llvmContext), sizeof(vmkit::ExceptionBuffer)), "exceptionSavePointStorage", currentBlock); jmpBuffer = new BitCastInst(jmpBuffer, intrinsics->ptrType, "exceptionSavePoint", currentBlock); } @@ -1141,7 +1199,7 @@ llvm::Function* JavaJIT::javaCompile() { endBlock = createBasicBlock("end"); if (returnType != Type::getVoidTy(*llvmContext)) { - endNode = llvm::PHINode::Create(returnType, 0, "", endBlock); + endNode = llvm::PHINode::Create(returnType, 0, "returnValuePhi", endBlock); } checkYieldPoint(); @@ -1165,8 +1223,8 @@ llvm::Function* JavaJIT::javaCompile() { stackCheck = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, stackCheck, intrinsics->constantPtrZero, ""); - BasicBlock* stackOverflow = createBasicBlock("stack overflow"); - BasicBlock* noStackOverflow = createBasicBlock("no stack overflow"); + BasicBlock* stackOverflow = createBasicBlock("stackOverflow"); + BasicBlock* noStackOverflow = createBasicBlock("noStackOverflow"); BranchInst::Create(stackOverflow, noStackOverflow, stackCheck, currentBlock); currentBlock = stackOverflow; @@ -1227,9 +1285,9 @@ llvm::Function* JavaJIT::javaCompile() { currentBlock->eraseFromParent(); } else { if (nbHandlers != 0) { - BasicBlock* ifNormal = createBasicBlock("No exception was thrown"); - BasicBlock* ifException = createBasicBlock("Rethrow Exception"); - Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr())); + BasicBlock* ifNormal = createBasicBlock("noExceptionThrown"); + BasicBlock* ifException = createBasicBlock("reThrowException"); + Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr()); Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock); Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, intrinsics->JavaObjectNullConstant, ""); BranchInst::Create(ifException, ifNormal, test, currentBlock); @@ -1381,8 +1439,8 @@ void JavaJIT::JITVerifyNull(Value* obj) } else { Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj, intrinsics->JavaObjectNullConstant, ""); - BasicBlock* nullObjBlock = createBasicBlock("object is null"); - BasicBlock* notNullObjBlock = createBasicBlock("object is not null"); + BasicBlock* nullObjBlock = createBasicBlock("objectIsNull"); + BasicBlock* notNullObjBlock = createBasicBlock("objectIsNotNull"); BranchInst::Create(nullObjBlock, notNullObjBlock, test, currentBlock); currentBlock = nullObjBlock; @@ -1408,8 +1466,8 @@ Value* JavaJIT::verifyAndComputePtr(Valu Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_ULT, index, size, ""); - BasicBlock* ifTrue = createBasicBlock("true verifyAndComputePtr"); - BasicBlock* ifFalse = createBasicBlock("false verifyAndComputePtr"); + BasicBlock* ifTrue = createBasicBlock("trueVerifyAndComputePtr"); + BasicBlock* ifFalse = createBasicBlock("falseVerifyAndComputePtr"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); @@ -2180,7 +2238,6 @@ void JavaJIT::getVirtualField(uint16 ind } } - void JavaJIT::invokeInterface(uint16 index) { // Do the usual @@ -2345,14 +2402,13 @@ DebugLoc JavaJIT::CreateLocation() { } Instruction* JavaJIT::invoke(Value *F, std::vector& args, - const char* Name, - BasicBlock *InsertAtEnd) { + const char* Name, BasicBlock *InsertAtEnd) { assert(!inlining); BasicBlock* ifException = NULL; if (jmpBuffer != NULL) { - BasicBlock* doCall = createBasicBlock("Perform call"); - ifException = createBasicBlock("Exception thrown"); + BasicBlock* doCall = createBasicBlock("performCall"); + ifException = createBasicBlock("exceptionThrown"); Instruction* check = CallInst::Create(intrinsics->SetjmpFunction, jmpBuffer, "", currentBlock); check = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, check, intrinsics->constantZero, ""); BranchInst::Create(doCall, ifException, check, currentBlock); @@ -2366,7 +2422,7 @@ Instruction* JavaJIT::invoke(Value *F, s if (jmpBuffer != NULL) { CallInst::Create(intrinsics->UnregisterSetjmpFunction, jmpBuffer, "", currentBlock); - BasicBlock* ifNormal = createBasicBlock("no exception block"); + BasicBlock* ifNormal = createBasicBlock("noExceptionBlock"); BranchInst::Create(ifNormal, currentBlock); currentBlock = ifException; @@ -2386,7 +2442,7 @@ Instruction* JavaJIT::invoke(Value *F, V } Instruction* JavaJIT::invoke(Value *F, Value* arg1, Value* arg2, - const char* Name, BasicBlock *InsertAtEnd) { + const char* Name, BasicBlock *InsertAtEnd) { std::vector args; args.push_back(arg1); args.push_back(arg2); @@ -2394,7 +2450,7 @@ Instruction* JavaJIT::invoke(Value *F, V } Instruction* JavaJIT::invoke(Value *F, const char* Name, - BasicBlock *InsertAtEnd) { + BasicBlock *InsertAtEnd) { std::vector args; return invoke(F, args, Name, InsertAtEnd); } @@ -2405,7 +2461,7 @@ void JavaJIT::throwException(Value* obj, CallInst::Create(intrinsics->ThrowExceptionFunction, obj, "", currentBlock); new UnreachableInst(*llvmContext, currentBlock); } else { - Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr())); + Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr()); if (vmkit::Collector::needsNonHeapWriteBarrier()) { Instruction* ptr = new BitCastInst(javaExceptionPtr, intrinsics->ptrPtrType, "", currentBlock); Instruction* val = new BitCastInst(obj, intrinsics->ptrType, "", currentBlock); @@ -2557,7 +2613,7 @@ unsigned JavaJIT::readExceptionTable(Rea Value* VTVar = TheCompiler->getVirtualTable(cur->catchClass->virtualVT); // Get the Java exception. - Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr())); + Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr()); Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock); Value* objVT = CallInst::Create(intrinsics->GetVTFunction, obj, "objectVT", Modified: vmkit/trunk/lib/j3/Compiler/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJIT.h?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/JavaJIT.h (original) +++ vmkit/trunk/lib/j3/Compiler/JavaJIT.h Wed Nov 20 11:07:04 2013 @@ -107,6 +107,7 @@ public: overridesThis = false; nbHandlers = 0; jmpBuffer = NULL; + currentThreadPtr = NULL; } /// javaCompile - Compile the Java method. @@ -168,6 +169,8 @@ private: llvm::Value* jmpBuffer; + llvm::Value* currentThreadPtr; + /// return the header of an object llvm::Value* objectToHeader(llvm::Value* obj); @@ -182,6 +185,8 @@ private: llvm::BasicBlock* currentBlock, bool usign); /// getMutatorThreadPtr - Emit code to get a pointer to the current MutatorThread. + llvm::Value* getThreadPtr(); + llvm::Value* getJavaThreadPtr(); llvm::Value* getMutatorThreadPtr(); /// getIsolateIDPtr - Emit code to get a pointer to IsolateID. @@ -570,6 +575,11 @@ private: //===--------------------- Yield point support ---------------------------===// void checkYieldPoint(); + + llvm::Value* getElementPtr( + const char *name, llvm::Value* element, llvm::Value* firstIndex, ...); + llvm::Value* allocateOnStack( + const char* name, size_t byteCount, llvm::Type* realType); }; enum Opcode { Modified: vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp Wed Nov 20 11:07:04 2013 @@ -376,7 +376,7 @@ void JavaJIT::compileOpcodes(Reader& rea stack.clear(); if (opinfo->handler) { // If it's a handler, put the exception object in the stack. - Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr())); + Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr()); Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock); new StoreInst(obj, objectStack[0], "", currentBlock); // And clear the exception. @@ -940,10 +940,10 @@ void JavaJIT::compileOpcodes(Reader& rea Value* res = 0; if (TheCompiler->isStaticCompiling()) { - BasicBlock* endBlock = createBasicBlock("end array store check"); - BasicBlock* checkBlock = createBasicBlock("array store check"); + BasicBlock* endBlock = createBasicBlock("endArrayStoreCheck"); + BasicBlock* checkBlock = createBasicBlock("arrayStoreCheck"); BasicBlock* exceptionBlock = - createBasicBlock("array store exception"); + createBasicBlock("arrayStoreException"); Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, intrinsics->JavaObjectNullConstant, ""); @@ -1262,8 +1262,8 @@ void JavaJIT::compileOpcodes(Reader& rea if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantZero, ""); - BasicBlock* ifFalse = createBasicBlock("non null div"); - BasicBlock* ifTrue = createBasicBlock("null div"); + BasicBlock* ifFalse = createBasicBlock("nonNullDiv"); + BasicBlock* ifTrue = createBasicBlock("nullDiv"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; @@ -1272,9 +1272,9 @@ void JavaJIT::compileOpcodes(Reader& rea } Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantMinusOne, ""); - BasicBlock* ifFalse = createBasicBlock("non -1 div"); - BasicBlock* ifTrue = createBasicBlock("-1 div"); - BasicBlock* endBlock = createBasicBlock("End division"); + BasicBlock* ifFalse = createBasicBlock("nonMinusOneDiv"); + BasicBlock* ifTrue = createBasicBlock("minusOneDiv"); + BasicBlock* endBlock = createBasicBlock("endDivision"); PHINode* node = PHINode::Create(val1->getType(), 2, "", endBlock); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; @@ -1300,8 +1300,8 @@ void JavaJIT::compileOpcodes(Reader& rea if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantLongZero, ""); - BasicBlock* ifFalse = createBasicBlock("non null div"); - BasicBlock* ifTrue = createBasicBlock("null div"); + BasicBlock* ifFalse = createBasicBlock("nonNullDiv"); + BasicBlock* ifTrue = createBasicBlock("nullDiv"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; @@ -1339,8 +1339,8 @@ void JavaJIT::compileOpcodes(Reader& rea if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantZero, ""); - BasicBlock* ifFalse = createBasicBlock("non null rem"); - BasicBlock* ifTrue = createBasicBlock("null rem"); + BasicBlock* ifFalse = createBasicBlock("nonNullRem"); + BasicBlock* ifTrue = createBasicBlock("nullRem"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; @@ -1349,8 +1349,8 @@ void JavaJIT::compileOpcodes(Reader& rea } Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantMinusOne, ""); - BasicBlock* ifFalse = createBasicBlock("non -1 rem"); - BasicBlock* endBlock = createBasicBlock("end block"); + BasicBlock* ifFalse = createBasicBlock("nonMinusOneRem"); + BasicBlock* endBlock = createBasicBlock("endBlock"); PHINode* node = PHINode::Create(val1->getType(), 2, "", endBlock); node->addIncoming(intrinsics->constantZero, currentBlock); BranchInst::Create(endBlock, ifFalse, cmp, currentBlock); @@ -1372,8 +1372,8 @@ void JavaJIT::compileOpcodes(Reader& rea if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantLongZero, ""); - BasicBlock* ifFalse = createBasicBlock("non null div"); - BasicBlock* ifTrue = createBasicBlock("null div"); + BasicBlock* ifFalse = createBasicBlock("nonNullDiv"); + BasicBlock* ifTrue = createBasicBlock("nullDiv"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; @@ -1911,7 +1911,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("false IFEQ"); + BasicBlock* ifFalse = createBasicBlock("falseIFEQ"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -1928,7 +1928,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("false IFNE"); + BasicBlock* ifFalse = createBasicBlock("falseIFNE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -1944,7 +1944,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("false IFLT"); + BasicBlock* ifFalse = createBasicBlock("falseIFLT"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -1960,7 +1960,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGE, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("false IFGE"); + BasicBlock* ifFalse = createBasicBlock("falseIFGE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -1976,7 +1976,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGT, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("false IFGT"); + BasicBlock* ifFalse = createBasicBlock("falseIFGT"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -1992,7 +1992,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLE, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("false IFLE"); + BasicBlock* ifFalse = createBasicBlock("falseIFLE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2007,7 +2007,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("false IF_ICMPEQ"); + BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPEQ"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2022,7 +2022,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("false IF_ICMPNE"); + BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPNE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2037,7 +2037,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("false IF_IFCMPLT"); + BasicBlock* ifFalse = createBasicBlock("falseIF_IFCMPLT"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2052,7 +2052,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGE, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("false IF_ICMPGE"); + BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPGE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2067,7 +2067,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGT, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("false IF_ICMPGT"); + BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPGT"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2082,7 +2082,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLE, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("false IF_ICMPLE"); + BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPLE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2097,7 +2097,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("false IF_ACMPEQ"); + BasicBlock* ifFalse = createBasicBlock("falseIF_ACMPEQ"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2112,7 +2112,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("false IF_ACMPNE"); + BasicBlock* ifFalse = createBasicBlock("falseIF_ACMPNE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2178,7 +2178,7 @@ void JavaJIT::compileOpcodes(Reader& rea for (sint32 cur = low; cur < high; ++cur) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, ConstantInt::get(type, cur), index, ""); - BasicBlock* falseBlock = createBasicBlock("continue tableswitch"); + BasicBlock* falseBlock = createBasicBlock("continueTableswitch"); Opinfo& info = opcodeInfos[tmp + reader.readU4()]; i += 4; branch(cmp, info.newBlock, falseBlock, currentBlock, info); @@ -2208,7 +2208,7 @@ void JavaJIT::compileOpcodes(Reader& rea i += 4; Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, key, ""); - BasicBlock* falseBlock = createBasicBlock("continue lookupswitch"); + BasicBlock* falseBlock = createBasicBlock("continueLookupswitch"); Opinfo& info = opcodeInfos[tmp + reader.readU4()]; i += 4; branch(cmp, info.newBlock, falseBlock, currentBlock, info); @@ -2474,22 +2474,22 @@ void JavaJIT::compileOpcodes(Reader& rea Value* args[2] = { obj, clVar }; Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj, intrinsics->JavaObjectNullConstant, ""); - BasicBlock* endBlock = createBasicBlock("end type compare"); + BasicBlock* endBlock = createBasicBlock("endTypeCompare"); PHINode* node = PHINode::Create(Type::getInt1Ty(*llvmContext), 2, "", endBlock); if (checkcast) { - exceptionCheckcast = createBasicBlock("false checkcast"); + exceptionCheckcast = createBasicBlock("falseCheckcast"); - endCheckcast = createBasicBlock("null checkcast"); - BasicBlock* ifFalse = createBasicBlock("non null checkcast"); + endCheckcast = createBasicBlock("nullCheckcast"); + BasicBlock* ifFalse = createBasicBlock("nonNullCheckcast"); BranchInst::Create(endCheckcast, ifFalse, cmp, currentBlock); currentBlock = exceptionCheckcast; throwRuntimeException(intrinsics->ClassCastExceptionFunction, args, 2); currentBlock = ifFalse; } else { - BasicBlock* ifFalse = createBasicBlock("false type compare"); + BasicBlock* ifFalse = createBasicBlock("falseTypeCompare"); BranchInst::Create(endBlock, ifFalse, cmp, currentBlock); node->addIncoming(ConstantInt::getFalse(*llvmContext), currentBlock); currentBlock = ifFalse; @@ -2607,7 +2607,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* nil = Constant::getNullValue(val->getType()); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, nil, ""); - BasicBlock* ifFalse = createBasicBlock("true IFNULL"); + BasicBlock* ifFalse = createBasicBlock("trueIFNULL"); Opinfo& ifTrueInfo = opcodeInfos[tmp + reader.readS2()]; i += 2; BasicBlock* ifTrue = ifTrueInfo.newBlock; @@ -2622,7 +2622,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* nil = Constant::getNullValue(val->getType()); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, val, nil, ""); - BasicBlock* ifFalse = createBasicBlock("false IFNONNULL"); + BasicBlock* ifFalse = createBasicBlock("falseIFNONNULL"); Opinfo& ifTrueInfo = opcodeInfos[tmp + reader.readS2()]; i += 2; BasicBlock* ifTrue = ifTrueInfo.newBlock; Modified: vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp (original) +++ vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp Wed Nov 20 11:07:04 2013 @@ -287,8 +287,8 @@ bool LowerConstantCalls::runOnFunction(F Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, Del, intrinsics->JavaObjectNullConstant, ""); - BasicBlock* NoDelegatee = BasicBlock::Create(*Context, "No delegatee", &F); - BasicBlock* DelegateeOK = BasicBlock::Create(*Context, "Delegatee OK", &F); + BasicBlock* NoDelegatee = BasicBlock::Create(*Context, "noDelegatee", &F); + BasicBlock* DelegateeOK = BasicBlock::Create(*Context, "delegateeOK", &F); BranchInst::Create(NoDelegatee, DelegateeOK, cmp, CI); PHINode* phi = PHINode::Create(intrinsics->JavaObjectType, 2, "", DelegateeOK); phi->addIncoming(Del, CI->getParent()); @@ -398,8 +398,8 @@ bool LowerConstantCalls::runOnFunction(F Value* test = new ICmpInst(CI, ICmpInst::ICMP_EQ, arg1, intrinsics->constantPtrNull, ""); - BasicBlock* trueCl = BasicBlock::Create(*Context, "Ctp OK", &F); - BasicBlock* falseCl = BasicBlock::Create(*Context, "Ctp Not OK", &F); + BasicBlock* trueCl = BasicBlock::Create(*Context, "CtpOK", &F); + BasicBlock* falseCl = BasicBlock::Create(*Context, "CtpNotOK", &F); PHINode* node = llvm::PHINode::Create(returnType, 2, "", trueCl); node->addIncoming(arg1, CI->getParent()); BranchInst::Create(falseCl, trueCl, test, CI); @@ -465,8 +465,8 @@ bool LowerConstantCalls::runOnFunction(F Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, LoadedGV, init, ""); - BasicBlock* OKBlock = BasicBlock::Create(*Context, "", &F); - BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "", &F); + BasicBlock* OKBlock = BasicBlock::Create(*Context, "OK", &F); + BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "NotOK", &F); PHINode* node = PHINode::Create(intrinsics->VTType, 2, "", OKBlock); node->addIncoming(LoadedGV, CI->getParent()); @@ -509,8 +509,8 @@ bool LowerConstantCalls::runOnFunction(F BasicBlock* EndBlock = II->getParent()->splitBasicBlock(II); I->getParent()->getTerminator()->eraseFromParent(); - BasicBlock* CurEndBlock = BasicBlock::Create(*Context, "", &F); - BasicBlock* FailedBlock = BasicBlock::Create(*Context, "", &F); + BasicBlock* CurEndBlock = BasicBlock::Create(*Context, "currentEnd", &F); + BasicBlock* FailedBlock = BasicBlock::Create(*Context, "failed", &F); PHINode* node = PHINode::Create(Type::getInt1Ty(*Context), 2, "", CurEndBlock); ConstantInt* CC = ConstantInt::get(Type::getInt32Ty(*Context), 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=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll (original) +++ vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll Wed Nov 20 11:07:04 2013 @@ -27,6 +27,10 @@ ;;; Field 2: The static instance %TaskClassMirror = type { i8, i1, i8* } +;;; Field 0: callerNode +;;; Field 1: data +%StackEmbeddedListNode = type { %StackEmbeddedListNode*, [1 x i8*] } + %CircularBase = type { %VT*, %CircularBase*, %CircularBase* } ;;; Field 0: the parent (circular base) @@ -41,7 +45,11 @@ ;;; field 9: void* routine ;;; field 10: void* lastKnownFrame ;;; field 11: void* lastExceptionBuffer -%Thread = type { %CircularBase, i32, i8*, i8*, i1, i1, i1, i8*, i8*, i8*, i8*, i8* } +;;; field 12: void* stackEmbeddedListHead ( 1 = vmkit::StackEmbeddedListNodeCountPerThread ) +%Thread = type { + %CircularBase, i32, i8*, i8*, i1, i1, i1, i8*, i8*, i8*, i8*, i8*, + [1 x %StackEmbeddedListNode*] +} %JavaThread = type { %MutatorThread, i8*, %JavaObject* } @@ -184,7 +192,7 @@ declare i8* @getConstantPoolAt(i8* (%Jav ;;; j3VirtualTableLookup - Look up the offset in a virtual table of a ;;; specific function. -declare i32 @j3VirtualTableLookup(%JavaClass*, i32, i32*, %JavaObject*) +declare %JavaMethod* @j3VirtualTableLookup(%JavaClass*, i32, %JavaMethod**, %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 Modified: vmkit/trunk/lib/j3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaClass.h?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/j3/VMCore/JavaClass.h Wed Nov 20 11:07:04 2013 @@ -1023,12 +1023,15 @@ private: jvalue* marshalArguments(vmkit::ThreadAllocator& allocator, va_list ap); template - TYPE invokeSpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) __attribute__((noinline)) { + TYPE invokeSpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, + void* buf) __attribute__((noinline)) + { llvm_gcroot(obj, 0); verifyNull(obj); void* func = this->compiledPtr(); - FUNC_TYPE_VIRTUAL_BUF call = (FUNC_TYPE_VIRTUAL_BUF)getSignature()->getVirtualCallBuf(); + FUNC_TYPE_VIRTUAL_BUF call = + (FUNC_TYPE_VIRTUAL_BUF)getSignature()->getVirtualCallBuf(); JavaThread* th = JavaThread::get(); th->startJava(); @@ -1043,11 +1046,14 @@ private: } template - TYPE invokeVirtualBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) __attribute__((noinline)) { + TYPE invokeVirtualBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, + void* buf) __attribute__((noinline)) + { llvm_gcroot(obj, 0); UserCommonClass* theClass = JavaObject::getClass(obj); - UserClass* objCl = theClass->isArray() ? theClass->super : theClass->asClass(); + UserClass* objCl = + theClass->isArray() ? theClass->super : theClass->asClass(); JavaMethod* meth = this; if ((objCl != classDef) && !isFinal(access)) { @@ -1057,18 +1063,22 @@ private: assert(objCl->isSubclassOf(meth->classDef) && "Wrong type"); - return meth->invokeSpecialBuf(vm, cl, obj, buf); + return meth->invokeSpecialBuf( + vm, cl, obj, buf); } template - TYPE invokeStaticBuf(Jnjvm* vm, UserClass* cl, void* buf) __attribute__((noinline)) { + TYPE invokeStaticBuf(Jnjvm* vm, UserClass* cl, + void* buf) __attribute__((noinline)) + { if (!cl->isReady()) { cl->resolveClass(); cl->initialiseClass(vm); } void* func = this->compiledPtr(); - FUNC_TYPE_STATIC_BUF call = (FUNC_TYPE_STATIC_BUF)getSignature()->getStaticCallBuf(); + FUNC_TYPE_STATIC_BUF call = + (FUNC_TYPE_STATIC_BUF)getSignature()->getStaticCallBuf(); JavaThread* th = JavaThread::get(); th->startJava(); @@ -1083,29 +1093,38 @@ private: } template - TYPE invokeVirtualAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap) __attribute__((noinline)) { + TYPE invokeVirtualAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, + va_list ap) __attribute__((noinline)) + { llvm_gcroot(obj, 0); assert(cl && "Class is NULL"); vmkit::ThreadAllocator allocator; jvalue* buffer = marshalArguments(allocator, ap); - return invokeVirtualBuf(vm, cl, obj, buffer); + return invokeVirtualBuf( + vm, cl, obj, buffer); } template - TYPE invokeSpecialAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap) __attribute__((noinline)) { + TYPE invokeSpecialAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, + va_list ap) __attribute__((noinline)) + { llvm_gcroot(obj, 0); assert(cl && "Class is NULL"); vmkit::ThreadAllocator allocator; jvalue* buffer = marshalArguments(allocator, ap); - return invokeSpecialBuf(vm, cl, obj, buffer); + return invokeSpecialBuf( + vm, cl, obj, buffer); } template - TYPE invokeStaticAP(Jnjvm* vm, UserClass* cl, va_list ap) __attribute__((noinline)) { + TYPE invokeStaticAP(Jnjvm* vm, UserClass* cl, + va_list ap) __attribute__((noinline)) + { assert(cl && "Class is NULL"); vmkit::ThreadAllocator allocator; jvalue* buffer = marshalArguments(allocator, ap); - return invokeStaticBuf(vm, cl, buffer); + return invokeStaticBuf( + vm, cl, buffer); } #define JavaMethod_DECL_INVOKE_VA(TYPE, TYPE_NAME) \ Modified: vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp Wed Nov 20 11:07:04 2013 @@ -69,19 +69,19 @@ jvalue* JavaMethod::marshalArguments(vmk return res; \ } \ TYPE JavaMethod::invoke##TYPE_NAME##Special(Jnjvm* vm, UserClass* cl, JavaObject* obj, ...) { \ - llvm_gcroot(obj, 0); \ - va_list ap; \ - va_start(ap, obj); \ - TYPE res = invokeSpecialAP(vm, cl, obj, ap); \ - va_end(ap); \ - return res; \ + llvm_gcroot(obj, 0); \ + va_list ap; \ + va_start(ap, obj); \ + TYPE res = invokeSpecialAP(vm, cl, obj, ap); \ + va_end(ap); \ + return res; \ } \ TYPE JavaMethod::invoke##TYPE_NAME##Static(Jnjvm* vm, UserClass* cl, ...) { \ - va_list ap; \ - va_start(ap, cl); \ - TYPE res = invokeStaticAP(vm, cl, ap); \ - va_end(ap); \ - return res; \ + va_list ap; \ + va_start(ap, cl); \ + TYPE res = invokeStaticAP(vm, cl, ap); \ + va_end(ap); \ + return res; \ } #define JavaMethod_INVOKE_AP(TYPE, TYPE_NAME, FUNC_TYPE_VIRTUAL_AP, FUNC_TYPE_STATIC_AP, FUNC_TYPE_VIRTUAL_BUF, FUNC_TYPE_STATIC_BUF) \ @@ -104,7 +104,7 @@ jvalue* JavaMethod::marshalArguments(vmk } \ TYPE JavaMethod::invoke##TYPE_NAME##SpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) { \ llvm_gcroot(obj, 0); \ - return invokeSpecialBuf(vm, cl, obj, buf); \ + return invokeSpecialBuf(vm, cl, obj, buf); \ } \ TYPE JavaMethod::invoke##TYPE_NAME##StaticBuf(Jnjvm* vm, UserClass* cl, void* buf) { \ return invokeStaticBuf(vm, cl, buf); \ Modified: vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp Wed Nov 20 11:07:04 2013 @@ -110,10 +110,9 @@ extern "C" void* j3StaticFieldLookup(Use } // Throws if the method is not found. -extern "C" uint32 j3VirtualTableLookup(UserClass* caller, uint32 index, - uint32* offset, JavaObject* obj) { +extern "C" void* j3VirtualTableLookup(UserClass* caller, uint32 index, + void** javaMethod, JavaObject* obj) { llvm_gcroot(obj, 0); - uint32 res = 0; UserCommonClass* cl = 0; const UTF8* utf8 = 0; @@ -134,15 +133,13 @@ extern "C" uint32 j3VirtualTableLookup(U JavaObject::getClass(obj)->asClass(); dmeth = lookup->lookupMethod(utf8, sign->keyName, false, true, 0); } else { - *offset = dmeth->offset; + *javaMethod = dmeth; } assert(dmeth->classDef->isInitializing() && "Class not ready in a virtual lookup."); - res = dmeth->offset; - - return res; + return dmeth; } // Throws if the class is not found. Modified: vmkit/trunk/lib/j3/VMCore/JavaString.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaString.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaString.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JavaString.cpp Wed Nov 20 11:07:04 2013 @@ -128,4 +128,20 @@ std::ostream& operator << (std::ostream& return os; } +const UTF8* JavaString::toUTF8(const JavaString* self, UTF8Map* hashMap) +{ + if (!self) return NULL; + if (!hashMap) { + Jnjvm* vm = JavaThread::get()->getJVM(); + hashMap = vm->bootstrapLoader->hashUTF8; + } + + const j3::ArrayUInt16 *array = j3::JavaString::getValue(self); + const j3::ArrayUInt16::ElementType *elts = + j3::ArrayUInt16::getElements(array); + size_t count = j3::ArrayUInt16::getSize(array); + + return hashMap->lookupOrCreateReader(elts, count); +} + } Modified: vmkit/trunk/lib/j3/VMCore/JavaString.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaString.h?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaString.h (original) +++ vmkit/trunk/lib/j3/VMCore/JavaString.h Wed Nov 20 11:07:04 2013 @@ -59,6 +59,7 @@ class JavaString : public JavaObject { static char* strToAsciiz(const JavaString* self); static char* strToAsciiz(const JavaString* self, vmkit::ThreadAllocator* allocator); static const ArrayUInt16* strToArray(JavaString* self, Jnjvm* vm); + static const UTF8* toUTF8(const JavaString* self, UTF8Map* hashMap); /// javaToInternal - Replaces all '/' into '.'. static const UTF8* javaToInternal(const JavaString* self, UTF8Map* map); Modified: vmkit/trunk/lib/j3/VMCore/JavaThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaThread.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaThread.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JavaThread.cpp Wed Nov 20 11:07:04 2013 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include +#include #include "vmkit/Locks.h" #include "vmkit/Thread.h" @@ -132,7 +133,7 @@ void JavaThread::printJavaBacktrace() { while (vmkit::FrameInfo* FI = Walker.get()) { if (FI->Metadata != NULL) { - MyVM->printMethod(FI, Walker.ip, Walker.addr); + MyVM->printMethod(FI, Walker.returnAddress, Walker.callFrameAddress); } ++Walker; } Modified: vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp Wed Nov 20 11:07:04 2013 @@ -44,7 +44,6 @@ #include "Reader.h" #include "Zip.h" - using namespace j3; using namespace std; Modified: vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp (original) +++ vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp Wed Nov 20 11:07:04 2013 @@ -103,7 +103,7 @@ void CooperativeCollectionRV::join() { th->inRV = true; lockRV(); - th->setLastSP(System::GetCallerAddress()); + th->setLastSP(System::GetCallFrameAddress()); th->joinedRV = true; another_mark(); waitEndOfRV(); Modified: vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp (original) +++ vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp Wed Nov 20 11:07:04 2013 @@ -336,8 +336,8 @@ bool FatLock::acquire(gc* obj, LockSyste // if (lockingThreads == 0) // table.deallocate(this); - word_t methodIP = System::GetCallerAddress(); - methodIP = System::GetIPFromCallerAddress(methodIP); + word_t methodIP = System::GetCallFrameAddress(); + methodIP = System::GetReturnAddressOfCallFrame(methodIP); Thread::get()->throwNullPointerException(methodIP); } Modified: vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc (original) +++ vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc Wed Nov 20 11:07:04 2013 @@ -38,7 +38,7 @@ void Handler::UpdateRegistersForNPE() { void Handler::UpdateRegistersForStackOverflow() { word_t alt_stack = vmkit::Thread::get()->GetAlternativeStackStart(); - ((ucontext_t*)context)->uc_mcontext.gregs[REG_RDI] = System::GetIPFromCallerAddress(((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP]); + ((ucontext_t*)context)->uc_mcontext.gregs[REG_RDI] = System::GetReturnAddressOfCallFrame(((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP]); ((ucontext_t*)context)->uc_mcontext.gregs[REG_RSI] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP]; ((ucontext_t*)context)->uc_mcontext.gregs[REG_RSP] = alt_stack; ((ucontext_t*)context)->uc_mcontext.gregs[REG_RIP] = (word_t)HandleStackOverflow; Modified: vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc (original) +++ vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc Wed Nov 20 11:07:04 2013 @@ -40,7 +40,7 @@ void Handler::UpdateRegistersForNPE() { void Handler::UpdateRegistersForStackOverflow() { word_t alt_stack = vmkit::Thread::get()->GetAlternativeStackStart(); - ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBX] = System::GetIPFromCallerAddress(((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP]); + ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBX] = System::GetReturnAddressOfCallFrame(((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP]); ((ucontext_t*)context)->uc_mcontext.gregs[REG_EAX] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP]; ((ucontext_t*)context)->uc_mcontext.gregs[REG_ESP] = alt_stack; ((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP] = (word_t)HandleStackOverflow; Modified: vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp (original) +++ vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp Wed Nov 20 11:07:04 2013 @@ -60,7 +60,7 @@ void Thread::joinRVAfterLeave(word_t sav void Thread::startKnownFrame(KnownFrame& F) { // Get the caller of this function - word_t cur = System::GetCallerAddress(); + word_t cur = System::GetCallFrameAddress(); F.previousFrame = lastKnownFrame; F.currentFP = cur; // This is used as a marker. @@ -75,12 +75,12 @@ void Thread::endKnownFrame() { void Thread::startUnknownFrame(KnownFrame& F) { // Get the caller of this function - word_t cur = System::GetCallerAddress(); + word_t cur = System::GetCallFrameAddress(); // Get the caller of the caller. - cur = System::GetCallerOfAddress(cur); + cur = System::GetCallerCallFrame(cur); F.previousFrame = lastKnownFrame; F.currentFP = cur; - F.currentIP = System::GetIPFromCallerAddress(cur); + F.currentIP = System::GetReturnAddressOfCallFrame(cur); lastKnownFrame = &F; } @@ -97,7 +97,7 @@ void Thread::printBacktrace() { StackWalker Walker(this); while (FrameInfo* FI = Walker.get()) { - MyVM->printMethod(FI, Walker.ip, Walker.addr); + MyVM->printMethod(FI, Walker.returnAddress, Walker.callFrameAddress); ++Walker; } } @@ -124,42 +124,44 @@ uint32_t Thread::getFrameContextLength() } FrameInfo* StackWalker::get() { - if (addr == thread->baseSP) return 0; - ip = System::GetIPFromCallerAddress(addr); - return thread->MyVM->IPToFrameInfo(ip); + if (callFrameAddress == thread->baseSP) return 0; + returnAddress = System::GetReturnAddressOfCallFrame(callFrameAddress); + return thread->MyVM->IPToFrameInfo(returnAddress); } word_t StackWalker::operator*() { - if (addr == thread->baseSP) return 0; - ip = System::GetIPFromCallerAddress(addr); - return ip; + if (callFrameAddress == thread->baseSP) return 0; + returnAddress = System::GetReturnAddressOfCallFrame(callFrameAddress); + return returnAddress; } void StackWalker::operator++() { - if (addr != thread->baseSP) { - assert((addr < thread->baseSP) && "Corrupted stack"); - assert((addr < System::GetCallerOfAddress(addr)) && "Corrupted stack"); - if ((frame != NULL) && (addr == frame->currentFP)) { + if (callFrameAddress != thread->baseSP) { + assert((callFrameAddress < thread->baseSP) && "Corrupted stack"); + assert((callFrameAddress < System::GetCallerCallFrame(callFrameAddress)) && "Corrupted stack"); + if ((frame != NULL) && (callFrameAddress == frame->currentFP)) { assert(frame->currentIP == 0); frame = frame->previousFrame; assert(frame != NULL); assert(frame->currentIP != 0); - addr = frame->currentFP; + callFrameAddress = frame->currentFP; frame = frame->previousFrame; } else { - addr = System::GetCallerOfAddress(addr); + callFrameAddress = System::GetCallerCallFrame(callFrameAddress); } } } -StackWalker::StackWalker(vmkit::Thread* th) { +StackWalker::StackWalker(vmkit::Thread* th) : + returnAddress(0) +{ thread = th; frame = th->lastKnownFrame; if (vmkit::Thread::get() == th) { - addr = System::GetCallerAddress(); - addr = System::GetCallerOfAddress(addr); + callFrameAddress = System::GetCallFrameAddress(); + callFrameAddress = System::GetCallerCallFrame(callFrameAddress); } else { - addr = th->waitOnSP(); + callFrameAddress = th->waitOnSP(); if (frame) { // if (frame->currentFP < addr) { // fprintf(stderr, "Error in thread with pointer %p because %x < %x\n", th, frame->currentFP, addr); @@ -167,9 +169,9 @@ StackWalker::StackWalker(vmkit::Thread* // } - assert(frame->currentFP >= addr); + assert(frame->currentFP >= callFrameAddress); } - if (frame && (addr == frame->currentFP)) { + if (frame && (callFrameAddress == frame->currentFP)) { frame = frame->previousFrame; // Let this be called from JNI, as in // OpenJDK's JVM_FillInStackTrace: @@ -178,14 +180,23 @@ StackWalker::StackWalker(vmkit::Thread* assert((frame == NULL) || (frame->currentIP == 0)); } } - assert(addr && "No address to start with"); + assert(callFrameAddress && "No address to start with"); } +StackWalker::StackWalker() : + returnAddress(0) +{ + thread = vmkit::Thread::get(); + frame = thread->lastKnownFrame; + callFrameAddress = System::GetCallFrameAddress(); + callFrameAddress = System::GetCallerCallFrame(callFrameAddress); + assert(callFrameAddress && "No address to start with"); +} void Thread::scanStack(word_t closure) { StackWalker Walker(this); while (FrameInfo* MI = Walker.get()) { - MethodInfoHelper::scan(closure, MI, Walker.ip, Walker.addr); + MethodInfoHelper::scan(closure, MI, Walker.returnAddress, Walker.callFrameAddress); ++Walker; } } @@ -195,11 +206,11 @@ void Thread::enterUncooperativeCode(uint if (!inRV) { assert(!lastSP && "SP already set when entering uncooperative code"); // Get the caller. - word_t temp = System::GetCallerAddress(); + word_t temp = System::GetCallFrameAddress(); // Make sure to at least get the caller of the caller. ++level; while (level--) - temp = System::GetCallerOfAddress(temp); + temp = System::GetCallerCallFrame(temp); // The cas is not necessary, but it does a memory barrier. __sync_bool_compare_and_swap(&lastSP, 0, temp); if (doYield) joinRVBeforeEnter(); @@ -337,7 +348,11 @@ extern void sigsTermHandler(int n, sigin /// given routine of th. /// void Thread::internalThreadStart(vmkit::Thread* th) { - th->baseSP = System::GetCallerAddress(); + th->baseSP = System::GetCallFrameAddress(); + +#if JAVA_INTERFACE_CALL_STACK + th->stackEmbeddedListHead[j3::StackEmbeddedListIntendedCaller] = NULL; +#endif // Set the alternate stack as the second page of the thread's // stack. Modified: vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp (original) +++ vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp Wed Nov 20 11:07:04 2013 @@ -21,7 +21,7 @@ namespace vmkit { void MethodInfoHelper::scan(word_t closure, FrameInfo* FI, word_t ip, word_t addr) { //word_t spaddr = (word_t)addr + FI->FrameSize + sizeof(void*); - word_t spaddr = System::GetCallerOfAddress(addr); + word_t spaddr = System::GetCallerCallFrame(addr); for (uint16 i = 0; i < FI->NumLiveOffsets; ++i) { word_t obj = *(word_t*)(spaddr + FI->LiveOffsets[i]); // Verify that obj does not come from a JSR bytecode. Modified: vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp?rev=195257&r1=195256&r2=195257&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp (original) +++ vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp Wed Nov 20 11:07:04 2013 @@ -41,17 +41,6 @@ uint32 UTF8::readerHasher(const uint16* return (r1 & 255) + ((r0 & 255) << 8); } -int UTF8::compare(const char *s) const -{ - int len = strlen(s); - int diff = size - len; - if (diff != 0) return diff; - - for (int i = 0; (i < size) && (diff == 0); ++i) - diff = (char)(elements[i]) - s[i]; - return diff; -} - std::string& UTF8::toString(std::string& buffer) const { buffer.resize(size); @@ -64,7 +53,7 @@ std::string& UTF8::toString(std::string& std::ostream& operator << (std::ostream& os, const UTF8& utf8) { - for (ssize_t i = 0; i < utf8.size; ++i) + for (ssize_t i = 0; (i < utf8.size) && (utf8.elements[i] != 0); ++i) os << (std::string::value_type)(utf8.elements[i]); return os; } From koutheir at gmail.com Wed Nov 20 09:12:50 2013 From: koutheir at gmail.com (Koutheir Attouchi) Date: Wed, 20 Nov 2013 17:12:50 -0000 Subject: [vmkit-commits] [vmkit] r195258 - Back-porting generic new features from work done on OSGi bundles monitoring in J3. Message-ID: <20131120171250.B18C32A6C029@llvm.org> Author: koutheir Date: Wed Nov 20 11:12:50 2013 New Revision: 195258 URL: http://llvm.org/viewvc/llvm-project?rev=195258&view=rev Log: Back-porting generic new features from work done on OSGi bundles monitoring in J3. Added: vmkit/trunk/include/vmkit/StackEmbeddedList.h (with props) Added: vmkit/trunk/include/vmkit/StackEmbeddedList.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/StackEmbeddedList.h?rev=195258&view=auto ============================================================================== --- vmkit/trunk/include/vmkit/StackEmbeddedList.h (added) +++ vmkit/trunk/include/vmkit/StackEmbeddedList.h Wed Nov 20 11:12:50 2013 @@ -0,0 +1,49 @@ + +#if JAVA_INTERFACE_CALL_STACK + +#ifndef STACK_EMBEDDED_LIST_NODE_H_ +#define STACK_EMBEDDED_LIST_NODE_H_ + +#include "vmkit/System.h" + +namespace vmkit { + +class Thread; + +} + +namespace j3 { + +class JavaMethod; + +enum StackEmbeddedListID { + StackEmbeddedListIntendedCaller = 0, + + StackEmbeddedListNodeCountPerThread +}; + +struct StackEmbeddedListNode +{ + StackEmbeddedListNode* callerNode; + word_t data[1]; + + void initialize() { + callerNode = NULL; + memset(data, 0, sizeof(*data) * StackEmbeddedListNodeCountPerThread); + } + + void dump() const __attribute__((noinline)); +}; + +} + +extern "C" void pushIntendedInvokedMethodNode( + vmkit::Thread* thread, j3::StackEmbeddedListNode* node, + j3::JavaMethod* intendedMethod); + +extern "C" void popIntendedInvokedMethodNode( + vmkit::Thread* thread, j3::StackEmbeddedListNode* node); + +#endif + +#endif Propchange: vmkit/trunk/include/vmkit/StackEmbeddedList.h ------------------------------------------------------------------------------ svn:mime-type = text/plain From gael.thomas at lip6.fr Fri Nov 22 04:54:09 2013 From: gael.thomas at lip6.fr (Gael Thomas) Date: Fri, 22 Nov 2013 12:54:09 -0000 Subject: [vmkit-commits] [vmkit] r195454 - commit test Message-ID: <20131122125409.2AB5A2A6C029@llvm.org> Author: gthomas Date: Fri Nov 22 06:54:08 2013 New Revision: 195454 URL: http://llvm.org/viewvc/llvm-project?rev=195454&view=rev Log: commit test Modified: vmkit/trunk/README.TXT Modified: vmkit/trunk/README.TXT URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/README.TXT?rev=195454&r1=195453&r2=195454&view=diff ============================================================================== --- vmkit/trunk/README.TXT (original) +++ vmkit/trunk/README.TXT Fri Nov 22 06:54:08 2013 @@ -118,3 +118,4 @@ svn co https://YOUR_USER_NAME at llvm.org/s * Build it: make -j12 + From gael.thomas at lip6.fr Mon Nov 25 01:16:35 2013 From: gael.thomas at lip6.fr (Gael Thomas) Date: Mon, 25 Nov 2013 09:16:35 -0000 Subject: [vmkit-commits] [vmkit] r195627 - delete useless multi-vm and py-vm, create a mcjit branch Message-ID: <20131125091636.24B862A6C029@llvm.org> Author: gthomas Date: Mon Nov 25 03:16:34 2013 New Revision: 195627 URL: http://llvm.org/viewvc/llvm-project?rev=195627&view=rev Log: delete useless multi-vm and py-vm, create a mcjit branch Added: vmkit/branches/mcjit/ Removed: vmkit/branches/multi-vm/ vmkit/branches/py-vm/ From gael.thomas at lip6.fr Mon Nov 25 01:27:11 2013 From: gael.thomas at lip6.fr (Gael Thomas) Date: Mon, 25 Nov 2013 09:27:11 -0000 Subject: [vmkit-commits] [vmkit] r195628 - initial import Message-ID: <20131125092712.EB5D82A6C029@llvm.org> Author: gthomas Date: Mon Nov 25 03:27:09 2013 New Revision: 195628 URL: http://llvm.org/viewvc/llvm-project?rev=195628&view=rev Log: initial import Added: vmkit/branches/mcjit/Makefile vmkit/branches/mcjit/Makefile.config vmkit/branches/mcjit/Makefile.config.in vmkit/branches/mcjit/Makefile.rules vmkit/branches/mcjit/autoconf/ vmkit/branches/mcjit/autoconf/configure.ac vmkit/branches/mcjit/autoconf/install-sh (with props) vmkit/branches/mcjit/configure (with props) vmkit/branches/mcjit/include/ vmkit/branches/mcjit/include/j3/ vmkit/branches/mcjit/include/j3/j3.h vmkit/branches/mcjit/include/j3/j3bc.def vmkit/branches/mcjit/include/j3/j3class.h vmkit/branches/mcjit/include/j3/j3classloader.h vmkit/branches/mcjit/include/j3/j3codegen.h vmkit/branches/mcjit/include/j3/j3codegenvar.h vmkit/branches/mcjit/include/j3/j3config.h vmkit/branches/mcjit/include/j3/j3config.h.in vmkit/branches/mcjit/include/j3/j3constants.h vmkit/branches/mcjit/include/j3/j3jni.h vmkit/branches/mcjit/include/j3/j3lib.h vmkit/branches/mcjit/include/j3/j3mangler.h vmkit/branches/mcjit/include/j3/j3method.h vmkit/branches/mcjit/include/j3/j3object.h vmkit/branches/mcjit/include/j3/j3options.h vmkit/branches/mcjit/include/j3/j3reader.h vmkit/branches/mcjit/include/j3/j3thread.h vmkit/branches/mcjit/include/j3/j3typesdef.h vmkit/branches/mcjit/include/j3/j3zip.h vmkit/branches/mcjit/include/jni_md.h vmkit/branches/mcjit/include/safepoint.h vmkit/branches/mcjit/include/vmkit/ vmkit/branches/mcjit/include/vmkit/allocator.h vmkit/branches/mcjit/include/vmkit/gc.h vmkit/branches/mcjit/include/vmkit/names.h vmkit/branches/mcjit/include/vmkit/thread.h vmkit/branches/mcjit/include/vmkit/util.h vmkit/branches/mcjit/include/vmkit/vmkit.h vmkit/branches/mcjit/lib/ vmkit/branches/mcjit/lib/Makefile vmkit/branches/mcjit/lib/j3/ vmkit/branches/mcjit/lib/j3/Makefile vmkit/branches/mcjit/lib/j3/openjdk/ vmkit/branches/mcjit/lib/j3/openjdk/Makefile vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc vmkit/branches/mcjit/lib/j3/openjdk/jvm.h vmkit/branches/mcjit/lib/j3/vm/ vmkit/branches/mcjit/lib/j3/vm/Makefile vmkit/branches/mcjit/lib/j3/vm/j3.cc vmkit/branches/mcjit/lib/j3/vm/j3class.cc vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc vmkit/branches/mcjit/lib/j3/vm/j3constants.cc vmkit/branches/mcjit/lib/j3/vm/j3jni.cc vmkit/branches/mcjit/lib/j3/vm/j3mangler.cc vmkit/branches/mcjit/lib/j3/vm/j3method.cc vmkit/branches/mcjit/lib/j3/vm/j3object.cc vmkit/branches/mcjit/lib/j3/vm/j3options.cc vmkit/branches/mcjit/lib/j3/vm/j3reader.cc vmkit/branches/mcjit/lib/j3/vm/j3thread.cc vmkit/branches/mcjit/lib/j3/vm/j3zip.cc vmkit/branches/mcjit/lib/vmkit/ vmkit/branches/mcjit/lib/vmkit/Makefile vmkit/branches/mcjit/lib/vmkit/allocator.cc vmkit/branches/mcjit/lib/vmkit/gc.cc vmkit/branches/mcjit/lib/vmkit/gcrootpass.cc vmkit/branches/mcjit/lib/vmkit/names.cc vmkit/branches/mcjit/lib/vmkit/thread.cc vmkit/branches/mcjit/lib/vmkit/util.cc vmkit/branches/mcjit/lib/vmkit/vmkit.cc vmkit/branches/mcjit/tools/ vmkit/branches/mcjit/tools/Makefile vmkit/branches/mcjit/tools/j3/ vmkit/branches/mcjit/tools/j3/Makefile vmkit/branches/mcjit/tools/j3/main.cc Added: vmkit/branches/mcjit/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/Makefile?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/Makefile (added) +++ vmkit/branches/mcjit/Makefile Mon Nov 25 03:27:09 2013 @@ -0,0 +1,10 @@ +#===- ./Makefile -------------------------------------------*- Makefile -*--===# +# +# The vmkit project +#===------------------------------------------------------------------------===# + +LEVEL := . + +DIRS := lib tools + +include $(LEVEL)/Makefile.rules Added: vmkit/branches/mcjit/Makefile.config URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/Makefile.config?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/Makefile.config (added) +++ vmkit/branches/mcjit/Makefile.config Mon Nov 25 03:27:09 2013 @@ -0,0 +1,33 @@ + +SHOPT=-Wl,-all_load -Wl,-compatibility_version,1 -Wl,-current_version,1 +EXEEXT= +SHLIBEXT=.dylib + +OPTIMIZED=0 +DEBUG=1 +ASSERT=1 + +PROJ_SRC_ROOT := $(subst //,/,/Users/gthomas/research/vmkit4/vmkit) +PROJ_OBJ_ROOT := $(subst //,/,/Users/gthomas/research/vmkit4/vmkit) + +CONFIG_FILES= Makefile.config include/j3/j3config.h +CONFIG_HEADERS= + +BUILD_NAME=Debug+Asserts + +GAWK=/opt/local/bin/gawk + +CLANG=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/clang +CLANGXX=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/clang++ +LLC=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/llc +LLNM=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/llvm-nm +LLOPT=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/opt +LLLINK=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/llvm-link + +LLVM_CXXFLAGS=-I/Users/gthomas/research/vmkit4/llvm/include -I/Users/gthomas/research/vmkit4/llvm/include -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fvisibility-inlines-hidden -fno-common -Woverloaded-virtual -Wcast-qual -I/Users/gthomas/research/vmkit4/llvm/include +LLVM_LIBS=-lLLVMInstrumentation -lLLVMIRReader -lLLVMAsmParser -lLLVMDebugInfo -lLLVMOption -lLLVMLTO -lLLVMLinker -lLLVMipo -lLLVMVectorize -lLLVMBitWriter -lLLVMBitReader -lLLVMTableGen -lLLVMR600CodeGen -lLLVMR600Desc -lLLVMR600Info -lLLVMR600AsmPrinter -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSystemZAsmPrinter -lLLVMHexagonCodeGen -lLLVMHexagonAsmPrinter -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMCppBackendCodeGen -lLLVMCppBackendInfo -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMSP430AsmPrinter -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMXCoreAsmPrinter -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMAArc! h64Disass embler -lLLVMAArch64CodeGen -lLLVMAArch64AsmParser -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMAArch64Utils -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMSparcCodeGen -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lgtest_main -lgtest -lLLVMMCDisassembler -lLLVMMCParser -lLLVMInterpreter -lLLVMMCJIT -lLLVMJIT -lLLVMCodeGen -lLLVMObjCARCOpts -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMExecutionEngine -lLLVMTarget -lLLVMMC -lLLVMObject -lLLVMCore -lLLVMSupport +LLVM_LDFLAGS=-L/Users/gthomas/research/vmkit4/llvm/Release+Asserts/lib -lz -lpthread -lcurses -lm + +OPENJDK_HOME=/Users/gthomas/research/vmkit4/jdk8/build/macosx-x86_64-normal-server-release/images/j2sdk-bundle/jdk1.8.0.jdk/Contents/Home/ + +OS=darwin Added: vmkit/branches/mcjit/Makefile.config.in URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/Makefile.config.in?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/Makefile.config.in (added) +++ vmkit/branches/mcjit/Makefile.config.in Mon Nov 25 03:27:09 2013 @@ -0,0 +1,33 @@ + +SHOPT=@SHOPT@ +EXEEXT=@EXEEXT@ +SHLIBEXT=@SHLIBEXT@ + +OPTIMIZED=@OPTIMIZED@ +DEBUG=@DEBUG@ +ASSERT=@ASSERT@ + +PROJ_SRC_ROOT := $(subst //,/, at abs_top_srcdir@) +PROJ_OBJ_ROOT := $(subst //,/, at abs_top_builddir@) + +CONFIG_FILES=@ac_config_files@ +CONFIG_HEADERS=@ac_config_headers@ + +BUILD_NAME=@BUILD_NAME@ + +GAWK=@GAWK@ + +CLANG=@CLANG@ +CLANGXX=@CLANGXX@ +LLC=@LLC@ +LLNM=@LLNM@ +LLOPT=@LLOPT@ +LLLINK=@LLLINK@ + +LLVM_CXXFLAGS=@LLVM_CXXFLAGS@ +LLVM_LIBS=@LLVM_LIBS@ +LLVM_LDFLAGS=@LLVM_LDFLAGS@ + +OPENJDK_HOME=@jdkhome@ + +OS=@OS@ \ No newline at end of file Added: vmkit/branches/mcjit/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/Makefile.rules?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/Makefile.rules (added) +++ vmkit/branches/mcjit/Makefile.rules Mon Nov 25 03:27:09 2013 @@ -0,0 +1,320 @@ + +-include $(LEVEL)/Makefile.config + +############################################################################### +# Configuration +############################################################################### +PROJ_OBJ_CWD:= $(call realpath, .) +PROJ_SRC_CWD:= $(call realpath, $(patsubst $(PROJ_OBJ_ROOT)%,$(PROJ_SRC_ROOT)%,$(PROJ_OBJ_CWD))) + +BUILD_DIR=$(PROJ_OBJ_CWD)/$(BUILD_NAME) +BIN_DIR=$(PROJ_OBJ_ROOT)/$(BUILD_NAME)/bin +LIB_DIR=$(PROJ_OBJ_ROOT)/$(BUILD_NAME)/lib + +############################################################################### +# Nice printing +############################################################################### +ifndef PROF +PROF=. +endif + +EchoMsg="[$(MAKECMDGOALS) $(PROF)]:" +Echo=@echo $(EchoMsg) + +ifndef VERBOSE + SUB_OPT=--no-print-directory -s + Verb:=@ +endif + +############################################################################### +# Compilation flags +############################################################################### +COMMON_FLAGS:=-Wall -Wno-return-type-c-linkage -Wno-varargs -Wno-unused-private-field -Werror -Wno-unused-variable \ + -I$(PROJ_SRC_ROOT)/include -I$(OPENJDK_HOME)/include -I$(OPENJDK_HOME)/include/$(OS) $(COMMON_FLAGS) \ + -fno-omit-frame-pointer + +ifeq ($(OPTIMIZED),1) + COMMON_FLAGS+=-O3 + LLCFLAGS+=-O=3 +else + COMMON_FLAGS+=-O0 + LLCFLAGS+=-O=0 +endif + +ifneq ($(DEBUG),0) + COMMON_FLAGS+=-g +endif + +LLCFLAGS+=-disable-cfi -disable-fp-elim -relocation-model=pic +OPTFLAGS+=-disable-cfi -disable-fp-elim -disable-opt + +#LDFLAGS=-fno-common -Wl,-flat_namespace -Wl,-undefined,suppress -Wl,-rpath,$(OPENJDK_HOME)/jre/lib/server +#LDFLAGS=-Wl,-rpath,$(OPENJDK_HOME)/jre/lib/server +#LDFLAGS=-Wl,-flat_namespace -rdynamic +CXXFLAGS=$(COMMON_FLAGS) $(LLVM_CXXFLAGS) -std=gnu++98 -fPIC +SHFLAGS=$(SHOPT) -fno-common -Wl,-flat_namespace -Wl,-undefined,suppress + +############################################################################### +# Targets +############################################################################### +.PHONY: all tidy clean cleanall confclean +.SECONDARY: +.SUFFIXES: + +all:: + +check:: + $(Echo) "---- building with: " + $(Echo) " PROJ_SRC_ROOT: $(PROJ_SRC_ROOT)" + $(Echo) " PROJ_OBJ_ROOT: $(PROJ_OBJ_ROOT)" + $(Echo) " SHFLAGS: $(SHFLAGS)" + $(Echo) " EXEEXT: $(EXEEXT)" + $(Echo) " SHLIBEXT: $(SHLIBEXT)" + $(Echo) " OPTIMIZED: $(OPTIMIZED)" + $(Echo) " DEBUG: $(DEBUG)" + $(Echo) " ASSERT: $(ASSERT)" + $(Echo) " CONFIG_FILES: $(CONFIG_FILES)" + $(Echo) " CONFIG_HEADERS: $(CONFIG_HEADERS)" + $(Echo) " BUILD_NAME: $(BUILD_NAME)" + $(Echo) " CLANG: $(CLANG)" + $(Echo) " CLANGXX: $(CLANGXX)" + $(Echo) " LLC: $(LLC)" + $(Echo) " LOPT: $(LOPT)" + +############################################################################### +# Recursive target managment +############################################################################### +RECURSIVE_TARGETS=all clean cleanall + +define do_sub_target +$1:: + #$(Echo) "Entering directory $$(PROF)/$2" + $(Verb) $(MAKE) $(SUB_OPT) -C $2 $1 PROF=$(PROF)/$2; \ + if [ $$$$? != 0 ]; then echo "$$(EchoMsg) abort with errors in $$(PROF)/$2"; exit 1; fi +endef + +$(foreach target,$(RECURSIVE_TARGETS),$(foreach dir,$(DIRS),$(eval $(call do_sub_target,$(target),$(dir))))) + +tidy: + $(Echo) "Cleaning temporary files" + $(Verb) find $(PROJ_OBJ_ROOT) \( -iname "*~" -o -iname "\#*" \) -exec rm -f {} \; + +clean:: + $(Echo) "Cleaning compilation files" + $(Verb) rm -Rf $(BUILD_DIR) + +cleanall:: + $(Echo) "Cleaning all compilation files" + +confclean: clean + $(Echo) "Cleaning configuration" + $(Verb) rm -Rf $(patsubst $(PROJ_OBJ_ROOT)/%,%,$(CONFIG_FILES)) + $(Verb) rm -Rf $(patsubst $(PROJ_OBJ_ROOT)/%,%,$(CONFIG_HEADERS)) + $(Verb) rm -Rf $(PROJ_OBJ_ROOT)/config.status $(PROJ_OBJ_ROOT)/config.log + $(Verb) rm -Rf $(PROJ_OBJ_ROOT)/autoconf/autom4te.cache $(PROJ_OBJ_ROOT)/autoconf/configure.bak + +############################################################################### +# Build system managment +############################################################################### +SELF=$(PROJ_SRC_ROOT)/Makefile.rules $(PROJ_OBJ_ROOT)/Makefile.config $(PROJ_SRC_CWD)/Makefile + +$(PROJ_SRC_ROOT)/configure: $(PROJ_SRC_ROOT)/autoconf/configure.ac + $(Echo) "Rebootstraping project" + $(Verb) cd $(PROJ_SRC_ROOT)/autoconf && autoconf -o $@ $< && touch $@ + $(Verb) cd $(PROJ_OBJ_ROOT) && ./config.status --recheck + +define define_config_rule +$$(LEVEL)/$1 $$(PROJ_OBJ_ROOT)/$1: $$(PROJ_SRC_ROOT)/$1.in $$(PROJ_SRC_ROOT)/configure + $(Echo) "Regenerating project files $$1" + $(Verb) cd $(PROJ_OBJ_ROOT) && ./config.status -q --$2=$1 && touch $$@ +endef + +$(foreach cur,$(CONFIG_FILES),$(eval $(call define_config_rule,$(cur),file))) +$(foreach cur,$(CONFIG_HEADERS),$(eval $(call define_config_rule,$(cur),header))) + + +############################################################################### +# Find sources +############################################################################### +define find-sources + $(basename $(notdir $(wildcard $(PROJ_SRC_CWD)/*$1))) +endef + +# $(wildcard $(BUILD_DIR)/*$1))) + +ifndef BASE_OBJ_FILES + BASE_OBJ_FILES=$(call find-sources,.cc) +endif +BC_FILES+=$(addsuffix .bc,$(addprefix $(BUILD_DIR)/,$(BASE_OBJ_FILES))) +OBJ_FILES+=$(addsuffix .o,$(addprefix $(BUILD_DIR)/,$(BASE_OBJ_FILES))) +DEP_FILES=$(addsuffix .d,$(addprefix $(BUILD_DIR)/,$(BASE_OBJ_FILES))) + +check:: + $(Echo) " BC_FILES: $(BC_FILES)" + $(Echo) " DEP_FILES: $(DEP_FILES)" + +############################################################################### +# Module +############################################################################### +ifdef MODULE + +GEN_MODULE=$(LIB_DIR)/$(MODULE) + +all:: $(LIB_DIR)/.dir $(GEN_MODULE).a $(GEN_MODULE).bc + +# not used for the moment +ifdef __EXTRACT__ + +EXTRACT_NAME=$(BUILD_DIR)/$(MODULE)-llvm-functions +TABLE_NAME=$(BUILD_DIR)/$(MODULE).table +STRIP_NAME=$(BUILD_DIR)/$(MODULE).strip + +OBJ_FILES+=$(EXTRACT_NAME).o + +$(EXTRACT_NAME).cc: $(STRIP_NAME).bc $(TABLE_NAME) $(SELF) + $(Echo) "Extracting llvm runtime functions into '$(notdir $@)'" + $(Verb) doit() { \ + echo '#include "llvm/IR/Module.h"'; \ + echo '#include "llvm/IR/Constants.h"'; \ + echo '#include "llvm/IR/Instructions.h"'; \ + echo '#include "j3/j3classloader.h"'; \ + echo 'using namespace llvm;'; \ + set -o pipefail; \ + for f in $(EXTRACT); do \ + mangled=`cat $(TABLE_NAME) | grep -F "$$f" | gawk -F'@' '{ print $$2 }' | tail -n 1`; \ + $(LLC) $< -march=cpp -cppgen=function -cppfor="$$mangled" -o - \ + | sed -e "s/makeLLVMFunction/makeLLVMFunction_$(MODULE)_$$mangled/" \ + | sed -e "s/\\x22//"; \ + if [ "$$?" != 0 ]; then \ + echo "Unable to find: $$f" >&2; \ + exit 1; \ + fi; \ + done; \ + for f in $(EXTRACT_TYPE); do \ + $(LLC) $< -march=cpp -cppgen=type -cppfor="$$f" -o - \ + | sed -e "s/makeLLVMType/makeLLVMType_$(MODULE)_`echo $$f | sed -e 's/\./_/' | sed -e 's/::/_/'`/" \ + | sed -e "s/\\x22//" \ + ; \ + done; \ + echo "void j3::J3InitialClassLoader::makeLLVMFunctions_$(MODULE)() {"; \ + for f in $(EXTRACT); do \ + mangled=`cat $(TABLE_NAME) | grep -F "$$f" | gawk -F'@' '{ print $$2 }' | tail -n 1`; \ + unmangled=`cat $(TABLE_NAME) | grep -F "$$f" | gawk -F'@' '{ print $$1 }' | tail -n 1`; \ + echo " makeLLVMFunction_$(MODULE)_$$mangled(module());"; \ + echo " registerCMangling(\"$$mangled\", \"$$unmangled\");"; \ + done; \ + for f in $(EXTRACT_TYPE); do \ + echo " makeLLVMType_$(MODULE)_`echo $$f | sed -e 's/\./_/' | sed -e 's/::/_/'`(module());"; \ + done; \ + echo "}"; \ + }; doit > $@ + +$(STRIP_NAME).bc: $(GEN_MODULE).bc + $(Echo) "Strip debug info from '$(notdir $<)'" + $(Verb) $(LLOPT) -strip-debug $< -o $@ + +$(TABLE_NAME): $(GEN_MODULE).bc + $(Echo) "Demangling '$(notdir $<)' in '$(notdir $@)'" + $(Verb) $(LLNM) --defined-only $< | tr -s ' ' | $(GAWK) -F' ' '{ print $$2 }' | \ + tee $(TABLE_NAME).mangled | c++filt -n > $(TABLE_NAME).demangled + $(Verb) $(GAWK) '{ d=$$0; getline < "'"$(TABLE_NAME).mangled"'"; m=$$0; printf("%s@%s\n", d, m); }' \ + < $(TABLE_NAME).demangled > $@ + +endif + +endif + +############################################################################### +# Tool +############################################################################### +ifdef TOOL +TOOL_OUT=$(BIN_DIR)/$(TOOL)$(EXEEXT) + +GEN_MODULE=$(LIB_DIR)/libjvm +SONAME=$(GEN_MODULE) + +BC_FILES+=$(addsuffix .bc,$(addprefix $(LIB_DIR)/,$(LIBS))) +SO_FILES=$(addsuffix .a,$(addprefix $(LIB_DIR)/,$(LIBS))) +SO_LIBS=$(LLVM_LIBS) + +all:: $(BIN_DIR)/.dir $(TOOL_OUT) $(GEN_MODULE).bc + +$(TOOL_OUT): $(OBJ_FILES) $(SONAME)$(SHLIBEXT) + $(Echo) "Linking '$(notdir $@)'" + $(Verb) $(CLANGXX) -o $@ -Wl,-rpath,$(LIB_DIR) $(LDFLAGS) $^ + +endif + +############################################################################### +# Library +############################################################################### +ifdef LIBRARY +SONAME=$(LIB_DIR)/$(LIBRARY) +all:: $(LIB_DIR)/.dir $(SONAME)$(SHLIBEXT) + +SO_FILES=$(OBJ_FILES) + +endif + +############################################################################### +# GC Managment +############################################################################### +STATIC_GC_PASS_LIB=$(LIB_DIR)/static-gc-pass$(SHLIBEXT) +STATIC_GC_PRINTER_LIB=$(LIB_DIR)/static-gc-printer$(SHLIBEXT) + +NO_GC=1 +ifdef NO_GC +GC_OBJ_FILES=$(OBJ_FILES) +else +GC_OBJ_FILES=$(patsubst %.o,%-gc.o,$(OBJ_FILES)) +GC_LLCFLAGS:=-load=$(STATIC_GC_PRINTER_LIB) +endif + +############################################################################### +# Compilation +############################################################################### +DEPEND_OPTIONS=-MMD -MP -MF "$(BUILD_DIR)/$$*.d.tmp" -MT "$(BUILD_DIR)/$$*.bc" -MT "$(BUILD_DIR)/$$*.d" +DOM=then mv -f "$(BUILD_DIR)/$$*.d.tmp" "$(BUILD_DIR)/$$*.d"; else rm -f "$(BUILD_DIR)/$$*.d.tmp"; exit 1; fi + +$(SONAME)$(SHLIBEXT): $(SO_FILES) + $(Echo) "Linking shared library '$(notdir $@)'" + $(Verb) $(CLANGXX) -shared $(LLVM_LDFLAGS) $(SHFLAGS) -o $@ $(SHFLAGS) $^ $(SO_LIBS) + +$(GEN_MODULE).bc: $(BC_FILES) + $(Echo) "Linking bc module '$(notdir $@)'" + $(Verb) $(LLLINK) $^ -o $@ + +$(GEN_MODULE).a: $(GC_OBJ_FILES) + $(Echo) "Linking module '$(notdir $@)'" + $(Verb) libtool -static -o $@ $^ + +%.o: %.bc + $(Echo) "Assembling '$(notdir $<)'" + $(Verb) $(LLC) $(LLCFLAGS) $(GC_LLCFLAGS) -filetype=obj $< -o $@ + +%-gc.bc: %.bc + $(Echo) "Preparing GC '$(notdir $<)'" + $(Verb) $(LLOPT) -load=$(STATIC_GC_PASS_LIB) $(OPTFLAGS) -StaticGCPass $< -o $@ + +define define_compile_rule +$(BUILD_DIR)/%.bc: %$1 $(SELF) $(BUILD_DIR)/.dir + $(Echo) "Compiling '$$(notdir $$<)'" + $(Verb) if $2 $3 $(DEPEND_OPTIONS) -emit-llvm -c "$$<" -o $$@; $(DOM) + +$(BUILD_DIR)/%.bc: $(BUILD_DIR)/%$1 $(SELF) $(BUILD_DIR)/.dir + $(Echo) "Compiling '$$(notdir $$<)'" + $(Verb) if $2 $3 $(DEPEND_OPTIONS) -emit-llvm -c "$$<" -o $$@; $(DOM) +endef + +$(eval $(call define_compile_rule,.cc,$(CLANGXX),$(CXXFLAGS))) + +%/.dir: + $(Verb) mkdir -p $(dir $@) && touch $@ + +ifneq ($(MAKECMDGOALS),tidy) +ifneq ($(MAKECMDGOALS),clean) +ifneq ($(MAKECMDGOALS),cleanall) +-include $(DEP_FILES) +endif +endif +endif Added: vmkit/branches/mcjit/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/autoconf/configure.ac?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/autoconf/configure.ac (added) +++ vmkit/branches/mcjit/autoconf/configure.ac Mon Nov 25 03:27:09 2013 @@ -0,0 +1,280 @@ +dnl === configure.ac --------------------------------------------------------=== +dnl SECTION 1: Initialization & Setup +dnl SECTION 2: Architecture, target, and host checks +dnl SECTION 3: Command line arguments for the configure script. +dnl SECTION 4: Check for programs we need and that they are the right version +dnl SECTION 5: Check for libraries +dnl SECTION 6: Check for header files +dnl SECTION 7: Check for types and structures +dnl SECTION 8: Check for specific functions needed +dnl SECTION 9: Additional checks, variables, etc. +dnl SECTION 10: Specify the output files and generate it +dnl +dnl===-----------------------------------------------------------------------=== +dnl=== +dnl=== SECTION 1: Initialization & Setup +dnl=== +dnl===-----------------------------------------------------------------------=== +dnl Initialize autoconf and define the package name, version number and +dnl email address for reporting bugs. +AC_INIT([vmkit],[0.1],[gael.thomas at lip6.fr]) + +dnl Provide a copyright substitution and ensure the copyright notice is included +dnl in the output of --version option of the generated configure script. +AC_COPYRIGHT([Copyright (c) 2013 Purdue Univeristy/Université Pierre et Marie Curie.]) + +dnl Indicate that we require autoconf 2.59 or later. Ths is needed because we +dnl use some autoconf macros only available in 2.59. +AC_PREREQ(2.59) + +dnl Verify that the source directory is valid. This makes sure that we are +dnl configuring reactor and not some other package (it validates --srcdir argument) +AC_CONFIG_SRCDIR([include/j3/j3config.h.in]) + +dnl Place all of the extra autoconf files into the config subdirectory. Tell +dnl various tools where the m4 autoconf macros are. +AC_CONFIG_AUX_DIR([autoconf]) + +dnl===-----------------------------------------------------------------------=== +dnl=== +dnl=== SECTION 2: Architecture, target, and host checks +dnl=== +dnl===-----------------------------------------------------------------------=== +AC_CANONICAL_TARGET + +dnl Determine the platform type and cache its value. This helps us configure +dnl the System library to the correct build platform. +AC_CACHE_CHECK([type of operating system we're going to host on], + [vmkit_cv_os_type], +[case $host in + *-*-aix*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *-*-irix*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *-*-cygwin*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *-*-darwin*) + OS="darwin" + SHLIBEXT=".dylib" +# SHOPT="-fno-common -Wl,-flat_namespace -Wl,-undefined,suppress" + SHOPT="-Wl,-all_load -Wl,-compatibility_version,1 -Wl,-current_version,1" + EXEEXT="" ;; + *-*-freebsd*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *-*-openbsd*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *-*-netbsd*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *-*-hpux*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *-*-interix*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *-*-linux*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *-*-solaris*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *-*-win32*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *-*-mingw*) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; + *) + AC_MSG_ERROR([Good luck porting vmkit to your host!]) ;; +esac]) + +dnl Make sure we aren't attempting to configure for an unknown system +AC_SUBST([OS]) +AC_SUBST([SHLIBEXT]) +AC_SUBST([SHOPT]) +AC_SUBST([EXEEXT]) + +dnl===-----------------------------------------------------------------------=== +dnl=== +dnl=== SECTION 3: Command line arguments for the configure script. +dnl=== +dnl===-----------------------------------------------------------------------=== + +dnl ************************************************************************** +dnl optimization and debug +dnl ************************************************************************** +AC_ARG_ENABLE(optimized, + AS_HELP_STRING([--enable-optimized], + [Build with all optimization flag enable (default is yes)]),, + enable_optimized=yes) +case "$enable_optimized" in + yes) AC_SUBST(OPTIMIZED,[1]) ;; + no) AC_SUBST(OPTIMIZED,[0]) ;; + *) AC_MSG_ERROR([Invalid setting for --enable-optimized. Use "yes" or "no"]) ;; +esac + +AC_ARG_ENABLE(debug, + AS_HELP_STRING([--enable-debug], + [Build with debug flags (default is no)]),, + enable_debug=no) +case "$enable_debug" in + yes) AC_SUBST(DEBUG,[1]) ;; + no) AC_SUBST(DEBUG,[0]) ;; + *) AC_MSG_ERROR([Invalid setting for --enable-debug. Use "yes" or "no"]) ;; +esac + +AC_ARG_ENABLE(assert, + AS_HELP_STRING([--enable-assert], + [Build with assert flags (default is yes)]),, + enable_assert=yes) + +case "$enable_assert" in + yes) AC_SUBST(ASSERT,[1]) ;; + no) AC_SUBST(ASSERT,[0]) ;; + *) AC_MSG_ERROR([Invalid setting for --enable-assert. Use "yes" or "no"]) ;; +esac + +if test "$enable_optimized" = "yes"; then + BUILD_NAME=Release + if test "$enable_debug" = "yes"; then + BUILD_NAME="$BUILD_NAME"+Debug + fi +else + if test "$enable_debug" = "yes"; then + BUILD_NAME=Debug + else + BUILD_NAME=Unoptimized + fi +fi + +if test "$enable_assert" = "yes"; then + BUILD_NAME="$BUILD_NAME"+Asserts +fi + +AC_SUBST([BUILD_NAME], ["$BUILD_NAME"]) + +dnl ************************************************************************** +dnl llvm +dnl ************************************************************************** +AC_ARG_WITH(llvm-config-path, + [AS_HELP_STRING(--with-llvm-config-path=path, + [llvm-config path (use default path)])], + [[LLVM_CONFIG=$with_llvm_config_path]], + [[LLVM_CONFIG="llvm-config"]] +) + +if test ! -x "$LLVM_CONFIG"; then + AC_MSG_ERROR([Cannot find $LLVM_CONFIG (or not executable)]) +fi + +LLVM_PATH="`$LLVM_CONFIG --bindir`" + +llvm_cfg=`$LLVM_CONFIG --cxxflags | sed -e 's/-O3//'` + +if ! test -z "`echo $llvm_cfg | grep -- -fno-exceptions`"; then + AC_MSG_ERROR([You have to compile LLVM with exception enabled, please compile it with 'make REQUIRES_EH=1']) +fi + +AC_SUBST(LLVM_CXXFLAGS, [$llvm_cfg" "-I`$LLVM_CONFIG --src-root`/include]) +AC_SUBST(LLVM_LIBS, [`$LLVM_CONFIG --libs`]) +AC_SUBST(LLVM_LDFLAGS, [`$LLVM_CONFIG --ldflags`]) + +dnl ************************************************************************** +dnl clang +dnl ************************************************************************** +AC_ARG_WITH(clang-path, + [AS_HELP_STRING(--with-clang-path=path, + [clang path (use llvm-config --bindir and then default path)])], + [[CLANG_PATH=$with_clang_path]] +) + +if test -z "$CLANG_PATH" -a ! -z "$LLVM_CONFIG"; then + CLANG_PATH="`$LLVM_CONFIG --bindir`" +fi + +dnl ************************************************************************** +dnl OpenJDK +dnl ************************************************************************** + +AC_ARG_WITH(jdkhome, + [AS_HELP_STRING(--with-jdkhome, + [Build J3 with OpenJDK JRE install (default is $JAVA_HOME or /usr/lib/java)])], + [[jdkhome=$with_jdkhome]], + [[jdkhome=""]] +) + +if test -z "$jdkhome"; then + if test -z "$JAVA_HOME"; then + jdkhome=/usr/lib/java + else + jdkhome=$JAVA_HOME + fi +fi + +AC_SUBST([jdkhome]) + +dnl===-----------------------------------------------------------------------=== +dnl=== +dnl=== SECTION 4: Check for programs we need and that they are the right version +dnl=== +dnl===-----------------------------------------------------------------------=== +dnl Check for compilation tools +AC_PROG_CPP + +dnl Find the install program +AC_PROG_INSTALL + +dnl AC_SUBST(SHLIBEXT,$libltdl_cv_shlibext) + +AC_DEFUN([AX_PATH_PROG_FAIL_OR_SUBST], [ + AC_PATH_PROG([$1], [$2], [no], [$3:$PATH]) + if test x"${$1}" == x"no"; then + AC_MSG_ERROR([Unable to find $2, please install $2]) + fi + AC_SUBST([$1]) +]) + +AX_PATH_PROG_FAIL_OR_SUBST([LLC], llc, $LLVM_PATH) +AX_PATH_PROG_FAIL_OR_SUBST([LLOPT], opt, $LLVM_PATH) +AX_PATH_PROG_FAIL_OR_SUBST([LLLINK], llvm-link, $LLVM_PATH) +AX_PATH_PROG_FAIL_OR_SUBST([LLNM], llvm-nm, $LLVM_PATH) +AX_PATH_PROG_FAIL_OR_SUBST([CLANG], clang, $CLANG_PATH) +AX_PATH_PROG_FAIL_OR_SUBST([CLANGXX], clang++, $CLANG_PATH) +AX_PATH_PROG_FAIL_OR_SUBST([GAWK], gawk, "") + +dnl===-----------------------------------------------------------------------=== +dnl=== +dnl=== SECTION 5: Check for libraries +dnl=== +dnl===-----------------------------------------------------------------------=== + +dnl===-----------------------------------------------------------------------=== +dnl=== +dnl=== SECTION 6: Check for header files +dnl=== +dnl===-----------------------------------------------------------------------=== + +dnl===-----------------------------------------------------------------------=== +dnl=== +dnl=== SECTION 7: Check for types and structures +dnl=== +dnl===-----------------------------------------------------------------------=== + +dnl===-----------------------------------------------------------------------=== +dnl=== +dnl=== SECTION 8: Check for specific functions needed +dnl=== +dnl===-----------------------------------------------------------------------=== + +dnl===-----------------------------------------------------------------------=== +dnl=== +dnl=== SECTION 9: Additional checks, variables, etc. +dnl=== +dnl===-----------------------------------------------------------------------=== + +dnl===-----------------------------------------------------------------------=== +dnl=== +dnl=== SECTION 10: Specify the output files and generate it +dnl=== +dnl===-----------------------------------------------------------------------=== + +dnl Configure header files +AC_CONFIG_FILES([Makefile.config include/j3/j3config.h]) + +AC_SUBST([ac_config_files]) +AC_SUBST([ac_config_headers]) + +AC_OUTPUT Added: vmkit/branches/mcjit/autoconf/install-sh URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/autoconf/install-sh?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/autoconf/install-sh (added) +++ vmkit/branches/mcjit/autoconf/install-sh Mon Nov 25 03:27:09 2013 @@ -0,0 +1,520 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2009-04-28.21; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: Propchange: vmkit/branches/mcjit/autoconf/install-sh ------------------------------------------------------------------------------ svn:executable = * Added: vmkit/branches/mcjit/configure URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/configure?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/configure (added) +++ vmkit/branches/mcjit/configure Mon Nov 25 03:27:09 2013 @@ -0,0 +1,4698 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for vmkit 0.1. +# +# Report bugs to . +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +# +# Copyright (c) 2013 Purdue Univeristy/Université Pierre et Marie Curie. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf at gnu.org and +$0: gael.thomas at lip6.fr about your system, including any +$0: error possibly output before this message. Then install +$0: a modern shell, or manually run the script under such a +$0: shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='vmkit' +PACKAGE_TARNAME='vmkit' +PACKAGE_VERSION='0.1' +PACKAGE_STRING='vmkit 0.1' +PACKAGE_BUGREPORT='gael.thomas at lip6.fr' +PACKAGE_URL='' + +ac_unique_file="include/j3/j3config.h.in" +ac_subst_vars='LTLIBOBJS +LIBOBJS +ac_config_headers +ac_config_files +GAWK +CLANGXX +CLANG +LLNM +LLLINK +LLOPT +LLC +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +CPP +OBJEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +jdkhome +LLVM_LDFLAGS +LLVM_LIBS +LLVM_CXXFLAGS +BUILD_NAME +ASSERT +DEBUG +OPTIMIZED +EXEEXT +SHOPT +SHLIBEXT +OS +target_os +target_vendor +target_cpu +target +host_os +host_vendor +host_cpu +host +build_os +build_vendor +build_cpu +build +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +enable_optimized +enable_debug +enable_assert +with_llvm_config_path +with_clang_path +with_jdkhome +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures vmkit 0.1 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/vmkit] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of vmkit 0.1:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-optimized Build with all optimization flag enable (default is + yes) + --enable-debug Build with debug flags (default is no) + --enable-assert Build with assert flags (default is yes) + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-llvm-config-path=path + llvm-config path (use default path) + --with-clang-path=path clang path (use llvm-config --bindir and then + default path) + --with-jdkhome Build J3 with OpenJDK JRE install (default is + $JAVA_HOME or /usr/lib/java) + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +vmkit configure 0.1 +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. + +Copyright (c) 2013 Purdue Univeristy/Université Pierre et Marie Curie. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by vmkit $as_me 0.1, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + +ac_aux_dir= +for ac_dir in autoconf "$srcdir"/autoconf; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in autoconf \"$srcdir\"/autoconf" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 +$as_echo_n "checking host system type... " >&6; } +if ${ac_cv_host+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 +$as_echo "$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5 +$as_echo_n "checking target system type... " >&6; } +if ${ac_cv_target+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5 +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5 +$as_echo "$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;; +esac +target=$ac_cv_target +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking type of operating system we're going to host on" >&5 +$as_echo_n "checking type of operating system we're going to host on... " >&6; } +if ${vmkit_cv_os_type+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $host in + *-*-aix*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *-*-irix*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *-*-cygwin*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *-*-darwin*) + OS="darwin" + SHLIBEXT=".dylib" +# SHOPT="-fno-common -Wl,-flat_namespace -Wl,-undefined,suppress" + SHOPT="-Wl,-all_load -Wl,-compatibility_version,1 -Wl,-current_version,1" + EXEEXT="" ;; + *-*-freebsd*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *-*-openbsd*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *-*-netbsd*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *-*-hpux*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *-*-interix*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *-*-linux*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *-*-solaris*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *-*-win32*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *-*-mingw*) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; + *) + as_fn_error $? "Good luck porting vmkit to your host!" "$LINENO" 5 ;; +esac +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vmkit_cv_os_type" >&5 +$as_echo "$vmkit_cv_os_type" >&6; } + + + + + + + +# Check whether --enable-optimized was given. +if test "${enable_optimized+set}" = set; then : + enableval=$enable_optimized; +else + enable_optimized=yes +fi + +case "$enable_optimized" in + yes) OPTIMIZED=1 + ;; + no) OPTIMIZED=0 + ;; + *) as_fn_error $? "Invalid setting for --enable-optimized. Use \"yes\" or \"no\"" "$LINENO" 5 ;; +esac + +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then : + enableval=$enable_debug; +else + enable_debug=no +fi + +case "$enable_debug" in + yes) DEBUG=1 + ;; + no) DEBUG=0 + ;; + *) as_fn_error $? "Invalid setting for --enable-debug. Use \"yes\" or \"no\"" "$LINENO" 5 ;; +esac + +# Check whether --enable-assert was given. +if test "${enable_assert+set}" = set; then : + enableval=$enable_assert; +else + enable_assert=yes +fi + + +case "$enable_assert" in + yes) ASSERT=1 + ;; + no) ASSERT=0 + ;; + *) as_fn_error $? "Invalid setting for --enable-assert. Use \"yes\" or \"no\"" "$LINENO" 5 ;; +esac + +if test "$enable_optimized" = "yes"; then + BUILD_NAME=Release + if test "$enable_debug" = "yes"; then + BUILD_NAME="$BUILD_NAME"+Debug + fi +else + if test "$enable_debug" = "yes"; then + BUILD_NAME=Debug + else + BUILD_NAME=Unoptimized + fi +fi + +if test "$enable_assert" = "yes"; then + BUILD_NAME="$BUILD_NAME"+Asserts +fi + +BUILD_NAME="$BUILD_NAME" + + + +# Check whether --with-llvm-config-path was given. +if test "${with_llvm_config_path+set}" = set; then : + withval=$with_llvm_config_path; LLVM_CONFIG=$with_llvm_config_path +else + LLVM_CONFIG="llvm-config" + +fi + + +if test ! -x "$LLVM_CONFIG"; then + as_fn_error $? "Cannot find $LLVM_CONFIG (or not executable)" "$LINENO" 5 +fi + +LLVM_PATH="`$LLVM_CONFIG --bindir`" + +llvm_cfg=`$LLVM_CONFIG --cxxflags | sed -e 's/-O3//'` + +if ! test -z "`echo $llvm_cfg | grep -- -fno-exceptions`"; then + as_fn_error $? "You have to compile LLVM with exception enabled, please compile it with 'make REQUIRES_EH=1'" "$LINENO" 5 +fi + +LLVM_CXXFLAGS=$llvm_cfg" "-I`$LLVM_CONFIG --src-root`/include + +LLVM_LIBS=`$LLVM_CONFIG --libs` + +LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags` + + + +# Check whether --with-clang-path was given. +if test "${with_clang_path+set}" = set; then : + withval=$with_clang_path; CLANG_PATH=$with_clang_path + +fi + + +if test -z "$CLANG_PATH" -a ! -z "$LLVM_CONFIG"; then + CLANG_PATH="`$LLVM_CONFIG --bindir`" +fi + + + +# Check whether --with-jdkhome was given. +if test "${with_jdkhome+set}" = set; then : + withval=$with_jdkhome; jdkhome=$with_jdkhome +else + jdkhome="" + +fi + + +if test -z "$jdkhome"; then + if test -z "$JAVA_HOME"; then + jdkhome=/usr/lib/java + else + jdkhome=$JAVA_HOME + fi +fi + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + + + + + + # Extract the first word of "llc", so it can be a program name with args. +set dummy llc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_LLC+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $LLC in + [\\/]* | ?:[\\/]*) + ac_cv_path_LLC="$LLC" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy="$LLVM_PATH:$PATH" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_LLC="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_LLC" && ac_cv_path_LLC="no" + ;; +esac +fi +LLC=$ac_cv_path_LLC +if test -n "$LLC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLC" >&5 +$as_echo "$LLC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test x"${LLC}" == x"no"; then + as_fn_error $? "Unable to find llc, please install llc" "$LINENO" 5 + fi + + + + # Extract the first word of "opt", so it can be a program name with args. +set dummy opt; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_LLOPT+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $LLOPT in + [\\/]* | ?:[\\/]*) + ac_cv_path_LLOPT="$LLOPT" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy="$LLVM_PATH:$PATH" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_LLOPT="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_LLOPT" && ac_cv_path_LLOPT="no" + ;; +esac +fi +LLOPT=$ac_cv_path_LLOPT +if test -n "$LLOPT"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLOPT" >&5 +$as_echo "$LLOPT" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test x"${LLOPT}" == x"no"; then + as_fn_error $? "Unable to find opt, please install opt" "$LINENO" 5 + fi + + + + # Extract the first word of "llvm-link", so it can be a program name with args. +set dummy llvm-link; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_LLLINK+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $LLLINK in + [\\/]* | ?:[\\/]*) + ac_cv_path_LLLINK="$LLLINK" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy="$LLVM_PATH:$PATH" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_LLLINK="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_LLLINK" && ac_cv_path_LLLINK="no" + ;; +esac +fi +LLLINK=$ac_cv_path_LLLINK +if test -n "$LLLINK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLLINK" >&5 +$as_echo "$LLLINK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test x"${LLLINK}" == x"no"; then + as_fn_error $? "Unable to find llvm-link, please install llvm-link" "$LINENO" 5 + fi + + + + # Extract the first word of "llvm-nm", so it can be a program name with args. +set dummy llvm-nm; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_LLNM+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $LLNM in + [\\/]* | ?:[\\/]*) + ac_cv_path_LLNM="$LLNM" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy="$LLVM_PATH:$PATH" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_LLNM="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_LLNM" && ac_cv_path_LLNM="no" + ;; +esac +fi +LLNM=$ac_cv_path_LLNM +if test -n "$LLNM"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLNM" >&5 +$as_echo "$LLNM" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test x"${LLNM}" == x"no"; then + as_fn_error $? "Unable to find llvm-nm, please install llvm-nm" "$LINENO" 5 + fi + + + + # Extract the first word of "clang", so it can be a program name with args. +set dummy clang; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_CLANG+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $CLANG in + [\\/]* | ?:[\\/]*) + ac_cv_path_CLANG="$CLANG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy="$CLANG_PATH:$PATH" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CLANG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_CLANG" && ac_cv_path_CLANG="no" + ;; +esac +fi +CLANG=$ac_cv_path_CLANG +if test -n "$CLANG"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CLANG" >&5 +$as_echo "$CLANG" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test x"${CLANG}" == x"no"; then + as_fn_error $? "Unable to find clang, please install clang" "$LINENO" 5 + fi + + + + # Extract the first word of "clang++", so it can be a program name with args. +set dummy clang++; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_CLANGXX+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $CLANGXX in + [\\/]* | ?:[\\/]*) + ac_cv_path_CLANGXX="$CLANGXX" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy="$CLANG_PATH:$PATH" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_CLANGXX="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_CLANGXX" && ac_cv_path_CLANGXX="no" + ;; +esac +fi +CLANGXX=$ac_cv_path_CLANGXX +if test -n "$CLANGXX"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CLANGXX" >&5 +$as_echo "$CLANGXX" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test x"${CLANGXX}" == x"no"; then + as_fn_error $? "Unable to find clang++, please install clang++" "$LINENO" 5 + fi + + + + # Extract the first word of "gawk", so it can be a program name with args. +set dummy gawk; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_GAWK+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GAWK in + [\\/]* | ?:[\\/]*) + ac_cv_path_GAWK="$GAWK" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy=""":$PATH" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GAWK="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + test -z "$ac_cv_path_GAWK" && ac_cv_path_GAWK="no" + ;; +esac +fi +GAWK=$ac_cv_path_GAWK +if test -n "$GAWK"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GAWK" >&5 +$as_echo "$GAWK" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test x"${GAWK}" == x"no"; then + as_fn_error $? "Unable to find gawk, please install gawk" "$LINENO" 5 + fi + + + + + + + + + +ac_config_files="$ac_config_files Makefile.config include/j3/j3config.h" + + + + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +# +# If the first sed substitution is executed (which looks for macros that +# take arguments), then branch to the quote section. Otherwise, +# look for a macro that doesn't take arguments. +ac_script=' +:mline +/\\$/{ + N + s,\\\n,, + b mline +} +t clear +:clear +s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g +t quote +s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g +t quote +b any +:quote +s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g +s/\[/\\&/g +s/\]/\\&/g +s/\$/$$/g +H +:any +${ + g + s/^\n// + s/\n/ /g + p +} +' +DEFS=`sed -n "$ac_script" confdefs.h` + + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by vmkit $as_me 0.1, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + +Configuration files: +$config_files + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +vmkit config.status 0.1 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h | --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;; + "include/j3/j3config.h") CONFIG_FILES="$CONFIG_FILES include/j3/j3config.h" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + + +eval set X " :F $CONFIG_FILES " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + Propchange: vmkit/branches/mcjit/configure ------------------------------------------------------------------------------ svn:executable = * Added: vmkit/branches/mcjit/include/j3/j3.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3.h (added) +++ vmkit/branches/mcjit/include/j3/j3.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,110 @@ +#ifndef _J3_J3_ +#define _J3_J3_ + +#include +#include + +#include "vmkit/names.h" +#include "vmkit/vmkit.h" +#include "vmkit/allocator.h" + +#include "j3/j3options.h" +#include "j3/j3typesdef.h" +#include "j3/j3jni.h" + + +namespace j3 { + class J3InitialClassLoader; + class J3Class; + class J3ArrayClass; + class J3Type; + class J3Object; + class J3ObjectHandle; + class J3Primitive; + class J3Lib; + class J3Method; + + class J3 : public vmkit::VMKit { + typedef std::map, + vmkit::StdAllocator > > StringMap; + + static vmkit::T_ptr_less_t charArrayLess; + + J3Options _options; + + pthread_mutex_t stringsMutex; + vmkit::NameMap::map nameToCharArrays; + StringMap charArrayToStrings; + vmkit::Names _names; + + void introspect(); + + J3(vmkit::BumpAllocator* allocator); + public: + J3InitialClassLoader* initialClassLoader; + + static J3* create(); + +#define defPrimitive(name, ctype, llvmtype) \ + J3Primitive* type##name; + onJavaTypes(defPrimitive) +#undef defPrimitive + + J3Type** arrayInterfaces; + uint32_t nbArrayInterfaces; + J3Class* objectClass; + J3ArrayClass* charArrayClass; + + J3Class* stringClass; + J3Method* stringInit; + J3Field* stringValue; + + J3Class* classClass; + J3Method* classInit; + J3Field* classVMData; + + const vmkit::Name* codeAttr; + const vmkit::Name* constantValueAttr; + const vmkit::Name* initName; + const vmkit::Name* clinitName; + const vmkit::Name* clinitSign; + + llvm::Type* typeJNIEnvPtr; + llvm::Type* typeJ3VirtualTablePtr; + llvm::Type* typeJ3Type; + llvm::Type* typeJ3TypePtr; + llvm::Type* typeJ3ObjectTypePtr; + llvm::Type* typeJ3Class; + llvm::Type* typeJ3ClassPtr; + llvm::Type* typeJ3ArrayClass; + llvm::Type* typeJ3ArrayClassPtr; + llvm::Type* typeJ3Method; + llvm::Type* typeJ3ArrayObject; + llvm::Type* typeJ3ArrayObjectPtr; + llvm::Type* typeJ3Object; + llvm::Type* typeJ3ObjectPtr; + llvm::Type* typeJ3ObjectHandlePtr; + llvm::Type* typeGXXException; + + J3Options* options() { return &_options; } + vmkit::Names* names() { return &_names; } + J3ObjectHandle* utfToString(const char* name); + J3ObjectHandle* nameToString(const vmkit::Name* name); + J3ObjectHandle* arrayToString(J3ObjectHandle* array); + + void start(int argc, char** argv); + + static JNIEnv* jniEnv(); + + static void noClassDefFoundError(J3Class* cl) __attribute__((noreturn)); + static void classFormatError(J3Class* cl, const wchar_t* reason, ...) __attribute__((noreturn)); + static void noSuchMethodError(const wchar_t* msg, + J3Class* clName, const vmkit::Name* name, const vmkit::Name* sign) __attribute__((noreturn)); + static void linkageError(J3Method* method) __attribute__((noreturn)); + + static void nullPointerException() __attribute__((noreturn)); + static void classCastException() __attribute__((noreturn)); + }; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3bc.def URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3bc.def?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3bc.def (added) +++ vmkit/branches/mcjit/include/j3/j3bc.def Mon Nov 25 03:27:09 2013 @@ -0,0 +1,205 @@ +defOpcode(nop, 0x00, nyi()) +defOpcode(aconst_null, 0x01, eat(0)) +defOpcode(iconst_m1, 0x02, eat(0)) +defOpcode(iconst_0, 0x03, eat(0)) +defOpcode(iconst_1, 0x04, eat(0)) +defOpcode(iconst_2, 0x05, eat(0)) +defOpcode(iconst_3, 0x06, eat(0)) +defOpcode(iconst_4, 0x07, eat(0)) +defOpcode(iconst_5, 0x08, eat(0)) +defOpcode(lconst_0, 0x09, eat(0)) +defOpcode(lconst_1, 0x0a, eat(0)) +defOpcode(fconst_0, 0x0b, eat(0)) +defOpcode(fconst_1, 0x0c, eat(0)) +defOpcode(fconst_2, 0x0d, eat(0)) +defOpcode(dconst_0, 0x0e, eat(0)) +defOpcode(dconst_1, 0x0f, eat(0)) +defOpcode(bipush, 0x10, nyi()) +defOpcode(sipush, 0x11, nyi()) +defOpcode(ldc, 0x12, nyi()) +defOpcode(ldc_w, 0x13, nyi()) +defOpcode(ldc2_w, 0x14, nyi()) +defOpcode(iload, 0x15, nyi()) +defOpcode(lload, 0x16, nyi()) +defOpcode(fload, 0x17, nyi()) +defOpcode(dload, 0x18, nyi()) +defOpcode(aload, 0x19, nyi()) +defOpcode(iload_0, 0x1a, nyi()) +defOpcode(iload_1, 0x1b, nyi()) +defOpcode(iload_2, 0x1c, nyi()) +defOpcode(iload_3, 0x1d, nyi()) +defOpcode(lload_0, 0x1e, nyi()) +defOpcode(lload_1, 0x1f, nyi()) +defOpcode(lload_2, 0x20, nyi()) +defOpcode(lload_3, 0x21, nyi()) +defOpcode(fload_0, 0x22, nyi()) +defOpcode(fload_1, 0x23, nyi()) +defOpcode(fload_2, 0x24, nyi()) +defOpcode(fload_3, 0x25, nyi()) +defOpcode(dload_0, 0x26, nyi()) +defOpcode(dload_1, 0x27, nyi()) +defOpcode(dload_2, 0x28, nyi()) +defOpcode(dload_3, 0x29, nyi()) +defOpcode(aload_0, 0x2a, nyi()) +defOpcode(aload_1, 0x2b, nyi()) +defOpcode(aload_2, 0x2c, nyi()) +defOpcode(aload_3, 0x2d, nyi()) +defOpcode(iaload, 0x2e, nyi()) +defOpcode(laload, 0x2f, nyi()) +defOpcode(faload, 0x30, nyi()) +defOpcode(daload, 0x31, nyi()) +defOpcode(aaload, 0x32, nyi()) +defOpcode(baload, 0x33, nyi()) +defOpcode(caload, 0x34, nyi()) +defOpcode(saload, 0x35, nyi()) +defOpcode(istore, 0x36, nyi()) +defOpcode(lstore, 0x37, nyi()) +defOpcode(fstore, 0x38, nyi()) +defOpcode(dstore, 0x39, nyi()) +defOpcode(astore, 0x3a, nyi()) +defOpcode(istore_0, 0x3b, nyi()) +defOpcode(istore_1, 0x3c, nyi()) +defOpcode(istore_2, 0x3d, nyi()) +defOpcode(istore_3, 0x3e, nyi()) +defOpcode(lstore_0, 0x3f, nyi()) +defOpcode(lstore_1, 0x40, nyi()) +defOpcode(lstore_2, 0x41, nyi()) +defOpcode(lstore_3, 0x42, nyi()) +defOpcode(fstore_0, 0x43, nyi()) +defOpcode(fstore_1, 0x44, nyi()) +defOpcode(fstore_2, 0x45, nyi()) +defOpcode(fstore_3, 0x46, nyi()) +defOpcode(dstore_0, 0x47, nyi()) +defOpcode(dstore_1, 0x48, nyi()) +defOpcode(dstore_2, 0x49, nyi()) +defOpcode(dstore_3, 0x4a, nyi()) +defOpcode(astore_0, 0x4b, nyi()) +defOpcode(astore_1, 0x4c, nyi()) +defOpcode(astore_2, 0x4d, nyi()) +defOpcode(astore_3, 0x4e, nyi()) +defOpcode(iastore, 0x4f, nyi()) +defOpcode(lastore, 0x50, nyi()) +defOpcode(fastore, 0x51, nyi()) +defOpcode(dastore, 0x52, nyi()) +defOpcode(aastore, 0x53, nyi()) +defOpcode(bastore, 0x54, nyi()) +defOpcode(castore, 0x55, nyi()) +defOpcode(sastore, 0x56, nyi()) +defOpcode(pop, 0x57, nyi()) +defOpcode(pop2, 0x58, nyi()) +defOpcode(dup, 0x59, eat(0)) +defOpcode(dup_x1, 0x5a, nyi()) +defOpcode(dup_x2, 0x5b, nyi()) +defOpcode(dup2, 0x5c, nyi()) +defOpcode(dup2_x1, 0x5d, nyi()) +defOpcode(dup2_x2, 0x5e, nyi()) +defOpcode(swap, 0x5f, nyi()) +defOpcode(iadd, 0x60, nyi()) +defOpcode(ladd, 0x61, nyi()) +defOpcode(fadd, 0x62, nyi()) +defOpcode(dadd, 0x63, nyi()) +defOpcode(isub, 0x64, nyi()) +defOpcode(lsub, 0x65, nyi()) +defOpcode(fsub, 0x66, nyi()) +defOpcode(dsub, 0x67, nyi()) +defOpcode(imul, 0x68, nyi()) +defOpcode(lmul, 0x69, nyi()) +defOpcode(fmul, 0x6a, nyi()) +defOpcode(dmul, 0x6b, nyi()) +defOpcode(idiv, 0x6c, nyi()) +defOpcode(ldiv, 0x6d, nyi()) +defOpcode(fdiv, 0x6e, nyi()) +defOpcode(ddiv, 0x6f, nyi()) +defOpcode(irem, 0x70, nyi()) +defOpcode(lrem, 0x71, nyi()) +defOpcode(frem, 0x72, nyi()) +defOpcode(drem, 0x73, nyi()) +defOpcode(ineg, 0x74, nyi()) +defOpcode(lneg, 0x75, nyi()) +defOpcode(fneg, 0x76, nyi()) +defOpcode(dneg, 0x77, nyi()) +defOpcode(ishl, 0x78, nyi()) +defOpcode(lshl, 0x79, nyi()) +defOpcode(ishr, 0x7a, nyi()) +defOpcode(lshr, 0x7b, nyi()) +defOpcode(iushr, 0x7c, nyi()) +defOpcode(lushr, 0x7d, nyi()) +defOpcode(iand, 0x7e, nyi()) +defOpcode(land, 0x7f, nyi()) +defOpcode(ior, 0x80, nyi()) +defOpcode(lor, 0x81, nyi()) +defOpcode(ixor, 0x82, nyi()) +defOpcode(lxor, 0x83, nyi()) +defOpcode(iinc, 0x84, nyi()) +defOpcode(i2l, 0x85, nyi()) +defOpcode(i2f, 0x86, nyi()) +defOpcode(i2d, 0x87, nyi()) +defOpcode(l2i, 0x88, nyi()) +defOpcode(l2f, 0x89, nyi()) +defOpcode(l2d, 0x8a, nyi()) +defOpcode(f2i, 0x8b, nyi()) +defOpcode(f2l, 0x8c, nyi()) +defOpcode(f2d, 0x8d, nyi()) +defOpcode(d2i, 0x8e, nyi()) +defOpcode(d2l, 0x8f, nyi()) +defOpcode(d2f, 0x90, nyi()) +defOpcode(i2b, 0x91, nyi()) +defOpcode(i2c, 0x92, nyi()) +defOpcode(i2s, 0x93, nyi()) +defOpcode(lcmp, 0x94, nyi()) +defOpcode(fcmpl, 0x95, nyi()) +defOpcode(fcmpg, 0x96, nyi()) +defOpcode(dcmpl, 0x97, nyi()) +defOpcode(dcmpg, 0x98, nyi()) +defOpcode(ifeq, 0x99, nyi()) +defOpcode(ifne, 0x9a, nyi()) +defOpcode(iflt, 0x9b, nyi()) +defOpcode(ifge, 0x9c, nyi()) +defOpcode(ifgt, 0x9d, nyi()) +defOpcode(ifle, 0x9e, nyi()) +defOpcode(if_icmpeq, 0x9f, nyi()) +defOpcode(if_icmpne, 0xa0, nyi()) +defOpcode(if_icmplt, 0xa1, nyi()) +defOpcode(if_icmpge, 0xa2, nyi()) +defOpcode(if_icmpgt, 0xa3, nyi()) +defOpcode(if_icmple, 0xa4, nyi()) +defOpcode(if_acmpeq, 0xa5, nyi()) +defOpcode(if_acmpne, 0xa6, nyi()) +defOpcode(goto, 0xa7, nyi()) +defOpcode(jsr, 0xa8, nyi()) +defOpcode(ret, 0xa9, nyi()) +defOpcode(tableswitch, 0xaa, nyi()) +defOpcode(lookupswitch, 0xab, nyi()) +defOpcode(ireturn, 0xac, nyi()) +defOpcode(lreturn, 0xad, nyi()) +defOpcode(freturn, 0xae, nyi()) +defOpcode(dreturn, 0xaf, nyi()) +defOpcode(areturn, 0xb0, nyi()) +defOpcode(return, 0xb1, eat(0)) +defOpcode(getstatic, 0xb2, nyi()) +defOpcode(putstatic, 0xb3, eat(2)) +defOpcode(getfield, 0xb4, nyi()) +defOpcode(putfield, 0xb5, nyi()) +defOpcode(invokevirtual, 0xb6, nyi()) +defOpcode(invokespecial, 0xb7, eat(2)) +defOpcode(invokestatic, 0xb8, eat(2)) +defOpcode(invokeinterface, 0xb9, nyi()) +defOpcode(xxxunusedxxx1, 0xba, nyi()) +defOpcode(new, 0xbb, eat(2)) +defOpcode(newarray, 0xbc, nyi()) +defOpcode(anewarray, 0xbd, eat(2)) +defOpcode(arraylength, 0xbe, nyi()) +defOpcode(athrow, 0xbf, nyi()) +defOpcode(checkcast, 0xc0, nyi()) +defOpcode(instanceof, 0xc1, nyi()) +defOpcode(monitorenter, 0xc2, nyi()) +defOpcode(monitorexit, 0xc3, nyi()) +defOpcode(wide, 0xc4, nyi()) +defOpcode(multianewarray, 0xc5, nyi()) +defOpcode(ifnull, 0xc6, nyi()) +defOpcode(ifnonnull, 0xc7, nyi()) +defOpcode(goto_w, 0xc8, nyi()) +defOpcode(jsr_w, 0xc9, nyi()) +defOpcode(breakpoint, 0xca, nyi()) +defOpcode(impdep1, 0xfe, nyi()) +defOpcode(impdep2, 0xff, nyi()) Added: vmkit/branches/mcjit/include/j3/j3class.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3class.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3class.h (added) +++ vmkit/branches/mcjit/include/j3/j3class.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,292 @@ +#ifndef _J3_CLASS_H_ +#define _J3_CLASS_H_ + +#include +#include +#include + +#include "vmkit/allocator.h" + +namespace llvm { + class StructType; + class Type; + class GlobalValue; + class Module; +} + +namespace vmkit { + class Name; +} + +namespace j3 { + class J3ClassLoader; + class J3ClassBytes; + class J3Reader; + class J3Primitive; + class J3Class; + class J3Layout; + class J3ArrayClass; + class J3ObjectType; + class J3Method; + class J3VirtualTable; + class J3ObjectHandle; + class J3Field; + + class J3Type : public vmkit::PermanentObject { + pthread_mutex_t _mutex; + J3ClassLoader* _loader; + J3ArrayClass* volatile _array; + + protected: + enum { CITED, LOADED, RESOLVED, INITED }; + + const vmkit::Name* _name; + char* _nativeName; + uint32_t _nativeNameLength; + J3VirtualTable* _vt; + + volatile int status; + + virtual void doResolve(J3Field* hiddenFields, size_t nbHiddenFields) { status = RESOLVED; } + virtual void doInitialise() { status = INITED; } + + public: + J3Type(J3ClassLoader* loader, const vmkit::Name* name); + + virtual llvm::GlobalValue* llvmDescriptor(llvm::Module* module) { return 0; } + + bool isResolved() { return status >= RESOLVED; } + bool isInitialised() { return status == INITED; } + J3Type* resolve(J3Field* hiddenFields, uint32_t nbHiddenFields); + J3Type* resolve(); + J3Type* initialise(); + + J3VirtualTable* vt(); + + bool isAssignableTo(J3Type* parent); + + char* nativeName(); + uint32_t nativeNameLength(); + + void lock() { pthread_mutex_lock(&_mutex); } + void unlock() { pthread_mutex_unlock(&_mutex); } + + const vmkit::Name* name() const { return _name; } + J3ArrayClass* getArray(uint32_t prof=1, const vmkit::Name* name=0); + + J3ClassLoader* loader() { return _loader; } + + J3ObjectType* asObjectType(); + J3Class* asClass(); + J3Primitive* asPrimitive(); + J3ArrayClass* asArrayClass(); + J3Layout* asLayout(); + + virtual bool isObjectType() { return 0; } + virtual bool isArrayClass() { return 0; } + virtual bool isLayout() { return 0; } + virtual bool isClass() { return 0; } + virtual bool isPrimitive() { return 0; } + virtual llvm::Type* llvmType() = 0; + + void dump(); + }; + + class J3Attribute : public vmkit::PermanentObject { + friend class J3Class; + + const vmkit::Name* _id; + uint32_t _offset; + public: + + const vmkit::Name* id() { return _id; } + uint32_t offset() { return _offset; } + }; + + class J3Attributes : public vmkit::PermanentObject { + size_t _nbAttributes; + J3Attribute _attributes[1]; + public: + J3Attributes(size_t n) { _nbAttributes = n; } + + void* operator new(size_t unused, vmkit::BumpAllocator* allocator, size_t n) { + return vmkit::PermanentObject::operator new(sizeof(J3Attributes) + (n - 1) * sizeof(J3Attribute), allocator); + } + + size_t nbAttributes() { return _nbAttributes; } + J3Attribute* attribute(size_t n); + + J3Attribute* lookup(const vmkit::Name* attr); + }; + + class J3Field : public vmkit::PermanentObject { + friend class J3Class; + + J3Class* _cl; + uint16_t _access; + const vmkit::Name* _name; + J3Type* _type; + J3Attributes* _attributes; + uint32_t _num; + + public: + J3Field() {} + J3Field(uint16_t access, const vmkit::Name* name, J3Type* type) { _access = access; _name = name; _type = type; } + + J3Attributes* attributes() const { return _attributes; } + uint16_t access() { return _access; } + J3Class* cl() { return _cl; } + const vmkit::Name* name() { return _name; } + J3Type* type() { return _type; } + + uint32_t num() { return _num; } + + void dump(); + }; + + class J3ObjectType : public J3Type { + J3ObjectHandle* _javaClass; + + public: + J3ObjectType(J3ClassLoader* loader, const vmkit::Name* name); + + virtual J3Method* findVirtualMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error=1); + virtual J3Method* findStaticMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error=1); + + bool isObjectType() { return 1; } + + J3ObjectHandle* javaClass(); + + static J3ObjectType* nativeClass(J3ObjectHandle* handle); + }; + + class J3Layout : public J3ObjectType { + friend class J3Class; + + llvm::Type* _llvmType; + + size_t nbFields; + J3Field* fields; + + size_t _nbMethods; + J3Method** _methods; + public: + J3Layout(J3ClassLoader* loader, const vmkit::Name* name); + + virtual bool isLayout() { return 1; } + + size_t nbMethods() { return _nbMethods; } + J3Method** methods() { return _methods; } + + J3Method* findMethod(const vmkit::Name* name, const vmkit::Name* sign); + J3Field* findField(const vmkit::Name* name, const J3Type* type); + llvm::Type* llvmType() { return _llvmType; } + }; + + class J3Class : public J3Layout { + J3Layout staticLayout; + + uint16_t _access; + + size_t _size; + + size_t _nbInterfaces; + J3Class** _interfaces; + J3Class* _super; /* this for root */ + + J3Attributes* _attributes; + + llvm::GlobalValue* _nomcjitDescriptor; + J3ClassBytes* _bytes; + size_t nbCtp; + uint8_t* ctpTypes; + uint32_t* ctpValues; + void** ctpResolved; + + /* GC Object */ + J3ObjectHandle* _staticInstance; + + J3Attributes* readAttributes(J3Reader* reader); + void readClassBytes(std::vector* virtualBody, J3Field* hiddenFields, uint32_t nbHiddenFields); + + void check(uint16_t idx, uint32_t id=-1); + + void fillFields(std::vector* staticBody, std::vector* virtualBody, J3Field** fields, size_t n); + + void createLLVMTypes(); + + void load(); + void doResolve(J3Field* hiddenFields, size_t nbHiddenFields); + void doInitialise(); + public: + J3Class(J3ClassLoader* loader, const vmkit::Name* name); + + size_t nbInterfaces() { return _nbInterfaces; } + J3Class** interfaces() { return _interfaces; } + J3Class* super() { return _super; } + uint16_t access() { return _access; } + + void adjustSize(uint32_t n) { _size += n; } + size_t size(); + J3ObjectHandle* staticInstance(); + + void registerNative(const vmkit::Name* methName, const vmkit::Name* methSign, void* fnPtr); + + uint8_t getCtpType(uint16_t idx); + void* getCtpResolved(uint16_t idx); + + const vmkit::Name* nameAt(uint16_t idx); + float floatAt(uint16_t idx); + double doubleAt(uint16_t idx); + uint32_t integerAt(uint16_t idx); + uint64_t longAt(uint16_t idx); + J3ObjectHandle* stringAt(uint16_t idx); + J3Class* classAt(uint16_t idx); + J3Method* methodAt(uint16_t idx, uint16_t access); + J3Field* fieldAt(uint16_t idx, uint16_t access); + + llvm::Type* llvmType(); + llvm::Type* staticLLVMType(); + llvm::Type* virtualLLVMType(); + llvm::GlobalValue* llvmDescriptor(llvm::Module* module); + + J3ClassBytes* bytes() { return _bytes; } + + bool isClass() { return 1; } + + J3Method* findVirtualMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error=1); + J3Method* findStaticMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error=1); + J3Field* findVirtualField(const vmkit::Name* name, const J3Type* type, bool error=1); + J3Field* findStaticField(const vmkit::Name* name, const J3Type* type, bool error=1); + }; + + class J3ArrayClass : public J3ObjectType { + llvm::Type* _llvmType; + J3Type* _component; + llvm::GlobalValue* _nomcjitDescriptor; + + void doResolve(J3Field* hiddenFields, size_t nbHiddenFields); + void doInitialise(); + public: + J3ArrayClass(J3ClassLoader* loader, J3Type* component, const vmkit::Name* name); + + + llvm::GlobalValue* llvmDescriptor(llvm::Module* module); + + J3Type* component() { return _component; } + bool isArrayClass() { return 1; } + llvm::Type* llvmType(); + }; + + class J3Primitive : public J3Type { + llvm::Type* _llvmType; + + public: + J3Primitive(J3ClassLoader* loader, char id, llvm::Type* type); + + bool isPrimitive() { return 1; } + llvm::Type* llvmType() { return _llvmType; } + }; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3classloader.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3classloader.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3classloader.h (added) +++ vmkit/branches/mcjit/include/j3/j3classloader.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,118 @@ +#ifndef _CLASSLOADER_H_ +#define _CLASSLOADER_H_ + +#include +#include + +#include "vmkit/allocator.h" +#include "vmkit/names.h" + +#include "j3/j3object.h" + +namespace llvm { + class ExecutionEngine; + class DataLayout; + class Type; + class Function; + class DIBuilder; + + namespace legacy { + class FunctionPassManager; + } + using legacy::FunctionPassManager; +} + +namespace j3 { + class J3ZipArchive; + class J3ClassBytes; + class J3MethodType; + class J3Method; + class J3Type; + class J3; + class J3Class; + + + class J3ClassLoader { + struct J3MethodLess : public std::binary_function { + bool operator()(const J3Method* lhs, const J3Method* rhs) const; + }; + + typedef std::map > > MethodRefMap; + + static J3MethodLess j3MethodLess; + + J3ObjectHandle* _javaClassLoader; + J3FixedPoint _fixedPoint; + llvm::FunctionPassManager* _pm; + pthread_mutex_t _mutex; /* a lock */ + vmkit::BumpAllocator* _allocator; /* the local allocator */ + J3* _vm; /* my vm */ + vmkit::NameMap::map classes; /* classes managed by this class loader */ + vmkit::NameMap::map types; /* shortcut to find types */ + vmkit::NameMap::map methodTypes; /* shortcut to find method types - REMOVE */ + llvm::Module* _module; /* the associated llvm module */ + llvm::DIBuilder* _dbgBuilder; + MethodRefMap methods; /* all te known method */ + + void wrongType(J3Class* from, const vmkit::Name* type); + J3Type* getTypeInternal(J3Class* from, const vmkit::Name* type, uint32_t start, uint32_t* end); + + protected: + std::vector > nativeLibraries; + + public: + void* operator new(size_t n, vmkit::BumpAllocator* allocator); + J3ClassLoader(J3* vm, J3ObjectHandle* javaClassLoader, vmkit::BumpAllocator* allocator); + + static void destroy(J3ClassLoader* loader); + + llvm::DIBuilder* dbgBuilder() const { return _dbgBuilder; } + + J3FixedPoint* fixedPoint() { return &_fixedPoint; } + + J3ObjectHandle* javaClassLoader() { return _javaClassLoader; } + + void lock() { pthread_mutex_lock(&_mutex); } + void unlock() { pthread_mutex_unlock(&_mutex); } + + vmkit::BumpAllocator* allocator() { return _allocator; } + J3* vm() const { return _vm; }; + llvm::FunctionPassManager* pm() { return _pm; } + + J3Method* method(uint16_t access, J3Class* cl, + const vmkit::Name* name, const vmkit::Name* sign); /* find a method ref */ + J3Method* method(uint16_t access, const vmkit::Name* clName, + const vmkit::Name* name, const vmkit::Name* sign); + J3Method* method(uint16_t access, const wchar_t* clName, const wchar_t* name, const wchar_t* sign); + + J3Class* getClass(const vmkit::Name* name); /* find a class */ + J3Type* getType(J3Class* from, const vmkit::Name* type); /* find a type */ + J3MethodType* getMethodType(J3Class* from, const vmkit::Name* sign); /* get a method type */ + llvm::Module* module() { return _module; } + + virtual J3ClassBytes* lookup(const vmkit::Name* name); + + void* lookupNativeFunctionPointer(J3Method* method, const char* symb); + }; + + struct char_ptr_less : public std::binary_function { + bool operator()(const char* lhs, const char* rhs) const; + }; + + class J3InitialClassLoader : public J3ClassLoader { + J3ZipArchive* archive; + std::map _cmangled; + public: + J3InitialClassLoader(J3* vm, const char* rtjar, vmkit::BumpAllocator* allocator); + + J3ClassBytes* lookup(const vmkit::Name* name); + + const char* cmangled(const char* demangled) { return _cmangled[demangled]; } + + void makeLLVMFunctions_j3(); + void registerCMangling(const char* mangled, const char* demangled); + }; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3codegen.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3codegen.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3codegen.h (added) +++ vmkit/branches/mcjit/include/j3/j3codegen.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,209 @@ +#ifndef _J3_CODE_GEN_H_ +#define _J3_CODE_GEN_H_ + +#include "llvm/IR/IRBuilder.h" +#include "j3/j3codegenvar.h" + +namespace llvm { + class Function; + class Value; +} + +namespace vmkit { + class BumpAllocator; +} + +namespace j3 { + class J3; + class J3Type; + class J3Class; + class J3ArrayClass; + class J3ClassLoader; + class J3Field; + class J3Method; + class J3MethodType; + class J3Reader; + class J3ObjectType; + + class J3ExceptionEntry { + public: + uint32_t startPC; + uint32_t endPC; + uint32_t handlerPC; + uint32_t catchType; + llvm::BasicBlock* bb; + + void dump(); + }; + + class J3ExceptionNode { + public: + uint32_t pc; + uint32_t nbEntries; + llvm::BasicBlock* landingPad; + llvm::BasicBlock* curCheck; + J3ExceptionEntry* entries[1]; + }; + + class J3OpInfo { + public: + llvm::Instruction* insn; + llvm::BasicBlock* bb; + llvm::Type** metaStack; + size_t topStack; + }; + + class J3CodeGen { + friend class J3CodeGenVar; + + vmkit::BumpAllocator* allocator; + llvm::Module* module; + llvm::BasicBlock* bb; + llvm::IRBuilder<>* builder; + llvm::Function* llvmFunction; + + J3* vm; + J3Class* cl; + J3ClassLoader* loader; + J3Method* method; + J3MethodType* methodType; + J3Reader* codeReader; + + llvm::BasicBlock* bbCheckCastFailed; + llvm::BasicBlock* bbNullCheckFailed; + llvm::BasicBlock* bbRet; + + J3ExceptionEntry* exceptionEntries; + J3ExceptionNode** exceptionNodes; + uint32_t nbExceptionEntries; + uint32_t nbExceptionNodes; + uint32_t curExceptionNode; + + J3OpInfo* opInfos; + uint32_t* pendingBranchs; + uint32_t topPendingBranchs; + + llvm::Value* nullValue; + + llvm::MDNode* dbgInfo; + uint32_t javaPC; + + J3CodeGenVar locals; + J3CodeGenVar stack; + J3CodeGenVar ret; + + bool closeBB; + + bool isWide; + + uint32_t wideReadU1(); + uint32_t wideReadS1(); + + llvm::Value* nullCheck(llvm::Value* obj); + + bool onEndPoint(); + llvm::BasicBlock* forwardBranch(const char* id, uint32_t pc, bool doAlloc, bool doPush); + void condBr(llvm::Value* op); + + llvm::Value* flatten(llvm::Value* v, J3Type* type); + llvm::Value* unflatten(llvm::Value* v, J3Type* type); + + llvm::Value* handleToObject(llvm::Value* obj); + llvm::Value* javaClass(J3ObjectType* type); + llvm::Value* staticInstance(J3Class* cl); + llvm::Value* vt(J3Type* cl); + llvm::Value* vt(llvm::Value* obj); + void initialiseJ3Type(J3Type* cl); + + llvm::Value* isAssignableTo(llvm::Value* obj, J3Type* type); + void instanceof(llvm::Value* obj, J3Type* type); + void checkCast(llvm::Value* obj, J3Type* type); + + void floatToInteger(J3Type* from, J3Type* to); + void compareFP(bool isL); + void compareLong(); + + void get(llvm::Value* obj, J3Field* field); + void getField(uint32_t idx); + void getStatic(uint32_t idx); + + void put(llvm::Value* obj, llvm::Value* val, J3Field* field); + void putField(uint32_t idx); + void putStatic(uint32_t idx); + + void invoke(J3Method* method, llvm::Value* func); + void invokeVirtual(uint32_t idx); + void invokeStatic(uint32_t idx); + void invokeSpecial(uint32_t idx); + + llvm::Value* arrayContent(J3Type* cType, llvm::Value* array, llvm::Value* idx); + + void arrayBoundCheck(llvm::Value* obj, llvm::Value* idx); + llvm::Value* arrayLength(llvm::Value* obj); + llvm::Value* arrayLengthPtr(llvm::Value* obj); + void arrayStore(J3Type* cType); + void arrayLoad(J3Type* cType); + + void newArray(uint8_t atype); + void newArray(J3ArrayClass* type); + void newObject(J3Class* cl); + + void ldc(uint32_t idx); + + void translate(); + + void initExceptionNode(J3ExceptionNode** pnode, uint32_t pc, J3ExceptionNode* node); + void addToExceptionNode(J3ExceptionNode* node, J3ExceptionEntry* entry); + void closeExceptionNode(J3ExceptionNode* node); + + void generateJava(); + void generateNative(); + + llvm::Value* buildString(const char* msg); + + static void echoDebugEnter(uint32_t isLeave, const char* msg, ...); + static void echoDebugExecute(uint32_t level, const char* msg, ...); + + llvm::Function* funcJ3MethodIndex; + llvm::Function* funcJ3TypeVT; + llvm::Function* funcJ3TypeInitialise; + llvm::Function* funcJ3ObjectTypeJavaClass; + llvm::Function* funcJ3ClassSize; + llvm::Function* funcJ3ClassStaticInstance; + llvm::Function* funcJ3ClassStringAt; + llvm::Function* funcJ3ObjectAllocate; + llvm::Function* funcJniEnv; + llvm::Function* funcClassCastException; + llvm::Function* funcNullPointerException; + llvm::Function* funcThrowException; + llvm::Function* funcSlowIsAssignableTo; + llvm::Function* funcFastIsAssignableToPrimaryChecker; + llvm::Function* funcFastIsAssignableToNonPrimaryChecker; + llvm::Function* funcJ3ThreadPushHandle; + llvm::Function* funcJ3ThreadPush; + llvm::Function* funcJ3ThreadTell; + llvm::Function* funcJ3ThreadRestore; + llvm::Function* funcJ3ThreadGet; + llvm::Function* funcEchoDebugExecute; + llvm::Function* funcEchoDebugEnter; + llvm::Function* funcCXABeginCatch; /* __cxa_begin_catch */ + llvm::Function* funcCXAEndCatch; /* __cxa_end_catch */ + llvm::Function* funcGXXPersonality; /* __gxx_personality_v0 */ + llvm::Function* gcRoot; + llvm::Function* ziTry; + llvm::GlobalValue* gvTypeInfo; /* typename void* */ + + J3CodeGen(vmkit::BumpAllocator* _allocator, J3Method* method); + ~J3CodeGen(); + + void* operator new(size_t n, vmkit::BumpAllocator* _allocator); + void operator delete(void* ptr); + public: + static J3CodeGen* create(J3Method* method); + static void destroy(J3CodeGen* codeGen); + + llvm::Function* generate(); + }; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3codegenvar.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3codegenvar.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3codegenvar.h (added) +++ vmkit/branches/mcjit/include/j3/j3codegenvar.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,45 @@ +#ifndef _J3_CODEGEN_VAR_H_ +#define _J3_CODEGEN_VAR_H_ + +#include + +namespace llvm { + class AllocaInst; + class Value; + class Type; +} + +namespace j3 { + class J3CodeGen; + + class J3CodeGenVar { + void killUnused(llvm::AllocaInst** stack, bool isObj); + public: + J3CodeGen* codeGen; + llvm::AllocaInst** intStack; + llvm::AllocaInst** longStack; + llvm::AllocaInst** floatStack; + llvm::AllocaInst** doubleStack; + llvm::AllocaInst** refStack; + llvm::Type** metaStack; + uint32_t topStack; + uint32_t maxStack; + + static uint32_t reservedSize(uint32_t max); + void init(J3CodeGen* _codeGen, uint32_t max, void* space); + + void killUnused(); + + uint32_t metaStackSize(); + + llvm::Value* at(uint32_t idx); + void setAt(llvm::Value* value, uint32_t idx); + void drop(uint32_t n); + llvm::Value* top(uint32_t idx=0); + llvm::Value* pop(); + void push(llvm::Value* value); + void dump(); + }; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3config.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3config.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3config.h (added) +++ vmkit/branches/mcjit/include/j3/j3config.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,6 @@ + +#define SHLIBEXT ".dylib" +#define OPENJDK_HOME "/Users/gthomas/research/vmkit4/jdk8/build/macosx-x86_64-normal-server-release/images/j2sdk-bundle/jdk1.8.0.jdk/Contents/Home/" + + + Added: vmkit/branches/mcjit/include/j3/j3config.h.in URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3config.h.in?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3config.h.in (added) +++ vmkit/branches/mcjit/include/j3/j3config.h.in Mon Nov 25 03:27:09 2013 @@ -0,0 +1,6 @@ + +#define SHLIBEXT "@SHLIBEXT@" +#define OPENJDK_HOME "@jdkhome@" + + + Added: vmkit/branches/mcjit/include/j3/j3constants.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3constants.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3constants.h (added) +++ vmkit/branches/mcjit/include/j3/j3constants.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,107 @@ +#ifndef _J3_CONSTANTS_H_ +#define _J3_CONSTANTS_H_ + +#include +#include + +namespace llvm { + class Type; +} + +namespace vmkit { + class Name; + class Names; +} + +namespace j3 { + class J3Class; + class J3; + + class J3Cst { + public: + static const char* opcodeNames[]; + + static const int MAGIC = 0xcafebabe; + + static wchar_t codeAttr[]; + static wchar_t constantValueAttr[]; + + static wchar_t clinitName[]; + static wchar_t clinitSign[]; + static wchar_t initName[]; + static char nativePrefix[]; + + static void initialize(vmkit::Names* names); + + static const int CONSTANT_Utf8 = 1; + static const int CONSTANT_Integer = 3; + static const int CONSTANT_Float = 4; + static const int CONSTANT_Long = 5; + static const int CONSTANT_Double = 6; + static const int CONSTANT_Class = 7; + static const int CONSTANT_String = 8; + static const int CONSTANT_Fieldref = 9; + static const int CONSTANT_Methodref = 10; + static const int CONSTANT_InterfaceMethodref = 11; + static const int CONSTANT_NameAndType = 12; + static const int CONSTANT_MethodHandle = 15; + static const int CONSTANT_MethodType = 16; + static const int CONSTANT_InvokeDynamic = 18; + +#define DO_IS(name, flag_name, value) \ + static const uint16_t flag_name = value; \ + static bool name(uint16_t flag) { return flag & flag_name; } + + DO_IS(isPublic, ACC_PUBLIC, 0x0001); + DO_IS(isPrivate, ACC_PRIVATE, 0x0002); + DO_IS(isProtected, ACC_PROTECTED, 0x0004); + DO_IS(isStatic, ACC_STATIC, 0x0008); + DO_IS(isFinal, ACC_FINAL, 0x0010); + DO_IS(isSuper, ACC_SUPER, 0x0020); + DO_IS(isSynchronized, ACC_SYNCHRONIZED, 0x0020); + DO_IS(isNative, ACC_NATIVE, 0x0100); + DO_IS(isVolatile, ACC_VOLATILE, 0x0040); + DO_IS(isTransient, ACC_TRANSIENT, 0x0080); + DO_IS(isInterface, ACC_INTERFACE, 0x0200); + DO_IS(isAbstract, ACC_ABSTRACT, 0x0400); + DO_IS(isStrict, ACC_STRICT, 0x0800); + +#undef DO_IS + + static const wchar_t ID_Void = 'V'; + static const wchar_t ID_Byte = 'B'; + static const wchar_t ID_Char = 'C'; + static const wchar_t ID_Double = 'D'; + static const wchar_t ID_Float = 'F'; + static const wchar_t ID_Integer = 'I'; + static const wchar_t ID_Long = 'J'; + static const wchar_t ID_Classname = 'L'; + static const wchar_t ID_End = ';'; + static const wchar_t ID_Short = 'S'; + static const wchar_t ID_Boolean = 'Z'; + static const wchar_t ID_Array = '['; + static const wchar_t ID_Left = '('; + static const wchar_t ID_Right = ')'; + + static const uint8_t T_BOOLEAN = 4; + static const uint8_t T_CHAR = 5; + static const uint8_t T_FLOAT = 6; + static const uint8_t T_DOUBLE = 7; + static const uint8_t T_BYTE = 8; + static const uint8_t T_SHORT = 9; + static const uint8_t T_INT = 10; + static const uint8_t T_LONG = 11; + + static uint32_t round(uint32_t value, uint32_t bound) { + return ((value - 1) & (-bound)) + bound; + } + + static const vmkit::Name* rewrite(J3* vm, const vmkit::Name* clName, const vmkit::Name* orig); + +#define defOpcode(ID, val, effect) \ + static const uint8_t BC_##ID = val; +#include "j3bc.def" +#undef defOpcode + }; +} +#endif Added: vmkit/branches/mcjit/include/j3/j3jni.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3jni.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3jni.h (added) +++ vmkit/branches/mcjit/include/j3/j3jni.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,10 @@ +#ifndef _J3_JNI_H_ +#define _J3_JNI_H_ + +#include "jni.h" + +namespace j3 { + extern struct JNINativeInterface_ jniEnvTable; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3lib.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3lib.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3lib.h (added) +++ vmkit/branches/mcjit/include/j3/j3lib.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,17 @@ +#ifndef _J3_LIB_H_ +#define _J3_LIB_H_ + +#include +#include + +namespace j3 { + class J3ClassBytes; + + class J3Lib { + public: + static const char** systemClassesArchives(); + static int loadSystemLibraries(std::vector >* handles); + }; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3mangler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3mangler.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3mangler.h (added) +++ vmkit/branches/mcjit/include/j3/j3mangler.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,40 @@ +#ifndef _J3_MANGLER_H_ +#define _J3_MANGLER_H_ + +#include + +namespace vmkit { + class Name; +} + +namespace j3 { + class J3Class; + class J3Method; + + class J3Mangler { + static const uint32_t max = 65536; + + J3Class* from; + char buf[max]; + char* cur; + char* next; + + void check(uint32_t n); + + public: + static const char* j3Id; + static const char* javaId; + + J3Mangler(J3Class* from); + + char* cStr() { return buf; } + uint32_t length() { return cur - buf; } + + J3Mangler* mangle(const char* prefix); + J3Mangler* mangle(const vmkit::Name* name); + J3Mangler* mangle(J3Method* method); + J3Mangler* mangleType(J3Method* method); + }; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3method.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3method.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3method.h (added) +++ vmkit/branches/mcjit/include/j3/j3method.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,133 @@ +#ifndef _J3_METHOD_H_ +#define _J3_METHOD_H_ + +#include +#include + +#include "vmkit/allocator.h" + +namespace llvm { + class FunctionType; + class Function; + class Type; + class GlobalValue; + class Module; + struct GenericValue; +} + +namespace vmkit { + class Name; +} + +namespace j3 { + class J3Type; + class J3Attributes; + class J3Class; + class J3Method; + class J3Value; + class J3ObjectHandle; + + class J3MethodType : public vmkit::PermanentObject { + llvm::FunctionType* _llvmType; + J3Type* _out; + uint32_t _nbIns; + J3Type* _ins[1]; + + public: + J3MethodType(J3Type** args, size_t nbArgs); + + llvm::FunctionType* llvmType() { return _llvmType; } + uint32_t nbIns() { return _nbIns; } + J3Type* out() { return _out; } + J3Type* ins(uint32_t idx) { return _ins[idx]; } + + void* operator new(size_t unused, vmkit::BumpAllocator* allocator, size_t n) { + return vmkit::PermanentObject::operator new(sizeof(J3MethodType) + (n - 1) * sizeof(J3Type*), allocator); + } + }; + + struct trampolin_t { + uint8_t code[1]; + }; + + class J3Method : public vmkit::PermanentObject { + public: + uint16_t _access; + J3Class* _cl; + const vmkit::Name* _name; + const vmkit::Name* _sign; + J3MethodType* _methodType; + J3Attributes* _attributes; + uint32_t _index; + llvm::Function* _nomcjitFunction; + llvm::GlobalValue* _nomcjitDescriptor; + llvm::Function* _compiledFunction; + char* volatile _llvmAllNames; /* md_ + llvm Name */ + size_t _llvmAllNamesLength; + void* _nativeFnPtr; + + uint8_t _trampoline[1]; + + llvm::Type* doNativeType(J3Type* type); + + J3Value internalInvoke(bool statically, std::vector* args); + J3Value internalInvoke(bool statically, J3ObjectHandle* handle, va_list va); + J3Value internalInvoke(bool statically, J3ObjectHandle* handle, J3Value* args); + + void* operator new(size_t size, vmkit::BumpAllocator* allocator, size_t trampolineSize); + + void buildLLVMNames(J3Class* from); + public: + J3Method(uint16_t access, J3Class* cl, const vmkit::Name* name, const vmkit::Name* sign); + + static J3Method* newMethod(vmkit::BumpAllocator* allocator, + uint16_t access, + J3Class* cl, + const vmkit::Name* name, + const vmkit::Name* sign); + + size_t llvmFunctionNameLength(J3Class* from=0); + char* llvmFunctionName(J3Class* from=0); + char* llvmDescriptorName(J3Class* from=0); + llvm::FunctionType* llvmType(J3Class* from=0); + + void postInitialise(uint32_t access, J3Attributes* attributes); + void setResolved(uint32_t index); + + J3Method* resolve(J3ObjectHandle* obj); + + llvm::Function* nativeLLVMFunction(llvm::Module* module); + llvm::GlobalValue* llvmDescriptor(llvm::Module* module); + llvm::Function* llvmFunction(bool isStub, llvm::Module* module, J3Class* from=0); + + uint32_t index(); + uint32_t* indexPtr() { return &_index; } + bool isResolved() { return _index != -1; } + + J3Attributes* attributes() const { return _attributes; } + uint16_t access() const { return _access; } + J3Class* cl() const { return _cl; } + const vmkit::Name* name() const { return _name; } + const vmkit::Name* sign() const { return _sign; } + J3MethodType* methodType(J3Class* from=0); + + void registerNative(void* ptr); + + J3Value invokeStatic(...); + J3Value invokeStatic(J3Value* args); + J3Value invokeStatic(va_list va); + J3Value invokeSpecial(J3ObjectHandle* obj, ...); + J3Value invokeSpecial(J3ObjectHandle* obj, J3Value* args); + J3Value invokeSpecial(J3ObjectHandle* obj, va_list va); + J3Value invokeVirtual(J3ObjectHandle* obj, ...); + J3Value invokeVirtual(J3ObjectHandle* obj, J3Value* args); + J3Value invokeVirtual(J3ObjectHandle* obj, va_list va); + + void* fnPtr(); + void* functionPointerOrTrampoline(); + + void dump(); + }; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3object.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3object.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3object.h (added) +++ vmkit/branches/mcjit/include/j3/j3object.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,202 @@ +#ifndef _J3_OBJECT_H_ +#define _J3_OBJECT_H_ + +#include +#include + +#include "j3/j3typesdef.h" + +namespace vmkit { + class BumpAllocator; +} + +namespace j3 { + class J3Type; + class J3Class; + class J3Layout; + class J3ArrayClass; + class J3Primitive; + class J3Field; + class J3VirtualTable; + class J3FixedPoint; + class J3Method; + + // see: Cliff Click and John Rose. 2002. Fast subtype checking in the HotSpot JVM. + // In Proceedings of the 2002 joint ACM-ISCOPE conference on Java Grande (JGI '02). ACM, New York, NY, USA, 96-107. + class J3TypeChecker { + public: + static const uint32_t displayLength = 9; + static const uint32_t cacheOffset = displayLength - 1; + + J3VirtualTable* display[displayLength]; + J3VirtualTable** secondaryTypes; + uint32_t nbSecondaryTypes; + uint32_t offset; /* offset between 1 and 8 if class, cache otherwise */ + + void dump(); + }; + + class J3VirtualTable { + public: + static const uint32_t gepObjectClass = 0; + static const uint32_t gepVirtualMethods = 3; + + private: + J3Type* _type; + J3TypeChecker checker; + size_t _nbVirtualMethods; + void* _virtualMethods[1]; + + J3VirtualTable(J3Type* type, J3Type* super, J3Type** interfaces, uint32_t nbInterfaces, bool isSecondary); + void* operator new(size_t unused, vmkit::BumpAllocator* allocator, size_t n); + public: + static J3VirtualTable* create(J3Layout* cl); + static J3VirtualTable* create(J3Class* cl); + static J3VirtualTable* create(J3ArrayClass* cl); + static J3VirtualTable* create(J3Primitive* prim); + + uint32_t offset() { return checker.offset; } + bool isPrimaryChecker() { return checker.offset < J3TypeChecker::cacheOffset; } + + bool slowIsAssignableTo(J3VirtualTable* parent); + bool fastIsAssignableToPrimaryChecker(J3VirtualTable* parent, uint32_t parentOffset); + bool fastIsAssignableToNonPrimaryChecker(J3VirtualTable* parent); + bool isAssignableTo(J3VirtualTable* parent); + + J3Type* type() const { return _type; } + void** virtualMethods() const { return (void**)_virtualMethods; } + size_t nbVirtualMethods() const { return _nbVirtualMethods; } + + void dump(); + }; + + class J3Object { + friend class J3ArrayObject; + friend class J3ObjectHandle; + public: + static const uint32_t gepVT = 0; + + private: + J3VirtualTable* _vt; + uintptr_t _header; + + J3Object(); /* never directly allocate an object */ + + static J3Object* allocate(J3VirtualTable* vt, size_t n); + static J3Object* doNewNoInit(J3Class* cl); + static J3Object* doNew(J3Class* cl); + public: + + J3VirtualTable* vt(); + uintptr_t* header(); + }; + + class J3ArrayObject : public J3Object { + friend class J3ObjectHandle; + public: + static const uint32_t gepLength = 1; + static const uint32_t gepContent = 2; + + private: + uint32_t _length; + static J3Object* doNew(J3ArrayClass* cl, uint32_t length); + + public: + + uint32_t length() { return _length; } + }; + + class J3ObjectHandle { + friend class J3FixedPoint; + friend class J3Method; + + public: + static const uint32_t gepObj = 0; + + private: + J3Object* volatile _obj; + + J3Object* obj() { return _obj; } + J3ArrayObject* array() { return (J3ArrayObject*)_obj; } + public: + J3VirtualTable* vt() { return obj()->vt(); } + uint32_t arrayLength() { return array()->length(); } + + static J3ObjectHandle* allocate(J3VirtualTable* vt, size_t n); + static J3ObjectHandle* doNewObject(J3Class* cl); + static J3ObjectHandle* doNewArray(J3ArrayClass* cl, uint32_t length); + + static void* trampoline(J3Object* obj, J3Method* ref); + + void harakiri() { _obj = 0; } + + uint32_t hashCode(); + + void rawSetObject(uint32_t offset, J3ObjectHandle* v); + J3ObjectHandle* rawGetObject(uint32_t offset); + void setObject(J3Field* f, J3ObjectHandle* v); + J3ObjectHandle* getObject(J3Field* f); + void setObjectAt(uint32_t idx, J3ObjectHandle* v); + J3ObjectHandle* getObjectAt(uint32_t idx); + +#define defAccessor(name, ctype, llvmtype) \ + void rawSet##name(uint32_t offset, ctype value); \ + ctype rawGet##name(uint32_t offset); \ + void set##name(J3Field* f, ctype value); \ + ctype get##name(J3Field* f); \ + void set##name##At(uint32_t idx, ctype value); \ + ctype get##name##At(uint32_t idx); + onJavaPrimitives(defAccessor); +#undef defAccessor + }; + + class J3FixedPointNode { + public: + J3FixedPointNode* nextFree; + J3FixedPointNode* nextBusy; + J3ObjectHandle* top; + J3ObjectHandle* max; + }; + + class J3FixedPoint { + static const uint32_t defaultNodeCapacity = 256; + + pthread_mutex_t mutex; + vmkit::BumpAllocator* allocator; + J3FixedPointNode* head; + + void createNode(uint32_t capacity=defaultNodeCapacity); + public: + J3FixedPoint(vmkit::BumpAllocator* _allocator); + + void unsyncEnsureCapacity(uint32_t capacity); + + J3ObjectHandle* syncPush(J3ObjectHandle* handle) { return syncPush(handle->obj()); } + J3ObjectHandle* syncPush(J3Object* obj); + J3ObjectHandle* unsyncPush(J3ObjectHandle* handle) { return unsyncPush(handle->obj()); } + J3ObjectHandle* unsyncPush(J3Object* obj); + void unsyncPop(); + + J3ObjectHandle* unsyncTell() { return head->top; } + void unsyncRestore(J3ObjectHandle* ptr); + }; + + class J3Value { + public: + union { +#define doIt(name, ctype, llvmtype) \ + ctype val##name; + onJavaFields(doIt); +#undef doIt + }; + +#define doIt(name, ctype, llvmtype) \ + J3Value(ctype val) { val##name = val; } + onJavaFields(doIt); +#undef doIt + + J3Value() {} + }; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3options.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3options.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3options.h (added) +++ vmkit/branches/mcjit/include/j3/j3options.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,44 @@ +#ifndef _J3_CMD_LINE_H_ +#define _J3_CMD_LINE_H_ + +#include + +namespace j3 { + class J3Options; + + class J3CmdLineParser { + J3Options* options; + char** argv; + int argc; + int cur; + + void help(); + public: + J3CmdLineParser(J3Options* _options, int _argc, char** _argv); + + void process(); + }; + + class J3Options { + friend class J3CmdLineParser; + + public: + bool assertionsEnabled; + const char* selfBitCodePath; + const char* rtJar; + bool debugEnterIndent; + uint32_t genDebugExecute; + uint32_t debugExecute; + uint32_t debugLoad; + uint32_t debugResolve; + uint32_t debugIniting; + uint32_t debugTranslate; + uint32_t debugLinking; + + J3Options(); + + void process(int argc, char** argv); + }; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3reader.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3reader.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3reader.h (added) +++ vmkit/branches/mcjit/include/j3/j3reader.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,127 @@ +//===----------------- Reader.h - Open and read files ---------------------===// +// +// The VMKit project +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef JNJVM_READER_H +#define JNJVM_READER_H + +#include + +#include "vmkit/allocator.h" + +namespace j3 { + +class JnjvmBootstrapLoader; +class JnjvmClassLoader; +class J3ZipArchive; + +class J3ClassBytes : vmkit::PermanentObject { + public: + uint32_t size; + uint8_t elements[1]; + + J3ClassBytes(int l) { + size = l; + } + + void* operator new(size_t sz, vmkit::BumpAllocator* allocator, int n) { + return vmkit::PermanentObject::operator new(sizeof(J3ClassBytes) + (n - 1) * sizeof(uint8_t), allocator); + } +}; + +class J3Reader { + friend class J3ZipArchive; + + J3ClassBytes* bytes; + uint32_t min; + uint32_t cursor; + uint32_t max; + +public: + J3Reader(J3ClassBytes* bytes, uint32_t s=0, uint32_t nbb=0) { + if (!nbb) nbb = bytes->size; + this->bytes = bytes; + this->cursor = s; + this->min = s; + this->max = s + nbb; + } + + J3Reader(J3Reader& r, uint32_t nbb) { + bytes = r.bytes; + cursor = r.cursor; + min = r.min; + max = min + nbb; + } + + static const int SeekSet; + static const int SeekCur; + static const int SeekEnd; + + static J3ClassBytes* openFile(vmkit::BumpAllocator* allocator, const char* path); + static J3ClassBytes* openZip(vmkit::BumpAllocator* allocator, J3ZipArchive* archive, const char* filename); + + uint32_t remaining() { + return max - cursor; + } + + unsigned int tell() { + return cursor - min; + } + + void seek(uint32_t pos, int from); + + bool adjustSize(uint32_t nbb); + + const uint8_t* pointer() { + return bytes->elements + cursor; + } + + uint8_t readU1() { + ++cursor; + return bytes->elements[cursor - 1]; + } + + int8_t readS1() { + ++cursor; + return bytes->elements[cursor - 1]; + } + + uint16_t readU2() { + uint16_t tmp = ((uint16_t)(readU1())) << 8; + return tmp | ((uint16_t)(readU1())); + } + + int16_t readS2() { + int16_t tmp = ((int16_t)(readS1())) << 8; + return tmp | ((int16_t)(readU1())); + } + + uint32_t readU4() { + uint32_t tmp = ((uint32_t)(readU2())) << 16; + return tmp | ((uint32_t)(readU2())); + } + + int32_t readS4() { + int32_t tmp = ((int32_t)(readS2())) << 16; + return tmp | ((int32_t)(readU2())); + } + + uint64_t readU8() { + uint64_t tmp = ((uint64_t)(readU4())) << 32; + return tmp | ((uint64_t)(readU4())); + } + + int64_t readS8() { + int64_t tmp = ((int64_t)(readS4())) << 32; + return tmp | ((int64_t)(readU4())); + } +}; + +} // end namespace j3 + +#endif Added: vmkit/branches/mcjit/include/j3/j3thread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3thread.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3thread.h (added) +++ vmkit/branches/mcjit/include/j3/j3thread.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,40 @@ +#ifndef _J3_THREAD_H_ +#define _J3_THREAD_H_ + +#include "vmkit/thread.h" +#include "vmkit/allocator.h" +#include "j3/j3object.h" +#include "j3/j3jni.h" + +namespace j3 { + class J3; + + class J3Thread : public vmkit::Thread { + vmkit::BumpAllocator* allocator; + JNIEnv _jniEnv; + J3FixedPoint _fixedPoint; + J3ObjectHandle* _pendingException; + + J3Thread(J3* vm, vmkit::BumpAllocator* allocator); + public: + static J3Thread* create(J3* j3); + + void ensureCapacity(uint32_t capacity); + J3ObjectHandle* pendingException() { return _pendingException; } + void setPendingException(J3ObjectHandle* handle) { _pendingException = handle; } + J3FixedPoint* fixedPoint() { return &_fixedPoint; } + + J3ObjectHandle* push(J3ObjectHandle* handle); + J3ObjectHandle* push(J3Object* obj); + J3ObjectHandle* tell(); + void restore(J3ObjectHandle* obj); + + J3* vm() { return (J3*)Thread::vm(); } + + JNIEnv* jniEnv() { return &_jniEnv; } + + static J3Thread* get(); + }; +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3typesdef.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3typesdef.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3typesdef.h (added) +++ vmkit/branches/mcjit/include/j3/j3typesdef.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,32 @@ +#ifndef _J3_PRIMITIVE_H_ +#define _J3_PRIMITIVE_H_ + +namespace j3 { + +#define onJavaPrimitives(_) \ + _(Boolean, bool, Int1) \ + _(Byte, int8_t, Int8) \ + _(Short, int16_t, Int16) \ + _(Char, uint16_t, Int16) \ + _(Integer, int32_t, Int32) \ + _(Long, int64_t, Int64) \ + _(Float, float, Float) \ + _(Double, double, Double) \ + +#define onJavaObject(_) \ + _(Object, J3ObjectHandle*, Fatal) + +#define onJavaVoid(_) \ + _(Void, void, Void) + +#define onJavaTypes(_) \ + onJavaPrimitives(_) \ + onJavaVoid(_) + +#define onJavaFields(_) \ + onJavaPrimitives(_) \ + onJavaObject(_) + +} + +#endif Added: vmkit/branches/mcjit/include/j3/j3zip.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3zip.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3zip.h (added) +++ vmkit/branches/mcjit/include/j3/j3zip.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,61 @@ +//===----------------- Zip.h - Interface with zlib ------------------------===// +// +// The VMKit project +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef JNJVM_ZIP_H +#define JNJVM_ZIP_H + +#include + +#include "vmkit/allocator.h" +#include "vmkit/util.h" + +namespace j3 { + +class J3ClassBytes; + +class J3ZipFile : public vmkit::PermanentObject { +public: + char* filename; + int ucsize; + int csize; + uint32_t filenameLength; + uint32_t extraFieldLength; + uint32_t fileCommentLength; + int rolh; + int compressionMethod; +}; + + +class J3ZipArchive : public vmkit::PermanentObject { + vmkit::BumpAllocator* allocator; + + typedef std::map > > FileMap; + + int ofscd; + FileMap filetable; + J3ClassBytes* bytes; + + void findOfscd(); + void addFiles(); + + void remove(); + +public: + J3ZipArchive(J3ClassBytes* bytes, vmkit::BumpAllocator* allocator); + + int getOfscd() { return ofscd; } + J3ZipFile* getFile(const char* filename); + int readFile(J3ClassBytes* array, const J3ZipFile* file); + + typedef FileMap::iterator table_iterator; +}; + +} // end namespace j3 + +#endif Added: vmkit/branches/mcjit/include/jni_md.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/jni_md.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/jni_md.h (added) +++ vmkit/branches/mcjit/include/jni_md.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,72 @@ +#ifndef _JNI_MD_H_ +#define _JNI_MD_H_ + +#define JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H + +#include + +namespace j3 { + class J3ObjectHandle; + class J3Value; + class J3ObjectType; + class J3Field; + class J3Method; +} + +extern "C" { + +#ifndef __has_attribute +#define __has_attribute(x) 0 +#endif +#if (defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4) && (__GNUC_MINOR__ > 2))) || __has_attribute(visibility) +#define JNIEXPORT __attribute__((visibility("default"))) +#define JNIIMPORT __attribute__((visibility("default"))) +#else + #define JNIEXPORT + #define JNIIMPORT +#endif + +#define JNICALL + + typedef bool jboolean; + typedef int8_t jbyte; + typedef uint16_t jchar; + typedef int16_t jshort; + typedef int32_t jint; + typedef int64_t jlong; + typedef float jfloat; + typedef double jdouble; + + typedef uint32_t jsize; + + typedef j3::J3ObjectHandle* jobject; + typedef jobject jclass; + typedef jobject jthrowable; + typedef jobject jstring; + typedef jobject jarray; + typedef jarray jbooleanArray; + typedef jarray jbyteArray; + typedef jarray jcharArray; + typedef jarray jshortArray; + typedef jarray jintArray; + typedef jarray jlongArray; + typedef jarray jfloatArray; + typedef jarray jdoubleArray; + typedef jarray jobjectArray; + + typedef jobject jweak; + typedef j3::J3Value jvalue; + + typedef j3::J3Field* jfieldID; + typedef j3::J3Method* jmethodID; + + /* Return values from jobjectRefType */ + typedef enum _jobjectType { + JNIInvalidRefType = 0, + JNILocalRefType = 1, + JNIGlobalRefType = 2, + JNIWeakGlobalRefType = 3 + } jobjectRefType; +} + +#endif Added: vmkit/branches/mcjit/include/safepoint.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/safepoint.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/safepoint.h (added) +++ vmkit/branches/mcjit/include/safepoint.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,12 @@ +#ifndef _SAFE_POINT_H_ +#define _SAFE_POINT_H_ + +namespace vmkit { + class SafePoint { + llvm::Function* function; /* safe inside this function */ + uintptr_t ip; /* ip of this safepoint */ + public: + }; +} + +#endif Added: vmkit/branches/mcjit/include/vmkit/allocator.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/vmkit/allocator.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/vmkit/allocator.h (added) +++ vmkit/branches/mcjit/include/vmkit/allocator.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,119 @@ +//===----------- Allocator.h - A memory allocator ------------------------===// +// +// The VMKit project +// +//===----------------------------------------------------------------------===// + +#ifndef ALLOCATOR_H +#define ALLOCATOR_H + +#include +#include +#include +#include +#include +#include + +namespace vmkit { + class BumpAllocatorNode { /* always the first bytes of a bucket */ + public: + BumpAllocatorNode* next; + uint8_t* top; + }; + + class BumpAllocator { + static const size_t bucketSize = 64*1024; + private: + pthread_mutex_t mutex; + BumpAllocatorNode* current; + + void* operator new(size_t n); + BumpAllocator(); /* private to force an allocation via the new operator */ + ~BumpAllocator(); + void operator delete(void* p); + public: + static size_t round(uint64_t n, uint64_t r) { return ((n - 1) & -r) + r; } + + static BumpAllocator* create(); + static void destroy(BumpAllocator* allocator); + + static void* map(size_t n); + static void unmap(void* p, size_t n); + + void* allocate(size_t size); + + }; + + class PermanentObject { + void* operator new(size_t size) { return 0; } + public: + void* operator new(size_t size, BumpAllocator* allocator) { + return allocator->allocate(size); + } + + void* operator new [](size_t size, BumpAllocator* allocator) { + return allocator->allocate(size); + } + + void operator delete(void* ptr); + + void operator delete[](void* ptr); + }; + + template + class StdAllocator : public PermanentObject { + public: + typedef T value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + + typedef T* pointer; + typedef const T* const_pointer; + + typedef T& reference; + typedef const T& const_reference; + + template struct rebind { typedef StdAllocator other; }; + + size_type max_size( ) const { return 0x1000L*0x1000L; } + + BumpAllocator* _allocator; + + template + StdAllocator(const StdAllocator &other) { + _allocator = other._allocator; + } + + StdAllocator(BumpAllocator* allocator) { + _allocator = allocator; + } + + pointer allocate(size_type n, const void* hint=0) { + pointer res = (pointer)_allocator->allocate(n*sizeof(T)); + //printf("allocate %lu object at %p\n", n, res); + return res; + } + + void deallocate(pointer p, size_type n) { + PermanentObject::operator delete(p); + } + + pointer address(reference r) const { return &r; } + const_pointer address(const_reference r) const { return &r; } + + void construct(pointer p, const T& val) { + new (p) T(val); + } + + void destroy(pointer p) { + p->~T(); + } + }; + + template + struct T_ptr_less_t : public PermanentObject { + bool operator()(const T& lhs, const T& rhs) const { return lhs < rhs; } + }; +} // end namespace vmkit + +#endif // VMKIT_ALLOCATOR_H Added: vmkit/branches/mcjit/include/vmkit/gc.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/vmkit/gc.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/vmkit/gc.h (added) +++ vmkit/branches/mcjit/include/vmkit/gc.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,13 @@ +#ifndef _GC_H_ +#define _GC_H_ + +#include + +namespace vmkit { + class GC { + public: + static void* allocate(size_t sz); + }; +}; + +#endif Added: vmkit/branches/mcjit/include/vmkit/names.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/vmkit/names.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/vmkit/names.h (added) +++ vmkit/branches/mcjit/include/vmkit/names.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,54 @@ +#ifndef _NAMES_H_ +#define _NAMES_H_ + +#include + +#include "vmkit/allocator.h" +#include "vmkit/util.h" + +namespace vmkit { + class Name : public PermanentObject { + uint32_t _length; + wchar_t _content[1]; + + public: + void* operator new(size_t unused, BumpAllocator* allocator, size_t length); + + Name(uint32_t length, const wchar_t* content); + + const wchar_t* cStr() const { + return _content; + } + + uint32_t length() const { + return _length; + } + + static T_ptr_less_t less; + }; + + class Names : public PermanentObject { + BumpAllocator* allocator; + pthread_mutex_t mutex; + + std::map > > names; + + public: + Names(BumpAllocator* allocator); + + const Name* get(const wchar_t* s); + const Name* get(const char* s, size_t start=0, size_t length=-1); + const Name* get(char c); + + }; + + template + class NameMap { + public: + typedef StdAllocator > alloc; + typedef std::map, alloc > map; + }; +} + +#endif Added: vmkit/branches/mcjit/include/vmkit/thread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/vmkit/thread.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/vmkit/thread.h (added) +++ vmkit/branches/mcjit/include/vmkit/thread.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,39 @@ +#ifndef _THREAD_H_ +#define _THREAD_H_ + +#include "vmkit/allocator.h" + +namespace vmkit { + class VMKit; + + class Thread : protected PermanentObject { + BumpAllocator* _allocator; + VMKit* _vm; + + protected: + Thread(VMKit* vm, BumpAllocator* allocator); + + public: + static void destroy(Thread* thread); + + VMKit* vm() { return _vm; } + BumpAllocator* allocator() { return _allocator; } + + static __thread Thread* _thread; + + static Thread* get() { return _thread; } + static void set(Thread* thread) { _thread = thread; } + }; + + class StackWalker { + uintptr_t framePointer; + + public: + StackWalker(uint32_t initialPop=1); + + void next(uint32_t nbPop=1); + uintptr_t ip(); + }; +} + +#endif Added: vmkit/branches/mcjit/include/vmkit/util.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/vmkit/util.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/vmkit/util.h (added) +++ vmkit/branches/mcjit/include/vmkit/util.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,20 @@ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +namespace vmkit { + class Util { + public: + struct char_less_t { + bool operator()(const char* s1, const char* s2) const; + }; + + struct wchar_t_less_t { + bool operator()(const wchar_t* lhs, const wchar_t* rhs) const; + }; + + static struct char_less_t char_less; + static struct wchar_t_less_t wchar_t_less; + }; +}; + +#endif Added: vmkit/branches/mcjit/include/vmkit/vmkit.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/vmkit/vmkit.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/vmkit/vmkit.h (added) +++ vmkit/branches/mcjit/include/vmkit/vmkit.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,100 @@ +#ifndef _VMKIT_VM_H_ +#define _VMKIT_VM_H_ + +#include "vmkit/util.h" +#include "vmkit/allocator.h" + +#include "llvm/ExecutionEngine/JITEventListener.h" + +namespace llvm { + class Module; + class ExecutionEngine; + class DataLayout; + class GlobalValue; + class Function; + class Type; + namespace legacy { + class FunctionPassManager; + } + using legacy::FunctionPassManager; +} + +namespace vmkit { + class Thread; + + class Safepoint { /* managed with malloc/free */ + const llvm::Function* _llvmFunction; + uintptr_t _address; + size_t _nbSlots; + uintptr_t _offsets[1]; + + void* operator new(size_t unused, size_t nbSlots); + Safepoint(const llvm::Function* llvmFunction, uintptr_t address, size_t nbSlots); + + public: + static Safepoint* create(const llvm::Function* llvmFunction, uintptr_t address, size_t nbSlots); + + void setAt(size_t idx, uintptr_t offset) { _offsets[idx] = idx; } + }; + + class ExceptionDescriptor { /* managed with malloc/free */ + const llvm::Function* _llvmFunction; + uintptr_t _point; + uintptr_t _landingPad; + public: + ExceptionDescriptor(const llvm::Function* llvmFunction, uintptr_t point, uintptr_t landingPad); + }; + + class VMKit : public llvm::JITEventListener { + typedef std::map > > MangleMap; + + std::map safepointMap; /* managed with malloc/free */ + std::map exceptionTable; /* managed with malloc/free */ + MangleMap mangleMap; + BumpAllocator* _allocator; + llvm::Module* _self; + llvm::ExecutionEngine* _ee; + llvm::DataLayout* _dataLayout; + void* ptrTypeInfo; + + uintptr_t addSymbol(llvm::GlobalValue* gv); + + static void defaultInternalError(const wchar_t* msg, va_list va) __attribute__((noreturn)); + protected: + void* operator new(size_t n, BumpAllocator* allocator); + + public: + static void destroy(VMKit* vm); + + VMKit(BumpAllocator* allocator); + + BumpAllocator* allocator() { return _allocator; } + + void vmkitBootstrap(Thread* initialThread, const char* selfBitCodePath); + + llvm::DataLayout* dataLayout() { return _dataLayout; } + llvm::Module* self() { return _self; } + llvm::ExecutionEngine* ee() { return _ee; } + llvm::FunctionPassManager* preparePM(llvm::Module* mod); + llvm::Function* getGCRoot(llvm::Module* mod); + llvm::Function* introspectFunction(llvm::Module* dest, const char* name); + llvm::GlobalValue* introspectGlobalValue(llvm::Module* dest, const char* name); + llvm::Type* introspectType(const char* name); + + void log(const wchar_t* msg, ...); + + virtual void internalError(const wchar_t* msg, va_list va) __attribute__((noreturn)); + + static void internalError(const wchar_t* msg, ...) __attribute__((noreturn)); + static void throwException(void* obj) __attribute__((noreturn)); + + void NotifyFunctionEmitted(const llvm::Function &F, + void *Code, + size_t Size, + const llvm::JITEventListener::EmittedFunctionDetails &Details); + + }; +}; + +#endif Added: vmkit/branches/mcjit/lib/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/Makefile?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/Makefile (added) +++ vmkit/branches/mcjit/lib/Makefile Mon Nov 25 03:27:09 2013 @@ -0,0 +1,10 @@ +#===- ./Makefile -------------------------------------------*- Makefile -*--===# +# +# The vmkit project +#===------------------------------------------------------------------------===# + +LEVEL := .. + +DIRS := vmkit j3 + +include $(LEVEL)/Makefile.rules Added: vmkit/branches/mcjit/lib/j3/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/Makefile?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/Makefile (added) +++ vmkit/branches/mcjit/lib/j3/Makefile Mon Nov 25 03:27:09 2013 @@ -0,0 +1,10 @@ +#===- ./Makefile -------------------------------------------*- Makefile -*--===# +# +# The vmkit project +#===------------------------------------------------------------------------===# + +LEVEL := ../.. + +DIRS := vm openjdk + +include $(LEVEL)/Makefile.rules Added: vmkit/branches/mcjit/lib/j3/openjdk/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/Makefile?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/openjdk/Makefile (added) +++ vmkit/branches/mcjit/lib/j3/openjdk/Makefile Mon Nov 25 03:27:09 2013 @@ -0,0 +1,10 @@ +#===- ./Makefile -------------------------------------------*- Makefile -*--===# +# +# The vmkit project +#===------------------------------------------------------------------------===# + +LEVEL := ../../.. + +MODULE=openjdk + +include $(LEVEL)/Makefile.rules Added: vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc (added) +++ vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,917 @@ +#include "j3/j3object.h" +#include "j3/j3lib.h" +#include "j3/j3config.h" +#include "j3/j3.h" +#include "j3/j3thread.h" +#include "j3/j3classloader.h" +#include "j3/j3class.h" +#include "jvm.h" + +#include + +using namespace j3; + +#define enterJVM() +#define leaveJVM() + +#define NYI() { fprintf(stderr, "++ not yet implemented: %s ++\n", __PRETTY_FUNCTION__); abort(); } + +#define OPENJDK_PATH OPENJDK_HOME"/jre" +#define OPENJDK_LIBPATH OPENJDK_PATH"/lib" +#define OPENJDK_RT OPENJDK_LIBPATH"/rt.jar" +#define OPENJDK_LIB OPENJDK_LIBPATH"/libjava"SHLIBEXT + +static const char* rtjar[] = { + OPENJDK_LIBPATH"/rt.jar", + 0 +}; + +const char** J3Lib::systemClassesArchives() { + return rtjar; +} + +int J3Lib::loadSystemLibraries(std::vector >* nativeLibraries) { + /* JavaRuntimeSupport checks for a symbol defined in this library */ + void* h0 = dlopen(OPENJDK_LIBPATH"/libinstrument"SHLIBEXT, RTLD_LAZY | RTLD_GLOBAL); + void* handle = dlopen(OPENJDK_LIBPATH"/libjava"SHLIBEXT, RTLD_LAZY | RTLD_LOCAL); + + if(!handle || !h0) { + fprintf(stderr, "Fatal: unable to find java system library: %s\n", dlerror()); + abort(); + } + + nativeLibraries->push_back(handle); + + return 0; +} + + +/************************************************************************* + PART 0 + ************************************************************************/ + +jint JNICALL JVM_GetInterfaceVersion(void) { enterJVM(); NYI(); leaveJVM(); } + +/************************************************************************* + PART 1: Functions for Native Libraries + ************************************************************************/ +/* + * java.lang.Object + */ +jint JNICALL JVM_IHashCode(JNIEnv* env, jobject obj) { + enterJVM(); + uint32_t res = obj ? obj->hashCode() : 0; + leaveJVM(); + return res; +} + +void JNICALL JVM_MonitorWait(JNIEnv* env, jobject obj, jlong ms) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_MonitorNotify(JNIEnv* env, jobject obj) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_MonitorNotifyAll(JNIEnv* env, jobject obj) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_Clone(JNIEnv* env, jobject obj) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.String + */ +jstring JNICALL JVM_InternString(JNIEnv* env, jstring str) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.System + */ +jlong JNICALL JVM_CurrentTimeMillis(JNIEnv* env, jclass ignored) { enterJVM(); NYI(); leaveJVM(); } +jlong JNICALL JVM_NanoTime(JNIEnv* env, jclass ignored) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_ArrayCopy(JNIEnv* env, jclass ignored, jobject src, jint src_pos, jobject dst, jint dst_pos, jint length) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_InitProperties(JNIEnv* env, jobject p) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.io.File + */ +void JNICALL JVM_OnExit(void (*func)(void)) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.Runtime + */ +void JNICALL JVM_Exit(jint code) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_Halt(jint code) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_GC(void) { enterJVM(); NYI(); leaveJVM(); } + +/* Returns the number of real-time milliseconds that have elapsed since the + * least-recently-inspected heap object was last inspected by the garbage + * collector. + * + * For simple stop-the-world collectors this value is just the time + * since the most recent collection. For generational collectors it is the + * time since the oldest generation was most recently collected. Other + * collectors are free to return a pessimistic estimate of the elapsed time, or + * simply the time since the last full collection was performed. + * + * Note that in the presence of reference objects, a given object that is no + * longer strongly reachable may have to be inspected multiple times before it + * can be reclaimed. + */ +jlong JNICALL JVM_MaxObjectInspectionAge(void) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_TraceInstructions(jboolean on) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_TraceMethodCalls(jboolean on) { enterJVM(); NYI(); leaveJVM(); } +jlong JNICALL JVM_TotalMemory(void) { enterJVM(); NYI(); leaveJVM(); } +jlong JNICALL JVM_FreeMemory(void) { enterJVM(); NYI(); leaveJVM(); } +jlong JNICALL JVM_MaxMemory(void) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_ActiveProcessorCount(void) { enterJVM(); NYI(); leaveJVM(); } +void * JNICALL JVM_LoadLibrary(const char *name) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_UnloadLibrary(void * handle) { enterJVM(); NYI(); leaveJVM(); } +void * JNICALL JVM_FindLibraryEntry(void *handle, const char *name) { enterJVM(); NYI(); leaveJVM(); } +jboolean JNICALL JVM_IsSupportedJNIVersion(jint version) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.Float and java.lang.Double + */ +jboolean JNICALL JVM_IsNaN(jdouble d) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.Throwable + */ +void JNICALL JVM_FillInStackTrace(JNIEnv* env, jobject throwable) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_GetStackTraceDepth(JNIEnv* env, jobject throwable) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_GetStackTraceElement(JNIEnv* env, jobject throwable, jint index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.Compiler + */ +void JNICALL JVM_InitializeCompiler (JNIEnv* env, jclass compCls) { enterJVM(); NYI(); leaveJVM(); } +jboolean JNICALL JVM_IsSilentCompiler(JNIEnv* env, jclass compCls) { enterJVM(); NYI(); leaveJVM(); } +jboolean JNICALL JVM_CompileClass(JNIEnv* env, jclass compCls, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +jboolean JNICALL JVM_CompileClasses(JNIEnv* env, jclass cls, jstring jname) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_CompilerCommand(JNIEnv* env, jclass compCls, jobject arg) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_EnableCompiler(JNIEnv* env, jclass compCls) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_DisableCompiler(JNIEnv* env, jclass compCls) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.Thread + */ +void JNICALL JVM_StartThread(JNIEnv* env, jobject thread) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_StopThread(JNIEnv* env, jobject thread, jobject exception) { enterJVM(); NYI(); leaveJVM(); } +jboolean JNICALL JVM_IsThreadAlive(JNIEnv* env, jobject thread) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_SuspendThread(JNIEnv* env, jobject thread) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_ResumeThread(JNIEnv* env, jobject thread) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_SetThreadPriority(JNIEnv* env, jobject thread, jint prio) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_Yield(JNIEnv* env, jclass threadClass) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_CurrentThread(JNIEnv* env, jclass threadClass) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_CountStackFrames(JNIEnv* env, jobject thread) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_Interrupt(JNIEnv* env, jobject thread) { enterJVM(); NYI(); leaveJVM(); } +jboolean JNICALL JVM_IsInterrupted(JNIEnv* env, jobject thread, jboolean clearInterrupted) { enterJVM(); NYI(); leaveJVM(); } +jboolean JNICALL JVM_HoldsLock(JNIEnv* env, jclass threadClass, jobject obj) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_DumpAllStacks(JNIEnv* env, jclass unused) { enterJVM(); NYI(); leaveJVM(); } +jobjectArray JNICALL JVM_GetAllThreads(JNIEnv* env, jclass dummy) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_SetNativeThreadName(JNIEnv* env, jobject jthread, jstring name) { enterJVM(); NYI(); leaveJVM(); } + +/* getStackTrace() and getAllStackTraces() method */ +jobjectArray JNICALL JVM_DumpThreads(JNIEnv* env, jclass threadClass, jobjectArray threads) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.SecurityManager + */ +jclass JNICALL JVM_CurrentLoadedClass(JNIEnv* env) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_CurrentClassLoader(JNIEnv* env) { enterJVM(); NYI(); leaveJVM(); } +jobjectArray JNICALL JVM_GetClassContext(JNIEnv* env) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_ClassDepth(JNIEnv* env, jstring name) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_ClassLoaderDepth(JNIEnv* env) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.Package + */ +jstring JNICALL JVM_GetSystemPackage(JNIEnv* env, jstring name) { enterJVM(); NYI(); leaveJVM(); } +jobjectArray JNICALL JVM_GetSystemPackages(JNIEnv* env) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.io.ObjectInputStream + */ +jobject JNICALL JVM_AllocateNewObject(JNIEnv* env, jobject obj, jclass currClass, jclass initClass) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_AllocateNewArray(JNIEnv* env, jobject obj, jclass currClass, jint length) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_LatestUserDefinedLoader(JNIEnv* env) { enterJVM(); NYI(); leaveJVM(); } + +/* + * This function has been deprecated and should not be considered + * part of the specified JVM interface. + */ +jclass JNICALL +JVM_LoadClass0(JNIEnv* env, jobject obj, jclass currClass, jstring currClassName) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.reflect.Array + */ +jint JNICALL JVM_GetArrayLength(JNIEnv* env, jobject arr) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_GetArrayElement(JNIEnv* env, jobject arr, jint index) { enterJVM(); NYI(); leaveJVM(); } +jvalue JNICALL JVM_GetPrimitiveArrayElement(JNIEnv* env, jobject arr, jint index, jint wCode) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_SetArrayElement(JNIEnv* env, jobject arr, jint index, jobject val) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_SetPrimitiveArrayElement(JNIEnv* env, jobject arr, jint index, jvalue v, unsigned char vCode) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_NewArray(JNIEnv* env, jclass eltClass, jint length) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_NewMultiArray(JNIEnv* env, jclass eltClass, jintArray dim) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.Class and java.lang.ClassLoader + */ + +/* + * Returns the immediate caller class of the native method invoking + * JVM_GetCallerClass. The Method.invoke and other frames due to + * reflection machinery are skipped. + * + * The depth parameter must be -1 (JVM_DEPTH). The caller is expected + * to be marked with sun.reflect.CallerSensitive. The JVM will throw + * an error if it is not marked propertly. + */ +jclass JNICALL JVM_GetCallerClass(JNIEnv* env, int depth) { enterJVM(); NYI(); leaveJVM(); } + + +/* + * Find primitive classes + * utf: class name + */ +jclass JNICALL JVM_FindPrimitiveClass(JNIEnv* env, const char *utf) { + enterJVM(); + J3* vm = J3Thread::get()->vm(); + + J3ClassLoader* loader = vm->initialClassLoader; + vmkit::Names* names = vm->names(); + J3Class* res; + + if(!strcmp(utf, "boolean")) + res = loader->getClass(names->get(L"java/lang/Boolean")); + else if(!strcmp(utf, "byte")) + res = loader->getClass(names->get(L"java/lang/Byte")); + else if(!strcmp(utf, "char")) + res = loader->getClass(names->get(L"java/lang/Character")); + else if(!strcmp(utf, "short")) + res = loader->getClass(names->get(L"java/lang/Short")); + else if(!strcmp(utf, "int")) + res = loader->getClass(names->get(L"java/lang/Integer")); + else if(!strcmp(utf, "long")) + res = loader->getClass(names->get(L"java/lang/Long")); + else if(!strcmp(utf, "float")) + res = loader->getClass(names->get(L"java/lang/Float")); + else if(!strcmp(utf, "double")) + res = loader->getClass(names->get(L"java/lang/Double")); + else if(!strcmp(utf, "void")) + res = loader->getClass(names->get(L"java/lang/Void")); + else + J3::internalError(L"unsupported primitive: %s", utf); + + leaveJVM(); + return res->javaClass(); +} + +/* + * Link the class + */ +void JNICALL JVM_ResolveClass(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Find a class from a boot class loader. Returns NULL if class not found. + */ +jclass JNICALL JVM_FindClassFromBootLoader(JNIEnv* env, const char *name) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Find a class from a given class loader. Throw ClassNotFoundException + * or NoClassDefFoundError depending on the value of the last + * argument. + */ +jclass JNICALL JVM_FindClassFromClassLoader(JNIEnv* env, const char *name, jboolean init, jobject loader, jboolean throwError) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Find a class from a given class. + */ +jclass JNICALL JVM_FindClassFromClass(JNIEnv* env, const char *name, jboolean init, jclass from) { enterJVM(); NYI(); leaveJVM(); } + +/* Find a loaded class cached by the VM */ +jclass JNICALL JVM_FindLoadedClass(JNIEnv* env, jobject loader, jstring name) { enterJVM(); NYI(); leaveJVM(); } + +/* Define a class */ +jclass JNICALL JVM_DefineClass(JNIEnv* env, const char *name, jobject loader, const jbyte *buf, jsize len, jobject pd) { enterJVM(); NYI(); leaveJVM(); } + +/* Define a class with a source (added in JDK1.5) */ +jclass JNICALL JVM_DefineClassWithSource(JNIEnv* env, const char *name, jobject loader, + const jbyte *buf, jsize len, jobject pd, + const char *source) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Reflection support functions + */ + +jstring JNICALL JVM_GetClassName(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +jobjectArray JNICALL JVM_GetClassInterfaces(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_GetClassLoader(JNIEnv* env, jclass cls) { + enterJVM(); + jobject res = J3Class::nativeClass(cls)->loader()->javaClassLoader(); + leaveJVM(); + return res; +} + +jboolean JNICALL JVM_IsInterface(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +jobjectArray JNICALL JVM_GetClassSigners(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_SetClassSigners(JNIEnv* env, jclass cls, jobjectArray signers) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_GetProtectionDomain(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +jboolean JNICALL JVM_IsArrayClass(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +jboolean JNICALL JVM_IsPrimitiveClass(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +jclass JNICALL JVM_GetComponentType(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_GetClassModifiers(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +jobjectArray JNICALL JVM_GetDeclaredClasses(JNIEnv* env, jclass ofClass) { enterJVM(); NYI(); leaveJVM(); } +jclass JNICALL JVM_GetDeclaringClass(JNIEnv* env, jclass ofClass) { enterJVM(); NYI(); leaveJVM(); } + +/* Generics support (JDK 1.5) */ +jstring JNICALL JVM_GetClassSignature(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } + +/* Annotations support (JDK 1.5) */ +jbyteArray JNICALL JVM_GetClassAnnotations(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } + +/* Type use annotations support (JDK 1.8) */ +jbyteArray JNICALL JVM_GetClassTypeAnnotations(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } + + +/* + * New (JDK 1.4) reflection implementation + */ + +jobjectArray JNICALL JVM_GetClassDeclaredMethods(JNIEnv* env, jclass ofClass, jboolean publicOnly) { enterJVM(); NYI(); leaveJVM(); } +jobjectArray JNICALL JVM_GetClassDeclaredFields(JNIEnv* env, jclass ofClass, jboolean publicOnly) { enterJVM(); NYI(); leaveJVM(); } +jobjectArray JNICALL JVM_GetClassDeclaredConstructors(JNIEnv* env, jclass ofClass, jboolean publicOnly) { enterJVM(); NYI(); leaveJVM(); } + +/* Differs from JVM_GetClassModifiers in treatment of inner classes. + This returns the access flags for the class as specified in the + class file rather than searching the InnerClasses attribute (if + present) to find the source-level access flags. Only the values of + the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be + valid. */ +jint JNICALL JVM_GetClassAccessFlags(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } + +/* The following two reflection routines are still needed due to startup time issues */ +/* + * java.lang.reflect.Method + */ +jobject JNICALL JVM_InvokeMethod(JNIEnv* env, jobject method, jobject obj, jobjectArray args0) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.reflect.Constructor + */ +jobject JNICALL JVM_NewInstanceFromConstructor(JNIEnv* env, jobject c, jobjectArray args0) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5) + */ + +jobject JNICALL JVM_GetClassConstantPool(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_ConstantPoolGetSize(JNIEnv* env, jobject unused, jobject jcpool) { enterJVM(); NYI(); leaveJVM(); } +jclass JNICALL JVM_ConstantPoolGetClassAt(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_ConstantPoolGetMethodAt(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_ConstantPoolGetFieldAt(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_ConstantPoolGetIntAt(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jlong JNICALL JVM_ConstantPoolGetLongAt(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jfloat JNICALL JVM_ConstantPoolGetFloatAt(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jdouble JNICALL JVM_ConstantPoolGetDoubleAt(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jstring JNICALL JVM_ConstantPoolGetStringAt(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } +jstring JNICALL JVM_ConstantPoolGetUTF8At(JNIEnv* env, jobject unused, jobject jcpool, jint index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Parameter reflection + */ + +jobjectArray JNICALL JVM_GetMethodParameters(JNIEnv* env, jobject method) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.security.* + */ + +jobject JNICALL JVM_DoPrivileged(JNIEnv* env, jclass cls, jobject action, jobject context, jboolean wrapException) { + enterJVM(); + + // For now, we don't do anything special, + // just call the requested 'run()' method... + jmethodID mid = env->GetMethodID(env->GetObjectClass(action), "run", "()Ljava/lang/Object;"); + jobject res = env->CallObjectMethod(action, mid); + leaveJVM(); + return res; +} + +jobject JNICALL JVM_GetInheritedAccessControlContext(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } +jobject JNICALL JVM_GetStackAccessControlContext(JNIEnv* env, jclass cls) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Signal support, used to implement the shutdown sequence. Every VM must + * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts + * (^C) and the latter for external termination (kill, system shutdown, etc.). + * Other platform-dependent signal values may also be supported. + */ + +void * JNICALL JVM_RegisterSignal(jint sig, void *handler) { enterJVM(); NYI(); leaveJVM(); } +jboolean JNICALL JVM_RaiseSignal(jint sig) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_FindSignal(const char *name) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Retrieve the assertion directives for the specified class. + */ +jboolean JNICALL JVM_DesiredAssertionStatus(JNIEnv* env, jclass unused, jclass cls) { + enterJVM(); + /* TODO: take into account the class name and its package (see j3options) */ + jboolean res = J3Thread::get()->vm()->options()->assertionsEnabled ? JNI_TRUE : JNI_FALSE; + leaveJVM(); + return res; +} + +/* + * Retrieve the assertion directives from the VM. + */ +jobject JNICALL JVM_AssertionStatusDirectives(JNIEnv* env, jclass unused) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.util.concurrent.atomic.AtomicLong + */ +jboolean JNICALL JVM_SupportsCX8(void) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Get the version number the JVM was built with + */ +jint JNICALL JVM_DTraceGetVersion(JNIEnv* env) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Register new probe with given signature, return global handle + * + * The version passed in is the version that the library code was + * built with. + */ +jlong JNICALL JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name, + jint providers_count, JVM_DTraceProvider* providers) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Check JSDT probe + */ +jboolean JNICALL JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Destroy custom DOF + */ +void JNICALL JVM_DTraceDispose(JNIEnv* env, jlong activation_handle) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Check to see if DTrace is supported by OS + */ +jboolean JNICALL JVM_DTraceIsSupported(JNIEnv* env) { enterJVM(); NYI(); leaveJVM(); } + +/************************************************************************* + PART 2: Support for the Verifier and Class File Format Checker + ************************************************************************/ +/* + * Return the class name in UTF format. The result is valid + * until JVM_ReleaseUTf is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +const char * JNICALL JVM_GetClassNameUTF(JNIEnv* env, jclass cb) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the constant pool types in the buffer provided by "types." + */ +void JNICALL JVM_GetClassCPTypes(JNIEnv* env, jclass cb, unsigned char *types) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the number of Constant Pool entries. + */ +jint JNICALL JVM_GetClassCPEntriesCount(JNIEnv* env, jclass cb) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the number of *declared* fields or methods. + */ +jint JNICALL JVM_GetClassFieldsCount(JNIEnv* env, jclass cb) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_GetClassMethodsCount(JNIEnv* env, jclass cb) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the CP indexes of exceptions raised by a given method. + * Places the result in the given buffer. + * + * The method is identified by method_index. + */ +void JNICALL JVM_GetMethodIxExceptionIndexes(JNIEnv* env, jclass cb, jint method_index, unsigned short *exceptions) { enterJVM(); NYI(); leaveJVM(); } +/* + * Returns the number of exceptions raised by a given method. + * The method is identified by method_index. + */ +jint JNICALL JVM_GetMethodIxExceptionsCount(JNIEnv* env, jclass cb, jint method_index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the byte code sequence of a given method. + * Places the result in the given buffer. + * + * The method is identified by method_index. + */ +void JNICALL JVM_GetMethodIxByteCode(JNIEnv* env, jclass cb, jint method_index, unsigned char *code) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the length of the byte code sequence of a given method. + * The method is identified by method_index. + */ +jint JNICALL JVM_GetMethodIxByteCodeLength(JNIEnv* env, jclass cb, jint method_index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the exception table entry at entry_index of a given method. + * Places the result in the given buffer. + * + * The method is identified by method_index. + */ +void JNICALL JVM_GetMethodIxExceptionTableEntry(JNIEnv* env, jclass cb, jint method_index, jint entry_index, + JVM_ExceptionTableEntryType *entry) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the length of the exception table of a given method. + * The method is identified by method_index. + */ +jint JNICALL JVM_GetMethodIxExceptionTableLength(JNIEnv* env, jclass cb, int index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the modifiers of a given field. + * The field is identified by field_index. + */ +jint JNICALL JVM_GetFieldIxModifiers(JNIEnv* env, jclass cb, int index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the modifiers of a given method. + * The method is identified by method_index. + */ +jint JNICALL JVM_GetMethodIxModifiers(JNIEnv* env, jclass cb, int index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the number of local variables of a given method. + * The method is identified by method_index. + */ +jint JNICALL JVM_GetMethodIxLocalsCount(JNIEnv* env, jclass cb, int index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the number of arguments (including this pointer) of a given method. + * The method is identified by method_index. + */ +jint JNICALL JVM_GetMethodIxArgsSize(JNIEnv* env, jclass cb, int index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the maximum amount of stack (in words) used by a given method. + * The method is identified by method_index. + */ +jint JNICALL JVM_GetMethodIxMaxStack(JNIEnv* env, jclass cb, int index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Is a given method a constructor. + * The method is identified by method_index. + */ +jboolean JNICALL JVM_IsConstructorIx(JNIEnv* env, jclass cb, int index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Is the given method generated by the VM. + * The method is identified by method_index. + */ +jboolean JNICALL JVM_IsVMGeneratedMethodIx(JNIEnv* env, jclass cb, int index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the name of a given method in UTF format. + * The result remains valid until JVM_ReleaseUTF is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +const char * JNICALL JVM_GetMethodIxNameUTF(JNIEnv* env, jclass cb, jint index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the signature of a given method in UTF format. + * The result remains valid until JVM_ReleaseUTF is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +const char * JNICALL JVM_GetMethodIxSignatureUTF(JNIEnv* env, jclass cb, jint index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the name of the field refered to at a given constant pool + * index. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +const char * JNICALL JVM_GetCPFieldNameUTF(JNIEnv* env, jclass cb, jint index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the name of the method refered to at a given constant pool + * index. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +const char * JNICALL JVM_GetCPMethodNameUTF(JNIEnv* env, jclass cb, jint index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the signature of the method refered to at a given constant pool + * index. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +const char * JNICALL JVM_GetCPMethodSignatureUTF(JNIEnv* env, jclass cb, jint index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the signature of the field refered to at a given constant pool + * index. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +const char * JNICALL JVM_GetCPFieldSignatureUTF(JNIEnv* env, jclass cb, jint index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the class name refered to at a given constant pool index. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +const char * JNICALL JVM_GetCPClassNameUTF(JNIEnv* env, jclass cb, jint index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the class name refered to at a given constant pool index. + * + * The constant pool entry must refer to a CONSTANT_Fieldref. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +const char * JNICALL JVM_GetCPFieldClassNameUTF(JNIEnv* env, jclass cb, jint index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the class name refered to at a given constant pool index. + * + * The constant pool entry must refer to CONSTANT_Methodref or + * CONSTANT_InterfaceMethodref. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +const char * JNICALL JVM_GetCPMethodClassNameUTF(JNIEnv* env, jclass cb, jint index) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the modifiers of a field in calledClass. The field is + * referred to in class cb at constant pool entry index. + * + * The caller must treat the string as a constant and not modify it + * in any way. + * + * Returns -1 if the field does not exist in calledClass. + */ +jint JNICALL JVM_GetCPFieldModifiers(JNIEnv* env, jclass cb, int index, jclass calledClass) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the modifiers of a method in calledClass. The method is + * referred to in class cb at constant pool entry index. + * + * Returns -1 if the method does not exist in calledClass. + */ +jint JNICALL JVM_GetCPMethodModifiers(JNIEnv* env, jclass cb, int index, jclass calledClass) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Releases the UTF string obtained from the VM. + */ +void JNICALL JVM_ReleaseUTF(const char *utf) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Compare if two classes are in the same package. + */ +jboolean JNICALL JVM_IsSameClassPackage(JNIEnv* env, jclass class1, jclass class2) { enterJVM(); NYI(); leaveJVM(); } + +/************************************************************************* + PART 3: I/O and Network Support + ************************************************************************/ + +/* Write a string into the given buffer, in the platform's local encoding, + * that describes the most recent system-level error to occur in this thread. + * Return the length of the string or zero if no error occurred. + */ +jint JNICALL JVM_GetLastErrorString(char *buf, int len) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Convert a pathname into native format. This function does syntactic + * cleanup, such as removing redundant separator characters. It modifies + * the given pathname string in place. + */ +char * JNICALL JVM_NativePath(char *) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Open a file descriptor. This function returns a negative error code + * on error, and a non-negative integer that is the file descriptor on + * success. + */ +jint JNICALL JVM_Open(const char *fname, jint flags, jint mode) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Close a file descriptor. This function returns -1 on error, and 0 + * on success. + * + * fd the file descriptor to close. + */ +jint JNICALL JVM_Close(jint fd) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Read data from a file decriptor into a char array. + * + * fd the file descriptor to read from. + * buf the buffer where to put the read data. + * nbytes the number of bytes to read. + * + * This function returns -1 on error, and 0 on success. + */ +jint JNICALL JVM_Read(jint fd, char *buf, jint nbytes) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Write data from a char array to a file decriptor. + * + * fd the file descriptor to read from. + * buf the buffer from which to fetch the data. + * nbytes the number of bytes to write. + * + * This function returns -1 on error, and 0 on success. + */ +jint JNICALL JVM_Write(jint fd, char *buf, jint nbytes) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns the number of bytes available for reading from a given file + * descriptor + */ +jint JNICALL JVM_Available(jint fd, jlong *pbytes) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Move the file descriptor pointer from whence by offset. + * + * fd the file descriptor to move. + * offset the number of bytes to move it by. + * whence the start from where to move it. + * + * This function returns the resulting pointer location. + */ +jlong JNICALL JVM_Lseek(jint fd, jlong offset, jint whence) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Set the length of the file associated with the given descriptor to the given + * length. If the new length is longer than the current length then the file + * is extended; the contents of the extended portion are not defined. The + * value of the file pointer is undefined after this procedure returns. + */ +jint JNICALL JVM_SetLength(jint fd, jlong length) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Synchronize the file descriptor's in memory state with that of the + * physical device. Return of -1 is an error, 0 is OK. + */ +jint JNICALL JVM_Sync(jint fd) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Networking library support + */ + +jint JNICALL JVM_InitializeSocketLibrary(void) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_Socket(jint domain, jint type, jint protocol) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_SocketClose(jint fd) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_SocketShutdown(jint fd, jint howto) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_Recv(jint fd, char *buf, jint nBytes, jint flags) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_Send(jint fd, char *buf, jint nBytes, jint flags) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_Timeout(int fd, long timeout) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_Listen(jint fd, jint count) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_Connect(jint fd, struct sockaddr *him, jint len) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_Bind(jint fd, struct sockaddr *him, jint len) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_Accept(jint fd, struct sockaddr *him, jint *len) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_RecvFrom(jint fd, char *buf, int nBytes, int flags, struct sockaddr *from, int *fromlen) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_SendTo(jint fd, char *buf, int len, int flags, struct sockaddr *to, int tolen) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_SocketAvailable(jint fd, jint *result) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_GetSockName(jint fd, struct sockaddr *him, int *len) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen) { enterJVM(); NYI(); leaveJVM(); } +int JNICALL JVM_GetHostName(char* name, int namelen) { enterJVM(); NYI(); leaveJVM(); } + +/* + * The standard printing functions supported by the Java VM. (Should they + * be renamed to JVM_* in the future? + */ + +/* + * BE CAREFUL! The following functions do not implement the + * full feature set of standard C printf formats. + */ +int jio_vsnprintf(char *str, size_t count, const char *fmt, va_list va) { + return vsnprintf(str, count, fmt, va); +} + +int jio_snprintf(char *str, size_t count, const char *fmt, ...) { + va_list va; + va_start(va, fmt); + int res = jio_vsnprintf(str, count, fmt, va); + va_end(va); + return res; +} + +int jio_fprintf(FILE *f, const char *fmt, ...) { + va_list va; + va_start(va, fmt); + int res = jio_vfprintf(f, fmt, va); + va_end(va); + return res; +} + +int jio_vfprintf(FILE *f, const char *fmt, va_list va) { + return vfprintf(f, fmt, va); +} + + +void * JNICALL JVM_RawMonitorCreate(void) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_RawMonitorDestroy(void *mon) { enterJVM(); NYI(); leaveJVM(); } +jint JNICALL JVM_RawMonitorEnter(void *mon) { enterJVM(); NYI(); leaveJVM(); } +void JNICALL JVM_RawMonitorExit(void *mon) { enterJVM(); NYI(); leaveJVM(); } + +/* + * java.lang.management support + */ +void* JNICALL JVM_GetManagement(jint version) { enterJVM(); NYI(); leaveJVM(); } + +/* + * com.sun.tools.attach.VirtualMachine support + * + * Initialize the agent properties with the properties maintained in the VM. + */ +jobject JNICALL JVM_InitAgentProperties(JNIEnv* env, jobject agent_props) { enterJVM(); NYI(); leaveJVM(); } + +/* Generics reflection support. + * + * Returns information about the given class's EnclosingMethod + * attribute, if present, or null if the class had no enclosing + * method. + * + * If non-null, the returned array contains three elements. Element 0 + * is the java.lang.Class of which the enclosing method is a member, + * and elements 1 and 2 are the java.lang.Strings for the enclosing + * method's name and descriptor, respectively. + */ +jobjectArray JNICALL JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns an array of the threadStatus values representing the + * given Java thread state. Returns NULL if the VM version is + * incompatible with the JDK or doesn't support the given + * Java thread state. + */ +jintArray JNICALL JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState) { enterJVM(); NYI(); leaveJVM(); } + +/* + * Returns an array of the substate names representing the + * given Java thread state. Returns NULL if the VM version is + * incompatible with the JDK or the VM doesn't support + * the given Java thread state. + * values must be the jintArray returned from JVM_GetThreadStateValues + * and javaThreadState. + */ +jobjectArray JNICALL JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values) { enterJVM(); NYI(); leaveJVM(); } + +/* ========================================================================= + * The following defines a private JVM interface that the JDK can query + * for the JVM version and capabilities. sun.misc.Version defines + * the methods for getting the VM version and its capabilities. + * + * When a new bit is added, the following should be updated to provide + * access to the new capability: + * HS: JVM_GetVersionInfo and Abstract_VM_Version class + * SDK: Version class + * + * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for + * JVM to query for the JDK version and capabilities. + * + * When a new bit is added, the following should be updated to provide + * access to the new capability: + * HS: JDK_Version class + * SDK: JDK_GetVersionInfo0 + * + * ========================================================================== + */ +void JNICALL JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size) { enterJVM(); NYI(); leaveJVM(); } Added: vmkit/branches/mcjit/lib/j3/openjdk/jvm.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/jvm.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/openjdk/jvm.h (added) +++ vmkit/branches/mcjit/lib/j3/openjdk/jvm.h Mon Nov 25 03:27:09 2013 @@ -0,0 +1,1505 @@ +/* + * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#ifndef _JAVASOFT_JVM_H_ +#define _JAVASOFT_JVM_H_ + +#include + +#include "jni.h" +//#include "jvm_md.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This file contains additional functions exported from the VM. + * These functions are complementary to the standard JNI support. + * There are three parts to this file: + * + * First, this file contains the VM-related functions needed by native + * libraries in the standard Java API. For example, the java.lang.Object + * class needs VM-level functions that wait for and notify monitors. + * + * Second, this file contains the functions and constant definitions + * needed by the byte code verifier and class file format checker. + * These functions allow the verifier and format checker to be written + * in a VM-independent way. + * + * Third, this file contains various I/O and nerwork operations needed + * by the standard Java I/O and network APIs. + */ + +/* + * Bump the version number when either of the following happens: + * + * 1. There is a change in JVM_* functions. + * + * 2. There is a change in the contract between VM and Java classes. + * For example, if the VM relies on a new private field in Thread + * class. + */ + +#define JVM_INTERFACE_VERSION 4 + +JNIEXPORT jint JNICALL +JVM_GetInterfaceVersion(void); + +/************************************************************************* + PART 1: Functions for Native Libraries + ************************************************************************/ +/* + * java.lang.Object + */ +JNIEXPORT jint JNICALL +JVM_IHashCode(JNIEnv *env, jobject obj); + +JNIEXPORT void JNICALL +JVM_MonitorWait(JNIEnv *env, jobject obj, jlong ms); + +JNIEXPORT void JNICALL +JVM_MonitorNotify(JNIEnv *env, jobject obj); + +JNIEXPORT void JNICALL +JVM_MonitorNotifyAll(JNIEnv *env, jobject obj); + +JNIEXPORT jobject JNICALL +JVM_Clone(JNIEnv *env, jobject obj); + +/* + * java.lang.String + */ +JNIEXPORT jstring JNICALL +JVM_InternString(JNIEnv *env, jstring str); + +/* + * java.lang.System + */ +JNIEXPORT jlong JNICALL +JVM_CurrentTimeMillis(JNIEnv *env, jclass ignored); + +JNIEXPORT jlong JNICALL +JVM_NanoTime(JNIEnv *env, jclass ignored); + +JNIEXPORT void JNICALL +JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos, + jobject dst, jint dst_pos, jint length); + +JNIEXPORT jobject JNICALL +JVM_InitProperties(JNIEnv *env, jobject p); + +/* + * java.io.File + */ +JNIEXPORT void JNICALL +JVM_OnExit(void (*func)(void)); + +/* + * java.lang.Runtime + */ +JNIEXPORT void JNICALL +JVM_Exit(jint code); + +JNIEXPORT void JNICALL +JVM_Halt(jint code); + +JNIEXPORT void JNICALL +JVM_GC(void); + +/* Returns the number of real-time milliseconds that have elapsed since the + * least-recently-inspected heap object was last inspected by the garbage + * collector. + * + * For simple stop-the-world collectors this value is just the time + * since the most recent collection. For generational collectors it is the + * time since the oldest generation was most recently collected. Other + * collectors are free to return a pessimistic estimate of the elapsed time, or + * simply the time since the last full collection was performed. + * + * Note that in the presence of reference objects, a given object that is no + * longer strongly reachable may have to be inspected multiple times before it + * can be reclaimed. + */ +JNIEXPORT jlong JNICALL +JVM_MaxObjectInspectionAge(void); + +JNIEXPORT void JNICALL +JVM_TraceInstructions(jboolean on); + +JNIEXPORT void JNICALL +JVM_TraceMethodCalls(jboolean on); + +JNIEXPORT jlong JNICALL +JVM_TotalMemory(void); + +JNIEXPORT jlong JNICALL +JVM_FreeMemory(void); + +JNIEXPORT jlong JNICALL +JVM_MaxMemory(void); + +JNIEXPORT jint JNICALL +JVM_ActiveProcessorCount(void); + +JNIEXPORT void * JNICALL +JVM_LoadLibrary(const char *name); + +JNIEXPORT void JNICALL +JVM_UnloadLibrary(void * handle); + +JNIEXPORT void * JNICALL +JVM_FindLibraryEntry(void *handle, const char *name); + +JNIEXPORT jboolean JNICALL +JVM_IsSupportedJNIVersion(jint version); + +/* + * java.lang.Float and java.lang.Double + */ +JNIEXPORT jboolean JNICALL +JVM_IsNaN(jdouble d); + +/* + * java.lang.Throwable + */ +JNIEXPORT void JNICALL +JVM_FillInStackTrace(JNIEnv *env, jobject throwable); + +JNIEXPORT jint JNICALL +JVM_GetStackTraceDepth(JNIEnv *env, jobject throwable); + +JNIEXPORT jobject JNICALL +JVM_GetStackTraceElement(JNIEnv *env, jobject throwable, jint index); + +/* + * java.lang.Compiler + */ +JNIEXPORT void JNICALL +JVM_InitializeCompiler (JNIEnv *env, jclass compCls); + +JNIEXPORT jboolean JNICALL +JVM_IsSilentCompiler(JNIEnv *env, jclass compCls); + +JNIEXPORT jboolean JNICALL +JVM_CompileClass(JNIEnv *env, jclass compCls, jclass cls); + +JNIEXPORT jboolean JNICALL +JVM_CompileClasses(JNIEnv *env, jclass cls, jstring jname); + +JNIEXPORT jobject JNICALL +JVM_CompilerCommand(JNIEnv *env, jclass compCls, jobject arg); + +JNIEXPORT void JNICALL +JVM_EnableCompiler(JNIEnv *env, jclass compCls); + +JNIEXPORT void JNICALL +JVM_DisableCompiler(JNIEnv *env, jclass compCls); + +/* + * java.lang.Thread + */ +JNIEXPORT void JNICALL +JVM_StartThread(JNIEnv *env, jobject thread); + +JNIEXPORT void JNICALL +JVM_StopThread(JNIEnv *env, jobject thread, jobject exception); + +JNIEXPORT jboolean JNICALL +JVM_IsThreadAlive(JNIEnv *env, jobject thread); + +JNIEXPORT void JNICALL +JVM_SuspendThread(JNIEnv *env, jobject thread); + +JNIEXPORT void JNICALL +JVM_ResumeThread(JNIEnv *env, jobject thread); + +JNIEXPORT void JNICALL +JVM_SetThreadPriority(JNIEnv *env, jobject thread, jint prio); + +JNIEXPORT void JNICALL +JVM_Yield(JNIEnv *env, jclass threadClass); + +JNIEXPORT void JNICALL +JVM_Sleep(JNIEnv *env, jclass threadClass, jlong millis); + +JNIEXPORT jobject JNICALL +JVM_CurrentThread(JNIEnv *env, jclass threadClass); + +JNIEXPORT jint JNICALL +JVM_CountStackFrames(JNIEnv *env, jobject thread); + +JNIEXPORT void JNICALL +JVM_Interrupt(JNIEnv *env, jobject thread); + +JNIEXPORT jboolean JNICALL +JVM_IsInterrupted(JNIEnv *env, jobject thread, jboolean clearInterrupted); + +JNIEXPORT jboolean JNICALL +JVM_HoldsLock(JNIEnv *env, jclass threadClass, jobject obj); + +JNIEXPORT void JNICALL +JVM_DumpAllStacks(JNIEnv *env, jclass unused); + +JNIEXPORT jobjectArray JNICALL +JVM_GetAllThreads(JNIEnv *env, jclass dummy); + +JNIEXPORT void JNICALL +JVM_SetNativeThreadName(JNIEnv *env, jobject jthread, jstring name); + +/* getStackTrace() and getAllStackTraces() method */ +JNIEXPORT jobjectArray JNICALL +JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads); + +/* + * java.lang.SecurityManager + */ +JNIEXPORT jclass JNICALL +JVM_CurrentLoadedClass(JNIEnv *env); + +JNIEXPORT jobject JNICALL +JVM_CurrentClassLoader(JNIEnv *env); + +JNIEXPORT jobjectArray JNICALL +JVM_GetClassContext(JNIEnv *env); + +JNIEXPORT jint JNICALL +JVM_ClassDepth(JNIEnv *env, jstring name); + +JNIEXPORT jint JNICALL +JVM_ClassLoaderDepth(JNIEnv *env); + +/* + * java.lang.Package + */ +JNIEXPORT jstring JNICALL +JVM_GetSystemPackage(JNIEnv *env, jstring name); + +JNIEXPORT jobjectArray JNICALL +JVM_GetSystemPackages(JNIEnv *env); + +/* + * java.io.ObjectInputStream + */ +JNIEXPORT jobject JNICALL +JVM_AllocateNewObject(JNIEnv *env, jobject obj, jclass currClass, + jclass initClass); + +JNIEXPORT jobject JNICALL +JVM_AllocateNewArray(JNIEnv *env, jobject obj, jclass currClass, + jint length); + +JNIEXPORT jobject JNICALL +JVM_LatestUserDefinedLoader(JNIEnv *env); + +/* + * This function has been deprecated and should not be considered + * part of the specified JVM interface. + */ +JNIEXPORT jclass JNICALL +JVM_LoadClass0(JNIEnv *env, jobject obj, jclass currClass, + jstring currClassName); + +/* + * java.lang.reflect.Array + */ +JNIEXPORT jint JNICALL +JVM_GetArrayLength(JNIEnv *env, jobject arr); + +JNIEXPORT jobject JNICALL +JVM_GetArrayElement(JNIEnv *env, jobject arr, jint index); + +JNIEXPORT jvalue JNICALL +JVM_GetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jint wCode); + +JNIEXPORT void JNICALL +JVM_SetArrayElement(JNIEnv *env, jobject arr, jint index, jobject val); + +JNIEXPORT void JNICALL +JVM_SetPrimitiveArrayElement(JNIEnv *env, jobject arr, jint index, jvalue v, + unsigned char vCode); + +JNIEXPORT jobject JNICALL +JVM_NewArray(JNIEnv *env, jclass eltClass, jint length); + +JNIEXPORT jobject JNICALL +JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim); + +/* + * java.lang.Class and java.lang.ClassLoader + */ + +#define JVM_DEPTH -1 + +/* + * Returns the immediate caller class of the native method invoking + * JVM_GetCallerClass. The Method.invoke and other frames due to + * reflection machinery are skipped. + * + * The depth parameter must be -1 (JVM_DEPTH). The caller is expected + * to be marked with sun.reflect.CallerSensitive. The JVM will throw + * an error if it is not marked propertly. + */ +JNIEXPORT jclass JNICALL +JVM_GetCallerClass(JNIEnv *env, int depth); + + +/* + * Find primitive classes + * utf: class name + */ +JNIEXPORT jclass JNICALL +JVM_FindPrimitiveClass(JNIEnv *env, const char *utf); + +/* + * Link the class + */ +JNIEXPORT void JNICALL +JVM_ResolveClass(JNIEnv *env, jclass cls); + +/* + * Find a class from a boot class loader. Returns NULL if class not found. + */ +JNIEXPORT jclass JNICALL +JVM_FindClassFromBootLoader(JNIEnv *env, const char *name); + +/* + * Find a class from a given class loader. Throw ClassNotFoundException + * or NoClassDefFoundError depending on the value of the last + * argument. + */ +JNIEXPORT jclass JNICALL +JVM_FindClassFromClassLoader(JNIEnv *env, const char *name, jboolean init, + jobject loader, jboolean throwError); + +/* + * Find a class from a given class. + */ +JNIEXPORT jclass JNICALL +JVM_FindClassFromClass(JNIEnv *env, const char *name, jboolean init, + jclass from); + +/* Find a loaded class cached by the VM */ +JNIEXPORT jclass JNICALL +JVM_FindLoadedClass(JNIEnv *env, jobject loader, jstring name); + +/* Define a class */ +JNIEXPORT jclass JNICALL +JVM_DefineClass(JNIEnv *env, const char *name, jobject loader, const jbyte *buf, + jsize len, jobject pd); + +/* Define a class with a source (added in JDK1.5) */ +JNIEXPORT jclass JNICALL +JVM_DefineClassWithSource(JNIEnv *env, const char *name, jobject loader, + const jbyte *buf, jsize len, jobject pd, + const char *source); + +/* + * Reflection support functions + */ + +JNIEXPORT jstring JNICALL +JVM_GetClassName(JNIEnv *env, jclass cls); + +JNIEXPORT jobjectArray JNICALL +JVM_GetClassInterfaces(JNIEnv *env, jclass cls); + +JNIEXPORT jobject JNICALL +JVM_GetClassLoader(JNIEnv *env, jclass cls); + +JNIEXPORT jboolean JNICALL +JVM_IsInterface(JNIEnv *env, jclass cls); + +JNIEXPORT jobjectArray JNICALL +JVM_GetClassSigners(JNIEnv *env, jclass cls); + +JNIEXPORT void JNICALL +JVM_SetClassSigners(JNIEnv *env, jclass cls, jobjectArray signers); + +JNIEXPORT jobject JNICALL +JVM_GetProtectionDomain(JNIEnv *env, jclass cls); + +JNIEXPORT jboolean JNICALL +JVM_IsArrayClass(JNIEnv *env, jclass cls); + +JNIEXPORT jboolean JNICALL +JVM_IsPrimitiveClass(JNIEnv *env, jclass cls); + +JNIEXPORT jclass JNICALL +JVM_GetComponentType(JNIEnv *env, jclass cls); + +JNIEXPORT jint JNICALL +JVM_GetClassModifiers(JNIEnv *env, jclass cls); + +JNIEXPORT jobjectArray JNICALL +JVM_GetDeclaredClasses(JNIEnv *env, jclass ofClass); + +JNIEXPORT jclass JNICALL +JVM_GetDeclaringClass(JNIEnv *env, jclass ofClass); + +/* Generics support (JDK 1.5) */ +JNIEXPORT jstring JNICALL +JVM_GetClassSignature(JNIEnv *env, jclass cls); + +/* Annotations support (JDK 1.5) */ +JNIEXPORT jbyteArray JNICALL +JVM_GetClassAnnotations(JNIEnv *env, jclass cls); + +/* Type use annotations support (JDK 1.8) */ + +JNIEXPORT jbyteArray JNICALL +JVM_GetClassTypeAnnotations(JNIEnv *env, jclass cls); + + +/* + * New (JDK 1.4) reflection implementation + */ + +JNIEXPORT jobjectArray JNICALL +JVM_GetClassDeclaredMethods(JNIEnv *env, jclass ofClass, jboolean publicOnly); + +JNIEXPORT jobjectArray JNICALL +JVM_GetClassDeclaredFields(JNIEnv *env, jclass ofClass, jboolean publicOnly); + +JNIEXPORT jobjectArray JNICALL +JVM_GetClassDeclaredConstructors(JNIEnv *env, jclass ofClass, jboolean publicOnly); + +/* Differs from JVM_GetClassModifiers in treatment of inner classes. + This returns the access flags for the class as specified in the + class file rather than searching the InnerClasses attribute (if + present) to find the source-level access flags. Only the values of + the low 13 bits (i.e., a mask of 0x1FFF) are guaranteed to be + valid. */ +JNIEXPORT jint JNICALL +JVM_GetClassAccessFlags(JNIEnv *env, jclass cls); + +/* The following two reflection routines are still needed due to startup time issues */ +/* + * java.lang.reflect.Method + */ +JNIEXPORT jobject JNICALL +JVM_InvokeMethod(JNIEnv *env, jobject method, jobject obj, jobjectArray args0); + +/* + * java.lang.reflect.Constructor + */ +JNIEXPORT jobject JNICALL +JVM_NewInstanceFromConstructor(JNIEnv *env, jobject c, jobjectArray args0); + +/* + * Constant pool access; currently used to implement reflective access to annotations (JDK 1.5) + */ + +JNIEXPORT jobject JNICALL +JVM_GetClassConstantPool(JNIEnv *env, jclass cls); + +JNIEXPORT jint JNICALL JVM_ConstantPoolGetSize +(JNIEnv *env, jobject unused, jobject jcpool); + +JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAt +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jclass JNICALL JVM_ConstantPoolGetClassAtIfLoaded +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAt +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jobject JNICALL JVM_ConstantPoolGetMethodAtIfLoaded +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAt +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jobject JNICALL JVM_ConstantPoolGetFieldAtIfLoaded +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jobjectArray JNICALL JVM_ConstantPoolGetMemberRefInfoAt +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jint JNICALL JVM_ConstantPoolGetIntAt +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jlong JNICALL JVM_ConstantPoolGetLongAt +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jfloat JNICALL JVM_ConstantPoolGetFloatAt +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jdouble JNICALL JVM_ConstantPoolGetDoubleAt +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jstring JNICALL JVM_ConstantPoolGetStringAt +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +JNIEXPORT jstring JNICALL JVM_ConstantPoolGetUTF8At +(JNIEnv *env, jobject unused, jobject jcpool, jint index); + +/* + * Parameter reflection + */ + +JNIEXPORT jobjectArray JNICALL +JVM_GetMethodParameters(JNIEnv *env, jobject method); + +/* + * java.security.* + */ + +JNIEXPORT jobject JNICALL +JVM_DoPrivileged(JNIEnv *env, jclass cls, + jobject action, jobject context, jboolean wrapException); + +JNIEXPORT jobject JNICALL +JVM_GetInheritedAccessControlContext(JNIEnv *env, jclass cls); + +JNIEXPORT jobject JNICALL +JVM_GetStackAccessControlContext(JNIEnv *env, jclass cls); + +/* + * Signal support, used to implement the shutdown sequence. Every VM must + * support JVM_SIGINT and JVM_SIGTERM, raising the former for user interrupts + * (^C) and the latter for external termination (kill, system shutdown, etc.). + * Other platform-dependent signal values may also be supported. + */ + +JNIEXPORT void * JNICALL +JVM_RegisterSignal(jint sig, void *handler); + +JNIEXPORT jboolean JNICALL +JVM_RaiseSignal(jint sig); + +JNIEXPORT jint JNICALL +JVM_FindSignal(const char *name); + +/* + * Retrieve the assertion directives for the specified class. + */ +JNIEXPORT jboolean JNICALL +JVM_DesiredAssertionStatus(JNIEnv *env, jclass unused, jclass cls); + +/* + * Retrieve the assertion directives from the VM. + */ +JNIEXPORT jobject JNICALL +JVM_AssertionStatusDirectives(JNIEnv *env, jclass unused); + +/* + * java.util.concurrent.atomic.AtomicLong + */ +JNIEXPORT jboolean JNICALL +JVM_SupportsCX8(void); + +/* + * com.sun.dtrace.jsdt support + */ + +#define JVM_TRACING_DTRACE_VERSION 1 + +/* + * Structure to pass one probe description to JVM + */ +typedef struct { + jmethodID method; + jstring function; + jstring name; + void* reserved[4]; // for future use +} JVM_DTraceProbe; + +/** + * Encapsulates the stability ratings for a DTrace provider field + */ +typedef struct { + jint nameStability; + jint dataStability; + jint dependencyClass; +} JVM_DTraceInterfaceAttributes; + +/* + * Structure to pass one provider description to JVM + */ +typedef struct { + jstring name; + JVM_DTraceProbe* probes; + jint probe_count; + JVM_DTraceInterfaceAttributes providerAttributes; + JVM_DTraceInterfaceAttributes moduleAttributes; + JVM_DTraceInterfaceAttributes functionAttributes; + JVM_DTraceInterfaceAttributes nameAttributes; + JVM_DTraceInterfaceAttributes argsAttributes; + void* reserved[4]; // for future use +} JVM_DTraceProvider; + +/* + * Get the version number the JVM was built with + */ +JNIEXPORT jint JNICALL +JVM_DTraceGetVersion(JNIEnv* env); + +/* + * Register new probe with given signature, return global handle + * + * The version passed in is the version that the library code was + * built with. + */ +JNIEXPORT jlong JNICALL +JVM_DTraceActivate(JNIEnv* env, jint version, jstring module_name, + jint providers_count, JVM_DTraceProvider* providers); + +/* + * Check JSDT probe + */ +JNIEXPORT jboolean JNICALL +JVM_DTraceIsProbeEnabled(JNIEnv* env, jmethodID method); + +/* + * Destroy custom DOF + */ +JNIEXPORT void JNICALL +JVM_DTraceDispose(JNIEnv* env, jlong activation_handle); + +/* + * Check to see if DTrace is supported by OS + */ +JNIEXPORT jboolean JNICALL +JVM_DTraceIsSupported(JNIEnv* env); + +/************************************************************************* + PART 2: Support for the Verifier and Class File Format Checker + ************************************************************************/ +/* + * Return the class name in UTF format. The result is valid + * until JVM_ReleaseUTf is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +JNIEXPORT const char * JNICALL +JVM_GetClassNameUTF(JNIEnv *env, jclass cb); + +/* + * Returns the constant pool types in the buffer provided by "types." + */ +JNIEXPORT void JNICALL +JVM_GetClassCPTypes(JNIEnv *env, jclass cb, unsigned char *types); + +/* + * Returns the number of Constant Pool entries. + */ +JNIEXPORT jint JNICALL +JVM_GetClassCPEntriesCount(JNIEnv *env, jclass cb); + +/* + * Returns the number of *declared* fields or methods. + */ +JNIEXPORT jint JNICALL +JVM_GetClassFieldsCount(JNIEnv *env, jclass cb); + +JNIEXPORT jint JNICALL +JVM_GetClassMethodsCount(JNIEnv *env, jclass cb); + +/* + * Returns the CP indexes of exceptions raised by a given method. + * Places the result in the given buffer. + * + * The method is identified by method_index. + */ +JNIEXPORT void JNICALL +JVM_GetMethodIxExceptionIndexes(JNIEnv *env, jclass cb, jint method_index, + unsigned short *exceptions); +/* + * Returns the number of exceptions raised by a given method. + * The method is identified by method_index. + */ +JNIEXPORT jint JNICALL +JVM_GetMethodIxExceptionsCount(JNIEnv *env, jclass cb, jint method_index); + +/* + * Returns the byte code sequence of a given method. + * Places the result in the given buffer. + * + * The method is identified by method_index. + */ +JNIEXPORT void JNICALL +JVM_GetMethodIxByteCode(JNIEnv *env, jclass cb, jint method_index, + unsigned char *code); + +/* + * Returns the length of the byte code sequence of a given method. + * The method is identified by method_index. + */ +JNIEXPORT jint JNICALL +JVM_GetMethodIxByteCodeLength(JNIEnv *env, jclass cb, jint method_index); + +/* + * A structure used to a capture exception table entry in a Java method. + */ +typedef struct { + jint start_pc; + jint end_pc; + jint handler_pc; + jint catchType; +} JVM_ExceptionTableEntryType; + +/* + * Returns the exception table entry at entry_index of a given method. + * Places the result in the given buffer. + * + * The method is identified by method_index. + */ +JNIEXPORT void JNICALL +JVM_GetMethodIxExceptionTableEntry(JNIEnv *env, jclass cb, jint method_index, + jint entry_index, + JVM_ExceptionTableEntryType *entry); + +/* + * Returns the length of the exception table of a given method. + * The method is identified by method_index. + */ +JNIEXPORT jint JNICALL +JVM_GetMethodIxExceptionTableLength(JNIEnv *env, jclass cb, int index); + +/* + * Returns the modifiers of a given field. + * The field is identified by field_index. + */ +JNIEXPORT jint JNICALL +JVM_GetFieldIxModifiers(JNIEnv *env, jclass cb, int index); + +/* + * Returns the modifiers of a given method. + * The method is identified by method_index. + */ +JNIEXPORT jint JNICALL +JVM_GetMethodIxModifiers(JNIEnv *env, jclass cb, int index); + +/* + * Returns the number of local variables of a given method. + * The method is identified by method_index. + */ +JNIEXPORT jint JNICALL +JVM_GetMethodIxLocalsCount(JNIEnv *env, jclass cb, int index); + +/* + * Returns the number of arguments (including this pointer) of a given method. + * The method is identified by method_index. + */ +JNIEXPORT jint JNICALL +JVM_GetMethodIxArgsSize(JNIEnv *env, jclass cb, int index); + +/* + * Returns the maximum amount of stack (in words) used by a given method. + * The method is identified by method_index. + */ +JNIEXPORT jint JNICALL +JVM_GetMethodIxMaxStack(JNIEnv *env, jclass cb, int index); + +/* + * Is a given method a constructor. + * The method is identified by method_index. + */ +JNIEXPORT jboolean JNICALL +JVM_IsConstructorIx(JNIEnv *env, jclass cb, int index); + +/* + * Is the given method generated by the VM. + * The method is identified by method_index. + */ +JNIEXPORT jboolean JNICALL +JVM_IsVMGeneratedMethodIx(JNIEnv *env, jclass cb, int index); + +/* + * Returns the name of a given method in UTF format. + * The result remains valid until JVM_ReleaseUTF is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +JNIEXPORT const char * JNICALL +JVM_GetMethodIxNameUTF(JNIEnv *env, jclass cb, jint index); + +/* + * Returns the signature of a given method in UTF format. + * The result remains valid until JVM_ReleaseUTF is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +JNIEXPORT const char * JNICALL +JVM_GetMethodIxSignatureUTF(JNIEnv *env, jclass cb, jint index); + +/* + * Returns the name of the field refered to at a given constant pool + * index. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +JNIEXPORT const char * JNICALL +JVM_GetCPFieldNameUTF(JNIEnv *env, jclass cb, jint index); + +/* + * Returns the name of the method refered to at a given constant pool + * index. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +JNIEXPORT const char * JNICALL +JVM_GetCPMethodNameUTF(JNIEnv *env, jclass cb, jint index); + +/* + * Returns the signature of the method refered to at a given constant pool + * index. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +JNIEXPORT const char * JNICALL +JVM_GetCPMethodSignatureUTF(JNIEnv *env, jclass cb, jint index); + +/* + * Returns the signature of the field refered to at a given constant pool + * index. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +JNIEXPORT const char * JNICALL +JVM_GetCPFieldSignatureUTF(JNIEnv *env, jclass cb, jint index); + +/* + * Returns the class name refered to at a given constant pool index. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +JNIEXPORT const char * JNICALL +JVM_GetCPClassNameUTF(JNIEnv *env, jclass cb, jint index); + +/* + * Returns the class name refered to at a given constant pool index. + * + * The constant pool entry must refer to a CONSTANT_Fieldref. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +JNIEXPORT const char * JNICALL +JVM_GetCPFieldClassNameUTF(JNIEnv *env, jclass cb, jint index); + +/* + * Returns the class name refered to at a given constant pool index. + * + * The constant pool entry must refer to CONSTANT_Methodref or + * CONSTANT_InterfaceMethodref. + * + * The result is in UTF format and remains valid until JVM_ReleaseUTF + * is called. + * + * The caller must treat the string as a constant and not modify it + * in any way. + */ +JNIEXPORT const char * JNICALL +JVM_GetCPMethodClassNameUTF(JNIEnv *env, jclass cb, jint index); + +/* + * Returns the modifiers of a field in calledClass. The field is + * referred to in class cb at constant pool entry index. + * + * The caller must treat the string as a constant and not modify it + * in any way. + * + * Returns -1 if the field does not exist in calledClass. + */ +JNIEXPORT jint JNICALL +JVM_GetCPFieldModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); + +/* + * Returns the modifiers of a method in calledClass. The method is + * referred to in class cb at constant pool entry index. + * + * Returns -1 if the method does not exist in calledClass. + */ +JNIEXPORT jint JNICALL +JVM_GetCPMethodModifiers(JNIEnv *env, jclass cb, int index, jclass calledClass); + +/* + * Releases the UTF string obtained from the VM. + */ +JNIEXPORT void JNICALL +JVM_ReleaseUTF(const char *utf); + +/* + * Compare if two classes are in the same package. + */ +JNIEXPORT jboolean JNICALL +JVM_IsSameClassPackage(JNIEnv *env, jclass class1, jclass class2); + +/* Get classfile constants */ +#include "classfile_constants.h" + +/* + * A function defined by the byte-code verifier and called by the VM. + * This is not a function implemented in the VM. + * + * Returns JNI_FALSE if verification fails. A detailed error message + * will be places in msg_buf, whose length is specified by buf_len. + */ +typedef jboolean (*verifier_fn_t)(JNIEnv *env, + jclass cb, + char * msg_buf, + jint buf_len); + + +/* + * Support for a VM-independent class format checker. + */ +typedef struct { + unsigned long code; /* byte code */ + unsigned long excs; /* exceptions */ + unsigned long etab; /* catch table */ + unsigned long lnum; /* line number */ + unsigned long lvar; /* local vars */ +} method_size_info; + +typedef struct { + unsigned int constants; /* constant pool */ + unsigned int fields; + unsigned int methods; + unsigned int interfaces; + unsigned int fields2; /* number of static 2-word fields */ + unsigned int innerclasses; /* # of records in InnerClasses attr */ + + method_size_info clinit; /* memory used in clinit */ + method_size_info main; /* used everywhere else */ +} class_size_info; + +/* + * Functions defined in libjava.so to perform string conversions. + * + */ + +typedef jstring (*to_java_string_fn_t)(JNIEnv *env, char *str); + +typedef char *(*to_c_string_fn_t)(JNIEnv *env, jstring s, jboolean *b); + +/* This is the function defined in libjava.so that performs class + * format checks. This functions fills in size information about + * the class file and returns: + * + * 0: good + * -1: out of memory + * -2: bad format + * -3: unsupported version + * -4: bad class name + */ + +typedef jint (*check_format_fn_t)(char *class_name, + unsigned char *data, + unsigned int data_size, + class_size_info *class_size, + char *message_buffer, + jint buffer_length, + jboolean measure_only, + jboolean check_relaxed); + +#define JVM_RECOGNIZED_CLASS_MODIFIERS (JVM_ACC_PUBLIC | \ + JVM_ACC_FINAL | \ + JVM_ACC_SUPER | \ + JVM_ACC_INTERFACE | \ + JVM_ACC_ABSTRACT | \ + JVM_ACC_ANNOTATION | \ + JVM_ACC_ENUM | \ + JVM_ACC_SYNTHETIC) + +#define JVM_RECOGNIZED_FIELD_MODIFIERS (JVM_ACC_PUBLIC | \ + JVM_ACC_PRIVATE | \ + JVM_ACC_PROTECTED | \ + JVM_ACC_STATIC | \ + JVM_ACC_FINAL | \ + JVM_ACC_VOLATILE | \ + JVM_ACC_TRANSIENT | \ + JVM_ACC_ENUM | \ + JVM_ACC_SYNTHETIC) + +#define JVM_RECOGNIZED_METHOD_MODIFIERS (JVM_ACC_PUBLIC | \ + JVM_ACC_PRIVATE | \ + JVM_ACC_PROTECTED | \ + JVM_ACC_STATIC | \ + JVM_ACC_FINAL | \ + JVM_ACC_SYNCHRONIZED | \ + JVM_ACC_BRIDGE | \ + JVM_ACC_VARARGS | \ + JVM_ACC_NATIVE | \ + JVM_ACC_ABSTRACT | \ + JVM_ACC_STRICT | \ + JVM_ACC_SYNTHETIC) + +/* + * This is the function defined in libjava.so to perform path + * canonicalization. VM call this function before opening jar files + * to load system classes. + * + */ + +typedef int (*canonicalize_fn_t)(JNIEnv *env, char *orig, char *out, int len); + +/************************************************************************* + PART 3: I/O and Network Support + ************************************************************************/ + +/* Note that the JVM IO functions are expected to return JVM_IO_ERR + * when there is any kind of error. The caller can then use the + * platform specific support (e.g., errno) to get the detailed + * error info. The JVM_GetLastErrorString procedure may also be used + * to obtain a descriptive error string. + */ +#define JVM_IO_ERR (-1) + +/* For interruptible IO. Returning JVM_IO_INTR indicates that an IO + * operation has been disrupted by Thread.interrupt. There are a + * number of technical difficulties related to interruptible IO that + * need to be solved. For example, most existing programs do not handle + * InterruptedIOExceptions specially, they simply treat those as any + * IOExceptions, which typically indicate fatal errors. + * + * There are also two modes of operation for interruptible IO. In the + * resumption mode, an interrupted IO operation is guaranteed not to + * have any side-effects, and can be restarted. In the termination mode, + * an interrupted IO operation corrupts the underlying IO stream, so + * that the only reasonable operation on an interrupted stream is to + * close that stream. The resumption mode seems to be impossible to + * implement on Win32 and Solaris. Implementing the termination mode is + * easier, but it's not clear that's the right semantics. + * + * Interruptible IO is not supported on Win32.It can be enabled/disabled + * using a compile-time flag on Solaris. Third-party JVM ports do not + * need to implement interruptible IO. + */ +#define JVM_IO_INTR (-2) + +/* Write a string into the given buffer, in the platform's local encoding, + * that describes the most recent system-level error to occur in this thread. + * Return the length of the string or zero if no error occurred. + */ +JNIEXPORT jint JNICALL +JVM_GetLastErrorString(char *buf, int len); + +/* + * Convert a pathname into native format. This function does syntactic + * cleanup, such as removing redundant separator characters. It modifies + * the given pathname string in place. + */ +JNIEXPORT char * JNICALL +JVM_NativePath(char *); + +/* + * JVM I/O error codes + */ +#define JVM_EEXIST -100 + +/* + * Open a file descriptor. This function returns a negative error code + * on error, and a non-negative integer that is the file descriptor on + * success. + */ +JNIEXPORT jint JNICALL +JVM_Open(const char *fname, jint flags, jint mode); + +/* + * Close a file descriptor. This function returns -1 on error, and 0 + * on success. + * + * fd the file descriptor to close. + */ +JNIEXPORT jint JNICALL +JVM_Close(jint fd); + +/* + * Read data from a file decriptor into a char array. + * + * fd the file descriptor to read from. + * buf the buffer where to put the read data. + * nbytes the number of bytes to read. + * + * This function returns -1 on error, and 0 on success. + */ +JNIEXPORT jint JNICALL +JVM_Read(jint fd, char *buf, jint nbytes); + +/* + * Write data from a char array to a file decriptor. + * + * fd the file descriptor to read from. + * buf the buffer from which to fetch the data. + * nbytes the number of bytes to write. + * + * This function returns -1 on error, and 0 on success. + */ +JNIEXPORT jint JNICALL +JVM_Write(jint fd, char *buf, jint nbytes); + +/* + * Returns the number of bytes available for reading from a given file + * descriptor + */ +JNIEXPORT jint JNICALL +JVM_Available(jint fd, jlong *pbytes); + +/* + * Move the file descriptor pointer from whence by offset. + * + * fd the file descriptor to move. + * offset the number of bytes to move it by. + * whence the start from where to move it. + * + * This function returns the resulting pointer location. + */ +JNIEXPORT jlong JNICALL +JVM_Lseek(jint fd, jlong offset, jint whence); + +/* + * Set the length of the file associated with the given descriptor to the given + * length. If the new length is longer than the current length then the file + * is extended; the contents of the extended portion are not defined. The + * value of the file pointer is undefined after this procedure returns. + */ +JNIEXPORT jint JNICALL +JVM_SetLength(jint fd, jlong length); + +/* + * Synchronize the file descriptor's in memory state with that of the + * physical device. Return of -1 is an error, 0 is OK. + */ +JNIEXPORT jint JNICALL +JVM_Sync(jint fd); + +/* + * Networking library support + */ + +JNIEXPORT jint JNICALL +JVM_InitializeSocketLibrary(void); + +struct sockaddr; + +JNIEXPORT jint JNICALL +JVM_Socket(jint domain, jint type, jint protocol); + +JNIEXPORT jint JNICALL +JVM_SocketClose(jint fd); + +JNIEXPORT jint JNICALL +JVM_SocketShutdown(jint fd, jint howto); + +JNIEXPORT jint JNICALL +JVM_Recv(jint fd, char *buf, jint nBytes, jint flags); + +JNIEXPORT jint JNICALL +JVM_Send(jint fd, char *buf, jint nBytes, jint flags); + +JNIEXPORT jint JNICALL +JVM_Timeout(int fd, long timeout); + +JNIEXPORT jint JNICALL +JVM_Listen(jint fd, jint count); + +JNIEXPORT jint JNICALL +JVM_Connect(jint fd, struct sockaddr *him, jint len); + +JNIEXPORT jint JNICALL +JVM_Bind(jint fd, struct sockaddr *him, jint len); + +JNIEXPORT jint JNICALL +JVM_Accept(jint fd, struct sockaddr *him, jint *len); + +JNIEXPORT jint JNICALL +JVM_RecvFrom(jint fd, char *buf, int nBytes, + int flags, struct sockaddr *from, int *fromlen); + +JNIEXPORT jint JNICALL +JVM_SendTo(jint fd, char *buf, int len, + int flags, struct sockaddr *to, int tolen); + +JNIEXPORT jint JNICALL +JVM_SocketAvailable(jint fd, jint *result); + + +JNIEXPORT jint JNICALL +JVM_GetSockName(jint fd, struct sockaddr *him, int *len); + +JNIEXPORT jint JNICALL +JVM_GetSockOpt(jint fd, int level, int optname, char *optval, int *optlen); + +JNIEXPORT jint JNICALL +JVM_SetSockOpt(jint fd, int level, int optname, const char *optval, int optlen); + +JNIEXPORT int JNICALL +JVM_GetHostName(char* name, int namelen); + +/* + * The standard printing functions supported by the Java VM. (Should they + * be renamed to JVM_* in the future? + */ + +/* + * BE CAREFUL! The following functions do not implement the + * full feature set of standard C printf formats. + */ +int +jio_vsnprintf(char *str, size_t count, const char *fmt, va_list args); + +int +jio_snprintf(char *str, size_t count, const char *fmt, ...); + +int +jio_fprintf(FILE *, const char *fmt, ...); + +int +jio_vfprintf(FILE *, const char *fmt, va_list args); + + +JNIEXPORT void * JNICALL +JVM_RawMonitorCreate(void); + +JNIEXPORT void JNICALL +JVM_RawMonitorDestroy(void *mon); + +JNIEXPORT jint JNICALL +JVM_RawMonitorEnter(void *mon); + +JNIEXPORT void JNICALL +JVM_RawMonitorExit(void *mon); + +/* + * java.lang.management support + */ +JNIEXPORT void* JNICALL +JVM_GetManagement(jint version); + +/* + * com.sun.tools.attach.VirtualMachine support + * + * Initialize the agent properties with the properties maintained in the VM. + */ +JNIEXPORT jobject JNICALL +JVM_InitAgentProperties(JNIEnv *env, jobject agent_props); + +/* Generics reflection support. + * + * Returns information about the given class's EnclosingMethod + * attribute, if present, or null if the class had no enclosing + * method. + * + * If non-null, the returned array contains three elements. Element 0 + * is the java.lang.Class of which the enclosing method is a member, + * and elements 1 and 2 are the java.lang.Strings for the enclosing + * method's name and descriptor, respectively. + */ +JNIEXPORT jobjectArray JNICALL +JVM_GetEnclosingMethodInfo(JNIEnv* env, jclass ofClass); + +/* + * Java thread state support + */ +enum { + JAVA_THREAD_STATE_NEW = 0, + JAVA_THREAD_STATE_RUNNABLE = 1, + JAVA_THREAD_STATE_BLOCKED = 2, + JAVA_THREAD_STATE_WAITING = 3, + JAVA_THREAD_STATE_TIMED_WAITING = 4, + JAVA_THREAD_STATE_TERMINATED = 5, + JAVA_THREAD_STATE_COUNT = 6 +}; + +/* + * Returns an array of the threadStatus values representing the + * given Java thread state. Returns NULL if the VM version is + * incompatible with the JDK or doesn't support the given + * Java thread state. + */ +JNIEXPORT jintArray JNICALL +JVM_GetThreadStateValues(JNIEnv* env, jint javaThreadState); + +/* + * Returns an array of the substate names representing the + * given Java thread state. Returns NULL if the VM version is + * incompatible with the JDK or the VM doesn't support + * the given Java thread state. + * values must be the jintArray returned from JVM_GetThreadStateValues + * and javaThreadState. + */ +JNIEXPORT jobjectArray JNICALL +JVM_GetThreadStateNames(JNIEnv* env, jint javaThreadState, jintArray values); + +/* ========================================================================= + * The following defines a private JVM interface that the JDK can query + * for the JVM version and capabilities. sun.misc.Version defines + * the methods for getting the VM version and its capabilities. + * + * When a new bit is added, the following should be updated to provide + * access to the new capability: + * HS: JVM_GetVersionInfo and Abstract_VM_Version class + * SDK: Version class + * + * Similary, a private JDK interface JDK_GetVersionInfo0 is defined for + * JVM to query for the JDK version and capabilities. + * + * When a new bit is added, the following should be updated to provide + * access to the new capability: + * HS: JDK_Version class + * SDK: JDK_GetVersionInfo0 + * + * ========================================================================== + */ +typedef struct { + /* Naming convention of RE build version string: n.n.n[_uu[c]][-]-bxx */ + unsigned int jvm_version; /* Consists of major, minor, micro (n.n.n) */ + /* and build number (xx) */ + unsigned int update_version : 8; /* Update release version (uu) */ + unsigned int special_update_version : 8; /* Special update release version (c)*/ + unsigned int reserved1 : 16; + unsigned int reserved2; + + /* The following bits represents JVM supports that JDK has dependency on. + * JDK can use these bits to determine which JVM version + * and support it has to maintain runtime compatibility. + * + * When a new bit is added in a minor or update release, make sure + * the new bit is also added in the main/baseline. + */ + unsigned int is_attach_supported : 1; + unsigned int : 31; + unsigned int : 32; + unsigned int : 32; +} jvm_version_info; + +#define JVM_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) +#define JVM_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) +#define JVM_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8) + +/* Build number is available only for RE builds. + * It will be zero for internal builds. + */ +#define JVM_VERSION_BUILD(version) ((version & 0x000000FF)) + +JNIEXPORT void JNICALL +JVM_GetVersionInfo(JNIEnv* env, jvm_version_info* info, size_t info_size); + +typedef struct { + // Naming convention of RE build version string: n.n.n[_uu[c]][-]-bxx + unsigned int jdk_version; /* Consists of major, minor, micro (n.n.n) */ + /* and build number (xx) */ + unsigned int update_version : 8; /* Update release version (uu) */ + unsigned int special_update_version : 8; /* Special update release version (c)*/ + unsigned int reserved1 : 16; + unsigned int reserved2; + + /* The following bits represents new JDK supports that VM has dependency on. + * VM implementation can use these bits to determine which JDK version + * and support it has to maintain runtime compatibility. + * + * When a new bit is added in a minor or update release, make sure + * the new bit is also added in the main/baseline. + */ + unsigned int thread_park_blocker : 1; + unsigned int post_vm_init_hook_enabled : 1; + unsigned int pending_list_uses_discovered_field : 1; + unsigned int : 29; + unsigned int : 32; + unsigned int : 32; +} jdk_version_info; + +#define JDK_VERSION_MAJOR(version) ((version & 0xFF000000) >> 24) +#define JDK_VERSION_MINOR(version) ((version & 0x00FF0000) >> 16) +#define JDK_VERSION_MICRO(version) ((version & 0x0000FF00) >> 8) + +/* Build number is available only for RE build (i.e. JDK_BUILD_NUMBER is set to bNN) + * It will be zero for internal builds. + */ +#define JDK_VERSION_BUILD(version) ((version & 0x000000FF)) + +/* + * This is the function JDK_GetVersionInfo0 defined in libjava.so + * that is dynamically looked up by JVM. + */ +typedef void (*jdk_version_info_fn_t)(jdk_version_info* info, size_t info_size); + +/* + * This structure is used by the launcher to get the default thread + * stack size from the VM using JNI_GetDefaultJavaVMInitArgs() with a + * version of 1.1. As it is not supported otherwise, it has been removed + * from jni.h + */ +typedef struct JDK1_1InitArgs { + jint version; + + char **properties; + jint checkSource; + jint nativeStackSize; + jint javaStackSize; + jint minHeapSize; + jint maxHeapSize; + jint verifyMode; + char *classpath; + + jint (JNICALL *vfprintf)(FILE *fp, const char *format, va_list args); + void (JNICALL *exit)(jint code); + void (JNICALL *abort)(void); + + jint enableClassGC; + jint enableVerboseGC; + jint disableAsyncGC; + jint verbose; + jboolean debugging; + jint debugPort; +} JDK1_1InitArgs; + + +#ifdef __cplusplus +} /* extern "C" */ + +#endif /* __cplusplus */ + +#endif /* !_JAVASOFT_JVM_H_ */ Added: vmkit/branches/mcjit/lib/j3/vm/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/Makefile?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/Makefile (added) +++ vmkit/branches/mcjit/lib/j3/vm/Makefile Mon Nov 25 03:27:09 2013 @@ -0,0 +1,38 @@ +#===- ./Makefile -------------------------------------------*- Makefile -*--===# +# +# The vmkit project +#===------------------------------------------------------------------------===# + +LEVEL := ../../.. + +MODULE=j3 + +ifdef rien +EXTRACT= \ + 'j3::J3Type::vt()' \ + 'j3::J3Method::index()' \ + 'j3::J3Type::initialise()' \ + 'j3::J3ObjectType::javaClass()' \ + 'j3::J3Class::size()' \ + 'j3::J3Class::staticInstance()' \ + 'j3::J3Class::stringAt(unsigned short)' \ + 'j3::J3Object::allocate(j3::J3VirtualTable*, unsigned long)' \ + 'j3::J3::jniEnv()' \ + 'j3::J3::throwException(j3::J3Object*)' \ + 'j3::J3::classCastException()' \ + 'j3::J3::nullPointerException()' \ + 'j3::J3VirtualTable::slowIsAssignableTo(j3::J3VirtualTable*)' \ + 'j3::J3VirtualTable::fastIsAssignableToPrimaryChecker(j3::J3VirtualTable*, unsigned int)' \ + 'j3::J3VirtualTable::fastIsAssignableToNonPrimaryChecker(j3::J3VirtualTable*)' \ + 'j3::J3Thread::push(j3::J3ObjectHandle*)' \ + 'j3::J3Thread::push(j3::J3Object*)' \ + 'j3::J3Thread::tell()' \ + 'j3::J3Thread::restore(j3::J3ObjectHandle*)' \ + 'j3::J3Thread::get()' + +EXTRACT_TYPE= \ + 'struct.JNIEnv_' \ + 'class.j3::J3ArrayObject' +endif + +include $(LEVEL)/Makefile.rules Added: vmkit/branches/mcjit/lib/j3/vm/j3.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,176 @@ +#include +#include + +#include "j3/j3class.h" +#include "j3/j3.h" +#include "j3/j3classloader.h" +#include "j3/j3constants.h" +#include "j3/j3method.h" +#include "j3/j3thread.h" + +#include "llvm/IR/Module.h" +#include "llvm/IR/Type.h" +#include "llvm/IR/DerivedTypes.h" + +#include "llvm/ExecutionEngine/ExecutionEngine.h" + +using namespace j3; + +vmkit::T_ptr_less_t J3::charArrayLess; + +J3::J3(vmkit::BumpAllocator* allocator) : + VMKit(allocator), + nameToCharArrays(vmkit::Name::less, allocator), + charArrayToStrings(charArrayLess, allocator), + _names(allocator) { + pthread_mutex_init(&stringsMutex, 0); + constantValueAttr = names()->get(J3Cst::constantValueAttr); + codeAttr = names()->get(J3Cst::codeAttr); + clinitName = names()->get(J3Cst::clinitName); + clinitSign = names()->get(J3Cst::clinitSign); + initName = names()->get(J3Cst::initName); +} + +J3* J3::create() { + vmkit::BumpAllocator* allocator = vmkit::BumpAllocator::create(); + return new(allocator) J3(allocator); +} + +void J3::introspect() { + typeJNIEnvPtr = llvm::PointerType::getUnqual(introspectType("struct.JNIEnv_")); + typeJ3VirtualTablePtr = llvm::PointerType::getUnqual(introspectType("class.j3::J3VirtualTable")); + typeJ3Type = introspectType("class.j3::J3Type"); + typeJ3TypePtr = llvm::PointerType::getUnqual(typeJ3Type); + typeJ3ObjectTypePtr = llvm::PointerType::getUnqual(introspectType("class.j3::J3ObjectType")); + typeJ3Class = introspectType("class.j3::J3Class"); + typeJ3ClassPtr = llvm::PointerType::getUnqual(typeJ3Class); + typeJ3ArrayClass = introspectType("class.j3::J3ArrayClass"); + typeJ3ArrayClassPtr = llvm::PointerType::getUnqual(typeJ3ArrayClass); + typeJ3ArrayObject = introspectType("class.j3::J3ArrayObject"); + typeJ3ArrayObjectPtr = llvm::PointerType::getUnqual(typeJ3ArrayObject); + typeJ3Method = introspectType("class.j3::J3Method"); + typeJ3Object = introspectType("class.j3::J3Object"); + typeJ3ObjectPtr = llvm::PointerType::getUnqual(typeJ3Object); + typeJ3ObjectHandlePtr = llvm::PointerType::getUnqual(introspectType("class.j3::J3ObjectHandle")); + + typeGXXException = llvm::StructType::get(llvm::Type::getInt8Ty(self()->getContext())->getPointerTo(), + llvm::Type::getInt32Ty(self()->getContext()), NULL); +} + +void J3::start(int argc, char** argv) { + _options.process(argc, argv); + + vmkitBootstrap(J3Thread::create(this), options()->selfBitCodePath); + + introspect(); + + vmkit::BumpAllocator* loaderAllocator = vmkit::BumpAllocator::create(); + initialClassLoader = + new(loaderAllocator) + J3InitialClassLoader(this, options()->rtJar, loaderAllocator); + + vmkit::BumpAllocator* a = initialClassLoader->allocator(); + +#define defPrimitive(name, ctype, llvmtype) \ + type##name = new(a) J3Primitive(initialClassLoader, J3Cst::ID_##name, llvm::Type::get##llvmtype##Ty(self()->getContext())); + onJavaTypes(defPrimitive) +#undef defPrimitive + + nbArrayInterfaces = 2; + arrayInterfaces = (J3Type**)initialClassLoader->allocator()->allocate(2*sizeof(J3Type*)); + arrayInterfaces[0] = initialClassLoader->getClass(names()->get(L"java/lang/Cloneable")); + arrayInterfaces[1] = initialClassLoader->getClass(names()->get(L"java/io/Serializable")); + + charArrayClass = typeChar->getArray(); + objectClass = initialClassLoader->getClass(names()->get(L"java/lang/Object")); + + stringClass = initialClassLoader->getClass(names()->get(L"java/lang/String")); + stringInit = initialClassLoader->method(0, stringClass, initName, names()->get(L"([CZ)V")); + stringValue = stringClass->findVirtualField(names()->get(L"value"), typeChar->getArray()); + + classClass = initialClassLoader->getClass(names()->get(L"java/lang/Class")); + J3Field hf(J3Cst::ACC_PRIVATE, names()->get(L"** vmData **"), typeLong); + classClass->resolve(&hf, 1); + classInit = initialClassLoader->method(0, classClass, initName, names()->get(L"()V")); + classVMData = classClass->findVirtualField(hf.name(), hf.type()); + + initialClassLoader->method(J3Cst::ACC_STATIC, L"java/lang/System", L"initializeSystemClass", L"()V")->invokeStatic(); + +#if 0 + J3Method* m = initialClassLoader->method(J3Cst::ACC_STATIC, + L"java/lang/ClassLoader", + L"getSystemClassLoader", + L"()Ljava/lang/ClassLoader;"); + + m->invokeStatic(); +#endif +} + +JNIEnv* J3::jniEnv() { + return J3Thread::get()->jniEnv(); +} + +J3ObjectHandle* J3::arrayToString(J3ObjectHandle* array) { + pthread_mutex_lock(&stringsMutex); + J3ObjectHandle* res = charArrayToStrings[array]; + if(!res) { + J3ObjectHandle* prev = J3Thread::get()->tell(); + res = initialClassLoader->fixedPoint()->syncPush(J3ObjectHandle::doNewObject(stringClass)); + J3Thread::get()->restore(prev); + + stringInit->invokeSpecial(res, array, 0); + + charArrayToStrings[array] = res; + } + pthread_mutex_unlock(&stringsMutex); + return res; +} + +J3ObjectHandle* J3::nameToString(const vmkit::Name* name) { + pthread_mutex_lock(&stringsMutex); + J3ObjectHandle* res = nameToCharArrays[name]; + if(!res) { + J3ObjectHandle* prev = J3Thread::get()->tell(); + res = initialClassLoader->fixedPoint()->syncPush(J3ObjectHandle::doNewArray(charArrayClass, name->length())); + J3Thread::get()->restore(prev); + + for(uint32_t i=0; ilength(); i++) + res->setCharAt(i, name->cStr()[i]); + nameToCharArrays[name] = res; + } + pthread_mutex_unlock(&stringsMutex); + return arrayToString(res); +} + +J3ObjectHandle* J3::utfToString(const char* name) { + return nameToString(names()->get(name)); +} + +void J3::classCastException() { + internalError(L"implement me: class cast exception"); +} + +void J3::nullPointerException() { + internalError(L"implement me: null pointer exception"); +} + +void J3::noClassDefFoundError(J3Class* cl) { + internalError(L"NoClassDefFoundError: %ls (%p - %p)", cl->name()->cStr(), cl, cl->name()); +} + +void J3::noSuchMethodError(const wchar_t* msg, J3Class* cl, const vmkit::Name* name, const vmkit::Name* sign) { + internalError(L"%ls: %ls::%ls %ls", msg, cl->name()->cStr(), name->cStr(), sign->cStr()); +} + +void J3::classFormatError(J3Class* cl, const wchar_t* reason, ...) { + wchar_t buf[65536]; + va_list va; + va_start(va, reason); + vswprintf(buf, 65536, reason, va); + va_end(va); + internalError(L"ClassFormatError in '%ls' caused by '%ls'", cl->name()->cStr(), buf); +} + +void J3::linkageError(J3Method* method) { + internalError(L"unable to find native method '%ls::%ls%ls'", method->cl()->name()->cStr(), method->name()->cStr(), method->sign()->cStr()); +} Added: vmkit/branches/mcjit/lib/j3/vm/j3class.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3class.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,876 @@ +#include +#include +#include + +#include "llvm/ExecutionEngine/ExecutionEngine.h" +#include "llvm/ExecutionEngine/GenericValue.h" +#include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/Module.h" +#include "llvm/IR/DataLayout.h" + +#include "j3/j3.h" +#include "j3/j3class.h" +#include "j3/j3classloader.h" +#include "j3/j3reader.h" +#include "j3/j3constants.h" +#include "j3/j3method.h" +#include "j3/j3mangler.h" +#include "j3/j3object.h" +#include "j3/j3thread.h" + +using namespace j3; + +/* + * ------------ J3Type ------------ + */ +J3Type::J3Type(J3ClassLoader* loader, const vmkit::Name* name) { + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&_mutex, &attr); + _loader = loader; + _name = name; +} + +J3VirtualTable* J3Type::vt() { + return _vt; +} + +void J3Type::dump() { + fprintf(stderr, "Type: %ls", name()->cStr()); +} + +char* J3Type::nativeName() { + if(!_nativeName) + llvmType(); + return _nativeName; +} + +uint32_t J3Type::nativeNameLength() { + if(!_nativeNameLength) + llvmType(); + return _nativeNameLength; +} + +J3ArrayClass* J3Type::getArray(uint32_t prof, const vmkit::Name* name) { + if(!_array) { + lock(); + if(!_array) { + _array = new(loader()->allocator()) J3ArrayClass(loader(), this, name); + } + unlock(); + } + + return prof > 1 ? _array->getArray(prof-1) : _array; +} + +bool J3Type::isAssignableTo(J3Type* parent) { + resolve(); + parent->resolve(); + return vt()->isAssignableTo(parent->vt()); +} + +J3Type* J3Type::resolve() { + if(status < RESOLVED) + doResolve(0, 0); + return this; +} + +J3Type* J3Type::resolve(J3Field* hiddenFields, uint32_t nbHiddenFields) { + if(status < RESOLVED) + doResolve(hiddenFields, nbHiddenFields); + else + J3::internalError(L"trying to resolve class %ls with hidden fields while it is already loaded", name()->cStr()); + return this; +} + +J3Type* J3Type::initialise() { + if(status < INITED) + doInitialise(); + return this; +} + +J3Class* J3Type::asClass() { + if(!isClass()) + J3::internalError(L"should not happen"); + return (J3Class*)this; +} + +J3Layout* J3Type::asLayout() { + if(!isLayout()) + J3::internalError(L"should not happen"); + return (J3Layout*)this; +} + +J3Primitive* J3Type::asPrimitive() { + if(!isPrimitive()) + J3::internalError(L"should not happen"); + return (J3Primitive*)this; +} + +J3ArrayClass* J3Type::asArrayClass() { + if(!isArrayClass()) + J3::internalError(L"should not happen"); + return (J3ArrayClass*)this; +} + +J3ObjectType* J3Type::asObjectType() { + if(!isObjectType()) + J3::internalError(L"should not happen"); + return (J3ObjectType*)this; +} + +/* + * ------------ J3ObjectType ------------ + */ +J3ObjectType::J3ObjectType(J3ClassLoader* loader, const vmkit::Name* name) : J3Type(loader, name) { +} + +J3Method* J3ObjectType::findVirtualMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error) { + J3::internalError(L"should not happen"); +} + +J3Method* J3ObjectType::findStaticMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error) { + J3::internalError(L"should not happen"); +} + +J3ObjectType* J3ObjectType::nativeClass(J3ObjectHandle* handle) { + return (J3ObjectType*)(uintptr_t)handle->getLong(J3Thread::get()->vm()->classVMData); +} + +J3ObjectHandle* J3ObjectType::javaClass() { + if(!_javaClass) { + lock(); + if(!_javaClass) { + J3ObjectHandle* prev = J3Thread::get()->tell(); + _javaClass = J3ObjectHandle::doNewObject(loader()->vm()->classClass); + loader()->fixedPoint()->syncPush(_javaClass); + J3Thread::get()->restore(prev); + _javaClass->setLong(loader()->vm()->classVMData, (int64_t)(uintptr_t)this); + loader()->vm()->classInit->invokeSpecial(_javaClass); + } + unlock(); + } + return _javaClass; +} + +/* + * ------------ J3Layout ------------ + */ +J3Layout::J3Layout(J3ClassLoader* loader, const vmkit::Name* name) : J3ObjectType(loader, name) { +} + +J3Method* J3Layout::findMethod(const vmkit::Name* name, const vmkit::Name* sign) { + for(size_t i=0; iname()->cStr(), cur->sign()->cStr()); + //printf("%ls - %ls\n", name->cStr(), sign->cStr()); + if(cur->name() == name && cur->sign() == sign) { + return cur; + } + } + return 0; +} + +J3Field* J3Layout::findField(const vmkit::Name* name, const J3Type* type) { + for(size_t i=0; iname()->cStr(), cur->sign()->cStr()); + //printf("%ls - %ls\n", name->cStr(), sign->cStr()); + if(cur->name() == name && cur->type() == type) { + return cur; + } + } + return 0; +} + +/* + * ------------ J3Class ------------ + */ +J3Class::J3Class(J3ClassLoader* loader, const vmkit::Name* name) : J3Layout(loader, name), staticLayout(loader, name) { + status = CITED; +} + +size_t J3Class::size() { + return _size; +} + +llvm::GlobalValue* J3Class::llvmDescriptor(llvm::Module* module) { + if(!_nomcjitDescriptor) { + _nomcjitDescriptor = llvm::cast(module->getOrInsertGlobal(nativeName(), loader()->vm()->typeJ3Class)); + loader()->vm()->ee()->addGlobalMapping(_nomcjitDescriptor, this); + } + return _nomcjitDescriptor; +} + + +J3Method* J3Class::findVirtualMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error) { + //loader()->vm()->log(L"Lookup: %ls %ls in %ls (%d)", methName->cStr(), methSign->cStr(), name()->cStr(), nbVirtualMethods); + resolve(); + + J3Method* res = findMethod(name, sign); + + if(!res) { + if(super() == this) { + if(error) + J3::noSuchMethodError(L"no such method", this, name, sign); + else + return 0; + } + res = super()->findVirtualMethod(name, sign, error); + } + + return res; +} + +J3Method* J3Class::findStaticMethod(const vmkit::Name* name, const vmkit::Name* sign, bool error) { + //loader()->vm()->log(L"Lookup: %ls %ls in %ls", methName->cStr(), methSign->cStr(), name()->cStr()); + resolve(); + + J3Method* res = staticLayout.findMethod(name, sign); + + if(!res) + J3::internalError(L"implement me"); + + return res; +} + +J3Field* J3Class::findVirtualField(const vmkit::Name* name, const J3Type* type, bool error) { + //loader()->vm()->log(L"Lookup: %ls %ls in %ls", methName->cStr(), methSign->cStr(), name()->cStr()); + resolve(); + + J3Field* res = findField(name, type); + + if(!res) + J3::internalError(L"implement me"); + + return res; +} + +J3Field* J3Class::findStaticField(const vmkit::Name* fname, const J3Type* ftype, bool error) { + //fprintf(stderr, "Lookup static field %ls %ls::%ls\n", ftype->name()->cStr(), name()->cStr(), fname->cStr()); + resolve(); + + J3Field* res = staticLayout.findField(fname, ftype); + + if(!res) + J3::internalError(L"implement me"); + + return res; +} + +void J3Class::registerNative(const vmkit::Name* methName, const vmkit::Name* methSign, void* fnPtr) { + resolve(); + J3Method* res = staticLayout.findMethod(methName, methSign); + if(!res) + res = findMethod(methName, methSign); + if(!res || !J3Cst::isNative(res->access())) + J3::noSuchMethodError(L"unable to find native method", this, methName, methSign); + + res->registerNative(fnPtr); +} + +J3ObjectHandle* J3Class::staticInstance() { + return _staticInstance; +} + +void J3Class::doInitialise() { + resolve(); + lock(); + if(status < INITED) { + if(loader()->vm()->options()->debugIniting) + fprintf(stderr, "Initing: %ls\n", name()->cStr()); + status = INITED; + + super()->initialise(); + + for(size_t i=0; iinitialise(); + + J3ObjectHandle* prev = J3Thread::get()->tell(); + J3ObjectHandle* stacked = J3ObjectHandle::allocate(staticLayout.vt(), + loader()->vm()->dataLayout()->getTypeAllocSize(staticLayout.llvmType() + ->getContainedType(0))); + _staticInstance = loader()->fixedPoint()->syncPush(stacked); + J3Thread::get()->restore(prev); + + for(size_t i=0; iattributes()->lookup(loader()->vm()->constantValueAttr); + + if(attr) { + J3Reader reader(bytes()); + reader.seek(attr->offset(), reader.SeekSet); + + uint32_t length = reader.readU4(); + if(length != 2) + J3::classFormatError(this, L"bad length for ConstantAttribute"); + + uint32_t idx = reader.readU2(); + + switch(getCtpType(idx)) { + case J3Cst::CONSTANT_Long: staticInstance()->setLong(cur, longAt(idx)); break; + case J3Cst::CONSTANT_Float: staticInstance()->setFloat(cur, floatAt(idx)); break; + case J3Cst::CONSTANT_Double: staticInstance()->setDouble(cur, doubleAt(idx)); break; + case J3Cst::CONSTANT_Integer: staticInstance()->setInteger(cur, integerAt(idx)); break; + case J3Cst::CONSTANT_String: staticInstance()->setObject(cur, stringAt(idx)); break; + default: + J3::classFormatError(this, L"invalid ctp entry ConstantAttribute with type %d", getCtpType(idx)); + } + } + } + + J3Method* clinit = staticLayout.findMethod(loader()->vm()->clinitName, loader()->vm()->clinitSign); + + if(clinit) + clinit->invokeStatic(); + } + unlock(); +} + +void J3Class::load() { + if(status < LOADED) { + lock(); + if(status < LOADED) { + if(loader()->vm()->options()->debugLoad) + fprintf(stderr, "Loading: %ls\n", name()->cStr()); + + _bytes = loader()->lookup(name()); + + if(!_bytes) + J3::noClassDefFoundError(this); + + status = LOADED; + } + unlock(); + } +} + +void J3Class::doResolve(J3Field* hiddenFields, size_t nbHiddenFields) { + load(); + lock(); + if(status < RESOLVED) { + if(loader()->vm()->options()->debugResolve) + fprintf(stderr, "Resolving: %ls\n", name()->cStr()); + + std::vector virtualBody; + status = RESOLVED; + readClassBytes(&virtualBody, hiddenFields, nbHiddenFields); + + if(super() == this) { + virtualBody[0] = loader()->vm()->typeJ3Object; + } else { + super()->resolve(); + virtualBody[0] = super()->llvmType()->getContainedType(0); + } + + llvm::cast(llvmType()->getContainedType(0))->setBody(virtualBody); + + _size = loader()->vm()->dataLayout()->getTypeAllocSize(llvmType()->getContainedType(0)); + + staticLayout._vt = J3VirtualTable::create(&staticLayout); + + _vt = J3VirtualTable::create(this); + + //fprintf(stderr, "virtual part of %ls: ", name()->cStr()); + //llvmType()->getContainedType(0)->dump(); + //fprintf(stderr, "\n"); + } + unlock(); +} + +#if 0 +void J3Class::addHiddenField(J3Field* f, uint32_t num) { + if(this == loader()->vm()->classClass) { + f->_access = J3Cst::ACC_PRIVATE; + f->_name = loader()->vm()->names()->get(L"vmData"); + f->_type = (sizeof(uintptr_t) == 8) ? loader()->vm()->typeLong : loader()->vm()->typeInteger; + f->_attributes = new (loader()->allocator(), 0) J3Attributes(0); + } +} +#endif + +void J3Class::readClassBytes(std::vector* virtualBody, J3Field* hiddenFields, uint32_t nbHiddenFields) { + J3Reader reader(_bytes); + + uint32_t magic = reader.readU4(); + if(magic != J3Cst::MAGIC) + J3::classFormatError(this, L"bad magic"); + + /* uint16_t minor = */reader.readU2(); + /* uint16_t major = */reader.readU2(); + + nbCtp = reader.readU2(); + + if(nbCtp < 1) + J3::classFormatError(this, L"zero-sized constant pool"); + + ctpTypes = (uint8_t*)loader()->allocator()->allocate(nbCtp * sizeof(uint8_t)); + ctpValues = (uint32_t*)loader()->allocator()->allocate(nbCtp * sizeof(uint32_t)); + ctpResolved = (void**)loader()->allocator()->allocate(nbCtp * sizeof(void*)); + + ctpTypes[0] = 0; + + for(uint32_t i=1; iname()->cStr()); + + uint16_t superIdx = reader.readU2(); + + _super = superIdx ? classAt(superIdx) : this; + + _nbInterfaces = reader.readU2(); + _interfaces = (J3Class**)loader()->allocator()->allocate(nbInterfaces()*sizeof(J3Class*)); + + for(size_t i=0; i_cl = this; + f->_access = hiddenFields[i].access(); + f->_name = hiddenFields[i].name(); + f->_type = hiddenFields[i].type(); + f->_attributes = new (loader()->allocator(), 0) J3Attributes(0); + } else { + f->_cl = this; + f->_access = reader.readU2(); + f->_name = nameAt(reader.readU2()); + f->_type = loader()->getType(this, nameAt(reader.readU2())); + f->_attributes = readAttributes(&reader); + } + + if(J3Cst::isStatic(f->access())) + nbStaticFields++; + else + nbVirtualFields++; + + switch(loader()->vm()->dataLayout()->getTypeSizeInBits(f->_type->llvmType())) { + case 1: pFields0[i0++] = f; break; + case 8: pFields1[i1++] = f; break; + case 16: pFields2[i2++] = f; break; + case 32: pFields4[i4++] = f; break; + case 64: pFields8[i8++] = f; break; + default: J3::internalError(L"should not happen"); + } + } + + staticLayout.fields = new(loader()->allocator()) J3Field[nbStaticFields]; + fields = new(loader()->allocator()) J3Field[nbVirtualFields]; + + std::vector staticBody; + + staticBody.push_back(loader()->vm()->typeJ3Object); + virtualBody->push_back(0); + + fillFields(&staticBody, virtualBody, pFields8, i8); + fillFields(&staticBody, virtualBody, pFields4, i4); + fillFields(&staticBody, virtualBody, pFields2, i2); + fillFields(&staticBody, virtualBody, pFields1, i1); + fillFields(&staticBody, virtualBody, pFields0, i0); + + staticLLVMType()->getContainedType(0); + + llvm::cast(staticLLVMType()->getContainedType(0))->setBody(staticBody); + + //fprintf(stderr, "static part of %ls: ", name()->cStr()); + //staticLayout.llvmType()->getContainedType(0)->dump(); + //fprintf(stderr, "\n"); + + size_t nbVirtualMethods = 0, nbStaticMethods = 0; + + n = reader.readU2(); + J3Method** methodsTmp = (J3Method**)alloca(sizeof(J3Method*)*n); + + for(size_t i=0; imethod(access, this, name, sign); + J3Attributes* attributes = readAttributes(&reader); + + method->postInitialise(access, attributes); + methodsTmp[i] = method; + + if(J3Cst::isStatic(access)) { + nbStaticMethods++; + method->setResolved(0); + } else + nbVirtualMethods++; + } + + staticLayout._methods = (J3Method**)loader()->allocator()->allocate(sizeof(J3Method*)*nbStaticMethods); + _methods = (J3Method**)loader()->allocator()->allocate(sizeof(J3Method*)*nbVirtualMethods); + + for(int i=0; iaccess()) ? &staticLayout : this; + layout->_methods[layout->_nbMethods++] = methodsTmp[i]; + } + + _attributes = readAttributes(&reader); +} + +void J3Class::fillFields(std::vector* staticBody, std::vector* virtualBody, J3Field** fields, size_t n) { + for(size_t i=0; iaccess())) { + //fprintf(stderr, " adding static field: %ls %ls::%ls\n", cur->type()->name()->cStr(), name()->cStr(), cur->name()->cStr()); + cur->_num = staticBody->size(); + layout = &staticLayout; + staticBody->push_back(cur->type()->llvmType()); + } else { + cur->_num = virtualBody->size(); + layout = this; + virtualBody->push_back(cur->type()->llvmType()); + } + layout->fields[layout->nbFields++] = *fields[i]; + + } +} + +J3Attributes* J3Class::readAttributes(J3Reader* reader) { + size_t nbAttributes = reader->readU2(); + J3Attributes* res = new (loader()->allocator(), nbAttributes) J3Attributes(nbAttributes); + + for(size_t i=0; iattribute(i)->_id = nameAt(reader->readU2()); + res->attribute(i)->_offset = reader->tell(); + reader->seek(reader->readU4(), reader->SeekCur); + } + + return res; +} + +uint8_t J3Class::getCtpType(uint16_t idx) { + check(idx); + return ctpTypes[idx]; +} + +void* J3Class::getCtpResolved(uint16_t idx) { + check(idx); + return ctpResolved[idx]; +} + +J3ObjectHandle* J3Class::stringAt(uint16_t idx) { + check(idx, J3Cst::CONSTANT_String); + J3ObjectHandle* res = (J3ObjectHandle*)ctpResolved[idx]; + if(!res) { + ctpResolved[idx] = res = loader()->vm()->nameToString(nameAt(ctpValues[idx])); + } + return (J3ObjectHandle*)res; +} + +float J3Class::floatAt(uint16_t idx) { + check(idx, J3Cst::CONSTANT_Float); + J3Value v; + v.valInteger = ctpValues[idx]; + return v.valFloat; +} + +double J3Class::doubleAt(uint16_t idx) { + check(idx, J3Cst::CONSTANT_Double); + J3Value v; + v.valLong = ((uint64_t)ctpValues[idx] << 32) + (uint64_t)ctpValues[idx+1]; + return v.valDouble; +} + +uint32_t J3Class::integerAt(uint16_t idx) { + check(idx, J3Cst::CONSTANT_Integer); + return ctpValues[idx]; +} + +uint64_t J3Class::longAt(uint16_t idx) { + check(idx, J3Cst::CONSTANT_Long); + return ((uint64_t)ctpValues[idx] << 32) + (uint64_t)ctpValues[idx+1]; +} + +J3Method* J3Class::methodAt(uint16_t idx, uint16_t access) { + check(idx, J3Cst::CONSTANT_Methodref); + J3Method* res = (J3Method*)ctpResolved[idx]; + + if(res) { + if((res->access() & J3Cst::ACC_STATIC) != (access & J3Cst::ACC_STATIC)) + J3::classFormatError(this, L"inconstitent use of virtual and static methods"); + return res; + } + + uint16_t ntIdx = ctpValues[idx] & 0xffff; + J3Class* cl = classAt(ctpValues[idx] >> 16); + + check(ntIdx, J3Cst::CONSTANT_NameAndType); + const vmkit::Name* name = nameAt(ctpValues[ntIdx] >> 16); + const vmkit::Name* sign = nameAt(ctpValues[ntIdx] & 0xffff); + + res = loader()->method(access, cl, name, sign); + + return res; +} + +J3Field* J3Class::fieldAt(uint16_t idx, uint16_t access) { + check(idx, J3Cst::CONSTANT_Fieldref); + J3Field* res = (J3Field*)ctpResolved[idx]; + + if(res) { + if((res->access() & J3Cst::ACC_STATIC) != (access & J3Cst::ACC_STATIC)) + J3::classFormatError(this, L"inconstitent use of virtual and static field"); + return res; + } + + uint16_t ntIdx = ctpValues[idx] & 0xffff; + J3Class* cl = classAt(ctpValues[idx] >> 16); + + check(ntIdx, J3Cst::CONSTANT_NameAndType); + const vmkit::Name* name = nameAt(ctpValues[ntIdx] >> 16); + const J3Type* type = loader()->getType(this, nameAt(ctpValues[ntIdx] & 0xffff)); + + res = J3Cst::isStatic(access) ? cl->findStaticField(name, type) : cl->findVirtualField(name, type); + + return res; +} + +J3Class* J3Class::classAt(uint16_t idx) { + check(idx, J3Cst::CONSTANT_Class); + J3Class* res = (J3Class*)ctpResolved[idx]; + + if(res) + return res; + + const vmkit::Name* name = nameAt(ctpValues[idx]); + if(name->cStr()[0] == J3Cst::ID_Array) + J3::internalError(L"implement me: classAt with array"); + else + res = loader()->getClass(name); + + ctpResolved[idx] = res; + + return res; +} + +const vmkit::Name* J3Class::nameAt(uint16_t idx) { + check(idx, J3Cst::CONSTANT_Utf8); + const vmkit::Name* res = (const vmkit::Name*)ctpResolved[idx]; + + if(res) + return res; + + J3Reader reader(_bytes); + + reader.seek(ctpValues[idx], reader.SeekSet); + + uint16_t len = reader.readU2(), i=0, n=0; + + res = loader()->vm()->names()->get((const char*)reader.pointer(), 0, len); + + ctpResolved[idx] = (void*)res; + + return res; +} + +void J3Class::check(uint16_t idx, uint32_t id) { + if(idx > nbCtp || (id != -1 && ctpTypes[idx] != id)) + J3::classFormatError(this, L"wrong constant pool type %d at index %d for %d", id, idx, nbCtp); +} + +void J3Class::createLLVMTypes() { + J3Mangler mangler(this); + + mangler.mangle("static_")->mangle(name()); + + staticLayout._llvmType = + llvm::PointerType::getUnqual(llvm::StructType::create(loader()->module()->getContext(), mangler.cStr())); + _llvmType = llvm::PointerType::getUnqual(llvm::StructType::create(loader()->module()->getContext(), mangler.cStr()+7)); + + mangler.mangle("_2"); + + _nativeNameLength = mangler.length() - 6; + _nativeName = (char*)loader()->allocator()->allocate(mangler.length() + 1); + + _nativeName[0] = 'L'; + memcpy(_nativeName + 1, mangler.cStr()+7, mangler.length()); +} + +llvm::Type* J3Class::staticLLVMType() { + llvm::Type* res = staticLayout._llvmType; + + if(!res) { + createLLVMTypes(); + res = staticLayout._llvmType; + } + + return res; +} + +llvm::Type* J3Class::virtualLLVMType() { + llvm::Type* res = _llvmType; + + if(!res) { + createLLVMTypes(); + res = _llvmType; + } + + return res; +} + +llvm::Type* J3Class::llvmType() { + return virtualLLVMType(); +} + +void J3Field::dump() { + printf("Field: %ls %ls::%ls (%d)\n", type()->name()->cStr(), cl()->name()->cStr(), name()->cStr(), access()); +} + + +J3Attribute* J3Attributes::attribute(size_t n) { + if(n >= _nbAttributes) + J3::internalError(L"should not happen"); + return _attributes + n; +} + +J3Attribute* J3Attributes::lookup(const vmkit::Name* id) { + for(size_t i=0; i<_nbAttributes; i++) { + if(_attributes[i].id() == id) + return _attributes+i; + } + + return 0; +} + +/* + * ------------ J3ArrayClass ------------ + */ +J3ArrayClass::J3ArrayClass(J3ClassLoader* loader, J3Type* component, const vmkit::Name* name) : J3ObjectType(loader, name) { + _component = component; + + if(!name) { + const vmkit::Name* compName = component->name(); + uint32_t len = compName->length(); + wchar_t buf[len + 16]; + uint32_t pos = 0; + + //printf(" build array of %ls\n", component->name()->cStr()); + buf[pos++] = J3Cst::ID_Array; + + if(component->isClass()) + buf[pos++] = J3Cst::ID_Classname; + memcpy(buf+pos, compName->cStr(), len * sizeof(wchar_t)); + pos += len; + if(component->isClass()) + buf[pos++] = J3Cst::ID_End; + buf[pos] = 0; + + _name = loader->vm()->names()->get(buf); + } +} + +void J3ArrayClass::doResolve(J3Field* hiddenFields, size_t nbHiddenFields) { + lock(); + if(status < RESOLVED) { + status = RESOLVED; + J3Class* objectClass = loader()->vm()->objectClass; + objectClass->resolve(); + _vt = J3VirtualTable::create(this); + } + unlock(); +} + +void J3ArrayClass::doInitialise() { + resolve(); + status = INITED; +} + +llvm::GlobalValue* J3ArrayClass::llvmDescriptor(llvm::Module* module) { + if(!_nomcjitDescriptor) { + _nomcjitDescriptor = llvm::cast(module->getOrInsertGlobal(nativeName(), loader()->vm()->typeJ3ArrayClass)); + loader()->vm()->ee()->updateGlobalMapping(_nomcjitDescriptor, this); + } + return _nomcjitDescriptor; +} + +llvm::Type* J3ArrayClass::llvmType() { + if(!_llvmType) { + llvm::Type* body[2] = { + loader()->vm()->typeJ3ArrayObject, + llvm::ArrayType::get(component()->llvmType(), 0) /* has to be called first */ + }; + uint32_t len = component()->nativeNameLength(); + + _nativeNameLength = len + 2; + _nativeName = (char*)loader()->allocator()->allocate(_nativeNameLength + 1); + _nativeName[0] = '_'; + _nativeName[1] = '3'; + memcpy(_nativeName+2, component()->nativeName(), len); + _nativeName[_nativeNameLength] = 0; + + _llvmType = llvm::PointerType::getUnqual(llvm::StructType::create(loader()->module()->getContext(), + body, + _nativeName)); + } + return _llvmType; +} + +/* + * ------------ J3Primitive ------------ + */ +J3Primitive::J3Primitive(J3ClassLoader* loader, char id, llvm::Type* type) : J3Type(loader, loader->vm()->names()->get(id)) { + _llvmType = type; + _nativeName = (char*)loader->allocator()->allocate(2); + _nativeName[0] = id; + _nativeName[1] = 0; + _nativeNameLength = 1; + _vt = J3VirtualTable::create(this); +} Added: vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,288 @@ +#include +#include + +#include "llvm/PassManager.h" +#include "llvm/Linker.h" + +#include "llvm/ExecutionEngine/JIT.h" +#include "llvm/ExecutionEngine/ExecutionEngine.h" + +#include "llvm/IR/Module.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/DerivedTypes.h" +#include "llvm/DIBuilder.h" + +#include "vmkit/allocator.h" + +#include "j3/j3classloader.h" +#include "j3/j3.h" +#include "j3/j3reader.h" +#include "j3/j3zip.h" +#include "j3/j3class.h" +#include "j3/j3constants.h" +#include "j3/j3method.h" +#include "j3/j3lib.h" +#include "j3/j3mangler.h" + +using namespace j3; + +J3ClassLoader::J3MethodLess J3ClassLoader::j3MethodLess; + +void J3ClassLoader::destroy(J3ClassLoader* loader) { + vmkit::BumpAllocator::destroy(loader->allocator()); +} + +void* J3ClassLoader::operator new(size_t n, vmkit::BumpAllocator* allocator) { + return allocator->allocate(n); +} + +J3ClassLoader::J3ClassLoader(J3* v, J3ObjectHandle* javaClassLoader, vmkit::BumpAllocator* allocator) + : _fixedPoint(allocator), + classes(vmkit::Name::less, allocator), + types(vmkit::Name::less, allocator), + methodTypes(vmkit::Name::less, allocator), + methods(j3MethodLess, allocator), + nativeLibraries(allocator) { + _allocator = allocator; + + _javaClassLoader = javaClassLoader; + + // pthread_mutexattr_t attr; + // pthread_mutexattr_init(&attr); + // pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + pthread_mutex_init(&_mutex, 0);//&attr); + + _vm = v; + + _module = new llvm::Module("j3", vm()->self()->getContext()); + _dbgBuilder = new llvm::DIBuilder(*module()); + _pm = vm()->preparePM(module()); + + vm()->ee()->addModule(module()); +} + +void* J3ClassLoader::lookupNativeFunctionPointer(J3Method* method, const char* symbol) { + for(std::vector::size_type i=0; i!=nativeLibraries.size(); i++) { + void* fnPtr = dlsym(nativeLibraries[i], symbol); + if(fnPtr) + return fnPtr; + } + + return 0; +} + +J3Class* J3ClassLoader::getClass(const vmkit::Name* name) { + lock(); + J3Class* res = classes[name]; + if(!res) + classes[name] = res = new(allocator()) J3Class(this, name); + unlock(); + return res; +} + +J3ClassBytes* J3ClassLoader::lookup(const vmkit::Name* name) { + J3::internalError(L"should not happen"); +} + +void J3ClassLoader::wrongType(J3Class* from, const vmkit::Name* type) { + J3::classFormatError(from, L"wrong type: %ls", type->cStr()); +} + +J3Type* J3ClassLoader::getTypeInternal(J3Class* from, const vmkit::Name* typeName, uint32_t start, uint32_t* pend) { + J3Type* res = 0; + const wchar_t* type = typeName->cStr(); + uint32_t len = typeName->length(); + uint32_t pos = start; + uint32_t prof = 0; + + while(!res) { + if(pos >= len) + wrongType(from, typeName); + + switch(type[pos]) { + case J3Cst::ID_Array: prof++; pos++; break; + case J3Cst::ID_Void: res = vm()->typeVoid; pos++; break; + case J3Cst::ID_Byte: res = vm()->typeByte; pos++; break; + case J3Cst::ID_Char: res = vm()->typeChar; pos++; break; + case J3Cst::ID_Double: res = vm()->typeDouble; pos++; break; + case J3Cst::ID_Float: res = vm()->typeFloat; pos++; break; + case J3Cst::ID_Integer: res = vm()->typeInteger; pos++; break; + case J3Cst::ID_Long: res = vm()->typeLong; pos++; break; + case J3Cst::ID_Short: res = vm()->typeShort; pos++; break; + case J3Cst::ID_Boolean: res = vm()->typeBoolean; pos++; break; + case J3Cst::ID_Classname: + { + uint32_t start = ++pos; + wchar_t buf[len + 1 - start], c; + + memset(buf, 0, len + 1 - pos); + + for(; pos < len && (c = type[pos]) != J3Cst::ID_End; pos++) + buf[pos - start] = c; + + if(type[pos] != J3Cst::ID_End) + wrongType(from, typeName); + + buf[pos++ - start] = 0; + + res = getClass(vm()->names()->get(buf)); + } + break; + case J3Cst::ID_Left: + case J3Cst::ID_Right: + default: + wrongType(from, typeName); + } + } + + *pend = pos; + + if(prof) + res = res->getArray(prof, start ? 0 : typeName); + + return res; +} + +J3Type* J3ClassLoader::getType(J3Class* from, const vmkit::Name* type) { + lock(); + J3Type* res = types[type]; + unlock(); + + if(!res) { + uint32_t end; + res = getTypeInternal(from, type, 0, &end); + + if(end != type->length()) + wrongType(from, type); + + //printf("Analyse %ls => %ls\n", type->cStr(), res->name()->cStr()); + + lock(); + types[type] = res; + unlock(); + } + + return res; +} + +J3MethodType* J3ClassLoader::getMethodType(J3Class* from, const vmkit::Name* sign) { + lock(); + J3MethodType* res = methodTypes[sign]; + unlock(); + + if(!res) { + J3Type* args[sign->length()]; + uint32_t nbArgs = 0; + uint32_t cur = 1; + + if(sign->cStr()[0] != J3Cst::ID_Left) + wrongType(from, sign); + + while(sign->cStr()[cur] != J3Cst::ID_Right) { + args[nbArgs++] = getTypeInternal(from, sign, cur, &cur); + } + args[nbArgs++] = getTypeInternal(from, sign, cur+1, &cur); + if(cur != sign->length()) + wrongType(from, sign); + + lock(); + J3MethodType* tmp = methodTypes[sign]; + if(tmp) + res = tmp; + else + res = new(allocator(), nbArgs - 1) J3MethodType(args, nbArgs); + unlock(); + } + + return res; +} + +J3Method* J3ClassLoader::method(uint16_t access, J3Class* cl, const vmkit::Name* name, const vmkit::Name* sign) { + J3Method method(access, cl, name, sign), *res; + + lock(); + std::map::iterator it = methods.find(&method); + + if(it == methods.end()) { + res = J3Method::newMethod(allocator(), access, cl, name, sign); + methods[res] = res; + } else { + res = it->second; + } + unlock(); + + return res; +} + +J3Method* J3ClassLoader::method(uint16_t access, const vmkit::Name* clName, const vmkit::Name* name, const vmkit::Name* sign) { + return method(access, getClass(clName), name, sign); +} + +J3Method* J3ClassLoader::method(uint16_t access, const wchar_t* clName, const wchar_t* name, const wchar_t* sign) { + vmkit::Names* names = vm()->names(); + return method(access, names->get(clName), names->get(name), names->get(sign)); +} + +bool J3ClassLoader::J3MethodLess::operator()(j3::J3Method const* lhs, j3::J3Method const* rhs) const { + return lhs->name() < rhs->name() + || (lhs->name() == rhs->name() + && (lhs->sign() < rhs->sign() + || (lhs->sign() == rhs->sign() + && (lhs->cl() < rhs->cl() + || (lhs->cl() == rhs->cl() + && ((lhs->access() & J3Cst::ACC_STATIC) < (rhs->access() & J3Cst::ACC_STATIC))))))); +} + +J3InitialClassLoader::J3InitialClassLoader(J3* v, const char* rtjar, vmkit::BumpAllocator* _alloc) + : J3ClassLoader(v, 0, _alloc) { + llvm::llvm_start_multithreaded(); + + const char** archives = J3Lib::systemClassesArchives(); + J3ClassBytes* bytes = J3Reader::openFile(allocator(), archives[0]); + + //makeLLVMFunctions_j3(); + + if (bytes) { + archive = new(allocator()) J3ZipArchive(bytes, allocator()); + if(!archive) { + J3::internalError(L"unable to find system archive"); + } + } else + J3::internalError(L"unable to find system archive"); + + if(J3Lib::loadSystemLibraries(&nativeLibraries) == -1) + J3::internalError(L"unable to find java library"); +} + +J3ClassBytes* J3InitialClassLoader::lookup(const vmkit::Name* name) { + char tmp[name->length()+16]; + + //printf("L: %ls\n", name->cStr()); + for(int i=0; ilength(); i++) { + char c = name->cStr()[i] & 0xff; + tmp[i] = c == '.' ? '/' : c; + } + strcpy(tmp + name->length(), ".class"); + J3ZipFile* file = archive->getFile(tmp); + + if(file) { + J3ClassBytes* res = new(allocator(), file->ucsize) J3ClassBytes(file->ucsize); + + if(archive->readFile(res, file)) + return res; + } + + return 0; +} + +bool char_ptr_less::operator()(const char* lhs, const char* rhs) const { + //printf("Compare: %ls - %ls - %d\n", lhs, rhs, wcscmp(lhs, rhs)); + return strcmp(lhs, rhs) < 0; +} + +void J3InitialClassLoader::registerCMangling(const char* mangled, const char* demangled) { + _cmangled[demangled] = mangled; +} + + + Added: vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3codegen.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,1578 @@ +#include + +#include "j3/j3.h" +#include "j3/j3thread.h" +#include "j3/j3reader.h" +#include "j3/j3codegen.h" +#include "j3/j3class.h" +#include "j3/j3constants.h" +#include "j3/j3classloader.h" +#include "j3/j3method.h" +#include "j3/j3mangler.h" +#include "j3/j3jni.h" +#include "j3/j3object.h" + +#include "llvm/IR/Function.h" +#include "llvm/IR/Module.h" +#include "llvm/IR/Argument.h" +#include "llvm/DebugInfo.h" +#include "llvm/DIBuilder.h" + +using namespace j3; + +#define _onEndPoint() ({ if(onEndPoint()) return; }) + +void J3ExceptionEntry::dump() { + fprintf(stderr, " exception entry:\n"); + fprintf(stderr, " start_pc: %u\n", startPC); + fprintf(stderr, " end_pc: %u\n", endPC); + fprintf(stderr, " handler_pc: %u\n", handlerPC); + fprintf(stderr, " catchType: %u\n", catchType); +} + +J3CodeGen::J3CodeGen(vmkit::BumpAllocator* _allocator, J3Method* m) { + allocator = _allocator; + + method = m; + cl = method->cl(); + methodType = method->methodType(); + loader = cl->loader(); + module = loader->module(); + vm = loader->vm(); + + llvmFunction = method->llvmFunction(0, module); + llvmFunction->setGC("vmkit"); + + bbCheckCastFailed = 0; + bbNullCheckFailed = 0; + topPendingBranchs = 0; + isWide = 0; + + funcJ3MethodIndex = vm->introspectFunction(module, "j3::J3Method::index()"); + funcJ3TypeVT = vm->introspectFunction(module, "j3::J3Type::vt()"); + funcJ3TypeInitialise = vm->introspectFunction(module, "j3::J3Type::initialise()"); + funcJ3ClassSize = vm->introspectFunction(module, "j3::J3Class::size()"); + funcJ3ClassStaticInstance = vm->introspectFunction(module, "j3::J3Class::staticInstance()"); + funcJ3ClassStringAt = vm->introspectFunction(module, "j3::J3Class::stringAt(unsigned short)"); + funcJ3ObjectTypeJavaClass = vm->introspectFunction(module, "j3::J3ObjectType::javaClass()"); + funcJniEnv = vm->introspectFunction(module, "j3::J3::jniEnv()"); + funcJ3ObjectAllocate = vm->introspectFunction(module, "j3::J3Object::allocate(j3::J3VirtualTable*, unsigned long)"); + + funcThrowException = vm->introspectFunction(module, "vmkit::VMKit::throwException(void*)"); + funcClassCastException = vm->introspectFunction(module, "j3::J3::classCastException()"); + funcNullPointerException = vm->introspectFunction(module, "j3::J3::nullPointerException()"); + + funcJ3ThreadPushHandle = vm->introspectFunction(module, "j3::J3Thread::push(j3::J3ObjectHandle*)"); + funcJ3ThreadPush = vm->introspectFunction(module, "j3::J3Thread::push(j3::J3Object*)"); + funcJ3ThreadTell = vm->introspectFunction(module, "j3::J3Thread::tell()"); + funcJ3ThreadRestore = vm->introspectFunction(module, "j3::J3Thread::restore(j3::J3ObjectHandle*)"); + funcJ3ThreadGet = vm->introspectFunction(module, "j3::J3Thread::get()"); + funcEchoDebugEnter = vm->introspectFunction(module, "j3::J3CodeGen::echoDebugEnter(unsigned int, char const*, ...)"); + funcEchoDebugExecute = vm->introspectFunction(module, "j3::J3CodeGen::echoDebugExecute(unsigned int, char const*, ...)"); + + funcSlowIsAssignableTo = vm->introspectFunction(module, "j3::J3VirtualTable::slowIsAssignableTo(j3::J3VirtualTable*)"); + funcFastIsAssignableToPrimaryChecker = + vm->introspectFunction(module, "j3::J3VirtualTable::fastIsAssignableToPrimaryChecker(j3::J3VirtualTable*, unsigned int)"); + funcFastIsAssignableToNonPrimaryChecker = + vm->introspectFunction(module, "j3::J3VirtualTable::fastIsAssignableToNonPrimaryChecker(j3::J3VirtualTable*)"); + + funcGXXPersonality = vm->introspectFunction(module, "__gxx_personality_v0"); + funcCXABeginCatch = vm->introspectFunction(module, "__cxa_begin_catch"); + funcCXAEndCatch = vm->introspectFunction(module, "__cxa_end_catch"); + + gvTypeInfo = vm->introspectGlobalValue(module, "typeinfo for void*"); + + gcRoot = vm->getGCRoot(module); + + ziTry = + (llvm::Function*)module->getOrInsertFunction("vmkit.try", + llvm::FunctionType::get(llvm::Type::getVoidTy(module->getContext()), 0)); +} + +J3CodeGen::~J3CodeGen() { +} + +void* J3CodeGen::operator new(size_t n, vmkit::BumpAllocator* _allocator) { + return _allocator->allocate(n); +} + +void J3CodeGen::operator delete(void* ptr) { +} + +J3CodeGen* J3CodeGen::create(J3Method* method) { + vmkit::BumpAllocator* allocator = vmkit::BumpAllocator::create(); + return new(allocator) J3CodeGen(allocator, method); +} + +void J3CodeGen::destroy(J3CodeGen* codeGen) { + vmkit::BumpAllocator* allocator = codeGen->allocator; + delete codeGen; + vmkit::BumpAllocator::destroy(allocator); +} + +uint32_t J3CodeGen::wideReadU1() { + if(isWide) { + isWide = 0; + return codeReader->readU2(); + } else + return codeReader->readU1(); +} + +uint32_t J3CodeGen::wideReadS1() { + if(isWide) { + isWide = 0; + return codeReader->readS2(); + } else + return codeReader->readS1(); +} + +llvm::Value* J3CodeGen::flatten(llvm::Value* v, J3Type* type) { + if(type == vm->typeInteger || type == vm->typeLong || type == vm->typeFloat || type == vm->typeDouble) + return v; + else if(type->llvmType()->isPointerTy()) { + if(v->getType() == vm->typeJ3ObjectPtr) + return v; + else + return builder->CreateBitCast(v, vm->typeJ3ObjectPtr); + } else if(type == vm->typeBoolean || type == vm->typeByte || type == vm->typeShort) + return builder->CreateSExt(v, vm->typeInteger->llvmType()); + else if(type == vm->typeChar) + return builder->CreateZExt(v, vm->typeInteger->llvmType()); + else + J3::internalError(L"should not happen"); +} + +llvm::Value* J3CodeGen::unflatten(llvm::Value* v, J3Type* type) { + if(type == vm->typeInteger || type == vm->typeLong || type == vm->typeFloat || type == vm->typeDouble) + return v; + else if(type->llvmType()->isPointerTy() && v->getType() != type->llvmType()) + return builder->CreateBitCast(v, type->llvmType()); + else if(type == vm->typeBoolean || type == vm->typeByte || type == vm->typeShort) + return builder->CreateSExtOrTrunc(v, type->llvmType()); + else if(type == vm->typeChar) + return builder->CreateZExtOrTrunc(v, type->llvmType()); + else { + type->dump(); + J3::internalError(L"should not happen"); + } +} + +void J3CodeGen::initialiseJ3Type(J3Type* cl) { + if(!cl->isInitialised()) + builder->CreateCall(funcJ3TypeInitialise, builder->CreateBitCast(cl->llvmDescriptor(module), vm->typeJ3TypePtr)); +} + +llvm::Value* J3CodeGen::javaClass(J3ObjectType* type) { + return builder->CreateCall(funcJ3ObjectTypeJavaClass, + builder->CreateBitCast(type->llvmDescriptor(module), vm->typeJ3ObjectTypePtr)); +} + +llvm::Value* J3CodeGen::handleToObject(llvm::Value* obj) { + llvm::Value* gep[] = { builder->getInt32(0), builder->getInt32(J3ObjectHandle::gepObj) }; + return builder->CreateLoad(builder->CreateGEP(obj, gep)); +} + +llvm::Value* J3CodeGen::staticInstance(J3Class* cl) { + initialiseJ3Type(cl); + return builder->CreateBitCast(handleToObject(builder->CreateCall(funcJ3ClassStaticInstance, + cl->llvmDescriptor(module))), + cl->staticLLVMType()); +} + +llvm::Value* J3CodeGen::vt(llvm::Value* obj) { + llvm::Value* gepVT[] = { builder->getInt32(0), + builder->getInt32(J3Object::gepVT) }; + llvm::Instruction* res = builder->CreateLoad(builder->CreateGEP(obj, gepVT)); + res->setDebugLoc(llvm::DebugLoc::get(javaPC, 1, dbgInfo)); + return res; +} + +llvm::Value* J3CodeGen::vt(J3Type* type) { + return builder->CreateCall(funcJ3TypeVT, builder->CreateBitCast(type->llvmDescriptor(module), vm->typeJ3TypePtr)); +} + +llvm::Value* J3CodeGen::nullCheck(llvm::Value* obj) { + if(exceptionNodes[curExceptionNode]->landingPad) { + llvm::BasicBlock* succeed = llvm::BasicBlock::Create(llvmFunction->getContext(), "nullcheck-succeed", llvmFunction); + + if(!bbNullCheckFailed) { + bbNullCheckFailed = llvm::BasicBlock::Create(llvmFunction->getContext(), "nullcheck-failed", llvmFunction); + builder->SetInsertPoint(bbNullCheckFailed); + builder->CreateInvoke(funcNullPointerException, bbRet, exceptionNodes[curExceptionNode]->landingPad); + builder->SetInsertPoint(bb); + } + + builder->CreateCondBr(builder->CreateIsNotNull(obj), succeed, bbNullCheckFailed); + + bb = succeed; + builder->SetInsertPoint(bb); + } + + return obj; +} + +#define nyi() J3::internalError(L"not yet implemented: '%s' (%d)", J3Cst::opcodeNames[bc], bc); + +void J3CodeGen::invoke(J3Method* target, llvm::Value* func) { + J3MethodType* type = target->methodType(cl); + std::vector args; + + for(uint32_t i=0; inbIns(); i++) + args.push_back(unflatten(stack.top(type->nbIns() - i - 1), type->ins(i))); + + stack.drop(type->nbIns()); + + llvm::Value* res; + + if(exceptionNodes[curExceptionNode]->landingPad) { + llvm::BasicBlock* after = llvm::BasicBlock::Create(llvmFunction->getContext(), "invoke-after", llvmFunction); + res = builder->CreateInvoke(func, after, exceptionNodes[curExceptionNode]->landingPad, args); + bb = after; + builder->SetInsertPoint(bb); + } else + res = builder->CreateCall(func, args); + + if(type->out() != vm->typeVoid) { + stack.push(flatten(res, type->out())); + } +} + +void J3CodeGen::invokeVirtual(uint32_t idx) { + J3Method* target = cl->methodAt(idx, 0); + J3MethodType* type = target->methodType(cl); + llvm::Value* funcEntry; + + if(target->isResolved()) + funcEntry = builder->getInt32(target->index()); + else + funcEntry = builder->CreateCall(funcJ3MethodIndex, target->llvmDescriptor(module)); + + llvm::Value* obj = nullCheck(stack.top(type->nbIns() - 1)); + llvm::Value* gepFunc[] = { builder->getInt32(0), + builder->getInt32(J3VirtualTable::gepVirtualMethods), + funcEntry }; + llvm::Value* func = builder->CreateBitCast(builder->CreateLoad(builder->CreateGEP(vt(obj), gepFunc)), + type->llvmType()->getPointerTo()); + + invoke(target, func); +} + +void J3CodeGen::invokeStatic(uint32_t idx) { + J3Method* target = cl->methodAt(idx, J3Cst::ACC_STATIC); + initialiseJ3Type(target->cl()); + invoke(target, target->llvmFunction(1, module, cl)); +} + +void J3CodeGen::invokeSpecial(uint32_t idx) { + J3Method* target = cl->methodAt(idx, 0); + invoke(target, target->llvmFunction(1, module, cl)); +} + +void J3CodeGen::get(llvm::Value* src, J3Field* f) { + llvm::Value* gep[2] = { builder->getInt32(0), builder->getInt32(f->num()) }; + llvm::Value* res = flatten(builder->CreateLoad(builder->CreateGEP(src, gep)), f->type()); + stack.push(res); +} + +void J3CodeGen::getField(uint32_t idx) { + llvm::Value* obj = stack.pop(); + J3Field* f = cl->fieldAt(idx, 0); + get(unflatten(nullCheck(obj), f->cl()), f); +} + +void J3CodeGen::getStatic(uint32_t idx) { + J3Field* f = cl->fieldAt(idx, J3Cst::ACC_STATIC); + get(staticInstance(f->cl()), f); +} + +void J3CodeGen::put(llvm::Value* dest, llvm::Value* val, J3Field* f) { + llvm::Value* gep[2] = { builder->getInt32(0), builder->getInt32(f->num()) }; + builder->CreateStore(unflatten(val, f->type()), builder->CreateGEP(dest, gep)); +} + +void J3CodeGen::putStatic(uint32_t idx) { + J3Field* f = cl->fieldAt(idx, J3Cst::ACC_STATIC); + put(staticInstance(f->cl()), stack.pop(), f); +} + +void J3CodeGen::putField(uint32_t idx) { + J3Field* f = cl->fieldAt(idx, 0); + llvm::Value* val = stack.pop(); + llvm::Value* obj = nullCheck(stack.pop()); + put(unflatten(obj, f->cl()), val, f); +} + +void J3CodeGen::arrayBoundCheck(llvm::Value* obj, llvm::Value* idx) { +} + +llvm::Value* J3CodeGen::arrayContent(J3Type* cType, llvm::Value* array, llvm::Value* idx) { + array = builder->CreateBitCast(array, vm->typeJ3ArrayObjectPtr); + return builder->CreateGEP(builder->CreateBitCast(builder->CreateGEP(array, builder->getInt32(1)), cType->llvmType()->getPointerTo()), + idx); +} + +void J3CodeGen::arrayStore(J3Type* cType) { + llvm::Value* val = stack.pop(); + llvm::Value* idx = stack.pop(); + llvm::Value* array = stack.pop(); + + arrayBoundCheck(array, idx); + builder->CreateStore(unflatten(val, cType), arrayContent(cType, array, idx)); +} + +void J3CodeGen::arrayLoad(J3Type* cType) { + llvm::Value* idx = stack.pop(); + llvm::Value* array = stack.pop(); + + arrayBoundCheck(array, idx); + stack.push(flatten(builder->CreateLoad(arrayContent(cType, array, idx)), cType)); +} + +llvm::Value* J3CodeGen::arrayLengthPtr(llvm::Value* obj) { + llvm::Value* gep[2] = { builder->getInt32(0), builder->getInt32(J3ArrayObject::gepLength) }; + return builder->CreateGEP(builder->CreateBitCast(obj, vm->typeJ3ArrayObjectPtr), gep); +} + +llvm::Value* J3CodeGen::arrayLength(llvm::Value* obj) { + return builder->CreateLoad(arrayLengthPtr(obj)); +} + +void J3CodeGen::newArray(uint8_t atype) { + J3Primitive* prim = 0; + + switch(atype) { + case J3Cst::T_BOOLEAN: prim = vm->typeBoolean; break; + case J3Cst::T_CHAR: prim = vm->typeChar; break; + case J3Cst::T_FLOAT: prim = vm->typeFloat; break; + case J3Cst::T_DOUBLE: prim = vm->typeDouble; break; + case J3Cst::T_BYTE: prim = vm->typeByte; break; + case J3Cst::T_SHORT: prim = vm->typeShort; break; + case J3Cst::T_INT: prim = vm->typeInteger; break; + case J3Cst::T_LONG: prim = vm->typeLong; break; + default: + J3::classFormatError(cl, L"wrong atype: %d\n", atype); + } + + newArray(prim->getArray()); +} + +void J3CodeGen::newArray(J3ArrayClass* array) { + initialiseJ3Type(array); + llvm::DataLayout* layout = vm->dataLayout(); + llvm::Value* length = stack.pop(); + llvm::Value* arraySize = + builder->CreateAdd(builder->getInt64(layout->getTypeAllocSize(array->llvmType()->getContainedType(0))), + builder->CreateMul(builder->getInt64(layout->getTypeAllocSize(array->component()->llvmType())), + builder->CreateZExtOrBitCast(length, builder->getInt64Ty()))); + + llvm::Value* res = builder->CreateCall2(funcJ3ObjectAllocate, vt(array), arraySize); + + builder->CreateStore(length, arrayLengthPtr(res)); + + stack.push(res); +} + +void J3CodeGen::newObject(J3Class* cl) { + initialiseJ3Type(cl); + + llvm::Value* size; + + if(!cl->isResolved()) { + size = builder->CreateCall(funcJ3ClassSize, cl->llvmDescriptor(module)); + } else { + size = builder->getInt64(cl->size()); + } + + llvm::Value* res = builder->CreateCall2(funcJ3ObjectAllocate, vt(cl), size); + + stack.push(res); +} + +llvm::Value* J3CodeGen::isAssignableTo(llvm::Value* obj, J3Type* type) { + llvm::Value* vtType = vt(type); + llvm::Value* vtObj = vt(obj); + if(type->isResolved()) { + if(type->vt()->isPrimaryChecker()) + return builder->CreateCall3(funcFastIsAssignableToPrimaryChecker, + vtObj, + vtType, + builder->getInt32(type->vt()->offset())); + else + return builder->CreateCall2(funcFastIsAssignableToNonPrimaryChecker, vtObj, vtType); + } else + return builder->CreateCall2(funcSlowIsAssignableTo, vtObj, vtType); +} + +void J3CodeGen::instanceof(llvm::Value* obj, J3Type* type) { + llvm::BasicBlock* after = forwardBranch("instanceof-after", codeReader->tell(), 0, 0); + llvm::BasicBlock* ok = llvm::BasicBlock::Create(llvmFunction->getContext(), "instanceof-ok", llvmFunction); + llvm::BasicBlock* test = llvm::BasicBlock::Create(llvmFunction->getContext(), "instanceof", llvmFunction); + + builder->CreateCondBr(builder->CreateIsNull(obj), ok, test); + + builder->SetInsertPoint(ok); + stack.push(builder->getInt32(1)); + builder->CreateBr(after); + + stack.drop(1); + builder->SetInsertPoint(test); + stack.push(builder->CreateZExt(isAssignableTo(obj, type), builder->getInt32Ty())); + builder->CreateBr(after); +} + +void J3CodeGen::checkCast(llvm::Value* obj, J3Type* type) { + llvm::BasicBlock* succeed = forwardBranch("checkcast-succeed", codeReader->tell(), 0, 0); + llvm::BasicBlock* test = llvm::BasicBlock::Create(llvmFunction->getContext(), "checkcast", llvmFunction); + + builder->CreateCondBr(builder->CreateIsNull(obj), succeed, test); + + if(!bbCheckCastFailed) { + bbCheckCastFailed = llvm::BasicBlock::Create(llvmFunction->getContext(), "checkcast-failed", llvmFunction); + builder->SetInsertPoint(bbCheckCastFailed); + builder->CreateCall(funcClassCastException); + builder->CreateBr(bbRet); + } + + builder->SetInsertPoint(test); + + llvm::Value* res = isAssignableTo(obj, type); + builder->CreateCondBr(res, succeed, bbCheckCastFailed); + + builder->SetInsertPoint(bb); +} + +void J3CodeGen::floatToInteger(J3Type* ftype, J3Type* itype) { + llvm::Value* min = llvm::ConstantFP::get(ftype->llvmType(), + llvm::APInt::getSignedMinValue(itype->llvmType()->getPrimitiveSizeInBits()).getSExtValue()); + llvm::Value* max = llvm::ConstantFP::get(ftype->llvmType(), + llvm::APInt::getSignedMaxValue(itype->llvmType()->getPrimitiveSizeInBits()).getZExtValue()); + llvm::Value* v = stack.pop(); + + llvm::Value* c = builder->CreateFCmpONE(v, v); + v = builder->CreateSelect(c, llvm::ConstantFP::get(ftype->llvmType(), 0), v); /* nan => 0 */ + + c = builder->CreateFCmpOGE(v, max); + v = builder->CreateSelect(c, max, v); + c = builder->CreateFCmpOLE(v, min); + v = builder->CreateSelect(c, min, v); + + stack.push(builder->CreateFPToSI(v, itype->llvmType())); +} + +void J3CodeGen::compareLong() { + llvm::Value* val2 = stack.pop(); + llvm::Value* val1 = stack.pop(); + llvm::Value* one = builder->getInt32(1); + llvm::Value* zero = builder->getInt32(0); + llvm::Value* minus = builder->getInt32(-1); + + llvm::Value* c = builder->CreateICmpSGT(val1, val2); + llvm::Value* r = builder->CreateSelect(c, one, zero); + c = builder->CreateICmpSLT(val1, val2); + r = builder->CreateSelect(c, minus, r); + + stack.push(r); +} + +void J3CodeGen::compareFP(bool isL) { + llvm::Value* val2 = stack.pop(); + llvm::Value* val1 = stack.pop(); + llvm::Value* one = builder->getInt32(1); + llvm::Value* zero = builder->getInt32(0); + llvm::Value* minus = builder->getInt32(-1); + + llvm::Value* c = builder->CreateFCmpUGT(val1, val2); + llvm::Value* r = builder->CreateSelect(c, one, zero); + c = builder->CreateFCmpULT(val1, val2); + r = builder->CreateSelect(c, minus, r); + c = builder->CreateFCmpUNO(val1, val2); + r = builder->CreateSelect(c, isL ? one : minus, r); + + stack.push(r); +} + +void J3CodeGen::ldc(uint32_t idx) { + llvm::Value* res; + + switch(cl->getCtpType(idx)) { + case J3Cst::CONSTANT_Long: res = builder->getInt64(cl->longAt(idx)); break; + case J3Cst::CONSTANT_Integer: res = builder->getInt32(cl->integerAt(idx)); break; + case J3Cst::CONSTANT_Float: res = llvm::ConstantFP::get(builder->getFloatTy(), cl->floatAt(idx)); break; + case J3Cst::CONSTANT_Double: res = llvm::ConstantFP::get(builder->getDoubleTy(), cl->doubleAt(idx)); break; + case J3Cst::CONSTANT_Class: res = handleToObject(javaClass(cl->classAt(idx))); break; + case J3Cst::CONSTANT_String: + res = handleToObject(builder->CreateCall2(funcJ3ClassStringAt, cl->llvmDescriptor(module), builder->getInt16(idx))); + break; + default: + J3::classFormatError(cl, L"wrong ldc type: %d\n", cl->getCtpType(idx)); + } + stack.push(res); +} + +void J3CodeGen::condBr(llvm::Value* op) { + builder->CreateCondBr(op, + forwardBranch("if-true", javaPC + codeReader->readS2(), 1, 1), + forwardBranch("if-false", codeReader->tell(), 0, 0)); +} + +llvm::BasicBlock* J3CodeGen::forwardBranch(const char* id, uint32_t pc, bool doAlloc, bool doPush) { + llvm::BasicBlock* res = opInfos[pc].bb; + + if(res) + return res; + + if(opInfos[pc].insn) { + //printf("split at %d (%s)\n", pc, id); + llvm::Instruction* insn = opInfos[pc].insn; + if(!insn) + J3::classFormatError(cl, L"jmp: not to an instruction"); + insn = insn->getNextNode(); + //fprintf(stderr, "--- instruction ---\n"); + //insn->dump(); + llvm::BasicBlock* before = insn->getParent(); + //fprintf(stderr, "--- basic block ---\n"); + //before->dump(); + llvm::BasicBlock* after = before->splitBasicBlock(insn); + //fprintf(stderr, "--- after split ---\n"); + //before->dump(); + //after->dump(); + opInfos[pc].bb = after; + return after; + } else { + llvm::BasicBlock* res = llvm::BasicBlock::Create(llvmFunction->getContext(), id, llvmFunction); + + if(doAlloc) { + opInfos[pc].metaStack = (llvm::Type**)allocator->allocate(sizeof(llvm::Type**)*stack.topStack); + memcpy(opInfos[pc].metaStack, stack.metaStack, sizeof(llvm::Type*)*stack.topStack); + } + + opInfos[pc].bb = res; + opInfos[pc].topStack = stack.topStack; + if(doPush) + pendingBranchs[topPendingBranchs++] = pc; + + return res; + } +} + +bool J3CodeGen::onEndPoint() { + uint32_t pc; + do { + if(!topPendingBranchs) + return 1; + pc = pendingBranchs[--topPendingBranchs]; + } while(opInfos[pc].insn); + closeBB = 0; + codeReader->seek(pc, codeReader->SeekSet); + return 0; +} + +llvm::Value* J3CodeGen::buildString(const char* msg) { + std::vector elmts; + uint32_t n; + + for(n=0; msg[n]; n++) + elmts.push_back(builder->getInt8(msg[n])); + + elmts.push_back(builder->getInt8(0)); + + llvm::Constant* str = llvm::ConstantArray::get(llvm::ArrayType::get(builder->getInt8Ty(), n+1), elmts); + llvm::Value* var = new llvm::GlobalVariable(*module, + str->getType(), + 1, + llvm::GlobalVariable::InternalLinkage, + str); + llvm::Value* gep[] = { builder->getInt32(0), builder->getInt32(0) }; + + return builder->CreateGEP(var, gep); +} + +void J3CodeGen::echoDebugEnter(uint32_t isLeave, const char* msg, ...) { + static __thread uint32_t prof = 0; + if(J3Thread::get()->vm()->options()->debugExecute >= 1) { + const char* enter = isLeave ? "leaving" : "entering"; + va_list va; + va_start(va, msg); + + if(!isLeave) + prof += J3Thread::get()->vm()->options()->debugEnterIndent; + fprintf(stderr, "%*s", prof, ""); + if(isLeave) + prof -= J3Thread::get()->vm()->options()->debugEnterIndent; + + fprintf(stderr, "%s ", enter); + vfprintf(stderr, msg, va); + va_end(va); + } +} + +void J3CodeGen::echoDebugExecute(uint32_t level, const char* msg, ...) { + if(J3Thread::get()->vm()->options()->debugExecute >= level) { + va_list va; + va_start(va, msg); + vfprintf(stderr, msg, va); + va_end(va); + } +} + +void J3CodeGen::translate() { + if(vm->options()->debugTranslate) { + fprintf(stderr, " translating bytecode of: %ls::%ls%ls\n", method->cl()->name()->cStr(), method->name()->cStr(), method->sign()->cStr()); + if(vm->options()->debugTranslate > 1) { + fprintf(stderr, " exception table:\n"); + for(uint32_t i=0; ipc); + for(uint32_t j=0; jnbEntries; j++) + fprintf(stderr, " %u", exceptionNodes[i]->entries[j]->catchType); + fprintf(stderr, exceptionNodes[i]->nbEntries ? "\n" : " \n"); + } + } + } + + curExceptionNode = 0; + + stack.topStack = 0; + builder->SetInsertPoint(bb); + _onEndPoint(); + + if(vm->options()->genDebugExecute) { + char buf[256]; + snprintf(buf, 256, "%ls::%ls", method->cl()->name()->cStr(), method->name()->cStr()); + builder->CreateCall3(funcEchoDebugEnter, + builder->getInt32(0), + buildString("%s\n"), + buildString(buf)); + } + + while(codeReader->remaining()) { + llvm::Value* val1; + llvm::Value* val2; + + javaPC = codeReader->tell(); + + if(javaPC < exceptionNodes[curExceptionNode]->pc || javaPC >= exceptionNodes[curExceptionNode+1]->pc) { + if(javaPC == exceptionNodes[curExceptionNode+1]->pc) + curExceptionNode++; + else + for(uint32_t i=0; ipc <= javaPC && javaPC < exceptionNodes[i+1]->pc) { + curExceptionNode = i; + break; + } + //printf("cur exception node: %d\n", curExceptionNode); + } + + if(opInfos[javaPC].insn || opInfos[javaPC].bb) { + if(closeBB && !bb->getTerminator()) { + if(!opInfos[javaPC].bb) + J3::internalError(L"random split???"); + builder->CreateBr(opInfos[javaPC].bb); + } + } + + if(opInfos[javaPC].insn) { + _onEndPoint(); + javaPC = codeReader->tell(); + } + + closeBB = 1; + + if(opInfos[javaPC].bb) { + bb = opInfos[javaPC].bb; + builder->SetInsertPoint(bb); + //printf("Meta stack before: %p\n", metaStack); + if(opInfos[javaPC].metaStack) { + stack.metaStack = opInfos[javaPC].metaStack; + stack.topStack = opInfos[javaPC].topStack; + } else if(opInfos[javaPC].topStack == -1) { /* exception handling */ + stack.metaStack[0] = vm->typeJ3ObjectPtr; + stack.topStack = 1; + } + //printf("Meta stack after: %p\n", metaStack); + } + + if(opInfos[javaPC].bb) + opInfos[javaPC].insn = bb->begin(); + else + opInfos[javaPC].insn = bb->end()->getPrevNode(); + + uint8_t bc = codeReader->readU1(); + + switch(vm->options()->debugTranslate) { + case 4: + fprintf(stderr, "--------------------------------------------\n"); + llvmFunction->dump(); + case 3: + fprintf(stderr, "stack:\n"); + stack.dump(); + case 2: + fprintf(stderr, " [%4d] decoding: %s\n", javaPC, J3Cst::opcodeNames[bc]); + break; + } + + if(vm->options()->genDebugExecute) { + char buf[256]; + snprintf(buf, 256, " [%4d] executing: %-20s in %ls::%ls", javaPC, + J3Cst::opcodeNames[bc], method->cl()->name()->cStr(), method->name()->cStr()); + builder->CreateCall3(funcEchoDebugExecute, + builder->getInt32(2), + buildString("%s\n"), + buildString(buf)); + } + + switch(bc) { + case J3Cst::BC_nop: /* 0x00 */ + break; + + case J3Cst::BC_aconst_null: /* 0x01 */ + stack.push(nullValue); + break; + + case J3Cst::BC_iconst_m1: /* 0x02 */ + case J3Cst::BC_iconst_0: /* 0x03 */ + case J3Cst::BC_iconst_1: /* 0x04 */ + case J3Cst::BC_iconst_2: /* 0x05 */ + case J3Cst::BC_iconst_3: /* 0x06 */ + case J3Cst::BC_iconst_4: /* 0x07 */ + case J3Cst::BC_iconst_5: /* 0x08 */ + stack.push(builder->getInt32(bc - J3Cst::BC_iconst_0)); + break; + + case J3Cst::BC_lconst_0: /* 0x09 */ + case J3Cst::BC_lconst_1: /* 0x0a */ + stack.push(builder->getInt64(bc - J3Cst::BC_lconst_0)); + break; + + case J3Cst::BC_fconst_0: /* 0x0b */ + case J3Cst::BC_fconst_1: /* 0x0c */ + case J3Cst::BC_fconst_2: /* 0x0d */ + stack.push(llvm::ConstantFP::get(builder->getFloatTy(), (bc - J3Cst::BC_fconst_0))); + break; + + case J3Cst::BC_dconst_0: /* 0x0e */ + case J3Cst::BC_dconst_1: /* 0x0f */ + stack.push(llvm::ConstantFP::get(builder->getDoubleTy(), (bc - J3Cst::BC_dconst_0))); + break; + + case J3Cst::BC_bipush: /* 0x10 */ + stack.push(builder->getInt32(codeReader->readS1())); + break; + + case J3Cst::BC_sipush: /* 0x11 */ + stack.push(builder->getInt32(codeReader->readS2())); + break; + + case J3Cst::BC_ldc: /* 0x12 */ + ldc(codeReader->readU1()); + break; + + case J3Cst::BC_ldc_w: /* 0x13 */ + case J3Cst::BC_ldc2_w: /* 0x14 */ + ldc(codeReader->readU2()); + break; + + case J3Cst::BC_iload: /* 0x15 wide */ + case J3Cst::BC_lload: /* 0x16 wide */ + case J3Cst::BC_fload: /* 0x17 wide */ + case J3Cst::BC_dload: /* 0x18 wide */ + case J3Cst::BC_aload: /* 0x19 wide */ + stack.push(locals.at(wideReadU1())); + break; + + case J3Cst::BC_iload_0: /* 0x1a */ + case J3Cst::BC_iload_1: /* 0x1b */ + case J3Cst::BC_iload_2: /* 0x1c */ + case J3Cst::BC_iload_3: /* 0x1d */ + stack.push(locals.at(bc - J3Cst::BC_iload_0)); + break; + + case J3Cst::BC_lload_0: /* 0x1e */ + case J3Cst::BC_lload_1: /* 0x1f */ + case J3Cst::BC_lload_2: /* 0x20 */ + case J3Cst::BC_lload_3: /* 0x21 */ + stack.push(locals.at(bc - J3Cst::BC_lload_0)); + break; + + case J3Cst::BC_fload_0: /* 0x22 */ + case J3Cst::BC_fload_1: /* 0x23 */ + case J3Cst::BC_fload_2: /* 0x24 */ + case J3Cst::BC_fload_3: /* 0x25 */ + stack.push(locals.at(bc - J3Cst::BC_fload_0)); + break; + + case J3Cst::BC_dload_0: /* 0x26 */ + case J3Cst::BC_dload_1: /* 0x27 */ + case J3Cst::BC_dload_2: /* 0x28 */ + case J3Cst::BC_dload_3: /* 0x29 */ + stack.push(locals.at(bc - J3Cst::BC_dload_0)); + break; + + case J3Cst::BC_aload_0: /* 0x2a */ + case J3Cst::BC_aload_1: /* 0x2b */ + case J3Cst::BC_aload_2: /* 0x2c */ + case J3Cst::BC_aload_3: /* 0x2d */ + stack.push(locals.at(bc - J3Cst::BC_aload_0)); + break; + + case J3Cst::BC_iaload: /* 0x2e */ + arrayLoad(vm->typeInteger); + break; + + case J3Cst::BC_laload: /* 0x2f */ + arrayLoad(vm->typeLong); + break; + + case J3Cst::BC_faload: /* 0x30 */ + arrayLoad(vm->typeFloat); + break; + + case J3Cst::BC_daload: /* 0x31 */ + arrayLoad(vm->typeDouble); + break; + + case J3Cst::BC_aaload: /* 0x32 */ + arrayLoad(vm->objectClass); + break; + + case J3Cst::BC_baload: /* 0x33 */ + arrayStore(vm->typeByte); + break; + + case J3Cst::BC_caload: /* 0x34 */ + arrayStore(vm->typeChar); + break; + + case J3Cst::BC_saload: /* 0x35 */ + arrayStore(vm->typeShort); + break; + + case J3Cst::BC_istore: /* 0x36 wide */ + case J3Cst::BC_lstore: /* 0x37 wide */ + case J3Cst::BC_fstore: /* 0x38 wide */ + case J3Cst::BC_dstore: /* 0x39 wide */ + case J3Cst::BC_astore: /* 0x3a wide */ + locals.setAt(stack.pop(), wideReadU1()); + break; + + case J3Cst::BC_istore_0: /* 0x3b */ + case J3Cst::BC_istore_1: /* 0x3c */ + case J3Cst::BC_istore_2: /* 0x3d */ + case J3Cst::BC_istore_3: /* 0x3e */ + locals.setAt(stack.pop(), bc - J3Cst::BC_istore_0); + break; + + case J3Cst::BC_lstore_0: /* 0x3f */ + case J3Cst::BC_lstore_1: /* 0x40 */ + case J3Cst::BC_lstore_2: /* 0x41 */ + case J3Cst::BC_lstore_3: /* 0x42 */ + locals.setAt(stack.pop(), bc - J3Cst::BC_lstore_0); + break; + + case J3Cst::BC_fstore_0: /* 0x43 */ + case J3Cst::BC_fstore_1: /* 0x44 */ + case J3Cst::BC_fstore_2: /* 0x45 */ + case J3Cst::BC_fstore_3: /* 0x46 */ + locals.setAt(stack.pop(), bc - J3Cst::BC_fstore_0); + break; + + case J3Cst::BC_dstore_0: /* 0x47 */ + case J3Cst::BC_dstore_1: /* 0x48 */ + case J3Cst::BC_dstore_2: /* 0x49 */ + case J3Cst::BC_dstore_3: /* 0x4a */ + locals.setAt(stack.pop(), bc - J3Cst::BC_dstore_0); + break; + + case J3Cst::BC_astore_0: /* 0x4b */ + case J3Cst::BC_astore_1: /* 0x4c */ + case J3Cst::BC_astore_2: /* 0x4d */ + case J3Cst::BC_astore_3: /* 0x4e */ + locals.setAt(stack.pop(), bc - J3Cst::BC_astore_0); + break; + + case J3Cst::BC_iastore: /* 0x4f */ + arrayStore(vm->typeInteger); + break; + + case J3Cst::BC_lastore: /* 0x50 */ + arrayStore(vm->typeLong); + break; + + case J3Cst::BC_fastore: /* 0x51 */ + arrayStore(vm->typeFloat); + break; + + case J3Cst::BC_dastore: /* 0x52 */ + arrayStore(vm->typeDouble); + break; + + case J3Cst::BC_aastore: /* 0x53 */ + arrayStore(vm->objectClass); + break; + + case J3Cst::BC_bastore: /* 0x54 */ + arrayStore(vm->typeByte); + break; + + case J3Cst::BC_castore: /* 0x55 */ + arrayStore(vm->typeChar); + break; + + case J3Cst::BC_sastore: /* 0x56 */ + arrayStore(vm->typeShort); + break; + + case J3Cst::BC_pop: /* 0x57 */ + stack.pop(); + break; + + case J3Cst::BC_pop2: nyi(); /* 0x58 */ + case J3Cst::BC_dup: /* 0x59 */ + stack.push(stack.top()); + break; + + case J3Cst::BC_dup_x1: nyi(); /* 0x5a */ + case J3Cst::BC_dup_x2: nyi(); /* 0x5b */ + case J3Cst::BC_dup2: nyi(); /* 0x5c */ + case J3Cst::BC_dup2_x1: nyi(); /* 0x5d */ + case J3Cst::BC_dup2_x2: nyi(); /* 0x5e */ + case J3Cst::BC_swap: nyi(); /* 0x5f */ + + case J3Cst::BC_iadd: /* 0x60 */ + case J3Cst::BC_ladd: /* 0x61 */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateAdd(val1, val2)); + break; + + case J3Cst::BC_fadd: /* 0x62 */ + case J3Cst::BC_dadd: /* 0x63 */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateFAdd(val1, val2)); + break; + + case J3Cst::BC_isub: /* 0x64 */ + case J3Cst::BC_lsub: /* 0x65 */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateSub(val1, val2)); + break; + + case J3Cst::BC_fsub: /* 0x66 */ + case J3Cst::BC_dsub: /* 0x67 */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateFSub(val1, val2)); + break; + + case J3Cst::BC_imul: /* 0x68 */ + case J3Cst::BC_lmul: /* 0x69 */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateMul(val1, val2)); + break; + + case J3Cst::BC_fmul: /* 0x6a */ + case J3Cst::BC_dmul: /* 0x6b */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateFMul(val1, val2)); + break; + + case J3Cst::BC_idiv: /* 0x6c */ + case J3Cst::BC_ldiv: /* 0x6d */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateSDiv(val1, val2)); + break; + + case J3Cst::BC_fdiv: /* 0x6e */ + case J3Cst::BC_ddiv: /* 0x6f */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateFDiv(val1, val2)); + break; + + case J3Cst::BC_irem: /* 0x70 */ + case J3Cst::BC_lrem: /* 0x71 */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateSRem(val1, val2)); + break; + + case J3Cst::BC_frem: /* 0x72 */ + case J3Cst::BC_drem: /* 0x73 */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateFRem(val1, val2)); + break; + + case J3Cst::BC_ineg: /* 0x74 */ + case J3Cst::BC_lneg: /* 0x75 */ + stack.push(builder->CreateNeg(stack.pop())); + break; + + case J3Cst::BC_fneg: /* 0x76 */ + case J3Cst::BC_dneg: /* 0x77 */ + stack.push(builder->CreateFNeg(stack.pop())); + break; + + case J3Cst::BC_ishl: /* 0x78 */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateShl(val1, builder->CreateAnd(val2, 0x1f))); + break; + + case J3Cst::BC_lshl: /* 0x79 */ + val2 = stack.pop(); val1 = stack.pop(); + stack.push(builder->CreateShl(val1, builder->CreateZExt(builder->CreateAnd(val2, 0x3f), builder->getInt64Ty()))); + break; + + case J3Cst::BC_ishr: /* 0x7a */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateAShr(val1, builder->CreateAnd(val2, 0x1f))); + break; + + case J3Cst::BC_lshr: /* 0x7b */ + val2 = stack.pop(); val1 = stack.pop(); + stack.push(builder->CreateAShr(val1, builder->CreateZExt(builder->CreateAnd(val2, 0x3f), builder->getInt64Ty()))); + break; + + case J3Cst::BC_iushr: /* 0x7c */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateLShr(val1, builder->CreateAnd(val2, 0x1f))); + break; + + case J3Cst::BC_lushr: /* 0x7d */ + val2 = stack.pop(); val1 = stack.pop(); + stack.push(builder->CreateLShr(val1, builder->CreateZExt(builder->CreateAnd(val2, 0x3f), builder->getInt64Ty()))); + break; + + case J3Cst::BC_iand: /* 0x7e */ + case J3Cst::BC_land: /* 0x7f */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateAnd(val1, val2)); + break; + + case J3Cst::BC_ior: /* 0x80 */ + case J3Cst::BC_lor: /* 0x81 */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateOr(val1, val2)); + break; + + case J3Cst::BC_ixor: /* 0x82 */ + case J3Cst::BC_lxor: /* 0x83 */ + val2 = stack.pop(); val1 = stack.pop(); stack.push(builder->CreateXor(val1, val2)); + break; + + case J3Cst::BC_iinc: /* 0x84 wide */ + { uint32_t idx = wideReadU1(); + int32_t val = wideReadS1(); + locals.setAt(builder->CreateAdd(locals.at(idx), builder->getInt32(val)), idx); + } break; + + case J3Cst::BC_i2l: /* 0x85 */ + stack.push(builder->CreateSExt(stack.pop(), vm->typeLong->llvmType())); + break; + + case J3Cst::BC_i2f: /* 0x86 */ + stack.push(builder->CreateSIToFP(stack.pop(), vm->typeFloat->llvmType())); + break; + + case J3Cst::BC_i2d: /* 0x87 */ + stack.push(builder->CreateSIToFP(stack.pop(), vm->typeDouble->llvmType())); + break; + + case J3Cst::BC_l2i: nyi(); /* 0x88 */ + case J3Cst::BC_l2f: nyi(); /* 0x89 */ + case J3Cst::BC_l2d: nyi(); /* 0x8a */ + case J3Cst::BC_f2i: /* 0x8b */ + floatToInteger(vm->typeFloat, vm->typeInteger); + break; + + case J3Cst::BC_f2l: nyi(); /* 0x8c */ + case J3Cst::BC_f2d: nyi(); /* 0x8d */ + case J3Cst::BC_d2i: nyi(); /* 0x8e */ + case J3Cst::BC_d2l: nyi(); /* 0x8f */ + case J3Cst::BC_d2f: nyi(); /* 0x90 */ + case J3Cst::BC_i2b: nyi(); /* 0x91 */ + case J3Cst::BC_i2c: nyi(); /* 0x92 */ + case J3Cst::BC_i2s: nyi(); /* 0x93 */ + + case J3Cst::BC_lcmp: /* 0x94 */ + compareLong(); + break; + + case J3Cst::BC_fcmpl: /* 0x95 */ + compareFP(1); + break; + + case J3Cst::BC_fcmpg: /* 0x96 */ + compareFP(0); + break; + + case J3Cst::BC_dcmpl: /* 0x97 */ + compareFP(0); + break; + + case J3Cst::BC_dcmpg: /* 0x98 */ + compareFP(1); + break; + + case J3Cst::BC_ifeq: /* 0x99 */ + condBr(builder->CreateICmpEQ(stack.pop(), builder->getInt32(0))); + break; + + case J3Cst::BC_ifne: /* 0x9a */ + condBr(builder->CreateICmpNE(stack.pop(), builder->getInt32(0))); + break; + + case J3Cst::BC_iflt: /* 0x9b */ + condBr(builder->CreateICmpSLT(stack.pop(), builder->getInt32(0))); + break; + + case J3Cst::BC_ifge: /* 0x9c */ + condBr(builder->CreateICmpSGE(stack.pop(), builder->getInt32(0))); + break; + + case J3Cst::BC_ifgt: /* 0x9d */ + condBr(builder->CreateICmpSGT(stack.pop(), builder->getInt32(0))); + break; + + case J3Cst::BC_ifle: /* 0x9e */ + condBr(builder->CreateICmpSLE(stack.pop(), builder->getInt32(0))); + break; + + case J3Cst::BC_if_icmpeq: /* 0x9f */ + val2 = stack.pop(); val1 = stack.pop(); condBr(builder->CreateICmpEQ(val1, val2)); + break; + + case J3Cst::BC_if_icmpne: /* 0xa0 */ + val2 = stack.pop(); val1 = stack.pop(); condBr(builder->CreateICmpNE(val1, val2)); + break; + + case J3Cst::BC_if_icmplt: /* 0xa1 */ + val2 = stack.pop(); val1 = stack.pop(); condBr(builder->CreateICmpSLE(val1, val2)); + break; + + case J3Cst::BC_if_icmpge: /* 0xa2 */ + val2 = stack.pop(); val1 = stack.pop(); condBr(builder->CreateICmpSGE(val1, val2)); + break; + + case J3Cst::BC_if_icmpgt: /* 0xa3 */ + val2 = stack.pop(); val1 = stack.pop(); condBr(builder->CreateICmpSGT(val1, val2)); + break; + + case J3Cst::BC_if_icmple: /* 0xa4 */ + val2 = stack.pop(); val1 = stack.pop(); condBr(builder->CreateICmpSLE(val1, val2)); + break; + + case J3Cst::BC_if_acmpeq: /* 0xa5 */ + val2 = stack.pop(); val1 = stack.pop(); condBr(builder->CreateICmpEQ(val1, val2)); + break; + + case J3Cst::BC_if_acmpne: /* 0xa6 */ + val2 = stack.pop(); val1 = stack.pop(); condBr(builder->CreateICmpNE(val1, val2)); + break; + + case J3Cst::BC_goto: /* 0xa7 */ + builder->CreateBr(forwardBranch("goto", javaPC + codeReader->readS2(), 0, 1)); + _onEndPoint(); + break; + + case J3Cst::BC_jsr: nyi(); /* 0xa8 */ + case J3Cst::BC_ret: nyi(); /* 0xa9 wide */ + case J3Cst::BC_tableswitch: nyi(); /* 0xaa */ + case J3Cst::BC_lookupswitch: nyi(); /* 0xab */ + + case J3Cst::BC_ireturn: /* 0xac */ + case J3Cst::BC_lreturn: /* 0xad */ + case J3Cst::BC_freturn: /* 0xae */ + case J3Cst::BC_dreturn: /* 0xaf */ + case J3Cst::BC_areturn: /* 0xb0 */ + ret.setAt(stack.pop(), 0); + builder->CreateBr(bbRet); + _onEndPoint(); + break; + + case J3Cst::BC_return: /* 0xb1 */ + builder->CreateBr(bbRet); + _onEndPoint(); + break; + + case J3Cst::BC_getstatic: /* 0xb2 */ + getStatic(codeReader->readU2()); + break; + + case J3Cst::BC_putstatic: /* 0xb3 */ + putStatic(codeReader->readU2()); + break; + + case J3Cst::BC_getfield: /* 0xb4 */ + getField(codeReader->readU2()); + break; + + case J3Cst::BC_putfield: /* 0xb5 */ + putField(codeReader->readU2()); + break; + + case J3Cst::BC_invokevirtual: /* 0xb6 */ + invokeVirtual(codeReader->readU2()); + break; + + case J3Cst::BC_invokespecial: /* 0xb7 */ + invokeSpecial(codeReader->readU2()); + break; + + case J3Cst::BC_invokestatic: /* 0xb8 */ + invokeStatic(codeReader->readU2()); + break; + + case J3Cst::BC_invokeinterface: nyi(); /* 0xb9 */ + case J3Cst::BC_new: /* 0xbb */ + newObject(cl->classAt(codeReader->readU2())); + break; + + case J3Cst::BC_newarray: /* 0xbc */ + newArray(codeReader->readU1()); + break; + + case J3Cst::BC_anewarray: /* 0xbd */ + newArray(cl->classAt(codeReader->readU2())->getArray()); + break; + + case J3Cst::BC_arraylength: /* 0xbe */ + stack.push(arrayLength(stack.pop())); + break; + + case J3Cst::BC_athrow: /* 0xbf */ + builder->CreateCall(funcThrowException, + builder->CreateBitCast(stack.pop(), + funcThrowException->getFunctionType()->getParamType(0))); + builder->CreateBr(bbRet); + _onEndPoint(); + break; + + case J3Cst::BC_checkcast: /* 0xc0 */ + checkCast(stack.top(), cl->classAt(codeReader->readU2())); + break; + + case J3Cst::BC_instanceof: /* 0xc1 */ + instanceof(stack.pop(), cl->classAt(codeReader->readU2())); + break; + + case J3Cst::BC_monitorenter: /* 0xc2 */ + stack.pop(); + break; + + case J3Cst::BC_monitorexit: /* 0xc3 */ + stack.pop(); + break; + + case J3Cst::BC_wide: nyi(); /* 0xc4 */ + case J3Cst::BC_multianewarray: nyi(); /* 0xc5 */ + case J3Cst::BC_ifnull: /* 0xc6 */ + condBr(builder->CreateIsNull(stack.pop())); + break; + + case J3Cst::BC_ifnonnull: /* 0xc7 */ + condBr(builder->CreateIsNotNull(stack.pop())); + break; + + + case J3Cst::BC_goto_w: nyi(); /* 0xc8 */ + case J3Cst::BC_jsr_w: nyi(); /* 0xc9 */ + + case J3Cst::BC_breakpoint: /* 0xca */ + case J3Cst::BC_impdep1: /* 0xfe */ + case J3Cst::BC_impdep2: /* 0xff */ + case J3Cst::BC_xxxunusedxxx1: /* 0xba */ + default: + J3::classFormatError(cl, L"unknow opcode '%s' (%d)", J3Cst::opcodeNames[bc], bc); + } + } + J3::classFormatError(cl, L"the last bytecode does not return"); +} + +#if 0 +void J3CodeGen::explore() { + printf(" exploring bytecode of: %ls::%ls%ls\n", method->cl()->name()->cStr(), method->name()->cStr(), method->sign()->cStr()); + while(codeReader->remaining()) { + uint8_t bc = codeReader->readU1(); + + printf(" exploring: %s (%d)\n", J3Cst::opcodeNames[bc], bc); + switch(bc) { +#define eat(n) codeReader->seek(n, codeReader->SeekCur); +#define defOpcode(id, val, effect) \ + case J3Cst::BC_##id: effect; break; +#include "j3/j3bc.def" + default: + J3::internalError(L"unknow opcode '%s' (%d)", J3Cst::opcodeNames[bc], bc); + } + } +} +#endif + +void J3CodeGen::initExceptionNode(J3ExceptionNode** pnode, uint32_t pc, J3ExceptionNode* node) { + *pnode = node; + nbExceptionNodes++; + node->pc = pc; + node->nbEntries = 0; + node->landingPad = 0; + node->curCheck = 0; +} + +void J3CodeGen::addToExceptionNode(J3ExceptionNode* node, J3ExceptionEntry* entry) { + if(!node->nbEntries) { + node->landingPad = llvm::BasicBlock::Create(llvmFunction->getContext(), "landing-pad", llvmFunction); + node->curCheck = node->landingPad; + builder->SetInsertPoint(node->landingPad); + + llvm::LandingPadInst *caughtResult = builder->CreateLandingPad(vm->typeGXXException, funcGXXPersonality, 1, "landing-pad"); + caughtResult->addClause(gvTypeInfo); + llvm::Value* excp = builder->CreateBitCast(builder->CreateCall(funcCXABeginCatch, + builder->CreateExtractValue(caughtResult, 0)), + vm->typeJ3ObjectPtr); + + builder->CreateCall(funcCXAEndCatch); + + builder->CreateCall2(funcEchoDebugExecute, + builder->getInt32(0), /* just to see my first exception :) */ + buildString("entering launchpad!\n")); + + stack.topStack = 0; + stack.push(excp); + } + + node->entries[node->nbEntries++] = entry; + + if(node->curCheck) { /* = 0 if I already have a finally */ + builder->SetInsertPoint(node->curCheck); + node->curCheck = llvm::BasicBlock::Create(llvmFunction->getContext(), "next-exception-check", llvmFunction); + + if(entry->catchType) { + stack.metaStack[0] = vm->typeJ3ObjectPtr; + stack.topStack = 1; + builder->CreateCondBr(isAssignableTo(stack.top(0), cl->classAt(entry->catchType)), entry->bb, node->curCheck); + } else { + builder->CreateBr(entry->bb); + node->curCheck = 0; + } + } +} + +void J3CodeGen::closeExceptionNode(J3ExceptionNode* node) { + if(node->curCheck) { + builder->SetInsertPoint(node->curCheck); + builder->CreateBr(bbRet); + } +} + +void J3CodeGen::generateJava() { + J3Attribute* attr = method->attributes()->lookup(vm->codeAttr); + + if(!attr) + J3::classFormatError(cl, L"No Code attribute in %ls %ls", method->name()->cStr(), method->sign()->cStr()); + + J3Reader reader(cl->bytes()); + reader.seek(attr->offset(), reader.SeekSet); + + uint32_t length = reader.readU4(); + + if(!reader.adjustSize(length)) + J3::classFormatError(cl, L"Code attribute of %ls %ls is too large (%d)", method->name()->cStr(), method->sign()->cStr(), length); + + nullValue = builder + ->CreateIntToPtr(llvm::ConstantInt::get(vm->dataLayout()->getIntPtrType(module->getContext()), (uintptr_t)0), + vm->typeJ3ObjectPtr); + + dbgInfo = + loader->dbgBuilder()->createFunction(llvm::DIDescriptor(), // Function scope + llvmFunction->getName(), // Function name + llvmFunction->getName(), // Mangled name + llvm::DIFile(), // File where this variable is defined + 0, // Line number + loader->dbgBuilder() // Function type. + ->createSubroutineType(llvm::DIFile(), // File in which this subroutine is defined + llvm::DIArray()), // An array of subroutine parameter types. + // This includes return type at 0th index. + false, // True if this function is not externally visible + false, // True if this is a function definition + 0 // Set to the beginning of the scope this starts + ); + + uint32_t maxStack = reader.readU2(); + uint32_t nbLocals = reader.readU2(); + uint32_t codeLength = reader.readU4(); + + locals.init(this, nbLocals, allocator->allocate(J3CodeGenVar::reservedSize(nbLocals))); + stack.init(this, maxStack, allocator->allocate(J3CodeGenVar::reservedSize(maxStack))); + ret.init(this, 1, allocator->allocate(J3CodeGenVar::reservedSize(1))); + + uint32_t n=0; + for(llvm::Function::arg_iterator cur=llvmFunction->arg_begin(); cur!=llvmFunction->arg_end(); cur++, n++) { + locals.setAt(flatten(cur, methodType->ins(n)), n); + } + + //builder->CreateCall(ziTry); + + pendingBranchs = (uint32_t*)allocator->allocate(sizeof(uint32_t) * codeLength); + opInfos = (J3OpInfo*)allocator->allocate(sizeof(J3OpInfo) * codeLength); + memset(opInfos, 0, sizeof(J3OpInfo) * codeLength); + + J3Reader codeReaderTmp(cl->bytes(), reader.tell(), codeLength); + codeReader = &codeReaderTmp; + + bbRet = llvm::BasicBlock::Create(llvmFunction->getContext(), "ret", llvmFunction); + builder->SetInsertPoint(bbRet); + if(vm->options()->genDebugExecute) { + char buf[256]; + snprintf(buf, 256, "%ls::%ls", method->cl()->name()->cStr(), method->name()->cStr()); + builder->CreateCall3(funcEchoDebugEnter, + builder->getInt32(1), + buildString("%s\n"), + buildString(buf)); + } + if(methodType->out() == vm->typeVoid) { + builder->CreateRetVoid(); + } else { + ret.metaStack[0] = methodType->out()->llvmType(); + builder->CreateRet(unflatten(ret.at(0), methodType->out())); + } + + if(J3Cst::isSynchronized(method->access())) { + static bool echoDone = 0; + if(!echoDone) { + fprintf(stderr, "IMPLEMENT ME: synchronized java\n"); + echoDone = 1; + } + } + + reader.seek(codeLength, reader.SeekCur); + nbExceptionEntries = reader.readU2(); + exceptionEntries = (J3ExceptionEntry*)allocator->allocate(sizeof(J3ExceptionEntry) * nbExceptionEntries); + exceptionNodes = (J3ExceptionNode**)allocator->allocate(sizeof(J3ExceptionNode*) * (nbExceptionEntries * 2 + 2)); + nbExceptionNodes = 0; + + initExceptionNode(exceptionNodes, + 0, + (J3ExceptionNode*)allocator->allocate(sizeof(J3ExceptionNode) - + sizeof(J3ExceptionEntry*) + + nbExceptionEntries * sizeof(J3ExceptionEntry*))); + + for(uint32_t i=0; ipc) { + create = 0; + found = 1; + } else if(exceptionNodes[cur]->pc > exceptionEntries[i].startPC) { + memmove(exceptionNodes + cur + 1, exceptionNodes + cur, (nbExceptionNodes - cur) * sizeof(J3ExceptionNode*)); + found = 1; + } + } + + if(create) { + initExceptionNode(exceptionNodes+cur, + exceptionEntries[i].startPC, + (J3ExceptionNode*)allocator->allocate(sizeof(J3ExceptionNode) + (nbExceptionEntries - 1)*sizeof(J3ExceptionEntry*))); + if(cur > 0) + for(uint32_t k=0; knbEntries; k++) + addToExceptionNode(exceptionNodes[cur], exceptionNodes[cur-1]->entries[k]); + } + + found = 0; create = 1; + for(; curpc) { + create = 0; + found = 1; + } else if(exceptionEntries[i].endPC < exceptionNodes[cur]->pc) { + memmove(exceptionNodes + cur + 1, exceptionNodes + cur, (nbExceptionNodes - cur) * sizeof(J3ExceptionNode*)); + found = 1; + } else + addToExceptionNode(exceptionNodes[cur], exceptionEntries + i); + } + + if(create) { + initExceptionNode(exceptionNodes+cur, + exceptionEntries[i].endPC, + (J3ExceptionNode*)allocator->allocate(sizeof(J3ExceptionNode) + (nbExceptionEntries - 1)*sizeof(J3ExceptionEntry*))); + for(uint32_t k=0; knbEntries-1; k++) + addToExceptionNode(exceptionNodes[cur], exceptionNodes[cur-1]->entries[k]); + } + } + + if(exceptionNodes[nbExceptionNodes-1]->pc != codeLength) + initExceptionNode(exceptionNodes + nbExceptionNodes, + codeLength, + (J3ExceptionNode*)allocator->allocate(sizeof(J3ExceptionNode) - + sizeof(J3ExceptionEntry*) + + nbExceptionEntries * sizeof(J3ExceptionEntry*))); + + for(uint32_t i=0; itell(); + translate(); + + locals.killUnused(); + stack.killUnused(); + ret.killUnused(); +} + +void J3CodeGen::generateNative() { + std::vector args; + + llvm::Function* nat = method->nativeLLVMFunction(module); + + llvm::Value* res; + llvm::Value* thread = builder->CreateCall(funcJ3ThreadGet); + llvm::Value* frame = builder->CreateCall(funcJ3ThreadTell, thread); + + if(J3Cst::isSynchronized(method->access())) { + static bool echoDone = 0; + if(!echoDone) { + fprintf(stderr, "IMPLEMENT ME: synchronized java\n"); + echoDone = 1; + } + } + + args.push_back(builder->CreateCall(funcJniEnv)); + if(J3Cst::isStatic(method->access())) + args.push_back(builder->CreateCall2(funcJ3ThreadPushHandle, thread, javaClass(cl))); /* avoid harakiri */ + + if(methodType->nbIns()) { + uint32_t i = 0; + + for(llvm::Function::arg_iterator cur=llvmFunction->arg_begin(); cur!=llvmFunction->arg_end(); cur++, i++) { + llvm::Value* a; + if(methodType->ins(i)->llvmType()->isPointerTy()) + a = builder->CreateCall2(funcJ3ThreadPush, thread, flatten(cur, methodType->ins(i))); + else + a = cur; + args.push_back(a); + } + } + + res = builder->CreateCall(nat, args); + + if(methodType->out() == vm->typeVoid) { + builder->CreateCall2(funcJ3ThreadRestore, thread, frame); + builder->CreateRetVoid(); + } else { + builder->CreateCall2(funcJ3ThreadRestore, thread, frame); + + if(methodType->out()->llvmType()->isPointerTy()) { + llvm::BasicBlock* ifnull = llvm::BasicBlock::Create(llvmFunction->getContext(), "ifnull", llvmFunction); + llvm::BasicBlock* ifnotnull = llvm::BasicBlock::Create(llvmFunction->getContext(), "ifnotnull", llvmFunction); + builder->CreateCondBr(builder->CreateIsNull(res), ifnull, ifnotnull); + + builder->SetInsertPoint(bb = ifnull); + builder->CreateRet(unflatten(res, methodType->out())); + + builder->SetInsertPoint(bb = ifnotnull); + res = unflatten(handleToObject(res), methodType->out()); + } + builder->CreateRet(res); + } +} + +llvm::Function* J3CodeGen::generate() { + bb = llvm::BasicBlock::Create(llvmFunction->getContext(), "entry", llvmFunction); + llvm::IRBuilder<> _builder(bb); + + builder = &_builder; + + if(J3Cst::isNative(method->access())) + generateNative(); + else + generateJava(); + + //llvmFunction->dump(); + //module->dump(); + + return llvmFunction; +} Added: vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3codegenvar.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,177 @@ +#include "j3/j3codegenvar.h" +#include "j3/j3codegen.h" +#include "j3/j3.h" +#include "j3/j3classloader.h" + +#include "llvm/IR/Intrinsics.h" +#include "llvm/IR/Function.h" + +using namespace j3; + +void J3CodeGenVar::killUnused(llvm::AllocaInst** stack, bool isObj) { + llvm::Type* i8ptr = codeGen->builder->getInt8Ty()->getPointerTo(); + llvm::Value* meta = codeGen->builder->CreateBitCast(codeGen->nullValue, i8ptr); + llvm::Type* i8ptrptr = i8ptr->getPointerTo(); + + for(uint32_t i=0; igetNumUses(); + if (!uses) { + cur->eraseFromParent(); + } else if (uses == 1 && llvm::dyn_cast(*(cur->use_begin()))) { + llvm::dyn_cast(*(cur->use_begin()))->eraseFromParent(); + cur->eraseFromParent(); + } else if(isObj) { + codeGen->builder->SetInsertPoint(cur->getNextNode()); + codeGen->builder->CreateCall2(codeGen->gcRoot, codeGen->builder->CreateBitCast(refStack[i], i8ptrptr), meta); + //codeGen->builder->CreateStore(codeGen->nullValue, cur); + // + } + } +} + +void J3CodeGenVar::killUnused() { + killUnused(intStack, 0); + killUnused(longStack, 0); + killUnused(floatStack, 0); + killUnused(doubleStack, 0); + killUnused(refStack, 1); +} + +uint32_t J3CodeGenVar::reservedSize(uint32_t max) { + return max*5*sizeof(llvm::AllocaInst*) + max*sizeof(llvm::Type*); +} + +uint32_t J3CodeGenVar::metaStackSize() { + return topStack*sizeof(llvm::Type*); +} + +void J3CodeGenVar::init(J3CodeGen* _codeGen, uint32_t max, void* space) { + codeGen = _codeGen; + maxStack = max; + intStack = (llvm::AllocaInst**)space; + longStack = intStack + max; + floatStack = longStack + max; + doubleStack = floatStack + max; + refStack = doubleStack + max; + metaStack = (llvm::Type**)(refStack + max); + topStack = 0; + + for(uint32_t i=0; ibuilder->CreateAlloca(codeGen->builder->getInt32Ty()); + longStack[i] = codeGen->builder->CreateAlloca(codeGen->builder->getInt64Ty()); + floatStack[i] = codeGen->builder->CreateAlloca(codeGen->builder->getFloatTy()); + doubleStack[i] = codeGen->builder->CreateAlloca(codeGen->builder->getDoubleTy()); + refStack[i] = codeGen->builder->CreateAlloca(codeGen->vm->typeJ3ObjectPtr); + } +} + +void J3CodeGenVar::dump() { + for(uint32_t i=0; iisIntegerTy(64)) + v = doubleStack[i]; + else if(t->isIntegerTy()) + v = intStack[i]; + else if(t->isFloatTy()) + v = floatStack[i]; + else if(t->isDoubleTy()) + v = doubleStack[i]; + else if(t->isPointerTy()) + v = refStack[i]; + else { + t->dump(); + J3::internalError(L"should not happen"); + } + + v->dump(); + //fprintf(stderr, "\n"); + } +} + +void J3CodeGenVar::drop(uint32_t n) { + topStack -= n; +} + +void J3CodeGenVar::setAt(llvm::Value* value, uint32_t idx) { + //if(idx >= nbLocals + maxStack) + //J3::classFormatError(cl, L"bad index %lu", idx); + llvm::Type* t = value->getType(); + llvm::AllocaInst** stack; + + if(t->isIntegerTy(64)) { + stack = longStack; + } else if(t->isIntegerTy()) { + stack = intStack; + } else if(t->isFloatTy()) { + stack = floatStack; + } else if(t->isDoubleTy()) { + stack = doubleStack; + } else if(t->isPointerTy()) { + stack = refStack; + } else + J3::internalError(L"should not happen"); + + // fprintf(stderr, "setAt[%u]: ", idx); + // value->dump(); + // fprintf(stderr, "\n"); + + metaStack[idx] = t; + + codeGen->builder->CreateStore(value, stack[idx]); +} + +llvm::Value* J3CodeGenVar::at(uint32_t idx) { + //if(idx >= nbLocals + maxStack) + //vm->classFormatError(cl, L"bad index %lu", idx); + llvm::Type* t = metaStack[idx]; + llvm::Value* res; + + if(t->isIntegerTy(64)) { + res = codeGen->builder->CreateLoad(longStack[idx]); + } else if(t->isIntegerTy()) { + res = codeGen->builder->CreateLoad(intStack[idx]); + } else if(t->isFloatTy()) { + res = codeGen->builder->CreateLoad(floatStack[idx]); + } else if(t->isDoubleTy()) { + res = codeGen->builder->CreateLoad(doubleStack[idx]); + } else if(t->isPointerTy()) { + res = codeGen->builder->CreateLoad(refStack[idx]); + } else + J3::internalError(L"should not happen"); + + // fprintf(stderr, "top: "); + // res->dump(); + // fprintf(stderr, "\n"); + + return res; +} + +void J3CodeGenVar::push(llvm::Value* value) { + // fprintf(stderr, "push: "); + // value->dump(); + // fprintf(stderr, "\n"); + if(topStack >= maxStack) + J3::classFormatError(codeGen->cl, L"too many push in... "); + + setAt(value, topStack++); +} + +llvm::Value* J3CodeGenVar::pop() { + if(!topStack) + J3::classFormatError(codeGen->cl, L"too many pop in... "); + + llvm::Value* res = at(--topStack); + return res; +} + +llvm::Value* J3CodeGenVar::top(uint32_t idx) { + if(topStack <= idx) + J3::classFormatError(codeGen->cl, L"too large top in... "); + + return at(topStack - idx - 1); +} Added: vmkit/branches/mcjit/lib/j3/vm/j3constants.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3constants.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3constants.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3constants.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,37 @@ +#include "j3/j3.h" +#include "j3/j3constants.h" +#include "j3/j3class.h" +#include "j3/j3classloader.h" +#include "j3/j3method.h" + +#include "llvm/IR/DerivedTypes.h" + +using namespace j3; + +wchar_t J3Cst::codeAttr[] = L"Code"; +wchar_t J3Cst::constantValueAttr[] = L"ConstantValue"; + +wchar_t J3Cst::clinitName[] = L""; +wchar_t J3Cst::clinitSign[] = L"()V"; +wchar_t J3Cst::initName[] = L""; +char J3Cst::nativePrefix[] = "Java_"; + +const vmkit::Name* J3Cst::rewrite(J3* vm, const vmkit::Name* clName, const vmkit::Name* orig) { + wchar_t res[clName->length() + orig->length() + 3]; + + res[0] = ID_Left; + res[1] = ID_Classname; + memcpy(res+2, clName->cStr(), sizeof(wchar_t)*clName->length()); + res[2 + clName->length()] = ID_End; + memcpy(res+3+clName->length(), orig->cStr()+1, sizeof(wchar_t)*(orig->length()-1)); + res[2 + clName->length() + orig->length()] = 0; + + return vm->names()->get(res); +} + +#define defOpcode(ID, val, effect) \ + #ID, +const char* J3Cst::opcodeNames[] = { +#include "j3/j3bc.def" +}; +#undef defOpcode Added: vmkit/branches/mcjit/lib/j3/vm/j3jni.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3jni.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3jni.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3jni.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,655 @@ +#include "j3/j3jni.h" +#include "j3/j3.h" +#include "j3/j3class.h" +#include "j3/j3classloader.h" +#include "j3/j3object.h" +#include "j3/j3method.h" +#include "j3/j3thread.h" +#include + +#define enterJVM() try { +#define leaveJVM() } catch(void* e) { J3Thread::get()->setPendingException(J3Thread::get()->push((J3Object*)e)); } + +#define NYI() { fprintf(stderr, "-- not yet implemented: %s --\n", __PRETTY_FUNCTION__); abort(); } + +namespace j3 { + +jint JNICALL GetVersion(JNIEnv* env) { enterJVM(); leaveJVM(); NYI(); } + +jclass JNICALL DefineClass(JNIEnv* env, const char* name, jobject loader, const jbyte* buf, jsize len) { enterJVM(); leaveJVM(); NYI(); } +jclass JNICALL FindClass(JNIEnv* env, const char* name) { + //jclass res; + enterJVM(); + //J3Class* cl = + leaveJVM(); + NYI(); +} + +jmethodID JNICALL FromReflectedMethod(JNIEnv* env, jobject method) { enterJVM(); leaveJVM(); NYI(); } +jfieldID JNICALL FromReflectedField(JNIEnv* env, jobject field) { enterJVM(); leaveJVM(); NYI(); } + +jobject JNICALL ToReflectedMethod(JNIEnv* env, jclass cls, jmethodID methodID, jboolean isStatic) { enterJVM(); leaveJVM(); NYI(); } + +jclass JNICALL GetSuperclass(JNIEnv* env, jclass sub) { enterJVM(); leaveJVM(); NYI(); } +jboolean JNICALL IsAssignableFrom(JNIEnv* env, jclass sub, jclass sup) { enterJVM(); leaveJVM(); NYI(); } + +jobject JNICALL ToReflectedField(JNIEnv* env, jclass cls, jfieldID fieldID, jboolean isStatic) { enterJVM(); leaveJVM(); NYI(); } + +jint JNICALL Throw(JNIEnv* env, jthrowable obj) { enterJVM(); leaveJVM(); NYI(); } +jint JNICALL ThrowNew(JNIEnv* env, jclass clazz, const char* msg) { enterJVM(); leaveJVM(); NYI(); } + +jthrowable JNICALL ExceptionOccurred(JNIEnv* env) { + return J3Thread::get()->pendingException(); +} + +void JNICALL ExceptionDescribe(JNIEnv* env) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL ExceptionClear(JNIEnv* env) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL FatalError(JNIEnv* env, const char* msg) { enterJVM(); leaveJVM(); NYI(); } + +jint JNICALL PushLocalFrame(JNIEnv* env, jint capacity) { enterJVM(); leaveJVM(); NYI(); } +jobject JNICALL PopLocalFrame(JNIEnv* env, jobject result) { enterJVM(); leaveJVM(); NYI(); } + +jobject JNICALL NewGlobalRef(JNIEnv* env, jobject lobj) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL DeleteGlobalRef(JNIEnv* env, jobject gref) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL DeleteLocalRef(JNIEnv* env, jobject obj) { + enterJVM(); + if(obj) obj->harakiri(); + leaveJVM(); +} + +jboolean JNICALL IsSameObject(JNIEnv* env, jobject obj1, jobject obj2) { enterJVM(); leaveJVM(); NYI(); } +jobject JNICALL NewLocalRef(JNIEnv* env, jobject ref) { enterJVM(); leaveJVM(); NYI(); } +jint JNICALL EnsureLocalCapacity(JNIEnv* env, jint capacity) { + enterJVM(); + J3Thread::get()->ensureCapacity(capacity); + leaveJVM(); + return JNI_OK; +} + +jobject JNICALL AllocObject(JNIEnv* env, jclass clazz) { enterJVM(); leaveJVM(); NYI(); } +jobject JNICALL NewObject(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jobject JNICALL NewObjectV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jobject JNICALL NewObjectA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jclass JNICALL GetObjectClass(JNIEnv* env, jobject obj) { + jclass res; + + enterJVM(); + res = obj->vt()->type()->asObjectType()->javaClass(); + leaveJVM(); + + return res; +} + +jboolean JNICALL IsInstanceOf(JNIEnv* env, jobject obj, jclass clazz) { enterJVM(); leaveJVM(); NYI(); } + +jmethodID JNICALL GetMethodID(JNIEnv* env, jclass clazz, const char* name, const char* sig) { + jmethodID res; + + enterJVM(); + J3ObjectType* cl = J3ObjectType::nativeClass(clazz); + cl->initialise(); + vmkit::Names* n = cl->loader()->vm()->names(); + res = cl->findVirtualMethod(n->get(name), n->get(sig)); + leaveJVM(); + return res; +} + +#define doInvoke(jtype, id, j3type) \ + jtype JNICALL Call##id##Method(JNIEnv* env, jobject obj, jmethodID methodID, ...) { \ + va_list va; \ + va_start(va, methodID); \ + jobject res = env->Call##id##MethodV(obj, methodID, va); \ + va_end(va); \ + return res; \ + } \ + \ + jtype JNICALL Call##id##MethodV(JNIEnv* env, jobject obj, jmethodID methodID, va_list args) { \ + jvalue res; \ + \ + enterJVM(); \ + res = methodID->invokeVirtual(obj, args); \ + leaveJVM(); \ + \ + return res.val##j3type; \ + } + + doInvoke(jobject, Object, Object); + + +jobject JNICALL CallObjectMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jboolean JNICALL CallBooleanMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jboolean JNICALL CallBooleanMethodV(JNIEnv* env, jobject obj, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jboolean JNICALL CallBooleanMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jbyte JNICALL CallByteMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jbyte JNICALL CallByteMethodV(JNIEnv* env, jobject obj, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jbyte JNICALL CallByteMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jchar JNICALL CallCharMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jchar JNICALL CallCharMethodV(JNIEnv* env, jobject obj, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jchar JNICALL CallCharMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jshort JNICALL CallShortMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jshort JNICALL CallShortMethodV(JNIEnv* env, jobject obj, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jshort JNICALL CallShortMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jint JNICALL CallIntMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jint JNICALL CallIntMethodV(JNIEnv* env, jobject obj, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jint JNICALL CallIntMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jlong JNICALL CallLongMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jlong JNICALL CallLongMethodV(JNIEnv* env, jobject obj, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jlong JNICALL CallLongMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jfloat JNICALL CallFloatMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jfloat JNICALL CallFloatMethodV(JNIEnv* env, jobject obj, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jfloat JNICALL CallFloatMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jdouble JNICALL CallDoubleMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jdouble JNICALL CallDoubleMethodV(JNIEnv* env, jobject obj, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jdouble JNICALL CallDoubleMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +void JNICALL CallVoidMethod(JNIEnv* env, jobject obj, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL CallVoidMethodV(JNIEnv* env, jobject obj, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL CallVoidMethodA(JNIEnv* env, jobject obj, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jobject JNICALL CallNonvirtualObjectMethod(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jobject JNICALL CallNonvirtualObjectMethodV(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jobject JNICALL CallNonvirtualObjectMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jboolean JNICALL CallNonvirtualBooleanMethod(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jboolean JNICALL CallNonvirtualBooleanMethodV(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jboolean JNICALL CallNonvirtualBooleanMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jbyte JNICALL CallNonvirtualByteMethod(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jbyte JNICALL CallNonvirtualByteMethodV(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jbyte JNICALL CallNonvirtualByteMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jchar JNICALL CallNonvirtualCharMethod(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jchar JNICALL CallNonvirtualCharMethodV(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jchar CallNonvirtualCharMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jshort JNICALL CallNonvirtualShortMethod(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jshort JNICALL CallNonvirtualShortMethodV(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jshort JNICALL CallNonvirtualShortMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jint JNICALL CallNonvirtualIntMethod(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jint JNICALL CallNonvirtualIntMethodV(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jint JNICALL CallNonvirtualIntMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jlong JNICALL CallNonvirtualLongMethod(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jlong JNICALL CallNonvirtualLongMethodV(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jlong JNICALL CallNonvirtualLongMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jfloat JNICALL CallNonvirtualFloatMethod(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jfloat JNICALL CallNonvirtualFloatMethodV(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jfloat JNICALL CallNonvirtualFloatMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jdouble JNICALL CallNonvirtualDoubleMethod(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jdouble JNICALL CallNonvirtualDoubleMethodV(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jdouble JNICALL CallNonvirtualDoubleMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +void JNICALL CallNonvirtualVoidMethod(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL CallNonvirtualVoidMethodV(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL CallNonvirtualVoidMethodA(JNIEnv* env, jobject obj, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jfieldID JNICALL GetFieldID(JNIEnv* env, jclass clazz, const char* name, const char* sig) { enterJVM(); leaveJVM(); NYI(); } + +jobject JNICALL GetObjectField(JNIEnv* env, jobject obj, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jboolean JNICALL GetBooleanField(JNIEnv* env, jobject obj, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jbyte JNICALL GetByteField(JNIEnv* env, jobject obj, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jchar JNICALL GetCharField(JNIEnv* env, jobject obj, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jshort JNICALL GetShortField(JNIEnv* env, jobject obj, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jint JNICALL GetIntField(JNIEnv* env, jobject obj, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jlong JNICALL GetLongField(JNIEnv* env, jobject obj, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jfloat JNICALL GetFloatField(JNIEnv* env, jobject obj, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jdouble JNICALL GetDoubleField(JNIEnv* env, jobject obj, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } + +void JNICALL SetObjectField(JNIEnv* env, jobject obj, jfieldID fieldID, jobject val) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetBooleanField(JNIEnv* env, jobject obj, jfieldID fieldID, jboolean val) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetByteField(JNIEnv* env, jobject obj, jfieldID fieldID, jbyte val) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetCharField(JNIEnv* env, jobject obj, jfieldID fieldID, jchar val) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetShortField(JNIEnv* env, jobject obj, jfieldID fieldID, jshort val) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetIntField(JNIEnv* env, jobject obj, jfieldID fieldID, jint val) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetLongField(JNIEnv* env, jobject obj, jfieldID fieldID, jlong val) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetFloatField(JNIEnv* env, jobject obj, jfieldID fieldID, jfloat val) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetDoubleField(JNIEnv* env, jobject obj, jfieldID fieldID, jdouble val) { enterJVM(); leaveJVM(); NYI(); } + +jmethodID JNICALL GetStaticMethodID(JNIEnv* env, jclass clazz, const char* name, const char* sig) { enterJVM(); leaveJVM(); NYI(); } + +jobject JNICALL CallStaticObjectMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jobject JNICALL CallStaticObjectMethodV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jobject JNICALL CallStaticObjectMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jboolean JNICALL CallStaticBooleanMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jboolean JNICALL CallStaticBooleanMethodV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jboolean JNICALL CallStaticBooleanMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jbyte JNICALL CallStaticByteMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jbyte JNICALL CallStaticByteMethodV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jbyte JNICALL CallStaticByteMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jchar JNICALL CallStaticCharMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jchar JNICALL CallStaticCharMethodV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jchar JNICALL CallStaticCharMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jshort JNICALL CallStaticShortMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jshort JNICALL CallStaticShortMethodV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jshort JNICALL CallStaticShortMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jint JNICALL CallStaticIntMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jint JNICALL CallStaticIntMethodV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jint JNICALL CallStaticIntMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jlong JNICALL CallStaticLongMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jlong JNICALL CallStaticLongMethodV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jlong JNICALL CallStaticLongMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jfloat JNICALL CallStaticFloatMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jfloat JNICALL CallStaticFloatMethodV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jfloat JNICALL CallStaticFloatMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jdouble JNICALL CallStaticDoubleMethod(JNIEnv* env, jclass clazz, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +jdouble JNICALL CallStaticDoubleMethodV(JNIEnv* env, jclass clazz, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +jdouble JNICALL CallStaticDoubleMethodA(JNIEnv* env, jclass clazz, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +void JNICALL CallStaticVoidMethod(JNIEnv* env, jclass cls, jmethodID methodID, ...) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL CallStaticVoidMethodV(JNIEnv* env, jclass cls, jmethodID methodID, va_list args) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL CallStaticVoidMethodA(JNIEnv* env, jclass cls, jmethodID methodID, const jvalue* args) { enterJVM(); leaveJVM(); NYI(); } + +jfieldID JNICALL GetStaticFieldID(JNIEnv* env, jclass clazz, const char* name, const char* sig) { enterJVM(); leaveJVM(); NYI(); } +jobject JNICALL GetStaticObjectField(JNIEnv* env, jclass clazz, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jboolean JNICALL GetStaticBooleanField(JNIEnv* env, jclass clazz, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jbyte JNICALL GetStaticByteField(JNIEnv* env, jclass clazz, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jchar JNICALL GetStaticCharField(JNIEnv* env, jclass clazz, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jshort JNICALL GetStaticShortField(JNIEnv* env, jclass clazz, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jint JNICALL GetStaticIntField(JNIEnv* env, jclass clazz, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jlong JNICALL GetStaticLongField(JNIEnv* env, jclass clazz, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jfloat JNICALL GetStaticFloatField(JNIEnv* env, jclass clazz, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } +jdouble JNICALL GetStaticDoubleField(JNIEnv* env, jclass clazz, jfieldID fieldID) { enterJVM(); leaveJVM(); NYI(); } + +void JNICALL SetStaticObjectField(JNIEnv* env, jclass clazz, jfieldID fieldID, jobject value) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetStaticBooleanField(JNIEnv* env, jclass clazz, jfieldID fieldID, jboolean value) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetStaticByteField(JNIEnv* env, jclass clazz, jfieldID fieldID, jbyte value) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetStaticCharField(JNIEnv* env, jclass clazz, jfieldID fieldID, jchar value) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetStaticShortField(JNIEnv* env, jclass clazz, jfieldID fieldID, jshort value) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetStaticIntField(JNIEnv* env, jclass clazz, jfieldID fieldID, jint value) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetStaticLongField(JNIEnv* env, jclass clazz, jfieldID fieldID, jlong value) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetStaticFloatField(JNIEnv* env, jclass clazz, jfieldID fieldID, jfloat value) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetStaticDoubleField(JNIEnv* env, jclass clazz, jfieldID fieldID, jdouble value) { enterJVM(); leaveJVM(); NYI(); } + +jstring JNICALL NewString(JNIEnv* env, const jchar* unicode, jsize len) { enterJVM(); leaveJVM(); NYI(); } +jsize JNICALL GetStringLength(JNIEnv* env, jstring str) { enterJVM(); leaveJVM(); NYI(); } +const jchar* JNICALL GetStringChars(JNIEnv* env, jstring str, jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL ReleaseStringChars(JNIEnv* env, jstring str, const jchar* chars) { enterJVM(); leaveJVM(); NYI(); } + +jstring JNICALL NewStringUTF(JNIEnv* env, const char* utf) { + jstring res; + + enterJVM(); + res = J3Thread::get()->push(J3Thread::get()->vm()->utfToString(utf)); /* harakiri want to kill me */ + leaveJVM(); + + return res; +} + +jsize JNICALL GetStringUTFLength(JNIEnv* env, jstring str) { enterJVM(); leaveJVM(); NYI(); } + +const char* JNICALL GetStringUTFChars(JNIEnv* env, jstring str, jboolean* isCopy) { + char* res; + + enterJVM(); + J3* vm = str->vt()->type()->loader()->vm(); + jobject content = str->getObject(vm->stringValue); + uint32_t length = content->arrayLength(); + res = new char[length+1]; + + for(uint32_t i=0; igetCharAt(i); + + res[length] = 0; + + if(isCopy) + *isCopy = 1; + + leaveJVM(); + + return res; +} + +void JNICALL ReleaseStringUTFChars(JNIEnv* env, jstring str, const char* chars) { + enterJVM(); + delete[] chars; + leaveJVM(); +} + + +jsize JNICALL GetArrayLength(JNIEnv* env, jarray array) { enterJVM(); leaveJVM(); NYI(); } + +jobjectArray JNICALL NewObjectArray(JNIEnv* env, jsize len, jclass clazz, jobject init) { enterJVM(); leaveJVM(); NYI(); } +jobject JNICALL GetObjectArrayElement(JNIEnv* env, jobjectArray array, jsize index) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetObjectArrayElement(JNIEnv* env, jobjectArray array, jsize index, jobject val) { enterJVM(); leaveJVM(); NYI(); } + +jbooleanArray JNICALL NewBooleanArray(JNIEnv* env, jsize len) { enterJVM(); leaveJVM(); NYI(); } +jbyteArray JNICALL NewByteArray(JNIEnv* env, jsize len) { enterJVM(); leaveJVM(); NYI(); } +jcharArray JNICALL NewCharArray(JNIEnv* env, jsize len) { enterJVM(); leaveJVM(); NYI(); } +jshortArray JNICALL NewShortArray(JNIEnv* env, jsize len) { enterJVM(); leaveJVM(); NYI(); } +jintArray JNICALL NewIntArray(JNIEnv* env, jsize len) { enterJVM(); leaveJVM(); NYI(); } +jlongArray JNICALL NewLongArray(JNIEnv* env, jsize len) { enterJVM(); leaveJVM(); NYI(); } +jfloatArray JNICALL NewFloatArray(JNIEnv* env, jsize len) { enterJVM(); leaveJVM(); NYI(); } +jdoubleArray JNICALL NewDoubleArray(JNIEnv* env, jsize len) { enterJVM(); leaveJVM(); NYI(); } + +jboolean* JNICALL GetBooleanArrayElements(JNIEnv* env, jbooleanArray array, jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); } +jbyte* JNICALL GetByteArrayElements(JNIEnv* env, jbyteArray array, jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); } +jchar* JNICALL GetCharArrayElements(JNIEnv* env, jcharArray array, jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); } +jshort* JNICALL GetShortArrayElements(JNIEnv* env, jshortArray array, jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); } +jint* JNICALL GetIntArrayElements(JNIEnv* env, jintArray array, jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); } +jlong* JNICALL GetLongArrayElements(JNIEnv* env, jlongArray array, jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); } +jfloat* JNICALL GetFloatArrayElements(JNIEnv* env, jfloatArray array, jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); } +jdouble* JNICALL GetDoubleArrayElements(JNIEnv* env, jdoubleArray array, jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); } + +void JNICALL ReleaseBooleanArrayElements(JNIEnv* env, jbooleanArray array, jboolean* elems, jint mode) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL ReleaseByteArrayElements(JNIEnv* env, jbyteArray array, jbyte* elems, jint mode) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL ReleaseCharArrayElements(JNIEnv* env, jcharArray array, jchar* elems, jint mode) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL ReleaseShortArrayElements(JNIEnv* env, jshortArray array, jshort* elems, jint mode) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL ReleaseIntArrayElements(JNIEnv* env, jintArray array, jint* elems, jint mode) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL ReleaseLongArrayElements(JNIEnv* env, jlongArray array, jlong* elems, jint mode) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL ReleaseFloatArrayElements(JNIEnv* env, jfloatArray array, jfloat* elems, jint mode) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL ReleaseDoubleArrayElements(JNIEnv* env, jdoubleArray array, jdouble* elems, jint mode) { enterJVM(); leaveJVM(); NYI(); } + +void JNICALL GetBooleanArrayRegion(JNIEnv* env, jbooleanArray array, jsize start, jsize l, jboolean* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL GetByteArrayRegion(JNIEnv* env, jbyteArray array, jsize start, jsize len, jbyte* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL GetCharArrayRegion(JNIEnv* env, jcharArray array, jsize start, jsize len, jchar* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL GetShortArrayRegion(JNIEnv* env, jshortArray array, jsize start, jsize len, jshort* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL GetIntArrayRegion(JNIEnv* env, jintArray array, jsize start, jsize len, jint* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL GetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start, jsize len, jlong* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL GetFloatArrayRegion(JNIEnv* env, jfloatArray array, jsize start, jsize len, jfloat* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL GetDoubleArrayRegion(JNIEnv* env, jdoubleArray array, jsize start, jsize len, jdouble* buf) { enterJVM(); leaveJVM(); NYI(); } + +void JNICALL SetBooleanArrayRegion(JNIEnv* env, jbooleanArray array, jsize start, jsize l, const jboolean* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetByteArrayRegion(JNIEnv* env, jbyteArray array, jsize start, jsize len, const jbyte* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetCharArrayRegion(JNIEnv* env, jcharArray array, jsize start, jsize len, const jchar* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetShortArrayRegion(JNIEnv* env, jshortArray array, jsize start, jsize len, const jshort* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetIntArrayRegion(JNIEnv* env, jintArray array, jsize start, jsize len, const jint* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetLongArrayRegion(JNIEnv* env, jlongArray array, jsize start, jsize len, const jlong* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetFloatArrayRegion(JNIEnv* env, jfloatArray array, jsize start, jsize len, const jfloat* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL SetDoubleArrayRegion(JNIEnv* env, jdoubleArray array, jsize start, jsize len, const jdouble* buf) { enterJVM(); leaveJVM(); NYI(); } + +jint JNICALL RegisterNatives(JNIEnv* env, jclass clazz, const JNINativeMethod* methods, jint nMethods) { + enterJVM(); + J3Class* cl = J3Class::nativeClass(clazz)->asClass(); + J3* j3 = cl->loader()->vm(); + + for(jint i=0; iregisterNative(j3->names()->get(methods[i].name), j3->names()->get(methods[i].signature), methods[i].fnPtr); + + leaveJVM(); + return 0; +} + +jint JNICALL UnregisterNatives(JNIEnv* env, jclass clazz) { enterJVM(); leaveJVM(); NYI(); } + +jint JNICALL MonitorEnter(JNIEnv* env, jobject obj) { enterJVM(); leaveJVM(); NYI(); } +jint JNICALL MonitorExit(JNIEnv* env, jobject obj) { enterJVM(); leaveJVM(); NYI(); } + +jint JNICALL GetJavaVM(JNIEnv* env, JavaVM** vm) { enterJVM(); leaveJVM(); NYI(); } + +void JNICALL GetStringRegion(JNIEnv* env, jstring str, jsize start, jsize len, jchar* buf) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL GetStringUTFRegion(JNIEnv* env, jstring str, jsize start, jsize len, char* buf) { enterJVM(); leaveJVM(); NYI(); } + +void* JNICALL GetPrimitiveArrayCritical(JNIEnv* env, jarray array, jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL ReleasePrimitiveArrayCritical(JNIEnv* env, jarray array, void* carray, jint mode) { enterJVM(); leaveJVM(); NYI(); } + +const jchar* JNICALL GetStringCritical(JNIEnv* env, jstring string, jboolean* isCopy) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL ReleaseStringCritical(JNIEnv* env, jstring string, const jchar* cstring) { enterJVM(); leaveJVM(); NYI(); } + +jweak JNICALL NewWeakGlobalRef(JNIEnv* env, jobject obj) { enterJVM(); leaveJVM(); NYI(); } +void JNICALL DeleteWeakGlobalRef(JNIEnv* env, jweak ref) { enterJVM(); leaveJVM(); NYI(); } + +jboolean JNICALL ExceptionCheck(JNIEnv* env) { enterJVM(); leaveJVM(); NYI(); } + +jobject JNICALL NewDirectByteBuffer(JNIEnv* env, void* address, jlong capacity) { enterJVM(); leaveJVM(); NYI(); } +void* JNICALL GetDirectBufferAddress(JNIEnv* env, jobject buf) { enterJVM(); leaveJVM(); NYI(); } +jlong JNICALL GetDirectBufferCapacity(JNIEnv* env, jobject buf) { enterJVM(); leaveJVM(); NYI(); } + +jobjectRefType JNICALL GetObjectRefType(JNIEnv* env, jobject obj) { enterJVM(); leaveJVM(); NYI(); } + +struct JNINativeInterface_ jniEnvTable = { + 0, + 0, + 0, + 0, + GetVersion, + DefineClass, + FindClass, + FromReflectedMethod, + FromReflectedField, + ToReflectedMethod, + GetSuperclass, + IsAssignableFrom, + ToReflectedField, + Throw, + ThrowNew, + ExceptionOccurred, + ExceptionDescribe, + ExceptionClear, + FatalError, + PushLocalFrame, + PopLocalFrame, + NewGlobalRef, + DeleteGlobalRef, + DeleteLocalRef, + IsSameObject, + NewLocalRef, + EnsureLocalCapacity, + AllocObject, + NewObject, + NewObjectV, + NewObjectA, + GetObjectClass, + IsInstanceOf, + GetMethodID, + CallObjectMethod, + CallObjectMethodV, + CallObjectMethodA, + CallBooleanMethod, + CallBooleanMethodV, + CallBooleanMethodA, + CallByteMethod, + CallByteMethodV, + CallByteMethodA, + CallCharMethod, + CallCharMethodV, + CallCharMethodA, + CallShortMethod, + CallShortMethodV, + CallShortMethodA, + CallIntMethod, + CallIntMethodV, + CallIntMethodA, + CallLongMethod, + CallLongMethodV, + CallLongMethodA, + CallFloatMethod, + CallFloatMethodV, + CallFloatMethodA, + CallDoubleMethod, + CallDoubleMethodV, + CallDoubleMethodA, + CallVoidMethod, + CallVoidMethodV, + CallVoidMethodA, + CallNonvirtualObjectMethod, + CallNonvirtualObjectMethodV, + CallNonvirtualObjectMethodA, + CallNonvirtualBooleanMethod, + CallNonvirtualBooleanMethodV, + CallNonvirtualBooleanMethodA, + CallNonvirtualByteMethod, + CallNonvirtualByteMethodV, + CallNonvirtualByteMethodA, + CallNonvirtualCharMethod, + CallNonvirtualCharMethodV, + CallNonvirtualCharMethodA, + CallNonvirtualShortMethod, + CallNonvirtualShortMethodV, + CallNonvirtualShortMethodA, + CallNonvirtualIntMethod, + CallNonvirtualIntMethodV, + CallNonvirtualIntMethodA, + CallNonvirtualLongMethod, + CallNonvirtualLongMethodV, + CallNonvirtualLongMethodA, + CallNonvirtualFloatMethod, + CallNonvirtualFloatMethodV, + CallNonvirtualFloatMethodA, + CallNonvirtualDoubleMethod, + CallNonvirtualDoubleMethodV, + CallNonvirtualDoubleMethodA, + CallNonvirtualVoidMethod, + CallNonvirtualVoidMethodV, + CallNonvirtualVoidMethodA, + GetFieldID, + GetObjectField, + GetBooleanField, + GetByteField, + GetCharField, + GetShortField, + GetIntField, + GetLongField, + GetFloatField, + GetDoubleField, + SetObjectField, + SetBooleanField, + SetByteField, + SetCharField, + SetShortField, + SetIntField, + SetLongField, + SetFloatField, + SetDoubleField, + GetStaticMethodID, + CallStaticObjectMethod, + CallStaticObjectMethodV, + CallStaticObjectMethodA, + CallStaticBooleanMethod, + CallStaticBooleanMethodV, + CallStaticBooleanMethodA, + CallStaticByteMethod, + CallStaticByteMethodV, + CallStaticByteMethodA, + CallStaticCharMethod, + CallStaticCharMethodV, + CallStaticCharMethodA, + CallStaticShortMethod, + CallStaticShortMethodV, + CallStaticShortMethodA, + CallStaticIntMethod, + CallStaticIntMethodV, + CallStaticIntMethodA, + CallStaticLongMethod, + CallStaticLongMethodV, + CallStaticLongMethodA, + CallStaticFloatMethod, + CallStaticFloatMethodV, + CallStaticFloatMethodA, + CallStaticDoubleMethod, + CallStaticDoubleMethodV, + CallStaticDoubleMethodA, + CallStaticVoidMethod, + CallStaticVoidMethodV, + CallStaticVoidMethodA, + GetStaticFieldID, + GetStaticObjectField, + GetStaticBooleanField, + GetStaticByteField, + GetStaticCharField, + GetStaticShortField, + GetStaticIntField, + GetStaticLongField, + GetStaticFloatField, + GetStaticDoubleField, + SetStaticObjectField, + SetStaticBooleanField, + SetStaticByteField, + SetStaticCharField, + SetStaticShortField, + SetStaticIntField, + SetStaticLongField, + SetStaticFloatField, + SetStaticDoubleField, + NewString, + GetStringLength, + GetStringChars, + ReleaseStringChars, + NewStringUTF, + GetStringUTFLength, + GetStringUTFChars, + ReleaseStringUTFChars, + GetArrayLength, + NewObjectArray, + GetObjectArrayElement, + SetObjectArrayElement, + NewBooleanArray, + NewByteArray, + NewCharArray, + NewShortArray, + NewIntArray, + NewLongArray, + NewFloatArray, + NewDoubleArray, + GetBooleanArrayElements, + GetByteArrayElements, + GetCharArrayElements, + GetShortArrayElements, + GetIntArrayElements, + GetLongArrayElements, + GetFloatArrayElements, + GetDoubleArrayElements, + ReleaseBooleanArrayElements, + ReleaseByteArrayElements, + ReleaseCharArrayElements, + ReleaseShortArrayElements, + ReleaseIntArrayElements, + ReleaseLongArrayElements, + ReleaseFloatArrayElements, + ReleaseDoubleArrayElements, + GetBooleanArrayRegion, + GetByteArrayRegion, + GetCharArrayRegion, + GetShortArrayRegion, + GetIntArrayRegion, + GetLongArrayRegion, + GetFloatArrayRegion, + GetDoubleArrayRegion, + SetBooleanArrayRegion, + SetByteArrayRegion, + SetCharArrayRegion, + SetShortArrayRegion, + SetIntArrayRegion, + SetLongArrayRegion, + SetFloatArrayRegion, + SetDoubleArrayRegion, + RegisterNatives, + UnregisterNatives, + MonitorEnter, + MonitorExit, + GetJavaVM, + GetStringRegion, + GetStringUTFRegion, + GetPrimitiveArrayCritical, + ReleasePrimitiveArrayCritical, + GetStringCritical, + ReleaseStringCritical, + NewWeakGlobalRef, + DeleteWeakGlobalRef, + ExceptionCheck, + NewDirectByteBuffer, + GetDirectBufferAddress, + GetDirectBufferCapacity, + GetObjectRefType +}; + +} Added: vmkit/branches/mcjit/lib/j3/vm/j3mangler.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3mangler.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3mangler.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3mangler.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,121 @@ +#include "j3/j3mangler.h" +#include "j3/j3class.h" +#include "j3/j3classloader.h" +#include "j3/j3method.h" +#include "j3/j3.h" + +using namespace j3; + +const char* J3Mangler::j3Id = "j3_"; +const char* J3Mangler::javaId = "Java_"; + + +J3Mangler::J3Mangler(J3Class* _from) { + from = _from; + cur = buf; +} + +void J3Mangler::check(uint32_t n) { + next = cur + n; + if((next+1) >= (buf + max)) + J3::internalError(L"unable to mangle: not enough space"); +} + +J3Mangler* J3Mangler::mangleType(J3Method* method) { + J3MethodType* type = method->methodType(from); + + if(type->nbIns()) { + check(2); + cur[0] = '_'; + cur[1] = '_'; + cur = next; + + for(uint32_t i=0; inbIns(); i++) { + check(type->ins(i)->nativeNameLength()); + memcpy(cur, type->ins(i)->nativeName(), type->ins(i)->nativeNameLength()); + cur = next; + } + +#if 0 + check(type->out()->nativeNameLength()); + memcpy(cur, type->out()->nativeName(), type->out()->nativeNameLength()); + cur = next; +#endif + } + check(1); + *cur = 0; + + return this; +} + +J3Mangler* J3Mangler::mangle(J3Method* method) { + check(method->cl()->nativeNameLength() - 3); + memcpy(cur, method->cl()->nativeName() + 1, method->cl()->nativeNameLength() - 3); + *next = '_'; + cur = next+1; + mangle(method->name()); + + return this; +} + +J3Mangler* J3Mangler::mangle(const char* prefix) { + uint32_t length = strlen(prefix); + + check(length); + memcpy(cur, prefix, length); + *next = 0; + cur = next; + + return this; +} + +J3Mangler* J3Mangler::mangle(const vmkit::Name* name) { + next = cur; + for(size_t i=0; ilength(); i++) { + wchar_t c = name->cStr()[i]; + + if(c > 256) { + check(6); + *cur++ = '_'; + *cur++ = '0'; + *cur++ = (c >> 24 & 0xf) + '0'; + *cur++ = (c >> 16 & 0xf) + '0'; + *cur++ = (c >> 8 & 0xf) + '0'; + *cur++ = (c >> 0 & 0xf) + '0'; + } else { + switch(c) { + case '<': + case '>': + case '(': + case ')': + break; + case '_': + check(2); + *cur++ = '_'; + *cur++ = '1'; + break; + case ';': + check(2); + *cur++ = '_'; + *cur++ = '2'; + break; + case '[': + check(2); + *cur++ = '_'; + *cur++ = '3'; + break; + case '/': + c = '_'; + default: + check(1); + *cur++ = c; + } + } + cur = next; + } + + *cur = 0; + + return this; +} + Added: vmkit/branches/mcjit/lib/j3/vm/j3method.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3method.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,436 @@ +#include "j3/j3method.h" +#include "j3/j3class.h" +#include "j3/j3classloader.h" +#include "j3/j3constants.h" +#include "j3/j3.h" +#include "j3/j3mangler.h" +#include "j3/j3thread.h" +#include "j3/j3codegen.h" + +#include "llvm/PassManager.h" + +#include "llvm/IR/Type.h" +#include "llvm/IR/Module.h" +#include "llvm/IR/Function.h" + +#include "llvm/ExecutionEngine/GenericValue.h" +#include "llvm/ExecutionEngine/ExecutionEngine.h" + +#include + +using namespace j3; + +J3MethodType::J3MethodType(J3Type** args, size_t nbArgs) { + _out = args[nbArgs-1]; + _nbIns = nbArgs-1; + memcpy(_ins, args, (nbArgs-1)*sizeof(J3Type*)); + + std::vector in; + for(uint32_t i=0; illvmType()); + _llvmType = llvm::FunctionType::get(out()->llvmType(), in, 0); +} + +J3Method::J3Method(uint16_t access, J3Class* cl, const vmkit::Name* name, const vmkit::Name* sign) { + _access = access; + _cl = cl; + _name = name; + _sign = sign; + _index = -1; +} + +uint32_t J3Method::index() { + return _index; +} + +void* J3Method::fnPtr() { + void* res; + + if(!_compiledFunction) { + //fprintf(stderr, "materializing: %ls::%ls%ls\n", cl()->name()->cStr(), name()->cStr(), sign()->cStr()); + if(!isResolved()) { + if(cl()->loader()->vm()->options()->debugLinking) + fprintf(stderr, "linking %ls::%ls\n", cl()->name()->cStr(), name()->cStr()); + + cl()->initialise(); + if(!isResolved()) + J3::noSuchMethodError(L"unable to find method", cl(), name(), sign()); + } + + J3CodeGen* codeGen = J3CodeGen::create(this); + _compiledFunction = codeGen->generate(); + J3CodeGen::destroy(codeGen); + + cl()->loader()->pm()->run(*_compiledFunction); + + //_compiledFunction->dump(); + + res = cl()->loader()->vm()->ee()->recompileAndRelinkFunction(_compiledFunction); + } else + res = cl()->loader()->vm()->ee()->getPointerToFunction(_compiledFunction); + + return res; +} + +void* J3Method::functionPointerOrTrampoline() { + return _compiledFunction ? fnPtr() : _trampoline; +} + +void J3Method::setResolved(uint32_t index) { + if(isResolved()) + J3::internalError(L"trying to re-resolve a resolved method, should not happen"); + _index = index; +} + +void J3Method::postInitialise(uint32_t access, J3Attributes* attributes) { + if((access & J3Cst::ACC_STATIC) != (_access & J3Cst::ACC_STATIC)) + J3::classFormatError(cl(), L"trying to modify the static flag of %ls", cl()->name()->cStr()); + _access = access; + _attributes = attributes; +} + +J3Method* J3Method::resolve(J3ObjectHandle* obj) { + if(cl()->loader()->vm()->options()->debugLinking) + fprintf(stderr, "virtual linking %ls::%ls\n", cl()->name()->cStr(), name()->cStr()); + vmkit::Names* n = cl()->loader()->vm()->names(); + return cl()->findVirtualMethod(name(), sign()); +} + +void* J3Method::operator new(size_t size, vmkit::BumpAllocator* allocator, size_t trampolineSize) { + return allocator->allocate(size + (trampolineSize - 1)*sizeof(uint8_t)); +} + +J3Method* J3Method::newMethod(vmkit::BumpAllocator* allocator, + uint16_t access, + J3Class* cl, + const vmkit::Name* name, + const vmkit::Name* sign) { + size_t trampolineSize = 48; + + void* tra = (void*)J3ObjectHandle::trampoline; + J3Method* res = new(allocator, trampolineSize) J3Method(access, cl, name, sign); + +#define dd(p, n) ((((uintptr_t)p) >> n) & 0xff) + uint8_t code[] = { + 0x57, // 0: push %rdi + 0x56, // 1: push %rsi + 0x52, // 2: push %rdx + 0x51, // 3: push %rcx + 0x41, 0x50, // 4: push %r8 + 0x41, 0x51, // 6: push %r9 + 0x48, 0x83, 0xc4, 0x08, // 8: sub %esp, 8 + 0x48, 0xbe, dd(res, 0), dd(res, 8), dd(res, 16), dd(res, 24), dd(res, 32), dd(res, 40), dd(res, 48), dd(res, 56), // 12: mov -> %rsi + 0x48, 0xb8, dd(tra, 0), dd(tra, 8), dd(tra, 16), dd(tra, 24), dd(tra, 32), dd(tra, 40), dd(tra, 48), dd(tra, 56), // 22: mov -> %rax + 0xff, 0xd0, // 32: call %rax + 0x48, 0x83, 0xec, 0x08, // 34: add %esp, 8 + 0x41, 0x59, // 38: pop %r9 + 0x41, 0x58, // 40: pop %r8 + 0x59, // 42: pop %rcx + 0x5a, // 43: pop %rdx + 0x5e, // 44: pop %rsi + 0x5f, // 45: pop %rdi + 0xff, 0xe0 // 46: jmp %rax + // total: 48 + }; +#undef dd + + memcpy(res->_trampoline, code, trampolineSize); + + return res; +} + +J3Value J3Method::internalInvoke(bool statically, std::vector* args) { + J3Method* target; + + if(statically) + target = this; + else { + /* can not use trampoline here */ + J3ObjectHandle* self = (J3ObjectHandle*)(*args)[0].PointerVal; + target = resolve(self); + } + + if(!_compiledFunction) + fnPtr(); /* ensure that the function is fully compiled */ + llvm::GenericValue res = cl()->loader()->vm()->ee()->runFunction(_compiledFunction, *args); + + J3Value holder; + J3* vm = cl()->loader()->vm(); + J3Type* cur = methodType()->out(); + + if(cur == vm->typeBoolean) + holder.valBoolean = (bool)res.IntVal.getZExtValue(); + else if(cur == vm->typeByte) + holder.valByte = (int8_t)res.IntVal.getZExtValue(); + else if(cur == vm->typeShort) + holder.valShort = (int16_t)res.IntVal.getZExtValue(); + else if(cur == vm->typeChar) + holder.valChar = (uint16_t)res.IntVal.getZExtValue(); + else if(cur == vm->typeInteger) + holder.valInteger = (int32_t)res.IntVal.getZExtValue(); + else if(cur == vm->typeLong) + holder.valLong = res.IntVal.getZExtValue(); + else if(cur == vm->typeFloat) + holder.valFloat = res.FloatVal; + else if(cur == vm->typeDouble) + holder.valDouble = res.FloatVal; + else if(cur != vm->typeVoid) + holder.valObject = J3Thread::get()->push((J3Object*)res.PointerVal); + + return holder; +} + +J3Value J3Method::internalInvoke(bool statically, J3ObjectHandle* handle, va_list va) { + std::vector args(methodType()->nbIns()); + J3* vm = cl()->loader()->vm(); + J3Type* cur; + uint32_t i = 0; + + if(handle) + args[i++].PointerVal = handle->obj(); + + for(; inbIns(); i++) { /* have to avoid collection at this point */ + cur = methodType()->ins(i); + + if(cur == vm->typeBoolean) + args[i].IntVal = va_arg(va, bool); + else if(cur == vm->typeByte) + args[i].IntVal = va_arg(va, int8_t); + else if(cur == vm->typeShort) + args[i].IntVal = va_arg(va, int16_t); + else if(cur == vm->typeChar) + args[i].IntVal = va_arg(va, uint16_t); + else if(cur == vm->typeInteger) + args[i].IntVal = va_arg(va, int32_t); + else if(cur == vm->typeLong) + args[i].IntVal = va_arg(va, int64_t); + else if(cur == vm->typeFloat) + args[i].FloatVal = va_arg(va, float); + else if(cur == vm->typeDouble) + args[i].FloatVal = va_arg(va, double); + else + args[i].PointerVal = va_arg(va, J3ObjectHandle*)->obj(); + } + + return internalInvoke(statically, &args); +} + +J3Value J3Method::internalInvoke(bool statically, J3ObjectHandle* handle, J3Value* inArgs) { + std::vector args(methodType()->nbIns()); + J3* vm = cl()->loader()->vm(); + J3Type* cur; + uint32_t i = 0; + + if(handle) + args[i++].PointerVal = handle->obj(); + + for(; inbIns(); i++) { /* have to avoid collection at this point */ + cur = methodType()->ins(i); + + if(cur == vm->typeBoolean) + args[i].IntVal = inArgs[i].valBoolean; + else if(cur == vm->typeByte) + args[i].IntVal = inArgs[i].valByte; + else if(cur == vm->typeShort) + args[i].IntVal = inArgs[i].valShort; + else if(cur == vm->typeChar) + args[i].IntVal = inArgs[i].valChar; + else if(cur == vm->typeInteger) + args[i].IntVal = inArgs[i].valInteger; + else if(cur == vm->typeLong) + args[i].IntVal = inArgs[i].valLong; + else if(cur == vm->typeFloat) + args[i].FloatVal = inArgs[i].valFloat; + else if(cur == vm->typeDouble) + args[i].FloatVal = inArgs[i].valDouble; + else + args[i].PointerVal = inArgs[i].valObject->obj(); + } + + return internalInvoke(statically, &args); +} + +J3Value J3Method::invokeStatic(J3Value* args) { + return internalInvoke(1, 0, args); +} + +J3Value J3Method::invokeSpecial(J3ObjectHandle* handle, J3Value* args) { + return internalInvoke(1, handle, args); +} + +J3Value J3Method::invokeVirtual(J3ObjectHandle* handle, J3Value* args) { + return internalInvoke(0, handle, args); +} + +J3Value J3Method::invokeStatic(va_list va) { + return internalInvoke(1, 0, va); +} + +J3Value J3Method::invokeSpecial(J3ObjectHandle* handle, va_list va) { + return internalInvoke(1, handle, va); +} + +J3Value J3Method::invokeVirtual(J3ObjectHandle* handle, va_list va) { + return internalInvoke(0, handle, va); +} + +J3Value J3Method::invokeStatic(...) { + va_list va; + va_start(va, this); + J3Value res = invokeStatic(va); + va_end(va); + return res; +} + +J3Value J3Method::invokeSpecial(J3ObjectHandle* handle, ...) { + va_list va; + va_start(va, this); + J3Value res = invokeSpecial(handle, va); + va_end(va); + return res; +} + +J3Value J3Method::invokeVirtual(J3ObjectHandle* handle, ...) { + va_list va; + va_start(va, this); + J3Value res = invokeVirtual(handle, va); + va_end(va); + return res; +} + +J3MethodType* J3Method::methodType(J3Class* from) { + if(!_methodType) { + const vmkit::Name* realSign = sign(); + J3ClassLoader* loader = cl()->loader(); + + if(!J3Cst::isStatic(access())) + realSign = J3Cst::rewrite(loader->vm(), cl()->name(), sign()); + + _methodType = loader->getMethodType(from ? from : cl(), realSign); + } + + return _methodType; +} + +void J3Method::buildLLVMNames(J3Class* from) { + J3Mangler mangler(from); + + mangler.mangle(mangler.j3Id)->mangle(this)->mangleType(this); + + _llvmAllNamesLength = mangler.length() + 18; + _llvmAllNames = (char*)cl()->loader()->allocator()->allocate(_llvmAllNamesLength + 1); + memcpy(_llvmAllNames, "method_descriptor_", 18); + memcpy(_llvmAllNames+18, mangler.cStr(), mangler.length()); + _llvmAllNames[_llvmAllNamesLength] = 0; +} + +size_t J3Method::llvmFunctionNameLength(J3Class* from) { + llvmFunctionName(from); + return _llvmAllNamesLength - 18; +} + +char* J3Method::llvmFunctionName(J3Class* from) { + if(!_llvmAllNames) + buildLLVMNames(from ? from : cl()); + return _llvmAllNames + 18; +} + +char* J3Method::llvmDescriptorName(J3Class* from) { + if(!_llvmAllNames) + buildLLVMNames(from ? from : cl()); + return _llvmAllNames; +} + +llvm::GlobalValue* J3Method::llvmDescriptor(llvm::Module* module) { + if(!_nomcjitDescriptor) { + J3ClassLoader* loader = cl()->loader(); + _nomcjitDescriptor = llvm::cast(module->getOrInsertGlobal(llvmDescriptorName(), loader->vm()->typeJ3Method)); + loader->vm()->ee()->addGlobalMapping(_nomcjitDescriptor, this); + } + + return _nomcjitDescriptor; +} + +llvm::Function* J3Method::llvmFunction(bool isStub, llvm::Module* module, J3Class* from) { + if(!_nomcjitFunction) { + llvm::Function* res; + + if(isStub && !_compiledFunction) { + char id[llvmFunctionNameLength() + 16]; + memcpy(id, llvmFunctionName(), llvmFunctionNameLength()); + memcpy(id + llvmFunctionNameLength(), "_stub", 6); + res = (llvm::Function*)module->getOrInsertFunction(id, methodType(from ? from : cl())->llvmType()); + } else + res = (llvm::Function*)module->getOrInsertFunction(llvmFunctionName(from), methodType(from ? from : cl())->llvmType()); + + _nomcjitFunction = res; + cl()->loader()->vm()->ee()->addGlobalMapping(_nomcjitFunction, functionPointerOrTrampoline()); + } + + return _nomcjitFunction; +} + +void J3Method::dump() { + printf("Method: %ls %ls::%ls\n", sign()->cStr(), cl()->name()->cStr(), name()->cStr()); +} + +void J3Method::registerNative(void* fnPtr) { + if(_nativeFnPtr) + J3::noSuchMethodError(L"unable to dynamically modify a native function", cl(), name(), sign()); + _nativeFnPtr = fnPtr; +} + +llvm::Type* J3Method::doNativeType(J3Type* type) { + llvm::Type* t = type->llvmType(); + + if(t->isPointerTy()) + return cl()->loader()->vm()->typeJ3ObjectHandlePtr; + else + return t; +} + +llvm::Function* J3Method::nativeLLVMFunction(llvm::Module* module) { + J3ClassLoader* loader = cl()->loader(); + J3Mangler mangler(cl()); + + mangler.mangle(mangler.javaId)->mangle(this); + uint32_t length = mangler.length(); + mangler.mangleType(this); + + void* fnPtr = _nativeFnPtr; + + if(!fnPtr) + fnPtr = loader->lookupNativeFunctionPointer(this, mangler.cStr()); + + if(!fnPtr) { + mangler.cStr()[length] = 0; + fnPtr = loader->lookupNativeFunctionPointer(this, mangler.mangleType(this)->cStr()); + } + + if(!fnPtr) + J3::linkageError(this); + + J3MethodType* type = methodType(); + std::vector nativeIns; + llvm::Type* nativeOut; + + nativeIns.push_back(loader->vm()->typeJNIEnvPtr); + + if(J3Cst::isStatic(access())) + nativeIns.push_back(doNativeType(loader->vm()->classClass)); + + for(int i=0; inbIns(); i++) + nativeIns.push_back(doNativeType(type->ins(i))); + + nativeOut = doNativeType(type->out()); + + llvm::FunctionType* fType = llvm::FunctionType::get(nativeOut, nativeIns, 0); + llvm::Function* res = llvm::Function::Create(fType, + llvm::GlobalValue::ExternalLinkage, + mangler.cStr(), + module); + + loader->vm()->ee()->addGlobalMapping(res, fnPtr); + + return res; +} Added: vmkit/branches/mcjit/lib/j3/vm/j3object.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3object.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3object.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3object.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,473 @@ +#include + +#include "llvm/IR/DataLayout.h" +#include "llvm/ExecutionEngine/ExecutionEngine.h" + +#include "vmkit/allocator.h" +#include "vmkit/gc.h" +#include "j3/j3object.h" +#include "j3/j3method.h" +#include "j3/j3class.h" +#include "j3/j3classloader.h" +#include "j3/j3.h" +#include "j3/j3constants.h" +#include "j3/j3thread.h" + +using namespace j3; + +/* + * --- J3TypeChecker --- + */ +void J3TypeChecker::dump() { + fprintf(stderr, " offset: %u\n", offset); + for(uint32_t i=0; itype()->name()->cStr()); + } + for(uint32_t i=0; itype()->name()->cStr()); + } + if(display[cacheOffset]) + fprintf(stderr, " cache: %ls\n", display[cacheOffset]->type()->name()->cStr()); +} + +/* + * --- J3VirtualTable --- + */ +J3VirtualTable* J3VirtualTable::create(J3Layout* layout) { + return new(layout->loader()->allocator(), 0) J3VirtualTable(layout, layout, 0, 0, 0); +} + +J3VirtualTable* J3VirtualTable::create(J3Class* cl) { + J3Class* super = cl->super(); + uint32_t base = cl == super ? 0 : super->vt()->nbVirtualMethods(); + uint32_t n = base; + + super->resolve(); + + J3Method* pm[cl->nbMethods()]; + + for(uint32_t i=0; inbMethods(); i++) { + J3Method* meth = cl->methods()[i]; + J3Method* parent = cl == super ? 0 : super->findVirtualMethod(meth->name(), meth->sign(), 0); + + if(parent) { + pm[i] = parent; + meth->setResolved(parent->index()); + } else { + pm[i] = meth; + meth->setResolved(n); + n++; + } + } + + J3VirtualTable* res = new(cl->loader()->allocator(), n) + J3VirtualTable(cl, cl->super(), (J3Type**)cl->interfaces(), cl->nbInterfaces(), J3Cst::isInterface(cl->access()) ? 1 : 0); + + + /* virtual table */ + res->_nbVirtualMethods = n; + if(super != cl) /* super->vt() is not yet allocated for Object */ + memcpy(res->_virtualMethods, super->vt()->_virtualMethods, sizeof(void*)*super->vt()->nbVirtualMethods()); + + for(uint32_t i=0; inbMethods(); i++) + res->_virtualMethods[pm[i]->index()] = pm[i]->functionPointerOrTrampoline(); + + return res; +} + +J3VirtualTable* J3VirtualTable::create(J3ArrayClass* cl) { + J3Class* objClass = cl->loader()->vm()->objectClass; + J3Type* super = cl->component(); + J3Type* base = super; + uint32_t dim = 1; + J3Type** secondaries = 0; + uint32_t nbSecondaries = 0; + bool isSecondary = 0; + + // for objects for primitives + // Integer[][] + // Number[][] + ifces[][] int[][][] + // Object[][] Object[][] + // Object[] int[] Object[] + // Object + Serializable/Cloneable + + while(base->isArrayClass()) { + base = base->asArrayClass()->component(); + dim++; + } + + if(base->isPrimitive()) { + super = objClass->getArray(dim-1); + nbSecondaries = cl->loader()->vm()->nbArrayInterfaces; + secondaries = (J3Type**)cl->loader()->allocator()->allocate(nbSecondaries*sizeof(J3Type*)); + for(uint32_t i=0; iloader()->vm()->arrayInterfaces[i]; + if(dim > 1) + secondaries[i] = secondaries[i]->getArray(dim-1); + } + } else if(base == objClass) { + nbSecondaries = cl->loader()->vm()->nbArrayInterfaces; + secondaries = (J3Type**)alloca(nbSecondaries*sizeof(J3Type*)); + for(uint32_t i=0; iloader()->vm()->arrayInterfaces[i]; + if(dim > 1) + secondaries[i] = secondaries[i]->getArray(dim - 1); + } + } else { + J3Class* baseClass = base->asClass(); + baseClass->resolve(); + if(J3Cst::isInterface(baseClass->access())) + isSecondary = 1; + super = baseClass->super()->getArray(dim); + super->resolve(); + //printf("%ls super is %ls (%d)\n", cl->name()->cStr(), super->name()->cStr(), isSecondary); + + uint32_t n = baseClass->vt()->checker.nbSecondaryTypes; + secondaries = (J3Type**)alloca(n*sizeof(J3Type*)); + + for(uint32_t i=0; ivt()->checker.secondaryTypes[i]->type(); + if(secondaries[i] != baseClass) { /* don't add myself */ + secondaries[nbSecondaries] = secondaries[nbSecondaries]->getArray(dim); + nbSecondaries++; + } + } + } + + super->resolve(); + + J3VirtualTable* res = new(cl->loader()->allocator(), 0) J3VirtualTable(cl, super, secondaries, nbSecondaries, isSecondary); + //memcpy(_virtualMethods, objClass->vt()->virtualMethods(), sizeof(void*)*objClass->nbVt()); + + return res; +} + +J3VirtualTable* J3VirtualTable::create(J3Primitive* prim) { + return new(prim->loader()->allocator(), 0) J3VirtualTable(prim, prim, 0, 0, 0); +} + +void* J3VirtualTable::operator new(size_t unused, vmkit::BumpAllocator* allocator, size_t n) { + return allocator->allocate(sizeof(J3VirtualTable) + n*sizeof(void*) - sizeof(void*)); +} + +J3VirtualTable::J3VirtualTable(J3Type* type, J3Type* super, J3Type** interfaces, uint32_t nbInterfaces, bool isSecondary) { + _type = type; + + //printf("*** Building the vt of %ls based on %ls\n", type->name()->cStr(), super->name()->cStr()); + + if(super == type) { + checker.offset = 0; + checker.display[checker.offset] = this; + if(nbInterfaces) + J3::internalError(L"a root J3VirtualTable should not have interfaces"); + } else { + uint32_t parentDisplayLength = super->vt()->checker.offset + 1; + + //printf("%ls (%p) secondary: %p %p (%d)\n", type->name()->cStr(), this, checker.secondaryTypes, checker.display[6], parentDisplayLength); + + if(parentDisplayLength >= J3TypeChecker::cacheOffset) + isSecondary = 1; + + memcpy(checker.display, super->vt()->checker.display, parentDisplayLength*sizeof(J3VirtualTable*)); + + checker.nbSecondaryTypes = super->vt()->checker.nbSecondaryTypes + nbInterfaces + isSecondary; + checker.secondaryTypes = (J3VirtualTable**)super->loader()->allocator()->allocate(checker.nbSecondaryTypes*sizeof(J3VirtualTable*)); + + //printf("%ls: %d - %d %d\n", type->name()->cStr(), isSecondary, parentDisplayLength, J3TypeChecker::displayLength); + if(isSecondary) { + checker.offset = J3TypeChecker::cacheOffset; + checker.secondaryTypes[0] = this; + } else { + checker.offset = parentDisplayLength; + checker.display[checker.offset] = this; + } + + for(uint32_t i=0; iname()->cStr(), sec->name()->cStr(), isSecondary+i); + sec->resolve(); + checker.secondaryTypes[isSecondary+i] = sec->vt(); + } + + memcpy(checker.secondaryTypes + nbInterfaces + isSecondary, + super->vt()->checker.secondaryTypes, + super->vt()->checker.nbSecondaryTypes*sizeof(J3VirtualTable*)); + } + + //dump(); +} + +bool J3VirtualTable::slowIsAssignableTo(J3VirtualTable* parent) { + for(uint32_t i=0; ichecker.offset; + if(checker.display[parentOffset] == parent) + return true; + else if(parentOffset != J3TypeChecker::cacheOffset) + return false; + else if(parent == this) + return true; + else + return slowIsAssignableTo(parent); +} + +void J3VirtualTable::dump() { + fprintf(stderr, "VirtualTable: %s%ls (%p)\n", + type()->isLayout() && !type()->isClass() ? "static_" : "", + type()->name()->cStr(), this); + checker.dump(); + +} + +/* + * --- J3Object --- + */ +J3VirtualTable* J3Object::vt() { + return _vt; +} + +uintptr_t* J3Object::header() { + return &_header; +} + +J3Object* J3Object::allocate(J3VirtualTable* vt, size_t n) { + J3Object* res = (J3Object*)vmkit::GC::allocate(n); + res->_vt = vt; + return res; +} + +J3Object* J3Object::doNewNoInit(J3Class* cl) { + return allocate(cl->vt(), cl->size()); +} + +J3Object* J3Object::doNew(J3Class* cl) { + cl->initialise(); + return doNewNoInit(cl); +} + +/* + * --- J3ArrayObject --- + */ +J3Object* J3ArrayObject::doNew(J3ArrayClass* cl, uint32_t length) { + llvm::DataLayout* layout = cl->loader()->vm()->dataLayout(); + J3ArrayObject* res = + (J3ArrayObject*)allocate(cl->vt(), + layout->getTypeAllocSize(cl->llvmType()->getContainedType(0)) + + layout->getTypeAllocSize(cl->component()->llvmType()) * length); + + res->_length = length; + + return res; +} + +/* + * J3ObjectHandle + */ +uint32_t J3ObjectHandle::hashCode() { + do { + uintptr_t oh = *obj()->header(); + uintptr_t res = oh; + if(res) + return res; + uintptr_t nh = oh + 256; + __sync_val_compare_and_swap(obj()->header(), oh, nh); + } while(1); +} + +J3ObjectHandle* J3ObjectHandle::allocate(J3VirtualTable* vt, size_t n) { + J3Object* res = J3Object::allocate(vt, n); + return J3Thread::get()->push(res); +} + +J3ObjectHandle* J3ObjectHandle::doNewObject(J3Class* cl) { + J3Object* res = J3Object::doNew(cl); + return J3Thread::get()->push(res); +} + +J3ObjectHandle* J3ObjectHandle::doNewArray(J3ArrayClass* cl, uint32_t length) { + J3Object* res = J3ArrayObject::doNew(cl, length); + return J3Thread::get()->push(res); +} + + + +#define defAccessor(name, ctype, llvmtype) \ + void J3ObjectHandle::rawSet##name(uint32_t offset, ctype value) { \ + *((ctype*)((uintptr_t)obj() + offset)) = value; \ + } \ + \ + ctype J3ObjectHandle::rawGet##name(uint32_t offset) { \ + return *((ctype*)((uintptr_t)obj() + offset)); \ + } \ + \ + void J3ObjectHandle::set##name(J3Field* field, ctype value) { \ + const llvm::StructLayout* layout = \ + obj()->vt()->type()->loader()->vm()->dataLayout()-> \ + getStructLayout((llvm::StructType*)(obj()->vt()->type()->llvmType()->getContainedType(0))); \ + uint32_t offset = layout->getElementOffset(field->num()); \ + rawSet##name(offset, value); \ + } \ + \ + ctype J3ObjectHandle::get##name(J3Field* field) { \ + const llvm::StructLayout* layout = \ + obj()->vt()->type()->loader()->vm()->dataLayout()-> \ + getStructLayout((llvm::StructType*)(obj()->vt()->type()->llvmType()->getContainedType(0))); \ + uint32_t offset = layout->getElementOffset(field->num()); \ + return rawGet##name(offset); \ + } \ + \ + void J3ObjectHandle::set##name##At(uint32_t idx, ctype value) { \ + rawSet##name(sizeof(J3ArrayObject) + idx*sizeof(ctype), value); \ + } \ + \ + ctype J3ObjectHandle::get##name##At(uint32_t idx) { \ + return rawGet##name(sizeof(J3ArrayObject) + idx*sizeof(ctype)); \ + } + +onJavaPrimitives(defAccessor) + +#undef defAccessor + +void J3ObjectHandle::rawSetObject(uint32_t offset, J3ObjectHandle* value) { + *((J3Object**)((uintptr_t)obj() + offset)) = value->obj(); +} + +J3ObjectHandle* J3ObjectHandle::rawGetObject(uint32_t offset) { + return J3Thread::get()->push(*((J3Object**)((uintptr_t)obj() + offset))); +} + +void J3ObjectHandle::setObject(J3Field* field, J3ObjectHandle* value) { + const llvm::StructLayout* layout = + obj()->vt()->type()->loader()->vm()->dataLayout()-> + getStructLayout((llvm::StructType*)(obj()->vt()->type()->llvmType()->getContainedType(0))); + uint32_t offset = layout->getElementOffset(field->num()); + rawSetObject(offset, value); +} + +J3ObjectHandle* J3ObjectHandle::getObject(J3Field* field) { + const llvm::StructLayout* layout = + obj()->vt()->type()->loader()->vm()->dataLayout()-> + getStructLayout((llvm::StructType*)(obj()->vt()->type()->llvmType()->getContainedType(0))); + return rawGetObject(layout->getElementOffset(field->num())); +} + +void J3ObjectHandle::setObjectAt(uint32_t idx, J3ObjectHandle* value) { + rawSetObject(sizeof(J3ArrayObject) + idx*sizeof(J3Object*), value); +} + +J3ObjectHandle* J3ObjectHandle::getObjectAt(uint32_t idx) { + return rawGetObject(sizeof(J3ArrayObject) + idx*sizeof(J3Object*)); +} + +void* J3ObjectHandle::trampoline(J3Object* obj, J3Method* target) { + J3ObjectHandle* prev = J3Thread::get()->tell(); + J3ObjectHandle* handle = J3Thread::get()->push(obj); + + void* res = target->fnPtr(); + + if(!J3Cst::isStatic(target->access())) + handle->vt()->virtualMethods()[target->index()] = res; + + return res; +} + +/* + * J3FixedPoint + */ +J3FixedPoint::J3FixedPoint(vmkit::BumpAllocator* _allocator) { + pthread_mutex_init(&mutex, 0); + allocator = _allocator; + head = 0; + createNode(); +} + +void J3FixedPoint::unsyncEnsureCapacity(uint32_t capacity) { + J3ObjectHandle* reserve = head->top + capacity; + if(reserve > head->max) + createNode(capacity); +} + +void J3FixedPoint::createNode(uint32_t capacity) { + uint64_t size = capacity * sizeof(J3Object*) + sizeof(J3FixedPointNode); + J3FixedPointNode* nn = (J3FixedPointNode*)allocator->allocate(size); + nn->top = (J3ObjectHandle*)(nn + 1); + nn->max = (J3ObjectHandle*)((uintptr_t)nn + size); + nn->nextFree = 0; + nn->nextBusy = head; + if(head) + head->nextFree = nn; + head = nn; +} + +J3ObjectHandle* J3FixedPoint::syncPush(J3Object* obj) { + J3FixedPointNode* cur = head; + J3ObjectHandle* res = (J3ObjectHandle*)__sync_fetch_and_add((uintptr_t*)&cur->top, (uintptr_t)sizeof(J3ObjectHandle)); + + if(res >= cur->max) { + pthread_mutex_lock(&mutex); + if(cur->nextFree) + head = cur->nextFree; + else + createNode(); + pthread_mutex_unlock(&mutex); + return syncPush(obj); + } else { + res->_obj = obj; + return res; + } +} + +J3ObjectHandle* J3FixedPoint::unsyncPush(J3Object* obj) { + J3ObjectHandle* res = head->top++; + + if(res >= head->max) { + if(head->nextFree) + head = head->nextFree; + else + createNode(); + return unsyncPush(obj); + } else { + res->_obj = obj; + return res; + } +} + +void J3FixedPoint::unsyncPop() { + J3ObjectHandle* res = head->top - 1; + if(res < (J3ObjectHandle*)(head + 1)) { + head = head->nextBusy; + head->top = (J3ObjectHandle*)(head+1); + } else + head->top = res; +} + +void J3FixedPoint::unsyncRestore(J3ObjectHandle* obj) { + while(obj <= (J3ObjectHandle*)head || obj > head->max) { + head = head->nextBusy; + head->top = (J3ObjectHandle*)(head+1); + } + head->top = obj; +} + + Added: vmkit/branches/mcjit/lib/j3/vm/j3options.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3options.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3options.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3options.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,160 @@ +#include "j3/j3options.h" + +#include +#include +#include + +using namespace j3; + +J3Options::J3Options() { + assertionsEnabled = 1; + selfBitCodePath = "/Users/gthomas/research/vmkit4/vmkit/Debug+Asserts/lib/libjvm.bc"; + rtJar = "/Users/gthomas/research/vmkit4/jdk8/build/macosx-x86_64-normal-server-release/images/lib/rt.jar"; + + debugEnterIndent = 1; + + genDebugExecute = 1; + debugExecute = 0; + debugLoad = 0; + debugResolve = 0; + debugIniting = 0; + debugTranslate = 1; + debugLinking = 1; +} + +#define nyi(cmd) ({ fprintf(stderr, "option '%s' not yet implemented\n", cmd); }) + +J3CmdLineParser::J3CmdLineParser(J3Options* _options, int _argc, char** _argv) { + options = _options; + argc = _argc; + argv = _argv; +} + +#define opteq(opt) (!strcmp(argv[cur], opt)) +#define optbeg(opt) (!memcmp(argv[cur], opt, strlen(opt))) + +void J3CmdLineParser::process() { + cur = 1; + + while(cur < argc) { + if(opteq("-jar")) { + nyi("-jar"); + return; + } else if(opteq("-cp") || opteq("-classpath")) + nyi("-cp/-classpath"); + else if(optbeg("-D")) + nyi("-D="); + else if(opteq("-verbose:class")) + nyi("-versbose:class"); + else if(opteq("-verbose:gc")) + nyi("-versbose:gc"); + else if(opteq("-verbose:jni")) + nyi("-versbose:jni"); + else if(opteq("-verbose")) + nyi("-versbose"); + else if(optbeg("-version:")) + nyi("-version:"); + else if(opteq("-version")) + nyi("-version"); + else if(opteq("-showversion")) + nyi("showversion"); + else if(opteq("-jre-restrict-search")) + nyi("-jre-restrict-search"); + else if(opteq("-no-jre-restrict-search")) + nyi("-no-jre-restrict-search"); + else if(opteq("-?") || opteq("-help")) + help(); + else if(optbeg("-X")) + nyi("-X"); + else if(optbeg("-ea:") || optbeg("-enableassertions:")) + nyi("-ea:/-enableassertions:"); + else if(opteq("-ea") || opteq("-enableassertions")) + options->assertionsEnabled = 1; + else if(optbeg("-da:") || optbeg("-disableassertions:")) + nyi("-da:/-disableassertions:"); + else if(opteq("-da") || opteq("-disableassertions")) + options->assertionsEnabled = 0; + else if(opteq("-esa") || opteq("-enablesystemassertions")) + nyi("-esa/-enablesystemassertions"); + else if(opteq("-dsa") || opteq("-disablesystemassertions")) + nyi("-dsa/-disablesystemassertions"); + else if(optbeg("-agentlib:")) + nyi("-agentlib:"); + else if(optbeg("-agentpath:")) + nyi("-agentpath:"); + else if(optbeg("-javaagent:")) + nyi("-javaagent:"); + else if(optbeg("-")) + help(); + else { + nyi("class args"); + return; + } + cur++; + } + + help(); +} + +void J3CmdLineParser::help() { + const char* cmd = "j3"; + fprintf(stdout, + "Usage: %s [-options] class [args...]\n" + " (to execute a class)\n" + " or %s [-options] -jar jarfile [args...]\n" + " (to execute a jar file)\n" + "where options include:\n" + // " -d32 use a 32-bit data model if available\n" + // " -d64 use a 64-bit data model if available\n" + // " -server to select the \"server\" VM\n" + // " -zero to select the \"zero\" VM\n" + // " -jamvm to select the \"jamvm\" VM\n" + // " -avian to select the \"avian\" VM\n" + // " The default VM is server,\n" + // " because you are running on a server-class machine.\n" + " -cp \n" + " -classpath \n" + " separated list of directories, JAR archives,\n" + " and ZIP archives to search for class files.\n" + " -D=\n" + " set a system property\n" + // " -verbose:[class|gc|jni]\n" + // " enable verbose output\n" + " -version print product version and exit\n" + // " -version:\n" + // " require the specified version to run\n" + // " -showversion print product version and continue\n" + // " -jre-restrict-search | -no-jre-restrict-search\n" + // " include/exclude user private JREs in the version search\n" + " -? -help print this help message\n" + // " -X print help on non-standard options\n" + " -ea[:...|:]\n" + " -enableassertions[:...|:]\n" + " enable assertions with specified granularity\n" + " -da[:...|:]\n" + " -disableassertions[:...|:]\n" + " disable assertions with specified granularity\n" + // " -esa | -enablesystemassertions\n" + // " enable system assertions\n" + // " -dsa | -disablesystemassertions\n" + // " disable system assertions\n" + // " -agentlib:[=]\n" + // " load native agent library , e.g. -agentlib:hprof\n" + // " see also, -agentlib:jdwp=help and -agentlib:hprof=help\n" + // " -agentpath:[=]\n" + // " load native agent library by full pathname\n" + // " -javaagent:[=]\n" + // " load Java programming language agent, see java.lang.instrument\n" + // " -splash:\n" + // " show splash screen with specified image\n" + , cmd, cmd + ); + exit(0); +} + +void J3Options::process(int argc, char** argv) { + J3CmdLineParser* p = new J3CmdLineParser(this, argc, argv); + p->process(); + delete p; +} + Added: vmkit/branches/mcjit/lib/j3/vm/j3reader.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3reader.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3reader.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3reader.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,72 @@ +//===--------------- J3Reader.cpp - Open and read files ---------------------===// +// +// The VMKit project +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#include "j3/j3reader.h" +#include "j3/j3zip.h" + +using namespace j3; + +const int J3Reader::SeekSet = SEEK_SET; +const int J3Reader::SeekCur = SEEK_CUR; +const int J3Reader::SeekEnd = SEEK_END; + +J3ClassBytes* J3Reader::openFile(vmkit::BumpAllocator* a, const char* path) { + J3ClassBytes* res = NULL; + FILE* fp = fopen(path, "r"); + if (fp != 0) { + fseek(fp, 0, SeekEnd); + long nbb = ftell(fp); + fseek(fp, 0, SeekSet); + res = new (a, nbb) J3ClassBytes(nbb); + if (fread(res->elements, nbb, 1, fp) == 0) { + fprintf(stderr, "fread error\n"); + abort(); + } + fclose(fp); + } + return res; +} + +J3ClassBytes* J3Reader::openZip(vmkit::BumpAllocator* allocator, J3ZipArchive* archive, + const char* filename) { + J3ClassBytes* res = 0; + J3ZipFile* file = archive->getFile(filename); + if (file != 0) { + res = new (allocator, file->ucsize) J3ClassBytes(file->ucsize); + if (archive->readFile(res, file) != 0) { + return res; + } + } + return NULL; +} + +void J3Reader::seek(uint32_t pos, int from) { + uint32_t n = 0; + uint32_t start = min; + uint32_t end = max; + + if (from == SeekCur) n = cursor + pos; + else if (from == SeekSet) n = start + pos; + else if (from == SeekEnd) n = end + pos; + + + assert(n >= start && n <= end && "out of range"); + + cursor = n; +} + +bool J3Reader::adjustSize(uint32_t length) { + if(cursor + length >= max) + return 0; + + max = cursor + length; + + return 1; +} Added: vmkit/branches/mcjit/lib/j3/vm/j3thread.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3thread.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3thread.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3thread.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,39 @@ +#include "j3/j3thread.h" +#include "j3/j3.h" + +using namespace j3; + +J3Thread::J3Thread(J3* vm, vmkit::BumpAllocator* allocator) : + Thread(vm, allocator), + _fixedPoint(allocator) { + _jniEnv.functions = &jniEnvTable; +} + +J3Thread* J3Thread::create(J3* j3) { + vmkit::BumpAllocator* allocator = vmkit::BumpAllocator::create(); + return new(allocator) J3Thread(j3, allocator); +} + +void J3Thread::ensureCapacity(uint32_t capacity) { + _fixedPoint.unsyncEnsureCapacity(capacity); +} + +J3ObjectHandle* J3Thread::push(J3ObjectHandle* handle) { + return _fixedPoint.unsyncPush(handle); +} + +J3ObjectHandle* J3Thread::push(J3Object* obj) { + return _fixedPoint.unsyncPush(obj); +} + +J3ObjectHandle* J3Thread::tell() { + return _fixedPoint.unsyncTell(); +} + +void J3Thread::restore(J3ObjectHandle* obj) { + _fixedPoint.unsyncRestore(obj); +} + +J3Thread* J3Thread::get() { + return (J3Thread*)Thread::get(); +} Added: vmkit/branches/mcjit/lib/j3/vm/j3zip.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3zip.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3zip.cc (added) +++ vmkit/branches/mcjit/lib/j3/vm/j3zip.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,235 @@ +//===----------------- Zip.cpp - Interface with zlib ----------------------===// +// +// The VMKit project +// +//===----------------------------------------------------------------------===// + +#include + +#include "j3/j3reader.h" +#include "j3/j3zip.h" + +using namespace j3; + +J3ZipArchive::J3ZipArchive(J3ClassBytes* bytes, vmkit::BumpAllocator* a) : + allocator(a), filetable(vmkit::Util::char_less, a) { + this->bytes = bytes; + findOfscd(); + if (ofscd > -1) addFiles(); +} + +J3ZipFile* J3ZipArchive::getFile(const char* filename) { + table_iterator End = filetable.end(); + table_iterator I = filetable.find(filename); + return I != End ? I->second : 0; +} + + +#define END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE 18 +#define CENTRAL_DIRECTORY_FILE_HEADER_SIZE 42 +#define LOCAL_FILE_HEADER_SIZE 26 + +#define C_FILENAME_LENGTH 24 +#define C_UCSIZE 20 +#define C_CSIZE 16 +#define C_EXTRA_FIELD_LENGTH 26 +#define C_FILE_COMMENT_LENGTH 28 +#define C_ROLH 38 +#define C_COMPRESSION_METHOD 6 + +#define L_FILENAME_LENGTH 22 +#define L_EXTRA_FIELD_LENGTH 24 + +#define E_OFFSET_START_CENTRAL_DIRECTORY 12 +#define HDR_ENDCENTRAL "PK\005\006" +#define HDR_CENTRAL "PK\001\002" +#define HDR_LOCAL "PK\003\004" +#define PATH_SEPARATOR '/' +#define ZIP_STORE 0 +#define ZIP_DEFLATE 8 +#define DEF_WBITS 15 + +static uint32_t readEndianDep4(J3Reader& reader) { + uint8_t one = reader.readU1(); + uint8_t two = reader.readU1(); + uint8_t three = reader.readU1(); + uint8_t four = reader.readU1(); + return (one + (two << 8) + (three << 16) + (four << 24)); +} + +static uint16_t readEndianDep2(J3Reader& reader) { + uint8_t one = reader.readU1(); + uint8_t two = reader.readU1(); + return (one + (two << 8)); +} + +void J3ZipArchive::findOfscd() { + int32_t curOffs = 0; + int32_t minOffs = 0; + int32_t st = END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4; + + J3Reader reader(bytes); + curOffs = reader.max; + if (curOffs >= (65535 + END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4)) { + minOffs = curOffs - (65535 + END_CENTRAL_DIRECTORY_FILE_HEADER_SIZE + 4); + } else { + minOffs = 0; + } + + while (curOffs > minOffs) { + int32_t searchPos = 0; + if (curOffs >= (1024 - st)) { + curOffs = curOffs - (1024 - st); + } else { + curOffs = 0; + } + reader.cursor += curOffs; + + int32_t diff = reader.max - reader.cursor; + int32_t temp = reader.cursor; + if (diff > 1024) { + searchPos = 1024; + reader.cursor += 1024; + } else { + searchPos = diff; + reader.cursor = reader.max; + } + + if (searchPos >= st) { + int32_t searchPtr = temp + (searchPos - st); + while (searchPtr > temp) { + if (bytes->elements[searchPtr] == 'P' && + !(memcmp(bytes->elements + searchPtr, HDR_ENDCENTRAL, 4))) { + int32_t offset = searchPtr + 4 + E_OFFSET_START_CENTRAL_DIRECTORY; + reader.cursor = offset; + this->ofscd = readEndianDep4(reader); + return; + } + searchPtr--; + } + } + } + this->ofscd = -1; +} + +void J3ZipArchive::addFiles() { + int32_t temp = ofscd; + + J3Reader reader(bytes); + reader.cursor = temp; + + while (true) { + if (memcmp(bytes->elements + temp, HDR_CENTRAL, 4)) return; + J3ZipFile* ptr = new(allocator) J3ZipFile(); + reader.cursor = temp + 4 + C_COMPRESSION_METHOD; + ptr->compressionMethod = readEndianDep2(reader); + + reader.cursor = temp + 4 + C_CSIZE; + + ptr->csize = readEndianDep4(reader); + ptr->ucsize = readEndianDep4(reader); + ptr->filenameLength = readEndianDep2(reader); + ptr->extraFieldLength = readEndianDep2(reader); + ptr->fileCommentLength = readEndianDep2(reader); + + reader.cursor = temp + 4 + C_ROLH; + ptr->rolh = readEndianDep4(reader); + + temp = temp + 4 + CENTRAL_DIRECTORY_FILE_HEADER_SIZE; + + if ((ptr->filenameLength > 1024) || + (reader.max - temp) < ptr->filenameLength) + return; + + ptr->filename = (char*)allocator->allocate(ptr->filenameLength + 1); + memcpy(ptr->filename, bytes->elements + temp, + ptr->filenameLength); + ptr->filename[ptr->filenameLength] = 0; + + if (ptr->filename[ptr->filenameLength - 1] != PATH_SEPARATOR) { + filetable.insert(std::make_pair(ptr->filename, ptr)); + } + + temp = temp + ptr->filenameLength + ptr->extraFieldLength + + ptr->fileCommentLength; + } +} + +int32_t J3ZipArchive::readFile(J3ClassBytes* array, const J3ZipFile* file) { + uint32_t bytesLeft = 0; + uint32_t filenameLength = 0; + uint32_t extraFieldLength = 0; + uint32_t temp = 0; + + J3Reader reader(bytes); + reader.cursor = file->rolh; + + if (!(memcmp(bytes->elements + file->rolh, HDR_LOCAL, 4))) { + reader.cursor += 4; + temp = reader.cursor; + reader.cursor += L_FILENAME_LENGTH; + filenameLength = readEndianDep2(reader); + extraFieldLength = readEndianDep2(reader); + + reader.cursor = + temp + extraFieldLength + filenameLength + LOCAL_FILE_HEADER_SIZE; + + if (file->compressionMethod == ZIP_STORE) { + memcpy(array->elements, bytes->elements + reader.cursor, file->ucsize); + return 1; + } else if (file->compressionMethod == ZIP_DEFLATE) { + z_stream stre; + int32_t err = 0; + + bytesLeft = file->csize; + stre.next_out = (Bytef*)array->elements; + stre.avail_out = file->ucsize; + stre.zalloc = 0; + stre.zfree = 0; + + err = inflateInit2_(&stre, - DEF_WBITS, zlib_version, sizeof(z_stream)); + + if (err != Z_OK) { + return 0; + } + + while (bytesLeft) { + uint32_t size = 0; + stre.next_in = bytes->elements + reader.cursor; + if (bytesLeft > 1024) size = 1024; + else size = bytesLeft; + + uint32_t diff = reader.max - reader.cursor; + if (diff < size) { + stre.avail_in = diff; + reader.cursor = reader.max; + } else { + stre.avail_in = size; + reader.cursor += size; + } + + if (bytesLeft > size) { + err = inflate(&stre, Z_PARTIAL_FLUSH); + } else { + err = inflate(&stre, Z_FINISH); + } + + bytesLeft = bytesLeft - size; + } + + inflateEnd(&stre); + + if ((err != Z_STREAM_END) && + (bytesLeft || err != Z_BUF_ERROR || stre.avail_out)) { + return 0; + } else { + return 1; + } + } else { + return 0; + } + } else { + return 0; + } + return 0; +} Added: vmkit/branches/mcjit/lib/vmkit/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/Makefile?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/vmkit/Makefile (added) +++ vmkit/branches/mcjit/lib/vmkit/Makefile Mon Nov 25 03:27:09 2013 @@ -0,0 +1,10 @@ +#===- ./Makefile -------------------------------------------*- Makefile -*--===# +# +# The vmkit project +#===------------------------------------------------------------------------===# + +LEVEL := ../.. + +MODULE=vmkit + +include $(LEVEL)/Makefile.rules Added: vmkit/branches/mcjit/lib/vmkit/allocator.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/allocator.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/vmkit/allocator.cc (added) +++ vmkit/branches/mcjit/lib/vmkit/allocator.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,92 @@ +#include "vmkit/allocator.h" +#include "vmkit/thread.h" +#include "vmkit/vmkit.h" +#include +#include +#include +#include + +using namespace vmkit; + +void* BumpAllocator::operator new(size_t n) { + return (void*)((uintptr_t)map(bucketSize) + sizeof(BumpAllocatorNode)); +} + +BumpAllocator::BumpAllocator() { + pthread_mutex_init(&mutex, 0); + current = (BumpAllocatorNode*)((uintptr_t)this - sizeof(BumpAllocatorNode)); + current->next = 0; + current->top = (uint8_t*)round((uintptr_t)(this + 1), 64); +} + +BumpAllocator* BumpAllocator::create() { + return new BumpAllocator(); +} + +BumpAllocator::~BumpAllocator() { + while(current->next) { + BumpAllocatorNode* tmp = current->next; + unmap(current, (uintptr_t)current->top - (uintptr_t)current); + } +} + +void BumpAllocator::operator delete(void* p) { + unmap(p, bucketSize); +} + +void BumpAllocator::destroy(BumpAllocator* allocator) { + delete allocator; +} + +void* BumpAllocator::allocate(size_t size) { + if(size > (bucketSize - sizeof(BumpAllocatorNode))) { + pthread_mutex_lock(&mutex); + size_t total = round((uintptr_t)size + sizeof(BumpAllocatorNode), 4096); + BumpAllocatorNode* newBucket = (BumpAllocatorNode*)map(total); + //memset(newBucket, 0, total); + newBucket->next = current->next; + current->next = newBucket; + newBucket->top = (uint8_t*)((uintptr_t)newBucket + bucketSize); + pthread_mutex_unlock(&mutex); + return newBucket + 1; + } + + while(1) { + BumpAllocatorNode* node = current; + uint8_t* res = __sync_fetch_and_add(&node->top, (uint8_t*)round(size, 8)); + uint8_t* end = res + size; + + if(res >= (uint8_t*)node && (res + size) < ((uint8_t*)node) + bucketSize) { + //printf("%p -> %lu %lu (%p -> %p)\n", res, size, round((uintptr_t)size, 64), node, ((uint8_t*)node) + bucketSize); + //memset(res, 0, size); + return res; + } + + pthread_mutex_lock(&mutex); + BumpAllocatorNode* newBucket = (BumpAllocatorNode*)map(bucketSize); + newBucket->next = current; + newBucket->top = (uint8_t*)(newBucket + 1); + current = newBucket; + pthread_mutex_unlock(&mutex); + } +} + +void* BumpAllocator::map(size_t n) { + void* res = mmap(0, n, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, 0, 0); + if(res == MAP_FAILED) + Thread::get()->vm()->internalError(L"unable to map %ld bytes", n); + //memset(res, 0, n); + return res; +} + +void BumpAllocator::unmap(void* p, size_t n) { + munmap(0, n); +} + +void PermanentObject::operator delete(void* ptr) { + Thread::get()->vm()->internalError(L"should not happen"); +} + +void PermanentObject::operator delete[](void* ptr) { + Thread::get()->vm()->internalError(L"should not happen"); +} Added: vmkit/branches/mcjit/lib/vmkit/gc.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/gc.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/vmkit/gc.cc (added) +++ vmkit/branches/mcjit/lib/vmkit/gc.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,8 @@ +#include "vmkit/gc.h" +#include + +using namespace vmkit; + +void* GC::allocate(size_t sz) { + return calloc(sz, 1); +} Added: vmkit/branches/mcjit/lib/vmkit/gcrootpass.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/gcrootpass.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/vmkit/gcrootpass.cc (added) +++ vmkit/branches/mcjit/lib/vmkit/gcrootpass.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,58 @@ +#include "llvm/CodeGen/GCs.h" +#include "llvm/CodeGen/GCStrategy.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" + +#include "llvm/MC/MCContext.h" + +#include "llvm/Support/Compiler.h" + +#include "llvm/Target/TargetInstrInfo.h" +#include "llvm/Target/TargetMachine.h" + +using namespace llvm; + +namespace vmkit { + class VmkitGCPass : public GCStrategy { + public: + VmkitGCPass(); + bool findCustomSafePoints(GCFunctionInfo& FI, MachineFunction &MF); + }; + + void linkVmkitGC() { } + + static GCRegistry::Add X("vmkit", "VMKit GC for JIT-generated functions"); + + VmkitGCPass::VmkitGCPass() { + CustomSafePoints = true; + InitRoots = 1; + } + + static MCSymbol *InsertLabel(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MI, + DebugLoc DL) { + const TargetInstrInfo* TII = MBB.getParent()->getTarget().getInstrInfo(); + MCSymbol *Label = MBB.getParent()->getContext().CreateTempSymbol(); + BuildMI(MBB, MI, DL, TII->get(TargetOpcode::GC_LABEL)).addSym(Label); + return Label; + } + + bool VmkitGCPass::findCustomSafePoints(GCFunctionInfo& FI, MachineFunction &MF) { + for (MachineFunction::iterator BBI = MF.begin(), + BBE = MF.end(); BBI != BBE; ++BBI) { + for (MachineBasicBlock::iterator MI = BBI->begin(), + ME = BBI->end(); MI != ME; ++MI) { + if (MI->getDesc().isCall()) { + MachineBasicBlock::iterator RAI = MI; ++RAI; + MCSymbol* Label = InsertLabel(*MI->getParent(), RAI, MI->getDebugLoc()); + FI.addSafePoint(GC::PostCall, Label, MI->getDebugLoc()); + } else if (MI->getDebugLoc().getCol() == 1) { + MCSymbol* Label = InsertLabel(*MI->getParent(), MI, MI->getDebugLoc()); + FI.addSafePoint(GC::Loop, Label, MI->getDebugLoc()); + } + } + } + + return false; + } +} Added: vmkit/branches/mcjit/lib/vmkit/names.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/names.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/vmkit/names.cc (added) +++ vmkit/branches/mcjit/lib/vmkit/names.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,79 @@ +#include + +#include "vmkit/names.h" + +using namespace vmkit; + +T_ptr_less_t Name::less; + +Name::Name(uint32_t length, const wchar_t* content) { + _length = length; + memcpy(_content, content, sizeof(wchar_t)*(length+1)); +} + +void* Name::operator new(size_t unused, BumpAllocator* allocator, size_t n) { + return PermanentObject::operator new(sizeof(Name) + n * sizeof(wchar_t), allocator); +} + +Names::Names(BumpAllocator* _allocator) : names(Util::wchar_t_less, _allocator) { + pthread_mutex_init(&mutex, 0); + allocator = _allocator; +} + +const Name* Names::get(const wchar_t* str) { + pthread_mutex_lock(&mutex); + //printf("---- internalize %ls\n", str); + + const Name* res; + std::map::iterator it = names.find(str); + + if(it == names.end()) { + size_t len = wcslen(str); + Name* tmp = new(allocator, len) Name(len, str); + + names[tmp->cStr()] = tmp; + + res = tmp; + } else { + res = it->second; + } + pthread_mutex_unlock(&mutex); + return res; +} + +const Name* Names::get(const char* str, size_t start, size_t length) { + //printf("%s %lu %lu\n", str, start, length); + if(length == -1) + length = strlen(str); + wchar_t buf[length + 1]; + size_t n = 0; + size_t i = 0; + + while (i < length) { + wchar_t x = str[i++]; + if(x & 0x80) { + wchar_t y = str[i++]; + if (x & 0x20) { + wchar_t z = str[i++]; + x = ((x & 0x0F) << 12) + + ((y & 0x3F) << 6) + + (z & 0x3F); + } else { + x = ((x & 0x1F) << 6) + + (y & 0x3F); + } + } + buf[n++] = x; + } + + buf[n] = 0; + + return get(buf); +} + +const Name* Names::get(char c) { + wchar_t buf[2]; + buf[0] = c; + buf[1] = 0; + return get(buf); +} Added: vmkit/branches/mcjit/lib/vmkit/thread.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/thread.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/vmkit/thread.cc (added) +++ vmkit/branches/mcjit/lib/vmkit/thread.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,15 @@ +#include "vmkit/thread.h" + +using namespace vmkit; + +__thread Thread* Thread::_thread = 0; + +Thread::Thread(VMKit* vm, BumpAllocator* allocator) { + _allocator = allocator; + _vm = vm; +} + +void Thread::destroy(Thread* thread) { + BumpAllocator::destroy(thread->allocator()); +} + Added: vmkit/branches/mcjit/lib/vmkit/util.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/util.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/vmkit/util.cc (added) +++ vmkit/branches/mcjit/lib/vmkit/util.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,18 @@ +#include "vmkit/util.h" + +#include +#include + +using namespace vmkit; + +struct Util::char_less_t Util::char_less; +struct Util::wchar_t_less_t Util::wchar_t_less; + +bool Util::char_less_t::operator()(const char* s1, const char* s2) const { + return strcmp(s1, s2) < 0; +} + +bool Util::wchar_t_less_t::operator()(const wchar_t* lhs, const wchar_t* rhs) const { + //printf("Compare: %ls - %ls - %d\n", lhs, rhs, wcscmp(lhs, rhs)); + return wcscmp(lhs, rhs) < 0; +} Added: vmkit/branches/mcjit/lib/vmkit/vmkit.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/vmkit/vmkit.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/lib/vmkit/vmkit.cc (added) +++ vmkit/branches/mcjit/lib/vmkit/vmkit.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,282 @@ +#include +#include +#include +#include +#include +#include + +#include "vmkit/vmkit.h" +#include "vmkit/thread.h" + +#include "llvm/LinkAllPasses.h" +#include "llvm/PassManager.h" + +#include "llvm/IR/Module.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Intrinsics.h" + +#include "llvm/ExecutionEngine/ExecutionEngine.h" + +#include "llvm/Support/TargetSelect.h" +#include "llvm/Support/MemoryBuffer.h" + +#include "llvm/Bitcode/ReaderWriter.h" + +#include "llvm/CodeGen/MachineCodeEmitter.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineModuleInfo.h" +#include "llvm/CodeGen/GCStrategy.h" + +using namespace vmkit; + +VMKit::VMKit(vmkit::BumpAllocator* allocator) : + mangleMap(Util::char_less, allocator) { + llvm::InitializeNativeTarget(); + _allocator = allocator; +} + +void* VMKit::operator new(size_t n, vmkit::BumpAllocator* allocator) { + return allocator->allocate(n); +} + +void VMKit::destroy(VMKit* vm) { + vmkit::BumpAllocator::destroy(vm->allocator()); +} + + +llvm::Type* VMKit::introspectType(const char* name) { + llvm::Type* res = self()->getTypeByName(name); + if(!res) + internalError(L"unable to find internal type: %s", name); + return res; +} + +llvm::Function* VMKit::introspectFunction(llvm::Module* dest, const char* name) { + llvm::Function* orig = (llvm::Function*)mangleMap[name]; + if(!orig) + internalError(L"unable to find internal function: %s", name); + + return orig; + // return (llvm::Function*)dest->getOrInsertFunction(orig->getName(), orig->getFunctionType()); +} + +llvm::GlobalValue* VMKit::introspectGlobalValue(llvm::Module* dest, const char* name) { + llvm::GlobalValue* res = mangleMap[name]; + if(!res) + internalError(L"unable to find internal global value: %s", name); + return res; +} + +uintptr_t VMKit::addSymbol(llvm::GlobalValue* gv) { + const char* id = gv->getName().data(); + void* ptr = dlsym(RTLD_SELF, id); + + if(ptr) { + ee()->updateGlobalMapping(gv, ptr); + int status; + char* realname; + realname = abi::__cxa_demangle(id, 0, 0, &status); + const char* tmp = realname ? realname : id; + uint32_t length = strlen(tmp); + char* mangled = (char*)allocator()->allocate(length+1); + strcpy(mangled, tmp); + mangleMap[mangled] = gv; + free(realname); + return (uintptr_t)ptr; + } else + return 0; +} + +void VMKit::vmkitBootstrap(Thread* initialThread, const char* selfBitCodePath) { + Thread::set(initialThread); + + std::string err; + llvm::OwningPtr buf; + if (llvm::MemoryBuffer::getFile(selfBitCodePath, buf)) + VMKit::internalError(L"Error while opening bitcode file %s\n", selfBitCodePath); + _self = llvm::getLazyBitcodeModule(buf.take(), llvm::getGlobalContext(), &err); + + if(!self()) + VMKit::internalError(L"Error while reading bitcode file %s: %s\n", selfBitCodePath, err.c_str()); + + _ee = llvm::EngineBuilder(self()).setErrorStr(&err).create(); + if (!ee()) + VMKit::internalError(L"Error while creating execution engine: %s\n", err.c_str()); + + ee()->DisableLazyCompilation(0); + ee()->RegisterJITEventListener(this); + + for(llvm::Module::iterator cur=self()->begin(); cur!=self()->end(); cur++) + addSymbol(cur); + + for(llvm::Module::global_iterator cur=self()->global_begin(); cur!=self()->global_end(); cur++) + addSymbol(cur); + + _dataLayout = new llvm::DataLayout(self()); + + ptrTypeInfo = ee()->getPointerToGlobal(introspectGlobalValue(self(), "typeinfo for void*")); + + if(!ptrTypeInfo) + internalError(L"unable to find typeinfo for void*"); + +#if 0 + llvm::Linker* linker = new llvm::Linker(new llvm::Module("linker", vm()->self()->getContext())); + std::string err; + if(linker->linkInModule(vm()->self(), llvm::Linker::PreserveSource, &err)) + J3::internalError(L"unable to add self to linker: %s", err.c_str()); + if(linker->linkInModule(module(), llvm::Linker::PreserveSource, &err)) + J3::internalError(L"unable to add module to linker: %s", err.c_str()); +#endif +} + + +llvm::Function* VMKit::getGCRoot(llvm::Module* mod) { + return llvm::Intrinsic::getDeclaration(mod, llvm::Intrinsic::gcroot); +} + +llvm::FunctionPassManager* VMKit::preparePM(llvm::Module* mod) { + llvm::FunctionPassManager* pm = new llvm::FunctionPassManager(mod); + //pm->add(new llvm::TargetData(*ee->getTargetData())); + + pm->add(llvm::createBasicAliasAnalysisPass()); + + pm->add(llvm::createCFGSimplificationPass()); // Clean up disgusting code + pm->add(llvm::createPromoteMemoryToRegisterPass());// Kill useless allocas + pm->add(llvm::createInstructionCombiningPass()); // Cleanup for scalarrepl. + pm->add(llvm::createScalarReplAggregatesPass()); // Break up aggregate allocas + pm->add(llvm::createInstructionCombiningPass()); // Cleanup for scalarrepl. + pm->add(llvm::createJumpThreadingPass()); // Thread jumps. + pm->add(llvm::createCFGSimplificationPass()); // Merge & remove BBs + pm->add(llvm::createInstructionCombiningPass()); // Combine silly seq's + pm->add(llvm::createCFGSimplificationPass()); // Merge & remove BBs + + pm->add(llvm::createReassociatePass()); // Reassociate expressions + pm->add(llvm::createLoopRotatePass()); // Rotate loops. + pm->add(llvm::createLICMPass()); // Hoist loop invariants + pm->add(llvm::createLoopUnswitchPass()); // Unswitch loops. + pm->add(llvm::createInstructionCombiningPass()); + pm->add(llvm::createIndVarSimplifyPass()); // Canonicalize indvars + pm->add(llvm::createLoopDeletionPass()); // Delete dead loops + pm->add(llvm::createLoopUnrollPass()); // Unroll small loops*/ + pm->add(llvm::createInstructionCombiningPass()); // Clean up after the unroller + pm->add(llvm::createGVNPass()); // Remove redundancies + pm->add(llvm::createMemCpyOptPass()); // Remove memcpy / form memset + pm->add(llvm::createSCCPPass()); // Constant prop with SCCP + + // Run instcombine after redundancy elimination to exploit opportunities + // opened up by them. + pm->add(llvm::createInstructionCombiningPass()); + pm->add(llvm::createJumpThreadingPass()); // Thread jumps + pm->add(llvm::createDeadStoreEliminationPass()); // Delete dead stores + pm->add(llvm::createAggressiveDCEPass()); // Delete dead instructions + pm->add(llvm::createCFGSimplificationPass()); // Merge & remove BBs + + pm->doInitialization(); + + return pm; +} + +void VMKit::NotifyFunctionEmitted(const llvm::Function &F, + void *Code, + size_t Size, + const llvm::JITEventListener::EmittedFunctionDetails &Details) { + const llvm::MachineFunction* mf = Details.MF; + const std::vector& landingPads = mf->getMMI().getLandingPads(); + const llvm::MachineCodeEmitter* mce = Details.MCE; + + for(std::vector::const_iterator i=landingPads.begin(); i!=landingPads.end(); i++) { + uintptr_t dest = mce->getLabelAddress(i->LandingPadLabel); + + for(uint32_t j=0; jBeginLabels.size(); j++) { + uintptr_t point = mce->getLabelAddress(i->EndLabels[j]); + ExceptionDescriptor* e = new ExceptionDescriptor(&F, point, dest); + exceptionTable[point] = e; + fprintf(stderr, " exceptionpoint at 0x%lx goes to 0x%lx\n", point, dest); + } + } + + if(F.hasGC()) { + llvm::GCFunctionInfo* gcInfo = &mf->getGMI()->getFunctionInfo(F); + uintptr_t start = (uintptr_t)Code; + uintptr_t end = start + Size; + + for(llvm::GCFunctionInfo::iterator safepoint=gcInfo->begin(); safepoint!=gcInfo->end(); safepoint++) { + uint32_t kind = safepoint->Kind; + llvm::MCSymbol* label = safepoint->Label; + uintptr_t addr = mce->getLabelAddress(label); + + if(addr < start || addr > end) + internalError(L"safe point is not inside the function (%p %p %p)", start, addr, end); + + Safepoint* sf = Safepoint::create(&F, addr, gcInfo->live_size(safepoint)); + uint32_t i=0; + + //fprintf(stderr, " safepoint at 0x%lx\n", addr); + for(llvm::GCFunctionInfo::live_iterator live=gcInfo->live_begin(safepoint); live!=gcInfo->live_end(safepoint); live++, i++) { + sf->setAt(i, live->StackOffset); + //fprintf(stderr, " offset: %d\n", live->StackOffset); + } + safepointMap[addr] = sf; + } + } +} + +void VMKit::log(const wchar_t* msg, ...) { + va_list va; + va_start(va, msg); + fprintf(stderr, "[vmkit]: "); + vfwprintf(stderr, msg, va); + fprintf(stderr, "\n"); + va_end(va); +} + +void VMKit::internalError(const wchar_t* msg, va_list va) { + defaultInternalError(msg, va); +} + +void VMKit::defaultInternalError(const wchar_t* msg, va_list va) { + fprintf(stderr, "Fatal error: "); + vfwprintf(stderr, msg, va); + fprintf(stderr, "\n"); + abort(); +} + +void VMKit::internalError(const wchar_t* msg, ...) { + va_list va; + va_start(va, msg); + if(Thread::get() && Thread::get()->vm()) + Thread::get()->vm()->internalError(msg, va); + else + defaultInternalError(msg, va); + va_end(va); + fprintf(stderr, "SHOULD NOT BE THERE\n"); + abort(); +} + +void VMKit::throwException(void* obj) { + void** exception = (void**)abi::__cxa_allocate_exception(sizeof(void*)); + *exception = obj; + abi::__cxa_throw(exception, (std::type_info*)Thread::get()->vm()->ptrTypeInfo, 0); + abort(); +} + + +void* Safepoint::operator new(size_t unused, size_t nbSlots) { + return ::operator new(sizeof(Safepoint) + nbSlots*sizeof(uintptr_t) - sizeof(uintptr_t)); +} + +Safepoint::Safepoint(const llvm::Function* llvmFunction, uintptr_t address, size_t nbSlots) { + _llvmFunction = llvmFunction; + _address = address; + _nbSlots = nbSlots; +} + +Safepoint* Safepoint::create(const llvm::Function* llvmFunction, uintptr_t address, size_t nbSlots) { + return new(nbSlots) Safepoint(llvmFunction, address, nbSlots); +} + +ExceptionDescriptor::ExceptionDescriptor(const llvm::Function* llvmFunction, uintptr_t point, uintptr_t landingPad) { + _llvmFunction = llvmFunction; + _point = point; + _landingPad = landingPad; +} Added: vmkit/branches/mcjit/tools/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/tools/Makefile?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/tools/Makefile (added) +++ vmkit/branches/mcjit/tools/Makefile Mon Nov 25 03:27:09 2013 @@ -0,0 +1,10 @@ +#===- ./Makefile -------------------------------------------*- Makefile -*--===# +# +# The vmkit project +#===------------------------------------------------------------------------===# + +LEVEL := .. + +DIRS := j3 + +include $(LEVEL)/Makefile.rules Added: vmkit/branches/mcjit/tools/j3/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/tools/j3/Makefile?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/tools/j3/Makefile (added) +++ vmkit/branches/mcjit/tools/j3/Makefile Mon Nov 25 03:27:09 2013 @@ -0,0 +1,11 @@ +#===- ./Makefile -------------------------------------------*- Makefile -*--===# +# +# The vmkit project +#===------------------------------------------------------------------------===# + +LEVEL := ../.. + +LIBS := vmkit j3 openjdk +TOOL := j3 + +include $(LEVEL)/Makefile.rules Added: vmkit/branches/mcjit/tools/j3/main.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/tools/j3/main.cc?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/tools/j3/main.cc (added) +++ vmkit/branches/mcjit/tools/j3/main.cc Mon Nov 25 03:27:09 2013 @@ -0,0 +1,8 @@ +#include +#include "j3/j3.h" + +int main(int argc, char** argv) { + j3::J3* vm = j3::J3::create(); + + vm->start(argc, argv); +} From gael.thomas at lip6.fr Mon Nov 25 01:36:28 2013 From: gael.thomas at lip6.fr (Gael Thomas) Date: Mon, 25 Nov 2013 09:36:28 -0000 Subject: [vmkit-commits] [vmkit] r195629 - add config.guess, config.sub, svn:ignore Message-ID: <20131125093628.B60C72A6C029@llvm.org> Author: gthomas Date: Mon Nov 25 03:36:27 2013 New Revision: 195629 URL: http://llvm.org/viewvc/llvm-project?rev=195629&view=rev Log: add config.guess, config.sub, svn:ignore Added: vmkit/branches/mcjit/Makefile.config.in vmkit/branches/mcjit/autoconf/config.guess (with props) vmkit/branches/mcjit/autoconf/config.sub (with props) Removed: vmkit/branches/mcjit/Makefile.config vmkit/branches/mcjit/include/safepoint.h Modified: vmkit/branches/mcjit/ (props changed) vmkit/branches/mcjit/Makefile.rules vmkit/branches/mcjit/autoconf/ (props changed) vmkit/branches/mcjit/lib/j3/openjdk/ (props changed) vmkit/branches/mcjit/lib/j3/vm/ (props changed) vmkit/branches/mcjit/lib/vmkit/ (props changed) vmkit/branches/mcjit/tools/j3/ (props changed) Propchange: vmkit/branches/mcjit/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Nov 25 03:36:27 2013 @@ -0,0 +1,3 @@ +Debug+Asserts +config.log +config.status Removed: vmkit/branches/mcjit/Makefile.config URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/Makefile.config?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/Makefile.config (original) +++ vmkit/branches/mcjit/Makefile.config (removed) @@ -1,33 +0,0 @@ - -SHOPT=-Wl,-all_load -Wl,-compatibility_version,1 -Wl,-current_version,1 -EXEEXT= -SHLIBEXT=.dylib - -OPTIMIZED=0 -DEBUG=1 -ASSERT=1 - -PROJ_SRC_ROOT := $(subst //,/,/Users/gthomas/research/vmkit4/vmkit) -PROJ_OBJ_ROOT := $(subst //,/,/Users/gthomas/research/vmkit4/vmkit) - -CONFIG_FILES= Makefile.config include/j3/j3config.h -CONFIG_HEADERS= - -BUILD_NAME=Debug+Asserts - -GAWK=/opt/local/bin/gawk - -CLANG=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/clang -CLANGXX=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/clang++ -LLC=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/llc -LLNM=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/llvm-nm -LLOPT=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/opt -LLLINK=/Users/gthomas/research/vmkit4/llvm/Release+Asserts/bin/llvm-link - -LLVM_CXXFLAGS=-I/Users/gthomas/research/vmkit4/llvm/include -I/Users/gthomas/research/vmkit4/llvm/include -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fvisibility-inlines-hidden -fno-common -Woverloaded-virtual -Wcast-qual -I/Users/gthomas/research/vmkit4/llvm/include -LLVM_LIBS=-lLLVMInstrumentation -lLLVMIRReader -lLLVMAsmParser -lLLVMDebugInfo -lLLVMOption -lLLVMLTO -lLLVMLinker -lLLVMipo -lLLVMVectorize -lLLVMBitWriter -lLLVMBitReader -lLLVMTableGen -lLLVMR600CodeGen -lLLVMR600Desc -lLLVMR600Info -lLLVMR600AsmPrinter -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSystemZAsmPrinter -lLLVMHexagonCodeGen -lLLVMHexagonAsmPrinter -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMNVPTXAsmPrinter -lLLVMCppBackendCodeGen -lLLVMCppBackendInfo -lLLVMMSP430CodeGen -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMSP430AsmPrinter -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMXCoreAsmPrinter -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMMipsAsmPrinter -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMAsmPrinter -lLLVMAArc! h64Disass embler -lLLVMAArch64CodeGen -lLLVMAArch64AsmParser -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64AsmPrinter -lLLVMAArch64Utils -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMPowerPCAsmPrinter -lLLVMSparcCodeGen -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Desc -lLLVMX86Info -lLLVMX86AsmPrinter -lLLVMX86Utils -lgtest_main -lgtest -lLLVMMCDisassembler -lLLVMMCParser -lLLVMInterpreter -lLLVMMCJIT -lLLVMJIT -lLLVMCodeGen -lLLVMObjCARCOpts -lLLVMScalarOpts -lLLVMInstCombine -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMRuntimeDyld -lLLVMExecutionEngine -lLLVMTarget -lLLVMMC -lLLVMObject -lLLVMCore -lLLVMSupport -LLVM_LDFLAGS=-L/Users/gthomas/research/vmkit4/llvm/Release+Asserts/lib -lz -lpthread -lcurses -lm - -OPENJDK_HOME=/Users/gthomas/research/vmkit4/jdk8/build/macosx-x86_64-normal-server-release/images/j2sdk-bundle/jdk1.8.0.jdk/Contents/Home/ - -OS=darwin Added: vmkit/branches/mcjit/Makefile.config.in URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/Makefile.config.in?rev=195629&view=auto ============================================================================== --- vmkit/branches/mcjit/Makefile.config.in (added) +++ vmkit/branches/mcjit/Makefile.config.in Mon Nov 25 03:36:27 2013 @@ -0,0 +1,33 @@ + +SHOPT=@SHOPT@ +EXEEXT=@EXEEXT@ +SHLIBEXT=@SHLIBEXT@ + +OPTIMIZED=@OPTIMIZED@ +DEBUG=@DEBUG@ +ASSERT=@ASSERT@ + +PROJ_SRC_ROOT := $(subst //,/, at abs_top_srcdir@) +PROJ_OBJ_ROOT := $(subst //,/, at abs_top_builddir@) + +CONFIG_FILES=@ac_config_files@ +CONFIG_HEADERS=@ac_config_headers@ + +BUILD_NAME=@BUILD_NAME@ + +GAWK=@GAWK@ + +CLANG=@CLANG@ +CLANGXX=@CLANGXX@ +LLC=@LLC@ +LLNM=@LLNM@ +LLOPT=@LLOPT@ +LLLINK=@LLLINK@ + +LLVM_CXXFLAGS=@LLVM_CXXFLAGS@ +LLVM_LIBS=@LLVM_LIBS@ +LLVM_LDFLAGS=@LLVM_LDFLAGS@ + +OPENJDK_HOME=@jdkhome@ + +OS=@OS@ \ No newline at end of file Modified: vmkit/branches/mcjit/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/Makefile.rules?rev=195629&r1=195628&r2=195629&view=diff ============================================================================== --- vmkit/branches/mcjit/Makefile.rules (original) +++ vmkit/branches/mcjit/Makefile.rules Mon Nov 25 03:36:27 2013 @@ -105,6 +105,7 @@ clean:: cleanall:: $(Echo) "Cleaning all compilation files" + $(Verb) rm -Rf autoconf/autom4te.cache config.log config.status Makefile.config $(BUILD_DIR) confclean: clean $(Echo) "Cleaning configuration" Propchange: vmkit/branches/mcjit/autoconf/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Nov 25 03:36:27 2013 @@ -0,0 +1 @@ +autom4te.cache Added: vmkit/branches/mcjit/autoconf/config.guess URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/autoconf/config.guess?rev=195629&view=auto ============================================================================== --- vmkit/branches/mcjit/autoconf/config.guess (added) +++ vmkit/branches/mcjit/autoconf/config.guess Mon Nov 25 03:36:27 2013 @@ -0,0 +1,1501 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +# Free Software Foundation, Inc. + +timestamp='2009-11-20' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner. Please send patches (context +# diff format) to and include a ChangeLog +# entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi at noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[456]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-gnu + else + echo ${UNAME_MACHINE}-unknown-linux-gnueabi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + LIBC=gnu + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-gnu + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf at swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green at stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green at stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + i386) + eval $set_cc_for_build + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + UNAME_PROCESSOR="x86_64" + fi + fi ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix\n"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + c34*) + echo c34-convex-bsd + exit ;; + c38*) + echo c38-convex-bsd + exit ;; + c4*) + echo c4-convex-bsd + exit ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: Propchange: vmkit/branches/mcjit/autoconf/config.guess ------------------------------------------------------------------------------ svn:executable = * Added: vmkit/branches/mcjit/autoconf/config.sub URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/autoconf/config.sub?rev=195629&view=auto ============================================================================== --- vmkit/branches/mcjit/autoconf/config.sub (added) +++ vmkit/branches/mcjit/autoconf/config.sub Mon Nov 25 03:36:27 2013 @@ -0,0 +1,1705 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +# Free Software Foundation, Inc. + +timestamp='2009-11-20' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to . Submit a context +# diff and a properly formatted GNU ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e \ + | we32k \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | picochip) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze) + basic_machine=microblaze-xilinx + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tile*) + basic_machine=tile-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: Propchange: vmkit/branches/mcjit/autoconf/config.sub ------------------------------------------------------------------------------ svn:executable = * Removed: vmkit/branches/mcjit/include/safepoint.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/safepoint.h?rev=195628&view=auto ============================================================================== --- vmkit/branches/mcjit/include/safepoint.h (original) +++ vmkit/branches/mcjit/include/safepoint.h (removed) @@ -1,12 +0,0 @@ -#ifndef _SAFE_POINT_H_ -#define _SAFE_POINT_H_ - -namespace vmkit { - class SafePoint { - llvm::Function* function; /* safe inside this function */ - uintptr_t ip; /* ip of this safepoint */ - public: - }; -} - -#endif Propchange: vmkit/branches/mcjit/lib/j3/openjdk/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Nov 25 03:36:27 2013 @@ -0,0 +1 @@ +Debug+Asserts Propchange: vmkit/branches/mcjit/lib/j3/vm/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Nov 25 03:36:27 2013 @@ -0,0 +1 @@ +Debug+Asserts Propchange: vmkit/branches/mcjit/lib/vmkit/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Nov 25 03:36:27 2013 @@ -0,0 +1 @@ +Debug+Asserts Propchange: vmkit/branches/mcjit/tools/j3/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Nov 25 03:36:27 2013 @@ -0,0 +1 @@ +Debug+Asserts From gael.thomas at lip6.fr Mon Nov 25 01:38:58 2013 From: gael.thomas at lip6.fr (Gael Thomas) Date: Mon, 25 Nov 2013 09:38:58 -0000 Subject: [vmkit-commits] [vmkit] r195630 - remove generated config.h file from the repo Message-ID: <20131125093858.6B7FA2A6C029@llvm.org> Author: gthomas Date: Mon Nov 25 03:38:58 2013 New Revision: 195630 URL: http://llvm.org/viewvc/llvm-project?rev=195630&view=rev Log: remove generated config.h file from the repo Removed: vmkit/branches/mcjit/include/j3/j3config.h Removed: vmkit/branches/mcjit/include/j3/j3config.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3config.h?rev=195629&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3config.h (original) +++ vmkit/branches/mcjit/include/j3/j3config.h (removed) @@ -1,6 +0,0 @@ - -#define SHLIBEXT ".dylib" -#define OPENJDK_HOME "/Users/gthomas/research/vmkit4/jdk8/build/macosx-x86_64-normal-server-release/images/j2sdk-bundle/jdk1.8.0.jdk/Contents/Home/" - - - From gael.thomas at lip6.fr Mon Nov 25 01:47:22 2013 From: gael.thomas at lip6.fr (Gael Thomas) Date: Mon, 25 Nov 2013 09:47:22 -0000 Subject: [vmkit-commits] [vmkit] r195631 - fix a bug in the Makefile that can potentially delete all the directories Message-ID: <20131125094722.6D5622A6C029@llvm.org> Author: gthomas Date: Mon Nov 25 03:47:22 2013 New Revision: 195631 URL: http://llvm.org/viewvc/llvm-project?rev=195631&view=rev Log: fix a bug in the Makefile that can potentially delete all the directories Modified: vmkit/branches/mcjit/Makefile.rules Modified: vmkit/branches/mcjit/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/Makefile.rules?rev=195631&r1=195630&r2=195631&view=diff ============================================================================== --- vmkit/branches/mcjit/Makefile.rules (original) +++ vmkit/branches/mcjit/Makefile.rules Mon Nov 25 03:47:22 2013 @@ -7,6 +7,10 @@ PROJ_OBJ_CWD:= $(call realpath, .) PROJ_SRC_CWD:= $(call realpath, $(patsubst $(PROJ_OBJ_ROOT)%,$(PROJ_SRC_ROOT)%,$(PROJ_OBJ_CWD))) +ifndef BUILD_NAME +BUILD_NAME=fake +endif + BUILD_DIR=$(PROJ_OBJ_CWD)/$(BUILD_NAME) BIN_DIR=$(PROJ_OBJ_ROOT)/$(BUILD_NAME)/bin LIB_DIR=$(PROJ_OBJ_ROOT)/$(BUILD_NAME)/lib @@ -57,7 +61,7 @@ SHFLAGS=$(SHOPT) -fno-common -Wl,-flat_n ############################################################################### # Targets ############################################################################### -.PHONY: all tidy clean cleanall confclean +.PHONY: all tidy clean confclean .SECONDARY: .SUFFIXES: @@ -84,7 +88,7 @@ check:: ############################################################################### # Recursive target managment ############################################################################### -RECURSIVE_TARGETS=all clean cleanall +RECURSIVE_TARGETS=all clean define do_sub_target $1:: @@ -103,10 +107,6 @@ clean:: $(Echo) "Cleaning compilation files" $(Verb) rm -Rf $(BUILD_DIR) -cleanall:: - $(Echo) "Cleaning all compilation files" - $(Verb) rm -Rf autoconf/autom4te.cache config.log config.status Makefile.config $(BUILD_DIR) - confclean: clean $(Echo) "Cleaning configuration" $(Verb) rm -Rf $(patsubst $(PROJ_OBJ_ROOT)/%,%,$(CONFIG_FILES)) @@ -314,7 +314,7 @@ $(eval $(call define_compile_rule,.cc,$( ifneq ($(MAKECMDGOALS),tidy) ifneq ($(MAKECMDGOALS),clean) -ifneq ($(MAKECMDGOALS),cleanall) +ifneq ($(MAKECMDGOALS),confclean) -include $(DEP_FILES) endif endif From gael.thomas at lip6.fr Mon Nov 25 02:31:31 2013 From: gael.thomas at lip6.fr (Gael Thomas) Date: Mon, 25 Nov 2013 10:31:31 -0000 Subject: [vmkit-commits] [vmkit] r195633 - add a j3symbol class, will be used to resolve symbol in mcjit Message-ID: <20131125103131.A5C672A6C029@llvm.org> Author: gthomas Date: Mon Nov 25 04:31:31 2013 New Revision: 195633 URL: http://llvm.org/viewvc/llvm-project?rev=195633&view=rev Log: add a j3symbol class, will be used to resolve symbol in mcjit Added: vmkit/branches/mcjit/include/j3/j3symbol.h Modified: vmkit/branches/mcjit/ (props changed) vmkit/branches/mcjit/include/j3/ (props changed) vmkit/branches/mcjit/include/j3/j3class.h vmkit/branches/mcjit/include/j3/j3method.h vmkit/branches/mcjit/lib/j3/vm/j3method.cc Propchange: vmkit/branches/mcjit/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Mon Nov 25 04:31:31 2013 @@ -1,3 +1,4 @@ +Makefile.config Debug+Asserts config.log config.status Propchange: vmkit/branches/mcjit/include/j3/ ------------------------------------------------------------------------------ --- svn:ignore (added) +++ svn:ignore Mon Nov 25 04:31:31 2013 @@ -0,0 +1 @@ +j3config.h Modified: vmkit/branches/mcjit/include/j3/j3class.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3class.h?rev=195633&r1=195632&r2=195633&view=diff ============================================================================== --- vmkit/branches/mcjit/include/j3/j3class.h (original) +++ vmkit/branches/mcjit/include/j3/j3class.h Mon Nov 25 04:31:31 2013 @@ -5,7 +5,7 @@ #include #include -#include "vmkit/allocator.h" +#include "j3/j3symbol.h" namespace llvm { class StructType; @@ -32,7 +32,7 @@ namespace j3 { class J3ObjectHandle; class J3Field; - class J3Type : public vmkit::PermanentObject { + class J3Type : public J3Symbol { pthread_mutex_t _mutex; J3ClassLoader* _loader; J3ArrayClass* volatile _array; @@ -55,6 +55,8 @@ namespace j3 { virtual llvm::GlobalValue* llvmDescriptor(llvm::Module* module) { return 0; } + int isTypeDescriptor() { return 1; } + bool isResolved() { return status >= RESOLVED; } bool isInitialised() { return status == INITED; } J3Type* resolve(J3Field* hiddenFields, uint32_t nbHiddenFields); Modified: vmkit/branches/mcjit/include/j3/j3method.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3method.h?rev=195633&r1=195632&r2=195633&view=diff ============================================================================== --- vmkit/branches/mcjit/include/j3/j3method.h (original) +++ vmkit/branches/mcjit/include/j3/j3method.h Mon Nov 25 04:31:31 2013 @@ -4,7 +4,7 @@ #include #include -#include "vmkit/allocator.h" +#include "j3/j3symbol.h" namespace llvm { class FunctionType; @@ -46,12 +46,18 @@ namespace j3 { } }; - struct trampolin_t { - uint8_t code[1]; + class J3MethodCode : public J3Symbol { + public: + J3Method* self; + + J3MethodCode(J3Method* _self) { self = _self; } + + int isMethodPointer() { return 1; } }; - class J3Method : public vmkit::PermanentObject { + class J3Method : public J3Symbol { public: + J3MethodCode _selfCode; uint16_t _access; J3Class* _cl; const vmkit::Name* _name; @@ -80,6 +86,8 @@ namespace j3 { public: J3Method(uint16_t access, J3Class* cl, const vmkit::Name* name, const vmkit::Name* sign); + int isMethodDescriptor() { return 1; } + static J3Method* newMethod(vmkit::BumpAllocator* allocator, uint16_t access, J3Class* cl, Added: vmkit/branches/mcjit/include/j3/j3symbol.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3symbol.h?rev=195633&view=auto ============================================================================== --- vmkit/branches/mcjit/include/j3/j3symbol.h (added) +++ vmkit/branches/mcjit/include/j3/j3symbol.h Mon Nov 25 04:31:31 2013 @@ -0,0 +1,15 @@ +#ifndef _J3_SYMBOL_H_ +#define _J3_SYMBOL_H_ + +#include "vmkit/allocator.h" + +namespace j3 { + class J3Symbol : public vmkit::PermanentObject { + public: + virtual int isMethodPointer() { return 0; } + virtual int isMethodDescriptor() { return 0; } + virtual int isTypeDescriptor() { return 0; } + }; +}; + +#endif Modified: vmkit/branches/mcjit/lib/j3/vm/j3method.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3method.cc?rev=195633&r1=195632&r2=195633&view=diff ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (original) +++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Mon Nov 25 04:31:31 2013 @@ -31,7 +31,8 @@ J3MethodType::J3MethodType(J3Type** args _llvmType = llvm::FunctionType::get(out()->llvmType(), in, 0); } -J3Method::J3Method(uint16_t access, J3Class* cl, const vmkit::Name* name, const vmkit::Name* sign) { +J3Method::J3Method(uint16_t access, J3Class* cl, const vmkit::Name* name, const vmkit::Name* sign) : + _selfCode(this) { _access = access; _cl = cl; _name = name; From gael.thomas at lip6.fr Mon Nov 25 08:49:33 2013 From: gael.thomas at lip6.fr (Gael Thomas) Date: Mon, 25 Nov 2013 16:49:33 -0000 Subject: [vmkit-commits] [vmkit] r195658 - add a symbol table in class loader and populates it Message-ID: <20131125164933.322382A6C029@llvm.org> Author: gthomas Date: Mon Nov 25 10:49:32 2013 New Revision: 195658 URL: http://llvm.org/viewvc/llvm-project?rev=195658&view=rev Log: add a symbol table in class loader and populates it Modified: vmkit/branches/mcjit/include/j3/j3classloader.h vmkit/branches/mcjit/lib/j3/vm/j3class.cc vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc vmkit/branches/mcjit/lib/j3/vm/j3method.cc Modified: vmkit/branches/mcjit/include/j3/j3classloader.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3classloader.h?rev=195658&r1=195657&r2=195658&view=diff ============================================================================== --- vmkit/branches/mcjit/include/j3/j3classloader.h (original) +++ vmkit/branches/mcjit/include/j3/j3classloader.h Mon Nov 25 10:49:32 2013 @@ -30,7 +30,7 @@ namespace j3 { class J3Type; class J3; class J3Class; - + class J3Symbol; class J3ClassLoader { struct J3MethodLess : public std::binary_function { @@ -40,8 +40,14 @@ namespace j3 { typedef std::map > > MethodRefMap; + typedef std::map > > SymbolMap; + static J3MethodLess j3MethodLess; + SymbolMap _symbolTable; + pthread_mutex_t _mutexSymbolTable; + J3ObjectHandle* _javaClassLoader; J3FixedPoint _fixedPoint; llvm::FunctionPassManager* _pm; @@ -65,6 +71,9 @@ namespace j3 { void* operator new(size_t n, vmkit::BumpAllocator* allocator); J3ClassLoader(J3* vm, J3ObjectHandle* javaClassLoader, vmkit::BumpAllocator* allocator); + void addSymbol(const char* id, J3Symbol* symbol); + J3Symbol* getSymbol(const char* id); + static void destroy(J3ClassLoader* loader); llvm::DIBuilder* dbgBuilder() const { return _dbgBuilder; } Modified: vmkit/branches/mcjit/lib/j3/vm/j3class.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3class.cc?rev=195658&r1=195657&r2=195658&view=diff ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original) +++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Mon Nov 25 10:49:32 2013 @@ -742,6 +742,8 @@ void J3Class::createLLVMTypes() { _nativeName[0] = 'L'; memcpy(_nativeName + 1, mangler.cStr()+7, mangler.length()); + + loader()->addSymbol(_nativeName, this); } llvm::Type* J3Class::staticLLVMType() { @@ -859,6 +861,8 @@ llvm::Type* J3ArrayClass::llvmType() { _llvmType = llvm::PointerType::getUnqual(llvm::StructType::create(loader()->module()->getContext(), body, _nativeName)); + + loader()->addSymbol(_nativeName, this); } return _llvmType; } Modified: vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc?rev=195658&r1=195657&r2=195658&view=diff ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc (original) +++ vmkit/branches/mcjit/lib/j3/vm/j3classloader.cc Mon Nov 25 10:49:32 2013 @@ -37,7 +37,8 @@ void* J3ClassLoader::operator new(size_t } J3ClassLoader::J3ClassLoader(J3* v, J3ObjectHandle* javaClassLoader, vmkit::BumpAllocator* allocator) - : _fixedPoint(allocator), + : _symbolTable(vmkit::Util::char_less, allocator), + _fixedPoint(allocator), classes(vmkit::Name::less, allocator), types(vmkit::Name::less, allocator), methodTypes(vmkit::Name::less, allocator), @@ -51,6 +52,7 @@ J3ClassLoader::J3ClassLoader(J3* v, J3Ob // pthread_mutexattr_init(&attr); // pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&_mutex, 0);//&attr); + pthread_mutex_init(&_mutexSymbolTable, 0); _vm = v; @@ -61,6 +63,19 @@ J3ClassLoader::J3ClassLoader(J3* v, J3Ob vm()->ee()->addModule(module()); } +void J3ClassLoader::addSymbol(const char* id, J3Symbol* symbol) { + pthread_mutex_lock(&_mutexSymbolTable); + _symbolTable[id] = symbol; + pthread_mutex_unlock(&_mutexSymbolTable); +} + +J3Symbol* J3ClassLoader::getSymbol(const char* id) { + pthread_mutex_lock(&_mutexSymbolTable); + J3Symbol* res = _symbolTable[id]; + pthread_mutex_unlock(&_mutexSymbolTable); + return res; +} + void* J3ClassLoader::lookupNativeFunctionPointer(J3Method* method, const char* symbol) { for(std::vector::size_type i=0; i!=nativeLibraries.size(); i++) { void* fnPtr = dlsym(nativeLibraries[i], symbol); Modified: vmkit/branches/mcjit/lib/j3/vm/j3method.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3method.cc?rev=195658&r1=195657&r2=195658&view=diff ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (original) +++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Mon Nov 25 10:49:32 2013 @@ -323,6 +323,9 @@ void J3Method::buildLLVMNames(J3Class* f memcpy(_llvmAllNames, "method_descriptor_", 18); memcpy(_llvmAllNames+18, mangler.cStr(), mangler.length()); _llvmAllNames[_llvmAllNamesLength] = 0; + + cl()->loader()->addSymbol(_llvmAllNames, this); + cl()->loader()->addSymbol(_llvmAllNames+18, &_selfCode); } size_t J3Method::llvmFunctionNameLength(J3Class* from) { From gael.thomas at lip6.fr Mon Nov 25 12:10:44 2013 From: gael.thomas at lip6.fr (Gael Thomas) Date: Mon, 25 Nov 2013 20:10:44 -0000 Subject: [vmkit-commits] [vmkit] r195678 - revert to r187580 Message-ID: <20131125201044.A85832A6C029@llvm.org> Author: gthomas Date: Mon Nov 25 14:10:43 2013 New Revision: 195678 URL: http://llvm.org/viewvc/llvm-project?rev=195678&view=rev Log: revert to r187580 Removed: vmkit/trunk/include/vmkit/StackEmbeddedList.h Modified: vmkit/trunk/README.TXT vmkit/trunk/include/j3/J3Intrinsics.h vmkit/trunk/include/vmkit/GC.h vmkit/trunk/include/vmkit/System.h vmkit/trunk/include/vmkit/Thread.h vmkit/trunk/include/vmkit/UTF8.h vmkit/trunk/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.cpp vmkit/trunk/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.h vmkit/trunk/lib/j3/ClassLib/OpenJDK/JavaUpcalls.cpp vmkit/trunk/lib/j3/ClassLib/OpenJDK/JavaUpcalls.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/JavaJIT.h vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.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/JavaMetaJIT.cpp vmkit/trunk/lib/j3/VMCore/JavaObject.cpp vmkit/trunk/lib/j3/VMCore/JavaObject.h vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp vmkit/trunk/lib/j3/VMCore/JavaString.cpp vmkit/trunk/lib/j3/VMCore/JavaString.h vmkit/trunk/lib/j3/VMCore/JavaThread.cpp vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp Modified: vmkit/trunk/README.TXT URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/README.TXT?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/README.TXT (original) +++ vmkit/trunk/README.TXT Mon Nov 25 14:10:43 2013 @@ -118,4 +118,3 @@ svn co https://YOUR_USER_NAME at llvm.org/s * Build it: make -j12 - Modified: vmkit/trunk/include/j3/J3Intrinsics.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/j3/J3Intrinsics.h?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/include/j3/J3Intrinsics.h (original) +++ vmkit/trunk/include/j3/J3Intrinsics.h Mon Nov 25 14:10:43 2013 @@ -45,7 +45,6 @@ public: llvm::Type* JavaMethodType; llvm::Type* JavaFieldType; llvm::Type* AttributeType; - llvm::Type* ThreadType; llvm::Type* JavaThreadType; llvm::Type* MutatorThreadType; llvm::Type* J3DenseMapType; @@ -141,8 +140,6 @@ public: llvm::Constant* OffsetBaseClassInArrayClassConstant; llvm::Constant* OffsetLogSizeInPrimitiveClassConstant; - llvm::Constant* OffsetOffsetInJavaMethodConstant; - llvm::Constant* ClassReadyConstant; llvm::Constant* JavaObjectNullConstant; Modified: vmkit/trunk/include/vmkit/GC.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/GC.h?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/include/vmkit/GC.h (original) +++ vmkit/trunk/include/vmkit/GC.h Mon Nov 25 14:10:43 2013 @@ -19,20 +19,14 @@ class gc; class gcHeader { public: word_t _header; - inline gc* toReference() { return (gc*)((uintptr_t)this + hiddenHeaderSize()); } static inline size_t hiddenHeaderSize() { return sizeof(gcHeader); } }; class gcRoot { public: - - inline word_t& header() {return toHeader()->_header; } - inline const word_t& header() const {return const_cast(this)->header(); } - - inline gcHeader* toHeader() { - return (gcHeader*)((uintptr_t)this - gcHeader::hiddenHeaderSize()); } - inline const gcHeader* toHeader() const {return const_cast(this)->toHeader(); } + word_t& header(){return toHeader()->_header; } + inline gcHeader* toHeader() { return (gcHeader*)((uintptr_t)this - gcHeader::hiddenHeaderSize()); } }; namespace vmkit { Removed: vmkit/trunk/include/vmkit/StackEmbeddedList.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/StackEmbeddedList.h?rev=195677&view=auto ============================================================================== --- vmkit/trunk/include/vmkit/StackEmbeddedList.h (original) +++ vmkit/trunk/include/vmkit/StackEmbeddedList.h (removed) @@ -1,49 +0,0 @@ - -#if JAVA_INTERFACE_CALL_STACK - -#ifndef STACK_EMBEDDED_LIST_NODE_H_ -#define STACK_EMBEDDED_LIST_NODE_H_ - -#include "vmkit/System.h" - -namespace vmkit { - -class Thread; - -} - -namespace j3 { - -class JavaMethod; - -enum StackEmbeddedListID { - StackEmbeddedListIntendedCaller = 0, - - StackEmbeddedListNodeCountPerThread -}; - -struct StackEmbeddedListNode -{ - StackEmbeddedListNode* callerNode; - word_t data[1]; - - void initialize() { - callerNode = NULL; - memset(data, 0, sizeof(*data) * StackEmbeddedListNodeCountPerThread); - } - - void dump() const __attribute__((noinline)); -}; - -} - -extern "C" void pushIntendedInvokedMethodNode( - vmkit::Thread* thread, j3::StackEmbeddedListNode* node, - j3::JavaMethod* intendedMethod); - -extern "C" void popIntendedInvokedMethodNode( - vmkit::Thread* thread, j3::StackEmbeddedListNode* node); - -#endif - -#endif Modified: vmkit/trunk/include/vmkit/System.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/System.h?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/include/vmkit/System.h (original) +++ vmkit/trunk/include/vmkit/System.h Mon Nov 25 14:10:43 2013 @@ -17,8 +17,6 @@ #include #include -#include "vmkit/config.h" - #if defined(__linux__) || defined(__FreeBSD__) #define LINUX_OS 1 #elif defined(__APPLE__) @@ -150,7 +148,7 @@ public: return pagesize; } - static word_t GetCallFrameAddress() __attribute((always_inline)) { + static word_t GetCallerAddress() __attribute((always_inline)) { #if defined(ARCH_X86) || defined(ARCH_X64) return (word_t)__builtin_frame_address(0); #else @@ -158,15 +156,15 @@ public: #endif } - static word_t GetCallerCallFrame(word_t currentCallFrame) { - return *(word_t*)currentCallFrame; + static word_t GetCallerOfAddress(word_t addr) { + return ((word_t*)addr)[0]; } - static word_t GetReturnAddressOfCallFrame(word_t currentCallFrame) { + static word_t GetIPFromCallerAddress(word_t addr) { #if defined(MACOS_OS) && defined(ARCH_PPC) - return ((word_t*)currentCallFrame)[2]; + return ((word_t*)addr)[2]; #else - return ((word_t*)currentCallFrame)[1]; + return ((word_t*)addr)[1]; #endif } Modified: vmkit/trunk/include/vmkit/Thread.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/Thread.h?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/include/vmkit/Thread.h (original) +++ vmkit/trunk/include/vmkit/Thread.h Mon Nov 25 14:10:43 2013 @@ -172,7 +172,7 @@ public: /// get - Get the thread specific data of the current thread. /// static Thread* get() { - return (Thread*)(System::GetCallFrameAddress() & System::GetThreadIDMask()); + return (Thread*)(System::GetCallerAddress() & System::GetThreadIDMask()); } private: @@ -239,7 +239,7 @@ public: /// stackOverflow - Returns if there is a stack overflow in Java land. /// bool stackOverflow() { - return (System::GetCallFrameAddress() & StackOverflowMask) == 0; + return (System::GetCallerAddress() & StackOverflowMask) == 0; } /// operator new - Allocate the Thread object as well as the stack for this @@ -331,12 +331,11 @@ public: /// class StackWalker { public: - word_t callFrameAddress; - word_t returnAddress; + word_t addr; + word_t ip; KnownFrame* frame; vmkit::Thread* thread; - StackWalker() __attribute__ ((noinline)); StackWalker(vmkit::Thread* th) __attribute__ ((noinline)); void operator++(); word_t operator*(); Modified: vmkit/trunk/include/vmkit/UTF8.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/include/vmkit/UTF8.h?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/include/vmkit/UTF8.h (original) +++ vmkit/trunk/include/vmkit/UTF8.h Mon Nov 25 14:10:43 2013 @@ -12,25 +12,6 @@ namespace vmkit { class UTF8Map; -template -int compare_null_terminated_arrays(const T1* array1, size_t size1, const T2* array2, size_t size2) -{ - // NULL array is treated as empty - if (!array1) size1 = 0; - if (!array2) size2 = 0; - - // Compute real sizes, excluding null terminators - for (; (size1 != 0) && (array1[size1 - 1] == 0); --size1); - for (; (size2 != 0) && (array2[size2 - 1] == 0); --size2); - - int diff = size1 - size2; // Compare sizes - if (diff == 0) { // Equal sizes, compare contents - for (; (size1 != 0) && (diff == 0); --size1, ++array1, ++array2) - diff = *array1 - *array2; - } - return diff; -} - class UTF8 { friend class UTF8Map; private: @@ -55,7 +36,8 @@ public: /// equals - Are the two UTF8s equal? bool equals(const UTF8* other) const { if (other == this) return true; - return (*this) == (*other); + else if (size != other->size) return false; + else return !memcmp(elements, other->elements, size * sizeof(uint16)); } /// equals - Does the UTF8 equal to the buffer? @@ -65,8 +47,12 @@ public: } /// lessThan - strcmp-like function for UTF8s, used by hash tables. - bool lessThan(const UTF8* other) const - { return (*this) < (*other); } + bool lessThan(const UTF8* other) const { + if (size < other->size) return true; + else if (size > other->size) return false; + else return memcmp((const char*)elements, (const char*)other->elements, + size * sizeof(uint16)) < 0; + } static uint32_t readerHasher(const uint16* buf, sint32 size); @@ -78,26 +64,9 @@ public: size = n; } - friend bool operator < (const UTF8& str1, const UTF8& str2) { - return UTF8::compare(&str1, &str2) < 0; - } - friend bool operator == (const UTF8& str1, const UTF8& str2) { - return UTF8::compare(&str1, &str2) == 0; - } friend std::ostream& operator << (std::ostream&, const UTF8&); - void dump() const __attribute__((noinline)); - int compare(const char *str, int length = -1) const { - return compare_null_terminated_arrays( - elements, size, str, (length == -1) ? strlen(str) : length); - } - int compare(const UTF8& str) const {return UTF8::compare(this, &str);} - static int compare(const UTF8* str1, const UTF8* str2) { - if (!str1 && !str2) return 0; - return compare_null_terminated_arrays( - (!str1 ? NULL : str1->elements), (!str1 ? 0 : str1->size), - (!str2 ? NULL : str2->elements), (!str2 ? 0 : str2->size)); - } + int compare(const char *) const; std::string& toString(std::string& buffer) const; }; @@ -114,13 +83,6 @@ struct UTF8MapKey { } }; -class UTF8_Comparator { -public: - bool operator() (const UTF8* str1, const UTF8* str2) const { - return (*str1) < (*str2); - } -}; - // Provide VmkitDenseMapInfo for UTF8. template<> struct VmkitDenseMapInfo { Modified: vmkit/trunk/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.cpp (original) +++ vmkit/trunk/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.cpp Mon Nov 25 14:10:43 2013 @@ -206,7 +206,6 @@ JavaMethod* Classpath::InitArithmeticExc JavaMethod* Classpath::InitCloneNotSupportedException; JavaMethod* Classpath::InitObject; JavaMethod* Classpath::FinalizeObject; -JavaMethod* Classpath::toString; JavaMethod* Classpath::IntToString; JavaMethod* Classpath::SystemArraycopy; @@ -906,9 +905,6 @@ void Classpath::initialiseClasspath(Jnjv FinalizeObject = UPCALL_METHOD(loader, "java/lang/Object", "finalize", "()V", ACC_VIRTUAL); - - toString = UPCALL_METHOD(loader, "java/lang/Object", "toString", - "()Ljava/lang/String;", ACC_VIRTUAL); IntToString = UPCALL_METHOD(loader, "java/lang/Integer", "toString", "(II)Ljava/lang/String;", ACC_STATIC); Modified: vmkit/trunk/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.h?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.h (original) +++ vmkit/trunk/lib/j3/ClassLib/GNUClasspath/JavaUpcalls.h Mon Nov 25 14:10:43 2013 @@ -251,7 +251,6 @@ public: ISOLATE_STATIC JavaMethod* InitObject; ISOLATE_STATIC JavaMethod* FinalizeObject; - ISOLATE_STATIC JavaMethod* toString; ISOLATE_STATIC JavaMethod* ErrorWithExcpNoClassDefFoundError; ISOLATE_STATIC JavaMethod* ErrorWithExcpExceptionInInitializerError; Modified: vmkit/trunk/lib/j3/ClassLib/OpenJDK/JavaUpcalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/ClassLib/OpenJDK/JavaUpcalls.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/ClassLib/OpenJDK/JavaUpcalls.cpp (original) +++ vmkit/trunk/lib/j3/ClassLib/OpenJDK/JavaUpcalls.cpp Mon Nov 25 14:10:43 2013 @@ -197,7 +197,6 @@ JavaMethod* Classpath::InitArithmeticExc JavaMethod* Classpath::InitCloneNotSupportedException; JavaMethod* Classpath::InitObject; JavaMethod* Classpath::FinalizeObject; -JavaMethod* Classpath::toString; JavaMethod* Classpath::IntToString; JavaMethod* Classpath::SystemArraycopy; @@ -788,9 +787,6 @@ void Classpath::initialiseClasspath(Jnjv FinalizeObject = UPCALL_METHOD(loader, "java/lang/Object", "finalize", "()V", ACC_VIRTUAL); - toString = UPCALL_METHOD(loader, "java/lang/Object", "toString", - "()Ljava/lang/String;", ACC_VIRTUAL); - IntToString = UPCALL_METHOD(loader, "java/lang/Integer", "toString", "(II)Ljava/lang/String;", ACC_STATIC); Modified: vmkit/trunk/lib/j3/ClassLib/OpenJDK/JavaUpcalls.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/ClassLib/OpenJDK/JavaUpcalls.h?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/ClassLib/OpenJDK/JavaUpcalls.h (original) +++ vmkit/trunk/lib/j3/ClassLib/OpenJDK/JavaUpcalls.h Mon Nov 25 14:10:43 2013 @@ -240,7 +240,6 @@ public: ISOLATE_STATIC JavaMethod* InitObject; ISOLATE_STATIC JavaMethod* FinalizeObject; - ISOLATE_STATIC JavaMethod* toString; ISOLATE_STATIC JavaMethod* ErrorWithExcpNoClassDefFoundError; ISOLATE_STATIC JavaMethod* ErrorWithExcpExceptionInInitializerError; Modified: vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp (original) +++ vmkit/trunk/lib/j3/Compiler/J3Intrinsics.cpp Mon Nov 25 14:10:43 2013 @@ -99,8 +99,6 @@ void J3Intrinsics::init(llvm::Module* mo PointerType::getUnqual(module->getTypeByName("UTF8")); AttributeType = PointerType::getUnqual(module->getTypeByName("Attribute")); - ThreadType = - PointerType::getUnqual(module->getTypeByName("Thread")); JavaThreadType = PointerType::getUnqual(module->getTypeByName("JavaThread")); MutatorThreadType = @@ -154,8 +152,6 @@ void J3Intrinsics::init(llvm::Module* mo OffsetBaseClassInArrayClassConstant = constantOne; OffsetLogSizeInPrimitiveClassConstant = constantOne; - OffsetOffsetInJavaMethodConstant = ConstantInt::get(Type::getInt32Ty(Context), 9); - OffsetObjectSizeInClassConstant = constantOne; OffsetVTInClassConstant = ConstantInt::get(Type::getInt32Ty(Context), 7); OffsetTaskClassMirrorInClassConstant = constantThree; Modified: vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/j3/Compiler/JavaAOTCompiler.cpp Mon Nov 25 14:10:43 2013 @@ -2143,8 +2143,7 @@ void mainCompilerStart(JavaThread* th) { JavaJITCompiler* Comp = NULL; if (!M->clinits->empty()) { - Comp = JavaJITCompiler::CreateCompiler( - "JIT", M->isCompilingGarbageCollector()); + Comp = JavaJITCompiler::CreateCompiler("JIT"); Comp->EmitFunctionName = true; if (!M->useCooperativeGC()) { Comp->disableCooperativeGC(); Modified: vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp (original) +++ vmkit/trunk/lib/j3/Compiler/JavaJIT.cpp Mon Nov 25 14:10:43 2013 @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -48,37 +47,6 @@ using namespace j3; using namespace llvm; using namespace std; -Value* JavaJIT::allocateOnStack( - const char* name, size_t byteCount, Type* realType) -{ - std::string bufferName(name); - bufferName += "Buffer"; - - Constant* wordCount = ConstantInt::get( - Type::getInt32Ty(*llvmContext), - vmkit::System::WordAlignUp(byteCount) / sizeof(void*)); - - Value* buffer = new AllocaInst(intrinsics->ptrType, - wordCount, sizeof(void*), bufferName, currentBlock); - return new BitCastInst(buffer, realType, name, currentBlock); -} - -Value* JavaJIT::getElementPtr( - const char *name, Value* element, Value* firstIndex, ...) -{ - std::vector indexList; - indexList.push_back(firstIndex); - - va_list argList; - Value* arg; - va_start(argList, firstIndex); - while ((arg = va_arg(argList, Value*)) != NULL) - indexList.push_back(arg); - va_end(argList); - - return GetElementPtrInst::Create(element, indexList, name, currentBlock); -} - void JavaJIT::updateStackInfo(Opinfo& info) { if (stackSize()) { if (!info.stack.size()) { @@ -253,47 +221,37 @@ void JavaJIT::invokeVirtual(uint16 index indexes2[1] = Offset; } else { nullChecked = true; - GlobalVariable* cachedMethodPtr = new GlobalVariable( - *llvmFunction->getParent(), intrinsics->JavaMethodType, - false, GlobalValue::ExternalLinkage, - Constant::getNullValue(intrinsics->JavaMethodType), "cachedMethodPtr"); - Value* cachedMethod = new LoadInst( - cachedMethodPtr, "cachedMethod", false, currentBlock); - + GlobalVariable* GV = new GlobalVariable(*llvmFunction->getParent(), + Type::getInt32Ty(*llvmContext), + false, + GlobalValue::ExternalLinkage, + intrinsics->constantZero, ""); + BasicBlock* resolveVirtual = createBasicBlock("resolveVirtual"); BasicBlock* endResolveVirtual = createBasicBlock("endResolveVirtual"); - PHINode* methodPtr = PHINode::Create( - intrinsics->JavaMethodType, 2, "methodPtr", endResolveVirtual); - methodPtr->addIncoming(cachedMethod, currentBlock); - - Value* test = new ICmpInst( - *currentBlock, ICmpInst::ICMP_EQ, cachedMethod, - Constant::getNullValue(intrinsics->JavaMethodType), "isCacheEmpty"); - BranchInst::Create(resolveVirtual, endResolveVirtual, test, currentBlock); + PHINode* node = PHINode::Create(Type::getInt32Ty(*llvmContext), 2, "", + 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(cachedMethodPtr); + Args.push_back(GV); Value* targetObject = getTarget(signature); - targetObject = new LoadInst( - targetObject, "targetObject", false, currentBlock); + targetObject = new LoadInst(targetObject, "", false, currentBlock); if (!thisReference) JITVerifyNull(targetObject); Args.push_back(targetObject); - Value* calculatedMethodPtr = invoke(intrinsics->VirtualLookupFunction, - Args, "calculatedMethod", currentBlock); - methodPtr->addIncoming(calculatedMethodPtr, currentBlock); - + load = invoke(intrinsics->VirtualLookupFunction, Args, "", currentBlock); + node->addIncoming(load, currentBlock); BranchInst::Create(endResolveVirtual, currentBlock); currentBlock = endResolveVirtual; - Value* methodOffset = getElementPtr( - "methodOffsetPtr", methodPtr, intrinsics->constantZero, - intrinsics->OffsetOffsetInJavaMethodConstant, NULL); - methodOffset = new LoadInst(methodOffset, "methodOffset", currentBlock); - - indexes2[1] = methodOffset; + indexes2[1] = node; } makeArgs(it, index, args, signature->nbArguments + 1); @@ -332,32 +290,19 @@ void JavaJIT::invokeVirtual(uint16 index } llvm::Value* JavaJIT::getMutatorThreadPtr() { - return new BitCastInst( - getThreadPtr(), intrinsics->MutatorThreadType, "MutatorThreadPtr", currentBlock); -} - -llvm::Value* JavaJIT::getThreadPtr() -{ - if (!currentThreadPtr) { - Value* frameAddr = CallInst::Create( - intrinsics->llvm_frameaddress, intrinsics->constantZero, - "frameAddress", currentBlock); - Value* ptr = new PtrToIntInst( - frameAddr, intrinsics->pointerSizeType, "", currentBlock); - ptr = BinaryOperator::CreateAnd( - ptr, intrinsics->constantThreadIDMask, "", currentBlock); - ptr = new IntToPtrInst( - ptr, intrinsics->ThreadType, "threadPtr", currentBlock); - - currentThreadPtr = ptr; - } + Value* FrameAddr = CallInst::Create(intrinsics->llvm_frameaddress, + intrinsics->constantZero, "", currentBlock); + Value* threadId = new PtrToIntInst(FrameAddr, intrinsics->pointerSizeType, "", + currentBlock); + threadId = BinaryOperator::CreateAnd(threadId, intrinsics->constantThreadIDMask, + "", currentBlock); + threadId = new IntToPtrInst(threadId, intrinsics->MutatorThreadType, "MutatorThreadPtr", currentBlock); - return currentThreadPtr; + return threadId; } -llvm::Value* JavaJIT::getJavaThreadPtr() { - return new BitCastInst( - getThreadPtr(), intrinsics->JavaThreadType, "JavaThreadPtr", currentBlock); +llvm::Value* JavaJIT::getJavaThreadPtr(llvm::Value* mutatorThreadPtr) { + return new BitCastInst(mutatorThreadPtr, intrinsics->JavaThreadType, "JavaThreadPtr", currentBlock); } llvm::Value* JavaJIT::getIsolateIDPtr(llvm::Value* mutatorThreadPtr) { @@ -475,6 +420,7 @@ llvm::Function* JavaJIT::nativeCompile(w return llvmFunction; } + Function* func = llvmFunction; if (j3) { Function* callee = Function::Create(llvmFunction->getFunctionType(), @@ -500,33 +446,30 @@ llvm::Function* JavaJIT::nativeCompile(w currentExceptionBlock = endExceptionBlock = 0; currentBlock = createBasicBlock("start"); - endBlock = createBasicBlock("endBlock"); + endBlock = createBasicBlock("end block"); - getThreadPtr(); - if (returnType != Type::getVoidTy(*llvmContext)) { endNode = PHINode::Create(returnType, 0, "", endBlock); } // Allocate currentLocalIndexNumber pointer - Value* temp = new AllocaInst( - Type::getInt32Ty(*llvmContext), "currentLocalIndexNumber", currentBlock); + 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(*llvmContext)), - "oldLocalIndexNumber", currentBlock); + Value* oldCLIN = new AllocaInst(PointerType::getUnqual(Type::getInt32Ty(*llvmContext)), "", + currentBlock); Constant* sizeF = ConstantInt::get(Type::getInt32Ty(*llvmContext), sizeof(vmkit::KnownFrame)); - Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "knownFrame", currentBlock); + Value* Frame = new AllocaInst(Type::getInt8Ty(*llvmContext), sizeF, "", currentBlock); uint32 nargs = func->arg_size() + 1 + (stat ? 1 : 0); std::vector nativeArgs; nativeArgs.push_back(NULL); // Will contain the callee - Value* jniEnv = getJNIEnvPtr(getJavaThreadPtr()); + Value* jniEnv = getJNIEnvPtr(getJavaThreadPtr(getMutatorThreadPtr())); jniEnv = new BitCastInst(jniEnv, intrinsics->ptrType, "", currentBlock); @@ -544,10 +487,10 @@ llvm::Function* JavaJIT::nativeCompile(w index < nargs; ++i, ++index) { if (i->getType() == intrinsics->JavaObjectType) { - BasicBlock* BB = createBasicBlock("continue"); - BasicBlock* NotZero = createBasicBlock("storeObjParamOnStack"); + BasicBlock* BB = createBasicBlock(""); + BasicBlock* NotZero = createBasicBlock(""); Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType); - PHINode* node = PHINode::Create(Ty, 2, "stack_obj_param_", BB); + PHINode* node = PHINode::Create(Ty, 2, "", BB); Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, i, intrinsics->JavaObjectNullConstant, ""); @@ -557,9 +500,8 @@ llvm::Function* JavaJIT::nativeCompile(w currentBlock = NotZero; - Instruction* temp = new AllocaInst( - intrinsics->JavaObjectType, "nonNullObjParamOnStack", - func->begin()->getTerminator()); + Instruction* temp = new AllocaInst(intrinsics->JavaObjectType, "", + func->begin()->getTerminator()); if (i == func->arg_begin() && !stat) { this->thisObject = temp; } @@ -587,10 +529,11 @@ llvm::Function* JavaJIT::nativeCompile(w } } + Instruction* ResultObject = 0; if (returnType == intrinsics->JavaObjectType) { - ResultObject = new AllocaInst( - intrinsics->JavaObjectType, "resultObjOnStack", func->begin()->begin()); + ResultObject = new AllocaInst(intrinsics->JavaObjectType, "", + func->begin()->begin()); if (TheCompiler->useCooperativeGC()) { @@ -612,8 +555,8 @@ llvm::Function* JavaJIT::nativeCompile(w Value* Arg = TheCompiler->getMethodInClass(compilingMethod); // If the global variable is null, then load it. - BasicBlock* unloadedBlock = createBasicBlock("unloadedBlock"); - BasicBlock* endBlock = createBasicBlock("endBlock"); + BasicBlock* unloadedBlock = createBasicBlock(""); + BasicBlock* endBlock = createBasicBlock(""); Value* test = new LoadInst(nativeFunc, "", currentBlock); Type* Ty = test->getType(); PHINode* node = PHINode::Create(Ty, 2, "", endBlock); @@ -652,7 +595,7 @@ llvm::Function* JavaJIT::nativeCompile(w Type* Ty = PointerType::getUnqual(intrinsics->JavaObjectType); Constant* C = Constant::getNullValue(Ty); Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, result, C, ""); - BasicBlock* loadBlock = createBasicBlock("loadBlock"); + BasicBlock* loadBlock = createBasicBlock(""); endNode->addIncoming(intrinsics->JavaObjectNullConstant, currentBlock); BranchInst::Create(endBlock, loadBlock, cmp, currentBlock); @@ -669,6 +612,7 @@ llvm::Function* JavaJIT::nativeCompile(w BranchInst::Create(endBlock, currentBlock); + currentBlock = endBlock; Value* Args2[1] = { oldCLIN }; @@ -679,9 +623,9 @@ llvm::Function* JavaJIT::nativeCompile(w if (isSynchro(compilingMethod->access)) endSynchronize(); - BasicBlock* ifNormal = createBasicBlock("ifNormal"); - BasicBlock* ifException = createBasicBlock("ifException"); - Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr()); + BasicBlock* ifNormal = createBasicBlock(""); + BasicBlock* ifException = createBasicBlock(""); + Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr())); Value* obj = new LoadInst(javaExceptionPtr, "", currentBlock); Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, intrinsics->JavaObjectNullConstant, ""); BranchInst::Create(ifException, ifNormal, test, currentBlock); @@ -737,8 +681,8 @@ void JavaJIT::monitorEnter(Value* obj) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, atomic, lock, ""); - BasicBlock* OK = createBasicBlock("synchronizePassed"); - BasicBlock* NotOK = createBasicBlock("synchronizeDidNotPass"); + BasicBlock* OK = createBasicBlock("synchronize passed"); + BasicBlock* NotOK = createBasicBlock("synchronize did not pass"); BranchInst::Create(OK, NotOK, cmp, currentBlock); @@ -790,7 +734,7 @@ void JavaJIT::monitorExit(Value* obj) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, atomic, oldValMask, ""); - BasicBlock* LockFreeCASFailed = createBasicBlock("LockFreeCASFailed"); + BasicBlock* LockFreeCASFailed = createBasicBlock("Lock-Free CAS Failed"); BranchInst::Create(EndBlock, LockFreeCASFailed, cmp, currentBlock); @@ -1094,30 +1038,28 @@ llvm::Function* JavaJIT::javaCompile() { opcodeInfos[i].exceptionBlock = endExceptionBlock; } - getThreadPtr(); - Instruction* returnValue = NULL; if (returnType == intrinsics->JavaObjectType && TheCompiler->useCooperativeGC()) { - returnValue = new AllocaInst( - intrinsics->JavaObjectType, "returnValueStorage", currentBlock); - Instruction* cast = new BitCastInst( - returnValue, intrinsics->ptrPtrType, "returnValue", currentBlock); + returnValue = new AllocaInst(intrinsics->JavaObjectType, "returnValue", + currentBlock); + Instruction* cast = + new BitCastInst(returnValue, intrinsics->ptrPtrType, "", currentBlock); Value* GCArgs[2] = { cast, intrinsics->constantPtrNull }; CallInst::Create(intrinsics->llvm_gc_gcroot, GCArgs, "", currentBlock); } for (int i = 0; i < maxLocals; i++) { - intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), setInstructionName(instName, instNameLen, "local_int_%d", i), currentBlock)); + intLocals.push_back(new AllocaInst(Type::getInt32Ty(*llvmContext), setInstructionName(instName, instNameLen, "int_%d", i), currentBlock)); new StoreInst(Constant::getNullValue(Type::getInt32Ty(*llvmContext)), intLocals.back(), false, currentBlock); - doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), setInstructionName(instName, instNameLen, "local_double_%d", i), currentBlock)); + doubleLocals.push_back(new AllocaInst(Type::getDoubleTy(*llvmContext), setInstructionName(instName, instNameLen, "double_%d", i), currentBlock)); new StoreInst(Constant::getNullValue(Type::getDoubleTy(*llvmContext)), doubleLocals.back(), false, currentBlock); - longLocals.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), setInstructionName(instName, instNameLen, "local_long_%d", i), currentBlock)); + longLocals.push_back(new AllocaInst(Type::getInt64Ty(*llvmContext), setInstructionName(instName, instNameLen, "long_%d", i), currentBlock)); new StoreInst(Constant::getNullValue(Type::getInt64Ty(*llvmContext)), longLocals.back(), false, currentBlock); - floatLocals.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), setInstructionName(instName, instNameLen, "local_float_%d", i), currentBlock)); + floatLocals.push_back(new AllocaInst(Type::getFloatTy(*llvmContext), setInstructionName(instName, instNameLen, "float_%d", i), currentBlock)); new StoreInst(Constant::getNullValue(Type::getFloatTy(*llvmContext)), floatLocals.back(), false, currentBlock); - objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, setInstructionName(instName, instNameLen, "local_object_%d", i), currentBlock)); + objectLocals.push_back(new AllocaInst(intrinsics->JavaObjectType, setInstructionName(instName, instNameLen, "object_%d", i), currentBlock)); // The GCStrategy will already initialize the value. if (!TheCompiler->useCooperativeGC()) new StoreInst(Constant::getNullValue(intrinsics->JavaObjectType), objectLocals.back(), false, currentBlock); @@ -1189,7 +1131,7 @@ llvm::Function* JavaJIT::javaCompile() { nbHandlers = readExceptionTable(reader, codeLen); if (nbHandlers != 0) { - jmpBuffer = new AllocaInst(ArrayType::get(Type::getInt8Ty(*llvmContext), sizeof(vmkit::ExceptionBuffer)), "exceptionSavePointStorage", currentBlock); + jmpBuffer = new AllocaInst(ArrayType::get(Type::getInt8Ty(*llvmContext), sizeof(vmkit::ExceptionBuffer)), "", currentBlock); jmpBuffer = new BitCastInst(jmpBuffer, intrinsics->ptrType, "exceptionSavePoint", currentBlock); } @@ -1199,7 +1141,7 @@ llvm::Function* JavaJIT::javaCompile() { endBlock = createBasicBlock("end"); if (returnType != Type::getVoidTy(*llvmContext)) { - endNode = llvm::PHINode::Create(returnType, 0, "returnValuePhi", endBlock); + endNode = llvm::PHINode::Create(returnType, 0, "", endBlock); } checkYieldPoint(); @@ -1223,8 +1165,8 @@ llvm::Function* JavaJIT::javaCompile() { stackCheck = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, stackCheck, intrinsics->constantPtrZero, ""); - BasicBlock* stackOverflow = createBasicBlock("stackOverflow"); - BasicBlock* noStackOverflow = createBasicBlock("noStackOverflow"); + BasicBlock* stackOverflow = createBasicBlock("stack overflow"); + BasicBlock* noStackOverflow = createBasicBlock("no stack overflow"); BranchInst::Create(stackOverflow, noStackOverflow, stackCheck, currentBlock); currentBlock = stackOverflow; @@ -1285,9 +1227,9 @@ llvm::Function* JavaJIT::javaCompile() { currentBlock->eraseFromParent(); } else { if (nbHandlers != 0) { - BasicBlock* ifNormal = createBasicBlock("noExceptionThrown"); - BasicBlock* ifException = createBasicBlock("reThrowException"); - Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr()); + BasicBlock* ifNormal = createBasicBlock("No exception was thrown"); + BasicBlock* ifException = createBasicBlock("Rethrow Exception"); + Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr())); Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock); Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, obj, intrinsics->JavaObjectNullConstant, ""); BranchInst::Create(ifException, ifNormal, test, currentBlock); @@ -1439,8 +1381,8 @@ void JavaJIT::JITVerifyNull(Value* obj) } else { Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj, intrinsics->JavaObjectNullConstant, ""); - BasicBlock* nullObjBlock = createBasicBlock("objectIsNull"); - BasicBlock* notNullObjBlock = createBasicBlock("objectIsNotNull"); + BasicBlock* nullObjBlock = createBasicBlock("object is null"); + BasicBlock* notNullObjBlock = createBasicBlock("object is not null"); BranchInst::Create(nullObjBlock, notNullObjBlock, test, currentBlock); currentBlock = nullObjBlock; @@ -1466,8 +1408,8 @@ Value* JavaJIT::verifyAndComputePtr(Valu Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_ULT, index, size, ""); - BasicBlock* ifTrue = createBasicBlock("trueVerifyAndComputePtr"); - BasicBlock* ifFalse = createBasicBlock("falseVerifyAndComputePtr"); + BasicBlock* ifTrue = createBasicBlock("true verifyAndComputePtr"); + BasicBlock* ifFalse = createBasicBlock("false verifyAndComputePtr"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); @@ -2238,6 +2180,7 @@ void JavaJIT::getVirtualField(uint16 ind } } + void JavaJIT::invokeInterface(uint16 index) { // Do the usual @@ -2402,13 +2345,14 @@ DebugLoc JavaJIT::CreateLocation() { } Instruction* JavaJIT::invoke(Value *F, std::vector& args, - const char* Name, BasicBlock *InsertAtEnd) { + const char* Name, + BasicBlock *InsertAtEnd) { assert(!inlining); BasicBlock* ifException = NULL; if (jmpBuffer != NULL) { - BasicBlock* doCall = createBasicBlock("performCall"); - ifException = createBasicBlock("exceptionThrown"); + BasicBlock* doCall = createBasicBlock("Perform call"); + ifException = createBasicBlock("Exception thrown"); Instruction* check = CallInst::Create(intrinsics->SetjmpFunction, jmpBuffer, "", currentBlock); check = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, check, intrinsics->constantZero, ""); BranchInst::Create(doCall, ifException, check, currentBlock); @@ -2422,7 +2366,7 @@ Instruction* JavaJIT::invoke(Value *F, s if (jmpBuffer != NULL) { CallInst::Create(intrinsics->UnregisterSetjmpFunction, jmpBuffer, "", currentBlock); - BasicBlock* ifNormal = createBasicBlock("noExceptionBlock"); + BasicBlock* ifNormal = createBasicBlock("no exception block"); BranchInst::Create(ifNormal, currentBlock); currentBlock = ifException; @@ -2442,7 +2386,7 @@ Instruction* JavaJIT::invoke(Value *F, V } Instruction* JavaJIT::invoke(Value *F, Value* arg1, Value* arg2, - const char* Name, BasicBlock *InsertAtEnd) { + const char* Name, BasicBlock *InsertAtEnd) { std::vector args; args.push_back(arg1); args.push_back(arg2); @@ -2450,7 +2394,7 @@ Instruction* JavaJIT::invoke(Value *F, V } Instruction* JavaJIT::invoke(Value *F, const char* Name, - BasicBlock *InsertAtEnd) { + BasicBlock *InsertAtEnd) { std::vector args; return invoke(F, args, Name, InsertAtEnd); } @@ -2461,7 +2405,7 @@ void JavaJIT::throwException(Value* obj, CallInst::Create(intrinsics->ThrowExceptionFunction, obj, "", currentBlock); new UnreachableInst(*llvmContext, currentBlock); } else { - Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr()); + Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr())); if (vmkit::Collector::needsNonHeapWriteBarrier()) { Instruction* ptr = new BitCastInst(javaExceptionPtr, intrinsics->ptrPtrType, "", currentBlock); Instruction* val = new BitCastInst(obj, intrinsics->ptrType, "", currentBlock); @@ -2613,7 +2557,7 @@ unsigned JavaJIT::readExceptionTable(Rea Value* VTVar = TheCompiler->getVirtualTable(cur->catchClass->virtualVT); // Get the Java exception. - Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr()); + Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr())); Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock); Value* objVT = CallInst::Create(intrinsics->GetVTFunction, obj, "objectVT", Modified: vmkit/trunk/lib/j3/Compiler/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJIT.h?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/JavaJIT.h (original) +++ vmkit/trunk/lib/j3/Compiler/JavaJIT.h Mon Nov 25 14:10:43 2013 @@ -107,7 +107,6 @@ public: overridesThis = false; nbHandlers = 0; jmpBuffer = NULL; - currentThreadPtr = NULL; } /// javaCompile - Compile the Java method. @@ -169,8 +168,6 @@ private: llvm::Value* jmpBuffer; - llvm::Value* currentThreadPtr; - /// return the header of an object llvm::Value* objectToHeader(llvm::Value* obj); @@ -185,8 +182,6 @@ private: llvm::BasicBlock* currentBlock, bool usign); /// getMutatorThreadPtr - Emit code to get a pointer to the current MutatorThread. - llvm::Value* getThreadPtr(); - llvm::Value* getJavaThreadPtr(); llvm::Value* getMutatorThreadPtr(); /// getIsolateIDPtr - Emit code to get a pointer to IsolateID. @@ -575,11 +570,6 @@ private: //===--------------------- Yield point support ---------------------------===// void checkYieldPoint(); - - llvm::Value* getElementPtr( - const char *name, llvm::Value* element, llvm::Value* firstIndex, ...); - llvm::Value* allocateOnStack( - const char* name, size_t byteCount, llvm::Type* realType); }; enum Opcode { Modified: vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/trunk/lib/j3/Compiler/JavaJITOpcodes.cpp Mon Nov 25 14:10:43 2013 @@ -376,7 +376,7 @@ void JavaJIT::compileOpcodes(Reader& rea stack.clear(); if (opinfo->handler) { // If it's a handler, put the exception object in the stack. - Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr()); + Value* javaExceptionPtr = getJavaExceptionPtr(getJavaThreadPtr(getMutatorThreadPtr())); Value* obj = new LoadInst(javaExceptionPtr, "pendingException", currentBlock); new StoreInst(obj, objectStack[0], "", currentBlock); // And clear the exception. @@ -940,10 +940,10 @@ void JavaJIT::compileOpcodes(Reader& rea Value* res = 0; if (TheCompiler->isStaticCompiling()) { - BasicBlock* endBlock = createBasicBlock("endArrayStoreCheck"); - BasicBlock* checkBlock = createBasicBlock("arrayStoreCheck"); + BasicBlock* endBlock = createBasicBlock("end array store check"); + BasicBlock* checkBlock = createBasicBlock("array store check"); BasicBlock* exceptionBlock = - createBasicBlock("arrayStoreException"); + createBasicBlock("array store exception"); Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, intrinsics->JavaObjectNullConstant, ""); @@ -1262,8 +1262,8 @@ void JavaJIT::compileOpcodes(Reader& rea if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantZero, ""); - BasicBlock* ifFalse = createBasicBlock("nonNullDiv"); - BasicBlock* ifTrue = createBasicBlock("nullDiv"); + BasicBlock* ifFalse = createBasicBlock("non null div"); + BasicBlock* ifTrue = createBasicBlock("null div"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; @@ -1272,9 +1272,9 @@ void JavaJIT::compileOpcodes(Reader& rea } Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantMinusOne, ""); - BasicBlock* ifFalse = createBasicBlock("nonMinusOneDiv"); - BasicBlock* ifTrue = createBasicBlock("minusOneDiv"); - BasicBlock* endBlock = createBasicBlock("endDivision"); + BasicBlock* ifFalse = createBasicBlock("non -1 div"); + BasicBlock* ifTrue = createBasicBlock("-1 div"); + BasicBlock* endBlock = createBasicBlock("End division"); PHINode* node = PHINode::Create(val1->getType(), 2, "", endBlock); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; @@ -1300,8 +1300,8 @@ void JavaJIT::compileOpcodes(Reader& rea if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantLongZero, ""); - BasicBlock* ifFalse = createBasicBlock("nonNullDiv"); - BasicBlock* ifTrue = createBasicBlock("nullDiv"); + BasicBlock* ifFalse = createBasicBlock("non null div"); + BasicBlock* ifTrue = createBasicBlock("null div"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; @@ -1339,8 +1339,8 @@ void JavaJIT::compileOpcodes(Reader& rea if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantZero, ""); - BasicBlock* ifFalse = createBasicBlock("nonNullRem"); - BasicBlock* ifTrue = createBasicBlock("nullRem"); + BasicBlock* ifFalse = createBasicBlock("non null rem"); + BasicBlock* ifTrue = createBasicBlock("null rem"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; @@ -1349,8 +1349,8 @@ void JavaJIT::compileOpcodes(Reader& rea } Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantMinusOne, ""); - BasicBlock* ifFalse = createBasicBlock("nonMinusOneRem"); - BasicBlock* endBlock = createBasicBlock("endBlock"); + BasicBlock* ifFalse = createBasicBlock("non -1 rem"); + BasicBlock* endBlock = createBasicBlock("end block"); PHINode* node = PHINode::Create(val1->getType(), 2, "", endBlock); node->addIncoming(intrinsics->constantZero, currentBlock); BranchInst::Create(endBlock, ifFalse, cmp, currentBlock); @@ -1372,8 +1372,8 @@ void JavaJIT::compileOpcodes(Reader& rea if (TheCompiler->hasExceptionsEnabled()) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val2, intrinsics->constantLongZero, ""); - BasicBlock* ifFalse = createBasicBlock("nonNullDiv"); - BasicBlock* ifTrue = createBasicBlock("nullDiv"); + BasicBlock* ifFalse = createBasicBlock("non null div"); + BasicBlock* ifTrue = createBasicBlock("null div"); BranchInst::Create(ifTrue, ifFalse, cmp, currentBlock); currentBlock = ifTrue; @@ -1911,7 +1911,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("falseIFEQ"); + BasicBlock* ifFalse = createBasicBlock("false IFEQ"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -1928,7 +1928,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("falseIFNE"); + BasicBlock* ifFalse = createBasicBlock("false IFNE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -1944,7 +1944,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("falseIFLT"); + BasicBlock* ifFalse = createBasicBlock("false IFLT"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -1960,7 +1960,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGE, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("falseIFGE"); + BasicBlock* ifFalse = createBasicBlock("false IFGE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -1976,7 +1976,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGT, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("falseIFGT"); + BasicBlock* ifFalse = createBasicBlock("false IFGT"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -1992,7 +1992,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLE, op, val, ""); - BasicBlock* ifFalse = createBasicBlock("falseIFLE"); + BasicBlock* ifFalse = createBasicBlock("false IFLE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2007,7 +2007,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPEQ"); + BasicBlock* ifFalse = createBasicBlock("false IF_ICMPEQ"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2022,7 +2022,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPNE"); + BasicBlock* ifFalse = createBasicBlock("false IF_ICMPNE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2037,7 +2037,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLT, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("falseIF_IFCMPLT"); + BasicBlock* ifFalse = createBasicBlock("false IF_IFCMPLT"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2052,7 +2052,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGE, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPGE"); + BasicBlock* ifFalse = createBasicBlock("false IF_ICMPGE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2067,7 +2067,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SGT, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPGT"); + BasicBlock* ifFalse = createBasicBlock("false IF_ICMPGT"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2082,7 +2082,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_SLE, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("falseIF_ICMPLE"); + BasicBlock* ifFalse = createBasicBlock("false IF_ICMPLE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2097,7 +2097,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("falseIF_ACMPEQ"); + BasicBlock* ifFalse = createBasicBlock("false IF_ACMPEQ"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2112,7 +2112,7 @@ void JavaJIT::compileOpcodes(Reader& rea BasicBlock* ifTrue = ifTrueInfo.newBlock; llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, val1, val2, ""); - BasicBlock* ifFalse = createBasicBlock("falseIF_ACMPNE"); + BasicBlock* ifFalse = createBasicBlock("false IF_ACMPNE"); branch(test, ifTrue, ifFalse, currentBlock, ifTrueInfo); currentBlock = ifFalse; break; @@ -2178,7 +2178,7 @@ void JavaJIT::compileOpcodes(Reader& rea for (sint32 cur = low; cur < high; ++cur) { Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, ConstantInt::get(type, cur), index, ""); - BasicBlock* falseBlock = createBasicBlock("continueTableswitch"); + BasicBlock* falseBlock = createBasicBlock("continue tableswitch"); Opinfo& info = opcodeInfos[tmp + reader.readU4()]; i += 4; branch(cmp, info.newBlock, falseBlock, currentBlock, info); @@ -2208,7 +2208,7 @@ void JavaJIT::compileOpcodes(Reader& rea i += 4; Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, key, ""); - BasicBlock* falseBlock = createBasicBlock("continueLookupswitch"); + BasicBlock* falseBlock = createBasicBlock("continue lookupswitch"); Opinfo& info = opcodeInfos[tmp + reader.readU4()]; i += 4; branch(cmp, info.newBlock, falseBlock, currentBlock, info); @@ -2474,22 +2474,22 @@ void JavaJIT::compileOpcodes(Reader& rea Value* args[2] = { obj, clVar }; Value* cmp = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, obj, intrinsics->JavaObjectNullConstant, ""); - BasicBlock* endBlock = createBasicBlock("endTypeCompare"); + BasicBlock* endBlock = createBasicBlock("end type compare"); PHINode* node = PHINode::Create(Type::getInt1Ty(*llvmContext), 2, "", endBlock); if (checkcast) { - exceptionCheckcast = createBasicBlock("falseCheckcast"); + exceptionCheckcast = createBasicBlock("false checkcast"); - endCheckcast = createBasicBlock("nullCheckcast"); - BasicBlock* ifFalse = createBasicBlock("nonNullCheckcast"); + endCheckcast = createBasicBlock("null checkcast"); + BasicBlock* ifFalse = createBasicBlock("non null checkcast"); BranchInst::Create(endCheckcast, ifFalse, cmp, currentBlock); currentBlock = exceptionCheckcast; throwRuntimeException(intrinsics->ClassCastExceptionFunction, args, 2); currentBlock = ifFalse; } else { - BasicBlock* ifFalse = createBasicBlock("falseTypeCompare"); + BasicBlock* ifFalse = createBasicBlock("false type compare"); BranchInst::Create(endBlock, ifFalse, cmp, currentBlock); node->addIncoming(ConstantInt::getFalse(*llvmContext), currentBlock); currentBlock = ifFalse; @@ -2607,7 +2607,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* nil = Constant::getNullValue(val->getType()); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_EQ, val, nil, ""); - BasicBlock* ifFalse = createBasicBlock("trueIFNULL"); + BasicBlock* ifFalse = createBasicBlock("true IFNULL"); Opinfo& ifTrueInfo = opcodeInfos[tmp + reader.readS2()]; i += 2; BasicBlock* ifTrue = ifTrueInfo.newBlock; @@ -2622,7 +2622,7 @@ void JavaJIT::compileOpcodes(Reader& rea Constant* nil = Constant::getNullValue(val->getType()); llvm::Value* test = new ICmpInst(*currentBlock, ICmpInst::ICMP_NE, val, nil, ""); - BasicBlock* ifFalse = createBasicBlock("falseIFNONNULL"); + BasicBlock* ifFalse = createBasicBlock("false IFNONNULL"); Opinfo& ifTrueInfo = opcodeInfos[tmp + reader.readS2()]; i += 2; BasicBlock* ifTrue = ifTrueInfo.newBlock; Modified: vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp (original) +++ vmkit/trunk/lib/j3/Compiler/LowerConstantCalls.cpp Mon Nov 25 14:10:43 2013 @@ -287,8 +287,8 @@ bool LowerConstantCalls::runOnFunction(F Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, Del, intrinsics->JavaObjectNullConstant, ""); - BasicBlock* NoDelegatee = BasicBlock::Create(*Context, "noDelegatee", &F); - BasicBlock* DelegateeOK = BasicBlock::Create(*Context, "delegateeOK", &F); + BasicBlock* NoDelegatee = BasicBlock::Create(*Context, "No delegatee", &F); + BasicBlock* DelegateeOK = BasicBlock::Create(*Context, "Delegatee OK", &F); BranchInst::Create(NoDelegatee, DelegateeOK, cmp, CI); PHINode* phi = PHINode::Create(intrinsics->JavaObjectType, 2, "", DelegateeOK); phi->addIncoming(Del, CI->getParent()); @@ -398,8 +398,8 @@ bool LowerConstantCalls::runOnFunction(F Value* test = new ICmpInst(CI, ICmpInst::ICMP_EQ, arg1, intrinsics->constantPtrNull, ""); - BasicBlock* trueCl = BasicBlock::Create(*Context, "CtpOK", &F); - BasicBlock* falseCl = BasicBlock::Create(*Context, "CtpNotOK", &F); + BasicBlock* trueCl = BasicBlock::Create(*Context, "Ctp OK", &F); + BasicBlock* falseCl = BasicBlock::Create(*Context, "Ctp Not OK", &F); PHINode* node = llvm::PHINode::Create(returnType, 2, "", trueCl); node->addIncoming(arg1, CI->getParent()); BranchInst::Create(falseCl, trueCl, test, CI); @@ -465,8 +465,8 @@ bool LowerConstantCalls::runOnFunction(F Value* cmp = new ICmpInst(CI, ICmpInst::ICMP_EQ, LoadedGV, init, ""); - BasicBlock* OKBlock = BasicBlock::Create(*Context, "OK", &F); - BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "NotOK", &F); + BasicBlock* OKBlock = BasicBlock::Create(*Context, "", &F); + BasicBlock* NotOKBlock = BasicBlock::Create(*Context, "", &F); PHINode* node = PHINode::Create(intrinsics->VTType, 2, "", OKBlock); node->addIncoming(LoadedGV, CI->getParent()); @@ -509,8 +509,8 @@ bool LowerConstantCalls::runOnFunction(F BasicBlock* EndBlock = II->getParent()->splitBasicBlock(II); I->getParent()->getTerminator()->eraseFromParent(); - BasicBlock* CurEndBlock = BasicBlock::Create(*Context, "currentEnd", &F); - BasicBlock* FailedBlock = BasicBlock::Create(*Context, "failed", &F); + BasicBlock* CurEndBlock = BasicBlock::Create(*Context, "", &F); + BasicBlock* FailedBlock = BasicBlock::Create(*Context, "", &F); PHINode* node = PHINode::Create(Type::getInt1Ty(*Context), 2, "", CurEndBlock); ConstantInt* CC = ConstantInt::get(Type::getInt32Ty(*Context), 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=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll (original) +++ vmkit/trunk/lib/j3/LLVMRuntime/runtime-default.ll Mon Nov 25 14:10:43 2013 @@ -27,10 +27,6 @@ ;;; Field 2: The static instance %TaskClassMirror = type { i8, i1, i8* } -;;; Field 0: callerNode -;;; Field 1: data -%StackEmbeddedListNode = type { %StackEmbeddedListNode*, [1 x i8*] } - %CircularBase = type { %VT*, %CircularBase*, %CircularBase* } ;;; Field 0: the parent (circular base) @@ -45,11 +41,7 @@ ;;; field 9: void* routine ;;; field 10: void* lastKnownFrame ;;; field 11: void* lastExceptionBuffer -;;; field 12: void* stackEmbeddedListHead ( 1 = vmkit::StackEmbeddedListNodeCountPerThread ) -%Thread = type { - %CircularBase, i32, i8*, i8*, i1, i1, i1, i8*, i8*, i8*, i8*, i8*, - [1 x %StackEmbeddedListNode*] -} +%Thread = type { %CircularBase, i32, i8*, i8*, i1, i1, i1, i8*, i8*, i8*, i8*, i8* } %JavaThread = type { %MutatorThread, i8*, %JavaObject* } @@ -192,7 +184,7 @@ declare i8* @getConstantPoolAt(i8* (%Jav ;;; j3VirtualTableLookup - Look up the offset in a virtual table of a ;;; specific function. -declare %JavaMethod* @j3VirtualTableLookup(%JavaClass*, i32, %JavaMethod**, %JavaObject*) +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 Modified: vmkit/trunk/lib/j3/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaClass.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JavaClass.cpp Mon Nov 25 14:10:43 2013 @@ -2349,8 +2349,8 @@ void JavaField::setStaticField(JavaObjec std::ostream& j3::operator << (std::ostream& os, const CommonClass& ccl) { - return os << *ccl.name << ';'; -// return (!ccl.super) ? (os << ';') : (os << ':' << *ccl.super); + os << *ccl.name; + return (!ccl.super) ? (os << ';') : (os << ':' << *ccl.super); } void CommonClass::dump() const Modified: vmkit/trunk/lib/j3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaClass.h?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/j3/VMCore/JavaClass.h Mon Nov 25 14:10:43 2013 @@ -1023,15 +1023,12 @@ private: jvalue* marshalArguments(vmkit::ThreadAllocator& allocator, va_list ap); template - TYPE invokeSpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, - void* buf) __attribute__((noinline)) - { + TYPE invokeSpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) __attribute__((noinline)) { llvm_gcroot(obj, 0); verifyNull(obj); void* func = this->compiledPtr(); - FUNC_TYPE_VIRTUAL_BUF call = - (FUNC_TYPE_VIRTUAL_BUF)getSignature()->getVirtualCallBuf(); + FUNC_TYPE_VIRTUAL_BUF call = (FUNC_TYPE_VIRTUAL_BUF)getSignature()->getVirtualCallBuf(); JavaThread* th = JavaThread::get(); th->startJava(); @@ -1046,14 +1043,11 @@ private: } template - TYPE invokeVirtualBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, - void* buf) __attribute__((noinline)) - { + TYPE invokeVirtualBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) __attribute__((noinline)) { llvm_gcroot(obj, 0); UserCommonClass* theClass = JavaObject::getClass(obj); - UserClass* objCl = - theClass->isArray() ? theClass->super : theClass->asClass(); + UserClass* objCl = theClass->isArray() ? theClass->super : theClass->asClass(); JavaMethod* meth = this; if ((objCl != classDef) && !isFinal(access)) { @@ -1063,22 +1057,18 @@ private: assert(objCl->isSubclassOf(meth->classDef) && "Wrong type"); - return meth->invokeSpecialBuf( - vm, cl, obj, buf); + return meth->invokeSpecialBuf(vm, cl, obj, buf); } template - TYPE invokeStaticBuf(Jnjvm* vm, UserClass* cl, - void* buf) __attribute__((noinline)) - { + TYPE invokeStaticBuf(Jnjvm* vm, UserClass* cl, void* buf) __attribute__((noinline)) { if (!cl->isReady()) { cl->resolveClass(); cl->initialiseClass(vm); } void* func = this->compiledPtr(); - FUNC_TYPE_STATIC_BUF call = - (FUNC_TYPE_STATIC_BUF)getSignature()->getStaticCallBuf(); + FUNC_TYPE_STATIC_BUF call = (FUNC_TYPE_STATIC_BUF)getSignature()->getStaticCallBuf(); JavaThread* th = JavaThread::get(); th->startJava(); @@ -1093,38 +1083,29 @@ private: } template - TYPE invokeVirtualAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, - va_list ap) __attribute__((noinline)) - { + TYPE invokeVirtualAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap) __attribute__((noinline)) { llvm_gcroot(obj, 0); assert(cl && "Class is NULL"); vmkit::ThreadAllocator allocator; jvalue* buffer = marshalArguments(allocator, ap); - return invokeVirtualBuf( - vm, cl, obj, buffer); + return invokeVirtualBuf(vm, cl, obj, buffer); } template - TYPE invokeSpecialAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, - va_list ap) __attribute__((noinline)) - { + TYPE invokeSpecialAP(Jnjvm* vm, UserClass* cl, JavaObject* obj, va_list ap) __attribute__((noinline)) { llvm_gcroot(obj, 0); assert(cl && "Class is NULL"); vmkit::ThreadAllocator allocator; jvalue* buffer = marshalArguments(allocator, ap); - return invokeSpecialBuf( - vm, cl, obj, buffer); + return invokeSpecialBuf(vm, cl, obj, buffer); } template - TYPE invokeStaticAP(Jnjvm* vm, UserClass* cl, - va_list ap) __attribute__((noinline)) - { + TYPE invokeStaticAP(Jnjvm* vm, UserClass* cl, va_list ap) __attribute__((noinline)) { assert(cl && "Class is NULL"); vmkit::ThreadAllocator allocator; jvalue* buffer = marshalArguments(allocator, ap); - return invokeStaticBuf( - vm, cl, buffer); + return invokeStaticBuf(vm, cl, buffer); } #define JavaMethod_DECL_INVOKE_VA(TYPE, TYPE_NAME) \ Modified: vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JavaMetaJIT.cpp Mon Nov 25 14:10:43 2013 @@ -69,19 +69,19 @@ jvalue* JavaMethod::marshalArguments(vmk return res; \ } \ TYPE JavaMethod::invoke##TYPE_NAME##Special(Jnjvm* vm, UserClass* cl, JavaObject* obj, ...) { \ - llvm_gcroot(obj, 0); \ - va_list ap; \ - va_start(ap, obj); \ - TYPE res = invokeSpecialAP(vm, cl, obj, ap); \ - va_end(ap); \ - return res; \ + llvm_gcroot(obj, 0); \ + va_list ap; \ + va_start(ap, obj); \ + TYPE res = invokeSpecialAP(vm, cl, obj, ap); \ + va_end(ap); \ + return res; \ } \ TYPE JavaMethod::invoke##TYPE_NAME##Static(Jnjvm* vm, UserClass* cl, ...) { \ - va_list ap; \ - va_start(ap, cl); \ - TYPE res = invokeStaticAP(vm, cl, ap); \ - va_end(ap); \ - return res; \ + va_list ap; \ + va_start(ap, cl); \ + TYPE res = invokeStaticAP(vm, cl, ap); \ + va_end(ap); \ + return res; \ } #define JavaMethod_INVOKE_AP(TYPE, TYPE_NAME, FUNC_TYPE_VIRTUAL_AP, FUNC_TYPE_STATIC_AP, FUNC_TYPE_VIRTUAL_BUF, FUNC_TYPE_STATIC_BUF) \ @@ -104,7 +104,7 @@ jvalue* JavaMethod::marshalArguments(vmk } \ TYPE JavaMethod::invoke##TYPE_NAME##SpecialBuf(Jnjvm* vm, UserClass* cl, JavaObject* obj, void* buf) { \ llvm_gcroot(obj, 0); \ - return invokeSpecialBuf(vm, cl, obj, buf); \ + return invokeSpecialBuf(vm, cl, obj, buf); \ } \ TYPE JavaMethod::invoke##TYPE_NAME##StaticBuf(Jnjvm* vm, UserClass* cl, void* buf) { \ return invokeStaticBuf(vm, cl, buf); \ Modified: vmkit/trunk/lib/j3/VMCore/JavaObject.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaObject.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaObject.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JavaObject.cpp Mon Nov 25 14:10:43 2013 @@ -387,11 +387,9 @@ bool JavaObject::instanceOf(JavaObject* std::ostream& j3::operator << (std::ostream& os, const JavaObject& obj) { JavaObject* javaLoader = NULL; - const JavaString* jstr = NULL; - const JavaObjectVMThread* vmthObj = NULL; + const JavaString* threadNameObj = NULL; llvm_gcroot(javaLoader, 0); - llvm_gcroot(jstr, 0); - llvm_gcroot(vmthObj, 0); + llvm_gcroot(threadNameObj, 0); if (VMClassLoader::isVMClassLoader(&obj)) { JnjvmClassLoader* loader = ((const VMClassLoader&)obj).getClassLoader(); @@ -418,31 +416,24 @@ std::ostream& j3::operator << (std::ostr os << &obj << "(class=" << *ccl; if (ccl == vm->upcalls->newThread) { - jstr = static_cast( + threadNameObj = static_cast( vm->upcalls->threadName->getInstanceObjectField( const_cast(&obj))); - os << ",name=" << *jstr; + char *threadName = JavaString::strToAsciiz(threadNameObj); + os << ",name=\"" << threadName << '\"'; + delete [] threadName; } #ifndef OpenJDKPath else if (ccl == vm->upcalls->newVMThread) { - vmthObj = static_cast(&obj); - for (int retries = 10; (!vmthObj->vmdata) && (retries >= 0); --retries) + const JavaObjectVMThread& vmthObj = (const JavaObjectVMThread&)obj; + for (int retries = 10; (!vmthObj.vmdata) && (retries >= 0); --retries) usleep(100); - if (const JavaObject* thObj = vmthObj->vmdata->currentThread()) + if (const JavaObject* thObj = vmthObj.vmdata->currentThread()) os << ",thread=" << *thObj; } #endif - else if (ccl == vm->upcalls->newClass) { - ccl = JavaObjectClass::getClass( - const_cast( - static_cast(&obj))); - - os << ",name=\"" << *ccl->asClass() << '\"'; - } else if (ccl == vm->upcalls->newString) { - os << ',' << static_cast(obj); - } os << ')'; } @@ -459,22 +450,3 @@ void JavaObject::dumpClass() const { JavaObject::getClass(this)->dump(); } - -void JavaObject::dumpToString() const -{ - JavaString* jstr = NULL; - llvm_gcroot(jstr, 0); - - if (VMClassLoader::isVMClassLoader(this) || VMStaticInstance::isVMStaticInstance(this)) - {cerr << "" << endl; return;} - - Class* cl = JavaObject::getClass(this)->asClass(); - if (!cl) {cerr << "" << endl; return;} - - Jnjvm* vm = cl->classLoader->getJVM(); - jstr = static_cast( - vm->upcalls->toString->invokeJavaObjectVirtual( - vm, cl, const_cast(this))); - - cerr << *jstr << endl; -} Modified: vmkit/trunk/lib/j3/VMCore/JavaObject.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaObject.h?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaObject.h (original) +++ vmkit/trunk/lib/j3/VMCore/JavaObject.h Mon Nov 25 14:10:43 2013 @@ -334,7 +334,6 @@ public: void dumpClass() const __attribute__((noinline)); void dump() const __attribute__((noinline)); friend std::ostream& operator << (std::ostream&, const JavaObject&); - void dumpToString() const __attribute__((noinline)); }; Modified: vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JavaRuntimeJIT.cpp Mon Nov 25 14:10:43 2013 @@ -110,9 +110,10 @@ extern "C" void* j3StaticFieldLookup(Use } // Throws if the method is not found. -extern "C" void* j3VirtualTableLookup(UserClass* caller, uint32 index, - void** javaMethod, JavaObject* obj) { +extern "C" uint32 j3VirtualTableLookup(UserClass* caller, uint32 index, + uint32* offset, JavaObject* obj) { llvm_gcroot(obj, 0); + uint32 res = 0; UserCommonClass* cl = 0; const UTF8* utf8 = 0; @@ -133,13 +134,15 @@ extern "C" void* j3VirtualTableLookup(Us JavaObject::getClass(obj)->asClass(); dmeth = lookup->lookupMethod(utf8, sign->keyName, false, true, 0); } else { - *javaMethod = dmeth; + *offset = dmeth->offset; } assert(dmeth->classDef->isInitializing() && "Class not ready in a virtual lookup."); - return dmeth; + res = dmeth->offset; + + return res; } // Throws if the class is not found. Modified: vmkit/trunk/lib/j3/VMCore/JavaString.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaString.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaString.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JavaString.cpp Mon Nov 25 14:10:43 2013 @@ -120,28 +120,4 @@ const UTF8* JavaString::javaToInternal(c return res; } -std::ostream& operator << (std::ostream& os, const JavaString& jstr) -{ - char *str = JavaString::strToAsciiz(&jstr); - os << '\"' << str << '\"'; - delete [] str; - return os; -} - -const UTF8* JavaString::toUTF8(const JavaString* self, UTF8Map* hashMap) -{ - if (!self) return NULL; - if (!hashMap) { - Jnjvm* vm = JavaThread::get()->getJVM(); - hashMap = vm->bootstrapLoader->hashUTF8; - } - - const j3::ArrayUInt16 *array = j3::JavaString::getValue(self); - const j3::ArrayUInt16::ElementType *elts = - j3::ArrayUInt16::getElements(array); - size_t count = j3::ArrayUInt16::getSize(array); - - return hashMap->lookupOrCreateReader(elts, count); -} - } Modified: vmkit/trunk/lib/j3/VMCore/JavaString.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaString.h?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaString.h (original) +++ vmkit/trunk/lib/j3/VMCore/JavaString.h Mon Nov 25 14:10:43 2013 @@ -59,12 +59,9 @@ class JavaString : public JavaObject { static char* strToAsciiz(const JavaString* self); static char* strToAsciiz(const JavaString* self, vmkit::ThreadAllocator* allocator); static const ArrayUInt16* strToArray(JavaString* self, Jnjvm* vm); - static const UTF8* toUTF8(const JavaString* self, UTF8Map* hashMap); /// javaToInternal - Replaces all '/' into '.'. static const UTF8* javaToInternal(const JavaString* self, UTF8Map* map); - - friend std::ostream& operator << (std::ostream&, const JavaString&); }; } // end namespace j3 Modified: vmkit/trunk/lib/j3/VMCore/JavaThread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JavaThread.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JavaThread.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JavaThread.cpp Mon Nov 25 14:10:43 2013 @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include -#include #include "vmkit/Locks.h" #include "vmkit/Thread.h" @@ -133,7 +132,7 @@ void JavaThread::printJavaBacktrace() { while (vmkit::FrameInfo* FI = Walker.get()) { if (FI->Metadata != NULL) { - MyVM->printMethod(FI, Walker.returnAddress, Walker.callFrameAddress); + MyVM->printMethod(FI, Walker.ip, Walker.addr); } ++Walker; } Modified: vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/trunk/lib/j3/VMCore/JnjvmClassLoader.cpp Mon Nov 25 14:10:43 2013 @@ -44,6 +44,7 @@ #include "Reader.h" #include "Zip.h" + using namespace j3; using namespace std; Modified: vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp (original) +++ vmkit/trunk/lib/vmkit/CommonThread/CollectionRV.cpp Mon Nov 25 14:10:43 2013 @@ -103,7 +103,7 @@ void CooperativeCollectionRV::join() { th->inRV = true; lockRV(); - th->setLastSP(System::GetCallFrameAddress()); + th->setLastSP(System::GetCallerAddress()); th->joinedRV = true; another_mark(); waitEndOfRV(); Modified: vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp (original) +++ vmkit/trunk/lib/vmkit/CommonThread/ObjectLocks.cpp Mon Nov 25 14:10:43 2013 @@ -336,8 +336,8 @@ bool FatLock::acquire(gc* obj, LockSyste // if (lockingThreads == 0) // table.deallocate(this); - word_t methodIP = System::GetCallFrameAddress(); - methodIP = System::GetReturnAddressOfCallFrame(methodIP); + word_t methodIP = System::GetCallerAddress(); + methodIP = System::GetIPFromCallerAddress(methodIP); Thread::get()->throwNullPointerException(methodIP); } Modified: vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc (original) +++ vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x64.inc Mon Nov 25 14:10:43 2013 @@ -38,7 +38,7 @@ void Handler::UpdateRegistersForNPE() { void Handler::UpdateRegistersForStackOverflow() { word_t alt_stack = vmkit::Thread::get()->GetAlternativeStackStart(); - ((ucontext_t*)context)->uc_mcontext.gregs[REG_RDI] = System::GetReturnAddressOfCallFrame(((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP]); + ((ucontext_t*)context)->uc_mcontext.gregs[REG_RDI] = System::GetIPFromCallerAddress(((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP]); ((ucontext_t*)context)->uc_mcontext.gregs[REG_RSI] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_RBP]; ((ucontext_t*)context)->uc_mcontext.gregs[REG_RSP] = alt_stack; ((ucontext_t*)context)->uc_mcontext.gregs[REG_RIP] = (word_t)HandleStackOverflow; Modified: vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc (original) +++ vmkit/trunk/lib/vmkit/CommonThread/Sigsegv-linux-x86.inc Mon Nov 25 14:10:43 2013 @@ -40,7 +40,7 @@ void Handler::UpdateRegistersForNPE() { void Handler::UpdateRegistersForStackOverflow() { word_t alt_stack = vmkit::Thread::get()->GetAlternativeStackStart(); - ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBX] = System::GetReturnAddressOfCallFrame(((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP]); + ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBX] = System::GetIPFromCallerAddress(((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP]); ((ucontext_t*)context)->uc_mcontext.gregs[REG_EAX] = ((ucontext_t*)context)->uc_mcontext.gregs[REG_EBP]; ((ucontext_t*)context)->uc_mcontext.gregs[REG_ESP] = alt_stack; ((ucontext_t*)context)->uc_mcontext.gregs[REG_EIP] = (word_t)HandleStackOverflow; Modified: vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp (original) +++ vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp Mon Nov 25 14:10:43 2013 @@ -60,7 +60,7 @@ void Thread::joinRVAfterLeave(word_t sav void Thread::startKnownFrame(KnownFrame& F) { // Get the caller of this function - word_t cur = System::GetCallFrameAddress(); + word_t cur = System::GetCallerAddress(); F.previousFrame = lastKnownFrame; F.currentFP = cur; // This is used as a marker. @@ -75,12 +75,12 @@ void Thread::endKnownFrame() { void Thread::startUnknownFrame(KnownFrame& F) { // Get the caller of this function - word_t cur = System::GetCallFrameAddress(); + word_t cur = System::GetCallerAddress(); // Get the caller of the caller. - cur = System::GetCallerCallFrame(cur); + cur = System::GetCallerOfAddress(cur); F.previousFrame = lastKnownFrame; F.currentFP = cur; - F.currentIP = System::GetReturnAddressOfCallFrame(cur); + F.currentIP = System::GetIPFromCallerAddress(cur); lastKnownFrame = &F; } @@ -97,7 +97,7 @@ void Thread::printBacktrace() { StackWalker Walker(this); while (FrameInfo* FI = Walker.get()) { - MyVM->printMethod(FI, Walker.returnAddress, Walker.callFrameAddress); + MyVM->printMethod(FI, Walker.ip, Walker.addr); ++Walker; } } @@ -124,44 +124,42 @@ uint32_t Thread::getFrameContextLength() } FrameInfo* StackWalker::get() { - if (callFrameAddress == thread->baseSP) return 0; - returnAddress = System::GetReturnAddressOfCallFrame(callFrameAddress); - return thread->MyVM->IPToFrameInfo(returnAddress); + if (addr == thread->baseSP) return 0; + ip = System::GetIPFromCallerAddress(addr); + return thread->MyVM->IPToFrameInfo(ip); } word_t StackWalker::operator*() { - if (callFrameAddress == thread->baseSP) return 0; - returnAddress = System::GetReturnAddressOfCallFrame(callFrameAddress); - return returnAddress; + if (addr == thread->baseSP) return 0; + ip = System::GetIPFromCallerAddress(addr); + return ip; } void StackWalker::operator++() { - if (callFrameAddress != thread->baseSP) { - assert((callFrameAddress < thread->baseSP) && "Corrupted stack"); - assert((callFrameAddress < System::GetCallerCallFrame(callFrameAddress)) && "Corrupted stack"); - if ((frame != NULL) && (callFrameAddress == frame->currentFP)) { + if (addr != thread->baseSP) { + assert((addr < thread->baseSP) && "Corrupted stack"); + assert((addr < System::GetCallerOfAddress(addr)) && "Corrupted stack"); + if ((frame != NULL) && (addr == frame->currentFP)) { assert(frame->currentIP == 0); frame = frame->previousFrame; assert(frame != NULL); assert(frame->currentIP != 0); - callFrameAddress = frame->currentFP; + addr = frame->currentFP; frame = frame->previousFrame; } else { - callFrameAddress = System::GetCallerCallFrame(callFrameAddress); + addr = System::GetCallerOfAddress(addr); } } } -StackWalker::StackWalker(vmkit::Thread* th) : - returnAddress(0) -{ +StackWalker::StackWalker(vmkit::Thread* th) { thread = th; frame = th->lastKnownFrame; if (vmkit::Thread::get() == th) { - callFrameAddress = System::GetCallFrameAddress(); - callFrameAddress = System::GetCallerCallFrame(callFrameAddress); + addr = System::GetCallerAddress(); + addr = System::GetCallerOfAddress(addr); } else { - callFrameAddress = th->waitOnSP(); + addr = th->waitOnSP(); if (frame) { // if (frame->currentFP < addr) { // fprintf(stderr, "Error in thread with pointer %p because %x < %x\n", th, frame->currentFP, addr); @@ -169,9 +167,9 @@ StackWalker::StackWalker(vmkit::Thread* // } - assert(frame->currentFP >= callFrameAddress); + assert(frame->currentFP >= addr); } - if (frame && (callFrameAddress == frame->currentFP)) { + if (frame && (addr == frame->currentFP)) { frame = frame->previousFrame; // Let this be called from JNI, as in // OpenJDK's JVM_FillInStackTrace: @@ -180,23 +178,14 @@ StackWalker::StackWalker(vmkit::Thread* assert((frame == NULL) || (frame->currentIP == 0)); } } - assert(callFrameAddress && "No address to start with"); + assert(addr && "No address to start with"); } -StackWalker::StackWalker() : - returnAddress(0) -{ - thread = vmkit::Thread::get(); - frame = thread->lastKnownFrame; - callFrameAddress = System::GetCallFrameAddress(); - callFrameAddress = System::GetCallerCallFrame(callFrameAddress); - assert(callFrameAddress && "No address to start with"); -} void Thread::scanStack(word_t closure) { StackWalker Walker(this); while (FrameInfo* MI = Walker.get()) { - MethodInfoHelper::scan(closure, MI, Walker.returnAddress, Walker.callFrameAddress); + MethodInfoHelper::scan(closure, MI, Walker.ip, Walker.addr); ++Walker; } } @@ -206,11 +195,11 @@ void Thread::enterUncooperativeCode(uint if (!inRV) { assert(!lastSP && "SP already set when entering uncooperative code"); // Get the caller. - word_t temp = System::GetCallFrameAddress(); + word_t temp = System::GetCallerAddress(); // Make sure to at least get the caller of the caller. ++level; while (level--) - temp = System::GetCallerCallFrame(temp); + temp = System::GetCallerOfAddress(temp); // The cas is not necessary, but it does a memory barrier. __sync_bool_compare_and_swap(&lastSP, 0, temp); if (doYield) joinRVBeforeEnter(); @@ -348,11 +337,7 @@ extern void sigsTermHandler(int n, sigin /// given routine of th. /// void Thread::internalThreadStart(vmkit::Thread* th) { - th->baseSP = System::GetCallFrameAddress(); - -#if JAVA_INTERFACE_CALL_STACK - th->stackEmbeddedListHead[j3::StackEmbeddedListIntendedCaller] = NULL; -#endif + th->baseSP = System::GetCallerAddress(); // Set the alternate stack as the second page of the thread's // stack. Modified: vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp (original) +++ vmkit/trunk/lib/vmkit/Runtime/MethodInfo.cpp Mon Nov 25 14:10:43 2013 @@ -21,7 +21,7 @@ namespace vmkit { void MethodInfoHelper::scan(word_t closure, FrameInfo* FI, word_t ip, word_t addr) { //word_t spaddr = (word_t)addr + FI->FrameSize + sizeof(void*); - word_t spaddr = System::GetCallerCallFrame(addr); + word_t spaddr = System::GetCallerOfAddress(addr); for (uint16 i = 0; i < FI->NumLiveOffsets; ++i) { word_t obj = *(word_t*)(spaddr + FI->LiveOffsets[i]); // Verify that obj does not come from a JSR bytecode. Modified: vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp?rev=195678&r1=195677&r2=195678&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp (original) +++ vmkit/trunk/lib/vmkit/Runtime/UTF8.cpp Mon Nov 25 14:10:43 2013 @@ -41,6 +41,17 @@ uint32 UTF8::readerHasher(const uint16* return (r1 & 255) + ((r0 & 255) << 8); } +int UTF8::compare(const char *s) const +{ + int len = strlen(s); + int diff = size - len; + if (diff != 0) return diff; + + for (int i = 0; (i < size) && (diff == 0); ++i) + diff = (char)(elements[i]) - s[i]; + return diff; +} + std::string& UTF8::toString(std::string& buffer) const { buffer.resize(size); @@ -53,7 +64,7 @@ std::string& UTF8::toString(std::string& std::ostream& operator << (std::ostream& os, const UTF8& utf8) { - for (ssize_t i = 0; (i < utf8.size) && (utf8.elements[i] != 0); ++i) + for (ssize_t i = 0; i < utf8.size; ++i) os << (std::string::value_type)(utf8.elements[i]); return os; } From gael.thomas at lip6.fr Mon Nov 25 12:15:18 2013 From: gael.thomas at lip6.fr (Gael Thomas) Date: Mon, 25 Nov 2013 20:15:18 -0000 Subject: [vmkit-commits] [vmkit] r195680 - remove the stack check, does not work for me Message-ID: <20131125201519.019D92A6C029@llvm.org> Author: gthomas Date: Mon Nov 25 14:15:18 2013 New Revision: 195680 URL: http://llvm.org/viewvc/llvm-project?rev=195680&view=rev Log: remove the stack check, does not work for me Modified: vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp Modified: vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp?rev=195680&r1=195679&r2=195680&view=diff ============================================================================== --- vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp (original) +++ vmkit/trunk/lib/vmkit/CommonThread/ctthread.cpp Mon Nov 25 14:15:18 2013 @@ -137,8 +137,8 @@ word_t StackWalker::operator*() { void StackWalker::operator++() { if (addr != thread->baseSP) { - assert((addr < thread->baseSP) && "Corrupted stack"); - assert((addr < System::GetCallerOfAddress(addr)) && "Corrupted stack"); + //assert((addr < thread->baseSP) && "Corrupted stack"); + //assert((addr < System::GetCallerOfAddress(addr)) && "Corrupted stack"); if ((frame != NULL) && (addr == frame->currentFP)) { assert(frame->currentIP == 0); frame = frame->previousFrame; From gael.thomas at lip6.fr Mon Nov 25 14:48:00 2013 From: gael.thomas at lip6.fr (Gael Thomas) Date: Mon, 25 Nov 2013 22:48:00 -0000 Subject: [vmkit-commits] [vmkit] r195694 - remove the llvm symbols cache of classes and methods because it will become useless with mcjit Message-ID: <20131125224800.71BB12A6C029@llvm.org> Author: gthomas Date: Mon Nov 25 16:48:00 2013 New Revision: 195694 URL: http://llvm.org/viewvc/llvm-project?rev=195694&view=rev Log: remove the llvm symbols cache of classes and methods because it will become useless with mcjit Modified: vmkit/branches/mcjit/include/j3/j3class.h vmkit/branches/mcjit/include/j3/j3classloader.h vmkit/branches/mcjit/include/j3/j3method.h vmkit/branches/mcjit/lib/j3/vm/j3class.cc vmkit/branches/mcjit/lib/j3/vm/j3method.cc Modified: vmkit/branches/mcjit/include/j3/j3class.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3class.h?rev=195694&r1=195693&r2=195694&view=diff ============================================================================== --- vmkit/branches/mcjit/include/j3/j3class.h (original) +++ vmkit/branches/mcjit/include/j3/j3class.h Mon Nov 25 16:48:00 2013 @@ -198,7 +198,6 @@ namespace j3 { J3Attributes* _attributes; - llvm::GlobalValue* _nomcjitDescriptor; J3ClassBytes* _bytes; size_t nbCtp; uint8_t* ctpTypes; @@ -265,7 +264,6 @@ namespace j3 { class J3ArrayClass : public J3ObjectType { llvm::Type* _llvmType; J3Type* _component; - llvm::GlobalValue* _nomcjitDescriptor; void doResolve(J3Field* hiddenFields, size_t nbHiddenFields); void doInitialise(); Modified: vmkit/branches/mcjit/include/j3/j3classloader.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3classloader.h?rev=195694&r1=195693&r2=195694&view=diff ============================================================================== --- vmkit/branches/mcjit/include/j3/j3classloader.h (original) +++ vmkit/branches/mcjit/include/j3/j3classloader.h Mon Nov 25 16:48:00 2013 @@ -10,7 +10,6 @@ #include "j3/j3object.h" namespace llvm { - class ExecutionEngine; class DataLayout; class Type; class Function; Modified: vmkit/branches/mcjit/include/j3/j3method.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3method.h?rev=195694&r1=195693&r2=195694&view=diff ============================================================================== --- vmkit/branches/mcjit/include/j3/j3method.h (original) +++ vmkit/branches/mcjit/include/j3/j3method.h Mon Nov 25 16:48:00 2013 @@ -65,8 +65,6 @@ namespace j3 { J3MethodType* _methodType; J3Attributes* _attributes; uint32_t _index; - llvm::Function* _nomcjitFunction; - llvm::GlobalValue* _nomcjitDescriptor; llvm::Function* _compiledFunction; char* volatile _llvmAllNames; /* md_ + llvm Name */ size_t _llvmAllNamesLength; Modified: vmkit/branches/mcjit/lib/j3/vm/j3class.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3class.cc?rev=195694&r1=195693&r2=195694&view=diff ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original) +++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Mon Nov 25 16:48:00 2013 @@ -198,11 +198,9 @@ size_t J3Class::size() { } llvm::GlobalValue* J3Class::llvmDescriptor(llvm::Module* module) { - if(!_nomcjitDescriptor) { - _nomcjitDescriptor = llvm::cast(module->getOrInsertGlobal(nativeName(), loader()->vm()->typeJ3Class)); - loader()->vm()->ee()->addGlobalMapping(_nomcjitDescriptor, this); - } - return _nomcjitDescriptor; + llvm::GlobalValue* res = llvm::cast(module->getOrInsertGlobal(nativeName(), loader()->vm()->typeJ3Class)); + loader()->vm()->ee()->updateGlobalMapping(res, this); + return res; } @@ -836,11 +834,9 @@ void J3ArrayClass::doInitialise() { } llvm::GlobalValue* J3ArrayClass::llvmDescriptor(llvm::Module* module) { - if(!_nomcjitDescriptor) { - _nomcjitDescriptor = llvm::cast(module->getOrInsertGlobal(nativeName(), loader()->vm()->typeJ3ArrayClass)); - loader()->vm()->ee()->updateGlobalMapping(_nomcjitDescriptor, this); - } - return _nomcjitDescriptor; + llvm::GlobalValue* res = llvm::cast(module->getOrInsertGlobal(nativeName(), loader()->vm()->typeJ3ArrayClass)); + loader()->vm()->ee()->updateGlobalMapping(res, this); + return res; } llvm::Type* J3ArrayClass::llvmType() { Modified: vmkit/branches/mcjit/lib/j3/vm/j3method.cc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3method.cc?rev=195694&r1=195693&r2=195694&view=diff ============================================================================== --- vmkit/branches/mcjit/lib/j3/vm/j3method.cc (original) +++ vmkit/branches/mcjit/lib/j3/vm/j3method.cc Mon Nov 25 16:48:00 2013 @@ -346,32 +346,26 @@ char* J3Method::llvmDescriptorName(J3Cla } llvm::GlobalValue* J3Method::llvmDescriptor(llvm::Module* module) { - if(!_nomcjitDescriptor) { - J3ClassLoader* loader = cl()->loader(); - _nomcjitDescriptor = llvm::cast(module->getOrInsertGlobal(llvmDescriptorName(), loader->vm()->typeJ3Method)); - loader->vm()->ee()->addGlobalMapping(_nomcjitDescriptor, this); - } - - return _nomcjitDescriptor; + J3ClassLoader* loader = cl()->loader(); + llvm::GlobalValue* res = llvm::cast(module->getOrInsertGlobal(llvmDescriptorName(), loader->vm()->typeJ3Method)); + loader->vm()->ee()->updateGlobalMapping(res, this); + return res; } llvm::Function* J3Method::llvmFunction(bool isStub, llvm::Module* module, J3Class* from) { - if(!_nomcjitFunction) { - llvm::Function* res; + llvm::Function* res; + + if(isStub && !_compiledFunction) { + char id[llvmFunctionNameLength() + 16]; + memcpy(id, llvmFunctionName(), llvmFunctionNameLength()); + memcpy(id + llvmFunctionNameLength(), "_stub", 6); + res = (llvm::Function*)module->getOrInsertFunction(id, methodType(from ? from : cl())->llvmType()); + } else + res = (llvm::Function*)module->getOrInsertFunction(llvmFunctionName(from), methodType(from ? from : cl())->llvmType()); - if(isStub && !_compiledFunction) { - char id[llvmFunctionNameLength() + 16]; - memcpy(id, llvmFunctionName(), llvmFunctionNameLength()); - memcpy(id + llvmFunctionNameLength(), "_stub", 6); - res = (llvm::Function*)module->getOrInsertFunction(id, methodType(from ? from : cl())->llvmType()); - } else - res = (llvm::Function*)module->getOrInsertFunction(llvmFunctionName(from), methodType(from ? from : cl())->llvmType()); - - _nomcjitFunction = res; - cl()->loader()->vm()->ee()->addGlobalMapping(_nomcjitFunction, functionPointerOrTrampoline()); - } + cl()->loader()->vm()->ee()->updateGlobalMapping(res, functionPointerOrTrampoline()); - return _nomcjitFunction; + return res; } void J3Method::dump() {