Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3e2aab6
Add Unsafe.setMemory as intrinsic
asgibbons Mar 27, 2024
2334b03
Added actual intrinsic
asgibbons Mar 27, 2024
6eebcbd
Removed setMemory1; debugged intrinsic code
asgibbons Mar 28, 2024
7c73856
Test removing intrinsic
asgibbons Mar 28, 2024
74c47e2
Add benchmark
asgibbons Mar 28, 2024
6e283bc
Restore intrinsic
asgibbons Mar 28, 2024
44c24ec
Address review comment
asgibbons Mar 29, 2024
b17a1f4
Fixed bug - incorrect interface to *_fill_entry
asgibbons Mar 29, 2024
401a2a9
Clean up code for PR
asgibbons Mar 29, 2024
c5cb30c
Use non-sse fill (old left in)
asgibbons Apr 1, 2024
6ee69c8
Remove dead code
asgibbons Apr 1, 2024
3aa60a4
Addressing review comments.
asgibbons Apr 2, 2024
8bed156
Fix Windows
asgibbons Apr 3, 2024
b025318
Fixed generate_fill when count > 0x80000000
asgibbons Apr 5, 2024
fd6f04f
Oops
asgibbons Apr 6, 2024
f81aaa9
Add movq to locate_operand
asgibbons Apr 8, 2024
b0ac857
Address review comments (#15)
asgibbons Apr 11, 2024
95230e2
Set memory test (#16)
asgibbons Apr 11, 2024
41ffcc3
Merge master
asgibbons Apr 11, 2024
b99499a
Fix whitespace error.
asgibbons Apr 11, 2024
89db3eb
Addressing more review comments
asgibbons Apr 11, 2024
970c575
Addressing yet more review comments
asgibbons Apr 12, 2024
6e731c8
Even more review comments
asgibbons Apr 12, 2024
405e4e0
Change fill routines
asgibbons Apr 15, 2024
95b0a34
Rename UnsafeCopyMemory{,Mark} to UnsafeMemory{Access,Mark} (#19)
asgibbons Apr 15, 2024
44cc91b
Only add a memory mark for byte unaligned fill
asgibbons Apr 15, 2024
824fb60
Set memory test (#21)
asgibbons Apr 15, 2024
80b5a0c
Set memory test (#22)
asgibbons Apr 15, 2024
856464e
Set memory test (#23)
asgibbons Apr 15, 2024
116d7dd
Merge branch 'openjdk:master' into setMemory
asgibbons Apr 15, 2024
113aa90
Fix memory mark after sync to upstream
asgibbons Apr 15, 2024
7a1d67e
Add enter() and leave(); remove Windows-specific register stuff
asgibbons Apr 16, 2024
dccf6b6
Address review comments; update copyright years
asgibbons Apr 19, 2024
dd0094e
Review comments
asgibbons Apr 19, 2024
1961624
Long to short jmp; other cleanup
asgibbons Apr 19, 2024
c129016
Fix UnsafeCopyMemoryMark scope issue
asgibbons Apr 20, 2024
1122b50
Merge branch 'openjdk:master' into setMemory
asgibbons Apr 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 18 additions & 37 deletions src/hotspot/cpu/x86/stubGenerator_x86_64_arraycopy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2585,6 +2585,7 @@ address StubGenerator::generate_unsafe_setmemory(const char *name,
__ align(CodeEntryAlignment);
StubCodeMark mark(this, "StubRoutines", name);
address start = __ pc();
__ enter(); // required for proper stackwalking of RuntimeStub frame

assert(unsafe_byte_fill != nullptr, "Invalid call");

Expand All @@ -2594,34 +2595,25 @@ address StubGenerator::generate_unsafe_setmemory(const char *name,
{
Label L_exit, L_fillQuadwords, L_fillDwords, L_fillBytes;

// setup_arg_regs only has an effect for Windows
// Windows argument registers are moved into Linux ABI-defined registers
// r9 and r10 are used to save rsi and rdi and are therefore unavailable
// as scratch registers for the routine.
setup_arg_regs(3);

const Register dest = rdi;
const Register size = rsi;
const Register dest = c_rarg0;
const Register size = c_rarg1;
const Register byteVal = c_rarg2;
const Register wide_value = rax;
const Register rScratch1 = rcx;
const Register rScratch1 = r10;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe put an assert_different_registers here for the above registers, just to be sure. (I see you are avoiding the existing rscratch1 already, because of a conflict with c_rarg2)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// fill_to_memory_atomic(unsigned char*, unsigned long, unsigned char)

__ testq(size, size);
__ jcc(Assembler::zero, L_exit);

{
const Register byteVal = rdx;

// Propagate byte to full Register
__ movzbl(rScratch1, byteVal);
__ mov64(wide_value, 0x0101010101010101);
__ imulq(wide_value, rScratch1);
// Propagate byte to full Register
__ movzbl(rScratch1, byteVal);
__ mov64(wide_value, 0x0101010101010101);
__ imulq(wide_value, rScratch1);

// Check for pointer & size alignment
__ movq(rScratch1, dest);
__ orq(rScratch1, size);
}
// Check for pointer & size alignment
__ movq(rScratch1, dest);
__ orq(rScratch1, size);

__ testb(rScratch1, 7);
__ jcc(Assembler::equal, L_fillQuadwords);
Expand Down Expand Up @@ -2658,7 +2650,7 @@ address StubGenerator::generate_unsafe_setmemory(const char *name,
}
__ BIND(L_exit);

restore_arg_regs();
__ leave(); // required for proper stackwalking of RuntimeStub frame
__ ret(0);

__ BIND(L_fillDwords);
Expand All @@ -2676,22 +2668,11 @@ address StubGenerator::generate_unsafe_setmemory(const char *name,
__ jmp(L_exit);

__ BIND(L_fillBytes);
{
const Register byteVal = rdx;
#ifdef _WIN32
__ movq(rcx, rdi); // Restore c_rarg*
__ movq(r8, rdx);
__ movq(rdx, rsi);
restore_arg_regs();
#endif
// rax has expanded byte value
__ movq(c_rarg2, rax);

// Set up for tail call to previously generated byte fill routine
// Parameter order is (ptr, byteVal, size)
__ xchgq(c_rarg1, c_rarg2);
__ jump(RuntimeAddress(unsafe_byte_fill));
}
// Set up for tail call to previously generated byte fill routine
// Parameter order is (ptr, byteVal, size)
__ xchgq(c_rarg1, c_rarg2);
__ pop(rbp); // Clear effect of enter()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just use leave() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No special reason. I've changed it since it seems to provide more clarity.

__ jump(RuntimeAddress(unsafe_byte_fill));
}

return start;
Expand Down