src/share/vm/opto/library_call.cpp

changeset 7152
166d744df0de
parent 7134
d8847542f83a
child 7155
4874332f9799
equal deleted inserted replaced
7151:bddcb33dadf4 7152:166d744df0de
320 Node* inline_digestBase_implCompressMB_predicate(int predicate); 320 Node* inline_digestBase_implCompressMB_predicate(int predicate);
321 bool inline_encodeISOArray(); 321 bool inline_encodeISOArray();
322 bool inline_updateCRC32(); 322 bool inline_updateCRC32();
323 bool inline_updateBytesCRC32(); 323 bool inline_updateBytesCRC32();
324 bool inline_updateByteBufferCRC32(); 324 bool inline_updateByteBufferCRC32();
325 bool inline_multiplyToLen();
325 }; 326 };
326 327
327 328
328 //---------------------------make_vm_intrinsic---------------------------- 329 //---------------------------make_vm_intrinsic----------------------------
329 CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) { 330 CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) {
330 vmIntrinsics::ID id = m->intrinsic_id(); 331 vmIntrinsics::ID id = m->intrinsic_id();
331 assert(id != vmIntrinsics::_none, "must be a VM intrinsic"); 332 assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
332 333
333 if (DisableIntrinsic[0] != '\0' 334 ccstr disable_intr = NULL;
334 && strstr(DisableIntrinsic, vmIntrinsics::name_at(id)) != NULL) { 335
336 if ((DisableIntrinsic[0] != '\0'
337 && strstr(DisableIntrinsic, vmIntrinsics::name_at(id)) != NULL) ||
338 (method_has_option_value("DisableIntrinsic", disable_intr)
339 && strstr(disable_intr, vmIntrinsics::name_at(id)) != NULL)) {
335 // disabled by a user request on the command line: 340 // disabled by a user request on the command line:
336 // example: -XX:DisableIntrinsic=_hashCode,_getClass 341 // example: -XX:DisableIntrinsic=_hashCode,_getClass
337 return NULL; 342 return NULL;
338 } 343 }
339 344
513 case vmIntrinsics::_aescrypt_encryptBlock: 518 case vmIntrinsics::_aescrypt_encryptBlock:
514 case vmIntrinsics::_aescrypt_decryptBlock: 519 case vmIntrinsics::_aescrypt_decryptBlock:
515 if (!UseAESIntrinsics) return NULL; 520 if (!UseAESIntrinsics) return NULL;
516 break; 521 break;
517 522
523 case vmIntrinsics::_multiplyToLen:
524 if (!UseMultiplyToLenIntrinsic) return NULL;
525 break;
526
518 case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt: 527 case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
519 case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: 528 case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
520 if (!UseAESIntrinsics) return NULL; 529 if (!UseAESIntrinsics) return NULL;
521 // these two require the predicated logic 530 // these two require the predicated logic
522 predicates = 1; 531 predicates = 1;
909 case vmIntrinsics::_sha5_implCompress: 918 case vmIntrinsics::_sha5_implCompress:
910 return inline_sha_implCompress(intrinsic_id()); 919 return inline_sha_implCompress(intrinsic_id());
911 920
912 case vmIntrinsics::_digestBase_implCompressMB: 921 case vmIntrinsics::_digestBase_implCompressMB:
913 return inline_digestBase_implCompressMB(predicate); 922 return inline_digestBase_implCompressMB(predicate);
923
924 case vmIntrinsics::_multiplyToLen:
925 return inline_multiplyToLen();
914 926
915 case vmIntrinsics::_encodeISOArray: 927 case vmIntrinsics::_encodeISOArray:
916 return inline_encodeISOArray(); 928 return inline_encodeISOArray();
917 929
918 case vmIntrinsics::_updateCRC32: 930 case vmIntrinsics::_updateCRC32:
5733 set_memory(res_mem, mtype); 5745 set_memory(res_mem, mtype);
5734 set_result(enc); 5746 set_result(enc);
5735 return true; 5747 return true;
5736 } 5748 }
5737 5749
5750 //-------------inline_multiplyToLen-----------------------------------
5751 bool LibraryCallKit::inline_multiplyToLen() {
5752 assert(UseMultiplyToLenIntrinsic, "not implementated on this platform");
5753
5754 address stubAddr = StubRoutines::multiplyToLen();
5755 if (stubAddr == NULL) {
5756 return false; // Intrinsic's stub is not implemented on this platform
5757 }
5758 const char* stubName = "multiplyToLen";
5759
5760 assert(callee()->signature()->size() == 5, "multiplyToLen has 5 parameters");
5761
5762 Node* x = argument(1);
5763 Node* xlen = argument(2);
5764 Node* y = argument(3);
5765 Node* ylen = argument(4);
5766 Node* z = argument(5);
5767
5768 const Type* x_type = x->Value(&_gvn);
5769 const Type* y_type = y->Value(&_gvn);
5770 const TypeAryPtr* top_x = x_type->isa_aryptr();
5771 const TypeAryPtr* top_y = y_type->isa_aryptr();
5772 if (top_x == NULL || top_x->klass() == NULL ||
5773 top_y == NULL || top_y->klass() == NULL) {
5774 // failed array check
5775 return false;
5776 }
5777
5778 BasicType x_elem = x_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
5779 BasicType y_elem = y_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
5780 if (x_elem != T_INT || y_elem != T_INT) {
5781 return false;
5782 }
5783
5784 // Set the original stack and the reexecute bit for the interpreter to reexecute
5785 // the bytecode that invokes BigInteger.multiplyToLen() if deoptimization happens
5786 // on the return from z array allocation in runtime.
5787 { PreserveReexecuteState preexecs(this);
5788 jvms()->set_should_reexecute(true);
5789
5790 Node* x_start = array_element_address(x, intcon(0), x_elem);
5791 Node* y_start = array_element_address(y, intcon(0), y_elem);
5792 // 'x_start' points to x array + scaled xlen
5793 // 'y_start' points to y array + scaled ylen
5794
5795 // Allocate the result array
5796 Node* zlen = _gvn.transform(new(C) AddINode(xlen, ylen));
5797 Node* klass_node = makecon(TypeKlassPtr::make(ciTypeArrayKlass::make(T_INT)));
5798
5799 IdealKit ideal(this);
5800
5801 #define __ ideal.
5802 Node* one = __ ConI(1);
5803 Node* zero = __ ConI(0);
5804 IdealVariable need_alloc(ideal), z_alloc(ideal); __ declarations_done();
5805 __ set(need_alloc, zero);
5806 __ set(z_alloc, z);
5807 __ if_then(z, BoolTest::eq, null()); {
5808 __ increment (need_alloc, one);
5809 } __ else_(); {
5810 // Update graphKit memory and control from IdealKit.
5811 sync_kit(ideal);
5812 Node* zlen_arg = load_array_length(z);
5813 // Update IdealKit memory and control from graphKit.
5814 __ sync_kit(this);
5815 __ if_then(zlen_arg, BoolTest::lt, zlen); {
5816 __ increment (need_alloc, one);
5817 } __ end_if();
5818 } __ end_if();
5819
5820 __ if_then(__ value(need_alloc), BoolTest::ne, zero); {
5821 // Update graphKit memory and control from IdealKit.
5822 sync_kit(ideal);
5823 Node * narr = new_array(klass_node, zlen, 1);
5824 // Update IdealKit memory and control from graphKit.
5825 __ sync_kit(this);
5826 __ set(z_alloc, narr);
5827 } __ end_if();
5828
5829 sync_kit(ideal);
5830 z = __ value(z_alloc);
5831 _gvn.set_type(z, TypeAryPtr::INTS);
5832 // Final sync IdealKit and GraphKit.
5833 final_sync(ideal);
5834 #undef __
5835
5836 Node* z_start = array_element_address(z, intcon(0), T_INT);
5837
5838 Node* call = make_runtime_call(RC_LEAF|RC_NO_FP,
5839 OptoRuntime::multiplyToLen_Type(),
5840 stubAddr, stubName, TypePtr::BOTTOM,
5841 x_start, xlen, y_start, ylen, z_start, zlen);
5842 } // original reexecute is set back here
5843
5844 C->set_has_split_ifs(true); // Has chance for split-if optimization
5845 set_result(z);
5846 return true;
5847 }
5848
5849
5738 /** 5850 /**
5739 * Calculate CRC32 for byte. 5851 * Calculate CRC32 for byte.
5740 * int java.util.zip.CRC32.update(int crc, int b) 5852 * int java.util.zip.CRC32.update(int crc, int b)
5741 */ 5853 */
5742 bool LibraryCallKit::inline_updateCRC32() { 5854 bool LibraryCallKit::inline_updateCRC32() {

mercurial