comparison src/share/vm/opto/library_call.cpp @ 17670:04d32e7fad07

8002074: Support for AES on SPARC Summary: Add intrinsics/stub routines support for single-block and multi-block (as used by Cipher Block Chaining mode) AES encryption and decryption operations on the SPARC platform. Reviewed-by: kvn, roland Contributed-by: shrinivas.joshi@oracle.com
author kvn
date Tue, 14 Jan 2014 17:46:48 -0800
parents a57a165b8296
children abec000618bf cdb71841f4bc
comparison
equal deleted inserted replaced
17669:2996010c4820 17670:04d32e7fad07
302 bool inline_reference_get(); 302 bool inline_reference_get();
303 bool inline_aescrypt_Block(vmIntrinsics::ID id); 303 bool inline_aescrypt_Block(vmIntrinsics::ID id);
304 bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id); 304 bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id);
305 Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting); 305 Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting);
306 Node* get_key_start_from_aescrypt_object(Node* aescrypt_object); 306 Node* get_key_start_from_aescrypt_object(Node* aescrypt_object);
307 Node* get_original_key_start_from_aescrypt_object(Node* aescrypt_object);
307 bool inline_encodeISOArray(); 308 bool inline_encodeISOArray();
308 bool inline_updateCRC32(); 309 bool inline_updateCRC32();
309 bool inline_updateBytesCRC32(); 310 bool inline_updateBytesCRC32();
310 bool inline_updateByteBufferCRC32(); 311 bool inline_updateByteBufferCRC32();
311 }; 312 };
5934 // now need to get the start of its expanded key array 5935 // now need to get the start of its expanded key array
5935 // this requires a newer class file that has this array as littleEndian ints, otherwise we revert to java 5936 // this requires a newer class file that has this array as littleEndian ints, otherwise we revert to java
5936 Node* k_start = get_key_start_from_aescrypt_object(aescrypt_object); 5937 Node* k_start = get_key_start_from_aescrypt_object(aescrypt_object);
5937 if (k_start == NULL) return false; 5938 if (k_start == NULL) return false;
5938 5939
5939 // Call the stub. 5940 if (Matcher::pass_original_key_for_aes()) {
5940 make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::aescrypt_block_Type(), 5941 // on SPARC we need to pass the original key since key expansion needs to happen in intrinsics due to
5941 stubAddr, stubName, TypePtr::BOTTOM, 5942 // compatibility issues between Java key expansion and SPARC crypto instructions
5942 src_start, dest_start, k_start); 5943 Node* original_k_start = get_original_key_start_from_aescrypt_object(aescrypt_object);
5944 if (original_k_start == NULL) return false;
5945
5946 // Call the stub.
5947 make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::aescrypt_block_Type(),
5948 stubAddr, stubName, TypePtr::BOTTOM,
5949 src_start, dest_start, k_start, original_k_start);
5950 } else {
5951 // Call the stub.
5952 make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::aescrypt_block_Type(),
5953 stubAddr, stubName, TypePtr::BOTTOM,
5954 src_start, dest_start, k_start);
5955 }
5943 5956
5944 return true; 5957 return true;
5945 } 5958 }
5946 5959
5947 //------------------------------inline_cipherBlockChaining_AESCrypt----------------------- 5960 //------------------------------inline_cipherBlockChaining_AESCrypt-----------------------
6015 // similarly, get the start address of the r vector 6028 // similarly, get the start address of the r vector
6016 Node* objRvec = load_field_from_object(cipherBlockChaining_object, "r", "[B", /*is_exact*/ false); 6029 Node* objRvec = load_field_from_object(cipherBlockChaining_object, "r", "[B", /*is_exact*/ false);
6017 if (objRvec == NULL) return false; 6030 if (objRvec == NULL) return false;
6018 Node* r_start = array_element_address(objRvec, intcon(0), T_BYTE); 6031 Node* r_start = array_element_address(objRvec, intcon(0), T_BYTE);
6019 6032
6020 // Call the stub, passing src_start, dest_start, k_start, r_start and src_len 6033 Node* cbcCrypt;
6021 make_runtime_call(RC_LEAF|RC_NO_FP, 6034 if (Matcher::pass_original_key_for_aes()) {
6022 OptoRuntime::cipherBlockChaining_aescrypt_Type(), 6035 // on SPARC we need to pass the original key since key expansion needs to happen in intrinsics due to
6023 stubAddr, stubName, TypePtr::BOTTOM, 6036 // compatibility issues between Java key expansion and SPARC crypto instructions
6024 src_start, dest_start, k_start, r_start, len); 6037 Node* original_k_start = get_original_key_start_from_aescrypt_object(aescrypt_object);
6025 6038 if (original_k_start == NULL) return false;
6026 // return is void so no result needs to be pushed 6039
6027 6040 // Call the stub, passing src_start, dest_start, k_start, r_start, src_len and original_k_start
6041 cbcCrypt = make_runtime_call(RC_LEAF|RC_NO_FP,
6042 OptoRuntime::cipherBlockChaining_aescrypt_Type(),
6043 stubAddr, stubName, TypePtr::BOTTOM,
6044 src_start, dest_start, k_start, r_start, len, original_k_start);
6045 } else {
6046 // Call the stub, passing src_start, dest_start, k_start, r_start and src_len
6047 cbcCrypt = make_runtime_call(RC_LEAF|RC_NO_FP,
6048 OptoRuntime::cipherBlockChaining_aescrypt_Type(),
6049 stubAddr, stubName, TypePtr::BOTTOM,
6050 src_start, dest_start, k_start, r_start, len);
6051 }
6052
6053 // return cipher length (int)
6054 Node* retvalue = _gvn.transform(new (C) ProjNode(cbcCrypt, TypeFunc::Parms));
6055 set_result(retvalue);
6028 return true; 6056 return true;
6029 } 6057 }
6030 6058
6031 //------------------------------get_key_start_from_aescrypt_object----------------------- 6059 //------------------------------get_key_start_from_aescrypt_object-----------------------
6032 Node * LibraryCallKit::get_key_start_from_aescrypt_object(Node *aescrypt_object) { 6060 Node * LibraryCallKit::get_key_start_from_aescrypt_object(Node *aescrypt_object) {
6035 if (objAESCryptKey == NULL) return (Node *) NULL; 6063 if (objAESCryptKey == NULL) return (Node *) NULL;
6036 6064
6037 // now have the array, need to get the start address of the K array 6065 // now have the array, need to get the start address of the K array
6038 Node* k_start = array_element_address(objAESCryptKey, intcon(0), T_INT); 6066 Node* k_start = array_element_address(objAESCryptKey, intcon(0), T_INT);
6039 return k_start; 6067 return k_start;
6068 }
6069
6070 //------------------------------get_original_key_start_from_aescrypt_object-----------------------
6071 Node * LibraryCallKit::get_original_key_start_from_aescrypt_object(Node *aescrypt_object) {
6072 Node* objAESCryptKey = load_field_from_object(aescrypt_object, "lastKey", "[B", /*is_exact*/ false);
6073 assert (objAESCryptKey != NULL, "wrong version of com.sun.crypto.provider.AESCrypt");
6074 if (objAESCryptKey == NULL) return (Node *) NULL;
6075
6076 // now have the array, need to get the start address of the lastKey array
6077 Node* original_k_start = array_element_address(objAESCryptKey, intcon(0), T_BYTE);
6078 return original_k_start;
6040 } 6079 }
6041 6080
6042 //----------------------------inline_cipherBlockChaining_AESCrypt_predicate---------------------------- 6081 //----------------------------inline_cipherBlockChaining_AESCrypt_predicate----------------------------
6043 // Return node representing slow path of predicate check. 6082 // Return node representing slow path of predicate check.
6044 // the pseudo code we want to emulate with this predicate is: 6083 // the pseudo code we want to emulate with this predicate is: