changeset 13178:5b58f4746286

fixed HotSpot compiler test 7184394 (GRAAL-612)
author Doug Simon <doug.simon@oracle.com>
date Tue, 26 Nov 2013 20:54:31 +0100
parents 74cfcd0fbedf
children 5c7f67c7ccd4
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/CipherBlockChainingSubstitutions.java
diffstat 1 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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);