702 void do_object(oop obj) {
703 if (should_visit(obj)) {
704 if (!_cit->record_instance(obj)) {
705 _missed_count++;
706 }
707 }
708 }
709
710 size_t missed_count() { return _missed_count; }
711
712 private:
713 bool should_visit(oop obj) {
714 return _filter == NULL || _filter->do_object_b(obj);
715 }
716 };
717
718 size_t HeapInspection::populate_table(KlassInfoTable* cit, BoolObjectClosure *filter) {
719 ResourceMark rm;
720
721 RecordInstanceClosure ric(cit, filter);
722 Universe::heap()->safe_object_iterate(&ric);
723 return ric.missed_count();
724 }
725
726 void HeapInspection::heap_inspection(outputStream* st) {
727 ResourceMark rm;
728
729 if (_print_help) {
730 for (int c=0; c<KlassSizeStats::_num_columns; c++) {
731 st->print("%s:\n\t", name_table[c]);
732 const int max_col = 60;
733 int col = 0;
734 for (const char *p = help_table[c]; *p; p++,col++) {
735 if (col >= max_col && *p == ' ') {
736 st->print("\n\t");
737 col = 0;
738 } else {
739 st->print("%c", *p);
740 }
741 }
742 st->print_cr(".\n");
775
776 public:
777 FindInstanceClosure(Klass* k, GrowableArray<oop>* result) : _klass(k), _result(result) {};
778
779 void do_object(oop obj) {
780 if (obj->is_a(_klass)) {
781 _result->append(obj);
782 }
783 }
784 };
785
786 void HeapInspection::find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) {
787 assert(SafepointSynchronize::is_at_safepoint(), "all threads are stopped");
788 assert(Heap_lock->is_locked(), "should have the Heap_lock");
789
790 // Ensure that the heap is parsable
791 Universe::heap()->ensure_parsability(false); // no need to retire TALBs
792
793 // Iterate over objects in the heap
794 FindInstanceClosure fic(k, result);
795 Universe::heap()->safe_object_iterate(&fic);
796 }
|
702 void do_object(oop obj) {
703 if (should_visit(obj)) {
704 if (!_cit->record_instance(obj)) {
705 _missed_count++;
706 }
707 }
708 }
709
710 size_t missed_count() { return _missed_count; }
711
712 private:
713 bool should_visit(oop obj) {
714 return _filter == NULL || _filter->do_object_b(obj);
715 }
716 };
717
718 size_t HeapInspection::populate_table(KlassInfoTable* cit, BoolObjectClosure *filter) {
719 ResourceMark rm;
720
721 RecordInstanceClosure ric(cit, filter);
722 Universe::heap()->object_iterate(&ric);
723 return ric.missed_count();
724 }
725
726 void HeapInspection::heap_inspection(outputStream* st) {
727 ResourceMark rm;
728
729 if (_print_help) {
730 for (int c=0; c<KlassSizeStats::_num_columns; c++) {
731 st->print("%s:\n\t", name_table[c]);
732 const int max_col = 60;
733 int col = 0;
734 for (const char *p = help_table[c]; *p; p++,col++) {
735 if (col >= max_col && *p == ' ') {
736 st->print("\n\t");
737 col = 0;
738 } else {
739 st->print("%c", *p);
740 }
741 }
742 st->print_cr(".\n");
775
776 public:
777 FindInstanceClosure(Klass* k, GrowableArray<oop>* result) : _klass(k), _result(result) {};
778
779 void do_object(oop obj) {
780 if (obj->is_a(_klass)) {
781 _result->append(obj);
782 }
783 }
784 };
785
786 void HeapInspection::find_instances_at_safepoint(Klass* k, GrowableArray<oop>* result) {
787 assert(SafepointSynchronize::is_at_safepoint(), "all threads are stopped");
788 assert(Heap_lock->is_locked(), "should have the Heap_lock");
789
790 // Ensure that the heap is parsable
791 Universe::heap()->ensure_parsability(false); // no need to retire TALBs
792
793 // Iterate over objects in the heap
794 FindInstanceClosure fic(k, result);
795 Universe::heap()->object_iterate(&fic);
796 }
|