< prev index next >

src/share/vm/opto/library_call.cpp

Print this page




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


 281   bool inline_sha_implCompress(vmIntrinsics::ID id);
 282   bool inline_digestBase_implCompressMB(int predicate);
 283   bool inline_sha_implCompressMB(Node* digestBaseObj, ciInstanceKlass* instklass_SHA,
 284                                  bool long_state, address stubAddr, const char *stubName,
 285                                  Node* src_start, Node* ofs, Node* limit);
 286   Node* get_state_from_sha_object(Node *sha_object);
 287   Node* get_state_from_sha5_object(Node *sha_object);
 288   Node* inline_digestBase_implCompressMB_predicate(int predicate);
 289   bool inline_encodeISOArray();
 290   bool inline_updateCRC32();
 291   bool inline_updateBytesCRC32();
 292   bool inline_updateByteBufferCRC32();
 293   bool inline_multiplyToLen();
 294   bool inline_squareToLen();
 295   bool inline_mulAdd();
 296 
 297   bool inline_profileBoolean();
 298   bool inline_isCompileConstant();
 299 };
 300 


 511     predicates = 1;
 512     break;
 513 
 514   case vmIntrinsics::_sha_implCompress:
 515     if (!UseSHA1Intrinsics) return NULL;
 516     break;
 517 
 518   case vmIntrinsics::_sha2_implCompress:
 519     if (!UseSHA256Intrinsics) return NULL;
 520     break;
 521 
 522   case vmIntrinsics::_sha5_implCompress:
 523     if (!UseSHA512Intrinsics) return NULL;
 524     break;
 525 
 526   case vmIntrinsics::_digestBase_implCompressMB:
 527     if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) return NULL;
 528     predicates = 3;
 529     break;
 530 




 531   case vmIntrinsics::_updateCRC32:
 532   case vmIntrinsics::_updateBytesCRC32:
 533   case vmIntrinsics::_updateByteBufferCRC32:
 534     if (!UseCRC32Intrinsics) return NULL;
 535     break;
 536 
 537   case vmIntrinsics::_incrementExactI:
 538   case vmIntrinsics::_addExactI:
 539     if (!Matcher::match_rule_supported(Op_OverflowAddI) || !UseMathExactIntrinsics) return NULL;
 540     break;
 541   case vmIntrinsics::_incrementExactL:
 542   case vmIntrinsics::_addExactL:
 543     if (!Matcher::match_rule_supported(Op_OverflowAddL) || !UseMathExactIntrinsics) return NULL;
 544     break;
 545   case vmIntrinsics::_decrementExactI:
 546   case vmIntrinsics::_subtractExactI:
 547     if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL;
 548     break;
 549   case vmIntrinsics::_decrementExactL:
 550   case vmIntrinsics::_subtractExactL:


 912   case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
 913     return inline_cipherBlockChaining_AESCrypt(intrinsic_id());
 914 
 915   case vmIntrinsics::_sha_implCompress:
 916   case vmIntrinsics::_sha2_implCompress:
 917   case vmIntrinsics::_sha5_implCompress:
 918     return inline_sha_implCompress(intrinsic_id());
 919 
 920   case vmIntrinsics::_digestBase_implCompressMB:
 921     return inline_digestBase_implCompressMB(predicate);
 922 
 923   case vmIntrinsics::_multiplyToLen:
 924     return inline_multiplyToLen();
 925 
 926   case vmIntrinsics::_squareToLen:
 927     return inline_squareToLen();
 928 
 929   case vmIntrinsics::_mulAdd:
 930     return inline_mulAdd();
 931 



 932   case vmIntrinsics::_encodeISOArray:
 933     return inline_encodeISOArray();
 934 
 935   case vmIntrinsics::_updateCRC32:
 936     return inline_updateCRC32();
 937   case vmIntrinsics::_updateBytesCRC32:
 938     return inline_updateBytesCRC32();
 939   case vmIntrinsics::_updateByteBufferCRC32:
 940     return inline_updateByteBufferCRC32();
 941 
 942   case vmIntrinsics::_profileBoolean:
 943     return inline_profileBoolean();
 944   case vmIntrinsics::_isCompileConstant:
 945     return inline_isCompileConstant();
 946 
 947   default:
 948     // If you get here, it may be that someone has added a new intrinsic
 949     // to the list in vmSymbols.hpp without implementing it here.
 950 #ifndef PRODUCT
 951     if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {


5839   Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN);
5840 
5841   // for encryption, we are done
5842   if (!decrypting)
5843     return instof_false;  // even if it is NULL
5844 
5845   // for decryption, we need to add a further check to avoid
5846   // taking the intrinsic path when cipher and plain are the same
5847   // see the original java code for why.
5848   RegionNode* region = new RegionNode(3);
5849   region->init_req(1, instof_false);
5850   Node* src = argument(1);
5851   Node* dest = argument(4);
5852   Node* cmp_src_dest = _gvn.transform(new CmpPNode(src, dest));
5853   Node* bool_src_dest = _gvn.transform(new BoolNode(cmp_src_dest, BoolTest::eq));
5854   Node* src_dest_conjoint = generate_guard(bool_src_dest, NULL, PROB_MIN);
5855   region->init_req(2, src_dest_conjoint);
5856 
5857   record_for_igvn(region);
5858   return _gvn.transform(region);







































5859 }
5860 
5861 //------------------------------inline_sha_implCompress-----------------------
5862 //
5863 // Calculate SHA (i.e., SHA-1) for single-block byte[] array.
5864 // void com.sun.security.provider.SHA.implCompress(byte[] buf, int ofs)
5865 //
5866 // Calculate SHA2 (i.e., SHA-244 or SHA-256) for single-block byte[] array.
5867 // void com.sun.security.provider.SHA2.implCompress(byte[] buf, int ofs)
5868 //
5869 // Calculate SHA5 (i.e., SHA-384 or SHA-512) for single-block byte[] array.
5870 // void com.sun.security.provider.SHA5.implCompress(byte[] buf, int ofs)
5871 //
5872 bool LibraryCallKit::inline_sha_implCompress(vmIntrinsics::ID id) {
5873   assert(callee()->signature()->size() == 2, "sha_implCompress has 2 parameters");
5874 
5875   Node* sha_obj = argument(0);
5876   Node* src     = argument(1); // type oop
5877   Node* ofs     = argument(2); // type int
5878 




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


 513     predicates = 1;
 514     break;
 515 
 516   case vmIntrinsics::_sha_implCompress:
 517     if (!UseSHA1Intrinsics) return NULL;
 518     break;
 519 
 520   case vmIntrinsics::_sha2_implCompress:
 521     if (!UseSHA256Intrinsics) return NULL;
 522     break;
 523 
 524   case vmIntrinsics::_sha5_implCompress:
 525     if (!UseSHA512Intrinsics) return NULL;
 526     break;
 527 
 528   case vmIntrinsics::_digestBase_implCompressMB:
 529     if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) return NULL;
 530     predicates = 3;
 531     break;
 532 
 533   case vmIntrinsics::_ghash_processBlocks:
 534     if (!UseGHASHIntrinsics) return NULL;
 535     break;
 536 
 537   case vmIntrinsics::_updateCRC32:
 538   case vmIntrinsics::_updateBytesCRC32:
 539   case vmIntrinsics::_updateByteBufferCRC32:
 540     if (!UseCRC32Intrinsics) return NULL;
 541     break;
 542 
 543   case vmIntrinsics::_incrementExactI:
 544   case vmIntrinsics::_addExactI:
 545     if (!Matcher::match_rule_supported(Op_OverflowAddI) || !UseMathExactIntrinsics) return NULL;
 546     break;
 547   case vmIntrinsics::_incrementExactL:
 548   case vmIntrinsics::_addExactL:
 549     if (!Matcher::match_rule_supported(Op_OverflowAddL) || !UseMathExactIntrinsics) return NULL;
 550     break;
 551   case vmIntrinsics::_decrementExactI:
 552   case vmIntrinsics::_subtractExactI:
 553     if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL;
 554     break;
 555   case vmIntrinsics::_decrementExactL:
 556   case vmIntrinsics::_subtractExactL:


 918   case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
 919     return inline_cipherBlockChaining_AESCrypt(intrinsic_id());
 920 
 921   case vmIntrinsics::_sha_implCompress:
 922   case vmIntrinsics::_sha2_implCompress:
 923   case vmIntrinsics::_sha5_implCompress:
 924     return inline_sha_implCompress(intrinsic_id());
 925 
 926   case vmIntrinsics::_digestBase_implCompressMB:
 927     return inline_digestBase_implCompressMB(predicate);
 928 
 929   case vmIntrinsics::_multiplyToLen:
 930     return inline_multiplyToLen();
 931 
 932   case vmIntrinsics::_squareToLen:
 933     return inline_squareToLen();
 934 
 935   case vmIntrinsics::_mulAdd:
 936     return inline_mulAdd();
 937 
 938   case vmIntrinsics::_ghash_processBlocks:
 939     return inline_ghash_processBlocks();
 940 
 941   case vmIntrinsics::_encodeISOArray:
 942     return inline_encodeISOArray();
 943 
 944   case vmIntrinsics::_updateCRC32:
 945     return inline_updateCRC32();
 946   case vmIntrinsics::_updateBytesCRC32:
 947     return inline_updateBytesCRC32();
 948   case vmIntrinsics::_updateByteBufferCRC32:
 949     return inline_updateByteBufferCRC32();
 950 
 951   case vmIntrinsics::_profileBoolean:
 952     return inline_profileBoolean();
 953   case vmIntrinsics::_isCompileConstant:
 954     return inline_isCompileConstant();
 955 
 956   default:
 957     // If you get here, it may be that someone has added a new intrinsic
 958     // to the list in vmSymbols.hpp without implementing it here.
 959 #ifndef PRODUCT
 960     if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {


5848   Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN);
5849 
5850   // for encryption, we are done
5851   if (!decrypting)
5852     return instof_false;  // even if it is NULL
5853 
5854   // for decryption, we need to add a further check to avoid
5855   // taking the intrinsic path when cipher and plain are the same
5856   // see the original java code for why.
5857   RegionNode* region = new RegionNode(3);
5858   region->init_req(1, instof_false);
5859   Node* src = argument(1);
5860   Node* dest = argument(4);
5861   Node* cmp_src_dest = _gvn.transform(new CmpPNode(src, dest));
5862   Node* bool_src_dest = _gvn.transform(new BoolNode(cmp_src_dest, BoolTest::eq));
5863   Node* src_dest_conjoint = generate_guard(bool_src_dest, NULL, PROB_MIN);
5864   region->init_req(2, src_dest_conjoint);
5865 
5866   record_for_igvn(region);
5867   return _gvn.transform(region);
5868 }
5869 
5870 //------------------------------get_vars_from_ghash_object-----------------------
5871 Node * LibraryCallKit::get_vars_from_ghash_object(Node *ghash_object, const char *var_name) {
5872   Node* ghash_var = load_field_from_object(ghash_object, var_name, "[J", /*is_exact*/ false);
5873   assert (ghash_var != NULL, "wrong version of sun.security.provider.GHASH");
5874   if (ghash_var == NULL) return (Node *) NULL;
5875 
5876   // now have the array, need to get the start address of the array
5877   Node* var = array_element_address(ghash_var, intcon(0), T_LONG);
5878   return var;
5879 }
5880 
5881 //------------------------------inline_ghash_processBlocks
5882 bool LibraryCallKit::inline_ghash_processBlocks() {
5883   address stubAddr;
5884   const char *stubName;
5885   assert(UseGHASHIntrinsics, "need GHASH intrinsics support");
5886 
5887   stubAddr = StubRoutines::ghash_processBlocks();
5888   stubName = "ghash_processBlocks";
5889 
5890   Node* ghash_object   = argument(0);
5891   Node* data           = argument(1);
5892   Node* offset         = argument(2);
5893   Node* len            = argument(3);
5894 
5895   Node* state_start = get_vars_from_ghash_object(ghash_object, "state");
5896   assert(state_start, "Unable to load GHASH state");
5897   Node* subkeyH_start = get_vars_from_ghash_object(ghash_object, "subkeyH");
5898   assert(subkeyH_start, "Unable to load GHASH subkeyH");
5899   Node* data_start  = array_element_address(data, offset, T_BYTE);
5900   assert(data_start, "data is NULL");
5901 
5902   Node* ghash = make_runtime_call(RC_LEAF|RC_NO_FP,
5903                                   OptoRuntime::ghash_processBlocks_Type(),
5904                                   stubAddr, stubName, TypePtr::BOTTOM,
5905                                   state_start, subkeyH_start, data_start, len);
5906   return true;
5907 }
5908 
5909 //------------------------------inline_sha_implCompress-----------------------
5910 //
5911 // Calculate SHA (i.e., SHA-1) for single-block byte[] array.
5912 // void com.sun.security.provider.SHA.implCompress(byte[] buf, int ofs)
5913 //
5914 // Calculate SHA2 (i.e., SHA-244 or SHA-256) for single-block byte[] array.
5915 // void com.sun.security.provider.SHA2.implCompress(byte[] buf, int ofs)
5916 //
5917 // Calculate SHA5 (i.e., SHA-384 or SHA-512) for single-block byte[] array.
5918 // void com.sun.security.provider.SHA5.implCompress(byte[] buf, int ofs)
5919 //
5920 bool LibraryCallKit::inline_sha_implCompress(vmIntrinsics::ID id) {
5921   assert(callee()->signature()->size() == 2, "sha_implCompress has 2 parameters");
5922 
5923   Node* sha_obj = argument(0);
5924   Node* src     = argument(1); // type oop
5925   Node* ofs     = argument(2); // type int
5926 


< prev index next >