From nicolas.geoffray at lip6.fr Mon Sep 1 01:08:09 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 01 Sep 2008 08:08:09 -0000 Subject: [vmkit-commits] [vmkit] r55600 - in /vmkit/branches/isolate/lib/JnJVM: Classpath/Classpath.cpp Classpath/ClasspathVMThread.cpp.inc Isolate/IsolateCommonClass.cpp Isolate/IsolateCommonClass.h VMCore/JavaClass.cpp VMCore/JavaClass.h VMCore/JavaConstantPool.cpp VMCore/JavaMetaJIT.cpp VMCore/JavaRuntimeJIT.cpp VMCore/Jni.cpp VMCore/Jnjvm.cpp VMCore/JnjvmModule.cpp VMCore/JnjvmModuleProvider.cpp Message-ID: <200809010808.m81889Ag025022@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 1 03:08:08 2008 New Revision: 55600 URL: http://llvm.org/viewvc/llvm-project?rev=55600&view=rev Log: Add a definingCl when doing a lookup of a method. Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp Mon Sep 1 03:08:08 2008 @@ -45,7 +45,9 @@ jclass Cl) { UserCommonClass* cl = NativeUtil::resolvedImplClass(Cl, true); - if (cl->lookupMethodDontThrow(Jnjvm::clinitName, Jnjvm::clinitType, true, false)) + UserClass* methodCl = 0; + if (cl->lookupMethodDontThrow(Jnjvm::clinitName, Jnjvm::clinitType, true, + false, methodCl)) return true; else return false; Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc Mon Sep 1 03:08:08 2008 @@ -77,7 +77,8 @@ vm->numThreads++; vm->lock->unlock(); #endif - JavaMethod* method = vmthClass->lookupMethod(Jnjvm::runName, Jnjvm::clinitType, ACC_VIRTUAL, true); + UserClass* methodCl = 0; + JavaMethod* method = vmthClass->lookupMethod(Jnjvm::runName, Jnjvm::clinitType, false, true, methodCl); method->invokeIntSpecial(isolate, (UserClass*)vmthClass, vmThread); Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Mon Sep 1 03:08:08 2008 @@ -217,26 +217,32 @@ JavaMethod* UserCommonClass::lookupMethodDontThrow(const UTF8* name, const UTF8* type, bool isStatic, - bool recurse) { + bool recurse, + UserClass*& methodCl) { CommonClass::FieldCmp CC(name, type); CommonClass::method_map* map = isStatic ? getStaticMethods() : getVirtualMethods(); CommonClass::method_iterator End = map->end(); CommonClass::method_iterator I = map->find(CC); - if (I != End) return I->second; + if (I != End) { + methodCl = (UserClass*)this; + return I->second; + } JavaMethod *cur = 0; if (recurse) { if (super) cur = super->lookupMethodDontThrow(name, type, isStatic, - recurse); + recurse, methodCl); if (cur) return cur; + if (isStatic) { std::vector* interfaces = getInterfaces(); for (std::vector::iterator i = interfaces->begin(), e = interfaces->end(); i!= e; i++) { - cur = (*i)->lookupMethodDontThrow(name, type, isStatic, recurse); + cur = (*i)->lookupMethodDontThrow(name, type, isStatic, recurse, + methodCl); if (cur) return cur; } } @@ -246,8 +252,10 @@ } JavaMethod* UserCommonClass::lookupMethod(const UTF8* name, const UTF8* type, - bool isStatic, bool recurse) { - JavaMethod* res = lookupMethodDontThrow(name, type, isStatic, recurse); + bool isStatic, bool recurse, + UserClass*& methodCl) { + JavaMethod* res = lookupMethodDontThrow(name, type, isStatic, recurse, + methodCl); if (!res) { JavaThread::get()->isolate->noSuchMethodError(this->classDef, name); } @@ -274,20 +282,15 @@ if (recurse) { if (super) cur = super->lookupFieldDontThrow(name, type, isStatic, recurse, definingClass); - if (cur) { - definingClass = (UserClass*)super; - return cur; - } + if (cur) return cur; + if (isStatic) { std::vector* interfaces = getInterfaces(); for (std::vector::iterator i = interfaces->begin(), e = interfaces->end(); i!= e; i++) { cur = (*i)->lookupFieldDontThrow(name, type, isStatic, recurse, definingClass); - if (cur) { - definingClass = *i; - return cur; - } + if (cur) return cur; } } } Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h Mon Sep 1 03:08:08 2008 @@ -174,10 +174,11 @@ JavaMethod* lookupMethodDontThrow(const UTF8* name, const UTF8* type, - bool isStatic, bool recurse); + bool isStatic, bool recurse, + UserClass*& methodCl); JavaMethod* lookupMethod(const UTF8* name, const UTF8* type, - bool isStatic, bool recurse); + bool isStatic, bool recurse, UserClass*& methodCl); JavaField* lookupField(const UTF8* name, const UTF8* type, bool isStatic, bool recurse, Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp Mon Sep 1 03:08:08 2008 @@ -331,26 +331,31 @@ JavaMethod* CommonClass::lookupMethodDontThrow(const UTF8* name, const UTF8* type, bool isStatic, - bool recurse) { + bool recurse, + Class*& methodCl) { CommonClass::FieldCmp CC(name, type); CommonClass::method_map* map = isStatic ? getStaticMethods() : getVirtualMethods(); CommonClass::method_iterator End = map->end(); CommonClass::method_iterator I = map->find(CC); - if (I != End) return I->second; + if (I != End) { + methodCl = (Class*)this; + return I->second; + } JavaMethod *cur = 0; if (recurse) { if (super) cur = super->lookupMethodDontThrow(name, type, isStatic, - recurse); + recurse, methodCl); if (cur) return cur; if (isStatic) { std::vector* interfaces = getInterfaces(); for (std::vector::iterator i = interfaces->begin(), e = interfaces->end(); i!= e; i++) { - cur = (*i)->lookupMethodDontThrow(name, type, isStatic, recurse); + cur = (*i)->lookupMethodDontThrow(name, type, isStatic, recurse, + methodCl); if (cur) return cur; } } @@ -360,8 +365,10 @@ } JavaMethod* CommonClass::lookupMethod(const UTF8* name, const UTF8* type, - bool isStatic, bool recurse) { - JavaMethod* res = lookupMethodDontThrow(name, type, isStatic, recurse); + bool isStatic, bool recurse, + Class*& methodCl) { + JavaMethod* res = lookupMethodDontThrow(name, type, isStatic, recurse, + methodCl); if (!res) { JavaThread::get()->isolate->noSuchMethodError(this, name); } @@ -388,20 +395,14 @@ if (recurse) { if (super) cur = super->lookupFieldDontThrow(name, type, isStatic, recurse, definingClass); - if (cur) { - definingClass = (Class*)super; - return cur; - } + if (cur) return cur; if (isStatic) { std::vector* interfaces = getInterfaces(); for (std::vector::iterator i = interfaces->begin(), e = interfaces->end(); i!= e; i++) { cur = (*i)->lookupFieldDontThrow(name, type, isStatic, recurse, definingClass); - if (cur) { - definingClass = *i; - return cur; - } + if (cur) return cur; } } } Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h Mon Sep 1 03:08:08 2008 @@ -370,12 +370,12 @@ /// Do not throw if the method is not found. /// JavaMethod* lookupMethodDontThrow(const UTF8* name, const UTF8* type, - bool isStatic, bool recurse); + bool isStatic, bool recurse, Class*& cl); /// lookupMethod - Lookup a method and throw an exception if not found. /// JavaMethod* lookupMethod(const UTF8* name, const UTF8* type, bool isStatic, - bool recurse); + bool recurse, Class*& cl); /// lookupFieldDontThrow - Lookup a field in the field map of this class. Do /// not throw if the field is not found. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp Mon Sep 1 03:08:08 2008 @@ -351,9 +351,10 @@ const UTF8* utf8 = UTF8At(ctpDef[ntIndex] >> 16); cl = getMethodClassIfLoaded(entry >> 16); if (cl && cl->status >= classRead) { + Class* methodCl = 0; // lookup the method - meth = - cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access), false); + meth = cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access), + false, methodCl); } } @@ -395,8 +396,9 @@ CommonClass* cl = getMethodClassIfLoaded(entry >> 16); if (cl && cl->status >= classRead) { // lookup the method - meth = - cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access), false); + Class* methodCl = 0; + meth = cl->lookupMethodDontThrow(utf8, sign->keyName, isStatic(access), + false, methodCl); if (meth) { // don't throw if no meth, the exception will be thrown just in time JnjvmModule* M = classDef->classLoader->TheModule; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp Mon Sep 1 03:08:08 2008 @@ -34,9 +34,10 @@ cl->initialiseClass(vm); bool stat = access == ACC_STATIC ? true : false; + UserClass* methodCl = 0; JavaMethod* method = cl->lookupMethod(loader->asciizConstructUTF8(func), loader->asciizConstructUTF8(sign), stat, - true); + true, methodCl); va_list ap; va_start(ap, access); if (stat) { @@ -141,7 +142,8 @@ } \ \ verifyNull(obj);\ - JavaMethod* meth = obj->classOf->lookupMethod(name, type, false, true);\ + UserClass* methodCl = 0; \ + JavaMethod* meth = obj->classOf->lookupMethod(name, type, false, true, methodCl);\ \ Signdef* sign = getSignature(); \ void* func = meth->compiledPtr();\ Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Mon Sep 1 03:08:08 2008 @@ -58,12 +58,12 @@ } if (!rcache) { + UserClass* methodCl = 0; + JavaMethod* dmeth = ocl->lookupMethod(utf8, sign->keyName, false, true, + methodCl); #ifndef MULTIPLE_VM - JavaMethod* dmeth = ocl->lookupMethod(utf8, sign->keyName, false, true); assert(dmeth->classDef->isReady() && "Class not ready in a virtual lookup."); -#else - JavaMethod* dmeth = ocl->lookupMethod(utf8, sign->keyName, false, true); #endif if (cache->methPtr) { rcache = new CacheNode(enveloppe); @@ -73,6 +73,9 @@ rcache->methPtr = dmeth->compiledPtr(); rcache->lastCible = (UserClass*)ocl; +#ifdef MULTIPLE_VM + rcache->definingCtp = methodCl->getConstantPool(); +#endif } @@ -156,8 +159,9 @@ Signdef* sign = 0; caller->getConstantPool()->resolveMethod(index, cl, utf8, sign); + UserClass* methodCl = 0; JavaMethod* dmeth = cl->lookupMethodDontThrow(utf8, sign->keyName, false, - true); + true, methodCl); if (!dmeth) { va_list ap; va_start(ap, index); @@ -166,7 +170,8 @@ assert(obj->classOf->isReady() && "Class not ready in a virtual lookup."); // Arg, the bytecode is buggy! Perform the lookup on the object class // and do not update offset. - dmeth = obj->classOf->lookupMethod(utf8, sign->keyName, false, true); + dmeth = obj->classOf->lookupMethod(utf8, sign->keyName, false, true, + methodCl); } else { caller->getConstantPool()->ctpRes[index] = (void*)dmeth->offset; } Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp Mon Sep 1 03:08:08 2008 @@ -140,9 +140,10 @@ UserCommonClass* cl = NativeUtil::resolvedImplClass(clazz, true); if (cl->isArray()) assert(0 && "implement me"); JavaObject* res = ((UserClass*)cl)->doNew(vm); - JavaMethod* init = - cl->lookupMethod(Jnjvm::initName, - cl->classLoader->asciizConstructUTF8("(Ljava/lang/String;)V"), 0, 1); + UserClass* methodCl = 0; + JavaMethod* init = cl->lookupMethod(Jnjvm::initName, + cl->classLoader->asciizConstructUTF8("(Ljava/lang/String;)V"), + false, true, methodCl); init->invokeIntSpecial(vm, (UserClass*)cl, res, vm->asciizToStr(msg)); th->pendingException = res; th->returnFromNative(); @@ -300,9 +301,11 @@ UserCommonClass* cl = NativeUtil::resolvedImplClass(clazz, true); const UTF8* name = cl->classLoader->asciizConstructUTF8(aname); const UTF8* type = cl->classLoader->asciizConstructUTF8(atype); + UserClass* methodCl = 0; JavaMethod* meth = cl->lookupMethod( name->javaToInternal(cl->classLoader->hashUTF8, 0, name->size), - type->javaToInternal(cl->classLoader->hashUTF8, 0, type->size), false, true); + type->javaToInternal(cl->classLoader->hashUTF8, 0, type->size), false, + true, methodCl); return (jmethodID)meth; @@ -1134,9 +1137,11 @@ UserCommonClass* cl = NativeUtil::resolvedImplClass(clazz, true); const UTF8* name = cl->classLoader->asciizConstructUTF8(aname); const UTF8* type = cl->classLoader->asciizConstructUTF8(atype); + UserClass* methodCl = 0; JavaMethod* meth = cl->lookupMethod( name->javaToInternal(cl->classLoader->hashUTF8, 0, name->size), - type->javaToInternal(cl->classLoader->hashUTF8, 0, type->size), true, true); + type->javaToInternal(cl->classLoader->hashUTF8, 0, type->size), true, + true, methodCl); return (jmethodID)meth; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp Mon Sep 1 03:08:08 2008 @@ -109,9 +109,10 @@ cl->resolveStaticClass(); status = inClinit; + UserClass* methodCl; JavaMethod* meth = lookupMethodDontThrow(Jnjvm::clinitName, Jnjvm::clinitType, true, - false); + false, methodCl); PRINT_DEBUG(JNJVM_LOAD, 0, COLOR_NORMAL, "; ", 0); PRINT_DEBUG(JNJVM_LOAD, 0, LIGHT_GREEN, "clinit ", 0); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Mon Sep 1 03:08:08 2008 @@ -226,8 +226,10 @@ } } else { + Class* methodCl = 0; JavaMethod* parent = cl->super? - cl->super->lookupMethodDontThrow(meth->name, meth->type, false, true) : + cl->super->lookupMethodDontThrow(meth->name, meth->type, false, true, + methodCl) : 0; uint64_t offset = 0; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp?rev=55600&r1=55599&r2=55600&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Mon Sep 1 03:08:08 2008 @@ -36,7 +36,9 @@ Signdef* sign = 0; ctpInfo->resolveMethod(index, cl, utf8, sign); - JavaMethod* meth = cl->lookupMethod(utf8, sign->keyName, isStatic, true); + Class* methodCl = 0; + JavaMethod* meth = cl->lookupMethod(utf8, sign->keyName, isStatic, true, + methodCl); #ifndef MULTIPLE_VM // A multi environment would have already initialized the class. Besides, From nicolas.geoffray at lip6.fr Thu Sep 4 09:13:09 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 04 Sep 2008 16:13:09 -0000 Subject: [vmkit-commits] [vmkit] r55770 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h Message-ID: <200809041613.m84GD9NL003051@zion.cs.uiuc.edu> Author: geoffray Date: Thu Sep 4 11:13:08 2008 New Revision: 55770 URL: http://llvm.org/viewvc/llvm-project?rev=55770&view=rev Log: Wrong comment. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h?rev=55770&r1=55769&r2=55770&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h Thu Sep 4 11:13:08 2008 @@ -81,7 +81,7 @@ /// uint32 nbb; - /// nbw - Number of words of instances if this assessor (e.g. 8 for "D"). + /// nbw - Number of words of instances if this assessor (e.g. 2 for "D"). /// uint32 nbw; From nicolas.geoffray at lip6.fr Thu Sep 4 09:45:09 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 04 Sep 2008 16:45:09 -0000 Subject: [vmkit-commits] [vmkit] r55771 - in /vmkit/branches/isolate/lib/JnJVM/Isolate: IsolateCommonClass.cpp IsolateCommonClass.h Message-ID: <200809041645.m84GjAWc004159@zion.cs.uiuc.edu> Author: geoffray Date: Thu Sep 4 11:45:06 2008 New Revision: 55771 URL: http://llvm.org/viewvc/llvm-project?rev=55771&view=rev Log: Implement UserClassArray resolution methods. Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp?rev=55771&r1=55770&r2=55771&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Thu Sep 4 11:45:06 2008 @@ -195,23 +195,18 @@ return alloc->allocateObject(sz + size * sizeof(void*), VT); } -AssessorDesc* UserClassArray::funcs() { - fprintf(stderr, "implement me"); - abort(); - return 0; -} - - UserClassPrimitive* AssessorDesc::getPrimitiveClass() const { - fprintf(stderr, "implement me"); - abort(); - return 0; + Jnjvm* vm = JavaThread::get()->isolate; + UserClassArray* arrayCl = vm->arrayClasses[numId]; + UserClassPrimitive* cl = (UserClassPrimitive*)arrayCl->baseClass(); + assert(cl && "Primitive array class does not have a primitive."); + return cl; } UserClassArray* AssessorDesc::getArrayClass() const { - fprintf(stderr, "implement me"); - abort(); - return 0; + Jnjvm* vm = JavaThread::get()->isolate; + UserClassArray* arrayCl = vm->arrayClasses[numId]; + return arrayCl; } JavaMethod* UserCommonClass::lookupMethodDontThrow(const UTF8* name, @@ -309,3 +304,9 @@ } return res; } + +void UserConstantPool::print(mvm::PrintBuffer* buf) const { + buf->write("User constant pool of <"); + getClass()->classDef->print(buf); + buf->write(">"); +} Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h?rev=55771&r1=55770&r2=55771&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h Thu Sep 4 11:45:06 2008 @@ -360,7 +360,11 @@ return _baseClass; } - AssessorDesc* funcs(); + AssessorDesc* funcs() { + if (_funcs == 0) + resolveComponent(); + return _funcs; + } }; class UserClassPrimitive : public UserCommonClass { @@ -394,17 +398,17 @@ void resolveField(uint32 index, UserCommonClass*& cl, const UTF8*& utf8, Typedef*& sign); - UserClass* getClass() { + UserClass* getClass() const { return (UserClass*)ctpRes[0]; } - JavaConstantPool* getSharedPool() { + JavaConstantPool* getSharedPool() const { return ((Class*)(getClass()->classDef))->ctpInfo; } /// UTF8At - Get the UTF8 referenced from this string entry. /// - const UTF8* UTF8AtForString(uint32 entry) { + const UTF8* UTF8AtForString(uint32 entry) const { return getSharedPool()->UTF8AtForString(entry); } @@ -423,6 +427,8 @@ UserCommonClass* isClassLoaded(uint32 entry); + virtual void print(mvm::PrintBuffer *buf) const; + }; } // end namespace jnjvm From nicolas.geoffray at lip6.fr Thu Sep 4 09:45:50 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 04 Sep 2008 16:45:50 -0000 Subject: [vmkit-commits] [vmkit] r55772 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp Message-ID: <200809041645.m84Gjo1a004189@zion.cs.uiuc.edu> Author: geoffray Date: Thu Sep 4 11:45:50 2008 New Revision: 55772 URL: http://llvm.org/viewvc/llvm-project?rev=55772&view=rev Log: Set the primitive class of an array when initializing the VM. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp?rev=55772&r1=55771&r2=55772&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp Thu Sep 4 11:45:50 2008 @@ -76,6 +76,10 @@ if (bid != I_PARG && bid != I_PARD && bid != I_REF && bid != I_TAB) { res->primitiveClass = new UserClassPrimitive(loader, res->UTF8Name, nb); + if (res->arrayClass) { + res->arrayClass->_baseClass = res->primitiveClass; + res->arrayClass->_funcs = res; + } } else { res->primitiveClass = 0; } From nicolas.geoffray at lip6.fr Thu Sep 4 09:46:31 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 04 Sep 2008 16:46:31 -0000 Subject: [vmkit-commits] [vmkit] r55773 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Message-ID: <200809041646.m84GkVpl004225@zion.cs.uiuc.edu> Author: geoffray Date: Thu Sep 4 11:46:31 2008 New Revision: 55773 URL: http://llvm.org/viewvc/llvm-project?rev=55773&view=rev Log: Bugfix for interface calls. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp?rev=55773&r1=55772&r2=55773&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Thu Sep 4 11:46:31 2008 @@ -2061,9 +2061,9 @@ Value* meth = new BitCastInst(_meth, virtualPtrType, "", currentBlock); #ifdef MULTIPLE_VM - cache = new LoadInst(cachePtr, "", currentBlock); + Value* cache2 = new LoadInst(cachePtr, "", currentBlock); Value* newCtpCache = CallInst::Create(JnjvmModule::GetCtpCacheNodeFunction, - cache, "", currentBlock); + cache2, "", currentBlock); args.push_back(newCtpCache); #endif Value* ret = invoke(meth, args, "", currentBlock); From nicolas.geoffray at lip6.fr Thu Sep 4 09:46:58 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 04 Sep 2008 16:46:58 -0000 Subject: [vmkit-commits] [vmkit] r55774 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Message-ID: <200809041646.m84Gkx8w004249@zion.cs.uiuc.edu> Author: geoffray Date: Thu Sep 4 11:46:58 2008 New Revision: 55774 URL: http://llvm.org/viewvc/llvm-project?rev=55774&view=rev Log: Bugfix for INSTANCEOF. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=55774&r1=55773&r2=55774&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Thu Sep 4 11:46:58 2008 @@ -2029,6 +2029,7 @@ case INSTANCEOF : { uint16 index = readU2(bytecodes, i); +#ifndef MULTIPLE_VM CommonClass* dcl = compilingClass->ctpInfo->getMethodClassIfLoaded(index); @@ -2039,6 +2040,9 @@ } else { clVar = getResolvedClass(index, false); } +#else + Value* clVar = getResolvedClass(index, false); +#endif std::vector args; args.push_back(pop()); args.push_back(clVar); From nicolas.geoffray at lip6.fr Thu Sep 4 09:48:03 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 04 Sep 2008 16:48:03 -0000 Subject: [vmkit-commits] [vmkit] r55775 - /vmkit/branches/isolate/lib/JnJVM/VMCore/LowerConstantCalls.cpp Message-ID: <200809041648.m84Gm3P7004326@zion.cs.uiuc.edu> Author: geoffray Date: Thu Sep 4 11:48:03 2008 New Revision: 55775 URL: http://llvm.org/viewvc/llvm-project?rev=55775&view=rev Log: Lower GetJnjvmExceptionClass. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/LowerConstantCalls.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/LowerConstantCalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/LowerConstantCalls.cpp?rev=55775&r1=55774&r2=55775&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/LowerConstantCalls.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/LowerConstantCalls.cpp Thu Sep 4 11:48:03 2008 @@ -354,6 +354,17 @@ Value* VT = new LoadInst(VTPtr, "", CI); CI->replaceAllUsesWith(VT); CI->eraseFromParent(); + } else if (V == jnjvm::JnjvmModule::GetJnjvmExceptionClassFunction) { + Changed = true; + Value* val = Call.getArgument(0); + std::vector indexes; + indexes.push_back(mvm::jit::constantZero); + indexes.push_back(mvm::jit::constantOne); + Value* VTPtr = GetElementPtrInst::Create(val, indexes.begin(), + indexes.end(), "", CI); + Value* VT = new LoadInst(VTPtr, "", CI); + CI->replaceAllUsesWith(VT); + CI->eraseFromParent(); } #endif } From nicolas.geoffray at lip6.fr Thu Sep 4 09:48:31 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 04 Sep 2008 16:48:31 -0000 Subject: [vmkit-commits] [vmkit] r55776 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.cpp Message-ID: <200809041648.m84GmWYm004385@zion.cs.uiuc.edu> Author: geoffray Date: Thu Sep 4 11:48:31 2008 New Revision: 55776 URL: http://llvm.org/viewvc/llvm-project?rev=55776&view=rev Log: Set to zero the definingCtp when creating a cache node. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.cpp?rev=55776&r1=55775&r2=55776&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaCache.cpp Thu Sep 4 11:48:31 2008 @@ -41,6 +41,9 @@ lastCible = 0; methPtr = 0; next = 0; +#ifdef MULTIPLE_VM + definingCtp = 0; +#endif enveloppe = E; } From nicolas.geoffray at lip6.fr Fri Sep 12 06:42:03 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 13:42:03 -0000 Subject: [vmkit-commits] [vmkit] r56146 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp Message-ID: <200809121342.m8CDg32A016303@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 08:42:01 2008 New Revision: 56146 URL: http://llvm.org/viewvc/llvm-project?rev=56146&view=rev Log: Implement getCallingClass for isolate environment. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp?rev=56146&r1=56145&r2=56146&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp Fri Sep 12 08:42:01 2008 @@ -104,13 +104,29 @@ return 0; } #else -UserClass* JavaJIT::getCallingClassWalker() { - fprintf(stderr, "implement me"); - abort(); -} UserClass* JavaJIT::getCallingClass() { - fprintf(stderr, "implement me"); - abort(); + unsigned int* top; + register unsigned int **cur = ⊤ + register unsigned int **max = (unsigned int**)mvm::Thread::get()->baseSP; + + void* obj = 0; + int i = 0; + + for(; curgetVirtualTable() == UserConstantPool::VT) { + if (i == 1) { + return ((UserConstantPool*)obj)->getClass(); + } + ++i; + } + } + return 0; +} + +UserClass* JavaJIT::getCallingClassWalker() { + return getCallingClass(); } #endif From nicolas.geoffray at lip6.fr Fri Sep 12 06:45:28 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 13:45:28 -0000 Subject: [vmkit-commits] [vmkit] r56147 - in /vmkit/branches/isolate/lib/JnJVM/Isolate: IsolateCommonClass.cpp IsolateCommonClass.h Message-ID: <200809121345.m8CDjSCm016456@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 08:45:27 2008 New Revision: 56147 URL: http://llvm.org/viewvc/llvm-project?rev=56147&view=rev Log: Make the static instance of user classes in the common class (for now). Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp?rev=56147&r1=56146&r2=56147&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Fri Sep 12 08:45:27 2008 @@ -310,3 +310,9 @@ getClass()->classDef->print(buf); buf->write(">"); } + +void UserCommonClass::print(mvm::PrintBuffer* buf) const { + buf->write("User class of <"); + classDef->print(buf); + buf->write(">"); +} Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h?rev=56147&r1=56146&r2=56147&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.h Fri Sep 12 08:45:27 2008 @@ -78,6 +78,8 @@ /// ctpInfo - The private constant pool of this class. /// UserConstantPool* ctpInfo; + + JavaObject* staticInstance; //===----------------------------------------------------------------------===// // @@ -275,12 +277,13 @@ } UserCommonClass(); + + virtual void print(mvm::PrintBuffer *buf) const; }; class UserClass : public UserCommonClass { public: static VirtualTable* VT; - JavaObject* staticInstance; virtual void TRACER; From nicolas.geoffray at lip6.fr Fri Sep 12 06:45:57 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 13:45:57 -0000 Subject: [vmkit-commits] [vmkit] r56148 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp Message-ID: <200809121345.m8CDjvkI016488@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 08:45:57 2008 New Revision: 56148 URL: http://llvm.org/viewvc/llvm-project?rev=56148&view=rev Log: Set the primitive array class as ready. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp?rev=56148&r1=56147&r2=56148&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp Fri Sep 12 08:45:57 2008 @@ -79,6 +79,7 @@ if (res->arrayClass) { res->arrayClass->_baseClass = res->primitiveClass; res->arrayClass->_funcs = res; + res->arrayClass->status = ready; } } else { res->primitiveClass = 0; From nicolas.geoffray at lip6.fr Fri Sep 12 06:48:12 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 13:48:12 -0000 Subject: [vmkit-commits] [vmkit] r56149 - /vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp.inc Message-ID: <200809121348.m8CDmCuZ016569@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 08:48:12 2008 New Revision: 56149 URL: http://llvm.org/viewvc/llvm-project?rev=56149&view=rev Log: Include exceptions constructor in the stacktrace (for now). Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp.inc Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp.inc?rev=56149&r1=56148&r2=56149&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThrowable.cpp.inc Fri Sep 12 08:48:12 2008 @@ -47,7 +47,6 @@ } -#ifndef MULTIPLE_VM JavaObject* consStackElement(JavaMethod* meth, int* ip) { Jnjvm* vm = JavaThread::get()->isolate; JavaObject* methodName = vm->UTF8ToStr(meth->name); @@ -102,7 +101,11 @@ while (stack[i] != 0) { JavaMethod* meth = JavaJIT::IPToJavaMethod(stack[i++]); +#ifdef MULTIPLE_VM + if (meth) { +#else if (meth && !meth->classDef->subclassOf(vm->upcalls->newThrowable)) { +#endif first = i - 1; break; } @@ -112,6 +115,5 @@ return res; } -#endif } From nicolas.geoffray at lip6.fr Fri Sep 12 06:50:56 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 13:50:56 -0000 Subject: [vmkit-commits] [vmkit] r56150 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp Message-ID: <200809121350.m8CDouZE016686@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 08:50:56 2008 New Revision: 56150 URL: http://llvm.org/viewvc/llvm-project?rev=56150&view=rev Log: Better assertions. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=56150&r1=56149&r2=56150&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp Fri Sep 12 08:50:56 2008 @@ -436,7 +436,8 @@ assert(sign && "No cached signature after JITting"); utf8 = UTF8At(ctpDef[ntIndex] >> 16); cl = loadClass(entry >> 16); - assert(cl && cl->isResolved() && "No class after loadClass"); + assert(cl && "No class after loadClass"); + assert(cl->isResolved() && "Class not resolved after loadClass"); } void JavaConstantPool::resolveField(uint32 index, CommonClass*& cl, @@ -447,7 +448,8 @@ assert(sign && "No cached Typedef after JITting"); utf8 = UTF8At(ctpDef[ntIndex] >> 16); cl = loadClass(entry >> 16); - assert(cl && cl->isResolved() && "No class after loadClass"); + assert(cl && "No class after loadClass"); + assert(cl->isResolved() && "Class not resolved after loadClass"); } JavaField* JavaConstantPool::lookupField(uint32 index, bool stat) { From nicolas.geoffray at lip6.fr Fri Sep 12 06:51:31 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 13:51:31 -0000 Subject: [vmkit-commits] [vmkit] r56151 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaString.cpp Message-ID: <200809121351.m8CDpVjZ016713@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 08:51:31 2008 New Revision: 56151 URL: http://llvm.org/viewvc/llvm-project?rev=56151&view=rev Log: Temporary hack for shared UTF8s. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaString.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaString.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaString.cpp?rev=56151&r1=56150&r2=56151&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaString.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaString.cpp Fri Sep 12 08:51:31 2008 @@ -19,6 +19,11 @@ JavaString* JavaString::stringDup(const UTF8*& utf8, Jnjvm* vm) { UserClass* cl = vm->upcalls->newString; JavaString* res = (JavaString*)malloc(cl->getVirtualSize()); +#ifdef MULTIPLE_VM + /// Do this for now, but we will have to change it to duplicate the UTF8. + /// UTF8 that dont have a class are shared UTF8. + if (!utf8->classOf) ((UTF8*)utf8)->classOf = vm->upcalls->ArrayOfChar; +#endif ((void**)res)[0] = cl->getVirtualVT(); res->classOf = cl; From nicolas.geoffray at lip6.fr Fri Sep 12 06:53:16 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 13:53:16 -0000 Subject: [vmkit-commits] [vmkit] r56152 - in /vmkit/branches/isolate/lib/JnJVM/VMCore: JavaRuntimeJIT.cpp Jnjvm.cpp Jnjvm.h Message-ID: <200809121353.m8CDrGaH016777@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 08:53:16 2008 New Revision: 56152 URL: http://llvm.org/viewvc/llvm-project?rev=56152&view=rev Log: Implement isolate specific runtime functions. New signature of function classCastException. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.h Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=56152&r1=56151&r2=56152&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Fri Sep 12 08:53:16 2008 @@ -150,6 +150,35 @@ ctpInfo->ctpRes[index] = enveloppe; return (void*)enveloppe; } + +extern "C" void* staticCtpLookup(UserClass* cl, uint32 index) { + UserConstantPool* ctpInfo = cl->getConstantPool(); + JavaConstantPool* shared = ctpInfo->getSharedPool(); + uint32 clIndex = shared->getClassIndexFromMethod(index); + UserClass* refCl = (UserClass*)ctpInfo->loadClass(clIndex); + refCl->initialiseClass(JavaThread::get()->isolate); + + CommonClass* baseCl = 0; + const UTF8* utf8 = 0; + Signdef* sign = 0; + + shared->resolveMethod(index, baseCl, utf8, sign); + UserClass* methodCl = 0; + refCl->lookupMethod(utf8, sign->keyName, isStatic, true, methodCl); + ctpInfo->ctpRes[index] = methodCl->getConstantPool(); + shared->ctpRes[clIndex] = refCl->classDef; + return (void*)methodCl->getConstantPool(); +} + +extern "C" UserClassArray* getArrayClass(UserCommonClass* cl) { + JnjvmClassLoader* JCL = cl->classLoader; + const UTF8* arrayName = + AssessorDesc::constructArrayName(JCL, 0, 1, cl->getName()); + + UserClassArray* dcl = JCL->constructArray(arrayName); + return dcl; +} + #endif #ifndef WITHOUT_VTABLE @@ -239,7 +268,7 @@ } extern "C" void jnjvmClassCastException(JavaObject* obj, UserCommonClass* cl) { - JavaThread::get()->isolate->classCastException(""); + JavaThread::get()->isolate->classCastException(obj, cl); } extern "C" void indexOutOfBoundsException(JavaObject* obj, sint32 index) { Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp?rev=56152&r1=56151&r2=56152&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp Fri Sep 12 08:53:16 2008 @@ -263,7 +263,7 @@ msg); } -void Jnjvm::classCastException(const char* msg) { +void Jnjvm::classCastException(JavaObject* obj, UserCommonClass* cl) { error(upcalls->ClassCastException, upcalls->InitClassCastException, msg); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.h?rev=56152&r1=56151&r2=56152&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.h Fri Sep 12 08:53:16 2008 @@ -292,7 +292,7 @@ void illegalArgumentExceptionForField(JavaField* field, UserCommonClass* required, UserCommonClass* given); void illegalArgumentException(const char* msg); - void classCastException(const char* msg); + void classCastException(JavaObject* obj, UserCommonClass* cl); void unknownError(const char* fmt, ...); void noSuchFieldError(CommonClass* cl, const UTF8* name); void noSuchMethodError(CommonClass* cl, const UTF8* name); From nicolas.geoffray at lip6.fr Fri Sep 12 07:20:23 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 14:20:23 -0000 Subject: [vmkit-commits] [vmkit] r56153 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Message-ID: <200809121420.m8CEKOCo017680@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 09:20:20 2008 New Revision: 56153 URL: http://llvm.org/viewvc/llvm-project?rev=56153&view=rev Log: Don't put the llvm::Function in the ctpRes, as it's the offset in the VT for special calls that should be there. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp?rev=56153&r1=56152&r2=56153&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Fri Sep 12 09:20:20 2008 @@ -50,9 +50,6 @@ meth->compiledPtr(); - LLVMMethodInfo* LMI = ((JnjvmModule*)TheModule)->getMethodInfo(meth); - ctpInfo->ctpRes[index] = LMI->getMethod(); - return meth; } @@ -169,7 +166,7 @@ Signdef* sign, bool stat) { void* key = &(cl->getConstantPool()->ctpRes[index]); - + reverse_callback_iterator CI = reverseCallbacks.find(key); if (CI != reverseCallbacks.end()) { return CI->second; From nicolas.geoffray at lip6.fr Fri Sep 12 07:21:47 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 14:21:47 -0000 Subject: [vmkit-commits] [vmkit] r56154 - in /vmkit/branches/isolate/lib/JnJVM/VMCore: JavaJIT.cpp JavaJIT.h Message-ID: <200809121421.m8CELlOh017734@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 09:21:47 2008 New Revision: 56154 URL: http://llvm.org/viewvc/llvm-project?rev=56154&view=rev Log: Bugfixes and implementation of getCtpClass and getStaticInstance. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.h Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp?rev=56154&r1=56153&r2=56154&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Fri Sep 12 09:21:47 2008 @@ -56,10 +56,12 @@ CommonClass* cl = 0; JavaMethod* meth = 0; ctpInfo->infoOfMethod(index, ACC_VIRTUAL, cl, meth); - + +#if !defined(MULTIPLE_VM) if ((cl && isFinal(cl->access)) || (meth && (isFinal(meth->access) || isPrivate(meth->access)))) return invokeSpecial(index); +#endif #if !defined(WITHOUT_VTABLE) && !defined(MULTIPLE_VM) @@ -204,9 +206,16 @@ uint32 index = 0; if (stat) { +#ifdef MULTIPLE_VM + Value* val = getClassCtp(); + Value* res = CallInst::Create(JnjvmModule::GetClassDelegateeFunction, + val, "", currentBlock); + nativeArgs.push_back(res); +#else LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(compilingClass); nativeArgs.push_back(LCI->getDelegatee(this)); +#endif index = 2; } else { index = 1; @@ -392,9 +401,25 @@ #ifdef MULTIPLE_VM Value* JavaJIT::getStaticInstanceCtp() { - /// get the -1 offset of the ctp - fprintf(stderr, "implement me"); - abort(); + Value* cl = getClassCtp(); + std::vector indexes; //[3]; + indexes.push_back(mvm::jit::constantZero); + indexes.push_back(mvm::jit::constantSeven); + Value* arg1 = GetElementPtrInst::Create(cl, indexes.begin(), + indexes.end(), "", currentBlock); + arg1 = new LoadInst(arg1, "", false, currentBlock); + return arg1; + +} + +Value* JavaJIT::getClassCtp() { + std::vector indexes; //[3]; + indexes.push_back(mvm::jit::constantOne); + Value* arg1 = GetElementPtrInst::Create(ctpCache, indexes.begin(), + indexes.end(), "", currentBlock); + arg1 = new LoadInst(arg1, "", false, currentBlock); + arg1 = new BitCastInst(arg1, JnjvmModule::JavaClassType, "", currentBlock); + return arg1; } #endif @@ -741,6 +766,10 @@ i++; ctpCache = i; #endif + Value* addrCtpCache = new AllocaInst(JnjvmModule::ConstantPoolType, "", + currentBlock); + /// make it volatile to be sure it's on the stack + new StoreInst(ctpCache, addrCtpCache, true, currentBlock); #endif unsigned nbe = readExceptionTable(reader); @@ -759,7 +788,8 @@ beginSynchronize(); compileOpcodes(&compilingClass->bytes->elements[start], codeLen); - + + assert(stack.size() == 0 && "Stack not empty after compiling bytecode"); // Fix a javac(?) bug where a method only throws an exception and des // not return. pred_iterator PI = pred_begin(endBlock); @@ -1125,16 +1155,20 @@ push(ConstantFP::get(Type::FloatTy, ctpInfo->FloatAt(index)), AssessorDesc::dFloat); } else if (type == JavaConstantPool::ConstantClass) { +#ifndef MULTIPLE_VM if (ctpInfo->ctpRes[index]) { CommonClass* cl = (CommonClass*)(ctpInfo->ctpRes[index]); LLVMCommonClassInfo* LCI = module->getClassInfo(cl); push(LCI->getDelegatee(this), AssessorDesc::dRef); } else { +#endif Value* val = getResolvedClass(index, false); Value* res = CallInst::Create(JnjvmModule::GetClassDelegateeFunction, val, "", currentBlock); push(res, AssessorDesc::dRef); +#ifndef MULTIPLE_VM } +#endif } else { JavaThread::get()->isolate->unknownError("unknown type %d", type); } @@ -1541,11 +1575,10 @@ signature, meth); #if defined(MULTIPLE_VM) - uint32 clIndex = ctpInfo->getClassIndexFromMethod(index); - Value* cl = getResolvedClass(clIndex, true); - - Value* newCtpCache = CallInst::Create(JnjvmModule::GetCtpClassFunction, cl, - "", currentBlock); + Value* newCtpCache = getConstantPoolAt(index, + JnjvmModule::StaticCtpLookupFunction, + JnjvmModule::ConstantPoolType, 0, + false); args.push_back(newCtpCache); #endif Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.h?rev=56154&r1=56153&r2=56154&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.h Fri Sep 12 09:21:47 2008 @@ -261,6 +261,7 @@ #if defined(MULTIPLE_VM) llvm::Value* ctpCache; llvm::Value* getStaticInstanceCtp(); + llvm::Value* getClassCtp(); #endif static const char* OpcodeNames[256]; From nicolas.geoffray at lip6.fr Fri Sep 12 07:24:14 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 14:24:14 -0000 Subject: [vmkit-commits] [vmkit] r56155 - in /vmkit/branches/isolate/lib/JnJVM: LLVMRuntime/runtime-default.ll LLVMRuntime/runtime-isolate.ll VMCore/JnjvmModule.cpp VMCore/JnjvmModule.h Message-ID: <200809121424.m8CEOEMs017821@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 09:24:14 2008 New Revision: 56155 URL: http://llvm.org/viewvc/llvm-project?rev=56155&view=rev Log: Add new runtime functions for an isolate environment, and add the static instance in the type of java classes. Modified: vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-default.ll vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-isolate.ll vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h Modified: vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-default.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-default.ll?rev=56155&r1=56154&r2=56155&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-default.ll (original) +++ vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-default.ll Fri Sep 12 09:24:14 2008 @@ -19,7 +19,8 @@ ;;; Field 5 - The depth of the class in its super hierarchy. ;;; Field 6 - The class state (resolved, initialized, ...) ;;; field 7 - The constant pool, only for multi vm environment. -%JavaClass = type { %VT, i32, %VT ,%JavaClass**, i32, i32, %ConstantPool* } +;;; field 8 - The static instance, only for multi vm environment. +%JavaClass = type { %VT, i32, %VT ,%JavaClass**, i32, i32, %ConstantPool*, %JavaObject* } ;;; The root of all Java Objects: a VT, a class and a lock. %JavaObject = type { %VT, %JavaClass*, i32 } Modified: vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-isolate.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-isolate.ll?rev=56155&r1=56154&r2=56155&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-isolate.ll (original) +++ vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-isolate.ll Fri Sep 12 09:24:14 2008 @@ -9,6 +9,10 @@ ;;; constant pool. declare i8* @stringLookup(%JavaClass*, i32, ...) +;;; staticCtpLookup - Find the user constant pool at the given offset in the +;;; constant pool. +declare i8* @staticCtpLookup(%JavaClass*, i32, ...) + ;;; getCtpCacheNode - Get the constant pool cache of a cache node. This is a ;;; constant call because the cache node never changes. declare %ConstantPool* @getCtpCacheNode(%CacheNode*) readnone @@ -24,3 +28,6 @@ ;;; getJnjvmArrayClass - Get the array user class of the index, for the given ;;; isolate. declare %JavaClass* @getJnjvmArrayClass(%Jnjvm*, i32) readnone + +;;; getArrayClass - Get the array user class of the user class. +declare %JavaClass* @getArrayClass(%JavaClass*) readnone Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=56155&r1=56154&r2=56155&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Fri Sep 12 09:24:14 2008 @@ -116,6 +116,8 @@ llvm::Function* JnjvmModule::EnveloppeLookupFunction = 0; llvm::Function* JnjvmModule::GetJnjvmExceptionClassFunction = 0; llvm::Function* JnjvmModule::GetJnjvmArrayClassFunction = 0; +llvm::Function* JnjvmModule::StaticCtpLookupFunction = 0; +llvm::Function* JnjvmModule::GetArrayClassFunction = 0; #endif llvm::Function* JnjvmModule::GetClassDelegateeFunction = 0; llvm::Function* JnjvmModule::ArrayLengthFunction = 0; @@ -1025,6 +1027,8 @@ GetJnjvmExceptionClassFunction = module->getFunction("getJnjvmExceptionClass"); GetJnjvmArrayClassFunction = module->getFunction("getJnjvmArrayClass"); + StaticCtpLookupFunction = module->getFunction("staticCtpLookup"); + GetArrayClassFunction = module->getFunction("getArrayClass"); #endif #ifdef SERVICE_VM Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h?rev=56155&r1=56154&r2=56155&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h Fri Sep 12 09:24:14 2008 @@ -352,6 +352,8 @@ static llvm::Function* EnveloppeLookupFunction; static llvm::Function* GetJnjvmExceptionClassFunction; static llvm::Function* GetJnjvmArrayClassFunction; + static llvm::Function* StaticCtpLookupFunction; + static llvm::Function* GetArrayClassFunction; #endif static llvm::Function* GetClassDelegateeFunction; From nicolas.geoffray at lip6.fr Fri Sep 12 07:25:09 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 14:25:09 -0000 Subject: [vmkit-commits] [vmkit] r56156 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Message-ID: <200809121425.m8CEP9ic017864@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 09:25:09 2008 New Revision: 56156 URL: http://llvm.org/viewvc/llvm-project?rev=56156&view=rev Log: Get the array class in ANEWARRAY, not the referenced class in the constant pool. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=56156&r1=56155&r2=56156&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Fri Sep 12 09:25:09 2008 @@ -1857,6 +1857,8 @@ #else valCl = getResolvedClass(index, true); + valCl = CallInst::Create(JnjvmModule::GetArrayClassFunction, valCl, + "", currentBlock); #endif TheVT = JnjvmModule::ArrayObjectVirtualTableGV; sizeElement = mvm::jit::constantPtrSize; From nicolas.geoffray at lip6.fr Fri Sep 12 07:31:42 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 14:31:42 -0000 Subject: [vmkit-commits] [vmkit] r56157 - in /vmkit/branches/isolate/tools: jnjvm/Makefile vmkit/Makefile Message-ID: <200809121431.m8CEVg7C018098@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 09:31:42 2008 New Revision: 56157 URL: http://llvm.org/viewvc/llvm-project?rev=56157&view=rev Log: Fix Makefile for building wit isolates. Modified: vmkit/branches/isolate/tools/jnjvm/Makefile vmkit/branches/isolate/tools/vmkit/Makefile Modified: vmkit/branches/isolate/tools/jnjvm/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/tools/jnjvm/Makefile?rev=56157&r1=56156&r2=56157&view=diff ============================================================================== --- vmkit/branches/isolate/tools/jnjvm/Makefile (original) +++ vmkit/branches/isolate/tools/jnjvm/Makefile Fri Sep 12 09:31:42 2008 @@ -14,4 +14,8 @@ USEDLIBS = Allocator CommonThread Mvm JnJVM Classpath $(GCLIB) LINK_COMPONENTS = jit nativecodegen scalaropts instrumentation ipa ipo +ifeq ($(ISOLATE_BUILD), 1) + USEDLIBS += Isolate +endif + include $(LEVEL)/Makefile.common Modified: vmkit/branches/isolate/tools/vmkit/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/tools/vmkit/Makefile?rev=56157&r1=56156&r2=56157&view=diff ============================================================================== --- vmkit/branches/isolate/tools/vmkit/Makefile (original) +++ vmkit/branches/isolate/tools/vmkit/Makefile Fri Sep 12 09:31:42 2008 @@ -17,6 +17,10 @@ USEDLIBS += JnJVM Classpath endif +ifeq ($(ISOLATE_BUILD), 1) + USEDLIBS += Isolate +endif + ifeq ($(WITH_N3_PNETLIB), 1) USEDLIBS += N3 PNetLib endif @@ -29,3 +33,5 @@ LIBS += $(PNETLIB)/engine/libILEngine.a $(PNETLIB)/image/libILImage.a $(PNETLIB)/support/libILSupport.a \ $(PNETLIB)/libffi/.libs/libffi.a $(PNETLIB)//dumpasm/libILDumpAsm.a endif + + From nicolas.geoffray at lip6.fr Fri Sep 12 07:35:28 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 12 Sep 2008 14:35:28 -0000 Subject: [vmkit-commits] [vmkit] r56158 - /vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp Message-ID: <200809121435.m8CEZTgW018229@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 12 09:35:28 2008 New Revision: 56158 URL: http://llvm.org/viewvc/llvm-project?rev=56158&view=rev Log: Oops, msg doesn't exist anymore. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp?rev=56158&r1=56157&r2=56158&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp Fri Sep 12 09:35:28 2008 @@ -266,7 +266,7 @@ void Jnjvm::classCastException(JavaObject* obj, UserCommonClass* cl) { error(upcalls->ClassCastException, upcalls->InitClassCastException, - msg); + ""); } void Jnjvm::noSuchFieldError(CommonClass* cl, const UTF8* name) { From nicolas.geoffray at lip6.fr Mon Sep 15 04:18:56 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 11:18:56 -0000 Subject: [vmkit-commits] [vmkit] r56201 - /vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Message-ID: <200809151118.m8FBIuMF027511@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 06:18:55 2008 New Revision: 56201 URL: http://llvm.org/viewvc/llvm-project?rev=56201&view=rev Log: Set missing informations in UserClass*. Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp?rev=56201&r1=56200&r2=56201&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Mon Sep 15 06:18:55 2008 @@ -48,6 +48,12 @@ delegatee = 0; _baseClass = 0; _funcs = 0; + super = JCL->bootstrapLoader->SuperArray; + interfaces = JCL->bootstrapLoader->InterfacesArray; + depth = 1; + display = (UserCommonClass**)malloc(2 * sizeof(UserCommonClass*)); + display[0] = super; + display[1] = this; } UserClassPrimitive::UserClassPrimitive(JnjvmClassLoader* JCL, const UTF8* name, @@ -60,6 +66,8 @@ classDef = cl; classLoader = JCL; delegatee = 0; + display = (UserCommonClass**)malloc(sizeof(UserCommonClass*)); + display[0] = this; } void UserCommonClass::resolveClass() { @@ -95,6 +103,18 @@ status = prepared; def->classLoader->TheModule->resolveVirtualClass(def); virtualSize = def->virtualSize; + /*uint64 vtSize = def->virtualTableSize * sizeof(void*); + virtualVT = (VirtualTable*)malloc(2 * vtSize); + memcpy(virtualVT, (void*)((uint64)def->virtualVT + vtSize), vtSize); + if (super) { + memcpy(virtualVT, (void*)((uint64)super->virtualVT - vtSize), + vtSize); + } + for (CommonClass::method_iterator i = def->virtualMethods.begin(), + e = def->virtualMethods.end(); i != e; ++i) { + ((void**)virtualVT)[i->second->offset] = ctpInfo; + } + virtualVT = (VirtualTable*)((uint64)virtualVT + vtSize);*/ virtualVT = def->virtualVT; def->status = resolved; status = resolved; @@ -125,9 +145,10 @@ } UserClass* UserCommonClass::lookupClassFromMethod(JavaMethod* meth) { - fprintf(stderr, "implement me"); - abort(); - return 0; + UserClass* res = 0; + lookupMethodDontThrow(meth->name, meth->type, + isStatic(meth->access), true, res); + return res; } UserCommonClass* UserCommonClass::getUserClass(CommonClass* cl) { @@ -197,10 +218,13 @@ UserClassPrimitive* AssessorDesc::getPrimitiveClass() const { Jnjvm* vm = JavaThread::get()->isolate; - UserClassArray* arrayCl = vm->arrayClasses[numId]; - UserClassPrimitive* cl = (UserClassPrimitive*)arrayCl->baseClass(); - assert(cl && "Primitive array class does not have a primitive."); - return cl; + if (numId > VOID_ID && numId < ARRAY_ID) { + UserClassArray* arrayCl = vm->arrayClasses[numId]; + UserClassPrimitive* cl = (UserClassPrimitive*)arrayCl->baseClass(); + assert(cl && "Primitive array class does not have a primitive."); + return cl; + } + return 0; } UserClassArray* AssessorDesc::getArrayClass() const { From nicolas.geoffray at lip6.fr Mon Sep 15 04:26:57 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 11:26:57 -0000 Subject: [vmkit-commits] [vmkit] r56202 - in /vmkit/branches/isolate/lib/JnJVM/VMCore: JnjvmClassLoader.cpp JnjvmClassLoader.h Message-ID: <200809151126.m8FBQvVP027748@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 06:26:57 2008 New Revision: 56202 URL: http://llvm.org/viewvc/llvm-project?rev=56202&view=rev Log: Have a cache user class for calling the loadClass function. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=56202&r1=56201&r2=56202&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Mon Sep 15 06:26:57 2008 @@ -64,12 +64,15 @@ JCL->analyseClasspathEnv(JCL->bootClasspathEnv); JCL->upcalls = new Classpath(); + JCL->bootstrapLoader = JCL; return JCL; } -JnjvmClassLoader::JnjvmClassLoader(JnjvmClassLoader& JCL, JavaObject* loader, Jnjvm* I) { +JnjvmClassLoader::JnjvmClassLoader(JnjvmClassLoader& JCL, JavaObject* loader, + Jnjvm* I) { TheModule = JCL.TheModule; TheModuleProvider = JCL.TheModuleProvider; + bootstrapLoader = JCL.bootstrapLoader; allocator = &(isolate->allocator); @@ -81,6 +84,13 @@ javaLoader = loader; isolate = I; +#ifdef MULTIPLE_VM + JavaMethod* meth = bootstrapLoader->upcalls->loadInClassLoader; + loader->classOf->lookupMethodDontThrow(meth->name, meth->type, false, true, + loadClass); + assert(loadClass && "Loader does not have a loadClass function"); +#endif + } ArrayUInt8* JnjvmBootstrapLoader::openName(const UTF8* utf8) { @@ -137,7 +147,7 @@ Classpath* upcalls = bootstrapLoader->upcalls; UserClass* forCtp = 0; #ifdef MULTIPLE_VM - forCtp = javaLoader->classOf->lookupClassFromMethod(upcalls->loadInClassLoader); + forCtp = loadClass; #else forCtp = upcalls->loadInClassLoader->classDef; #endif Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h?rev=56202&r1=56201&r2=56202&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h Mon Sep 15 06:26:57 2008 @@ -204,6 +204,10 @@ isolate = 0; } +#ifdef MULTIPLE_VM + UserClass* loadClass; +#endif + }; /// JnjvmBootstrapLoader - This class is for the bootstrap class loader, which From nicolas.geoffray at lip6.fr Mon Sep 15 04:28:46 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 11:28:46 -0000 Subject: [vmkit-commits] [vmkit] r56203 - in /vmkit/branches/isolate/lib/JnJVM: LLVMRuntime/runtime-isolate.ll VMCore/JavaJIT.cpp VMCore/JavaRuntimeJIT.cpp VMCore/JnjvmModule.cpp VMCore/JnjvmModule.h Message-ID: <200809151128.m8FBSkMa027816@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 06:28:46 2008 New Revision: 56203 URL: http://llvm.org/viewvc/llvm-project?rev=56203&view=rev Log: Support for invokeSpecial calls to give the correct user constant pool of the callee. Modified: vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-isolate.ll vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h Modified: vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-isolate.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-isolate.ll?rev=56203&r1=56202&r2=56203&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-isolate.ll (original) +++ vmkit/branches/isolate/lib/JnJVM/LLVMRuntime/runtime-isolate.ll Mon Sep 15 06:28:46 2008 @@ -13,6 +13,10 @@ ;;; constant pool. declare i8* @staticCtpLookup(%JavaClass*, i32, ...) +;;; specialCtpLookup - Find the user constant pool at the given offset in the +;;; constant pool. +declare %ConstantPool* @specialCtpLookup(%ConstantPool*, i32, %ConstantPool**) + ;;; getCtpCacheNode - Get the constant pool cache of a cache node. This is a ;;; constant call because the cache node never changes. declare %ConstantPool* @getCtpCacheNode(%CacheNode*) readnone Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp?rev=56203&r1=56202&r2=56203&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Mon Sep 15 06:28:46 2008 @@ -57,11 +57,9 @@ JavaMethod* meth = 0; ctpInfo->infoOfMethod(index, ACC_VIRTUAL, cl, meth); -#if !defined(MULTIPLE_VM) if ((cl && isFinal(cl->access)) || (meth && (isFinal(meth->access) || isPrivate(meth->access)))) return invokeSpecial(index); -#endif #if !defined(WITHOUT_VTABLE) && !defined(MULTIPLE_VM) @@ -78,14 +76,27 @@ Value* VT = CallInst::Create(JnjvmModule::GetVTFunction, args[0], "", currentBlock); std::vector indexes2; //[3]; +#ifdef MULTIPLE_VM + std::vector indexesCtp; //[3]; +#endif if (meth) { LLVMMethodInfo* LMI = module->getMethodInfo(meth); - indexes2.push_back(LMI->getOffset()); + ConstantInt* Offset = LMI->getOffset(); + indexes2.push_back(Offset); +#ifdef MULTIPLE_VM + indexesCtp.push_back(ConstantInt::get(Type::Int32Ty, + Offset->getZExtValue() * -1)); +#endif } else { Value* val = getConstantPoolAt(index, JnjvmModule::VirtualLookupFunction, Type::Int32Ty, args[0], true); indexes2.push_back(val); +#ifdef MULTIPLE_VM + Value* mul = BinaryOperator::createMul(val, mvm::jit::constantMinusOne, + "", currentBlock); + indexesCtp.push_back(mul); +#endif } Value* FuncPtr = GetElementPtrInst::Create(VT, indexes2.begin(), @@ -94,7 +105,15 @@ Value* Func = new LoadInst(FuncPtr, "", currentBlock); Func = new BitCastInst(Func, LSI->getVirtualPtrType(), "", currentBlock); - +#ifdef MULTIPLE_VM + Value* CTP = GetElementPtrInst::Create(VT, indexesCtp.begin(), + indexesCtp.end(), "", + currentBlock); + + CTP = new LoadInst(CTP, "", currentBlock); + CTP = new BitCastInst(CTP, JnjvmModule::ConstantPoolType, "", currentBlock); + args.push_back(CTP); +#endif Value* val = invoke(Func, args, "", currentBlock); const llvm::Type* retType = virtualType->getReturnType(); @@ -1373,7 +1392,7 @@ Instruction* JavaJIT::lowerMathOps(const UTF8* name, std::vector& args) { - if (name == Jnjvm::abs) { + if (name->equals(Jnjvm::abs)) { const Type* Ty = args[0]->getType(); if (Ty == Type::Int32Ty) { Constant* const_int32_9 = mvm::jit::constantZero; @@ -1407,71 +1426,71 @@ return llvm::CallInst::Create(mvm::jit::func_llvm_fabs_f64, args[0], "tmp1", currentBlock); } - } else if (name == Jnjvm::sqrt) { + } else if (name->equals(Jnjvm::sqrt)) { return llvm::CallInst::Create(mvm::jit::func_llvm_sqrt_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::sin) { + } else if (name->equals(Jnjvm::sin)) { return llvm::CallInst::Create(mvm::jit::func_llvm_sin_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::cos) { + } else if (name->equals(Jnjvm::cos)) { return llvm::CallInst::Create(mvm::jit::func_llvm_cos_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::tan) { + } else if (name->equals(Jnjvm::tan)) { return llvm::CallInst::Create(mvm::jit::func_llvm_tan_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::asin) { + } else if (name->equals(Jnjvm::asin)) { return llvm::CallInst::Create(mvm::jit::func_llvm_asin_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::acos) { + } else if (name->equals(Jnjvm::acos)) { return llvm::CallInst::Create(mvm::jit::func_llvm_acos_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::atan) { + } else if (name->equals(Jnjvm::atan)) { return llvm::CallInst::Create(mvm::jit::func_llvm_atan_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::atan2) { + } else if (name->equals(Jnjvm::atan2)) { return llvm::CallInst::Create(mvm::jit::func_llvm_atan2_f64, args.begin(), args.end(), "tmp1", currentBlock); - } else if (name == Jnjvm::exp) { + } else if (name->equals(Jnjvm::exp)) { return llvm::CallInst::Create(mvm::jit::func_llvm_exp_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::log) { + } else if (name->equals(Jnjvm::log)) { return llvm::CallInst::Create(mvm::jit::func_llvm_log_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::pow) { + } else if (name->equals(Jnjvm::pow)) { return llvm::CallInst::Create(mvm::jit::func_llvm_pow_f64, args.begin(), args.end(), "tmp1", currentBlock); - } else if (name == Jnjvm::ceil) { + } else if (name->equals(Jnjvm::ceil)) { return llvm::CallInst::Create(mvm::jit::func_llvm_ceil_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::floor) { + } else if (name->equals(Jnjvm::floor)) { return llvm::CallInst::Create(mvm::jit::func_llvm_floor_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::rint) { + } else if (name->equals(Jnjvm::rint)) { return llvm::CallInst::Create(mvm::jit::func_llvm_rint_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::cbrt) { + } else if (name->equals(Jnjvm::cbrt)) { return llvm::CallInst::Create(mvm::jit::func_llvm_cbrt_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::cosh) { + } else if (name->equals(Jnjvm::cosh)) { return llvm::CallInst::Create(mvm::jit::func_llvm_cosh_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::expm1) { + } else if (name->equals(Jnjvm::expm1)) { return llvm::CallInst::Create(mvm::jit::func_llvm_expm1_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::hypot) { + } else if (name->equals(Jnjvm::hypot)) { return llvm::CallInst::Create(mvm::jit::func_llvm_hypot_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::log10) { + } else if (name->equals(Jnjvm::log10)) { return llvm::CallInst::Create(mvm::jit::func_llvm_log10_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::log1p) { + } else if (name->equals(Jnjvm::log1p)) { return llvm::CallInst::Create(mvm::jit::func_llvm_log1p_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::sinh) { + } else if (name->equals(Jnjvm::sinh)) { return llvm::CallInst::Create(mvm::jit::func_llvm_sinh_f64, args[0], "tmp1", currentBlock); - } else if (name == Jnjvm::tanh) { + } else if (name->equals(Jnjvm::tanh)) { return llvm::CallInst::Create(mvm::jit::func_llvm_tanh_f64, args[0], "tmp1", currentBlock); } @@ -1512,19 +1531,36 @@ makeArgs(it, index, args, signature->args.size() + 1); JITVerifyNull(args[0]); - if (cl == Jnjvm::mathName) { + if (cl->equals(Jnjvm::mathName)) { val = lowerMathOps(name, args); } if (!val) { #if defined(MULTIPLE_VM) - uint32 clIndex = ctpInfo->getClassIndexFromMethod(index); - Value* cl = getResolvedClass(clIndex, false); - - Value* newCtpCache = CallInst::Create(JnjvmModule::GetCtpClassFunction, cl, - "", currentBlock); - args.push_back(newCtpCache); + const Type* Ty = JnjvmModule::ConstantPoolType; + Constant* Nil = Constant::getNullValue(Ty); + GlobalVariable* GV = new GlobalVariable(Ty, false, + GlobalValue::ExternalLinkage, Nil, + "", module); + Value* res = new LoadInst(GV, "", false, currentBlock); + Value* test = new ICmpInst(ICmpInst::ICMP_EQ, res, Nil, "", currentBlock); + + BasicBlock* trueCl = createBasicBlock("UserCtp OK"); + BasicBlock* falseCl = createBasicBlock("UserCtp Not OK"); + PHINode* node = llvm::PHINode::Create(Ty, "", trueCl); + node->addIncoming(res, currentBlock); + BranchInst::Create(falseCl, trueCl, test, currentBlock); + std::vector Args; + Args.push_back(ctpCache); + Args.push_back(ConstantInt::get(Type::Int32Ty, index)); + Args.push_back(GV); + res = CallInst::Create(JnjvmModule::SpecialCtpLookupFunction, Args.begin(), + Args.end(), "", falseCl); + node->addIncoming(res, falseCl); + BranchInst::Create(trueCl, falseCl); + currentBlock = trueCl; + args.push_back(node); #endif Function* func = (Function*)ctpInfo->infoOfStaticOrSpecialMethod(index, ACC_VIRTUAL, @@ -1565,7 +1601,7 @@ makeArgs(it, index, args, signature->args.size()); ctpInfo->markAsStaticCall(index); - if (cl == Jnjvm::mathName) { + if (cl->equals(Jnjvm::mathName)) { val = lowerMathOps(name, args); } @@ -1745,11 +1781,12 @@ } else { LLVMClassInfo* LCI = (LLVMClassInfo*)module->getClassInfo(cl); Size = LCI->getVirtualSize(this); - VT = LCI->getVirtualTable(this); #ifndef MULTIPLE_VM + VT = LCI->getVirtualTable(this); Cl = LCI->getVar(this); if (!cl->isReady()) { - Cl = invoke(JnjvmModule::InitialisationCheckFunction, Cl, "", currentBlock); + Cl = invoke(JnjvmModule::InitialisationCheckFunction, Cl, "", + currentBlock); CallInst::Create(JnjvmModule::ForceInitialisationCheckFunction, Cl, "", currentBlock); } @@ -1757,6 +1794,8 @@ Cl = getResolvedClass(index, true); CallInst::Create(JnjvmModule::ForceInitialisationCheckFunction, Cl, "", currentBlock); + VT = CallInst::Create(JnjvmModule::GetVTFromClassFunction, Cl, "", + currentBlock); #endif } std::vector args; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=56203&r1=56202&r2=56203&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Mon Sep 15 06:28:46 2008 @@ -164,7 +164,7 @@ shared->resolveMethod(index, baseCl, utf8, sign); UserClass* methodCl = 0; - refCl->lookupMethod(utf8, sign->keyName, isStatic, true, methodCl); + refCl->lookupMethod(utf8, sign->keyName, true, true, methodCl); ctpInfo->ctpRes[index] = methodCl->getConstantPool(); shared->ctpRes[clIndex] = refCl->classDef; return (void*)methodCl->getConstantPool(); @@ -179,6 +179,25 @@ return dcl; } +extern "C" UserConstantPool* specialCtpLookup(UserConstantPool* ctpInfo, + uint32 index, + UserConstantPool** res) { + JavaConstantPool* shared = ctpInfo->getSharedPool(); + uint32 clIndex = shared->getClassIndexFromMethod(index); + UserClass* refCl = (UserClass*)ctpInfo->loadClass(clIndex); + + CommonClass* baseCl = 0; + const UTF8* utf8 = 0; + Signdef* sign = 0; + + shared->resolveMethod(index, baseCl, utf8, sign); + UserClass* methodCl = 0; + refCl->lookupMethod(utf8, sign->keyName, false, true, methodCl); + shared->ctpRes[clIndex] = refCl->classDef; + *res = methodCl->getConstantPool(); + return methodCl->getConstantPool(); +} + #endif #ifndef WITHOUT_VTABLE @@ -204,8 +223,10 @@ } else { caller->getConstantPool()->ctpRes[index] = (void*)dmeth->offset; } - + +#ifndef MULTIPLE_VM assert(dmeth->classDef->isReady() && "Class not ready in a virtual lookup."); +#endif return (void*)dmeth->offset; } Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=56203&r1=56202&r2=56203&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Mon Sep 15 06:28:46 2008 @@ -118,6 +118,7 @@ llvm::Function* JnjvmModule::GetJnjvmArrayClassFunction = 0; llvm::Function* JnjvmModule::StaticCtpLookupFunction = 0; llvm::Function* JnjvmModule::GetArrayClassFunction = 0; +llvm::Function* JnjvmModule::SpecialCtpLookupFunction = 0; #endif llvm::Function* JnjvmModule::GetClassDelegateeFunction = 0; llvm::Function* JnjvmModule::ArrayLengthFunction = 0; @@ -1028,6 +1029,7 @@ module->getFunction("getJnjvmExceptionClass"); GetJnjvmArrayClassFunction = module->getFunction("getJnjvmArrayClass"); StaticCtpLookupFunction = module->getFunction("staticCtpLookup"); + SpecialCtpLookupFunction = module->getFunction("specialCtpLookup"); GetArrayClassFunction = module->getFunction("getArrayClass"); #endif Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h?rev=56203&r1=56202&r2=56203&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h Mon Sep 15 06:28:46 2008 @@ -353,6 +353,7 @@ static llvm::Function* GetJnjvmExceptionClassFunction; static llvm::Function* GetJnjvmArrayClassFunction; static llvm::Function* StaticCtpLookupFunction; + static llvm::Function* SpecialCtpLookupFunction; static llvm::Function* GetArrayClassFunction; #endif From nicolas.geoffray at lip6.fr Mon Sep 15 04:29:19 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 11:29:19 -0000 Subject: [vmkit-commits] [vmkit] r56204 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp Message-ID: <200809151129.m8FBTJmX027848@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 06:29:19 2008 New Revision: 56204 URL: http://llvm.org/viewvc/llvm-project?rev=56204&view=rev Log: Use equals() instead of ==. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp?rev=56204&r1=56203&r2=56204&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp Mon Sep 15 06:29:19 2008 @@ -223,10 +223,8 @@ uint32 nb) : CommonClass(loader, n, false) { -#ifndef MULTIPLE_VM display = (CommonClass**)malloc(sizeof(CommonClass*)); display[0] = this; -#endif primitive = true; status = ready; access = ACC_ABSTRACT | ACC_FINAL | ACC_PUBLIC; @@ -248,12 +246,10 @@ _baseClass = 0; super = ClassArray::SuperArray; interfaces = ClassArray::InterfacesArray; -#ifndef MULTIPLE_VM depth = 1; display = (CommonClass**)malloc(2 * sizeof(CommonClass*)); - display[0] = JnjvmBootstrapLoader::SuperArray; + display[0] = ClassArray::SuperArray; display[1] = this; -#endif access = ACC_FINAL | ACC_ABSTRACT; } @@ -776,7 +772,7 @@ e = virtualMethods.end(); i != e; ++i) { JavaMethod* meth = i->second; bool pub = isPublic(meth->access); - if (meth->name == Jnjvm::initName && (!publicOnly || pub)) { + if (meth->name->equals(Jnjvm::initName) && (!publicOnly || pub)) { res.push_back(meth); } } @@ -788,7 +784,7 @@ e = virtualMethods.end(); i != e; ++i) { JavaMethod* meth = i->second; bool pub = isPublic(meth->access); - if (meth->name != Jnjvm::initName && (!publicOnly || pub)) { + if (!(meth->name->equals(Jnjvm::initName)) && (!publicOnly || pub)) { res.push_back(meth); } } @@ -797,7 +793,7 @@ e = staticMethods.end(); i != e; ++i) { JavaMethod* meth = i->second; bool pub = isPublic(meth->access); - if (meth->name != Jnjvm::clinitName && (!publicOnly || pub)) { + if (!(meth->name->equals(Jnjvm::clinitName)) && (!publicOnly || pub)) { res.push_back(meth); } } From nicolas.geoffray at lip6.fr Mon Sep 15 04:30:17 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 11:30:17 -0000 Subject: [vmkit-commits] [vmkit] r56205 - /vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp Message-ID: <200809151130.m8FBUHA8027891@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 06:30:16 2008 New Revision: 56205 URL: http://llvm.org/viewvc/llvm-project?rev=56205&view=rev Log: Also trace the shared loader. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp?rev=56205&r1=56204&r2=56205&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp Mon Sep 15 06:30:16 2008 @@ -109,7 +109,10 @@ appClassLoader->MARK_AND_TRACE; TRACE_VECTOR(JavaObject*, gc_allocator, globalRefs); bootstrapThread->MARK_AND_TRACE; - bootstrapLoader->MARK_AND_TRACE; + bootstrapLoader->MARK_AND_TRACE; +#ifdef MULTIPLE_VM + JnjvmSharedLoader::sharedLoader->MARK_AND_TRACE; +#endif } void ClassMap::TRACER { From nicolas.geoffray at lip6.fr Mon Sep 15 04:31:05 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 11:31:05 -0000 Subject: [vmkit-commits] [vmkit] r56206 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Message-ID: <200809151131.m8FBV5JH027934@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 06:31:04 2008 New Revision: 56206 URL: http://llvm.org/viewvc/llvm-project?rev=56206&view=rev Log: Do not initialize class in ANEWARRAY. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=56206&r1=56205&r2=56206&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Mon Sep 15 06:31:04 2008 @@ -1856,7 +1856,7 @@ dcl = JCL->constructArray(arrayName); #else - valCl = getResolvedClass(index, true); + valCl = getResolvedClass(index, false); valCl = CallInst::Create(JnjvmModule::GetArrayClassFunction, valCl, "", currentBlock); #endif From nicolas.geoffray at lip6.fr Mon Sep 15 04:31:35 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 11:31:35 -0000 Subject: [vmkit-commits] [vmkit] r56207 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Message-ID: <200809151131.m8FBVZSF027966@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 06:31:35 2008 New Revision: 56207 URL: http://llvm.org/viewvc/llvm-project?rev=56207&view=rev Log: Fix debugging code. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp?rev=56207&r1=56206&r2=56207&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Mon Sep 15 06:31:35 2008 @@ -112,7 +112,6 @@ return false; } - void* JnjvmModuleProvider::materializeFunction(JavaMethod* meth) { Function* func = parseFunction(meth); @@ -120,10 +119,10 @@ mvm::Code* m = mvm::jit::getCodeFromPointer(res); if (m) m->setMetaInfo(meth); - /* - if (compilingMethod->name == - compilingClass->isolate->asciizConstructUTF8("main")) { - llvmFunction->print(llvm::cout); +/* + if (meth->name->equals( + JavaThread::get()->isolate->bootstrapLoader->asciizConstructUTF8("getDeclaredConstructors"))) { + func->print(std::cout); printf("\n"); void* res = mvm::jit::executionEngine->getPointerToGlobal(llvmFunction); void* base = res; @@ -135,8 +134,7 @@ } printf("\n"); fflush(stdout); - } - */ + }*/ return res; } From nicolas.geoffray at lip6.fr Mon Sep 15 04:32:59 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 11:32:59 -0000 Subject: [vmkit-commits] [vmkit] r56208 - /vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp Message-ID: <200809151132.m8FBWx3b028034@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 06:32:59 2008 New Revision: 56208 URL: http://llvm.org/viewvc/llvm-project?rev=56208&view=rev Log: Fix error message in noSuch{Field, Method}*() methods. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp?rev=56208&r1=56207&r2=56208&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp Mon Sep 15 06:32:59 2008 @@ -273,7 +273,7 @@ error(upcalls->NoSuchFieldError, upcalls->InitNoSuchFieldError, "unable to find %s in %s", - name->printString(), cl->printString()); + name->UTF8ToAsciiz(), cl->name->UTF8ToAsciiz()); } @@ -281,7 +281,7 @@ error(upcalls->NoSuchMethodError, upcalls->InitNoSuchMethodError, "unable to find %s in %s", - name->printString(), cl->printString()); + name->UTF8ToAsciiz(), cl->name->UTF8ToAsciiz()); } From nicolas.geoffray at lip6.fr Mon Sep 15 05:16:45 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 12:16:45 -0000 Subject: [vmkit-commits] [vmkit] r56209 - /vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateSharedLoader.h Message-ID: <200809151216.m8FCGjtJ029464@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 07:16:45 2008 New Revision: 56209 URL: http://llvm.org/viewvc/llvm-project?rev=56209&view=rev Log: abort instead of exit. Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateSharedLoader.h Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateSharedLoader.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateSharedLoader.h?rev=56209&r1=56208&r2=56209&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateSharedLoader.h (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateSharedLoader.h Mon Sep 15 07:16:45 2008 @@ -22,7 +22,7 @@ /// virtual UserClass* internalLoad(const UTF8* utf8) { fprintf(stderr, "Don't use me"); - exit(1); + abort(); } SharedClassByteMap* byteClasses; From nicolas.geoffray at lip6.fr Mon Sep 15 05:17:19 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 12:17:19 -0000 Subject: [vmkit-commits] [vmkit] r56210 - in /vmkit/branches/isolate/lib/JnJVM/Classpath: ClasspathConstructor.cpp.inc ClasspathMethod.cpp.inc Message-ID: <200809151217.m8FCHKrv029490@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 07:17:19 2008 New Revision: 56210 URL: http://llvm.org/viewvc/llvm-project?rev=56210&view=rev Log: Use the right loader in a isolate environment. Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathConstructor.cpp.inc vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathConstructor.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathConstructor.cpp.inc?rev=56210&r1=56209&r2=56210&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathConstructor.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathConstructor.cpp.inc Mon Sep 15 07:17:19 2008 @@ -34,7 +34,14 @@ jobject cons) { Jnjvm* vm = JavaThread::get()->isolate; JavaMethod* meth = (JavaMethod*)(vm->upcalls->constructorSlot->getInt32Field((JavaObject*)cons)); +#ifdef MULTIPLE_VM + jclass Cl = (jclass)vm->upcalls->constructorClass->getInt32Field((JavaObject*)cons); + UserCommonClass* cl = NativeUtil::resolvedImplClass(Cl, false); + JnjvmClassLoader* loader = cl->classLoader; +#else JnjvmClassLoader* loader = meth->classDef->classLoader; +#endif + return (jobject)(NativeUtil::getParameterTypes(loader, meth)); } Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc?rev=56210&r1=56209&r2=56210&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc Mon Sep 15 07:17:19 2008 @@ -62,7 +62,13 @@ jobject Meth) { Jnjvm* vm = JavaThread::get()->isolate; JavaMethod* meth = (JavaMethod*)vm->upcalls->methodSlot->getInt32Field((JavaObject*)Meth); +#ifdef MULTIPLE_VM + jclass Cl = (jclass)vm->upcalls->methodClass->getInt32Field((JavaObject*)Meth); + UserCommonClass* cl = NativeUtil::resolvedImplClass(Cl, false); + JnjvmClassLoader* loader = cl->classLoader; +#else JnjvmClassLoader* loader = meth->classDef->classLoader; +#endif return (jobject)(NativeUtil::getParameterTypes(loader, meth)); } From nicolas.geoffray at lip6.fr Mon Sep 15 06:25:25 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 13:25:25 -0000 Subject: [vmkit-commits] [vmkit] r56211 - /vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Message-ID: <200809151325.m8FDPPP0031586@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 08:25:24 2008 New Revision: 56211 URL: http://llvm.org/viewvc/llvm-project?rev=56211&view=rev Log: The baseClass of a primitive array is set at boot time. Also return the primitive class of void. Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp?rev=56211&r1=56210&r2=56211&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Mon Sep 15 08:25:24 2008 @@ -12,6 +12,7 @@ #include "JavaAllocator.h" #include "JavaClass.h" #include "JavaThread.h" +#include "JavaUpcalls.h" #include "Jnjvm.h" #include "JnjvmModule.h" @@ -220,9 +221,11 @@ Jnjvm* vm = JavaThread::get()->isolate; if (numId > VOID_ID && numId < ARRAY_ID) { UserClassArray* arrayCl = vm->arrayClasses[numId]; - UserClassPrimitive* cl = (UserClassPrimitive*)arrayCl->baseClass(); + UserClassPrimitive* cl = (UserClassPrimitive*)arrayCl->_baseClass; assert(cl && "Primitive array class does not have a primitive."); return cl; + } else if (numId == VOID_ID) { + return vm->upcalls->OfVoid; } return 0; } From nicolas.geoffray at lip6.fr Mon Sep 15 06:27:00 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 13:27:00 -0000 Subject: [vmkit-commits] [vmkit] r56212 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Message-ID: <200809151327.m8FDR0Q1031676@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 08:27:00 2008 New Revision: 56212 URL: http://llvm.org/viewvc/llvm-project?rev=56212&view=rev Log: Getting a string out of a constant pool does not throw an exception. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp?rev=56212&r1=56211&r2=56212&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Mon Sep 15 08:27:00 2008 @@ -1151,7 +1151,7 @@ #ifdef MULTIPLE_VM // Lookup the constant pool cache Value* val = getConstantPoolAt(index, JnjvmModule::StringLookupFunction, - JnjvmModule::JavaObjectType, 0, true); + JnjvmModule::JavaObjectType, 0, false); push(val, AssessorDesc::dRef); #else const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]); From nicolas.geoffray at lip6.fr Mon Sep 15 06:27:39 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 13:27:39 -0000 Subject: [vmkit-commits] [vmkit] r56213 - /vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp Message-ID: <200809151327.m8FDRdiE031705@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 08:27:38 2008 New Revision: 56213 URL: http://llvm.org/viewvc/llvm-project?rev=56213&view=rev Log: Add an assert. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp?rev=56213&r1=56212&r2=56213&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp Mon Sep 15 08:27:38 2008 @@ -382,6 +382,7 @@ JavaObject* NativeUtil::getClassType(JnjvmClassLoader* loader, Typedef* type) { Jnjvm* vm = JavaThread::get()->isolate; UserCommonClass* res = type->assocClass(loader); + assert(res && "No associated class"); return res->getClassDelegatee(vm); } From nicolas.geoffray at lip6.fr Mon Sep 15 06:28:35 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 13:28:35 -0000 Subject: [vmkit-commits] [vmkit] r56214 - in /vmkit/branches/isolate/lib/JnJVM/VMCore: JavaInitialise.cpp JavaTypes.cpp JavaTypes.h JavaUpcalls.cpp JavaUpcalls.h Message-ID: <200809151328.m8FDSZHt031756@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 08:28:34 2008 New Revision: 56214 URL: http://llvm.org/viewvc/llvm-project?rev=56214&view=rev Log: Set the primitive classes at boot time, not when initializing AssessorDescs. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=56214&r1=56213&r2=56214&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp Mon Sep 15 08:28:34 2008 @@ -141,6 +141,16 @@ // End array initialization + JCL->upcalls->OfByte = UPCALL_PRIMITIVE_CLASS(JCL, "B", 1); + JCL->upcalls->OfBool = UPCALL_PRIMITIVE_CLASS(JCL, "Z", 1); + JCL->upcalls->OfChar = UPCALL_PRIMITIVE_CLASS(JCL, "C", 2); + JCL->upcalls->OfShort = UPCALL_PRIMITIVE_CLASS(JCL, "S", 2); + JCL->upcalls->OfInt = UPCALL_PRIMITIVE_CLASS(JCL, "I", 4); + JCL->upcalls->OfLong = UPCALL_PRIMITIVE_CLASS(JCL, "J", 8); + JCL->upcalls->OfFloat = UPCALL_PRIMITIVE_CLASS(JCL, "F", 4); + JCL->upcalls->OfDouble = UPCALL_PRIMITIVE_CLASS(JCL, "D", 8); + JCL->upcalls->OfVoid = UPCALL_PRIMITIVE_CLASS(JCL, "V", 0); + AssessorDesc::initialise(JCL); Attribut::codeAttribut = JCL->asciizConstructUTF8("Code"); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp?rev=56214&r1=56213&r2=56214&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp Mon Sep 15 08:28:34 2008 @@ -56,7 +56,8 @@ AssessorDesc::AssessorDesc(bool dt, char bid, uint32 nb, uint32 nw, const char* name, JnjvmClassLoader* loader, uint8 nid, - const char* assocName, UserClassArray* cl, + const char* assocName, + UserClassPrimitive* prim, UserClassArray* cl, arrayCtor_t ctor) { AssessorDesc* res = this; res->numId = nid; @@ -75,7 +76,7 @@ res->assocClassName = 0; if (bid != I_PARG && bid != I_PARD && bid != I_REF && bid != I_TAB) { - res->primitiveClass = new UserClassPrimitive(loader, res->UTF8Name, nb); + res->primitiveClass = prim; if (res->arrayClass) { res->arrayClass->_baseClass = res->primitiveClass; res->arrayClass->_funcs = res; @@ -89,53 +90,62 @@ void AssessorDesc::initialise(JnjvmBootstrapLoader* vm) { dParg = new AssessorDesc(false, I_PARG, 0, 0, "(", vm, 0, 0, 0, - 0); + 0, 0); dPard = new AssessorDesc(false, I_PARD, 0, 0, ")", vm, 0, 0, 0, - 0); + 0, 0); dVoid = new AssessorDesc(false, I_VOID, 0, 0, "void", - vm, VOID_ID, "java/lang/Void", 0, 0); + vm, VOID_ID, "java/lang/Void", + vm->upcalls->OfVoid, 0, 0); dBool = new AssessorDesc(false, I_BOOL, 1, 1, "boolean", vm, BOOL_ID, "java/lang/Boolean", + vm->upcalls->OfBool, vm->upcalls->ArrayOfBool, (arrayCtor_t)ArrayUInt8::acons); dByte = new AssessorDesc(false, I_BYTE, 1, 1, "byte", vm, BYTE_ID, "java/lang/Byte", + vm->upcalls->OfByte, vm->upcalls->ArrayOfByte, (arrayCtor_t)ArraySInt8::acons); dChar = new AssessorDesc(false, I_CHAR, 2, 1, "char", vm, CHAR_ID, "java/lang/Character", + vm->upcalls->OfChar, vm->upcalls->ArrayOfChar, (arrayCtor_t)ArrayUInt16::acons); dShort = new AssessorDesc(false, I_SHORT, 2, 1, "short", vm, SHORT_ID, "java/lang/Short", + vm->upcalls->OfShort, vm->upcalls->ArrayOfShort, (arrayCtor_t)ArraySInt16::acons); dInt = new AssessorDesc(false, I_INT, 4, 1, "int", vm, INT_ID, "java/lang/Integer", + vm->upcalls->OfInt, vm->upcalls->ArrayOfInt, (arrayCtor_t)ArraySInt32::acons); dFloat = new AssessorDesc(false, I_FLOAT, 4, 1, "float", vm, FLOAT_ID, "java/lang/Float", + vm->upcalls->OfFloat, vm->upcalls->ArrayOfFloat, (arrayCtor_t)ArrayFloat::acons); dLong = new AssessorDesc(false, I_LONG, 8, 2, "long", vm, LONG_ID, "java/lang/Long", + vm->upcalls->OfLong, vm->upcalls->ArrayOfLong, (arrayCtor_t)ArrayLong::acons); dDouble = new AssessorDesc(false, I_DOUBLE, 8, 2, "double", vm, DOUBLE_ID, "java/lang/Double", + vm->upcalls->OfDouble, vm->upcalls->ArrayOfDouble, (arrayCtor_t)ArrayDouble::acons); dTab = new AssessorDesc(true, I_TAB, sizeof(void*), 1, "array", - vm, ARRAY_ID, 0, 0, + vm, ARRAY_ID, 0, 0, 0, (arrayCtor_t)ArrayObject::acons); dRef = new AssessorDesc(true, I_REF, sizeof(void*), 1, "reference", vm, OBJECT_ID, - 0, 0, + 0, 0, 0, (arrayCtor_t)ArrayObject::acons); } Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h?rev=56214&r1=56213&r2=56214&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h Mon Sep 15 08:28:34 2008 @@ -186,7 +186,8 @@ AssessorDesc(bool dt, char bid, uint32 nb, uint32 nw, const char* name, JnjvmClassLoader* loader, uint8 nid, - const char* assocName, UserClassArray* cl, + const char* assocName, + UserClassPrimitive* prim, UserClassArray* cl, arrayCtor_t ctor); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp?rev=56214&r1=56213&r2=56214&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp Mon Sep 15 08:28:34 2008 @@ -193,6 +193,16 @@ ClassArray* Classpath::ArrayOfDouble; ClassArray* Classpath::ArrayOfObject; +ClassPrimitive* Classpath::OfByte; +ClassPrimitive* Classpath::OfChar; +ClassPrimitive* Classpath::OfInt; +ClassPrimitive* Classpath::OfShort; +ClassPrimitive* Classpath::OfBool; +ClassPrimitive* Classpath::OfLong; +ClassPrimitive* Classpath::OfFloat; +ClassPrimitive* Classpath::OfDouble; +ClassPrimitive* Classpath::OfVoid; + JavaField* Classpath::methodClass; JavaField* Classpath::fieldClass; JavaField* Classpath::constructorClass; @@ -234,6 +244,7 @@ } void Classpath::initialiseClasspath(JnjvmClassLoader* loader) { + newClassLoader = UPCALL_CLASS(loader, "java/lang/ClassLoader"); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h?rev=56214&r1=56213&r2=56214&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h Mon Sep 15 08:28:34 2008 @@ -15,6 +15,9 @@ #define UPCALL_CLASS(vm, name) \ vm->loadName(vm->asciizConstructUTF8(name), false, false) +#define UPCALL_PRIMITIVE_CLASS(loader, name, nb) \ + new UserClassPrimitive(loader, loader->asciizConstructUTF8(name), nb) + #define UPCALL_FIELD(vm, cl, name, type, acc) \ UPCALL_CLASS(vm, cl)->constructField(vm->asciizConstructUTF8(name), \ vm->asciizConstructUTF8(type), acc) @@ -207,7 +210,6 @@ ISOLATE_STATIC UserClassArray* ArrayOfByte; ISOLATE_STATIC UserClassArray* ArrayOfChar; - ISOLATE_STATIC UserClassArray* ArrayOfString; ISOLATE_STATIC UserClassArray* ArrayOfInt; ISOLATE_STATIC UserClassArray* ArrayOfShort; ISOLATE_STATIC UserClassArray* ArrayOfBool; @@ -215,6 +217,17 @@ ISOLATE_STATIC UserClassArray* ArrayOfFloat; ISOLATE_STATIC UserClassArray* ArrayOfDouble; ISOLATE_STATIC UserClassArray* ArrayOfObject; + ISOLATE_STATIC UserClassArray* ArrayOfString; + + ISOLATE_STATIC UserClassPrimitive* OfByte; + ISOLATE_STATIC UserClassPrimitive* OfChar; + ISOLATE_STATIC UserClassPrimitive* OfInt; + ISOLATE_STATIC UserClassPrimitive* OfShort; + ISOLATE_STATIC UserClassPrimitive* OfBool; + ISOLATE_STATIC UserClassPrimitive* OfLong; + ISOLATE_STATIC UserClassPrimitive* OfFloat; + ISOLATE_STATIC UserClassPrimitive* OfDouble; + ISOLATE_STATIC UserClassPrimitive* OfVoid; ISOLATE_STATIC JavaField* methodClass; ISOLATE_STATIC JavaField* fieldClass; From nicolas.geoffray at lip6.fr Mon Sep 15 08:21:58 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 15:21:58 -0000 Subject: [vmkit-commits] [vmkit] r56217 - /vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc Message-ID: <200809151521.m8FFLwdQ002845@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 10:21:58 2008 New Revision: 56217 URL: http://llvm.org/viewvc/llvm-project?rev=56217&view=rev Log: Use the correct class in a isolate environment. Do invokeSpecial instead of invokeVirtual when it's possible. Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc?rev=56217&r1=56216&r2=56217&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc Mon Sep 15 10:21:58 2008 @@ -94,17 +94,17 @@ if (isVirtual(meth->access)) { verifyNull(obj); - UserCommonClass* cl; -#ifdef MULTIPLE_VM - jclass Cl = (jclass)vm->upcalls->methodClass->getInt32Field((JavaObject*)Meth); - cl = NativeUtil::resolvedImplClass(Cl, false); - -#else - cl = meth->classDef; -#endif if (!(obj->classOf->isAssignableFrom(cl))) { vm->illegalArgumentExceptionForMethod(meth, cl, obj->classOf); } +#ifdef MULTIPLE_VM + if (isInterface(cl->classDef->access)) { + cl = obj->classOf->lookupClassFromMethod(meth); + } else { + jclass Cl = (jclass)vm->upcalls->methodClass->getInt32Field((JavaObject*)Meth); + cl = (UserClass*)NativeUtil::resolvedImplClass(Cl, false); + } +#endif } else { cl->initialiseClass(vm); @@ -121,7 +121,7 @@ #define RUN_METH(TYPE) \ try{ \ if (isVirtual(meth->access)) { \ - if (isPublic(meth->access)) { \ + if (isPublic(meth->access) && !isFinal(meth->access) && !isFinal(meth->classDef->access)) { \ val = meth->invoke##TYPE##VirtualBuf(vm, cl, obj, _buf); \ } else { \ val = meth->invoke##TYPE##SpecialBuf(vm, cl, obj, _buf); \ From nicolas.geoffray at lip6.fr Mon Sep 15 08:22:49 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 15:22:49 -0000 Subject: [vmkit-commits] [vmkit] r56218 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp Message-ID: <200809151522.m8FFMnur002883@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 10:22:49 2008 New Revision: 56218 URL: http://llvm.org/viewvc/llvm-project?rev=56218&view=rev Log: Now the used constant pool must be the 4th. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp?rev=56218&r1=56217&r2=56218&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp Mon Sep 15 10:22:49 2008 @@ -116,7 +116,7 @@ obj = (void*)(*cur); obj = Collector::begOf(obj); if (obj && ((mvm::Object*)obj)->getVirtualTable() == UserConstantPool::VT) { - if (i == 1) { + if (i == 4) { return ((UserConstantPool*)obj)->getClass(); } ++i; From nicolas.geoffray at lip6.fr Mon Sep 15 08:23:33 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 15:23:33 -0000 Subject: [vmkit-commits] [vmkit] r56219 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp Message-ID: <200809151523.m8FFNX7O002920@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 10:23:33 2008 New Revision: 56219 URL: http://llvm.org/viewvc/llvm-project?rev=56219&view=rev Log: isArray works on UserClasses, not Classes! Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp?rev=56219&r1=56218&r2=56219&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp Mon Sep 15 10:23:33 2008 @@ -609,8 +609,8 @@ extern "C" uint8 isArray(JavaObject* klass) { Jnjvm* vm = JavaThread::get()->isolate; - CommonClass* cl = - (CommonClass*)((vm->upcalls->vmdataClass->getObjectField(klass))); + UserCommonClass* cl = + (UserCommonClass*)((vm->upcalls->vmdataClass->getObjectField(klass))); return (uint8)cl->isArray(); } From nicolas.geoffray at lip6.fr Mon Sep 15 08:24:06 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 15 Sep 2008 15:24:06 -0000 Subject: [vmkit-commits] [vmkit] r56220 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp Message-ID: <200809151524.m8FFO6CG002944@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 15 10:24:06 2008 New Revision: 56220 URL: http://llvm.org/viewvc/llvm-project?rev=56220&view=rev Log: Fix name of primitive classes. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=56220&r1=56219&r2=56220&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp Mon Sep 15 10:24:06 2008 @@ -141,15 +141,15 @@ // End array initialization - JCL->upcalls->OfByte = UPCALL_PRIMITIVE_CLASS(JCL, "B", 1); - JCL->upcalls->OfBool = UPCALL_PRIMITIVE_CLASS(JCL, "Z", 1); - JCL->upcalls->OfChar = UPCALL_PRIMITIVE_CLASS(JCL, "C", 2); - JCL->upcalls->OfShort = UPCALL_PRIMITIVE_CLASS(JCL, "S", 2); - JCL->upcalls->OfInt = UPCALL_PRIMITIVE_CLASS(JCL, "I", 4); - JCL->upcalls->OfLong = UPCALL_PRIMITIVE_CLASS(JCL, "J", 8); - JCL->upcalls->OfFloat = UPCALL_PRIMITIVE_CLASS(JCL, "F", 4); - JCL->upcalls->OfDouble = UPCALL_PRIMITIVE_CLASS(JCL, "D", 8); - JCL->upcalls->OfVoid = UPCALL_PRIMITIVE_CLASS(JCL, "V", 0); + JCL->upcalls->OfByte = UPCALL_PRIMITIVE_CLASS(JCL, "byte", 1); + JCL->upcalls->OfBool = UPCALL_PRIMITIVE_CLASS(JCL, "boolean", 1); + JCL->upcalls->OfChar = UPCALL_PRIMITIVE_CLASS(JCL, "char", 2); + JCL->upcalls->OfShort = UPCALL_PRIMITIVE_CLASS(JCL, "short", 2); + JCL->upcalls->OfInt = UPCALL_PRIMITIVE_CLASS(JCL, "int", 4); + JCL->upcalls->OfLong = UPCALL_PRIMITIVE_CLASS(JCL, "long", 8); + JCL->upcalls->OfFloat = UPCALL_PRIMITIVE_CLASS(JCL, "float", 4); + JCL->upcalls->OfDouble = UPCALL_PRIMITIVE_CLASS(JCL, "double", 8); + JCL->upcalls->OfVoid = UPCALL_PRIMITIVE_CLASS(JCL, "void", 0); AssessorDesc::initialise(JCL); From nicolas.geoffray at lip6.fr Mon Sep 15 22:38:47 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 16 Sep 2008 05:38:47 -0000 Subject: [vmkit-commits] [vmkit] r56236 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp Message-ID: <200809160538.m8G5clTK028990@zion.cs.uiuc.edu> Author: geoffray Date: Tue Sep 16 00:38:45 2008 New Revision: 56236 URL: http://llvm.org/viewvc/llvm-project?rev=56236&view=rev Log: Fix 80-col violations. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp?rev=56236&r1=56235&r2=56236&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp Tue Sep 16 00:38:45 2008 @@ -205,7 +205,8 @@ buf->write(">"); } -CommonClass::CommonClass(JnjvmClassLoader* loader, const UTF8* n, bool isArray) { +CommonClass::CommonClass(JnjvmClassLoader* loader, const UTF8* n, + bool isArray) { name = n; this->lockVar = mvm::Lock::allocRecursive(); this->condVar = mvm::Cond::allocCond(); @@ -241,7 +242,8 @@ #endif } -ClassArray::ClassArray(JnjvmClassLoader* loader, const UTF8* n) : CommonClass(loader, n, true) { +ClassArray::ClassArray(JnjvmClassLoader* loader, const UTF8* n) : + CommonClass(loader, n, true) { _funcs = 0; _baseClass = 0; super = ClassArray::SuperArray; @@ -278,8 +280,8 @@ if (name->elements[start] == AssessorDesc::I_TAB) { return arrayLoader(name, loader, start + 1, len - 1); } else if (name->elements[start] == AssessorDesc::I_REF) { - const UTF8* componentName = name->javaToInternal(loader->hashUTF8, start + 1, - len - 2); + const UTF8* componentName = name->javaToInternal(loader->hashUTF8, + start + 1, len - 2); UserCommonClass* cl = loader->loadName(componentName, false, true); return cl->classLoader; } else { @@ -419,6 +421,7 @@ } JavaObject* UserClass::doNew(Jnjvm* vm) { + assert(this && "No class when allocating."); assert(this->isReady() && "Uninitialized class when allocating."); JavaObject* res = (JavaObject*)vm->allocator.allocateObject(getVirtualSize(), getVirtualVT()); @@ -459,7 +462,8 @@ } return (Tname->elements[prof] == AssessorDesc::I_REF) && - (res && curS->inheritName(Tname->extract(classLoader->hashUTF8, prof + 1, len - 1))); + (res && curS->inheritName(Tname->extract(classLoader->hashUTF8, prof + 1, + len - 1))); } else { return false; } @@ -687,8 +691,9 @@ ctpInfo->resolveClassName(reader.readU2()); if (!(thisClassName->equals(name))) { - JavaThread::get()->isolate->classFormatError("try to load %s and found class named %s", - printString(), thisClassName->printString()); + JavaThread::get()->isolate->classFormatError( + "try to load %s and found class named %s", + printString(), thisClassName->printString()); } readParents(reader); From nicolas.geoffray at lip6.fr Mon Sep 15 22:39:15 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 16 Sep 2008 05:39:15 -0000 Subject: [vmkit-commits] [vmkit] r56237 - /vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc Message-ID: <200809160539.m8G5dFBO029018@zion.cs.uiuc.edu> Author: geoffray Date: Tue Sep 16 00:39:15 2008 New Revision: 56237 URL: http://llvm.org/viewvc/llvm-project?rev=56237&view=rev Log: Get the class loader of the user class, not of the class. Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc?rev=56237&r1=56236&r2=56237&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc Tue Sep 16 00:39:15 2008 @@ -47,7 +47,13 @@ jobject obj) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)obj); +#ifdef MULTIPLE_VM + jclass Cl = (jclass)vm->upcalls->fieldClass->getInt32Field((JavaObject*)obj); + UserClass* fieldCl = (UserClass*)NativeUtil::resolvedImplClass(Cl, false); + JnjvmClassLoader* loader = fieldCl->classLoader; +#else JnjvmClassLoader* loader = field->classDef->classLoader; +#endif UserCommonClass* cl = field->getSignature()->assocClass(loader); return (jclass)cl->getClassDelegatee(vm); } From nicolas.geoffray at lip6.fr Mon Sep 15 22:39:44 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 16 Sep 2008 05:39:44 -0000 Subject: [vmkit-commits] [vmkit] r56238 - /vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp.inc Message-ID: <200809160539.m8G5diYB029062@zion.cs.uiuc.edu> Author: geoffray Date: Tue Sep 16 00:39:44 2008 New Revision: 56238 URL: http://llvm.org/viewvc/llvm-project?rev=56238&view=rev Log: Implement getContextClass for isolates. Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp.inc Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp.inc?rev=56238&r1=56237&r2=56238&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMStackWalker.cpp.inc Tue Sep 16 00:39:44 2008 @@ -28,7 +28,51 @@ extern "C" { -#ifndef MULTIPLE_VM +#ifdef MULTIPLE_VM +uint32 getPools(UserConstantPool** pools, uint32 size) { + unsigned int* top; + register unsigned int **cur = ⊤ + register unsigned int **max = (unsigned int**)mvm::Thread::get()->baseSP; + + uint32 i = 0; + for(; curgetVirtualTable() == UserConstantPool::VT) { + UserConstantPool* ctp = (UserConstantPool*)obj; + pools[i++] = ctp; + } + } + return i; +} +#endif + +#ifdef MULTIPLE_VM +JavaObject* getClassInContext(Jnjvm* vm, Class* cl, UserConstantPool** ctps, uint32& ctpIndex) { + for (; ctpIndex < 100; ++ctpIndex) { + UserClass* newCl = ctps[ctpIndex]->getClass(); + if (cl == newCl->classDef) return newCl->getClassDelegatee(vm); + } + return 0; +} + +ArrayObject* recGetClassContext(Jnjvm* vm, int** stack, uint32 size, uint32 first, uint32 rec, UserConstantPool** ctps, uint32 ctpIndex) { + if (size != first) { + JavaMethod* meth = JavaJIT::IPToJavaMethod(stack[first]); + if (meth) { + JavaObject* obj = getClassInContext(vm, meth->classDef, ctps, ctpIndex); + ArrayObject* res = recGetClassContext(vm, stack, size, first + 1, rec + 1, ctps, ctpIndex); + res->elements[rec] = obj; + assert(res->elements[rec] && "Did not found the user class"); + return res; + } else { + return recGetClassContext(vm, stack, size, first + 1, rec, ctps, ctpIndex); + } + } else { + return ArrayObject::acons(rec, vm->upcalls->classArrayClass, &(vm->allocator)); + } +} +#else ArrayObject* recGetClassContext(Jnjvm* vm, int** stack, uint32 size, uint32 first, uint32 rec) { if (size != first) { JavaMethod* meth = JavaJIT::IPToJavaMethod(stack[first]); @@ -43,6 +87,7 @@ return ArrayObject::acons(rec, vm->upcalls->classArrayClass, &(vm->allocator)); } } +#endif JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_getClassContext( #ifdef NATIVE_JNI @@ -53,19 +98,32 @@ Jnjvm* vm = JavaThread::get()->isolate; int* ips[100]; int real_size = mvm::jit::getBacktrace((void**)(void*)ips, 100); +#ifdef MULTIPLE_VM + UserConstantPool* pools[100]; + getPools(pools, 100); +#endif + int i = 0; int first = 0; UserCommonClass* cl = vm->upcalls->vmStackWalker; while (i < real_size) { JavaMethod* meth = JavaJIT::IPToJavaMethod(ips[i++]); +#ifdef MULTIPLE_VM + if (meth && meth->classDef == cl->classDef) { +#else if (meth && meth->classDef == cl) { +#endif first = i; break; } } +#ifdef MULTIPLE_VM + return (jobject)recGetClassContext(vm, ips, real_size, first, 0, pools, 0); +#else return (jobject)recGetClassContext(vm, ips, real_size, first, 0); +#endif } JNIEXPORT jobject JNICALL Java_gnu_classpath_VMStackWalker_getClassLoader( @@ -79,7 +137,6 @@ UserCommonClass* cl = (UserCommonClass*)vm->upcalls->vmdataClass->getObjectField(Cl); return (jobject)cl->classLoader->getJavaClassLoader(); } -#endif extern "C" JavaObject* getCallingClass() { UserClass* cl = JavaJIT::getCallingClass(); From nicolas.geoffray at lip6.fr Mon Sep 15 22:40:42 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 16 Sep 2008 05:40:42 -0000 Subject: [vmkit-commits] [vmkit] r56239 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp Message-ID: <200809160540.m8G5egAZ029108@zion.cs.uiuc.edu> Author: geoffray Date: Tue Sep 16 00:40:42 2008 New Revision: 56239 URL: http://llvm.org/viewvc/llvm-project?rev=56239&view=rev Log: Fix getting the backtrace in an isolate environment. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp?rev=56239&r1=56238&r2=56239&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaBacktrace.cpp Tue Sep 16 00:40:42 2008 @@ -104,22 +104,44 @@ return 0; } #else + UserClass* JavaJIT::getCallingClass() { + Class* res = 0; + + int* ips[10]; + int real_size = mvm::jit::getBacktrace((void**)(void*)ips, 10); + int n = 0; + int i = 0; + while (n < real_size) { + mvm::Code* code = mvm::jit::getCodeFromPointer(ips[n++]); + if (code) { + JavaMethod* meth = (JavaMethod*)code->getMetaInfo(); + if (meth) { + if (i == 1) { + res = meth->classDef; + break; + } else { + ++i; + } + } + } + } + + if (!res) return 0; + unsigned int* top; register unsigned int **cur = ⊤ register unsigned int **max = (unsigned int**)mvm::Thread::get()->baseSP; - void* obj = 0; - int i = 0; - for(; curgetVirtualTable() == UserConstantPool::VT) { - if (i == 4) { - return ((UserConstantPool*)obj)->getClass(); + UserConstantPool* ctp = (UserConstantPool*)obj; + UserClass* cl = ctp->getClass(); + if (cl->classDef == res) { + return cl; } - ++i; } } return 0; From nicolas.geoffray at lip6.fr Wed Sep 17 03:27:00 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Wed, 17 Sep 2008 10:27:00 -0000 Subject: [vmkit-commits] [vmkit] r56278 - /vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp Message-ID: <200809171027.m8HAR0Ht020448@zion.cs.uiuc.edu> Author: geoffray Date: Wed Sep 17 05:26:59 2008 New Revision: 56278 URL: http://llvm.org/viewvc/llvm-project?rev=56278&view=rev Log: Trace primitive delegatees even in isolate environment. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp?rev=56278&r1=56277&r2=56278&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/VirtualTables.cpp Wed Sep 17 05:26:59 2008 @@ -14,6 +14,7 @@ #include "JavaClass.h" #include "JavaObject.h" #include "JavaThread.h" +#include "JavaUpcalls.h" #include "Jnjvm.h" #include "JnjvmClassLoader.h" #include "LockedMap.h" @@ -134,21 +135,19 @@ e = bootArchives.end(); i != e; ++i) { (*i)->bytes->MARK_AND_TRACE; } -#ifndef MULTIPLE_VM #define TRACE_DELEGATEE(prim) \ - prim->primitiveClass->delegatee->MARK_AND_TRACE + prim->delegatee->MARK_AND_TRACE - TRACE_DELEGATEE(AssessorDesc::dVoid); - TRACE_DELEGATEE(AssessorDesc::dBool); - TRACE_DELEGATEE(AssessorDesc::dByte); - TRACE_DELEGATEE(AssessorDesc::dChar); - TRACE_DELEGATEE(AssessorDesc::dShort); - TRACE_DELEGATEE(AssessorDesc::dInt); - TRACE_DELEGATEE(AssessorDesc::dFloat); - TRACE_DELEGATEE(AssessorDesc::dLong); - TRACE_DELEGATEE(AssessorDesc::dDouble); + TRACE_DELEGATEE(upcalls->OfVoid); + TRACE_DELEGATEE(upcalls->OfBool); + TRACE_DELEGATEE(upcalls->OfByte); + TRACE_DELEGATEE(upcalls->OfChar); + TRACE_DELEGATEE(upcalls->OfShort); + TRACE_DELEGATEE(upcalls->OfInt); + TRACE_DELEGATEE(upcalls->OfFloat); + TRACE_DELEGATEE(upcalls->OfLong); + TRACE_DELEGATEE(upcalls->OfDouble); #undef TRACE_DELEGATEE -#endif } #ifdef MULTIPLE_VM From nicolas.geoffray at lip6.fr Wed Sep 17 05:19:22 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Wed, 17 Sep 2008 12:19:22 -0000 Subject: [vmkit-commits] [vmkit] r56279 - /vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Message-ID: <200809171219.m8HCJMFj025549@zion.cs.uiuc.edu> Author: geoffray Date: Wed Sep 17 07:19:21 2008 New Revision: 56279 URL: http://llvm.org/viewvc/llvm-project?rev=56279&view=rev Log: Set info for UserClassPrimitive: ready and virtualSize. Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp?rev=56279&r1=56278&r2=56279&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Wed Sep 17 07:19:21 2008 @@ -69,6 +69,8 @@ delegatee = 0; display = (UserCommonClass**)malloc(sizeof(UserCommonClass*)); display[0] = this; + virtualSize = nb; + status = ready; } void UserCommonClass::resolveClass() { From nicolas.geoffray at lip6.fr Wed Sep 17 22:13:35 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 18 Sep 2008 05:13:35 -0000 Subject: [vmkit-commits] [vmkit] r56296 - /vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Message-ID: <200809180513.m8I5Dak5031107@zion.cs.uiuc.edu> Author: geoffray Date: Thu Sep 18 00:13:34 2008 New Revision: 56296 URL: http://llvm.org/viewvc/llvm-project?rev=56296&view=rev Log: Release class after resolving. Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp?rev=56296&r1=56295&r2=56296&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Thu Sep 18 00:13:34 2008 @@ -126,8 +126,8 @@ while (classDef->status < resolved) { classDef->waitClass(); } - classDef->release(); } + classDef->release(); } else { cl->ctpInfo = new(classLoader->allocator, def->ctpInfo->ctpSize) UserConstantPool(cl); @@ -138,6 +138,7 @@ broadcastClass(); } } + release(); } else { while (status < resolved) { waitClass(); From nicolas.geoffray at lip6.fr Thu Sep 18 00:48:18 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 18 Sep 2008 07:48:18 -0000 Subject: [vmkit-commits] [vmkit] r56302 - in /vmkit/branches/isolate/lib/JnJVM: Classpath/ClasspathVMThread.cpp.inc VMCore/JavaUpcalls.cpp VMCore/JavaUpcalls.h Message-ID: <200809180748.m8I7mJYI008133@zion.cs.uiuc.edu> Author: geoffray Date: Thu Sep 18 02:48:16 2008 New Revision: 56302 URL: http://llvm.org/viewvc/llvm-project?rev=56302&view=rev Log: Do not lookup the method VMThread::run, call it directly. Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc?rev=56302&r1=56301&r2=56302&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMThread.cpp.inc Thu Sep 18 02:48:16 2008 @@ -56,7 +56,7 @@ #else Collector::inject_my_thread(&argc); #endif - UserCommonClass* vmthClass = vmThread->classOf; + UserClass* vmthClass = (UserClass*)vmThread->classOf; Jnjvm* isolate = intern->isolate; JavaObject* thread = isolate->upcalls->assocThread->getObjectField(vmThread); ThreadSystem* ts = isolate->threadSystem; @@ -77,10 +77,8 @@ vm->numThreads++; vm->lock->unlock(); #endif - UserClass* methodCl = 0; - JavaMethod* method = vmthClass->lookupMethod(Jnjvm::runName, Jnjvm::clinitType, false, true, methodCl); - method->invokeIntSpecial(isolate, (UserClass*)vmthClass, vmThread); - + + isolate->upcalls->runVMThread->invokeIntSpecial(isolate, vmthClass, vmThread); if (!isDaemon) { ts->nonDaemonLock->lock(); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp?rev=56302&r1=56301&r2=56302&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.cpp Thu Sep 18 02:48:16 2008 @@ -55,6 +55,7 @@ JavaMethod* Classpath::uncaughtException; Class* Classpath::inheritableThreadLocal; +JavaMethod* Classpath::runVMThread; JavaMethod* Classpath::setContextClassLoader; JavaMethod* Classpath::getSystemClassLoader; Class* Classpath::newString; @@ -526,6 +527,10 @@ initVMThread = UPCALL_METHOD(loader, "java/lang/VMThread", "", "(Ljava/lang/Thread;)V", ACC_VIRTUAL); + + runVMThread = + UPCALL_METHOD(loader, "java/lang/VMThread", "run", "()V", ACC_VIRTUAL); + groupAddThread = UPCALL_METHOD(loader, "java/lang/ThreadGroup", "addThread", Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h?rev=56302&r1=56301&r2=56302&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h Thu Sep 18 02:48:16 2008 @@ -125,6 +125,7 @@ ISOLATE_STATIC JavaField* vmdataVMThread; ISOLATE_STATIC JavaMethod* finaliseCreateInitialThread; ISOLATE_STATIC JavaMethod* initVMThread; + ISOLATE_STATIC JavaMethod* runVMThread; ISOLATE_STATIC JavaMethod* groupAddThread; ISOLATE_STATIC JavaField* name; ISOLATE_STATIC JavaField* priority; From nicolas.geoffray at lip6.fr Thu Sep 18 06:08:33 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Thu, 18 Sep 2008 13:08:33 -0000 Subject: [vmkit-commits] [vmkit] r56304 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Message-ID: <200809181308.m8ID8Xbp022783@zion.cs.uiuc.edu> Author: geoffray Date: Thu Sep 18 08:08:32 2008 New Revision: 56304 URL: http://llvm.org/viewvc/llvm-project?rev=56304&view=rev Log: Disable finalization in a isolate environment. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=56304&r1=56303&r2=56304&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Thu Sep 18 08:08:32 2008 @@ -215,6 +215,7 @@ VirtualTable* VT = 0; if (meth->name->equals(Jnjvm::finalize)) { VT = allocateVT(cl, ++meths); +#ifndef MULTIPLE_VM meth->offset = 0; Function* func = cl->classLoader->TheModuleProvider->parseFunction(meth); if (!cl->super) meth->canBeInlined = true; @@ -227,6 +228,7 @@ // LLVM does not allow recursive compilation. Create the code now. ((void**)VT)[0] = EE->getPointerToFunction(func); } +#endif } else { Class* methodCl = 0; From nicolas.geoffray at lip6.fr Fri Sep 19 00:13:03 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 19 Sep 2008 07:13:03 -0000 Subject: [vmkit-commits] [vmkit] r56335 - in /vmkit/branches/isolate/lib/JnJVM: Isolate/IsolateCommonClass.cpp VMCore/JavaJIT.cpp Message-ID: <200809190713.m8J7D4vv031752@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 19 02:13:03 2008 New Revision: 56335 URL: http://llvm.org/viewvc/llvm-project?rev=56335&view=rev Log: Enable virtual table for isolate environments. Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Modified: vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp?rev=56335&r1=56334&r2=56335&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/Isolate/IsolateCommonClass.cpp Fri Sep 19 02:13:03 2008 @@ -106,19 +106,26 @@ status = prepared; def->classLoader->TheModule->resolveVirtualClass(def); virtualSize = def->virtualSize; - /*uint64 vtSize = def->virtualTableSize * sizeof(void*); + + uint64 vtSize = def->virtualTableSize * sizeof(void*); + virtualVT = (VirtualTable*)malloc(2 * vtSize); - memcpy(virtualVT, (void*)((uint64)def->virtualVT + vtSize), vtSize); + + memcpy((void*)((uint64)virtualVT + vtSize), def->virtualVT, vtSize); if (super) { memcpy(virtualVT, (void*)((uint64)super->virtualVT - vtSize), vtSize); } + + virtualVT = (VirtualTable*)((uint64)virtualVT + vtSize); + for (CommonClass::method_iterator i = def->virtualMethods.begin(), e = def->virtualMethods.end(); i != e; ++i) { - ((void**)virtualVT)[i->second->offset] = ctpInfo; + if (i->second->offset > 0) { + ((void**)virtualVT)[-(i->second->offset)] = ctpInfo; + } } - virtualVT = (VirtualTable*)((uint64)virtualVT + vtSize);*/ - virtualVT = def->virtualVT; + def->status = resolved; status = resolved; classDef->broadcastClass(); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp?rev=56335&r1=56334&r2=56335&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Fri Sep 19 02:13:03 2008 @@ -62,7 +62,7 @@ return invokeSpecial(index); -#if !defined(WITHOUT_VTABLE) && !defined(MULTIPLE_VM) +#if !defined(WITHOUT_VTABLE) Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index); std::vector args; // size = [signature->nbIn + 3]; LLVMSignatureInfo* LSI = module->getSignatureInfo(signature); From nicolas.geoffray at lip6.fr Fri Sep 19 00:16:01 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 19 Sep 2008 07:16:01 -0000 Subject: [vmkit-commits] [vmkit] r56336 - in /vmkit/branches/isolate/lib/JnJVM: Classpath/ClasspathVMSystem.cpp.inc VMCore/JavaClass.cpp VMCore/JavaClass.h VMCore/JavaInitialise.cpp VMCore/JavaRuntimeJIT.cpp VMCore/JavaTypes.cpp VMCore/JavaTypes.h VMCore/JnjvmClassLoader.cpp VMCore/JnjvmClassLoader.h VMCore/JnjvmModule.cpp Message-ID: <200809190716.m8J7G1nw031862@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 19 02:16:01 2008 New Revision: 56336 URL: http://llvm.org/viewvc/llvm-project?rev=56336&view=rev Log: Add a doNew function to arrays, and remove a reference to an AssessorDesc (which was dRef or dTab for almost all array classes). Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMSystem.cpp.inc vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMSystem.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMSystem.cpp.inc?rev=56336&r1=56335&r2=56336&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMSystem.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMSystem.cpp.inc Fri Sep 19 02:16:01 2008 @@ -47,10 +47,7 @@ UserClassArray* ts = (UserClassArray*)src->classOf; UserClassArray* td = (UserClassArray*)dst->classOf; UserCommonClass* dstType = td->baseClass(); - AssessorDesc* dstFuncs = td->funcs(); - AssessorDesc* srcFuncs = ts->funcs(); - UserCommonClass* srcPrim = srcFuncs->getPrimitiveClass(); - UserCommonClass* dstPrim = dstFuncs->getPrimitiveClass(); + UserCommonClass* srcType = ts->baseClass(); if (len > src->size) { vm->indexOutOfBounds(src, len); @@ -66,13 +63,14 @@ vm->indexOutOfBounds(src, sstart); } else if (len < 0) { vm->indexOutOfBounds(src, len); - } else if (srcPrim != dstPrim) { + } else if ((dstType->isPrimitive() || srcType->isPrimitive()) && + srcType != dstType) { vm->arrayStoreException(); } jint i = sstart; bool doThrow = false; - if (srcFuncs->doTrace) { + if (!(dstType->isPrimitive())) { while (i < sstart + len && !doThrow) { JavaObject* cur = ((ArrayObject*)src)->elements[i]; if (cur) { @@ -85,8 +83,10 @@ } } - uint32 size = srcFuncs->nbb; - if (size == 0) size = sizeof(void*); + uint32 size = dstType->isPrimitive() ? + dstType->virtualSize : sizeof(JavaObject*); + + assert(size && "Size zero in a arraycopy"); void* ptrDst = (void*)((int64_t)(dst->elements) + size * dstart); void* ptrSrc = (void*)((int64_t)(src->elements) + size * sstart); memmove(ptrDst, ptrSrc, size * len); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp?rev=56336&r1=56335&r2=56336&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp Fri Sep 19 02:16:01 2008 @@ -242,10 +242,10 @@ #endif } -ClassArray::ClassArray(JnjvmClassLoader* loader, const UTF8* n) : +ClassArray::ClassArray(JnjvmClassLoader* loader, const UTF8* n, + UserCommonClass* base) : CommonClass(loader, n, true) { - _funcs = 0; - _baseClass = 0; + _baseClass = base; super = ClassArray::SuperArray; interfaces = ClassArray::InterfacesArray; depth = 1; @@ -253,6 +253,11 @@ display[0] = ClassArray::SuperArray; display[1] = this; access = ACC_FINAL | ACC_ABSTRACT; + if (base->isPrimitive()) { + virtualVT = JavaArray::VT; + } else { + virtualVT = ArrayObject::VT; + } } void Class::print(mvm::PrintBuffer* buf) const { @@ -267,26 +272,21 @@ buf->write(">"); } -void UserClassArray::resolveComponent() { - AssessorDesc::introspectArray(classLoader, getName(), 0, _funcs, - _baseClass); -} - -JnjvmClassLoader* ClassArray::arrayLoader(const UTF8* name, - JnjvmClassLoader* loader, - unsigned int start, - unsigned int len) { - - if (name->elements[start] == AssessorDesc::I_TAB) { - return arrayLoader(name, loader, start + 1, len - 1); - } else if (name->elements[start] == AssessorDesc::I_REF) { - const UTF8* componentName = name->javaToInternal(loader->hashUTF8, - start + 1, len - 2); - UserCommonClass* cl = loader->loadName(componentName, false, true); - return cl->classLoader; - } else { - return JavaThread::get()->isolate->bootstrapLoader; - } +JavaArray* UserClassArray::doNew(sint32 n, Jnjvm* vm) { + if (n < 0) + vm->negativeArraySizeException(n); + else if (n > JavaArray::MaxArraySize) + vm->outOfMemoryError(n); + + UserCommonClass* cl = baseClass(); + assert(cl && virtualVT && "array class not resolved"); + + uint32 primSize = cl->isPrimitive() ? cl->virtualSize : sizeof(JavaObject*); + JavaArray* res = (JavaArray*) + vm->allocator.allocateObject(sizeof(name) + n * primSize, virtualVT); + res->initialise(this); + res->size = n; + return res; } void* JavaMethod::compiledPtr() { Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h?rev=56336&r1=56335&r2=56336&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h Fri Sep 19 02:16:01 2008 @@ -32,6 +32,7 @@ class Enveloppe; class Class; class ClassArray; +class JavaArray; class JavaConstantPool; class JavaField; class JavaJIT; @@ -682,39 +683,25 @@ /// CommonClass* _baseClass; - /// _funcs - The type of the base class of the array (primitive or - /// reference). Null if not resolved. - /// - AssessorDesc* _funcs; - - /// resolveComponent - Resolve the array class. The base class and the - /// AssessorDesc are resolved. - /// - void resolveComponent(); - /// baseClass - Get the base class of this array class. Resolve the array /// class if needed. /// CommonClass* baseClass() { - if (_baseClass == 0) - resolveComponent(); return _baseClass; } - /// funcs - Get the type of the base class/ Resolve the array if needed. - AssessorDesc* funcs() { - if (_funcs == 0) - resolveComponent(); - return _funcs; - } + /// funcs - Get the type of the base class/ Resolve the array if needed. + JavaArray* doNew(sint32 n, Jnjvm* vm); + /// ClassArray - Empty constructor for VT. /// ClassArray() {} /// ClassArray - Construct a Java array class with the given name. /// - ClassArray(JnjvmClassLoader* loader, const UTF8* name); + ClassArray(JnjvmClassLoader* loader, const UTF8* name, + UserCommonClass* baseClass); /// arrayLoader - Return the class loader of the class with the name 'name'. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=56336&r1=56335&r2=56336&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp Fri Sep 19 02:16:01 2008 @@ -88,12 +88,28 @@ JnjvmBootstrapLoader* JCL = bootstrapLoader = JnjvmBootstrapLoader::createBootstrapLoader(); - // Array initialization + // Create the name of char arrays. const UTF8* utf8OfChar = JCL->asciizConstructUTF8("[C"); - JCL->upcalls->ArrayOfChar = JCL->constructArray(utf8OfChar); + + // Create the base class of char arrays. + JCL->upcalls->OfChar = UPCALL_PRIMITIVE_CLASS(JCL, "char", 2); + + // Create the char array. + JCL->upcalls->ArrayOfChar = JCL->constructArray(utf8OfChar, + JCL->upcalls->OfChar); + + // Alright, now we can repair the damage: set the class to the UTF8s created + // and set the array class of UTF8s. ((UTF8*)utf8OfChar)->classOf = JCL->upcalls->ArrayOfChar; + ((UTF8*)JCL->upcalls->OfChar->name)->classOf = JCL->upcalls->ArrayOfChar; JCL->hashUTF8->array = JCL->upcalls->ArrayOfChar; + + // Create the byte array, so that bytes for classes can be created. + JCL->upcalls->OfByte = UPCALL_PRIMITIVE_CLASS(JCL, "byte", 1); + JCL->upcalls->ArrayOfByte = + JCL->constructArray(JCL->asciizConstructUTF8("[B"), JCL->upcalls->OfByte); + // Now we can create the super and interfaces of arrays. JCL->InterfacesArray.push_back( JCL->loadName(JCL->asciizConstructUTF8("java/lang/Cloneable"), false, false)); @@ -116,41 +132,49 @@ ClassArray::SuperArray = JCL->SuperArray; ClassArray::InterfacesArray = JCL->InterfacesArray; #endif - + + // And repair the damage: set the interfaces and super of array classes already + // created. JCL->upcalls->ArrayOfChar->setInterfaces(JCL->InterfacesArray); JCL->upcalls->ArrayOfChar->setSuper(JCL->SuperArray); + JCL->upcalls->ArrayOfByte->setInterfaces(JCL->InterfacesArray); + JCL->upcalls->ArrayOfByte->setSuper(JCL->SuperArray); - JCL->upcalls->ArrayOfByte = JCL->constructArray(JCL->asciizConstructUTF8("[B")); - JCL->upcalls->ArrayOfString = - JCL->constructArray(JCL->asciizConstructUTF8("[Ljava/lang/String;")); + // Yay, create the other primitive types. + JCL->upcalls->OfBool = UPCALL_PRIMITIVE_CLASS(JCL, "boolean", 1); + JCL->upcalls->OfShort = UPCALL_PRIMITIVE_CLASS(JCL, "short", 2); + JCL->upcalls->OfInt = UPCALL_PRIMITIVE_CLASS(JCL, "int", 4); + JCL->upcalls->OfLong = UPCALL_PRIMITIVE_CLASS(JCL, "long", 8); + JCL->upcalls->OfFloat = UPCALL_PRIMITIVE_CLASS(JCL, "float", 4); + JCL->upcalls->OfDouble = UPCALL_PRIMITIVE_CLASS(JCL, "double", 8); + JCL->upcalls->OfVoid = UPCALL_PRIMITIVE_CLASS(JCL, "void", 0); - JCL->upcalls->ArrayOfObject = - JCL->constructArray(JCL->asciizConstructUTF8("[Ljava/lang/Object;")); + // And finally create the primitive arrays. + JCL->upcalls->ArrayOfInt = + JCL->constructArray(JCL->asciizConstructUTF8("[I"), JCL->upcalls->OfInt); - JCL->upcalls->ArrayOfInt = JCL->constructArray(JCL->asciizConstructUTF8("[I")); + JCL->upcalls->ArrayOfBool = + JCL->constructArray(JCL->asciizConstructUTF8("[Z"), JCL->upcalls->OfBool); - JCL->upcalls->ArrayOfBool = JCL->constructArray(JCL->asciizConstructUTF8("[Z")); + JCL->upcalls->ArrayOfLong = + JCL->constructArray(JCL->asciizConstructUTF8("[J"), JCL->upcalls->OfLong); - JCL->upcalls->ArrayOfLong = JCL->constructArray(JCL->asciizConstructUTF8("[J")); + JCL->upcalls->ArrayOfFloat = + JCL->constructArray(JCL->asciizConstructUTF8("[F"), JCL->upcalls->OfFloat); - JCL->upcalls->ArrayOfFloat = JCL->constructArray(JCL->asciizConstructUTF8("[F")); + JCL->upcalls->ArrayOfDouble = + JCL->constructArray(JCL->asciizConstructUTF8("[D"), JCL->upcalls->OfDouble); - JCL->upcalls->ArrayOfDouble = JCL->constructArray(JCL->asciizConstructUTF8("[D")); + JCL->upcalls->ArrayOfShort = + JCL->constructArray(JCL->asciizConstructUTF8("[S"), JCL->upcalls->OfShort); - JCL->upcalls->ArrayOfShort = JCL->constructArray(JCL->asciizConstructUTF8("[S")); + JCL->upcalls->ArrayOfString = + JCL->constructArray(JCL->asciizConstructUTF8("[Ljava/lang/String;")); + + JCL->upcalls->ArrayOfObject = + JCL->constructArray(JCL->asciizConstructUTF8("[Ljava/lang/Object;")); - // End array initialization - JCL->upcalls->OfByte = UPCALL_PRIMITIVE_CLASS(JCL, "byte", 1); - JCL->upcalls->OfBool = UPCALL_PRIMITIVE_CLASS(JCL, "boolean", 1); - JCL->upcalls->OfChar = UPCALL_PRIMITIVE_CLASS(JCL, "char", 2); - JCL->upcalls->OfShort = UPCALL_PRIMITIVE_CLASS(JCL, "short", 2); - JCL->upcalls->OfInt = UPCALL_PRIMITIVE_CLASS(JCL, "int", 4); - JCL->upcalls->OfLong = UPCALL_PRIMITIVE_CLASS(JCL, "long", 8); - JCL->upcalls->OfFloat = UPCALL_PRIMITIVE_CLASS(JCL, "float", 4); - JCL->upcalls->OfDouble = UPCALL_PRIMITIVE_CLASS(JCL, "double", 8); - JCL->upcalls->OfVoid = UPCALL_PRIMITIVE_CLASS(JCL, "void", 0); - AssessorDesc::initialise(JCL); Attribut::codeAttribut = JCL->asciizConstructUTF8("Code"); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=56336&r1=56335&r2=56336&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Fri Sep 19 02:16:01 2008 @@ -306,22 +306,18 @@ return cl->getClassDelegatee(vm); } -static JavaArray* multiCallNewIntern(arrayCtor_t ctor, UserClassArray* cl, - uint32 len, - sint32* dims, - Jnjvm* vm) { +static JavaArray* multiCallNewIntern(UserClassArray* cl, uint32 len, + sint32* dims, Jnjvm* vm) { if (len <= 0) JavaThread::get()->isolate->unknownError("Can not happen"); - JavaArray* _res = ctor(dims[0], cl, vm); + JavaArray* _res = cl->doNew(dims[0], vm); if (len > 1) { ArrayObject* res = (ArrayObject*)_res; UserCommonClass* _base = cl->baseClass(); if (_base->isArray()) { UserClassArray* base = (UserClassArray*)_base; - AssessorDesc* func = base->funcs(); - arrayCtor_t newCtor = func->arrayCtor; if (dims[0] > 0) { for (sint32 i = 0; i < dims[0]; ++i) { - res->elements[i] = multiCallNewIntern(newCtor, base, (len - 1), + res->elements[i] = multiCallNewIntern(base, (len - 1), &dims[1], vm); } } else { @@ -345,7 +341,7 @@ dims[i] = va_arg(ap, int); } Jnjvm* vm = JavaThread::get()->isolate; - return multiCallNewIntern((arrayCtor_t)ArrayObject::acons, cl, len, dims, vm); + return multiCallNewIntern(cl, len, dims, vm); } extern "C" void JavaObjectAquire(JavaObject* obj) { Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp?rev=56336&r1=56335&r2=56336&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp Fri Sep 19 02:16:01 2008 @@ -57,8 +57,8 @@ const char* name, JnjvmClassLoader* loader, uint8 nid, const char* assocName, - UserClassPrimitive* prim, UserClassArray* cl, - arrayCtor_t ctor) { + UserClassPrimitive* prim, UserClassArray* cl) { + AssessorDesc* res = this; res->numId = nid; res->doTrace = dt; @@ -67,7 +67,6 @@ res->nbw = nw; res->asciizName = name; res->UTF8Name = loader->asciizConstructUTF8(name); - res->arrayCtor = ctor; res->arrayClass = cl; if (assocName) @@ -79,7 +78,6 @@ res->primitiveClass = prim; if (res->arrayClass) { res->arrayClass->_baseClass = res->primitiveClass; - res->arrayClass->_funcs = res; res->arrayClass->status = ready; } } else { @@ -90,63 +88,53 @@ void AssessorDesc::initialise(JnjvmBootstrapLoader* vm) { dParg = new AssessorDesc(false, I_PARG, 0, 0, "(", vm, 0, 0, 0, - 0, 0); + 0); dPard = new AssessorDesc(false, I_PARD, 0, 0, ")", vm, 0, 0, 0, - 0, 0); + 0); dVoid = new AssessorDesc(false, I_VOID, 0, 0, "void", vm, VOID_ID, "java/lang/Void", - vm->upcalls->OfVoid, 0, 0); + vm->upcalls->OfVoid, 0); dBool = new AssessorDesc(false, I_BOOL, 1, 1, "boolean", vm, BOOL_ID, "java/lang/Boolean", vm->upcalls->OfBool, - vm->upcalls->ArrayOfBool, - (arrayCtor_t)ArrayUInt8::acons); + vm->upcalls->ArrayOfBool); dByte = new AssessorDesc(false, I_BYTE, 1, 1, "byte", vm, BYTE_ID, "java/lang/Byte", vm->upcalls->OfByte, - vm->upcalls->ArrayOfByte, - (arrayCtor_t)ArraySInt8::acons); + vm->upcalls->ArrayOfByte); dChar = new AssessorDesc(false, I_CHAR, 2, 1, "char", vm, CHAR_ID, "java/lang/Character", vm->upcalls->OfChar, - vm->upcalls->ArrayOfChar, - (arrayCtor_t)ArrayUInt16::acons); + vm->upcalls->ArrayOfChar); dShort = new AssessorDesc(false, I_SHORT, 2, 1, "short", vm, SHORT_ID, "java/lang/Short", vm->upcalls->OfShort, - vm->upcalls->ArrayOfShort, - (arrayCtor_t)ArraySInt16::acons); + vm->upcalls->ArrayOfShort); dInt = new AssessorDesc(false, I_INT, 4, 1, "int", vm, INT_ID, "java/lang/Integer", vm->upcalls->OfInt, - vm->upcalls->ArrayOfInt, - (arrayCtor_t)ArraySInt32::acons); + vm->upcalls->ArrayOfInt); dFloat = new AssessorDesc(false, I_FLOAT, 4, 1, "float", vm, FLOAT_ID, "java/lang/Float", vm->upcalls->OfFloat, - vm->upcalls->ArrayOfFloat, - (arrayCtor_t)ArrayFloat::acons); + vm->upcalls->ArrayOfFloat); dLong = new AssessorDesc(false, I_LONG, 8, 2, "long", vm, LONG_ID, "java/lang/Long", vm->upcalls->OfLong, - vm->upcalls->ArrayOfLong, - (arrayCtor_t)ArrayLong::acons); + vm->upcalls->ArrayOfLong); dDouble = new AssessorDesc(false, I_DOUBLE, 8, 2, "double", vm, DOUBLE_ID, "java/lang/Double", vm->upcalls->OfDouble, - vm->upcalls->ArrayOfDouble, - (arrayCtor_t)ArrayDouble::acons); + vm->upcalls->ArrayOfDouble); dTab = new AssessorDesc(true, I_TAB, sizeof(void*), 1, "array", - vm, ARRAY_ID, 0, 0, 0, - (arrayCtor_t)ArrayObject::acons); + vm, ARRAY_ID, 0, 0, 0); dRef = new AssessorDesc(true, I_REF, sizeof(void*), 1, "reference", vm, OBJECT_ID, - 0, 0, 0, - (arrayCtor_t)ArrayObject::acons); + 0, 0, 0); } @@ -279,35 +267,6 @@ } } -void AssessorDesc::introspectArray(JnjvmClassLoader* loader, - const UTF8* utf8, uint32 start, - AssessorDesc*& ass, UserCommonClass*& res) { - uint32 pos = 0; - uint32 intern = 0; - AssessorDesc* funcs = 0; - - analyseIntern(utf8, start, 1, funcs, intern); - - if (funcs != dTab) { - Jnjvm* vm = JavaThread::get()->isolate; - vm->unknownError("%s isn't an array", utf8->printString()); - } - - analyseIntern(utf8, intern, 0, funcs, pos); - - if (funcs == dRef) { - ass = dRef; - const UTF8* temp = utf8->extract(loader->hashUTF8, intern + 1, pos - 1); - res = loader->loadName(temp, false, true); - } else if (funcs == dTab) { - ass = dTab; - res = loader->constructArray(utf8->extract(loader->hashUTF8, intern, pos)); - } else { - ass = funcs; - res = funcs->getPrimitiveClass(); - } -} - AssessorDesc* AssessorDesc::arrayType(unsigned int t) { if (t == JavaArray::T_CHAR) { return AssessorDesc::dChar; @@ -487,9 +446,9 @@ res->initialLoader = loader; res->keyName = name; res->funcs = funcs; - if (funcs == AssessorDesc::dRef) { + if (isReference()) { res->pseudoAssocClassName = name->extract(loader->hashUTF8, 1, next - 1); - } else if (funcs == AssessorDesc::dTab) { + } else if (isArray()) { res->pseudoAssocClassName = name; } else { res->pseudoAssocClassName = 0; @@ -497,6 +456,19 @@ } +bool Typedef::isArray() { + return keyName->elements[0] == '['; +} + +bool Typedef::isReference() { + return keyName->elements[0] == 'L'; +} + +bool Typedef::trace() { + uint16 val = keyName->elements[0]; + return (val == '[' || val == 'L'); +} + intptr_t Signdef::staticCallBuf() { if (!_staticCallBuf) { LLVMSignatureInfo* LSI = initialLoader->TheModule->getSignatureInfo(this); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h?rev=56336&r1=56335&r2=56336&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h Fri Sep 19 02:16:01 2008 @@ -43,9 +43,6 @@ #define OBJECT_ID 10 #define NUM_ASSESSORS 11 -typedef JavaArray* (*arrayCtor_t)(uint32 len, UserClassArray* cl, Jnjvm* vm); - - /// AssessorDesc - Description of a Java assessor: these are the letters found /// in Java signatures, e.g. "I" or "(". /// @@ -111,10 +108,6 @@ /// UserClassArray* arrayClass; - /// arrayCtor - The constructor of an array of this assessor. - /// - arrayCtor_t arrayCtor; - //===----------------------------------------------------------------------===// // // The set of assessors in Java. This set is unique and there are no other @@ -187,8 +180,7 @@ const char* name, JnjvmClassLoader* loader, uint8 nid, const char* assocName, - UserClassPrimitive* prim, UserClassArray* cl, - arrayCtor_t ctor); + UserClassPrimitive* prim, UserClassArray* cl); /// initialise - Construct all assessors. @@ -207,10 +199,6 @@ static const UTF8* constructArrayName(JnjvmClassLoader* loader, AssessorDesc* ass, uint32 steps, const UTF8* className); - static void introspectArray(JnjvmClassLoader* loader, const UTF8* utf8, - uint32 start, AssessorDesc*& ass, - UserCommonClass*& res); - static AssessorDesc* arrayType(unsigned int t); static AssessorDesc* byteIdToPrimitive(const char id); @@ -277,6 +265,10 @@ /// tPrintBuf - Prints the name of the class this Typedef represents. /// void tPrintBuf(mvm::PrintBuffer* buf) const; + + bool isArray(); + bool isReference(); + bool trace(); }; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=56336&r1=56335&r2=56336&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Fri Sep 19 02:16:01 2008 @@ -253,21 +253,31 @@ return classes->lookup(utf8); } -static UserCommonClass* arrayDup(const UTF8*& name, JnjvmClassLoader* loader) { - UserClassArray* cl = allocator_new(loader->allocator, UserClassArray)(loader, name); - return cl; +UserCommonClass* JnjvmClassLoader::loadBaseClass(const UTF8* name, + uint32 start, uint32 len) { + + if (name->elements[start] == AssessorDesc::I_TAB) { + UserCommonClass* baseClass = loadBaseClass(name, start + 1, len - 1); + JnjvmClassLoader* loader = baseClass->classLoader; + const UTF8* arrayName = name->extract(loader->hashUTF8, start, start + len); + return loader->constructArray(arrayName); + } else if (name->elements[start] == AssessorDesc::I_REF) { + const UTF8* componentName = name->extract(hashUTF8, + start + 1, start + len - 1); + UserCommonClass* cl = loadName(componentName, false, true); + return cl; + } else { + AssessorDesc* ass = AssessorDesc::byteIdToPrimitive(name->elements[start]); + return ass ? ass->primitiveClass : 0; + } } + UserClassArray* JnjvmClassLoader::constructArray(const UTF8* name) { - if (javaLoader != 0) { - JnjvmClassLoader * ld = - ClassArray::arrayLoader(name, this, 1, name->size - 1); - UserClassArray* res = - (UserClassArray*)ld->classes->lookupOrCreate(name, this, arrayDup); - return res; - } else { - return (UserClassArray*)classes->lookupOrCreate(name, this, arrayDup); - } + UserCommonClass* cl = loadBaseClass(name, 1, name->size - 1); + assert(cl && "no base class for an array"); + JnjvmClassLoader* ld = cl->classLoader; + return ld->constructArray(name, cl); } UserClass* JnjvmClassLoader::constructClass(const UTF8* name, ArrayUInt8* bytes) { @@ -286,6 +296,25 @@ return res; } +UserClassArray* JnjvmClassLoader::constructArray(const UTF8* name, + UserCommonClass* baseClass) { + assert(baseClass && "constructing an array class without a base class"); + assert(baseClass->classLoader == this && + "constructing an array with wrong loader"); + classes->lock->lock(); + ClassMap::iterator End = classes->map.end(); + ClassMap::iterator I = classes->map.find(name); + UserClassArray* res = 0; + if (I == End) { + res = allocator_new(allocator, UserClassArray)(this, name, baseClass); + classes->map.insert(std::make_pair(name, res)); + } else { + res = ((UserClassArray*)(I->second)); + } + classes->lock->unlock(); + return res; +} + Typedef* JnjvmClassLoader::constructType(const UTF8* name) { Typedef* res = javaTypes->lookup(name); if (res == 0) { Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h?rev=56336&r1=56335&r2=56336&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h Fri Sep 19 02:16:01 2008 @@ -158,6 +158,9 @@ /// the given name. /// UserClassArray* constructArray(const UTF8* name); + UserClassArray* constructArray(const UTF8* name, UserCommonClass* base); + + UserCommonClass* loadBaseClass(const UTF8* name, uint32 start, uint32 len); /// constructClass - Hashes a runtime representation of a class with /// the given name. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=56336&r1=56335&r2=56336&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Fri Sep 19 02:16:01 2008 @@ -330,7 +330,7 @@ for (CommonClass::field_iterator i = fields.begin(), e = fields.end(); i!= e; ++i) { - if (i->second->getSignature()->funcs->doTrace) { + if (i->second->getSignature()->trace()) { LLVMFieldInfo* LFI = getFieldInfo(i->second); std::vector args; //size = 2 args.push_back(zero); From nicolas.geoffray at lip6.fr Fri Sep 19 07:50:41 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 19 Sep 2008 14:50:41 -0000 Subject: [vmkit-commits] [vmkit] r56347 - in /vmkit/branches/isolate/lib/JnJVM: Classpath/ VMCore/ Message-ID: <200809191450.m8JEog78023221@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 19 09:50:39 2008 New Revision: 56347 URL: http://llvm.org/viewvc/llvm-project?rev=56347&view=rev Log: Get rid of AssessorDescs, and only base the type information on primitive classes. Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp.inc vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.h vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.h vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp Fri Sep 19 09:50:39 2008 @@ -179,7 +179,7 @@ UserCommonClass* base = NativeUtil::resolvedImplClass(arrayType, true); JnjvmClassLoader* loader = base->classLoader; const UTF8* name = base->getName(); - const UTF8* arrayName = AssessorDesc::constructArrayName(loader, 0, 1, name); + const UTF8* arrayName = AssessorDesc::constructArrayName(loader, 1, name); UserClassArray* array = loader->constructArray(arrayName); ArrayObject* res = ArrayObject::acons(arrayLength, array, &(vm->allocator)); Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathMethod.cpp.inc Fri Sep 19 09:50:39 2008 @@ -144,58 +144,59 @@ } \ JavaObject* res = 0; - const AssessorDesc* retType = meth->getSignature()->ret->funcs; - if (retType == AssessorDesc::dVoid) { - res = 0; - uint32 val = 0; - RUN_METH(Int); - } else if (retType == AssessorDesc::dBool) { - uint32 val = 0; - RUN_METH(Int); - res = vm->upcalls->boolClass->doNew(vm); - vm->upcalls->boolValue->setInt8Field(res, val); - } else if (retType == AssessorDesc::dByte) { - uint32 val = 0; - RUN_METH(Int); - res = vm->upcalls->byteClass->doNew(vm); - vm->upcalls->byteValue->setInt8Field(res, val); - } else if (retType == AssessorDesc::dChar) { - uint32 val = 0; - RUN_METH(Int); - res = vm->upcalls->charClass->doNew(vm); - vm->upcalls->charValue->setInt16Field(res, val); - } else if (retType == AssessorDesc::dShort) { - uint32 val = 0; - RUN_METH(Int); - res = vm->upcalls->shortClass->doNew(vm); - vm->upcalls->shortValue->setInt16Field(res, val); - } else if (retType == AssessorDesc::dInt) { - uint32 val = 0; - RUN_METH(Int); - res = vm->upcalls->intClass->doNew(vm); - vm->upcalls->intValue->setInt32Field(res, val); - } else if (retType == AssessorDesc::dLong) { - sint64 val = 0; - RUN_METH(Long); - res = vm->upcalls->longClass->doNew(vm); - vm->upcalls->longValue->setLongField(res, val); - } else if (retType == AssessorDesc::dFloat) { - float val = 0; - RUN_METH(Float); - res = vm->upcalls->floatClass->doNew(vm); - vm->upcalls->floatValue->setFloatField(res, val); - } else if (retType == AssessorDesc::dDouble) { - double val = 0; - RUN_METH(Double); - res = vm->upcalls->doubleClass->doNew(vm); - vm->upcalls->doubleValue->setDoubleField(res, val); - } else if (retType == AssessorDesc::dTab || retType == AssessorDesc::dRef) { + Typedef* retType = meth->getSignature()->ret; + if (retType->isPrimitive()) { + PrimitiveTypedef* prim = (PrimitiveTypedef*)retType; + if (prim->isVoid()) { + res = 0; + uint32 val = 0; + RUN_METH(Int); + } else if (prim->isBool()) { + uint32 val = 0; + RUN_METH(Int); + res = vm->upcalls->boolClass->doNew(vm); + vm->upcalls->boolValue->setInt8Field(res, val); + } else if (prim->isByte()) { + uint32 val = 0; + RUN_METH(Int); + res = vm->upcalls->byteClass->doNew(vm); + vm->upcalls->byteValue->setInt8Field(res, val); + } else if (prim->isChar()) { + uint32 val = 0; + RUN_METH(Int); + res = vm->upcalls->charClass->doNew(vm); + vm->upcalls->charValue->setInt16Field(res, val); + } else if (prim->isShort()) { + uint32 val = 0; + RUN_METH(Int); + res = vm->upcalls->shortClass->doNew(vm); + vm->upcalls->shortValue->setInt16Field(res, val); + } else if (prim->isInt()) { + uint32 val = 0; + RUN_METH(Int); + res = vm->upcalls->intClass->doNew(vm); + vm->upcalls->intValue->setInt32Field(res, val); + } else if (prim->isLong()) { + sint64 val = 0; + RUN_METH(Long); + res = vm->upcalls->longClass->doNew(vm); + vm->upcalls->longValue->setLongField(res, val); + } else if (prim->isFloat()) { + float val = 0; + RUN_METH(Float); + res = vm->upcalls->floatClass->doNew(vm); + vm->upcalls->floatValue->setFloatField(res, val); + } else if (prim->isDouble()) { + double val = 0; + RUN_METH(Double); + res = vm->upcalls->doubleClass->doNew(vm); + vm->upcalls->doubleValue->setDoubleField(res, val); + } + } else { JavaObject* val = 0; RUN_METH(JavaObject); res = val; - } else { - vm->unknownError("should not be here"); - } + } return (jobject)res; } vm->illegalArgumentExceptionForMethod(meth, 0, 0); Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp.inc?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp.inc Fri Sep 19 09:50:39 2008 @@ -32,12 +32,12 @@ #endif jchar byteId) { - AssessorDesc* ass = AssessorDesc::byteIdToPrimitive(byteId); Jnjvm* vm = JavaThread::get()->isolate; - if (!ass) + UserClassPrimitive* prim = AssessorDesc::byteIdToPrimitive(byteId, vm->upcalls); + if (!prim) vm->unknownError("unknown byte primitive %c", byteId); - return (jobject)ass->getPrimitiveClass()->getClassDelegatee(vm); + return (jobject)prim->getClassDelegatee(vm); } Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMField.cpp.inc Fri Sep 19 09:50:39 2008 @@ -65,7 +65,7 @@ jobject Field, jobject obj) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; + const Typedef* type = field->getSignature(); JavaObject* Obj = (JavaObject*)obj; @@ -75,18 +75,20 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case INT_ID : + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + + if (prim->isInt()) return (sint32)field->getInt32Field(Obj); - case CHAR_ID : + if (prim->isChar()) return (uint32)field->getInt16Field(Obj); - case BYTE_ID : + if (prim->isByte()) return (sint32)field->getInt8Field(Obj); - case SHORT_ID : + if (prim->isShort()) return (sint32)field->getInt16Field(Obj); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + + JavaThread::get()->isolate->illegalArgumentException(""); return 0; } @@ -98,7 +100,6 @@ jobject Field, jobject obj) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; @@ -108,20 +109,23 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case INT_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + + if (prim->isInt()) return (sint64)field->getInt32Field(Obj); - case CHAR_ID : + if (prim->isChar()) return (uint64)field->getInt16Field(Obj); - case BYTE_ID : + if (prim->isByte()) return (sint64)field->getInt8Field(Obj); - case SHORT_ID : + if (prim->isShort()) return (sint64)field->getInt16Field(Obj); - case LONG_ID : + if (prim->isLong()) return (sint64)field->getLongField(Obj); - default: - JavaThread::get()->isolate->illegalArgumentException(""); } + + JavaThread::get()->isolate->illegalArgumentException(""); return 0; } @@ -132,7 +136,6 @@ jobject Field, jobject obj) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; @@ -142,12 +145,14 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case BOOL_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isBool()) return (uint8)field->getInt8Field(Obj); - default: - JavaThread::get()->isolate->illegalArgumentException(""); } + + JavaThread::get()->isolate->illegalArgumentException(""); return 0; @@ -160,7 +165,6 @@ jobject Field, jobject obj) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; @@ -170,22 +174,23 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case BYTE_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isByte()) return (jfloat)field->getInt8Field(Obj); - case INT_ID : + if (prim->isInt()) return (jfloat)field->getInt32Field((JavaObject*)obj); - case SHORT_ID : + if (prim->isShort()) return (jfloat)field->getInt16Field((JavaObject*)obj); - case LONG_ID : + if (prim->isLong()) return (jfloat)field->getLongField((JavaObject*)obj); - case CHAR_ID : + if (prim->isChar()) return (jfloat)(uint32)field->getInt16Field((JavaObject*)obj); - case FLOAT_ID : + if (prim->isFloat()) return (jfloat)field->getFloatField((JavaObject*)obj); - default: - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); return 0.0; } @@ -196,7 +201,6 @@ jobject Field, jobject obj) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; @@ -206,12 +210,13 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case BYTE_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isByte()) return (sint8)field->getInt8Field(Obj); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); return 0; } @@ -223,7 +228,6 @@ jobject Field, jobject obj) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; @@ -233,12 +237,13 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case CHAR_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isChar()) return (uint16)field->getInt16Field((JavaObject*)obj); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); return 0; @@ -251,7 +256,6 @@ jobject Field, jobject obj) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; @@ -261,14 +265,15 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case SHORT_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isShort()) return (sint16)field->getInt16Field(Obj); - case BYTE_ID : + if (prim->isByte()) return (sint16)field->getInt8Field(Obj); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); return 0; } @@ -280,7 +285,6 @@ jobject Field, jobject obj) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; @@ -290,24 +294,25 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case BYTE_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isByte()) return (jdouble)(sint64)field->getInt8Field(Obj); - case INT_ID : + if (prim->isInt()) return (jdouble)(sint64)field->getInt32Field(Obj); - case SHORT_ID : + if (prim->isShort()) return (jdouble)(sint64)field->getInt16Field(Obj); - case LONG_ID : + if (prim->isLong()) return (jdouble)(sint64)field->getLongField(Obj); - case CHAR_ID : + if (prim->isChar()) return (jdouble)(uint64)field->getInt16Field(Obj); - case FLOAT_ID : + if (prim->isFloat()) return (jdouble)field->getFloatField(Obj); - case DOUBLE_ID : + if (prim->isDouble()) return (jdouble)field->getDoubleField(Obj); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); return 0.0; } @@ -318,8 +323,6 @@ jobject Field, jobject _obj) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - Typedef* type = field->getSignature(); - const AssessorDesc* ass = type->funcs; JavaObject* Obj = (JavaObject*)_obj; @@ -330,61 +333,51 @@ } JavaObject* res = 0; - switch (ass->numId) { - case BOOL_ID : { + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isBool()) { uint8 val = field->getInt8Field(Obj); res = vm->upcalls->boolClass->doNew(vm); vm->upcalls->boolValue->setInt8Field(res, val); - break; } - case BYTE_ID : { + else if (prim->isByte()) { sint8 val = field->getInt8Field(Obj); res = vm->upcalls->byteClass->doNew(vm); vm->upcalls->byteValue->setInt8Field(res, val); - break; } - case CHAR_ID : { + else if (prim->isChar()) { uint16 val = field->getInt16Field(Obj); res = vm->upcalls->charClass->doNew(vm); vm->upcalls->charValue->setInt16Field(res, val); - break; } - case SHORT_ID : { + else if (prim->isShort()) { sint16 val = field->getInt16Field(Obj); res = vm->upcalls->shortClass->doNew(vm); vm->upcalls->shortValue->setInt16Field(res, val); - break; } - case INT_ID : { + else if (prim->isInt()) { sint32 val = field->getInt32Field(Obj); res = vm->upcalls->intClass->doNew(vm); vm->upcalls->intValue->setInt32Field(res, val); - break; } - case LONG_ID : { + else if (prim->isLong()) { sint64 val = field->getLongField(Obj); res = vm->upcalls->longClass->doNew(vm); vm->upcalls->longValue->setLongField(res, val); - break; } - case FLOAT_ID : { + else if (prim->isFloat()) { float val = field->getFloatField(Obj); res = vm->upcalls->floatClass->doNew(vm); vm->upcalls->floatValue->setFloatField(res, val); - break; } - case DOUBLE_ID : { + else if (prim->isDouble()) { double val = field->getDoubleField(Obj); res = vm->upcalls->doubleClass->doNew(vm); vm->upcalls->doubleValue->setDoubleField(res, val); - break; } - case OBJECT_ID : - case ARRAY_ID : - res = field->getObjectField(Obj); - break; - default: - JavaThread::get()->isolate->unknownError("should not be here"); + } else { + res = field->getObjectField(Obj); } return (jobject)res; } @@ -400,7 +393,6 @@ void* _buf = (void*)buf; NativeUtil::decapsulePrimitive(JavaThread::get()->isolate, buf, (JavaObject*)val, field->getSignature()); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; @@ -410,28 +402,27 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case BOOL_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isBool()) return field->setInt8Field(Obj, ((uint8*)_buf)[0]); - case BYTE_ID : + if (prim->isByte()) return field->setInt8Field(Obj, ((sint8*)_buf)[0]); - case CHAR_ID : + if (prim->isChar()) return field->setInt16Field(Obj, ((uint16*)_buf)[0]); - case SHORT_ID : + if (prim->isShort()) return field->setInt16Field(Obj, ((sint16*)_buf)[0]); - case INT_ID : + if (prim->isInt()) return field->setInt32Field(Obj, ((sint32*)_buf)[0]); - case LONG_ID : + if (prim->isLong()) return field->setLongField(Obj, ((sint64*)_buf)[0]); - case FLOAT_ID : + if (prim->isFloat()) return field->setFloatField(Obj, ((float*)_buf)[0]); - case DOUBLE_ID : + if (prim->isDouble()) return field->setDoubleField(Obj, ((double*)_buf)[0]); - case ARRAY_ID : - case OBJECT_ID : - return field->setObjectField(Obj, ((JavaObject**)_buf)[0]); - default : - JavaThread::get()->isolate->unknownError("should not be here"); + } else { + return field->setObjectField(Obj, ((JavaObject**)_buf)[0]); } } @@ -442,7 +433,6 @@ jobject Field, jobject obj, jboolean val) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; if (isStatic(field->access)) { @@ -451,12 +441,13 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case BOOL_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isBool()) return field->setInt8Field(Obj, (uint8)val); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); } @@ -467,7 +458,6 @@ jobject Field, jobject obj, jbyte val) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; if (isStatic(field->access)) { @@ -476,22 +466,23 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case BYTE_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isByte()) return field->setInt8Field(Obj, (sint8)val); - case SHORT_ID : + if (prim->isShort()) return field->setInt16Field(Obj, (sint16)val); - case INT_ID : + if (prim->isInt()) return field->setInt32Field(Obj, (sint32)val); - case LONG_ID : + if (prim->isLong()) return field->setLongField(Obj, (sint64)val); - case FLOAT_ID : + if (prim->isFloat()) return field->setFloatField(Obj, (float)val); - case DOUBLE_ID : + if (prim->isDouble()) return field->setDoubleField(Obj, (double)val); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); } JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setChar( @@ -501,7 +492,6 @@ jobject Field, jobject obj, jchar val) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; @@ -511,20 +501,21 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case CHAR_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isChar()) return field->setInt16Field(Obj, (uint16)val); - case INT_ID : + if (prim->isInt()) return field->setInt32Field(Obj, (uint32)val); - case LONG_ID : + if (prim->isLong()) return field->setLongField(Obj, (uint64)val); - case FLOAT_ID : + if (prim->isFloat()) return field->setFloatField(Obj, (float)(uint32)val); - case DOUBLE_ID : + if (prim->isDouble()) return field->setDoubleField(Obj, (double)(uint64)val); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); } JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setShort( @@ -534,7 +525,6 @@ jobject Field, jobject obj, jshort val) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; @@ -544,20 +534,21 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case SHORT_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isShort()) return field->setInt16Field(Obj, (sint16)val); - case INT_ID : + if (prim->isInt()) return field->setInt32Field(Obj, (sint32)val); - case LONG_ID : + if (prim->isLong()) return field->setLongField(Obj, (sint64)val); - case FLOAT_ID : + if (prim->isFloat()) return field->setFloatField(Obj, (float)val); - case DOUBLE_ID : + if (prim->isDouble()) return field->setDoubleField(Obj, (double)val); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); } JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setInt( @@ -567,7 +558,6 @@ jobject Field, jobject obj, jint val) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; if (isStatic(field->access)) { @@ -576,18 +566,19 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case INT_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isInt()) return field->setInt32Field(Obj, (sint32)val); - case LONG_ID : + if (prim->isLong()) return field->setLongField(Obj, (sint64)val); - case FLOAT_ID : + if (prim->isFloat()) return field->setFloatField(Obj, (float)val); - case DOUBLE_ID : + if (prim->isDouble()) return field->setDoubleField(Obj, (double)val); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); } JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setLong( @@ -597,7 +588,6 @@ jobject Field, jobject obj, jlong val) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; if (isStatic(field->access)) { @@ -606,16 +596,17 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case LONG_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isLong()) return field->setLongField(Obj, (sint64)val); - case FLOAT_ID : + if (prim->isFloat()) return field->setFloatField(Obj, (float)val); - case DOUBLE_ID : + if (prim->isDouble()) return field->setDoubleField(Obj, (double)val); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); } JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setFloat( @@ -625,7 +616,6 @@ jobject Field, jobject obj, jfloat val) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; if (isStatic(field->access)) { @@ -634,14 +624,15 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case FLOAT_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isFloat()) return field->setFloatField(Obj, (float)val); - case DOUBLE_ID : + if (prim->isDouble()) return field->setDoubleField(Obj, (double)val); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); } JNIEXPORT void JNICALL Java_java_lang_reflect_Field_setDouble( @@ -651,7 +642,6 @@ jobject Field, jobject obj, jdouble val) { Jnjvm* vm = JavaThread::get()->isolate; JavaField* field = (JavaField*)vm->upcalls->fieldSlot->getInt32Field((JavaObject*)Field); - const AssessorDesc* ass = field->getSignature()->funcs; JavaObject* Obj = (JavaObject*)obj; if (isStatic(field->access)) { @@ -660,12 +650,13 @@ Obj = cl->getStaticInstance(); } - switch (ass->numId) { - case DOUBLE_ID : + const Typedef* type = field->getSignature(); + if (type->isPrimitive()) { + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isDouble()) return field->setDoubleField(Obj, (double)val); - default : - JavaThread::get()->isolate->illegalArgumentException(""); } + JavaThread::get()->isolate->illegalArgumentException(""); } JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_objectFieldOffset( Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp Fri Sep 19 09:50:39 2008 @@ -25,6 +25,7 @@ #include "JavaObject.h" #include "JavaThread.h" #include "JavaTypes.h" +#include "JavaUpcalls.h" #include "Jnjvm.h" #include "JnjvmModuleProvider.h" #include "LockedMap.h" @@ -176,10 +177,7 @@ if (name->elements[stepsEnd] == AssessorDesc::I_REF) { printClassNameIntern(name, (stepsEnd + 1),(end - 1), buf); } else { - AssessorDesc * funcs = 0; - uint32 next = 0; - AssessorDesc::analyseIntern(name, stepsEnd, 0, funcs, next); - buf->write(funcs->asciizName); + name->print(buf); } buf->write(" "); for (uint32 i = start; i < stepsEnd; i++) @@ -205,6 +203,30 @@ buf->write(">"); } +UserClassPrimitive* CommonClass::toPrimitive(Jnjvm* vm) const { + if (this == vm->upcalls->voidClass) { + return vm->upcalls->OfVoid; + } else if (this == vm->upcalls->intClass) { + return vm->upcalls->OfInt; + } else if (this == vm->upcalls->shortClass) { + return vm->upcalls->OfShort; + } else if (this == vm->upcalls->charClass) { + return vm->upcalls->OfChar; + } else if (this == vm->upcalls->doubleClass) { + return vm->upcalls->OfDouble; + } else if (this == vm->upcalls->byteClass) { + return vm->upcalls->OfByte; + } else if (this == vm->upcalls->boolClass) { + return vm->upcalls->OfBool; + } else if (this == vm->upcalls->longClass) { + return vm->upcalls->OfLong; + } else if (this == vm->upcalls->floatClass) { + return vm->upcalls->OfFloat; + } else { + return 0; + } +} + CommonClass::CommonClass(JnjvmClassLoader* loader, const UTF8* n, bool isArray) { name = n; @@ -521,8 +543,8 @@ } } -void JavaField::initField(JavaObject* obj) { - const AssessorDesc* funcs = getSignature()->funcs; +void JavaField::initField(JavaObject* obj, Jnjvm* vm) { + const Typedef* type = getSignature(); Attribut* attribut = lookupAttribut(Attribut::constantAttribut); if (!attribut) { @@ -531,26 +553,26 @@ Reader reader(attribut, classDef->bytes); JavaConstantPool * ctpInfo = classDef->ctpInfo; uint16 idx = reader.readU2(); - if (funcs == AssessorDesc::dLong) { - JnjvmModule::InitField(this, obj, (uint64)ctpInfo->LongAt(idx)); - } else if (funcs == AssessorDesc::dDouble) { - JnjvmModule::InitField(this, obj, ctpInfo->DoubleAt(idx)); - } else if (funcs == AssessorDesc::dFloat) { - JnjvmModule::InitField(this, obj, ctpInfo->FloatAt(idx)); - } else if (funcs == AssessorDesc::dRef) { + if (type->isPrimitive()) { + UserCommonClass* cl = type->assocClass(vm->bootstrapLoader); + if (cl == vm->upcalls->OfLong) { + JnjvmModule::InitField(this, obj, (uint64)ctpInfo->LongAt(idx)); + } else if (cl == vm->upcalls->OfDouble) { + JnjvmModule::InitField(this, obj, ctpInfo->DoubleAt(idx)); + } else if (cl == vm->upcalls->OfFloat) { + JnjvmModule::InitField(this, obj, ctpInfo->FloatAt(idx)); + } else { + JnjvmModule::InitField(this, obj, (uint64)ctpInfo->IntegerAt(idx)); + } + } else if (type->isReference()){ const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[idx]); JnjvmModule::InitField(this, obj, (JavaObject*)ctpInfo->resolveString(utf8, idx)); - } else if (funcs == AssessorDesc::dInt || funcs == AssessorDesc::dChar || - funcs == AssessorDesc::dShort || funcs == AssessorDesc::dByte || - funcs == AssessorDesc::dBool) { - JnjvmModule::InitField(this, obj, (uint64)ctpInfo->IntegerAt(idx)); } else { JavaThread::get()->isolate-> - unknownError("unknown constant %c", funcs->byteId); + unknownError("unknown constant %s\n", type->printString()); } - } - + } } JavaMethod* CommonClass::constructMethod(const UTF8* name, Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h Fri Sep 19 09:50:39 2008 @@ -495,6 +495,9 @@ void setSuper(CommonClass* S) { super = S; } + + UserClassPrimitive* toPrimitive(Jnjvm* vm) const; + }; /// ClassPrimitive - This class represents internal classes for primitive @@ -936,7 +939,7 @@ /// initField - Init the value of the field in the given object. This is /// used for static fields which have a default value. /// - void initField(JavaObject* obj); + void initField(JavaObject* obj, Jnjvm* vm); /// lookupAttribut - Look up the attribut in the field's list of attributs. /// Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaInitialise.cpp Fri Sep 19 09:50:39 2008 @@ -175,8 +175,6 @@ JCL->constructArray(JCL->asciizConstructUTF8("[Ljava/lang/Object;")); - AssessorDesc::initialise(JCL); - Attribut::codeAttribut = JCL->asciizConstructUTF8("Code"); Attribut::exceptionsAttribut = JCL->asciizConstructUTF8("Exceptions"); Attribut::constantAttribut = JCL->asciizConstructUTF8("ConstantValue"); @@ -228,9 +226,6 @@ DEF_UTF8(finalize); #undef DEF_UTF8 - - JCL->upcalls->initialiseClasspath(JCL); - } void mvm::VirtualMachine::initialiseJVM() { Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Fri Sep 19 09:50:39 2008 @@ -64,6 +64,7 @@ #if !defined(WITHOUT_VTABLE) Signdef* signature = ctpInfo->infoOfInterfaceOrVirtualMethod(index); + Typedef* retTypedef = signature->ret; std::vector args; // size = [signature->nbIn + 3]; LLVMSignatureInfo* LSI = module->getSignatureInfo(signature); const llvm::FunctionType* virtualType = LSI->getVirtualType(); @@ -118,9 +119,9 @@ const llvm::Type* retType = virtualType->getReturnType(); if (retType != Type::VoidTy) { - push(val, signature->ret->funcs); + push(val, retTypedef->isUnsigned()); if (retType == Type::DoubleTy || retType == Type::Int64Ty) { - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantZero, false); } } @@ -154,6 +155,7 @@ currentBlock = createBasicBlock("start"); BasicBlock* executeBlock = createBasicBlock("execute"); endBlock = createBasicBlock("end block"); + returnType = funcType->getReturnType(); #if defined(MULTIPLE_VM) Value* lastArg = 0; @@ -192,8 +194,6 @@ #endif #endif - if (funcType->getReturnType() != Type::VoidTy) - endNode = llvm::PHINode::Create(funcType->getReturnType(), "", endBlock); Value* buf = llvm::CallInst::Create(JnjvmModule::GetSJLJBufferFunction, "", currentBlock); @@ -202,14 +202,13 @@ test = new ICmpInst(ICmpInst::ICMP_EQ, test, mvm::jit::constantZero, "", currentBlock); llvm::BranchInst::Create(executeBlock, endBlock, test, currentBlock); - - if (compilingMethod->getSignature()->ret->funcs != AssessorDesc::dVoid) { - uint8 id = compilingMethod->getSignature()->ret->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; - Constant* C = LAI.llvmNullConstant; - endNode->addIncoming(C, currentBlock); - } + if (returnType != Type::VoidTy) { + endNode = llvm::PHINode::Create(returnType, "", endBlock); + endNode->addIncoming(Constant::getNullValue(returnType), + currentBlock); + } + currentBlock = executeBlock; if (isSynchro(compilingMethod->access)) beginSynchronize(); @@ -256,7 +255,7 @@ Value* result = llvm::CallInst::Create(valPtr, nativeArgs.begin(), nativeArgs.end(), "", currentBlock); - if (funcType->getReturnType() != Type::VoidTy) + if (returnType != Type::VoidTy) endNode->addIncoming(result, currentBlock); llvm::BranchInst::Create(endBlock, currentBlock); @@ -267,7 +266,7 @@ llvm::CallInst::Create(JnjvmModule::JniProceedPendingExceptionFunction, "", currentBlock); - if (funcType->getReturnType() != Type::VoidTy) + if (returnType != Type::VoidTy) llvm::ReturnInst::Create(result, currentBlock); else llvm::ReturnInst::Create(currentBlock); @@ -556,37 +555,39 @@ #endif std::vector::iterator type = compilingMethod->getSignature()->args.begin(); - std::vector::iterator i = args.begin(); + Function::arg_iterator i = func->arg_begin(); if (isVirtual(compilingMethod->access)) { - new StoreInst(*i, objectLocals[0], false, currentBlock); + new StoreInst(i, objectLocals[0], false, currentBlock); ++i; ++index; ++count; } + for (;count < max; ++i, ++index, ++count, ++type) { - const AssessorDesc* cur = (*type)->funcs; + const Typedef* cur = *type; + const Type* curType = i->getType(); - if (cur == AssessorDesc::dLong){ - new StoreInst(*i, longLocals[index], false, currentBlock); + if (curType == Type::Int64Ty){ + new StoreInst(i, longLocals[index], false, currentBlock); ++index; - } else if (cur == AssessorDesc::dBool || cur == AssessorDesc::dChar) { - new StoreInst(new ZExtInst(*i, Type::Int32Ty, "", currentBlock), + } else if (cur->isUnsigned()) { + new StoreInst(new ZExtInst(i, Type::Int32Ty, "", currentBlock), intLocals[index], false, currentBlock); - } else if (cur == AssessorDesc::dByte || cur == AssessorDesc::dShort) { - new StoreInst(new SExtInst(*i, Type::Int32Ty, "", currentBlock), + } else if (curType == Type::Int8Ty || curType == Type::Int16Ty) { + new StoreInst(new SExtInst(i, Type::Int32Ty, "", currentBlock), intLocals[index], false, currentBlock); - } else if (cur == AssessorDesc::dInt) { - new StoreInst(*i, intLocals[index], false, currentBlock); - } else if (cur == AssessorDesc::dDouble) { - new StoreInst(*i, doubleLocals[index], false, currentBlock); + } else if (curType == Type::Int32Ty) { + new StoreInst(i, intLocals[index], false, currentBlock); + } else if (curType == Type::DoubleTy) { + new StoreInst(i, doubleLocals[index], false, currentBlock); ++index; - } else if (cur == AssessorDesc::dFloat) { - new StoreInst(*i, floatLocals[index], false, currentBlock); + } else if (curType == Type::FloatTy) { + new StoreInst(i, floatLocals[index], false, currentBlock); } else { - new StoreInst(*i, objectLocals[index], false, currentBlock); + new StoreInst(i, objectLocals[index], false, currentBlock); } } @@ -733,22 +734,24 @@ for (;count < max; ++i, ++index, ++count, ++type) { - const AssessorDesc* cur = (*type)->funcs; - if (cur == AssessorDesc::dLong){ + const Typedef* cur = *type; + const llvm::Type* curType = i->getType(); + + if (curType == Type::Int64Ty){ new StoreInst(i, longLocals[index], false, currentBlock); ++index; - } else if (cur == AssessorDesc::dBool || cur == AssessorDesc::dChar) { + } else if (cur->isUnsigned()) { new StoreInst(new ZExtInst(i, Type::Int32Ty, "", currentBlock), intLocals[index], false, currentBlock); - } else if (cur == AssessorDesc::dByte || cur == AssessorDesc::dShort) { + } else if (curType == Type::Int8Ty || curType == Type::Int16Ty) { new StoreInst(new SExtInst(i, Type::Int32Ty, "", currentBlock), intLocals[index], false, currentBlock); - } else if (cur == AssessorDesc::dInt) { + } else if (curType == Type::Int32Ty) { new StoreInst(i, intLocals[index], false, currentBlock); - } else if (cur == AssessorDesc::dDouble) { + } else if (curType == Type::DoubleTy) { new StoreInst(i, doubleLocals[index], false, currentBlock); ++index; - } else if (cur == AssessorDesc::dFloat) { + } else if (curType == Type::FloatTy) { new StoreInst(i, floatLocals[index], false, currentBlock); } else { new StoreInst(i, objectLocals[index], false, currentBlock); @@ -1139,7 +1142,7 @@ c = new FCmpInst(FCmpInst::FCMP_UNO, val1, val2, "", currentBlock); r = llvm::SelectInst::Create(c, l ? one : minus, r, "", currentBlock); - push(r, AssessorDesc::dInt); + push(r, false); } @@ -1152,39 +1155,39 @@ // Lookup the constant pool cache Value* val = getConstantPoolAt(index, JnjvmModule::StringLookupFunction, JnjvmModule::JavaObjectType, 0, false); - push(val, AssessorDesc::dRef); + push(val, false); #else const UTF8* utf8 = ctpInfo->UTF8At(ctpInfo->ctpDef[index]); JavaString* str = JavaThread::get()->isolate->UTF8ToStr(utf8); LLVMStringInfo* LSI = module->getStringInfo(str); Value* val = LSI->getDelegatee(this); - push(val, AssessorDesc::dRef); + push(val, false); #endif } else if (type == JavaConstantPool::ConstantLong) { push(ConstantInt::get(Type::Int64Ty, ctpInfo->LongAt(index)), - AssessorDesc::dLong); + false); } else if (type == JavaConstantPool::ConstantDouble) { push(ConstantFP::get(Type::DoubleTy, ctpInfo->DoubleAt(index)), - AssessorDesc::dDouble); + false); } else if (type == JavaConstantPool::ConstantInteger) { push(ConstantInt::get(Type::Int32Ty, ctpInfo->IntegerAt(index)), - AssessorDesc::dInt); + false); } else if (type == JavaConstantPool::ConstantFloat) { push(ConstantFP::get(Type::FloatTy, ctpInfo->FloatAt(index)), - AssessorDesc::dFloat); + false); } else if (type == JavaConstantPool::ConstantClass) { #ifndef MULTIPLE_VM if (ctpInfo->ctpRes[index]) { CommonClass* cl = (CommonClass*)(ctpInfo->ctpRes[index]); LLVMCommonClassInfo* LCI = module->getClassInfo(cl); - push(LCI->getDelegatee(this), AssessorDesc::dRef); + push(LCI->getDelegatee(this), false); } else { #endif Value* val = getResolvedClass(index, false); Value* res = CallInst::Create(JnjvmModule::GetClassDelegateeFunction, val, "", currentBlock); - push(res, AssessorDesc::dRef); + push(res, false); #ifndef MULTIPLE_VM } #endif @@ -1274,7 +1277,7 @@ void JavaJIT::setCurrentBlock(BasicBlock* newBlock) { - std::vector< std::pair > newStack; + std::vector< std::pair > newStack; uint32 index = 0; for (BasicBlock::iterator i = newBlock->begin(), e = newBlock->end(); i != e; ++i, ++index) { @@ -1285,7 +1288,7 @@ const llvm::Type* type = i->getType(); if (type == Type::Int32Ty || type == Type::Int16Ty || type == Type::Int8Ty) { - newStack.push_back(std::make_pair(i, AssessorDesc::dInt)); + newStack.push_back(std::make_pair(i, false)); } else { newStack.push_back(std::make_pair(i, stack[index].second)); } @@ -1298,16 +1301,17 @@ static void testPHINodes(BasicBlock* dest, BasicBlock* insert, JavaJIT* jit) { if(dest->empty()) { - for (std::vector< std::pair >::iterator i = + for (std::vector< std::pair >::iterator i = jit->stack.begin(), e = jit->stack.end(); i!= e; ++i) { Value* cur = i->first; - const AssessorDesc* func = i->second; + bool unsign = i->second; PHINode* node = 0; - if (func == AssessorDesc::dChar || func == AssessorDesc::dBool) { + const Type* type = cur->getType(); + if (unsign) { node = llvm::PHINode::Create(Type::Int32Ty, "", dest); cur = new ZExtInst(cur, Type::Int32Ty, "", jit->currentBlock); - } else if (func == AssessorDesc::dByte || func == AssessorDesc::dShort) { + } else if (type == Type::Int8Ty || type == Type::Int16Ty) { node = llvm::PHINode::Create(Type::Int32Ty, "", dest); cur = new SExtInst(cur, Type::Int32Ty, "", jit->currentBlock); } else { @@ -1316,7 +1320,7 @@ node->addIncoming(cur, insert); } } else { - std::vector< std::pair >::iterator stackit = + std::vector< std::pair >::iterator stackit = jit->stack.begin(); for (BasicBlock::iterator i = dest->begin(), e = dest->end(); i != e; ++i) { @@ -1325,11 +1329,12 @@ } else { Instruction* ins = i; Value* cur = stackit->first; - const AssessorDesc* func = stackit->second; + const Type* type = cur->getType(); + bool unsign = stackit->second; - if (func == AssessorDesc::dChar || func == AssessorDesc::dBool) { + if (unsign) { cur = new ZExtInst(cur, Type::Int32Ty, "", jit->currentBlock); - } else if (func == AssessorDesc::dByte || func == AssessorDesc::dShort) { + } else if (type == Type::Int8Ty || type == Type::Int16Ty) { cur = new SExtInst(cur, Type::Int32Ty, "", jit->currentBlock); } @@ -1372,13 +1377,12 @@ if (it->get() == Type::Int64Ty || it->get() == Type::DoubleTy) { pop(); } - const AssessorDesc* func = topFunc(); + bool unsign = topFunc(); Value* tmp = pop(); const Type* type = it->get(); if (tmp->getType() != type) { // int8 or int16 - convertValue(tmp, type, currentBlock, - func == AssessorDesc::dChar || func == AssessorDesc::dBool); + convertValue(tmp, type, currentBlock, unsign); } args[i] = tmp; @@ -1577,9 +1581,9 @@ const llvm::Type* retType = virtualType->getReturnType(); if (retType != Type::VoidTy) { - push(val, signature->ret->funcs); + push(val, signature->ret->isUnsigned()); if (retType == Type::DoubleTy || retType == Type::Int64Ty) { - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantZero, false); } } @@ -1629,9 +1633,9 @@ const llvm::Type* retType = staticType->getReturnType(); if (retType != Type::VoidTy) { - push(val, signature->ret->funcs); + push(val, signature->ret->isUnsigned()); if (retType == Type::DoubleTy || retType == Type::Int64Ty) { - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantZero, false); } } } @@ -1818,7 +1822,7 @@ new StoreInst(Cl, GEP, currentBlock); - push(val, AssessorDesc::dRef); + push(val, false); } Value* JavaJIT::arraySize(Value* val) { @@ -1922,20 +1926,21 @@ void JavaJIT::setStaticField(uint16 index) { - const AssessorDesc* ass = topFunc(); + bool unsign = topFunc(); Value* val = pop(); + Typedef* sign = compilingClass->ctpInfo->infoOfField(index); - uint8 id = sign->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + LLVMAssessorInfo& LAI = module->getTypedefInfo(sign); const Type* type = LAI.llvmType; + if (type == Type::Int64Ty || type == Type::DoubleTy) { val = pop(); } + Value* ptr = ldResolved(index, true, 0, type, LAI.llvmTypePtr); if (type != val->getType()) { // int1, int8, int16 - convertValue(val, type, currentBlock, - ass == AssessorDesc::dChar || ass == AssessorDesc::dBool); + convertValue(val, type, currentBlock, unsign); } new StoreInst(val, ptr, false, currentBlock); @@ -1943,23 +1948,22 @@ void JavaJIT::getStaticField(uint16 index) { Typedef* sign = compilingClass->ctpInfo->infoOfField(index); - uint8 id = sign->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; - Value* ptr = ldResolved(index, true, 0, LAI.llvmType, - LAI.llvmTypePtr); - push(new LoadInst(ptr, "", currentBlock), sign->funcs); + LLVMAssessorInfo& LAI = module->getTypedefInfo(sign); const Type* type = LAI.llvmType; + + Value* ptr = ldResolved(index, true, 0, type, LAI.llvmTypePtr); + + push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned()); if (type == Type::Int64Ty || type == Type::DoubleTy) { - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantZero, false); } } void JavaJIT::setVirtualField(uint16 index) { - const AssessorDesc* ass = topFunc(); + bool unsign = topFunc(); Value* val = pop(); Typedef* sign = compilingClass->ctpInfo->infoOfField(index); - uint8 id = sign->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + LLVMAssessorInfo& LAI = module->getTypedefInfo(sign); const Type* type = LAI.llvmType; if (type == Type::Int64Ty || type == Type::DoubleTy) { @@ -1968,12 +1972,10 @@ Value* object = pop(); JITVerifyNull(object); - Value* ptr = ldResolved(index, false, object, type, - LAI.llvmTypePtr); + Value* ptr = ldResolved(index, false, object, type, LAI.llvmTypePtr); if (type != val->getType()) { // int1, int8, int16 - convertValue(val, type, currentBlock, - ass == AssessorDesc::dChar || ass == AssessorDesc::dBool); + convertValue(val, type, currentBlock, unsign); } new StoreInst(val, ptr, false, currentBlock); @@ -1981,16 +1983,16 @@ void JavaJIT::getVirtualField(uint16 index) { Typedef* sign = compilingClass->ctpInfo->infoOfField(index); + LLVMAssessorInfo& LAI = module->getTypedefInfo(sign); + const Type* type = LAI.llvmType; Value* obj = pop(); JITVerifyNull(obj); - uint8 id = sign->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; - Value* ptr = ldResolved(index, false, obj, LAI.llvmType, - LAI.llvmTypePtr); - push(new LoadInst(ptr, "", currentBlock), sign->funcs); - const Type* type = LAI.llvmType; + + Value* ptr = ldResolved(index, false, obj, type, LAI.llvmTypePtr); + + push(new LoadInst(ptr, "", currentBlock), sign->isUnsigned()); if (type == Type::Int64Ty || type == Type::DoubleTy) { - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantZero, false); } } @@ -2168,9 +2170,9 @@ currentBlock = endBlock; if (node) { - push(node, signature->ret->funcs); + push(node, signature->ret->isUnsigned()); if (retType == Type::DoubleTy || retType == Type::Int64Ty) { - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantZero, false); } } } Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.h?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.h Fri Sep 19 09:50:39 2008 @@ -24,7 +24,6 @@ #include "mvm/Object.h" #include "mvm/PrintBuffer.h" -#include "JavaTypes.h" #include "JnjvmModule.h" namespace jnjvm { @@ -102,16 +101,12 @@ // stack manipulation - std::vector< std::pair > stack; - void push(llvm::Value* val, const AssessorDesc* ass) { - assert(LLVMAssessorInfo::AssessorInfo[ass->numId].llvmType == - val->getType()); - stack.push_back(std::make_pair(val, ass)); + std::vector< std::pair > stack; + void push(llvm::Value* val, bool unsign) { + stack.push_back(std::make_pair(val, unsign)); } - void push(std::pair pair) { - assert(LLVMAssessorInfo::AssessorInfo[pair.second->numId].llvmType == - pair.first->getType()); + void push(std::pair pair) { stack.push_back(pair); } @@ -125,7 +120,7 @@ return stack.back().first; } - const AssessorDesc* topFunc() { + bool topFunc() { return stack.back().second; } @@ -135,11 +130,11 @@ llvm::Value* popAsInt() { llvm::Value * ret = top(); - const AssessorDesc* ass = topFunc(); + bool unsign = topFunc(); stack.pop_back(); if (ret->getType() != llvm::Type::Int32Ty) { - if (ass == AssessorDesc::dChar || ass == AssessorDesc::dBool) { + if (unsign) { ret = new llvm::ZExtInst(ret, llvm::Type::Int32Ty, "", currentBlock); } else { ret = new llvm::SExtInst(ret, llvm::Type::Int32Ty, "", currentBlock); @@ -150,8 +145,8 @@ } - std::pair popPair() { - std::pair ret = stack.back(); + std::pair popPair() { + std::pair ret = stack.back(); stack.pop_back(); return ret; } Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Fri Sep 19 09:50:39 2008 @@ -136,85 +136,85 @@ #endif if (opinfo->reqSuppl) { - push(new LoadInst(supplLocal, "", currentBlock), AssessorDesc::dRef); + push(new LoadInst(supplLocal, "", currentBlock), false); } switch (bytecodes[i]) { case ACONST_NULL : - push(JnjvmModule::JavaObjectNullConstant, AssessorDesc::dRef); + push(JnjvmModule::JavaObjectNullConstant, false); break; case ICONST_M1 : - push(mvm::jit::constantMinusOne, AssessorDesc::dInt); + push(mvm::jit::constantMinusOne, false); break; case ICONST_0 : - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantZero, false); break; case ICONST_1 : - push(mvm::jit::constantOne, AssessorDesc::dInt); + push(mvm::jit::constantOne, false); break; case ICONST_2 : - push(mvm::jit::constantTwo, AssessorDesc::dInt); + push(mvm::jit::constantTwo, false); break; case ICONST_3 : - push(mvm::jit::constantThree, AssessorDesc::dInt); + push(mvm::jit::constantThree, false); break; case ICONST_4 : - push(mvm::jit::constantFour, AssessorDesc::dInt); + push(mvm::jit::constantFour, false); break; case ICONST_5 : - push(mvm::jit::constantFive, AssessorDesc::dInt); + push(mvm::jit::constantFive, false); break; case LCONST_0 : - push(mvm::jit::constantLongZero, AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantLongZero, false); + push(mvm::jit::constantZero, false); break; case LCONST_1 : - push(mvm::jit::constantLongOne, AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantLongOne, false); + push(mvm::jit::constantZero, false); break; case FCONST_0 : - push(mvm::jit::constantFloatZero, AssessorDesc::dFloat); + push(mvm::jit::constantFloatZero, false); break; case FCONST_1 : - push(mvm::jit::constantFloatOne, AssessorDesc::dFloat); + push(mvm::jit::constantFloatOne, false); break; case FCONST_2 : - push(mvm::jit::constantFloatTwo, AssessorDesc::dFloat); + push(mvm::jit::constantFloatTwo, false); break; case DCONST_0 : - push(mvm::jit::constantDoubleZero, AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantDoubleZero, false); + push(mvm::jit::constantZero, false); break; case DCONST_1 : - push(mvm::jit::constantDoubleOne, AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantDoubleOne, false); + push(mvm::jit::constantZero, false); break; case BIPUSH : push(ConstantExpr::getSExt(ConstantInt::get(Type::Int8Ty, bytecodes[++i]), - Type::Int32Ty), AssessorDesc::dInt); + Type::Int32Ty), false); break; case SIPUSH : push(ConstantExpr::getSExt(ConstantInt::get(Type::Int16Ty, readS2(bytecodes, i)), - Type::Int32Ty), AssessorDesc::dInt); + Type::Int32Ty), false); break; case LDC : @@ -227,138 +227,138 @@ case LDC2_W : _ldc(readS2(bytecodes, i)); - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(mvm::jit::constantZero, false); break; case ILOAD : push(new LoadInst(intLocals[WREAD_U1(bytecodes, false, i)], "", - currentBlock), AssessorDesc::dInt); + currentBlock), false); break; case LLOAD : push(new LoadInst(longLocals[WREAD_U1(bytecodes, false, i)], "", - currentBlock), AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + currentBlock), false); + push(mvm::jit::constantZero, false); break; case FLOAD : push(new LoadInst(floatLocals[WREAD_U1(bytecodes, false, i)], "", - currentBlock), AssessorDesc::dFloat); + currentBlock), false); break; case DLOAD : push(new LoadInst(doubleLocals[WREAD_U1(bytecodes, false, i)], "", - currentBlock), AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + currentBlock), false); + push(mvm::jit::constantZero, false); break; case ALOAD : push(new LoadInst(objectLocals[WREAD_U1(bytecodes, false, i)], "", - currentBlock), AssessorDesc::dRef); + currentBlock), false); break; case ILOAD_0 : - push(new LoadInst(intLocals[0], "", currentBlock), AssessorDesc::dInt); + push(new LoadInst(intLocals[0], "", currentBlock), false); break; case ILOAD_1 : - push(new LoadInst(intLocals[1], "", currentBlock), AssessorDesc::dInt); + push(new LoadInst(intLocals[1], "", currentBlock), false); break; case ILOAD_2 : - push(new LoadInst(intLocals[2], "", currentBlock), AssessorDesc::dInt); + push(new LoadInst(intLocals[2], "", currentBlock), false); break; case ILOAD_3 : - push(new LoadInst(intLocals[3], "", currentBlock), AssessorDesc::dInt); + push(new LoadInst(intLocals[3], "", currentBlock), false); break; case LLOAD_0 : push(new LoadInst(longLocals[0], "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case LLOAD_1 : push(new LoadInst(longLocals[1], "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case LLOAD_2 : push(new LoadInst(longLocals[2], "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case LLOAD_3 : push(new LoadInst(longLocals[3], "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case FLOAD_0 : push(new LoadInst(floatLocals[0], "", currentBlock), - AssessorDesc::dFloat); + false); break; case FLOAD_1 : push(new LoadInst(floatLocals[1], "", currentBlock), - AssessorDesc::dFloat); + false); break; case FLOAD_2 : push(new LoadInst(floatLocals[2], "", currentBlock), - AssessorDesc::dFloat); + false); break; case FLOAD_3 : push(new LoadInst(floatLocals[3], "", currentBlock), - AssessorDesc::dFloat); + false); break; case DLOAD_0 : push(new LoadInst(doubleLocals[0], "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case DLOAD_1 : push(new LoadInst(doubleLocals[1], "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case DLOAD_2 : push(new LoadInst(doubleLocals[2], "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case DLOAD_3 : push(new LoadInst(doubleLocals[3], "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case ALOAD_0 : push(new LoadInst(objectLocals[0], "", currentBlock), - AssessorDesc::dRef); + false); break; case ALOAD_1 : push(new LoadInst(objectLocals[1], "", currentBlock), - AssessorDesc::dRef); + false); break; case ALOAD_2 : push(new LoadInst(objectLocals[2], "", currentBlock), - AssessorDesc::dRef); + false); break; case ALOAD_3 : push(new LoadInst(objectLocals[3], "", currentBlock), - AssessorDesc::dRef); + false); break; case IALOAD : { @@ -366,7 +366,7 @@ Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, JnjvmModule::JavaArraySInt32Type); - push(new LoadInst(ptr, "", currentBlock), AssessorDesc::dInt); + push(new LoadInst(ptr, "", currentBlock), false); break; } @@ -375,8 +375,8 @@ Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, JnjvmModule::JavaArrayLongType); - push(new LoadInst(ptr, "", currentBlock), AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(new LoadInst(ptr, "", currentBlock), false); + push(mvm::jit::constantZero, false); break; } @@ -385,7 +385,7 @@ Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, JnjvmModule::JavaArrayFloatType); - push(new LoadInst(ptr, "", currentBlock), AssessorDesc::dFloat); + push(new LoadInst(ptr, "", currentBlock), false); break; } @@ -394,8 +394,8 @@ Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, JnjvmModule::JavaArrayDoubleType); - push(new LoadInst(ptr, "", currentBlock), AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(new LoadInst(ptr, "", currentBlock), false); + push(mvm::jit::constantZero, false); break; } @@ -404,7 +404,7 @@ Value* obj = pop(); Value* ptr = verifyAndComputePtr(obj, index, JnjvmModule::JavaArrayObjectType); - push(new LoadInst(ptr, "", currentBlock), AssessorDesc::dRef); + push(new LoadInst(ptr, "", currentBlock), false); break; } @@ -415,7 +415,7 @@ JnjvmModule::JavaArraySInt8Type); Value* val = new LoadInst(ptr, "", currentBlock); push(new SExtInst(val, Type::Int32Ty, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -426,7 +426,7 @@ JnjvmModule::JavaArrayUInt16Type); Value* val = new LoadInst(ptr, "", currentBlock); push(new ZExtInst(val, Type::Int32Ty, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -437,7 +437,7 @@ JnjvmModule::JavaArraySInt16Type); Value* val = new LoadInst(ptr, "", currentBlock); push(new SExtInst(val, Type::Int32Ty, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -640,11 +640,11 @@ } case CASTORE : { - const AssessorDesc* ass = topFunc(); Value* val = pop(); - if (ass == AssessorDesc::dInt) { + const Type* type = val->getType(); + if (type == Type::Int32Ty) { val = new TruncInst(val, Type::Int16Ty, "", currentBlock); - } else if (ass == AssessorDesc::dByte || ass == AssessorDesc::dBool) { + } else if (type == Type::Int8Ty) { val = new ZExtInst(val, Type::Int16Ty, "", currentBlock); } Value* index = pop(); @@ -656,11 +656,11 @@ } case SASTORE : { - const AssessorDesc* ass = topFunc(); Value* val = pop(); - if (ass == AssessorDesc::dInt) { + const Type* type = val->getType(); + if (type == Type::Int32Ty) { val = new TruncInst(val, Type::Int16Ty, "", currentBlock); - } else if (ass == AssessorDesc::dByte || ass == AssessorDesc::dBool) { + } else if (type == Type::Int8Ty) { val = new SExtInst(val, Type::Int16Ty, "", currentBlock); } Value* index = pop(); @@ -684,8 +684,8 @@ break; case DUP_X1 : { - std::pair one = popPair(); - std::pair two = popPair(); + std::pair one = popPair(); + std::pair two = popPair(); push(one); push(two); push(one); @@ -693,9 +693,9 @@ } case DUP_X2 : { - std::pair one = popPair(); - std::pair two = popPair(); - std::pair three = popPair(); + std::pair one = popPair(); + std::pair two = popPair(); + std::pair three = popPair(); push(one); push(three); push(two); @@ -709,9 +709,9 @@ break; case DUP2_X1 : { - std::pair one = popPair(); - std::pair two = popPair(); - std::pair three = popPair(); + std::pair one = popPair(); + std::pair two = popPair(); + std::pair three = popPair(); push(two); push(one); @@ -724,10 +724,10 @@ } case DUP2_X2 : { - std::pair one = popPair(); - std::pair two = popPair(); - std::pair three = popPair(); - std::pair four = popPair(); + std::pair one = popPair(); + std::pair two = popPair(); + std::pair three = popPair(); + std::pair four = popPair(); push(two); push(one); @@ -741,8 +741,8 @@ } case SWAP : { - std::pair one = popPair(); - std::pair two = popPair(); + std::pair one = popPair(); + std::pair two = popPair(); push(one); push(two); break; @@ -752,7 +752,7 @@ Value* val2 = popAsInt(); Value* val1 = popAsInt(); push(BinaryOperator::createAdd(val1, val2, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -762,8 +762,8 @@ pop(); llvm::Value* val1 = pop(); push(BinaryOperator::createAdd(val1, val2, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -771,7 +771,7 @@ Value* val2 = pop(); Value* val1 = pop(); push(BinaryOperator::createAdd(val1, val2, "", currentBlock), - AssessorDesc::dFloat); + false); break; } @@ -781,8 +781,8 @@ pop(); llvm::Value* val1 = pop(); push(BinaryOperator::createAdd(val1, val2, "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -790,7 +790,7 @@ Value* val2 = popAsInt(); Value* val1 = popAsInt(); push(BinaryOperator::createSub(val1, val2, "", currentBlock), - AssessorDesc::dInt); + false); break; } case LSUB : { @@ -799,8 +799,8 @@ pop(); llvm::Value* val1 = pop(); push(BinaryOperator::createSub(val1, val2, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -808,7 +808,7 @@ Value* val2 = pop(); Value* val1 = pop(); push(BinaryOperator::createSub(val1, val2, "", currentBlock), - AssessorDesc::dFloat); + false); break; } @@ -818,8 +818,8 @@ pop(); llvm::Value* val1 = pop(); push(BinaryOperator::createSub(val1, val2, "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -827,7 +827,7 @@ Value* val2 = popAsInt(); Value* val1 = popAsInt(); push(BinaryOperator::createMul(val1, val2, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -837,8 +837,8 @@ pop(); llvm::Value* val1 = pop(); push(BinaryOperator::createMul(val1, val2, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -846,7 +846,7 @@ Value* val2 = pop(); Value* val1 = pop(); push(BinaryOperator::createMul(val1, val2, "", currentBlock), - AssessorDesc::dFloat); + false); break; } @@ -856,8 +856,8 @@ pop(); llvm::Value* val1 = pop(); push(BinaryOperator::createMul(val1, val2, "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -865,7 +865,7 @@ Value* val2 = popAsInt(); Value* val1 = popAsInt(); push(BinaryOperator::createSDiv(val1, val2, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -875,8 +875,8 @@ pop(); llvm::Value* val1 = pop(); push(BinaryOperator::createSDiv(val1, val2, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -884,7 +884,7 @@ Value* val2 = pop(); Value* val1 = pop(); push(BinaryOperator::createFDiv(val1, val2, "", currentBlock), - AssessorDesc::dFloat); + false); break; } @@ -894,8 +894,8 @@ pop(); llvm::Value* val1 = pop(); push(BinaryOperator::createFDiv(val1, val2, "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -903,7 +903,7 @@ Value* val2 = popAsInt(); Value* val1 = popAsInt(); push(BinaryOperator::createSRem(val1, val2, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -913,8 +913,8 @@ pop(); llvm::Value* val1 = pop(); push(BinaryOperator::createSRem(val1, val2, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -922,7 +922,7 @@ Value* val2 = pop(); Value* val1 = pop(); push(BinaryOperator::createFRem(val1, val2, "", currentBlock), - AssessorDesc::dFloat); + false); break; } @@ -932,8 +932,8 @@ pop(); llvm::Value* val1 = pop(); push(BinaryOperator::createFRem(val1, val2, "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -941,30 +941,30 @@ push(BinaryOperator::createSub( mvm::jit::constantZero, popAsInt(), "", currentBlock), - AssessorDesc::dInt); + false); break; case LNEG : { pop(); push(BinaryOperator::createSub( mvm::jit::constantLongZero, - pop(), "", currentBlock), AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + pop(), "", currentBlock), false); + push(mvm::jit::constantZero, false); break; } case FNEG : push(BinaryOperator::createSub( mvm::jit::constantFloatMinusZero, - pop(), "", currentBlock), AssessorDesc::dFloat); + pop(), "", currentBlock), false); break; case DNEG : { pop(); push(BinaryOperator::createSub( mvm::jit::constantDoubleMinusZero, - pop(), "", currentBlock), AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + pop(), "", currentBlock), false); + push(mvm::jit::constantZero, false); break; } @@ -972,7 +972,7 @@ Value* val2 = popAsInt(); Value* val1 = popAsInt(); push(BinaryOperator::createShl(val1, val2, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -981,8 +981,8 @@ pop(); // remove the 0 on the stack Value* val1 = pop(); push(BinaryOperator::createShl(val1, val2, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -990,7 +990,7 @@ Value* val2 = popAsInt(); Value* val1 = popAsInt(); push(BinaryOperator::createAShr(val1, val2, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -999,8 +999,8 @@ pop(); // remove the 0 on the stack Value* val1 = pop(); push(BinaryOperator::createAShr(val1, val2, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -1010,7 +1010,7 @@ Value* mask = ConstantInt::get(Type::Int32Ty, 0x1F); val2 = BinaryOperator::CreateAnd(val2, mask, "", currentBlock); push(BinaryOperator::createLShr(val1, val2, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -1021,8 +1021,8 @@ pop(); // remove the 0 on the stack Value* val1 = pop(); push(BinaryOperator::createLShr(val1, val2, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -1030,7 +1030,7 @@ Value* val2 = popAsInt(); Value* val1 = popAsInt(); push(BinaryOperator::createAnd(val1, val2, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -1040,8 +1040,8 @@ pop(); // remove the 0 on the stack Value* val1 = pop(); push(BinaryOperator::createAnd(val1, val2, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -1049,7 +1049,7 @@ Value* val2 = popAsInt(); Value* val1 = popAsInt(); push(BinaryOperator::createOr(val1, val2, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -1059,8 +1059,8 @@ pop(); // remove the 0 on the stack Value* val1 = pop(); push(BinaryOperator::createOr(val1, val2, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -1068,7 +1068,7 @@ Value* val2 = popAsInt(); Value* val1 = popAsInt(); push(BinaryOperator::createXor(val1, val2, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -1078,8 +1078,8 @@ pop(); // remove the 0 on the stack Value* val1 = pop(); push(BinaryOperator::createXor(val1, val2, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; } @@ -1096,38 +1096,38 @@ case I2L : push(new SExtInst(pop(), llvm::Type::Int64Ty, "", currentBlock), - AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case I2F : push(new SIToFPInst(pop(), llvm::Type::FloatTy, "", currentBlock), - AssessorDesc::dFloat); + false); break; case I2D : push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case L2I : pop(); push(new TruncInst(pop(), llvm::Type::Int32Ty, "", currentBlock), - AssessorDesc::dInt); + false); break; case L2F : pop(); push(new SIToFPInst(pop(), llvm::Type::FloatTy, "", currentBlock), - AssessorDesc::dFloat); + false); break; case L2D : pop(); push(new SIToFPInst(pop(), llvm::Type::DoubleTy, "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case F2I : { @@ -1174,7 +1174,7 @@ currentBlock = res; - push(node, AssessorDesc::dInt); + push(node, false); break; } @@ -1220,15 +1220,15 @@ currentBlock = res; - push(node, AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(node, false); + push(mvm::jit::constantZero, false); break; } case F2D : push(new FPExtInst(pop(), llvm::Type::DoubleTy, "", currentBlock), - AssessorDesc::dDouble); - push(mvm::jit::constantZero, AssessorDesc::dInt); + false); + push(mvm::jit::constantZero, false); break; case D2I : { @@ -1275,7 +1275,7 @@ currentBlock = res; - push(node, AssessorDesc::dInt); + push(node, false); break; } @@ -1324,15 +1324,15 @@ currentBlock = res; - push(node, AssessorDesc::dLong); - push(mvm::jit::constantZero, AssessorDesc::dInt); + push(node, false); + push(mvm::jit::constantZero, false); break; } case D2F : pop(); // remove the 0 on the stack push(new FPTruncInst(pop(), llvm::Type::FloatTy, "", currentBlock), - AssessorDesc::dFloat); + false); break; case I2B : { @@ -1341,7 +1341,7 @@ val = new TruncInst(val, llvm::Type::Int8Ty, "", currentBlock); } push(new SExtInst(val, llvm::Type::Int32Ty, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -1351,7 +1351,7 @@ val = new TruncInst(val, llvm::Type::Int16Ty, "", currentBlock); } push(new ZExtInst(val, llvm::Type::Int32Ty, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -1361,7 +1361,7 @@ val = new TruncInst(val, llvm::Type::Int16Ty, "", currentBlock); } push(new SExtInst(val, llvm::Type::Int32Ty, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -1392,7 +1392,7 @@ BranchInst::Create(res, currentBlock); currentBlock = res; - push(node, AssessorDesc::dInt); + push(node, false); break; } @@ -1433,13 +1433,10 @@ case IFEQ : { uint32 tmp = i; BasicBlock* ifTrue = opcodeInfos[tmp + readS2(bytecodes, i)].newBlock; - const AssessorDesc* ass = topFunc(); - - uint8 id = ass->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; - llvm::Value* val = LAI.llvmNullConstant; Value* op = pop(); + const Type* type = op->getType(); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(ICmpInst::ICMP_EQ, op, val, "", currentBlock); BasicBlock* ifFalse = createBasicBlock("false IFEQ"); @@ -1451,13 +1448,10 @@ case IFNE : { uint32 tmp = i; BasicBlock* ifTrue = opcodeInfos[tmp + readS2(bytecodes, i)].newBlock; - const AssessorDesc* ass = topFunc(); - - uint8 id = ass->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; - llvm::Value* val = LAI.llvmNullConstant; Value* op = pop(); + const Type* type = op->getType(); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(ICmpInst::ICMP_NE, op, val, "", currentBlock); BasicBlock* ifFalse = createBasicBlock("false IFNE"); @@ -1469,11 +1463,9 @@ case IFLT : { uint32 tmp = i; BasicBlock* ifTrue = opcodeInfos[tmp + readS2(bytecodes, i)].newBlock; - const AssessorDesc* ass = topFunc(); - uint8 id = ass->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; - llvm::Value* val = LAI.llvmNullConstant; Value* op = pop(); + const Type* type = op->getType(); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(ICmpInst::ICMP_SLT, op, val, "", currentBlock); BasicBlock* ifFalse = createBasicBlock("false IFLT"); @@ -1485,11 +1477,9 @@ case IFGE : { uint32 tmp = i; BasicBlock* ifTrue = opcodeInfos[tmp + readS2(bytecodes, i)].newBlock; - const AssessorDesc* ass = topFunc(); - uint8 id = ass->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; - llvm::Value* val = LAI.llvmNullConstant; Value* op = pop(); + const Type* type = op->getType(); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(ICmpInst::ICMP_SGE, op, val, "", currentBlock); BasicBlock* ifFalse = createBasicBlock("false IFGE"); @@ -1501,11 +1491,9 @@ case IFGT : { uint32 tmp = i; BasicBlock* ifTrue = opcodeInfos[tmp + readS2(bytecodes, i)].newBlock; - const AssessorDesc* ass = topFunc(); - uint8 id = ass->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; - llvm::Value* val = LAI.llvmNullConstant; Value* op = pop(); + const Type* type = op->getType(); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(ICmpInst::ICMP_SGT, op, val, "", currentBlock); BasicBlock* ifFalse = createBasicBlock("false IFGT"); @@ -1517,11 +1505,9 @@ case IFLE : { uint32 tmp = i; BasicBlock* ifTrue = opcodeInfos[tmp + readS2(bytecodes, i)].newBlock; - const AssessorDesc* ass = topFunc(); - uint8 id = ass->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; - llvm::Value* val = LAI.llvmNullConstant; Value* op = pop(); + const Type* type = op->getType(); + Constant* val = Constant::getNullValue(type); llvm::Value* test = new ICmpInst(ICmpInst::ICMP_SLE, op, val, "", currentBlock); BasicBlock* ifFalse = createBasicBlock("false IFLE"); @@ -1707,12 +1693,13 @@ BasicBlock* def = opcodeInfos[tmp + readU4(bytecodes, i)].newBlock; uint32 nbs = readU4(bytecodes, i); - const AssessorDesc* ass = topFunc(); + bool unsign = topFunc(); Value* key = pop(); - if (ass == AssessorDesc::dShort || ass == AssessorDesc::dByte) { - key = new SExtInst(key, Type::Int32Ty, "", currentBlock); - } else if (ass == AssessorDesc::dChar || ass == AssessorDesc::dBool) { + const Type* type = key->getType(); + if (unsign) { key = new ZExtInst(key, Type::Int32Ty, "", currentBlock); + } else if (type == Type::Int8Ty || type == Type::Int16Ty) { + key = new SExtInst(key, Type::Int32Ty, "", currentBlock); } for (uint32 cur = 0; cur < nbs; ++cur) { Value* val = ConstantInt::get(Type::Int32Ty, readU4(bytecodes, i)); @@ -1727,11 +1714,10 @@ break; } case IRETURN : { - const AssessorDesc* ass = topFunc(); + bool unsign = topFunc(); Value* val = pop(); assert(val->getType()->isInteger()); - convertValue(val, returnType, currentBlock, - ass == AssessorDesc::dChar || ass == AssessorDesc::dBool); + convertValue(val, returnType, currentBlock, unsign); endNode->addIncoming(val, currentBlock); BranchInst::Create(endBlock, currentBlock); break; @@ -1829,19 +1815,19 @@ if (bytecodes[i] == NEWARRAY) { uint8 id = bytecodes[++i]; - AssessorDesc* ass = AssessorDesc::arrayType(id); + uint8 charId = AssessorDesc::arrayType(id); #ifndef MULTIPLE_VM - dcl = ass->getArrayClass(); + dcl = JavaThread::get()->isolate->arrayClasses[id - 4]; #else std::vector args; args.push_back(isolateLocal); - args.push_back(ConstantInt::get(Type::Int32Ty, ass->numId)); + args.push_back(ConstantInt::get(Type::Int32Ty, id - 4)); valCl = CallInst::Create(JnjvmModule::GetJnjvmArrayClassFunction, args.begin(), args.end(), "", currentBlock); #endif TheVT = JnjvmModule::JavaObjectVirtualTableGV; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[ass->numId]; + LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[charId]; sizeElement = LAI.sizeInBytesConstant; } else { uint16 index = readU2(bytecodes, i); @@ -1851,7 +1837,7 @@ JnjvmClassLoader* JCL = compilingClass->classLoader; const UTF8* arrayName = - AssessorDesc::constructArrayName(JCL, 0, 1, className); + AssessorDesc::constructArrayName(JCL, 1, className); dcl = JCL->constructArray(arrayName); #else @@ -1945,7 +1931,7 @@ currentBlock); new StoreInst(valCl, GEP, currentBlock); - push(res, AssessorDesc::dRef); + push(res, false); break; } @@ -1953,7 +1939,7 @@ case ARRAYLENGTH : { Value* val = pop(); JITVerifyNull(val); - push(arraySize(val), AssessorDesc::dInt); + push(arraySize(val), false); break; } @@ -2052,7 +2038,7 @@ args.begin(), args.end(), "", currentBlock); push(new ZExtInst(val, Type::Int32Ty, "", currentBlock), - AssessorDesc::dInt); + false); break; } @@ -2118,7 +2104,7 @@ Args.push_back(args[v]); } push(invoke(JnjvmModule::MultiCallNewFunction, Args, "", currentBlock), - AssessorDesc::dRef); + false); break; } @@ -2128,10 +2114,8 @@ case IFNULL : { uint32 tmp = i; - const AssessorDesc* ass = topFunc(); - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[ass->numId]; - llvm::Value* nil = LAI.llvmNullConstant; llvm::Value* val = pop(); + Constant* nil = Constant::getNullValue(val->getType()); llvm::Value* test = new ICmpInst(ICmpInst::ICMP_EQ, val, nil, "", currentBlock); BasicBlock* ifFalse = createBasicBlock("true IFNULL"); @@ -2143,10 +2127,8 @@ case IFNONNULL : { uint32 tmp = i; - const AssessorDesc* ass = topFunc(); - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[ass->numId]; - llvm::Value* nil = LAI.llvmNullConstant; llvm::Value* val = pop(); + Constant* nil = Constant::getNullValue(val->getType()); llvm::Value* test = new ICmpInst(ICmpInst::ICMP_NE, val, nil, "", currentBlock); BasicBlock* ifFalse = createBasicBlock("false IFNONNULL"); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaMetaJIT.cpp Fri Sep 19 09:50:39 2008 @@ -55,38 +55,42 @@ #define readArgs(buf, signature, ap) \ for (std::vector::iterator i = signature->args.begin(), \ e = signature->args.end(); i!= e; i++) { \ - const AssessorDesc* funcs = (*i)->funcs; \ - if (funcs == AssessorDesc::dLong) { \ - ((sint64*)buf)[0] = va_arg(ap, sint64); \ - buf += 2; \ - } else if (funcs == AssessorDesc::dInt) { \ - ((sint32*)buf)[0] = va_arg(ap, sint32); \ + const Typedef* type = *i;\ + if (type->isPrimitive()){\ + const PrimitiveTypedef* prim = (PrimitiveTypedef*)type;\ + if (prim->isLong()){\ + ((sint64*)buf)[0] = va_arg(ap, sint64);\ + buf += 2;\ + } else if (prim->isInt()){ \ + ((sint32*)buf)[0] = va_arg(ap, sint32);\ + buf++; \ + } else if (prim->isChar()){ \ + ((uint32*)buf)[0] = va_arg(ap, uint32);\ + buf++; \ + } else if (prim->isShort()){ \ + ((uint32*)buf)[0] = va_arg(ap, uint32);\ + buf++; \ + } else if (prim->isByte()){ \ + ((uint32*)buf)[0] = va_arg(ap, uint32);\ + buf++; \ + } else if (prim->isBool()){ \ + ((uint32*)buf)[0] = va_arg(ap, uint32);\ + buf++;\ + } else if (prim->isFloat()){\ + ((float*)buf)[0] = (float)va_arg(ap, double);\ + buf++;\ + } else if (prim->isDouble()){\ + ((double*)buf)[0] = va_arg(ap, double);\ + buf += 2;\ + } else{\ + fprintf(stderr, "Can't happen");\ + abort();\ + }\ + } else{\ + ((JavaObject**)buf)[0] = va_arg(ap, JavaObject*);\ buf++; \ - } else if (funcs == AssessorDesc::dChar) { \ - ((uint32*)buf)[0] = va_arg(ap, uint32); \ - buf++; \ - } else if (funcs == AssessorDesc::dShort) { \ - ((uint32*)buf)[0] = va_arg(ap, uint32); \ - buf++; \ - } else if (funcs == AssessorDesc::dByte) { \ - ((uint32*)buf)[0] = va_arg(ap, uint32); \ - buf++; \ - } else if (funcs == AssessorDesc::dBool) { \ - ((uint32*)buf)[0] = va_arg(ap, uint32); \ - buf++; \ - } else if (funcs == AssessorDesc::dFloat) { \ - ((float*)buf)[0] = (float)va_arg(ap, double); \ - buf++; \ - } else if (funcs == AssessorDesc::dDouble) { \ - ((double*)buf)[0] = va_arg(ap, double); \ - buf += 2; \ - } else if (funcs == AssessorDesc::dRef || funcs == AssessorDesc::dTab) { \ - ((JavaObject**)buf)[0] = va_arg(ap, JavaObject*); \ - buf++; \ - } else { \ - assert(0 && "Should not be here"); \ - } \ - } \ + }\ + }\ #if 1//defined(__PPC__) && !defined(__MACH__) Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Fri Sep 19 09:50:39 2008 @@ -173,7 +173,7 @@ extern "C" UserClassArray* getArrayClass(UserCommonClass* cl) { JnjvmClassLoader* JCL = cl->classLoader; const UTF8* arrayName = - AssessorDesc::constructArrayName(JCL, 0, 1, cl->getName()); + AssessorDesc::constructArrayName(JCL, 1, cl->getName()); UserClassArray* dcl = JCL->constructArray(arrayName); return dcl; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp Fri Sep 19 09:50:39 2008 @@ -39,113 +39,6 @@ const char AssessorDesc::I_BOOL = 'Z'; const char AssessorDesc::I_SEP = '/'; -AssessorDesc* AssessorDesc::dParg = 0; -AssessorDesc* AssessorDesc::dPard = 0; -AssessorDesc* AssessorDesc::dVoid = 0; -AssessorDesc* AssessorDesc::dBool = 0; -AssessorDesc* AssessorDesc::dByte = 0; -AssessorDesc* AssessorDesc::dChar = 0; -AssessorDesc* AssessorDesc::dShort = 0; -AssessorDesc* AssessorDesc::dInt = 0; -AssessorDesc* AssessorDesc::dFloat = 0; -AssessorDesc* AssessorDesc::dLong = 0; -AssessorDesc* AssessorDesc::dDouble = 0; -AssessorDesc* AssessorDesc::dTab = 0; -AssessorDesc* AssessorDesc::dRef = 0; - -AssessorDesc::AssessorDesc(bool dt, char bid, uint32 nb, uint32 nw, - const char* name, - JnjvmClassLoader* loader, uint8 nid, - const char* assocName, - UserClassPrimitive* prim, UserClassArray* cl) { - - AssessorDesc* res = this; - res->numId = nid; - res->doTrace = dt; - res->byteId = bid; - res->nbb = nb; - res->nbw = nw; - res->asciizName = name; - res->UTF8Name = loader->asciizConstructUTF8(name); - - res->arrayClass = cl; - if (assocName) - res->assocClassName = loader->asciizConstructUTF8(assocName); - else - res->assocClassName = 0; - - if (bid != I_PARG && bid != I_PARD && bid != I_REF && bid != I_TAB) { - res->primitiveClass = prim; - if (res->arrayClass) { - res->arrayClass->_baseClass = res->primitiveClass; - res->arrayClass->status = ready; - } - } else { - res->primitiveClass = 0; - } -} - -void AssessorDesc::initialise(JnjvmBootstrapLoader* vm) { - - dParg = new AssessorDesc(false, I_PARG, 0, 0, "(", vm, 0, 0, 0, - 0); - dPard = new AssessorDesc(false, I_PARD, 0, 0, ")", vm, 0, 0, 0, - 0); - dVoid = new AssessorDesc(false, I_VOID, 0, 0, "void", - vm, VOID_ID, "java/lang/Void", - vm->upcalls->OfVoid, 0); - dBool = new AssessorDesc(false, I_BOOL, 1, 1, "boolean", - vm, - BOOL_ID, "java/lang/Boolean", - vm->upcalls->OfBool, - vm->upcalls->ArrayOfBool); - dByte = new AssessorDesc(false, I_BYTE, 1, 1, "byte", - vm, BYTE_ID, "java/lang/Byte", - vm->upcalls->OfByte, - vm->upcalls->ArrayOfByte); - dChar = new AssessorDesc(false, I_CHAR, 2, 1, "char", - vm, CHAR_ID, "java/lang/Character", - vm->upcalls->OfChar, - vm->upcalls->ArrayOfChar); - dShort = new AssessorDesc(false, I_SHORT, 2, 1, "short", - vm, SHORT_ID, - "java/lang/Short", - vm->upcalls->OfShort, - vm->upcalls->ArrayOfShort); - dInt = new AssessorDesc(false, I_INT, 4, 1, "int", vm, - INT_ID, "java/lang/Integer", - vm->upcalls->OfInt, - vm->upcalls->ArrayOfInt); - dFloat = new AssessorDesc(false, I_FLOAT, 4, 1, "float", - vm, - FLOAT_ID, "java/lang/Float", - vm->upcalls->OfFloat, - vm->upcalls->ArrayOfFloat); - dLong = new AssessorDesc(false, I_LONG, 8, 2, "long", - vm, LONG_ID, "java/lang/Long", - vm->upcalls->OfLong, - vm->upcalls->ArrayOfLong); - dDouble = new AssessorDesc(false, I_DOUBLE, 8, 2, "double", - vm, - DOUBLE_ID, "java/lang/Double", - vm->upcalls->OfDouble, - vm->upcalls->ArrayOfDouble); - dTab = new AssessorDesc(true, I_TAB, sizeof(void*), 1, "array", - vm, ARRAY_ID, 0, 0, 0); - dRef = new AssessorDesc(true, I_REF, sizeof(void*), 1, "reference", - vm, OBJECT_ID, - 0, 0, 0); - -} - -const char* AssessorDesc::printString() const { - mvm::PrintBuffer *buf= mvm::PrintBuffer::alloc(); - buf->write("AssessorDescriptor<"); - buf->write(asciizName); - buf->write(">"); - return buf->contents()->cString(); -} - static void typeError(const UTF8* name, short int l) { if (l != 0) { JavaThread::get()->isolate-> @@ -157,195 +50,152 @@ } -void AssessorDesc::analyseIntern(const UTF8* name, uint32 pos, - uint32 meth, AssessorDesc*& ass, +bool AssessorDesc::analyseIntern(const UTF8* name, uint32 pos, + uint32 meth, uint32& ret) { short int cur = name->elements[pos]; switch (cur) { - case I_PARG : - ass = dParg; - ret = pos + 1; - break; case I_PARD : - ass = dPard; ret = pos + 1; - break; + return true; case I_BOOL : - ass = dBool; ret = pos + 1; - break; + return false; case I_BYTE : - ass = dByte; ret = pos + 1; - break; + return false; case I_CHAR : - ass = dChar; ret = pos + 1; - break; + return false; case I_SHORT : - ass = dShort; ret = pos + 1; - break; + return false; case I_INT : - ass = dInt; ret = pos + 1; - break; + return false; case I_FLOAT : - ass = dFloat; ret = pos + 1; - break; + return false; case I_DOUBLE : - ass = dDouble; ret = pos + 1; - break; + return false; case I_LONG : - ass = dLong; ret = pos + 1; - break; + return false; case I_VOID : - ass = dVoid; ret = pos + 1; - break; + return false; case I_TAB : if (meth == 1) { pos++; } else { - AssessorDesc * typeIntern = dTab; while (name->elements[++pos] == I_TAB) {} - analyseIntern(name, pos, 1, typeIntern, pos); + analyseIntern(name, pos, 1, pos); } - ass = dTab; ret = pos; - break; + return false; case I_REF : if (meth != 2) { while (name->elements[++pos] != I_END_REF) {} } - ass = dRef; ret = pos + 1; - break; + return false; default : typeError(name, cur); } + return false; } -const UTF8* AssessorDesc::constructArrayName(JnjvmClassLoader *loader, AssessorDesc* ass, +const UTF8* AssessorDesc::constructArrayName(JnjvmClassLoader *loader, uint32 steps, const UTF8* className) { - if (ass) { - uint16* buf = (uint16*)alloca((steps + 1) * sizeof(uint16)); - for (uint32 i = 0; i < steps; i++) { - buf[i] = I_TAB; - } - buf[steps] = ass->byteId; - return loader->readerConstructUTF8(buf, steps + 1); - } else { - uint32 len = className->size; - uint32 pos = steps; - AssessorDesc * funcs = (className->elements[0] == I_TAB ? dTab : dRef); - uint32 n = steps + len + (funcs == dRef ? 2 : 0); - uint16* buf = (uint16*)alloca(n * sizeof(uint16)); + uint32 len = className->size; + uint32 pos = steps; + bool isTab = (className->elements[0] == I_TAB ? true : false); + uint32 n = steps + len + (isTab ? 0 : 2); + uint16* buf = (uint16*)alloca(n * sizeof(uint16)); - for (uint32 i = 0; i < steps; i++) { - buf[i] = I_TAB; - } - - if (funcs == dRef) { - ++pos; - buf[steps] = funcs->byteId; - } + for (uint32 i = 0; i < steps; i++) { + buf[i] = I_TAB; + } - for (uint32 i = 0; i < len; i++) { - buf[pos + i] = className->elements[i]; - } + if (!isTab) { + ++pos; + buf[steps] = I_REF; + } - if (funcs == dRef) { - buf[n - 1] = I_END_REF; - } + for (uint32 i = 0; i < len; i++) { + buf[pos + i] = className->elements[i]; + } - return loader->readerConstructUTF8(buf, n); + if (!isTab) { + buf[n - 1] = I_END_REF; } + + return loader->readerConstructUTF8(buf, n); } -AssessorDesc* AssessorDesc::arrayType(unsigned int t) { +uint8 AssessorDesc::arrayType(unsigned int t) { if (t == JavaArray::T_CHAR) { - return AssessorDesc::dChar; + return I_CHAR; } else if (t == JavaArray::T_BOOLEAN) { - return AssessorDesc::dBool; + return I_BOOL; } else if (t == JavaArray::T_INT) { - return AssessorDesc::dInt; + return I_INT; } else if (t == JavaArray::T_SHORT) { - return AssessorDesc::dShort; + return I_SHORT; } else if (t == JavaArray::T_BYTE) { - return AssessorDesc::dByte; + return I_BYTE; } else if (t == JavaArray::T_FLOAT) { - return AssessorDesc::dFloat; + return I_FLOAT; } else if (t == JavaArray::T_LONG) { - return AssessorDesc::dLong; + return I_LONG; } else if (t == JavaArray::T_DOUBLE) { - return AssessorDesc::dDouble; + return I_DOUBLE; } else { JavaThread::get()->isolate->unknownError("unknown array type %d\n", t); return 0; } } -void Typedef::tPrintBuf(mvm::PrintBuffer* buf) const { - if (pseudoAssocClassName == 0) - buf->write(funcs->asciizName); - else - CommonClass::printClassName(pseudoAssocClassName, buf); +void PrimitiveTypedef::tPrintBuf(mvm::PrintBuffer* buf) const { + prim->name->print(buf); } -AssessorDesc* AssessorDesc::byteIdToPrimitive(char id) { +void ArrayTypedef::tPrintBuf(mvm::PrintBuffer* buf) const { + CommonClass::printClassName(keyName, buf); +} + +void ObjectTypedef::tPrintBuf(mvm::PrintBuffer* buf) const { + CommonClass::printClassName(pseudoAssocClassName, buf); +} + +UserClassPrimitive* +AssessorDesc::byteIdToPrimitive(char id, Classpath* upcalls) { switch (id) { case I_FLOAT : - return dFloat; + return upcalls->OfFloat; case I_INT : - return dInt; + return upcalls->OfInt; case I_SHORT : - return dShort; + return upcalls->OfShort; case I_CHAR : - return dChar; + return upcalls->OfChar; case I_DOUBLE : - return dDouble; + return upcalls->OfDouble; case I_BYTE : - return dByte; + return upcalls->OfByte; case I_BOOL : - return dBool; + return upcalls->OfBool; case I_LONG : - return dLong; + return upcalls->OfLong; case I_VOID : - return dVoid; + return upcalls->OfVoid; default : return 0; } } -AssessorDesc* AssessorDesc::classNameToPrimitive(const UTF8* name) { - if (name->equals(dFloat->assocClassName)) { - return dFloat; - } else if (name->equals(dInt->assocClassName)) { - return dInt; - } else if (name->equals(dShort->assocClassName)) { - return dShort; - } else if (name->equals(dChar->assocClassName)) { - return dChar; - } else if (name->equals(dDouble->assocClassName)) { - return dDouble; - } else if (name->equals(dByte->assocClassName)) { - return dByte; - } else if (name->equals(dBool->assocClassName)) { - return dBool; - } else if (name->equals(dLong->assocClassName)) { - return dLong; - } else if (name->equals(dVoid->assocClassName)) { - return dVoid; - } else { - return 0; - } -} - const char* Typedef::printString() const { mvm::PrintBuffer *buf= mvm::PrintBuffer::alloc(); buf->write("Type<"); @@ -354,14 +204,12 @@ return buf->contents()->cString(); } -UserCommonClass* Typedef::assocClass(JnjvmClassLoader* loader) { - if (pseudoAssocClassName == 0) { - return funcs->getPrimitiveClass(); - } else if (funcs == AssessorDesc::dRef) { - return loader->loadName(pseudoAssocClassName, false, true); - } else { - return loader->constructArray(pseudoAssocClassName); - } +UserCommonClass* ArrayTypedef::assocClass(JnjvmClassLoader* loader) const { + return loader->constructArray(keyName); +} + +UserCommonClass* ObjectTypedef::assocClass(JnjvmClassLoader* loader) const { + return loader->loadName(pseudoAssocClassName, false, true); } void Typedef::humanPrintArgs(const std::vector* args, @@ -402,12 +250,11 @@ uint32 len = (uint32)name->size; uint32 pos = 1; uint32 pred = 0; - AssessorDesc* funcs = 0; while (pos < len) { pred = pos; - AssessorDesc::analyseIntern(name, pos, 0, funcs, pos); - if (funcs == AssessorDesc::dPard) break; + bool end = AssessorDesc::analyseIntern(name, pos, 0, pos); + if (end) break; else { buf.push_back(loader->constructType(name->extract(loader->hashUTF8, pred, pos))); } @@ -417,7 +264,7 @@ typeError(name, 0); } - AssessorDesc::analyseIntern(name, pos, 0, funcs, pred); + AssessorDesc::analyseIntern(name, pos, 0, pred); if (pred != len) { typeError(name, 0); @@ -435,38 +282,28 @@ } -Typedef::Typedef(const UTF8* name, JnjvmClassLoader *loader) { - Typedef* res = this; - AssessorDesc* funcs = 0; - uint32 next; - AssessorDesc::analyseIntern(name, 0, 0, funcs, next); - - assert(funcs != AssessorDesc::dParg && - "Error: resolving a signature for a field"); - res->initialLoader = loader; - res->keyName = name; - res->funcs = funcs; - if (isReference()) { - res->pseudoAssocClassName = name->extract(loader->hashUTF8, 1, next - 1); - } else if (isArray()) { - res->pseudoAssocClassName = name; - } else { - res->pseudoAssocClassName = 0; +Typedef* Typedef::constructType(const UTF8* name, UTF8Map* map, Jnjvm* vm) { + short int cur = name->elements[0]; + Typedef* res = 0; + switch (cur) { + case AssessorDesc::I_TAB : + res = new ArrayTypedef(name); + break; + case AssessorDesc::I_REF : + res = new ObjectTypedef(name, map); + break; + default : + UserClassPrimitive* cl = vm->getPrimitiveClass((char)name->elements[0]); + assert(cl && "No primitive"); + bool unsign = (cl == vm->upcalls->OfChar || cl == vm->upcalls->OfBool); + res = new PrimitiveTypedef(name, cl, unsign, cur); } - -} - -bool Typedef::isArray() { - return keyName->elements[0] == '['; -} - -bool Typedef::isReference() { - return keyName->elements[0] == 'L'; + return res; } -bool Typedef::trace() { - uint16 val = keyName->elements[0]; - return (val == '[' || val == 'L'); +ObjectTypedef::ObjectTypedef(const UTF8* name, UTF8Map* map) { + keyName = name; + pseudoAssocClassName = name->extract(map, 1, name->size - 1); } intptr_t Signdef::staticCallBuf() { Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h Fri Sep 19 09:50:39 2008 @@ -17,6 +17,7 @@ namespace jnjvm { +class Classpath; class ClassArray; class CommonClass; class JavaArray; @@ -29,6 +30,7 @@ class UserClassPrimitive; class UserCommonClass; class UTF8; +class UTF8Map; #define VOID_ID 0 #define BOOL_ID 1 @@ -39,12 +41,12 @@ #define FLOAT_ID 6 #define LONG_ID 7 #define DOUBLE_ID 8 -#define ARRAY_ID 9 -#define OBJECT_ID 10 +#define OBJECT_ID 9 +#define ARRAY_ID 10 #define NUM_ASSESSORS 11 -/// AssessorDesc - Description of a Java assessor: these are the letters found -/// in Java signatures, e.g. "I" or "(". +/// AssessorDesc - Helpful functions to analyse UTF8s and ids and get +/// either Typedefs or Classes. /// class AssessorDesc { public: @@ -65,213 +67,218 @@ static const char I_BOOL; static const char I_SEP; - /// doTrace - Is this assessor for garbage collected objects? True for - /// the "L" assessor and the "[" assessor. - /// - bool doTrace; + static bool analyseIntern(const UTF8* name, uint32 pos, + uint32 meth, + uint32& ret); - /// byteId - Letter reprensenting this assessor. - /// - char byteId; + static const UTF8* constructArrayName(JnjvmClassLoader* loader, + uint32 steps, const UTF8* className); + + static uint8 arrayType(unsigned int t); + + static UserClassPrimitive* byteIdToPrimitive(char id, Classpath* upcalls); - /// nbb - Number of bytes of instances of this assessor (e.g. 4 for "I"). - /// - uint32 nbb; - /// nbw - Number of words of instances if this assessor (e.g. 2 for "D"). - /// - uint32 nbw; +}; - /// numId - A byte identifier from 0 to the number of assessors. - /// - uint8 numId; - /// asciizName - The name of the assessor in asciiz, e.g. "void" for "V". +/// Typedef - Each class has a Typedef representation. A Typedef is also a class +/// which has not been loaded yet. Typedefs are hashed on the name of the class. +/// Hashing is for memory purposes, not for comparison. +/// +class Typedef { +public: + + /// keyName - The name of the Typedef. It is the representation of a class + /// in a Java signature, e.g. "Ljava/lang/Object;". /// - const char* asciizName; + const UTF8* keyName; - /// UTF8Name - The name of the assessor in UTF8, e.g. "void" for "V". + /// humanPrintArgs - Prints the list of typedef in a human readable form. /// - const UTF8* UTF8Name; + static void humanPrintArgs(const std::vector*, + mvm::PrintBuffer* buf); - /// primitiveClass - The primitive Java class of this assessor. This class - /// is internal to the JVM. + /// tPrintBuf - Prints the name of the class this Typedef represents. /// - UserClassPrimitive* primitiveClass; - - /// assocClassName - The associated class name, e.g. "java/lang/Integer" for - /// "I". + virtual void tPrintBuf(mvm::PrintBuffer* buf) const = 0; + + /// printString - Print the Typedef for debugging purposes. /// - const UTF8* assocClassName; + const char* printString() const; - /// arrayClass - The primitive array class of the assessor, e.g. I[] for "I". + /// assocClass - Given the loaded, try to load the class represented by this + /// Typedef. /// - UserClassArray* arrayClass; + virtual UserCommonClass* assocClass(JnjvmClassLoader* loader) const = 0; + + /// Typedef - Create a new Typedef. + /// + static Typedef* constructType(const UTF8* name, UTF8Map* map, Jnjvm* vm); + + virtual bool trace() const = 0; + + virtual bool isPrimitive() const { + return false; + } + + virtual bool isReference() const { + return true; + } + + virtual bool isUnsigned() const { + return false; + } -//===----------------------------------------------------------------------===// -// -// The set of assessors in Java. This set is unique and there are no other -// assessors. -// -//===----------------------------------------------------------------------===// + virtual const UTF8* getName() const { + return keyName; + } + const UTF8* getKey() const { + return keyName; + } - /// dParg - The "(" assessor. - /// - static AssessorDesc* dParg; +}; - /// dPard - The ")" assessor. +class PrimitiveTypedef : public Typedef { +private: + UserClassPrimitive* prim; + bool unsign; + char charId; + +public: + + /// tPrintBuf - Prints the name of the class this Typedef represents. /// - static AssessorDesc* dPard; + virtual void tPrintBuf(mvm::PrintBuffer* buf) const; + - /// dVoid - The "V" assessor. - /// - static AssessorDesc* dVoid; + virtual bool trace() const { + return false; + } + + virtual bool isPrimitive() const { + return true; + } + + virtual bool isReference() const { + return false; + } - /// dBool - The "Z" assessor. - /// - static AssessorDesc* dBool; + virtual bool isUnsigned() const { + return unsign; + } - /// dByte - The "B" assessor. - /// - static AssessorDesc* dByte; + virtual UserCommonClass* assocClass(JnjvmClassLoader* loader) const { + return (UserCommonClass*)prim; + } - /// dChar - The "C" assessor. - /// - static AssessorDesc* dChar; + PrimitiveTypedef(const UTF8* name, UserClassPrimitive* cl, bool u, char i) { + keyName = name; + prim = cl; + unsign = u; + charId = i; + } + + bool isVoid() const { + return charId == AssessorDesc::I_VOID; + } - /// dShort - The "S" assessor. - /// - static AssessorDesc* dShort; + bool isLong() const { + return charId == AssessorDesc::I_LONG; + } - /// dInt - The "I" assessor. - /// - static AssessorDesc* dInt; + bool isInt() const { + return charId == AssessorDesc::I_INT; + } - /// dFloat - The "F" assessor. - /// - static AssessorDesc* dFloat; + bool isChar() const { + return charId == AssessorDesc::I_CHAR; + } - /// dLong - The "J" assessor. - /// - static AssessorDesc* dLong; + bool isShort() const { + return charId == AssessorDesc::I_SHORT; + } - /// dDouble - The "D" assessor. - /// - static AssessorDesc* dDouble; + bool isByte() const { + return charId == AssessorDesc::I_BYTE; + } - /// dTab - The "[" assessor. - /// - static AssessorDesc* dTab; + bool isBool() const { + return charId == AssessorDesc::I_BOOL; + } - /// dRef - The "L" assessor. - /// - static AssessorDesc* dRef; - -//===----------------------------------------------------------------------===// -// -// End of assessors. -// -//===----------------------------------------------------------------------===// + bool isFloat() const { + return charId == AssessorDesc::I_FLOAT; + } - /// AssessorDesc - Construct an assessor. + bool isDouble() const { + return charId == AssessorDesc::I_DOUBLE; + } + + /// JInfo - Holds info useful for the JIT. /// - AssessorDesc(bool dt, char bid, uint32 nb, uint32 nw, - const char* name, - JnjvmClassLoader* loader, uint8 nid, - const char* assocName, - UserClassPrimitive* prim, UserClassArray* cl); - + mvm::JITInfo* JInfo; - /// initialise - Construct all assessors. + /// getInfo - Get the JIT info of this signature. The info is created lazely. /// - static void initialise(JnjvmBootstrapLoader* loader); - + template + Ty *getInfo() { + if (!JInfo) { + JInfo = new Ty(this); + } - /// printString - Print the assessor for debugging purposes. - /// - const char* printString() const; + assert((void*)dynamic_cast(JInfo) == (void*)JInfo && + "Invalid concrete type or multiple inheritence for getInfo"); + return static_cast(JInfo); + } +}; - static void analyseIntern(const UTF8* name, uint32 pos, - uint32 meth, AssessorDesc*& ass, - uint32& ret); +class ArrayTypedef : public Typedef { +public: + /// tPrintBuf - Prints the name of the class this Typedef represents. + /// + virtual void tPrintBuf(mvm::PrintBuffer* buf) const; - static const UTF8* constructArrayName(JnjvmClassLoader* loader, AssessorDesc* ass, - uint32 steps, const UTF8* className); - - static AssessorDesc* arrayType(unsigned int t); - static AssessorDesc* byteIdToPrimitive(const char id); - static AssessorDesc* classNameToPrimitive(const UTF8* name); - -#ifdef MULTIPLE_VM - UserClassArray* getArrayClass() const; - UserClassPrimitive* getPrimitiveClass() const; -#else - UserClassArray* getArrayClass() const { - return arrayClass; - } - UserClassPrimitive* getPrimitiveClass() const { - return primitiveClass; + virtual bool trace() const { + return true; } -#endif -}; + virtual UserCommonClass* assocClass(JnjvmClassLoader* loader) const; -/// Typedef - Each class has a Typedef representation. A Typedef is also a class -/// which has not been loaded yet. Typedefs are hashed on the name of the class. -/// Hashing is for memory purposes, not for comparison. -/// -class Typedef { -public: - - /// keyName - The name of the Typedef. It is the representation of a class - /// in a Java signature, e.g. "Ljava/lang/Object;". - /// - const UTF8* keyName; + ArrayTypedef(const UTF8* name) { + keyName = name; + } +}; +class ObjectTypedef : public Typedef { +private: /// pseudoAssocClassName - The real name of the class this Typedef /// represents, e.g. "java/lang/Object" /// const UTF8* pseudoAssocClassName; - /// funcs - The assessor for this Typedef. All Typedef must have the dRef - /// or the dTab assessor, except the primive Typedefs. - /// - const AssessorDesc* funcs; - - /// initialLoader - The loader that first loaded this typedef. - /// - JnjvmClassLoader* initialLoader; - - /// printString - Print the Typedef for debugging purposes. - /// - const char* printString() const; - - /// assocClass - Given the loaded, try to load the class represented by this - /// Typedef. - /// - UserCommonClass* assocClass(JnjvmClassLoader* loader); - - /// humanPrintArgs - Prints the list of typedef in a human readable form. +public: + /// tPrintBuf - Prints the name of the class this Typedef represents. /// - static void humanPrintArgs(const std::vector*, - mvm::PrintBuffer* buf); + virtual void tPrintBuf(mvm::PrintBuffer* buf) const; - /// Typedef - Create a new Typedef. - /// - Typedef(const UTF8* name, JnjvmClassLoader* loader); + virtual bool trace() const { + return true; + } - /// tPrintBuf - Prints the name of the class this Typedef represents. - /// - void tPrintBuf(mvm::PrintBuffer* buf) const; + virtual UserCommonClass* assocClass(JnjvmClassLoader* loader) const; + + ObjectTypedef(const UTF8*name, UTF8Map* map); - bool isArray(); - bool isReference(); - bool trace(); + virtual const UTF8* getName() const { + return pseudoAssocClassName; + } }; + /// Signdef - This class represents a Java signature. Each Java method has a /// Java signature. Signdefs are hashed for memory purposes, not equality /// purposes. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h Fri Sep 19 09:50:39 2008 @@ -28,7 +28,7 @@ #define UPCALL_ARRAY_CLASS(vm, name, depth) \ vm->constructArray( \ - AssessorDesc::constructArrayName(vm, 0, depth, \ + AssessorDesc::constructArrayName(vm, depth, \ vm->asciizConstructUTF8(name))) #define UPCALL_CLASS_EXCEPTION(loader, name) \ Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp Fri Sep 19 09:50:39 2008 @@ -1746,7 +1746,7 @@ UserCommonClass* base = NativeUtil::resolvedImplClass(elementClass, true); JnjvmClassLoader* loader = base->classLoader; const UTF8* name = base->getName(); - const UTF8* arrayName = AssessorDesc::constructArrayName(loader, 0, 1, name); + const UTF8* arrayName = AssessorDesc::constructArrayName(loader, 1, name); UserClassArray* array = loader->constructArray(arrayName); ArrayObject* res = ArrayObject::acons(length, array, &(vm->allocator)); if (initialElement) { Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp Fri Sep 19 09:50:39 2008 @@ -84,6 +84,7 @@ /// If we're not in a multi-vm environment, this can be made static. std::vector Jnjvm::nativeLibs; JnjvmBootstrapLoader* Jnjvm::bootstrapLoader; +std::map Jnjvm::primitiveMap; #endif typedef void (*clinit_t)(Jnjvm* vm, UserConstantPool*); @@ -125,7 +126,7 @@ CommonClass::field_map* map = cl->getStaticFields(); for (CommonClass::field_iterator i = map->begin(), e = map->end(); i!= e; ++i) { - i->second->initField(val); + i->second->initField(val, vm); } cl->setStaticInstance(val); @@ -846,15 +847,34 @@ #ifdef MULTIPLE_VM isolate->throwable = isolate->upcalls->newThrowable; - isolate->arrayClasses[1] = isolate->upcalls->ArrayOfBool; - isolate->arrayClasses[2] = isolate->upcalls->ArrayOfByte; - isolate->arrayClasses[3] = isolate->upcalls->ArrayOfChar; - isolate->arrayClasses[4] = isolate->upcalls->ArrayOfShort; - isolate->arrayClasses[5] = isolate->upcalls->ArrayOfInt; - isolate->arrayClasses[6] = isolate->upcalls->ArrayOfFloat; - isolate->arrayClasses[7] = isolate->upcalls->ArrayOfLong; - isolate->arrayClasses[8] = isolate->upcalls->ArrayOfDouble; #endif - + isolate->arrayClasses[JavaArray::T_BOOLEAN - 4] = + isolate->upcalls->ArrayOfBool; + isolate->arrayClasses[JavaArray::T_BYTE - 4] = + isolate->upcalls->ArrayOfByte; + isolate->arrayClasses[JavaArray::T_CHAR - 4] = + isolate->upcalls->ArrayOfChar; + isolate->arrayClasses[JavaArray::T_SHORT - 4] = + isolate->upcalls->ArrayOfShort; + isolate->arrayClasses[JavaArray::T_INT - 4] = + isolate->upcalls->ArrayOfInt; + isolate->arrayClasses[JavaArray::T_FLOAT - 4] = + isolate->upcalls->ArrayOfFloat; + isolate->arrayClasses[JavaArray::T_LONG - 4] = + isolate->upcalls->ArrayOfLong; + isolate->arrayClasses[JavaArray::T_DOUBLE - 4] = + isolate->upcalls->ArrayOfDouble; + + isolate->primitiveMap[AssessorDesc::I_VOID] = isolate->upcalls->OfVoid; + isolate->primitiveMap[AssessorDesc::I_BOOL] = isolate->upcalls->OfBool; + isolate->primitiveMap[AssessorDesc::I_BYTE] = isolate->upcalls->OfByte; + isolate->primitiveMap[AssessorDesc::I_CHAR] = isolate->upcalls->OfChar; + isolate->primitiveMap[AssessorDesc::I_SHORT] = isolate->upcalls->OfShort; + isolate->primitiveMap[AssessorDesc::I_INT] = isolate->upcalls->OfInt; + isolate->primitiveMap[AssessorDesc::I_FLOAT] = isolate->upcalls->OfFloat; + isolate->primitiveMap[AssessorDesc::I_LONG] = isolate->upcalls->OfLong; + isolate->primitiveMap[AssessorDesc::I_DOUBLE] = isolate->upcalls->OfDouble; + + isolate->upcalls->initialiseClasspath(bootstrapLoader); return isolate; } Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.h?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.h Fri Sep 19 09:50:39 2008 @@ -98,10 +98,12 @@ #ifdef MULTIPLE_VM UserClass* throwable; - UserClassArray* arrayClasses[9]; #endif + std::map arrayClasses; private: + ISOLATE_STATIC std::map primitiveMap; + /// bootstrapThread - The initial thread of this JVM. /// JavaThread* bootstrapThread; @@ -245,10 +247,7 @@ /// nativeLibs - Native libraries (e.g. '.so') loaded by this JVM. /// -#ifndef MULTIPLE_VM - static -#endif - std::vector nativeLibs; + ISOLATE_STATIC std::vector nativeLibs; /// classpath - The CLASSPATH value, or the paths given in command line. /// @@ -331,6 +330,10 @@ /// static variables in a single environment. /// ISOLATE_STATIC void initialiseStatics(); + + ISOLATE_STATIC UserClassPrimitive* getPrimitiveClass(char id) { + return primitiveMap[id]; + } /// allocateIsolate - Allocates a new JVM. /// Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Fri Sep 19 09:50:39 2008 @@ -267,8 +267,11 @@ UserCommonClass* cl = loadName(componentName, false, true); return cl; } else { - AssessorDesc* ass = AssessorDesc::byteIdToPrimitive(name->elements[start]); - return ass ? ass->primitiveClass : 0; + Classpath* upcalls = bootstrapLoader->upcalls; + UserClassPrimitive* prim = + AssessorDesc::byteIdToPrimitive(name->elements[start], upcalls); + assert(prim && "No primitive found"); + return prim; } } @@ -318,11 +321,14 @@ Typedef* JnjvmClassLoader::constructType(const UTF8* name) { Typedef* res = javaTypes->lookup(name); if (res == 0) { - res = new Typedef(name, this); + res = Typedef::constructType(name, hashUTF8, isolate); javaTypes->lock->lock(); Typedef* tmp = javaTypes->lookup(name); if (tmp == 0) javaTypes->hash(name, res); - else res = tmp; + else { + delete res; + res = tmp; + } javaTypes->lock->unlock(); } return res; @@ -335,7 +341,10 @@ javaSignatures->lock->lock(); Signdef* tmp = javaSignatures->lookup(name); if (tmp == 0) javaSignatures->hash(name, res); - else res = tmp; + else { + delete res; + res = tmp; + } javaSignatures->lock->unlock(); } return res; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Fri Sep 19 09:50:39 2008 @@ -389,8 +389,8 @@ for (uint32 index = 0; index < classDef->virtualFields.size(); ++index) { - uint8 id = array[index]->getSignature()->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + Typedef* type = array[index]->getSignature(); + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(type); fields.push_back(LAI.llvmType); } @@ -434,8 +434,8 @@ for (uint32 index = 0; index < classDef->staticFields.size(); ++index) { JavaField* field = array[index]; - uint8 id = field->getSignature()->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + Typedef* type = field->getSignature(); + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(type); fields.push_back(LAI.llvmType); } @@ -573,8 +573,8 @@ llvmArgs.push_back(JnjvmModule::JavaObjectType); for (uint32 i = 0; i < size; ++i) { - uint8 id = signature->args.at(i)->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + Typedef* type = signature->args.at(i); + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(type); llvmArgs.push_back(LAI.llvmType); } @@ -583,8 +583,7 @@ llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool #endif - uint8 id = signature->ret->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(signature->ret); virtualType = FunctionType::get(LAI.llvmType, llvmArgs, false); } return virtualType; @@ -598,8 +597,8 @@ unsigned int size = signature->args.size(); for (uint32 i = 0; i < size; ++i) { - uint8 id = signature->args.at(i)->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + Typedef* type = signature->args.at(i); + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(type); llvmArgs.push_back(LAI.llvmType); } @@ -608,8 +607,7 @@ llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool #endif - uint8 id = signature->ret->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(signature->ret); staticType = FunctionType::get(LAI.llvmType, llvmArgs, false); } return staticType; @@ -626,8 +624,8 @@ llvmArgs.push_back(JnjvmModule::JavaObjectType); // Class for (uint32 i = 0; i < size; ++i) { - uint8 id = signature->args.at(i)->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + Typedef* type = signature->args.at(i); + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(type); llvmArgs.push_back(LAI.llvmType); } @@ -636,8 +634,7 @@ llvmArgs.push_back(JnjvmModule::ConstantPoolType); // cached constant pool #endif - uint8 id = signature->ret->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(signature->ret); nativeType = FunctionType::get(LAI.llvmType, llvmArgs, false); } return nativeType; @@ -678,13 +675,13 @@ for (std::vector::iterator i = signature->args.begin(), e = signature->args.end(); i!= e; ++i) { - const AssessorDesc* funcs = (*i)->funcs; ptr = GetElementPtrInst::Create(ptr, CI, "", currentBlock); - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[funcs->numId]; + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(*i); + const Type* type = LAI.llvmType; Value* val = new BitCastInst(ptr, LAI.llvmTypePtr, "", currentBlock); Value* arg = new LoadInst(val, "", currentBlock); Args.push_back(arg); - if (funcs == AssessorDesc::dLong || funcs == AssessorDesc::dDouble) { + if (type == Type::Int64Ty || type == Type::DoubleTy) { CI = mvm::jit::constantTwo; } else { CI = mvm::jit::constantOne; @@ -697,7 +694,7 @@ #endif Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock); - if (signature->ret->funcs != AssessorDesc::dVoid) + if (res->getFunctionType()->getReturnType() != Type::VoidTy) ReturnInst::Create(val, currentBlock); else ReturnInst::Create(currentBlock); @@ -735,10 +732,9 @@ } ap = i; - for (std::vector::iterator i = signature->args.begin(), + for (std::vector::iterator i = signature->args.begin(), e = signature->args.end(); i!= e; i++) { - - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[(*i)->funcs->numId]; + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(*i); Args.push_back(new VAArgInst(ap, LAI.llvmType, "", currentBlock)); } @@ -748,7 +744,7 @@ #endif Value* val = CallInst::Create(func, Args.begin(), Args.end(), "", currentBlock); - if (signature->ret->funcs != AssessorDesc::dVoid) + if (res->getFunctionType()->getReturnType() != Type::VoidTy) ReturnInst::Create(val, currentBlock); else ReturnInst::Create(currentBlock); @@ -788,8 +784,7 @@ Args2.push_back(getVirtualPtrType()); Args2.push_back(JnjvmModule::JavaObjectType); Args2.push_back(PointerType::getUnqual(Type::Int32Ty)); - uint8 id = signature->ret->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(signature->ret); virtualBufType = FunctionType::get(LAI.llvmType, Args2, false); } return virtualBufType; @@ -804,8 +799,7 @@ Args.push_back(JnjvmModule::ConstantPoolType); // ctp Args.push_back(getStaticPtrType()); Args.push_back(PointerType::getUnqual(Type::Int32Ty)); - uint8 id = signature->ret->funcs->numId; - LLVMAssessorInfo& LAI = LLVMAssessorInfo::AssessorInfo[id]; + LLVMAssessorInfo& LAI = JnjvmModule::getTypedefInfo(signature->ret); staticBufType = FunctionType::get(LAI.llvmType, Args, false); } return staticBufType; @@ -1104,18 +1098,24 @@ void JnjvmModule::InitField(JavaField* field, JavaObject* obj, uint64 val) { - const AssessorDesc* funcs = field->getSignature()->funcs; - if (funcs == AssessorDesc::dLong) { + Typedef* type = field->getSignature(); + if (!type->isPrimitive()) { + ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val; + return; + } + + PrimitiveTypedef* prim = (PrimitiveTypedef*)type; + if (prim->isLong()) { ((sint64*)((uint64)obj + field->ptrOffset))[0] = val; - } else if (funcs == AssessorDesc::dInt) { + } else if (prim->isInt()) { ((sint32*)((uint64)obj + field->ptrOffset))[0] = (sint32)val; - } else if (funcs == AssessorDesc::dChar) { + } else if (prim->isChar()) { ((uint16*)((uint64)obj + field->ptrOffset))[0] = (uint16)val; - } else if (funcs == AssessorDesc::dShort) { + } else if (prim->isShort()) { ((sint16*)((uint64)obj + field->ptrOffset))[0] = (sint16)val; - } else if (funcs == AssessorDesc::dByte) { + } else if (prim->isByte()) { ((sint8*)((uint64)obj + field->ptrOffset))[0] = (sint8)val; - } else if (funcs == AssessorDesc::dBool) { + } else if (prim->isBool()) { ((uint8*)((uint64)obj + field->ptrOffset))[0] = (uint8)val; } else { // 0 value for everything else @@ -1151,72 +1151,77 @@ setDataLayout(str); } void LLVMAssessorInfo::initialise() { - AssessorInfo[VOID_ID].llvmType = Type::VoidTy; - AssessorInfo[VOID_ID].llvmTypePtr = 0; - AssessorInfo[VOID_ID].llvmNullConstant = 0; - AssessorInfo[VOID_ID].sizeInBytesConstant = 0; - - AssessorInfo[BOOL_ID].llvmType = Type::Int8Ty; - AssessorInfo[BOOL_ID].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty); - AssessorInfo[BOOL_ID].llvmNullConstant = + AssessorInfo[AssessorDesc::I_VOID].llvmType = Type::VoidTy; + AssessorInfo[AssessorDesc::I_VOID].llvmTypePtr = 0; + AssessorInfo[AssessorDesc::I_VOID].llvmNullConstant = 0; + AssessorInfo[AssessorDesc::I_VOID].sizeInBytesConstant = 0; + + AssessorInfo[AssessorDesc::I_BOOL].llvmType = Type::Int8Ty; + AssessorInfo[AssessorDesc::I_BOOL].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty); + AssessorInfo[AssessorDesc::I_BOOL].llvmNullConstant = Constant::getNullValue(Type::Int8Ty); - AssessorInfo[BOOL_ID].sizeInBytesConstant = mvm::jit::constantOne; + AssessorInfo[AssessorDesc::I_BOOL].sizeInBytesConstant = mvm::jit::constantOne; - AssessorInfo[BYTE_ID].llvmType = Type::Int8Ty; - AssessorInfo[BYTE_ID].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty); - AssessorInfo[BYTE_ID].llvmNullConstant = + AssessorInfo[AssessorDesc::I_BYTE].llvmType = Type::Int8Ty; + AssessorInfo[AssessorDesc::I_BYTE].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty); + AssessorInfo[AssessorDesc::I_BYTE].llvmNullConstant = Constant::getNullValue(Type::Int8Ty); - AssessorInfo[BYTE_ID].sizeInBytesConstant = mvm::jit::constantOne; + AssessorInfo[AssessorDesc::I_BYTE].sizeInBytesConstant = mvm::jit::constantOne; - AssessorInfo[SHORT_ID].llvmType = Type::Int16Ty; - AssessorInfo[SHORT_ID].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty); - AssessorInfo[SHORT_ID].llvmNullConstant = + AssessorInfo[AssessorDesc::I_SHORT].llvmType = Type::Int16Ty; + AssessorInfo[AssessorDesc::I_SHORT].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty); + AssessorInfo[AssessorDesc::I_SHORT].llvmNullConstant = Constant::getNullValue(Type::Int16Ty); - AssessorInfo[SHORT_ID].sizeInBytesConstant = mvm::jit::constantTwo; + AssessorInfo[AssessorDesc::I_SHORT].sizeInBytesConstant = mvm::jit::constantTwo; - AssessorInfo[CHAR_ID].llvmType = Type::Int16Ty; - AssessorInfo[CHAR_ID].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty); - AssessorInfo[CHAR_ID].llvmNullConstant = + AssessorInfo[AssessorDesc::I_CHAR].llvmType = Type::Int16Ty; + AssessorInfo[AssessorDesc::I_CHAR].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty); + AssessorInfo[AssessorDesc::I_CHAR].llvmNullConstant = Constant::getNullValue(Type::Int16Ty); - AssessorInfo[CHAR_ID].sizeInBytesConstant = mvm::jit::constantTwo; + AssessorInfo[AssessorDesc::I_CHAR].sizeInBytesConstant = mvm::jit::constantTwo; - AssessorInfo[INT_ID].llvmType = Type::Int32Ty; - AssessorInfo[INT_ID].llvmTypePtr = PointerType::getUnqual(Type::Int32Ty); - AssessorInfo[INT_ID].llvmNullConstant = + AssessorInfo[AssessorDesc::I_INT].llvmType = Type::Int32Ty; + AssessorInfo[AssessorDesc::I_INT].llvmTypePtr = PointerType::getUnqual(Type::Int32Ty); + AssessorInfo[AssessorDesc::I_INT].llvmNullConstant = Constant::getNullValue(Type::Int32Ty); - AssessorInfo[INT_ID].sizeInBytesConstant = mvm::jit::constantFour; + AssessorInfo[AssessorDesc::I_INT].sizeInBytesConstant = mvm::jit::constantFour; - AssessorInfo[FLOAT_ID].llvmType = Type::FloatTy; - AssessorInfo[FLOAT_ID].llvmTypePtr = PointerType::getUnqual(Type::FloatTy); - AssessorInfo[FLOAT_ID].llvmNullConstant = + AssessorInfo[AssessorDesc::I_FLOAT].llvmType = Type::FloatTy; + AssessorInfo[AssessorDesc::I_FLOAT].llvmTypePtr = PointerType::getUnqual(Type::FloatTy); + AssessorInfo[AssessorDesc::I_FLOAT].llvmNullConstant = Constant::getNullValue(Type::FloatTy); - AssessorInfo[FLOAT_ID].sizeInBytesConstant = mvm::jit::constantFour; + AssessorInfo[AssessorDesc::I_FLOAT].sizeInBytesConstant = mvm::jit::constantFour; - AssessorInfo[LONG_ID].llvmType = Type::Int64Ty; - AssessorInfo[LONG_ID].llvmTypePtr = PointerType::getUnqual(Type::Int64Ty); - AssessorInfo[LONG_ID].llvmNullConstant = + AssessorInfo[AssessorDesc::I_LONG].llvmType = Type::Int64Ty; + AssessorInfo[AssessorDesc::I_LONG].llvmTypePtr = PointerType::getUnqual(Type::Int64Ty); + AssessorInfo[AssessorDesc::I_LONG].llvmNullConstant = Constant::getNullValue(Type::Int64Ty); - AssessorInfo[LONG_ID].sizeInBytesConstant = mvm::jit::constantEight; + AssessorInfo[AssessorDesc::I_LONG].sizeInBytesConstant = mvm::jit::constantEight; - AssessorInfo[DOUBLE_ID].llvmType = Type::DoubleTy; - AssessorInfo[DOUBLE_ID].llvmTypePtr = PointerType::getUnqual(Type::DoubleTy); - AssessorInfo[DOUBLE_ID].llvmNullConstant = + AssessorInfo[AssessorDesc::I_DOUBLE].llvmType = Type::DoubleTy; + AssessorInfo[AssessorDesc::I_DOUBLE].llvmTypePtr = PointerType::getUnqual(Type::DoubleTy); + AssessorInfo[AssessorDesc::I_DOUBLE].llvmNullConstant = Constant::getNullValue(Type::DoubleTy); - AssessorInfo[DOUBLE_ID].sizeInBytesConstant = mvm::jit::constantEight; + AssessorInfo[AssessorDesc::I_DOUBLE].sizeInBytesConstant = mvm::jit::constantEight; - AssessorInfo[ARRAY_ID].llvmType = JnjvmModule::JavaObjectType; - AssessorInfo[ARRAY_ID].llvmTypePtr = + AssessorInfo[AssessorDesc::I_TAB].llvmType = JnjvmModule::JavaObjectType; + AssessorInfo[AssessorDesc::I_TAB].llvmTypePtr = PointerType::getUnqual(JnjvmModule::JavaObjectType); - AssessorInfo[ARRAY_ID].llvmNullConstant = + AssessorInfo[AssessorDesc::I_TAB].llvmNullConstant = JnjvmModule::JavaObjectNullConstant; - AssessorInfo[ARRAY_ID].sizeInBytesConstant = mvm::jit::constantPtrSize; + AssessorInfo[AssessorDesc::I_TAB].sizeInBytesConstant = mvm::jit::constantPtrSize; - AssessorInfo[OBJECT_ID].llvmType = JnjvmModule::JavaObjectType; - AssessorInfo[OBJECT_ID].llvmTypePtr = + AssessorInfo[AssessorDesc::I_REF].llvmType = JnjvmModule::JavaObjectType; + AssessorInfo[AssessorDesc::I_REF].llvmTypePtr = PointerType::getUnqual(JnjvmModule::JavaObjectType); - AssessorInfo[OBJECT_ID].llvmNullConstant = + AssessorInfo[AssessorDesc::I_REF].llvmNullConstant = JnjvmModule::JavaObjectNullConstant; - AssessorInfo[OBJECT_ID].sizeInBytesConstant = mvm::jit::constantPtrSize; + AssessorInfo[AssessorDesc::I_REF].sizeInBytesConstant = mvm::jit::constantPtrSize; +} + +std::map LLVMAssessorInfo::AssessorInfo; + +LLVMAssessorInfo& JnjvmModule::getTypedefInfo(Typedef* type) { + return LLVMAssessorInfo::AssessorInfo[type->getKey()->elements[0]]; } -LLVMAssessorInfo LLVMAssessorInfo::AssessorInfo[NUM_ASSESSORS]; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.h Fri Sep 19 09:50:39 2008 @@ -45,7 +45,7 @@ llvm::ConstantInt* sizeInBytesConstant; static void initialise(); - static LLVMAssessorInfo AssessorInfo[]; + static std::map AssessorInfo; }; @@ -436,6 +436,8 @@ return ctp->getInfo(); } + static LLVMAssessorInfo& getTypedefInfo(Typedef* type); + LLVMStringInfo* getStringInfo(JavaString* str); #ifdef SERVICE_VM Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp?rev=56347&r1=56346&r2=56347&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp Fri Sep 19 09:50:39 2008 @@ -239,10 +239,9 @@ void NativeUtil::decapsulePrimitive(Jnjvm *vm, void** &buf, JavaObject* obj, Typedef* signature) { - const AssessorDesc* funcs = signature->funcs; - if (funcs == AssessorDesc::dRef || funcs == AssessorDesc::dTab) { - if (obj && !(obj->classOf->isOfTypeName(signature->pseudoAssocClassName))) { + if (!signature->isPrimitive()) { + if (obj && !(obj->classOf->isOfTypeName(signature->getName()))) { vm->illegalArgumentException("wrong type argument"); } ((JavaObject**)buf)[0] = obj; @@ -252,18 +251,19 @@ vm->illegalArgumentException(""); } else { UserCommonClass* cl = obj->classOf; - AssessorDesc* value = AssessorDesc::classNameToPrimitive(cl->getName()); - + UserClassPrimitive* value = cl->toPrimitive(vm); + PrimitiveTypedef* prim = (PrimitiveTypedef*)signature; + if (value == 0) { vm->illegalArgumentException(""); } - if (funcs == AssessorDesc::dShort) { - if (value == AssessorDesc::dShort) { + if (prim->isShort()) { + if (value == vm->upcalls->OfShort) { ((uint16*)buf)[0] = vm->upcalls->shortValue->getInt16Field(obj); buf++; return; - } else if (value == AssessorDesc::dByte) { + } else if (value == vm->upcalls->OfByte) { ((sint16*)buf)[0] = (sint16)vm->upcalls->byteValue->getInt8Field(obj); buf++; @@ -271,31 +271,31 @@ } else { vm->illegalArgumentException(""); } - } else if (funcs == AssessorDesc::dByte) { - if (value == AssessorDesc::dByte) { + } else if (prim->isByte()) { + if (value == vm->upcalls->OfByte) { ((uint8*)buf)[0] = vm->upcalls->byteValue->getInt8Field(obj); buf++; return; } else { vm->illegalArgumentException(""); } - } else if (funcs == AssessorDesc::dBool) { - if (value == AssessorDesc::dBool) { + } else if (prim->isBool()) { + if (value == vm->upcalls->OfBool) { ((uint8*)buf)[0] = vm->upcalls->boolValue->getInt8Field(obj); buf++; return; } else { vm->illegalArgumentException(""); } - } else if (funcs == AssessorDesc::dInt) { + } else if (prim->isInt()) { sint32 val = 0; - if (value == AssessorDesc::dInt) { + if (value == vm->upcalls->OfInt) { val = vm->upcalls->intValue->getInt32Field(obj); - } else if (value == AssessorDesc::dByte) { + } else if (value == vm->upcalls->OfByte) { val = (sint32)vm->upcalls->byteValue->getInt8Field(obj); - } else if (value == AssessorDesc::dChar) { + } else if (value == vm->upcalls->OfChar) { val = (uint32)vm->upcalls->charValue->getInt16Field(obj); - } else if (value == AssessorDesc::dShort) { + } else if (value == vm->upcalls->OfShort) { val = (sint32)vm->upcalls->shortValue->getInt16Field(obj); } else { vm->illegalArgumentException(""); @@ -303,9 +303,9 @@ ((sint32*)buf)[0] = val; buf++; return; - } else if (funcs == AssessorDesc::dChar) { + } else if (prim->isChar()) { uint16 val = 0; - if (value == AssessorDesc::dChar) { + if (value == vm->upcalls->OfChar) { val = (uint16)vm->upcalls->charValue->getInt16Field(obj); } else { vm->illegalArgumentException(""); @@ -313,19 +313,19 @@ ((uint16*)buf)[0] = val; buf++; return; - } else if (funcs == AssessorDesc::dFloat) { + } else if (prim->isFloat()) { float val = 0; - if (value == AssessorDesc::dFloat) { + if (value == vm->upcalls->OfFloat) { val = (float)vm->upcalls->floatValue->getFloatField(obj); - } else if (value == AssessorDesc::dByte) { + } else if (value == vm->upcalls->OfByte) { val = (float)(sint32)vm->upcalls->byteValue->getInt8Field(obj); - } else if (value == AssessorDesc::dChar) { + } else if (value == vm->upcalls->OfChar) { val = (float)(uint32)vm->upcalls->charValue->getInt16Field(obj); - } else if (value == AssessorDesc::dShort) { + } else if (value == vm->upcalls->OfShort) { val = (float)(sint32)vm->upcalls->shortValue->getInt16Field(obj); - } else if (value == AssessorDesc::dInt) { + } else if (value == vm->upcalls->OfInt) { val = (float)(sint32)vm->upcalls->intValue->getInt32Field(obj); - } else if (value == AssessorDesc::dLong) { + } else if (value == vm->upcalls->OfLong) { val = (float)vm->upcalls->longValue->getLongField(obj); } else { vm->illegalArgumentException(""); @@ -333,21 +333,21 @@ ((float*)buf)[0] = val; buf++; return; - } else if (funcs == AssessorDesc::dDouble) { + } else if (prim->isDouble()) { double val = 0; - if (value == AssessorDesc::dDouble) { + if (value == vm->upcalls->OfDouble) { val = (double)vm->upcalls->doubleValue->getDoubleField(obj); - } else if (value == AssessorDesc::dFloat) { + } else if (value == vm->upcalls->OfFloat) { val = (double)vm->upcalls->floatValue->getFloatField(obj); - } else if (value == AssessorDesc::dByte) { + } else if (value == vm->upcalls->OfByte) { val = (double)(sint64)vm->upcalls->byteValue->getInt8Field(obj); - } else if (value == AssessorDesc::dChar) { + } else if (value == vm->upcalls->OfChar) { val = (double)(uint64)vm->upcalls->charValue->getInt16Field(obj); - } else if (value == AssessorDesc::dShort) { + } else if (value == vm->upcalls->OfShort) { val = (double)(sint16)vm->upcalls->shortValue->getInt16Field(obj); - } else if (value == AssessorDesc::dInt) { + } else if (value == vm->upcalls->OfInt) { val = (double)(sint32)vm->upcalls->intValue->getInt32Field(obj); - } else if (value == AssessorDesc::dLong) { + } else if (value == vm->upcalls->OfLong) { val = (double)(sint64)vm->upcalls->longValue->getLongField(obj); } else { vm->illegalArgumentException(""); @@ -355,17 +355,17 @@ ((double*)buf)[0] = val; buf += 2; return; - } else if (funcs == AssessorDesc::dLong) { + } else if (prim->isLong()) { sint64 val = 0; - if (value == AssessorDesc::dByte) { + if (value == vm->upcalls->OfByte) { val = (sint64)vm->upcalls->byteValue->getInt8Field(obj); - } else if (value == AssessorDesc::dChar) { + } else if (value == vm->upcalls->OfChar) { val = (sint64)(uint64)vm->upcalls->charValue->getInt16Field(obj); - } else if (value == AssessorDesc::dShort) { + } else if (value == vm->upcalls->OfShort) { val = (sint64)vm->upcalls->shortValue->getInt16Field(obj); - } else if (value == AssessorDesc::dInt) { + } else if (value == vm->upcalls->OfInt) { val = (sint64)vm->upcalls->intValue->getInt32Field(obj); - } else if (value == AssessorDesc::dLong) { + } else if (value == vm->upcalls->OfLong) { val = (sint64)vm->upcalls->intValue->getLongField(obj); } else { vm->illegalArgumentException(""); From nicolas.geoffray at lip6.fr Fri Sep 19 08:22:36 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Fri, 19 Sep 2008 15:22:36 -0000 Subject: [vmkit-commits] [vmkit] r56350 - in /vmkit/branches/isolate/lib/JnJVM: Classpath/Classpath.cpp Classpath/ClasspathVMClassLoader.cpp.inc VMCore/JavaClass.cpp VMCore/JavaClass.h VMCore/JavaConstantPool.cpp VMCore/JavaJITOpcodes.cpp VMCore/JavaRuntimeJIT.cpp VMCore/JavaTypes.cpp VMCore/JavaTypes.h VMCore/JavaUpcalls.h VMCore/Jni.cpp VMCore/Jnjvm.cpp VMCore/JnjvmClassLoader.cpp VMCore/JnjvmClassLoader.h VMCore/JnjvmModule.cpp VMCore/NativeUtil.cpp Message-ID: <200809191522.m8JFMaPU024231@zion.cs.uiuc.edu> Author: geoffray Date: Fri Sep 19 10:22:36 2008 New Revision: 56350 URL: http://llvm.org/viewvc/llvm-project?rev=56350&view=rev Log: Removal of the AssessorDesc class. Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp.inc vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/Classpath.cpp Fri Sep 19 10:22:36 2008 @@ -179,8 +179,8 @@ UserCommonClass* base = NativeUtil::resolvedImplClass(arrayType, true); JnjvmClassLoader* loader = base->classLoader; const UTF8* name = base->getName(); - const UTF8* arrayName = AssessorDesc::constructArrayName(loader, 1, name); - UserClassArray* array = loader->constructArray(arrayName); + const UTF8* arrayName = loader->constructArrayName(1, name); + UserClassArray* array = loader->constructArray(arrayName, base); ArrayObject* res = ArrayObject::acons(arrayLength, array, &(vm->allocator)); return (jobject) res; Modified: vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp.inc URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp.inc?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp.inc (original) +++ vmkit/branches/isolate/lib/JnJVM/Classpath/ClasspathVMClassLoader.cpp.inc Fri Sep 19 10:22:36 2008 @@ -33,7 +33,8 @@ jchar byteId) { Jnjvm* vm = JavaThread::get()->isolate; - UserClassPrimitive* prim = AssessorDesc::byteIdToPrimitive(byteId, vm->upcalls); + UserClassPrimitive* prim = + UserClassPrimitive::byteIdToPrimitive(byteId, vm->upcalls); if (!prim) vm->unknownError("unknown byte primitive %c", byteId); Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.cpp Fri Sep 19 10:22:36 2008 @@ -171,10 +171,10 @@ unsigned int end, mvm::PrintBuffer* buf) { uint16 first = name->elements[start]; - if (first == AssessorDesc::I_TAB) { + if (first == I_TAB) { unsigned int stepsEnd = start; - while (name->elements[stepsEnd] == AssessorDesc::I_TAB) stepsEnd++; - if (name->elements[stepsEnd] == AssessorDesc::I_REF) { + while (name->elements[stepsEnd] == I_TAB) stepsEnd++; + if (name->elements[stepsEnd] == I_REF) { printClassNameIntern(name, (stepsEnd + 1),(end - 1), buf); } else { name->print(buf); @@ -227,6 +227,33 @@ } } + +UserClassPrimitive* +ClassPrimitive::byteIdToPrimitive(char id, Classpath* upcalls) { + switch (id) { + case I_FLOAT : + return upcalls->OfFloat; + case I_INT : + return upcalls->OfInt; + case I_SHORT : + return upcalls->OfShort; + case I_CHAR : + return upcalls->OfChar; + case I_DOUBLE : + return upcalls->OfDouble; + case I_BYTE : + return upcalls->OfByte; + case I_BOOL : + return upcalls->OfBool; + case I_LONG : + return upcalls->OfLong; + case I_VOID : + return upcalls->OfVoid; + default : + return 0; + } +} + CommonClass::CommonClass(JnjvmClassLoader* loader, const UTF8* n, bool isArray) { name = n; @@ -475,7 +502,7 @@ uint32 len = Tname->size; bool res = true; - while (res && Tname->elements[prof] == AssessorDesc::I_TAB) { + while (res && Tname->elements[prof] == I_TAB) { UserCommonClass* cl = ((UserClassArray*)curS)->baseClass(); ++prof; cl->resolveClass(); @@ -483,7 +510,7 @@ curS = cl; } - return (Tname->elements[prof] == AssessorDesc::I_REF) && + return (Tname->elements[prof] == I_REF) && (res && curS->inheritName(Tname->extract(classLoader->hashUTF8, prof + 1, len - 1))); } else { Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaClass.h Fri Sep 19 10:22:36 2008 @@ -506,6 +506,9 @@ class ClassPrimitive : public CommonClass { public: ClassPrimitive(JnjvmClassLoader* loader, const UTF8* name, uint32 nb); + + static UserClassPrimitive* byteIdToPrimitive(char id, Classpath* upcalls); + }; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaConstantPool.cpp Fri Sep 19 10:22:36 2008 @@ -271,7 +271,7 @@ if (!temp) { JnjvmClassLoader* loader = classDef->classLoader; const UTF8* name = UTF8At(ctpDef[index]); - if (name->elements[0] == AssessorDesc::I_TAB) { + if (name->elements[0] == I_TAB) { temp = loader->constructArray(name); temp->resolveClass(); } else { Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJITOpcodes.cpp Fri Sep 19 10:22:36 2008 @@ -43,6 +43,28 @@ using namespace jnjvm; using namespace llvm; +uint8 arrayType(unsigned int t) { + if (t == JavaArray::T_CHAR) { + return I_CHAR; + } else if (t == JavaArray::T_BOOLEAN) { + return I_BOOL; + } else if (t == JavaArray::T_INT) { + return I_INT; + } else if (t == JavaArray::T_SHORT) { + return I_SHORT; + } else if (t == JavaArray::T_BYTE) { + return I_BYTE; + } else if (t == JavaArray::T_FLOAT) { + return I_FLOAT; + } else if (t == JavaArray::T_LONG) { + return I_LONG; + } else if (t == JavaArray::T_DOUBLE) { + return I_DOUBLE; + } else { + JavaThread::get()->isolate->unknownError("unknown array type %d\n", t); + return 0; + } +} static inline sint8 readS1(uint8* bytecode, uint32& i) { return ((sint8*)bytecode)[++i]; @@ -1815,7 +1837,7 @@ if (bytecodes[i] == NEWARRAY) { uint8 id = bytecodes[++i]; - uint8 charId = AssessorDesc::arrayType(id); + uint8 charId = arrayType(id); #ifndef MULTIPLE_VM dcl = JavaThread::get()->isolate->arrayClasses[id - 4]; #else @@ -1836,8 +1858,7 @@ compilingClass->ctpInfo->resolveClassName(index); JnjvmClassLoader* JCL = compilingClass->classLoader; - const UTF8* arrayName = - AssessorDesc::constructArrayName(JCL, 1, className); + const UTF8* arrayName = JCL->constructArrayName(1, className); dcl = JCL->constructArray(arrayName); #else Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaRuntimeJIT.cpp Fri Sep 19 10:22:36 2008 @@ -172,8 +172,7 @@ extern "C" UserClassArray* getArrayClass(UserCommonClass* cl) { JnjvmClassLoader* JCL = cl->classLoader; - const UTF8* arrayName = - AssessorDesc::constructArrayName(JCL, 1, cl->getName()); + const UTF8* arrayName = JCL->constructArrayName(1, cl->getName()); UserClassArray* dcl = JCL->constructArray(arrayName); return dcl; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.cpp Fri Sep 19 10:22:36 2008 @@ -23,21 +23,7 @@ using namespace jnjvm; -const char AssessorDesc::I_TAB = '['; -const char AssessorDesc::I_END_REF = ';'; -const char AssessorDesc::I_PARG = '('; -const char AssessorDesc::I_PARD = ')'; -const char AssessorDesc::I_BYTE = 'B'; -const char AssessorDesc::I_CHAR = 'C'; -const char AssessorDesc::I_DOUBLE = 'D'; -const char AssessorDesc::I_FLOAT = 'F'; -const char AssessorDesc::I_INT = 'I'; -const char AssessorDesc::I_LONG = 'J'; -const char AssessorDesc::I_REF = 'L'; -const char AssessorDesc::I_SHORT = 'S'; -const char AssessorDesc::I_VOID = 'V'; -const char AssessorDesc::I_BOOL = 'Z'; -const char AssessorDesc::I_SEP = '/'; + static void typeError(const UTF8* name, short int l) { if (l != 0) { @@ -50,9 +36,8 @@ } -bool AssessorDesc::analyseIntern(const UTF8* name, uint32 pos, - uint32 meth, - uint32& ret) { +static bool analyseIntern(const UTF8* name, uint32 pos, uint32 meth, + uint32& ret) { short int cur = name->elements[pos]; switch (cur) { case I_PARD : @@ -106,58 +91,6 @@ return false; } -const UTF8* AssessorDesc::constructArrayName(JnjvmClassLoader *loader, - uint32 steps, - const UTF8* className) { - uint32 len = className->size; - uint32 pos = steps; - bool isTab = (className->elements[0] == I_TAB ? true : false); - uint32 n = steps + len + (isTab ? 0 : 2); - uint16* buf = (uint16*)alloca(n * sizeof(uint16)); - - for (uint32 i = 0; i < steps; i++) { - buf[i] = I_TAB; - } - - if (!isTab) { - ++pos; - buf[steps] = I_REF; - } - - for (uint32 i = 0; i < len; i++) { - buf[pos + i] = className->elements[i]; - } - - if (!isTab) { - buf[n - 1] = I_END_REF; - } - - return loader->readerConstructUTF8(buf, n); -} - -uint8 AssessorDesc::arrayType(unsigned int t) { - if (t == JavaArray::T_CHAR) { - return I_CHAR; - } else if (t == JavaArray::T_BOOLEAN) { - return I_BOOL; - } else if (t == JavaArray::T_INT) { - return I_INT; - } else if (t == JavaArray::T_SHORT) { - return I_SHORT; - } else if (t == JavaArray::T_BYTE) { - return I_BYTE; - } else if (t == JavaArray::T_FLOAT) { - return I_FLOAT; - } else if (t == JavaArray::T_LONG) { - return I_LONG; - } else if (t == JavaArray::T_DOUBLE) { - return I_DOUBLE; - } else { - JavaThread::get()->isolate->unknownError("unknown array type %d\n", t); - return 0; - } -} - void PrimitiveTypedef::tPrintBuf(mvm::PrintBuffer* buf) const { prim->name->print(buf); } @@ -170,32 +103,6 @@ CommonClass::printClassName(pseudoAssocClassName, buf); } -UserClassPrimitive* -AssessorDesc::byteIdToPrimitive(char id, Classpath* upcalls) { - switch (id) { - case I_FLOAT : - return upcalls->OfFloat; - case I_INT : - return upcalls->OfInt; - case I_SHORT : - return upcalls->OfShort; - case I_CHAR : - return upcalls->OfChar; - case I_DOUBLE : - return upcalls->OfDouble; - case I_BYTE : - return upcalls->OfByte; - case I_BOOL : - return upcalls->OfBool; - case I_LONG : - return upcalls->OfLong; - case I_VOID : - return upcalls->OfVoid; - default : - return 0; - } -} - const char* Typedef::printString() const { mvm::PrintBuffer *buf= mvm::PrintBuffer::alloc(); buf->write("Type<"); @@ -253,7 +160,7 @@ while (pos < len) { pred = pos; - bool end = AssessorDesc::analyseIntern(name, pos, 0, pos); + bool end = analyseIntern(name, pos, 0, pos); if (end) break; else { buf.push_back(loader->constructType(name->extract(loader->hashUTF8, pred, pos))); @@ -264,7 +171,7 @@ typeError(name, 0); } - AssessorDesc::analyseIntern(name, pos, 0, pred); + analyseIntern(name, pos, 0, pred); if (pred != len) { typeError(name, 0); @@ -286,10 +193,10 @@ short int cur = name->elements[0]; Typedef* res = 0; switch (cur) { - case AssessorDesc::I_TAB : + case I_TAB : res = new ArrayTypedef(name); break; - case AssessorDesc::I_REF : + case I_REF : res = new ObjectTypedef(name, map); break; default : Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaTypes.h Fri Sep 19 10:22:36 2008 @@ -45,42 +45,21 @@ #define ARRAY_ID 10 #define NUM_ASSESSORS 11 -/// AssessorDesc - Helpful functions to analyse UTF8s and ids and get -/// either Typedefs or Classes. -/// -class AssessorDesc { -public: - static VirtualTable *VT; - static const char I_TAB; - static const char I_END_REF; - static const char I_PARG; - static const char I_PARD; - static const char I_BYTE; - static const char I_CHAR; - static const char I_DOUBLE; - static const char I_FLOAT; - static const char I_INT; - static const char I_LONG; - static const char I_REF; - static const char I_SHORT; - static const char I_VOID; - static const char I_BOOL; - static const char I_SEP; - - static bool analyseIntern(const UTF8* name, uint32 pos, - uint32 meth, - uint32& ret); - - static const UTF8* constructArrayName(JnjvmClassLoader* loader, - uint32 steps, const UTF8* className); - - static uint8 arrayType(unsigned int t); - - static UserClassPrimitive* byteIdToPrimitive(char id, Classpath* upcalls); - - -}; - +static const char I_TAB = '['; +static const char I_END_REF = ';'; +static const char I_PARG = '('; +static const char I_PARD = ')'; +static const char I_BYTE = 'B'; +static const char I_CHAR = 'C'; +static const char I_DOUBLE = 'D'; +static const char I_FLOAT = 'F'; +static const char I_INT = 'I'; +static const char I_LONG = 'J'; +static const char I_REF = 'L'; +static const char I_SHORT = 'S'; +static const char I_VOID = 'V'; +static const char I_BOOL = 'Z'; +static const char I_SEP = '/'; /// Typedef - Each class has a Typedef representation. A Typedef is also a class /// which has not been loaded yet. Typedefs are hashed on the name of the class. @@ -181,39 +160,39 @@ } bool isVoid() const { - return charId == AssessorDesc::I_VOID; + return charId == I_VOID; } bool isLong() const { - return charId == AssessorDesc::I_LONG; + return charId == I_LONG; } bool isInt() const { - return charId == AssessorDesc::I_INT; + return charId == I_INT; } bool isChar() const { - return charId == AssessorDesc::I_CHAR; + return charId == I_CHAR; } bool isShort() const { - return charId == AssessorDesc::I_SHORT; + return charId == I_SHORT; } bool isByte() const { - return charId == AssessorDesc::I_BYTE; + return charId == I_BYTE; } bool isBool() const { - return charId == AssessorDesc::I_BOOL; + return charId == I_BOOL; } bool isFloat() const { - return charId == AssessorDesc::I_FLOAT; + return charId == I_FLOAT; } bool isDouble() const { - return charId == AssessorDesc::I_DOUBLE; + return charId == I_DOUBLE; } /// JInfo - Holds info useful for the JIT. @@ -313,7 +292,7 @@ /// intptr_t _virtualCallAP; intptr_t virtualCallAP(); - + public: /// args - The arguments as Typedef of this signature. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaUpcalls.h Fri Sep 19 10:22:36 2008 @@ -12,29 +12,28 @@ #include "JnjvmConfig.h" -#define UPCALL_CLASS(vm, name) \ +#define UPCALL_CLASS(vm, name) \ vm->loadName(vm->asciizConstructUTF8(name), false, false) -#define UPCALL_PRIMITIVE_CLASS(loader, name, nb) \ +#define UPCALL_PRIMITIVE_CLASS(loader, name, nb) \ new UserClassPrimitive(loader, loader->asciizConstructUTF8(name), nb) -#define UPCALL_FIELD(vm, cl, name, type, acc) \ - UPCALL_CLASS(vm, cl)->constructField(vm->asciizConstructUTF8(name), \ +#define UPCALL_FIELD(vm, cl, name, type, acc) \ + UPCALL_CLASS(vm, cl)->constructField(vm->asciizConstructUTF8(name), \ vm->asciizConstructUTF8(type), acc) -#define UPCALL_METHOD(vm, cl, name, type, acc) \ - UPCALL_CLASS(vm, cl)->constructMethod(vm->asciizConstructUTF8(name), \ +#define UPCALL_METHOD(vm, cl, name, type, acc) \ + UPCALL_CLASS(vm, cl)->constructMethod(vm->asciizConstructUTF8(name), \ vm->asciizConstructUTF8(type), acc) -#define UPCALL_ARRAY_CLASS(vm, name, depth) \ - vm->constructArray( \ - AssessorDesc::constructArrayName(vm, depth, \ - vm->asciizConstructUTF8(name))) +#define UPCALL_ARRAY_CLASS(loader, name, depth) \ + loader->constructArray( \ + loader->constructArrayName(depth, loader->asciizConstructUTF8(name))) -#define UPCALL_CLASS_EXCEPTION(loader, name) \ +#define UPCALL_CLASS_EXCEPTION(loader, name) \ name = UPCALL_CLASS(loader, "java/lang/"#name) -#define UPCALL_REFLECT_CLASS_EXCEPTION(loader, name) \ +#define UPCALL_REFLECT_CLASS_EXCEPTION(loader, name) \ name = UPCALL_CLASS(loader, "java/lang/reflect/"#name) #define UPCALL_METHOD_EXCEPTION(loader, name) \ Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jni.cpp Fri Sep 19 10:22:36 2008 @@ -1746,7 +1746,7 @@ UserCommonClass* base = NativeUtil::resolvedImplClass(elementClass, true); JnjvmClassLoader* loader = base->classLoader; const UTF8* name = base->getName(); - const UTF8* arrayName = AssessorDesc::constructArrayName(loader, 1, name); + const UTF8* arrayName = loader->constructArrayName(1, name); UserClassArray* array = loader->constructArray(arrayName); ArrayObject* res = ArrayObject::acons(length, array, &(vm->allocator)); if (initialElement) { Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/Jnjvm.cpp Fri Sep 19 10:22:36 2008 @@ -865,15 +865,15 @@ isolate->arrayClasses[JavaArray::T_DOUBLE - 4] = isolate->upcalls->ArrayOfDouble; - isolate->primitiveMap[AssessorDesc::I_VOID] = isolate->upcalls->OfVoid; - isolate->primitiveMap[AssessorDesc::I_BOOL] = isolate->upcalls->OfBool; - isolate->primitiveMap[AssessorDesc::I_BYTE] = isolate->upcalls->OfByte; - isolate->primitiveMap[AssessorDesc::I_CHAR] = isolate->upcalls->OfChar; - isolate->primitiveMap[AssessorDesc::I_SHORT] = isolate->upcalls->OfShort; - isolate->primitiveMap[AssessorDesc::I_INT] = isolate->upcalls->OfInt; - isolate->primitiveMap[AssessorDesc::I_FLOAT] = isolate->upcalls->OfFloat; - isolate->primitiveMap[AssessorDesc::I_LONG] = isolate->upcalls->OfLong; - isolate->primitiveMap[AssessorDesc::I_DOUBLE] = isolate->upcalls->OfDouble; + isolate->primitiveMap[I_VOID] = isolate->upcalls->OfVoid; + isolate->primitiveMap[I_BOOL] = isolate->upcalls->OfBool; + isolate->primitiveMap[I_BYTE] = isolate->upcalls->OfByte; + isolate->primitiveMap[I_CHAR] = isolate->upcalls->OfChar; + isolate->primitiveMap[I_SHORT] = isolate->upcalls->OfShort; + isolate->primitiveMap[I_INT] = isolate->upcalls->OfInt; + isolate->primitiveMap[I_FLOAT] = isolate->upcalls->OfFloat; + isolate->primitiveMap[I_LONG] = isolate->upcalls->OfLong; + isolate->primitiveMap[I_DOUBLE] = isolate->upcalls->OfDouble; isolate->upcalls->initialiseClasspath(bootstrapLoader); return isolate; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Fri Sep 19 10:22:36 2008 @@ -190,7 +190,7 @@ if (len == 0) { return 0; - } else if (name->elements[0] == AssessorDesc::I_TAB) { + } else if (name->elements[0] == I_TAB) { while (doLoop) { --len; @@ -198,12 +198,12 @@ doLoop = false; } else { ++start; - if (name->elements[start] != AssessorDesc::I_TAB) { - if (name->elements[start] == AssessorDesc::I_REF) { + if (name->elements[start] != I_TAB) { + if (name->elements[start] == I_REF) { uint32 size = (uint32)name->size; if ((size == (start + 1)) || (size == (start + 2)) || - (name->elements[start + 1] == AssessorDesc::I_TAB) || - (utf8->elements[origLen - 1] != AssessorDesc::I_END_REF)) { + (name->elements[start + 1] == I_TAB) || + (utf8->elements[origLen - 1] != I_END_REF)) { doLoop = false; } else { const UTF8* componentName = utf8->javaToInternal(hashUTF8, @@ -219,10 +219,10 @@ } } else { uint16 cur = name->elements[start]; - if ((cur == AssessorDesc::I_BOOL || cur == AssessorDesc::I_BYTE || - cur == AssessorDesc::I_CHAR || cur == AssessorDesc::I_SHORT || - cur == AssessorDesc::I_INT || cur == AssessorDesc::I_FLOAT || - cur == AssessorDesc::I_DOUBLE || cur == AssessorDesc::I_LONG) + if ((cur == I_BOOL || cur == I_BYTE || + cur == I_CHAR || cur == I_SHORT || + cur == I_INT || cur == I_FLOAT || + cur == I_DOUBLE || cur == I_LONG) && ((uint32)name->size) == start + 1) { ret = constructArray(name); @@ -256,12 +256,12 @@ UserCommonClass* JnjvmClassLoader::loadBaseClass(const UTF8* name, uint32 start, uint32 len) { - if (name->elements[start] == AssessorDesc::I_TAB) { + if (name->elements[start] == I_TAB) { UserCommonClass* baseClass = loadBaseClass(name, start + 1, len - 1); JnjvmClassLoader* loader = baseClass->classLoader; const UTF8* arrayName = name->extract(loader->hashUTF8, start, start + len); return loader->constructArray(arrayName); - } else if (name->elements[start] == AssessorDesc::I_REF) { + } else if (name->elements[start] == I_REF) { const UTF8* componentName = name->extract(hashUTF8, start + 1, start + len - 1); UserCommonClass* cl = loadName(componentName, false, true); @@ -269,7 +269,7 @@ } else { Classpath* upcalls = bootstrapLoader->upcalls; UserClassPrimitive* prim = - AssessorDesc::byteIdToPrimitive(name->elements[start], upcalls); + UserClassPrimitive::byteIdToPrimitive(name->elements[start], upcalls); assert(prim && "No primitive found"); return prim; } @@ -432,3 +432,30 @@ } } +const UTF8* JnjvmClassLoader::constructArrayName(uint32 steps, + const UTF8* className) { + uint32 len = className->size; + uint32 pos = steps; + bool isTab = (className->elements[0] == I_TAB ? true : false); + uint32 n = steps + len + (isTab ? 0 : 2); + uint16* buf = (uint16*)alloca(n * sizeof(uint16)); + + for (uint32 i = 0; i < steps; i++) { + buf[i] = I_TAB; + } + + if (!isTab) { + ++pos; + buf[steps] = I_REF; + } + + for (uint32 i = 0; i < len; i++) { + buf[pos + i] = className->elements[i]; + } + + if (!isTab) { + buf[n - 1] = I_END_REF; + } + + return readerConstructUTF8(buf, n); +} Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.h Fri Sep 19 10:22:36 2008 @@ -210,7 +210,8 @@ #ifdef MULTIPLE_VM UserClass* loadClass; #endif - + + const UTF8* constructArrayName(uint32 steps, const UTF8* className); }; /// JnjvmBootstrapLoader - This class is for the bootstrap class loader, which Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Fri Sep 19 10:22:36 2008 @@ -1151,72 +1151,72 @@ setDataLayout(str); } void LLVMAssessorInfo::initialise() { - AssessorInfo[AssessorDesc::I_VOID].llvmType = Type::VoidTy; - AssessorInfo[AssessorDesc::I_VOID].llvmTypePtr = 0; - AssessorInfo[AssessorDesc::I_VOID].llvmNullConstant = 0; - AssessorInfo[AssessorDesc::I_VOID].sizeInBytesConstant = 0; - - AssessorInfo[AssessorDesc::I_BOOL].llvmType = Type::Int8Ty; - AssessorInfo[AssessorDesc::I_BOOL].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty); - AssessorInfo[AssessorDesc::I_BOOL].llvmNullConstant = + AssessorInfo[I_VOID].llvmType = Type::VoidTy; + AssessorInfo[I_VOID].llvmTypePtr = 0; + AssessorInfo[I_VOID].llvmNullConstant = 0; + AssessorInfo[I_VOID].sizeInBytesConstant = 0; + + AssessorInfo[I_BOOL].llvmType = Type::Int8Ty; + AssessorInfo[I_BOOL].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty); + AssessorInfo[I_BOOL].llvmNullConstant = Constant::getNullValue(Type::Int8Ty); - AssessorInfo[AssessorDesc::I_BOOL].sizeInBytesConstant = mvm::jit::constantOne; + AssessorInfo[I_BOOL].sizeInBytesConstant = mvm::jit::constantOne; - AssessorInfo[AssessorDesc::I_BYTE].llvmType = Type::Int8Ty; - AssessorInfo[AssessorDesc::I_BYTE].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty); - AssessorInfo[AssessorDesc::I_BYTE].llvmNullConstant = + AssessorInfo[I_BYTE].llvmType = Type::Int8Ty; + AssessorInfo[I_BYTE].llvmTypePtr = PointerType::getUnqual(Type::Int8Ty); + AssessorInfo[I_BYTE].llvmNullConstant = Constant::getNullValue(Type::Int8Ty); - AssessorInfo[AssessorDesc::I_BYTE].sizeInBytesConstant = mvm::jit::constantOne; + AssessorInfo[I_BYTE].sizeInBytesConstant = mvm::jit::constantOne; - AssessorInfo[AssessorDesc::I_SHORT].llvmType = Type::Int16Ty; - AssessorInfo[AssessorDesc::I_SHORT].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty); - AssessorInfo[AssessorDesc::I_SHORT].llvmNullConstant = + AssessorInfo[I_SHORT].llvmType = Type::Int16Ty; + AssessorInfo[I_SHORT].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty); + AssessorInfo[I_SHORT].llvmNullConstant = Constant::getNullValue(Type::Int16Ty); - AssessorInfo[AssessorDesc::I_SHORT].sizeInBytesConstant = mvm::jit::constantTwo; + AssessorInfo[I_SHORT].sizeInBytesConstant = mvm::jit::constantTwo; - AssessorInfo[AssessorDesc::I_CHAR].llvmType = Type::Int16Ty; - AssessorInfo[AssessorDesc::I_CHAR].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty); - AssessorInfo[AssessorDesc::I_CHAR].llvmNullConstant = + AssessorInfo[I_CHAR].llvmType = Type::Int16Ty; + AssessorInfo[I_CHAR].llvmTypePtr = PointerType::getUnqual(Type::Int16Ty); + AssessorInfo[I_CHAR].llvmNullConstant = Constant::getNullValue(Type::Int16Ty); - AssessorInfo[AssessorDesc::I_CHAR].sizeInBytesConstant = mvm::jit::constantTwo; + AssessorInfo[I_CHAR].sizeInBytesConstant = mvm::jit::constantTwo; - AssessorInfo[AssessorDesc::I_INT].llvmType = Type::Int32Ty; - AssessorInfo[AssessorDesc::I_INT].llvmTypePtr = PointerType::getUnqual(Type::Int32Ty); - AssessorInfo[AssessorDesc::I_INT].llvmNullConstant = + AssessorInfo[I_INT].llvmType = Type::Int32Ty; + AssessorInfo[I_INT].llvmTypePtr = PointerType::getUnqual(Type::Int32Ty); + AssessorInfo[I_INT].llvmNullConstant = Constant::getNullValue(Type::Int32Ty); - AssessorInfo[AssessorDesc::I_INT].sizeInBytesConstant = mvm::jit::constantFour; + AssessorInfo[I_INT].sizeInBytesConstant = mvm::jit::constantFour; - AssessorInfo[AssessorDesc::I_FLOAT].llvmType = Type::FloatTy; - AssessorInfo[AssessorDesc::I_FLOAT].llvmTypePtr = PointerType::getUnqual(Type::FloatTy); - AssessorInfo[AssessorDesc::I_FLOAT].llvmNullConstant = + AssessorInfo[I_FLOAT].llvmType = Type::FloatTy; + AssessorInfo[I_FLOAT].llvmTypePtr = PointerType::getUnqual(Type::FloatTy); + AssessorInfo[I_FLOAT].llvmNullConstant = Constant::getNullValue(Type::FloatTy); - AssessorInfo[AssessorDesc::I_FLOAT].sizeInBytesConstant = mvm::jit::constantFour; + AssessorInfo[I_FLOAT].sizeInBytesConstant = mvm::jit::constantFour; - AssessorInfo[AssessorDesc::I_LONG].llvmType = Type::Int64Ty; - AssessorInfo[AssessorDesc::I_LONG].llvmTypePtr = PointerType::getUnqual(Type::Int64Ty); - AssessorInfo[AssessorDesc::I_LONG].llvmNullConstant = + AssessorInfo[I_LONG].llvmType = Type::Int64Ty; + AssessorInfo[I_LONG].llvmTypePtr = PointerType::getUnqual(Type::Int64Ty); + AssessorInfo[I_LONG].llvmNullConstant = Constant::getNullValue(Type::Int64Ty); - AssessorInfo[AssessorDesc::I_LONG].sizeInBytesConstant = mvm::jit::constantEight; + AssessorInfo[I_LONG].sizeInBytesConstant = mvm::jit::constantEight; - AssessorInfo[AssessorDesc::I_DOUBLE].llvmType = Type::DoubleTy; - AssessorInfo[AssessorDesc::I_DOUBLE].llvmTypePtr = PointerType::getUnqual(Type::DoubleTy); - AssessorInfo[AssessorDesc::I_DOUBLE].llvmNullConstant = + AssessorInfo[I_DOUBLE].llvmType = Type::DoubleTy; + AssessorInfo[I_DOUBLE].llvmTypePtr = PointerType::getUnqual(Type::DoubleTy); + AssessorInfo[I_DOUBLE].llvmNullConstant = Constant::getNullValue(Type::DoubleTy); - AssessorInfo[AssessorDesc::I_DOUBLE].sizeInBytesConstant = mvm::jit::constantEight; + AssessorInfo[I_DOUBLE].sizeInBytesConstant = mvm::jit::constantEight; - AssessorInfo[AssessorDesc::I_TAB].llvmType = JnjvmModule::JavaObjectType; - AssessorInfo[AssessorDesc::I_TAB].llvmTypePtr = + AssessorInfo[I_TAB].llvmType = JnjvmModule::JavaObjectType; + AssessorInfo[I_TAB].llvmTypePtr = PointerType::getUnqual(JnjvmModule::JavaObjectType); - AssessorInfo[AssessorDesc::I_TAB].llvmNullConstant = + AssessorInfo[I_TAB].llvmNullConstant = JnjvmModule::JavaObjectNullConstant; - AssessorInfo[AssessorDesc::I_TAB].sizeInBytesConstant = mvm::jit::constantPtrSize; + AssessorInfo[I_TAB].sizeInBytesConstant = mvm::jit::constantPtrSize; - AssessorInfo[AssessorDesc::I_REF].llvmType = JnjvmModule::JavaObjectType; - AssessorInfo[AssessorDesc::I_REF].llvmTypePtr = + AssessorInfo[I_REF].llvmType = JnjvmModule::JavaObjectType; + AssessorInfo[I_REF].llvmTypePtr = PointerType::getUnqual(JnjvmModule::JavaObjectType); - AssessorInfo[AssessorDesc::I_REF].llvmNullConstant = + AssessorInfo[I_REF].llvmNullConstant = JnjvmModule::JavaObjectNullConstant; - AssessorInfo[AssessorDesc::I_REF].sizeInBytesConstant = mvm::jit::constantPtrSize; + AssessorInfo[I_REF].sizeInBytesConstant = mvm::jit::constantPtrSize; } std::map LLVMAssessorInfo::AssessorInfo; Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp?rev=56350&r1=56349&r2=56350&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp Fri Sep 19 10:22:36 2008 @@ -151,7 +151,7 @@ sint32 i = 0; while (i < jniConsType->size) { char c = jniConsType->elements[i++]; - if (c == AssessorDesc::I_PARG) { + if (c == I_PARG) { ptr[0] = '_'; ptr[1] = '_'; ptr += 2; @@ -162,15 +162,15 @@ ptr[0] = '_'; ptr[1] = '1'; ptr += 2; - } else if (c == AssessorDesc::I_END_REF) { + } else if (c == I_END_REF) { ptr[0] = '_'; ptr[1] = '2'; ptr += 2; - } else if (c == AssessorDesc::I_TAB) { + } else if (c == I_TAB) { ptr[0] = '_'; ptr[1] = '3'; ptr += 2; - } else if (c == AssessorDesc::I_PARD) { + } else if (c == I_PARD) { break; } else { ptr[0] = c; From nicolas.geoffray at lip6.fr Mon Sep 22 07:45:02 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 22 Sep 2008 14:45:02 -0000 Subject: [vmkit-commits] [vmkit] r56434 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Message-ID: <200809221445.m8MEj2pX003167@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 22 09:45:01 2008 New Revision: 56434 URL: http://llvm.org/viewvc/llvm-project?rev=56434&view=rev Log: Delete generated LLVM instructions after jitting. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp?rev=56434&r1=56433&r2=56434&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModuleProvider.cpp Mon Sep 22 09:45:01 2008 @@ -118,7 +118,7 @@ void* res = mvm::jit::executionEngine->getPointerToGlobal(func); mvm::Code* m = mvm::jit::getCodeFromPointer(res); if (m) m->setMetaInfo(meth); - + func->deleteBody(); /* if (meth->name->equals( JavaThread::get()->isolate->bootstrapLoader->asciizConstructUTF8("getDeclaredConstructors"))) { From nicolas.geoffray at lip6.fr Mon Sep 22 07:46:29 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 22 Sep 2008 14:46:29 -0000 Subject: [vmkit-commits] [vmkit] r56435 - /vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp Message-ID: <200809221446.m8MEkTIQ003328@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 22 09:46:29 2008 New Revision: 56435 URL: http://llvm.org/viewvc/llvm-project?rev=56435&view=rev Log: Use alloca in the top-level function, instead of mallocs in the called functions. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp?rev=56435&r1=56434&r2=56435&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/NativeUtil.cpp Mon Sep 22 09:46:29 2008 @@ -38,15 +38,12 @@ #define PRE "Java_" #define PRE_LEN 5 -static char* jniConsFromMeth(CommonClass* cl, JavaMethod* meth) { +static char* jniConsFromMeth(CommonClass* cl, JavaMethod* meth, char* buf) { const UTF8* jniConsClName = cl->name; const UTF8* jniConsName = meth->name; - const UTF8* jniConsType = meth->type; sint32 clen = jniConsClName->size; sint32 mnlen = jniConsName->size; - sint32 mtlen = jniConsType->size; - char* buf = (char*)malloc(3 + PRE_LEN + mnlen + clen + (mtlen << 1)); uint32 cur = 0; char* ptr = &(buf[PRE_LEN]); @@ -75,15 +72,12 @@ } -static char* jniConsFromMeth2(CommonClass* cl, JavaMethod* meth) { +static char* jniConsFromMeth2(CommonClass* cl, JavaMethod* meth, char* buf) { const UTF8* jniConsClName = cl->name; const UTF8* jniConsName = meth->name; - const UTF8* jniConsType = meth->type; sint32 clen = jniConsClName->size; sint32 mnlen = jniConsName->size; - sint32 mtlen = jniConsType->size; - char* buf = (char*)malloc(3 + PRE_LEN + mnlen + clen + (mtlen << 1)); uint32 cur = 0; char* ptr = &(buf[PRE_LEN]); @@ -117,15 +111,13 @@ } -static char* jniConsFromMeth3(CommonClass* cl, JavaMethod* meth) { +static char* jniConsFromMeth3(CommonClass* cl, JavaMethod* meth, char* buf) { const UTF8* jniConsClName = cl->name; const UTF8* jniConsName = meth->name; const UTF8* jniConsType = meth->type; sint32 clen = jniConsClName->size; sint32 mnlen = jniConsName->size; - sint32 mtlen = jniConsType->size; - char* buf = (char*)malloc(3 + PRE_LEN + mnlen + clen + (mtlen << 1)); uint32 cur = 0; char* ptr = &(buf[PRE_LEN]); @@ -183,7 +175,6 @@ return buf; } -#undef PRE_LEN static void* loadName(char* buf, bool& jnjvm) { void* res = dlsym(SELF_HANDLE, buf); @@ -205,13 +196,21 @@ } void* NativeUtil::nativeLookup(CommonClass* cl, JavaMethod* meth, bool& jnjvm) { - char* buf = jniConsFromMeth(cl, meth); + const UTF8* jniConsClName = cl->name; + const UTF8* jniConsName = meth->name; + const UTF8* jniConsType = meth->type; + sint32 clen = jniConsClName->size; + sint32 mnlen = jniConsName->size; + sint32 mtlen = jniConsType->size; + + char* buf = (char*)alloca(3 + PRE_LEN + mnlen + clen + (mtlen << 1)); + jniConsFromMeth(cl, meth, buf); void* res = loadName(buf, jnjvm); if (!res) { - buf = jniConsFromMeth2(cl, meth); + buf = jniConsFromMeth2(cl, meth, buf); res = loadName(buf, jnjvm); if (!res) { - buf = jniConsFromMeth3(cl, meth); + buf = jniConsFromMeth3(cl, meth, buf); res = loadName(buf, jnjvm); if (!res) { printf("Native function %s not found. Probably " @@ -222,10 +221,11 @@ } } } - free(buf); return res; } +#undef PRE_LEN + UserCommonClass* NativeUtil::resolvedImplClass(jclass clazz, bool doClinit) { Jnjvm* vm = JavaThread::get()->isolate; JavaObject *Cl = (JavaObject*)clazz; From nicolas.geoffray at lip6.fr Mon Sep 22 07:50:20 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Mon, 22 Sep 2008 14:50:20 -0000 Subject: [vmkit-commits] [vmkit] r56437 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Message-ID: <200809221450.m8MEoKje003873@zion.cs.uiuc.edu> Author: geoffray Date: Mon Sep 22 09:50:20 2008 New Revision: 56437 URL: http://llvm.org/viewvc/llvm-project?rev=56437&view=rev Log: Alloca rp instead of malloc+free. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp?rev=56437&r1=56436&r2=56437&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmClassLoader.cpp Mon Sep 22 09:50:20 2008 @@ -397,7 +397,7 @@ if (top != 0) { memcpy(buf, cur, top); buf[top] = 0; - char* rp = (char*)malloc(PATH_MAX); + char* rp = (char*)alloca(PATH_MAX); memset(rp, 0, PATH_MAX); rp = realpath(buf, rp); if (rp[PATH_MAX - 1] == 0 && strlen(rp) != 0) { @@ -410,11 +410,9 @@ temp[len] = Jnjvm::dirSeparator[0]; temp[len + 1] = 0; bootClasspath.push_back(temp); - free(rp); } else { ArrayUInt8* bytes = Reader::openFile(this, rp); - free(rp); if (bytes) { ZipArchive *archive = new ZipArchive(bytes); if (archive) { @@ -422,9 +420,7 @@ } } } - } else { - free(rp); - } + } } cur = cur + top + 1; top = 0; From nicolas.geoffray at lip6.fr Tue Sep 23 09:06:01 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 23 Sep 2008 16:06:01 -0000 Subject: [vmkit-commits] [vmkit] r56488 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Message-ID: <200809231606.m8NG62aX016962@zion.cs.uiuc.edu> Author: geoffray Date: Tue Sep 23 11:06:00 2008 New Revision: 56488 URL: http://llvm.org/viewvc/llvm-project?rev=56488&view=rev Log: Bugfix for inline compile and native compile. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp?rev=56488&r1=56487&r2=56488&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaJIT.cpp Tue Sep 23 11:06:00 2008 @@ -267,7 +267,7 @@ currentBlock); if (returnType != Type::VoidTy) - llvm::ReturnInst::Create(result, currentBlock); + llvm::ReturnInst::Create(endNode, currentBlock); else llvm::ReturnInst::Create(currentBlock); @@ -523,8 +523,7 @@ Function* func = LMI->getMethod(); llvmFunction = parentFunction; - const FunctionType *funcType = func->getFunctionType(); - returnType = funcType->getReturnType(); + returnType = func->getReturnType(); endBlock = createBasicBlock("end"); llvmFunction = parentFunction; @@ -555,10 +554,10 @@ #endif std::vector::iterator type = compilingMethod->getSignature()->args.begin(); - Function::arg_iterator i = func->arg_begin(); + std::vector::iterator i = args.begin(); if (isVirtual(compilingMethod->access)) { - new StoreInst(i, objectLocals[0], false, currentBlock); + new StoreInst(*i, objectLocals[0], false, currentBlock); ++i; ++index; ++count; @@ -568,26 +567,26 @@ for (;count < max; ++i, ++index, ++count, ++type) { const Typedef* cur = *type; - const Type* curType = i->getType(); + const Type* curType = (*i)->getType(); if (curType == Type::Int64Ty){ - new StoreInst(i, longLocals[index], false, currentBlock); + new StoreInst(*i, longLocals[index], false, currentBlock); ++index; } else if (cur->isUnsigned()) { - new StoreInst(new ZExtInst(i, Type::Int32Ty, "", currentBlock), + new StoreInst(new ZExtInst(*i, Type::Int32Ty, "", currentBlock), intLocals[index], false, currentBlock); } else if (curType == Type::Int8Ty || curType == Type::Int16Ty) { - new StoreInst(new SExtInst(i, Type::Int32Ty, "", currentBlock), + new StoreInst(new SExtInst(*i, Type::Int32Ty, "", currentBlock), intLocals[index], false, currentBlock); } else if (curType == Type::Int32Ty) { - new StoreInst(i, intLocals[index], false, currentBlock); + new StoreInst(*i, intLocals[index], false, currentBlock); } else if (curType == Type::DoubleTy) { - new StoreInst(i, doubleLocals[index], false, currentBlock); + new StoreInst(*i, doubleLocals[index], false, currentBlock); ++index; } else if (curType == Type::FloatTy) { - new StoreInst(i, floatLocals[index], false, currentBlock); + new StoreInst(*i, floatLocals[index], false, currentBlock); } else { - new StoreInst(i, objectLocals[index], false, currentBlock); + new StoreInst(*i, objectLocals[index], false, currentBlock); } } From nicolas.geoffray at lip6.fr Tue Sep 23 09:07:39 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 23 Sep 2008 16:07:39 -0000 Subject: [vmkit-commits] [vmkit] r56489 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Message-ID: <200809231607.m8NG7dkg017048@zion.cs.uiuc.edu> Author: geoffray Date: Tue Sep 23 11:07:38 2008 New Revision: 56489 URL: http://llvm.org/viewvc/llvm-project?rev=56489&view=rev Log: Always delete the body of llvm functions. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=56489&r1=56488&r2=56489&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Tue Sep 23 11:07:38 2008 @@ -357,6 +357,8 @@ void* codePtr = mvm::jit::executionEngine->getPointerToGlobal(func); ((void**)res)[VT_TRACER_OFFSET] = codePtr; + func->deleteBody(); + if (!stat) { LCI->virtualTracerFunction = func; } else { @@ -812,6 +814,7 @@ virtualBufFunction = createFunctionCallBuf(true); signature->setVirtualCallBuf((intptr_t) mvm::jit::executionEngine->getPointerToGlobal(virtualBufFunction)); + virtualBufFunction->deleteBody(); } return virtualBufFunction; } @@ -823,6 +826,7 @@ virtualAPFunction = createFunctionCallAP(true); signature->setVirtualCallAP((intptr_t) mvm::jit::executionEngine->getPointerToGlobal(virtualAPFunction)); + virtualAPFunction->deleteBody(); } return virtualAPFunction; } @@ -834,6 +838,7 @@ staticBufFunction = createFunctionCallBuf(false); signature->setStaticCallBuf((intptr_t) mvm::jit::executionEngine->getPointerToGlobal(staticBufFunction)); + staticBufFunction->deleteBody(); } return staticBufFunction; } @@ -845,6 +850,7 @@ staticAPFunction = createFunctionCallAP(false); signature->setStaticCallAP((intptr_t) mvm::jit::executionEngine->getPointerToGlobal(staticAPFunction)); + staticAPFunction->deleteBody(); } return staticAPFunction; } From nicolas.geoffray at lip6.fr Tue Sep 23 09:13:36 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 23 Sep 2008 16:13:36 -0000 Subject: [vmkit-commits] [vmkit] r56490 - /vmkit/branches/isolate/lib/Mvm/Runtime/LLVMRuntime.ll Message-ID: <200809231613.m8NGDac3017302@zion.cs.uiuc.edu> Author: geoffray Date: Tue Sep 23 11:13:36 2008 New Revision: 56490 URL: http://llvm.org/viewvc/llvm-project?rev=56490&view=rev Log: Fix signature of selectors. Modified: vmkit/branches/isolate/lib/Mvm/Runtime/LLVMRuntime.ll Modified: vmkit/branches/isolate/lib/Mvm/Runtime/LLVMRuntime.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/Mvm/Runtime/LLVMRuntime.ll?rev=56490&r1=56489&r2=56490&view=diff ============================================================================== --- vmkit/branches/isolate/lib/Mvm/Runtime/LLVMRuntime.ll (original) +++ vmkit/branches/isolate/lib/Mvm/Runtime/LLVMRuntime.ll Tue Sep 23 11:13:36 2008 @@ -14,8 +14,8 @@ declare void @_Unwind_Resume_or_Rethrow(i8*) declare i8* @llvm.eh.exception() -declare i32 @llvm.eh.selector.i32(i8*, i8*, i8*, ...) -declare i64 @llvm.eh.selector.i64(i8*, i8*, i8*, ...) +declare i32 @llvm.eh.selector.i32(i8*, i8*, ...) +declare i64 @llvm.eh.selector.i64(i8*, i8*, ...) declare void @__gxx_personality_v0() declare i8* @__cxa_begin_catch(i8*) declare void @__cxa_end_catch() From nicolas.geoffray at lip6.fr Tue Sep 30 07:21:30 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 30 Sep 2008 14:21:30 -0000 Subject: [vmkit-commits] [vmkit] r56839 - /vmkit/branches/isolate/lib/Mvm/Runtime/JIT.cpp Message-ID: <200809301421.m8UELVJO023184@zion.cs.uiuc.edu> Author: geoffray Date: Tue Sep 30 09:21:29 2008 New Revision: 56839 URL: http://llvm.org/viewvc/llvm-project?rev=56839&view=rev Log: Also verify that the next value in the call stack is below the current address. Modified: vmkit/branches/isolate/lib/Mvm/Runtime/JIT.cpp Modified: vmkit/branches/isolate/lib/Mvm/Runtime/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/Mvm/Runtime/JIT.cpp?rev=56839&r1=56838&r2=56839&view=diff ============================================================================== --- vmkit/branches/isolate/lib/Mvm/Runtime/JIT.cpp (original) +++ vmkit/branches/isolate/lib/Mvm/Runtime/JIT.cpp Tue Sep 30 09:21:29 2008 @@ -315,12 +315,12 @@ #endif int mvm::jit::getBacktrace(void** stack, int size) { - void** blah = (void**)__builtin_frame_address(1); + void** addr = (void**)__builtin_frame_address(1); int cpt = 0; void* baseSP = mvm::Thread::get()->baseSP; - while (blah && cpt < size && blah < baseSP) { - stack[cpt++] = (void**)FRAME_IP(blah); - blah = (void**)blah[0]; + while (addr && cpt < size && addr < baseSP && addr < addr[0]) { + stack[cpt++] = (void**)FRAME_IP(addr); + addr = (void**)addr[0]; } return cpt; } From nicolas.geoffray at lip6.fr Tue Sep 30 07:24:08 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 30 Sep 2008 14:24:08 -0000 Subject: [vmkit-commits] [vmkit] r56840 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Message-ID: <200809301424.m8UEO8MC023339@zion.cs.uiuc.edu> Author: geoffray Date: Tue Sep 30 09:24:07 2008 New Revision: 56840 URL: http://llvm.org/viewvc/llvm-project?rev=56840&view=rev Log: Remove dead include. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp?rev=56840&r1=56839&r2=56840&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JnjvmModule.cpp Tue Sep 30 09:24:07 2008 @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// #include "llvm/CallingConv.h" -#include "llvm/ParameterAttributes.h" #include "llvm/Support/MutexGuard.h" From nicolas.geoffray at lip6.fr Tue Sep 30 07:25:24 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 30 Sep 2008 14:25:24 -0000 Subject: [vmkit-commits] [vmkit] r56841 - /vmkit/branches/isolate/lib/JnJVM/VMCore/JavaArray.cpp Message-ID: <200809301425.m8UEPOrN023417@zion.cs.uiuc.edu> Author: geoffray Date: Tue Sep 30 09:25:24 2008 New Revision: 56841 URL: http://llvm.org/viewvc/llvm-project?rev=56841&view=rev Log: Do not malloc but use GC-allocated memory to print an UTF8. Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaArray.cpp Modified: vmkit/branches/isolate/lib/JnJVM/VMCore/JavaArray.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/JnJVM/VMCore/JavaArray.cpp?rev=56841&r1=56840&r2=56841&view=diff ============================================================================== --- vmkit/branches/isolate/lib/JnJVM/VMCore/JavaArray.cpp (original) +++ vmkit/branches/isolate/lib/JnJVM/VMCore/JavaArray.cpp Tue Sep 30 09:25:24 2008 @@ -112,18 +112,12 @@ } char* UTF8::UTF8ToAsciiz() const { - /*mvm::NativeString* buf = mvm::NativeString::alloc(size + 1); + mvm::NativeString* buf = mvm::NativeString::alloc(size + 1); for (sint32 i = 0; i < size; ++i) { buf->setAt(i, elements[i]); } buf->setAt(size, 0); - return buf->cString();*/ - char* buf = (char*)malloc(size + 1); - for (sint32 i = 0; i < size; ++i) { - buf[i] = elements[i]; - } - buf[size] = 0; - return buf; + return buf->cString(); } /// Currently, this uses malloc/free. This should use a custom memory pool. @@ -135,6 +129,7 @@ free(obj); } + const UTF8* UTF8::acons(sint32 n, UserClassArray* cl, JavaAllocator* allocator) { if (n < 0) From nicolas.geoffray at lip6.fr Tue Sep 30 09:06:06 2008 From: nicolas.geoffray at lip6.fr (Nicolas Geoffray) Date: Tue, 30 Sep 2008 16:06:06 -0000 Subject: [vmkit-commits] [vmkit] r56850 - in /vmkit/branches/isolate/lib/N3: LLVMRuntime/ LLVMRuntime/Makefile LLVMRuntime/runtime.ll Makefile VMCore/CLIJit.cpp VMCore/CLIRuntimeJIT.cpp VMCore/CLISignature.cpp VMCore/Makefile VMCore/VMCache.cpp VMCore/VMClass.cpp VMCore/VMClass.h VMCore/VirtualTables.cpp Message-ID: <200809301606.m8UG665M026998@zion.cs.uiuc.edu> Author: geoffray Date: Tue Sep 30 11:06:06 2008 New Revision: 56850 URL: http://llvm.org/viewvc/llvm-project?rev=56850&view=rev Log: Declare runtime functions for LLVM in LLVM format. Added: vmkit/branches/isolate/lib/N3/LLVMRuntime/ vmkit/branches/isolate/lib/N3/LLVMRuntime/Makefile vmkit/branches/isolate/lib/N3/LLVMRuntime/runtime.ll vmkit/branches/isolate/lib/N3/VMCore/CLIRuntimeJIT.cpp Modified: vmkit/branches/isolate/lib/N3/Makefile vmkit/branches/isolate/lib/N3/VMCore/CLIJit.cpp vmkit/branches/isolate/lib/N3/VMCore/CLISignature.cpp vmkit/branches/isolate/lib/N3/VMCore/Makefile vmkit/branches/isolate/lib/N3/VMCore/VMCache.cpp vmkit/branches/isolate/lib/N3/VMCore/VMClass.cpp vmkit/branches/isolate/lib/N3/VMCore/VMClass.h vmkit/branches/isolate/lib/N3/VMCore/VirtualTables.cpp Added: vmkit/branches/isolate/lib/N3/LLVMRuntime/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/N3/LLVMRuntime/Makefile?rev=56850&view=auto ============================================================================== --- vmkit/branches/isolate/lib/N3/LLVMRuntime/Makefile (added) +++ vmkit/branches/isolate/lib/N3/LLVMRuntime/Makefile Tue Sep 30 11:06:06 2008 @@ -0,0 +1,16 @@ +##===- lib/N3/LLVMRuntime/Makefile -------------------------*- Makefile -*-===## +# +# The vmkit project +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +LEVEL = ../../.. + +include $(LEVEL)/Makefile.config + +VMKIT_RUNTIME = runtime.ll +BUILT_SOURCES = LLVMRuntime.inc + +include $(LEVEL)/Makefile.common Added: vmkit/branches/isolate/lib/N3/LLVMRuntime/runtime.ll URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/N3/LLVMRuntime/runtime.ll?rev=56850&view=auto ============================================================================== --- vmkit/branches/isolate/lib/N3/LLVMRuntime/runtime.ll (added) +++ vmkit/branches/isolate/lib/N3/LLVMRuntime/runtime.ll Tue Sep 30 11:06:06 2008 @@ -0,0 +1,53 @@ +%CLIObject = type {i8*, i8*, i8*} + +;;; Types for CLI arrays. A size of 0 means an undefined size. +%CLIArray = type { %CLIObject, i32 } +%ArrayDouble = type { %CLIObject, i32, [0 x double] } +%ArrayFloat = type { %CLIObject, i32, [0 x float] } +%ArrayLong = type { %CLIObject, i32, [0 x i64] } +%ArrayObject = type { %CLIObject, i32, [0 x %CLIObject*] } +%ArraySInt16 = type { %CLIObject, i32, [0 x i16] } +%ArraySInt32 = type { %CLIObject, i32, [0 x i32] } +%ArraySInt8 = type { %CLIObject, i32, [0 x i8] } +%ArrayUInt16 = type { %CLIObject, i32, [0 x i16] } +%ArrayUInt32 = type { %CLIObject, i32, [0 x i32] } +%ArrayUInt8 = type { %CLIObject, i32, [0 x i8] } + +%CacheNode = type {i8*, i8*, i8*, i8*, i8*, i1} + +%Enveloppe = type {i8*, %CacheNode*, i8*, i8*} + +declare void @MarkAndTrace(%CLIObject*) +declare void @CLIObjectTracer(%CLIObject*) + +declare %CLIObject* @initialiseClass(i8*) + +declare %CacheNode* @n3VirtualLookup(%CacheNode*, %CLIObject*) + +declare %CLIObject* @newArray(i8*, i32) +declare %CLIObject* @newObject(i8*) +declare %CLIObject* @newMultiArray(i8*) +declare %CLIObject* @newString(i8*) + +declare %CLIObject* @initialiseObject(i8*, i32) readnone + +declare i32 @arrayLength(%CLIArray*) readnone + +declare void @n3NullPointerException() +declare void @n3ClassCastException() +declare void @indexOutOfBounds(%CLIObject*, i32) + +declare void @ThrowException(%CLIObject*) +declare void @ClearException() +declare i8* @GetCppException() +declare %CLIObject* @GetCLIException() +declare i1 @CompareException(i8*) + +declare i32 @n3InstanceOf(%CLIObject*, i8*) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Debugging methods ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +declare void @printExecution(i32, i32) + Modified: vmkit/branches/isolate/lib/N3/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/N3/Makefile?rev=56850&r1=56849&r2=56850&view=diff ============================================================================== --- vmkit/branches/isolate/lib/N3/Makefile (original) +++ vmkit/branches/isolate/lib/N3/Makefile Tue Sep 30 11:06:06 2008 @@ -10,7 +10,7 @@ include $(LEVEL)/Makefile.config -DIRS = VMCore +DIRS = LLVMRuntime VMCore ifeq ($(WITH_N3_MONO), 1) DIRS += Mono Modified: vmkit/branches/isolate/lib/N3/VMCore/CLIJit.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/N3/VMCore/CLIJit.cpp?rev=56850&r1=56849&r2=56850&view=diff ============================================================================== --- vmkit/branches/isolate/lib/N3/VMCore/CLIJit.cpp (original) +++ vmkit/branches/isolate/lib/N3/VMCore/CLIJit.cpp Tue Sep 30 11:06:06 2008 @@ -14,6 +14,7 @@ #include "debug.h" #include "types.h" +#include "llvm/CallingConv.h" #include #include #include @@ -1497,33 +1498,6 @@ } -extern "C" VMObject* initialiseClass(VMClass* cl) { - cl->clinitClass(NULL); - return cl->staticInstance; -} - -extern "C" void n3ClassCastException() { - fflush(stdout); - assert(0 && "implement class cast exception"); -} - -extern "C" void n3NullPointerException() { - fflush(stdout); - assert(0 && "implement null pointer exception"); -} - -extern "C" void indexOutOfBounds() { - fflush(stdout); - assert(0 && "implement index out of bounds exception"); -} - - -extern "C" VMObject* newString(const UTF8* utf8) { - CLIString * str = - (CLIString*)(((N3*)VMThread::get()->vm)->UTF8ToStr(utf8)); - return str; -} - void CLIJit::initialise() { } @@ -1533,501 +1507,82 @@ mvm::jit::protectEngine->unlock(); } +namespace n3 { + namespace llvm_runtime { + #include "LLVMRuntime.inc" + } +} + + void CLIJit::initialiseBootstrapVM(N3* vm) { Module* module = vm->module; mvm::jit::protectEngine->lock(); mvm::jit::executionEngine->addModuleProvider(vm->TheModuleProvider); mvm::jit::protectEngine->unlock(); - - - - { - std::vector arg_types; - arg_types.insert (arg_types.begin (), llvm::PointerType::getUnqual(mvm::jit::ptrType)); - llvm::FunctionType *mtype = llvm::FunctionType::get (llvm::Type::VoidTy, arg_types, false); - Function::Create(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.va_start", module); - } - - { - std::vector arg_types; - arg_types.insert (arg_types.begin (), llvm::Type::Int32Ty); - - llvm::FunctionType *mtype = llvm::FunctionType::get (llvm::PointerType::getUnqual(llvm::Type::Int8Ty), arg_types, false); - Function::Create(mtype, llvm::GlobalValue::ExternalLinkage, "llvm.frameaddress", module); - } + n3::llvm_runtime::makeLLVMModuleContents(module); - - { - const llvm::Type *BPTy = PointerType::getUnqual(llvm::Type::Int8Ty); - // Prototype malloc as "char* malloc(...)", because we don't know in - // doInitialization whether size_t is int or long. - FunctionType *FT = FunctionType::get(BPTy, std::vector(), true); - Function::Create(FT, llvm::GlobalValue::ExternalLinkage, "_ZN2gcnwEjP5gc_vt", module); - } - - - // Create VMObject::llvmType - const llvm::Type* Pty = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); - - std::vector objectFields; - objectFields.push_back(Pty); // VT - objectFields.push_back(Pty); // Class - objectFields.push_back(Pty); // Lock VMObject::llvmType = - llvm::PointerType::getUnqual(llvm::StructType::get(objectFields, false)); - - // Create VMArray::llvmType - { - std::vector arrayFields; - arrayFields.push_back(VMObject::llvmType->getContainedType(0)); - arrayFields.push_back(llvm::Type::Int32Ty); - VMArray::llvmType = - llvm::PointerType::getUnqual(llvm::StructType::get(arrayFields, false)); - } - -#define ARRAY_TYPE(name, type) \ - { \ - std::vector arrayFields; \ - arrayFields.push_back(VMObject::llvmType->getContainedType(0)); \ - arrayFields.push_back(Type::Int32Ty); \ - arrayFields.push_back(ArrayType::get(type, 0)); \ - name::llvmType = PointerType::getUnqual(StructType::get(arrayFields, false)); \ - } - - ARRAY_TYPE(ArrayUInt8, Type::Int8Ty); - ARRAY_TYPE(ArraySInt8, Type::Int8Ty); - ARRAY_TYPE(ArrayUInt16, Type::Int16Ty); - ARRAY_TYPE(ArraySInt16, Type::Int16Ty); - ARRAY_TYPE(ArrayUInt32, Type::Int32Ty); - ARRAY_TYPE(ArraySInt32, Type::Int32Ty); - ARRAY_TYPE(ArrayLong, Type::Int64Ty); - ARRAY_TYPE(ArrayDouble, Type::DoubleTy); - ARRAY_TYPE(ArrayFloat, Type::FloatTy); - ARRAY_TYPE(ArrayObject, VMObject::llvmType); - -#undef ARRAY_TYPE - - // Create UTF8::llvmType - { - std::vector arrayFields; - arrayFields.push_back(VMObject::llvmType->getContainedType(0)); - arrayFields.push_back(llvm::Type::Int32Ty); - arrayFields.push_back(llvm::ArrayType::get(llvm::Type::Int16Ty, 0)); - UTF8::llvmType = - llvm::PointerType::getUnqual(llvm::StructType::get(arrayFields, false)); - } + PointerType::getUnqual(module->getTypeByName("CLIObject")); + VMArray::llvmType = + PointerType::getUnqual(module->getTypeByName("CLIArray")); + ArrayUInt8::llvmType = + PointerType::getUnqual(module->getTypeByName("ArrayUInt8")); + ArraySInt8::llvmType = + PointerType::getUnqual(module->getTypeByName("ArraySInt8")); + ArrayUInt16::llvmType = + PointerType::getUnqual(module->getTypeByName("ArrayUInt16")); + ArraySInt16::llvmType = + PointerType::getUnqual(module->getTypeByName("ArraySInt16")); + ArraySInt32::llvmType = + PointerType::getUnqual(module->getTypeByName("ArraySInt32")); + ArrayLong::llvmType = + PointerType::getUnqual(module->getTypeByName("ArrayLong")); + ArrayDouble::llvmType = + PointerType::getUnqual(module->getTypeByName("ArrayDouble")); + ArrayFloat::llvmType = + PointerType::getUnqual(module->getTypeByName("ArrayFloat")); + ArrayObject::llvmType = + PointerType::getUnqual(module->getTypeByName("ArrayObject")); + UTF8::llvmType = + PointerType::getUnqual(module->getTypeByName("ArrayUInt16")); + CacheNode::llvmType = + PointerType::getUnqual(module->getTypeByName("CacheNode")); + Enveloppe::llvmType = + PointerType::getUnqual(module->getTypeByName("Enveloppe")); - // Create CacheNode::llvmType - { - std::vector arrayFields; - arrayFields.push_back(PointerType::getUnqual(Type::Int8Ty)); // VT - arrayFields.push_back(PointerType::getUnqual(Type::Int8Ty)); // methPtr - arrayFields.push_back(PointerType::getUnqual(Type::Int8Ty)); // lastCible - arrayFields.push_back(PointerType::getUnqual(Type::Int8Ty)); // next - arrayFields.push_back(PointerType::getUnqual(Type::Int8Ty)); // enveloppe - arrayFields.push_back(Type::Int1Ty); // box - CacheNode::llvmType = - PointerType::getUnqual(StructType::get(arrayFields, false)); - } - - // Create Enveloppe::llvmType - { - std::vector arrayFields; - arrayFields.push_back(PointerType::getUnqual(Type::Int8Ty)); // VT - arrayFields.push_back(CacheNode::llvmType); // firstCache - arrayFields.push_back(PointerType::getUnqual(Type::Int8Ty)); // cacheLock - arrayFields.push_back(PointerType::getUnqual(Type::Int8Ty)); // originalMethod - Enveloppe::llvmType = - PointerType::getUnqual(StructType::get(arrayFields, false)); - } - #ifdef WITH_TRACER - // Create markAndTraceLLVM - { - std::vector args; - args.push_back(VMObject::llvmType); -#ifdef MULTIPLE_GC - args.push_back(mvm::jit::ptrType); -#endif - markAndTraceLLVMType = FunctionType::get(llvm::Type::VoidTy, args, false); - markAndTraceLLVM = Function::Create(markAndTraceLLVMType, - GlobalValue::ExternalLinkage, -#ifdef MULTIPLE_GC - "_ZNK2gc12markAndTraceEP9Collector", -#else - "_ZNK2gc12markAndTraceEv", -#endif - module); - } -#endif - - // Create vmObjectTracerLLVM - { - std::vector args; - args.push_back(VMObject::llvmType); -#ifdef MULTIPLE_GC - args.push_back(mvm::jit::ptrType); -#endif - const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - vmObjectTracerLLVM = Function::Create(type, - GlobalValue::ExternalLinkage, -#ifdef MULTIPLE_GC - "_ZN2n38VMObject6tracerEPv", -#else - "_ZN2n38VMObject6tracerEv", + markAndTraceLLVM = module->getFunction("MarkAndTrace"); + markAndTraceLLVMType = markAndTraceLLVM->getFunctionType(); + vmObjectTracerLLVM = module->getFunction("CLIObjectTracer"); #endif - module); - } - // Create intialiseClassLLVM - { - std::vector args; - args.push_back(PointerType::getUnqual(Type::Int8Ty)); - const FunctionType* type = FunctionType::get(VMObject::llvmType, args, false); - initialiseClassLLVM = Function::Create(type, - GlobalValue::ExternalLinkage, - "initialiseClass", - module); - } - - // Create resolveStringLLVM - /*{ - std::vector args; - args.push_back(UTF8::llvmType); - args.push_back(PointerType::getUnqual(Type::Int8Ty)); - args.push_back(llvm::Type::Int32Ty); - const FunctionType* type = FunctionType::get(VMObject::llvmType, args, - false); - stringLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n37CLIJit12stringLookupEPKNS_4UTF8EPNS_5ClassEj", - module); - }*/ - - // Create staticLookupLLVM - /*{ - std::vector args; - args.push_back(PointerType::getUnqual(Type::Int8Ty)); - args.push_back(llvm::Type::Int32Ty); - const FunctionType* type = - FunctionType::get(llvm::PointerType::getUnqual(llvm::Type::Int8Ty), args, - false); - - staticLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n37CLIJit12staticLookupEPNS_5ClassEj", - module); - }*/ - - // Create virtualLookupLLVM - { - std::vector args; - //args.push_back(VMObject::llvmType); - //args.push_back(PointerType::getUnqual(Type::Int8Ty)); - //args.push_back(llvm::Type::Int32Ty); - args.push_back(CacheNode::llvmType); - args.push_back(VMObject::llvmType); - const FunctionType* type = - FunctionType::get(CacheNode::llvmType, args, false); - - virtualLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "n3VirtualLookup", module); - -/* - virtualLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n37CLIJit13virtualLookupEPNS_10VMObjectEPNS_5ClassEj", - module); -*/ - } - - // Create newLookupLLVM - /*{ - std::vector args; - args.push_back(PointerType::getUnqual(Type::Int8Ty)); - args.push_back(llvm::Type::Int32Ty); - const FunctionType* type = FunctionType::get(VMObject::llvmType, args, - false); - - newLookupLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n37CLIJit9newLookupEPNS_5ClassEj", - module); - }*/ - - // Create arrayConsLLVM - { - std::vector args; - args.push_back(PointerType::getUnqual(Type::Int8Ty)); - args.push_back(Type::Int32Ty); - const FunctionType* type = FunctionType::get(VMObject::llvmType, args, - false); - - arrayConsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN2n312VMClassArray5doNewEj", - module); - } - - // Create objConsLLVM - { - std::vector args; - args.push_back(PointerType::getUnqual(Type::Int8Ty)); - const FunctionType* type = FunctionType::get(VMObject::llvmType, args, - false); - - objConsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN2n37VMClass5doNewEv", - module); - } - - // Create objInitLLVM - { - std::vector args; - args.push_back(PointerType::getUnqual(Type::Int8Ty)); - args.push_back(VMObject::llvmType); - const FunctionType* type = FunctionType::get(VMObject::llvmType, args, - false); - - objInitLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN2n37VMClass16initialiseObjectEPNS_8VMObjectE", - module); - PAListPtr func_toto_PAL; - SmallVector Attrs; - ParamAttrsWithIndex PAWI; - PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone; - Attrs.push_back(PAWI); - func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end()); - objInitLLVM->setParamAttrs(func_toto_PAL); - } - - // Create arrayLengthLLVM - { - std::vector args; - args.push_back(VMArray::llvmType); - const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false); - - arrayLengthLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "arrayLength", - module); - PAListPtr func_toto_PAL; - SmallVector Attrs; - ParamAttrsWithIndex PAWI; - PAWI.Index = 0; PAWI.Attrs = 0 | ParamAttr::ReadNone; - Attrs.push_back(PAWI); - func_toto_PAL = PAListPtr::get(Attrs.begin(), Attrs.end()); - arrayLengthLLVM->setParamAttrs(func_toto_PAL); - } + initialiseClassLLVM = module->getFunction("initialiseClass"); + virtualLookupLLVM = module->getFunction("n3VirtualLookup"); - - // Create nullPointerExceptionLLVM - { - std::vector args; - const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); + arrayConsLLVM = module->getFunction("newArray"); + objConsLLVM = module->getFunction("newObject"); + newStringLLVM = module->getFunction("newString"); + objInitLLVM = module->getFunction("initialiseObject"); + arrayMultiConsLLVM = module->getFunction("newMultiArray"); + arrayLengthLLVM = module->getFunction("arrayLength"); + instanceOfLLVM = module->getFunction("n3InstanceOf"); - nullPointerExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "n3NullPointerException", - module); - } - - // Create classCastExceptionLLVM - { - std::vector args; - const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); + nullPointerExceptionLLVM = module->getFunction("n3NullPointerException"); + classCastExceptionLLVM = module->getFunction("n3ClassCastException"); + indexOutOfBoundsExceptionLLVM = module->getFunction("indexOutOfBounds"); - classCastExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "n3ClassCastException", - module); - } - - // Create indexOutOfBoundsExceptionLLVM - { - std::vector args; - args.push_back(VMObject::llvmType); - args.push_back(Type::Int32Ty); - const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - - indexOutOfBoundsExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "indexOutOfBounds", - module); - } - - // Create proceedPendingExceptionLLVM - /*{ - std::vector args; - const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - - jniProceedPendingExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n37CLIJit26jniProceedPendingExceptionEv", - module); - }*/ - // Create printExecutionLLVM - { - std::vector args; - args.push_back(Type::Int32Ty); - args.push_back(Type::Int32Ty); - const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); + throwExceptionLLVM = module->getFunction("ThrowException"); + clearExceptionLLVM = module->getFunction("ClearException"); + compareExceptionLLVM = module->getFunction("CompareException"); + getCppExceptionLLVM = module->getFunction("GetCppException"); + getCLIExceptionLLVM = module->getFunction("GetCLIException"); - printExecutionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN2n36CLIJit14printExecutionEPcPNS_8VMMethodE", - module); - } - - // Create throwExceptionLLVM - { - std::vector args; - args.push_back(VMObject::llvmType); - const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - - throwExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN2n38VMThread14throwExceptionEPNS_8VMObjectE", - module); - } - - // Create clearExceptionLLVM - { - std::vector args; - const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - clearExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN2n38VMThread14clearExceptionEv", - module); - } - - - // Create compareExceptionLLVM - { - std::vector args; - args.push_back(PointerType::getUnqual(Type::Int8Ty)); - const FunctionType* type = FunctionType::get(Type::Int1Ty, args, false); + printExecutionLLVM = module->getFunction("printExecution"); - compareExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN2n38VMThread16compareExceptionEPNS_7VMClassE", - module); - } - - // Create instanceOfLLVM - { - std::vector args; - args.push_back(VMObject::llvmType); - args.push_back(PointerType::getUnqual(Type::Int8Ty)); - const FunctionType* type = FunctionType::get(Type::Int32Ty, args, false); - - instanceOfLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN2n38VMObject10instanceOfEPNS_13VMCommonClassE", - module); - } - - // Create arrayMultiConsLLVM - { - std::vector args; - args.push_back(PointerType::getUnqual(Type::Int8Ty)); - const FunctionType* type = FunctionType::get(VMObject::llvmType, args, - true); - - arrayMultiConsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "doMultiNew", - module); - } - - /* - // Create aquireObjectLLVM - { - std::vector args; - args.push_back(VMObject::llvmType); - const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - - aquireObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n310VMObject6aquireEv", - module); - } - - // Create releaseObjectLLVM - { - std::vector args; - args.push_back(VMObject::llvmType); - const FunctionType* type = FunctionType::get(Type::VoidTy, args, false); - - releaseObjectLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n310VMObject6unlockEv", - module); - } - - */ - - - // Create *AconsLLVM - /*{ - std::vector args; - args.push_back(Type::Int32Ty); - args.push_back(PointerType::getUnqual(Type::Int8Ty)); - const FunctionType* type = FunctionType::get(VMObject::llvmType, args, - false); - - FloatAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n310ArrayFloat5aconsEiPNS_10VMClassArrayE", - module); - - Int8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n310ArraySInt85aconsEiPNS_10VMClassArrayE", - module); - - DoubleAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n311ArrayDouble5aconsEiPNS_10VMClassArrayE", - module); - - Int16AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n311ArraySInt165aconsEiPNS_10VMClassArrayE", - module); - - Int32AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n311ArraySInt325aconsEiPNS_10VMClassArrayE", - module); - - UTF8AconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n34UTF85aconsEiPNS_10VMClassArrayE", - module); - - LongAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n39ArrayLong5aconsEiPNS_10VMClassArrayE", - module); - - ObjectAconsLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN5n311ArrayObject5aconsEiPNS_10VMClassArrayE", - module); - }*/ - - // Create getCppExceptionLLVM - { - std::vector args; - const FunctionType* type = FunctionType::get(mvm::jit::ptrType, - args, false); - - getCppExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN2n38VMThread15getCppExceptionEv", - module); - } - - // Create getCLIExceptionLLVM - { - std::vector args; - const FunctionType* type = FunctionType::get(VMObject::llvmType, - args, false); - - getCLIExceptionLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "_ZN2n38VMThread15getCLIExceptionEv", - module); - } - - // Create newStringLLVM - { - std::vector args; - args.push_back(mvm::jit::ptrType); - const FunctionType* type = FunctionType::get(VMObject::llvmType, - args, false); - - newStringLLVM = Function::Create(type, GlobalValue::ExternalLinkage, - "newString", - module); - } constantVMObjectNull = Constant::getNullValue(VMObject::llvmType); Added: vmkit/branches/isolate/lib/N3/VMCore/CLIRuntimeJIT.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/N3/VMCore/CLIRuntimeJIT.cpp?rev=56850&view=auto ============================================================================== --- vmkit/branches/isolate/lib/N3/VMCore/CLIRuntimeJIT.cpp (added) +++ vmkit/branches/isolate/lib/N3/VMCore/CLIRuntimeJIT.cpp Tue Sep 30 11:06:06 2008 @@ -0,0 +1,183 @@ +//===--- CLIRuntimeJIT.cpp - Runtime functions for the JIT compiled code --===// +// +// The vmkit project +// +// This file is distributed under the University Of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + + +#include + +#include "llvm/DerivedTypes.h" +#include "llvm/Instructions.h" + +#include "mvm/JIT.h" +#include "mvm/Object.h" +#include "mvm/PrintBuffer.h" +#include "mvm/Threads/Locks.h" + +#include "CLIString.h" +#include "MSCorlib.h" +#include "N3.h" +#include "VMArray.h" +#include "VMCache.h" +#include "VMClass.h" +#include "VMObject.h" +#include "VMThread.h" + +using namespace n3; +using namespace llvm; + +extern "C" VMObject* initialiseClass(VMClass* cl) { + cl->clinitClass(NULL); + return cl->staticInstance; +} + +extern "C" void n3ClassCastException() { + fflush(stdout); + assert(0 && "implement class cast exception"); +} + +extern "C" void n3NullPointerException() { + fflush(stdout); + assert(0 && "implement null pointer exception"); +} + +extern "C" void indexOutOfBounds() { + fflush(stdout); + assert(0 && "implement index out of bounds exception"); +} + +extern "C" VMObject* newString(const UTF8* utf8) { + CLIString * str = + (CLIString*)(((N3*)VMThread::get()->vm)->UTF8ToStr(utf8)); + return str; +} + +extern "C" bool n3InstanceOf(VMObject* obj, VMCommonClass* cl) { + return obj->instanceOf(cl); +} + +extern "C" void* GetCppException() { + return VMThread::getCppException(); +} + +extern "C" void ThrowException(VMObject* obj) { + return VMThread::throwException(obj); +} + +extern "C" VMObject* GetCLIException() { + return VMThread::getCLIException(); +} + +extern "C" bool CompareException(VMClass* cl) { + return VMThread::compareException(cl); +} + +extern "C" void ClearException() { + return VMThread::clearException(); +} + +static VMObject* doMultiNewIntern(VMClassArray* cl, uint32 dim, sint32* buf) { + if (dim <= 0) VMThread::get()->vm->error("Can't happen"); + sint32 n = buf[0]; + if (n < 0) VMThread::get()->vm->negativeArraySizeException(n); + + VMArray* res = (VMArray*)cl->doNew(n); + if (dim > 1) { + VMCommonClass* base = cl->baseClass; + if (n > 0) { + for (sint32 i = 0; i < n; ++i) { + res->elements[i] = doMultiNewIntern((VMClassArray*)base, dim - 1, &(buf[1])); + } + } + for (uint32 i = 1; i < dim; ++i) { + if (buf[i] < 0) VMThread::get()->vm->negativeArraySizeException(buf[i]); + } + } + return res; +} + +extern "C" VMObject* doMultiNew(VMClassArray* cl, ...) { + sint32* dimSizes = (sint32*)alloca(cl->dims * sizeof(sint32)); + va_list ap; + va_start(ap, cl); + for (uint32 i = 0; i < cl->dims; ++i) { + dimSizes[i] = va_arg(ap, sint32); + } + va_end(ap); + return doMultiNewIntern(cl, cl->dims, dimSizes); +} + +extern "C" CacheNode* n3VirtualLookup(CacheNode* cache, VMObject *obj) { + Enveloppe* enveloppe = cache->enveloppe; + VMCommonClass* ocl = obj->classOf; + VMMethod* orig = enveloppe->originalMethod; + + CacheNode* rcache = 0; + CacheNode* tmp = enveloppe->firstCache; + CacheNode* last = tmp; + enveloppe->cacheLock->lock(); + + while (tmp) { + if (ocl == tmp->lastCible) { + rcache = tmp; + break; + } else { + last = tmp; + tmp = tmp->next; + } + } + + if (!rcache) { + VMMethod* dmeth = ocl->lookupMethodDontThrow(orig->name, + orig->parameters, + false, true); + if (dmeth == 0) { + char* methAsciiz = orig->name->UTF8ToAsciiz(); + char* nameAsciiz = orig->classDef->name->UTF8ToAsciiz(); + char* nameSpaceAsciiz = orig->classDef->nameSpace->UTF8ToAsciiz(); + + char *buf = (char*)alloca(3 + strlen(methAsciiz) + + strlen(nameAsciiz) + + strlen(nameSpaceAsciiz)); + sprintf(buf, "%s.%s.%s", nameSpaceAsciiz, nameAsciiz, methAsciiz); + const UTF8* newName = VMThread::get()->vm->asciizConstructUTF8(buf); + dmeth = ocl->lookupMethod(newName, orig->parameters, false, true); + } + + if (cache->methPtr) { + rcache = CacheNode::allocate(); + rcache->enveloppe = enveloppe; + } else { + rcache = cache; + } + + Function* func = dmeth->compiledPtr(NULL); + rcache->methPtr = mvm::jit::executionEngine->getPointerToGlobal(func); + rcache->lastCible = (VMClass*)ocl; + rcache->box = (dmeth->classDef->super == MSCorlib::pValue); + } + + if (enveloppe->firstCache != rcache) { + CacheNode *f = enveloppe->firstCache; + enveloppe->firstCache = rcache; + last->next = rcache->next; + rcache->next = f; + + } + + enveloppe->cacheLock->unlock(); + + return rcache; +} + +extern "C" VMObject* newObject(VMClass* cl) { + return cl->doNew(); +} + +extern "C" VMObject* newArray(VMClassArray* cl, sint32 nb) { + return cl->doNew(nb); +} Modified: vmkit/branches/isolate/lib/N3/VMCore/CLISignature.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/N3/VMCore/CLISignature.cpp?rev=56850&r1=56849&r2=56850&view=diff ============================================================================== --- vmkit/branches/isolate/lib/N3/VMCore/CLISignature.cpp (original) +++ vmkit/branches/isolate/lib/N3/VMCore/CLISignature.cpp Tue Sep 30 11:06:06 2008 @@ -300,10 +300,9 @@ if (currGenericMethod == NULL) { // when reading in signatures which contain references to generic arguments // of generic methods we need create a placeholder for each of them, - // this is done by creating a dummy VMClass, - // the token field is used to store the generic argument number + // this is done by creating a dummy VMClass which has the assembly field + // set to NULL, the token field is used to store the generic argument number VMClass* cl = gc_new(VMClass)(); - cl->isDummy = true; cl->token = number; cl->assembly = ass; cl->nameSpace = ass->name; Modified: vmkit/branches/isolate/lib/N3/VMCore/Makefile URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/N3/VMCore/Makefile?rev=56850&r1=56849&r2=56850&view=diff ============================================================================== --- vmkit/branches/isolate/lib/N3/VMCore/Makefile (original) +++ vmkit/branches/isolate/lib/N3/VMCore/Makefile Tue Sep 30 11:06:06 2008 @@ -10,3 +10,5 @@ LIBRARYNAME = N3 include $(LEVEL)/Makefile.common + +CXX.Flags += -I../LLVMRuntime Modified: vmkit/branches/isolate/lib/N3/VMCore/VMCache.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/N3/VMCore/VMCache.cpp?rev=56850&r1=56849&r2=56850&view=diff ============================================================================== --- vmkit/branches/isolate/lib/N3/VMCore/VMCache.cpp (original) +++ vmkit/branches/isolate/lib/N3/VMCore/VMCache.cpp Tue Sep 30 11:06:06 2008 @@ -157,66 +157,3 @@ push(ret); } } - -extern "C" CacheNode* n3VirtualLookup(CacheNode* cache, VMObject *obj) { - Enveloppe* enveloppe = cache->enveloppe; - VMCommonClass* ocl = obj->classOf; - VMMethod* orig = enveloppe->originalMethod; - - CacheNode* rcache = 0; - CacheNode* tmp = enveloppe->firstCache; - CacheNode* last = tmp; - enveloppe->cacheLock->lock(); - - while (tmp) { - if (ocl == tmp->lastCible) { - rcache = tmp; - break; - } else { - last = tmp; - tmp = tmp->next; - } - } - - if (!rcache) { - VMMethod* dmeth = ocl->lookupMethodDontThrow(orig->name, - orig->parameters, - false, true); - if (dmeth == 0) { - char* methAsciiz = orig->name->UTF8ToAsciiz(); - char* nameAsciiz = orig->classDef->name->UTF8ToAsciiz(); - char* nameSpaceAsciiz = orig->classDef->nameSpace->UTF8ToAsciiz(); - - char *buf = (char*)alloca(3 + strlen(methAsciiz) + - strlen(nameAsciiz) + - strlen(nameSpaceAsciiz)); - sprintf(buf, "%s.%s.%s", nameSpaceAsciiz, nameAsciiz, methAsciiz); - const UTF8* newName = VMThread::get()->vm->asciizConstructUTF8(buf); - dmeth = ocl->lookupMethod(newName, orig->parameters, false, true); - } - - if (cache->methPtr) { - rcache = CacheNode::allocate(); - rcache->enveloppe = enveloppe; - } else { - rcache = cache; - } - - Function* func = dmeth->compiledPtr(NULL); - rcache->methPtr = mvm::jit::executionEngine->getPointerToGlobal(func); - rcache->lastCible = (VMClass*)ocl; - rcache->box = (dmeth->classDef->super == MSCorlib::pValue); - } - - if (enveloppe->firstCache != rcache) { - CacheNode *f = enveloppe->firstCache; - enveloppe->firstCache = rcache; - last->next = rcache->next; - rcache->next = f; - - } - - enveloppe->cacheLock->unlock(); - - return rcache; -} Modified: vmkit/branches/isolate/lib/N3/VMCore/VMClass.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/N3/VMCore/VMClass.cpp?rev=56850&r1=56849&r2=56850&view=diff ============================================================================== --- vmkit/branches/isolate/lib/N3/VMCore/VMClass.cpp (original) +++ vmkit/branches/isolate/lib/N3/VMCore/VMClass.cpp Tue Sep 30 11:06:06 2008 @@ -168,7 +168,6 @@ this->isArray = isArray; this->isPointer = false; this->isPrimitive = false; - this->isDummy = false; this->naturalType = llvm::OpaqueType::get(); } @@ -640,38 +639,6 @@ return res; } -static VMObject* doMultiNewIntern(VMClassArray* cl, uint32 dim, sint32* buf) { - if (dim <= 0) VMThread::get()->vm->error("Can't happen"); - sint32 n = buf[0]; - if (n < 0) VMThread::get()->vm->negativeArraySizeException(n); - - VMArray* res = (VMArray*)cl->doNew(n); - if (dim > 1) { - VMCommonClass* base = cl->baseClass; - if (n > 0) { - for (sint32 i = 0; i < n; ++i) { - res->elements[i] = doMultiNewIntern((VMClassArray*)base, dim - 1, &(buf[1])); - } - } - for (uint32 i = 1; i < dim; ++i) { - if (buf[i] < 0) VMThread::get()->vm->negativeArraySizeException(buf[i]); - } - } - return res; -} - -extern "C" VMObject* doMultiNew(VMClassArray* cl, ...) { - sint32* dimSizes = (sint32*)alloca(cl->dims * sizeof(sint32)); - va_list ap; - va_start(ap, cl); - for (uint32 i = 0; i < cl->dims; ++i) { - dimSizes[i] = va_arg(ap, sint32); - } - va_end(ap); - return doMultiNewIntern(cl, cl->dims, dimSizes); -} - - static void disassembleStruct(std::vector &args, const llvm::Type* arg) { const llvm::StructType* STy = llvm::dyn_cast(arg); @@ -832,14 +799,16 @@ std::vector::iterator i = parameters.begin(), a = args.begin(), e = args.end(); + // dummy classes for generic arguments have a NULL assembly field // check whether both i and a point to a dummy class - if (((*i)->isDummy && !(*a)->isDummy) || (!(*i)->isDummy && (*a)->isDummy)) + if (((*i)->assembly == NULL && (*a)->assembly != NULL) || + ((*i)->assembly != NULL && (*a)->assembly == NULL)) return false; // dummy classes for generic arguments contain the // argument number in the token field // signature is only equal if the argument number matches - if ((*i)->isDummy && (*a)->isDummy) { + if ((*i)->assembly == NULL && (*a)->assembly == NULL) { if ((*i)->token != (*a)->token) { return false; } @@ -856,14 +825,16 @@ } for (; a != e; ++i, ++a) { + // dummy classes for generic arguments have a NULL assembly field // check whether both i and a point to a dummy class - if (((*i)->isDummy && !(*a)->isDummy) || (!(*i)->isDummy && (*a)->isDummy)) + if (((*i)->assembly == NULL && (*a)->assembly != NULL) || + ((*i)->assembly != NULL && (*a)->assembly == NULL)) return false; // dummy classes for generic arguments contain the // argument number in the token field // signature is only equal if the argument number matches - if ((*i)->isDummy && (*a)->isDummy) { + if ((*i)->assembly == NULL && (*a)->assembly == NULL) { if ((*i)->token != (*a)->token) { return false; } else { Modified: vmkit/branches/isolate/lib/N3/VMCore/VMClass.h URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/N3/VMCore/VMClass.h?rev=56850&r1=56849&r2=56850&view=diff ============================================================================== --- vmkit/branches/isolate/lib/N3/VMCore/VMClass.h (original) +++ vmkit/branches/isolate/lib/N3/VMCore/VMClass.h Tue Sep 30 11:06:06 2008 @@ -74,7 +74,6 @@ bool isArray; bool isPointer; bool isPrimitive; - bool isDummy; uint32 depth; VMClassState status; uint32 flags; Modified: vmkit/branches/isolate/lib/N3/VMCore/VirtualTables.cpp URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/isolate/lib/N3/VMCore/VirtualTables.cpp?rev=56850&r1=56849&r2=56850&view=diff ============================================================================== --- vmkit/branches/isolate/lib/N3/VMCore/VirtualTables.cpp (original) +++ vmkit/branches/isolate/lib/N3/VMCore/VirtualTables.cpp Tue Sep 30 11:06:06 2008 @@ -300,3 +300,13 @@ void Exception::TRACER { catchClass->MARK_AND_TRACE; } + +#ifdef MULTIPLE_GC +extern "C" void CLIObjectTracer(VMObject* obj, Collector* GC) { +#else +extern "C" void CLIObjectTracer(VMObject* obj) { +#endif + obj->classOf->MARK_AND_TRACE; + obj->lockObj->MARK_AND_TRACE; +} +