test/hotspot/jtreg/runtime/CompressedOops/UseCompressedOops.java
author lkorinth
Wed, 13 Nov 2019 11:37:29 +0100
changeset 59053 ba6c248cae19
parent 54034 fa9b16328e6a
permissions -rw-r--r--
8232365: Implementation for JEP 363: Remove the Concurrent Mark Sweep (CMS) Garbage Collector Reviewed-by: kbarrett, tschatzl, erikj, coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     1
/*
53774
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     4
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     7
 * published by the Free Software Foundation.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     8
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    13
 * accompanied this code).
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    14
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    18
 *
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    21
 * questions.
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    22
 */
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    23
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    24
/*
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    25
 * @test
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    26
 * @bug 8022865
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    27
 * @summary Tests for different combination of UseCompressedOops options
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 37477
diff changeset
    28
 * @library /test/lib
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 33785
diff changeset
    29
 * @modules java.base/jdk.internal.misc
29678
dd2f3932c21e 8075586: Add @modules as needed to the open hotspot tests
ykantser
parents: 28372
diff changeset
    30
 *          java.management
50455
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 47216
diff changeset
    31
 * @build sun.hotspot.WhiteBox
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 47216
diff changeset
    32
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
54034
fa9b16328e6a 8220085: runtime/CompressedOops/UseCompressedOops.java times out on Windows intermittently
hseigel
parents: 53774
diff changeset
    33
 * @run main/othervm/timeout=480 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. UseCompressedOops
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    34
 */
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    35
import java.util.ArrayList;
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    36
import java.util.Collections;
40631
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 37477
diff changeset
    37
import jdk.test.lib.Platform;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 37477
diff changeset
    38
import jdk.test.lib.process.ProcessTools;
ed82623d7831 8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents: 37477
diff changeset
    39
import jdk.test.lib.process.OutputAnalyzer;
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 50455
diff changeset
    40
import sun.hotspot.gc.GC;
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    41
50455
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 47216
diff changeset
    42
import sun.hotspot.code.Compiler;
2b73cce96dce 8202611: [GRAAL] Exclude CMS GC testing from runs with Graal
kvn
parents: 47216
diff changeset
    43
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    44
public class UseCompressedOops {
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    45
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    46
    public static void main(String[] args) throws Exception {
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    47
        testCompressedOopsModesGCs();
53774
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
    48
        if (!Platform.isOSX() && !Platform.isAix()) {
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
    49
            testCompressedOopsModesGCs("-XX:+UseLargePages");
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
    50
        }
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    51
    }
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    52
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    53
    public static void testCompressedOopsModesGCs(String... flags) throws Exception {
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    54
        ArrayList<String> args = new ArrayList<>();
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    55
        Collections.addAll(args, flags);
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    56
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    57
        // Test default.
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    58
        testCompressedOopsModes(args);
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    59
        // Test GCs.
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    60
        testCompressedOopsModes(args, "-XX:+UseG1GC");
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    61
        testCompressedOopsModes(args, "-XX:+UseSerialGC");
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    62
        testCompressedOopsModes(args, "-XX:+UseParallelGC");
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    63
        testCompressedOopsModes(args, "-XX:+UseParallelOldGC");
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 50455
diff changeset
    64
        if (GC.Shenandoah.isSupported()) {
53530
f5671b2e74df 8217854: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java fails with Shenandoah
shade
parents: 52925
diff changeset
    65
            testCompressedOopsModes(args, "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC");
52925
9c18c9d839d3 8214259: Implementation: JEP 189: Shenandoah: A Low-Pause-Time Garbage Collector (Experimental)
rkennke
parents: 50455
diff changeset
    66
        }
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    67
    }
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    68
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    69
    public static void testCompressedOopsModes(ArrayList<String> flags1, String... flags2) throws Exception {
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    70
        ArrayList<String> args = new ArrayList<>();
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    71
        args.addAll(flags1);
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    72
        Collections.addAll(args, flags2);
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    73
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    74
        if (Platform.is64bit()) {
53774
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
    75
            // Explicitly turn off compressed oops
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    76
            testCompressedOops(args, "-XX:-UseCompressedOops", "-Xmx32m")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    77
                .shouldNotContain("Compressed Oops")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    78
                .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    79
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    80
            // Compressed oops should be on by default
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    81
            testCompressedOops(args, "-Xmx32m")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    82
                .shouldContain("Compressed Oops mode")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    83
                .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    84
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    85
            // Explicly enabling compressed oops
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    86
            testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    87
                .shouldContain("Compressed Oops mode")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    88
                .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
    89
53774
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
    90
            // Skip the following seven test cases if we're on OSX, Windows, or Solaris.
26813
fd74c05c4a7e 8058369: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java Exception java.lang.RuntimeException: 'Zero based' missing from stdout/stderr
ctornqvi
parents: 26688
diff changeset
    91
            //
53774
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
    92
            // OSX doesn't seem to care about HeapBaseMinAddress.  Windows memory
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
    93
            // locations are affected by ASLR.  Solaris puts the heap way up,
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
    94
            // forcing different behaviour.
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
    95
            if (!Platform.isOSX() && !Platform.isWindows() && !Platform.isSolaris()) {
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
    96
26813
fd74c05c4a7e 8058369: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java Exception java.lang.RuntimeException: 'Zero based' missing from stdout/stderr
ctornqvi
parents: 26688
diff changeset
    97
                // Larger than 4gb heap should result in zero based with shift 3
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    98
                testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx5g")
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
    99
                    .shouldContain("Zero based")
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   100
                    .shouldContain("Oop shift amount: 3")
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   101
                    .shouldHaveExitValue(0);
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   102
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   103
                // Larger than 3gb heap and HeapBaseMinAddress=1g should result in zero based with shift 3
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   104
                testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx3200m", "-XX:HeapBaseMinAddress=1g")
26813
fd74c05c4a7e 8058369: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java Exception java.lang.RuntimeException: 'Zero based' missing from stdout/stderr
ctornqvi
parents: 26688
diff changeset
   105
                    .shouldContain("Zero based")
fd74c05c4a7e 8058369: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java Exception java.lang.RuntimeException: 'Zero based' missing from stdout/stderr
ctornqvi
parents: 26688
diff changeset
   106
                    .shouldContain("Oop shift amount: 3")
fd74c05c4a7e 8058369: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java Exception java.lang.RuntimeException: 'Zero based' missing from stdout/stderr
ctornqvi
parents: 26688
diff changeset
   107
                    .shouldHaveExitValue(0);
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   108
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   109
                // Small heap above 4gb should result in zero based with shift 3
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   110
                testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m", "-XX:HeapBaseMinAddress=4g")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   111
                    .shouldContain("Zero based")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   112
                    .shouldContain("Oop shift amount: 3")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   113
                    .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   114
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   115
                // Small heap above 32gb should result in non-zero based with shift 3
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   116
                testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m", "-XX:HeapBaseMinAddress=32g")
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   117
                    .shouldContain("Non-zero disjoint base")
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   118
                    .shouldContain("Oop shift amount: 3")
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   119
                    .shouldHaveExitValue(0);
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   120
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   121
                // Small heap above 32gb should result in non-zero based with shift 3
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   122
                testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m", "-XX:HeapBaseMinAddress=72704m")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   123
                    .shouldContain("Non-zero based")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   124
                    .shouldContain("Oop shift amount: 3")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   125
                    .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   126
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   127
                // 32gb heap with heap base above 64gb and object alignment set to 16 bytes should result
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   128
                // in non-zero based with shift 4
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   129
                testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32g", "-XX:ObjectAlignmentInBytes=16",
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   130
                               "-XX:HeapBaseMinAddress=64g")
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   131
                    .shouldContain("Non-zero disjoint base")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   132
                    .shouldContain("Oop shift amount: 4")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   133
                    .shouldHaveExitValue(0);
26813
fd74c05c4a7e 8058369: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java Exception java.lang.RuntimeException: 'Zero based' missing from stdout/stderr
ctornqvi
parents: 26688
diff changeset
   134
fd74c05c4a7e 8058369: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java Exception java.lang.RuntimeException: 'Zero based' missing from stdout/stderr
ctornqvi
parents: 26688
diff changeset
   135
                // 32gb heap with object alignment set to 16 bytes should result in zero based with shift 4
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   136
                testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32g", "-XX:ObjectAlignmentInBytes=16")
26813
fd74c05c4a7e 8058369: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java Exception java.lang.RuntimeException: 'Zero based' missing from stdout/stderr
ctornqvi
parents: 26688
diff changeset
   137
                    .shouldContain("Zero based")
fd74c05c4a7e 8058369: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java Exception java.lang.RuntimeException: 'Zero based' missing from stdout/stderr
ctornqvi
parents: 26688
diff changeset
   138
                    .shouldContain("Oop shift amount: 4")
fd74c05c4a7e 8058369: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java Exception java.lang.RuntimeException: 'Zero based' missing from stdout/stderr
ctornqvi
parents: 26688
diff changeset
   139
                    .shouldHaveExitValue(0);
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   140
            }
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   141
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   142
            // This is a pathologic case for the heap allocation algorithm. Regression test.
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   143
            // HeapBaseMinAddress must be 2g and should not be set on the command line.
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   144
            testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx2g")
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   145
                .shouldNotContain("Max heap size too large for Compressed Oops")
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   146
                .shouldHaveExitValue(0);
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   147
            testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx29g", "-XX:CompressedClassSpaceSize=1g")
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   148
                .shouldNotContain("Max heap size too large for Compressed Oops")
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   149
                .shouldHaveExitValue(0);
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   150
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   151
            // Explicitly enabling compressed oops with 32gb heap should result a warning
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   152
            testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32g")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   153
                .shouldContain("Max heap size too large for Compressed Oops")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   154
                .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   155
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   156
            // 32gb heap should not result a warning
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   157
            testCompressedOops(args, "-Xmx32g")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   158
                .shouldNotContain("Max heap size too large for Compressed Oops")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   159
                .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   160
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   161
            // Explicitly enabling compressed oops with 32gb heap and object
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   162
            // alignment set to 8 byte should result a warning
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   163
            testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32g", "-XX:ObjectAlignmentInBytes=8")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   164
                .shouldContain("Max heap size too large for Compressed Oops")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   165
                .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   166
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   167
            // 64gb heap and object alignment set to 16 bytes should result in a warning
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   168
            testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx64g", "-XX:ObjectAlignmentInBytes=16")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   169
                .shouldContain("Max heap size too large for Compressed Oops")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   170
                .shouldHaveExitValue(0);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   171
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   172
        } else {
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   173
            // Compressed oops should only apply to 64bit platforms
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   174
            testCompressedOops(args, "-XX:+UseCompressedOops", "-Xmx32m")
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   175
                .shouldContain("Unrecognized VM option 'UseCompressedOops'")
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   176
                .shouldHaveExitValue(1);
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   177
        }
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   178
    }
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   179
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   180
    private static OutputAnalyzer testCompressedOops(ArrayList<String> flags1, String... flags2) throws Exception {
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   181
        ArrayList<String> args = new ArrayList<>();
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   182
53774
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
   183
        // Always run with these two:
622c26f0673f 8079353: [TESTBUG] runtime/CompressedOops/UseCompressedOops.java failed on Windows when getting disjoint instead of zero based coops
hseigel
parents: 53530
diff changeset
   184
        args.add("-Xlog:gc+heap+coops=trace");
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   185
        args.add("-Xms32m");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   186
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   187
        // Add the extra flags
28372
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   188
        args.addAll(flags1);
ce0aad4b8c44 8064457: Introduce compressed oops mode disjoint base and improve compressed heap handling.
goetz
parents: 26813
diff changeset
   189
        Collections.addAll(args, flags2);
26688
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   190
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   191
        args.add("-version");
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   192
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   193
        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[0]));
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   194
        return new OutputAnalyzer(pb.start());
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   195
    }
bb0cdd873e51 8022865: [TESTBUG] Compressed Oops testing needs to be revised
ctornqvi
parents:
diff changeset
   196
}