hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp
changeset 36555 4f37fd7a5a09
parent 35540 e001ad24dcdb
child 36825 6ebe5519b753
equal deleted inserted replaced
36554:a7eb9ee4680c 36555:4f37fd7a5a09
  3066     __ jmp(L_multiBlock_loopTop[2]); //key192
  3066     __ jmp(L_multiBlock_loopTop[2]); //key192
  3067 
  3067 
  3068     return start;
  3068     return start;
  3069   }
  3069   }
  3070 
  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   }
  3071 
  3201 
  3072   // byte swap x86 long
  3202   // byte swap x86 long
  3073   address generate_ghash_long_swap_mask() {
  3203   address generate_ghash_long_swap_mask() {
  3074     __ align(CodeEntryAlignment);
  3204     __ align(CodeEntryAlignment);
  3075     StubCodeMark mark(this, "StubRoutines", "ghash_long_swap_mask");
  3205     StubCodeMark mark(this, "StubRoutines", "ghash_long_swap_mask");
  3770     if (UseAESCTRIntrinsics) {
  3900     if (UseAESCTRIntrinsics) {
  3771       StubRoutines::x86::_counter_shuffle_mask_addr = generate_counter_shuffle_mask();
  3901       StubRoutines::x86::_counter_shuffle_mask_addr = generate_counter_shuffle_mask();
  3772       StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel();
  3902       StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel();
  3773     }
  3903     }
  3774 
  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 
  3775     // Generate GHASH intrinsics code
  3918     // Generate GHASH intrinsics code
  3776     if (UseGHASHIntrinsics) {
  3919     if (UseGHASHIntrinsics) {
  3777       StubRoutines::x86::_ghash_long_swap_mask_addr = generate_ghash_long_swap_mask();
  3920       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();
  3921       StubRoutines::x86::_ghash_byte_swap_mask_addr = generate_ghash_byte_swap_mask();
  3779       StubRoutines::_ghash_processBlocks = generate_ghash_processBlocks();
  3922       StubRoutines::_ghash_processBlocks = generate_ghash_processBlocks();