1 /* 2 * Copyright (c) 2017, 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 */ 23 24 /* 25 * @test TestConcurrentPhaseControlG1 26 * @bug 8169517 27 * @requires vm.gc.G1 28 * @summary Test of WhiteBox concurrent GC phase control. 29 * @key gc 30 * @modules java.base 31 * @library /test/lib 32 * @build sun.hotspot.WhiteBox 33 * @run main ClassFileInstaller sun.hotspot.WhiteBox 34 * @run driver TestConcurrentPhaseControlG1 35 */ 36 37 import jdk.test.lib.gc.ConcurrentPhaseControlUtil; 38 39 public class TestConcurrentPhaseControlG1 { 40 // All requestable phases. 41 private static final String[] g1AllPhases = { 42 "ANY", 43 "IDLE", 44 "CONCURRENT_CYCLE", 45 "CLEAR_CLAIMED_MARKS", 46 "SCAN_ROOT_REGIONS", 47 "CONCURRENT_MARK", 48 "MARK_FROM_ROOTS", 49 "BEFORE_REMARK", 50 "REMARK", 51 "CREATE_LIVE_DATA", 52 "COMPLETE_CLEANUP", 53 "CLEANUP_FOR_NEXT_MARK", 54 }; 55 56 // Pairs of phase name and regex to match log stringm for stepping through, 57 private static final String[][] g1StepPhases = { 58 // Step through the phases in order. 59 {"IDLE", null}, 60 {"CONCURRENT_CYCLE", "Concurrent Cycle"}, 61 {"IDLE", null}, // Resume IDLE before testing subphases 62 {"CLEAR_CLAIMED_MARKS", "Concurrent Clear Claimed Marks"}, 63 {"SCAN_ROOT_REGIONS", "Concurrent Scan Root Regions"}, 64 // ^F so not "From Roots", ^R so not "Restart" 65 {"CONCURRENT_MARK", "Concurrent Mark [^FR]"}, 66 {"IDLE", null}, // Resume IDLE before testing subphases 67 {"MARK_FROM_ROOTS", "Concurrent Mark From Roots"}, 68 {"BEFORE_REMARK", null}, 69 {"REMARK", "Pause Remark"}, 70 {"CREATE_LIVE_DATA", "Concurrent Create Live Data"}, 71 // "COMPLETE_CLEANUP", -- optional phase, not reached by this test 72 {"CLEANUP_FOR_NEXT_MARK", "Concurrent Cleanup for Next Mark"}, 73 // Clear request 74 {"IDLE", null}, 75 {"ANY", null}, 76 // Request a phase. 77 {"MARK_FROM_ROOTS", "Concurrent Mark From Roots"}, 78 // Request an earlier phase, to ensure loop rather than stuck at idle. 79 {"SCAN_ROOT_REGIONS", "Concurrent Scan Root Regions"}, 80 // Clear request, to unblock service. 81 {"IDLE", null}, 82 {"ANY", null}, 83 }; 84 85 private static final String[] g1Options = 86 new String[]{"-XX:+UseG1GC", "-Xlog:gc,gc+marking"}; 87 88 private static final String g1Name = "G1"; 89 90 public static void main(String[] args) throws Exception { 91 ConcurrentPhaseControlUtil test = 92 new ConcurrentPhaseControlUtil(PhaseStepper.class.getName(), 93 g1StepPhases, 94 g1Options, 95 g1Name); 96 test.run(); 97 } 98 99 public static class PhaseStepper { 100 public static void main(String[] args) throws Exception { 101 ConcurrentPhaseControlUtil.Executor executor = 102 new ConcurrentPhaseControlUtil.Executor(g1AllPhases, 103 g1StepPhases); 104 executor.run(); 105 } 106 } 107 }