< prev index next >

src/hotspot/cpu/x86/stubGenerator_x86_32.cpp

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "gc/shared/barrierSet.hpp"
  29 #include "gc/shared/barrierSetAssembler.hpp"
  30 #include "interpreter/interpreter.hpp"
  31 #include "memory/universe.hpp"
  32 #include "nativeInst_x86.hpp"
  33 #include "oops/instanceOop.hpp"
  34 #include "oops/method.hpp"
  35 #include "oops/objArrayKlass.hpp"
  36 #include "oops/oop.inline.hpp"
  37 #include "prims/methodHandles.hpp"
  38 #include "runtime/frame.inline.hpp"
  39 #include "runtime/handles.inline.hpp"
  40 #include "runtime/sharedRuntime.hpp"
  41 #include "runtime/stubCodeGenerator.hpp"
  42 #include "runtime/stubRoutines.hpp"
  43 #include "runtime/thread.inline.hpp"
  44 #ifdef COMPILER2
  45 #include "opto/runtime.hpp"
  46 #endif
  47 
  48 // Declaration and definition of StubGenerator (no .hpp file).
  49 // For a more detailed description of the stub routine structure
  50 // see the comment in stubRoutines.hpp
  51 


 586     // Call the C code to massage the double.  Result in EAX
 587     if (t == T_INT)
 588       { BLOCK_COMMENT("SharedRuntime::d2i"); }
 589     else if (t == T_LONG)
 590       { BLOCK_COMMENT("SharedRuntime::d2l"); }
 591     __ call_VM_leaf( fcn, 2 );
 592 
 593     // Restore CPU & FPU state
 594     __ pop_FPU_state();
 595     __ pop(rbp);
 596     __ pop(rdi);
 597     __ pop(rsi);
 598     __ pop(rcx);
 599     __ pop(rbx);
 600     __ addptr(rsp, wordSize * 2);
 601 
 602     __ ret(0);
 603 
 604     return start;
 605   }
 606   //---------------------------------------------------------------------------------------------------
 607 
 608   address generate_vector_mask(const char *stub_name, int32_t mask) {
 609     __ align(CodeEntryAlignment);
 610     StubCodeMark mark(this, "StubRoutines", stub_name);
 611     address start = __ pc();
 612 
 613     for (int i = 0; i < 16; i++) {
 614       __ emit_data(mask, relocInfo::none, 0);
 615     }
 616 
 617     return start;
 618   }
 619 
 620   address generate_vector_mask_long_double(const char *stub_name, int32_t maskhi, int32_t masklo) {
 621     __ align(CodeEntryAlignment);
 622     StubCodeMark mark(this, "StubRoutines", stub_name);
 623     address start = __ pc();
 624 
 625     for (int i = 0; i < 8; i++) {
 626       __ emit_data(masklo, relocInfo::none, 0);
 627       __ emit_data(maskhi, relocInfo::none, 0);
 628     }
 629 
 630     return start;
 631   }
 632 
 633   //----------------------------------------------------------------------------------------------------
 634 
 635   address generate_vector_byte_perm_mask(const char *stub_name) {
 636     __ align(CodeEntryAlignment);
 637     StubCodeMark mark(this, "StubRoutines", stub_name);
 638     address start = __ pc();
 639 
 640     __ emit_data(0x00000001, relocInfo::none, 0);
 641     __ emit_data(0x00000000, relocInfo::none, 0);
 642     __ emit_data(0x00000003, relocInfo::none, 0);
 643     __ emit_data(0x00000000, relocInfo::none, 0);
 644     __ emit_data(0x00000005, relocInfo::none, 0);
 645     __ emit_data(0x00000000, relocInfo::none, 0);
 646     __ emit_data(0x00000007, relocInfo::none, 0);
 647     __ emit_data(0x00000000, relocInfo::none, 0);
 648     __ emit_data(0x00000000, relocInfo::none, 0);
 649     __ emit_data(0x00000000, relocInfo::none, 0);
 650     __ emit_data(0x00000002, relocInfo::none, 0);
 651     __ emit_data(0x00000000, relocInfo::none, 0);
 652     __ emit_data(0x00000004, relocInfo::none, 0);
 653     __ emit_data(0x00000000, relocInfo::none, 0);
 654     __ emit_data(0x00000006, relocInfo::none, 0);
 655     __ emit_data(0x00000000, relocInfo::none, 0);
 656 
 657     return start;
 658   }
 659 
 660   //----------------------------------------------------------------------------------------------------
 661   // Non-destructive plausibility checks for oops
 662 
 663   address generate_verify_oop() {
 664     StubCodeMark mark(this, "StubRoutines", "verify_oop");
 665     address start = __ pc();
 666 
 667     // Incoming arguments on stack after saving rax,:
 668     //
 669     // [tos    ]: saved rdx
 670     // [tos + 1]: saved EFLAGS
 671     // [tos + 2]: return address
 672     // [tos + 3]: char* error message
 673     // [tos + 4]: oop   object to verify
 674     // [tos + 5]: saved rax, - saved by caller and bashed
 675 
 676     Label exit, error;
 677     __ pushf();
 678     __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr()));


3004     Register ofs   = rcx;
3005     Register limit = rdi;
3006 
3007     const Address  buf_param(rbp, 8 + 0);
3008     const Address  state_param(rbp, 8 + 4);
3009     const Address  ofs_param(rbp, 8 + 8);
3010     const Address  limit_param(rbp, 8 + 12);
3011 
3012     const XMMRegister abcd = xmm0;
3013     const XMMRegister e0 = xmm1;
3014     const XMMRegister e1 = xmm2;
3015     const XMMRegister msg0 = xmm3;
3016 
3017     const XMMRegister msg1 = xmm4;
3018     const XMMRegister msg2 = xmm5;
3019     const XMMRegister msg3 = xmm6;
3020     const XMMRegister shuf_mask = xmm7;
3021 
3022     __ enter();
3023     __ subptr(rsp, 8 * wordSize);
3024     handleSOERegisters(true /*saving*/);
3025 

3026     __ movptr(buf, buf_param);
3027     __ movptr(state, state_param);
3028     if (multi_block) {
3029       __ movptr(ofs, ofs_param);
3030       __ movptr(limit, limit_param);
3031     }
3032 
3033     __ fast_sha1(abcd, e0, e1, msg0, msg1, msg2, msg3, shuf_mask,
3034       buf, state, ofs, limit, rsp, multi_block);
3035 
3036     handleSOERegisters(false /*restoring*/);


3037     __ addptr(rsp, 8 * wordSize);
3038     __ leave();
3039     __ ret(0);
3040     return start;
3041   }
3042 
3043   address generate_pshuffle_byte_flip_mask() {
3044     __ align(64);
3045     StubCodeMark mark(this, "StubRoutines", "pshuffle_byte_flip_mask");
3046     address start = __ pc();
3047     __ emit_data(0x00010203, relocInfo::none, 0);
3048     __ emit_data(0x04050607, relocInfo::none, 0);
3049     __ emit_data(0x08090a0b, relocInfo::none, 0);
3050     __ emit_data(0x0c0d0e0f, relocInfo::none, 0);
3051     return start;
3052   }
3053 
3054   // ofs and limit are use for multi-block byte array.
3055   // int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
3056  address generate_sha256_implCompress(bool multi_block, const char *name) {


3858         StubRoutines::_dcos = generate_libmCos();
3859       }
3860       if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dtan)) {
3861         StubRoutines::_dlibm_tan_cot_huge = generate_libm_tan_cot_huge();
3862         StubRoutines::_dtan = generate_libmTan();
3863       }
3864     }
3865   }
3866 
3867   void generate_all() {
3868     // Generates all stubs and initializes the entry points
3869 
3870     // These entry points require SharedInfo::stack0 to be set up in non-core builds
3871     // and need to be relocatable, so they each fabricate a RuntimeStub internally.
3872     StubRoutines::_throw_AbstractMethodError_entry         = generate_throw_exception("AbstractMethodError throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError));
3873     StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError));
3874     StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call));
3875 
3876     //------------------------------------------------------------------------------------------------------------------------
3877     // entry points that are platform specific
3878 
3879     StubRoutines::x86::_vector_float_sign_mask = generate_vector_mask("vector_float_sign_mask", 0x7FFFFFFF);
3880     StubRoutines::x86::_vector_float_sign_flip = generate_vector_mask("vector_float_sign_flip", 0x80000000);
3881     StubRoutines::x86::_vector_double_sign_mask = generate_vector_mask_long_double("vector_double_sign_mask", 0x7FFFFFFF, 0xFFFFFFFF);
3882     StubRoutines::x86::_vector_double_sign_flip = generate_vector_mask_long_double("vector_double_sign_flip", 0x80000000, 0x00000000);
3883     StubRoutines::x86::_vector_short_to_byte_mask = generate_vector_mask("vector_short_to_byte_mask", 0x00ff00ff);
3884     StubRoutines::x86::_vector_byte_perm_mask = generate_vector_byte_perm_mask("vector_byte_perm_mask");
3885     StubRoutines::x86::_vector_long_sign_mask = generate_vector_mask_long_double("vector_long_sign_mask", 0x80000000, 0x00000000);
3886 
3887     // support for verify_oop (must happen after universe_init)
3888     StubRoutines::_verify_oop_subroutine_entry     = generate_verify_oop();
3889 
3890     // arraycopy stubs used by compilers
3891     generate_arraycopy_stubs();
3892 
3893     // don't bother generating these AES intrinsic stubs unless global flag is set
3894     if (UseAESIntrinsics) {
3895       StubRoutines::x86::_key_shuffle_mask_addr = generate_key_shuffle_mask();  // might be needed by the others
3896 
3897       StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock();
3898       StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock();
3899       StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt();
3900       StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt_Parallel();
3901     }
3902 
3903     if (UseAESCTRIntrinsics) {
3904       StubRoutines::x86::_counter_shuffle_mask_addr = generate_counter_shuffle_mask();
3905       StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel();




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "asm/macroAssembler.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "gc/shared/barrierSet.hpp"
  29 #include "gc/shared/barrierSetAssembler.hpp"
  30 #include "interpreter/interpreter.hpp"

  31 #include "nativeInst_x86.hpp"
  32 #include "oops/instanceOop.hpp"
  33 #include "oops/method.hpp"
  34 #include "oops/objArrayKlass.hpp"
  35 #include "oops/oop.inline.hpp"
  36 #include "prims/methodHandles.hpp"
  37 #include "runtime/frame.inline.hpp"
  38 #include "runtime/handles.inline.hpp"
  39 #include "runtime/sharedRuntime.hpp"
  40 #include "runtime/stubCodeGenerator.hpp"
  41 #include "runtime/stubRoutines.hpp"
  42 #include "runtime/thread.inline.hpp"
  43 #ifdef COMPILER2
  44 #include "opto/runtime.hpp"
  45 #endif
  46 
  47 // Declaration and definition of StubGenerator (no .hpp file).
  48 // For a more detailed description of the stub routine structure
  49 // see the comment in stubRoutines.hpp
  50 


 585     // Call the C code to massage the double.  Result in EAX
 586     if (t == T_INT)
 587       { BLOCK_COMMENT("SharedRuntime::d2i"); }
 588     else if (t == T_LONG)
 589       { BLOCK_COMMENT("SharedRuntime::d2l"); }
 590     __ call_VM_leaf( fcn, 2 );
 591 
 592     // Restore CPU & FPU state
 593     __ pop_FPU_state();
 594     __ pop(rbp);
 595     __ pop(rdi);
 596     __ pop(rsi);
 597     __ pop(rcx);
 598     __ pop(rbx);
 599     __ addptr(rsp, wordSize * 2);
 600 
 601     __ ret(0);
 602 
 603     return start;
 604   }

 605 



















































 606 
 607   //----------------------------------------------------------------------------------------------------
 608   // Non-destructive plausibility checks for oops
 609 
 610   address generate_verify_oop() {
 611     StubCodeMark mark(this, "StubRoutines", "verify_oop");
 612     address start = __ pc();
 613 
 614     // Incoming arguments on stack after saving rax,:
 615     //
 616     // [tos    ]: saved rdx
 617     // [tos + 1]: saved EFLAGS
 618     // [tos + 2]: return address
 619     // [tos + 3]: char* error message
 620     // [tos + 4]: oop   object to verify
 621     // [tos + 5]: saved rax, - saved by caller and bashed
 622 
 623     Label exit, error;
 624     __ pushf();
 625     __ incrementl(ExternalAddress((address) StubRoutines::verify_oop_count_addr()));


2951     Register ofs   = rcx;
2952     Register limit = rdi;
2953 
2954     const Address  buf_param(rbp, 8 + 0);
2955     const Address  state_param(rbp, 8 + 4);
2956     const Address  ofs_param(rbp, 8 + 8);
2957     const Address  limit_param(rbp, 8 + 12);
2958 
2959     const XMMRegister abcd = xmm0;
2960     const XMMRegister e0 = xmm1;
2961     const XMMRegister e1 = xmm2;
2962     const XMMRegister msg0 = xmm3;
2963 
2964     const XMMRegister msg1 = xmm4;
2965     const XMMRegister msg2 = xmm5;
2966     const XMMRegister msg3 = xmm6;
2967     const XMMRegister shuf_mask = xmm7;
2968 
2969     __ enter();
2970     __ subptr(rsp, 8 * wordSize);
2971     if (multi_block) {
2972       __ push(limit);
2973     }
2974     __ movptr(buf, buf_param);
2975     __ movptr(state, state_param);
2976     if (multi_block) {
2977       __ movptr(ofs, ofs_param);
2978       __ movptr(limit, limit_param);
2979     }
2980 
2981     __ fast_sha1(abcd, e0, e1, msg0, msg1, msg2, msg3, shuf_mask,
2982       buf, state, ofs, limit, rsp, multi_block);
2983 
2984     if (multi_block) {
2985       __ pop(limit);
2986     }
2987     __ addptr(rsp, 8 * wordSize);
2988     __ leave();
2989     __ ret(0);
2990     return start;
2991   }
2992 
2993   address generate_pshuffle_byte_flip_mask() {
2994     __ align(64);
2995     StubCodeMark mark(this, "StubRoutines", "pshuffle_byte_flip_mask");
2996     address start = __ pc();
2997     __ emit_data(0x00010203, relocInfo::none, 0);
2998     __ emit_data(0x04050607, relocInfo::none, 0);
2999     __ emit_data(0x08090a0b, relocInfo::none, 0);
3000     __ emit_data(0x0c0d0e0f, relocInfo::none, 0);
3001     return start;
3002   }
3003 
3004   // ofs and limit are use for multi-block byte array.
3005   // int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit)
3006  address generate_sha256_implCompress(bool multi_block, const char *name) {


3808         StubRoutines::_dcos = generate_libmCos();
3809       }
3810       if (vmIntrinsics::is_intrinsic_available(vmIntrinsics::_dtan)) {
3811         StubRoutines::_dlibm_tan_cot_huge = generate_libm_tan_cot_huge();
3812         StubRoutines::_dtan = generate_libmTan();
3813       }
3814     }
3815   }
3816 
3817   void generate_all() {
3818     // Generates all stubs and initializes the entry points
3819 
3820     // These entry points require SharedInfo::stack0 to be set up in non-core builds
3821     // and need to be relocatable, so they each fabricate a RuntimeStub internally.
3822     StubRoutines::_throw_AbstractMethodError_entry         = generate_throw_exception("AbstractMethodError throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError));
3823     StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError));
3824     StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call));
3825 
3826     //------------------------------------------------------------------------------------------------------------------------
3827     // entry points that are platform specific








3828 
3829     // support for verify_oop (must happen after universe_init)
3830     StubRoutines::_verify_oop_subroutine_entry     = generate_verify_oop();
3831 
3832     // arraycopy stubs used by compilers
3833     generate_arraycopy_stubs();
3834 
3835     // don't bother generating these AES intrinsic stubs unless global flag is set
3836     if (UseAESIntrinsics) {
3837       StubRoutines::x86::_key_shuffle_mask_addr = generate_key_shuffle_mask();  // might be needed by the others
3838 
3839       StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock();
3840       StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock();
3841       StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt();
3842       StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt_Parallel();
3843     }
3844 
3845     if (UseAESCTRIntrinsics) {
3846       StubRoutines::x86::_counter_shuffle_mask_addr = generate_counter_shuffle_mask();
3847       StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel();


< prev index next >