private static void testDynamicNumberOfGCThreads(String gcFlag) throws Exception {
    // UseDynamicNumberOfGCThreads and TraceDynamicGCThreads enabled
    String[] baseArgs = {
      "-XX:+" + gcFlag,
      "-Xmx10M",
      "-XX:+UseDynamicNumberOfGCThreads",
      "-Xlog:gc+task=trace",
      GCTest.class.getName()
    };

    // Base test with gc and +UseDynamicNumberOfGCThreads:
    ProcessBuilder pb_enabled = ProcessTools.createJavaProcessBuilder(baseArgs);
    verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));

    // Ensure it also works on uniprocessors or if user specifies -XX:ParallelGCThreads=1:
    String[] extraArgs = {
      "-XX:+UnlockDiagnosticVMOptions",
      "-XX:+ForceDynamicNumberOfGCThreads",
      "-XX:ParallelGCThreads=1"
    };
    String[] finalArgs = new String[baseArgs.length + extraArgs.length];
    System.arraycopy(extraArgs, 0, finalArgs, 0, extraArgs.length);
    System.arraycopy(baseArgs, 0, finalArgs, extraArgs.length, baseArgs.length);
    pb_enabled = ProcessTools.createJavaProcessBuilder(finalArgs);
    verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));

    // Turn on parallel reference processing
    String[] parRefProcArg = {"-XX:+ParallelRefProcEnabled", "-XX:-ShowMessageBoxOnError"};
    String[] parRefArgs = new String[baseArgs.length + parRefProcArg.length];
    System.arraycopy(parRefProcArg, 0, parRefArgs, 0, parRefProcArg.length);
    System.arraycopy(baseArgs, 0, parRefArgs, parRefProcArg.length, baseArgs.length);
    pb_enabled = ProcessTools.createJavaProcessBuilder(parRefArgs);
    verifyDynamicNumberOfGCThreads(new OutputAnalyzer(pb_enabled.start()));
  }
Esempio n. 2
0
  /** Compile two module definitions used by the test, jdk.test and jdk.translet. */
  public static void main(String[] args) throws Exception {

    boolean compiled;
    // Compile module jdk.test declaration
    compiled = CompilerUtils.compile(SRC_DIR.resolve("jdk.test"), MODS_DIR.resolve("jdk.test"));
    if (!compiled) {
      throw new RuntimeException("Test failed to compile module jdk.test");
    }

    // Compile module jdk.translet declaration
    compiled =
        CompilerUtils.compile(
            SRC_DIR.resolve("jdk.translet"),
            MODS_DIR.resolve("jdk.translet"),
            "--add-exports=jdk.test/test=jdk.translet",
            "-p",
            MODS_DIR.toString());
    if (!compiled) {
      throw new RuntimeException("Test failed to compile module jdk.translet");
    }

    // Sanity check that the test, jdk.test/test/MainGC.java,
    // correctly walks module jdk.test's reads list and package
    // test's, defined to module jdk.translet, export list at
    // GC safepoints.
    ProcessBuilder pb =
        ProcessTools.createJavaProcessBuilder(
            "-Xlog:modules=trace", "-p", MODS_DIR.toString(), "-m", "jdk.test/test.MainGC");
    OutputAnalyzer oa = new OutputAnalyzer(pb.start());
    oa.shouldContain("package test defined in module jdk.test, exports list being walked")
        .shouldContain("module jdk.test reads list being walked")
        .shouldHaveExitValue(0);
  }
  /** Check the result of segmented code cache related VM options. */
  public static void main(String[] args) throws Exception {
    ProcessBuilder pb;

    // Disabled with ReservedCodeCacheSize < 240MB
    pb =
        ProcessTools.createJavaProcessBuilder(
            "-XX:ReservedCodeCacheSize=239m", "-XX:+PrintCodeCache", "-version");
    verifySegmentedCodeCache(pb, false);

    // Disabled without TieredCompilation
    pb =
        ProcessTools.createJavaProcessBuilder(
            "-XX:-TieredCompilation", "-XX:+PrintCodeCache", "-version");
    verifySegmentedCodeCache(pb, false);

    // Enabled with TieredCompilation and ReservedCodeCacheSize >= 240MB
    pb =
        ProcessTools.createJavaProcessBuilder(
            "-XX:+TieredCompilation",
            "-XX:ReservedCodeCacheSize=240m",
            "-XX:+PrintCodeCache",
            "-version");
    verifySegmentedCodeCache(pb, true);
    pb =
        ProcessTools.createJavaProcessBuilder(
            "-XX:+TieredCompilation",
            "-XX:ReservedCodeCacheSize=400m",
            "-XX:+PrintCodeCache",
            "-version");
    verifySegmentedCodeCache(pb, true);

    // Always enabled if SegmentedCodeCache is set
    pb =
        ProcessTools.createJavaProcessBuilder(
            "-XX:+SegmentedCodeCache",
            "-XX:-TieredCompilation",
            "-XX:ReservedCodeCacheSize=239m",
            "-XX:+PrintCodeCache",
            "-version");
    verifySegmentedCodeCache(pb, true);

    // The profiled and non-profiled code heaps should not be available in
    // interpreter-only mode
    pb =
        ProcessTools.createJavaProcessBuilder(
            "-XX:+SegmentedCodeCache", "-Xint", "-XX:+PrintCodeCache", "-version");
    verifyCodeHeapNotExists(pb, PROFILED, NON_PROFILED);

    // If we stop compilation at CompLevel_none or CompLevel_simple we
    // don't need a profiled code heap.
    pb =
        ProcessTools.createJavaProcessBuilder(
            "-XX:+SegmentedCodeCache",
            "-XX:TieredStopAtLevel=0",
            "-XX:+PrintCodeCache",
            "-version");
    verifyCodeHeapNotExists(pb, PROFILED);
    pb =
        ProcessTools.createJavaProcessBuilder(
            "-XX:+SegmentedCodeCache",
            "-XX:TieredStopAtLevel=1",
            "-XX:+PrintCodeCache",
            "-version");
    verifyCodeHeapNotExists(pb, PROFILED);

    // Fails with too small non-nmethod code heap size
    pb = ProcessTools.createJavaProcessBuilder("-XX:NonNMethodCodeHeapSize=100K");
    failsWith(pb, "Invalid NonNMethodCodeHeapSize");

    // Fails if code heap sizes do not add up
    pb =
        ProcessTools.createJavaProcessBuilder(
            "-XX:+SegmentedCodeCache",
            "-XX:ReservedCodeCacheSize=10M",
            "-XX:NonNMethodCodeHeapSize=5M",
            "-XX:ProfiledCodeHeapSize=5M",
            "-XX:NonProfiledCodeHeapSize=5M");
    failsWith(pb, "Invalid code heap sizes");

    // Fails if not enough space for VM internal code
    long minUseSpace = WHITE_BOX.getUintxVMFlag("CodeCacheMinimumUseSpace");
    // minimum size: CodeCacheMinimumUseSpace DEBUG_ONLY(* 3)
    long minSize = (Platform.isDebugBuild() ? 3 : 1) * minUseSpace;
    pb =
        ProcessTools.createJavaProcessBuilder(
            "-XX:+SegmentedCodeCache",
            "-XX:ReservedCodeCacheSize=" + minSize,
            "-XX:InitialCodeCacheSize=100K");
    failsWith(pb, "Not enough space in non-nmethod code heap to run VM");
  }
Esempio n. 4
0
 public static void runTest(String test, String result) throws Throwable {
   ProcessBuilder pb =
       ProcessTools.createJavaProcessBuilder("-cp", testsrc + File.separator + "test.jar", test);
   OutputAnalyzer output = new OutputAnalyzer(pb.start());
   output.shouldContain("java.lang.ClassFormatError: Multiple " + result);
 }