diff src/share/vm/c1x/c1x_VMEntries.cpp @ 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 89bf01e6b049
line wrap: on
line diff
--- 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));
     }