annotate test/runtime/SharedArchiveFile/SpaceUtilizationCheck.java @ 20627:e7b3d177adda

8057622: java/util/stream/test/org/openjdk/tests/java/util/stream/InfiniteStreamWithLimitOpTest: SEGV inside compiled code (sparc) Summary: In Parse::array_store_check(), add control edge FROM IfTrue branch of runtime type check of the destination array TO loading _element_klass from destination array. Reviewed-by: kvn, roland, anoll Contributed-by: Zoltan Majo <zoltan.majo@oracle.com>
author zmajo
date Mon, 10 Nov 2014 17:14:59 +0100
parents 9c8439756c05
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20488
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
1 /*
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
4 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
7 * published by the Free Software Foundation.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
8 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
13 * accompanied this code).
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
14 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
18 *
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
21 * questions.
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
22 */
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
23
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
24 /*
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
25 * @test SpaceUtilizationCheck
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
26 * @summary Check if the space utilization for shared spaces is adequate
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
27 * @library /testlibrary
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
28 * @run main SpaceUtilizationCheck
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
29 */
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
30
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
31 import com.oracle.java.testlibrary.*;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
32
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
33 import java.util.regex.Pattern;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
34 import java.util.regex.Matcher;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
35 import java.util.ArrayList;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
36 import java.lang.Integer;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
37
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
38 public class SpaceUtilizationCheck {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
39 // Minimum allowed utilization value (percent)
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
40 // The goal is to have this number to be 50% for RO and RW regions
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
41 // Once that feature is implemented, increase the MIN_UTILIZATION to 50
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
42 private static final int MIN_UTILIZATION = 30;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
43
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
44 // Only RO and RW regions are considered for this check, since they
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
45 // currently account for the bulk of the shared space
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
46 private static final int NUMBER_OF_CHECKED_SHARED_REGIONS = 2;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
47
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
48 public static void main(String[] args) throws Exception {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
49 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
50 "-XX:+UnlockDiagnosticVMOptions",
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
51 "-XX:SharedArchiveFile=./test.jsa",
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
52 "-Xshare:dump");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
53
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
54 OutputAnalyzer output = new OutputAnalyzer(pb.start());
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
55 String stdout = output.getStdout();
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
56 ArrayList<String> utilization = findUtilization(stdout);
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
57
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
58 if (utilization.size() != NUMBER_OF_CHECKED_SHARED_REGIONS )
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
59 throw new RuntimeException("The output format of sharing summary has changed");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
60
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
61 for(String str : utilization) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
62 int value = Integer.parseInt(str);
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
63 if (value < MIN_UTILIZATION) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
64 System.out.println(stdout);
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
65 throw new RuntimeException("Utilization for one of the regions" +
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
66 "is below a threshold of " + MIN_UTILIZATION + "%");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
67 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
68 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
69 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
70
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
71 public static ArrayList<String> findUtilization(String input) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
72 ArrayList<String> regions = filterRegionsOfInterest(input.split("\n"));
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
73 return filterByPattern(filterByPattern(regions, "bytes \\[.*% used\\]"), "\\d+");
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
74 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
75
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
76 private static ArrayList<String> filterByPattern(Iterable<String> input, String pattern) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
77 ArrayList<String> result = new ArrayList<String>();
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
78 for (String str : input) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
79 Matcher matcher = Pattern.compile(pattern).matcher(str);
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
80 if (matcher.find()) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
81 result.add(matcher.group());
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
82 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
83 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
84 return result;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
85 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
86
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
87 private static ArrayList<String> filterRegionsOfInterest(String[] inputLines) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
88 ArrayList<String> result = new ArrayList<String>();
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
89 for (String str : inputLines) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
90 if (str.contains("ro space:") || str.contains("rw space:")) {
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
91 result.add(str);
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
92 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
93 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
94 return result;
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
95 }
9c8439756c05 8052313: Backport CDS tests from JDK-9 to jdk8_u40
mseledtsov
parents:
diff changeset
96 }