[vmkit-commits] [vmkit] r198573 - Interface lookup has to explore the parent interfaces, not the super class.
Gael Thomas
gael.thomas at lip6.fr
Sun Jan 5 14:12:08 PST 2014
Author: gthomas
Date: Sun Jan 5 16:12:08 2014
New Revision: 198573
URL: http://llvm.org/viewvc/llvm-project?rev=198573&view=rev
Log:
Interface lookup has to explore the parent interfaces, not the super class.
Modified:
vmkit/branches/mcjit/include/j3/j3class.h
vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc
vmkit/branches/mcjit/lib/j3/openjdk/j3unsafe.cc
vmkit/branches/mcjit/lib/j3/vm/j3.cc
vmkit/branches/mcjit/lib/j3/vm/j3class.cc
Modified: vmkit/branches/mcjit/include/j3/j3class.h
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/include/j3/j3class.h?rev=198573&r1=198572&r2=198573&view=diff
==============================================================================
--- vmkit/branches/mcjit/include/j3/j3class.h (original)
+++ vmkit/branches/mcjit/include/j3/j3class.h Sun Jan 5 16:12:08 2014
@@ -218,7 +218,7 @@ namespace j3 {
void doResolve(J3Field* hiddenFields, size_t nbHiddenFields);
void doInitialise();
- J3Method* interfaceOrMethodAt(uint16_t idx, uint16_t access);
+ J3Method* interfaceOrMethodAt(uint16_t idx, uint16_t access, bool isInterfaceMethod);
public:
J3Class(J3ClassLoader* loader, const vmkit::Name* name, J3ClassBytes* bytes);
@@ -259,6 +259,7 @@ namespace j3 {
bool isClass() { return 1; }
+ J3Method* findInterfaceMethod(const vmkit::Name* name, J3Signature* signature, bool error=1);
J3Method* findMethod(uint32_t access, const vmkit::Name* name, J3Signature* signature, bool error=1);
J3Field* findField(uint32_t access, const vmkit::Name* name, J3Type* type, bool error=1);
};
Modified: vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc?rev=198573&r1=198572&r2=198573&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc (original)
+++ vmkit/branches/mcjit/lib/j3/openjdk/j3openjdk.cc Sun Jan 5 16:12:08 2014
@@ -290,7 +290,9 @@ void JNICALL JVM_TraceMethodCalls(jboole
jlong JNICALL JVM_TotalMemory(void) { enterJVM(); NYI(); leaveJVM(); }
jlong JNICALL JVM_FreeMemory(void) { enterJVM(); NYI(); leaveJVM(); }
jlong JNICALL JVM_MaxMemory(void) { enterJVM(); NYI(); leaveJVM(); }
-jint JNICALL JVM_ActiveProcessorCount(void) { enterJVM(); NYI(); leaveJVM(); }
+jint JNICALL JVM_ActiveProcessorCount(void) {
+ return sysconf(_SC_NPROCESSORS_ONLN);
+}
void* JNICALL JVM_LoadLibrary(const char *name) {
void* res;
Modified: vmkit/branches/mcjit/lib/j3/openjdk/j3unsafe.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/openjdk/j3unsafe.cc?rev=198573&r1=198572&r2=198573&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/openjdk/j3unsafe.cc (original)
+++ vmkit/branches/mcjit/lib/j3/openjdk/j3unsafe.cc Sun Jan 5 16:12:08 2014
@@ -29,7 +29,7 @@ extern "C" {
/// makes this type of access impossible or unsupported.
///
JNIEXPORT jlong JNICALL Java_sun_misc_Unsafe_arrayIndexScale(JNIEnv* env, jobject unsafe, jclass clazz) {
- return J3ObjectType::nativeClass(clazz)->asArrayClass()->component()->logSize();
+ return 1<<J3ObjectType::nativeClass(clazz)->asArrayClass()->component()->logSize();
}
JNIEXPORT jint JNICALL Java_sun_misc_Unsafe_addressSize(JNIEnv* env, jobject unsafe) {
Modified: vmkit/branches/mcjit/lib/j3/vm/j3.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3.cc?rev=198573&r1=198572&r2=198573&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3.cc Sun Jan 5 16:12:08 2014
@@ -153,6 +153,9 @@ void J3::run() {
if(options()->debugLifeCycle)
fprintf(stderr, " Creating the system class loader\n");
+ //options()->genDebugExecute = 1;
+ //options()->debugExecute = 2;
+
z_method(J3Cst::ACC_STATIC,
z_class("java/lang/ClassLoader"),
names()->get("getSystemClassLoader"),
Modified: vmkit/branches/mcjit/lib/j3/vm/j3class.cc
URL: http://llvm.org/viewvc/llvm-project/vmkit/branches/mcjit/lib/j3/vm/j3class.cc?rev=198573&r1=198572&r2=198573&view=diff
==============================================================================
--- vmkit/branches/mcjit/lib/j3/vm/j3class.cc (original)
+++ vmkit/branches/mcjit/lib/j3/vm/j3class.cc Sun Jan 5 16:12:08 2014
@@ -340,6 +340,33 @@ J3ObjectHandle* J3Class::extractAttribut
return J3ObjectHandle::doNewArray(J3Thread::get()->vm()->typeByte->getArray(), 0);
}
+J3Method* J3Class::findInterfaceMethod(const vmkit::Name* name, J3Signature* signature, bool error) {
+ resolve();
+
+ J3Class* cur = this;
+ while(1) {
+ J3Method* res = cur->localFindMethod(name, signature);
+
+ if(res)
+ return res;
+
+ switch(cur->nbInterfaces()) {
+ case 1: cur = cur->interfaces()[0]; break;
+ default:
+ for(uint32_t i=0; i<cur->nbInterfaces(); i++) {
+ res = cur->interfaces()[i]->findInterfaceMethod(name, signature, error);
+ if(res)
+ return res;
+ }
+ case 0:
+ if(error)
+ J3::noSuchMethodError("no such interface method", this, name, signature);
+ else
+ return 0;
+ }
+ }
+}
+
J3Method* J3Class::findMethod(uint32_t access, const vmkit::Name* name, J3Signature* signature, bool error) {
resolve();
@@ -724,7 +751,7 @@ uint64_t J3Class::longAt(uint16_t idx) {
return ((uint64_t)ctpValues[idx] << 32) + (uint64_t)ctpValues[idx+1];
}
-J3Method* J3Class::interfaceOrMethodAt(uint16_t idx, uint16_t access) {
+J3Method* J3Class::interfaceOrMethodAt(uint16_t idx, uint16_t access, bool isInterfaceMethod) {
J3Method* res = (J3Method*)ctpResolved[idx];
if(res) {
@@ -743,7 +770,9 @@ J3Method* J3Class::interfaceOrMethodAt(u
if(!signature)
ctpResolved[idx] = signature = loader()->getSignature(this, nameAt(ctpValues[ntIdx] & 0xffff));
- res = cl->findMethod(access, name, signature);
+ res = (isInterfaceMethod && J3Cst::isInterface(cl->access())) ?
+ cl->asClass()->findInterfaceMethod(name, signature) :
+ cl->findMethod(access, name, signature);
ctpResolved[idx] = res;
@@ -752,12 +781,12 @@ J3Method* J3Class::interfaceOrMethodAt(u
J3Method* J3Class::methodAt(uint16_t idx, uint16_t access) {
check(idx, J3Cst::CONSTANT_Methodref);
- return interfaceOrMethodAt(idx, access);
+ return interfaceOrMethodAt(idx, access, 0);
}
J3Method* J3Class::interfaceMethodAt(uint16_t idx, uint16_t access) {
check(idx, J3Cst::CONSTANT_InterfaceMethodref);
- return interfaceOrMethodAt(idx, access);
+ return interfaceOrMethodAt(idx, access, 1);
}
J3Field* J3Class::fieldAt(uint16_t idx, uint16_t access) {
More information about the vmkit-commits
mailing list