author | dsamersoff |
Thu, 18 Aug 2016 12:10:18 +0300 | |
changeset 40624 | cb96161ede05 |
parent 40059 | c2304140ed64 |
child 40631 | ed82623d7831 |
permissions | -rw-r--r-- |
28384 | 1 |
/* |
36210
9ea881b5873b
8151348: quarantine compiler/codecache/jmx/PeakUsageTest.java in JDK9-dev
dcubed
parents:
33730
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
28384 | 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 |
/* |
|
25 |
* @test PeakUsageTest |
|
40059 | 26 |
* @library /testlibrary /test/lib / |
36851 | 27 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28384
diff
changeset
|
28 |
* java.management |
40059 | 29 |
* |
30 |
* @build ompiler.codecache.jmx.PeakUsageTest |
|
31 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
|
28384 | 32 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
33 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
|
40059 | 34 |
* -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,null::* |
35 |
* -XX:+SegmentedCodeCache |
|
36 |
* compiler.codecache.jmx.PeakUsageTest |
|
28384 | 37 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
40059 | 38 |
* -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,null::* |
39 |
* -XX:-SegmentedCodeCache |
|
40 |
* compiler.codecache.jmx.PeakUsageTest |
|
28384 | 41 |
* @summary testing of getPeakUsage() and resetPeakUsage for |
42 |
* segmented code cache |
|
43 |
*/ |
|
40059 | 44 |
|
45 |
package compiler.codecache.jmx; |
|
46 |
||
47 |
import sun.hotspot.code.BlobType; |
|
48 |
||
49 |
import java.lang.management.MemoryPoolMXBean; |
|
50 |
||
51 |
||
28384 | 52 |
public class PeakUsageTest { |
53 |
||
54 |
private final BlobType btype; |
|
55 |
||
56 |
public PeakUsageTest(BlobType btype) { |
|
57 |
this.btype = btype; |
|
58 |
} |
|
59 |
||
60 |
public static void main(String[] args) { |
|
61 |
for (BlobType btype : BlobType.getAvailable()) { |
|
31522
2d29f2e927fc
8129937: compiler/codecache/jmx/UsageThresholdIncreasedTest.java fails with "Usage threshold was hit"
thartmann
parents:
30604
diff
changeset
|
62 |
new PeakUsageTest(btype).runTest(); |
28384 | 63 |
} |
64 |
} |
|
65 |
||
66 |
protected void runTest() { |
|
67 |
MemoryPoolMXBean bean = btype.getMemoryPool(); |
|
68 |
bean.resetPeakUsage(); |
|
69 |
long addr = CodeCacheUtils.WB.allocateCodeBlob( |
|
70 |
CodeCacheUtils.ALLOCATION_SIZE, btype.id); |
|
40624
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
71 |
|
28384 | 72 |
try { |
40624
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
73 |
/* |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
74 |
Always save peakUsage after saving currentUsage. Reversing the order |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
75 |
can lead to inconsistent results (currentUsage > peakUsage) because |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
76 |
of intermediate allocations. |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
77 |
*/ |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
78 |
long currUsage = bean.getUsage().getUsed(); |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
79 |
long peakUsage = bean.getPeakUsage().getUsed(); |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
80 |
CodeCacheUtils.assertEQorLTE(btype, currUsage, |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
81 |
peakUsage, |
28384 | 82 |
"Peak usage does not match usage after allocation for " |
83 |
+ bean.getName()); |
|
84 |
} finally { |
|
85 |
if (addr != 0) { |
|
86 |
CodeCacheUtils.WB.freeCodeBlob(addr); |
|
87 |
} |
|
88 |
} |
|
89 |
bean.resetPeakUsage(); |
|
40624
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
90 |
long currUsage = bean.getUsage().getUsed(); |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
91 |
long peakUsage = bean.getPeakUsage().getUsed(); |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
92 |
CodeCacheUtils.assertEQorLTE(btype, currUsage, |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
93 |
peakUsage, |
28384 | 94 |
"Code cache peak usage is not equal to usage after reset for " |
95 |
+ bean.getName()); |
|
96 |
long addr2 = CodeCacheUtils.WB.allocateCodeBlob( |
|
97 |
CodeCacheUtils.ALLOCATION_SIZE, btype.id); |
|
98 |
try { |
|
40624
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
99 |
currUsage = bean.getUsage().getUsed(); |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
100 |
peakUsage = bean.getPeakUsage().getUsed(); |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
101 |
|
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
102 |
CodeCacheUtils.assertEQorLTE(btype, currUsage, |
cb96161ede05
8151345: compiler/codecache/jmx/PeakUsageTest.java is failing on jdk9/dev for JPRT -testset hotspot
dsamersoff
parents:
40059
diff
changeset
|
103 |
peakUsage, |
28384 | 104 |
"Code cache peak usage is not equal to usage after fresh " |
105 |
+ "allocation for " + bean.getName()); |
|
106 |
} finally { |
|
107 |
if (addr2 != 0) { |
|
108 |
CodeCacheUtils.WB.freeCodeBlob(addr2); |
|
109 |
} |
|
110 |
} |
|
111 |
System.out.printf("INFO: Scenario finished successfully for %s%n", |
|
112 |
bean.getName()); |
|
113 |
} |
|
114 |
} |