本文整理汇总了C++中KlassInfoEntry::count方法的典型用法代码示例。如果您正苦于以下问题:C++ KlassInfoEntry::count方法的具体用法?C++ KlassInfoEntry::count怎么用?C++ KlassInfoEntry::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KlassInfoEntry
的用法示例。
在下文中一共展示了KlassInfoEntry::count方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: record_instance
// Return false if the entry could not be recorded on account
// of running out of space required to create a new entry.
bool KlassInfoTable::record_instance(const oop obj) {
klassOop k = obj->klass();
KlassInfoEntry* elt = lookup(k);
// elt may be NULL if it's a new klass for which we
// could not allocate space for a new entry in the hashtable.
if (elt != NULL) {
elt->set_count(elt->count() + 1);
elt->set_words(elt->words() + obj->size());
return true;
} else {
return false;
}
}
示例2: print_class_stats
void KlassInfoHisto::print_class_stats(outputStream* st,
bool csv_format, const char *columns) {
ResourceMark rm;
KlassSizeStats sz, sz_sum;
int i;
julong *col_table = (julong*)(&sz);
julong *colsum_table = (julong*)(&sz_sum);
int width_table[KlassSizeStats::_num_columns];
bool selected[KlassSizeStats::_num_columns];
_selected_columns = columns;
memset(&sz_sum, 0, sizeof(sz_sum));
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
selected[c] = is_selected(name_table[c]);
}
for(i=0; i < elements()->length(); i++) {
elements()->at(i)->set_index(i+1);
}
for (int pass=1; pass<=2; pass++) {
if (pass == 2) {
print_title(st, csv_format, selected, width_table, name_table);
}
for(i=0; i < elements()->length(); i++) {
KlassInfoEntry* e = (KlassInfoEntry*)elements()->at(i);
const Klass* k = e->klass();
memset(&sz, 0, sizeof(sz));
sz._inst_count = e->count();
sz._inst_bytes = HeapWordSize * e->words();
k->collect_statistics(&sz);
sz._total_bytes = sz._ro_bytes + sz._rw_bytes;
if (pass == 1) {
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
colsum_table[c] += col_table[c];
}
} else {
int super_index = -1;
if (k->oop_is_instance()) {
Klass* super = ((InstanceKlass*)k)->java_super();
if (super) {
KlassInfoEntry* super_e = _cit->lookup(super);
if (super_e) {
super_index = super_e->index();
}
}
}
if (csv_format) {
st->print("%d,%d", e->index(), super_index);
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
if (selected[c]) {st->print("," JULONG_FORMAT, col_table[c]);}
}
st->print(",%s",e->name());
} else {
st->print("%5d %5d", e->index(), super_index);
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
if (selected[c]) {print_julong(st, width_table[c], col_table[c]);}
}
st->print(" %s", e->name());
}
if (is_selected("ClassLoader")) {
ClassLoaderData* loader_data = k->class_loader_data();
st->print(",");
loader_data->print_value_on(st);
}
st->cr();
}
}
if (pass == 1) {
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
width_table[c] = col_width(colsum_table[c], name_table[c]);
}
}
}
sz_sum._inst_size = 0;
if (csv_format) {
st->print(",");
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
if (selected[c]) {st->print("," JULONG_FORMAT, colsum_table[c]);}
}
} else {
st->print(" ");
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
if (selected[c]) {print_julong(st, width_table[c], colsum_table[c]);}
}
st->print(" Total");
if (sz_sum._total_bytes > 0) {
st->cr();
st->print(" ");
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
if (selected[c]) {
switch (c) {
case KlassSizeStats::_index_inst_size:
//.........这里部分代码省略.........
示例3: print_class_stats
void KlassInfoHisto::print_class_stats(outputStream* st,
bool csv_format, const char *columns) {
ResourceMark rm;
KlassSizeStats sz, sz_sum;
int i;
julong *col_table = (julong*)(&sz);
julong *colsum_table = (julong*)(&sz_sum);
int width_table[KlassSizeStats::_num_columns];
bool selected[KlassSizeStats::_num_columns];
_selected_columns = columns;
memset(&sz_sum, 0, sizeof(sz_sum));
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
selected[c] = is_selected(name_table[c]);
}
for(i=0; i < elements()->length(); i++) {
elements()->at(i)->set_index(i+1);
}
// First iteration is for accumulating stats totals in colsum_table[].
// Second iteration is for printing stats for each class.
for (int pass=1; pass<=2; pass++) {
if (pass == 2) {
print_title(st, csv_format, selected, width_table, name_table);
}
for(i=0; i < elements()->length(); i++) {
KlassInfoEntry* e = (KlassInfoEntry*)elements()->at(i);
const Klass* k = e->klass();
// Get the stats for this class.
memset(&sz, 0, sizeof(sz));
sz._inst_count = e->count();
sz._inst_bytes = HeapWordSize * e->words();
k->collect_statistics(&sz);
sz._total_bytes = sz._ro_bytes + sz._rw_bytes;
if (pass == 1) {
// Add the stats for this class to the overall totals.
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
colsum_table[c] += col_table[c];
}
} else {
int super_index = -1;
// Print the stats for this class.
if (k->is_instance_klass()) {
Klass* super = k->super();
if (super) {
KlassInfoEntry* super_e = _cit->lookup(super);
if (super_e) {
super_index = super_e->index();
}
}
}
if (csv_format) {
st->print("%ld,%d", e->index(), super_index);
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
if (selected[c]) {st->print("," JULONG_FORMAT, col_table[c]);}
}
st->print(",%s",e->name());
} else {
st->print("%5ld %5d", e->index(), super_index);
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
if (selected[c]) {print_julong(st, width_table[c], col_table[c]);}
}
st->print(" %s", e->name());
}
if (is_selected("ClassLoader")) {
ClassLoaderData* loader_data = k->class_loader_data();
st->print(",");
loader_data->print_value_on(st);
}
st->cr();
}
}
if (pass == 1) {
// Calculate the minimum width needed for the column by accounting for the
// column header width and the width of the largest value in the column.
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
width_table[c] = col_width(colsum_table[c], name_table[c]);
}
}
}
sz_sum._inst_size = 0;
// Print the column totals.
if (csv_format) {
st->print(",");
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
if (selected[c]) {st->print("," JULONG_FORMAT, colsum_table[c]);}
}
} else {
st->print(" ");
for (int c=0; c<KlassSizeStats::_num_columns; c++) {
if (selected[c]) {print_julong(st, width_table[c], colsum_table[c]);}
}
//.........这里部分代码省略.........
示例4: record_instance
void KlassInfoTable::record_instance(const oop obj) {
klassOop k = obj->klass();
KlassInfoEntry* elt = lookup(k);
elt->set_count(elt->count() + 1);
elt->set_words(elt->words() + obj->size());
}