1 /*
   2  * Copyright (c) 2017, 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  */
  23 
  24 /*
  25  * @test TestConcurrentPhaseControlG1
  26  * @bug 8169517
  27  * @requires vm.gc.G1
  28  * @summary Test of WhiteBox concurrent GC phase control for G1.
  29  * @key gc
  30  * @modules java.base
  31  * @library /test/lib /
  32  * @build sun.hotspot.WhiteBox
  33  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  34  *    sun.hotspot.WhiteBox$WhiteBoxPermission
  35  * @run driver TestConcurrentPhaseControlG1
  36  */
  37 
  38 import gc.concurrent_phase_control.CheckControl;
  39 
  40 public class TestConcurrentPhaseControlG1 {
  41 
  42     // Pairs of phase name and regex to match log stringm for stepping through,
  43     private static final String[][] g1PhaseInfo = {
  44         // Step through the phases in order.
  45         {"IDLE", null},
  46         {"CONCURRENT_CYCLE", "Concurrent Cycle"},
  47         {"IDLE", null},  // Resume IDLE before testing subphases
  48         {"CLEAR_CLAIMED_MARKS", "Concurrent Clear Claimed Marks"},
  49         {"SCAN_ROOT_REGIONS", "Concurrent Scan Root Regions"},
  50         // ^F so not "From Roots", ^R so not "Restart"
  51         {"CONCURRENT_MARK", "Concurrent Mark [^FR]"},
  52         {"IDLE", null},  // Resume IDLE before testing subphases
  53         {"MARK_FROM_ROOTS", "Concurrent Mark From Roots"},
  54         {"PRECLEAN", "Concurrent Preclean"},
  55         {"BEFORE_REMARK", null},
  56         {"REMARK", "Pause Remark"},
  57         {"REBUILD_REMEMBERED_SETS", "Concurrent Rebuild Remembered Sets"},
  58         // Clear request
  59         {"IDLE", null},
  60         {"ANY", null},
  61         // Request a phase.
  62         {"MARK_FROM_ROOTS", "Concurrent Mark From Roots"},
  63         // Request an earlier phase, to ensure loop rather than stuck at idle.
  64         {"SCAN_ROOT_REGIONS", "Concurrent Scan Root Regions"},
  65         // Clear request, to unblock service.
  66         {"IDLE", null},
  67         {"ANY", null},
  68     };
  69 
  70     private static final String[] g1Options =
  71         new String[]{"-XX:+UseG1GC",  "-Xlog:gc,gc+marking"};
  72 
  73     private static final String g1Name = "G1";
  74 
  75     public static void main(String[] args) throws Exception {
  76         CheckControl.check(g1Name, g1Options, g1PhaseInfo);
  77     }
  78 }