src/share/vm/gc_implementation/shared/gcTrace.cpp

changeset 5386
2cbc8f3011a0
parent 5237
f2110083203d
child 5387
63cffb381adc
     1.1 --- a/src/share/vm/gc_implementation/shared/gcTrace.cpp	Thu Jul 04 14:56:49 2013 -0700
     1.2 +++ b/src/share/vm/gc_implementation/shared/gcTrace.cpp	Wed Jun 05 09:44:03 2013 +0200
     1.3 @@ -23,10 +23,11 @@
     1.4   */
     1.5  
     1.6  #include "precompiled.hpp"
     1.7 +#include "gc_implementation/shared/copyFailedInfo.hpp"
     1.8  #include "gc_implementation/shared/gcHeapSummary.hpp"
     1.9  #include "gc_implementation/shared/gcTimer.hpp"
    1.10  #include "gc_implementation/shared/gcTrace.hpp"
    1.11 -#include "gc_implementation/shared/copyFailedInfo.hpp"
    1.12 +#include "gc_implementation/shared/objectCountEventSender.hpp"
    1.13  #include "memory/heapInspection.hpp"
    1.14  #include "memory/referenceProcessorStats.hpp"
    1.15  #include "utilities/globalDefinitions.hpp"
    1.16 @@ -91,26 +92,36 @@
    1.17  }
    1.18  
    1.19  #if INCLUDE_SERVICES
    1.20 -void ObjectCountEventSenderClosure::do_cinfo(KlassInfoEntry* entry) {
    1.21 -  if (should_send_event(entry)) {
    1.22 -    send_event(entry);
    1.23 +class ObjectCountEventSenderClosure : public KlassInfoClosure {
    1.24 +  const GCId _gc_id;
    1.25 +  const double _size_threshold_percentage;
    1.26 +  const size_t _total_size_in_words;
    1.27 +
    1.28 + public:
    1.29 +  ObjectCountEventSenderClosure(GCId gc_id, size_t total_size_in_words) :
    1.30 +    _gc_id(gc_id),
    1.31 +    _size_threshold_percentage(ObjectCountCutOffPercent / 100),
    1.32 +    _total_size_in_words(total_size_in_words)
    1.33 +  {}
    1.34 +
    1.35 +  virtual void do_cinfo(KlassInfoEntry* entry) {
    1.36 +    if (should_send_event(entry)) {
    1.37 +      ObjectCountEventSender::send(entry, _gc_id);
    1.38 +    }
    1.39    }
    1.40 -}
    1.41  
    1.42 -void ObjectCountEventSenderClosure::send_event(KlassInfoEntry* entry) {
    1.43 -  _gc_tracer->send_object_count_after_gc_event(entry->klass(), entry->count(),
    1.44 -                                               entry->words() * BytesPerWord);
    1.45 -}
    1.46 -
    1.47 -bool ObjectCountEventSenderClosure::should_send_event(KlassInfoEntry* entry) const {
    1.48 -  double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
    1.49 -  return percentage_of_heap > _size_threshold_percentage;
    1.50 -}
    1.51 + private:
    1.52 +  bool should_send_event(const KlassInfoEntry* entry) const {
    1.53 +    double percentage_of_heap = ((double) entry->words()) / _total_size_in_words;
    1.54 +    return percentage_of_heap >= _size_threshold_percentage;
    1.55 +  }
    1.56 +};
    1.57  
    1.58  void GCTracer::report_object_count_after_gc(BoolObjectClosure* is_alive_cl) {
    1.59    assert_set_gc_id();
    1.60 +  assert(is_alive_cl != NULL, "Must supply function to check liveness");
    1.61  
    1.62 -  if (should_send_object_count_after_gc_event()) {
    1.63 +  if (ObjectCountEventSender::should_send_event()) {
    1.64      ResourceMark rm;
    1.65  
    1.66      KlassInfoTable cit(false);
    1.67 @@ -118,12 +129,12 @@
    1.68        HeapInspection hi(false, false, false, NULL);
    1.69        hi.populate_table(&cit, is_alive_cl);
    1.70  
    1.71 -      ObjectCountEventSenderClosure event_sender(this, cit.size_of_instances_in_words());
    1.72 +      ObjectCountEventSenderClosure event_sender(_shared_gc_info.id(), cit.size_of_instances_in_words());
    1.73        cit.iterate(&event_sender);
    1.74      }
    1.75    }
    1.76  }
    1.77 -#endif
    1.78 +#endif // INCLUDE_SERVICES
    1.79  
    1.80  void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const MetaspaceSummary& meta_space_summary) const {
    1.81    assert_set_gc_id();

mercurial