hotspot/src/share/vm/oops/klassVtable.cpp
changeset 15591 b8aa0577f137
parent 14488 ab48109f7d1b
child 16591 73047b0eb568
equal deleted inserted replaced
15469:7719efe7b23d 15591:b8aa0577f137
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   608 
   608 
   609 void klassVtable::copy_vtable_to(vtableEntry* start) {
   609 void klassVtable::copy_vtable_to(vtableEntry* start) {
   610   Copy::disjoint_words((HeapWord*)table(), (HeapWord*)start, _length * vtableEntry::size());
   610   Copy::disjoint_words((HeapWord*)table(), (HeapWord*)start, _length * vtableEntry::size());
   611 }
   611 }
   612 
   612 
       
   613 #if INCLUDE_JVMTI
   613 void klassVtable::adjust_method_entries(Method** old_methods, Method** new_methods,
   614 void klassVtable::adjust_method_entries(Method** old_methods, Method** new_methods,
   614                                         int methods_length, bool * trace_name_printed) {
   615                                         int methods_length, bool * trace_name_printed) {
   615   // search the vtable for uses of either obsolete or EMCP methods
   616   // search the vtable for uses of either obsolete or EMCP methods
   616   for (int j = 0; j < methods_length; j++) {
   617   for (int j = 0; j < methods_length; j++) {
   617     Method* old_method = old_methods[j];
   618     Method* old_method = old_methods[j];
   636           // RC_TRACE macro has an embedded ResourceMark
   637           // RC_TRACE macro has an embedded ResourceMark
   637           RC_TRACE(0x00100000, ("vtable method update: %s(%s)",
   638           RC_TRACE(0x00100000, ("vtable method update: %s(%s)",
   638                                 new_method->name()->as_C_string(),
   639                                 new_method->name()->as_C_string(),
   639                                 new_method->signature()->as_C_string()));
   640                                 new_method->signature()->as_C_string()));
   640         }
   641         }
       
   642         // cannot 'break' here; see for-loop comment above.
   641       }
   643       }
   642     }
   644     }
   643   }
   645   }
   644 }
   646 }
       
   647 
       
   648 // a vtable should never contain old or obsolete methods
       
   649 bool klassVtable::check_no_old_or_obsolete_entries() {
       
   650   for (int i = 0; i < length(); i++) {
       
   651     Method* m = unchecked_method_at(i);
       
   652     if (m != NULL &&
       
   653         (NOT_PRODUCT(!m->is_valid() ||) m->is_old() || m->is_obsolete())) {
       
   654       return false;
       
   655     }
       
   656   }
       
   657   return true;
       
   658 }
       
   659 
       
   660 void klassVtable::dump_vtable() {
       
   661   tty->print_cr("vtable dump --");
       
   662   for (int i = 0; i < length(); i++) {
       
   663     Method* m = unchecked_method_at(i);
       
   664     if (m != NULL) {
       
   665       tty->print("      (%5d)  ", i);
       
   666       m->access_flags().print_on(tty);
       
   667       tty->print(" --  ");
       
   668       m->print_name(tty);
       
   669       tty->cr();
       
   670     }
       
   671   }
       
   672 }
       
   673 #endif // INCLUDE_JVMTI
   645 
   674 
   646 // CDS/RedefineClasses support - clear vtables so they can be reinitialized
   675 // CDS/RedefineClasses support - clear vtables so they can be reinitialized
   647 void klassVtable::clear_vtable() {
   676 void klassVtable::clear_vtable() {
   648   for (int i = 0; i < _length; i++) table()[i].clear();
   677   for (int i = 0; i < _length; i++) table()[i].clear();
   649 }
   678 }
   803     }
   832     }
   804     ime++;
   833     ime++;
   805   }
   834   }
   806 }
   835 }
   807 
   836 
       
   837 #if INCLUDE_JVMTI
   808 void klassItable::adjust_method_entries(Method** old_methods, Method** new_methods,
   838 void klassItable::adjust_method_entries(Method** old_methods, Method** new_methods,
   809                                         int methods_length, bool * trace_name_printed) {
   839                                         int methods_length, bool * trace_name_printed) {
   810   // search the itable for uses of either obsolete or EMCP methods
   840   // search the itable for uses of either obsolete or EMCP methods
   811   for (int j = 0; j < methods_length; j++) {
   841   for (int j = 0; j < methods_length; j++) {
   812     Method* old_method = old_methods[j];
   842     Method* old_method = old_methods[j];
   831           // RC_TRACE macro has an embedded ResourceMark
   861           // RC_TRACE macro has an embedded ResourceMark
   832           RC_TRACE(0x00200000, ("itable method update: %s(%s)",
   862           RC_TRACE(0x00200000, ("itable method update: %s(%s)",
   833             new_method->name()->as_C_string(),
   863             new_method->name()->as_C_string(),
   834             new_method->signature()->as_C_string()));
   864             new_method->signature()->as_C_string()));
   835         }
   865         }
   836         // Cannot break because there might be another entry for this method
   866         // cannot 'break' here; see for-loop comment above.
   837       }
   867       }
   838       ime++;
   868       ime++;
   839     }
   869     }
   840   }
   870   }
   841 }
   871 }
       
   872 
       
   873 // an itable should never contain old or obsolete methods
       
   874 bool klassItable::check_no_old_or_obsolete_entries() {
       
   875   itableMethodEntry* ime = method_entry(0);
       
   876   for (int i = 0; i < _size_method_table; i++) {
       
   877     Method* m = ime->method();
       
   878     if (m != NULL &&
       
   879         (NOT_PRODUCT(!m->is_valid() ||) m->is_old() || m->is_obsolete())) {
       
   880       return false;
       
   881     }
       
   882     ime++;
       
   883   }
       
   884   return true;
       
   885 }
       
   886 
       
   887 void klassItable::dump_itable() {
       
   888   itableMethodEntry* ime = method_entry(0);
       
   889   tty->print_cr("itable dump --");
       
   890   for (int i = 0; i < _size_method_table; i++) {
       
   891     Method* m = ime->method();
       
   892     if (m != NULL) {
       
   893       tty->print("      (%5d)  ", i);
       
   894       m->access_flags().print_on(tty);
       
   895       tty->print(" --  ");
       
   896       m->print_name(tty);
       
   897       tty->cr();
       
   898     }
       
   899     ime++;
       
   900   }
       
   901 }
       
   902 #endif // INCLUDE_JVMTI
   842 
   903 
   843 
   904 
   844 // Setup
   905 // Setup
   845 class InterfaceVisiterClosure : public StackObj {
   906 class InterfaceVisiterClosure : public StackObj {
   846  public:
   907  public:
  1124   tty->print_cr("%6d bytes filler overhead", VtableStats::filler);
  1185   tty->print_cr("%6d bytes filler overhead", VtableStats::filler);
  1125   tty->print_cr("%6d bytes for vtable entries (%d for arrays)", VtableStats::entries, VtableStats::array_entries);
  1186   tty->print_cr("%6d bytes for vtable entries (%d for arrays)", VtableStats::entries, VtableStats::array_entries);
  1126   tty->print_cr("%6d bytes total", total);
  1187   tty->print_cr("%6d bytes total", total);
  1127 }
  1188 }
  1128 
  1189 
  1129 bool klassVtable::check_no_old_entries() {
       
  1130   // Check that there really is no entry
       
  1131   for (int i = 0; i < length(); i++) {
       
  1132     Method* m = unchecked_method_at(i);
       
  1133     if (m != NULL) {
       
  1134         if (!m->is_valid() || m->is_old()) {
       
  1135             return false;
       
  1136         }
       
  1137     }
       
  1138   }
       
  1139   return true;
       
  1140 }
       
  1141 
       
  1142 void klassVtable::dump_vtable() {
       
  1143   tty->print_cr("vtable dump --");
       
  1144   for (int i = 0; i < length(); i++) {
       
  1145     Method* m = unchecked_method_at(i);
       
  1146     if (m != NULL) {
       
  1147       tty->print("      (%5d)  ", i);
       
  1148       m->access_flags().print_on(tty);
       
  1149       tty->print(" --  ");
       
  1150       m->print_name(tty);
       
  1151       tty->cr();
       
  1152     }
       
  1153   }
       
  1154 }
       
  1155 
       
  1156 bool klassItable::check_no_old_entries() {
       
  1157   itableMethodEntry* ime = method_entry(0);
       
  1158   for(int i = 0; i < _size_method_table; i++) {
       
  1159     Method* m = ime->method();
       
  1160     if (m != NULL && (!m->is_valid() || m->is_old())) return false;
       
  1161     ime++;
       
  1162   }
       
  1163   return true;
       
  1164 }
       
  1165 
       
  1166 int  klassItable::_total_classes;   // Total no. of classes with itables
  1190 int  klassItable::_total_classes;   // Total no. of classes with itables
  1167 long klassItable::_total_size;      // Total no. of bytes used for itables
  1191 long klassItable::_total_size;      // Total no. of bytes used for itables
  1168 
  1192 
  1169 void klassItable::print_statistics() {
  1193 void klassItable::print_statistics() {
  1170  tty->print_cr("itable statistics:");
  1194  tty->print_cr("itable statistics:");