< prev index next >

src/share/vm/oops/methodData.cpp

Print this page




  93   for (;; dp = MethodData::next_extra(dp)) {
  94     assert(dp < end, "moved past end of extra data");
  95     switch(dp->tag()) {
  96     case DataLayout::speculative_trap_data_tag:
  97       if (dp->bci() == bci()) {
  98         SpeculativeTrapData* data = new SpeculativeTrapData(dp);
  99         int trap = data->trap_state();
 100         char buf[100];
 101         ss.print("trap/");
 102         data->method()->print_short_name(&ss);
 103         ss.print("(%s) ", Deoptimization::format_trap_state(buf, sizeof(buf), trap));
 104       }
 105       break;
 106     case DataLayout::bit_data_tag:
 107       break;
 108     case DataLayout::no_tag:
 109     case DataLayout::arg_info_data_tag:
 110       return ss.as_string();
 111       break;
 112     default:
 113       fatal(err_msg("unexpected tag %d", dp->tag()));
 114     }
 115   }
 116   return NULL;
 117 }
 118 
 119 void ProfileData::print_data_on(outputStream* st, const MethodData* md) const {
 120   print_data_on(st, print_data_on_helper(md));
 121 }
 122 
 123 void ProfileData::print_shared(outputStream* st, const char* name, const char* extra) const {
 124   st->print("bci: %d", bci());
 125   st->fill_to(tab_width_one);
 126   st->print("%s", name);
 127   tab(st);
 128   int trap = trap_state();
 129   if (trap != 0) {
 130     char buf[100];
 131     st->print("trap(%s) ", Deoptimization::format_trap_state(buf, sizeof(buf), trap));
 132   }
 133   if (extra != NULL) {


1222       set_hint_di(dp_to_di(data->dp()));
1223       return data;
1224     } else if (data->bci() > bci) {
1225       break;
1226     }
1227   }
1228   return bci_to_extra_data(bci, NULL, false);
1229 }
1230 
1231 DataLayout* MethodData::next_extra(DataLayout* dp) {
1232   int nb_cells = 0;
1233   switch(dp->tag()) {
1234   case DataLayout::bit_data_tag:
1235   case DataLayout::no_tag:
1236     nb_cells = BitData::static_cell_count();
1237     break;
1238   case DataLayout::speculative_trap_data_tag:
1239     nb_cells = SpeculativeTrapData::static_cell_count();
1240     break;
1241   default:
1242     fatal(err_msg("unexpected tag %d", dp->tag()));
1243   }
1244   return (DataLayout*)((address)dp + DataLayout::compute_size_in_bytes(nb_cells));
1245 }
1246 
1247 ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp, bool concurrent) {
1248   DataLayout* end = args_data_limit();
1249 
1250   for (;; dp = next_extra(dp)) {
1251     assert(dp < end, "moved past end of extra data");
1252     // No need for "OrderAccess::load_acquire" ops,
1253     // since the data structure is monotonic.
1254     switch(dp->tag()) {
1255     case DataLayout::no_tag:
1256       return NULL;
1257     case DataLayout::arg_info_data_tag:
1258       dp = end;
1259       return NULL; // ArgInfoData is at the end of extra data section.
1260     case DataLayout::bit_data_tag:
1261       if (m == NULL && dp->bci() == bci) {
1262         return new BitData(dp);
1263       }
1264       break;
1265     case DataLayout::speculative_trap_data_tag:
1266       if (m != NULL) {
1267         SpeculativeTrapData* data = new SpeculativeTrapData(dp);
1268         // data->method() may be null in case of a concurrent
1269         // allocation. Maybe it's for the same method. Try to use that
1270         // entry in that case.
1271         if (dp->bci() == bci) {
1272           if (data->method() == NULL) {
1273             assert(concurrent, "impossible because no concurrent allocation");
1274             return NULL;
1275           } else if (data->method() == m) {
1276             return data;
1277           }
1278         }
1279       }
1280       break;
1281     default:
1282       fatal(err_msg("unexpected tag %d", dp->tag()));
1283     }
1284   }
1285   return NULL;
1286 }
1287 
1288 
1289 // Translate a bci to its corresponding extra data, or NULL.
1290 ProfileData* MethodData::bci_to_extra_data(int bci, Method* m, bool create_if_missing) {
1291   // This code assumes an entry for a SpeculativeTrapData is 2 cells
1292   assert(2*DataLayout::compute_size_in_bytes(BitData::static_cell_count()) ==
1293          DataLayout::compute_size_in_bytes(SpeculativeTrapData::static_cell_count()),
1294          "code needs to be adjusted");
1295 
1296   // Do not create one of these if method has been redefined.
1297   if (m != NULL && m->is_old()) {
1298     return NULL;
1299   }
1300 
1301   DataLayout* dp  = extra_data_base();
1302   DataLayout* end = args_data_limit();


1383   DataLayout* dp    = extra_data_base();
1384   DataLayout* end   = args_data_limit();
1385   for (;; dp = next_extra(dp)) {
1386     assert(dp < end, "moved past end of extra data");
1387     // No need for "OrderAccess::load_acquire" ops,
1388     // since the data structure is monotonic.
1389     switch(dp->tag()) {
1390     case DataLayout::no_tag:
1391       continue;
1392     case DataLayout::bit_data_tag:
1393       data = new BitData(dp);
1394       break;
1395     case DataLayout::speculative_trap_data_tag:
1396       data = new SpeculativeTrapData(dp);
1397       break;
1398     case DataLayout::arg_info_data_tag:
1399       data = new ArgInfoData(dp);
1400       dp = end; // ArgInfoData is at the end of extra data section.
1401       break;
1402     default:
1403       fatal(err_msg("unexpected tag %d", dp->tag()));
1404     }
1405     st->print("%d", dp_to_di(data->dp()));
1406     st->fill_to(6);
1407     data->print_data_on(st);
1408     if (dp >= end) return;
1409   }
1410 }
1411 
1412 #if INCLUDE_SERVICES
1413 // Size Statistics
1414 void MethodData::collect_statistics(KlassSizeStats *sz) const {
1415   int n = sz->count(this);
1416   sz->_method_data_bytes += n;
1417   sz->_method_all_bytes += n;
1418   sz->_rw_bytes += n;
1419 }
1420 #endif // INCLUDE_SERVICES
1421 
1422 // Verification
1423 


1595       } else {
1596         // Shift this entry left if it follows dead
1597         // SpeculativeTrapData entries
1598         clean_extra_data_helper(dp, shift);
1599       }
1600       break;
1601     }
1602     case DataLayout::bit_data_tag:
1603       // Shift this entry left if it follows dead SpeculativeTrapData
1604       // entries
1605       clean_extra_data_helper(dp, shift);
1606       continue;
1607     case DataLayout::no_tag:
1608     case DataLayout::arg_info_data_tag:
1609       // We are at end of the live trap entries. The previous "shift"
1610       // cells contain entries that are either dead or were shifted
1611       // left. They need to be reset to no_tag
1612       clean_extra_data_helper(dp, shift, true);
1613       return;
1614     default:
1615       fatal(err_msg("unexpected tag %d", dp->tag()));
1616     }
1617   }
1618 }
1619 
1620 // Verify there's no unloaded or redefined method referenced by a
1621 // SpeculativeTrapData entry
1622 void MethodData::verify_extra_data_clean(CleanExtraDataClosure* cl) {
1623 #ifdef ASSERT
1624   DataLayout* dp  = extra_data_base();
1625   DataLayout* end = args_data_limit();
1626 
1627   for (; dp < end; dp = next_extra(dp)) {
1628     switch(dp->tag()) {
1629     case DataLayout::speculative_trap_data_tag: {
1630       SpeculativeTrapData* data = new SpeculativeTrapData(dp);
1631       Method* m = data->method();
1632       assert(m != NULL && cl->is_live(m), "Method should exist");
1633       break;
1634     }
1635     case DataLayout::bit_data_tag:
1636       continue;
1637     case DataLayout::no_tag:
1638     case DataLayout::arg_info_data_tag:
1639       return;
1640     default:
1641       fatal(err_msg("unexpected tag %d", dp->tag()));
1642     }
1643   }
1644 #endif
1645 }
1646 
1647 void MethodData::clean_method_data(BoolObjectClosure* is_alive) {
1648   for (ProfileData* data = first_data();
1649        is_valid(data);
1650        data = next_data(data)) {
1651     data->clean_weak_klass_links(is_alive);
1652   }
1653   ParametersTypeData* parameters = parameters_type_data();
1654   if (parameters != NULL) {
1655     parameters->clean_weak_klass_links(is_alive);
1656   }
1657 
1658   CleanExtraDataKlassClosure cl(is_alive);
1659   clean_extra_data(&cl);
1660   verify_extra_data_clean(&cl);
1661 }




  93   for (;; dp = MethodData::next_extra(dp)) {
  94     assert(dp < end, "moved past end of extra data");
  95     switch(dp->tag()) {
  96     case DataLayout::speculative_trap_data_tag:
  97       if (dp->bci() == bci()) {
  98         SpeculativeTrapData* data = new SpeculativeTrapData(dp);
  99         int trap = data->trap_state();
 100         char buf[100];
 101         ss.print("trap/");
 102         data->method()->print_short_name(&ss);
 103         ss.print("(%s) ", Deoptimization::format_trap_state(buf, sizeof(buf), trap));
 104       }
 105       break;
 106     case DataLayout::bit_data_tag:
 107       break;
 108     case DataLayout::no_tag:
 109     case DataLayout::arg_info_data_tag:
 110       return ss.as_string();
 111       break;
 112     default:
 113       fatal("unexpected tag %d", dp->tag());
 114     }
 115   }
 116   return NULL;
 117 }
 118 
 119 void ProfileData::print_data_on(outputStream* st, const MethodData* md) const {
 120   print_data_on(st, print_data_on_helper(md));
 121 }
 122 
 123 void ProfileData::print_shared(outputStream* st, const char* name, const char* extra) const {
 124   st->print("bci: %d", bci());
 125   st->fill_to(tab_width_one);
 126   st->print("%s", name);
 127   tab(st);
 128   int trap = trap_state();
 129   if (trap != 0) {
 130     char buf[100];
 131     st->print("trap(%s) ", Deoptimization::format_trap_state(buf, sizeof(buf), trap));
 132   }
 133   if (extra != NULL) {


1222       set_hint_di(dp_to_di(data->dp()));
1223       return data;
1224     } else if (data->bci() > bci) {
1225       break;
1226     }
1227   }
1228   return bci_to_extra_data(bci, NULL, false);
1229 }
1230 
1231 DataLayout* MethodData::next_extra(DataLayout* dp) {
1232   int nb_cells = 0;
1233   switch(dp->tag()) {
1234   case DataLayout::bit_data_tag:
1235   case DataLayout::no_tag:
1236     nb_cells = BitData::static_cell_count();
1237     break;
1238   case DataLayout::speculative_trap_data_tag:
1239     nb_cells = SpeculativeTrapData::static_cell_count();
1240     break;
1241   default:
1242     fatal("unexpected tag %d", dp->tag());
1243   }
1244   return (DataLayout*)((address)dp + DataLayout::compute_size_in_bytes(nb_cells));
1245 }
1246 
1247 ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp, bool concurrent) {
1248   DataLayout* end = args_data_limit();
1249 
1250   for (;; dp = next_extra(dp)) {
1251     assert(dp < end, "moved past end of extra data");
1252     // No need for "OrderAccess::load_acquire" ops,
1253     // since the data structure is monotonic.
1254     switch(dp->tag()) {
1255     case DataLayout::no_tag:
1256       return NULL;
1257     case DataLayout::arg_info_data_tag:
1258       dp = end;
1259       return NULL; // ArgInfoData is at the end of extra data section.
1260     case DataLayout::bit_data_tag:
1261       if (m == NULL && dp->bci() == bci) {
1262         return new BitData(dp);
1263       }
1264       break;
1265     case DataLayout::speculative_trap_data_tag:
1266       if (m != NULL) {
1267         SpeculativeTrapData* data = new SpeculativeTrapData(dp);
1268         // data->method() may be null in case of a concurrent
1269         // allocation. Maybe it's for the same method. Try to use that
1270         // entry in that case.
1271         if (dp->bci() == bci) {
1272           if (data->method() == NULL) {
1273             assert(concurrent, "impossible because no concurrent allocation");
1274             return NULL;
1275           } else if (data->method() == m) {
1276             return data;
1277           }
1278         }
1279       }
1280       break;
1281     default:
1282       fatal("unexpected tag %d", dp->tag());
1283     }
1284   }
1285   return NULL;
1286 }
1287 
1288 
1289 // Translate a bci to its corresponding extra data, or NULL.
1290 ProfileData* MethodData::bci_to_extra_data(int bci, Method* m, bool create_if_missing) {
1291   // This code assumes an entry for a SpeculativeTrapData is 2 cells
1292   assert(2*DataLayout::compute_size_in_bytes(BitData::static_cell_count()) ==
1293          DataLayout::compute_size_in_bytes(SpeculativeTrapData::static_cell_count()),
1294          "code needs to be adjusted");
1295 
1296   // Do not create one of these if method has been redefined.
1297   if (m != NULL && m->is_old()) {
1298     return NULL;
1299   }
1300 
1301   DataLayout* dp  = extra_data_base();
1302   DataLayout* end = args_data_limit();


1383   DataLayout* dp    = extra_data_base();
1384   DataLayout* end   = args_data_limit();
1385   for (;; dp = next_extra(dp)) {
1386     assert(dp < end, "moved past end of extra data");
1387     // No need for "OrderAccess::load_acquire" ops,
1388     // since the data structure is monotonic.
1389     switch(dp->tag()) {
1390     case DataLayout::no_tag:
1391       continue;
1392     case DataLayout::bit_data_tag:
1393       data = new BitData(dp);
1394       break;
1395     case DataLayout::speculative_trap_data_tag:
1396       data = new SpeculativeTrapData(dp);
1397       break;
1398     case DataLayout::arg_info_data_tag:
1399       data = new ArgInfoData(dp);
1400       dp = end; // ArgInfoData is at the end of extra data section.
1401       break;
1402     default:
1403       fatal("unexpected tag %d", dp->tag());
1404     }
1405     st->print("%d", dp_to_di(data->dp()));
1406     st->fill_to(6);
1407     data->print_data_on(st);
1408     if (dp >= end) return;
1409   }
1410 }
1411 
1412 #if INCLUDE_SERVICES
1413 // Size Statistics
1414 void MethodData::collect_statistics(KlassSizeStats *sz) const {
1415   int n = sz->count(this);
1416   sz->_method_data_bytes += n;
1417   sz->_method_all_bytes += n;
1418   sz->_rw_bytes += n;
1419 }
1420 #endif // INCLUDE_SERVICES
1421 
1422 // Verification
1423 


1595       } else {
1596         // Shift this entry left if it follows dead
1597         // SpeculativeTrapData entries
1598         clean_extra_data_helper(dp, shift);
1599       }
1600       break;
1601     }
1602     case DataLayout::bit_data_tag:
1603       // Shift this entry left if it follows dead SpeculativeTrapData
1604       // entries
1605       clean_extra_data_helper(dp, shift);
1606       continue;
1607     case DataLayout::no_tag:
1608     case DataLayout::arg_info_data_tag:
1609       // We are at end of the live trap entries. The previous "shift"
1610       // cells contain entries that are either dead or were shifted
1611       // left. They need to be reset to no_tag
1612       clean_extra_data_helper(dp, shift, true);
1613       return;
1614     default:
1615       fatal("unexpected tag %d", dp->tag());
1616     }
1617   }
1618 }
1619 
1620 // Verify there's no unloaded or redefined method referenced by a
1621 // SpeculativeTrapData entry
1622 void MethodData::verify_extra_data_clean(CleanExtraDataClosure* cl) {
1623 #ifdef ASSERT
1624   DataLayout* dp  = extra_data_base();
1625   DataLayout* end = args_data_limit();
1626 
1627   for (; dp < end; dp = next_extra(dp)) {
1628     switch(dp->tag()) {
1629     case DataLayout::speculative_trap_data_tag: {
1630       SpeculativeTrapData* data = new SpeculativeTrapData(dp);
1631       Method* m = data->method();
1632       assert(m != NULL && cl->is_live(m), "Method should exist");
1633       break;
1634     }
1635     case DataLayout::bit_data_tag:
1636       continue;
1637     case DataLayout::no_tag:
1638     case DataLayout::arg_info_data_tag:
1639       return;
1640     default:
1641       fatal("unexpected tag %d", dp->tag());
1642     }
1643   }
1644 #endif
1645 }
1646 
1647 void MethodData::clean_method_data(BoolObjectClosure* is_alive) {
1648   for (ProfileData* data = first_data();
1649        is_valid(data);
1650        data = next_data(data)) {
1651     data->clean_weak_klass_links(is_alive);
1652   }
1653   ParametersTypeData* parameters = parameters_type_data();
1654   if (parameters != NULL) {
1655     parameters->clean_weak_klass_links(is_alive);
1656   }
1657 
1658   CleanExtraDataKlassClosure cl(is_alive);
1659   clean_extra_data(&cl);
1660   verify_extra_data_clean(&cl);
1661 }


< prev index next >