Mercurial > hg > graal-jvmci-8
changeset 22583:c9f8eec77163
CompilerToVm.getVtableIndexForInterfaceMethod must not allow non-interface methods (JDK-8136659)
author | Stefan Anzinger <stefan.anzinger@oracle.com> |
---|---|
date | Fri, 18 Sep 2015 10:10:55 +0200 |
parents | 232c53e17ea0 |
children | f94fd2b4f794 |
files | jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java src/share/vm/jvmci/jvmciCompilerToVM.cpp |
diffstat | 3 files changed, 13 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java Fri Sep 18 15:16:15 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/CompilerToVM.java Fri Sep 18 10:10:55 2015 +0200 @@ -514,8 +514,11 @@ * Gets the v-table index for interface method {@code method} in the receiver {@code type} or * {@link HotSpotVMConfig#invalidVtableIndex} if {@code method} is not in {@code type}'s * v-table. + * + * @throws InternalError if {@code type} is an interface or {@code method} is not held by an + * interface */ - native int getVtableIndexForInterface(HotSpotResolvedObjectTypeImpl type, HotSpotResolvedJavaMethodImpl method); + native int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, HotSpotResolvedJavaMethodImpl method); /** * Determines if debug info should also be emitted at non-safepoint locations.
--- a/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Fri Sep 18 15:16:15 2015 +0200 +++ b/jvmci/jdk.internal.jvmci.hotspot/src/jdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethodImpl.java Fri Sep 18 10:10:55 2015 +0200 @@ -680,7 +680,7 @@ if (resolved.isInterface()) { return config().invalidVtableIndex; } - return getVtableIndexForInterface(resolved); + return getVtableIndexForInterfaceMethod(resolved); } return getVtableIndex(); } @@ -698,9 +698,9 @@ return result; } - private int getVtableIndexForInterface(ResolvedJavaType resolved) { + private int getVtableIndexForInterfaceMethod(ResolvedJavaType resolved) { HotSpotResolvedObjectTypeImpl hotspotType = (HotSpotResolvedObjectTypeImpl) resolved; - return compilerToVM().getVtableIndexForInterface(hotspotType, this); + return compilerToVM().getVtableIndexForInterfaceMethod(hotspotType, this); } /**
--- a/src/share/vm/jvmci/jvmciCompilerToVM.cpp Fri Sep 18 15:16:15 2015 +0200 +++ b/src/share/vm/jvmci/jvmciCompilerToVM.cpp Fri Sep 18 10:10:55 2015 +0200 @@ -467,13 +467,17 @@ return JNIHandles::make_local(THREAD, field_holder); C2V_END -C2V_VMENTRY(jint, getVtableIndexForInterface, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) +C2V_VMENTRY(jint, getVtableIndexForInterfaceMethod, (JNIEnv *, jobject, jobject jvmci_type, jobject jvmci_method)) Klass* klass = CompilerToVM::asKlass(jvmci_type); Method* method = CompilerToVM::asMethod(jvmci_method); if (klass->is_interface()) { ResourceMark rm; THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Interface %s should be handled in Java code", klass->external_name())); } + if (!method->method_holder()->is_interface()) { + ResourceMark rm; + THROW_MSG_0(vmSymbols::java_lang_InternalError(), err_msg("Method %s is not held by an interface, this case should be handled in Java code", method->name_and_sig_as_C_string())); + } return LinkResolver::vtable_index_of_interface_method(klass, method); C2V_END @@ -1189,7 +1193,7 @@ {CC"resolveInvokeDynamicInPool", CC"("HS_CONSTANT_POOL"I)V", FN_PTR(resolveInvokeDynamicInPool)}, {CC"resolveInvokeHandleInPool", CC"("HS_CONSTANT_POOL"I)V", FN_PTR(resolveInvokeHandleInPool)}, {CC"resolveMethod", CC"("HS_RESOLVED_KLASS HS_RESOLVED_METHOD HS_RESOLVED_KLASS")"HS_RESOLVED_METHOD, FN_PTR(resolveMethod)}, - {CC"getVtableIndexForInterface", CC"("HS_RESOLVED_KLASS HS_RESOLVED_METHOD")I", FN_PTR(getVtableIndexForInterface)}, + {CC"getVtableIndexForInterfaceMethod", CC"("HS_RESOLVED_KLASS HS_RESOLVED_METHOD")I", FN_PTR(getVtableIndexForInterfaceMethod)}, {CC"getClassInitializer", CC"("HS_RESOLVED_KLASS")"HS_RESOLVED_METHOD, FN_PTR(getClassInitializer)}, {CC"hasFinalizableSubclass", CC"("HS_RESOLVED_KLASS")Z", FN_PTR(hasFinalizableSubclass)}, {CC"getMaxCallTargetOffset", CC"(J)J", FN_PTR(getMaxCallTargetOffset)},