1 /* 2 * Copyright (c) 2020, Huawei Technologies Co. Ltd. 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 /** 25 * @test 26 * @bug 8252204 27 * @summary Verify that SHA3-224, SHA3-256, SHA3-384, SHA3-512 multi block intrinsic is actually used. 28 * @comment the test verifies compilation of java.base methods, so it can't be run w/ AOT'ed java.base 29 * @requires !vm.aot.enabled 30 * 31 * @library /test/lib / 32 * @modules java.base/jdk.internal.misc 33 * java.management 34 * 35 * @build sun.hotspot.WhiteBox 36 * @run driver ClassFileInstaller sun.hotspot.WhiteBox 37 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 38 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 39 * -XX:Tier4InvocationThreshold=500 40 * -XX:+LogCompilation -XX:LogFile=positive_224.log 41 * -XX:CompileOnly=sun/security/provider/DigestBase 42 * -XX:CompileOnly=sun/security/provider/SHA3 43 * -XX:+UseSHA3Intrinsics -XX:-UseMD5Intrinsics 44 * -XX:-UseSHA1Intrinsics -XX:-UseSHA256Intrinsics 45 * -XX:-UseSHA512Intrinsics -Dalgorithm=SHA3-224 46 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 47 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 48 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 49 * -XX:Tier4InvocationThreshold=500 50 * -XX:+LogCompilation -XX:LogFile=positive_224_def.log 51 * -XX:CompileOnly=sun/security/provider/DigestBase 52 * -XX:CompileOnly=sun/security/provider/SHA3 53 * -XX:+UseSHA3Intrinsics -Dalgorithm=SHA3-224 54 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 55 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 56 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 57 * -XX:Tier4InvocationThreshold=500 58 * -XX:+LogCompilation -XX:LogFile=negative_224.log 59 * -XX:CompileOnly=sun/security/provider/DigestBase 60 * -XX:CompileOnly=sun/security/provider/SHA3 -XX:-UseSHA 61 * -Dalgorithm=SHA3-224 62 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 63 * 64 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 65 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 66 * -XX:Tier4InvocationThreshold=500 67 * -XX:+LogCompilation -XX:LogFile=positive_256.log 68 * -XX:CompileOnly=sun/security/provider/DigestBase 69 * -XX:CompileOnly=sun/security/provider/SHA3 70 * -XX:+UseSHA3Intrinsics -XX:-UseMD5Intrinsics 71 * -XX:-UseSHA1Intrinsics -XX:-UseSHA256Intrinsics 72 * -XX:-UseSHA512Intrinsics -Dalgorithm=SHA3-256 73 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 74 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 75 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 76 * -XX:Tier4InvocationThreshold=500 77 * -XX:+LogCompilation -XX:LogFile=positive_256_def.log 78 * -XX:CompileOnly=sun/security/provider/DigestBase 79 * -XX:CompileOnly=sun/security/provider/SHA3 80 * -XX:+UseSHA3Intrinsics -Dalgorithm=SHA3-256 81 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 82 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 83 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 84 * -XX:Tier4InvocationThreshold=500 85 * -XX:+LogCompilation -XX:LogFile=negative_256.log 86 * -XX:CompileOnly=sun/security/provider/DigestBase 87 * -XX:CompileOnly=sun/security/provider/SHA3 -XX:-UseSHA 88 * -Dalgorithm=SHA3-256 89 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 90 * 91 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 92 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 93 * -XX:Tier4InvocationThreshold=500 94 * -XX:+LogCompilation -XX:LogFile=positive_384.log 95 * -XX:CompileOnly=sun/security/provider/DigestBase 96 * -XX:CompileOnly=sun/security/provider/SHA3 97 * -XX:+UseSHA3Intrinsics -XX:-UseMD5Intrinsics 98 * -XX:-UseSHA1Intrinsics -XX:-UseSHA256Intrinsics 99 * -XX:-UseSHA512Intrinsics -Dalgorithm=SHA3-384 100 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 101 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 102 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 103 * -XX:Tier4InvocationThreshold=500 104 * -XX:+LogCompilation -XX:LogFile=positive_384_def.log 105 * -XX:CompileOnly=sun/security/provider/DigestBase 106 * -XX:CompileOnly=sun/security/provider/SHA3 107 * -XX:+UseSHA3Intrinsics -Dalgorithm=SHA3-384 108 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 109 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 110 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 111 * -XX:Tier4InvocationThreshold=500 112 * -XX:+LogCompilation -XX:LogFile=negative_384.log 113 * -XX:CompileOnly=sun/security/provider/DigestBase 114 * -XX:CompileOnly=sun/security/provider/SHA3 -XX:-UseSHA 115 * -Dalgorithm=SHA3-384 116 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 117 * 118 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 119 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 120 * -XX:Tier4InvocationThreshold=500 121 * -XX:+LogCompilation -XX:LogFile=positive_512.log 122 * -XX:CompileOnly=sun/security/provider/DigestBase 123 * -XX:CompileOnly=sun/security/provider/SHA3 124 * -XX:+UseSHA3Intrinsics -XX:-UseMD5Intrinsics 125 * -XX:-UseSHA1Intrinsics -XX:-UseSHA256Intrinsics 126 * -XX:-UseSHA512Intrinsics -Dalgorithm=SHA3-512 127 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 128 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 129 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 130 * -XX:Tier4InvocationThreshold=500 131 * -XX:+LogCompilation -XX:LogFile=positive_512_def.log 132 * -XX:CompileOnly=sun/security/provider/DigestBase 133 * -XX:CompileOnly=sun/security/provider/SHA3 134 * -XX:+UseSHA3Intrinsics -Dalgorithm=SHA3-512 135 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 136 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 137 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 138 * -XX:Tier4InvocationThreshold=500 139 * -XX:+LogCompilation -XX:LogFile=negative_512.log 140 * -XX:CompileOnly=sun/security/provider/DigestBase 141 * -XX:CompileOnly=sun/security/provider/SHA3 -XX:-UseSHA 142 * -Dalgorithm=SHA3-512 143 * compiler.intrinsics.sha.sanity.TestSHA3MultiBlockIntrinsics 144 * @run main/othervm -DverificationStrategy=VERIFY_INTRINSIC_USAGE 145 * compiler.testlibrary.intrinsics.Verifier positive_224.log positive_256.log 146 * positive_384.log positive_512.log positive_224_def.log positive_256_def.log 147 * positive_384_def.log positive_512_def.log negative_224.log negative_256.log 148 * negative_384.log negative_512.log 149 */ 150 151 package compiler.intrinsics.sha.sanity; 152 153 import compiler.testlibrary.sha.predicate.IntrinsicPredicates; 154 155 public class TestSHA3MultiBlockIntrinsics { 156 public static void main(String args[]) throws Exception { 157 new DigestSanityTestBase(IntrinsicPredicates.isSHA3IntrinsicAvailable(), 158 DigestSanityTestBase.MB_INTRINSIC_ID).test(); 159 } 160 }