author | jiangli |
Wed, 27 Sep 2017 17:55:20 -0400 | |
changeset 47548 | 664b9d44db74 |
parent 47216 | 71c04702a3d5 |
child 53732 | d667de4734ac |
permissions | -rw-r--r-- |
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
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. |
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
4 |
* |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
8 |
* |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
13 |
* accompanied this code). |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
14 |
* |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
18 |
* |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
21 |
* questions. |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
22 |
*/ |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
23 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
24 |
/* |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
25 |
* @test GetCodeHeapEntriesTest |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
26 |
* @bug 8059624 |
40059 | 27 |
* @summary testing of WB::getCodeHeapEntries() |
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 |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
31 |
* @build sun.hotspot.WhiteBox |
40059 | 32 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
33 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
|
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
34 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
35 |
* -XX:+WhiteBoxAPI -XX:-SegmentedCodeCache |
40059 | 36 |
* compiler.whitebox.GetCodeHeapEntriesTest |
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
37 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
38 |
* -XX:+WhiteBoxAPI -XX:+SegmentedCodeCache |
40059 | 39 |
* compiler.whitebox.GetCodeHeapEntriesTest |
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
40 |
*/ |
40059 | 41 |
|
42 |
package compiler.whitebox; |
|
43 |
||
44 |
import jdk.test.lib.Asserts; |
|
45 |
import sun.hotspot.WhiteBox; |
|
46 |
import sun.hotspot.code.BlobType; |
|
47 |
import sun.hotspot.code.CodeBlob; |
|
48 |
||
49 |
import java.util.Arrays; |
|
50 |
import java.util.EnumSet; |
|
51 |
||
27642
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
52 |
public class GetCodeHeapEntriesTest { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
53 |
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
54 |
private static final int SIZE = 1024; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
55 |
private static final String DUMMY_NAME = "WB::DummyBlob"; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
56 |
private static EnumSet<BlobType> SEGMENTED_TYPES |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
57 |
= EnumSet.complementOf(EnumSet.of(BlobType.All)); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
58 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
59 |
public static void main(String[] args) { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
60 |
EnumSet<BlobType> blobTypes = BlobType.getAvailable(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
61 |
for (BlobType type : blobTypes) { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
62 |
new GetCodeHeapEntriesTest(type).test(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
63 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
64 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
65 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
66 |
private final BlobType type; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
67 |
private GetCodeHeapEntriesTest(BlobType type) { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
68 |
this.type = type; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
69 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
70 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
71 |
private void test() { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
72 |
System.out.printf("type %s%n", type); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
73 |
long addr = WHITE_BOX.allocateCodeBlob(SIZE, type.id); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
74 |
Asserts.assertNE(0, addr, "allocation failed"); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
75 |
CodeBlob[] blobs = CodeBlob.getCodeBlobs(type); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
76 |
Asserts.assertNotNull(blobs); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
77 |
CodeBlob blob = Arrays.stream(blobs) |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
78 |
.filter(GetCodeHeapEntriesTest::filter) |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
79 |
.findAny() |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
80 |
.get(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
81 |
Asserts.assertNotNull(blob); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
82 |
Asserts.assertEQ(blob.code_blob_type, type); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
83 |
Asserts.assertGTE(blob.size, SIZE); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
84 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
85 |
WHITE_BOX.freeCodeBlob(addr); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
86 |
blobs = CodeBlob.getCodeBlobs(type); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
87 |
long count = Arrays.stream(blobs) |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
88 |
.filter(GetCodeHeapEntriesTest::filter) |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
89 |
.count(); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
90 |
Asserts.assertEQ(0L, count); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
91 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
92 |
|
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
93 |
private static boolean filter(CodeBlob blob) { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
94 |
if (blob == null) { |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
95 |
return false; |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
96 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
97 |
return DUMMY_NAME.equals(blob.name); |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
98 |
} |
8c9eff693145
8059624: Test task: WhiteBox API for testing segmented codecache feature
iignatyev
parents:
diff
changeset
|
99 |
} |