src/share/vm/opto/library_call.cpp

changeset 6507
752ba2e5f6d0
parent 6502
3514ee402842
parent 6312
04d32e7fad07
child 6510
7c462558a08a
     1.1 --- a/src/share/vm/opto/library_call.cpp	Wed Feb 19 20:12:43 2014 -0800
     1.2 +++ b/src/share/vm/opto/library_call.cpp	Tue Feb 25 15:11:18 2014 -0800
     1.3 @@ -304,6 +304,7 @@
     1.4    bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id);
     1.5    Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting);
     1.6    Node* get_key_start_from_aescrypt_object(Node* aescrypt_object);
     1.7 +  Node* get_original_key_start_from_aescrypt_object(Node* aescrypt_object);
     1.8    bool inline_encodeISOArray();
     1.9    bool inline_updateCRC32();
    1.10    bool inline_updateBytesCRC32();
    1.11 @@ -5945,10 +5946,22 @@
    1.12    Node* k_start = get_key_start_from_aescrypt_object(aescrypt_object);
    1.13    if (k_start == NULL) return false;
    1.14  
    1.15 -  // Call the stub.
    1.16 -  make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::aescrypt_block_Type(),
    1.17 -                    stubAddr, stubName, TypePtr::BOTTOM,
    1.18 -                    src_start, dest_start, k_start);
    1.19 +  if (Matcher::pass_original_key_for_aes()) {
    1.20 +    // on SPARC we need to pass the original key since key expansion needs to happen in intrinsics due to
    1.21 +    // compatibility issues between Java key expansion and SPARC crypto instructions
    1.22 +    Node* original_k_start = get_original_key_start_from_aescrypt_object(aescrypt_object);
    1.23 +    if (original_k_start == NULL) return false;
    1.24 +
    1.25 +    // Call the stub.
    1.26 +    make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::aescrypt_block_Type(),
    1.27 +                      stubAddr, stubName, TypePtr::BOTTOM,
    1.28 +                      src_start, dest_start, k_start, original_k_start);
    1.29 +  } else {
    1.30 +    // Call the stub.
    1.31 +    make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::aescrypt_block_Type(),
    1.32 +                      stubAddr, stubName, TypePtr::BOTTOM,
    1.33 +                      src_start, dest_start, k_start);
    1.34 +  }
    1.35  
    1.36    return true;
    1.37  }
    1.38 @@ -6026,14 +6039,29 @@
    1.39    if (objRvec == NULL) return false;
    1.40    Node* r_start = array_element_address(objRvec, intcon(0), T_BYTE);
    1.41  
    1.42 -  // Call the stub, passing src_start, dest_start, k_start, r_start and src_len
    1.43 -  make_runtime_call(RC_LEAF|RC_NO_FP,
    1.44 -                    OptoRuntime::cipherBlockChaining_aescrypt_Type(),
    1.45 -                    stubAddr, stubName, TypePtr::BOTTOM,
    1.46 -                    src_start, dest_start, k_start, r_start, len);
    1.47 -
    1.48 -  // return is void so no result needs to be pushed
    1.49 -
    1.50 +  Node* cbcCrypt;
    1.51 +  if (Matcher::pass_original_key_for_aes()) {
    1.52 +    // on SPARC we need to pass the original key since key expansion needs to happen in intrinsics due to
    1.53 +    // compatibility issues between Java key expansion and SPARC crypto instructions
    1.54 +    Node* original_k_start = get_original_key_start_from_aescrypt_object(aescrypt_object);
    1.55 +    if (original_k_start == NULL) return false;
    1.56 +
    1.57 +    // Call the stub, passing src_start, dest_start, k_start, r_start, src_len and original_k_start
    1.58 +    cbcCrypt = make_runtime_call(RC_LEAF|RC_NO_FP,
    1.59 +                                 OptoRuntime::cipherBlockChaining_aescrypt_Type(),
    1.60 +                                 stubAddr, stubName, TypePtr::BOTTOM,
    1.61 +                                 src_start, dest_start, k_start, r_start, len, original_k_start);
    1.62 +  } else {
    1.63 +    // Call the stub, passing src_start, dest_start, k_start, r_start and src_len
    1.64 +    cbcCrypt = make_runtime_call(RC_LEAF|RC_NO_FP,
    1.65 +                                 OptoRuntime::cipherBlockChaining_aescrypt_Type(),
    1.66 +                                 stubAddr, stubName, TypePtr::BOTTOM,
    1.67 +                                 src_start, dest_start, k_start, r_start, len);
    1.68 +  }
    1.69 +
    1.70 +  // return cipher length (int)
    1.71 +  Node* retvalue = _gvn.transform(new (C) ProjNode(cbcCrypt, TypeFunc::Parms));
    1.72 +  set_result(retvalue);
    1.73    return true;
    1.74  }
    1.75  
    1.76 @@ -6048,6 +6076,17 @@
    1.77    return k_start;
    1.78  }
    1.79  
    1.80 +//------------------------------get_original_key_start_from_aescrypt_object-----------------------
    1.81 +Node * LibraryCallKit::get_original_key_start_from_aescrypt_object(Node *aescrypt_object) {
    1.82 +  Node* objAESCryptKey = load_field_from_object(aescrypt_object, "lastKey", "[B", /*is_exact*/ false);
    1.83 +  assert (objAESCryptKey != NULL, "wrong version of com.sun.crypto.provider.AESCrypt");
    1.84 +  if (objAESCryptKey == NULL) return (Node *) NULL;
    1.85 +
    1.86 +  // now have the array, need to get the start address of the lastKey array
    1.87 +  Node* original_k_start = array_element_address(objAESCryptKey, intcon(0), T_BYTE);
    1.88 +  return original_k_start;
    1.89 +}
    1.90 +
    1.91  //----------------------------inline_cipherBlockChaining_AESCrypt_predicate----------------------------
    1.92  // Return node representing slow path of predicate check.
    1.93  // the pseudo code we want to emulate with this predicate is:

mercurial