src/hotspot/share/oops/klassVtable.cpp
changeset 58507 7c1d0616828c
parent 58177 4932dce35882
child 58575 6941d77417f4
equal deleted inserted replaced
58506:dfe3d11378cc 58507:7c1d0616828c
   124   }
   124   }
   125   assert(vtable_length % vtableEntry::size() == 0, "bad vtable length");
   125   assert(vtable_length % vtableEntry::size() == 0, "bad vtable length");
   126   assert(vtable_length >= Universe::base_vtable_size(), "vtable too small");
   126   assert(vtable_length >= Universe::base_vtable_size(), "vtable too small");
   127 
   127 
   128   *vtable_length_ret = vtable_length;
   128   *vtable_length_ret = vtable_length;
   129 }
       
   130 
       
   131 int klassVtable::index_of(Method* m, int len) const {
       
   132   assert(m->has_vtable_index(), "do not ask this of non-vtable methods");
       
   133   return m->vtable_index();
       
   134 }
   129 }
   135 
   130 
   136 // Copy super class's vtable to the first part (prefix) of this class's vtable,
   131 // Copy super class's vtable to the first part (prefix) of this class's vtable,
   137 // and return the number of entries copied.  Expects that 'super' is the Java
   132 // and return the number of entries copied.  Expects that 'super' is the Java
   138 // super class (arrays can have "array" super classes that must be skipped).
   133 // super class (arrays can have "array" super classes that must be skipped).
   167 // Revised lookup semantics   introduced 1.3 (Kestrel beta)
   162 // Revised lookup semantics   introduced 1.3 (Kestrel beta)
   168 void klassVtable::initialize_vtable(bool checkconstraints, TRAPS) {
   163 void klassVtable::initialize_vtable(bool checkconstraints, TRAPS) {
   169 
   164 
   170   // Note:  Arrays can have intermediate array supers.  Use java_super to skip them.
   165   // Note:  Arrays can have intermediate array supers.  Use java_super to skip them.
   171   InstanceKlass* super = _klass->java_super();
   166   InstanceKlass* super = _klass->java_super();
   172   int nofNewEntries = 0;
       
   173 
   167 
   174   bool is_shared = _klass->is_shared();
   168   bool is_shared = _klass->is_shared();
   175 
   169 
   176   if (!_klass->is_array_klass()) {
   170   if (!_klass->is_array_klass()) {
   177     ResourceMark rm(THREAD);
   171     ResourceMark rm(THREAD);
  1027     }
  1021     }
  1028   }
  1022   }
  1029 }
  1023 }
  1030 #endif // INCLUDE_JVMTI
  1024 #endif // INCLUDE_JVMTI
  1031 
  1025 
  1032 // CDS/RedefineClasses support - clear vtables so they can be reinitialized
       
  1033 void klassVtable::clear_vtable() {
       
  1034   for (int i = 0; i < _length; i++) table()[i].clear();
       
  1035 }
       
  1036 
       
  1037 bool klassVtable::is_initialized() {
       
  1038   return _length == 0 || table()[0].method() != NULL;
       
  1039 }
       
  1040 
       
  1041 //-----------------------------------------------------------------------------------------
  1026 //-----------------------------------------------------------------------------------------
  1042 // Itable code
  1027 // Itable code
  1043 
  1028 
  1044 // Initialize a itableMethodEntry
  1029 // Initialize a itableMethodEntry
  1045 void itableMethodEntry::initialize(Method* m) {
  1030 void itableMethodEntry::initialize(Method* m) {
  1466   oop* v = (oop*) klass->end_of_itable();
  1451   oop* v = (oop*) klass->end_of_itable();
  1467   assert( (oop*)(ime) == v, "wrong offset calculation (2)");
  1452   assert( (oop*)(ime) == v, "wrong offset calculation (2)");
  1468 #endif
  1453 #endif
  1469 }
  1454 }
  1470 
  1455 
  1471 
       
  1472 // inverse to itable_index
       
  1473 Method* klassItable::method_for_itable_index(InstanceKlass* intf, int itable_index) {
       
  1474   assert(intf->is_interface(), "sanity check");
       
  1475   assert(intf->verify_itable_index(itable_index), "");
       
  1476   Array<Method*>* methods = InstanceKlass::cast(intf)->methods();
       
  1477 
       
  1478   if (itable_index < 0 || itable_index >= method_count_for_interface(intf))
       
  1479     return NULL;                // help caller defend against bad indices
       
  1480 
       
  1481   int index = itable_index;
       
  1482   Method* m = methods->at(index);
       
  1483   int index2 = -1;
       
  1484   while (!m->has_itable_index() ||
       
  1485          (index2 = m->itable_index()) != itable_index) {
       
  1486     assert(index2 < itable_index, "monotonic");
       
  1487     if (++index == methods->length())
       
  1488       return NULL;
       
  1489     m = methods->at(index);
       
  1490   }
       
  1491   assert(m->itable_index() == itable_index, "correct inverse");
       
  1492 
       
  1493   return m;
       
  1494 }
       
  1495 
       
  1496 void klassVtable::verify(outputStream* st, bool forced) {
  1456 void klassVtable::verify(outputStream* st, bool forced) {
  1497   // make sure table is initialized
  1457   // make sure table is initialized
  1498   if (!Universe::is_fully_initialized()) return;
  1458   if (!Universe::is_fully_initialized()) return;
  1499 #ifndef PRODUCT
  1459 #ifndef PRODUCT
  1500   // avoid redundant verifies
  1460   // avoid redundant verifies