< prev index next >

src/hotspot/share/oops/klassVtable.cpp

Print this page




1316       tty->print("      (%5d)  ", i);
1317       m->access_flags().print_on(tty);
1318       if (m->is_default_method()) {
1319         tty->print("default ");
1320       }
1321       tty->print(" --  ");
1322       m->print_name(tty);
1323       tty->cr();
1324     }
1325     ime++;
1326   }
1327 }
1328 #endif // INCLUDE_JVMTI
1329 
1330 // Setup
1331 class InterfaceVisiterClosure : public StackObj {
1332  public:
1333   virtual void doit(InstanceKlass* intf, int method_count) = 0;
1334 };
1335 












1336 // Visit all interfaces with at least one itable method
1337 void visit_all_interfaces(Array<InstanceKlass*>* transitive_intf, InterfaceVisiterClosure *blk) {
1338   // Handle array argument
1339   for(int i = 0; i < transitive_intf->length(); i++) {
1340     InstanceKlass* intf = transitive_intf->at(i);
1341     assert(intf->is_interface(), "sanity check");
1342 
1343     // Find no. of itable methods
1344     int method_count = 0;
1345     // method_count = klassItable::method_count_for_interface(intf);
1346     Array<Method*>* methods = intf->methods();
1347     if (methods->length() > 0) {
1348       for (int i = methods->length(); --i >= 0; ) {
1349         if (interface_method_needs_itable_index(methods->at(i))) {
1350           method_count++;
1351         }
1352       }
1353     }
1354 
1355     // Visit all interfaces which either have any methods or can participate in receiver type check.


1384     _klass_begin  = klass_begin;
1385     _offset_entry = offset_entry;
1386     _method_entry = method_entry;
1387   }
1388 
1389   itableMethodEntry* method_entry() const { return _method_entry; }
1390 
1391   void doit(InstanceKlass* intf, int method_count) {
1392     int offset = ((address)_method_entry) - _klass_begin;
1393     _offset_entry->initialize(intf, offset);
1394     _offset_entry++;
1395     _method_entry += method_count;
1396   }
1397 };
1398 
1399 int klassItable::compute_itable_size(Array<InstanceKlass*>* transitive_interfaces) {
1400   // Count no of interfaces and total number of interface methods
1401   CountInterfacesClosure cic;
1402   visit_all_interfaces(transitive_interfaces, &cic);
1403 
1404   // There's alway an extra itable entry so we can null-terminate it.
1405   int itable_size = calc_itable_size(cic.nof_interfaces() + 1, cic.nof_methods());
1406 
1407   // Statistics
1408   update_stats(itable_size * wordSize);
1409 
1410   return itable_size;
1411 }
1412 
1413 
1414 // Fill out offset table and interface klasses into the itable space
1415 void klassItable::setup_itable_offset_table(InstanceKlass* klass) {
1416   if (klass->itable_length() == 0) return;
1417   assert(!klass->is_interface(), "Should have zero length itable");
1418 
1419   // Count no of interfaces and total number of interface methods
1420   CountInterfacesClosure cic;
1421   visit_all_interfaces(klass->transitive_interfaces(), &cic);
1422   int nof_methods    = cic.nof_methods();
1423   int nof_interfaces = cic.nof_interfaces();
1424 




1316       tty->print("      (%5d)  ", i);
1317       m->access_flags().print_on(tty);
1318       if (m->is_default_method()) {
1319         tty->print("default ");
1320       }
1321       tty->print(" --  ");
1322       m->print_name(tty);
1323       tty->cr();
1324     }
1325     ime++;
1326   }
1327 }
1328 #endif // INCLUDE_JVMTI
1329 
1330 // Setup
1331 class InterfaceVisiterClosure : public StackObj {
1332  public:
1333   virtual void doit(InstanceKlass* intf, int method_count) = 0;
1334 };
1335 
1336 int count_interface_methods_needing_itable_index(Array<Method*>* methods) {
1337   int method_count = 0;
1338   if (methods->length() > 0) {
1339     for (int i = methods->length(); --i >= 0; ) {
1340       if (interface_method_needs_itable_index(methods->at(i))) {
1341         method_count++;
1342       }
1343     }
1344   }
1345   return method_count;
1346 }
1347 
1348 // Visit all interfaces with at least one itable method
1349 void visit_all_interfaces(Array<InstanceKlass*>* transitive_intf, InterfaceVisiterClosure *blk) {
1350   // Handle array argument
1351   for(int i = 0; i < transitive_intf->length(); i++) {
1352     InstanceKlass* intf = transitive_intf->at(i);
1353     assert(intf->is_interface(), "sanity check");
1354 
1355     // Find no. of itable methods
1356     int method_count = 0;
1357     // method_count = klassItable::method_count_for_interface(intf);
1358     Array<Method*>* methods = intf->methods();
1359     if (methods->length() > 0) {
1360       for (int i = methods->length(); --i >= 0; ) {
1361         if (interface_method_needs_itable_index(methods->at(i))) {
1362           method_count++;
1363         }
1364       }
1365     }
1366 
1367     // Visit all interfaces which either have any methods or can participate in receiver type check.


1396     _klass_begin  = klass_begin;
1397     _offset_entry = offset_entry;
1398     _method_entry = method_entry;
1399   }
1400 
1401   itableMethodEntry* method_entry() const { return _method_entry; }
1402 
1403   void doit(InstanceKlass* intf, int method_count) {
1404     int offset = ((address)_method_entry) - _klass_begin;
1405     _offset_entry->initialize(intf, offset);
1406     _offset_entry++;
1407     _method_entry += method_count;
1408   }
1409 };
1410 
1411 int klassItable::compute_itable_size(Array<InstanceKlass*>* transitive_interfaces) {
1412   // Count no of interfaces and total number of interface methods
1413   CountInterfacesClosure cic;
1414   visit_all_interfaces(transitive_interfaces, &cic);
1415 
1416   // There's always an extra itable entry so we can null-terminate it.
1417   int itable_size = calc_itable_size(cic.nof_interfaces() + 1, cic.nof_methods());
1418 
1419   // Statistics
1420   update_stats(itable_size * wordSize);
1421 
1422   return itable_size;
1423 }
1424 
1425 
1426 // Fill out offset table and interface klasses into the itable space
1427 void klassItable::setup_itable_offset_table(InstanceKlass* klass) {
1428   if (klass->itable_length() == 0) return;
1429   assert(!klass->is_interface(), "Should have zero length itable");
1430 
1431   // Count no of interfaces and total number of interface methods
1432   CountInterfacesClosure cic;
1433   visit_all_interfaces(klass->transitive_interfaces(), &cic);
1434   int nof_methods    = cic.nof_methods();
1435   int nof_interfaces = cic.nof_interfaces();
1436 


< prev index next >