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 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 44 * -Dalgorithm=SHA3-224 45 * compiler.intrinsics.sha.sanity.TestSHA3Intrinsics 46 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 47 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 48 * -XX:Tier4InvocationThreshold=500 49 * -XX:+LogCompilation -XX:LogFile=negative_224.log 50 * -XX:CompileOnly=sun/security/provider/DigestBase 51 * -XX:CompileOnly=sun/security/provider/SHA3 52 * -XX:-UseSHA3Intrinsics 53 * -Dalgorithm=SHA3-224 54 * compiler.intrinsics.sha.sanity.TestSHA3Intrinsics 55 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 56 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 57 * -XX:Tier4InvocationThreshold=500 58 * -XX:+LogCompilation -XX:LogFile=positive_256.log 59 * -XX:CompileOnly=sun/security/provider/DigestBase 60 * -XX:CompileOnly=sun/security/provider/SHA3 61 * -XX:+UseSHA3Intrinsics 62 * -Dalgorithm=SHA3-256 63 * compiler.intrinsics.sha.sanity.TestSHA3Intrinsics 64 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 65 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 66 * -XX:Tier4InvocationThreshold=500 67 * -XX:+LogCompilation -XX:LogFile=negative_256.log 68 * -XX:CompileOnly=sun/security/provider/DigestBase 69 * -XX:CompileOnly=sun/security/provider/SHA3 70 * -XX:-UseSHA3Intrinsics 71 * -Dalgorithm=SHA3-256 72 * compiler.intrinsics.sha.sanity.TestSHA3Intrinsics 73 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 74 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 75 * -XX:Tier4InvocationThreshold=500 76 * -XX:+LogCompilation -XX:LogFile=positive_384.log 77 * -XX:CompileOnly=sun/security/provider/DigestBase 78 * -XX:CompileOnly=sun/security/provider/SHA3 79 * -XX:+UseSHA3Intrinsics 80 * -Dalgorithm=SHA3-384 81 * compiler.intrinsics.sha.sanity.TestSHA3Intrinsics 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_384.log 86 * -XX:CompileOnly=sun/security/provider/DigestBase 87 * -XX:CompileOnly=sun/security/provider/SHA3 88 * -XX:-UseSHA3Intrinsics 89 * -Dalgorithm=SHA3-384 90 * compiler.intrinsics.sha.sanity.TestSHA3Intrinsics 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_512.log 95 * -XX:CompileOnly=sun/security/provider/DigestBase 96 * -XX:CompileOnly=sun/security/provider/SHA3 97 * -XX:+UseSHA3Intrinsics 98 * -Dalgorithm=SHA3-512 99 * compiler.intrinsics.sha.sanity.TestSHA3Intrinsics 100 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions 101 * -XX:+WhiteBoxAPI -Xbatch -XX:CompileThreshold=500 102 * -XX:Tier4InvocationThreshold=500 103 * -XX:+LogCompilation -XX:LogFile=negative_512.log 104 * -XX:CompileOnly=sun/security/provider/DigestBase 105 * -XX:CompileOnly=sun/security/provider/SHA3 106 * -XX:-UseSHA3Intrinsics 107 * -Dalgorithm=SHA3-512 108 * compiler.intrinsics.sha.sanity.TestSHA3Intrinsics 109 * @run main/othervm -DverificationStrategy=VERIFY_INTRINSIC_USAGE 110 * compiler.testlibrary.intrinsics.Verifier positive_224.log positive_256.log positive_384.log positive_512.log 111 * negative_224.log negative_256.log negative_384.log negative_512.log 112 */ 113 114 package compiler.intrinsics.sha.sanity; 115 116 import compiler.testlibrary.sha.predicate.IntrinsicPredicates; 117 118 public class TestSHA3Intrinsics { 119 public static void main(String args[]) throws Exception { 120 new DigestSanityTestBase(IntrinsicPredicates.isSHA3IntrinsicAvailable(), 121 DigestSanityTestBase.SHA3_INTRINSIC_ID).test(); 122 } 123 }