hotspot/test/gc/g1/TestSharedArchiveWithPreTouch.java
author sangheki
Thu, 10 Aug 2017 18:09:19 -0700
changeset 46795 623a5e42deb6
parent 46779 d80ca591ae48
permissions -rw-r--r--
8173335: Improve logging for j.l.ref.reference processing Summary: Add logs for each phases of references and stats for each worker threads Reviewed-by: tschatzl, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
42595
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
     1
/*
46779
d80ca591ae48 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 42595
diff changeset
     2
 * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
42595
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
     4
 *
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
     8
 *
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    14
 *
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    18
 *
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    21
 * questions.
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    22
 */
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    23
46779
d80ca591ae48 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 42595
diff changeset
    24
/**
42595
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    25
 * @test
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    26
 * @bug 8169703
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    27
 * @summary Verifies that dumping and loading a CDS archive succeeds with AlwaysPreTouch
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    28
 * @requires vm.gc.G1
46779
d80ca591ae48 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 42595
diff changeset
    29
 * @key gc regression
d80ca591ae48 8185436: jtreg: introduce @requires property to disable cds tests
goetz
parents: 42595
diff changeset
    30
 * @requires vm.cds
42595
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    31
 * @library /test/lib
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    32
 * @modules java.base/jdk.internal.misc
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    33
 *          java.management
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    34
 * @run main TestSharedArchiveWithPreTouch
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    35
 */
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    36
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    37
import java.util.List;
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    38
import java.util.ArrayList;
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    39
import java.util.Arrays;
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    40
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    41
import jdk.test.lib.Platform;
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    42
import jdk.test.lib.process.ProcessTools;
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    43
import jdk.test.lib.process.OutputAnalyzer;
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    44
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    45
public class TestSharedArchiveWithPreTouch {
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    46
    public static void main(String[] args) throws Exception {
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    47
        final String ArchiveFileName = "./SharedArchiveWithPreTouch.jsa";
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    48
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    49
        final List<String> BaseOptions = Arrays.asList(new String[] {"-XX:+UseG1GC", "-XX:+AlwaysPreTouch",
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    50
            "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=" + ArchiveFileName });
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    51
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    52
        ProcessBuilder pb;
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    53
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    54
        List<String> dump_args = new ArrayList<String>(BaseOptions);
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    55
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    56
        if (Platform.is64bit()) {
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    57
          dump_args.addAll(0, Arrays.asList(new String[] { "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops" }));
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    58
        }
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    59
        dump_args.addAll(Arrays.asList(new String[] { "-Xshare:dump" }));
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    60
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    61
        pb = ProcessTools.createJavaProcessBuilder(dump_args.toArray(new String[0]));
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    62
        OutputAnalyzer output = new OutputAnalyzer(pb.start());
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    63
        try {
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    64
            output.shouldContain("Loading classes to share");
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    65
            output.shouldHaveExitValue(0);
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    66
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    67
            List<String> load_args = new ArrayList<String>(BaseOptions);
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    68
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    69
            if (Platform.is64bit()) {
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    70
                load_args.addAll(0, Arrays.asList(new String[] { "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops" }));
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    71
            }
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    72
            load_args.addAll(Arrays.asList(new String[] { "-Xshare:on", "-version" }));
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    73
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    74
            pb = ProcessTools.createJavaProcessBuilder(load_args.toArray(new String[0]));
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    75
            output = new OutputAnalyzer(pb.start());
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    76
            output.shouldContain("sharing");
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    77
            output.shouldHaveExitValue(0);
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    78
        } catch (RuntimeException e) {
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    79
            // Report 'passed' if CDS was turned off.
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    80
            output.shouldContain("Unable to use shared archive");
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    81
            output.shouldHaveExitValue(1);
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    82
        }
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    83
    }
b1ae41a4eae9 8169703: G1 crashes with guarantee(pretouch_gang != NULL) failed: No pretouch gang specified
tschatzl
parents:
diff changeset
    84
}