< prev index next >
src/share/vm/oops/klassVtable.cpp
Print this page
rev 8110 : 8030680: 292 cleanup from default method code assessment
@@ -1031,11 +1031,11 @@
return true;
}
int klassItable::assign_itable_indices_for_interface(Klass* klass) {
// an interface does not have an itable, but its methods need to be numbered
- if (TraceItables) tty->print_cr("%3d: Initializing itable for interface %s", ++initialize_count,
+ if (TraceItables) tty->print_cr("%3d: Initializing itable indices for interface %s", ++initialize_count,
klass->name()->as_C_string());
Array<Method*>* methods = InstanceKlass::cast(klass)->methods();
int nof_methods = methods->length();
int ime_num = 0;
for (int i = 0; i < nof_methods; i++) {
@@ -1045,11 +1045,11 @@
// If m is already assigned a vtable index, do not disturb it.
if (TraceItables && Verbose) {
ResourceMark rm;
const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
if (m->has_vtable_index()) {
- tty->print("itable index %d for method: %s, flags: ", m->vtable_index(), sig);
+ tty->print("vtable index %d for method: %s, flags: ", m->vtable_index(), sig);
} else {
tty->print("itable index %d for method: %s, flags: ", ime_num, sig);
}
if (m != NULL) {
m->access_flags().print_on(tty);
@@ -1077,26 +1077,29 @@
int klassItable::method_count_for_interface(Klass* interf) {
assert(interf->oop_is_instance(), "must be");
assert(interf->is_interface(), "must be");
Array<Method*>* methods = InstanceKlass::cast(interf)->methods();
int nof_methods = methods->length();
+ int length = 0;
while (nof_methods > 0) {
Method* m = methods->at(nof_methods-1);
if (m->has_itable_index()) {
- int length = m->itable_index() + 1;
-#ifdef ASSERT
- while (nof_methods = 0) {
- m = methods->at(--nof_methods);
- assert(!m->has_itable_index() || m->itable_index() < length, "");
- }
-#endif //ASSERT
- return length; // return the rightmost itable index, plus one
+ length = m->itable_index() + 1;
+ break;
}
nof_methods -= 1;
}
- // no methods have itable indices
- return 0;
+#ifdef ASSERT
+ int nof_methods_copy = nof_methods;
+ while (nof_methods_copy > 0) {
+ Method* mm = methods->at(--nof_methods_copy);
+ assert(!mm->has_itable_index() || mm->itable_index() < length, "");
+ }
+#endif //ASSERT
+ // return the rightmost itable index, plus one; or 0 if no methods have
+ // itable indices
+ return length;
}
void klassItable::initialize_itable_for_interface(int method_table_offset, KlassHandle interf_h, bool checkconstraints, TRAPS) {
Array<Method*>* methods = InstanceKlass::cast(interf_h())->methods();
< prev index next >