src/hotspot/share/gc/g1/g1ConcurrentMarkThread.cpp
author kbarrett
Wed, 28 Aug 2019 14:06:37 -0400
changeset 57913 d1a6f72e4aec
parent 55268 c5fe45d1281d
child 58002 01d31583f25c
permissions -rw-r--r--
8230126: delay_to_keep_mmu can delay shutdown Summary: Wait on CGC_lock instead of sleeping to provide the delay. Reviewed-by: sangheki, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
     1
/*
53985
0da5c17f5e43 8219747: Remove g1_ prefix to g1_remset and g1_policy members in G1CollectedHeap
tschatzl
parents: 53647
diff changeset
     2
 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
     4
 *
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
     7
 * published by the Free Software Foundation.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
     8
 *
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    13
 * accompanied this code).
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    14
 *
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    18
 *
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    21
 * questions.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    22
 *
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    23
 */
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    24
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    25
#include "precompiled.hpp"
51959
db0c3952de52 8209645: Split ClassLoaderData and ClassLoaderDataGraph into separate files
coleenp
parents: 51835
diff changeset
    26
#include "classfile/classLoaderDataGraph.hpp"
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    27
#include "gc/g1/g1Analytics.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    28
#include "gc/g1/g1CollectedHeap.inline.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    29
#include "gc/g1/g1ConcurrentMark.inline.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    30
#include "gc/g1/g1ConcurrentMarkThread.inline.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    31
#include "gc/g1/g1MMUTracker.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    32
#include "gc/g1/g1Policy.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    33
#include "gc/g1/g1RemSet.hpp"
52876
2d17750d41e7 8214791: Consistently name gc files containing VM operations
tschatzl
parents: 52874
diff changeset
    34
#include "gc/g1/g1VMOperations.hpp"
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    35
#include "gc/shared/concurrentGCPhaseManager.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    36
#include "gc/shared/gcId.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    37
#include "gc/shared/gcTrace.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    38
#include "gc/shared/gcTraceTime.inline.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    39
#include "gc/shared/suspendibleThreadSet.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    40
#include "logging/log.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    41
#include "memory/resourceArea.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    42
#include "runtime/handles.inline.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    43
#include "runtime/vmThread.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    44
#include "utilities/debug.hpp"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    45
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    46
// ======= Concurrent Mark Thread ========
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    47
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    48
// Check order in EXPAND_CURRENT_PHASES
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    49
STATIC_ASSERT(ConcurrentGCPhaseManager::UNCONSTRAINED_PHASE <
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    50
              ConcurrentGCPhaseManager::IDLE_PHASE);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    51
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    52
#define EXPAND_CONCURRENT_PHASES(expander)                                 \
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    53
  expander(ANY, = ConcurrentGCPhaseManager::UNCONSTRAINED_PHASE, NULL)     \
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    54
  expander(IDLE, = ConcurrentGCPhaseManager::IDLE_PHASE, NULL)             \
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    55
  expander(CONCURRENT_CYCLE,, "Concurrent Cycle")                          \
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    56
  expander(CLEAR_CLAIMED_MARKS,, "Concurrent Clear Claimed Marks")         \
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    57
  expander(SCAN_ROOT_REGIONS,, "Concurrent Scan Root Regions")             \
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    58
  expander(CONCURRENT_MARK,, "Concurrent Mark")                            \
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    59
  expander(MARK_FROM_ROOTS,, "Concurrent Mark From Roots")                 \
50097
ed8a43d83fcc 8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents: 49668
diff changeset
    60
  expander(PRECLEAN,, "Concurrent Preclean")                               \
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    61
  expander(BEFORE_REMARK,, NULL)                                           \
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    62
  expander(REMARK,, NULL)                                                  \
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    63
  expander(REBUILD_REMEMBERED_SETS,, "Concurrent Rebuild Remembered Sets") \
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    64
  expander(CLEANUP_FOR_NEXT_MARK,, "Concurrent Cleanup for Next Mark")     \
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    65
  /* */
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    66
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    67
class G1ConcurrentPhase : public AllStatic {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    68
public:
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    69
  enum {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    70
#define CONCURRENT_PHASE_ENUM(tag, value, ignore_title) tag value,
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    71
    EXPAND_CONCURRENT_PHASES(CONCURRENT_PHASE_ENUM)
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    72
#undef CONCURRENT_PHASE_ENUM
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    73
    PHASE_ID_LIMIT
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    74
  };
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    75
};
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    76
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    77
G1ConcurrentMarkThread::G1ConcurrentMarkThread(G1ConcurrentMark* cm) :
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    78
  ConcurrentGCThread(),
51332
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 50097
diff changeset
    79
  _vtime_start(0.0),
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 50097
diff changeset
    80
  _vtime_accum(0.0),
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 50097
diff changeset
    81
  _vtime_mark_accum(0.0),
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    82
  _cm(cm),
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    83
  _state(Idle),
51332
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 50097
diff changeset
    84
  _phase_manager_stack() {
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    85
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    86
  set_name("G1 Main Marker");
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    87
  create_and_start();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    88
}
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    89
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    90
class CMRemark : public VoidClosure {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    91
  G1ConcurrentMark* _cm;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    92
public:
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    93
  CMRemark(G1ConcurrentMark* cm) : _cm(cm) {}
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    94
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    95
  void do_void(){
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    96
    _cm->remark();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    97
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    98
};
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
    99
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   100
class CMCleanup : public VoidClosure {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   101
  G1ConcurrentMark* _cm;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   102
public:
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   103
  CMCleanup(G1ConcurrentMark* cm) : _cm(cm) {}
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   104
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   105
  void do_void(){
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   106
    _cm->cleanup();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   107
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   108
};
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   109
57913
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   110
double G1ConcurrentMarkThread::mmu_delay_end(G1Policy* g1_policy, bool remark) {
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   111
  // There are 3 reasons to use SuspendibleThreadSetJoiner.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   112
  // 1. To avoid concurrency problem.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   113
  //    - G1MMUTracker::add_pause(), when_sec() and its variation(when_ms() etc..) can be called
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   114
  //      concurrently from ConcurrentMarkThread and VMThread.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   115
  // 2. If currently a gc is running, but it has not yet updated the MMU,
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   116
  //    we will not forget to consider that pause in the MMU calculation.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   117
  // 3. If currently a gc is running, ConcurrentMarkThread will wait it to be finished.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   118
  //    And then sleep for predicted amount of time by delay_to_keep_mmu().
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   119
  SuspendibleThreadSetJoiner sts_join;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   120
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   121
  const G1Analytics* analytics = g1_policy->analytics();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   122
  double prediction_ms = remark ? analytics->predict_remark_time_ms()
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   123
                                : analytics->predict_cleanup_time_ms();
57913
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   124
  double prediction = prediction_ms / MILLIUNITS;
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   125
  G1MMUTracker *mmu_tracker = g1_policy->mmu_tracker();
57913
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   126
  double now = os::elapsedTime();
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   127
  return now + mmu_tracker->when_sec(now, prediction);
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   128
}
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   129
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   130
void G1ConcurrentMarkThread::delay_to_keep_mmu(G1Policy* g1_policy, bool remark) {
54466
58751415d5f8 8222105: Add "use_" prefix to G1Policy::adaptive_young_list_length
tschatzl
parents: 53985
diff changeset
   131
  if (g1_policy->use_adaptive_young_list_length()) {
57913
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   132
    double delay_end_sec = mmu_delay_end(g1_policy, remark);
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   133
    // Wait for timeout or thread termination request.
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   134
    MonitorLocker ml(CGC_lock, Monitor::_no_safepoint_check_flag);
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   135
    while (!_cm->has_aborted()) {
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   136
      double sleep_time_sec = (delay_end_sec - os::elapsedTime());
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   137
      jlong sleep_time_ms = ceil(sleep_time_sec * MILLIUNITS);
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   138
      if (sleep_time_ms <= 0) {
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   139
        break;                  // Passed end time.
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   140
      } else if (ml.wait(sleep_time_ms, Monitor::_no_safepoint_check_flag)) {
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   141
        break;                  // Timeout => reached end time.
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   142
      } else if (should_terminate()) {
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   143
        break;                  // Wakeup for pending termination request.
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   144
      }
d1a6f72e4aec 8230126: delay_to_keep_mmu can delay shutdown
kbarrett
parents: 55268
diff changeset
   145
      // Other (possibly spurious) wakeup.  Retry with updated sleep time.
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   146
    }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   147
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   148
}
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   149
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   150
class G1ConcPhaseTimer : public GCTraceConcTimeImpl<LogLevel::Info, LOG_TAGS(gc, marking)> {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   151
  G1ConcurrentMark* _cm;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   152
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   153
 public:
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   154
  G1ConcPhaseTimer(G1ConcurrentMark* cm, const char* title) :
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   155
    GCTraceConcTimeImpl<LogLevel::Info,  LogTag::_gc, LogTag::_marking>(title),
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   156
    _cm(cm)
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   157
  {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   158
    _cm->gc_timer_cm()->register_gc_concurrent_start(title);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   159
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   160
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   161
  ~G1ConcPhaseTimer() {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   162
    _cm->gc_timer_cm()->register_gc_concurrent_end();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   163
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   164
};
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   165
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   166
static const char* const concurrent_phase_names[] = {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   167
#define CONCURRENT_PHASE_NAME(tag, ignore_value, ignore_title) XSTR(tag),
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   168
  EXPAND_CONCURRENT_PHASES(CONCURRENT_PHASE_NAME)
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   169
#undef CONCURRENT_PHASE_NAME
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   170
  NULL                          // terminator
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   171
};
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   172
// Verify dense enum assumption.  +1 for terminator.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   173
STATIC_ASSERT(G1ConcurrentPhase::PHASE_ID_LIMIT + 1 ==
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   174
              ARRAY_SIZE(concurrent_phase_names));
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   175
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   176
// Returns the phase number for name, or a negative value if unknown.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   177
static int lookup_concurrent_phase(const char* name) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   178
  const char* const* names = concurrent_phase_names;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   179
  for (uint i = 0; names[i] != NULL; ++i) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   180
    if (strcmp(name, names[i]) == 0) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   181
      return static_cast<int>(i);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   182
    }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   183
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   184
  return -1;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   185
}
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   186
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   187
// The phase must be valid and must have a title.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   188
static const char* lookup_concurrent_phase_title(int phase) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   189
  static const char* const titles[] = {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   190
#define CONCURRENT_PHASE_TITLE(ignore_tag, ignore_value, title) title,
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   191
    EXPAND_CONCURRENT_PHASES(CONCURRENT_PHASE_TITLE)
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   192
#undef CONCURRENT_PHASE_TITLE
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   193
  };
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   194
  // Verify dense enum assumption.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   195
  STATIC_ASSERT(G1ConcurrentPhase::PHASE_ID_LIMIT == ARRAY_SIZE(titles));
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   196
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   197
  assert(0 <= phase, "precondition");
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   198
  assert((uint)phase < ARRAY_SIZE(titles), "precondition");
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   199
  const char* title = titles[phase];
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   200
  assert(title != NULL, "precondition");
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   201
  return title;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   202
}
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   203
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   204
class G1ConcPhaseManager : public StackObj {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   205
  G1ConcurrentMark* _cm;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   206
  ConcurrentGCPhaseManager _manager;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   207
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   208
public:
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   209
  G1ConcPhaseManager(int phase, G1ConcurrentMarkThread* thread) :
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   210
    _cm(thread->cm()),
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   211
    _manager(phase, thread->phase_manager_stack())
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   212
  { }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   213
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   214
  ~G1ConcPhaseManager() {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   215
    // Deactivate the manager if marking aborted, to avoid blocking on
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   216
    // phase exit when the phase has been requested.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   217
    if (_cm->has_aborted()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   218
      _manager.deactivate();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   219
    }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   220
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   221
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   222
  void set_phase(int phase, bool force) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   223
    _manager.set_phase(phase, force);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   224
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   225
};
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   226
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   227
// Combine phase management and timing into one convenient utility.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   228
class G1ConcPhase : public StackObj {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   229
  G1ConcPhaseTimer _timer;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   230
  G1ConcPhaseManager _manager;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   231
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   232
public:
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   233
  G1ConcPhase(int phase, G1ConcurrentMarkThread* thread) :
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   234
    _timer(thread->cm(), lookup_concurrent_phase_title(phase)),
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   235
    _manager(phase, thread)
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   236
  { }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   237
};
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   238
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   239
bool G1ConcurrentMarkThread::request_concurrent_phase(const char* phase_name) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   240
  int phase = lookup_concurrent_phase(phase_name);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   241
  if (phase < 0) return false;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   242
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   243
  while (!ConcurrentGCPhaseManager::wait_for_phase(phase,
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   244
                                                   phase_manager_stack())) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   245
    assert(phase != G1ConcurrentPhase::ANY, "Wait for ANY phase must succeed");
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   246
    if ((phase != G1ConcurrentPhase::IDLE) && !during_cycle()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   247
      // If idle and the goal is !idle, start a collection.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   248
      G1CollectedHeap::heap()->collect(GCCause::_wb_conc_mark);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   249
    }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   250
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   251
  return true;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   252
}
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   253
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   254
void G1ConcurrentMarkThread::run_service() {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   255
  _vtime_start = os::elapsedVTime();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   256
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   257
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
53985
0da5c17f5e43 8219747: Remove g1_ prefix to g1_remset and g1_policy members in G1CollectedHeap
tschatzl
parents: 53647
diff changeset
   258
  G1Policy* policy = g1h->policy();
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   259
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   260
  G1ConcPhaseManager cpmanager(G1ConcurrentPhase::IDLE, this);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   261
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   262
  while (!should_terminate()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   263
    // wait until started is set.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   264
    sleep_before_next_cycle();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   265
    if (should_terminate()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   266
      break;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   267
    }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   268
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   269
    cpmanager.set_phase(G1ConcurrentPhase::CONCURRENT_CYCLE, false /* force */);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   270
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   271
    GCIdMark gc_id_mark;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   272
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   273
    _cm->concurrent_cycle_start();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   274
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   275
    GCTraceConcTime(Info, gc) tt("Concurrent Cycle");
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   276
    {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   277
      ResourceMark rm;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   278
      HandleMark   hm;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   279
      double cycle_start = os::elapsedVTime();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   280
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   281
      {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   282
        G1ConcPhase p(G1ConcurrentPhase::CLEAR_CLAIMED_MARKS, this);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   283
        ClassLoaderDataGraph::clear_claimed_marks();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   284
      }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   285
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   286
      // We have to ensure that we finish scanning the root regions
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   287
      // before the next GC takes place. To ensure this we have to
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   288
      // make sure that we do not join the STS until the root regions
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   289
      // have been scanned. If we did then it's possible that a
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   290
      // subsequent GC could block us from joining the STS and proceed
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   291
      // without the root regions have been scanned which would be a
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   292
      // correctness issue.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   293
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   294
      {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   295
        G1ConcPhase p(G1ConcurrentPhase::SCAN_ROOT_REGIONS, this);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   296
        _cm->scan_root_regions();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   297
      }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   298
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   299
      // It would be nice to use the G1ConcPhase class here but
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   300
      // the "end" logging is inside the loop and not at the end of
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   301
      // a scope. Also, the timer doesn't support nesting.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   302
      // Mimicking the same log output instead.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   303
      {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   304
        G1ConcPhaseManager mark_manager(G1ConcurrentPhase::CONCURRENT_MARK, this);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   305
        jlong mark_start = os::elapsed_counter();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   306
        const char* cm_title = lookup_concurrent_phase_title(G1ConcurrentPhase::CONCURRENT_MARK);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   307
        log_info(gc, marking)("%s (%.3fs)",
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   308
                              cm_title,
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   309
                              TimeHelper::counter_to_seconds(mark_start));
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   310
        for (uint iter = 1; !_cm->has_aborted(); ++iter) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   311
          // Concurrent marking.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   312
          {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   313
            G1ConcPhase p(G1ConcurrentPhase::MARK_FROM_ROOTS, this);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   314
            _cm->mark_from_roots();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   315
          }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   316
          if (_cm->has_aborted()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   317
            break;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   318
          }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   319
50097
ed8a43d83fcc 8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents: 49668
diff changeset
   320
          if (G1UseReferencePrecleaning) {
ed8a43d83fcc 8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents: 49668
diff changeset
   321
            G1ConcPhase p(G1ConcurrentPhase::PRECLEAN, this);
ed8a43d83fcc 8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents: 49668
diff changeset
   322
            _cm->preclean();
ed8a43d83fcc 8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents: 49668
diff changeset
   323
          }
ed8a43d83fcc 8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents: 49668
diff changeset
   324
ed8a43d83fcc 8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents: 49668
diff changeset
   325
          // Provide a control point before remark.
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   326
          {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   327
            G1ConcPhaseManager p(G1ConcurrentPhase::BEFORE_REMARK, this);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   328
          }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   329
          if (_cm->has_aborted()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   330
            break;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   331
          }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   332
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   333
          // Delay remark pause for MMU.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   334
          double mark_end_time = os::elapsedVTime();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   335
          jlong mark_end = os::elapsed_counter();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   336
          _vtime_mark_accum += (mark_end_time - cycle_start);
53985
0da5c17f5e43 8219747: Remove g1_ prefix to g1_remset and g1_policy members in G1CollectedHeap
tschatzl
parents: 53647
diff changeset
   337
          delay_to_keep_mmu(policy, true /* remark */);
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   338
          if (_cm->has_aborted()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   339
            break;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   340
          }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   341
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   342
          // Pause Remark.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   343
          log_info(gc, marking)("%s (%.3fs, %.3fs) %.3fms",
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   344
                                cm_title,
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   345
                                TimeHelper::counter_to_seconds(mark_start),
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   346
                                TimeHelper::counter_to_seconds(mark_end),
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   347
                                TimeHelper::counter_to_millis(mark_end - mark_start));
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   348
          mark_manager.set_phase(G1ConcurrentPhase::REMARK, false);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   349
          CMRemark cl(_cm);
52874
c45a5b46461b 8193312: Rename VM_CGC_Operation to VM_G1Concurrent
tschatzl
parents: 51959
diff changeset
   350
          VM_G1Concurrent op(&cl, "Pause Remark");
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   351
          VMThread::execute(&op);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   352
          if (_cm->has_aborted()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   353
            break;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   354
          } else if (!_cm->restart_for_overflow()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   355
            break;              // Exit loop if no restart requested.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   356
          } else {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   357
            // Loop to restart for overflow.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   358
            mark_manager.set_phase(G1ConcurrentPhase::CONCURRENT_MARK, false);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   359
            log_info(gc, marking)("%s Restart for Mark Stack Overflow (iteration #%u)",
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   360
                                  cm_title, iter);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   361
          }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   362
        }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   363
      }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   364
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   365
      if (!_cm->has_aborted()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   366
        G1ConcPhase p(G1ConcurrentPhase::REBUILD_REMEMBERED_SETS, this);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   367
        _cm->rebuild_rem_set_concurrently();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   368
      }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   369
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   370
      double end_time = os::elapsedVTime();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   371
      // Update the total virtual time before doing this, since it will try
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   372
      // to measure it to get the vtime for this marking.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   373
      _vtime_accum = (end_time - _vtime_start);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   374
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   375
      if (!_cm->has_aborted()) {
53985
0da5c17f5e43 8219747: Remove g1_ prefix to g1_remset and g1_policy members in G1CollectedHeap
tschatzl
parents: 53647
diff changeset
   376
        delay_to_keep_mmu(policy, false /* cleanup */);
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   377
      }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   378
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   379
      if (!_cm->has_aborted()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   380
        CMCleanup cl_cl(_cm);
52874
c45a5b46461b 8193312: Rename VM_CGC_Operation to VM_G1Concurrent
tschatzl
parents: 51959
diff changeset
   381
        VM_G1Concurrent op(&cl_cl, "Pause Cleanup");
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   382
        VMThread::execute(&op);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   383
      }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   384
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   385
      // We now want to allow clearing of the marking bitmap to be
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   386
      // suspended by a collection pause.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   387
      // We may have aborted just before the remark. Do not bother clearing the
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   388
      // bitmap then, as it has been done during mark abort.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   389
      if (!_cm->has_aborted()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   390
        G1ConcPhase p(G1ConcurrentPhase::CLEANUP_FOR_NEXT_MARK, this);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   391
        _cm->cleanup_for_next_mark();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   392
      }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   393
    }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   394
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   395
    // Update the number of full collections that have been
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   396
    // completed. This will also notify the FullGCCount_lock in case a
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   397
    // Java thread is waiting for a full GC to happen (e.g., it
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   398
    // called System.gc() with +ExplicitGCInvokesConcurrent).
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   399
    {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   400
      SuspendibleThreadSetJoiner sts_join;
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   401
      g1h->increment_old_marking_cycles_completed(true /* concurrent */);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   402
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   403
      _cm->concurrent_cycle_end();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   404
    }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   405
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   406
    cpmanager.set_phase(G1ConcurrentPhase::IDLE, _cm->has_aborted() /* force */);
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   407
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   408
  _cm->root_regions()->cancel_scan();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   409
}
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   410
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   411
void G1ConcurrentMarkThread::stop_service() {
54623
1126f0607c70 8222811: Consolidate MutexLockerEx and MutexLocker
coleenp
parents: 54466
diff changeset
   412
  MutexLocker ml(CGC_lock, Mutex::_no_safepoint_check_flag);
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   413
  CGC_lock->notify_all();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   414
}
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   415
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   416
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   417
void G1ConcurrentMarkThread::sleep_before_next_cycle() {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   418
  // We join here because we don't want to do the "shouldConcurrentMark()"
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   419
  // below while the world is otherwise stopped.
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   420
  assert(!in_progress(), "should have been cleared");
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   421
54645
05aaccf7d558 8222988: Use MonitorLocker rather than MutexLocker when wait/notify used
coleenp
parents: 54623
diff changeset
   422
  MonitorLocker ml(CGC_lock, Mutex::_no_safepoint_check_flag);
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   423
  while (!started() && !should_terminate()) {
54645
05aaccf7d558 8222988: Use MonitorLocker rather than MutexLocker when wait/notify used
coleenp
parents: 54623
diff changeset
   424
    ml.wait();
49659
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   425
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   426
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   427
  if (started()) {
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   428
    set_in_progress();
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   429
  }
0ed1370f52bb 8200371: In g1, rename ConcurrentMarkThread to G1ConcurrentMarkThread
lkorinth
parents:
diff changeset
   430
}