author | thartmann |
Fri, 24 Oct 2014 08:27:39 +0200 | |
changeset 27418 | a13fdcbaa345 |
parent 27015 | 7a7b66fbc782 |
child 27431 | 5f970b31939c |
permissions | -rw-r--r-- |
26796 | 1 |
/* |
2 |
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
||
24 |
import com.oracle.java.testlibrary.*; |
|
27418
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
25 |
import sun.hotspot.WhiteBox; |
26796 | 26 |
|
27 |
/* |
|
28 |
* @test CheckSegmentedCodeCache |
|
29 |
* @bug 8015774 |
|
27418
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
30 |
* @library /testlibrary /testlibrary/whitebox |
26796 | 31 |
* @summary "Checks VM options related to the segmented code cache" |
27418
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
32 |
* @build CheckSegmentedCodeCache |
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
33 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
34 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
35 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI CheckSegmentedCodeCache |
26796 | 36 |
*/ |
37 |
public class CheckSegmentedCodeCache { |
|
27418
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
38 |
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
26796 | 39 |
// Code heap names |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26796
diff
changeset
|
40 |
private static final String NON_METHOD = "CodeHeap 'non-nmethods'"; |
26796 | 41 |
private static final String PROFILED = "CodeHeap 'profiled nmethods'"; |
42 |
private static final String NON_PROFILED = "CodeHeap 'non-profiled nmethods'"; |
|
43 |
||
44 |
private static void verifySegmentedCodeCache(ProcessBuilder pb, boolean enabled) throws Exception { |
|
45 |
OutputAnalyzer out = new OutputAnalyzer(pb.start()); |
|
27015
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
46 |
out.shouldHaveExitValue(0); |
26796 | 47 |
if (enabled) { |
48 |
try { |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26796
diff
changeset
|
49 |
// Non-nmethod code heap should be always available with the segmented code cache |
26796 | 50 |
out.shouldContain(NON_METHOD); |
51 |
} catch (RuntimeException e) { |
|
27015
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
52 |
// Check if TieredCompilation is disabled (in a client VM) |
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
53 |
if(!out.getOutput().contains("TieredCompilation is disabled in this release.")) { |
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
54 |
// Code cache is not segmented |
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
55 |
throw new RuntimeException("No code cache segmentation."); |
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
56 |
} |
26796 | 57 |
} |
58 |
} else { |
|
59 |
out.shouldNotContain(NON_METHOD); |
|
60 |
} |
|
61 |
} |
|
62 |
||
63 |
private static void verifyCodeHeapNotExists(ProcessBuilder pb, String... heapNames) throws Exception { |
|
64 |
OutputAnalyzer out = new OutputAnalyzer(pb.start()); |
|
27015
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
65 |
out.shouldHaveExitValue(0); |
26796 | 66 |
for (String name : heapNames) { |
67 |
out.shouldNotContain(name); |
|
68 |
} |
|
69 |
} |
|
70 |
||
71 |
private static void failsWith(ProcessBuilder pb, String message) throws Exception { |
|
72 |
OutputAnalyzer out = new OutputAnalyzer(pb.start()); |
|
73 |
out.shouldContain(message); |
|
74 |
out.shouldHaveExitValue(1); |
|
75 |
} |
|
76 |
||
77 |
/** |
|
78 |
* Check the result of segmented code cache related VM options. |
|
79 |
*/ |
|
80 |
public static void main(String[] args) throws Exception { |
|
81 |
ProcessBuilder pb; |
|
82 |
||
83 |
// Disabled with ReservedCodeCacheSize < 240MB |
|
84 |
pb = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=239m", |
|
85 |
"-XX:+PrintCodeCache", "-version"); |
|
86 |
verifySegmentedCodeCache(pb, false); |
|
87 |
||
88 |
// Disabled without TieredCompilation |
|
89 |
pb = ProcessTools.createJavaProcessBuilder("-XX:-TieredCompilation", |
|
90 |
"-XX:+PrintCodeCache", "-version"); |
|
91 |
verifySegmentedCodeCache(pb, false); |
|
92 |
||
93 |
// Enabled with TieredCompilation and ReservedCodeCacheSize >= 240MB |
|
94 |
pb = ProcessTools.createJavaProcessBuilder("-XX:+TieredCompilation", |
|
95 |
"-XX:ReservedCodeCacheSize=240m", |
|
96 |
"-XX:+PrintCodeCache", "-version"); |
|
97 |
verifySegmentedCodeCache(pb, true); |
|
27015
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
98 |
pb = ProcessTools.createJavaProcessBuilder("-XX:+TieredCompilation", |
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
99 |
"-XX:ReservedCodeCacheSize=400m", |
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
100 |
"-XX:+PrintCodeCache", "-version"); |
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
101 |
verifySegmentedCodeCache(pb, true); |
26796 | 102 |
|
103 |
// Always enabled if SegmentedCodeCache is set |
|
104 |
pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", |
|
105 |
"-XX:-TieredCompilation", |
|
106 |
"-XX:ReservedCodeCacheSize=239m", |
|
107 |
"-XX:+PrintCodeCache", "-version"); |
|
108 |
verifySegmentedCodeCache(pb, true); |
|
109 |
||
110 |
// The profiled and non-profiled code heaps should not be available in |
|
111 |
// interpreter-only mode |
|
112 |
pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", |
|
113 |
"-Xint", |
|
114 |
"-XX:+PrintCodeCache", "-version"); |
|
115 |
verifyCodeHeapNotExists(pb, PROFILED, NON_PROFILED); |
|
27015
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
116 |
|
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
117 |
// If we stop compilation at CompLevel_none or CompLevel_simple we |
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
118 |
// don't need a profiled code heap. |
26796 | 119 |
pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", |
120 |
"-XX:TieredStopAtLevel=0", |
|
121 |
"-XX:+PrintCodeCache", "-version"); |
|
27015
7a7b66fbc782
8059559: SIGSEGV at CodeHeap::allocate(unsigned int, bool)
thartmann
parents:
26919
diff
changeset
|
122 |
verifyCodeHeapNotExists(pb, PROFILED); |
26796 | 123 |
pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", |
124 |
"-XX:TieredStopAtLevel=1", |
|
125 |
"-XX:+PrintCodeCache", "-version"); |
|
126 |
verifyCodeHeapNotExists(pb, PROFILED); |
|
127 |
||
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26796
diff
changeset
|
128 |
// Fails with too small non-nmethod code heap size |
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26796
diff
changeset
|
129 |
pb = ProcessTools.createJavaProcessBuilder("-XX:NonNMethodCodeHeapSize=100K"); |
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26796
diff
changeset
|
130 |
failsWith(pb, "Invalid NonNMethodCodeHeapSize"); |
26796 | 131 |
|
132 |
// Fails if code heap sizes do not add up |
|
133 |
pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", |
|
134 |
"-XX:ReservedCodeCacheSize=10M", |
|
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26796
diff
changeset
|
135 |
"-XX:NonNMethodCodeHeapSize=5M", |
26796 | 136 |
"-XX:ProfiledCodeHeapSize=5M", |
137 |
"-XX:NonProfiledCodeHeapSize=5M"); |
|
138 |
failsWith(pb, "Invalid code heap sizes"); |
|
139 |
||
140 |
// Fails if not enough space for VM internal code |
|
27418
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
141 |
long minUseSpace = WHITE_BOX.getUintxVMFlag("CodeCacheMinimumUseSpace"); |
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
142 |
long minFreeSpace = WHITE_BOX.getUintxVMFlag("CodeCacheMinimumFreeSpace"); |
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
143 |
// minimum size: (CodeCacheMinimumUseSpace DEBUG_ONLY(* 3)) + CodeCacheMinimumFreeSpace |
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
144 |
long minSize = (Platform.isDebugBuild() ? 3 : 1) * minUseSpace + minFreeSpace; |
26796 | 145 |
pb = ProcessTools.createJavaProcessBuilder("-XX:+SegmentedCodeCache", |
27418
a13fdcbaa345
8060479: [TESTBUG] compiler/codecache/CheckSegmentedCodeCache.java test fails with product build
thartmann
parents:
27015
diff
changeset
|
146 |
"-XX:ReservedCodeCacheSize=" + minSize, |
26796 | 147 |
"-XX:InitialCodeCacheSize=100K"); |
26919
361b4b4c92c0
8059468: Fix PrintCodeCache output changed by JDK-8059137
thartmann
parents:
26796
diff
changeset
|
148 |
failsWith(pb, "Not enough space in non-nmethod code heap to run VM"); |
26796 | 149 |
} |
150 |
} |