hotspot/src/share/vm/gc/g1/g1FullGCScope.cpp
author sjohanss
Mon, 21 Aug 2017 10:45:02 +0200
changeset 46828 19b0b4ceb75d
permissions -rw-r--r--
8177544: Restructure G1 Full GC code Reviewed-by: tschatzl, ehelin
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46828
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
     1
/*
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
     4
 *
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
     7
 * published by the Free Software Foundation.
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
     8
 *
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    13
 * accompanied this code).
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    14
 *
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    18
 *
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    21
 * questions.
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    22
 *
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    23
 */
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    24
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    25
#include "precompiled.hpp"
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    26
#include "gc/g1/g1FullGCScope.hpp"
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    27
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    28
G1FullGCScope* G1FullGCScope::_instance = NULL;
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    29
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    30
G1FullGCScope* G1FullGCScope::instance() {
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    31
  assert(_instance != NULL, "Must be setup already");
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    32
  return _instance;
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    33
}
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    34
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    35
G1FullGCScope::G1FullGCScope(bool explicit_gc, bool clear_soft) :
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    36
    _rm(),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    37
    _explicit_gc(explicit_gc),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    38
    _g1h(G1CollectedHeap::heap()),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    39
    _gc_id(),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    40
    _svc_marker(SvcGCMarker::FULL),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    41
    _timer(),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    42
    _tracer(),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    43
    _active(),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    44
    _cpu_time(),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    45
    _soft_refs(clear_soft, _g1h->collector_policy()),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    46
    _memory_stats(true, _g1h->gc_cause()),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    47
    _collector_stats(_g1h->g1mm()->full_collection_counters()),
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    48
    _heap_transition(_g1h) {
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    49
  assert(_instance == NULL, "Only one scope at a time");
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    50
  _timer.register_gc_start();
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    51
  _tracer.report_gc_start(_g1h->gc_cause(), _timer.gc_start());
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    52
  _g1h->pre_full_gc_dump(&_timer);
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    53
  _g1h->trace_heap_before_gc(&_tracer);
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    54
  _instance = this;
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    55
}
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    56
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    57
G1FullGCScope::~G1FullGCScope() {
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    58
  // We must call G1MonitoringSupport::update_sizes() in the same scoping level
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    59
  // as an active TraceMemoryManagerStats object (i.e. before the destructor for the
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    60
  // TraceMemoryManagerStats is called) so that the G1 memory pools are updated
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    61
  // before any GC notifications are raised.
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    62
  _g1h->g1mm()->update_sizes();
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    63
  _g1h->trace_heap_after_gc(&_tracer);
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    64
  _g1h->post_full_gc_dump(&_timer);
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    65
  _timer.register_gc_end();
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    66
  _tracer.report_gc_end(_timer.gc_end(), _timer.time_partitions());
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    67
  _instance = NULL;
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    68
}
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    69
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    70
bool G1FullGCScope::is_explicit_gc() {
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    71
  return _explicit_gc;
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    72
}
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    73
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    74
bool G1FullGCScope::should_clear_soft_refs() {
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    75
  return _soft_refs.should_clear();
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    76
}
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    77
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    78
STWGCTimer* G1FullGCScope::timer() {
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    79
  return &_timer;
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    80
}
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    81
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    82
SerialOldTracer* G1FullGCScope::tracer() {
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    83
  return &_tracer;
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    84
}
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    85
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    86
G1HeapTransition* G1FullGCScope::heap_transition() {
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    87
  return &_heap_transition;
19b0b4ceb75d 8177544: Restructure G1 Full GC code
sjohanss
parents:
diff changeset
    88
}