From nicolas.geoffray at lip6.fr Tue Sep 7 12:48:53 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 07 Sep 2010 19:48:53 -0000 Subject: [vmkit-commits] [vmkit] r113254 - in /vmkit/branches/precise: include/j3/ lib/J3/Classpath/ lib/J3/Compiler/ lib/J3/VMCore/ mmtk/mmtk-j3/ Message-ID: <20100907194853.D0B542A6C12D@llvm.org> Author: geoffray Date: Tue Sep 7 14:48:53 2010 New Revision: 113254 URL: http://llvm.org/viewvc/llvm-project?rev=113254&view=rev Log: Create a stub method in between a Java native and a J3 implementation. This way we don't need to hack the MethodInfos. Modified: vmkit/branches/precise/include/j3/JavaAOTCompiler.h vmkit/branches/precise/include/j3/JavaCompiler.h vmkit/branches/precise/include/j3/JavaJITCompiler.h vmkit/branches/precise/include/j3/JavaLLVMCompiler.h vmkit/branches/precise/lib/J3/Classpath/ClasspathVMClassLoader.inc vmkit/branches/precise/lib/J3/Classpath/ClasspathVMSystemProperties.inc vmkit/branches/precise/lib/J3/Classpath/JavaUpcalls.cpp vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp vmkit/branches/precise/lib/J3/VMCore/JavaClass.h vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp vmkit/branches/precise/mmtk/mmtk-j3/Assert.cpp vmkit/branches/precise/mmtk/mmtk-j3/Lock.cpp vmkit/branches/precise/mmtk/mmtk-j3/SynchronizedCounter.cpp Modified: vmkit/branches/precise/include/j3/JavaAOTCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/j3/JavaAOTCompiler.h?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/include/j3/JavaAOTCompiler.h (original) +++ vmkit/branches/precise/include/j3/JavaAOTCompiler.h Tue Sep 7 14:48:53 2010 @@ -67,7 +67,7 @@ virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp); virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr); - virtual void setMethod(JavaMethod* meth, void* ptr, const char* name); + virtual void setMethod(llvm::Function* func, void* ptr, const char* name); #ifdef SERVICE Modified: vmkit/branches/precise/include/j3/JavaCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/j3/JavaCompiler.h?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/include/j3/JavaCompiler.h (original) +++ vmkit/branches/precise/include/j3/JavaCompiler.h Tue Sep 7 14:48:53 2010 @@ -46,9 +46,6 @@ return 0; } - virtual void setMethod(JavaMethod* meth, void* ptr, const char* name) { - } - virtual bool isStaticCompiling() { return false; } Modified: vmkit/branches/precise/include/j3/JavaJITCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/j3/JavaJITCompiler.h?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/include/j3/JavaJITCompiler.h (original) +++ vmkit/branches/precise/include/j3/JavaJITCompiler.h Tue Sep 7 14:48:53 2010 @@ -72,7 +72,7 @@ virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp); virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr); - virtual void setMethod(JavaMethod* meth, void* ptr, const char* name); + virtual void setMethod(llvm::Function* func, void* ptr, const char* name); #ifdef SERVICE Modified: vmkit/branches/precise/include/j3/JavaLLVMCompiler.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/j3/JavaLLVMCompiler.h?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/include/j3/JavaLLVMCompiler.h (original) +++ vmkit/branches/precise/include/j3/JavaLLVMCompiler.h Tue Sep 7 14:48:53 2010 @@ -195,7 +195,7 @@ virtual llvm::Constant* getConstantPool(JavaConstantPool* ctp) = 0; virtual llvm::Constant* getNativeFunction(JavaMethod* meth, void* natPtr) = 0; - virtual void setMethod(JavaMethod* meth, void* ptr, const char* name) = 0; + virtual void setMethod(llvm::Function* func, void* ptr, const char* name) = 0; #ifdef SERVICE virtual llvm::Value* getIsolate(Jnjvm* vm, llvm::Value* Where) = 0; Modified: vmkit/branches/precise/lib/J3/Classpath/ClasspathVMClassLoader.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Classpath/ClasspathVMClassLoader.inc?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Classpath/ClasspathVMClassLoader.inc (original) +++ vmkit/branches/precise/lib/J3/Classpath/ClasspathVMClassLoader.inc Tue Sep 7 14:48:53 2010 @@ -351,7 +351,7 @@ "org.xml.sax.helpers" }; -extern "C" ArrayObject* nativeGetBootPackages() { +extern "C" ArrayObject* Java_java_lang_VMClassLoader_getBootPackages__() { ArrayObject* obj = 0; llvm_gcroot(obj, 0); Modified: vmkit/branches/precise/lib/J3/Classpath/ClasspathVMSystemProperties.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Classpath/ClasspathVMSystemProperties.inc?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Classpath/ClasspathVMSystemProperties.inc (original) +++ vmkit/branches/precise/lib/J3/Classpath/ClasspathVMSystemProperties.inc Tue Sep 7 14:48:53 2010 @@ -136,7 +136,7 @@ END_NATIVE_EXCEPTION } -extern "C" void nativePropertiesPostInit(JavaObject* prop) { +extern "C" void Java_gnu_classpath_VMSystemProperties_postInit__Ljava_util_Properties_2(JavaObject* prop) { llvm_gcroot(prop, 0); Modified: vmkit/branches/precise/lib/J3/Classpath/JavaUpcalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Classpath/JavaUpcalls.cpp?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Classpath/JavaUpcalls.cpp (original) +++ vmkit/branches/precise/lib/J3/Classpath/JavaUpcalls.cpp Tue Sep 7 14:48:53 2010 @@ -296,9 +296,8 @@ CreateJavaThread(vm, vm->getEnqueueThread(), "Reference", SystemGroup); } -extern "C" void nativeInitWeakReference(JavaObjectReference* reference, - JavaObject* referent) { - +extern "C" void Java_java_lang_ref_WeakReference__0003Cinit_0003E__Ljava_lang_Object_2( + JavaObjectReference* reference, JavaObject* referent) { llvm_gcroot(reference, 0); llvm_gcroot(referent, 0); @@ -311,9 +310,10 @@ } -extern "C" void nativeInitWeakReferenceQ(JavaObjectReference* reference, - JavaObject* referent, - JavaObject* queue) { +extern "C" void Java_java_lang_ref_WeakReference__0003Cinit_0003E__Ljava_lang_Object_2Ljava_lang_ref_ReferenceQueue_2( + JavaObjectReference* reference, + JavaObject* referent, + JavaObject* queue) { llvm_gcroot(reference, 0); llvm_gcroot(referent, 0); llvm_gcroot(queue, 0); @@ -327,8 +327,8 @@ } -extern "C" void nativeInitSoftReference(JavaObjectReference* reference, - JavaObject* referent) { +extern "C" void Java_java_lang_ref_SoftReference__0003Cinit_0003E__Ljava_lang_Object_2( + JavaObjectReference* reference, JavaObject* referent) { llvm_gcroot(reference, 0); llvm_gcroot(referent, 0); @@ -341,9 +341,10 @@ } -extern "C" void nativeInitSoftReferenceQ(JavaObjectReference* reference, - JavaObject* referent, - JavaObject* queue) { +extern "C" void Java_java_lang_ref_SoftReference__0003Cinit_0003E__Ljava_lang_Object_2Ljava_lang_ref_ReferenceQueue_2( + JavaObjectReference* reference, + JavaObject* referent, + JavaObject* queue) { llvm_gcroot(reference, 0); llvm_gcroot(referent, 0); llvm_gcroot(queue, 0); @@ -357,9 +358,10 @@ } -extern "C" void nativeInitPhantomReferenceQ(JavaObjectReference* reference, - JavaObject* referent, - JavaObject* queue) { +extern "C" void Java_java_lang_ref_PhantomReference__0003Cinit_0003E__Ljava_lang_Object_2Ljava_lang_ref_ReferenceQueue_2( + JavaObjectReference* reference, + JavaObject* referent, + JavaObject* queue) { llvm_gcroot(reference, 0); llvm_gcroot(referent, 0); llvm_gcroot(queue, 0); @@ -372,7 +374,8 @@ END_NATIVE_EXCEPTION } -extern "C" JavaString* nativeInternString(JavaString* obj) { +extern "C" JavaString* Java_java_lang_VMString_intern__Ljava_lang_String_2( + JavaString* obj) { const ArrayUInt16* array = 0; JavaString* res = 0; llvm_gcroot(obj, 0); @@ -392,7 +395,7 @@ return res; } -extern "C" uint8 nativeIsArray(JavaObjectClass* klass) { +extern "C" uint8 Java_java_lang_Class_isArray__(JavaObjectClass* klass) { llvm_gcroot(klass, 0); UserCommonClass* cl = 0; @@ -405,7 +408,7 @@ return (uint8)cl->isArray(); } -extern "C" JavaObject* nativeGetCallingClass() { +extern "C" JavaObject* Java_gnu_classpath_VMStackWalker_getCallingClass__() { JavaObject* res = 0; llvm_gcroot(res, 0); @@ -421,7 +424,7 @@ return res; } -extern "C" JavaObject* nativeGetCallingClassLoader() { +extern "C" JavaObject* Java_gnu_classpath_VMStackWalker_getCallingClassLoader__() { JavaObject* res = 0; llvm_gcroot(res, 0); @@ -437,7 +440,7 @@ return res; } -extern "C" JavaObject* nativeFirstNonNullClassLoader() { +extern "C" JavaObject* Java_gnu_classpath_VMStackWalker_firstNonNullClassLoader__() { JavaObject* res = 0; llvm_gcroot(res, 0); @@ -451,7 +454,7 @@ return res; } -extern "C" JavaObject* nativeGetCallerClass(uint32 index) { +extern "C" JavaObject* Java_sun_reflect_Reflection_getCallerClass__I(uint32 index) { JavaObject* res = 0; llvm_gcroot(res, 0); @@ -468,12 +471,13 @@ return res; } -extern "C" JavaObject* nativeGetAnnotation(JavaObject* obj) { +extern "C" JavaObject* Java_java_lang_reflect_AccessibleObject_getAnnotation__Ljava_lang_Class_2( + JavaObject* obj) { llvm_gcroot(obj, 0); return 0; } -extern "C" JavaObject* nativeGetDeclaredAnnotations() { +extern "C" JavaObject* Java_java_lang_reflect_AccessibleObject_getDeclaredAnnotations__() { JavaObject* res = 0; llvm_gcroot(res, 0); @@ -488,8 +492,6 @@ return res; } -extern "C" void nativePropertiesPostInit(JavaObject* prop); - extern "C" void nativeJavaObjectClassTracer( JavaObjectClass* obj, uintptr_t closure) { JavaObjectClass::staticTracer(obj, closure); @@ -520,10 +522,7 @@ JavaObjectVMThread::staticDestructor(obj); } -// Defined in Classpath/ClasspathVMClassLoader.cpp -extern "C" ArrayObject* nativeGetBootPackages(); - -extern "C" JavaString* nativeGetenv(JavaString* str) { +extern "C" JavaString* Java_java_lang_VMSystem_getenv__Ljava_lang_String_2(JavaString* str) { JavaString* ret = 0; llvm_gcroot(str, 0); llvm_gcroot(ret, 0); @@ -748,12 +747,11 @@ JavaMethod* internString = UPCALL_METHOD(loader, "java/lang/VMString", "intern", "(Ljava/lang/String;)Ljava/lang/String;", ACC_STATIC); - internString->setCompiledPtr((void*)(intptr_t)nativeInternString, - "nativeInternString"); + internString->setNative(); JavaMethod* isArray = UPCALL_METHOD(loader, "java/lang/Class", "isArray", "()Z", ACC_VIRTUAL); - isArray->setCompiledPtr((void*)(intptr_t)nativeIsArray, "nativeIsArray"); + isArray->setNative(); UPCALL_REFLECT_CLASS_EXCEPTION(loader, InvocationTargetException); @@ -944,61 +942,51 @@ JavaMethod* getEnv = UPCALL_METHOD(loader, "java/lang/VMSystem", "getenv", "(Ljava/lang/String;)Ljava/lang/String;", ACC_STATIC); - getEnv->setCompiledPtr((void*)(intptr_t)nativeGetenv, "nativeGetenv"); + getEnv->setNative(); JavaMethod* getCallingClass = UPCALL_METHOD(loader, "gnu/classpath/VMStackWalker", "getCallingClass", "()Ljava/lang/Class;", ACC_STATIC); - getCallingClass->setCompiledPtr((void*)(intptr_t)nativeGetCallingClass, - "nativeGetCallingClass"); + getCallingClass->setNative(); JavaMethod* getCallingClassLoader = UPCALL_METHOD(loader, "gnu/classpath/VMStackWalker", "getCallingClassLoader", "()Ljava/lang/ClassLoader;", ACC_STATIC); - getCallingClassLoader->setCompiledPtr((void*)(intptr_t) - nativeGetCallingClassLoader, - "nativeGetCallingClassLoader"); + getCallingClassLoader->setNative(); JavaMethod* firstNonNullClassLoader = UPCALL_METHOD(loader, "gnu/classpath/VMStackWalker", "firstNonNullClassLoader", "()Ljava/lang/ClassLoader;", ACC_STATIC); - firstNonNullClassLoader->setCompiledPtr((void*)(intptr_t) - nativeFirstNonNullClassLoader, - "nativeFirstNonNullClassLoader"); + firstNonNullClassLoader->setNative(); JavaMethod* getCallerClass = UPCALL_METHOD(loader, "sun/reflect/Reflection", "getCallerClass", "(I)Ljava/lang/Class;", ACC_STATIC); - getCallerClass->setCompiledPtr((void*)(intptr_t)nativeGetCallerClass, - "nativeGetCallerClass"); + getCallerClass->setNative(); JavaMethod* postProperties = UPCALL_METHOD(loader, "gnu/classpath/VMSystemProperties", "postInit", "(Ljava/util/Properties;)V", ACC_STATIC); - postProperties->setCompiledPtr((void*)(intptr_t)nativePropertiesPostInit, - "nativePropertiesPostInit"); + postProperties->setNative(); // Also implement these twos, implementation in GNU Classpath 0.97.2 is buggy. JavaMethod* getAnnotation = UPCALL_METHOD(loader, "java/lang/reflect/AccessibleObject", "getAnnotation", "(Ljava/lang/Class;)Ljava/lang/annotation/Annotation;", ACC_VIRTUAL); - getAnnotation->setCompiledPtr((void*)(intptr_t)nativeGetAnnotation, - "nativeGetAnnotation"); + getAnnotation->setNative(); JavaMethod* getAnnotations = UPCALL_METHOD(loader, "java/lang/reflect/AccessibleObject", "getDeclaredAnnotations", "()[Ljava/lang/annotation/Annotation;", ACC_VIRTUAL); - getAnnotations->setCompiledPtr((void*)(intptr_t)nativeGetDeclaredAnnotations, - "nativeGetDeclaredAnnotations"); + getAnnotations->setNative(); JavaMethod* getBootPackages = UPCALL_METHOD(loader, "java/lang/VMClassLoader", "getBootPackages", "()[Ljava/lang/String;", ACC_STATIC); - getBootPackages->setCompiledPtr((void*)(intptr_t)nativeGetBootPackages, - "nativeGetBootPackages"); + getBootPackages->setNative(); //===----------------------------------------------------------------------===// // @@ -1044,39 +1032,31 @@ UPCALL_METHOD(loader, "java/lang/ref/WeakReference", "", "(Ljava/lang/Object;)V", ACC_VIRTUAL); - initWeakReference->setCompiledPtr((void*)(intptr_t)nativeInitWeakReference, - "nativeInitWeakReference"); + initWeakReference->setNative(); initWeakReference = UPCALL_METHOD(loader, "java/lang/ref/WeakReference", "", "(Ljava/lang/Object;Ljava/lang/ref/ReferenceQueue;)V", ACC_VIRTUAL); - initWeakReference->setCompiledPtr((void*)(intptr_t)nativeInitWeakReferenceQ, - "nativeInitWeakReferenceQ"); + initWeakReference->setNative(); JavaMethod* initSoftReference = UPCALL_METHOD(loader, "java/lang/ref/SoftReference", "", "(Ljava/lang/Object;)V", ACC_VIRTUAL); - initSoftReference->setCompiledPtr((void*)(intptr_t)nativeInitSoftReference, - "nativeInitSoftReference"); + initSoftReference->setNative(); initSoftReference = - UPCALL_METHOD(loader, "java/lang/ref/WeakReference", "", + UPCALL_METHOD(loader, "java/lang/ref/SoftReference", "", "(Ljava/lang/Object;Ljava/lang/ref/ReferenceQueue;)V", ACC_VIRTUAL); - initSoftReference->setCompiledPtr((void*)(intptr_t)nativeInitSoftReferenceQ, - "nativeInitSoftReferenceQ"); + initSoftReference->setNative(); JavaMethod* initPhantomReference = UPCALL_METHOD(loader, "java/lang/ref/PhantomReference", "", "(Ljava/lang/Object;Ljava/lang/ref/ReferenceQueue;)V", ACC_VIRTUAL); - initPhantomReference->setCompiledPtr( - (void*)(intptr_t)nativeInitPhantomReferenceQ, - "nativeInitPhantomReferenceQ"); - - + initPhantomReference->setNative(); } gc** Jnjvm::getReferentPtr(gc* _obj) { Modified: vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp Tue Sep 7 14:48:53 2010 @@ -1849,8 +1849,7 @@ void JavaAOTCompiler::makeIMT(Class* cl) { } -void JavaAOTCompiler::setMethod(JavaMethod* meth, void* ptr, const char* name) { - Function* func = getMethodInfo(meth)->getMethod(); +void JavaAOTCompiler::setMethod(Function* func, void* ptr, const char* name) { func->setName(name); func->setLinkage(GlobalValue::ExternalLinkage); } Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp Tue Sep 7 14:48:53 2010 @@ -295,8 +295,9 @@ sint32 mnlen = jniConsName->size; sint32 mtlen = jniConsType->size; - char* functionName = (char*)alloca(3 + JNI_NAME_PRE_LEN + - ((mnlen + clen + mtlen) << 3)); + mvm::ThreadAllocator allocator; + char* functionName = (char*)allocator.Allocate( + 3 + JNI_NAME_PRE_LEN + ((mnlen + clen + mtlen) << 3)); if (!natPtr) natPtr = compilingClass->classLoader->nativeLookup(compilingMethod, j3, @@ -305,10 +306,11 @@ if (!natPtr && !TheCompiler->isStaticCompiling()) { currentBlock = createBasicBlock("start"); CallInst::Create(intrinsics->ThrowExceptionFromJITFunction, "", currentBlock); - if (returnType != Type::getVoidTy(*llvmContext)) + if (returnType != Type::getVoidTy(*llvmContext)) { ReturnInst::Create(*llvmContext, Constant::getNullValue(returnType), currentBlock); - else + } else { ReturnInst::Create(*llvmContext, currentBlock); + } PRINT_DEBUG(JNJVM_COMPILE, 1, COLOR_NORMAL, "end native compile %s.%s\n", UTF8Buffer(compilingClass->name).cString(), @@ -320,8 +322,25 @@ Function* func = llvmFunction; if (j3) { - compilingMethod->setCompiledPtr((void*)natPtr, functionName); - llvmFunction->clearGC(); + Function* callee = Function::Create(llvmFunction->getFunctionType(), + GlobalValue::ExternalLinkage, + functionName, + llvmFunction->getParent()); + TheCompiler->setMethod(callee, (void*)natPtr, functionName); + currentBlock = createBasicBlock("start"); + std::vector args; + for (Function::arg_iterator i = func->arg_begin(), e = func->arg_end(); + i != e; + i++) { + args.push_back(i); + } + Value* res = CallInst::Create( + callee, args.begin(), args.end(), "", currentBlock); + if (returnType != Type::getVoidTy(*llvmContext)) { + ReturnInst::Create(*llvmContext, res, currentBlock); + } else { + ReturnInst::Create(*llvmContext, currentBlock); + } return llvmFunction; } Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp Tue Sep 7 14:48:53 2010 @@ -386,12 +386,11 @@ } } -void JavaJITCompiler::setMethod(JavaMethod* meth, void* ptr, const char* name) { - Function* func = getMethodInfo(meth)->getMethod(); +void JavaJITCompiler::setMethod(Function* func, void* ptr, const char* name) { + func->setLinkage(GlobalValue::ExternalLinkage); func->setName(name); assert(ptr && "No value given"); executionEngine->updateGlobalMapping(func, ptr); - func->setLinkage(GlobalValue::ExternalLinkage); } void* JavaJITCompiler::materializeFunction(JavaMethod* meth) { Modified: vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp Tue Sep 7 14:48:53 2010 @@ -157,10 +157,8 @@ JCL->nativeLookup(methodDef, j3, buf); } - if (!j3) { - methodDef->jniConsFromMethOverloaded(buf + 1); - memcpy(buf, "JnJVM", 5); - } + methodDef->jniConsFromMethOverloaded(buf + 1); + memcpy(buf, "JnJVM", 5); methodFunction = Function::Create(getFunctionType(), GlobalValue::ExternalWeakLinkage, buf, @@ -177,7 +175,7 @@ Compiler->functions.insert(std::make_pair(methodFunction, methodDef)); if (Compiler != JCL->getCompiler() && methodDef->code) { - Compiler->setMethod(methodDef, methodDef->code, methodFunction->getName().data()); + Compiler->setMethod(methodFunction, methodDef->code, methodFunction->getName().data()); } } return methodFunction; Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp (original) +++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp Tue Sep 7 14:48:53 2010 @@ -298,20 +298,8 @@ fprintf(stderr, "\n"); } -void JavaMethod::setCompiledPtr(void* ptr, const char* name) { - classDef->acquire(); - if (code == 0) { - code = ptr; - Jnjvm* vm = JavaThread::get()->getJVM(); - mvm::MethodInfo* MI = vm->SharedStaticFunctions.CodeStartToMethodInfo(ptr); - JavaStaticMethodInfo* JMI = - new (classDef->classLoader->allocator, "JavaStaticMethodInfo") - JavaStaticMethodInfo((mvm::CamlMethodInfo*)MI, code, this); - vm->StaticFunctions.addMethodInfo(JMI, code); - classDef->classLoader->getCompiler()->setMethod(this, ptr, name); - } +void JavaMethod::setNative() { access |= ACC_NATIVE; - classDef->release(); } void JavaVirtualTable::setNativeTracer(uintptr_t ptr, const char* name) { @@ -1216,19 +1204,35 @@ for (sint32 i =0; i < mnlen; ++i) { cur = jniConsName->elements[i]; - if (cur == '/') ptr[0] = '_'; - else if (cur == '_') { + if (cur == '/') { + ptr[0] = '_'; + ++ptr; + } else if (cur == '_') { ptr[0] = '_'; ptr[1] = '1'; + ptr += 2; + } else if (cur == '<') { + ptr[0] = '_'; + ptr[1] = '0'; + ptr[2] = '0'; + ptr[3] = '0'; + ptr[4] = '3'; + ptr[5] = 'C'; + ptr += 6; + } else if (cur == '>') { + ptr[0] = '_'; + ptr[1] = '0'; + ptr[2] = '0'; + ptr[3] = '0'; + ptr[4] = '3'; + ptr[5] = 'E'; + ptr += 6; + } else { + ptr[0] = (uint8)cur; ++ptr; } - else ptr[0] = (uint8)cur; - ++ptr; - } - + } ptr[0] = 0; - - } void JavaMethod::jniConsFromMethOverloaded(char* buf, const UTF8* jniConsClName, Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.h?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.h Tue Sep 7 14:48:53 2010 @@ -949,9 +949,9 @@ /// void* compiledPtr(); - /// setCompiledPtr - Set the pointer function to the method. + /// setNative - Set the method as native. /// - void setCompiledPtr(void*, const char*); + void setNative(); /// JavaMethod - Delete the method as well as the cache enveloppes and /// attributes of the method. Modified: vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp Tue Sep 7 14:48:53 2010 @@ -1062,7 +1062,6 @@ } void JnjvmClassLoader::insertAllMethodsInVM(Jnjvm* vm) { - JavaCompiler* M = getCompiler(); for (ClassMap::iterator i = classes->map.begin(), e = classes->map.end(); i != e; ++i) { CommonClass* cl = i->second; @@ -1075,7 +1074,6 @@ JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo") JavaStaticMethodInfo(0, meth.code, &meth); vm->StaticFunctions.addMethodInfo(MI, meth.code); - M->setMethod(&meth, meth.code, ""); } } @@ -1085,7 +1083,6 @@ JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo") JavaStaticMethodInfo(0, meth.code, &meth); vm->StaticFunctions.addMethodInfo(MI, meth.code); - M->setMethod(&meth, meth.code, ""); } } } Modified: vmkit/branches/precise/mmtk/mmtk-j3/Assert.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/mmtk/mmtk-j3/Assert.cpp?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/mmtk/mmtk-j3/Assert.cpp (original) +++ vmkit/branches/precise/mmtk/mmtk-j3/Assert.cpp Tue Sep 7 14:48:53 2010 @@ -15,4 +15,4 @@ using namespace j3; -extern "C" void Java_org_j3_mmtk_Assert_dumpStack__ () { UNIMPLEMENTED(); } +extern "C" void Java_org_j3_mmtk_Assert_dumpStack__ (JavaObject* self) { UNIMPLEMENTED(); } Modified: vmkit/branches/precise/mmtk/mmtk-j3/Lock.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/mmtk/mmtk-j3/Lock.cpp?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/mmtk/mmtk-j3/Lock.cpp (original) +++ vmkit/branches/precise/mmtk/mmtk-j3/Lock.cpp Tue Sep 7 14:48:53 2010 @@ -27,7 +27,7 @@ extern "C" void Java_org_j3_mmtk_Lock_acquire__(Lock* l) { l->spin.acquire(); } -extern "C" void Java_org_j3_mmtk_Lock_check__I () { UNIMPLEMENTED(); } +extern "C" void Java_org_j3_mmtk_Lock_check__I (Lock* l, int i) { UNIMPLEMENTED(); } extern "C" void Java_org_j3_mmtk_Lock_release__(Lock* l) { l->spin.release(); Modified: vmkit/branches/precise/mmtk/mmtk-j3/SynchronizedCounter.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/mmtk/mmtk-j3/SynchronizedCounter.cpp?rev=113254&r1=113253&r2=113254&view=diff ============================================================================== --- vmkit/branches/precise/mmtk/mmtk-j3/SynchronizedCounter.cpp (original) +++ vmkit/branches/precise/mmtk/mmtk-j3/SynchronizedCounter.cpp Tue Sep 7 14:48:53 2010 @@ -15,6 +15,6 @@ using namespace j3; -extern "C" void Java_org_j3_mmtk_SynchronizedCounter_reset__ () { UNIMPLEMENTED(); } -extern "C" void Java_org_j3_mmtk_SynchronizedCounter_increment__ () { UNIMPLEMENTED(); } +extern "C" void Java_org_j3_mmtk_SynchronizedCounter_reset__ (JavaObject* self) { UNIMPLEMENTED(); } +extern "C" void Java_org_j3_mmtk_SynchronizedCounter_increment__ (JavaObject* self) { UNIMPLEMENTED(); } From nicolas.geoffray at lip6.fr Sat Sep 11 15:33:49 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 11 Sep 2010 22:33:49 -0000 Subject: [vmkit-commits] [vmkit] r113706 - in /vmkit/branches/precise: include/mvm/JIT.h include/mvm/MethodInfo.h include/mvm/VirtualMachine.h lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.h lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/JnjvmClassLoader.cpp lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp Message-ID: <20100911223349.47BDA2A6C12C@llvm.org> Author: geoffray Date: Sat Sep 11 17:33:49 2010 New Revision: 113706 URL: http://llvm.org/viewvc/llvm-project?rev=113706&view=rev Log: Have a single function map per vm, and put exact ip information in it. Modified: vmkit/branches/precise/include/mvm/JIT.h vmkit/branches/precise/include/mvm/MethodInfo.h vmkit/branches/precise/include/mvm/VirtualMachine.h vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp vmkit/branches/precise/lib/J3/VMCore/JavaClass.h vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp Modified: vmkit/branches/precise/include/mvm/JIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/JIT.h?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/include/mvm/JIT.h (original) +++ vmkit/branches/precise/include/mvm/JIT.h Sat Sep 11 17:33:49 2010 @@ -30,6 +30,7 @@ class FunctionPassManager; class GCFunctionInfo; class GCStrategy; + class JIT; class Module; class PointerType; class TargetData; @@ -176,15 +177,13 @@ class MvmModule { -private: - static llvm::ExecutionEngine* executionEngine; - public: static llvm::GCStrategy* TheGCStrategy; static mvm::LockRecursive protectEngine; static llvm::Module *globalModule; static const llvm::TargetData* TheTargetData; static mvm::BumpPtrAllocator* Allocator; + static llvm::ExecutionEngine* executionEngine; //static unsigned MetadataTypeKind; static uint64 getTypeSize(const llvm::Type* type); @@ -209,6 +208,7 @@ public: virtual void scan(uintptr_t closure, void* ip, void* addr); JITMethodInfo(llvm::GCFunctionInfo* GFI) : GCInfo(GFI) {} + void addToVM(VirtualMachine* vm, llvm::JIT* jit); }; class MvmJITMethodInfo : public JITMethodInfo { Modified: vmkit/branches/precise/include/mvm/MethodInfo.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/MethodInfo.h?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/include/mvm/MethodInfo.h (original) +++ vmkit/branches/precise/include/mvm/MethodInfo.h Sat Sep 11 17:33:49 2010 @@ -29,7 +29,6 @@ void* getMetaInfo() const { return MetaInfo; } unsigned MethodType; - void* InstructionPointer; void* MetaInfo; }; @@ -45,15 +44,15 @@ public: CamlFrame* CF; virtual void scan(uintptr_t closure, void* ip, void* addr); - CamlMethodInfo(CamlFrame* C, void* ip); + CamlMethodInfo(CamlFrame* C) : CF(C) { } }; class StaticCamlMethodInfo : public CamlMethodInfo { const char* name; public: virtual void print(void* ip, void* addr); - StaticCamlMethodInfo(CamlFrame* CF, void* ip, const char* n) : - CamlMethodInfo(CF, ip) { + StaticCamlMethodInfo(CamlFrame* CF, const char* n) : + CamlMethodInfo(CF) { name = n; MethodType = 0; } Modified: vmkit/branches/precise/include/mvm/VirtualMachine.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/VirtualMachine.h?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/include/mvm/VirtualMachine.h (original) +++ vmkit/branches/precise/include/mvm/VirtualMachine.h Sat Sep 11 17:33:49 2010 @@ -48,79 +48,16 @@ /// IPToMethodInfo - Map a code start instruction instruction to the MethodInfo. /// - MethodInfo* CodeStartToMethodInfo(void* ip) { - FunctionMapLock.acquire(); - std::map::iterator I = Functions.find(ip); - MethodInfo* res = NULL; - if (I != Functions.end()) { - res = I->second; - } - FunctionMapLock.release(); - return res; - } -}; - -/// StartEndFunctionMap - This map is for functions for which we have -/// a start and end address. -/// -class StartEndFunctionMap : public FunctionMap { -public: - /// addMethodInFunctionMap - A new method pointer in the function map. - /// - void addMethodInfo(MethodInfo* meth, void* start, void* end) { - FunctionMapLock.acquire(); - Functions.insert(std::make_pair(start, meth)); - Functions.insert(std::make_pair(end, meth)); - FunctionMapLock.release(); - } - - /// IPToMethodInfo - Map an instruction pointer to the MethodInfo. - /// - MethodInfo* IPToMethodInfo(void* ip) { - FunctionMapLock.acquire(); - std::map::iterator I = Functions.upper_bound(ip); - MethodInfo* res = 0; - if (I != Functions.end() && I != Functions.begin()) { - res = I->second; - if ((--I)->second != res) res = 0; - } - FunctionMapLock.release(); - return res; - } -}; - -/// StartFunctionMap - This map is for static functions where getting an end -/// address is cumbersome. -/// -class StartFunctionMap : public FunctionMap { -public: - /// addMethodInFunctionMap - A new method pointer in the function map. - /// - void addMethodInfo(MethodInfo* meth, void* addr) { - FunctionMapLock.acquire(); - Functions.insert(std::make_pair((void*)addr, meth)); - FunctionMapLock.release(); - } - - /// IPToMethodInfo - Map an instruction pointer to the MethodInfo. - /// MethodInfo* IPToMethodInfo(void* ip); - -}; -class SharedStartFunctionMap : public StartFunctionMap { -public: - BumpPtrAllocator* StaticAllocator; - bool initialized; - SharedStartFunctionMap() { - initialized = false; - } + /// addMethodInfo - A new instruction pointer in the function map. + /// + void addMethodInfo(MethodInfo* meth, void* ip); - void initialize(); + FunctionMap(); }; - // Same values than JikesRVM #define INITIAL_QUEUE_SIZE 256 #define GROW_FACTOR 2 @@ -232,7 +169,6 @@ mainThread = 0; NumberOfThreads = 0; - if (!SharedStaticFunctions.initialized) SharedStaticFunctions.initialize(); } public: @@ -529,13 +465,10 @@ UncooperativeCollectionRV rendezvous; #endif - - StartEndFunctionMap RuntimeFunctions; - static StartEndFunctionMap SharedRuntimeFunctions; - StartFunctionMap StaticFunctions; - static SharedStartFunctionMap SharedStaticFunctions; - - MethodInfo* IPToMethodInfo(void* ip); + FunctionMap FunctionsCache; + MethodInfo* IPToMethodInfo(void* ip) { + return FunctionsCache.IPToMethodInfo(ip); + } #ifdef ISOLATE size_t IsolateID; Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp Sat Sep 11 17:33:49 2010 @@ -55,10 +55,16 @@ if (ip) new_ip = isStub(ip, addr); JavaMethod* meth = (JavaMethod*)MetaInfo; CodeLineInfo* info = meth->lookupCodeLineInfo((uintptr_t)ip); - fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)", new_ip, - UTF8Buffer(meth->classDef->name).cString(), - UTF8Buffer(meth->name).cString(), info->lineNumber, - info->bytecodeIndex, meth->code); + if (info != NULL) { + fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)", new_ip, + UTF8Buffer(meth->classDef->name).cString(), + UTF8Buffer(meth->name).cString(), info->lineNumber, + info->bytecodeIndex, meth->code); + } else { + fprintf(stderr, "; %p in %s.%s (native method, code start %p)", new_ip, + UTF8Buffer(meth->classDef->name).cString(), + UTF8Buffer(meth->name).cString(), meth->code); + } if (ip != new_ip) fprintf(stderr, " (from stub)"); fprintf(stderr, "\n"); } @@ -71,41 +77,39 @@ // The following could be changed to an assert when -load-bc supports // the verifier. if (F.getParent() != TheCompiler->getLLVMModule()) return; + assert(F.hasGC()); Jnjvm* vm = JavaThread::get()->getJVM(); mvm::BumpPtrAllocator& Alloc = TheCompiler->allocator; - llvm::GCFunctionInfo* GFI = 0; - if (F.hasGC()) { - if (TheCompiler->TheGCStrategy == NULL) { - assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy"); - TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy; - mvm::MvmModule::TheGCStrategy = NULL; - } - GCStrategy::iterator I = TheCompiler->TheGCStrategy->end(); + // Fetch the GCStrategy if it wasn't created before. + if (TheCompiler->TheGCStrategy == NULL) { + assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy"); + TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy; + mvm::MvmModule::TheGCStrategy = NULL; + } + + GCStrategy::iterator I = TheCompiler->TheGCStrategy->end(); + I--; + while (&(*I)->getFunction() != &F) { + // This happens when the compilation of a function was post-poned. + assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info"); I--; - while (&(*I)->getFunction() != &F) { - // This happens when the compilation of a function was post-poned. - assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info"); - I--; - } - assert(&(*I)->getFunction() == &F && - "GC Info and method do not correspond"); - GFI = *I; } + assert(&(*I)->getFunction() == &F && "GC Info and method do not correspond"); + llvm::GCFunctionInfo* GFI = *I; JavaMethod* meth = TheCompiler->getJavaMethod(F); + mvm::JITMethodInfo* MI = NULL; if (meth == NULL) { // This is a stub. - mvm::MvmJITMethodInfo* MI = new(Alloc, "JITMethodInfo") - mvm::MvmJITMethodInfo(GFI, &F); - vm->RuntimeFunctions.addMethodInfo(MI, Code, - (void*)((uintptr_t)Code + Size)); + MI = new(Alloc, "JITMethodInfo") mvm::MvmJITMethodInfo(GFI, &F); } else { - JavaJITMethodInfo* MI = new(Alloc, "JavaJITMethodInfo") - JavaJITMethodInfo(GFI, meth); - vm->RuntimeFunctions.addMethodInfo(MI, Code, - (void*)((uintptr_t)Code + Size)); + MI = new(Alloc, "JavaJITMethodInfo") JavaJITMethodInfo(GFI, meth); + } + MI->addToVM(vm, (JIT*)TheCompiler->executionEngine); + + if (meth != NULL) { uint32 infoLength = Details.LineStarts.size(); meth->codeInfoLength = infoLength; if (infoLength > 0) { Modified: vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp Sat Sep 11 17:33:49 2010 @@ -169,9 +169,7 @@ "", Compiler->getLLVMModule()); } - if (Compiler->useCooperativeGC()) { - methodFunction->setGC("vmkit"); - } + methodFunction->setGC("vmkit"); Compiler->functions.insert(std::make_pair(methodFunction, methodDef)); if (Compiler != JCL->getCompiler() && methodDef->code) { @@ -404,10 +402,13 @@ Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock); - if (!signature->getReturnType()->isVoid()) + if (!signature->getReturnType()->isVoid()) { ReturnInst::Create(context, val, currentBlock); - else + } else { ReturnInst::Create(context, currentBlock); + } + + res->setGC("vmkit"); return res; } @@ -481,15 +482,14 @@ Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock); - if (!signature->getReturnType()->isVoid()) + if (!signature->getReturnType()->isVoid()) { ReturnInst::Create(context, val, currentBlock); - else + } else { ReturnInst::Create(context, currentBlock); - - if (Compiler->useCooperativeGC()) { - res->setGC("vmkit"); } + res->setGC("vmkit"); + return res; } @@ -545,7 +545,7 @@ if (virt) { if (Compiler->useCooperativeGC()) { Args.push_back(new LoadInst(TempArgs[0], "", false, currentBlock)); - }else { + } else { Args.push_back(TempArgs[0]); } } @@ -587,9 +587,7 @@ ReturnInst::Create(context, currentBlock); } - if (Compiler->useCooperativeGC()) { - stub->setGC("vmkit"); - } + stub->setGC("vmkit"); return stub; } Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.h?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.h Sat Sep 11 17:33:49 2010 @@ -902,7 +902,7 @@ virtual void print(void* ip, void* addr); JavaStaticMethodInfo(mvm::CamlMethodInfo* super, void* ip, JavaMethod* M) : - mvm::CamlMethodInfo(super != NULL ? super->CF : NULL, ip) { + mvm::CamlMethodInfo(super->CF) { MetaInfo = M; MethodType = 1; } Modified: vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp (original) +++ vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp Sat Sep 11 17:33:49 2010 @@ -1487,8 +1487,7 @@ } void Jnjvm::removeMethodsInFunctionMaps(JnjvmClassLoader* loader) { - internalRemoveMethods(loader, RuntimeFunctions); - internalRemoveMethods(loader, StaticFunctions); + internalRemoveMethods(loader, FunctionsCache); } Modified: vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp Sat Sep 11 17:33:49 2010 @@ -1073,7 +1073,7 @@ if (!isAbstract(meth.access) && meth.code) { JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo") JavaStaticMethodInfo(0, meth.code, &meth); - vm->StaticFunctions.addMethodInfo(MI, meth.code); + vm->FunctionsCache.addMethodInfo(MI, meth.code); } } @@ -1082,7 +1082,7 @@ if (!isAbstract(meth.access) && meth.code) { JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo") JavaStaticMethodInfo(0, meth.code, &meth); - vm->StaticFunctions.addMethodInfo(MI, meth.code); + vm->FunctionsCache.addMethodInfo(MI, meth.code); } } } Modified: vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp Sat Sep 11 17:33:49 2010 @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include "llvm/ExecutionEngine/JITEventListener.h" @@ -35,6 +36,7 @@ #include #include #include +#include <../lib/ExecutionEngine/JIT/JIT.h> #include "mvm/JIT.h" #include "mvm/Threads/Locks.h" @@ -93,24 +95,33 @@ void *Code, size_t Size, const EmittedFunctionDetails &Details) { assert(F.getParent() == MvmModule::globalModule); - llvm::GCFunctionInfo* GFI = 0; + assert(F.hasGC()); // We know the last GC info is for this method. - if (F.hasGC()) { - GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end(); - I--; - DEBUG(errs() << (*I)->getFunction().getName() << '\n'); - DEBUG(errs() << F.getName() << '\n'); - assert(&(*I)->getFunction() == &F && + GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end(); + I--; + DEBUG(errs() << (*I)->getFunction().getName() << '\n'); + DEBUG(errs() << F.getName() << '\n'); + assert(&(*I)->getFunction() == &F && "GC Info and method do not correspond"); - GFI = *I; - } - MethodInfo* MI = + llvm::GCFunctionInfo* GFI = *I; + JITMethodInfo* MI = new(*MvmModule::Allocator, "MvmJITMethodInfo") MvmJITMethodInfo(GFI, &F); - VirtualMachine::SharedRuntimeFunctions.addMethodInfo(MI, Code, - (void*)((uintptr_t)Code + Size)); + MI->addToVM(mvm::Thread::get()->MyVM, (JIT*)MvmModule::executionEngine); } }; +void JITMethodInfo::addToVM(VirtualMachine* VM, JIT* jit) { + JITCodeEmitter* JCE = jit->getCodeEmitter(); + assert(GCInfo != NULL); + for (GCFunctionInfo::iterator I = GCInfo->begin(), E = GCInfo->end(); + I != E; + I++) { + uintptr_t address = JCE->getLabelAddress(I->Label); + assert(address != 0); + VM->FunctionsCache.addMethodInfo(this, (void*)address); + } +} + static MvmJITListener JITListener; void MvmModule::loadBytecodeFile(const std::string& str) { @@ -317,6 +328,7 @@ unconditionalSafePoint = module->getFunction("unconditionalSafePoint"); conditionalSafePoint = module->getFunction("conditionalSafePoint"); AllocateFunction = module->getFunction("gcmalloc"); + AllocateFunction->setGC("vmkit"); assert(AllocateFunction && "No allocate function"); AllocateUnresolvedFunction = module->getFunction("gcmallocUnresolved"); assert(AllocateUnresolvedFunction && "No allocateUnresolved function"); Modified: vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp (original) +++ vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp Sat Sep 11 17:33:49 2010 @@ -24,19 +24,11 @@ using namespace mvm; void CamlMethodInfo::scan(uintptr_t closure, void* ip, void* addr) { - if (!CF && InstructionPointer) { - MethodInfo* MI = VirtualMachine::SharedStaticFunctions.IPToMethodInfo(ip); - if (MI != &DefaultMethodInfo::DM) { - CF = ((CamlMethodInfo*)MI)->CF; - } - } - - if (CF) { - //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*); - uintptr_t spaddr = ((uintptr_t*)addr)[0]; - for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) { - Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure); - } + assert(CF != NULL); + //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*); + uintptr_t spaddr = ((uintptr_t*)addr)[0]; + for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) { + Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure); } } @@ -59,52 +51,6 @@ void DefaultMethodInfo::scan(uintptr_t closure, void* ip, void* addr) { } - -MethodInfo* StartFunctionMap::IPToMethodInfo(void* ip) { - FunctionMapLock.acquire(); - std::map::iterator E = Functions.end(); - std::map::iterator I = Functions.find(ip); - MethodInfo* MI = 0; - if (I == E) { - Dl_info info; - int res = dladdr(ip, &info); - if (res != 0) { - I = Functions.find(info.dli_saddr); - if (I == E) { - // The method is static, and we have no information for it. - // Just return the Default MethodInfo object. - MI = &DefaultMethodInfo::DM; - } else { - MI = I->second; - } - } else { - // The method is jitted, and no-one has intercepted its compilation. - // Just return the Default MethodInfo object. - MI = &DefaultMethodInfo::DM; - } - // Add it to the map, so that we don't need to call dladdr again. - Functions.insert(std::make_pair(ip, MI)); - } else { - MI = I->second; - } - FunctionMapLock.release(); - return MI; -} - -MethodInfo* VirtualMachine::IPToMethodInfo(void* ip) { - MethodInfo* MI = RuntimeFunctions.IPToMethodInfo(ip); - if (MI) return MI; - - MI = SharedRuntimeFunctions.IPToMethodInfo(ip); - if (MI) return MI; - - MI = StaticFunctions.IPToMethodInfo(ip); - if (MI != &DefaultMethodInfo::DM) return MI; - - MI = SharedStaticFunctions.IPToMethodInfo(ip); - return MI; -} - struct CamlFrames { uint16_t NumDescriptors; CamlFrame frames[1]; @@ -114,14 +60,11 @@ CamlFrames* frames ; uint32 currentDescriptor; CamlFrame* currentFrame; - Dl_info info; CamlFrameDecoder(CamlFrames* frames) { this->frames = frames; currentDescriptor = 0; currentFrame = &(frames->frames[0]); - int res = dladdr(currentFrame->ReturnAddress, &info); - assert(res != 0 && "No frame"); } bool hasNext() { @@ -135,55 +78,51 @@ (currentFrame->NumLiveOffsets % 2) * sizeof(uint16_t) + currentFrame->NumLiveOffsets * sizeof(uint16_t) + sizeof(void*) + sizeof(uint16_t) + sizeof(uint16_t)); - int res = dladdr(currentFrame->ReturnAddress, &info); - assert(res != 0 && "No frame"); } - CamlFrame* next(void** funcAddress, const char** funcName) { + CamlFrame* next() { assert(hasNext()); CamlFrame* result = currentFrame; - *funcAddress = info.dli_saddr; - *funcName = info.dli_sname; - - // Skip the remaining ones. - do { - advance(); - } while (hasNext() && (info.dli_saddr == *funcAddress)); - - // Skip the entries that start at another method. - while (hasNext() && (info.dli_saddr == currentFrame->ReturnAddress)) { - advance(); - } - - while (hasNext() && (info.dli_saddr == NULL)) { - advance(); - } + advance(); return result; } }; -void SharedStartFunctionMap::initialize() { +static BumpPtrAllocator* StaticAllocator = NULL; + +FunctionMap::FunctionMap() { CamlFrames* frames = (CamlFrames*)dlsym(SELF_HANDLE, "camlVmkitoptimized__frametable"); + if (frames == NULL) return; + StaticAllocator = new BumpPtrAllocator(); - const char* name = NULL; - void* address = NULL; - - if (frames != NULL) { - CamlFrameDecoder decoder(frames); - while (decoder.hasNext()) { - CamlFrame* frame = decoder.next(&address, &name); - StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo") - StaticCamlMethodInfo(frame, address, name); - addMethodInfo(MI, address); - } + CamlFrameDecoder decoder(frames); + Dl_info info; + while (decoder.hasNext()) { + CamlFrame* frame = decoder.next(); + int res = dladdr(frame->ReturnAddress, &info); + assert(res != 0 && "No frame"); + StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo") + StaticCamlMethodInfo(frame, info.dli_sname); + addMethodInfo(MI, frame->ReturnAddress); } } -CamlMethodInfo::CamlMethodInfo(CamlFrame* C, void* ip) { - InstructionPointer = ip; - CF = C; +MethodInfo* FunctionMap::IPToMethodInfo(void* ip) { + FunctionMapLock.acquire(); + std::map::iterator I = Functions.find(ip); + MethodInfo* res = NULL; + if (I != Functions.end()) { + res = I->second; + } else { + res = &DefaultMethodInfo::DM; + } + FunctionMapLock.release(); + return res; } -StartEndFunctionMap VirtualMachine::SharedRuntimeFunctions; -SharedStartFunctionMap VirtualMachine::SharedStaticFunctions; +void FunctionMap::addMethodInfo(MethodInfo* meth, void* ip) { + FunctionMapLock.acquire(); + Functions.insert(std::make_pair(ip, meth)); + FunctionMapLock.release(); +} From igf1 at yahoo.com Tue Sep 14 14:27:03 2010 From: igf1 at yahoo.com (Richard Corsale) Date: Tue, 14 Sep 2010 14:27:03 -0700 (PDT) Subject: [vmkit-commits] vmkit-commits Digest, Vol 28, Issue 2 In-Reply-To: References: Message-ID: <558356.48670.qm@web112619.mail.gq1.yahoo.com> Hi all, I seem to get this error when running make: llvm[1]: Linking Debug+Asserts executable vmjc /media/tank/Downloads/VMKit/vmkit/Debug+Asserts/lib/libJ3.a(Jnjvm.o): In function `ForceRuntimeLinking': /media/tank/Downloads/VMKit/vmkit/lib/J3/VMCore/LinkJavaRuntime.h:108: undefined reference to `j3OverflowThinLock' collect2: ld returned 1 exit status make[1]: *** [/media/tank/Downloads/VMKit/vmkit/Debug+Asserts/bin/vmjc] Error 1 make[1]: Leaving directory `/media/tank/Downloads/VMKit/vmkit/tools/vmjc' make: *** [all] Error 1 I any idea what's going on? ----- Original Message ---- From: "vmkit-commits-request at cs.uiuc.edu" To: vmkit-commits at cs.uiuc.edu Sent: Sun, September 12, 2010 1:00:07 PM Subject: vmkit-commits Digest, Vol 28, Issue 2 Send vmkit-commits mailing list submissions to vmkit-commits at cs.uiuc.edu To subscribe or unsubscribe via the World Wide Web, visit http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits or, via email, send a message with subject or body 'help' to vmkit-commits-request at cs.uiuc.edu You can reach the person managing the list at vmkit-commits-owner at cs.uiuc.edu When replying, please edit your Subject line so it is more specific than "Re: Contents of vmkit-commits digest..." Today's Topics: 1. [vmkit] r113706 - in /vmkit/branches/precise: include/mvm/JIT.h include/mvm/MethodInfo.h include/mvm/VirtualMachine.h lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.h lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/JnjvmClassLoader.cpp lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp (Nicolas Geoffray) ---------------------------------------------------------------------- Message: 1 Date: Sat, 11 Sep 2010 22:33:49 -0000 From: Nicolas Geoffray Subject: [vmkit-commits] [vmkit] r113706 - in /vmkit/branches/precise: include/mvm/JIT.h include/mvm/MethodInfo.h include/mvm/VirtualMachine.h lib/J3/Compiler/JavaJITCompiler.cpp lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.h lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/JnjvmClassLoader.cpp lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp To: vmkit-commits at cs.uiuc.edu Message-ID: <20100911223349.47BDA2A6C12C at llvm.org> Content-Type: text/plain; charset="utf-8" Author: geoffray Date: Sat Sep 11 17:33:49 2010 New Revision: 113706 URL: http://llvm.org/viewvc/llvm-project?rev=113706&view=rev Log: Have a single function map per vm, and put exact ip information in it. Modified: vmkit/branches/precise/include/mvm/JIT.h vmkit/branches/precise/include/mvm/MethodInfo.h vmkit/branches/precise/include/mvm/VirtualMachine.h vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp vmkit/branches/precise/lib/J3/VMCore/JavaClass.h vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp Modified: vmkit/branches/precise/include/mvm/JIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/JIT.h?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/include/mvm/JIT.h (original) +++ vmkit/branches/precise/include/mvm/JIT.h Sat Sep 11 17:33:49 2010 @@ -30,6 +30,7 @@ class FunctionPassManager; class GCFunctionInfo; class GCStrategy; + class JIT; class Module; class PointerType; class TargetData; @@ -176,15 +177,13 @@ class MvmModule { -private: - static llvm::ExecutionEngine* executionEngine; - public: static llvm::GCStrategy* TheGCStrategy; static mvm::LockRecursive protectEngine; static llvm::Module *globalModule; static const llvm::TargetData* TheTargetData; static mvm::BumpPtrAllocator* Allocator; + static llvm::ExecutionEngine* executionEngine; //static unsigned MetadataTypeKind; static uint64 getTypeSize(const llvm::Type* type); @@ -209,6 +208,7 @@ public: virtual void scan(uintptr_t closure, void* ip, void* addr); JITMethodInfo(llvm::GCFunctionInfo* GFI) : GCInfo(GFI) {} + void addToVM(VirtualMachine* vm, llvm::JIT* jit); }; class MvmJITMethodInfo : public JITMethodInfo { Modified: vmkit/branches/precise/include/mvm/MethodInfo.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/MethodInfo.h?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/include/mvm/MethodInfo.h (original) +++ vmkit/branches/precise/include/mvm/MethodInfo.h Sat Sep 11 17:33:49 2010 @@ -29,7 +29,6 @@ void* getMetaInfo() const { return MetaInfo; } unsigned MethodType; - void* InstructionPointer; void* MetaInfo; }; @@ -45,15 +44,15 @@ public: CamlFrame* CF; virtual void scan(uintptr_t closure, void* ip, void* addr); - CamlMethodInfo(CamlFrame* C, void* ip); + CamlMethodInfo(CamlFrame* C) : CF(C) { } }; class StaticCamlMethodInfo : public CamlMethodInfo { const char* name; public: virtual void print(void* ip, void* addr); - StaticCamlMethodInfo(CamlFrame* CF, void* ip, const char* n) : - CamlMethodInfo(CF, ip) { + StaticCamlMethodInfo(CamlFrame* CF, const char* n) : + CamlMethodInfo(CF) { name = n; MethodType = 0; } Modified: vmkit/branches/precise/include/mvm/VirtualMachine.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/VirtualMachine.h?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/include/mvm/VirtualMachine.h (original) +++ vmkit/branches/precise/include/mvm/VirtualMachine.h Sat Sep 11 17:33:49 2010 @@ -48,79 +48,16 @@ /// IPToMethodInfo - Map a code start instruction instruction to the MethodInfo. /// - MethodInfo* CodeStartToMethodInfo(void* ip) { - FunctionMapLock.acquire(); - std::map::iterator I = Functions.find(ip); - MethodInfo* res = NULL; - if (I != Functions.end()) { - res = I->second; - } - FunctionMapLock.release(); - return res; - } -}; - -/// StartEndFunctionMap - This map is for functions for which we have -/// a start and end address. -/// -class StartEndFunctionMap : public FunctionMap { -public: - /// addMethodInFunctionMap - A new method pointer in the function map. - /// - void addMethodInfo(MethodInfo* meth, void* start, void* end) { - FunctionMapLock.acquire(); - Functions.insert(std::make_pair(start, meth)); - Functions.insert(std::make_pair(end, meth)); - FunctionMapLock.release(); - } - - /// IPToMethodInfo - Map an instruction pointer to the MethodInfo. - /// - MethodInfo* IPToMethodInfo(void* ip) { - FunctionMapLock.acquire(); - std::map::iterator I = Functions.upper_bound(ip); - MethodInfo* res = 0; - if (I != Functions.end() && I != Functions.begin()) { - res = I->second; - if ((--I)->second != res) res = 0; - } - FunctionMapLock.release(); - return res; - } -}; - -/// StartFunctionMap - This map is for static functions where getting an end -/// address is cumbersome. -/// -class StartFunctionMap : public FunctionMap { -public: - /// addMethodInFunctionMap - A new method pointer in the function map. - /// - void addMethodInfo(MethodInfo* meth, void* addr) { - FunctionMapLock.acquire(); - Functions.insert(std::make_pair((void*)addr, meth)); - FunctionMapLock.release(); - } - - /// IPToMethodInfo - Map an instruction pointer to the MethodInfo. - /// MethodInfo* IPToMethodInfo(void* ip); - -}; -class SharedStartFunctionMap : public StartFunctionMap { -public: - BumpPtrAllocator* StaticAllocator; - bool initialized; - SharedStartFunctionMap() { - initialized = false; - } + /// addMethodInfo - A new instruction pointer in the function map. + /// + void addMethodInfo(MethodInfo* meth, void* ip); - void initialize(); + FunctionMap(); }; - // Same values than JikesRVM #define INITIAL_QUEUE_SIZE 256 #define GROW_FACTOR 2 @@ -232,7 +169,6 @@ mainThread = 0; NumberOfThreads = 0; - if (!SharedStaticFunctions.initialized) SharedStaticFunctions.initialize(); } public: @@ -529,13 +465,10 @@ UncooperativeCollectionRV rendezvous; #endif - - StartEndFunctionMap RuntimeFunctions; - static StartEndFunctionMap SharedRuntimeFunctions; - StartFunctionMap StaticFunctions; - static SharedStartFunctionMap SharedStaticFunctions; - - MethodInfo* IPToMethodInfo(void* ip); + FunctionMap FunctionsCache; + MethodInfo* IPToMethodInfo(void* ip) { + return FunctionsCache.IPToMethodInfo(ip); + } #ifdef ISOLATE size_t IsolateID; Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp Sat Sep 11 17:33:49 2010 @@ -55,10 +55,16 @@ if (ip) new_ip = isStub(ip, addr); JavaMethod* meth = (JavaMethod*)MetaInfo; CodeLineInfo* info = meth->lookupCodeLineInfo((uintptr_t)ip); - fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)", new_ip, - UTF8Buffer(meth->classDef->name).cString(), - UTF8Buffer(meth->name).cString(), info->lineNumber, - info->bytecodeIndex, meth->code); + if (info != NULL) { + fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)", new_ip, + UTF8Buffer(meth->classDef->name).cString(), + UTF8Buffer(meth->name).cString(), info->lineNumber, + info->bytecodeIndex, meth->code); + } else { + fprintf(stderr, "; %p in %s.%s (native method, code start %p)", new_ip, + UTF8Buffer(meth->classDef->name).cString(), + UTF8Buffer(meth->name).cString(), meth->code); + } if (ip != new_ip) fprintf(stderr, " (from stub)"); fprintf(stderr, "\n"); } @@ -71,41 +77,39 @@ // The following could be changed to an assert when -load-bc supports // the verifier. if (F.getParent() != TheCompiler->getLLVMModule()) return; + assert(F.hasGC()); Jnjvm* vm = JavaThread::get()->getJVM(); mvm::BumpPtrAllocator& Alloc = TheCompiler->allocator; - llvm::GCFunctionInfo* GFI = 0; - if (F.hasGC()) { - if (TheCompiler->TheGCStrategy == NULL) { - assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy"); - TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy; - mvm::MvmModule::TheGCStrategy = NULL; - } - GCStrategy::iterator I = TheCompiler->TheGCStrategy->end(); + // Fetch the GCStrategy if it wasn't created before. + if (TheCompiler->TheGCStrategy == NULL) { + assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy"); + TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy; + mvm::MvmModule::TheGCStrategy = NULL; + } + + GCStrategy::iterator I = TheCompiler->TheGCStrategy->end(); + I--; + while (&(*I)->getFunction() != &F) { + // This happens when the compilation of a function was post-poned. + assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info"); I--; - while (&(*I)->getFunction() != &F) { - // This happens when the compilation of a function was post-poned. - assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info"); - I--; - } - assert(&(*I)->getFunction() == &F && - "GC Info and method do not correspond"); - GFI = *I; } + assert(&(*I)->getFunction() == &F && "GC Info and method do not correspond"); + llvm::GCFunctionInfo* GFI = *I; JavaMethod* meth = TheCompiler->getJavaMethod(F); + mvm::JITMethodInfo* MI = NULL; if (meth == NULL) { // This is a stub. - mvm::MvmJITMethodInfo* MI = new(Alloc, "JITMethodInfo") - mvm::MvmJITMethodInfo(GFI, &F); - vm->RuntimeFunctions.addMethodInfo(MI, Code, - (void*)((uintptr_t)Code + Size)); + MI = new(Alloc, "JITMethodInfo") mvm::MvmJITMethodInfo(GFI, &F); } else { - JavaJITMethodInfo* MI = new(Alloc, "JavaJITMethodInfo") - JavaJITMethodInfo(GFI, meth); - vm->RuntimeFunctions.addMethodInfo(MI, Code, - (void*)((uintptr_t)Code + Size)); + MI = new(Alloc, "JavaJITMethodInfo") JavaJITMethodInfo(GFI, meth); + } + MI->addToVM(vm, (JIT*)TheCompiler->executionEngine); + + if (meth != NULL) { uint32 infoLength = Details.LineStarts.size(); meth->codeInfoLength = infoLength; if (infoLength > 0) { Modified: vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp Sat Sep 11 17:33:49 2010 @@ -169,9 +169,7 @@ "", Compiler->getLLVMModule()); } - if (Compiler->useCooperativeGC()) { - methodFunction->setGC("vmkit"); - } + methodFunction->setGC("vmkit"); Compiler->functions.insert(std::make_pair(methodFunction, methodDef)); if (Compiler != JCL->getCompiler() && methodDef->code) { @@ -404,10 +402,13 @@ Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock); - if (!signature->getReturnType()->isVoid()) + if (!signature->getReturnType()->isVoid()) { ReturnInst::Create(context, val, currentBlock); - else + } else { ReturnInst::Create(context, currentBlock); + } + + res->setGC("vmkit"); return res; } @@ -481,15 +482,14 @@ Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock); - if (!signature->getReturnType()->isVoid()) + if (!signature->getReturnType()->isVoid()) { ReturnInst::Create(context, val, currentBlock); - else + } else { ReturnInst::Create(context, currentBlock); - - if (Compiler->useCooperativeGC()) { - res->setGC("vmkit"); } + res->setGC("vmkit"); + return res; } @@ -545,7 +545,7 @@ if (virt) { if (Compiler->useCooperativeGC()) { Args.push_back(new LoadInst(TempArgs[0], "", false, currentBlock)); - }else { + } else { Args.push_back(TempArgs[0]); } } @@ -587,9 +587,7 @@ ReturnInst::Create(context, currentBlock); } - if (Compiler->useCooperativeGC()) { - stub->setGC("vmkit"); - } + stub->setGC("vmkit"); return stub; } Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.h?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.h Sat Sep 11 17:33:49 2010 @@ -902,7 +902,7 @@ virtual void print(void* ip, void* addr); JavaStaticMethodInfo(mvm::CamlMethodInfo* super, void* ip, JavaMethod* M) : - mvm::CamlMethodInfo(super != NULL ? super->CF : NULL, ip) { + mvm::CamlMethodInfo(super->CF) { MetaInfo = M; MethodType = 1; } Modified: vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp (original) +++ vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp Sat Sep 11 17:33:49 2010 @@ -1487,8 +1487,7 @@ } void Jnjvm::removeMethodsInFunctionMaps(JnjvmClassLoader* loader) { - internalRemoveMethods(loader, RuntimeFunctions); - internalRemoveMethods(loader, StaticFunctions); + internalRemoveMethods(loader, FunctionsCache); } Modified: vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp Sat Sep 11 17:33:49 2010 @@ -1073,7 +1073,7 @@ if (!isAbstract(meth.access) && meth.code) { JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo") JavaStaticMethodInfo(0, meth.code, &meth); - vm->StaticFunctions.addMethodInfo(MI, meth.code); + vm->FunctionsCache.addMethodInfo(MI, meth.code); } } @@ -1082,7 +1082,7 @@ if (!isAbstract(meth.access) && meth.code) { JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo") JavaStaticMethodInfo(0, meth.code, &meth); - vm->StaticFunctions.addMethodInfo(MI, meth.code); + vm->FunctionsCache.addMethodInfo(MI, meth.code); } } } Modified: vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp (original) +++ vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp Sat Sep 11 17:33:49 2010 @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include "llvm/ExecutionEngine/JITEventListener.h" @@ -35,6 +36,7 @@ #include #include #include +#include <../lib/ExecutionEngine/JIT/JIT.h> #include "mvm/JIT.h" #include "mvm/Threads/Locks.h" @@ -93,24 +95,33 @@ void *Code, size_t Size, const EmittedFunctionDetails &Details) { assert(F.getParent() == MvmModule::globalModule); - llvm::GCFunctionInfo* GFI = 0; + assert(F.hasGC()); // We know the last GC info is for this method. - if (F.hasGC()) { - GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end(); - I--; - DEBUG(errs() << (*I)->getFunction().getName() << '\n'); - DEBUG(errs() << F.getName() << '\n'); - assert(&(*I)->getFunction() == &F && + GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end(); + I--; + DEBUG(errs() << (*I)->getFunction().getName() << '\n'); + DEBUG(errs() << F.getName() << '\n'); + assert(&(*I)->getFunction() == &F && "GC Info and method do not correspond"); - GFI = *I; - } - MethodInfo* MI = + llvm::GCFunctionInfo* GFI = *I; + JITMethodInfo* MI = new(*MvmModule::Allocator, "MvmJITMethodInfo") MvmJITMethodInfo(GFI, &F); - VirtualMachine::SharedRuntimeFunctions.addMethodInfo(MI, Code, - (void*)((uintptr_t)Code + Size)); + MI->addToVM(mvm::Thread::get()->MyVM, (JIT*)MvmModule::executionEngine); } }; +void JITMethodInfo::addToVM(VirtualMachine* VM, JIT* jit) { + JITCodeEmitter* JCE = jit->getCodeEmitter(); + assert(GCInfo != NULL); + for (GCFunctionInfo::iterator I = GCInfo->begin(), E = GCInfo->end(); + I != E; + I++) { + uintptr_t address = JCE->getLabelAddress(I->Label); + assert(address != 0); + VM->FunctionsCache.addMethodInfo(this, (void*)address); + } +} + static MvmJITListener JITListener; void MvmModule::loadBytecodeFile(const std::string& str) { @@ -317,6 +328,7 @@ unconditionalSafePoint = module->getFunction("unconditionalSafePoint"); conditionalSafePoint = module->getFunction("conditionalSafePoint"); AllocateFunction = module->getFunction("gcmalloc"); + AllocateFunction->setGC("vmkit"); assert(AllocateFunction && "No allocate function"); AllocateUnresolvedFunction = module->getFunction("gcmallocUnresolved"); assert(AllocateUnresolvedFunction && "No allocateUnresolved function"); Modified: vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff ============================================================================== --- vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp (original) +++ vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp Sat Sep 11 17:33:49 2010 @@ -24,19 +24,11 @@ using namespace mvm; void CamlMethodInfo::scan(uintptr_t closure, void* ip, void* addr) { - if (!CF && InstructionPointer) { - MethodInfo* MI = VirtualMachine::SharedStaticFunctions.IPToMethodInfo(ip); - if (MI != &DefaultMethodInfo::DM) { - CF = ((CamlMethodInfo*)MI)->CF; - } - } - - if (CF) { - //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*); - uintptr_t spaddr = ((uintptr_t*)addr)[0]; - for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) { - Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure); - } + assert(CF != NULL); + //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*); + uintptr_t spaddr = ((uintptr_t*)addr)[0]; + for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) { + Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure); } } @@ -59,52 +51,6 @@ void DefaultMethodInfo::scan(uintptr_t closure, void* ip, void* addr) { } - -MethodInfo* StartFunctionMap::IPToMethodInfo(void* ip) { - FunctionMapLock.acquire(); - std::map::iterator E = Functions.end(); - std::map::iterator I = Functions.find(ip); - MethodInfo* MI = 0; - if (I == E) { - Dl_info info; - int res = dladdr(ip, &info); - if (res != 0) { - I = Functions.find(info.dli_saddr); - if (I == E) { - // The method is static, and we have no information for it. - // Just return the Default MethodInfo object. - MI = &DefaultMethodInfo::DM; - } else { - MI = I->second; - } - } else { - // The method is jitted, and no-one has intercepted its compilation. - // Just return the Default MethodInfo object. - MI = &DefaultMethodInfo::DM; - } - // Add it to the map, so that we don't need to call dladdr again. - Functions.insert(std::make_pair(ip, MI)); - } else { - MI = I->second; - } - FunctionMapLock.release(); - return MI; -} - -MethodInfo* VirtualMachine::IPToMethodInfo(void* ip) { - MethodInfo* MI = RuntimeFunctions.IPToMethodInfo(ip); - if (MI) return MI; - - MI = SharedRuntimeFunctions.IPToMethodInfo(ip); - if (MI) return MI; - - MI = StaticFunctions.IPToMethodInfo(ip); - if (MI != &DefaultMethodInfo::DM) return MI; - - MI = SharedStaticFunctions.IPToMethodInfo(ip); - return MI; -} - struct CamlFrames { uint16_t NumDescriptors; CamlFrame frames[1]; @@ -114,14 +60,11 @@ CamlFrames* frames ; uint32 currentDescriptor; CamlFrame* currentFrame; - Dl_info info; CamlFrameDecoder(CamlFrames* frames) { this->frames = frames; currentDescriptor = 0; currentFrame = &(frames->frames[0]); - int res = dladdr(currentFrame->ReturnAddress, &info); - assert(res != 0 && "No frame"); } bool hasNext() { @@ -135,55 +78,51 @@ (currentFrame->NumLiveOffsets % 2) * sizeof(uint16_t) + currentFrame->NumLiveOffsets * sizeof(uint16_t) + sizeof(void*) + sizeof(uint16_t) + sizeof(uint16_t)); - int res = dladdr(currentFrame->ReturnAddress, &info); - assert(res != 0 && "No frame"); } - CamlFrame* next(void** funcAddress, const char** funcName) { + CamlFrame* next() { assert(hasNext()); CamlFrame* result = currentFrame; - *funcAddress = info.dli_saddr; - *funcName = info.dli_sname; - - // Skip the remaining ones. - do { - advance(); - } while (hasNext() && (info.dli_saddr == *funcAddress)); - - // Skip the entries that start at another method. - while (hasNext() && (info.dli_saddr == currentFrame->ReturnAddress)) { - advance(); - } - - while (hasNext() && (info.dli_saddr == NULL)) { - advance(); - } + advance(); return result; } }; -void SharedStartFunctionMap::initialize() { +static BumpPtrAllocator* StaticAllocator = NULL; + +FunctionMap::FunctionMap() { CamlFrames* frames = (CamlFrames*)dlsym(SELF_HANDLE, "camlVmkitoptimized__frametable"); + if (frames == NULL) return; + StaticAllocator = new BumpPtrAllocator(); - const char* name = NULL; - void* address = NULL; - - if (frames != NULL) { - CamlFrameDecoder decoder(frames); - while (decoder.hasNext()) { - CamlFrame* frame = decoder.next(&address, &name); - StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo") - StaticCamlMethodInfo(frame, address, name); - addMethodInfo(MI, address); - } + CamlFrameDecoder decoder(frames); + Dl_info info; + while (decoder.hasNext()) { + CamlFrame* frame = decoder.next(); + int res = dladdr(frame->ReturnAddress, &info); + assert(res != 0 && "No frame"); + StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo") + StaticCamlMethodInfo(frame, info.dli_sname); + addMethodInfo(MI, frame->ReturnAddress); } } -CamlMethodInfo::CamlMethodInfo(CamlFrame* C, void* ip) { - InstructionPointer = ip; - CF = C; +MethodInfo* FunctionMap::IPToMethodInfo(void* ip) { + FunctionMapLock.acquire(); + std::map::iterator I = Functions.find(ip); + MethodInfo* res = NULL; + if (I != Functions.end()) { + res = I->second; + } else { + res = &DefaultMethodInfo::DM; + } + FunctionMapLock.release(); + return res; } -StartEndFunctionMap VirtualMachine::SharedRuntimeFunctions; -SharedStartFunctionMap VirtualMachine::SharedStaticFunctions; +void FunctionMap::addMethodInfo(MethodInfo* meth, void* ip) { + FunctionMapLock.acquire(); + Functions.insert(std::make_pair(ip, meth)); + FunctionMapLock.release(); +} ------------------------------ _______________________________________________ vmkit-commits mailing list vmkit-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits End of vmkit-commits Digest, Vol 28, Issue 2 ******************************************** From actong88 at gmail.com Wed Sep 15 07:37:04 2010 From: actong88 at gmail.com (Allan Tong) Date: Wed, 15 Sep 2010 10:37:04 -0400 Subject: [vmkit-commits] vmkit-commits Digest, Vol 28, Issue 2 In-Reply-To: <558356.48670.qm@web112619.mail.gq1.yahoo.com> References: <558356.48670.qm@web112619.mail.gq1.yahoo.com> Message-ID: The attached patch should fix your issue, though it was actually created to get around another problem, that being that r109973 caused the mmtk/llvm-gcc build to fail due to the use of gc_root from ForceRuntimeLinking. Alternatively you could just remove references to j3OverflowThinLock, which was removed by r111784, from LinkJavaRuntime.h - Allan On Tue, Sep 14, 2010 at 5:27 PM, Richard Corsale wrote: > Hi all, I seem to get this error when running make: > > llvm[1]: Linking Debug+Asserts executable vmjc > /media/tank/Downloads/VMKit/vmkit/Debug+Asserts/lib/libJ3.a(Jnjvm.o): In > function `ForceRuntimeLinking': > /media/tank/Downloads/VMKit/vmkit/lib/J3/VMCore/LinkJavaRuntime.h:108: undefined > reference to `j3OverflowThinLock' > collect2: ld returned 1 exit status > make[1]: *** [/media/tank/Downloads/VMKit/vmkit/Debug+Asserts/bin/vmjc] Error 1 > make[1]: Leaving directory `/media/tank/Downloads/VMKit/vmkit/tools/vmjc' > make: *** [all] Error 1 > > > I any idea what's going on? > > > > ----- Original Message ---- > From: "vmkit-commits-request at cs.uiuc.edu" > To: vmkit-commits at cs.uiuc.edu > Sent: Sun, September 12, 2010 1:00:07 PM > Subject: vmkit-commits Digest, Vol 28, Issue 2 > > Send vmkit-commits mailing list submissions to >    vmkit-commits at cs.uiuc.edu > > To subscribe or unsubscribe via the World Wide Web, visit >    http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits > or, via email, send a message with subject or body 'help' to >    vmkit-commits-request at cs.uiuc.edu > > You can reach the person managing the list at >    vmkit-commits-owner at cs.uiuc.edu > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of vmkit-commits digest..." > > > Today's Topics: > >   1. [vmkit] r113706 - in /vmkit/branches/precise: >      include/mvm/JIT.h include/mvm/MethodInfo.h >      include/mvm/VirtualMachine.h lib/J3/Compiler/JavaJITCompiler.cpp >      lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.h >      lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/JnjvmClassLoader.cpp >      lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp >      (Nicolas Geoffray) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Sat, 11 Sep 2010 22:33:49 -0000 > From: Nicolas Geoffray > Subject: [vmkit-commits] [vmkit] r113706 - in /vmkit/branches/precise: >    include/mvm/JIT.h include/mvm/MethodInfo.h >    include/mvm/VirtualMachine.h lib/J3/Compiler/JavaJITCompiler.cpp >    lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.h >    lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/JnjvmClassLoader.cpp >    lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp > To: vmkit-commits at cs.uiuc.edu > Message-ID: <20100911223349.47BDA2A6C12C at llvm.org> > Content-Type: text/plain; charset="utf-8" > > Author: geoffray > Date: Sat Sep 11 17:33:49 2010 > New Revision: 113706 > > URL: http://llvm.org/viewvc/llvm-project?rev=113706&view=rev > Log: > Have  a single function map per vm, and put exact ip information in it. > > > Modified: >    vmkit/branches/precise/include/mvm/JIT.h >    vmkit/branches/precise/include/mvm/MethodInfo.h >    vmkit/branches/precise/include/mvm/VirtualMachine.h >    vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp >    vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp >    vmkit/branches/precise/lib/J3/VMCore/JavaClass.h >    vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp >    vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp >    vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp >    vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp > > Modified: vmkit/branches/precise/include/mvm/JIT.h > URL: > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/JIT.h?rev=113706&r1=113705&r2=113706&view=diff > > ============================================================================== > --- vmkit/branches/precise/include/mvm/JIT.h (original) > +++ vmkit/branches/precise/include/mvm/JIT.h Sat Sep 11 17:33:49 2010 > @@ -30,6 +30,7 @@ >   class FunctionPassManager; >   class GCFunctionInfo; >   class GCStrategy; > +  class JIT; >   class Module; >   class PointerType; >   class TargetData; > @@ -176,15 +177,13 @@ > > > class MvmModule { > -private: > -   static llvm::ExecutionEngine* executionEngine; > - > public: >    static llvm::GCStrategy* TheGCStrategy; >    static mvm::LockRecursive protectEngine; >    static llvm::Module *globalModule; >    static const llvm::TargetData* TheTargetData; >    static mvm::BumpPtrAllocator* Allocator; > +   static llvm::ExecutionEngine* executionEngine; >    //static unsigned MetadataTypeKind; > >    static uint64 getTypeSize(const llvm::Type* type); > @@ -209,6 +208,7 @@ > public: >   virtual void scan(uintptr_t closure, void* ip, void* addr); >   JITMethodInfo(llvm::GCFunctionInfo* GFI) : GCInfo(GFI) {} > +  void addToVM(VirtualMachine* vm, llvm::JIT* jit); > }; > > class MvmJITMethodInfo : public JITMethodInfo { > > Modified: vmkit/branches/precise/include/mvm/MethodInfo.h > URL: > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/MethodInfo.h?rev=113706&r1=113705&r2=113706&view=diff > > ============================================================================== > --- vmkit/branches/precise/include/mvm/MethodInfo.h (original) > +++ vmkit/branches/precise/include/mvm/MethodInfo.h Sat Sep 11 17:33:49 2010 > @@ -29,7 +29,6 @@ >   void* getMetaInfo() const { return MetaInfo; } > >   unsigned MethodType; > -  void* InstructionPointer; >   void* MetaInfo; > }; > > @@ -45,15 +44,15 @@ > public: >   CamlFrame* CF; >   virtual void scan(uintptr_t closure, void* ip, void* addr); > -  CamlMethodInfo(CamlFrame* C, void* ip); > +  CamlMethodInfo(CamlFrame* C) : CF(C) { } > }; > > class StaticCamlMethodInfo : public CamlMethodInfo { >   const char* name; > public: >   virtual void print(void* ip, void* addr); > -  StaticCamlMethodInfo(CamlFrame* CF, void* ip, const char* n) : > -    CamlMethodInfo(CF, ip) { > +  StaticCamlMethodInfo(CamlFrame* CF, const char* n) : > +    CamlMethodInfo(CF) { >     name = n; >     MethodType = 0; >   } > > Modified: vmkit/branches/precise/include/mvm/VirtualMachine.h > URL: > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/VirtualMachine.h?rev=113706&r1=113705&r2=113706&view=diff > > ============================================================================== > --- vmkit/branches/precise/include/mvm/VirtualMachine.h (original) > +++ vmkit/branches/precise/include/mvm/VirtualMachine.h Sat Sep 11 17:33:49 2010 > @@ -48,79 +48,16 @@ > >   /// IPToMethodInfo - Map a code start instruction instruction to the > MethodInfo. >   /// > -  MethodInfo* CodeStartToMethodInfo(void* ip) { > -    FunctionMapLock.acquire(); > -    std::map::iterator I = Functions.find(ip); > -    MethodInfo* res = NULL; > -    if (I != Functions.end()) { > -      res = I->second; > -    } > -    FunctionMapLock.release(); > -    return res; > -  } > -}; > - > -/// StartEndFunctionMap - This map is for functions for which we have > -/// a start and end address. > -/// > -class StartEndFunctionMap : public FunctionMap { > -public: > -  /// addMethodInFunctionMap - A new method pointer in the function map. > -  /// > -  void addMethodInfo(MethodInfo* meth, void* start, void* end) { > -    FunctionMapLock.acquire(); > -    Functions.insert(std::make_pair(start, meth)); > -    Functions.insert(std::make_pair(end, meth)); > -    FunctionMapLock.release(); > -  } > - > -  /// IPToMethodInfo - Map an instruction pointer to the MethodInfo. > -  /// > -  MethodInfo* IPToMethodInfo(void* ip) { > -    FunctionMapLock.acquire(); > -    std::map::iterator I = Functions.upper_bound(ip); > -    MethodInfo* res = 0; > -    if (I != Functions.end() && I != Functions.begin()) { > -      res = I->second; > -      if ((--I)->second != res) res = 0; > -    } > -    FunctionMapLock.release(); > -    return res; > -  } > -}; > - > -/// StartFunctionMap - This map is for static functions where getting an end > -/// address is cumbersome. > -/// > -class StartFunctionMap : public FunctionMap { > -public: > -  /// addMethodInFunctionMap - A new method pointer in the function map. > -  /// > -  void addMethodInfo(MethodInfo* meth, void* addr) { > -    FunctionMapLock.acquire(); > -    Functions.insert(std::make_pair((void*)addr, meth)); > -    FunctionMapLock.release(); > -  } > - > -  /// IPToMethodInfo - Map an instruction pointer to the MethodInfo. > -  /// >   MethodInfo* IPToMethodInfo(void* ip); > - > -}; > > -class SharedStartFunctionMap : public StartFunctionMap { > -public: > -  BumpPtrAllocator* StaticAllocator; > -  bool initialized; > -  SharedStartFunctionMap() { > -    initialized = false; > -  } > +  /// addMethodInfo - A new instruction pointer in the function map. > +  /// > +  void addMethodInfo(MethodInfo* meth, void* ip); > > -  void initialize(); > +  FunctionMap(); > }; > > > - > // Same values than JikesRVM > #define INITIAL_QUEUE_SIZE 256 > #define GROW_FACTOR 2 > @@ -232,7 +169,6 @@ > >     mainThread = 0; >     NumberOfThreads = 0; > -    if (!SharedStaticFunctions.initialized) SharedStaticFunctions.initialize(); >   } > public: > > @@ -529,13 +465,10 @@ >   UncooperativeCollectionRV rendezvous; > #endif > > - > -  StartEndFunctionMap RuntimeFunctions; > -  static StartEndFunctionMap SharedRuntimeFunctions; > -  StartFunctionMap StaticFunctions; > -  static SharedStartFunctionMap SharedStaticFunctions; > - > -  MethodInfo* IPToMethodInfo(void* ip); > +  FunctionMap FunctionsCache; > +  MethodInfo* IPToMethodInfo(void* ip) { > +    return FunctionsCache.IPToMethodInfo(ip); > +  } > > #ifdef ISOLATE >   size_t IsolateID; > > Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp > URL: > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp?rev=113706&r1=113705&r2=113706&view=diff > > ============================================================================== > --- vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp (original) > +++ vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp Sat Sep 11 > 17:33:49 2010 > @@ -55,10 +55,16 @@ >   if (ip) new_ip = isStub(ip, addr); >   JavaMethod* meth = (JavaMethod*)MetaInfo; >   CodeLineInfo* info = meth->lookupCodeLineInfo((uintptr_t)ip); > -  fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)", > new_ip, > -          UTF8Buffer(meth->classDef->name).cString(), > -          UTF8Buffer(meth->name).cString(), info->lineNumber, > -          info->bytecodeIndex, meth->code); > +  if (info != NULL) { > +    fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)", > new_ip, > +            UTF8Buffer(meth->classDef->name).cString(), > +            UTF8Buffer(meth->name).cString(), info->lineNumber, > +            info->bytecodeIndex, meth->code); > +  } else { > +    fprintf(stderr, "; %p in %s.%s (native method, code start %p)", new_ip, > +            UTF8Buffer(meth->classDef->name).cString(), > +            UTF8Buffer(meth->name).cString(), meth->code); > +  } >   if (ip != new_ip) fprintf(stderr, " (from stub)"); >   fprintf(stderr, "\n"); > } > @@ -71,41 +77,39 @@ >   // The following could be changed to an assert when -load-bc supports >   // the verifier. >   if (F.getParent() != TheCompiler->getLLVMModule()) return; > +  assert(F.hasGC()); > >   Jnjvm* vm = JavaThread::get()->getJVM(); >   mvm::BumpPtrAllocator& Alloc = TheCompiler->allocator; > -  llvm::GCFunctionInfo* GFI = 0; > > -  if (F.hasGC()) { > -    if (TheCompiler->TheGCStrategy == NULL) { > -      assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy"); > -      TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy; > -      mvm::MvmModule::TheGCStrategy = NULL; > -    } > -    GCStrategy::iterator I = TheCompiler->TheGCStrategy->end(); > +  // Fetch the GCStrategy if it wasn't created before. > +  if (TheCompiler->TheGCStrategy == NULL) { > +    assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy"); > +    TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy; > +    mvm::MvmModule::TheGCStrategy = NULL; > +  } > + > +  GCStrategy::iterator I = TheCompiler->TheGCStrategy->end(); > +  I--; > +  while (&(*I)->getFunction() != &F) { > +    // This happens when the compilation of a function was post-poned. > +    assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info"); >     I--; > -    while (&(*I)->getFunction() != &F) { > -      // This happens when the compilation of a function was post-poned. > -      assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info"); > -      I--; > -    } > -    assert(&(*I)->getFunction() == &F && > -        "GC Info and method do not correspond"); > -    GFI = *I; >   } > +  assert(&(*I)->getFunction() == &F && "GC Info and method do not correspond"); > +  llvm::GCFunctionInfo* GFI = *I; > >   JavaMethod* meth = TheCompiler->getJavaMethod(F); > +  mvm::JITMethodInfo* MI = NULL; >   if (meth == NULL) { >     // This is a stub. > -    mvm::MvmJITMethodInfo* MI = new(Alloc, "JITMethodInfo") > -      mvm::MvmJITMethodInfo(GFI, &F); > -    vm->RuntimeFunctions.addMethodInfo(MI, Code, > -                                       (void*)((uintptr_t)Code + Size)); > +    MI = new(Alloc, "JITMethodInfo") mvm::MvmJITMethodInfo(GFI, &F); >   } else { > -    JavaJITMethodInfo* MI = new(Alloc, "JavaJITMethodInfo") > -      JavaJITMethodInfo(GFI, meth); > -    vm->RuntimeFunctions.addMethodInfo(MI, Code, > -                                       (void*)((uintptr_t)Code + Size)); > +    MI = new(Alloc, "JavaJITMethodInfo") JavaJITMethodInfo(GFI, meth); > +  } > +  MI->addToVM(vm, (JIT*)TheCompiler->executionEngine); > + > +  if (meth != NULL) { >     uint32 infoLength = Details.LineStarts.size(); >     meth->codeInfoLength = infoLength; >     if (infoLength > 0) { > > Modified: vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp > URL: > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff > > ============================================================================== > --- vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp (original) > +++ vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp Sat Sep 11 17:33:49 2010 > @@ -169,9 +169,7 @@ >                                         "", Compiler->getLLVMModule()); >     } > > -    if (Compiler->useCooperativeGC()) { > -      methodFunction->setGC("vmkit"); > -    } > +    methodFunction->setGC("vmkit"); > >     Compiler->functions.insert(std::make_pair(methodFunction, methodDef)); >     if (Compiler != JCL->getCompiler() && methodDef->code) { > @@ -404,10 +402,13 @@ > >   Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", >                                 currentBlock); > -  if (!signature->getReturnType()->isVoid()) > +  if (!signature->getReturnType()->isVoid()) { >     ReturnInst::Create(context, val, currentBlock); > -  else > +  } else { >     ReturnInst::Create(context, currentBlock); > +  } > + > +  res->setGC("vmkit"); > >   return res; > } > @@ -481,15 +482,14 @@ > >   Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", >                                 currentBlock); > -  if (!signature->getReturnType()->isVoid()) > +  if (!signature->getReturnType()->isVoid()) { >     ReturnInst::Create(context, val, currentBlock); > -  else > +  } else { >     ReturnInst::Create(context, currentBlock); > - > -  if (Compiler->useCooperativeGC()) { > -    res->setGC("vmkit"); >   } > > +  res->setGC("vmkit"); > + >   return res; > } > > @@ -545,7 +545,7 @@ >   if (virt) { >     if (Compiler->useCooperativeGC()) { >       Args.push_back(new LoadInst(TempArgs[0], "", false, currentBlock)); > -    }else { > +    } else { >       Args.push_back(TempArgs[0]); >     } >   } > @@ -587,9 +587,7 @@ >     ReturnInst::Create(context, currentBlock); >   } > > -  if (Compiler->useCooperativeGC()) { > -    stub->setGC("vmkit"); > -  } > +  stub->setGC("vmkit"); > >   return stub; > } > > Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.h > URL: > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.h?rev=113706&r1=113705&r2=113706&view=diff > > ============================================================================== > --- vmkit/branches/precise/lib/J3/VMCore/JavaClass.h (original) > +++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.h Sat Sep 11 17:33:49 2010 > @@ -902,7 +902,7 @@ >   virtual void print(void* ip, void* addr); > >   JavaStaticMethodInfo(mvm::CamlMethodInfo* super, void* ip, JavaMethod* M) : > -    mvm::CamlMethodInfo(super != NULL ? super->CF : NULL, ip) { > +    mvm::CamlMethodInfo(super->CF) { >     MetaInfo = M; >     MethodType = 1; >   } > > Modified: vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp > URL: > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp?rev=113706&r1=113705&r2=113706&view=diff > > ============================================================================== > --- vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp (original) > +++ vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp Sat Sep 11 17:33:49 2010 > @@ -1487,8 +1487,7 @@ > } > > void Jnjvm::removeMethodsInFunctionMaps(JnjvmClassLoader* loader) { > -  internalRemoveMethods(loader, RuntimeFunctions); > -  internalRemoveMethods(loader, StaticFunctions); > +  internalRemoveMethods(loader, FunctionsCache); > } > > > > Modified: vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp > URL: > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=113706&r1=113705&r2=113706&view=diff > > ============================================================================== > --- vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp (original) > +++ vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp Sat Sep 11 > 17:33:49 2010 > @@ -1073,7 +1073,7 @@ >         if (!isAbstract(meth.access) && meth.code) { >           JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo") >             JavaStaticMethodInfo(0, meth.code, &meth); > -          vm->StaticFunctions.addMethodInfo(MI, meth.code); > +          vm->FunctionsCache.addMethodInfo(MI, meth.code); >         } >       } > > @@ -1082,7 +1082,7 @@ >         if (!isAbstract(meth.access) && meth.code) { >           JavaStaticMethodInfo* MI = new (allocator, "JavaStaticMethodInfo") >             JavaStaticMethodInfo(0, meth.code, &meth); > -          vm->StaticFunctions.addMethodInfo(MI, meth.code); > +          vm->FunctionsCache.addMethodInfo(MI, meth.code); >         } >       } >     } > > Modified: vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp > URL: > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp?rev=113706&r1=113705&r2=113706&view=diff > > ============================================================================== > --- vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp (original) > +++ vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp Sat Sep 11 17:33:49 2010 > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > #include > #include > #include "llvm/ExecutionEngine/JITEventListener.h" > @@ -35,6 +36,7 @@ > #include > #include > #include > +#include <../lib/ExecutionEngine/JIT/JIT.h> > > #include "mvm/JIT.h" > #include "mvm/Threads/Locks.h" > @@ -93,24 +95,33 @@ >                                      void *Code, size_t Size, >                                      const EmittedFunctionDetails &Details) { >     assert(F.getParent() == MvmModule::globalModule); > -    llvm::GCFunctionInfo* GFI = 0; > +    assert(F.hasGC()); >     // We know the last GC info is for this method. > -    if (F.hasGC()) { > -      GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end(); > -      I--; > -      DEBUG(errs() << (*I)->getFunction().getName() << '\n'); > -      DEBUG(errs() << F.getName() << '\n'); > -      assert(&(*I)->getFunction() == &F && > +    GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end(); > +    I--; > +    DEBUG(errs() << (*I)->getFunction().getName() << '\n'); > +    DEBUG(errs() << F.getName() << '\n'); > +    assert(&(*I)->getFunction() == &F && >         "GC Info and method do not correspond"); > -      GFI = *I; > -    } > -    MethodInfo* MI = > +    llvm::GCFunctionInfo* GFI = *I; > +    JITMethodInfo* MI = >       new(*MvmModule::Allocator, "MvmJITMethodInfo") MvmJITMethodInfo(GFI, &F); > -    VirtualMachine::SharedRuntimeFunctions.addMethodInfo(MI, Code, > -                                            (void*)((uintptr_t)Code + Size)); > +    MI->addToVM(mvm::Thread::get()->MyVM, (JIT*)MvmModule::executionEngine); >   } > }; > > +void JITMethodInfo::addToVM(VirtualMachine* VM, JIT* jit) { > +  JITCodeEmitter* JCE = jit->getCodeEmitter(); > +  assert(GCInfo != NULL); > +  for (GCFunctionInfo::iterator I = GCInfo->begin(), E = GCInfo->end(); > +       I != E; > +       I++) { > +    uintptr_t address = JCE->getLabelAddress(I->Label); > +    assert(address != 0); > +    VM->FunctionsCache.addMethodInfo(this, (void*)address); > +  } > +} > + > static MvmJITListener JITListener; > > void MvmModule::loadBytecodeFile(const std::string& str) { > @@ -317,6 +328,7 @@ >   unconditionalSafePoint = module->getFunction("unconditionalSafePoint"); >   conditionalSafePoint = module->getFunction("conditionalSafePoint"); >   AllocateFunction = module->getFunction("gcmalloc"); > +  AllocateFunction->setGC("vmkit"); >   assert(AllocateFunction && "No allocate function"); >   AllocateUnresolvedFunction = module->getFunction("gcmallocUnresolved"); >   assert(AllocateUnresolvedFunction && "No allocateUnresolved function"); > > Modified: vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp > URL: > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff > > ============================================================================== > --- vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp (original) > +++ vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp Sat Sep 11 17:33:49 > 2010 > @@ -24,19 +24,11 @@ > using namespace mvm; > > void CamlMethodInfo::scan(uintptr_t closure, void* ip, void* addr) { > -  if (!CF && InstructionPointer) { > -    MethodInfo* MI = VirtualMachine::SharedStaticFunctions.IPToMethodInfo(ip); > -    if (MI != &DefaultMethodInfo::DM) { > -      CF = ((CamlMethodInfo*)MI)->CF; > -    } > -  } > - > -  if (CF) { > -    //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*); > -    uintptr_t spaddr = ((uintptr_t*)addr)[0]; > -    for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) { > -      Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure); > -    } > +  assert(CF != NULL); > +  //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*); > +  uintptr_t spaddr = ((uintptr_t*)addr)[0]; > +  for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) { > +    Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), closure); >   } > } > > @@ -59,52 +51,6 @@ > void DefaultMethodInfo::scan(uintptr_t closure, void* ip, void* addr) { > } > > - > -MethodInfo* StartFunctionMap::IPToMethodInfo(void* ip) { > -  FunctionMapLock.acquire(); > -  std::map::iterator E = Functions.end(); > -  std::map::iterator I = Functions.find(ip); > -  MethodInfo* MI = 0; > -  if (I == E) { > -    Dl_info info; > -    int res = dladdr(ip, &info); > -    if (res != 0) { > -      I = Functions.find(info.dli_saddr); > -      if (I == E) { > -        // The method is static, and we have no information for it. > -        // Just return the Default MethodInfo object. > -        MI = &DefaultMethodInfo::DM; > -      } else { > -        MI = I->second; > -      } > -    } else { > -      // The method is jitted, and no-one has intercepted its compilation. > -      // Just return the Default MethodInfo object. > -      MI = &DefaultMethodInfo::DM; > -    } > -    // Add it to the map, so that we don't need to call dladdr again. > -    Functions.insert(std::make_pair(ip, MI)); > -  } else { > -    MI = I->second; > -  } > -  FunctionMapLock.release(); > -  return MI; > -} > - > -MethodInfo* VirtualMachine::IPToMethodInfo(void* ip) { > -  MethodInfo* MI = RuntimeFunctions.IPToMethodInfo(ip); > -  if (MI) return MI; > - > -  MI = SharedRuntimeFunctions.IPToMethodInfo(ip); > -  if (MI) return MI; > - > -  MI = StaticFunctions.IPToMethodInfo(ip); > -  if (MI != &DefaultMethodInfo::DM) return MI; > - > -  MI = SharedStaticFunctions.IPToMethodInfo(ip); > -  return MI; > -} > - > struct CamlFrames { >   uint16_t NumDescriptors; >   CamlFrame frames[1]; > @@ -114,14 +60,11 @@ >   CamlFrames* frames ; >   uint32 currentDescriptor; >   CamlFrame* currentFrame; > -  Dl_info info; > >   CamlFrameDecoder(CamlFrames* frames) { >     this->frames = frames; >     currentDescriptor = 0; >     currentFrame = &(frames->frames[0]); > -    int res = dladdr(currentFrame->ReturnAddress, &info); > -    assert(res != 0 && "No frame"); >   } > >   bool hasNext() { > @@ -135,55 +78,51 @@ >       (currentFrame->NumLiveOffsets % 2) * sizeof(uint16_t) + >       currentFrame->NumLiveOffsets * sizeof(uint16_t) + >       sizeof(void*) + sizeof(uint16_t) + sizeof(uint16_t)); > -    int res = dladdr(currentFrame->ReturnAddress, &info); > -    assert(res != 0 && "No frame"); >   } > > -  CamlFrame* next(void** funcAddress, const char** funcName) { > +  CamlFrame* next() { >     assert(hasNext()); >     CamlFrame* result = currentFrame; > -    *funcAddress = info.dli_saddr; > -    *funcName = info.dli_sname; > - > -    // Skip the remaining ones. > -    do { > -      advance(); > -    } while (hasNext() && (info.dli_saddr == *funcAddress)); > - > -    // Skip the entries that start at another method. > -    while (hasNext() && (info.dli_saddr == currentFrame->ReturnAddress)) { > -      advance(); > -    } > - > -    while (hasNext() && (info.dli_saddr == NULL)) { > -      advance(); > -    } > +    advance(); >     return result; >   } > }; > > -void SharedStartFunctionMap::initialize() { > +static BumpPtrAllocator* StaticAllocator = NULL; > + > +FunctionMap::FunctionMap() { >   CamlFrames* frames = >     (CamlFrames*)dlsym(SELF_HANDLE, "camlVmkitoptimized__frametable"); > +  if (frames == NULL) return; > + >   StaticAllocator = new BumpPtrAllocator(); > -  const char* name = NULL; > -  void* address = NULL; > - > -  if (frames != NULL) { > -    CamlFrameDecoder decoder(frames); > -    while (decoder.hasNext()) { > -      CamlFrame* frame = decoder.next(&address, &name); > -      StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo") > -          StaticCamlMethodInfo(frame, address, name); > -      addMethodInfo(MI, address); > -    } > +  CamlFrameDecoder decoder(frames); > +  Dl_info info; > +  while (decoder.hasNext()) { > +    CamlFrame* frame = decoder.next(); > +    int res = dladdr(frame->ReturnAddress, &info); > +    assert(res != 0 && "No frame"); > +    StaticCamlMethodInfo* MI = new(*StaticAllocator, "StaticCamlMethodInfo") > +        StaticCamlMethodInfo(frame, info.dli_sname); > +    addMethodInfo(MI, frame->ReturnAddress); >   } > } > > -CamlMethodInfo::CamlMethodInfo(CamlFrame* C, void* ip) { > -  InstructionPointer = ip; > -  CF = C; > +MethodInfo* FunctionMap::IPToMethodInfo(void* ip) { > +  FunctionMapLock.acquire(); > +  std::map::iterator I = Functions.find(ip); > +  MethodInfo* res = NULL; > +  if (I != Functions.end()) { > +    res = I->second; > +  } else { > +    res = &DefaultMethodInfo::DM; > +  } > +  FunctionMapLock.release(); > +  return res; > } > > -StartEndFunctionMap VirtualMachine::SharedRuntimeFunctions; > -SharedStartFunctionMap VirtualMachine::SharedStaticFunctions; > +void FunctionMap::addMethodInfo(MethodInfo* meth, void* ip) { > +  FunctionMapLock.acquire(); > +  Functions.insert(std::make_pair(ip, meth)); > +  FunctionMapLock.release(); > +} > > > > > ------------------------------ > > _______________________________________________ > vmkit-commits mailing list > vmkit-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits > > > End of vmkit-commits Digest, Vol 28, Issue 2 > ******************************************** > > > > > _______________________________________________ > vmkit-commits mailing list > vmkit-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits > -------------- next part -------------- A non-text attachment was scrubbed... Name: linkjavaruntime.patch Type: application/octet-stream Size: 17018 bytes Desc: not available URL: From nicolas.geoffray at lip6.fr Thu Sep 16 12:45:34 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 16 Sep 2010 19:45:34 -0000 Subject: [vmkit-commits] [vmkit] r114108 - /vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h Message-ID: <20100916194534.C47DC2A6C12C@llvm.org> Author: geoffray Date: Thu Sep 16 14:45:34 2010 New Revision: 114108 URL: http://llvm.org/viewvc/llvm-project?rev=114108&view=rev Log: j3OverflowThinlock does not exist anymore. Modified: vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h Modified: vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h?rev=114108&r1=114107&r2=114108&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h (original) +++ vmkit/trunk/lib/J3/VMCore/LinkJavaRuntime.h Thu Sep 16 14:45:34 2010 @@ -45,7 +45,6 @@ extern "C" void j3JavaObjectAquire(JavaObject* obj); extern "C" void j3JavaObjectRelease(JavaObject* obj); extern "C" void j3ThrowException(JavaObject* obj); -extern "C" void j3OverflowThinLock(JavaObject* obj); extern "C" JavaObject* j3NullPointerException(); extern "C" JavaObject* j3NegativeArraySizeException(sint32 val); extern "C" JavaObject* j3OutOfMemoryError(sint32 val); @@ -105,7 +104,6 @@ (void) j3JavaObjectAquire(0); (void) j3JavaObjectRelease(0); (void) j3ThrowException(0); - (void) j3OverflowThinLock(0); (void) j3NullPointerException(); (void) j3NegativeArraySizeException(0); (void) j3OutOfMemoryError(0); From nicolas.geoffray at gmail.com Thu Sep 16 12:46:52 2010 From: nicolas.geoffray at gmail.com (nicolas geoffray) Date: Thu, 16 Sep 2010 21:46:52 +0200 Subject: [vmkit-commits] vmkit-commits Digest, Vol 28, Issue 2 In-Reply-To: References: <558356.48670.qm@web112619.mail.gq1.yahoo.com> Message-ID: Hi Richard, This should be fixed in latest svn. Thanks for reporting! Cheers, Nicolas On Wed, Sep 15, 2010 at 4:37 PM, Allan Tong wrote: > The attached patch should fix your issue, though it was actually > created to get around another problem, that being that r109973 caused > the mmtk/llvm-gcc build to fail due to the use of gc_root from > ForceRuntimeLinking. > > Alternatively you could just remove references to j3OverflowThinLock, > which was removed by r111784, from LinkJavaRuntime.h > > - Allan > > On Tue, Sep 14, 2010 at 5:27 PM, Richard Corsale wrote: > > Hi all, I seem to get this error when running make: > > > > llvm[1]: Linking Debug+Asserts executable vmjc > > /media/tank/Downloads/VMKit/vmkit/Debug+Asserts/lib/libJ3.a(Jnjvm.o): In > > function `ForceRuntimeLinking': > > /media/tank/Downloads/VMKit/vmkit/lib/J3/VMCore/LinkJavaRuntime.h:108: > undefined > > reference to `j3OverflowThinLock' > > collect2: ld returned 1 exit status > > make[1]: *** [/media/tank/Downloads/VMKit/vmkit/Debug+Asserts/bin/vmjc] > Error 1 > > make[1]: Leaving directory `/media/tank/Downloads/VMKit/vmkit/tools/vmjc' > > make: *** [all] Error 1 > > > > > > I any idea what's going on? > > > > > > > > ----- Original Message ---- > > From: "vmkit-commits-request at cs.uiuc.edu" < > vmkit-commits-request at cs.uiuc.edu> > > To: vmkit-commits at cs.uiuc.edu > > Sent: Sun, September 12, 2010 1:00:07 PM > > Subject: vmkit-commits Digest, Vol 28, Issue 2 > > > > Send vmkit-commits mailing list submissions to > > vmkit-commits at cs.uiuc.edu > > > > To subscribe or unsubscribe via the World Wide Web, visit > > http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits > > or, via email, send a message with subject or body 'help' to > > vmkit-commits-request at cs.uiuc.edu > > > > You can reach the person managing the list at > > vmkit-commits-owner at cs.uiuc.edu > > > > When replying, please edit your Subject line so it is more specific > > than "Re: Contents of vmkit-commits digest..." > > > > > > Today's Topics: > > > > 1. [vmkit] r113706 - in /vmkit/branches/precise: > > include/mvm/JIT.h include/mvm/MethodInfo.h > > include/mvm/VirtualMachine.h lib/J3/Compiler/JavaJITCompiler.cpp > > lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.h > > lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/JnjvmClassLoader.cpp > > lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp > > (Nicolas Geoffray) > > > > > > ---------------------------------------------------------------------- > > > > Message: 1 > > Date: Sat, 11 Sep 2010 22:33:49 -0000 > > From: Nicolas Geoffray > > Subject: [vmkit-commits] [vmkit] r113706 - in /vmkit/branches/precise: > > include/mvm/JIT.h include/mvm/MethodInfo.h > > include/mvm/VirtualMachine.h lib/J3/Compiler/JavaJITCompiler.cpp > > lib/J3/Compiler/LLVMInfo.cpp lib/J3/VMCore/JavaClass.h > > lib/J3/VMCore/Jnjvm.cpp lib/J3/VMCore/JnjvmClassLoader.cpp > > lib/Mvm/Compiler/JIT.cpp lib/Mvm/Runtime/MethodInfo.cpp > > To: vmkit-commits at cs.uiuc.edu > > Message-ID: <20100911223349.47BDA2A6C12C at llvm.org> > > Content-Type: text/plain; charset="utf-8" > > > > Author: geoffray > > Date: Sat Sep 11 17:33:49 2010 > > New Revision: 113706 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=113706&view=rev > > Log: > > Have a single function map per vm, and put exact ip information in it. > > > > > > Modified: > > vmkit/branches/precise/include/mvm/JIT.h > > vmkit/branches/precise/include/mvm/MethodInfo.h > > vmkit/branches/precise/include/mvm/VirtualMachine.h > > vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp > > vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp > > vmkit/branches/precise/lib/J3/VMCore/JavaClass.h > > vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp > > vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp > > vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp > > vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp > > > > Modified: vmkit/branches/precise/include/mvm/JIT.h > > URL: > > > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/JIT.h?rev=113706&r1=113705&r2=113706&view=diff > > > > > ============================================================================== > > --- vmkit/branches/precise/include/mvm/JIT.h (original) > > +++ vmkit/branches/precise/include/mvm/JIT.h Sat Sep 11 17:33:49 2010 > > @@ -30,6 +30,7 @@ > > class FunctionPassManager; > > class GCFunctionInfo; > > class GCStrategy; > > + class JIT; > > class Module; > > class PointerType; > > class TargetData; > > @@ -176,15 +177,13 @@ > > > > > > class MvmModule { > > -private: > > - static llvm::ExecutionEngine* executionEngine; > > - > > public: > > static llvm::GCStrategy* TheGCStrategy; > > static mvm::LockRecursive protectEngine; > > static llvm::Module *globalModule; > > static const llvm::TargetData* TheTargetData; > > static mvm::BumpPtrAllocator* Allocator; > > + static llvm::ExecutionEngine* executionEngine; > > //static unsigned MetadataTypeKind; > > > > static uint64 getTypeSize(const llvm::Type* type); > > @@ -209,6 +208,7 @@ > > public: > > virtual void scan(uintptr_t closure, void* ip, void* addr); > > JITMethodInfo(llvm::GCFunctionInfo* GFI) : GCInfo(GFI) {} > > + void addToVM(VirtualMachine* vm, llvm::JIT* jit); > > }; > > > > class MvmJITMethodInfo : public JITMethodInfo { > > > > Modified: vmkit/branches/precise/include/mvm/MethodInfo.h > > URL: > > > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/MethodInfo.h?rev=113706&r1=113705&r2=113706&view=diff > > > > > ============================================================================== > > --- vmkit/branches/precise/include/mvm/MethodInfo.h (original) > > +++ vmkit/branches/precise/include/mvm/MethodInfo.h Sat Sep 11 17:33:49 > 2010 > > @@ -29,7 +29,6 @@ > > void* getMetaInfo() const { return MetaInfo; } > > > > unsigned MethodType; > > - void* InstructionPointer; > > void* MetaInfo; > > }; > > > > @@ -45,15 +44,15 @@ > > public: > > CamlFrame* CF; > > virtual void scan(uintptr_t closure, void* ip, void* addr); > > - CamlMethodInfo(CamlFrame* C, void* ip); > > + CamlMethodInfo(CamlFrame* C) : CF(C) { } > > }; > > > > class StaticCamlMethodInfo : public CamlMethodInfo { > > const char* name; > > public: > > virtual void print(void* ip, void* addr); > > - StaticCamlMethodInfo(CamlFrame* CF, void* ip, const char* n) : > > - CamlMethodInfo(CF, ip) { > > + StaticCamlMethodInfo(CamlFrame* CF, const char* n) : > > + CamlMethodInfo(CF) { > > name = n; > > MethodType = 0; > > } > > > > Modified: vmkit/branches/precise/include/mvm/VirtualMachine.h > > URL: > > > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/include/mvm/VirtualMachine.h?rev=113706&r1=113705&r2=113706&view=diff > > > > > ============================================================================== > > --- vmkit/branches/precise/include/mvm/VirtualMachine.h (original) > > +++ vmkit/branches/precise/include/mvm/VirtualMachine.h Sat Sep 11 > 17:33:49 2010 > > @@ -48,79 +48,16 @@ > > > > /// IPToMethodInfo - Map a code start instruction instruction to the > > MethodInfo. > > /// > > - MethodInfo* CodeStartToMethodInfo(void* ip) { > > - FunctionMapLock.acquire(); > > - std::map::iterator I = Functions.find(ip); > > - MethodInfo* res = NULL; > > - if (I != Functions.end()) { > > - res = I->second; > > - } > > - FunctionMapLock.release(); > > - return res; > > - } > > -}; > > - > > -/// StartEndFunctionMap - This map is for functions for which we have > > -/// a start and end address. > > -/// > > -class StartEndFunctionMap : public FunctionMap { > > -public: > > - /// addMethodInFunctionMap - A new method pointer in the function map. > > - /// > > - void addMethodInfo(MethodInfo* meth, void* start, void* end) { > > - FunctionMapLock.acquire(); > > - Functions.insert(std::make_pair(start, meth)); > > - Functions.insert(std::make_pair(end, meth)); > > - FunctionMapLock.release(); > > - } > > - > > - /// IPToMethodInfo - Map an instruction pointer to the MethodInfo. > > - /// > > - MethodInfo* IPToMethodInfo(void* ip) { > > - FunctionMapLock.acquire(); > > - std::map::iterator I = > Functions.upper_bound(ip); > > - MethodInfo* res = 0; > > - if (I != Functions.end() && I != Functions.begin()) { > > - res = I->second; > > - if ((--I)->second != res) res = 0; > > - } > > - FunctionMapLock.release(); > > - return res; > > - } > > -}; > > - > > -/// StartFunctionMap - This map is for static functions where getting an > end > > -/// address is cumbersome. > > -/// > > -class StartFunctionMap : public FunctionMap { > > -public: > > - /// addMethodInFunctionMap - A new method pointer in the function map. > > - /// > > - void addMethodInfo(MethodInfo* meth, void* addr) { > > - FunctionMapLock.acquire(); > > - Functions.insert(std::make_pair((void*)addr, meth)); > > - FunctionMapLock.release(); > > - } > > - > > - /// IPToMethodInfo - Map an instruction pointer to the MethodInfo. > > - /// > > MethodInfo* IPToMethodInfo(void* ip); > > - > > -}; > > > > -class SharedStartFunctionMap : public StartFunctionMap { > > -public: > > - BumpPtrAllocator* StaticAllocator; > > - bool initialized; > > - SharedStartFunctionMap() { > > - initialized = false; > > - } > > + /// addMethodInfo - A new instruction pointer in the function map. > > + /// > > + void addMethodInfo(MethodInfo* meth, void* ip); > > > > - void initialize(); > > + FunctionMap(); > > }; > > > > > > - > > // Same values than JikesRVM > > #define INITIAL_QUEUE_SIZE 256 > > #define GROW_FACTOR 2 > > @@ -232,7 +169,6 @@ > > > > mainThread = 0; > > NumberOfThreads = 0; > > - if (!SharedStaticFunctions.initialized) > SharedStaticFunctions.initialize(); > > } > > public: > > > > @@ -529,13 +465,10 @@ > > UncooperativeCollectionRV rendezvous; > > #endif > > > > - > > - StartEndFunctionMap RuntimeFunctions; > > - static StartEndFunctionMap SharedRuntimeFunctions; > > - StartFunctionMap StaticFunctions; > > - static SharedStartFunctionMap SharedStaticFunctions; > > - > > - MethodInfo* IPToMethodInfo(void* ip); > > + FunctionMap FunctionsCache; > > + MethodInfo* IPToMethodInfo(void* ip) { > > + return FunctionsCache.IPToMethodInfo(ip); > > + } > > > > #ifdef ISOLATE > > size_t IsolateID; > > > > Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp > > URL: > > > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp?rev=113706&r1=113705&r2=113706&view=diff > > > > > ============================================================================== > > --- vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp (original) > > +++ vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp Sat Sep 11 > > 17:33:49 2010 > > @@ -55,10 +55,16 @@ > > if (ip) new_ip = isStub(ip, addr); > > JavaMethod* meth = (JavaMethod*)MetaInfo; > > CodeLineInfo* info = meth->lookupCodeLineInfo((uintptr_t)ip); > > - fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)", > > new_ip, > > - UTF8Buffer(meth->classDef->name).cString(), > > - UTF8Buffer(meth->name).cString(), info->lineNumber, > > - info->bytecodeIndex, meth->code); > > + if (info != NULL) { > > + fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start > %p)", > > new_ip, > > + UTF8Buffer(meth->classDef->name).cString(), > > + UTF8Buffer(meth->name).cString(), info->lineNumber, > > + info->bytecodeIndex, meth->code); > > + } else { > > + fprintf(stderr, "; %p in %s.%s (native method, code start %p)", > new_ip, > > + UTF8Buffer(meth->classDef->name).cString(), > > + UTF8Buffer(meth->name).cString(), meth->code); > > + } > > if (ip != new_ip) fprintf(stderr, " (from stub)"); > > fprintf(stderr, "\n"); > > } > > @@ -71,41 +77,39 @@ > > // The following could be changed to an assert when -load-bc supports > > // the verifier. > > if (F.getParent() != TheCompiler->getLLVMModule()) return; > > + assert(F.hasGC()); > > > > Jnjvm* vm = JavaThread::get()->getJVM(); > > mvm::BumpPtrAllocator& Alloc = TheCompiler->allocator; > > - llvm::GCFunctionInfo* GFI = 0; > > > > - if (F.hasGC()) { > > - if (TheCompiler->TheGCStrategy == NULL) { > > - assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy"); > > - TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy; > > - mvm::MvmModule::TheGCStrategy = NULL; > > - } > > - GCStrategy::iterator I = TheCompiler->TheGCStrategy->end(); > > + // Fetch the GCStrategy if it wasn't created before. > > + if (TheCompiler->TheGCStrategy == NULL) { > > + assert(mvm::MvmModule::TheGCStrategy != NULL && "No GC strategy"); > > + TheCompiler->TheGCStrategy = mvm::MvmModule::TheGCStrategy; > > + mvm::MvmModule::TheGCStrategy = NULL; > > + } > > + > > + GCStrategy::iterator I = TheCompiler->TheGCStrategy->end(); > > + I--; > > + while (&(*I)->getFunction() != &F) { > > + // This happens when the compilation of a function was post-poned. > > + assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info"); > > I--; > > - while (&(*I)->getFunction() != &F) { > > - // This happens when the compilation of a function was post-poned. > > - assert(I != TheCompiler->TheGCStrategy->begin() && "No GC info"); > > - I--; > > - } > > - assert(&(*I)->getFunction() == &F && > > - "GC Info and method do not correspond"); > > - GFI = *I; > > } > > + assert(&(*I)->getFunction() == &F && "GC Info and method do not > correspond"); > > + llvm::GCFunctionInfo* GFI = *I; > > > > JavaMethod* meth = TheCompiler->getJavaMethod(F); > > + mvm::JITMethodInfo* MI = NULL; > > if (meth == NULL) { > > // This is a stub. > > - mvm::MvmJITMethodInfo* MI = new(Alloc, "JITMethodInfo") > > - mvm::MvmJITMethodInfo(GFI, &F); > > - vm->RuntimeFunctions.addMethodInfo(MI, Code, > > - (void*)((uintptr_t)Code + Size)); > > + MI = new(Alloc, "JITMethodInfo") mvm::MvmJITMethodInfo(GFI, &F); > > } else { > > - JavaJITMethodInfo* MI = new(Alloc, "JavaJITMethodInfo") > > - JavaJITMethodInfo(GFI, meth); > > - vm->RuntimeFunctions.addMethodInfo(MI, Code, > > - (void*)((uintptr_t)Code + Size)); > > + MI = new(Alloc, "JavaJITMethodInfo") JavaJITMethodInfo(GFI, meth); > > + } > > + MI->addToVM(vm, (JIT*)TheCompiler->executionEngine); > > + > > + if (meth != NULL) { > > uint32 infoLength = Details.LineStarts.size(); > > meth->codeInfoLength = infoLength; > > if (infoLength > 0) { > > > > Modified: vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp > > URL: > > > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff > > > > > ============================================================================== > > --- vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp (original) > > +++ vmkit/branches/precise/lib/J3/Compiler/LLVMInfo.cpp Sat Sep 11 > 17:33:49 2010 > > @@ -169,9 +169,7 @@ > > "", Compiler->getLLVMModule()); > > } > > > > - if (Compiler->useCooperativeGC()) { > > - methodFunction->setGC("vmkit"); > > - } > > + methodFunction->setGC("vmkit"); > > > > Compiler->functions.insert(std::make_pair(methodFunction, > methodDef)); > > if (Compiler != JCL->getCompiler() && methodDef->code) { > > @@ -404,10 +402,13 @@ > > > > Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", > > currentBlock); > > - if (!signature->getReturnType()->isVoid()) > > + if (!signature->getReturnType()->isVoid()) { > > ReturnInst::Create(context, val, currentBlock); > > - else > > + } else { > > ReturnInst::Create(context, currentBlock); > > + } > > + > > + res->setGC("vmkit"); > > > > return res; > > } > > @@ -481,15 +482,14 @@ > > > > Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", > > currentBlock); > > - if (!signature->getReturnType()->isVoid()) > > + if (!signature->getReturnType()->isVoid()) { > > ReturnInst::Create(context, val, currentBlock); > > - else > > + } else { > > ReturnInst::Create(context, currentBlock); > > - > > - if (Compiler->useCooperativeGC()) { > > - res->setGC("vmkit"); > > } > > > > + res->setGC("vmkit"); > > + > > return res; > > } > > > > @@ -545,7 +545,7 @@ > > if (virt) { > > if (Compiler->useCooperativeGC()) { > > Args.push_back(new LoadInst(TempArgs[0], "", false, currentBlock)); > > - }else { > > + } else { > > Args.push_back(TempArgs[0]); > > } > > } > > @@ -587,9 +587,7 @@ > > ReturnInst::Create(context, currentBlock); > > } > > > > - if (Compiler->useCooperativeGC()) { > > - stub->setGC("vmkit"); > > - } > > + stub->setGC("vmkit"); > > > > return stub; > > } > > > > Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.h > > URL: > > > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.h?rev=113706&r1=113705&r2=113706&view=diff > > > > > ============================================================================== > > --- vmkit/branches/precise/lib/J3/VMCore/JavaClass.h (original) > > +++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.h Sat Sep 11 17:33:49 > 2010 > > @@ -902,7 +902,7 @@ > > virtual void print(void* ip, void* addr); > > > > JavaStaticMethodInfo(mvm::CamlMethodInfo* super, void* ip, JavaMethod* > M) : > > - mvm::CamlMethodInfo(super != NULL ? super->CF : NULL, ip) { > > + mvm::CamlMethodInfo(super->CF) { > > MetaInfo = M; > > MethodType = 1; > > } > > > > Modified: vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp > > URL: > > > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp?rev=113706&r1=113705&r2=113706&view=diff > > > > > ============================================================================== > > --- vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp (original) > > +++ vmkit/branches/precise/lib/J3/VMCore/Jnjvm.cpp Sat Sep 11 17:33:49 > 2010 > > @@ -1487,8 +1487,7 @@ > > } > > > > void Jnjvm::removeMethodsInFunctionMaps(JnjvmClassLoader* loader) { > > - internalRemoveMethods(loader, RuntimeFunctions); > > - internalRemoveMethods(loader, StaticFunctions); > > + internalRemoveMethods(loader, FunctionsCache); > > } > > > > > > > > Modified: vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp > > URL: > > > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=113706&r1=113705&r2=113706&view=diff > > > > > ============================================================================== > > --- vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp (original) > > +++ vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp Sat Sep 11 > > 17:33:49 2010 > > @@ -1073,7 +1073,7 @@ > > if (!isAbstract(meth.access) && meth.code) { > > JavaStaticMethodInfo* MI = new (allocator, > "JavaStaticMethodInfo") > > JavaStaticMethodInfo(0, meth.code, &meth); > > - vm->StaticFunctions.addMethodInfo(MI, meth.code); > > + vm->FunctionsCache.addMethodInfo(MI, meth.code); > > } > > } > > > > @@ -1082,7 +1082,7 @@ > > if (!isAbstract(meth.access) && meth.code) { > > JavaStaticMethodInfo* MI = new (allocator, > "JavaStaticMethodInfo") > > JavaStaticMethodInfo(0, meth.code, &meth); > > - vm->StaticFunctions.addMethodInfo(MI, meth.code); > > + vm->FunctionsCache.addMethodInfo(MI, meth.code); > > } > > } > > } > > > > Modified: vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp > > URL: > > > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp?rev=113706&r1=113705&r2=113706&view=diff > > > > > ============================================================================== > > --- vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp (original) > > +++ vmkit/branches/precise/lib/Mvm/Compiler/JIT.cpp Sat Sep 11 17:33:49 > 2010 > > @@ -22,6 +22,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include "llvm/ExecutionEngine/JITEventListener.h" > > @@ -35,6 +36,7 @@ > > #include > > #include > > #include > > +#include <../lib/ExecutionEngine/JIT/JIT.h> > > > > #include "mvm/JIT.h" > > #include "mvm/Threads/Locks.h" > > @@ -93,24 +95,33 @@ > > void *Code, size_t Size, > > const EmittedFunctionDetails > &Details) { > > assert(F.getParent() == MvmModule::globalModule); > > - llvm::GCFunctionInfo* GFI = 0; > > + assert(F.hasGC()); > > // We know the last GC info is for this method. > > - if (F.hasGC()) { > > - GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end(); > > - I--; > > - DEBUG(errs() << (*I)->getFunction().getName() << '\n'); > > - DEBUG(errs() << F.getName() << '\n'); > > - assert(&(*I)->getFunction() == &F && > > + GCStrategy::iterator I = mvm::MvmModule::TheGCStrategy->end(); > > + I--; > > + DEBUG(errs() << (*I)->getFunction().getName() << '\n'); > > + DEBUG(errs() << F.getName() << '\n'); > > + assert(&(*I)->getFunction() == &F && > > "GC Info and method do not correspond"); > > - GFI = *I; > > - } > > - MethodInfo* MI = > > + llvm::GCFunctionInfo* GFI = *I; > > + JITMethodInfo* MI = > > new(*MvmModule::Allocator, "MvmJITMethodInfo") > MvmJITMethodInfo(GFI, &F); > > - VirtualMachine::SharedRuntimeFunctions.addMethodInfo(MI, Code, > > - (void*)((uintptr_t)Code + > Size)); > > + MI->addToVM(mvm::Thread::get()->MyVM, > (JIT*)MvmModule::executionEngine); > > } > > }; > > > > +void JITMethodInfo::addToVM(VirtualMachine* VM, JIT* jit) { > > + JITCodeEmitter* JCE = jit->getCodeEmitter(); > > + assert(GCInfo != NULL); > > + for (GCFunctionInfo::iterator I = GCInfo->begin(), E = GCInfo->end(); > > + I != E; > > + I++) { > > + uintptr_t address = JCE->getLabelAddress(I->Label); > > + assert(address != 0); > > + VM->FunctionsCache.addMethodInfo(this, (void*)address); > > + } > > +} > > + > > static MvmJITListener JITListener; > > > > void MvmModule::loadBytecodeFile(const std::string& str) { > > @@ -317,6 +328,7 @@ > > unconditionalSafePoint = module->getFunction("unconditionalSafePoint"); > > conditionalSafePoint = module->getFunction("conditionalSafePoint"); > > AllocateFunction = module->getFunction("gcmalloc"); > > + AllocateFunction->setGC("vmkit"); > > assert(AllocateFunction && "No allocate function"); > > AllocateUnresolvedFunction = module->getFunction("gcmallocUnresolved"); > > assert(AllocateUnresolvedFunction && "No allocateUnresolved function"); > > > > Modified: vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp > > URL: > > > http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp?rev=113706&r1=113705&r2=113706&view=diff > > > > > ============================================================================== > > --- vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp (original) > > +++ vmkit/branches/precise/lib/Mvm/Runtime/MethodInfo.cpp Sat Sep 11 > 17:33:49 > > 2010 > > @@ -24,19 +24,11 @@ > > using namespace mvm; > > > > void CamlMethodInfo::scan(uintptr_t closure, void* ip, void* addr) { > > - if (!CF && InstructionPointer) { > > - MethodInfo* MI = > VirtualMachine::SharedStaticFunctions.IPToMethodInfo(ip); > > - if (MI != &DefaultMethodInfo::DM) { > > - CF = ((CamlMethodInfo*)MI)->CF; > > - } > > - } > > - > > - if (CF) { > > - //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + > sizeof(void*); > > - uintptr_t spaddr = ((uintptr_t*)addr)[0]; > > - for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) { > > - Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), > closure); > > - } > > + assert(CF != NULL); > > + //uintptr_t spaddr = (uintptr_t)addr + CF->FrameSize + sizeof(void*); > > + uintptr_t spaddr = ((uintptr_t*)addr)[0]; > > + for (uint16 i = 0; i < CF->NumLiveOffsets; ++i) { > > + Collector::scanObject((void**)(spaddr + CF->LiveOffsets[i]), > closure); > > } > > } > > > > @@ -59,52 +51,6 @@ > > void DefaultMethodInfo::scan(uintptr_t closure, void* ip, void* addr) { > > } > > > > - > > -MethodInfo* StartFunctionMap::IPToMethodInfo(void* ip) { > > - FunctionMapLock.acquire(); > > - std::map::iterator E = Functions.end(); > > - std::map::iterator I = Functions.find(ip); > > - MethodInfo* MI = 0; > > - if (I == E) { > > - Dl_info info; > > - int res = dladdr(ip, &info); > > - if (res != 0) { > > - I = Functions.find(info.dli_saddr); > > - if (I == E) { > > - // The method is static, and we have no information for it. > > - // Just return the Default MethodInfo object. > > - MI = &DefaultMethodInfo::DM; > > - } else { > > - MI = I->second; > > - } > > - } else { > > - // The method is jitted, and no-one has intercepted its > compilation. > > - // Just return the Default MethodInfo object. > > - MI = &DefaultMethodInfo::DM; > > - } > > - // Add it to the map, so that we don't need to call dladdr again. > > - Functions.insert(std::make_pair(ip, MI)); > > - } else { > > - MI = I->second; > > - } > > - FunctionMapLock.release(); > > - return MI; > > -} > > - > > -MethodInfo* VirtualMachine::IPToMethodInfo(void* ip) { > > - MethodInfo* MI = RuntimeFunctions.IPToMethodInfo(ip); > > - if (MI) return MI; > > - > > - MI = SharedRuntimeFunctions.IPToMethodInfo(ip); > > - if (MI) return MI; > > - > > - MI = StaticFunctions.IPToMethodInfo(ip); > > - if (MI != &DefaultMethodInfo::DM) return MI; > > - > > - MI = SharedStaticFunctions.IPToMethodInfo(ip); > > - return MI; > > -} > > - > > struct CamlFrames { > > uint16_t NumDescriptors; > > CamlFrame frames[1]; > > @@ -114,14 +60,11 @@ > > CamlFrames* frames ; > > uint32 currentDescriptor; > > CamlFrame* currentFrame; > > - Dl_info info; > > > > CamlFrameDecoder(CamlFrames* frames) { > > this->frames = frames; > > currentDescriptor = 0; > > currentFrame = &(frames->frames[0]); > > - int res = dladdr(currentFrame->ReturnAddress, &info); > > - assert(res != 0 && "No frame"); > > } > > > > bool hasNext() { > > @@ -135,55 +78,51 @@ > > (currentFrame->NumLiveOffsets % 2) * sizeof(uint16_t) + > > currentFrame->NumLiveOffsets * sizeof(uint16_t) + > > sizeof(void*) + sizeof(uint16_t) + sizeof(uint16_t)); > > - int res = dladdr(currentFrame->ReturnAddress, &info); > > - assert(res != 0 && "No frame"); > > } > > > > - CamlFrame* next(void** funcAddress, const char** funcName) { > > + CamlFrame* next() { > > assert(hasNext()); > > CamlFrame* result = currentFrame; > > - *funcAddress = info.dli_saddr; > > - *funcName = info.dli_sname; > > - > > - // Skip the remaining ones. > > - do { > > - advance(); > > - } while (hasNext() && (info.dli_saddr == *funcAddress)); > > - > > - // Skip the entries that start at another method. > > - while (hasNext() && (info.dli_saddr == currentFrame->ReturnAddress)) > { > > - advance(); > > - } > > - > > - while (hasNext() && (info.dli_saddr == NULL)) { > > - advance(); > > - } > > + advance(); > > return result; > > } > > }; > > > > -void SharedStartFunctionMap::initialize() { > > +static BumpPtrAllocator* StaticAllocator = NULL; > > + > > +FunctionMap::FunctionMap() { > > CamlFrames* frames = > > (CamlFrames*)dlsym(SELF_HANDLE, "camlVmkitoptimized__frametable"); > > + if (frames == NULL) return; > > + > > StaticAllocator = new BumpPtrAllocator(); > > - const char* name = NULL; > > - void* address = NULL; > > - > > - if (frames != NULL) { > > - CamlFrameDecoder decoder(frames); > > - while (decoder.hasNext()) { > > - CamlFrame* frame = decoder.next(&address, &name); > > - StaticCamlMethodInfo* MI = new(*StaticAllocator, > "StaticCamlMethodInfo") > > - StaticCamlMethodInfo(frame, address, name); > > - addMethodInfo(MI, address); > > - } > > + CamlFrameDecoder decoder(frames); > > + Dl_info info; > > + while (decoder.hasNext()) { > > + CamlFrame* frame = decoder.next(); > > + int res = dladdr(frame->ReturnAddress, &info); > > + assert(res != 0 && "No frame"); > > + StaticCamlMethodInfo* MI = new(*StaticAllocator, > "StaticCamlMethodInfo") > > + StaticCamlMethodInfo(frame, info.dli_sname); > > + addMethodInfo(MI, frame->ReturnAddress); > > } > > } > > > > -CamlMethodInfo::CamlMethodInfo(CamlFrame* C, void* ip) { > > - InstructionPointer = ip; > > - CF = C; > > +MethodInfo* FunctionMap::IPToMethodInfo(void* ip) { > > + FunctionMapLock.acquire(); > > + std::map::iterator I = Functions.find(ip); > > + MethodInfo* res = NULL; > > + if (I != Functions.end()) { > > + res = I->second; > > + } else { > > + res = &DefaultMethodInfo::DM; > > + } > > + FunctionMapLock.release(); > > + return res; > > } > > > > -StartEndFunctionMap VirtualMachine::SharedRuntimeFunctions; > > -SharedStartFunctionMap VirtualMachine::SharedStaticFunctions; > > +void FunctionMap::addMethodInfo(MethodInfo* meth, void* ip) { > > + FunctionMapLock.acquire(); > > + Functions.insert(std::make_pair(ip, meth)); > > + FunctionMapLock.release(); > > +} > > > > > > > > > > ------------------------------ > > > > _______________________________________________ > > vmkit-commits mailing list > > vmkit-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits > > > > > > End of vmkit-commits Digest, Vol 28, Issue 2 > > ******************************************** > > > > > > > > > > _______________________________________________ > > vmkit-commits mailing list > > vmkit-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits > > > > _______________________________________________ > vmkit-commits mailing list > vmkit-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicolas.geoffray at lip6.fr Sat Sep 18 10:49:32 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 18 Sep 2010 17:49:32 -0000 Subject: [vmkit-commits] [vmkit] r114291 - in /vmkit/trunk/lib/J3: Classpath/JavaUpcalls.cpp VMCore/JnjvmClassLoader.cpp Message-ID: <20100918174932.60BCF2A6C12C@llvm.org> Author: geoffray Date: Sat Sep 18 12:49:32 2010 New Revision: 114291 URL: http://llvm.org/viewvc/llvm-project?rev=114291&view=rev Log: Invoke loadClass(String), not loadClass(String, boolean). Modified: vmkit/trunk/lib/J3/Classpath/JavaUpcalls.cpp vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp Modified: vmkit/trunk/lib/J3/Classpath/JavaUpcalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Classpath/JavaUpcalls.cpp?rev=114291&r1=114290&r2=114291&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Classpath/JavaUpcalls.cpp (original) +++ vmkit/trunk/lib/J3/Classpath/JavaUpcalls.cpp Sat Sep 18 12:49:32 2010 @@ -743,7 +743,7 @@ loadInClassLoader = UPCALL_METHOD(loader, "java/lang/ClassLoader", "loadClass", - "(Ljava/lang/String;Z)Ljava/lang/Class;", ACC_VIRTUAL); + "(Ljava/lang/String;)Ljava/lang/Class;", ACC_VIRTUAL); JavaMethod* internString = UPCALL_METHOD(loader, "java/lang/VMString", "intern", Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=114291&r1=114290&r2=114291&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp Sat Sep 18 12:49:32 2010 @@ -383,7 +383,7 @@ strName = JavaString::internalToJava(name, isolate); } obj = loadClassMethod->invokeJavaObjectVirtual(isolate, forCtp, javaLoader, - &strName, doResolve); + &strName); cl = JavaObjectClass::getClass(((JavaObjectClass*)obj)); } From nicolas.geoffray at lip6.fr Sat Sep 18 12:10:36 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Sat, 18 Sep 2010 19:10:36 -0000 Subject: [vmkit-commits] [vmkit] r114295 - /vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Message-ID: <20100918191036.17BBD2A6C12C@llvm.org> Author: geoffray Date: Sat Sep 18 14:10:35 2010 New Revision: 114295 URL: http://llvm.org/viewvc/llvm-project?rev=114295&view=rev Log: Do a yield loop when trying to allocate a thread. Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Modified: vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp?rev=114295&r1=114294&r2=114295&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp (original) +++ vmkit/trunk/lib/Mvm/CommonThread/ctthread.cpp Sat Sep 18 14:10:35 2010 @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#include "debug.h" + #include "MvmGC.h" #include "mvm/VirtualMachine.h" #include "mvm/Threads/Cond.h" @@ -336,9 +338,13 @@ assert(sz < (size_t)getpagesize() && "Thread local data too big"); void* res = (void*)TheStackManager.allocate(); // Give it a second chance. - if (!res) { + if (res == NULL) { Collector::collect(); - res = (void*)TheStackManager.allocate(); + // Wait for the finalizer to have cleaned up the threads. + while (res == NULL) { + mvm::Thread::yield(); + res = (void*)TheStackManager.allocate(); + } } return res; } From actong88 at gmail.com Wed Sep 22 18:09:18 2010 From: actong88 at gmail.com (Allan Tong) Date: Wed, 22 Sep 2010 21:09:18 -0400 Subject: [vmkit-commits] Add class lock and condition variable to AOT compiled classes Message-ID: Revision 111399 breaks AOT compiled code. The thin lock was removed from the LLVM class structure, but the new lock and condition variable were not added. When loading the AOT compiled class, the lock and condition members would access memory outside of the object. Trying to run a hello world with a precompiled libvmjc.so resulted in an assertion in the pthread library since the mutex contained garbage data: j3: tpp.c:63: __pthread_tpp_change_priority: Assertion `new_prio == -1 || (new_prio >= __sched_fifo_min_prio && new_prio <= __sched_fifo_max_prio)' failed. The attached patch should fix the issue. I modeled the pthread structures as byte arrays, and while I believe the alignment should be correct, I'm not sure if there isn't some better way of doing this. Also note that the patch does not include the regenerated configure script. Only the changes to configure.ac are included. - Allan -------------- next part -------------- A non-text attachment was scrubbed... Name: aotlock.patch Type: application/octet-stream Size: 24264 bytes Desc: not available URL: From nicolas.geoffray at lip6.fr Fri Sep 24 10:16:33 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 24 Sep 2010 17:16:33 -0000 Subject: [vmkit-commits] [vmkit] r114734 - in /vmkit/trunk: lib/J3/Compiler/LowerConstantCalls.cpp lib/Mvm/Compiler/EscapeAnalysis.cpp lib/Mvm/Compiler/InlineMalloc.cpp lib/Mvm/Compiler/LoopSafePoints.cpp mmtk/magic/LowerMagic.cpp Message-ID: <20100924171633.B88002A6C12C@llvm.org> Author: geoffray Date: Fri Sep 24 12:16:33 2010 New Revision: 114734 URL: http://llvm.org/viewvc/llvm-project?rev=114734&view=rev Log: Move to new LLVM API. Modified: vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp vmkit/trunk/mmtk/magic/LowerMagic.cpp Modified: vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp?rev=114734&r1=114733&r2=114734&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/LowerConstantCalls.cpp Fri Sep 24 12:16:33 2010 @@ -143,14 +143,18 @@ Cmp->eraseFromParent(); break; } - - CallSite Ca = CallSite::get(Arg); - Instruction* CI = Ca.getInstruction(); - if (CI && Ca.getCalledValue() == intrinsics->AllocateFunction) { - Changed = true; - Cmp->replaceAllUsesWith(ConstantInt::getFalse(*Context)); - Cmp->eraseFromParent(); - break; + + Instruction* InsArg = dyn_cast(Arg); + if (InsArg != NULL && + (InsArg->getOpcode() == Instruction::Call || + InsArg->getOpcode() == Instruction::Invoke)) { + CallSite Ca(Arg); + if (Ca.getCalledValue() == intrinsics->AllocateFunction) { + Changed = true; + Cmp->replaceAllUsesWith(ConstantInt::getFalse(*Context)); + Cmp->eraseFromParent(); + break; + } } } } @@ -164,10 +168,15 @@ if (dyn_cast(*UI)) continue; if (BitCastInst* BI = dyn_cast(*UI)) { if (BI->hasOneUse()) { - CallSite Call = CallSite::get(*(BI->use_begin())); - Instruction* CI = Call.getInstruction(); - if (CI && Call.getCalledFunction() == intrinsics->llvm_gc_gcroot) - continue; + Instruction* use = dyn_cast(*(BI->use_begin())); + if (use != NULL && + (use->getOpcode() == Instruction::Call || + use->getOpcode() == Instruction::Invoke)) { + CallSite Call(use); + if (Call.getCalledFunction() == intrinsics->llvm_gc_gcroot) { + continue; + } + } } } @@ -185,7 +194,7 @@ if (dyn_cast(II) == SI) ++II; SI->eraseFromParent(); } else if (BitCastInst* BI = dyn_cast(Temp)) { - CallSite Call = CallSite::get(*(BI->use_begin())); + CallSite Call(*(BI->use_begin())); Instruction* CI = Call.getInstruction(); if (dyn_cast(II) == CI) ++II; CI->eraseFromParent(); @@ -205,9 +214,10 @@ } } - CallSite Call = CallSite::get(I); - Instruction* CI = Call.getInstruction(); - if (CI) { + if ((I->getOpcode() == Instruction::Call || + I->getOpcode() == Instruction::Invoke)) { + Instruction* CI = I; + CallSite Call(I); Value* V = Call.getCalledValue(); if (V == intrinsics->ArrayLengthFunction) { Changed = true; Modified: vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp?rev=114734&r1=114733&r2=114734&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/EscapeAnalysis.cpp Fri Sep 24 12:16:33 2010 @@ -76,9 +76,12 @@ for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) { Instruction *I = II; II++; - CallSite Call = CallSite::get(I); - if (Call.getInstruction() && Call.getCalledValue() == Allocator) { - + if (I->getOpcode() != Instruction::Call && + I->getOpcode() != Instruction::Invoke) { + continue; + } + CallSite Call(I); + if (Call.getCalledValue() == Allocator) { if (CurLoop) { bool escapesLoop = false; for (Value::use_iterator U = I->use_begin(), E = I->use_end(); @@ -118,7 +121,7 @@ if (II->getOpcode() == Instruction::Call || II->getOpcode() == Instruction::Invoke) { - CallSite CS = CallSite::get(II); + CallSite CS(II); if (!CS.onlyReadsMemory()) return true; CallSite::arg_iterator B = CS.arg_begin(), E = CS.arg_end(); Modified: vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp?rev=114734&r1=114733&r2=114734&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/InlineMalloc.cpp Fri Sep 24 12:16:33 2010 @@ -49,16 +49,17 @@ for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) { Instruction *I = II; II++; - CallSite Call = CallSite::get(I); - Instruction* CI = Call.getInstruction(); - if (CI) { - Function* Temp = Call.getCalledFunction(); - if (Temp == Malloc) { - if (dyn_cast(Call.getArgument(0))) { - InlineFunctionInfo IFI(NULL, mvm::MvmModule::TheTargetData); - Changed |= InlineFunction(Call, IFI); - break; - } + if (I->getOpcode() != Instruction::Call && + I->getOpcode() != Instruction::Invoke) { + continue; + } + CallSite Call(I); + Function* Temp = Call.getCalledFunction(); + if (Temp == Malloc) { + if (dyn_cast(Call.getArgument(0))) { + InlineFunctionInfo IFI(NULL, mvm::MvmModule::TheTargetData); + Changed |= InlineFunction(Call, IFI); + break; } } } Modified: vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp?rev=114734&r1=114733&r2=114734&view=diff ============================================================================== --- vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp (original) +++ vmkit/trunk/lib/Mvm/Compiler/LoopSafePoints.cpp Fri Sep 24 12:16:33 2010 @@ -82,8 +82,13 @@ for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) { Instruction *I = II; II++; - CallSite Call = CallSite::get(I); - if (Call.getInstruction() && Call.getCalledValue() == SafeFunction) { + if (I->getOpcode() != Instruction::Call && + I->getOpcode() != Instruction::Invoke) { + continue; + } + + CallSite Call(I); + if (Call.getCalledValue() == SafeFunction) { if (BasicBlock* Incoming = Cur->getSinglePredecessor()) { if (BranchInst* T = dyn_cast(Incoming->getTerminator())) { if (LoadInst* LI = dyn_cast(T->getCondition())) { Modified: vmkit/trunk/mmtk/magic/LowerMagic.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/mmtk/magic/LowerMagic.cpp?rev=114734&r1=114733&r2=114734&view=diff ============================================================================== --- vmkit/trunk/mmtk/magic/LowerMagic.cpp (original) +++ vmkit/trunk/mmtk/magic/LowerMagic.cpp Fri Sep 24 12:16:33 2010 @@ -422,9 +422,13 @@ for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) { Instruction *I = II; II++; - CallSite Call = CallSite::get(I); - Instruction* CI = Call.getInstruction(); - if (CI) { + if (I->getOpcode() != Instruction::Call && + I->getOpcode() != Instruction::Invoke) { + continue; + } + + CallSite Call(I); + Instruction* CI = I; Value* V = Call.getCalledValue(); if (Function* FCur = dyn_cast(V)) { const char* name = FCur->getName().data(); @@ -1250,7 +1254,6 @@ } } } - } } } return Changed; From nicolas.geoffray at gmail.com Fri Sep 24 10:50:10 2010 From: nicolas.geoffray at gmail.com (nicolas geoffray) Date: Fri, 24 Sep 2010 19:50:10 +0200 Subject: [vmkit-commits] Add class lock and condition variable to AOT compiled classes In-Reply-To: References: Message-ID: Thanks very much Allan for the debugging and the patch! Thinking about it, I think we should get rid of these variables in the JavaClass class. I plan on doing this soon. Cheers, Nicolas On Thu, Sep 23, 2010 at 3:09 AM, Allan Tong wrote: > Revision 111399 breaks AOT compiled code. The thin lock was removed > from the LLVM class structure, but the new lock and condition variable > were not added. When loading the AOT compiled class, the lock and > condition members would access memory outside of the object. Trying > to run a hello world with a precompiled libvmjc.so resulted in an > assertion in the pthread library since the mutex contained garbage > data: > > j3: tpp.c:63: __pthread_tpp_change_priority: Assertion `new_prio == -1 > || (new_prio >= __sched_fifo_min_prio && new_prio <= > __sched_fifo_max_prio)' failed. > > The attached patch should fix the issue. I modeled the pthread > structures as byte arrays, and while I believe the alignment should be > correct, I'm not sure if there isn't some better way of doing this. > > Also note that the patch does not include the regenerated configure > script. Only the changes to configure.ac are included. > > - Allan > > _______________________________________________ > vmkit-commits mailing list > vmkit-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicolas.geoffray at lip6.fr Fri Sep 24 11:05:18 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 24 Sep 2010 18:05:18 -0000 Subject: [vmkit-commits] [vmkit] r114740 - in /vmkit/branches/precise: ./ lib/J3/Classpath/ lib/J3/Compiler/ lib/J3/LLVMRuntime/ lib/J3/VMCore/ lib/Mvm/CommonThread/ lib/Mvm/Compiler/ mmtk/magic/ Message-ID: <20100924180518.C69FE2A6C12C@llvm.org> Author: geoffray Date: Fri Sep 24 13:05:18 2010 New Revision: 114740 URL: http://llvm.org/viewvc/llvm-project?rev=114740&view=rev Log: Merge with trunk Use the new GC infrastructure for precise debug and GC information. Modified: vmkit/branches/precise/ (props changed) vmkit/branches/precise/lib/J3/Classpath/JavaUpcalls.cpp vmkit/branches/precise/lib/J3/Compiler/ExceptionsCheck.inc vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp vmkit/branches/precise/lib/J3/Compiler/JavaJIT.h vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp vmkit/branches/precise/lib/J3/Compiler/JavaJITOpcodes.cpp vmkit/branches/precise/lib/J3/Compiler/LowerConstantCalls.cpp vmkit/branches/precise/lib/J3/LLVMRuntime/runtime-default.ll vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp vmkit/branches/precise/lib/J3/VMCore/JavaClass.h vmkit/branches/precise/lib/J3/VMCore/JavaConstantPool.h vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp vmkit/branches/precise/lib/J3/VMCore/LinkJavaRuntime.h vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp vmkit/branches/precise/lib/Mvm/Compiler/EscapeAnalysis.cpp vmkit/branches/precise/lib/Mvm/Compiler/InlineMalloc.cpp vmkit/branches/precise/lib/Mvm/Compiler/LoopSafePoints.cpp vmkit/branches/precise/mmtk/magic/LowerMagic.cpp Propchange: vmkit/branches/precise/ ------------------------------------------------------------------------------ svn:mergeinfo = /vmkit/trunk:112509-114734 Modified: vmkit/branches/precise/lib/J3/Classpath/JavaUpcalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Classpath/JavaUpcalls.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Classpath/JavaUpcalls.cpp (original) +++ vmkit/branches/precise/lib/J3/Classpath/JavaUpcalls.cpp Fri Sep 24 13:05:18 2010 @@ -742,7 +742,7 @@ loadInClassLoader = UPCALL_METHOD(loader, "java/lang/ClassLoader", "loadClass", - "(Ljava/lang/String;Z)Ljava/lang/Class;", ACC_VIRTUAL); + "(Ljava/lang/String;)Ljava/lang/Class;", ACC_VIRTUAL); JavaMethod* internString = UPCALL_METHOD(loader, "java/lang/VMString", "intern", Modified: vmkit/branches/precise/lib/J3/Compiler/ExceptionsCheck.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/ExceptionsCheck.inc?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/ExceptionsCheck.inc (original) +++ vmkit/branches/precise/lib/J3/Compiler/ExceptionsCheck.inc Fri Sep 24 13:05:18 2010 @@ -541,7 +541,6 @@ // Restore currentBlock. currentBlock = temp; return nbe; - } void JavaJIT::finishExceptions() { Modified: vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/JavaAOTCompiler.cpp Fri Sep 24 13:05:18 2010 @@ -167,6 +167,7 @@ } Constant* JavaAOTCompiler::getString(JavaString* str) { + assert(!useCooperativeGC()); string_iterator SI = strings.find(str); if (SI != strings.end()) { return SI->second; @@ -304,6 +305,7 @@ Constant* JavaAOTCompiler::getFinalObject(JavaObject* obj, CommonClass* objCl) { + assert(!useCooperativeGC()); llvm::GlobalVariable* varGV = 0; final_object_iterator End = finalObjects.end(); final_object_iterator I = finalObjects.find(obj); Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/JavaJIT.cpp Fri Sep 24 13:05:18 2010 @@ -299,9 +299,10 @@ char* functionName = (char*)allocator.Allocate( 3 + JNI_NAME_PRE_LEN + ((mnlen + clen + mtlen) << 3)); - if (!natPtr) + if (!natPtr) { natPtr = compilingClass->classLoader->nativeLookup(compilingMethod, j3, functionName); + } if (!natPtr && !TheCompiler->isStaticCompiling()) { currentBlock = createBasicBlock("start"); @@ -543,18 +544,6 @@ UTF8Buffer(compilingClass->name).cString(), UTF8Buffer(compilingMethod->name).cString()); - if (codeInfo.size()) { - compilingMethod->codeInfo = new CodeLineInfo[codeInfo.size()]; - for (uint32 i = 0; i < codeInfo.size(); i++) { - compilingMethod->codeInfo[i].lineNumber = codeInfo[i].lineNumber; - compilingMethod->codeInfo[i].ctpIndex = codeInfo[i].ctpIndex; - compilingMethod->codeInfo[i].bytecodeIndex = codeInfo[i].bytecodeIndex; - compilingMethod->codeInfo[i].bytecode = codeInfo[i].bytecode; - } - } else { - compilingMethod->codeInfo = NULL; - } - return llvmFunction; } @@ -896,23 +885,6 @@ readExceptionTable(reader, codeLen); - // Lookup line number table attribute. - uint16 nba = reader.readU2(); - for (uint16 i = 0; i < nba; ++i) { - const UTF8* attName = compilingClass->ctpInfo->UTF8At(reader.readU2()); - uint32 attLen = reader.readU4(); - if (attName->equals(Attribut::lineNumberTableAttribut)) { - uint16 lineLength = reader.readU2(); - for (uint16 i = 0; i < lineLength; ++i) { - uint16 pc = reader.readU2(); - uint16 ln = reader.readU2(); - opcodeInfos[pc].lineNumber = ln; - } - } else { - reader.seek(attLen, Reader::SeekCur); - } - } - reader.cursor = start; exploreOpcodes(reader, codeLen); @@ -1146,23 +1118,6 @@ readExceptionTable(reader, codeLen); - // Lookup line number table attribute. - uint16 nba = reader.readU2(); - for (uint16 i = 0; i < nba; ++i) { - const UTF8* attName = compilingClass->ctpInfo->UTF8At(reader.readU2()); - uint32 attLen = reader.readU4(); - if (attName->equals(Attribut::lineNumberTableAttribut)) { - uint16 lineLength = reader.readU2(); - for (uint16 i = 0; i < lineLength; ++i) { - uint16 pc = reader.readU2(); - uint16 ln = reader.readU2(); - opcodeInfos[pc].lineNumber = ln; - } - } else { - reader.seek(attLen, Reader::SeekCur); - } - } - reader.cursor = start; exploreOpcodes(reader, codeLen); @@ -1346,18 +1301,6 @@ } } - if (codeInfo.size()) { - compilingMethod->codeInfo = new CodeLineInfo[codeInfo.size()]; - for (uint32 i = 0; i < codeInfo.size(); i++) { - compilingMethod->codeInfo[i].lineNumber = codeInfo[i].lineNumber; - compilingMethod->codeInfo[i].ctpIndex = codeInfo[i].ctpIndex; - compilingMethod->codeInfo[i].bytecodeIndex = codeInfo[i].bytecodeIndex; - compilingMethod->codeInfo[i].bytecode = codeInfo[i].bytecode; - } - } else { - compilingMethod->codeInfo = NULL; - } - return llvmFunction; } @@ -2137,7 +2080,7 @@ abort(); } } else { - if (TheCompiler->isStaticCompiling()) { + if (TheCompiler->isStaticCompiling() && !TheCompiler->useCooperativeGC()) { JavaObject* val = field->getStaticObjectField(); JnjvmClassLoader* JCL = field->classDef->classLoader; Value* V = TheCompiler->getFinalObject(val, sign->assocClass(JCL)); @@ -2630,10 +2573,7 @@ } DebugLoc JavaJIT::CreateLocation() { - LineInfo LI = { currentLineNumber, currentCtpIndex, currentBytecodeIndex, - currentBytecode }; - codeInfo.push_back(LI); - DebugLoc DL = DebugLoc::get(callNumber++, 0, DbgSubprogram); + DebugLoc DL = DebugLoc::get(currentBytecodeIndex, 0, DbgSubprogram); return DL; } Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJIT.h?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/JavaJIT.h (original) +++ vmkit/branches/precise/lib/J3/Compiler/JavaJIT.h Fri Sep 24 13:05:18 2010 @@ -58,19 +58,9 @@ /// stack - The stack at this location if there is a new block /// std::vector stack; - - /// lineNumber - The line number of this bytecode. - uint16 lineNumber; }; -struct LineInfo { - uint16 lineNumber; - uint16 ctpIndex; - uint16 bytecodeIndex; - uint16 bytecode; -}; - /// JavaJIT - The compilation engine of J3. Parses the bycode and returns /// its LLVM representation. /// @@ -90,11 +80,7 @@ callsStackWalker = false; endNode = 0; currentStackIndex = 0; - currentLineNumber = 0; currentBytecodeIndex = 0; - currentCtpIndex = -1; - currentBytecode = -1; - callNumber = 0; thisObject = NULL; } @@ -158,27 +144,12 @@ llvm::MDNode* DbgSubprogram; - /// currentLineIndex - The current line being processed. - uint16 currentLineNumber; - /// currentBytecodeIndex - The current bytecode being processed. uint16 currentBytecodeIndex; - /// currentCtpIndex - The constant pool index being processed. - uint16 currentCtpIndex; - - /// currentBytecode - The bytecode being processed. - uint16 currentBytecode; - - /// callNumber - The number of a call for a single opcode. - uint16 callNumber; - /// CreateLocation - Create debug information for a call. llvm::DebugLoc CreateLocation(); - // codeInfo - List of LineInfo for this method. - std::vector codeInfo; - //===--------------------------- Inline support ---------------------------===// /// inlineCompile - Parse the method and start its LLVM representation Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/JavaJITCompiler.cpp Fri Sep 24 13:05:18 2010 @@ -15,12 +15,14 @@ #include "llvm/Module.h" #include "llvm/Analysis/DebugInfo.h" #include "llvm/CodeGen/GCStrategy.h" +#include #include "llvm/CodeGen/MachineFunction.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +#include <../lib/ExecutionEngine/JIT/JIT.h> #include "MvmGC.h" #include "mvm/VirtualMachine.h" @@ -58,7 +60,8 @@ if (info != NULL) { fprintf(stderr, "; %p in %s.%s (line %d, bytecode %d, code start %p)", new_ip, UTF8Buffer(meth->classDef->name).cString(), - UTF8Buffer(meth->name).cString(), info->lineNumber, + UTF8Buffer(meth->name).cString(), + meth->lookupLineNumber((uintptr_t)ip), info->bytecodeIndex, meth->code); } else { fprintf(stderr, "; %p in %s.%s (native method, code start %p)", new_ip, @@ -74,8 +77,7 @@ void *Code, size_t Size, const EmittedFunctionDetails &Details) { - // The following could be changed to an assert when -load-bc supports - // the verifier. + // The following is necessary for -load-bc. if (F.getParent() != TheCompiler->getLLVMModule()) return; assert(F.hasGC()); @@ -107,35 +109,34 @@ } else { MI = new(Alloc, "JavaJITMethodInfo") JavaJITMethodInfo(GFI, meth); } - MI->addToVM(vm, (JIT*)TheCompiler->executionEngine); + JIT* jit = (JIT*)TheCompiler->executionEngine; + MI->addToVM(vm, jit); - if (meth != NULL) { - uint32 infoLength = Details.LineStarts.size(); - meth->codeInfoLength = infoLength; - if (infoLength > 0) { - mvm::BumpPtrAllocator& JavaAlloc = meth->classDef->classLoader->allocator; - CodeLineInfo* infoTable = - new(JavaAlloc, "CodeLineInfo") CodeLineInfo[infoLength]; - for (uint32 i = 0; i < infoLength; ++i) { - DebugLoc DL = Details.LineStarts[i].Loc; - uint32_t first = DL.getLine(); - uint32_t second = DL.getCol(); - assert(second == 0 && "Wrong column number"); - infoTable[i].address = Details.LineStarts[i].Address; - infoTable[i].lineNumber = meth->codeInfo[first].lineNumber; - infoTable[i].bytecodeIndex = meth->codeInfo[first].bytecodeIndex; - infoTable[i].ctpIndex = meth->codeInfo[first].ctpIndex; - infoTable[i].bytecode = meth->codeInfo[first].bytecode; - } - delete[] meth->codeInfo; - meth->codeInfo = infoTable; - } else { - if (meth->codeInfo != NULL) { - delete[] meth->codeInfo; - meth->codeInfo = NULL; - } - } + if (meth == NULL) return; + + uint32_t infoLength = GFI->size(); + meth->codeInfoLength = infoLength; + if (infoLength == 0) { + meth->codeInfo = NULL; + return; + } + + mvm::BumpPtrAllocator& JavaAlloc = meth->classDef->classLoader->allocator; + CodeLineInfo* infoTable = + new(JavaAlloc, "CodeLineInfo") CodeLineInfo[infoLength]; + uint32_t index = 0; + for (GCFunctionInfo::iterator I = GFI->begin(), E = GFI->end(); + I != E; + I++, index++) { + DebugLoc DL = I->Loc; + uint32_t bytecodeIndex = DL.getLine(); + uint32_t second = DL.getCol(); + assert(second == 0 && "Wrong column number"); + uintptr_t address = jit->getCodeEmitter()->getLabelAddress(I->Label); + infoTable[index].address = address; + infoTable[index].bytecodeIndex = bytecodeIndex; } + meth->codeInfo = infoTable; } Constant* JavaJITCompiler::getNativeClass(CommonClass* classDef) { Modified: vmkit/branches/precise/lib/J3/Compiler/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/JavaJITOpcodes.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/JavaJITOpcodes.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/JavaJITOpcodes.cpp Fri Sep 24 13:05:18 2010 @@ -148,13 +148,7 @@ currentExceptionBlock = opinfo->exceptionBlock; - // Update the line number information. - if (opinfo->lineNumber) - currentLineNumber = opinfo->lineNumber; - - currentCtpIndex = -1; currentBytecodeIndex = i; - currentBytecode = bytecode; // To prevent a gcj bug with useless goto if (currentBlock->getTerminator() != 0) { @@ -2013,7 +2007,6 @@ case INVOKEVIRTUAL : { uint16 index = reader.readU2(); i += 2; - currentCtpIndex = index; invokeVirtual(index); break; } @@ -2021,7 +2014,6 @@ case INVOKESPECIAL : { uint16 index = reader.readU2(); i += 2; - currentCtpIndex = index; invokeSpecial(index); break; } @@ -2029,7 +2021,6 @@ case INVOKESTATIC : { uint16 index = reader.readU2(); i += 2; - currentCtpIndex = index; invokeStatic(index); break; } @@ -2037,7 +2028,6 @@ case INVOKEINTERFACE : { uint16 index = reader.readU2(); i += 2; - currentCtpIndex = index; invokeInterface(index); i += 2; break; Modified: vmkit/branches/precise/lib/J3/Compiler/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/Compiler/LowerConstantCalls.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/Compiler/LowerConstantCalls.cpp (original) +++ vmkit/branches/precise/lib/J3/Compiler/LowerConstantCalls.cpp Fri Sep 24 13:05:18 2010 @@ -143,14 +143,18 @@ Cmp->eraseFromParent(); break; } - - CallSite Ca = CallSite::get(Arg); - Instruction* CI = Ca.getInstruction(); - if (CI && Ca.getCalledValue() == intrinsics->AllocateFunction) { - Changed = true; - Cmp->replaceAllUsesWith(ConstantInt::getFalse(*Context)); - Cmp->eraseFromParent(); - break; + + Instruction* InsArg = dyn_cast(Arg); + if (InsArg != NULL && + (InsArg->getOpcode() == Instruction::Call || + InsArg->getOpcode() == Instruction::Invoke)) { + CallSite Ca(Arg); + if (Ca.getCalledValue() == intrinsics->AllocateFunction) { + Changed = true; + Cmp->replaceAllUsesWith(ConstantInt::getFalse(*Context)); + Cmp->eraseFromParent(); + break; + } } } } @@ -164,10 +168,15 @@ if (dyn_cast(*UI)) continue; if (BitCastInst* BI = dyn_cast(*UI)) { if (BI->hasOneUse()) { - CallSite Call = CallSite::get(*(BI->use_begin())); - Instruction* CI = Call.getInstruction(); - if (CI && Call.getCalledFunction() == intrinsics->llvm_gc_gcroot) - continue; + Instruction* use = dyn_cast(*(BI->use_begin())); + if (use != NULL && + (use->getOpcode() == Instruction::Call || + use->getOpcode() == Instruction::Invoke)) { + CallSite Call(use); + if (Call.getCalledFunction() == intrinsics->llvm_gc_gcroot) { + continue; + } + } } } @@ -185,7 +194,7 @@ if (dyn_cast(II) == SI) ++II; SI->eraseFromParent(); } else if (BitCastInst* BI = dyn_cast(Temp)) { - CallSite Call = CallSite::get(*(BI->use_begin())); + CallSite Call(*(BI->use_begin())); Instruction* CI = Call.getInstruction(); if (dyn_cast(II) == CI) ++II; CI->eraseFromParent(); @@ -205,9 +214,10 @@ } } - CallSite Call = CallSite::get(I); - Instruction* CI = Call.getInstruction(); - if (CI) { + if ((I->getOpcode() == Instruction::Call || + I->getOpcode() == Instruction::Invoke)) { + Instruction* CI = I; + CallSite Call(I); Value* V = Call.getCalledValue(); if (V == intrinsics->ArrayLengthFunction) { Changed = true; @@ -374,8 +384,9 @@ PHINode* phi = PHINode::Create(intrinsics->JavaObjectType, "", DelegateeOK); phi->addIncoming(Del, CI->getParent()); - Value* Res = CallInst::Create(intrinsics->RuntimeDelegateeFunction, - Call.getArgument(0), "", NoDelegatee); + Instruction* Res = CallInst::Create(intrinsics->RuntimeDelegateeFunction, + Call.getArgument(0), "", NoDelegatee); + Res->setDebugLoc(CI->getDebugLoc()); BranchInst::Create(DelegateeOK, NoDelegatee); phi->addIncoming(Res, NoDelegatee); @@ -414,7 +425,7 @@ BranchInst::Create(trueCl, falseCl, test, CI); - Value* res = 0; + Instruction* res = 0; if (InvokeInst* Invoke = dyn_cast(CI)) { Value* Args[1] = { Cl }; BasicBlock* UI = Invoke->getUnwindDest(); @@ -448,6 +459,7 @@ Cl, "", falseCl); BranchInst::Create(trueCl, falseCl); } + res->setDebugLoc(CI->getDebugLoc()); node->addIncoming(res, falseCl); @@ -498,7 +510,7 @@ Args.push_back(Call.getArgument(i)); } - Value* res = 0; + Instruction* res = 0; if (InvokeInst* Invoke = dyn_cast(CI)) { BasicBlock* UI = Invoke->getUnwindDest(); res = InvokeInst::Create(resolver, trueCl, UI, Args.begin(), @@ -530,9 +542,9 @@ BranchInst::Create(trueCl, falseCl); } + res->setDebugLoc(CI->getDebugLoc()); node->addIncoming(res, falseCl); - CI->replaceAllUsesWith(node); CI->eraseFromParent(); BranchInst::Create(NBB, trueCl); @@ -564,8 +576,9 @@ BranchInst::Create(NotOKBlock, OKBlock, cmp, CI); Value* args[3] = { Call.getArgument(0), Call.getArgument(1), GV }; - Value* res = CallInst::Create(intrinsics->GetArrayClassFunction, args, - args + 3, "", NotOKBlock); + Instruction* res = CallInst::Create(intrinsics->GetArrayClassFunction, args, + args + 3, "", NotOKBlock); + res->setDebugLoc(CI->getDebugLoc()); BranchInst::Create(OKBlock, NotOKBlock); node->addIncoming(res, NotOKBlock); @@ -615,7 +628,8 @@ CurVT = new LoadInst(CurVT, "", false, CI); CurVT = new BitCastInst(CurVT, intrinsics->VTType, "", CI); - Value* res = new ICmpInst(CI, ICmpInst::ICMP_EQ, CurVT, VT2, ""); + Instruction* res = + new ICmpInst(CI, ICmpInst::ICMP_EQ, CurVT, VT2, ""); node->addIncoming(ConstantInt::getTrue(*Context), CI->getParent()); BranchInst::Create(CurEndBlock, FailedBlock, res, CI); @@ -623,6 +637,7 @@ Value* Args[2] = { VT1, VT2 }; res = CallInst::Create(intrinsics->IsSecondaryClassFunction, Args, Args + 2, "", FailedBlock); + res->setDebugLoc(CI->getDebugLoc()); node->addIncoming(res, FailedBlock); BranchInst::Create(CurEndBlock, FailedBlock); Modified: vmkit/branches/precise/lib/J3/LLVMRuntime/runtime-default.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/LLVMRuntime/runtime-default.ll?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/LLVMRuntime/runtime-default.ll (original) +++ vmkit/branches/precise/lib/J3/LLVMRuntime/runtime-default.ll Fri Sep 24 13:05:18 2010 @@ -29,6 +29,7 @@ %JavaThread = type { %MutatorThread, i8*, %JavaObject* } +%JavaConstantPool = type { %JavaClass*, i32, i8*, i32*, i8** } %Attribut = type { %UTF8*, i32, i32 } @@ -38,7 +39,7 @@ %JavaField = type { i8*, i16, %UTF8*, %UTF8*, %Attribut*, i16, %JavaClass*, i32, i16 } -%CodeLineInfo = type { i8*, i16, i16, %JavaMethod*, %CodeLineInfo* } +%CodeLineInfo = type { i8*, %JavaMethod*, %CodeLineInfo* } %JavaMethod = type { i8*, i16, %Attribut*, i16, %JavaClass*, %UTF8*, %UTF8*, i8, i8*, %CodeLineInfo*, i16, i32 } Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp (original) +++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.cpp Fri Sep 24 13:05:18 2010 @@ -1830,31 +1830,54 @@ CodeLineInfo* JavaMethod::lookupCodeLineInfo(uintptr_t ip) { for(uint16 i = 0; i < codeInfoLength; ++i) { - if (codeInfo[i].address > ip) { - assert(i > 0 && "Wrong ip address for method"); - return &(codeInfo[i - 1]); + if (codeInfo[i].address == ip) { + return &(codeInfo[i]); } } - if (codeInfoLength) return &(codeInfo[codeInfoLength - 1]); return NULL; } uint16 JavaMethod::lookupLineNumber(uintptr_t ip) { - for(uint16 i = 1; i < codeInfoLength; ++i) { - if (codeInfo[i].address > ip) { - return codeInfo[i - 1].lineNumber; + for(uint16 i = 0; i < codeInfoLength; ++i) { + if (codeInfo[i].address == ip) { + Attribut* codeAtt = lookupAttribut(Attribut::codeAttribut); + Reader reader(codeAtt, &(classDef->bytes)); + reader.readU2(); // max_stack + reader.readU2(); // max_locals; + uint32_t codeLength = reader.readU4(); + reader.seek(codeLength, Reader::SeekCur); + uint16_t exceptionTableLength = reader.readU2(); + reader.seek(8 * exceptionTableLength, Reader::SeekCur); + uint16_t nba = reader.readU2(); + for (uint16 att = 0; att < nba; ++att) { + const UTF8* attName = classDef->ctpInfo->UTF8At(reader.readU2()); + uint32 attLen = reader.readU4(); + if (attName->equals(Attribut::lineNumberTableAttribut)) { + uint16_t lineLength = reader.readU2(); + uint16_t currentLine = 0; + for (uint16 j = 0; j < lineLength; ++j) { + uint16 pc = reader.readU2(); + if (pc > codeInfo[i].bytecodeIndex + 1) return currentLine; + currentLine = reader.readU2(); + } + return currentLine; + } else { + reader.seek(attLen, Reader::SeekCur); + } + } } } - if (codeInfoLength) return codeInfo[codeInfoLength - 1].lineNumber; return 0; } uint16 JavaMethod::lookupCtpIndex(uintptr_t ip) { - for(uint16 i = 1; i < codeInfoLength; ++i) { - if (codeInfo[i].address > ip) { - return codeInfo[i - 1].ctpIndex; + for(uint16 i = 0; i < codeInfoLength; ++i) { + if (codeInfo[i].address == ip) { + Attribut* codeAtt = lookupAttribut(Attribut::codeAttribut); + Reader reader(codeAtt, &(classDef->bytes)); + reader.cursor = reader.cursor + 2 + 2 + 4 + codeInfo[i].bytecodeIndex + 1; + return reader.readU2(); } } - if (codeInfoLength) return codeInfo[codeInfoLength - 1].ctpIndex; return 0; } Modified: vmkit/branches/precise/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaClass.h?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/branches/precise/lib/J3/VMCore/JavaClass.h Fri Sep 24 13:05:18 2010 @@ -912,10 +912,7 @@ class CodeLineInfo : public mvm::PermanentObject { public: uintptr_t address; - uint16 lineNumber; - uint16 ctpIndex; uint16 bytecodeIndex; - uint16 bytecode; // TODO: Use these fields when inlining. JavaMethod* executingMethod; // The code where the inlined method starts. Modified: vmkit/branches/precise/lib/J3/VMCore/JavaConstantPool.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaConstantPool.h?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JavaConstantPool.h (original) +++ vmkit/branches/precise/lib/J3/VMCore/JavaConstantPool.h Fri Sep 24 13:05:18 2010 @@ -52,7 +52,7 @@ /// ctpRes - Objects resolved dynamically, e.g. UTF8s, classes, methods, /// fields, string pointers. /// - void** ctpRes; + void** ctpRes; /// operator new - Redefine the operator to allocate the arrays of a /// constant pool inline. Modified: vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/branches/precise/lib/J3/VMCore/JavaRuntimeJIT.cpp Fri Sep 24 13:05:18 2010 @@ -614,9 +614,7 @@ void* ip = *Walker; // Lookup the method info in the constant pool of the caller. - CodeLineInfo* CLInfo = - meth->lookupCodeLineInfo(reinterpret_cast(ip)); - uint16 ctpIndex = CLInfo->ctpIndex; + uint16 ctpIndex = meth->lookupCtpIndex(reinterpret_cast(ip)); assert(ctpIndex && "No constant pool index"); JavaConstantPool* ctpInfo = meth->classDef->getConstantPool(); CommonClass* ctpCl = 0; Modified: vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/branches/precise/lib/J3/VMCore/JnjvmClassLoader.cpp Fri Sep 24 13:05:18 2010 @@ -383,7 +383,7 @@ strName = JavaString::internalToJava(name, isolate); } obj = loadClassMethod->invokeJavaObjectVirtual(isolate, forCtp, javaLoader, - &strName, doResolve); + &strName); cl = JavaObjectClass::getClass(((JavaObjectClass*)obj)); } Modified: vmkit/branches/precise/lib/J3/VMCore/LinkJavaRuntime.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/J3/VMCore/LinkJavaRuntime.h?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/J3/VMCore/LinkJavaRuntime.h (original) +++ vmkit/branches/precise/lib/J3/VMCore/LinkJavaRuntime.h Fri Sep 24 13:05:18 2010 @@ -45,7 +45,6 @@ extern "C" void j3JavaObjectAquire(JavaObject* obj); extern "C" void j3JavaObjectRelease(JavaObject* obj); extern "C" void j3ThrowException(JavaObject* obj); -extern "C" void j3OverflowThinLock(JavaObject* obj); extern "C" JavaObject* j3NullPointerException(); extern "C" JavaObject* j3NegativeArraySizeException(sint32 val); extern "C" JavaObject* j3OutOfMemoryError(sint32 val); @@ -105,7 +104,6 @@ (void) j3JavaObjectAquire(0); (void) j3JavaObjectRelease(0); (void) j3ThrowException(0); - (void) j3OverflowThinLock(0); (void) j3NullPointerException(); (void) j3NegativeArraySizeException(0); (void) j3OutOfMemoryError(0); Modified: vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp (original) +++ vmkit/branches/precise/lib/Mvm/CommonThread/ctthread.cpp Fri Sep 24 13:05:18 2010 @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#include "debug.h" + #include "MvmGC.h" #include "mvm/VirtualMachine.h" #include "mvm/Threads/Cond.h" @@ -336,9 +338,13 @@ assert(sz < (size_t)getpagesize() && "Thread local data too big"); void* res = (void*)TheStackManager.allocate(); // Give it a second chance. - if (!res) { + if (res == NULL) { Collector::collect(); - res = (void*)TheStackManager.allocate(); + // Wait for the finalizer to have cleaned up the threads. + while (res == NULL) { + mvm::Thread::yield(); + res = (void*)TheStackManager.allocate(); + } } return res; } Modified: vmkit/branches/precise/lib/Mvm/Compiler/EscapeAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/EscapeAnalysis.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/Mvm/Compiler/EscapeAnalysis.cpp (original) +++ vmkit/branches/precise/lib/Mvm/Compiler/EscapeAnalysis.cpp Fri Sep 24 13:05:18 2010 @@ -76,9 +76,12 @@ for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) { Instruction *I = II; II++; - CallSite Call = CallSite::get(I); - if (Call.getInstruction() && Call.getCalledValue() == Allocator) { - + if (I->getOpcode() != Instruction::Call && + I->getOpcode() != Instruction::Invoke) { + continue; + } + CallSite Call(I); + if (Call.getCalledValue() == Allocator) { if (CurLoop) { bool escapesLoop = false; for (Value::use_iterator U = I->use_begin(), E = I->use_end(); @@ -118,7 +121,7 @@ if (II->getOpcode() == Instruction::Call || II->getOpcode() == Instruction::Invoke) { - CallSite CS = CallSite::get(II); + CallSite CS(II); if (!CS.onlyReadsMemory()) return true; CallSite::arg_iterator B = CS.arg_begin(), E = CS.arg_end(); Modified: vmkit/branches/precise/lib/Mvm/Compiler/InlineMalloc.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/InlineMalloc.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/Mvm/Compiler/InlineMalloc.cpp (original) +++ vmkit/branches/precise/lib/Mvm/Compiler/InlineMalloc.cpp Fri Sep 24 13:05:18 2010 @@ -49,16 +49,17 @@ for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) { Instruction *I = II; II++; - CallSite Call = CallSite::get(I); - Instruction* CI = Call.getInstruction(); - if (CI) { - Function* Temp = Call.getCalledFunction(); - if (Temp == Malloc) { - if (dyn_cast(Call.getArgument(0))) { - InlineFunctionInfo IFI(NULL, mvm::MvmModule::TheTargetData); - Changed |= InlineFunction(Call, IFI); - break; - } + if (I->getOpcode() != Instruction::Call && + I->getOpcode() != Instruction::Invoke) { + continue; + } + CallSite Call(I); + Function* Temp = Call.getCalledFunction(); + if (Temp == Malloc) { + if (dyn_cast(Call.getArgument(0))) { + InlineFunctionInfo IFI(NULL, mvm::MvmModule::TheTargetData); + Changed |= InlineFunction(Call, IFI); + break; } } } Modified: vmkit/branches/precise/lib/Mvm/Compiler/LoopSafePoints.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/lib/Mvm/Compiler/LoopSafePoints.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/lib/Mvm/Compiler/LoopSafePoints.cpp (original) +++ vmkit/branches/precise/lib/Mvm/Compiler/LoopSafePoints.cpp Fri Sep 24 13:05:18 2010 @@ -82,8 +82,13 @@ for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) { Instruction *I = II; II++; - CallSite Call = CallSite::get(I); - if (Call.getInstruction() && Call.getCalledValue() == SafeFunction) { + if (I->getOpcode() != Instruction::Call && + I->getOpcode() != Instruction::Invoke) { + continue; + } + + CallSite Call(I); + if (Call.getCalledValue() == SafeFunction) { if (BasicBlock* Incoming = Cur->getSinglePredecessor()) { if (BranchInst* T = dyn_cast(Incoming->getTerminator())) { if (LoadInst* LI = dyn_cast(T->getCondition())) { Modified: vmkit/branches/precise/mmtk/magic/LowerMagic.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/precise/mmtk/magic/LowerMagic.cpp?rev=114740&r1=114739&r2=114740&view=diff ============================================================================== --- vmkit/branches/precise/mmtk/magic/LowerMagic.cpp (original) +++ vmkit/branches/precise/mmtk/magic/LowerMagic.cpp Fri Sep 24 13:05:18 2010 @@ -422,9 +422,13 @@ for (BasicBlock::iterator II = Cur->begin(), IE = Cur->end(); II != IE;) { Instruction *I = II; II++; - CallSite Call = CallSite::get(I); - Instruction* CI = Call.getInstruction(); - if (CI) { + if (I->getOpcode() != Instruction::Call && + I->getOpcode() != Instruction::Invoke) { + continue; + } + + CallSite Call(I); + Instruction* CI = I; Value* V = Call.getCalledValue(); if (Function* FCur = dyn_cast(V)) { const char* name = FCur->getName().data(); @@ -1250,7 +1254,6 @@ } } } - } } } return Changed; From actong88 at gmail.com Fri Sep 24 16:42:11 2010 From: actong88 at gmail.com (Allan Tong) Date: Fri, 24 Sep 2010 19:42:11 -0400 Subject: [vmkit-commits] Add class lock and condition variable to AOT compiled classes In-Reply-To: References: Message-ID: Ok, sounds good. - Allan On Fri, Sep 24, 2010 at 1:50 PM, nicolas geoffray wrote: > Thanks very much Allan for the debugging and the patch! > Thinking about it, I think we should get rid of these variables in the > JavaClass class. I plan on doing this soon. > Cheers, > Nicolas > > On Thu, Sep 23, 2010 at 3:09 AM, Allan Tong wrote: >> >> Revision 111399 breaks AOT compiled code.  The thin lock was removed >> from the LLVM class structure, but the new lock and condition variable >> were not added.  When loading the AOT compiled class, the lock and >> condition members would access memory outside of the object.  Trying >> to run a hello world with a precompiled libvmjc.so resulted in an >> assertion in the pthread library since the mutex contained garbage >> data: >> >> j3: tpp.c:63: __pthread_tpp_change_priority: Assertion `new_prio == -1 >> || (new_prio >= __sched_fifo_min_prio && new_prio <= >> __sched_fifo_max_prio)' failed. >> >> The attached patch should fix the issue.  I modeled the pthread >> structures as byte arrays, and while I believe the alignment should be >> correct, I'm not sure if there isn't some better way of doing this. >> >> Also note that the patch does not include the regenerated configure >> script.  Only the changes to configure.ac are included. >> >>  - Allan >> >> _______________________________________________ >> vmkit-commits mailing list >> vmkit-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits >> > > > _______________________________________________ > vmkit-commits mailing list > vmkit-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/vmkit-commits > > From nicolas.geoffray at lip6.fr Tue Sep 28 12:17:12 2010 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 28 Sep 2010 19:17:12 -0000 Subject: [vmkit-commits] [vmkit] r114976 - in /vmkit/trunk/lib/J3: Compiler/JavaAOTCompiler.cpp VMCore/JavaClass.cpp VMCore/JavaClass.h VMCore/JnjvmClassLoader.cpp VMCore/JnjvmClassLoader.h Message-ID: <20100928191712.91ECD2A6C12C@llvm.org> Author: geoffray Date: Tue Sep 28 14:17:12 2010 New Revision: 114976 URL: http://llvm.org/viewvc/llvm-project?rev=114976&view=rev Log: - Change locking of a class by using the java.lang.Class instance - Resolve eagerly classes This should fix the AOT compilation of classes. Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp vmkit/trunk/lib/J3/VMCore/JavaClass.cpp vmkit/trunk/lib/J3/VMCore/JavaClass.h vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h Modified: vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp?rev=114976&r1=114975&r2=114976&view=diff ============================================================================== --- vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp (original) +++ vmkit/trunk/lib/J3/Compiler/JavaAOTCompiler.cpp Tue Sep 28 14:17:12 2010 @@ -1916,16 +1916,11 @@ char* name = file->filename; uint32 size = strlen(name); if (size > 6 && !strcmp(&(name[size - 6]), ".class")) { - UserClassArray* array = bootstrapLoader->upcalls->ArrayOfByte; - ArrayUInt8* res = - (ArrayUInt8*)array->doNew(file->ucsize, JavaThread::get()->getJVM()); - int ok = archive.readFile(res, file); - if (!ok) return; - memcpy(realName, name, size); realName[size - 6] = 0; const UTF8* utf8 = bootstrapLoader->asciizConstructUTF8(realName); - Class* cl = bootstrapLoader->constructClass(utf8, res); + Class* cl = bootstrapLoader->loadName(utf8, true, false, NULL); + assert(cl && "Class not created"); if (cl == ClassArray::SuperArray) M->compileRT = true; classes.push_back(cl); } else if (size > 4 && (!strcmp(&name[size - 4], ".jar") || @@ -1952,6 +1947,12 @@ JavaJITCompiler* Comp = 0; mvm::ThreadAllocator allocator; bootstrapLoader->analyseClasspathEnv(vm->bootstrapLoader->bootClasspathEnv); + uint32 size = strlen(name); + if (size > 4 && + (!strcmp(&name[size - 4], ".jar") || !strcmp(&name[size - 4], ".zip"))) { + bootstrapLoader->analyseClasspathEnv(name); + } + if (!M->clinits->empty()) { Comp = JavaJITCompiler::CreateCompiler("JIT"); Comp->EmitFunctionName = true; @@ -1962,7 +1963,6 @@ bootstrapLoader->upcalls->initialiseClasspath(bootstrapLoader); } - uint32 size = strlen(name); if (size > 4 && (!strcmp(&name[size - 4], ".jar") || !strcmp(&name[size - 4], ".zip"))) { Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.cpp?rev=114976&r1=114975&r2=114976&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.cpp Tue Sep 28 14:17:12 2010 @@ -476,7 +476,8 @@ llvm_gcroot(res, 0); assert(this && "No class when allocating."); assert((this->isInitializing() || - classLoader->getCompiler()->isStaticCompiling()) + classLoader->getCompiler()->isStaticCompiling() || + this == classLoader->bootstrapLoader->upcalls->newClass) && "Uninitialized class when allocating."); assert(getVirtualVT() && "No VT\n"); res = (JavaObject*)gc::operator new(getVirtualSize(), getVirtualVT()); @@ -952,78 +953,18 @@ #ifndef ISOLATE_SHARING void Class::resolveClass() { - JavaObject* exc = 0; - llvm_gcroot(exc, 0); - if (!isResolved() && !isErroneous()) { - acquire(); - if (isResolved() || isErroneous()) { - release(); - } else if (!isResolving()) { - setOwnerClass(JavaThread::get()); - TRY { - readClass(); - } CATCH { - exc = JavaThread::get()->pendingException; - JavaThread::get()->clearException(); - } END_CATCH; - - if (exc != NULL) { - setErroneous(); - setOwnerClass(0); - broadcastClass(); - release(); - JavaThread::get()->throwException(exc); - } - - release(); - - TRY { - loadParents(); - } CATCH { - setInitializationState(loaded); - exc = JavaThread::get()->pendingException; - JavaThread::get()->clearException(); - } END_CATCH; - - if (exc != NULL) { - setErroneous(); - setOwnerClass(0); - JavaThread::get()->throwException(exc); - } - - makeVT(); - JavaCompiler *Comp = classLoader->getCompiler(); - Comp->resolveVirtualClass(this); - Comp->resolveStaticClass(this); - loadExceptions(); - setResolved(); - if (!needsInitialisationCheck()) { - setInitializationState(ready); - } - if (!super) ClassArray::initialiseVT(this); - - bool needInit = needsInitialisationCheck(); - - acquire(); - if (needInit) setResolved(); - setOwnerClass(0); - broadcastClass(); - release(); - } else if (JavaThread::get() != getOwnerClass()) { - while (!isResolved()) { - waitClass(); - if (isErroneous()) break; - } - release(); - - } + if (isResolved() || isErroneous()) return; + readClass(); + loadParents(); + makeVT(); + JavaCompiler *Comp = classLoader->getCompiler(); + Comp->resolveVirtualClass(this); + Comp->resolveStaticClass(this); + loadExceptions(); + setResolved(); + if (!needsInitialisationCheck()) { + setInitializationState(ready); } - - if (isErroneous()) { - JavaThread* th = JavaThread::get(); - th->getJVM()->noClassDefFoundError(name); - } - assert(virtualVT && "No virtual VT after resolution"); } #else @@ -1854,3 +1795,31 @@ if (codeInfoLength) return codeInfo[codeInfoLength - 1].ctpIndex; return 0; } + +void Class::acquire() { + JavaObject* delegatee = NULL; + llvm_gcroot(delegatee, 0); + delegatee = getClassDelegatee(JavaThread::get()->getJVM()); + JavaObject::acquire(delegatee); +} + +void Class::release() { + JavaObject* delegatee = NULL; + llvm_gcroot(delegatee, 0); + delegatee = getClassDelegatee(JavaThread::get()->getJVM()); + JavaObject::release(delegatee); +} + +void Class::waitClass() { + JavaObject* delegatee = NULL; + llvm_gcroot(delegatee, 0); + delegatee = getClassDelegatee(JavaThread::get()->getJVM()); + JavaObject::wait(delegatee); +} + +void Class::broadcastClass() { + JavaObject* delegatee = NULL; + llvm_gcroot(delegatee, 0); + delegatee = getClassDelegatee(JavaThread::get()->getJVM()); + JavaObject::notifyAll(delegatee); +} Modified: vmkit/trunk/lib/J3/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JavaClass.h?rev=114976&r1=114975&r2=114976&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JavaClass.h (original) +++ vmkit/trunk/lib/J3/VMCore/JavaClass.h Tue Sep 28 14:17:12 2010 @@ -503,10 +503,6 @@ /// uint32 staticSize; - /// lock - The lock of this class. - mvm::LockRecursive lock; - mvm::Cond condition; - /// getVirtualSize - Get the virtual size of instances of this class. /// uint32 getVirtualSize() const { return virtualSize; } @@ -688,28 +684,20 @@ /// acquire - Acquire this class lock. /// - void acquire() { - lock.lock(); - } + void acquire(); /// release - Release this class lock. /// - void release() { - lock.unlock(); - } + void release(); /// waitClass - Wait for the class to be loaded/initialized/resolved. /// - void waitClass() { - condition.wait(&lock); - } + void waitClass(); /// broadcastClass - Unblock threads that were waiting on the class being /// loaded/initialized/resolved. /// - void broadcastClass() { - condition.broadcast(); - } + void broadcastClass(); #ifndef ISOLATE Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp?rev=114976&r1=114975&r2=114976&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.cpp Tue Sep 28 14:17:12 2010 @@ -664,21 +664,40 @@ UserClass* JnjvmClassLoader::constructClass(const UTF8* name, ArrayUInt8* bytes) { - llvm_gcroot(bytes, 0); - assert(bytes && "constructing a class without bytes"); + JavaObject* excp = NULL; + llvm_gcroot(bytes, 0); + llvm_gcroot(excp, 0); + UserClass* res = NULL; + lock.lock(); classes->lock.lock(); ClassMap::iterator End = classes->map.end(); ClassMap::iterator I = classes->map.find(name); - UserClass* res = 0; - if (I == End) { - const UTF8* internalName = readerConstructUTF8(name->elements, name->size); - res = new(allocator, "Class") UserClass(this, internalName, bytes); - bool success = classes->map.insert(std::make_pair(internalName, res)).second; - assert(success && "Could not add class in map"); - } else { + classes->lock.unlock(); + if (I != End) { res = ((UserClass*)(I->second)); + } else { + TRY { + const UTF8* internalName = readerConstructUTF8(name->elements, name->size); + res = new(allocator, "Class") UserClass(this, internalName, bytes); + res->resolveClass(); + classes->lock.lock(); + bool success = classes->map.insert(std::make_pair(internalName, res)).second; + classes->lock.unlock(); + assert(success && "Could not add class in map"); + } CATCH { + excp = JavaThread::get()->pendingException; + JavaThread::get()->clearException(); + } END_CATCH; + } + if (excp != NULL) { + JavaThread::get()->throwException(excp); + } + lock.unlock(); + + if (res->super == NULL) { + // java.lang.Object just got created, initialise VTs of arrays. + ClassArray::initialiseVT(res); } - classes->lock.unlock(); return res; } Modified: vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h URL: http://llvm.org/viewvc/llvm-project/vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h?rev=114976&r1=114975&r2=114976&view=diff ============================================================================== --- vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h (original) +++ vmkit/trunk/lib/J3/VMCore/JnjvmClassLoader.h Tue Sep 28 14:17:12 2010 @@ -105,6 +105,10 @@ /// SignMap* javaSignatures; + /// lock - Lock when loading classes. + /// + mvm::LockRecursive lock; + public: /// allocator - Reference to the memory allocator, which will allocate UTF8s, From actong88 at gmail.com Wed Sep 29 17:20:46 2010 From: actong88 at gmail.com (Allan Tong) Date: Wed, 29 Sep 2010 20:20:46 -0400 Subject: [vmkit-commits] [vmkit] r114976 - in /vmkit/trunk/lib/J3: Compiler/JavaAOTCompiler.cpp VMCore/JavaClass.cpp VMCore/JavaClass.h VMCore/JnjvmClassLoader.cpp VMCore/JnjvmClassLoader.h In-Reply-To: <20100928191712.91ECD2A6C12C@llvm.org> References: <20100928191712.91ECD2A6C12C@llvm.org> Message-ID: Unfortunately now it won't even compile libvmjc.so: $ make REQUIRES_FRAME_POINTER=1 llvm[0]: Compiling glibj.zip to llvm Segmentation fault make: *** [glibj.zip.bc] Error 139 The eager resolution of classes causes a stack overflow; gdb showed over 10,000 stack frames at the time of segfault. - Allan On Tue, Sep 28, 2010 at 3:17 PM, Nicolas Geoffray wrote: > Log: > - Change locking of a class by using the java.lang.Class instance > - Resolve eagerly classes > > This should fix the AOT compilation of classes.