# HG changeset patch # User Doug Simon # Date 1385495671 -3600 # Node ID 5b58f47462862b008752c80ee4e9746433db5f38 # Parent 74cfcd0fbedfa1e30321e8b4ed6502a075ab4a76 fixed HotSpot compiler test 7184394 (GRAAL-612) diff -r 74cfcd0fbedf -r 5b58f4746286 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java Tue Nov 26 18:43:53 2013 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java Tue Nov 26 20:54:31 2013 +0100 @@ -69,7 +69,7 @@ return AESCryptSubstitutions.AESCryptClass; } - @MethodSubstitution(isStatic = false) + @MethodSubstitution(isStatic = false, optional = true) static void encrypt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset) { Object embeddedCipher = UnsafeLoadNode.load(rcvr, embeddedCipherOffset, Kind.Object, embeddedCipherLocationIdentity); if (getAESCryptClass().isInstance(embeddedCipher)) { @@ -79,7 +79,7 @@ } } - @MethodSubstitution(isStatic = false) + @MethodSubstitution(isStatic = false, optional = true) static void decrypt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset) { Object embeddedCipher = UnsafeLoadNode.load(rcvr, embeddedCipherOffset, Kind.Object, embeddedCipherLocationIdentity); if (in != out && getAESCryptClass().isInstance(embeddedCipher)) { @@ -89,6 +89,28 @@ } } + @MethodSubstitution(value = "encrypt", isStatic = false, optional = true) + static int encryptInt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset) { + Object embeddedCipher = UnsafeLoadNode.load(rcvr, embeddedCipherOffset, Kind.Object, embeddedCipherLocationIdentity); + if (getAESCryptClass().isInstance(embeddedCipher)) { + crypt(rcvr, in, inOffset, inLength, out, outOffset, embeddedCipher, true); + return inLength; + } else { + return encryptInt(rcvr, in, inOffset, inLength, out, outOffset); + } + } + + @MethodSubstitution(value = "decrypt", isStatic = false, optional = true) + static int decryptInt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset) { + Object embeddedCipher = UnsafeLoadNode.load(rcvr, embeddedCipherOffset, Kind.Object, embeddedCipherLocationIdentity); + if (in != out && getAESCryptClass().isInstance(embeddedCipher)) { + crypt(rcvr, in, inOffset, inLength, out, outOffset, embeddedCipher, false); + return inLength; + } else { + return decryptInt(rcvr, in, inOffset, inLength, out, outOffset); + } + } + private static void crypt(Object rcvr, byte[] in, int inOffset, int inLength, byte[] out, int outOffset, Object embeddedCipher, boolean encrypt) { Object kObject = UnsafeLoadNode.load(embeddedCipher, AESCryptSubstitutions.kOffset, Kind.Object, AESCryptSubstitutions.kLocationIdentity); Object rObject = UnsafeLoadNode.load(rcvr, rOffset, Kind.Object, rLocationIdentity);