hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java
author ccheung
Thu, 23 Oct 2014 10:08:02 -0700
changeset 27404 33c0f343cd5c
parent 25896 5f21a029fdeb
child 28018 abc067cd68fd
permissions -rw-r--r--
8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize Summary: estimate the minimum required size for the misc code region and check if the specified misc code region size meets the minimum size requirement Reviewed-by: jiangli, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     1
/*
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     4
 *
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     8
 *
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    13
 * accompanied this code).
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    14
 *
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    18
 *
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    21
 * questions.
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    22
 */
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    23
25896
5f21a029fdeb 8053956: [TESTBUG] Remove @ignore tag from fixed runtime issues
ctornqvi
parents: 24840
diff changeset
    24
/* @test LimitSharedSizes
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    25
 * @summary Test handling of limits on shared space size
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    26
 * @library /testlibrary
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    27
 * @run main LimitSharedSizes
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    28
 */
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    29
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    30
import com.oracle.java.testlibrary.*;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    31
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    32
public class LimitSharedSizes {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    33
    private static class SharedSizeTestData {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    34
        public String optionName;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    35
        public String optionValue;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    36
        public String expectedErrorMsg;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    37
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    38
        public SharedSizeTestData(String name, String value, String msg) {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    39
            optionName = name;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    40
            optionValue = value;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    41
            expectedErrorMsg = msg;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    42
        }
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    43
    }
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    44
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    45
    private static final SharedSizeTestData[] testTable = {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    46
        // values in this part of the test table should cause failure
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    47
        // (shared space sizes are deliberately too small)
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    48
        new SharedSizeTestData("-XX:SharedReadOnlySize", "4M",      "read only"),
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    49
        new SharedSizeTestData("-XX:SharedReadWriteSize","4M",      "read write"),
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    50
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    51
        // Known issue, JDK-8038422 (assert() on Windows)
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    52
        // new SharedSizeTestData("-XX:SharedMiscDataSize", "500k",    "miscellaneous data"),
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    53
27404
33c0f343cd5c 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 25896
diff changeset
    54
        // Too small of a misc code size should not cause a vm crash.
33c0f343cd5c 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 25896
diff changeset
    55
        // It should result in the following error message:
33c0f343cd5c 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 25896
diff changeset
    56
        // The shared miscellaneous code space is not large enough
33c0f343cd5c 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 25896
diff changeset
    57
        // to preload requested classes. Use -XX:SharedMiscCodeSize=
33c0f343cd5c 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 25896
diff changeset
    58
        // to increase the initial size of shared miscellaneous code space.
33c0f343cd5c 8038268: VM Crashes in MetaspaceShared::generate_vtable_methods while creating CDS archive with limiting SharedMiscCodeSize
ccheung
parents: 25896
diff changeset
    59
        new SharedSizeTestData("-XX:SharedMiscCodeSize", "20k",     "miscellaneous code"),
24840
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    60
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    61
        // these values are larger than default ones, but should
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    62
        // be acceptable and not cause failure
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    63
        new SharedSizeTestData("-XX:SharedReadOnlySize",    "20M", null),
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    64
        new SharedSizeTestData("-XX:SharedReadWriteSize",   "20M", null),
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    65
        new SharedSizeTestData("-XX:SharedMiscDataSize",    "20M", null),
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    66
        new SharedSizeTestData("-XX:SharedMiscCodeSize",    "20M", null)
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    67
    };
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    68
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    69
    public static void main(String[] args) throws Exception {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    70
        String fileName = "test.jsa";
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    71
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    72
        for (SharedSizeTestData td : testTable) {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    73
            String option = td.optionName + "=" + td.optionValue;
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    74
            System.out.println("testing option <" + option + ">");
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    75
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    76
            ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    77
               "-XX:+UnlockDiagnosticVMOptions",
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    78
               "-XX:SharedArchiveFile=./" + fileName,
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    79
               option,
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    80
               "-Xshare:dump");
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    81
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    82
            OutputAnalyzer output = new OutputAnalyzer(pb.start());
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    83
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    84
            if (td.expectedErrorMsg != null) {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    85
                output.shouldContain("The shared " + td.expectedErrorMsg
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    86
                    + " space is not large enough");
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    87
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    88
                output.shouldHaveExitValue(2);
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    89
            } else {
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    90
                output.shouldNotContain("space is not large enough");
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    91
                output.shouldHaveExitValue(0);
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    92
            }
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    93
        }
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    94
    }
96be34dfc72a 8038587: [TESTBUG] Create CDS tests to exercise region sizes and base address
mseledtsov
parents:
diff changeset
    95
}