Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
2049:7e09ea4a8f36 | 2050:b6d2c238e585 |
---|---|
119 return cimethod->has_balanced_monitors(); | 119 return cimethod->has_balanced_monitors(); |
120 } | 120 } |
121 | 121 |
122 // public boolean RiMethod_uniqueConcreteMethod(long vmId); | 122 // public boolean RiMethod_uniqueConcreteMethod(long vmId); |
123 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1uniqueConcreteMethod(JNIEnv *, jobject, jlong vmId) { | 123 JNIEXPORT jobject JNICALL Java_com_sun_hotspot_c1x_VMEntries_RiMethod_1uniqueConcreteMethod(JNIEnv *, jobject, jlong vmId) { |
124 Thread* THREAD = Thread::current(); | 124 VM_ENTRY_MARK; |
125 ciMethod* cimethod; | 125 ciMethod* cimethod = (ciMethod*)CURRENT_ENV->get_object(VmIds::get<methodOop>(vmId)); |
126 { | 126 if (cimethod->holder()->is_interface()) { |
127 VM_ENTRY_MARK; | 127 // Cannot trust interfaces. Because of: |
128 cimethod = (ciMethod*)CURRENT_ENV->get_object(VmIds::get<methodOop>(vmId)); | 128 // interface I { void foo(); } |
129 } | 129 // class A { public void foo() {} } |
130 | 130 // class B extends A implements I { } |
131 | 131 // class C extends B { public void foo() { } } |
132 // class D extends B { } | |
133 // Would lead to identify C.foo() as the unique concrete method for I.foo() without seeing A.foo(). | |
134 return false; | |
135 } | |
132 klassOop klass = (klassOop)cimethod->holder()->get_oop(); | 136 klassOop klass = (klassOop)cimethod->holder()->get_oop(); |
133 methodOop method = (methodOop)cimethod->get_oop(); | 137 methodOop method = (methodOop)cimethod->get_oop(); |
134 methodOop unique_concrete = Dependencies::find_unique_concrete_method(klass, method); | 138 methodOop unique_concrete = NULL; |
139 { | |
140 MutexLocker locker(Compile_lock); | |
141 unique_concrete = Dependencies::find_unique_concrete_method(klass, method); | |
142 } | |
135 if (unique_concrete == NULL) { | 143 if (unique_concrete == NULL) { |
136 return NULL; | 144 return NULL; |
137 } | 145 } |
138 | 146 |
139 Handle name = VmIds::toString<Handle>(unique_concrete->name(), CHECK_NULL); | 147 Handle name = VmIds::toString<Handle>(unique_concrete->name(), CHECK_NULL); |
409 k = (ciInstanceKlass *) CURRENT_ENV->get_object(klass_handle()); | 417 k = (ciInstanceKlass *) CURRENT_ENV->get_object(klass_handle()); |
410 } | 418 } |
411 | 419 |
412 if (k->is_abstract()) { | 420 if (k->is_abstract()) { |
413 ciInstanceKlass* sub = k->unique_concrete_subklass(); | 421 ciInstanceKlass* sub = k->unique_concrete_subklass(); |
414 if (sub != NULL) { | 422 if (sub != NULL && sub->is_leaf_type()) { |
415 VM_ENTRY_MARK; | 423 VM_ENTRY_MARK; |
416 return JNIHandles::make_local(C1XCompiler::get_RiType(sub, klass_handle, THREAD)); | 424 return JNIHandles::make_local(C1XCompiler::get_RiType(sub, klass_handle, THREAD)); |
417 } | 425 } |
418 } else if (k->is_leaf_type()) { | 426 } else if (k->is_leaf_type()) { |
419 assert(!k->is_interface(), ""); | 427 assert(!k->is_interface(), ""); |