1152 return true; |
1152 return true; |
1153 } |
1153 } |
1154 |
1154 |
1155 int klassItable::assign_itable_indices_for_interface(Klass* klass) { |
1155 int klassItable::assign_itable_indices_for_interface(Klass* klass) { |
1156 // an interface does not have an itable, but its methods need to be numbered |
1156 // an interface does not have an itable, but its methods need to be numbered |
1157 if (TraceItables) tty->print_cr("%3d: Initializing itable for interface %s", ++initialize_count, |
1157 if (TraceItables) tty->print_cr("%3d: Initializing itable indices for interface %s", ++initialize_count, |
1158 klass->name()->as_C_string()); |
1158 klass->name()->as_C_string()); |
1159 Array<Method*>* methods = InstanceKlass::cast(klass)->methods(); |
1159 Array<Method*>* methods = InstanceKlass::cast(klass)->methods(); |
1160 int nof_methods = methods->length(); |
1160 int nof_methods = methods->length(); |
1161 int ime_num = 0; |
1161 int ime_num = 0; |
1162 for (int i = 0; i < nof_methods; i++) { |
1162 for (int i = 0; i < nof_methods; i++) { |
1166 // If m is already assigned a vtable index, do not disturb it. |
1166 // If m is already assigned a vtable index, do not disturb it. |
1167 if (TraceItables && Verbose) { |
1167 if (TraceItables && Verbose) { |
1168 ResourceMark rm; |
1168 ResourceMark rm; |
1169 const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>"; |
1169 const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>"; |
1170 if (m->has_vtable_index()) { |
1170 if (m->has_vtable_index()) { |
1171 tty->print("itable index %d for method: %s, flags: ", m->vtable_index(), sig); |
1171 tty->print("vtable index %d for method: %s, flags: ", m->vtable_index(), sig); |
1172 } else { |
1172 } else { |
1173 tty->print("itable index %d for method: %s, flags: ", ime_num, sig); |
1173 tty->print("itable index %d for method: %s, flags: ", ime_num, sig); |
1174 } |
1174 } |
1175 if (m != NULL) { |
1175 if (m != NULL) { |
1176 m->access_flags().print_on(tty); |
1176 m->access_flags().print_on(tty); |
1202 int klassItable::method_count_for_interface(Klass* interf) { |
1202 int klassItable::method_count_for_interface(Klass* interf) { |
1203 assert(interf->oop_is_instance(), "must be"); |
1203 assert(interf->oop_is_instance(), "must be"); |
1204 assert(interf->is_interface(), "must be"); |
1204 assert(interf->is_interface(), "must be"); |
1205 Array<Method*>* methods = InstanceKlass::cast(interf)->methods(); |
1205 Array<Method*>* methods = InstanceKlass::cast(interf)->methods(); |
1206 int nof_methods = methods->length(); |
1206 int nof_methods = methods->length(); |
|
1207 int length = 0; |
1207 while (nof_methods > 0) { |
1208 while (nof_methods > 0) { |
1208 Method* m = methods->at(nof_methods-1); |
1209 Method* m = methods->at(nof_methods-1); |
1209 if (m->has_itable_index()) { |
1210 if (m->has_itable_index()) { |
1210 int length = m->itable_index() + 1; |
1211 length = m->itable_index() + 1; |
|
1212 break; |
|
1213 } |
|
1214 nof_methods -= 1; |
|
1215 } |
1211 #ifdef ASSERT |
1216 #ifdef ASSERT |
1212 while (nof_methods = 0) { |
1217 int nof_methods_copy = nof_methods; |
1213 m = methods->at(--nof_methods); |
1218 while (nof_methods_copy > 0) { |
1214 assert(!m->has_itable_index() || m->itable_index() < length, ""); |
1219 Method* mm = methods->at(--nof_methods_copy); |
1215 } |
1220 assert(!mm->has_itable_index() || mm->itable_index() < length, ""); |
|
1221 } |
1216 #endif //ASSERT |
1222 #endif //ASSERT |
1217 return length; // return the rightmost itable index, plus one |
1223 // return the rightmost itable index, plus one; or 0 if no methods have |
1218 } |
1224 // itable indices |
1219 nof_methods -= 1; |
1225 return length; |
1220 } |
|
1221 // no methods have itable indices |
|
1222 return 0; |
|
1223 } |
1226 } |
1224 |
1227 |
1225 |
1228 |
1226 void klassItable::initialize_itable_for_interface(int method_table_offset, KlassHandle interf_h, bool checkconstraints, TRAPS) { |
1229 void klassItable::initialize_itable_for_interface(int method_table_offset, KlassHandle interf_h, bool checkconstraints, TRAPS) { |
1227 Array<Method*>* methods = InstanceKlass::cast(interf_h())->methods(); |
1230 Array<Method*>* methods = InstanceKlass::cast(interf_h())->methods(); |