1 /*
2 * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
226
227 bool G1ConcurrentMarkThread::request_concurrent_phase(const char* phase_name) {
228 int phase = lookup_concurrent_phase(phase_name);
229 if (phase < 0) return false;
230
231 while (!ConcurrentGCPhaseManager::wait_for_phase(phase,
232 phase_manager_stack())) {
233 assert(phase != G1ConcurrentPhase::ANY, "Wait for ANY phase must succeed");
234 if ((phase != G1ConcurrentPhase::IDLE) && !during_cycle()) {
235 // If idle and the goal is !idle, start a collection.
236 G1CollectedHeap::heap()->collect(GCCause::_wb_conc_mark);
237 }
238 }
239 return true;
240 }
241
242 void G1ConcurrentMarkThread::run_service() {
243 _vtime_start = os::elapsedVTime();
244
245 G1CollectedHeap* g1h = G1CollectedHeap::heap();
246 G1Policy* g1_policy = g1h->g1_policy();
247
248 G1ConcPhaseManager cpmanager(G1ConcurrentPhase::IDLE, this);
249
250 while (!should_terminate()) {
251 // wait until started is set.
252 sleep_before_next_cycle();
253 if (should_terminate()) {
254 break;
255 }
256
257 cpmanager.set_phase(G1ConcurrentPhase::CONCURRENT_CYCLE, false /* force */);
258
259 GCIdMark gc_id_mark;
260
261 _cm->concurrent_cycle_start();
262
263 GCTraceConcTime(Info, gc) tt("Concurrent Cycle");
264 {
265 ResourceMark rm;
266 HandleMark hm;
|
1 /*
2 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
226
227 bool G1ConcurrentMarkThread::request_concurrent_phase(const char* phase_name) {
228 int phase = lookup_concurrent_phase(phase_name);
229 if (phase < 0) return false;
230
231 while (!ConcurrentGCPhaseManager::wait_for_phase(phase,
232 phase_manager_stack())) {
233 assert(phase != G1ConcurrentPhase::ANY, "Wait for ANY phase must succeed");
234 if ((phase != G1ConcurrentPhase::IDLE) && !during_cycle()) {
235 // If idle and the goal is !idle, start a collection.
236 G1CollectedHeap::heap()->collect(GCCause::_wb_conc_mark);
237 }
238 }
239 return true;
240 }
241
242 void G1ConcurrentMarkThread::run_service() {
243 _vtime_start = os::elapsedVTime();
244
245 G1CollectedHeap* g1h = G1CollectedHeap::heap();
246 G1Policy* g1_policy = g1h->policy();
247
248 G1ConcPhaseManager cpmanager(G1ConcurrentPhase::IDLE, this);
249
250 while (!should_terminate()) {
251 // wait until started is set.
252 sleep_before_next_cycle();
253 if (should_terminate()) {
254 break;
255 }
256
257 cpmanager.set_phase(G1ConcurrentPhase::CONCURRENT_CYCLE, false /* force */);
258
259 GCIdMark gc_id_mark;
260
261 _cm->concurrent_cycle_start();
262
263 GCTraceConcTime(Info, gc) tt("Concurrent Cycle");
264 {
265 ResourceMark rm;
266 HandleMark hm;
|