# HG changeset patch # User kvn # Date 1534191895 25200 # Node ID ae001a1deb74eb8da53ec362dd8ac2e5921085f7 # Parent 0dcd27526967514c749c43d3b5980825003ebaa5 8207153: Some intrinsic tests take long time to run Reviewed-by: thartmann, mikael diff -r 0dcd27526967 -r ae001a1deb74 test/hotspot/jtreg/compiler/codegen/aes/TestAESMain.java --- a/test/hotspot/jtreg/compiler/codegen/aes/TestAESMain.java Mon Aug 13 19:21:43 2018 +0200 +++ b/test/hotspot/jtreg/compiler/codegen/aes/TestAESMain.java Mon Aug 13 13:24:55 2018 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,65 +29,95 @@ * @library /test/lib / * @modules java.base/jdk.internal.misc * java.management + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission * * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DdecOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencOutputOffset= + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DdecOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DdecOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 -DencOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=GCM -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DdecOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.codegen.aes.TestAESMain * * @author Tom Deneau @@ -95,9 +125,26 @@ package compiler.codegen.aes; +import compiler.whitebox.CompilerWhiteBoxTest; +import sun.hotspot.code.Compiler; +import jtreg.SkippedException; + public class TestAESMain { public static void main(String[] args) { - int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 1000000); + String mode = System.getProperty("mode", "CBC"); + if ((mode.equals("CBC") || mode.equals("ECB")) && + !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.AESCrypt", "implEncryptBlock", byte[].class, int.class, byte[].class, int.class)) { + throw new SkippedException("AES intrinsic is not available"); + } + if (mode.equals("GCM") && + !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.GHASH", "processBlocks", byte[].class, int.class, int.class, long[].class, long[].class)) { + throw new SkippedException("GHASH intrinsic is not available"); + } + if (mode.equals("CTR") && + !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.CounterMode", "implCrypt", byte[].class, int.class, int.class, byte[].class, int.class)) { + throw new SkippedException("AES-CTR intrinsic is not available"); + } + int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 100000); int warmupIters = (args.length > 1 ? Integer.valueOf(args[1]) : 20000); System.out.println(iters + " iterations"); TestAESEncode etest = new TestAESEncode(); diff -r 0dcd27526967 -r ae001a1deb74 test/hotspot/jtreg/compiler/intrinsics/base64/TestBase64.java --- a/test/hotspot/jtreg/compiler/intrinsics/base64/TestBase64.java Mon Aug 13 19:21:43 2018 +0200 +++ b/test/hotspot/jtreg/compiler/intrinsics/base64/TestBase64.java Mon Aug 13 13:24:55 2018 -0700 @@ -25,8 +25,12 @@ * @test * @author Eric Wang * @summary tests java.util.Base64 + * @library /test/lib / + * @build sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission * * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * compiler.intrinsics.base64.TestBase64 */ @@ -45,12 +49,18 @@ import java.util.Objects; import java.util.Random; +import compiler.whitebox.CompilerWhiteBoxTest; +import sun.hotspot.code.Compiler; +import jtreg.SkippedException; public class TestBase64 { static boolean checkOutput = Boolean.getBoolean("checkOutput"); public static void main(String[] args) throws Exception { - int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 1000000); + if (!Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "java.util.Base64$Encoder", "encodeBlock", byte[].class, int.class, int.class, byte[].class, int.class, boolean.class)) { + throw new SkippedException("Base64 intrinsic is not available"); + } + int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 100000); System.out.println(iters + " iterations"); test0(Base64Type.BASIC, Base64.getEncoder(), Base64.getDecoder(),"plain.txt", "baseEncode.txt", iters); diff -r 0dcd27526967 -r ae001a1deb74 test/lib/sun/hotspot/code/Compiler.java --- a/test/lib/sun/hotspot/code/Compiler.java Mon Aug 13 19:21:43 2018 +0200 +++ b/test/lib/sun/hotspot/code/Compiler.java Mon Aug 13 13:24:55 2018 -0700 @@ -23,6 +23,7 @@ package sun.hotspot.code; +import java.lang.reflect.Executable; import sun.hotspot.WhiteBox; /** @@ -133,4 +134,20 @@ } return true; } + + /* + * Determine if the compiler corresponding to the compilation level 'compLevel' + * provides an intrinsic for 'class'.'method'. + */ + public static boolean isIntrinsicAvailable(int compLevel, String klass, String method, Class... parameterTypes) { + Executable intrinsicMethod; + try { + intrinsicMethod = Class.forName(klass).getDeclaredMethod(method, parameterTypes); + } catch (NoSuchMethodException e) { + throw new RuntimeException("Test bug, '" + method + "' method unavailable. " + e); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Test bug, '" + klass + "' class unavailable. " + e); + } + return WB.isIntrinsicAvailable(intrinsicMethod, compLevel); + } }