author | thartmann |
Wed, 15 Aug 2018 14:35:33 +0200 | |
changeset 51410 | cb8cab787ba2 |
parent 49345 | 2a12ff1fff68 |
permissions | -rw-r--r-- |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
1 |
/* |
49345
2a12ff1fff68
8198987: [Graal] compiler/intrinsics/sha/sanity tests fail on macos with Graal as JIT
thartmann
parents:
47565
diff
changeset
|
2 |
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
4 |
* |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
8 |
* |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
13 |
* accompanied this code). |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
14 |
* |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
18 |
* |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
21 |
* questions. |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
22 |
*/ |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
23 |
|
39438 | 24 |
package compiler.testlibrary.sha.predicate; |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
25 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
26438
diff
changeset
|
26 |
import jdk.test.lib.Platform; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
26438
diff
changeset
|
27 |
import jdk.test.lib.cli.predicate.AndPredicate; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
26438
diff
changeset
|
28 |
import jdk.test.lib.cli.predicate.CPUSpecificPredicate; |
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
26438
diff
changeset
|
29 |
import jdk.test.lib.cli.predicate.OrPredicate; |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
30 |
import sun.hotspot.WhiteBox; |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
31 |
|
49345
2a12ff1fff68
8198987: [Graal] compiler/intrinsics/sha/sanity tests fail on macos with Graal as JIT
thartmann
parents:
47565
diff
changeset
|
32 |
import java.lang.reflect.Method; |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
33 |
import java.util.function.BooleanSupplier; |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
34 |
|
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
35 |
/** |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
36 |
* Helper class aimed to provide predicates on availability of SHA-related |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
37 |
* CPU instructions and intrinsics. |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
38 |
*/ |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
39 |
public class IntrinsicPredicates { |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
40 |
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
41 |
private static final long TIERED_MAX_LEVEL = 4L; |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
42 |
/** |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
43 |
* Boolean supplier that check if any method could be compiled by C2. |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
44 |
* Method potentially could be compiled by C2 if Server VM is used and |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
45 |
* either tiered compilation is disabled or TIERED_MAX_LEVEL tier is |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
46 |
* reachable. |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
47 |
* |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
48 |
* Please don't place this definition after SHA*_INTRINSICS_AVAILABLE |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
49 |
* definitions. Otherwise its value will be {@code null} at the time when |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
50 |
* all dependent fields will be initialized. |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
51 |
*/ |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
52 |
private static final BooleanSupplier COMPILABLE_BY_C2 = () -> { |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
53 |
boolean isTiered = IntrinsicPredicates.WHITE_BOX.getBooleanVMFlag( |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
54 |
"TieredCompilation"); |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
55 |
long tieredMaxLevel = IntrinsicPredicates.WHITE_BOX.getIntxVMFlag( |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
56 |
"TieredStopAtLevel"); |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
57 |
boolean maxLevelIsReachable = (tieredMaxLevel |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
58 |
== IntrinsicPredicates.TIERED_MAX_LEVEL); |
43455
96560cffef4d
8166002: Emulate client build on platforms with reduced virtual address space
jcm
parents:
42543
diff
changeset
|
59 |
return Platform.isServer() && !Platform.isEmulatedClient() && (!isTiered || maxLevelIsReachable); |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
60 |
}; |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
61 |
|
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
62 |
public static final BooleanSupplier SHA1_INSTRUCTION_AVAILABLE |
42543 | 63 |
= new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] { "sha1" }, null), |
64 |
new OrPredicate(new CPUSpecificPredicate("s390.*", new String[] { "sha1" }, null), |
|
65 |
new OrPredicate(new CPUSpecificPredicate("sparc.*", new String[] { "sha1" }, null), |
|
66 |
// x86 variants |
|
67 |
new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" }, null), |
|
68 |
new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] { "sha" }, null), |
|
69 |
new CPUSpecificPredicate("x86.*", new String[] { "sha" }, null)))))); |
|
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
70 |
|
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
71 |
public static final BooleanSupplier SHA256_INSTRUCTION_AVAILABLE |
42543 | 72 |
= new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] { "sha256" }, null), |
73 |
new OrPredicate(new CPUSpecificPredicate("s390.*", new String[] { "sha256" }, null), |
|
74 |
new OrPredicate(new CPUSpecificPredicate("sparc.*", new String[] { "sha256" }, null), |
|
47565 | 75 |
new OrPredicate(new CPUSpecificPredicate("ppc64.*", new String[] { "sha" }, null), |
76 |
new OrPredicate(new CPUSpecificPredicate("ppc64le.*", new String[] { "sha" }, null), |
|
42543 | 77 |
// x86 variants |
78 |
new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" }, null), |
|
79 |
new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] { "sha" }, null), |
|
80 |
new OrPredicate(new CPUSpecificPredicate("x86.*", new String[] { "sha" }, null), |
|
81 |
new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "avx2", "bmi2" }, null), |
|
47565 | 82 |
new CPUSpecificPredicate("x86_64", new String[] { "avx2", "bmi2" }, null)))))))))); |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
83 |
|
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
84 |
public static final BooleanSupplier SHA512_INSTRUCTION_AVAILABLE |
42543 | 85 |
= new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] { "sha512" }, null), |
86 |
new OrPredicate(new CPUSpecificPredicate("s390.*", new String[] { "sha512" }, null), |
|
87 |
new OrPredicate(new CPUSpecificPredicate("sparc.*", new String[] { "sha512" }, null), |
|
47565 | 88 |
new OrPredicate(new CPUSpecificPredicate("ppc64.*", new String[] { "sha" }, null), |
89 |
new OrPredicate(new CPUSpecificPredicate("ppc64le.*", new String[] { "sha" }, null), |
|
42543 | 90 |
// x86 variants |
91 |
new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" }, null), |
|
92 |
new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] { "sha" }, null), |
|
93 |
new OrPredicate(new CPUSpecificPredicate("x86.*", new String[] { "sha" }, null), |
|
94 |
new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "avx2", "bmi2" }, null), |
|
47565 | 95 |
new CPUSpecificPredicate("x86_64", new String[] { "avx2", "bmi2" }, null)))))))))); |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
96 |
|
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
97 |
public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
98 |
= new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE, |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
99 |
new OrPredicate( |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
100 |
IntrinsicPredicates.SHA256_INSTRUCTION_AVAILABLE, |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
101 |
IntrinsicPredicates.SHA512_INSTRUCTION_AVAILABLE)); |
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
102 |
|
51410
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
103 |
public static BooleanSupplier isSHA1IntrinsicAvailable() { |
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
104 |
return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2, |
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
105 |
IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA", "implCompress0")); |
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
106 |
} |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
107 |
|
51410
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
108 |
public static BooleanSupplier isSHA256IntrinsicAvailable() { |
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
109 |
return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2, |
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
110 |
IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA2", "implCompress0")); |
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
111 |
} |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
112 |
|
51410
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
113 |
public static BooleanSupplier isSHA512IntrinsicAvailable() { |
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
114 |
return new AndPredicate(IntrinsicPredicates.COMPILABLE_BY_C2, |
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
115 |
IntrinsicPredicates.isIntrinsicAvailable("sun.security.provider.SHA5", "implCompress0")); |
cb8cab787ba2
8209459: TestSHA512MultiBlockIntrinsics failed on AArch64
thartmann
parents:
49345
diff
changeset
|
116 |
} |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
117 |
|
49345
2a12ff1fff68
8198987: [Graal] compiler/intrinsics/sha/sanity tests fail on macos with Graal as JIT
thartmann
parents:
47565
diff
changeset
|
118 |
private static BooleanSupplier isIntrinsicAvailable(String klass, String method) { |
2a12ff1fff68
8198987: [Graal] compiler/intrinsics/sha/sanity tests fail on macos with Graal as JIT
thartmann
parents:
47565
diff
changeset
|
119 |
try { |
2a12ff1fff68
8198987: [Graal] compiler/intrinsics/sha/sanity tests fail on macos with Graal as JIT
thartmann
parents:
47565
diff
changeset
|
120 |
Method m = Class.forName(klass).getDeclaredMethod(method, byte[].class, int.class); |
2a12ff1fff68
8198987: [Graal] compiler/intrinsics/sha/sanity tests fail on macos with Graal as JIT
thartmann
parents:
47565
diff
changeset
|
121 |
return () -> WHITE_BOX.isIntrinsicAvailable(m, (int)IntrinsicPredicates.TIERED_MAX_LEVEL); |
2a12ff1fff68
8198987: [Graal] compiler/intrinsics/sha/sanity tests fail on macos with Graal as JIT
thartmann
parents:
47565
diff
changeset
|
122 |
} catch (Exception e) { |
2a12ff1fff68
8198987: [Graal] compiler/intrinsics/sha/sanity tests fail on macos with Graal as JIT
thartmann
parents:
47565
diff
changeset
|
123 |
throw new RuntimeException("Intrinsified method " + klass + "::" + method + " not found!"); |
2a12ff1fff68
8198987: [Graal] compiler/intrinsics/sha/sanity tests fail on macos with Graal as JIT
thartmann
parents:
47565
diff
changeset
|
124 |
} |
2a12ff1fff68
8198987: [Graal] compiler/intrinsics/sha/sanity tests fail on macos with Graal as JIT
thartmann
parents:
47565
diff
changeset
|
125 |
}; |
26438
7a4e6f3d7b53
8055903: Develop sanity tests on SPARC's SHA instructions support
fzhinkin
parents:
diff
changeset
|
126 |
} |