src/hotspot/share/gc/g1/g1FullGCScope.cpp
changeset 47885 5caa1d5f74c1
parent 47216 71c04702a3d5
child 48168 cb5d2d4453d0
equal deleted inserted replaced
47884:3cfab71d6c81 47885:5caa1d5f74c1
    23  */
    23  */
    24 
    24 
    25 #include "precompiled.hpp"
    25 #include "precompiled.hpp"
    26 #include "gc/g1/g1FullGCScope.hpp"
    26 #include "gc/g1/g1FullGCScope.hpp"
    27 
    27 
    28 G1FullGCScope* G1FullGCScope::_instance = NULL;
       
    29 
       
    30 G1FullGCScope* G1FullGCScope::instance() {
       
    31   assert(_instance != NULL, "Must be setup already");
       
    32   return _instance;
       
    33 }
       
    34 
       
    35 G1FullGCScope::G1FullGCScope(bool explicit_gc, bool clear_soft) :
    28 G1FullGCScope::G1FullGCScope(bool explicit_gc, bool clear_soft) :
    36     _rm(),
    29     _rm(),
    37     _explicit_gc(explicit_gc),
    30     _explicit_gc(explicit_gc),
    38     _g1h(G1CollectedHeap::heap()),
    31     _g1h(G1CollectedHeap::heap()),
    39     _gc_id(),
    32     _gc_id(),
    44     _cpu_time(),
    37     _cpu_time(),
    45     _soft_refs(clear_soft, _g1h->collector_policy()),
    38     _soft_refs(clear_soft, _g1h->collector_policy()),
    46     _memory_stats(true, _g1h->gc_cause()),
    39     _memory_stats(true, _g1h->gc_cause()),
    47     _collector_stats(_g1h->g1mm()->full_collection_counters()),
    40     _collector_stats(_g1h->g1mm()->full_collection_counters()),
    48     _heap_transition(_g1h) {
    41     _heap_transition(_g1h) {
    49   assert(_instance == NULL, "Only one scope at a time");
       
    50   _timer.register_gc_start();
    42   _timer.register_gc_start();
    51   _tracer.report_gc_start(_g1h->gc_cause(), _timer.gc_start());
    43   _tracer.report_gc_start(_g1h->gc_cause(), _timer.gc_start());
    52   _g1h->pre_full_gc_dump(&_timer);
    44   _g1h->pre_full_gc_dump(&_timer);
    53   _g1h->trace_heap_before_gc(&_tracer);
    45   _g1h->trace_heap_before_gc(&_tracer);
    54   _instance = this;
       
    55 }
    46 }
    56 
    47 
    57 G1FullGCScope::~G1FullGCScope() {
    48 G1FullGCScope::~G1FullGCScope() {
    58   // We must call G1MonitoringSupport::update_sizes() in the same scoping level
    49   // We must call G1MonitoringSupport::update_sizes() in the same scoping level
    59   // as an active TraceMemoryManagerStats object (i.e. before the destructor for the
    50   // as an active TraceMemoryManagerStats object (i.e. before the destructor for the
    62   _g1h->g1mm()->update_sizes();
    53   _g1h->g1mm()->update_sizes();
    63   _g1h->trace_heap_after_gc(&_tracer);
    54   _g1h->trace_heap_after_gc(&_tracer);
    64   _g1h->post_full_gc_dump(&_timer);
    55   _g1h->post_full_gc_dump(&_timer);
    65   _timer.register_gc_end();
    56   _timer.register_gc_end();
    66   _tracer.report_gc_end(_timer.gc_end(), _timer.time_partitions());
    57   _tracer.report_gc_end(_timer.gc_end(), _timer.time_partitions());
    67   _instance = NULL;
       
    68 }
    58 }
    69 
    59 
    70 bool G1FullGCScope::is_explicit_gc() {
    60 bool G1FullGCScope::is_explicit_gc() {
    71   return _explicit_gc;
    61   return _explicit_gc;
    72 }
    62 }
    77 
    67 
    78 STWGCTimer* G1FullGCScope::timer() {
    68 STWGCTimer* G1FullGCScope::timer() {
    79   return &_timer;
    69   return &_timer;
    80 }
    70 }
    81 
    71 
    82 SerialOldTracer* G1FullGCScope::tracer() {
    72 G1FullGCTracer* G1FullGCScope::tracer() {
    83   return &_tracer;
    73   return &_tracer;
    84 }
    74 }
    85 
    75 
    86 G1HeapTransition* G1FullGCScope::heap_transition() {
    76 G1HeapTransition* G1FullGCScope::heap_transition() {
    87   return &_heap_transition;
    77   return &_heap_transition;