< prev index next >

src/share/vm/oops/klassVtable.cpp

Print this page
rev 8978 : imported patch remove_err_msg


1444     if (++index == methods->length())
1445       return NULL;
1446     m = methods->at(index);
1447   }
1448   assert(m->itable_index() == itable_index, "correct inverse");
1449 
1450   return m;
1451 }
1452 
1453 void klassVtable::verify(outputStream* st, bool forced) {
1454   // make sure table is initialized
1455   if (!Universe::is_fully_initialized()) return;
1456 #ifndef PRODUCT
1457   // avoid redundant verifies
1458   if (!forced && _verify_count == Universe::verify_count()) return;
1459   _verify_count = Universe::verify_count();
1460 #endif
1461   oop* end_of_obj = (oop*)_klass() + _klass()->size();
1462   oop* end_of_vtable = (oop *)&table()[_length];
1463   if (end_of_vtable > end_of_obj) {
1464     fatal(err_msg("klass %s: klass object too short (vtable extends beyond "
1465                   "end)", _klass->internal_name()));
1466   }
1467 
1468   for (int i = 0; i < _length; i++) table()[i].verify(this, st);
1469   // verify consistency with superKlass vtable
1470   Klass* super = _klass->super();
1471   if (super != NULL) {
1472     InstanceKlass* sk = InstanceKlass::cast(super);
1473     klassVtable* vt = sk->vtable();
1474     for (int i = 0; i < vt->length(); i++) {
1475       verify_against(st, vt, i);
1476     }
1477   }
1478 }
1479 
1480 void klassVtable::verify_against(outputStream* st, klassVtable* vt, int index) {
1481   vtableEntry* vte = &vt->table()[index];
1482   if (vte->method()->name()      != table()[index].method()->name() ||
1483       vte->method()->signature() != table()[index].method()->signature()) {
1484     fatal("mismatched name/signature of vtable entries");
1485   }


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(err_msg("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




1444     if (++index == methods->length())
1445       return NULL;
1446     m = methods->at(index);
1447   }
1448   assert(m->itable_index() == itable_index, "correct inverse");
1449 
1450   return m;
1451 }
1452 
1453 void klassVtable::verify(outputStream* st, bool forced) {
1454   // make sure table is initialized
1455   if (!Universe::is_fully_initialized()) return;
1456 #ifndef PRODUCT
1457   // avoid redundant verifies
1458   if (!forced && _verify_count == Universe::verify_count()) return;
1459   _verify_count = Universe::verify_count();
1460 #endif
1461   oop* end_of_obj = (oop*)_klass() + _klass()->size();
1462   oop* end_of_vtable = (oop *)&table()[_length];
1463   if (end_of_vtable > end_of_obj) {
1464     fatal("klass %s: klass object too short (vtable extends beyond "
1465           "end)", _klass->internal_name());
1466   }
1467 
1468   for (int i = 0; i < _length; i++) table()[i].verify(this, st);
1469   // verify consistency with superKlass vtable
1470   Klass* super = _klass->super();
1471   if (super != NULL) {
1472     InstanceKlass* sk = InstanceKlass::cast(super);
1473     klassVtable* vt = sk->vtable();
1474     for (int i = 0; i < vt->length(); i++) {
1475       verify_against(st, vt, i);
1476     }
1477   }
1478 }
1479 
1480 void klassVtable::verify_against(outputStream* st, klassVtable* vt, int index) {
1481   vtableEntry* vte = &vt->table()[index];
1482   if (vte->method()->name()      != table()[index].method()->name() ||
1483       vte->method()->signature() != table()[index].method()->signature()) {
1484     fatal("mismatched name/signature of vtable entries");
1485   }


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


< prev index next >