Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8379,7 +8379,7 @@ class StubGenerator: public StubCodeGenerator {

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

if (UseCRC32Intrinsics) {
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/arm/stubGenerator_arm.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -3135,7 +3135,7 @@ class StubGenerator: public StubCodeGenerator {
StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError));

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

// integer division used both by interpreter and compiler
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/ppc/stubGenerator_ppc.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2023 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand Down Expand Up @@ -4746,7 +4746,7 @@ class StubGenerator: public StubCodeGenerator {
StubRoutines::_catch_exception_entry = generate_catch_exception();

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

// Build this early so it's available for the interpreter.
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/riscv/stubGenerator_riscv.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved.
* Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
Expand Down Expand Up @@ -5501,7 +5501,7 @@ static const int64_t right_3_bits = right_n_bits(3);
StubRoutines::_forward_exception_entry = generate_forward_exception();

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

StubRoutines::_call_stub_entry =
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/cpu/x86/assembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ address Assembler::locate_operand(address inst, WhichOperand which) {
case 0x6F: // movdq
case 0x7F: // movdq
case 0xAE: // ldmxcsr, stmxcsr, fxrstor, fxsave, clflush
case 0xD6: // movq
case 0xFE: // paddd
debug_only(has_disp32 = true);
break;
Expand Down
36 changes: 18 additions & 18 deletions src/hotspot/cpu/x86/macroAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6299,7 +6299,7 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned,
orl(value, rtmp);
}

cmpl(count, 2<<shift); // Short arrays (< 8 bytes) fill by element
cmpptr(count, 2<<shift); // Short arrays (< 8 bytes) fill by element
jcc(Assembler::below, L_fill_4_bytes); // use unsigned cmp
if (!UseUnalignedLoadStores && !aligned && (t == T_BYTE || t == T_SHORT)) {
Label L_skip_align2;
Expand All @@ -6319,13 +6319,13 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned,
jccb(Assembler::zero, L_skip_align2);
movw(Address(to, 0), value);
addptr(to, 2);
subl(count, 1<<(shift-1));
subptr(count, 1<<(shift-1));
BIND(L_skip_align2);
}
if (UseSSE < 2) {
Label L_fill_32_bytes_loop, L_check_fill_8_bytes, L_fill_8_bytes_loop, L_fill_8_bytes;
// Fill 32-byte chunks
subl(count, 8 << shift);
subptr(count, 8 << shift);
jcc(Assembler::less, L_check_fill_8_bytes);
align(16);

Expand All @@ -6336,10 +6336,10 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned,
}

addptr(to, 32);
subl(count, 8 << shift);
subptr(count, 8 << shift);
jcc(Assembler::greaterEqual, L_fill_32_bytes_loop);
BIND(L_check_fill_8_bytes);
addl(count, 8 << shift);
addptr(count, 8 << shift);
jccb(Assembler::zero, L_exit);
jmpb(L_fill_8_bytes);

Expand All @@ -6351,7 +6351,7 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned,
movl(Address(to, 4), value);
addptr(to, 8);
BIND(L_fill_8_bytes);
subl(count, 1 << (shift + 1));
subptr(count, 1 << (shift + 1));
jcc(Assembler::greaterEqual, L_fill_8_bytes_loop);
// fall through to fill 4 bytes
} else {
Expand All @@ -6362,7 +6362,7 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned,
jccb(Assembler::zero, L_fill_32_bytes);
movl(Address(to, 0), value);
addptr(to, 4);
subl(count, 1<<shift);
subptr(count, 1<<shift);
}
BIND(L_fill_32_bytes);
{
Expand All @@ -6376,19 +6376,19 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned,
Label L_fill_64_bytes_loop_avx3, L_check_fill_64_bytes_avx2;

// If number of bytes to fill < VM_Version::avx3_threshold(), perform fill using AVX2
cmpl(count, VM_Version::avx3_threshold());
cmpptr(count, VM_Version::avx3_threshold());
jccb(Assembler::below, L_check_fill_64_bytes_avx2);

vpbroadcastd(xtmp, xtmp, Assembler::AVX_512bit);

subl(count, 16 << shift);
subptr(count, 16 << shift);
jccb(Assembler::less, L_check_fill_32_bytes);
align(16);

BIND(L_fill_64_bytes_loop_avx3);
evmovdqul(Address(to, 0), xtmp, Assembler::AVX_512bit);
addptr(to, 64);
subl(count, 16 << shift);
subptr(count, 16 << shift);
jcc(Assembler::greaterEqual, L_fill_64_bytes_loop_avx3);
jmpb(L_check_fill_32_bytes);

Expand All @@ -6398,23 +6398,23 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned,
Label L_fill_64_bytes_loop;
vpbroadcastd(xtmp, xtmp, Assembler::AVX_256bit);

subl(count, 16 << shift);
subptr(count, 16 << shift);
jcc(Assembler::less, L_check_fill_32_bytes);
align(16);

BIND(L_fill_64_bytes_loop);
vmovdqu(Address(to, 0), xtmp);
vmovdqu(Address(to, 32), xtmp);
addptr(to, 64);
subl(count, 16 << shift);
subptr(count, 16 << shift);
jcc(Assembler::greaterEqual, L_fill_64_bytes_loop);

BIND(L_check_fill_32_bytes);
addl(count, 8 << shift);
addptr(count, 8 << shift);
jccb(Assembler::less, L_check_fill_8_bytes);
vmovdqu(Address(to, 0), xtmp);
addptr(to, 32);
subl(count, 8 << shift);
subptr(count, 8 << shift);

BIND(L_check_fill_8_bytes);
// clean upper bits of YMM registers
Expand All @@ -6424,7 +6424,7 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned,
// Fill 32-byte chunks
pshufd(xtmp, xtmp, 0);

subl(count, 8 << shift);
subptr(count, 8 << shift);
jcc(Assembler::less, L_check_fill_8_bytes);
align(16);

Expand All @@ -6441,12 +6441,12 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned,
}

addptr(to, 32);
subl(count, 8 << shift);
subptr(count, 8 << shift);
jcc(Assembler::greaterEqual, L_fill_32_bytes_loop);

BIND(L_check_fill_8_bytes);
}
addl(count, 8 << shift);
addptr(count, 8 << shift);
jccb(Assembler::zero, L_exit);
jmpb(L_fill_8_bytes);

Expand All @@ -6457,7 +6457,7 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned,
movq(Address(to, 0), xtmp);
addptr(to, 8);
BIND(L_fill_8_bytes);
subl(count, 1 << (shift + 1));
subptr(count, 1 << (shift + 1));
jcc(Assembler::greaterEqual, L_fill_8_bytes_loop);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/x86/stubGenerator_x86_32.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -4122,7 +4122,7 @@ class StubGenerator: public StubCodeGenerator {

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

StubRoutines::x86::_verify_mxcsr_entry = generate_verify_mxcsr();
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4058,7 +4058,7 @@ void StubGenerator::generate_initial_stubs() {

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

// entry points that exist in all platforms Note: This is code
Expand Down
8 changes: 8 additions & 0 deletions src/hotspot/cpu/x86/stubGenerator_x86_64.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,14 @@ class StubGenerator: public StubCodeGenerator {
address byte_copy_entry, address short_copy_entry,
address int_copy_entry, address long_copy_entry);

// Generate 'unsafe' set memory stub
// Though just as safe as the other stubs, it takes an unscaled
// size_t argument instead of an element count.
//
// Examines the alignment of the operands and dispatches
// to an int, short, or byte copy loop.
address generate_unsafe_setmemory(const char *name, address byte_copy_entry);

// Perform range checks on the proposed arraycopy.
// Kills temp, but nothing else.
// Also, clean the sign bits of src_pos and dst_pos.
Expand Down
Loading