test/hotspot/jtreg/gc/arguments/TestUseCompressedOopsErgoTools.java
author rkennke
Mon, 10 Dec 2018 15:47:44 +0100
changeset 52925 9c18c9d839d3
parent 47216 71c04702a3d5
child 53523 4c5184c56dc2
permissions -rw-r--r--
8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental) Reviewed-by: kvn, roland, shade, coleenp, lmesnik, pliden, jgeorge, ihse, erikj Contributed-by: Christine Flood <chf@redhat.com>, Aleksey Shipilev <shade@redhat.com>, Roland Westrelin <rwestrel@redhat.com>, Zhenygu Gu <zgu@redhat.com>, Andrew Haley <aph@redhat.com>, Andrew Dinn <adinn@redhat.com>, Mario Torre <mtorre@redhat.com>, Roman Kennke <rkennke@redhat.com>
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19986
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
     1
/*
41705
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     4
 *
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     7
 * published by the Free Software Foundation.
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     8
 *
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    13
 * accompanied this code).
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    14
 *
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    18
 *
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    21
 * questions.
332239c052cc 8165687: Fix license and copyright headers in jd9 under hotspot/test
stsmirno
parents: 40631
diff changeset
    22
 */
19986
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    23
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    24
import com.sun.management.HotSpotDiagnosticMXBean;
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    25
import com.sun.management.VMOption;
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    26
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    27
import java.util.regex.Matcher;
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    28
import java.util.regex.Pattern;
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    29
import java.util.ArrayList;
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    30
import java.util.Arrays;
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    31
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 30604
diff changeset
    32
import jdk.test.lib.Asserts;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 30604
diff changeset
    33
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 30604
diff changeset
    34
import jdk.test.lib.process.OutputAnalyzer;
30247
9925b07bba5b 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 20002
diff changeset
    35
import java.lang.management.ManagementFactory;
19986
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    36
import sun.hotspot.WhiteBox;
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    37
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    38
class DetermineMaxHeapForCompressedOops {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    39
  public static void main(String[] args) throws Exception {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    40
    WhiteBox wb = WhiteBox.getWhiteBox();
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    41
    System.out.print(wb.getCompressedOopsMaxHeapSize());
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    42
  }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    43
}
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    44
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    45
class TestUseCompressedOopsErgoTools {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    46
20002
a81f45903813 8024662: gc/arguments/TestUseCompressedOopsErgo.java does not compile.
tschatzl
parents: 19986
diff changeset
    47
  private static long getCompressedClassSpaceSize() {
30247
9925b07bba5b 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 20002
diff changeset
    48
    HotSpotDiagnosticMXBean diagnostic =
9925b07bba5b 8042901: Allow com.sun.management to be in a different module to java.lang.management
sjiang
parents: 20002
diff changeset
    49
        ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
19986
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    50
20002
a81f45903813 8024662: gc/arguments/TestUseCompressedOopsErgo.java does not compile.
tschatzl
parents: 19986
diff changeset
    51
    VMOption option = diagnostic.getVMOption("CompressedClassSpaceSize");
19986
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    52
    return Long.parseLong(option.getValue());
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    53
  }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    54
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    55
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    56
  public static long getMaxHeapForCompressedOops(String[] vmargs) throws Exception {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    57
    OutputAnalyzer output = runWhiteBoxTest(vmargs, DetermineMaxHeapForCompressedOops.class.getName(), new String[] {}, false);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    58
    return Long.parseLong(output.getStdout());
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    59
  }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    60
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    61
  public static boolean is64bitVM() {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    62
    String val = System.getProperty("sun.arch.data.model");
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    63
    if (val == null) {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    64
      throw new RuntimeException("Could not read sun.arch.data.model");
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    65
    }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    66
    if (val.equals("64")) {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    67
      return true;
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    68
    } else if (val.equals("32")) {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    69
      return false;
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    70
    }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    71
    throw new RuntimeException("Unexpected value " + val + " of sun.arch.data.model");
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    72
  }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    73
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    74
  /**
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    75
   * Executes a new VM process with the given class and parameters.
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    76
   * @param vmargs Arguments to the VM to run
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    77
   * @param classname Name of the class to run
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    78
   * @param arguments Arguments to the class
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    79
   * @param useTestDotJavaDotOpts Use test.java.opts as part of the VM argument string
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    80
   * @return The OutputAnalyzer with the results for the invocation.
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    81
   */
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    82
  public static OutputAnalyzer runWhiteBoxTest(String[] vmargs, String classname, String[] arguments, boolean useTestDotJavaDotOpts) throws Exception {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    83
    ArrayList<String> finalargs = new ArrayList<String>();
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    84
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    85
    String[] whiteboxOpts = new String[] {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    86
      "-Xbootclasspath/a:.",
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    87
      "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI",
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    88
      "-cp", System.getProperty("java.class.path"),
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    89
    };
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    90
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    91
    if (useTestDotJavaDotOpts) {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    92
      // System.getProperty("test.java.opts") is '' if no options is set,
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    93
      // we need to skip such a result
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    94
      String[] externalVMOpts = new String[0];
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    95
      if (System.getProperty("test.java.opts") != null && System.getProperty("test.java.opts").length() != 0) {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    96
        externalVMOpts = System.getProperty("test.java.opts").split(" ");
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    97
      }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    98
      finalargs.addAll(Arrays.asList(externalVMOpts));
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
    99
    }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   100
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   101
    finalargs.addAll(Arrays.asList(vmargs));
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   102
    finalargs.addAll(Arrays.asList(whiteboxOpts));
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   103
    finalargs.add(classname);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   104
    finalargs.addAll(Arrays.asList(arguments));
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   105
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   106
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(finalargs.toArray(new String[0]));
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   107
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   108
    output.shouldHaveExitValue(0);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   109
    return output;
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   110
  }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   111
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   112
  private static String[] join(String[] part1, String part2) {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   113
    ArrayList<String> result = new ArrayList<String>();
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   114
    result.addAll(Arrays.asList(part1));
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   115
    result.add(part2);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   116
    return result.toArray(new String[0]);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   117
  }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   118
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   119
  public static void checkCompressedOopsErgo(String[] gcflags) throws Exception {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   120
    long maxHeapForCompressedOops = getMaxHeapForCompressedOops(gcflags);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   121
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   122
    checkUseCompressedOops(gcflags, maxHeapForCompressedOops, true);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   123
    checkUseCompressedOops(gcflags, maxHeapForCompressedOops - 1, true);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   124
    checkUseCompressedOops(gcflags, maxHeapForCompressedOops + 1, false);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   125
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   126
    // the use of HeapBaseMinAddress should not change the outcome
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   127
    checkUseCompressedOops(join(gcflags, "-XX:HeapBaseMinAddress=32G"), maxHeapForCompressedOops, true);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   128
    checkUseCompressedOops(join(gcflags, "-XX:HeapBaseMinAddress=32G"), maxHeapForCompressedOops - 1, true);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   129
    checkUseCompressedOops(join(gcflags, "-XX:HeapBaseMinAddress=32G"), maxHeapForCompressedOops + 1, false);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   130
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   131
    // use a different object alignment
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   132
    maxHeapForCompressedOops = getMaxHeapForCompressedOops(join(gcflags, "-XX:ObjectAlignmentInBytes=16"));
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   133
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   134
    checkUseCompressedOops(join(gcflags, "-XX:ObjectAlignmentInBytes=16"), maxHeapForCompressedOops, true);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   135
    checkUseCompressedOops(join(gcflags, "-XX:ObjectAlignmentInBytes=16"), maxHeapForCompressedOops - 1, true);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   136
    checkUseCompressedOops(join(gcflags, "-XX:ObjectAlignmentInBytes=16"), maxHeapForCompressedOops + 1, false);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   137
20002
a81f45903813 8024662: gc/arguments/TestUseCompressedOopsErgo.java does not compile.
tschatzl
parents: 19986
diff changeset
   138
    // use a different CompressedClassSpaceSize
a81f45903813 8024662: gc/arguments/TestUseCompressedOopsErgo.java does not compile.
tschatzl
parents: 19986
diff changeset
   139
    String compressedClassSpaceSizeArg = "-XX:CompressedClassSpaceSize=" + 2 * getCompressedClassSpaceSize();
a81f45903813 8024662: gc/arguments/TestUseCompressedOopsErgo.java does not compile.
tschatzl
parents: 19986
diff changeset
   140
    maxHeapForCompressedOops = getMaxHeapForCompressedOops(join(gcflags, compressedClassSpaceSizeArg));
19986
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   141
20002
a81f45903813 8024662: gc/arguments/TestUseCompressedOopsErgo.java does not compile.
tschatzl
parents: 19986
diff changeset
   142
    checkUseCompressedOops(join(gcflags, compressedClassSpaceSizeArg), maxHeapForCompressedOops, true);
a81f45903813 8024662: gc/arguments/TestUseCompressedOopsErgo.java does not compile.
tschatzl
parents: 19986
diff changeset
   143
    checkUseCompressedOops(join(gcflags, compressedClassSpaceSizeArg), maxHeapForCompressedOops - 1, true);
a81f45903813 8024662: gc/arguments/TestUseCompressedOopsErgo.java does not compile.
tschatzl
parents: 19986
diff changeset
   144
    checkUseCompressedOops(join(gcflags, compressedClassSpaceSizeArg), maxHeapForCompressedOops + 1, false);
19986
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   145
  }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   146
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   147
  private static void checkUseCompressedOops(String[] args, long heapsize, boolean expectUseCompressedOops) throws Exception {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   148
     ArrayList<String> finalargs = new ArrayList<String>();
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   149
     finalargs.addAll(Arrays.asList(args));
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   150
     finalargs.add("-Xmx" + heapsize);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   151
     finalargs.add("-XX:+PrintFlagsFinal");
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   152
     finalargs.add("-version");
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   153
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   154
     String output = expectValid(finalargs.toArray(new String[0]));
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   155
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   156
     boolean actualUseCompressedOops = getFlagBoolValue(" UseCompressedOops", output);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   157
20002
a81f45903813 8024662: gc/arguments/TestUseCompressedOopsErgo.java does not compile.
tschatzl
parents: 19986
diff changeset
   158
     Asserts.assertEQ(expectUseCompressedOops, actualUseCompressedOops);
19986
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   159
  }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   160
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   161
  private static boolean getFlagBoolValue(String flag, String where) {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   162
    Matcher m = Pattern.compile(flag + "\\s+:?= (true|false)").matcher(where);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   163
    if (!m.find()) {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   164
      throw new RuntimeException("Could not find value for flag " + flag + " in output string");
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   165
    }
20002
a81f45903813 8024662: gc/arguments/TestUseCompressedOopsErgo.java does not compile.
tschatzl
parents: 19986
diff changeset
   166
    return m.group(1).equals("true");
19986
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   167
  }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   168
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   169
  private static String expect(String[] flags, boolean hasWarning, boolean hasError, int errorcode) throws Exception {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   170
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   171
    OutputAnalyzer output = new OutputAnalyzer(pb.start());
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   172
    output.shouldHaveExitValue(errorcode);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   173
    return output.getStdout();
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   174
  }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   175
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   176
  private static String expectValid(String[] flags) throws Exception {
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   177
    return expect(flags, false, false, 0);
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   178
  }
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents:
diff changeset
   179
}