changeset 2050:b6d2c238e585

Two fixes for leaf type and leaf method assumptions.
author Thomas Wuerthinger <wuerthinger@ssw.jku.at>
date Tue, 11 Jan 2011 11:55:19 +0100
parents 7e09ea4a8f36
children 926f2cf71b62
files src/share/vm/c1x/c1x_CodeInstaller.cpp src/share/vm/c1x/c1x_VMEntries.cpp
diffstat 2 files changed, 23 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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() {
--- 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<methodOop>(vmId));
+  VM_ENTRY_MARK;
+  ciMethod* cimethod = (ciMethod*)CURRENT_ENV->get_object(VmIds::get<methodOop>(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));
     }