author | dtitov |
Fri, 31 Aug 2018 11:56:43 -0700 | |
changeset 51613 | 3835dc32de5e |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
27701
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
2 |
* Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
27701
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
4 |
* |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
8 |
* |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
14 |
* |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
18 |
* |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
22 |
*/ |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
23 |
|
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
24 |
/* |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
25 |
* @test OverflowCodeCacheTest |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
26 |
* @bug 8059550 |
40059 | 27 |
* @summary testing of code cache segments overflow |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
28 |
* @library /test/lib |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
33730
diff
changeset
|
29 |
* @modules java.base/jdk.internal.misc |
40059 | 30 |
* java.management |
31 |
* |
|
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
32 |
* @build sun.hotspot.WhiteBox |
40059 | 33 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
34 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
|
35 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
|
36 |
* -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,null::* |
|
37 |
* -XX:-SegmentedCodeCache |
|
38 |
* compiler.codecache.OverflowCodeCacheTest |
|
27701
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
39 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
40 |
* -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,null::* |
40059 | 41 |
* -XX:+SegmentedCodeCache |
42 |
* compiler.codecache.OverflowCodeCacheTest |
|
27701
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
43 |
*/ |
40059 | 44 |
|
45 |
package compiler.codecache; |
|
46 |
||
47 |
import jdk.test.lib.Asserts; |
|
48 |
import sun.hotspot.WhiteBox; |
|
49 |
import sun.hotspot.code.BlobType; |
|
50 |
import sun.hotspot.code.CodeBlob; |
|
51 |
||
52 |
import java.lang.management.MemoryPoolMXBean; |
|
53 |
import java.util.ArrayList; |
|
54 |
import java.util.EnumSet; |
|
55 |
||
27701
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
56 |
public class OverflowCodeCacheTest { |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
57 |
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
58 |
|
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
59 |
public static void main(String[] args) { |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
60 |
EnumSet<BlobType> blobTypes = BlobType.getAvailable(); |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
61 |
for (BlobType type : blobTypes) { |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
62 |
new OverflowCodeCacheTest(type).test(); |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
63 |
} |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
64 |
} |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
65 |
|
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
66 |
private final BlobType type; |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
67 |
private final MemoryPoolMXBean bean; |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
68 |
private OverflowCodeCacheTest(BlobType type) { |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
69 |
this.type = type; |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
70 |
this.bean = type.getMemoryPool(); |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
71 |
} |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
72 |
|
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
73 |
private void test() { |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
74 |
System.out.printf("type %s%n", type); |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
75 |
System.out.println("allocating till possible..."); |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
76 |
ArrayList<Long> blobs = new ArrayList<>(); |
41061
7eecf643e9f3
8157956: OverflowCodeCacheTest.java fails with Out of space in CodeCache for method handle intrinsic
dpochepk
parents:
40631
diff
changeset
|
77 |
int compilationActivityMode = -1; |
27701
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
78 |
try { |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
79 |
long addr; |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
80 |
int size = (int) (getHeapSize() >> 7); |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
81 |
while ((addr = WHITE_BOX.allocateCodeBlob(size, type.id)) != 0) { |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
82 |
blobs.add(addr); |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
83 |
|
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
84 |
BlobType actualType = CodeBlob.getCodeBlob(addr).code_blob_type; |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
85 |
if (actualType != type) { |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
86 |
// check we got allowed overflow handling |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
87 |
Asserts.assertTrue(type.allowTypeWhenOverflow(actualType), |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
88 |
type + " doesn't allow using " + actualType + " when overflow"); |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
89 |
} |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
90 |
} |
41061
7eecf643e9f3
8157956: OverflowCodeCacheTest.java fails with Out of space in CodeCache for method handle intrinsic
dpochepk
parents:
40631
diff
changeset
|
91 |
/* now, remember compilationActivityMode to check it later, after freeing, since we |
7eecf643e9f3
8157956: OverflowCodeCacheTest.java fails with Out of space in CodeCache for method handle intrinsic
dpochepk
parents:
40631
diff
changeset
|
92 |
possibly have no free cache for futher work */ |
7eecf643e9f3
8157956: OverflowCodeCacheTest.java fails with Out of space in CodeCache for method handle intrinsic
dpochepk
parents:
40631
diff
changeset
|
93 |
compilationActivityMode = WHITE_BOX.getCompilationActivityMode(); |
27701
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
94 |
} finally { |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
95 |
for (Long blob : blobs) { |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
96 |
WHITE_BOX.freeCodeBlob(blob); |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
97 |
} |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
98 |
} |
41061
7eecf643e9f3
8157956: OverflowCodeCacheTest.java fails with Out of space in CodeCache for method handle intrinsic
dpochepk
parents:
40631
diff
changeset
|
99 |
Asserts.assertNotEquals(compilationActivityMode, 1 /* run_compilation*/, |
7eecf643e9f3
8157956: OverflowCodeCacheTest.java fails with Out of space in CodeCache for method handle intrinsic
dpochepk
parents:
40631
diff
changeset
|
100 |
"Compilation must be disabled when CodeCache(CodeHeap) overflows"); |
27701
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
101 |
} |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
102 |
|
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
103 |
private long getHeapSize() { |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
104 |
return bean.getUsage().getMax(); |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
105 |
} |
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
106 |
|
c6b49b72dc61
8059550: JEP-JDK-8043304: Test task: segment overflow w/ empty others
iignatyev
parents:
diff
changeset
|
107 |
} |