src/hotspot/share/opto/library_call.cpp

Print this page




 307   Node* get_state_from_sha_object(Node *sha_object);
 308   Node* get_state_from_sha5_object(Node *sha_object);
 309   Node* inline_digestBase_implCompressMB_predicate(int predicate);
 310   bool inline_encodeISOArray();
 311   bool inline_updateCRC32();
 312   bool inline_updateBytesCRC32();
 313   bool inline_updateByteBufferCRC32();
 314   Node* get_table_from_crc32c_class(ciInstanceKlass *crc32c_class);
 315   bool inline_updateBytesCRC32C();
 316   bool inline_updateDirectByteBufferCRC32C();
 317   bool inline_updateBytesAdler32();
 318   bool inline_updateByteBufferAdler32();
 319   bool inline_multiplyToLen();
 320   bool inline_hasNegatives();
 321   bool inline_squareToLen();
 322   bool inline_mulAdd();
 323   bool inline_montgomeryMultiply();
 324   bool inline_montgomerySquare();
 325   bool inline_vectorizedMismatch();
 326   bool inline_fma(vmIntrinsics::ID id);

 327 
 328   bool inline_profileBoolean();
 329   bool inline_isCompileConstant();
 330   void clear_upper_avx() {
 331 #ifdef X86
 332     if (UseAVX >= 2) {
 333       C->set_clear_upper_avx(true);
 334     }
 335 #endif
 336   }
 337 };
 338 
 339 //---------------------------make_vm_intrinsic----------------------------
 340 CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) {
 341   vmIntrinsics::ID id = m->intrinsic_id();
 342   assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
 343 
 344   if (!m->is_loaded()) {
 345     // Do not attempt to inline unloaded methods.
 346     return NULL;


 850   case vmIntrinsics::_updateDirectByteBufferCRC32C:
 851     return inline_updateDirectByteBufferCRC32C();
 852 
 853   case vmIntrinsics::_updateBytesAdler32:
 854     return inline_updateBytesAdler32();
 855   case vmIntrinsics::_updateByteBufferAdler32:
 856     return inline_updateByteBufferAdler32();
 857 
 858   case vmIntrinsics::_profileBoolean:
 859     return inline_profileBoolean();
 860   case vmIntrinsics::_isCompileConstant:
 861     return inline_isCompileConstant();
 862 
 863   case vmIntrinsics::_hasNegatives:
 864     return inline_hasNegatives();
 865 
 866   case vmIntrinsics::_fmaD:
 867   case vmIntrinsics::_fmaF:
 868     return inline_fma(intrinsic_id());
 869 






 870   default:
 871     // If you get here, it may be that someone has added a new intrinsic
 872     // to the list in vmSymbols.hpp without implementing it here.
 873 #ifndef PRODUCT
 874     if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {
 875       tty->print_cr("*** Warning: Unimplemented intrinsic %s(%d)",
 876                     vmIntrinsics::name_at(intrinsic_id()), intrinsic_id());
 877     }
 878 #endif
 879     return false;
 880   }
 881 }
 882 
 883 Node* LibraryCallKit::try_to_predicate(int predicate) {
 884   if (!jvms()->has_method()) {
 885     // Root JVMState has a null method.
 886     assert(map()->memory()->Opcode() == Op_Parm, "");
 887     // Insert the memory aliasing node
 888     set_all_memory(reset_memory());
 889   }


6535   switch (id) {
6536   case vmIntrinsics::_fmaD:
6537     assert(callee()->signature()->size() == 6, "fma has 3 parameters of size 2 each.");
6538     // no receiver since it is static method
6539     a = round_double_node(argument(0));
6540     b = round_double_node(argument(2));
6541     c = round_double_node(argument(4));
6542     result = _gvn.transform(new FmaDNode(control(), a, b, c));
6543     break;
6544   case vmIntrinsics::_fmaF:
6545     assert(callee()->signature()->size() == 3, "fma has 3 parameters of size 1 each.");
6546     a = argument(0);
6547     b = argument(1);
6548     c = argument(2);
6549     result = _gvn.transform(new FmaFNode(control(), a, b, c));
6550     break;
6551   default:
6552     fatal_unexpected_iid(id);  break;
6553   }
6554   set_result(result);




















































6555   return true;
6556 }
6557 
6558 bool LibraryCallKit::inline_profileBoolean() {
6559   Node* counts = argument(1);
6560   const TypeAryPtr* ary = NULL;
6561   ciArray* aobj = NULL;
6562   if (counts->is_Con()
6563       && (ary = counts->bottom_type()->isa_aryptr()) != NULL
6564       && (aobj = ary->const_oop()->as_array()) != NULL
6565       && (aobj->length() == 2)) {
6566     // Profile is int[2] where [0] and [1] correspond to false and true value occurrences respectively.
6567     jint false_cnt = aobj->element_value(0).as_int();
6568     jint  true_cnt = aobj->element_value(1).as_int();
6569 
6570     if (C->log() != NULL) {
6571       C->log()->elem("observe source='profileBoolean' false='%d' true='%d'",
6572                      false_cnt, true_cnt);
6573     }
6574 




 307   Node* get_state_from_sha_object(Node *sha_object);
 308   Node* get_state_from_sha5_object(Node *sha_object);
 309   Node* inline_digestBase_implCompressMB_predicate(int predicate);
 310   bool inline_encodeISOArray();
 311   bool inline_updateCRC32();
 312   bool inline_updateBytesCRC32();
 313   bool inline_updateByteBufferCRC32();
 314   Node* get_table_from_crc32c_class(ciInstanceKlass *crc32c_class);
 315   bool inline_updateBytesCRC32C();
 316   bool inline_updateDirectByteBufferCRC32C();
 317   bool inline_updateBytesAdler32();
 318   bool inline_updateByteBufferAdler32();
 319   bool inline_multiplyToLen();
 320   bool inline_hasNegatives();
 321   bool inline_squareToLen();
 322   bool inline_mulAdd();
 323   bool inline_montgomeryMultiply();
 324   bool inline_montgomerySquare();
 325   bool inline_vectorizedMismatch();
 326   bool inline_fma(vmIntrinsics::ID id);
 327   bool inline_character_compare(vmIntrinsics::ID id);
 328 
 329   bool inline_profileBoolean();
 330   bool inline_isCompileConstant();
 331   void clear_upper_avx() {
 332 #ifdef X86
 333     if (UseAVX >= 2) {
 334       C->set_clear_upper_avx(true);
 335     }
 336 #endif
 337   }
 338 };
 339 
 340 //---------------------------make_vm_intrinsic----------------------------
 341 CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) {
 342   vmIntrinsics::ID id = m->intrinsic_id();
 343   assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
 344 
 345   if (!m->is_loaded()) {
 346     // Do not attempt to inline unloaded methods.
 347     return NULL;


 851   case vmIntrinsics::_updateDirectByteBufferCRC32C:
 852     return inline_updateDirectByteBufferCRC32C();
 853 
 854   case vmIntrinsics::_updateBytesAdler32:
 855     return inline_updateBytesAdler32();
 856   case vmIntrinsics::_updateByteBufferAdler32:
 857     return inline_updateByteBufferAdler32();
 858 
 859   case vmIntrinsics::_profileBoolean:
 860     return inline_profileBoolean();
 861   case vmIntrinsics::_isCompileConstant:
 862     return inline_isCompileConstant();
 863 
 864   case vmIntrinsics::_hasNegatives:
 865     return inline_hasNegatives();
 866 
 867   case vmIntrinsics::_fmaD:
 868   case vmIntrinsics::_fmaF:
 869     return inline_fma(intrinsic_id());
 870 
 871   case vmIntrinsics::_isDigit_c:
 872   case vmIntrinsics::_isLowerCase_c:
 873   case vmIntrinsics::_isUpperCase_c:
 874   case vmIntrinsics::_isWhitespace_c:
 875     return inline_character_compare(intrinsic_id());
 876 
 877   default:
 878     // If you get here, it may be that someone has added a new intrinsic
 879     // to the list in vmSymbols.hpp without implementing it here.
 880 #ifndef PRODUCT
 881     if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {
 882       tty->print_cr("*** Warning: Unimplemented intrinsic %s(%d)",
 883                     vmIntrinsics::name_at(intrinsic_id()), intrinsic_id());
 884     }
 885 #endif
 886     return false;
 887   }
 888 }
 889 
 890 Node* LibraryCallKit::try_to_predicate(int predicate) {
 891   if (!jvms()->has_method()) {
 892     // Root JVMState has a null method.
 893     assert(map()->memory()->Opcode() == Op_Parm, "");
 894     // Insert the memory aliasing node
 895     set_all_memory(reset_memory());
 896   }


6542   switch (id) {
6543   case vmIntrinsics::_fmaD:
6544     assert(callee()->signature()->size() == 6, "fma has 3 parameters of size 2 each.");
6545     // no receiver since it is static method
6546     a = round_double_node(argument(0));
6547     b = round_double_node(argument(2));
6548     c = round_double_node(argument(4));
6549     result = _gvn.transform(new FmaDNode(control(), a, b, c));
6550     break;
6551   case vmIntrinsics::_fmaF:
6552     assert(callee()->signature()->size() == 3, "fma has 3 parameters of size 1 each.");
6553     a = argument(0);
6554     b = argument(1);
6555     c = argument(2);
6556     result = _gvn.transform(new FmaFNode(control(), a, b, c));
6557     break;
6558   default:
6559     fatal_unexpected_iid(id);  break;
6560   }
6561   set_result(result);
6562   return true;
6563 }
6564 
6565 bool LibraryCallKit::inline_character_compare(vmIntrinsics::ID id) {
6566   if (!control()->is_Region()) {
6567     return false;
6568   }
6569   RegionNode* r = control()->as_Region();
6570 
6571   // argument(0) is receiver
6572   Node* codePoint = argument(1);
6573   Node* n = NULL;
6574 
6575   switch (id) {
6576     case vmIntrinsics::_isDigit_c :
6577       if (!Matcher::match_rule_supported(Op_DigitC)) {
6578         return false;
6579       }
6580       n = new DigitCNode(0, codePoint);
6581       break;
6582     case vmIntrinsics::_isLowerCase_c :
6583       if (!Matcher::match_rule_supported(Op_LowerCaseC)) {
6584         return false;
6585       }
6586       n = new LowerCaseCNode(0,  codePoint);
6587       break;
6588     case vmIntrinsics::_isUpperCase_c :
6589       if (!Matcher::match_rule_supported(Op_UpperCaseC)) {
6590         return false;
6591       }
6592       n = new UpperCaseCNode(0, codePoint);
6593       break;
6594     case vmIntrinsics::_isWhitespace_c :
6595       if (!Matcher::match_rule_supported(Op_WhitespaceC)) {
6596         return false;
6597       }
6598       n = new WhitespaceCNode(0, codePoint);
6599       break;
6600     default:
6601       fatal_unexpected_iid(id);  
6602   }
6603 
6604   RegionNode *rgn = new RegionNode(2);
6605   PhiNode *phi = new PhiNode(rgn, TypeInt::CHAR);
6606 
6607   // Swap current RegionNode with new one
6608   Node* new_ctrl = r->in(1);
6609   r->del_req(1);
6610   rgn->init_req(1, new_ctrl);
6611   phi->init_req(1, _gvn.transform(n));
6612   set_result(rgn, phi);
6613 
6614   return true;
6615 }
6616 
6617 bool LibraryCallKit::inline_profileBoolean() {
6618   Node* counts = argument(1);
6619   const TypeAryPtr* ary = NULL;
6620   ciArray* aobj = NULL;
6621   if (counts->is_Con()
6622       && (ary = counts->bottom_type()->isa_aryptr()) != NULL
6623       && (aobj = ary->const_oop()->as_array()) != NULL
6624       && (aobj->length() == 2)) {
6625     // Profile is int[2] where [0] and [1] correspond to false and true value occurrences respectively.
6626     jint false_cnt = aobj->element_value(0).as_int();
6627     jint  true_cnt = aobj->element_value(1).as_int();
6628 
6629     if (C->log() != NULL) {
6630       C->log()->elem("observe source='profileBoolean' false='%d' true='%d'",
6631                      false_cnt, true_cnt);
6632     }
6633