# HG changeset patch # User Thomas Wuerthinger # Date 1294743319 -3600 # Node ID b6d2c238e5851a339afba9177c03a2bb3915baec # Parent 7e09ea4a8f36e5b26a1f9b9cb84d7d9b98009eb5 Two fixes for leaf type and leaf method assumptions. diff -r 7e09ea4a8f36 -r b6d2c238e585 src/share/vm/c1x/c1x_CodeInstaller.cpp --- a/src/share/vm/c1x/c1x_CodeInstaller.cpp Mon Jan 10 16:59:48 2011 +0100 +++ b/src/share/vm/c1x/c1x_CodeInstaller.cpp Tue Jan 11 11:55:19 2011 +0100 @@ -303,9 +303,8 @@ ciKlass* context = (ciKlass*) CURRENT_ENV->get_object(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(context_oop))); ciKlass* type = (ciKlass*) CURRENT_ENV->get_object(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type_oop))); - if (context == type) { - _dependencies->assert_leaf_type(type); - } else { + _dependencies->assert_leaf_type(type); + if (context != type) { assert(context->is_abstract(), ""); ThreadToNativeFromVM trans(JavaThread::current()); _dependencies->assert_abstract_with_unique_concrete_subtype(context, type); @@ -323,7 +322,10 @@ ciMethod* m = (ciMethod*) CURRENT_ENV->get_object(method); ciMethod* c = (ciMethod*) CURRENT_ENV->get_object(context); ciKlass* context_klass = c->holder(); - _dependencies->assert_unique_concrete_method(context_klass, m); + { + ThreadToNativeFromVM trans(JavaThread::current()); + _dependencies->assert_unique_concrete_method(context_klass, m); + } } void CodeInstaller::process_exception_handlers() { diff -r 7e09ea4a8f36 -r b6d2c238e585 src/share/vm/c1x/c1x_VMEntries.cpp --- a/src/share/vm/c1x/c1x_VMEntries.cpp Mon Jan 10 16:59:48 2011 +0100 +++ b/src/share/vm/c1x/c1x_VMEntries.cpp Tue Jan 11 11:55:19 2011 +0100 @@ -121,17 +121,25 @@ // public boolean RiMethod_uniqueConcreteMethod(long vmId); JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1uniqueConcreteMethod(JNIEnv *, jobject, jlong vmId) { - Thread* THREAD = Thread::current(); - ciMethod* cimethod; - { - VM_ENTRY_MARK; - cimethod = (ciMethod*)CURRENT_ENV->get_object(VmIds::get(vmId)); + VM_ENTRY_MARK; + ciMethod* cimethod = (ciMethod*)CURRENT_ENV->get_object(VmIds::get(vmId)); + if (cimethod->holder()->is_interface()) { + // Cannot trust interfaces. Because of: + // interface I { void foo(); } + // class A { public void foo() {} } + // class B extends A implements I { } + // class C extends B { public void foo() { } } + // class D extends B { } + // Would lead to identify C.foo() as the unique concrete method for I.foo() without seeing A.foo(). + return false; } - - klassOop klass = (klassOop)cimethod->holder()->get_oop(); methodOop method = (methodOop)cimethod->get_oop(); - methodOop unique_concrete = Dependencies::find_unique_concrete_method(klass, method); + methodOop unique_concrete = NULL; + { + MutexLocker locker(Compile_lock); + unique_concrete = Dependencies::find_unique_concrete_method(klass, method); + } if (unique_concrete == NULL) { return NULL; } @@ -411,7 +419,7 @@ if (k->is_abstract()) { ciInstanceKlass* sub = k->unique_concrete_subklass(); - if (sub != NULL) { + if (sub != NULL && sub->is_leaf_type()) { VM_ENTRY_MARK; return JNIHandles::make_local(C1XCompiler::get_RiType(sub, klass_handle, THREAD)); }