hotspot/src/share/vm/opto/library_call.cpp
changeset 31583 eb5bea7b4835
parent 31228 8e427370cdd1
child 31584 24e491478c2f
equal deleted inserted replaced
31228:8e427370cdd1 31583:eb5bea7b4835
   291   bool inline_updateBytesCRC32();
   291   bool inline_updateBytesCRC32();
   292   bool inline_updateByteBufferCRC32();
   292   bool inline_updateByteBufferCRC32();
   293   bool inline_multiplyToLen();
   293   bool inline_multiplyToLen();
   294   bool inline_squareToLen();
   294   bool inline_squareToLen();
   295   bool inline_mulAdd();
   295   bool inline_mulAdd();
       
   296   bool inline_montgomeryMultiply();
       
   297   bool inline_montgomerySquare();
   296 
   298 
   297   bool inline_profileBoolean();
   299   bool inline_profileBoolean();
   298   bool inline_isCompileConstant();
   300   bool inline_isCompileConstant();
   299 };
   301 };
   300 
   302 
   502 
   504 
   503   case vmIntrinsics::_mulAdd:
   505   case vmIntrinsics::_mulAdd:
   504     if (!UseMulAddIntrinsic) return NULL;
   506     if (!UseMulAddIntrinsic) return NULL;
   505     break;
   507     break;
   506 
   508 
       
   509   case vmIntrinsics::_montgomeryMultiply:
       
   510      if (!UseMontgomeryMultiplyIntrinsic) return NULL;
       
   511     break;
       
   512   case vmIntrinsics::_montgomerySquare:
       
   513      if (!UseMontgomerySquareIntrinsic) return NULL;
       
   514     break;
       
   515 
   507   case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
   516   case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
   508   case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
   517   case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
   509     if (!UseAESIntrinsics) return NULL;
   518     if (!UseAESIntrinsics) return NULL;
   510     // these two require the predicated logic
   519     // these two require the predicated logic
   511     predicates = 1;
   520     predicates = 1;
   926   case vmIntrinsics::_squareToLen:
   935   case vmIntrinsics::_squareToLen:
   927     return inline_squareToLen();
   936     return inline_squareToLen();
   928 
   937 
   929   case vmIntrinsics::_mulAdd:
   938   case vmIntrinsics::_mulAdd:
   930     return inline_mulAdd();
   939     return inline_mulAdd();
       
   940 
       
   941   case vmIntrinsics::_montgomeryMultiply:
       
   942     return inline_montgomeryMultiply();
       
   943   case vmIntrinsics::_montgomerySquare:
       
   944     return inline_montgomerySquare();
   931 
   945 
   932   case vmIntrinsics::_encodeISOArray:
   946   case vmIntrinsics::_encodeISOArray:
   933     return inline_encodeISOArray();
   947     return inline_encodeISOArray();
   934 
   948 
   935   case vmIntrinsics::_updateCRC32:
   949   case vmIntrinsics::_updateCRC32:
  5231   }
  5245   }
  5232   const char* stubName = "multiplyToLen";
  5246   const char* stubName = "multiplyToLen";
  5233 
  5247 
  5234   assert(callee()->signature()->size() == 5, "multiplyToLen has 5 parameters");
  5248   assert(callee()->signature()->size() == 5, "multiplyToLen has 5 parameters");
  5235 
  5249 
  5236   Node* x    = argument(1);
  5250   // no receiver because it is a static method
  5237   Node* xlen = argument(2);
  5251   Node* x    = argument(0);
  5238   Node* y    = argument(3);
  5252   Node* xlen = argument(1);
  5239   Node* ylen = argument(4);
  5253   Node* y    = argument(2);
  5240   Node* z    = argument(5);
  5254   Node* ylen = argument(3);
       
  5255   Node* z    = argument(4);
  5241 
  5256 
  5242   const Type* x_type = x->Value(&_gvn);
  5257   const Type* x_type = x->Value(&_gvn);
  5243   const Type* y_type = y->Value(&_gvn);
  5258   const Type* y_type = y->Value(&_gvn);
  5244   const TypeAryPtr* top_x = x_type->isa_aryptr();
  5259   const TypeAryPtr* top_x = x_type->isa_aryptr();
  5245   const TypeAryPtr* top_y = y_type->isa_aryptr();
  5260   const TypeAryPtr* top_y = y_type->isa_aryptr();
  5414   Node* result = _gvn.transform(new ProjNode(call, TypeFunc::Parms));
  5429   Node* result = _gvn.transform(new ProjNode(call, TypeFunc::Parms));
  5415   set_result(result);
  5430   set_result(result);
  5416   return true;
  5431   return true;
  5417 }
  5432 }
  5418 
  5433 
       
  5434 //-------------inline_montgomeryMultiply-----------------------------------
       
  5435 bool LibraryCallKit::inline_montgomeryMultiply() {
       
  5436   address stubAddr = StubRoutines::montgomeryMultiply();
       
  5437   if (stubAddr == NULL) {
       
  5438     return false; // Intrinsic's stub is not implemented on this platform
       
  5439   }
       
  5440 
       
  5441   assert(UseMontgomeryMultiplyIntrinsic, "not implemented on this platform");
       
  5442   const char* stubName = "montgomery_square";
       
  5443 
       
  5444   assert(callee()->signature()->size() == 7, "montgomeryMultiply has 7 parameters");
       
  5445 
       
  5446   Node* a    = argument(0);
       
  5447   Node* b    = argument(1);
       
  5448   Node* n    = argument(2);
       
  5449   Node* len  = argument(3);
       
  5450   Node* inv  = argument(4);
       
  5451   Node* m    = argument(6);
       
  5452 
       
  5453   const Type* a_type = a->Value(&_gvn);
       
  5454   const TypeAryPtr* top_a = a_type->isa_aryptr();
       
  5455   const Type* b_type = b->Value(&_gvn);
       
  5456   const TypeAryPtr* top_b = b_type->isa_aryptr();
       
  5457   const Type* n_type = a->Value(&_gvn);
       
  5458   const TypeAryPtr* top_n = n_type->isa_aryptr();
       
  5459   const Type* m_type = a->Value(&_gvn);
       
  5460   const TypeAryPtr* top_m = m_type->isa_aryptr();
       
  5461   if (top_a  == NULL || top_a->klass()  == NULL ||
       
  5462       top_b == NULL || top_b->klass()  == NULL ||
       
  5463       top_n == NULL || top_n->klass()  == NULL ||
       
  5464       top_m == NULL || top_m->klass()  == NULL) {
       
  5465     // failed array check
       
  5466     return false;
       
  5467   }
       
  5468 
       
  5469   BasicType a_elem = a_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
       
  5470   BasicType b_elem = b_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
       
  5471   BasicType n_elem = n_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
       
  5472   BasicType m_elem = m_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
       
  5473   if (a_elem != T_INT || b_elem != T_INT || n_elem != T_INT || m_elem != T_INT) {
       
  5474     return false;
       
  5475   }
       
  5476 
       
  5477   // Make the call
       
  5478   {
       
  5479     Node* a_start = array_element_address(a, intcon(0), a_elem);
       
  5480     Node* b_start = array_element_address(b, intcon(0), b_elem);
       
  5481     Node* n_start = array_element_address(n, intcon(0), n_elem);
       
  5482     Node* m_start = array_element_address(m, intcon(0), m_elem);
       
  5483 
       
  5484     Node* call = make_runtime_call(RC_LEAF,
       
  5485                                    OptoRuntime::montgomeryMultiply_Type(),
       
  5486                                    stubAddr, stubName, TypePtr::BOTTOM,
       
  5487                                    a_start, b_start, n_start, len, inv, top(),
       
  5488                                    m_start);
       
  5489     set_result(m);
       
  5490   }
       
  5491 
       
  5492   return true;
       
  5493 }
       
  5494 
       
  5495 bool LibraryCallKit::inline_montgomerySquare() {
       
  5496   address stubAddr = StubRoutines::montgomerySquare();
       
  5497   if (stubAddr == NULL) {
       
  5498     return false; // Intrinsic's stub is not implemented on this platform
       
  5499   }
       
  5500 
       
  5501   assert(UseMontgomerySquareIntrinsic, "not implemented on this platform");
       
  5502   const char* stubName = "montgomery_square";
       
  5503 
       
  5504   assert(callee()->signature()->size() == 6, "montgomerySquare has 6 parameters");
       
  5505 
       
  5506   Node* a    = argument(0);
       
  5507   Node* n    = argument(1);
       
  5508   Node* len  = argument(2);
       
  5509   Node* inv  = argument(3);
       
  5510   Node* m    = argument(5);
       
  5511 
       
  5512   const Type* a_type = a->Value(&_gvn);
       
  5513   const TypeAryPtr* top_a = a_type->isa_aryptr();
       
  5514   const Type* n_type = a->Value(&_gvn);
       
  5515   const TypeAryPtr* top_n = n_type->isa_aryptr();
       
  5516   const Type* m_type = a->Value(&_gvn);
       
  5517   const TypeAryPtr* top_m = m_type->isa_aryptr();
       
  5518   if (top_a  == NULL || top_a->klass()  == NULL ||
       
  5519       top_n == NULL || top_n->klass()  == NULL ||
       
  5520       top_m == NULL || top_m->klass()  == NULL) {
       
  5521     // failed array check
       
  5522     return false;
       
  5523   }
       
  5524 
       
  5525   BasicType a_elem = a_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
       
  5526   BasicType n_elem = n_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
       
  5527   BasicType m_elem = m_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
       
  5528   if (a_elem != T_INT || n_elem != T_INT || m_elem != T_INT) {
       
  5529     return false;
       
  5530   }
       
  5531 
       
  5532   // Make the call
       
  5533   {
       
  5534     Node* a_start = array_element_address(a, intcon(0), a_elem);
       
  5535     Node* n_start = array_element_address(n, intcon(0), n_elem);
       
  5536     Node* m_start = array_element_address(m, intcon(0), m_elem);
       
  5537 
       
  5538     Node* call = make_runtime_call(RC_LEAF,
       
  5539                                    OptoRuntime::montgomerySquare_Type(),
       
  5540                                    stubAddr, stubName, TypePtr::BOTTOM,
       
  5541                                    a_start, n_start, len, inv, top(),
       
  5542                                    m_start);
       
  5543     set_result(m);
       
  5544   }
       
  5545 
       
  5546   return true;
       
  5547 }
       
  5548 
  5419 
  5549 
  5420 /**
  5550 /**
  5421  * Calculate CRC32 for byte.
  5551  * Calculate CRC32 for byte.
  5422  * int java.util.zip.CRC32.update(int crc, int b)
  5552  * int java.util.zip.CRC32.update(int crc, int b)
  5423  */
  5553  */