Skip to content

Commit

Permalink
8307555: Reduce memory reads in x86 MD5 intrinsic
Browse files Browse the repository at this point in the history
Backport-of: 43c8c65
  • Loading branch information
chadrako authored and Paul Hohensee committed Jul 13, 2023
1 parent 2b8c260 commit 9f3c095
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/hotspot/cpu/x86/macroAssembler_x86_md5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,16 @@
// int com.sun.security.provider.MD5.implCompress0(byte[] b, int ofs)
void MacroAssembler::fast_md5(Register buf, Address state, Address ofs, Address limit, bool multi_block) {

Label start, done_hash, loop0;
Label done_hash, loop0;

bind(start);

bind(loop0);

// Save hash values for addition after rounds
movptr(rdi, state);
movl(rax, Address(rdi, 0));
movl(rbx, Address(rdi, 4));
movl(rcx, Address(rdi, 8));
movl(rdx, Address(rdi, 12));

bind(loop0);

#define FF(r1, r2, r3, r4, k, s, t) \
addl(r1, t); \
movl(rsi, r3); \
Expand Down Expand Up @@ -189,10 +186,14 @@ void MacroAssembler::fast_md5(Register buf, Address state, Address ofs, Address

// write hash values back in the correct order
movptr(rdi, state);
addl(Address(rdi, 0), rax);
addl(Address(rdi, 4), rbx);
addl(Address(rdi, 8), rcx);
addl(Address(rdi, 12), rdx);
addl(rax, Address(rdi, 0));
movl(Address(rdi, 0), rax);
addl(rbx, Address(rdi, 4));
movl(Address(rdi, 4), rbx);
addl(rcx, Address(rdi, 8));
movl(Address(rdi, 8), rcx);
addl(rdx, Address(rdi, 12));
movl(Address(rdi, 12), rdx);

if (multi_block) {
// increment data pointer and loop if more to process
Expand Down

0 comments on commit 9f3c095

Please sign in to comment.