Skip to content
Closed
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1519,9 +1519,9 @@ class StubGenerator: public StubCodeGenerator {
__ push(RegSet::of(d, count), sp);
}
{
// UnsafeMemoryAccess page error: continue after ucm
// UnsafeCopyMemory page error: continue after ucm
bool add_entry = !is_oop && (!aligned || sizeof(jlong) == size);
UnsafeMemoryMark ucmm(this, add_entry, true);
UnsafeCopyMemoryMark ucmm(this, add_entry, true);
copy_memory(decorators, is_oop ? T_OBJECT : T_BYTE, aligned, s, d, count, size);
}

Expand Down Expand Up @@ -1590,9 +1590,9 @@ class StubGenerator: public StubCodeGenerator {
__ push(RegSet::of(d, count), sp);
}
{
// UnsafeMemoryAccess page error: continue after ucm
// UnsafeCopyMemory page error: continue after ucm
bool add_entry = !is_oop && (!aligned || sizeof(jlong) == size);
UnsafeMemoryMark ucmm(this, add_entry, true);
UnsafeCopyMemoryMark ucmm(this, add_entry, true);
copy_memory(decorators, is_oop ? T_OBJECT : T_BYTE, aligned, s, d, count, -size);
}
if (is_oop) {
Expand Down Expand Up @@ -8332,8 +8332,8 @@ class StubGenerator: public StubCodeGenerator {
SharedRuntime::throw_delayed_StackOverflowError));

// Initialize table for copy memory (arraycopy) check.
if (UnsafeMemoryAccess::_table == nullptr) {
UnsafeMemoryAccess::create_table(18);
if (UnsafeCopyMemory::_table == nullptr) {
UnsafeCopyMemory::create_table(8 + 4); // 8 for copyMemory; 4 for setMemory
}

if (UseCRC32Intrinsics) {
Expand Down
34 changes: 17 additions & 17 deletions src/hotspot/cpu/arm/stubGenerator_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,8 +956,8 @@ class StubGenerator: public StubCodeGenerator {
Label L_skip_pld;

{
// UnsafeMemoryAccess page error: continue after ucm
UnsafeMemoryMark ucmm(this, unsafe_copy, true);
// UnsafeCopyMemory page error: continue after ucm
UnsafeCopyMemoryMark ucmm(this, unsafe_copy, true);
// predecrease to exit when there is less than count_per_loop
__ sub_32(count, count, count_per_loop);

Expand Down Expand Up @@ -1105,8 +1105,8 @@ class StubGenerator: public StubCodeGenerator {
__ push(RegisterSet(R4,R10));

{
// UnsafeMemoryAccess page error: continue after ucm
UnsafeMemoryMark ucmm(this, unsafe_copy, true);
// UnsafeCopyMemory page error: continue after ucm
UnsafeCopyMemoryMark ucmm(this, unsafe_copy, true);
__ sub_32(count, count, count_per_loop);

const bool prefetch_before = pld_offset < 0;
Expand Down Expand Up @@ -1761,8 +1761,8 @@ class StubGenerator: public StubCodeGenerator {
assert_different_registers(from, to, count, tmp);

{
// UnsafeMemoryAccess page error: continue after ucm
UnsafeMemoryMark ucmm(this, unsafe_copy, true);
// UnsafeCopyMemory page error: continue after ucm
UnsafeCopyMemoryMark ucmm(this, unsafe_copy, true);
__ align(OptoLoopAlignment);
Label L_small_loop;
__ BIND(L_small_loop);
Expand Down Expand Up @@ -1900,8 +1900,8 @@ class StubGenerator: public StubCodeGenerator {
__ push(RegisterSet(R4,R10));

{
// UnsafeMemoryAccess page error: continue after ucm
UnsafeMemoryMark ucmm(this, unsafe_copy, true);
// UnsafeCopyMemory page error: continue after ucm
UnsafeCopyMemoryMark ucmm(this, unsafe_copy, true);
load_one(Rval, from, wordSize, forward);

switch (bytes_per_count) {
Expand Down Expand Up @@ -2058,8 +2058,8 @@ class StubGenerator: public StubCodeGenerator {

int count_required_to_align = 0;
{
// UnsafeMemoryMark page error: continue at UnsafeMemoryAccess common_error_exit
UnsafeMemoryMark ucmm(this, !aligned, false);
// UnsafeCopyMemoryMark page error: continue at UnsafeCopyMemory common_error_exit
UnsafeCopyMemoryMark ucmm(this, !aligned, false);
count_required_to_align = from_is_aligned ? 0 : align_src(from, to, count, tmp1, bytes_per_count, forward);
assert (small_copy_limit >= count_required_to_align, "alignment could exhaust count");
}
Expand Down Expand Up @@ -2092,9 +2092,9 @@ class StubGenerator: public StubCodeGenerator {

int min_copy;
if (forward) {
min_copy = generate_forward_aligned_copy_loop(from, to, count, bytes_per_count, !aligned /*add UnsafeMemoryAccess entry*/);
min_copy = generate_forward_aligned_copy_loop(from, to, count, bytes_per_count, !aligned /*add UnsafeCopyMemory entry*/);
} else {
min_copy = generate_backward_aligned_copy_loop(from, to, count, bytes_per_count, !aligned /*add UnsafeMemoryAccess entry*/);
min_copy = generate_backward_aligned_copy_loop(from, to, count, bytes_per_count, !aligned /*add UnsafeCopyMemory entry*/);
}
assert(small_copy_limit >= count_required_to_align + min_copy, "first loop might exhaust count");

Expand All @@ -2105,7 +2105,7 @@ class StubGenerator: public StubCodeGenerator {
__ ret();

{
copy_small_array(from, to, count, tmp1, tmp2, bytes_per_count, forward, L_small_array /* entry */, !aligned /*add UnsafeMemoryAccess entry*/);
copy_small_array(from, to, count, tmp1, tmp2, bytes_per_count, forward, L_small_array /* entry */, !aligned /*add UnsafeCopyMemory entry*/);

if (status) {
__ mov(R0, 0); // OK
Expand All @@ -2116,7 +2116,7 @@ class StubGenerator: public StubCodeGenerator {

if (! to_is_aligned) {
__ BIND(L_unaligned_dst);
int min_copy_shifted = align_dst_and_generate_shifted_copy_loop(from, to, count, bytes_per_count, forward, !aligned /*add UnsafeMemoryAccess entry*/);
int min_copy_shifted = align_dst_and_generate_shifted_copy_loop(from, to, count, bytes_per_count, forward, !aligned /*add UnsafeCopyMemory entry*/);
assert (small_copy_limit >= count_required_to_align + min_copy_shifted, "first loop might exhaust count");

if (status) {
Expand Down Expand Up @@ -2862,7 +2862,7 @@ class StubGenerator: public StubCodeGenerator {
#endif

address ucm_common_error_exit = generate_unsafecopy_common_error_exit();
UnsafeMemoryAccess::set_common_exit_stub_pc(ucm_common_error_exit);
UnsafeCopyMemory::set_common_exit_stub_pc(ucm_common_error_exit);

// these need always status in case they are called from generic_arraycopy
StubRoutines::_jbyte_disjoint_arraycopy = generate_primitive_copy(false, "jbyte_disjoint_arraycopy", true, 1, true);
Expand Down Expand Up @@ -3134,8 +3134,8 @@ class StubGenerator: public StubCodeGenerator {
// stub for throwing stack overflow error used both by interpreter and compiler
StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError));

if (UnsafeMemoryAccess::_table == nullptr) {
UnsafeMemoryAccess::create_table(42);
if (UnsafeCopyMemory::_table == nullptr) {
UnsafeCopyMemory::create_table(32 + 4); // 32 for copyMemory; 4 for setMemory
}

// integer division used both by interpreter and compiler
Expand Down
40 changes: 20 additions & 20 deletions src/hotspot/cpu/ppc/stubGenerator_ppc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ class StubGenerator: public StubCodeGenerator {
// need to copy backwards
}

// This is common errorexit stub for UnsafeMemoryAccess.
// This is common errorexit stub for UnsafeCopyMemory.
address generate_unsafecopy_common_error_exit() {
address start_pc = __ pc();
Register tmp1 = R6_ARG4;
Expand Down Expand Up @@ -1013,8 +1013,8 @@ class StubGenerator: public StubCodeGenerator {

Label l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8, l_9, l_10;
{
// UnsafeMemoryAccess page error: continue at UnsafeMemoryAccess common_error_exit
UnsafeMemoryMark ucmm(this, !aligned, false);
// UnsafeCopyMemory page error: continue at UnsafeCopyMemory common_error_exit
UnsafeCopyMemoryMark ucmm(this, !aligned, false);

// Don't try anything fancy if arrays don't have many elements.
__ li(tmp3, 0);
Expand Down Expand Up @@ -1195,8 +1195,8 @@ class StubGenerator: public StubCodeGenerator {
// that we don't have to optimize it.
Label l_1, l_2;
{
// UnsafeMemoryAccess page error: continue at UnsafeMemoryAccess common_error_exit
UnsafeMemoryMark ucmm(this, !aligned, false);
// UnsafeCopyMemory page error: continue at UnsafeCopyMemory common_error_exit
UnsafeCopyMemoryMark ucmm(this, !aligned, false);
__ b(l_2);
__ bind(l_1);
__ stbx(tmp1, R4_ARG2, R5_ARG3);
Expand Down Expand Up @@ -1282,8 +1282,8 @@ class StubGenerator: public StubCodeGenerator {

Label l_1, l_2, l_3, l_4, l_5, l_6, l_7, l_8, l_9;
{
// UnsafeMemoryAccess page error: continue at UnsafeMemoryAccess common_error_exit
UnsafeMemoryMark ucmm(this, !aligned, false);
// UnsafeCopyMemory page error: continue at UnsafeCopyMemory common_error_exit
UnsafeCopyMemoryMark ucmm(this, !aligned, false);
// don't try anything fancy if arrays don't have many elements
__ li(tmp3, 0);
__ cmpwi(CCR0, R5_ARG3, 9);
Expand Down Expand Up @@ -1466,8 +1466,8 @@ class StubGenerator: public StubCodeGenerator {

Label l_1, l_2;
{
// UnsafeMemoryAccess page error: continue at UnsafeMemoryAccess common_error_exit
UnsafeMemoryMark ucmm(this, !aligned, false);
// UnsafeCopyMemory page error: continue at UnsafeCopyMemory common_error_exit
UnsafeCopyMemoryMark ucmm(this, !aligned, false);
__ sldi(tmp1, R5_ARG3, 1);
__ b(l_2);
__ bind(l_1);
Expand Down Expand Up @@ -1625,8 +1625,8 @@ class StubGenerator: public StubCodeGenerator {
address start = __ function_entry();
assert_positive_int(R5_ARG3);
{
// UnsafeMemoryAccess page error: continue at UnsafeMemoryAccess common_error_exit
UnsafeMemoryMark ucmm(this, !aligned, false);
// UnsafeCopyMemory page error: continue at UnsafeCopyMemory common_error_exit
UnsafeCopyMemoryMark ucmm(this, !aligned, false);
generate_disjoint_int_copy_core(aligned);
}
__ li(R3_RET, 0); // return 0
Expand Down Expand Up @@ -1777,8 +1777,8 @@ class StubGenerator: public StubCodeGenerator {

array_overlap_test(nooverlap_target, 2);
{
// UnsafeMemoryAccess page error: continue at UnsafeMemoryAccess common_error_exit
UnsafeMemoryMark ucmm(this, !aligned, false);
// UnsafeCopyMemory page error: continue at UnsafeCopyMemory common_error_exit
UnsafeCopyMemoryMark ucmm(this, !aligned, false);
generate_conjoint_int_copy_core(aligned);
}

Expand Down Expand Up @@ -1903,8 +1903,8 @@ class StubGenerator: public StubCodeGenerator {
address start = __ function_entry();
assert_positive_int(R5_ARG3);
{
// UnsafeMemoryAccess page error: continue at UnsafeMemoryAccess common_error_exit
UnsafeMemoryMark ucmm(this, !aligned, false);
// UnsafeCopyMemory page error: continue at UnsafeCopyMemory common_error_exit
UnsafeCopyMemoryMark ucmm(this, !aligned, false);
generate_disjoint_long_copy_core(aligned);
}
__ li(R3_RET, 0); // return 0
Expand Down Expand Up @@ -2034,8 +2034,8 @@ class StubGenerator: public StubCodeGenerator {

array_overlap_test(nooverlap_target, 3);
{
// UnsafeMemoryAccess page error: continue at UnsafeMemoryAccess common_error_exit
UnsafeMemoryMark ucmm(this, !aligned, false);
// UnsafeCopyMemory page error: continue at UnsafeCopyMemory common_error_exit
UnsafeCopyMemoryMark ucmm(this, !aligned, false);
generate_conjoint_long_copy_core(aligned);
}
__ li(R3_RET, 0); // return 0
Expand Down Expand Up @@ -3129,7 +3129,7 @@ class StubGenerator: public StubCodeGenerator {
// the conjoint stubs use them.

address ucm_common_error_exit = generate_unsafecopy_common_error_exit();
UnsafeMemoryAccess::set_common_exit_stub_pc(ucm_common_error_exit);
UnsafeCopyMemory::set_common_exit_stub_pc(ucm_common_error_exit);

// non-aligned disjoint versions
StubRoutines::_jbyte_disjoint_arraycopy = generate_disjoint_byte_copy(false, "jbyte_disjoint_arraycopy");
Expand Down Expand Up @@ -4745,8 +4745,8 @@ class StubGenerator: public StubCodeGenerator {
StubRoutines::_call_stub_entry = generate_call_stub(StubRoutines::_call_stub_return_address);
StubRoutines::_catch_exception_entry = generate_catch_exception();

if (UnsafeMemoryAccess::_table == nullptr) {
UnsafeMemoryAccess::create_table(18);
if (UnsafeCopyMemory::_table == nullptr) {
UnsafeCopyMemory::create_table(8 + 4); // 8 for copyMemory; 4 for setMemory
}

// Build this early so it's available for the interpreter.
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,9 +1115,9 @@ class StubGenerator: public StubCodeGenerator {
}

{
// UnsafeMemoryAccess page error: continue after ucm
// UnsafeCopyMemory page error: continue after ucm
bool add_entry = !is_oop && (!aligned || sizeof(jlong) == size);
UnsafeMemoryMark ucmm(this, add_entry, true);
UnsafeCopyMemoryMark ucmm(this, add_entry, true);
copy_memory(decorators, is_oop ? T_OBJECT : T_BYTE, aligned, s, d, count, size);
}

Expand Down Expand Up @@ -1191,9 +1191,9 @@ class StubGenerator: public StubCodeGenerator {
}

{
// UnsafeMemoryAccess page error: continue after ucm
// UnsafeCopyMemory page error: continue after ucm
bool add_entry = !is_oop && (!aligned || sizeof(jlong) == size);
UnsafeMemoryMark ucmm(this, add_entry, true);
UnsafeCopyMemoryMark ucmm(this, add_entry, true);
copy_memory(decorators, is_oop ? T_OBJECT : T_BYTE, aligned, s, d, count, -size);
}

Expand Down Expand Up @@ -5479,8 +5479,8 @@ static const int64_t right_3_bits = right_n_bits(3);

StubRoutines::_forward_exception_entry = generate_forward_exception();

if (UnsafeMemoryAccess::_table == nullptr) {
UnsafeMemoryAccess::create_table(18);
if (UnsafeCopyMemory::_table == nullptr) {
UnsafeCopyMemory::create_table(8 + 4); // 8 for copyMemory; 4 for setMemory
}

StubRoutines::_call_stub_entry =
Expand Down
20 changes: 10 additions & 10 deletions src/hotspot/cpu/x86/stubGenerator_x86_32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,8 @@ class StubGenerator: public StubCodeGenerator {
bs->arraycopy_prologue(_masm, decorators, t, from, to, count);
{
bool add_entry = (t != T_OBJECT && (!aligned || t == T_INT));
// UnsafeMemoryAccess page error: continue after ucm
UnsafeMemoryMark ucmm(this, add_entry, true);
// UnsafeCopyMemory page error: continue after ucm
UnsafeCopyMemoryMark ucmm(this, add_entry, true);
__ subptr(to, from); // to --> to_from
__ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element
__ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp
Expand Down Expand Up @@ -1321,8 +1321,8 @@ class StubGenerator: public StubCodeGenerator {

{
bool add_entry = (t != T_OBJECT && (!aligned || t == T_INT));
// UnsafeMemoryAccess page error: continue after ucm
UnsafeMemoryMark ucmm(this, add_entry, true);
// UnsafeCopyMemory page error: continue after ucm
UnsafeCopyMemoryMark ucmm(this, add_entry, true);
// copy from high to low
__ cmpl(count, 2<<shift); // Short arrays (< 8 bytes) copy by element
__ jcc(Assembler::below, L_copy_4_bytes); // use unsigned cmp
Expand Down Expand Up @@ -1450,8 +1450,8 @@ class StubGenerator: public StubCodeGenerator {
BLOCK_COMMENT("Entry:");

{
// UnsafeMemoryAccess page error: continue after ucm
UnsafeMemoryMark ucmm(this, true, true);
// UnsafeCopyMemory page error: continue after ucm
UnsafeCopyMemoryMark ucmm(this, true, true);
__ subptr(to, from); // to --> to_from
if (UseXMMForArrayCopy) {
xmm_copy_forward(from, to_from, count);
Expand Down Expand Up @@ -1505,8 +1505,8 @@ class StubGenerator: public StubCodeGenerator {
__ jump_cc(Assembler::aboveEqual, nooverlap);

{
// UnsafeMemoryAccess page error: continue after ucm
UnsafeMemoryMark ucmm(this, true, true);
// UnsafeCopyMemory page error: continue after ucm
UnsafeCopyMemoryMark ucmm(this, true, true);

__ jmpb(L_copy_8_bytes);

Expand Down Expand Up @@ -4121,8 +4121,8 @@ class StubGenerator: public StubCodeGenerator {
create_control_words();

// Initialize table for copy memory (arraycopy) check.
if (UnsafeMemoryAccess::_table == nullptr) {
UnsafeMemoryAccess::create_table(26);
if (UnsafeCopyMemory::_table == nullptr) {
UnsafeCopyMemory::create_table(16 + 4); // 16 for copyMemory; 4 for setMemory
}

StubRoutines::x86::_verify_mxcsr_entry = generate_verify_mxcsr();
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4009,8 +4009,8 @@ void StubGenerator::generate_initial_stubs() {
create_control_words();

// Initialize table for unsafe copy memeory check.
if (UnsafeMemoryAccess::_table == nullptr) {
UnsafeMemoryAccess::create_table(26);
if (UnsafeCopyMemory::_table == nullptr) {
UnsafeCopyMemory::create_table(16 + 4); // 16 for copyMemory; 4 for setMemory
}

// entry points that exist in all platforms Note: This is code
Expand Down
Loading