110 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DdecOutputOffset=1 111 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. 112 * compiler.codegen.aes.TestAESMain 113 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 114 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. 115 * compiler.codegen.aes.TestAESMain 116 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 117 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. 118 * compiler.codegen.aes.TestAESMain 119 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 120 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. 121 * compiler.codegen.aes.TestAESMain 122 * 123 * @author Tom Deneau 124 */ 125 126 package compiler.codegen.aes; 127 128 import compiler.whitebox.CompilerWhiteBoxTest; 129 import sun.hotspot.code.Compiler; 130 import jtreg.SkippedException; 131 132 public class TestAESMain { 133 public static void main(String[] args) { 134 String mode = System.getProperty("mode", "CBC"); 135 if ((mode.equals("CBC") || mode.equals("ECB")) && 136 !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.AESCrypt", "implEncryptBlock", byte[].class, int.class, byte[].class, int.class)) { 137 throw new SkippedException("AES intrinsic is not available"); 138 } 139 if (mode.equals("GCM") && 140 !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.GHASH", "processBlocks", byte[].class, int.class, int.class, long[].class, long[].class)) { 141 throw new SkippedException("GHASH intrinsic is not available"); 142 } 143 if (mode.equals("CTR") && 144 !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.CounterMode", "implCrypt", byte[].class, int.class, int.class, byte[].class, int.class)) { 145 throw new SkippedException("AES-CTR intrinsic is not available"); 146 } 147 int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 100000); 148 int warmupIters = (args.length > 1 ? Integer.valueOf(args[1]) : 20000); 149 System.out.println(iters + " iterations"); 150 TestAESEncode etest = new TestAESEncode(); 151 etest.prepare(); 152 // warm-up 153 System.out.println("Starting encryption warm-up"); 154 for (int i = 0; i < warmupIters; i++) { 155 etest.run(); 156 } 157 System.out.println("Finished encryption warm-up"); 158 long start = System.nanoTime(); 159 for (int i = 0; i < iters; i++) { 160 etest.run(); 161 } 162 long end = System.nanoTime(); 163 System.out.println("TestAESEncode runtime was " + (double) ((end - start) / 1000000.0) + " ms"); 164 165 TestAESDecode dtest = new TestAESDecode(); | 110 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DdecOutputOffset=1 111 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. 112 * compiler.codegen.aes.TestAESMain 113 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 114 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. 115 * compiler.codegen.aes.TestAESMain 116 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 117 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. 118 * compiler.codegen.aes.TestAESMain 119 * @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CTR -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 120 * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. 121 * compiler.codegen.aes.TestAESMain 122 * 123 * @author Tom Deneau 124 */ 125 126 package compiler.codegen.aes; 127 128 import compiler.whitebox.CompilerWhiteBoxTest; 129 import sun.hotspot.code.Compiler; 130 131 public class TestAESMain { 132 public static void main(String[] args) { 133 String mode = System.getProperty("mode", "CBC"); 134 if ((mode.equals("CBC") || mode.equals("ECB")) && 135 !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.AESCrypt", "implEncryptBlock", byte[].class, int.class, byte[].class, int.class)) { 136 System.out.println("AES intrinsic is not available"); 137 return; 138 } 139 if (mode.equals("GCM") && 140 !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.GHASH", "processBlocks", byte[].class, int.class, int.class, long[].class, long[].class)) { 141 System.out.println("GHASH intrinsic is not available"); 142 return; 143 } 144 if (mode.equals("CTR") && 145 !Compiler.isIntrinsicAvailable(CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION, "com.sun.crypto.provider.CounterMode", "implCrypt", byte[].class, int.class, int.class, byte[].class, int.class)) { 146 System.out.println("AES-CTR intrinsic is not available"); 147 return; 148 } 149 int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 100000); 150 int warmupIters = (args.length > 1 ? Integer.valueOf(args[1]) : 20000); 151 System.out.println(iters + " iterations"); 152 TestAESEncode etest = new TestAESEncode(); 153 etest.prepare(); 154 // warm-up 155 System.out.println("Starting encryption warm-up"); 156 for (int i = 0; i < warmupIters; i++) { 157 etest.run(); 158 } 159 System.out.println("Finished encryption warm-up"); 160 long start = System.nanoTime(); 161 for (int i = 0; i < iters; i++) { 162 etest.run(); 163 } 164 long end = System.nanoTime(); 165 System.out.println("TestAESEncode runtime was " + (double) ((end - start) / 1000000.0) + " ms"); 166 167 TestAESDecode dtest = new TestAESDecode(); |