mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-15 08:34:30 +02:00
Merge
This commit is contained in:
commit
3e18a6f16d
17 changed files with 769 additions and 174 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2014, 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
|
||||
|
@ -40,9 +40,20 @@ abstract public class TestAESBase {
|
|||
int msgSize = Integer.getInteger("msgSize", 646);
|
||||
boolean checkOutput = Boolean.getBoolean("checkOutput");
|
||||
boolean noReinit = Boolean.getBoolean("noReinit");
|
||||
boolean testingMisalignment;
|
||||
private static final int ALIGN = 8;
|
||||
int encInputOffset = Integer.getInteger("encInputOffset", 0) % ALIGN;
|
||||
int encOutputOffset = Integer.getInteger("encOutputOffset", 0) % ALIGN;
|
||||
int decOutputOffset = Integer.getInteger("decOutputOffset", 0) % ALIGN;
|
||||
int lastChunkSize = Integer.getInteger("lastChunkSize", 32);
|
||||
int keySize = Integer.getInteger("keySize", 128);
|
||||
int inputLength;
|
||||
int encodeLength;
|
||||
int decodeLength;
|
||||
int decodeMsgSize;
|
||||
String algorithm = System.getProperty("algorithm", "AES");
|
||||
String mode = System.getProperty("mode", "CBC");
|
||||
String paddingStr = System.getProperty("paddingStr", "PKCS5Padding");
|
||||
byte[] input;
|
||||
byte[] encode;
|
||||
byte[] expectedEncode;
|
||||
|
@ -51,7 +62,6 @@ abstract public class TestAESBase {
|
|||
Random random = new Random(0);
|
||||
Cipher cipher;
|
||||
Cipher dCipher;
|
||||
String paddingStr = "PKCS5Padding";
|
||||
AlgorithmParameters algParams;
|
||||
SecretKey key;
|
||||
|
||||
|
@ -67,7 +77,10 @@ abstract public class TestAESBase {
|
|||
|
||||
public void prepare() {
|
||||
try {
|
||||
System.out.println("\nalgorithm=" + algorithm + ", mode=" + mode + ", msgSize=" + msgSize + ", keySize=" + keySize + ", noReinit=" + noReinit + ", checkOutput=" + checkOutput);
|
||||
System.out.println("\nalgorithm=" + algorithm + ", mode=" + mode + ", paddingStr=" + paddingStr + ", msgSize=" + msgSize + ", keySize=" + keySize + ", noReinit=" + noReinit + ", checkOutput=" + checkOutput + ", encInputOffset=" + encInputOffset + ", encOutputOffset=" + encOutputOffset + ", decOutputOffset=" + decOutputOffset + ", lastChunkSize=" +lastChunkSize );
|
||||
|
||||
if (encInputOffset % ALIGN != 0 || encOutputOffset % ALIGN != 0 || decOutputOffset % ALIGN !=0 )
|
||||
testingMisalignment = true;
|
||||
|
||||
int keyLenBytes = (keySize == 0 ? 16 : keySize/8);
|
||||
byte keyBytes[] = new byte[keyLenBytes];
|
||||
|
@ -81,10 +94,6 @@ abstract public class TestAESBase {
|
|||
System.out.println("Algorithm: " + key.getAlgorithm() + "("
|
||||
+ key.getEncoded().length * 8 + "bit)");
|
||||
}
|
||||
input = new byte[msgSize];
|
||||
for (int i=0; i<input.length; i++) {
|
||||
input[i] = (byte) (i & 0xff);
|
||||
}
|
||||
|
||||
cipher = Cipher.getInstance(algorithm + "/" + mode + "/" + paddingStr, "SunJCE");
|
||||
dCipher = Cipher.getInstance(algorithm + "/" + mode + "/" + paddingStr, "SunJCE");
|
||||
|
@ -103,10 +112,35 @@ abstract public class TestAESBase {
|
|||
childShowCipher();
|
||||
}
|
||||
|
||||
inputLength = msgSize + encInputOffset;
|
||||
if (testingMisalignment) {
|
||||
encodeLength = cipher.getOutputSize(msgSize - lastChunkSize) + encOutputOffset;
|
||||
encodeLength += cipher.getOutputSize(lastChunkSize);
|
||||
decodeLength = dCipher.getOutputSize(encodeLength - lastChunkSize) + decOutputOffset;
|
||||
decodeLength += dCipher.getOutputSize(lastChunkSize);
|
||||
} else {
|
||||
encodeLength = cipher.getOutputSize(msgSize) + encOutputOffset;
|
||||
decodeLength = dCipher.getOutputSize(encodeLength) + decOutputOffset;
|
||||
}
|
||||
|
||||
input = new byte[inputLength];
|
||||
for (int i=encInputOffset, j=0; i<inputLength; i++, j++) {
|
||||
input[i] = (byte) (j & 0xff);
|
||||
}
|
||||
|
||||
// do one encode and decode in preparation
|
||||
// this will also create the encode buffer and decode buffer
|
||||
encode = cipher.doFinal(input);
|
||||
decode = dCipher.doFinal(encode);
|
||||
encode = new byte[encodeLength];
|
||||
decode = new byte[decodeLength];
|
||||
if (testingMisalignment) {
|
||||
decodeMsgSize = cipher.update(input, encInputOffset, (msgSize - lastChunkSize), encode, encOutputOffset);
|
||||
decodeMsgSize += cipher.doFinal(input, (encInputOffset + msgSize - lastChunkSize), lastChunkSize, encode, (encOutputOffset + decodeMsgSize));
|
||||
|
||||
int tempSize = dCipher.update(encode, encOutputOffset, (decodeMsgSize - lastChunkSize), decode, decOutputOffset);
|
||||
dCipher.doFinal(encode, (encOutputOffset + decodeMsgSize - lastChunkSize), lastChunkSize, decode, (decOutputOffset + tempSize));
|
||||
} else {
|
||||
decodeMsgSize = cipher.doFinal(input, encInputOffset, msgSize, encode, encOutputOffset);
|
||||
dCipher.doFinal(encode, encOutputOffset, decodeMsgSize, decode, decOutputOffset);
|
||||
}
|
||||
if (checkOutput) {
|
||||
expectedEncode = (byte[]) encode.clone();
|
||||
expectedDecode = (byte[]) decode.clone();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2014, 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
|
||||
|
@ -33,14 +33,15 @@ public class TestAESDecode extends TestAESBase {
|
|||
public void run() {
|
||||
try {
|
||||
if (!noReinit) dCipher.init(Cipher.DECRYPT_MODE, key, algParams);
|
||||
if (checkOutput) {
|
||||
// checked version creates new output buffer each time
|
||||
decode = dCipher.doFinal(encode, 0, encode.length);
|
||||
compareArrays(decode, expectedDecode);
|
||||
decode = new byte[decodeLength];
|
||||
if (testingMisalignment) {
|
||||
int tempSize = dCipher.update(encode, encOutputOffset, (decodeMsgSize - lastChunkSize), decode, decOutputOffset);
|
||||
dCipher.doFinal(encode, (encOutputOffset + decodeMsgSize - lastChunkSize), lastChunkSize, decode, (decOutputOffset + tempSize));
|
||||
} else {
|
||||
// non-checked version outputs to existing encode buffer for maximum speed
|
||||
decode = new byte[dCipher.getOutputSize(encode.length)];
|
||||
dCipher.doFinal(encode, 0, encode.length, decode);
|
||||
dCipher.doFinal(encode, encOutputOffset, decodeMsgSize, decode, decOutputOffset);
|
||||
}
|
||||
if (checkOutput) {
|
||||
compareArrays(decode, expectedDecode);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2014, 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
|
||||
|
@ -33,14 +33,15 @@ public class TestAESEncode extends TestAESBase {
|
|||
public void run() {
|
||||
try {
|
||||
if (!noReinit) cipher.init(Cipher.ENCRYPT_MODE, key, algParams);
|
||||
if (checkOutput) {
|
||||
// checked version creates new output buffer each time
|
||||
encode = cipher.doFinal(input, 0, msgSize);
|
||||
compareArrays(encode, expectedEncode);
|
||||
encode = new byte[encodeLength];
|
||||
if (testingMisalignment) {
|
||||
int tempSize = cipher.update(input, encInputOffset, (msgSize - lastChunkSize), encode, encOutputOffset);
|
||||
cipher.doFinal(input, (encInputOffset + msgSize - lastChunkSize), lastChunkSize, encode, (encOutputOffset + tempSize));
|
||||
} else {
|
||||
// non-checked version outputs to existing encode buffer for maximum speed
|
||||
encode = new byte[cipher.getOutputSize(msgSize)];
|
||||
cipher.doFinal(input, 0, msgSize, encode);
|
||||
cipher.doFinal(input, encInputOffset, msgSize, encode, encOutputOffset);
|
||||
}
|
||||
if (checkOutput) {
|
||||
compareArrays(encode, expectedEncode);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2014 Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2014, 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
|
||||
|
@ -28,7 +28,19 @@
|
|||
* @summary add intrinsics to use AES instructions
|
||||
*
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencOutputOffset=1 TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DdecOutputOffset=1 TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=CBC -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencOutputOffset=1 TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DdecOutputOffset=1 TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 TestAESMain
|
||||
* @run main/othervm/timeout=600 -Xbatch -DcheckOutput=true -Dmode=ECB -DencInputOffset=1 -DencOutputOffset=1 -DdecOutputOffset=1 -DpaddingStr=NoPadding -DmsgSize=640 TestAESMain
|
||||
*
|
||||
* @author Tom Deneau
|
||||
*/
|
||||
|
@ -36,12 +48,13 @@
|
|||
public class TestAESMain {
|
||||
public static void main(String[] args) {
|
||||
int iters = (args.length > 0 ? Integer.valueOf(args[0]) : 1000000);
|
||||
int warmupIters = (args.length > 1 ? Integer.valueOf(args[1]) : 20000);
|
||||
System.out.println(iters + " iterations");
|
||||
TestAESEncode etest = new TestAESEncode();
|
||||
etest.prepare();
|
||||
// warm-up for 20K iterations
|
||||
// warm-up
|
||||
System.out.println("Starting encryption warm-up");
|
||||
for (int i=0; i<20000; i++) {
|
||||
for (int i=0; i<warmupIters; i++) {
|
||||
etest.run();
|
||||
}
|
||||
System.out.println("Finished encryption warm-up");
|
||||
|
@ -54,9 +67,9 @@ public class TestAESMain {
|
|||
|
||||
TestAESDecode dtest = new TestAESDecode();
|
||||
dtest.prepare();
|
||||
// warm-up for 20K iterations
|
||||
// warm-up
|
||||
System.out.println("Starting decryption warm-up");
|
||||
for (int i=0; i<20000; i++) {
|
||||
for (int i=0; i<warmupIters; i++) {
|
||||
dtest.run();
|
||||
}
|
||||
System.out.println("Finished decryption warm-up");
|
||||
|
|
|
@ -30,11 +30,28 @@
|
|||
import com.oracle.java.testlibrary.*;
|
||||
|
||||
public class NumCompilerThreadsCheck {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:CICompilerCount=-1");
|
||||
OutputAnalyzer out = new OutputAnalyzer(pb.start());
|
||||
|
||||
String expectedOutput = "CICompilerCount of -1 is invalid";
|
||||
out.shouldContain(expectedOutput);
|
||||
|
||||
if (isZeroVm()) {
|
||||
String expectedLowWaterMarkText = "must be at least 0";
|
||||
out.shouldContain(expectedLowWaterMarkText);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isZeroVm() {
|
||||
String vmName = System.getProperty("java.vm.name");
|
||||
if (vmName == null) {
|
||||
throw new RuntimeException("No VM name");
|
||||
}
|
||||
if (vmName.toLowerCase().contains("zero")) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue