--- /dev/null 2017-02-06 22:16:02.409658130 -0500 +++ new/test/gc/g1/TestConcurrentPhaseControlG1.java 2017-02-17 20:09:50.810314191 -0500 @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test TestConcurrentPhaseControl + * @bug 8169517 + * @requires vm.gc.G1 + * @summary Test of WhiteBox concurrent GC phase control. + * @key gc + * @modules java.base + * @library /test/lib + * @build sun.hotspot.WhiteBox + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run driver TestConcurrentPhaseControlG1 + */ + +import jdk.test.lib.gc.TestConcurrentPhaseControlSupport; + +public class TestConcurrentPhaseControlG1 + extends TestConcurrentPhaseControlSupport +{ + // Pairs of phase name and regex to match log string. + private static final String[][] g1Phases = { + // Step through the phases in order. + {"IDLE", null}, + {"CONCURRENT_CYCLE", "Concurrent Cycle"}, + {"IDLE", null}, // Resume IDLE before testing subphases + {"CLEAR_CLAIMED_MARKS", "Concurrent Clear Claimed Marks"}, + {"SCAN_ROOT_REGIONS", "Concurrent Scan Root Regions"}, + // ^F so not "From Roots", ^R so not "Restart" + {"CONCURRENT_MARK", "Concurrent Mark [^FR]"}, + {"IDLE", null}, // Resume IDLE before testing subphases + {"MARK_FROM_ROOTS", "Concurrent Mark From Roots"}, + {"BEFORE_REMARK", null}, + {"CREATE_LIVE_DATA", "Concurrent Create Live Data"}, + // "COMPLETE_CLEANUP", -- optional phase, not reached by this test + {"CLEANUP_FOR_NEXT_MARK", "Concurrent Cleanup for Next Mark"}, + // Clear request + {"IDLE", null}, + {"ANY", null}, + // Request a phase. + {"MARK_FROM_ROOTS", "Concurrent Mark From Roots"}, + // Request an earlier phase, to ensure loop rather than stuck at idle. + {"SCAN_ROOT_REGIONS", "Concurrent Scan Root Regions"}, + // Clear request, to unblock service. + {"IDLE", null}, + {"ANY", null}, + }; + + protected String[][] gcPhases() { + return g1Phases; + } + + protected String[] gcOptions() { + return new String[]{"-XX:+UseG1GC", "-Xlog:gc,gc+marking"}; + } + + protected String executorClassName() { + return G1Test.class.getName(); + } + + protected String gcName() { + return "G1"; + } + + public static void main(String[] args) throws Exception { + TestConcurrentPhaseControlG1 test = new TestConcurrentPhaseControlG1(); + test.run(); + } + + static class G1Test extends TestConcurrentPhaseControlSupport.Executor + { + protected String[][] gcPhases() { + return g1Phases; + } + + public static void main(String[] args) throws Exception { + G1Test test = new G1Test(); + test.run(); + } + } +}