Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/library_call.cpp @ 23885:51c505229e71
8081778: Use Intel x64 CPU instructions for RSA acceleration
Summary: Add intrinsics for BigInteger squareToLen and mulAdd methods.
Reviewed-by: kvn, jrose
author | igerasim |
---|---|
date | Wed, 17 Feb 2016 13:40:12 +0300 |
parents | bf41eee321e5 |
children | 626f594dffa6 5601e440e5e7 |
comparison
equal
deleted
inserted
replaced
23884:0d5597f44603 | 23885:51c505229e71 |
---|---|
322 bool inline_encodeISOArray(); | 322 bool inline_encodeISOArray(); |
323 bool inline_updateCRC32(); | 323 bool inline_updateCRC32(); |
324 bool inline_updateBytesCRC32(); | 324 bool inline_updateBytesCRC32(); |
325 bool inline_updateByteBufferCRC32(); | 325 bool inline_updateByteBufferCRC32(); |
326 bool inline_multiplyToLen(); | 326 bool inline_multiplyToLen(); |
327 bool inline_squareToLen(); | |
328 bool inline_mulAdd(); | |
327 | 329 |
328 bool inline_profileBoolean(); | 330 bool inline_profileBoolean(); |
329 }; | 331 }; |
330 | 332 |
331 | 333 |
525 | 527 |
526 case vmIntrinsics::_multiplyToLen: | 528 case vmIntrinsics::_multiplyToLen: |
527 if (!UseMultiplyToLenIntrinsic) return NULL; | 529 if (!UseMultiplyToLenIntrinsic) return NULL; |
528 break; | 530 break; |
529 | 531 |
532 case vmIntrinsics::_squareToLen: | |
533 if (!UseSquareToLenIntrinsic) return NULL; | |
534 break; | |
535 | |
536 case vmIntrinsics::_mulAdd: | |
537 if (!UseMulAddIntrinsic) return NULL; | |
538 break; | |
539 | |
530 case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt: | 540 case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt: |
531 case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: | 541 case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: |
532 if (!UseAESIntrinsics) return NULL; | 542 if (!UseAESIntrinsics) return NULL; |
533 // these two require the predicated logic | 543 // these two require the predicated logic |
534 predicates = 1; | 544 predicates = 1; |
924 case vmIntrinsics::_digestBase_implCompressMB: | 934 case vmIntrinsics::_digestBase_implCompressMB: |
925 return inline_digestBase_implCompressMB(predicate); | 935 return inline_digestBase_implCompressMB(predicate); |
926 | 936 |
927 case vmIntrinsics::_multiplyToLen: | 937 case vmIntrinsics::_multiplyToLen: |
928 return inline_multiplyToLen(); | 938 return inline_multiplyToLen(); |
939 | |
940 case vmIntrinsics::_squareToLen: | |
941 return inline_squareToLen(); | |
942 | |
943 case vmIntrinsics::_mulAdd: | |
944 return inline_mulAdd(); | |
929 | 945 |
930 case vmIntrinsics::_encodeISOArray: | 946 case vmIntrinsics::_encodeISOArray: |
931 return inline_encodeISOArray(); | 947 return inline_encodeISOArray(); |
932 | 948 |
933 case vmIntrinsics::_updateCRC32: | 949 case vmIntrinsics::_updateCRC32: |
5854 C->set_has_split_ifs(true); // Has chance for split-if optimization | 5870 C->set_has_split_ifs(true); // Has chance for split-if optimization |
5855 set_result(z); | 5871 set_result(z); |
5856 return true; | 5872 return true; |
5857 } | 5873 } |
5858 | 5874 |
5875 //-------------inline_squareToLen------------------------------------ | |
5876 bool LibraryCallKit::inline_squareToLen() { | |
5877 assert(UseSquareToLenIntrinsic, "not implementated on this platform"); | |
5878 | |
5879 address stubAddr = StubRoutines::squareToLen(); | |
5880 if (stubAddr == NULL) { | |
5881 return false; // Intrinsic's stub is not implemented on this platform | |
5882 } | |
5883 const char* stubName = "squareToLen"; | |
5884 | |
5885 assert(callee()->signature()->size() == 4, "implSquareToLen has 4 parameters"); | |
5886 | |
5887 Node* x = argument(0); | |
5888 Node* len = argument(1); | |
5889 Node* z = argument(2); | |
5890 Node* zlen = argument(3); | |
5891 | |
5892 const Type* x_type = x->Value(&_gvn); | |
5893 const Type* z_type = z->Value(&_gvn); | |
5894 const TypeAryPtr* top_x = x_type->isa_aryptr(); | |
5895 const TypeAryPtr* top_z = z_type->isa_aryptr(); | |
5896 if (top_x == NULL || top_x->klass() == NULL || | |
5897 top_z == NULL || top_z->klass() == NULL) { | |
5898 // failed array check | |
5899 return false; | |
5900 } | |
5901 | |
5902 BasicType x_elem = x_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); | |
5903 BasicType z_elem = z_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); | |
5904 if (x_elem != T_INT || z_elem != T_INT) { | |
5905 return false; | |
5906 } | |
5907 | |
5908 | |
5909 Node* x_start = array_element_address(x, intcon(0), x_elem); | |
5910 Node* z_start = array_element_address(z, intcon(0), z_elem); | |
5911 | |
5912 Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, | |
5913 OptoRuntime::squareToLen_Type(), | |
5914 stubAddr, stubName, TypePtr::BOTTOM, | |
5915 x_start, len, z_start, zlen); | |
5916 | |
5917 set_result(z); | |
5918 return true; | |
5919 } | |
5920 | |
5921 //-------------inline_mulAdd------------------------------------------ | |
5922 bool LibraryCallKit::inline_mulAdd() { | |
5923 assert(UseMulAddIntrinsic, "not implementated on this platform"); | |
5924 | |
5925 address stubAddr = StubRoutines::mulAdd(); | |
5926 if (stubAddr == NULL) { | |
5927 return false; // Intrinsic's stub is not implemented on this platform | |
5928 } | |
5929 const char* stubName = "mulAdd"; | |
5930 | |
5931 assert(callee()->signature()->size() == 5, "mulAdd has 5 parameters"); | |
5932 | |
5933 Node* out = argument(0); | |
5934 Node* in = argument(1); | |
5935 Node* offset = argument(2); | |
5936 Node* len = argument(3); | |
5937 Node* k = argument(4); | |
5938 | |
5939 const Type* out_type = out->Value(&_gvn); | |
5940 const Type* in_type = in->Value(&_gvn); | |
5941 const TypeAryPtr* top_out = out_type->isa_aryptr(); | |
5942 const TypeAryPtr* top_in = in_type->isa_aryptr(); | |
5943 if (top_out == NULL || top_out->klass() == NULL || | |
5944 top_in == NULL || top_in->klass() == NULL) { | |
5945 // failed array check | |
5946 return false; | |
5947 } | |
5948 | |
5949 BasicType out_elem = out_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); | |
5950 BasicType in_elem = in_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); | |
5951 if (out_elem != T_INT || in_elem != T_INT) { | |
5952 return false; | |
5953 } | |
5954 | |
5955 Node* outlen = load_array_length(out); | |
5956 Node* new_offset = _gvn.transform(new (C) SubINode(outlen, offset)); | |
5957 Node* out_start = array_element_address(out, intcon(0), out_elem); | |
5958 Node* in_start = array_element_address(in, intcon(0), in_elem); | |
5959 | |
5960 Node* call = make_runtime_call(RC_LEAF|RC_NO_FP, | |
5961 OptoRuntime::mulAdd_Type(), | |
5962 stubAddr, stubName, TypePtr::BOTTOM, | |
5963 out_start,in_start, new_offset, len, k); | |
5964 Node* result = _gvn.transform(new (C) ProjNode(call, TypeFunc::Parms)); | |
5965 set_result(result); | |
5966 return true; | |
5967 } | |
5968 | |
5859 | 5969 |
5860 /** | 5970 /** |
5861 * Calculate CRC32 for byte. | 5971 * Calculate CRC32 for byte. |
5862 * int java.util.zip.CRC32.update(int crc, int b) | 5972 * int java.util.zip.CRC32.update(int crc, int b) |
5863 */ | 5973 */ |