< prev index next >

src/share/vm/oops/klassVtable.cpp

Print this page
rev 9019 : [mq]: format.patch


  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 "memory/resourceArea.hpp"
  30 #include "memory/universe.inline.hpp"
  31 #include "oops/instanceKlass.hpp"
  32 #include "oops/klassVtable.hpp"
  33 #include "oops/method.hpp"
  34 #include "oops/objArrayOop.hpp"
  35 #include "oops/oop.inline.hpp"
  36 #include "prims/jvmtiRedefineClassesTrace.hpp"
  37 #include "runtime/arguments.hpp"
  38 #include "runtime/handles.inline.hpp"
  39 #include "utilities/copy.hpp"
  40 
  41 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  42 
  43 inline InstanceKlass* klassVtable::ik() const {
  44   Klass* k = _klass();
  45   assert(k->oop_is_instance(), "not an InstanceKlass");
  46   return (InstanceKlass*)k;
  47 }
  48 
  49 
  50 // this function computes the vtable size (including the size needed for miranda
  51 // methods) and the number of miranda methods in this class.
  52 // Note on Miranda methods: Let's say there is a class C that implements
  53 // interface I, and none of C's superclasses implements I.
  54 // Let's say there is an abstract method m in I that neither C
  55 // nor any of its super classes implement (i.e there is no method of any access,
  56 // with the same name and signature as m), then m is a Miranda method which is
  57 // entered as a public abstract method in C's vtable.  From then on it should
  58 // treated as any other public method in C for method over-ride purposes.
  59 void klassVtable::compute_vtable_size_and_num_mirandas(
  60     int* vtable_length_ret, int* num_new_mirandas,
  61     GrowableArray<Method*>* all_mirandas, Klass* super,
  62     Array<Method*>* methods, AccessFlags class_flags,


1488 #ifndef PRODUCT
1489 void klassVtable::print() {
1490   ResourceMark rm;
1491   tty->print("klassVtable for klass %s (length %d):\n", _klass->internal_name(), length());
1492   for (int i = 0; i < length(); i++) {
1493     table()[i].print();
1494     tty->cr();
1495   }
1496 }
1497 #endif
1498 
1499 void vtableEntry::verify(klassVtable* vt, outputStream* st) {
1500   NOT_PRODUCT(FlagSetting fs(IgnoreLockingAssertions, true));
1501   assert(method() != NULL, "must have set method");
1502   method()->verify();
1503   // we sub_type, because it could be a miranda method
1504   if (!vt->klass()->is_subtype_of(method()->method_holder())) {
1505 #ifndef PRODUCT
1506     print();
1507 #endif
1508     fatal("vtableEntry " PTR_FORMAT ": method is from subclass", this);
1509   }
1510 }
1511 
1512 #ifndef PRODUCT
1513 
1514 void vtableEntry::print() {
1515   ResourceMark rm;
1516   tty->print("vtableEntry %s: ", method()->name()->as_C_string());
1517   if (Verbose) {
1518     tty->print("m %#lx ", (address)method());
1519   }
1520 }
1521 
1522 class VtableStats : AllStatic {
1523  public:
1524   static int no_klasses;                // # classes with vtables
1525   static int no_array_klasses;          // # array classes
1526   static int no_instance_klasses;       // # instanceKlasses
1527   static int sum_of_vtable_len;         // total # of vtable entries
1528   static int sum_of_array_vtable_len;   // total # of vtable entries in array klasses only
1529   static int fixed;                     // total fixed overhead in bytes
1530   static int filler;                    // overhead caused by filler bytes
1531   static int entries;                   // total bytes consumed by vtable entries
1532   static int array_entries;             // total bytes consumed by array vtable entries
1533 
1534   static void do_class(Klass* k) {
1535     Klass* kl = k;
1536     klassVtable* vt = kl->vtable();
1537     if (vt == NULL) return;
1538     no_klasses++;


1569 
1570 void klassVtable::print_statistics() {
1571   ResourceMark rm;
1572   HandleMark hm;
1573   VtableStats::compute();
1574   tty->print_cr("vtable statistics:");
1575   tty->print_cr("%6d classes (%d instance, %d array)", VtableStats::no_klasses, VtableStats::no_instance_klasses, VtableStats::no_array_klasses);
1576   int total = VtableStats::fixed + VtableStats::filler + VtableStats::entries;
1577   tty->print_cr("%6d bytes fixed overhead (refs + vtable object header)", VtableStats::fixed);
1578   tty->print_cr("%6d bytes filler overhead", VtableStats::filler);
1579   tty->print_cr("%6d bytes for vtable entries (%d for arrays)", VtableStats::entries, VtableStats::array_entries);
1580   tty->print_cr("%6d bytes total", total);
1581 }
1582 
1583 int  klassItable::_total_classes;   // Total no. of classes with itables
1584 long klassItable::_total_size;      // Total no. of bytes used for itables
1585 
1586 void klassItable::print_statistics() {
1587  tty->print_cr("itable statistics:");
1588  tty->print_cr("%6d classes with itables", _total_classes);
1589  tty->print_cr("%6d K uses for itables (average by class: %d bytes)", _total_size / K, _total_size / _total_classes);
1590 }
1591 
1592 #endif // PRODUCT


  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 "memory/resourceArea.hpp"
  30 #include "memory/universe.inline.hpp"
  31 #include "oops/instanceKlass.hpp"
  32 #include "oops/klassVtable.hpp"
  33 #include "oops/method.hpp"
  34 #include "oops/objArrayOop.hpp"
  35 #include "oops/oop.inline.hpp"
  36 #include "prims/jvmtiRedefineClassesTrace.hpp"
  37 #include "runtime/arguments.hpp"
  38 #include "runtime/handles.inline.hpp"
  39 #include "utilities/copy.hpp"
  40 


  41 inline InstanceKlass* klassVtable::ik() const {
  42   Klass* k = _klass();
  43   assert(k->oop_is_instance(), "not an InstanceKlass");
  44   return (InstanceKlass*)k;
  45 }
  46 
  47 
  48 // this function computes the vtable size (including the size needed for miranda
  49 // methods) and the number of miranda methods in this class.
  50 // Note on Miranda methods: Let's say there is a class C that implements
  51 // interface I, and none of C's superclasses implements I.
  52 // Let's say there is an abstract method m in I that neither C
  53 // nor any of its super classes implement (i.e there is no method of any access,
  54 // with the same name and signature as m), then m is a Miranda method which is
  55 // entered as a public abstract method in C's vtable.  From then on it should
  56 // treated as any other public method in C for method over-ride purposes.
  57 void klassVtable::compute_vtable_size_and_num_mirandas(
  58     int* vtable_length_ret, int* num_new_mirandas,
  59     GrowableArray<Method*>* all_mirandas, Klass* super,
  60     Array<Method*>* methods, AccessFlags class_flags,


1486 #ifndef PRODUCT
1487 void klassVtable::print() {
1488   ResourceMark rm;
1489   tty->print("klassVtable for klass %s (length %d):\n", _klass->internal_name(), length());
1490   for (int i = 0; i < length(); i++) {
1491     table()[i].print();
1492     tty->cr();
1493   }
1494 }
1495 #endif
1496 
1497 void vtableEntry::verify(klassVtable* vt, outputStream* st) {
1498   NOT_PRODUCT(FlagSetting fs(IgnoreLockingAssertions, true));
1499   assert(method() != NULL, "must have set method");
1500   method()->verify();
1501   // we sub_type, because it could be a miranda method
1502   if (!vt->klass()->is_subtype_of(method()->method_holder())) {
1503 #ifndef PRODUCT
1504     print();
1505 #endif
1506     fatal("vtableEntry " PTR_FORMAT ": method is from subclass", p2i(this));
1507   }
1508 }
1509 
1510 #ifndef PRODUCT
1511 
1512 void vtableEntry::print() {
1513   ResourceMark rm;
1514   tty->print("vtableEntry %s: ", method()->name()->as_C_string());
1515   if (Verbose) {
1516     tty->print("m " INTPTR_FORMAT_W(#) " ", p2i(method()));
1517   }
1518 }
1519 
1520 class VtableStats : AllStatic {
1521  public:
1522   static int no_klasses;                // # classes with vtables
1523   static int no_array_klasses;          // # array classes
1524   static int no_instance_klasses;       // # instanceKlasses
1525   static int sum_of_vtable_len;         // total # of vtable entries
1526   static int sum_of_array_vtable_len;   // total # of vtable entries in array klasses only
1527   static int fixed;                     // total fixed overhead in bytes
1528   static int filler;                    // overhead caused by filler bytes
1529   static int entries;                   // total bytes consumed by vtable entries
1530   static int array_entries;             // total bytes consumed by array vtable entries
1531 
1532   static void do_class(Klass* k) {
1533     Klass* kl = k;
1534     klassVtable* vt = kl->vtable();
1535     if (vt == NULL) return;
1536     no_klasses++;


1567 
1568 void klassVtable::print_statistics() {
1569   ResourceMark rm;
1570   HandleMark hm;
1571   VtableStats::compute();
1572   tty->print_cr("vtable statistics:");
1573   tty->print_cr("%6d classes (%d instance, %d array)", VtableStats::no_klasses, VtableStats::no_instance_klasses, VtableStats::no_array_klasses);
1574   int total = VtableStats::fixed + VtableStats::filler + VtableStats::entries;
1575   tty->print_cr("%6d bytes fixed overhead (refs + vtable object header)", VtableStats::fixed);
1576   tty->print_cr("%6d bytes filler overhead", VtableStats::filler);
1577   tty->print_cr("%6d bytes for vtable entries (%d for arrays)", VtableStats::entries, VtableStats::array_entries);
1578   tty->print_cr("%6d bytes total", total);
1579 }
1580 
1581 int  klassItable::_total_classes;   // Total no. of classes with itables
1582 long klassItable::_total_size;      // Total no. of bytes used for itables
1583 
1584 void klassItable::print_statistics() {
1585  tty->print_cr("itable statistics:");
1586  tty->print_cr("%6d classes with itables", _total_classes);
1587  tty->print_cr("%6ld K uses for itables (average by class: %ld bytes)", _total_size / K, _total_size / _total_classes);
1588 }
1589 
1590 #endif // PRODUCT
< prev index next >