Mercurial > hg > truffle
comparison src/share/vm/opto/library_call.cpp @ 7637:b30b3c2a0cf2
6896617: Optimize sun.nio.cs.ISO_8859_1$Encode.encodeArrayLoop() on x86
Summary: Use SSE4.2 and AVX2 instructions for encodeArray intrinsic.
Reviewed-by: roland
author | kvn |
---|---|
date | Tue, 22 Jan 2013 15:34:16 -0800 |
parents | 6d1f5516534e |
children | 8b3da8d14c93 |
comparison
equal
deleted
inserted
replaced
7636:a7114d3d712e | 7637:b30b3c2a0cf2 |
---|---|
288 bool inline_reference_get(); | 288 bool inline_reference_get(); |
289 bool inline_aescrypt_Block(vmIntrinsics::ID id); | 289 bool inline_aescrypt_Block(vmIntrinsics::ID id); |
290 bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id); | 290 bool inline_cipherBlockChaining_AESCrypt(vmIntrinsics::ID id); |
291 Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting); | 291 Node* inline_cipherBlockChaining_AESCrypt_predicate(bool decrypting); |
292 Node* get_key_start_from_aescrypt_object(Node* aescrypt_object); | 292 Node* get_key_start_from_aescrypt_object(Node* aescrypt_object); |
293 bool inline_encodeISOArray(); | |
293 }; | 294 }; |
294 | 295 |
295 | 296 |
296 //---------------------------make_vm_intrinsic---------------------------- | 297 //---------------------------make_vm_intrinsic---------------------------- |
297 CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) { | 298 CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) { |
379 case vmIntrinsics::_copyOfRange: | 380 case vmIntrinsics::_copyOfRange: |
380 if (!InlineObjectCopy) return NULL; | 381 if (!InlineObjectCopy) return NULL; |
381 // These also use the arraycopy intrinsic mechanism: | 382 // These also use the arraycopy intrinsic mechanism: |
382 if (!InlineArrayCopy) return NULL; | 383 if (!InlineArrayCopy) return NULL; |
383 break; | 384 break; |
385 case vmIntrinsics::_encodeISOArray: | |
386 if (!SpecialEncodeISOArray) return NULL; | |
387 if (!Matcher::match_rule_supported(Op_EncodeISOArray)) return NULL; | |
388 break; | |
384 case vmIntrinsics::_checkIndex: | 389 case vmIntrinsics::_checkIndex: |
385 // We do not intrinsify this. The optimizer does fine with it. | 390 // We do not intrinsify this. The optimizer does fine with it. |
386 return NULL; | 391 return NULL; |
387 | 392 |
388 case vmIntrinsics::_getCallerClass: | 393 case vmIntrinsics::_getCallerClass: |
796 case vmIntrinsics::_aescrypt_decryptBlock: return inline_aescrypt_Block(intrinsic_id()); | 801 case vmIntrinsics::_aescrypt_decryptBlock: return inline_aescrypt_Block(intrinsic_id()); |
797 | 802 |
798 case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt: | 803 case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt: |
799 case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: | 804 case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt: |
800 return inline_cipherBlockChaining_AESCrypt(intrinsic_id()); | 805 return inline_cipherBlockChaining_AESCrypt(intrinsic_id()); |
806 | |
807 case vmIntrinsics::_encodeISOArray: | |
808 return inline_encodeISOArray(); | |
801 | 809 |
802 default: | 810 default: |
803 // If you get here, it may be that someone has added a new intrinsic | 811 // If you get here, it may be that someone has added a new intrinsic |
804 // to the list in vmSymbols.hpp without implementing it here. | 812 // to the list in vmSymbols.hpp without implementing it here. |
805 #ifndef PRODUCT | 813 #ifndef PRODUCT |
5366 OptoRuntime::fast_arraycopy_Type(), | 5374 OptoRuntime::fast_arraycopy_Type(), |
5367 copyfunc_addr, copyfunc_name, adr_type, | 5375 copyfunc_addr, copyfunc_name, adr_type, |
5368 src_start, dest_start, copy_length XTOP); | 5376 src_start, dest_start, copy_length XTOP); |
5369 } | 5377 } |
5370 | 5378 |
5379 //-------------inline_encodeISOArray----------------------------------- | |
5380 // encode char[] to byte[] in ISO_8859_1 | |
5381 bool LibraryCallKit::inline_encodeISOArray() { | |
5382 assert(callee()->signature()->size() == 5, "encodeISOArray has 5 parameters"); | |
5383 // no receiver since it is static method | |
5384 Node *src = argument(0); | |
5385 Node *src_offset = argument(1); | |
5386 Node *dst = argument(2); | |
5387 Node *dst_offset = argument(3); | |
5388 Node *length = argument(4); | |
5389 | |
5390 const Type* src_type = src->Value(&_gvn); | |
5391 const Type* dst_type = dst->Value(&_gvn); | |
5392 const TypeAryPtr* top_src = src_type->isa_aryptr(); | |
5393 const TypeAryPtr* top_dest = dst_type->isa_aryptr(); | |
5394 if (top_src == NULL || top_src->klass() == NULL || | |
5395 top_dest == NULL || top_dest->klass() == NULL) { | |
5396 // failed array check | |
5397 return false; | |
5398 } | |
5399 | |
5400 // Figure out the size and type of the elements we will be copying. | |
5401 BasicType src_elem = src_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); | |
5402 BasicType dst_elem = dst_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type(); | |
5403 if (src_elem != T_CHAR || dst_elem != T_BYTE) { | |
5404 return false; | |
5405 } | |
5406 Node* src_start = array_element_address(src, src_offset, src_elem); | |
5407 Node* dst_start = array_element_address(dst, dst_offset, dst_elem); | |
5408 // 'src_start' points to src array + scaled offset | |
5409 // 'dst_start' points to dst array + scaled offset | |
5410 | |
5411 const TypeAryPtr* mtype = TypeAryPtr::BYTES; | |
5412 Node* enc = new (C) EncodeISOArrayNode(control(), memory(mtype), src_start, dst_start, length); | |
5413 enc = _gvn.transform(enc); | |
5414 Node* res_mem = _gvn.transform(new (C) SCMemProjNode(enc)); | |
5415 set_memory(res_mem, mtype); | |
5416 set_result(enc); | |
5417 return true; | |
5418 } | |
5419 | |
5371 //----------------------------inline_reference_get---------------------------- | 5420 //----------------------------inline_reference_get---------------------------- |
5372 // public T java.lang.ref.Reference.get(); | 5421 // public T java.lang.ref.Reference.get(); |
5373 bool LibraryCallKit::inline_reference_get() { | 5422 bool LibraryCallKit::inline_reference_get() { |
5374 const int referent_offset = java_lang_ref_Reference::referent_offset; | 5423 const int referent_offset = java_lang_ref_Reference::referent_offset; |
5375 guarantee(referent_offset > 0, "should have already been set"); | 5424 guarantee(referent_offset > 0, "should have already been set"); |