< prev index next >

src/share/vm/opto/library_call.cpp

Print this page




 264   bool inline_native_hashcode(bool is_virtual, bool is_static);
 265   bool inline_native_getClass();
 266 
 267   // Helper functions for inlining arraycopy
 268   bool inline_arraycopy();
 269   AllocateArrayNode* tightly_coupled_allocation(Node* ptr,
 270                                                 RegionNode* slow_region);
 271   JVMState* arraycopy_restore_alloc_state(AllocateArrayNode* alloc, int& saved_reexecute_sp);
 272   void arraycopy_move_allocation_here(AllocateArrayNode* alloc, Node* dest, JVMState* saved_jvms, int saved_reexecute_sp);
 273 
 274   typedef enum { LS_xadd, LS_xchg, LS_cmpxchg } LoadStoreKind;
 275   bool inline_unsafe_load_store(BasicType type,  LoadStoreKind kind);
 276   bool inline_unsafe_ordered_store(BasicType type);
 277   bool inline_unsafe_fence(vmIntrinsics::ID id);
 278   bool inline_fp_conversions(vmIntrinsics::ID id);
 279   bool inline_number_methods(vmIntrinsics::ID id);
 280   bool inline_reference_get();
 281   bool inline_Class_cast();
 282   bool inline_aescrypt_Block(vmIntrinsics::ID id);
 283   bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id);

 284   Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting);

 285   Node* get_key_start_from_aescrypt_object(Node* aescrypt_object);
 286   Node* get_original_key_start_from_aescrypt_object(Node* aescrypt_object);
 287   bool inline_ghash_processBlocks();
 288   bool inline_sha_implCompress(vmIntrinsics::ID id);
 289   bool inline_digestBase_implCompressMB(int predicate);
 290   bool inline_sha_implCompressMB(Node* digestBaseObj, ciInstanceKlass* instklass_SHA,
 291                                  bool long_state, address stubAddr, const char *stubName,
 292                                  Node* src_start, Node* ofs, Node* limit);
 293   Node* get_state_from_sha_object(Node *sha_object);
 294   Node* get_state_from_sha5_object(Node *sha_object);
 295   Node* inline_digestBase_implCompressMB_predicate(int predicate);
 296   bool inline_encodeISOArray();
 297   bool inline_updateCRC32();
 298   bool inline_updateBytesCRC32();
 299   bool inline_updateByteBufferCRC32();
 300   Node* get_table_from_crc32c_class(ciInstanceKlass *crc32c_class);
 301   bool inline_updateBytesCRC32C();
 302   bool inline_updateDirectByteBufferCRC32C();
 303   bool inline_updateBytesAdler32();
 304   bool inline_updateByteBufferAdler32();


 675   case vmIntrinsics::_bitCount_i:
 676   case vmIntrinsics::_bitCount_l:
 677   case vmIntrinsics::_reverseBytes_i:
 678   case vmIntrinsics::_reverseBytes_l:
 679   case vmIntrinsics::_reverseBytes_s:
 680   case vmIntrinsics::_reverseBytes_c:           return inline_number_methods(intrinsic_id());
 681 
 682   case vmIntrinsics::_getCallerClass:           return inline_native_Reflection_getCallerClass();
 683 
 684   case vmIntrinsics::_Reference_get:            return inline_reference_get();
 685 
 686   case vmIntrinsics::_Class_cast:               return inline_Class_cast();
 687 
 688   case vmIntrinsics::_aescrypt_encryptBlock:
 689   case vmIntrinsics::_aescrypt_decryptBlock:    return inline_aescrypt_Block(intrinsic_id());
 690 
 691   case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
 692   case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
 693     return inline_cipherBlockChaining_AESCrypt(intrinsic_id());
 694 



 695   case vmIntrinsics::_sha_implCompress:
 696   case vmIntrinsics::_sha2_implCompress:
 697   case vmIntrinsics::_sha5_implCompress:
 698     return inline_sha_implCompress(intrinsic_id());
 699 
 700   case vmIntrinsics::_digestBase_implCompressMB:
 701     return inline_digestBase_implCompressMB(predicate);
 702 
 703   case vmIntrinsics::_multiplyToLen:
 704     return inline_multiplyToLen();
 705 
 706   case vmIntrinsics::_squareToLen:
 707     return inline_squareToLen();
 708 
 709   case vmIntrinsics::_mulAdd:
 710     return inline_mulAdd();
 711 
 712   case vmIntrinsics::_montgomeryMultiply:
 713     return inline_montgomeryMultiply();
 714   case vmIntrinsics::_montgomerySquare:


 756     }
 757 #endif
 758     return false;
 759   }
 760 }
 761 
 762 Node* LibraryCallKit::try_to_predicate(int predicate) {
 763   if (!jvms()->has_method()) {
 764     // Root JVMState has a null method.
 765     assert(map()->memory()->Opcode() == Op_Parm, "");
 766     // Insert the memory aliasing node
 767     set_all_memory(reset_memory());
 768   }
 769   assert(merged_memory(), "");
 770 
 771   switch (intrinsic_id()) {
 772   case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
 773     return inline_cipherBlockChaining_AESCrypt_predicate(false);
 774   case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
 775     return inline_cipherBlockChaining_AESCrypt_predicate(true);


 776   case vmIntrinsics::_digestBase_implCompressMB:
 777     return inline_digestBase_implCompressMB_predicate(predicate);
 778 
 779   default:
 780     // If you get here, it may be that someone has added a new intrinsic
 781     // to the list in vmSymbols.hpp without implementing it here.
 782 #ifndef PRODUCT
 783     if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {
 784       tty->print_cr("*** Warning: Unimplemented predicate for intrinsic %s(%d)",
 785                     vmIntrinsics::name_at(intrinsic_id()), intrinsic_id());
 786     }
 787 #endif
 788     Node* slow_ctl = control();
 789     set_control(top()); // No fast path instrinsic
 790     return slow_ctl;
 791   }
 792 }
 793 
 794 //------------------------------set_result-------------------------------
 795 // Helper function for finishing intrinsics.


6045 
6046     // Call the stub, passing src_start, dest_start, k_start, r_start, src_len and original_k_start
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, original_k_start);
6051   } else {
6052     // Call the stub, passing src_start, dest_start, k_start, r_start and src_len
6053     cbcCrypt = make_runtime_call(RC_LEAF|RC_NO_FP,
6054                                  OptoRuntime::cipherBlockChaining_aescrypt_Type(),
6055                                  stubAddr, stubName, TypePtr::BOTTOM,
6056                                  src_start, dest_start, k_start, r_start, len);
6057   }
6058 
6059   // return cipher length (int)
6060   Node* retvalue = _gvn.transform(new ProjNode(cbcCrypt, TypeFunc::Parms));
6061   set_result(retvalue);
6062   return true;
6063 }
6064 















































































6065 //------------------------------get_key_start_from_aescrypt_object-----------------------
6066 Node * LibraryCallKit::get_key_start_from_aescrypt_object(Node *aescrypt_object) {
6067   Node* objAESCryptKey = load_field_from_object(aescrypt_object, "K", "[I", /*is_exact*/ false);
6068   assert (objAESCryptKey != NULL, "wrong version of com.sun.crypto.provider.AESCrypt");
6069   if (objAESCryptKey == NULL) return (Node *) NULL;
6070 
6071   // now have the array, need to get the start address of the K array
6072   Node* k_start = array_element_address(objAESCryptKey, intcon(0), T_INT);
6073   return k_start;
6074 }
6075 
6076 //------------------------------get_original_key_start_from_aescrypt_object-----------------------
6077 Node * LibraryCallKit::get_original_key_start_from_aescrypt_object(Node *aescrypt_object) {
6078   Node* objAESCryptKey = load_field_from_object(aescrypt_object, "lastKey", "[B", /*is_exact*/ false);
6079   assert (objAESCryptKey != NULL, "wrong version of com.sun.crypto.provider.AESCrypt");
6080   if (objAESCryptKey == NULL) return (Node *) NULL;
6081 
6082   // now have the array, need to get the start address of the lastKey array
6083   Node* original_k_start = array_element_address(objAESCryptKey, intcon(0), T_BYTE);
6084   return original_k_start;


6124   Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN);
6125 
6126   // for encryption, we are done
6127   if (!decrypting)
6128     return instof_false;  // even if it is NULL
6129 
6130   // for decryption, we need to add a further check to avoid
6131   // taking the intrinsic path when cipher and plain are the same
6132   // see the original java code for why.
6133   RegionNode* region = new RegionNode(3);
6134   region->init_req(1, instof_false);
6135   Node* src = argument(1);
6136   Node* dest = argument(4);
6137   Node* cmp_src_dest = _gvn.transform(new CmpPNode(src, dest));
6138   Node* bool_src_dest = _gvn.transform(new BoolNode(cmp_src_dest, BoolTest::eq));
6139   Node* src_dest_conjoint = generate_guard(bool_src_dest, NULL, PROB_MIN);
6140   region->init_req(2, src_dest_conjoint);
6141 
6142   record_for_igvn(region);
6143   return _gvn.transform(region);










































6144 }
6145 
6146 //------------------------------inline_ghash_processBlocks
6147 bool LibraryCallKit::inline_ghash_processBlocks() {
6148   address stubAddr;
6149   const char *stubName;
6150   assert(UseGHASHIntrinsics, "need GHASH intrinsics support");
6151 
6152   stubAddr = StubRoutines::ghash_processBlocks();
6153   stubName = "ghash_processBlocks";
6154 
6155   Node* data           = argument(0);
6156   Node* offset         = argument(1);
6157   Node* len            = argument(2);
6158   Node* state          = argument(3);
6159   Node* subkeyH        = argument(4);
6160 
6161   Node* state_start  = array_element_address(state, intcon(0), T_LONG);
6162   assert(state_start, "state is NULL");
6163   Node* subkeyH_start  = array_element_address(subkeyH, intcon(0), T_LONG);




 264   bool inline_native_hashcode(bool is_virtual, bool is_static);
 265   bool inline_native_getClass();
 266 
 267   // Helper functions for inlining arraycopy
 268   bool inline_arraycopy();
 269   AllocateArrayNode* tightly_coupled_allocation(Node* ptr,
 270                                                 RegionNode* slow_region);
 271   JVMState* arraycopy_restore_alloc_state(AllocateArrayNode* alloc, int& saved_reexecute_sp);
 272   void arraycopy_move_allocation_here(AllocateArrayNode* alloc, Node* dest, JVMState* saved_jvms, int saved_reexecute_sp);
 273 
 274   typedef enum { LS_xadd, LS_xchg, LS_cmpxchg } LoadStoreKind;
 275   bool inline_unsafe_load_store(BasicType type,  LoadStoreKind kind);
 276   bool inline_unsafe_ordered_store(BasicType type);
 277   bool inline_unsafe_fence(vmIntrinsics::ID id);
 278   bool inline_fp_conversions(vmIntrinsics::ID id);
 279   bool inline_number_methods(vmIntrinsics::ID id);
 280   bool inline_reference_get();
 281   bool inline_Class_cast();
 282   bool inline_aescrypt_Block(vmIntrinsics::ID id);
 283   bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id);
 284   bool inline_counterMode_AESCrypt(vmIntrinsics::ID id);
 285   Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting);
 286   Node* inline_counterMode_AESCrypt_predicate();
 287   Node* get_key_start_from_aescrypt_object(Node* aescrypt_object);
 288   Node* get_original_key_start_from_aescrypt_object(Node* aescrypt_object);
 289   bool inline_ghash_processBlocks();
 290   bool inline_sha_implCompress(vmIntrinsics::ID id);
 291   bool inline_digestBase_implCompressMB(int predicate);
 292   bool inline_sha_implCompressMB(Node* digestBaseObj, ciInstanceKlass* instklass_SHA,
 293                                  bool long_state, address stubAddr, const char *stubName,
 294                                  Node* src_start, Node* ofs, Node* limit);
 295   Node* get_state_from_sha_object(Node *sha_object);
 296   Node* get_state_from_sha5_object(Node *sha_object);
 297   Node* inline_digestBase_implCompressMB_predicate(int predicate);
 298   bool inline_encodeISOArray();
 299   bool inline_updateCRC32();
 300   bool inline_updateBytesCRC32();
 301   bool inline_updateByteBufferCRC32();
 302   Node* get_table_from_crc32c_class(ciInstanceKlass *crc32c_class);
 303   bool inline_updateBytesCRC32C();
 304   bool inline_updateDirectByteBufferCRC32C();
 305   bool inline_updateBytesAdler32();
 306   bool inline_updateByteBufferAdler32();


 677   case vmIntrinsics::_bitCount_i:
 678   case vmIntrinsics::_bitCount_l:
 679   case vmIntrinsics::_reverseBytes_i:
 680   case vmIntrinsics::_reverseBytes_l:
 681   case vmIntrinsics::_reverseBytes_s:
 682   case vmIntrinsics::_reverseBytes_c:           return inline_number_methods(intrinsic_id());
 683 
 684   case vmIntrinsics::_getCallerClass:           return inline_native_Reflection_getCallerClass();
 685 
 686   case vmIntrinsics::_Reference_get:            return inline_reference_get();
 687 
 688   case vmIntrinsics::_Class_cast:               return inline_Class_cast();
 689 
 690   case vmIntrinsics::_aescrypt_encryptBlock:
 691   case vmIntrinsics::_aescrypt_decryptBlock:    return inline_aescrypt_Block(intrinsic_id());
 692 
 693   case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
 694   case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
 695     return inline_cipherBlockChaining_AESCrypt(intrinsic_id());
 696   
 697   case vmIntrinsics::_counterMode_AESCrypt:
 698     return inline_counterMode_AESCrypt(intrinsic_id());
 699     
 700   case vmIntrinsics::_sha_implCompress:
 701   case vmIntrinsics::_sha2_implCompress:
 702   case vmIntrinsics::_sha5_implCompress:
 703     return inline_sha_implCompress(intrinsic_id());
 704 
 705   case vmIntrinsics::_digestBase_implCompressMB:
 706     return inline_digestBase_implCompressMB(predicate);
 707 
 708   case vmIntrinsics::_multiplyToLen:
 709     return inline_multiplyToLen();
 710 
 711   case vmIntrinsics::_squareToLen:
 712     return inline_squareToLen();
 713 
 714   case vmIntrinsics::_mulAdd:
 715     return inline_mulAdd();
 716 
 717   case vmIntrinsics::_montgomeryMultiply:
 718     return inline_montgomeryMultiply();
 719   case vmIntrinsics::_montgomerySquare:


 761     }
 762 #endif
 763     return false;
 764   }
 765 }
 766 
 767 Node* LibraryCallKit::try_to_predicate(int predicate) {
 768   if (!jvms()->has_method()) {
 769     // Root JVMState has a null method.
 770     assert(map()->memory()->Opcode() == Op_Parm, "");
 771     // Insert the memory aliasing node
 772     set_all_memory(reset_memory());
 773   }
 774   assert(merged_memory(), "");
 775 
 776   switch (intrinsic_id()) {
 777   case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
 778     return inline_cipherBlockChaining_AESCrypt_predicate(false);
 779   case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
 780     return inline_cipherBlockChaining_AESCrypt_predicate(true);
 781   case vmIntrinsics::_counterMode_AESCrypt:
 782     return inline_counterMode_AESCrypt_predicate();
 783   case vmIntrinsics::_digestBase_implCompressMB:
 784     return inline_digestBase_implCompressMB_predicate(predicate);
 785 
 786   default:
 787     // If you get here, it may be that someone has added a new intrinsic
 788     // to the list in vmSymbols.hpp without implementing it here.
 789 #ifndef PRODUCT
 790     if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {
 791       tty->print_cr("*** Warning: Unimplemented predicate for intrinsic %s(%d)",
 792                     vmIntrinsics::name_at(intrinsic_id()), intrinsic_id());
 793     }
 794 #endif
 795     Node* slow_ctl = control();
 796     set_control(top()); // No fast path instrinsic
 797     return slow_ctl;
 798   }
 799 }
 800 
 801 //------------------------------set_result-------------------------------
 802 // Helper function for finishing intrinsics.


6052 
6053     // Call the stub, passing src_start, dest_start, k_start, r_start, src_len and original_k_start
6054     cbcCrypt = make_runtime_call(RC_LEAF|RC_NO_FP,
6055                                  OptoRuntime::cipherBlockChaining_aescrypt_Type(),
6056                                  stubAddr, stubName, TypePtr::BOTTOM,
6057                                  src_start, dest_start, k_start, r_start, len, original_k_start);
6058   } else {
6059     // Call the stub, passing src_start, dest_start, k_start, r_start and src_len
6060     cbcCrypt = make_runtime_call(RC_LEAF|RC_NO_FP,
6061                                  OptoRuntime::cipherBlockChaining_aescrypt_Type(),
6062                                  stubAddr, stubName, TypePtr::BOTTOM,
6063                                  src_start, dest_start, k_start, r_start, len);
6064   }
6065 
6066   // return cipher length (int)
6067   Node* retvalue = _gvn.transform(new ProjNode(cbcCrypt, TypeFunc::Parms));
6068   set_result(retvalue);
6069   return true;
6070 }
6071 
6072 //------------------------------inline_counterMode_AESCrypt-----------------------
6073 bool LibraryCallKit::inline_counterMode_AESCrypt(vmIntrinsics::ID id) {
6074   assert(UseAES, "need AES instruction support");
6075   if (!UseCTRAESIntrinsics) return false;
6076   
6077   address stubAddr = NULL;
6078   const char *stubName = NULL; 
6079   if (id == vmIntrinsics::_counterMode_AESCrypt) {
6080     stubAddr = StubRoutines::counterMode_AESCrypt();
6081     stubName = "counterMode_AESCrypt";
6082   }
6083   if (stubAddr == NULL) return false;
6084     
6085   Node* counterMode_object = argument(0);
6086   Node* src = argument(1);
6087   Node* src_offset = argument(2);
6088   Node* len = argument(3);
6089   Node* dest = argument(4);
6090   Node* dest_offset = argument(5);
6091   
6092   // (1) src and dest are arrays.
6093   const Type* src_type = src->Value(&_gvn);
6094   const Type* dest_type = dest->Value(&_gvn);
6095   const TypeAryPtr* top_src = src_type->isa_aryptr();
6096   const TypeAryPtr* top_dest = dest_type->isa_aryptr();
6097   assert(top_src != NULL && top_src->klass() != NULL
6098           && top_dest != NULL && top_dest->klass() != NULL, "args are strange");
6099   
6100   // checks are the responsibility of the caller
6101   Node* src_start = src;
6102   Node* dest_start = dest;
6103   if (src_offset != NULL || dest_offset != NULL) {
6104     assert(src_offset != NULL && dest_offset != NULL, "");
6105     src_start = array_element_address(src, src_offset, T_BYTE);
6106     dest_start = array_element_address(dest, dest_offset, T_BYTE);
6107   }
6108   
6109   // if we are in this set of code, we "know" the embeddedCipher is an AESCrypt object
6110   // (because of the predicated logic executed earlier).
6111   // so we cast it here safely.
6112   // this requires a newer class file that has this array as littleEndian ints, otherwise we revert to java
6113   Node* embeddedCipherObj = load_field_from_object(counterMode_object, "embeddedCipher", "Lcom/sun/crypto/provider/SymmetricCipher;", /*is_exact*/ false);
6114   if (embeddedCipherObj == NULL) return false;
6115   // cast it to what we know it will be at runtime
6116   const TypeInstPtr* tinst = _gvn.type(counterMode_object)->isa_instptr();
6117   assert(tinst != NULL, "CTR obj is null");
6118   assert(tinst->klass()->is_loaded(), "CTR obj is not loaded");
6119   ciKlass* klass_AESCrypt = tinst->klass()->as_instance_klass()->find_klass(ciSymbol::make("com/sun/crypto/provider/AESCrypt"));
6120   assert(klass_AESCrypt->is_loaded(), "predicate checks that this class is loaded");
6121   ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass();
6122   const TypeKlassPtr* aklass = TypeKlassPtr::make(instklass_AESCrypt);
6123   const TypeOopPtr* xtype = aklass->as_instance_type();
6124   Node* aescrypt_object = new CheckCastPPNode(control(), embeddedCipherObj, xtype);
6125   aescrypt_object = _gvn.transform(aescrypt_object);
6126   // we need to get the start of the aescrypt_object's expanded key array
6127   Node* k_start = get_key_start_from_aescrypt_object(aescrypt_object);
6128   if (k_start == NULL) return false;
6129   // similarly, get the start address of the r vector
6130   Node* obj_counter = load_field_from_object(counterMode_object, "counter", "[B", /*is_exact*/ false);
6131   if (obj_counter == NULL) return false;  
6132   Node* cnt_start = array_element_address(obj_counter, intcon(0), T_BYTE);
6133   
6134   Node* ctrCrypt;
6135   if (Matcher::pass_original_key_for_aes()) {
6136     // no SPARC version for AES/CTR intrinsics now.
6137     return false;
6138   } 
6139   // Call the stub, passing src_start, dest_start, k_start, r_start and src_len
6140   ctrCrypt = make_runtime_call(RC_LEAF|RC_NO_FP,
6141                                OptoRuntime::counterMode_aescrypt_Type(),
6142                                stubAddr, stubName, TypePtr::BOTTOM,
6143                                src_start, dest_start, k_start, cnt_start, len);
6144     
6145   // return cipher length (int)
6146   Node* retvalue = _gvn.transform(new ProjNode(ctrCrypt, TypeFunc::Parms));
6147   set_result(retvalue);
6148   return true;
6149 }
6150 
6151 //------------------------------get_key_start_from_aescrypt_object-----------------------
6152 Node * LibraryCallKit::get_key_start_from_aescrypt_object(Node *aescrypt_object) {
6153   Node* objAESCryptKey = load_field_from_object(aescrypt_object, "K", "[I", /*is_exact*/ false);
6154   assert (objAESCryptKey != NULL, "wrong version of com.sun.crypto.provider.AESCrypt");
6155   if (objAESCryptKey == NULL) return (Node *) NULL;
6156 
6157   // now have the array, need to get the start address of the K array
6158   Node* k_start = array_element_address(objAESCryptKey, intcon(0), T_INT);
6159   return k_start;
6160 }
6161 
6162 //------------------------------get_original_key_start_from_aescrypt_object-----------------------
6163 Node * LibraryCallKit::get_original_key_start_from_aescrypt_object(Node *aescrypt_object) {
6164   Node* objAESCryptKey = load_field_from_object(aescrypt_object, "lastKey", "[B", /*is_exact*/ false);
6165   assert (objAESCryptKey != NULL, "wrong version of com.sun.crypto.provider.AESCrypt");
6166   if (objAESCryptKey == NULL) return (Node *) NULL;
6167 
6168   // now have the array, need to get the start address of the lastKey array
6169   Node* original_k_start = array_element_address(objAESCryptKey, intcon(0), T_BYTE);
6170   return original_k_start;


6210   Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN);
6211 
6212   // for encryption, we are done
6213   if (!decrypting)
6214     return instof_false;  // even if it is NULL
6215 
6216   // for decryption, we need to add a further check to avoid
6217   // taking the intrinsic path when cipher and plain are the same
6218   // see the original java code for why.
6219   RegionNode* region = new RegionNode(3);
6220   region->init_req(1, instof_false);
6221   Node* src = argument(1);
6222   Node* dest = argument(4);
6223   Node* cmp_src_dest = _gvn.transform(new CmpPNode(src, dest));
6224   Node* bool_src_dest = _gvn.transform(new BoolNode(cmp_src_dest, BoolTest::eq));
6225   Node* src_dest_conjoint = generate_guard(bool_src_dest, NULL, PROB_MIN);
6226   region->init_req(2, src_dest_conjoint);
6227 
6228   record_for_igvn(region);
6229   return _gvn.transform(region);
6230 }
6231 
6232 //----------------------------inline_counterMode_AESCrypt_predicate----------------------------
6233 // Return node representing slow path of predicate check.
6234 // the pseudo code we want to emulate with this predicate is:
6235 // for encryption:
6236 //    if (embeddedCipherObj instanceof AESCrypt) do_intrinsic, else do_javapath
6237 // for decryption:
6238 //    if ((embeddedCipherObj instanceof AESCrypt) && (cipher!=plain)) do_intrinsic, else do_javapath
6239 //    note cipher==plain is more conservative than the original java code but that's OK
6240 //
6241 
6242 Node* LibraryCallKit::inline_counterMode_AESCrypt_predicate() {
6243   // The receiver was checked for NULL already.
6244   Node* objCTR = argument(0);
6245   
6246   // Load embeddedCipher field of CipherBlockChaining object.
6247   Node* embeddedCipherObj = load_field_from_object(objCTR, "embeddedCipher", "Lcom/sun/crypto/provider/SymmetricCipher;", /*is_exact*/ false);
6248   
6249   // get AESCrypt klass for instanceOf check
6250   // AESCrypt might not be loaded yet if some other SymmetricCipher got us to this compile point
6251   // will have same classloader as CipherBlockChaining object
6252   const TypeInstPtr* tinst = _gvn.type(objCTR)->isa_instptr();
6253   assert(tinst != NULL, "CTRobj is null");
6254   assert(tinst->klass()->is_loaded(), "CTRobj is not loaded");
6255   
6256   // we want to do an instanceof comparison against the AESCrypt class
6257   ciKlass* klass_AESCrypt = tinst->klass()->as_instance_klass()->find_klass(ciSymbol::make("com/sun/crypto/provider/AESCrypt"));
6258   if (!klass_AESCrypt->is_loaded()) {
6259     // if AESCrypt is not even loaded, we never take the intrinsic fast path
6260     Node* ctrl = control();
6261     set_control(top()); // no regular fast path
6262     return ctrl;
6263   }
6264   
6265   ciInstanceKlass* instklass_AESCrypt = klass_AESCrypt->as_instance_klass();
6266   Node* instof = gen_instanceof(embeddedCipherObj, makecon(TypeKlassPtr::make(instklass_AESCrypt)));
6267   Node* cmp_instof = _gvn.transform(new CmpINode(instof, intcon(1)));
6268   Node* bool_instof = _gvn.transform(new BoolNode(cmp_instof, BoolTest::ne));
6269   Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN);
6270 
6271   return instof_false; // even if it is NULL
6272 }
6273 
6274 //------------------------------inline_ghash_processBlocks
6275 bool LibraryCallKit::inline_ghash_processBlocks() {
6276   address stubAddr;
6277   const char *stubName;
6278   assert(UseGHASHIntrinsics, "need GHASH intrinsics support");
6279 
6280   stubAddr = StubRoutines::ghash_processBlocks();
6281   stubName = "ghash_processBlocks";
6282 
6283   Node* data           = argument(0);
6284   Node* offset         = argument(1);
6285   Node* len            = argument(2);
6286   Node* state          = argument(3);
6287   Node* subkeyH        = argument(4);
6288 
6289   Node* state_start  = array_element_address(state, intcon(0), T_LONG);
6290   assert(state_start, "state is NULL");
6291   Node* subkeyH_start  = array_element_address(subkeyH, intcon(0), T_LONG);


< prev index next >