src/hotspot/share/gc/g1/g1VMOperations.cpp
author kbarrett
Wed, 13 Nov 2019 18:00:30 -0500
changeset 59067 f080b08daace
parent 54786 ebf733a324d4
permissions -rw-r--r--
8232588: G1 concurrent System.gc can return early or late 8233279: G1: GCLocker GC with +GCLockerInvokesConcurrent spins while cycle in progress Summary: Refactor G1CH::try_collect and fix bugs with concurrent collections. Reviewed-by: tschatzl, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
53983
7935353a466a 8218880: G1 crashes when issuing a periodic GC while the GCLocker is held
tschatzl
parents: 53116
diff changeset
     2
 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4458
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4458
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4458
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6058
diff changeset
    25
#include "precompiled.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30147
diff changeset
    26
#include "gc/g1/g1CollectedHeap.inline.hpp"
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents: 49449
diff changeset
    27
#include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
37985
539c597ee0fa 8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy
mgerdin
parents: 37235
diff changeset
    28
#include "gc/g1/g1Policy.hpp"
52876
2d17750d41e7 8214791: Consistently name gc files containing VM operations
tschatzl
parents: 52874
diff changeset
    29
#include "gc/g1/g1VMOperations.hpp"
33107
77bf0d2069a3 8134953: Make the GC ID available in a central place
brutisso
parents: 33105
diff changeset
    30
#include "gc/shared/gcId.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30147
diff changeset
    31
#include "gc/shared/gcTimer.hpp"
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
    32
#include "gc/shared/gcTraceTime.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30147
diff changeset
    33
#include "gc/shared/isGCActiveMark.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 54645
diff changeset
    34
#include "memory/universe.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49377
diff changeset
    35
#include "runtime/interfaceSupport.inline.hpp"
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    37
void VM_G1CollectFull::doit() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    39
  GCCauseSetter x(g1h, _gc_cause);
53983
7935353a466a 8218880: G1 crashes when issuing a periodic GC while the GCLocker is held
tschatzl
parents: 53116
diff changeset
    40
  _gc_succeeded = g1h->do_full_collection(true /* explicit_gc */, false /* clear_all_soft_refs */);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    42
59067
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    43
VM_G1TryInitiateConcMark::VM_G1TryInitiateConcMark(uint gc_count_before,
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    44
                                                   GCCause::Cause gc_cause,
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    45
                                                   double target_pause_time_ms) :
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    46
  VM_GC_Operation(gc_count_before, gc_cause),
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    47
  _target_pause_time_ms(target_pause_time_ms),
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    48
  _transient_failure(false),
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    49
  _cycle_already_in_progress(false),
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    50
  _gc_succeeded(false)
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    51
{}
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    52
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    53
bool VM_G1TryInitiateConcMark::doit_prologue() {
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    54
  bool result = VM_GC_Operation::doit_prologue();
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    55
  // The prologue can fail for a couple of reasons. The first is that another GC
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    56
  // got scheduled and prevented the scheduling of the initial mark GC. The
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    57
  // second is that the GC locker may be active and the heap can't be expanded.
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    58
  // In both cases we want to retry the GC so that the initial mark pause is
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    59
  // actually scheduled. In the second case, however, we should stall until
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    60
  // until the GC locker is no longer active and then retry the initial mark GC.
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    61
  if (!result) _transient_failure = true;
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    62
  return result;
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    63
}
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    64
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    65
void VM_G1TryInitiateConcMark::doit() {
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    66
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    67
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    68
  GCCauseSetter x(g1h, _gc_cause);
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    69
  if (!g1h->policy()->force_initial_mark_if_outside_cycle(_gc_cause)) {
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    70
    // Failure to force the next GC pause to be an initial mark indicates
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    71
    // there is already a concurrent marking cycle in progress.  Set flag
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    72
    // to notify the caller and return immediately.
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    73
    _cycle_already_in_progress = true;
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    74
  } else if (!g1h->do_collection_pause_at_safepoint(_target_pause_time_ms)) {
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    75
    // Failure to perform the collection at all occurs because GCLocker is
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    76
    // active, and we have the bad luck to be the collection request that
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    77
    // makes a later _gc_locker collection needed.  (Else we would have hit
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    78
    // the GCLocker check in the prologue.)
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    79
    _transient_failure = true;
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    80
  } else if (g1h->should_upgrade_to_full_gc(_gc_cause)) {
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    81
    // GC ran, but we're still in trouble and need a full GC.
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    82
    log_info(gc, ergo)("Attempting maximally compacting collection");
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    83
    _gc_succeeded = g1h->do_full_collection(false, /* explicit gc */
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    84
                                            true /* clear_all_soft_refs */);
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    85
    guarantee(_gc_succeeded, "Elevated collections during the safepoint must always succeed");
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    86
  } else {
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    87
    _gc_succeeded = true;
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    88
  }
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    89
}
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    90
48631
862c41cf1c7f 8137099: G1 needs to "upgrade" GC within the safepoint if it can't allocate during that safepoint to avoid OoME
tschatzl
parents: 47216
diff changeset
    91
VM_G1CollectForAllocation::VM_G1CollectForAllocation(size_t         word_size,
862c41cf1c7f 8137099: G1 needs to "upgrade" GC within the safepoint if it can't allocate during that safepoint to avoid OoME
tschatzl
parents: 47216
diff changeset
    92
                                                     uint           gc_count_before,
862c41cf1c7f 8137099: G1 needs to "upgrade" GC within the safepoint if it can't allocate during that safepoint to avoid OoME
tschatzl
parents: 47216
diff changeset
    93
                                                     GCCause::Cause gc_cause,
52874
c45a5b46461b 8193312: Rename VM_CGC_Operation to VM_G1Concurrent
tschatzl
parents: 51332
diff changeset
    94
                                                     double         target_pause_time_ms) :
c45a5b46461b 8193312: Rename VM_CGC_Operation to VM_G1Concurrent
tschatzl
parents: 51332
diff changeset
    95
  VM_CollectForAllocation(word_size, gc_count_before, gc_cause),
53983
7935353a466a 8218880: G1 crashes when issuing a periodic GC while the GCLocker is held
tschatzl
parents: 53116
diff changeset
    96
  _gc_succeeded(false),
59067
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
    97
  _target_pause_time_ms(target_pause_time_ms) {
52874
c45a5b46461b 8193312: Rename VM_CGC_Operation to VM_G1Concurrent
tschatzl
parents: 51332
diff changeset
    98
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    99
  guarantee(target_pause_time_ms > 0.0,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32185
diff changeset
   100
            "target_pause_time_ms = %1.6lf should be positive",
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32185
diff changeset
   101
            target_pause_time_ms);
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   102
  _gc_cause = gc_cause;
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   103
}
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   104
48631
862c41cf1c7f 8137099: G1 needs to "upgrade" GC within the safepoint if it can't allocate during that safepoint to avoid OoME
tschatzl
parents: 47216
diff changeset
   105
void VM_G1CollectForAllocation::doit() {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   106
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
6058
9c9aec6ab47d 6944166: G1: explicit GCs are not always handled correctly
tonyp
parents: 5547
diff changeset
   107
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   108
  if (_word_size > 0) {
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   109
    // An allocation has been requested. So, try to do that first.
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31032
diff changeset
   110
    _result = g1h->attempt_allocation_at_safepoint(_word_size,
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31032
diff changeset
   111
                                                   false /* expect_null_cur_alloc_region */);
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   112
    if (_result != NULL) {
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   113
      // If we can successfully allocate before we actually do the
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   114
      // pause then we will consider this pause successful.
53983
7935353a466a 8218880: G1 crashes when issuing a periodic GC while the GCLocker is held
tschatzl
parents: 53116
diff changeset
   115
      _gc_succeeded = true;
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   116
      return;
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   117
    }
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   118
  }
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   119
4458
075a9ef4e467 6902303: G1: ScavengeALot should cause an incremental, rather than a full, collection
ysr
parents: 3261
diff changeset
   120
  GCCauseSetter x(g1h, _gc_cause);
48631
862c41cf1c7f 8137099: G1 needs to "upgrade" GC within the safepoint if it can't allocate during that safepoint to avoid OoME
tschatzl
parents: 47216
diff changeset
   121
  // Try a partial collection of some kind.
53983
7935353a466a 8218880: G1 crashes when issuing a periodic GC while the GCLocker is held
tschatzl
parents: 53116
diff changeset
   122
  _gc_succeeded = g1h->do_collection_pause_at_safepoint(_target_pause_time_ms);
48631
862c41cf1c7f 8137099: G1 needs to "upgrade" GC within the safepoint if it can't allocate during that safepoint to avoid OoME
tschatzl
parents: 47216
diff changeset
   123
53983
7935353a466a 8218880: G1 crashes when issuing a periodic GC while the GCLocker is held
tschatzl
parents: 53116
diff changeset
   124
  if (_gc_succeeded) {
48631
862c41cf1c7f 8137099: G1 needs to "upgrade" GC within the safepoint if it can't allocate during that safepoint to avoid OoME
tschatzl
parents: 47216
diff changeset
   125
    if (_word_size > 0) {
862c41cf1c7f 8137099: G1 needs to "upgrade" GC within the safepoint if it can't allocate during that safepoint to avoid OoME
tschatzl
parents: 47216
diff changeset
   126
      // An allocation had been requested. Do it, eventually trying a stronger
862c41cf1c7f 8137099: G1 needs to "upgrade" GC within the safepoint if it can't allocate during that safepoint to avoid OoME
tschatzl
parents: 47216
diff changeset
   127
      // kind of GC.
53983
7935353a466a 8218880: G1 crashes when issuing a periodic GC while the GCLocker is held
tschatzl
parents: 53116
diff changeset
   128
      _result = g1h->satisfy_failed_allocation(_word_size, &_gc_succeeded);
59067
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
   129
    } else if (g1h->should_upgrade_to_full_gc(_gc_cause)) {
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
   130
      // There has been a request to perform a GC to free some space. We have no
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
   131
      // information on how much memory has been asked for. In case there are
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
   132
      // absolutely no regions left to allocate into, do a maximally compacting full GC.
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
   133
      log_info(gc, ergo)("Attempting maximally compacting collection");
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
   134
      _gc_succeeded = g1h->do_full_collection(false, /* explicit gc */
f080b08daace 8232588: G1 concurrent System.gc can return early or late
kbarrett
parents: 54786
diff changeset
   135
                                              true   /* clear_all_soft_refs */);
48631
862c41cf1c7f 8137099: G1 needs to "upgrade" GC within the safepoint if it can't allocate during that safepoint to avoid OoME
tschatzl
parents: 47216
diff changeset
   136
    }
53983
7935353a466a 8218880: G1 crashes when issuing a periodic GC while the GCLocker is held
tschatzl
parents: 53116
diff changeset
   137
    guarantee(_gc_succeeded, "Elevated collections during the safepoint must always succeed.");
6058
9c9aec6ab47d 6944166: G1: explicit GCs are not always handled correctly
tonyp
parents: 5547
diff changeset
   138
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   139
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   140
52874
c45a5b46461b 8193312: Rename VM_CGC_Operation to VM_G1Concurrent
tschatzl
parents: 51332
diff changeset
   141
void VM_G1Concurrent::doit() {
35061
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
   142
  GCIdMark gc_id_mark(_gc_id);
be6025ebffea 8145092: Use Unified Logging for the GC logging
brutisso
parents: 33107
diff changeset
   143
  GCTraceCPUTime tcpu;
30147
af9a41999c6e 8076314: Remove the static instance variable SharedHeap:: _sh
brutisso
parents: 29079
diff changeset
   144
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
52874
c45a5b46461b 8193312: Rename VM_CGC_Operation to VM_G1Concurrent
tschatzl
parents: 51332
diff changeset
   145
  GCTraceTime(Info, gc) t(_message, g1h->concurrent_mark()->gc_timer_cm(), GCCause::_no_gc, true);
49377
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 49323
diff changeset
   146
  TraceCollectorStats tcs(g1h->g1mm()->conc_collection_counters());
ecd91135d645 8153333: [REDO] STW phases at Concurrent GC should count in PerfCounte
ysuenaga
parents: 49323
diff changeset
   147
  SvcGCMarker sgcm(SvcGCMarker::CONCURRENT);
30147
af9a41999c6e 8076314: Remove the static instance variable SharedHeap:: _sh
brutisso
parents: 29079
diff changeset
   148
  IsGCActiveMark x;
af9a41999c6e 8076314: Remove the static instance variable SharedHeap:: _sh
brutisso
parents: 29079
diff changeset
   149
  _cl->do_void();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   150
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   151
52874
c45a5b46461b 8193312: Rename VM_CGC_Operation to VM_G1Concurrent
tschatzl
parents: 51332
diff changeset
   152
bool VM_G1Concurrent::doit_prologue() {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   153
  Heap_lock->lock();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   154
  return true;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   155
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   156
52874
c45a5b46461b 8193312: Rename VM_CGC_Operation to VM_G1Concurrent
tschatzl
parents: 51332
diff changeset
   157
void VM_G1Concurrent::doit_epilogue() {
40892
330a02d935ad 8156500: Move Reference pending list into VM to prevent deadlocks
kbarrett
parents: 37985
diff changeset
   158
  if (Universe::has_reference_pending_list()) {
330a02d935ad 8156500: Move Reference pending list into VM to prevent deadlocks
kbarrett
parents: 37985
diff changeset
   159
    Heap_lock->notify_all();
330a02d935ad 8156500: Move Reference pending list into VM to prevent deadlocks
kbarrett
parents: 37985
diff changeset
   160
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   161
  Heap_lock->unlock();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   162
}