65
65
const int MXCSR_MASK = 0xFFC0 ; // Mask out any pending exceptions
66
66
const int FPU_CNTRL_WRD_MASK = 0xFFFF ;
67
67
68
+ ATTRIBUTE_ALIGNED (16 ) uint32_t KEY_SHUFFLE_MASK[] = {
69
+ 0x00010203UL , 0x04050607UL , 0x08090A0BUL , 0x0C0D0E0FUL ,
70
+ };
71
+
72
+ ATTRIBUTE_ALIGNED (16 ) uint32_t COUNTER_SHUFFLE_MASK[] = {
73
+ 0x0C0D0E0FUL , 0x08090A0BUL , 0x04050607UL , 0x00010203UL ,
74
+ };
75
+
76
+ ATTRIBUTE_ALIGNED (16 ) uint32_t GHASH_BYTE_SWAP_MASK[] = {
77
+ 0x0C0D0E0FUL , 0x08090A0BUL , 0x04050607UL , 0x00010203UL ,
78
+ };
79
+
80
+ ATTRIBUTE_ALIGNED (16 ) uint32_t GHASH_LONG_SWAP_MASK[] = {
81
+ 0x0B0A0908UL , 0x0F0E0D0CUL , 0x03020100UL , 0x07060504UL ,
82
+ };
83
+
68
84
// -------------------------------------------------------------------------------------------------------------------------
69
85
// Stub Code definitions
70
86
@@ -2180,26 +2196,12 @@ class StubGenerator: public StubCodeGenerator {
2180
2196
// AES intrinsic stubs
2181
2197
enum {AESBlockSize = 16 };
2182
2198
2183
- address generate_key_shuffle_mask () {
2184
- __ align (16 );
2185
- StubCodeMark mark (this , " StubRoutines" , " key_shuffle_mask" );
2186
- address start = __ pc ();
2187
- __ emit_data (0x00010203 , relocInfo::none, 0 );
2188
- __ emit_data (0x04050607 , relocInfo::none, 0 );
2189
- __ emit_data (0x08090a0b , relocInfo::none, 0 );
2190
- __ emit_data (0x0c0d0e0f , relocInfo::none, 0 );
2191
- return start;
2199
+ address key_shuffle_mask_addr () {
2200
+ return (address)KEY_SHUFFLE_MASK;
2192
2201
}
2193
2202
2194
- address generate_counter_shuffle_mask () {
2195
- __ align (16 );
2196
- StubCodeMark mark (this , " StubRoutines" , " counter_shuffle_mask" );
2197
- address start = __ pc ();
2198
- __ emit_data (0x0c0d0e0f , relocInfo::none, 0 );
2199
- __ emit_data (0x08090a0b , relocInfo::none, 0 );
2200
- __ emit_data (0x04050607 , relocInfo::none, 0 );
2201
- __ emit_data (0x00010203 , relocInfo::none, 0 );
2202
- return start;
2203
+ address counter_shuffle_mask_addr () {
2204
+ return (address)COUNTER_SHUFFLE_MASK;
2203
2205
}
2204
2206
2205
2207
// Utility routine for loading a 128-bit key word in little endian format
@@ -2209,7 +2211,7 @@ class StubGenerator: public StubCodeGenerator {
2209
2211
if (xmm_shuf_mask != xnoreg) {
2210
2212
__ pshufb (xmmdst, xmm_shuf_mask);
2211
2213
} else {
2212
- __ pshufb (xmmdst, ExternalAddress (StubRoutines::x86:: key_shuffle_mask_addr ()));
2214
+ __ pshufb (xmmdst, ExternalAddress (key_shuffle_mask_addr ()));
2213
2215
}
2214
2216
}
2215
2217
@@ -2290,7 +2292,7 @@ class StubGenerator: public StubCodeGenerator {
2290
2292
// keylen could be only {11, 13, 15} * 4 = {44, 52, 60}
2291
2293
__ movl (keylen, Address (key, arrayOopDesc::length_offset_in_bytes () - arrayOopDesc::base_offset_in_bytes (T_INT)));
2292
2294
2293
- __ movdqu (xmm_key_shuf_mask, ExternalAddress (StubRoutines::x86:: key_shuffle_mask_addr ()));
2295
+ __ movdqu (xmm_key_shuf_mask, ExternalAddress (key_shuffle_mask_addr ()));
2294
2296
__ movdqu (xmm_result, Address (from, 0 )); // get 16 bytes of input
2295
2297
__ movptr (to, to_param);
2296
2298
@@ -2389,7 +2391,7 @@ class StubGenerator: public StubCodeGenerator {
2389
2391
// keylen could be only {11, 13, 15} * 4 = {44, 52, 60}
2390
2392
__ movl (keylen, Address (key, arrayOopDesc::length_offset_in_bytes () - arrayOopDesc::base_offset_in_bytes (T_INT)));
2391
2393
2392
- __ movdqu (xmm_key_shuf_mask, ExternalAddress (StubRoutines::x86:: key_shuffle_mask_addr ()));
2394
+ __ movdqu (xmm_key_shuf_mask, ExternalAddress (key_shuffle_mask_addr ()));
2393
2395
__ movdqu (xmm_result, Address (from, 0 ));
2394
2396
__ movptr (to, to_param);
2395
2397
@@ -2522,7 +2524,7 @@ class StubGenerator: public StubCodeGenerator {
2522
2524
__ movptr (len_reg , len_param);
2523
2525
2524
2526
const XMMRegister xmm_key_shuf_mask = xmm_temp; // used temporarily to swap key bytes up front
2525
- __ movdqu (xmm_key_shuf_mask, ExternalAddress (StubRoutines::x86:: key_shuffle_mask_addr ()));
2527
+ __ movdqu (xmm_key_shuf_mask, ExternalAddress (key_shuffle_mask_addr ()));
2526
2528
// load up xmm regs 2 thru 7 with keys 0-5
2527
2529
for (int rnum = XMM_REG_NUM_KEY_FIRST, offset = 0x00 ; rnum <= XMM_REG_NUM_KEY_LAST; rnum++) {
2528
2530
load_key (as_XMMRegister (rnum), key, offset, xmm_key_shuf_mask);
@@ -2690,7 +2692,7 @@ class StubGenerator: public StubCodeGenerator {
2690
2692
__ movptr (rvec , rvec_param);
2691
2693
__ movptr (len_reg , len_param);
2692
2694
2693
- __ movdqu (xmm_key_shuf_mask, ExternalAddress (StubRoutines::x86:: key_shuffle_mask_addr ()));
2695
+ __ movdqu (xmm_key_shuf_mask, ExternalAddress (key_shuffle_mask_addr ()));
2694
2696
__ movdqu (xmm_prev_block_cipher, Address (rvec, 0x00 )); // initialize with initial rvec
2695
2697
2696
2698
__ xorptr (pos, pos);
@@ -2909,11 +2911,11 @@ class StubGenerator: public StubCodeGenerator {
2909
2911
2910
2912
// initialize counter with initial counter
2911
2913
__ movdqu (xmm_curr_counter, Address (counter, 0x00 ));
2912
- __ movdqu (xmm_counter_shuf_mask, ExternalAddress (StubRoutines::x86:: counter_shuffle_mask_addr ()));
2914
+ __ movdqu (xmm_counter_shuf_mask, ExternalAddress (counter_shuffle_mask_addr ()));
2913
2915
__ pshufb (xmm_curr_counter, xmm_counter_shuf_mask); // counter is shuffled for increase
2914
2916
2915
2917
// key length could be only {11, 13, 15} * 4 = {44, 52, 60}
2916
- __ movdqu (xmm_key_shuf_mask, ExternalAddress (StubRoutines::x86:: key_shuffle_mask_addr ()));
2918
+ __ movdqu (xmm_key_shuf_mask, ExternalAddress (key_shuffle_mask_addr ()));
2917
2919
__ movl (rax, Address (key, arrayOopDesc::length_offset_in_bytes () - arrayOopDesc::base_offset_in_bytes (T_INT)));
2918
2920
__ cmpl (rax, 52 );
2919
2921
__ jcc (Assembler::equal, L_key192_top);
@@ -2939,8 +2941,8 @@ class StubGenerator: public StubCodeGenerator {
2939
2941
__ cmpptr (len_reg, PARALLEL_FACTOR * AESBlockSize); // see if at least PARALLEL_FACTOR blocks left
2940
2942
__ jcc (Assembler::less, L_singleBlockLoopTop[k]);
2941
2943
2942
- __ movdqu (xmm_key_shuf_mask, ExternalAddress (StubRoutines::x86:: key_shuffle_mask_addr ()));
2943
- __ movdqu (xmm_counter_shuf_mask, ExternalAddress (StubRoutines::x86:: counter_shuffle_mask_addr ()));
2944
+ __ movdqu (xmm_key_shuf_mask, ExternalAddress (key_shuffle_mask_addr ()));
2945
+ __ movdqu (xmm_counter_shuf_mask, ExternalAddress (counter_shuffle_mask_addr ()));
2944
2946
2945
2947
// load, then increase counters
2946
2948
CTR_DoFour (movdqa, xmm_curr_counter);
@@ -2992,8 +2994,8 @@ class StubGenerator: public StubCodeGenerator {
2992
2994
__ BIND (L_singleBlockLoopTop[k]);
2993
2995
__ cmpptr (len_reg, 0 );
2994
2996
__ jcc (Assembler::equal, L_exit);
2995
- __ movdqu (xmm_key_shuf_mask, ExternalAddress (StubRoutines::x86:: key_shuffle_mask_addr ()));
2996
- __ movdqu (xmm_counter_shuf_mask, ExternalAddress (StubRoutines::x86:: counter_shuffle_mask_addr ()));
2997
+ __ movdqu (xmm_key_shuf_mask, ExternalAddress (key_shuffle_mask_addr ()));
2998
+ __ movdqu (xmm_counter_shuf_mask, ExternalAddress (counter_shuffle_mask_addr ()));
2997
2999
__ movdqa (xmm_result0, xmm_curr_counter);
2998
3000
load_key (xmm_key, key, 0x00 , xmm_key_shuf_mask);
2999
3001
__ push (rbx);// rbx is used for increasing counter
@@ -3078,7 +3080,7 @@ class StubGenerator: public StubCodeGenerator {
3078
3080
}
3079
3081
3080
3082
__ BIND (L_exit);
3081
- __ movdqu (xmm_counter_shuf_mask, ExternalAddress (StubRoutines::x86:: counter_shuffle_mask_addr ()));
3083
+ __ movdqu (xmm_counter_shuf_mask, ExternalAddress (counter_shuffle_mask_addr ()));
3082
3084
__ pshufb (xmm_curr_counter, xmm_counter_shuf_mask); // counter is shuffled back.
3083
3085
__ movdqu (Address (counter, 0 ), xmm_curr_counter); // save counter back
3084
3086
handleSOERegisters (false /* restoring*/ );
@@ -3266,28 +3268,13 @@ class StubGenerator: public StubCodeGenerator {
3266
3268
}
3267
3269
3268
3270
// byte swap x86 long
3269
- address generate_ghash_long_swap_mask () {
3270
- __ align (CodeEntryAlignment);
3271
- StubCodeMark mark (this , " StubRoutines" , " ghash_long_swap_mask" );
3272
- address start = __ pc ();
3273
- __ emit_data (0x0b0a0908 , relocInfo::none, 0 );
3274
- __ emit_data (0x0f0e0d0c , relocInfo::none, 0 );
3275
- __ emit_data (0x03020100 , relocInfo::none, 0 );
3276
- __ emit_data (0x07060504 , relocInfo::none, 0 );
3277
-
3278
- return start;
3271
+ address ghash_long_swap_mask_addr () {
3272
+ return (address)GHASH_LONG_SWAP_MASK;
3279
3273
}
3280
3274
3281
3275
// byte swap x86 byte array
3282
- address generate_ghash_byte_swap_mask () {
3283
- __ align (CodeEntryAlignment);
3284
- StubCodeMark mark (this , " StubRoutines" , " ghash_byte_swap_mask" );
3285
- address start = __ pc ();
3286
- __ emit_data (0x0c0d0e0f , relocInfo::none, 0 );
3287
- __ emit_data (0x08090a0b , relocInfo::none, 0 );
3288
- __ emit_data (0x04050607 , relocInfo::none, 0 );
3289
- __ emit_data (0x00010203 , relocInfo::none, 0 );
3290
- return start;
3276
+ address ghash_byte_swap_mask_addr () {
3277
+ return (address)GHASH_BYTE_SWAP_MASK;
3291
3278
}
3292
3279
3293
3280
/* Single and multi-block ghash operations */
@@ -3326,14 +3313,14 @@ class StubGenerator: public StubCodeGenerator {
3326
3313
__ movptr (blocks, blocks_param);
3327
3314
3328
3315
__ movdqu (xmm_temp0, Address (state, 0 ));
3329
- __ pshufb (xmm_temp0, ExternalAddress (StubRoutines::x86:: ghash_long_swap_mask_addr ()));
3316
+ __ pshufb (xmm_temp0, ExternalAddress (ghash_long_swap_mask_addr ()));
3330
3317
3331
3318
__ movdqu (xmm_temp1, Address (subkeyH, 0 ));
3332
- __ pshufb (xmm_temp1, ExternalAddress (StubRoutines::x86:: ghash_long_swap_mask_addr ()));
3319
+ __ pshufb (xmm_temp1, ExternalAddress (ghash_long_swap_mask_addr ()));
3333
3320
3334
3321
__ BIND (L_ghash_loop);
3335
3322
__ movdqu (xmm_temp2, Address (data, 0 ));
3336
- __ pshufb (xmm_temp2, ExternalAddress (StubRoutines::x86:: ghash_byte_swap_mask_addr ()));
3323
+ __ pshufb (xmm_temp2, ExternalAddress (ghash_byte_swap_mask_addr ()));
3337
3324
3338
3325
__ pxor (xmm_temp0, xmm_temp2);
3339
3326
@@ -3419,7 +3406,7 @@ class StubGenerator: public StubCodeGenerator {
3419
3406
3420
3407
__ BIND (L_exit);
3421
3408
// Byte swap 16-byte result
3422
- __ pshufb (xmm_temp6, ExternalAddress (StubRoutines::x86:: ghash_long_swap_mask_addr ()));
3409
+ __ pshufb (xmm_temp6, ExternalAddress (ghash_long_swap_mask_addr ()));
3423
3410
__ movdqu (Address (state, 0 ), xmm_temp6); // store the result
3424
3411
3425
3412
handleSOERegisters (false ); // restore registers
@@ -4126,16 +4113,13 @@ class StubGenerator: public StubCodeGenerator {
4126
4113
4127
4114
// don't bother generating these AES intrinsic stubs unless global flag is set
4128
4115
if (UseAESIntrinsics) {
4129
- StubRoutines::x86::_key_shuffle_mask_addr = generate_key_shuffle_mask (); // might be needed by the others
4130
-
4131
4116
StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock ();
4132
4117
StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock ();
4133
4118
StubRoutines::_cipherBlockChaining_encryptAESCrypt = generate_cipherBlockChaining_encryptAESCrypt ();
4134
4119
StubRoutines::_cipherBlockChaining_decryptAESCrypt = generate_cipherBlockChaining_decryptAESCrypt_Parallel ();
4135
4120
}
4136
4121
4137
4122
if (UseAESCTRIntrinsics) {
4138
- StubRoutines::x86::_counter_shuffle_mask_addr = generate_counter_shuffle_mask ();
4139
4123
StubRoutines::_counterMode_AESCrypt = generate_counterMode_AESCrypt_Parallel ();
4140
4124
}
4141
4125
@@ -4158,8 +4142,6 @@ class StubGenerator: public StubCodeGenerator {
4158
4142
4159
4143
// Generate GHASH intrinsics code
4160
4144
if (UseGHASHIntrinsics) {
4161
- StubRoutines::x86::_ghash_long_swap_mask_addr = generate_ghash_long_swap_mask ();
4162
- StubRoutines::x86::_ghash_byte_swap_mask_addr = generate_ghash_byte_swap_mask ();
4163
4145
StubRoutines::_ghash_processBlocks = generate_ghash_processBlocks ();
4164
4146
}
4165
4147
0 commit comments