3051 __ BIND(L_exit); 3052 __ movdqu(xmm_counter_shuf_mask, ExternalAddress(StubRoutines::x86::counter_shuffle_mask_addr())); 3053 __ pshufb(xmm_curr_counter, xmm_counter_shuf_mask); //counter is shuffled back. 3054 __ movdqu(Address(counter, 0), xmm_curr_counter); //save counter back 3055 handleSOERegisters(false /*restoring*/); 3056 __ movptr(rax, len_param); // return length 3057 __ leave(); // required for proper stackwalking of RuntimeStub frame 3058 __ ret(0); 3059 3060 __ BIND (L_key192_top); 3061 __ movptr(pos, 0); // init pos before L_multiBlock_loopTop 3062 __ jmp(L_multiBlock_loopTop[1]); //key192 3063 3064 __ BIND (L_key256_top); 3065 __ movptr(pos, 0); // init pos before L_multiBlock_loopTop 3066 __ jmp(L_multiBlock_loopTop[2]); //key192 3067 3068 return start; 3069 } 3070 3071 3072 // byte swap x86 long 3073 address generate_ghash_long_swap_mask() { 3074 __ align(CodeEntryAlignment); 3075 StubCodeMark mark(this, "StubRoutines", "ghash_long_swap_mask"); 3076 address start = __ pc(); 3077 __ emit_data(0x0b0a0908, relocInfo::none, 0); 3078 __ emit_data(0x0f0e0d0c, relocInfo::none, 0); 3079 __ emit_data(0x03020100, relocInfo::none, 0); 3080 __ emit_data(0x07060504, relocInfo::none, 0); 3081 3082 return start; 3083 } 3084 3085 // byte swap x86 byte array 3086 address generate_ghash_byte_swap_mask() { 3087 __ align(CodeEntryAlignment); 3088 StubCodeMark mark(this, "StubRoutines", "ghash_byte_swap_mask"); 3089 address start = __ pc(); 3090 __ emit_data(0x0c0d0e0f, relocInfo::none, 0); 3753 StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop(); 3754 3755 // arraycopy stubs used by compilers 3756 generate_arraycopy_stubs(); 3757 3758 generate_math_stubs(); 3759 3760 // don't bother generating these AES intrinsic stubs unless global flag is set 3761 if (UseAESIntrinsics) { 3762 StubRoutines::x86::_key_shuffle_mask_addr = generate_key_shuffle_mask(); // might be needed by the others 3763 3764 StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock(); 3765 StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock(); 3766 StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt(); 3767 StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt(); 3768 } 3769 3770 if (UseAESCTRIntrinsics) { 3771 StubRoutines::x86::_counter_shuffle_mask_addr = generate_counter_shuffle_mask(); 3772 StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel(); 3773 } 3774 3775 // Generate GHASH intrinsics code 3776 if (UseGHASHIntrinsics) { 3777 StubRoutines::x86::_ghash_long_swap_mask_addr = generate_ghash_long_swap_mask(); 3778 StubRoutines::x86::_ghash_byte_swap_mask_addr = generate_ghash_byte_swap_mask(); 3779 StubRoutines::_ghash_processBlocks = generate_ghash_processBlocks(); 3780 } 3781 3782 // Safefetch stubs. 3783 generate_safefetch("SafeFetch32", sizeof(int), &StubRoutines::_safefetch32_entry, 3784 &StubRoutines::_safefetch32_fault_pc, 3785 &StubRoutines::_safefetch32_continuation_pc); 3786 StubRoutines::_safefetchN_entry = StubRoutines::_safefetch32_entry; 3787 StubRoutines::_safefetchN_fault_pc = StubRoutines::_safefetch32_fault_pc; 3788 StubRoutines::_safefetchN_continuation_pc = StubRoutines::_safefetch32_continuation_pc; 3789 } 3790 3791 3792 public: | 3051 __ BIND(L_exit); 3052 __ movdqu(xmm_counter_shuf_mask, ExternalAddress(StubRoutines::x86::counter_shuffle_mask_addr())); 3053 __ pshufb(xmm_curr_counter, xmm_counter_shuf_mask); //counter is shuffled back. 3054 __ movdqu(Address(counter, 0), xmm_curr_counter); //save counter back 3055 handleSOERegisters(false /*restoring*/); 3056 __ movptr(rax, len_param); // return length 3057 __ leave(); // required for proper stackwalking of RuntimeStub frame 3058 __ ret(0); 3059 3060 __ BIND (L_key192_top); 3061 __ movptr(pos, 0); // init pos before L_multiBlock_loopTop 3062 __ jmp(L_multiBlock_loopTop[1]); //key192 3063 3064 __ BIND (L_key256_top); 3065 __ movptr(pos, 0); // init pos before L_multiBlock_loopTop 3066 __ jmp(L_multiBlock_loopTop[2]); //key192 3067 3068 return start; 3069 } 3070 3071 address generate_upper_word_mask() { 3072 __ align(64); 3073 StubCodeMark mark(this, "StubRoutines", "upper_word_mask"); 3074 address start = __ pc(); 3075 __ emit_data(0x00000000, relocInfo::none, 0); 3076 __ emit_data(0x00000000, relocInfo::none, 0); 3077 __ emit_data(0x00000000, relocInfo::none, 0); 3078 __ emit_data(0xFFFFFFFF, relocInfo::none, 0); 3079 return start; 3080 } 3081 3082 address generate_shuffle_byte_flip_mask() { 3083 __ align(64); 3084 StubCodeMark mark(this, "StubRoutines", "shuffle_byte_flip_mask"); 3085 address start = __ pc(); 3086 __ emit_data(0x0c0d0e0f, relocInfo::none, 0); 3087 __ emit_data(0x08090a0b, relocInfo::none, 0); 3088 __ emit_data(0x04050607, relocInfo::none, 0); 3089 __ emit_data(0x00010203, relocInfo::none, 0); 3090 return start; 3091 } 3092 3093 // ofs and limit are use for multi-block byte array. 3094 // int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit) 3095 address generate_sha1_implCompress(bool multi_block, const char *name) { 3096 __ align(CodeEntryAlignment); 3097 StubCodeMark mark(this, "StubRoutines", name); 3098 address start = __ pc(); 3099 3100 Register buf = rax; 3101 Register state = rdx; 3102 Register ofs = rcx; 3103 Register limit = rdi; 3104 3105 const Address buf_param(rbp, 8 + 0); 3106 const Address state_param(rbp, 8 + 4); 3107 const Address ofs_param(rbp, 8 + 8); 3108 const Address limit_param(rbp, 8 + 12); 3109 3110 const XMMRegister abcd = xmm0; 3111 const XMMRegister e0 = xmm1; 3112 const XMMRegister e1 = xmm2; 3113 const XMMRegister msg0 = xmm3; 3114 3115 const XMMRegister msg1 = xmm4; 3116 const XMMRegister msg2 = xmm5; 3117 const XMMRegister msg3 = xmm6; 3118 const XMMRegister shuf_mask = xmm7; 3119 3120 __ enter(); 3121 __ subptr(rsp, 8 * wordSize); 3122 if (multi_block) { 3123 __ push(limit); 3124 } 3125 __ movptr(buf, buf_param); 3126 __ movptr(state, state_param); 3127 if (multi_block) { 3128 __ movptr(ofs, ofs_param); 3129 __ movptr(limit, limit_param); 3130 } 3131 3132 __ fast_sha1(abcd, e0, e1, msg0, msg1, msg2, msg3, shuf_mask, 3133 buf, state, ofs, limit, rsp, multi_block); 3134 3135 if (multi_block) { 3136 __ pop(limit); 3137 } 3138 __ addptr(rsp, 8 * wordSize); 3139 __ leave(); 3140 __ ret(0); 3141 return start; 3142 } 3143 3144 address generate_pshuffle_byte_flip_mask() { 3145 __ align(64); 3146 StubCodeMark mark(this, "StubRoutines", "pshuffle_byte_flip_mask"); 3147 address start = __ pc(); 3148 __ emit_data(0x00010203, relocInfo::none, 0); 3149 __ emit_data(0x04050607, relocInfo::none, 0); 3150 __ emit_data(0x08090a0b, relocInfo::none, 0); 3151 __ emit_data(0x0c0d0e0f, relocInfo::none, 0); 3152 return start; 3153 } 3154 3155 // ofs and limit are use for multi-block byte array. 3156 // int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit) 3157 address generate_sha256_implCompress(bool multi_block, const char *name) { 3158 __ align(CodeEntryAlignment); 3159 StubCodeMark mark(this, "StubRoutines", name); 3160 address start = __ pc(); 3161 3162 Register buf = rbx; 3163 Register state = rsi; 3164 Register ofs = rdx; 3165 Register limit = rcx; 3166 3167 const Address buf_param(rbp, 8 + 0); 3168 const Address state_param(rbp, 8 + 4); 3169 const Address ofs_param(rbp, 8 + 8); 3170 const Address limit_param(rbp, 8 + 12); 3171 3172 const XMMRegister msg = xmm0; 3173 const XMMRegister state0 = xmm1; 3174 const XMMRegister state1 = xmm2; 3175 const XMMRegister msgtmp0 = xmm3; 3176 3177 const XMMRegister msgtmp1 = xmm4; 3178 const XMMRegister msgtmp2 = xmm5; 3179 const XMMRegister msgtmp3 = xmm6; 3180 const XMMRegister msgtmp4 = xmm7; 3181 3182 __ enter(); 3183 __ subptr(rsp, 8 * wordSize); 3184 handleSOERegisters(true /*saving*/); 3185 __ movptr(buf, buf_param); 3186 __ movptr(state, state_param); 3187 if (multi_block) { 3188 __ movptr(ofs, ofs_param); 3189 __ movptr(limit, limit_param); 3190 } 3191 3192 __ fast_sha256(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4, 3193 buf, state, ofs, limit, rsp, multi_block); 3194 3195 handleSOERegisters(false); 3196 __ addptr(rsp, 8 * wordSize); 3197 __ leave(); 3198 __ ret(0); 3199 return start; 3200 } 3201 3202 // byte swap x86 long 3203 address generate_ghash_long_swap_mask() { 3204 __ align(CodeEntryAlignment); 3205 StubCodeMark mark(this, "StubRoutines", "ghash_long_swap_mask"); 3206 address start = __ pc(); 3207 __ emit_data(0x0b0a0908, relocInfo::none, 0); 3208 __ emit_data(0x0f0e0d0c, relocInfo::none, 0); 3209 __ emit_data(0x03020100, relocInfo::none, 0); 3210 __ emit_data(0x07060504, relocInfo::none, 0); 3211 3212 return start; 3213 } 3214 3215 // byte swap x86 byte array 3216 address generate_ghash_byte_swap_mask() { 3217 __ align(CodeEntryAlignment); 3218 StubCodeMark mark(this, "StubRoutines", "ghash_byte_swap_mask"); 3219 address start = __ pc(); 3220 __ emit_data(0x0c0d0e0f, relocInfo::none, 0); 3883 StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop(); 3884 3885 // arraycopy stubs used by compilers 3886 generate_arraycopy_stubs(); 3887 3888 generate_math_stubs(); 3889 3890 // don't bother generating these AES intrinsic stubs unless global flag is set 3891 if (UseAESIntrinsics) { 3892 StubRoutines::x86::_key_shuffle_mask_addr = generate_key_shuffle_mask(); // might be needed by the others 3893 3894 StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock(); 3895 StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock(); 3896 StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt(); 3897 StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt(); 3898 } 3899 3900 if (UseAESCTRIntrinsics) { 3901 StubRoutines::x86::_counter_shuffle_mask_addr = generate_counter_shuffle_mask(); 3902 StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel(); 3903 } 3904 3905 if (UseSHA1Intrinsics) { 3906 StubRoutines::x86::_upper_word_mask_addr = generate_upper_word_mask(); 3907 StubRoutines::x86::_shuffle_byte_flip_mask_addr = generate_shuffle_byte_flip_mask(); 3908 StubRoutines::_sha1_implCompress = generate_sha1_implCompress(false, "sha1_implCompress"); 3909 StubRoutines::_sha1_implCompressMB = generate_sha1_implCompress(true, "sha1_implCompressMB"); 3910 } 3911 if (UseSHA256Intrinsics) { 3912 StubRoutines::x86::_k256_adr = (address)StubRoutines::x86::_k256; 3913 StubRoutines::x86::_pshuffle_byte_flip_mask_addr = generate_pshuffle_byte_flip_mask(); 3914 StubRoutines::_sha256_implCompress = generate_sha256_implCompress(false, "sha256_implCompress"); 3915 StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB"); 3916 } 3917 3918 // Generate GHASH intrinsics code 3919 if (UseGHASHIntrinsics) { 3920 StubRoutines::x86::_ghash_long_swap_mask_addr = generate_ghash_long_swap_mask(); 3921 StubRoutines::x86::_ghash_byte_swap_mask_addr = generate_ghash_byte_swap_mask(); 3922 StubRoutines::_ghash_processBlocks = generate_ghash_processBlocks(); 3923 } 3924 3925 // Safefetch stubs. 3926 generate_safefetch("SafeFetch32", sizeof(int), &StubRoutines::_safefetch32_entry, 3927 &StubRoutines::_safefetch32_fault_pc, 3928 &StubRoutines::_safefetch32_continuation_pc); 3929 StubRoutines::_safefetchN_entry = StubRoutines::_safefetch32_entry; 3930 StubRoutines::_safefetchN_fault_pc = StubRoutines::_safefetch32_fault_pc; 3931 StubRoutines::_safefetchN_continuation_pc = StubRoutines::_safefetch32_continuation_pc; 3932 } 3933 3934 3935 public: |