Mercurial > hg > graal-compiler
comparison src/cpu/x86/vm/stubGenerator_x86_64.cpp @ 14909:4ca6dc0799b6
Backout jdk9 merge
author | Gilles Duboscq <duboscq@ssw.jku.at> |
---|---|
date | Tue, 01 Apr 2014 13:57:07 +0200 |
parents | d8041d695d19 |
children | 4062efea018b |
comparison
equal
deleted
inserted
replaced
14908:8db6e76cb658 | 14909:4ca6dc0799b6 |
---|---|
3215 // c_rarg1 - destination byte array address | 3215 // c_rarg1 - destination byte array address |
3216 // c_rarg2 - K (key) in little endian int array | 3216 // c_rarg2 - K (key) in little endian int array |
3217 // c_rarg3 - r vector byte array address | 3217 // c_rarg3 - r vector byte array address |
3218 // c_rarg4 - input length | 3218 // c_rarg4 - input length |
3219 // | 3219 // |
3220 // Output: | |
3221 // rax - input length | |
3222 // | |
3223 address generate_cipherBlockChaining_encryptAESCrypt() { | 3220 address generate_cipherBlockChaining_encryptAESCrypt() { |
3224 assert(UseAES, "need AES instructions and misaligned SSE support"); | 3221 assert(UseAES, "need AES instructions and misaligned SSE support"); |
3225 __ align(CodeEntryAlignment); | 3222 __ align(CodeEntryAlignment); |
3226 StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_encryptAESCrypt"); | 3223 StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_encryptAESCrypt"); |
3227 address start = __ pc(); | 3224 address start = __ pc(); |
3233 const Register rvec = c_rarg3; // r byte array initialized from initvector array address | 3230 const Register rvec = c_rarg3; // r byte array initialized from initvector array address |
3234 // and left with the results of the last encryption block | 3231 // and left with the results of the last encryption block |
3235 #ifndef _WIN64 | 3232 #ifndef _WIN64 |
3236 const Register len_reg = c_rarg4; // src len (must be multiple of blocksize 16) | 3233 const Register len_reg = c_rarg4; // src len (must be multiple of blocksize 16) |
3237 #else | 3234 #else |
3238 const Address len_mem(rbp, 6 * wordSize); // length is on stack on Win64 | 3235 const Address len_mem(rsp, 6 * wordSize); // length is on stack on Win64 |
3239 const Register len_reg = r10; // pick the first volatile windows register | 3236 const Register len_reg = r10; // pick the first volatile windows register |
3240 #endif | 3237 #endif |
3241 const Register pos = rax; | 3238 const Register pos = rax; |
3242 | 3239 |
3243 // xmm register assignments for the loops below | 3240 // xmm register assignments for the loops below |
3260 // save the xmm registers which must be preserved 6-15 | 3257 // save the xmm registers which must be preserved 6-15 |
3261 __ subptr(rsp, -rsp_after_call_off * wordSize); | 3258 __ subptr(rsp, -rsp_after_call_off * wordSize); |
3262 for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) { | 3259 for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) { |
3263 __ movdqu(xmm_save(i), as_XMMRegister(i)); | 3260 __ movdqu(xmm_save(i), as_XMMRegister(i)); |
3264 } | 3261 } |
3265 #else | |
3266 __ push(len_reg); // Save | |
3267 #endif | 3262 #endif |
3268 | 3263 |
3269 const XMMRegister xmm_key_shuf_mask = xmm_temp; // used temporarily to swap key bytes up front | 3264 const XMMRegister xmm_key_shuf_mask = xmm_temp; // used temporarily to swap key bytes up front |
3270 __ movdqu(xmm_key_shuf_mask, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr())); | 3265 __ movdqu(xmm_key_shuf_mask, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr())); |
3271 // load up xmm regs xmm2 thru xmm12 with key 0x00 - 0xa0 | 3266 // load up xmm regs xmm2 thru xmm12 with key 0x00 - 0xa0 |
3304 #ifdef _WIN64 | 3299 #ifdef _WIN64 |
3305 // restore xmm regs belonging to calling function | 3300 // restore xmm regs belonging to calling function |
3306 for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) { | 3301 for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) { |
3307 __ movdqu(as_XMMRegister(i), xmm_save(i)); | 3302 __ movdqu(as_XMMRegister(i), xmm_save(i)); |
3308 } | 3303 } |
3309 __ movl(rax, len_mem); | |
3310 #else | |
3311 __ pop(rax); // return length | |
3312 #endif | 3304 #endif |
3305 __ movl(rax, 0); // return 0 (why?) | |
3313 __ leave(); // required for proper stackwalking of RuntimeStub frame | 3306 __ leave(); // required for proper stackwalking of RuntimeStub frame |
3314 __ ret(0); | 3307 __ ret(0); |
3315 | 3308 |
3316 __ BIND(L_key_192_256); | 3309 __ BIND(L_key_192_256); |
3317 // here rax = len in ints of AESCrypt.KLE array (52=192, or 60=256) | 3310 // here rax = len in ints of AESCrypt.KLE array (52=192, or 60=256) |
3414 // c_rarg1 - destination byte array address | 3407 // c_rarg1 - destination byte array address |
3415 // c_rarg2 - K (key) in little endian int array | 3408 // c_rarg2 - K (key) in little endian int array |
3416 // c_rarg3 - r vector byte array address | 3409 // c_rarg3 - r vector byte array address |
3417 // c_rarg4 - input length | 3410 // c_rarg4 - input length |
3418 // | 3411 // |
3419 // Output: | |
3420 // rax - input length | |
3421 // | |
3422 | 3412 |
3423 address generate_cipherBlockChaining_decryptAESCrypt_Parallel() { | 3413 address generate_cipherBlockChaining_decryptAESCrypt_Parallel() { |
3424 assert(UseAES, "need AES instructions and misaligned SSE support"); | 3414 assert(UseAES, "need AES instructions and misaligned SSE support"); |
3425 __ align(CodeEntryAlignment); | 3415 __ align(CodeEntryAlignment); |
3426 StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_decryptAESCrypt"); | 3416 StubCodeMark mark(this, "StubRoutines", "cipherBlockChaining_decryptAESCrypt"); |
3435 const Register rvec = c_rarg3; // r byte array initialized from initvector array address | 3425 const Register rvec = c_rarg3; // r byte array initialized from initvector array address |
3436 // and left with the results of the last encryption block | 3426 // and left with the results of the last encryption block |
3437 #ifndef _WIN64 | 3427 #ifndef _WIN64 |
3438 const Register len_reg = c_rarg4; // src len (must be multiple of blocksize 16) | 3428 const Register len_reg = c_rarg4; // src len (must be multiple of blocksize 16) |
3439 #else | 3429 #else |
3440 const Address len_mem(rbp, 6 * wordSize); // length is on stack on Win64 | 3430 const Address len_mem(rsp, 6 * wordSize); // length is on stack on Win64 |
3441 const Register len_reg = r10; // pick the first volatile windows register | 3431 const Register len_reg = r10; // pick the first volatile windows register |
3442 #endif | 3432 #endif |
3443 const Register pos = rax; | 3433 const Register pos = rax; |
3444 | 3434 |
3445 // keys 0-10 preloaded into xmm2-xmm12 | 3435 // keys 0-10 preloaded into xmm2-xmm12 |
3456 // save the xmm registers which must be preserved 6-15 | 3446 // save the xmm registers which must be preserved 6-15 |
3457 __ subptr(rsp, -rsp_after_call_off * wordSize); | 3447 __ subptr(rsp, -rsp_after_call_off * wordSize); |
3458 for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) { | 3448 for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) { |
3459 __ movdqu(xmm_save(i), as_XMMRegister(i)); | 3449 __ movdqu(xmm_save(i), as_XMMRegister(i)); |
3460 } | 3450 } |
3461 #else | |
3462 __ push(len_reg); // Save | |
3463 #endif | 3451 #endif |
3464 | |
3465 // the java expanded key ordering is rotated one position from what we want | 3452 // the java expanded key ordering is rotated one position from what we want |
3466 // so we start from 0x10 here and hit 0x00 last | 3453 // so we start from 0x10 here and hit 0x00 last |
3467 const XMMRegister xmm_key_shuf_mask = xmm1; // used temporarily to swap key bytes up front | 3454 const XMMRegister xmm_key_shuf_mask = xmm1; // used temporarily to swap key bytes up front |
3468 __ movdqu(xmm_key_shuf_mask, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr())); | 3455 __ movdqu(xmm_key_shuf_mask, ExternalAddress(StubRoutines::x86::key_shuffle_mask_addr())); |
3469 // load up xmm regs 5 thru 15 with key 0x10 - 0xa0 - 0x00 | 3456 // load up xmm regs 5 thru 15 with key 0x10 - 0xa0 - 0x00 |
3565 #ifdef _WIN64 | 3552 #ifdef _WIN64 |
3566 // restore regs belonging to calling function | 3553 // restore regs belonging to calling function |
3567 for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) { | 3554 for (int i = 6; i <= XMM_REG_NUM_KEY_LAST; i++) { |
3568 __ movdqu(as_XMMRegister(i), xmm_save(i)); | 3555 __ movdqu(as_XMMRegister(i), xmm_save(i)); |
3569 } | 3556 } |
3570 __ movl(rax, len_mem); | |
3571 #else | |
3572 __ pop(rax); // return length | |
3573 #endif | 3557 #endif |
3558 __ movl(rax, 0); // return 0 (why?) | |
3574 __ leave(); // required for proper stackwalking of RuntimeStub frame | 3559 __ leave(); // required for proper stackwalking of RuntimeStub frame |
3575 __ ret(0); | 3560 __ ret(0); |
3576 | 3561 |
3577 | 3562 |
3578 __ BIND(L_key_192_256); | 3563 __ BIND(L_key_192_256); |