< prev index next >

src/share/vm/oops/klassVtable.cpp

Print this page
rev 13113 : imported patch 8181917-refactor-ul-logstream


  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "classfile/vmSymbols.hpp"
  28 #include "gc/shared/gcLocker.hpp"
  29 #include "logging/log.hpp"

  30 #include "memory/metaspaceShared.hpp"
  31 #include "memory/resourceArea.hpp"
  32 #include "memory/universe.inline.hpp"
  33 #include "oops/instanceKlass.hpp"
  34 #include "oops/klassVtable.hpp"
  35 #include "oops/method.hpp"
  36 #include "oops/objArrayOop.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "runtime/arguments.hpp"
  39 #include "runtime/handles.inline.hpp"
  40 #include "utilities/copy.hpp"
  41 
  42 inline InstanceKlass* klassVtable::ik() const {
  43   return InstanceKlass::cast(_klass);
  44 }
  45 
  46 bool klassVtable::is_preinitialized_vtable() {
  47   return _klass->is_shared() && !MetaspaceShared::remapped_readwrite();
  48 }
  49 


 284 // P1.C.m needs to override P1.A.m and can not override P2.B.m
 285 // Therefore: all package private methods need their own vtable entries for
 286 // them to be the root of an inheritance overriding decision
 287 // Package private methods may also override other vtable entries
 288 InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper, methodHandle target_method,
 289                             int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) {
 290   InstanceKlass* superk = initialsuper;
 291   while (superk != NULL && superk->super() != NULL) {
 292     InstanceKlass* supersuperklass = InstanceKlass::cast(superk->super());
 293     klassVtable ssVtable = supersuperklass->vtable();
 294     if (vtable_index < ssVtable.length()) {
 295       Method* super_method = ssVtable.method_at(vtable_index);
 296 #ifndef PRODUCT
 297       Symbol* name= target_method()->name();
 298       Symbol* signature = target_method()->signature();
 299       assert(super_method->name() == name && super_method->signature() == signature, "vtable entry name/sig mismatch");
 300 #endif
 301       if (supersuperklass->is_override(super_method, target_loader, target_classname, THREAD)) {
 302         if (log_develop_is_enabled(Trace, vtables)) {
 303           ResourceMark rm(THREAD);
 304           outputStream* logst = Log(vtables)::trace_stream();

 305           char* sig = target_method()->name_and_sig_as_C_string();
 306           logst->print("transitive overriding superclass %s with %s index %d, original flags: ",
 307                        supersuperklass->internal_name(),
 308                        sig, vtable_index);
 309           super_method->print_linkage_flags(logst);
 310           logst->print("overriders flags: ");
 311           target_method->print_linkage_flags(logst);
 312           logst->cr();
 313         }
 314 
 315         break; // return found superk
 316       }
 317     } else  {
 318       // super class has no vtable entry here, stop transitive search
 319       superk = (InstanceKlass*)NULL;
 320       break;
 321     }
 322     // if no override found yet, continue to search up
 323     superk = superk->super() == NULL ? NULL : InstanceKlass::cast(superk->super());
 324   }
 325 
 326   return superk;
 327 }
 328 
 329 static void log_vtables(int i, bool overrides, methodHandle target_method,
 330                         Klass* target_klass, Method* super_method,
 331                         Thread* thread) {
 332 #ifndef PRODUCT
 333   if (log_develop_is_enabled(Trace, vtables)) {
 334     ResourceMark rm(thread);
 335     outputStream* logst = Log(vtables)::trace_stream();

 336     char* sig = target_method()->name_and_sig_as_C_string();
 337     if (overrides) {
 338       logst->print("overriding with %s index %d, original flags: ",
 339                    sig, i);
 340     } else {
 341       logst->print("NOT overriding with %s index %d, original flags: ",
 342                    sig, i);
 343     }
 344     super_method->print_linkage_flags(logst);
 345     logst->print("overriders flags: ");
 346     target_method->print_linkage_flags(logst);
 347     logst->cr();
 348   }
 349 #endif
 350 }
 351 
 352 // Update child's copy of super vtable for overrides
 353 // OR return true if a new vtable entry is required.
 354 // Only called for InstanceKlass's, i.e. not for arrays
 355 // If that changed, could not use _klass as handle for klass
 356 bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle target_method,
 357                                           int super_vtable_len, int default_index,
 358                                           bool checkconstraints, TRAPS) {
 359   ResourceMark rm;
 360   bool allocate_new = true;
 361   assert(klass->is_instance_klass(), "must be InstanceKlass");
 362 
 363   Array<int>* def_vtable_indices = NULL;
 364   bool is_default = false;
 365 
 366   // default methods are non-private concrete methods in superinterfaces which are added
 367   // to the vtable with their real method_holder.


 533       } else {
 534         overrides = false;
 535       }
 536       log_vtables(i, overrides, target_method, target_klass, super_method, THREAD);
 537     }
 538   }
 539   return allocate_new;
 540 }
 541 
 542 void klassVtable::put_method_at(Method* m, int index) {
 543   if (is_preinitialized_vtable()) {
 544     // At runtime initialize_vtable is rerun as part of link_class_impl()
 545     // for shared class loaded by the non-boot loader to obtain the loader
 546     // constraints based on the runtime classloaders' context. The dumptime
 547     // method at the vtable index should be the same as the runtime method.
 548     assert(table()[index].method() == m,
 549            "archived method is different from the runtime method");
 550   } else {
 551     if (log_develop_is_enabled(Trace, vtables)) {
 552       ResourceMark rm;
 553       outputStream* logst = Log(vtables)::trace_stream();

 554       const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
 555       logst->print("adding %s at index %d, flags: ", sig, index);
 556       if (m != NULL) {
 557         m->print_linkage_flags(logst);
 558       }
 559       logst->cr();
 560     }
 561     table()[index].set(m);
 562   }
 563 }
 564 
 565 // Find out if a method "m" with superclass "super", loader "classloader" and
 566 // name "classname" needs a new vtable entry.  Let P be a class package defined
 567 // by "classloader" and "classname".
 568 // NOTE: The logic used here is very similar to the one used for computing
 569 // the vtables indices for a method. We cannot directly use that function because,
 570 // we allocate the InstanceKlass at load time, and that requires that the
 571 // superclass has been loaded.
 572 // However, the vtable entries are filled in at link time, and therefore
 573 // the superclass' vtable may not yet have been filled in.
 574 bool klassVtable::needs_new_vtable_entry(methodHandle target_method,
 575                                          const Klass* super,
 576                                          Handle classloader,
 577                                          Symbol* classname,
 578                                          AccessFlags class_flags,
 579                                          u2 major_version,


 867       add_new_mirandas_to_lists(new_mirandas, all_mirandas,
 868                                 sik->methods(), class_methods,
 869                                 default_methods, super);
 870     }
 871   }
 872 }
 873 
 874 // Discover miranda methods ("miranda" = "interface abstract, no binding"),
 875 // and append them into the vtable starting at index initialized,
 876 // return the new value of initialized.
 877 // Miranda methods use vtable entries, but do not get assigned a vtable_index
 878 // The vtable_index is discovered by searching from the end of the vtable
 879 int klassVtable::fill_in_mirandas(int initialized) {
 880   GrowableArray<Method*> mirandas(20);
 881   get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(),
 882                ik()->default_methods(), ik()->local_interfaces());
 883   for (int i = 0; i < mirandas.length(); i++) {
 884     if (log_develop_is_enabled(Trace, vtables)) {
 885       Method* meth = mirandas.at(i);
 886       ResourceMark rm(Thread::current());
 887       outputStream* logst = Log(vtables)::trace_stream();

 888       if (meth != NULL) {
 889         char* sig = meth->name_and_sig_as_C_string();
 890         logst->print("fill in mirandas with %s index %d, flags: ",
 891                      sig, initialized);
 892         meth->print_linkage_flags(logst);
 893         logst->cr();
 894       }
 895     }
 896     put_method_at(mirandas.at(i), initialized);
 897     ++initialized;
 898   }
 899   return initialized;
 900 }
 901 
 902 // Copy this class's vtable to the vtable beginning at start.
 903 // Used to copy superclass vtable to prefix of subclass's vtable.
 904 void klassVtable::copy_vtable_to(vtableEntry* start) {
 905   Copy::disjoint_words((HeapWord*)table(), (HeapWord*)start, _length * vtableEntry::size());
 906 }
 907 
 908 #if INCLUDE_JVMTI
 909 bool klassVtable::adjust_default_method(int vtable_index, Method* old_method, Method* new_method) {
 910   // If old_method is default, find this vtable index in default_vtable_indices
 911   // and replace that method in the _default_methods list
 912   bool updated = false;
 913 


1099   // it should already have a vtable index, don't touch it.
1100   // e.g., CharSequence.toString (from initialize_vtable)
1101   // if (m->has_vtable_index())  return false; // NO!
1102   return true;
1103 }
1104 
1105 int klassItable::assign_itable_indices_for_interface(Klass* klass) {
1106   // an interface does not have an itable, but its methods need to be numbered
1107   log_develop_debug(itables)("%3d: Initializing itable indices for interface %s",
1108                              ++initialize_count, klass->name()->as_C_string());
1109   Array<Method*>* methods = InstanceKlass::cast(klass)->methods();
1110   int nof_methods = methods->length();
1111   int ime_num = 0;
1112   for (int i = 0; i < nof_methods; i++) {
1113     Method* m = methods->at(i);
1114     if (interface_method_needs_itable_index(m)) {
1115       assert(!m->is_final_method(), "no final interface methods");
1116       // If m is already assigned a vtable index, do not disturb it.
1117       if (log_develop_is_enabled(Trace, itables)) {
1118         ResourceMark rm;
1119         outputStream* logst = Log(itables)::trace_stream();

1120         assert(m != NULL, "methods can never be null");
1121         const char* sig = m->name_and_sig_as_C_string();
1122         if (m->has_vtable_index()) {
1123           logst->print("vtable index %d for method: %s, flags: ", m->vtable_index(), sig);
1124         } else {
1125           logst->print("itable index %d for method: %s, flags: ", ime_num, sig);
1126         }
1127         m->print_linkage_flags(logst);
1128         logst->cr();
1129       }
1130       if (!m->has_vtable_index()) {
1131         // A shared method could have an initialized itable_index that
1132         // is < 0.
1133         assert(m->vtable_index() == Method::pending_itable_index ||
1134                m->is_shared(),
1135                "set by initialize_vtable");
1136         m->set_itable_index(ime_num);
1137         // Progress to next itable entry
1138         ime_num++;
1139       }
1140     }
1141   }
1142   assert(ime_num == method_count_for_interface(klass), "proper sizing");
1143   return ime_num;
1144 }
1145 
1146 int klassItable::method_count_for_interface(Klass* interf) {
1147   assert(interf->is_instance_klass(), "must be");
1148   assert(interf->is_interface(), "must be");


1219             char* iface = InstanceKlass::cast(interf)->name()->as_C_string();
1220             char* failed_type_name = failed_type_symbol->as_C_string();
1221             size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
1222               strlen(current) + strlen(loader2) + strlen(iface) +
1223               strlen(failed_type_name);
1224             char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
1225             jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
1226                          iface, failed_type_name);
1227             THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
1228           }
1229         }
1230       }
1231 
1232       // ime may have moved during GC so recalculate address
1233       int ime_num = m->itable_index();
1234       assert(ime_num < ime_count, "oob");
1235       itableOffsetEntry::method_entry(_klass, method_table_offset)[ime_num].initialize(target());
1236       if (log_develop_is_enabled(Trace, itables)) {
1237         ResourceMark rm(THREAD);
1238         if (target() != NULL) {
1239           outputStream* logst = Log(itables)::trace_stream();

1240           char* sig = target()->name_and_sig_as_C_string();
1241           logst->print("interface: %s, ime_num: %d, target: %s, method_holder: %s ",
1242                        interf->internal_name(), ime_num, sig,
1243                        target()->method_holder()->internal_name());
1244           logst->print("target_method flags: ");
1245           target()->print_linkage_flags(logst);
1246           logst->cr();
1247         }
1248       }
1249     }
1250   }
1251 }
1252 
1253 #if INCLUDE_JVMTI
1254 // search the itable for uses of either obsolete or EMCP methods
1255 void klassItable::adjust_method_entries(InstanceKlass* holder, bool * trace_name_printed) {
1256 
1257   itableMethodEntry* ime = method_entry(0);
1258   for (int i = 0; i < _size_method_table; i++, ime++) {
1259     Method* old_method = ime->method();
1260     if (old_method == NULL || old_method->method_holder() != holder || !old_method->is_old()) {
1261       continue; // skip uninteresting entries
1262     }
1263     assert(!old_method->is_deleted(), "itable methods may not be deleted");
1264 
1265     Method* new_method = holder->method_with_idnum(old_method->orig_method_idnum());
1266 




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "classfile/vmSymbols.hpp"
  28 #include "gc/shared/gcLocker.hpp"
  29 #include "logging/log.hpp"
  30 #include "logging/logStream.hpp"
  31 #include "memory/metaspaceShared.hpp"
  32 #include "memory/resourceArea.hpp"
  33 #include "memory/universe.inline.hpp"
  34 #include "oops/instanceKlass.hpp"
  35 #include "oops/klassVtable.hpp"
  36 #include "oops/method.hpp"
  37 #include "oops/objArrayOop.hpp"
  38 #include "oops/oop.inline.hpp"
  39 #include "runtime/arguments.hpp"
  40 #include "runtime/handles.inline.hpp"
  41 #include "utilities/copy.hpp"
  42 
  43 inline InstanceKlass* klassVtable::ik() const {
  44   return InstanceKlass::cast(_klass);
  45 }
  46 
  47 bool klassVtable::is_preinitialized_vtable() {
  48   return _klass->is_shared() && !MetaspaceShared::remapped_readwrite();
  49 }
  50 


 285 // P1.C.m needs to override P1.A.m and can not override P2.B.m
 286 // Therefore: all package private methods need their own vtable entries for
 287 // them to be the root of an inheritance overriding decision
 288 // Package private methods may also override other vtable entries
 289 InstanceKlass* klassVtable::find_transitive_override(InstanceKlass* initialsuper, methodHandle target_method,
 290                             int vtable_index, Handle target_loader, Symbol* target_classname, Thread * THREAD) {
 291   InstanceKlass* superk = initialsuper;
 292   while (superk != NULL && superk->super() != NULL) {
 293     InstanceKlass* supersuperklass = InstanceKlass::cast(superk->super());
 294     klassVtable ssVtable = supersuperklass->vtable();
 295     if (vtable_index < ssVtable.length()) {
 296       Method* super_method = ssVtable.method_at(vtable_index);
 297 #ifndef PRODUCT
 298       Symbol* name= target_method()->name();
 299       Symbol* signature = target_method()->signature();
 300       assert(super_method->name() == name && super_method->signature() == signature, "vtable entry name/sig mismatch");
 301 #endif
 302       if (supersuperklass->is_override(super_method, target_loader, target_classname, THREAD)) {
 303         if (log_develop_is_enabled(Trace, vtables)) {
 304           ResourceMark rm(THREAD);
 305           LogTarget(Trace, vtables) lt;
 306           LogStream ls(lt);
 307           char* sig = target_method()->name_and_sig_as_C_string();
 308           ls.print("transitive overriding superclass %s with %s index %d, original flags: ",
 309                        supersuperklass->internal_name(),
 310                        sig, vtable_index);
 311           super_method->print_linkage_flags(&ls);
 312           ls.print("overriders flags: ");
 313           target_method->print_linkage_flags(&ls);
 314           ls.cr();
 315         }
 316 
 317         break; // return found superk
 318       }
 319     } else  {
 320       // super class has no vtable entry here, stop transitive search
 321       superk = (InstanceKlass*)NULL;
 322       break;
 323     }
 324     // if no override found yet, continue to search up
 325     superk = superk->super() == NULL ? NULL : InstanceKlass::cast(superk->super());
 326   }
 327 
 328   return superk;
 329 }
 330 
 331 static void log_vtables(int i, bool overrides, methodHandle target_method,
 332                         Klass* target_klass, Method* super_method,
 333                         Thread* thread) {
 334 #ifndef PRODUCT
 335   if (log_develop_is_enabled(Trace, vtables)) {
 336     ResourceMark rm(thread);
 337     LogTarget(Trace, vtables) lt;
 338     LogStream ls(lt);
 339     char* sig = target_method()->name_and_sig_as_C_string();
 340     if (overrides) {
 341       ls.print("overriding with %s index %d, original flags: ",
 342                    sig, i);
 343     } else {
 344       ls.print("NOT overriding with %s index %d, original flags: ",
 345                    sig, i);
 346     }
 347     super_method->print_linkage_flags(&ls);
 348     ls.print("overriders flags: ");
 349     target_method->print_linkage_flags(&ls);
 350     ls.cr();
 351   }
 352 #endif
 353 }
 354 
 355 // Update child's copy of super vtable for overrides
 356 // OR return true if a new vtable entry is required.
 357 // Only called for InstanceKlass's, i.e. not for arrays
 358 // If that changed, could not use _klass as handle for klass
 359 bool klassVtable::update_inherited_vtable(InstanceKlass* klass, methodHandle target_method,
 360                                           int super_vtable_len, int default_index,
 361                                           bool checkconstraints, TRAPS) {
 362   ResourceMark rm;
 363   bool allocate_new = true;
 364   assert(klass->is_instance_klass(), "must be InstanceKlass");
 365 
 366   Array<int>* def_vtable_indices = NULL;
 367   bool is_default = false;
 368 
 369   // default methods are non-private concrete methods in superinterfaces which are added
 370   // to the vtable with their real method_holder.


 536       } else {
 537         overrides = false;
 538       }
 539       log_vtables(i, overrides, target_method, target_klass, super_method, THREAD);
 540     }
 541   }
 542   return allocate_new;
 543 }
 544 
 545 void klassVtable::put_method_at(Method* m, int index) {
 546   if (is_preinitialized_vtable()) {
 547     // At runtime initialize_vtable is rerun as part of link_class_impl()
 548     // for shared class loaded by the non-boot loader to obtain the loader
 549     // constraints based on the runtime classloaders' context. The dumptime
 550     // method at the vtable index should be the same as the runtime method.
 551     assert(table()[index].method() == m,
 552            "archived method is different from the runtime method");
 553   } else {
 554     if (log_develop_is_enabled(Trace, vtables)) {
 555       ResourceMark rm;
 556       LogTarget(Trace, vtables) lt;
 557       LogStream ls(lt);
 558       const char* sig = (m != NULL) ? m->name_and_sig_as_C_string() : "<NULL>";
 559       ls.print("adding %s at index %d, flags: ", sig, index);
 560       if (m != NULL) {
 561         m->print_linkage_flags(&ls);
 562       }
 563       ls.cr();
 564     }
 565     table()[index].set(m);
 566   }
 567 }
 568 
 569 // Find out if a method "m" with superclass "super", loader "classloader" and
 570 // name "classname" needs a new vtable entry.  Let P be a class package defined
 571 // by "classloader" and "classname".
 572 // NOTE: The logic used here is very similar to the one used for computing
 573 // the vtables indices for a method. We cannot directly use that function because,
 574 // we allocate the InstanceKlass at load time, and that requires that the
 575 // superclass has been loaded.
 576 // However, the vtable entries are filled in at link time, and therefore
 577 // the superclass' vtable may not yet have been filled in.
 578 bool klassVtable::needs_new_vtable_entry(methodHandle target_method,
 579                                          const Klass* super,
 580                                          Handle classloader,
 581                                          Symbol* classname,
 582                                          AccessFlags class_flags,
 583                                          u2 major_version,


 871       add_new_mirandas_to_lists(new_mirandas, all_mirandas,
 872                                 sik->methods(), class_methods,
 873                                 default_methods, super);
 874     }
 875   }
 876 }
 877 
 878 // Discover miranda methods ("miranda" = "interface abstract, no binding"),
 879 // and append them into the vtable starting at index initialized,
 880 // return the new value of initialized.
 881 // Miranda methods use vtable entries, but do not get assigned a vtable_index
 882 // The vtable_index is discovered by searching from the end of the vtable
 883 int klassVtable::fill_in_mirandas(int initialized) {
 884   GrowableArray<Method*> mirandas(20);
 885   get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(),
 886                ik()->default_methods(), ik()->local_interfaces());
 887   for (int i = 0; i < mirandas.length(); i++) {
 888     if (log_develop_is_enabled(Trace, vtables)) {
 889       Method* meth = mirandas.at(i);
 890       ResourceMark rm(Thread::current());
 891       LogTarget(Trace, vtables) lt;
 892       LogStream ls(lt);
 893       if (meth != NULL) {
 894         char* sig = meth->name_and_sig_as_C_string();
 895         ls.print("fill in mirandas with %s index %d, flags: ",
 896                      sig, initialized);
 897         meth->print_linkage_flags(&ls);
 898         ls.cr();
 899       }
 900     }
 901     put_method_at(mirandas.at(i), initialized);
 902     ++initialized;
 903   }
 904   return initialized;
 905 }
 906 
 907 // Copy this class's vtable to the vtable beginning at start.
 908 // Used to copy superclass vtable to prefix of subclass's vtable.
 909 void klassVtable::copy_vtable_to(vtableEntry* start) {
 910   Copy::disjoint_words((HeapWord*)table(), (HeapWord*)start, _length * vtableEntry::size());
 911 }
 912 
 913 #if INCLUDE_JVMTI
 914 bool klassVtable::adjust_default_method(int vtable_index, Method* old_method, Method* new_method) {
 915   // If old_method is default, find this vtable index in default_vtable_indices
 916   // and replace that method in the _default_methods list
 917   bool updated = false;
 918 


1104   // it should already have a vtable index, don't touch it.
1105   // e.g., CharSequence.toString (from initialize_vtable)
1106   // if (m->has_vtable_index())  return false; // NO!
1107   return true;
1108 }
1109 
1110 int klassItable::assign_itable_indices_for_interface(Klass* klass) {
1111   // an interface does not have an itable, but its methods need to be numbered
1112   log_develop_debug(itables)("%3d: Initializing itable indices for interface %s",
1113                              ++initialize_count, klass->name()->as_C_string());
1114   Array<Method*>* methods = InstanceKlass::cast(klass)->methods();
1115   int nof_methods = methods->length();
1116   int ime_num = 0;
1117   for (int i = 0; i < nof_methods; i++) {
1118     Method* m = methods->at(i);
1119     if (interface_method_needs_itable_index(m)) {
1120       assert(!m->is_final_method(), "no final interface methods");
1121       // If m is already assigned a vtable index, do not disturb it.
1122       if (log_develop_is_enabled(Trace, itables)) {
1123         ResourceMark rm;
1124         LogTarget(Trace, itables) lt;
1125         LogStream ls(lt);
1126         assert(m != NULL, "methods can never be null");
1127         const char* sig = m->name_and_sig_as_C_string();
1128         if (m->has_vtable_index()) {
1129           ls.print("vtable index %d for method: %s, flags: ", m->vtable_index(), sig);
1130         } else {
1131           ls.print("itable index %d for method: %s, flags: ", ime_num, sig);
1132         }
1133         m->print_linkage_flags(&ls);
1134         ls.cr();
1135       }
1136       if (!m->has_vtable_index()) {
1137         // A shared method could have an initialized itable_index that
1138         // is < 0.
1139         assert(m->vtable_index() == Method::pending_itable_index ||
1140                m->is_shared(),
1141                "set by initialize_vtable");
1142         m->set_itable_index(ime_num);
1143         // Progress to next itable entry
1144         ime_num++;
1145       }
1146     }
1147   }
1148   assert(ime_num == method_count_for_interface(klass), "proper sizing");
1149   return ime_num;
1150 }
1151 
1152 int klassItable::method_count_for_interface(Klass* interf) {
1153   assert(interf->is_instance_klass(), "must be");
1154   assert(interf->is_interface(), "must be");


1225             char* iface = InstanceKlass::cast(interf)->name()->as_C_string();
1226             char* failed_type_name = failed_type_symbol->as_C_string();
1227             size_t buflen = strlen(msg) + strlen(sig) + strlen(loader1) +
1228               strlen(current) + strlen(loader2) + strlen(iface) +
1229               strlen(failed_type_name);
1230             char* buf = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, buflen);
1231             jio_snprintf(buf, buflen, msg, sig, loader1, current, loader2,
1232                          iface, failed_type_name);
1233             THROW_MSG(vmSymbols::java_lang_LinkageError(), buf);
1234           }
1235         }
1236       }
1237 
1238       // ime may have moved during GC so recalculate address
1239       int ime_num = m->itable_index();
1240       assert(ime_num < ime_count, "oob");
1241       itableOffsetEntry::method_entry(_klass, method_table_offset)[ime_num].initialize(target());
1242       if (log_develop_is_enabled(Trace, itables)) {
1243         ResourceMark rm(THREAD);
1244         if (target() != NULL) {
1245           LogTarget(Trace, itables) lt;
1246           LogStream ls(lt);
1247           char* sig = target()->name_and_sig_as_C_string();
1248           ls.print("interface: %s, ime_num: %d, target: %s, method_holder: %s ",
1249                        interf->internal_name(), ime_num, sig,
1250                        target()->method_holder()->internal_name());
1251           ls.print("target_method flags: ");
1252           target()->print_linkage_flags(&ls);
1253           ls.cr();
1254         }
1255       }
1256     }
1257   }
1258 }
1259 
1260 #if INCLUDE_JVMTI
1261 // search the itable for uses of either obsolete or EMCP methods
1262 void klassItable::adjust_method_entries(InstanceKlass* holder, bool * trace_name_printed) {
1263 
1264   itableMethodEntry* ime = method_entry(0);
1265   for (int i = 0; i < _size_method_table; i++, ime++) {
1266     Method* old_method = ime->method();
1267     if (old_method == NULL || old_method->method_holder() != holder || !old_method->is_old()) {
1268       continue; // skip uninteresting entries
1269     }
1270     assert(!old_method->is_deleted(), "itable methods may not be deleted");
1271 
1272     Method* new_method = holder->method_with_idnum(old_method->orig_method_idnum());
1273 


< prev index next >