Skip to content

Commit

Permalink
Merge branch 'master' into 8332689
Browse files Browse the repository at this point in the history
  • Loading branch information
robehn committed Jun 26, 2024
2 parents ea57c42 + 25c3845 commit 78a240a
Show file tree
Hide file tree
Showing 106 changed files with 1,659 additions and 810 deletions.
15 changes: 8 additions & 7 deletions make/GenerateLinkOptData.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ ifeq ($(EXTERNAL_BUILDJDK), true)
INTERIM_IMAGE_DIR := $(BUILD_JDK)
endif

# These are needed for deterministic classlist:
# To make the classlist deterministic:
# - The classlist can be influenced by locale. Always set it to en/US.
# - Run with -Xint, as the compiler can speculatively resolve constant pool entries.
# - ForkJoinPool parallelism can cause constant pool resolution to be non-deterministic.
# - Concurrency in the core libraries can cause constant pool resolution
# to be non-deterministic. Since the benefits of resolved CP references in the
# default classlist is minimal, let's filter out the '@cp' lines until we can
# find a proper solution.
CLASSLIST_FILE_VM_OPTS = \
-Duser.language=en -Duser.country=US \
-Xint \
-Djava.util.concurrent.ForkJoinPool.common.parallelism=0
-Duser.language=en -Duser.country=US

# Save the stderr output of the command and print it along with stdout in case
# something goes wrong.
Expand Down Expand Up @@ -101,9 +101,10 @@ $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXECUTABLE_SUFFIX) $(CLASSLIST
exit $$exitcode \
)
$(GREP) -v HelloClasslist [email protected] > [email protected]
$(GREP) -v @cp [email protected] > [email protected]
$(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java \
-cp $(SUPPORT_OUTPUTDIR)/classlist.jar \
build.tools.classlist.SortClasslist [email protected].3 > $@
build.tools.classlist.SortClasslist [email protected].4 > $@

# The jli trace is created by the same recipe as classlist. By declaring these
# dependencies, make will correctly rebuild both jli trace and classlist
Expand Down
10 changes: 2 additions & 8 deletions make/jdk/src/classes/build/tools/intpoly/FieldGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ private String generate(FieldParams params) throws IOException {
result.appendLine("}");

result.appendLine("@Override");
result.appendLine("protected int mult(long[] a, long[] b, long[] r) {");
result.appendLine("protected void mult(long[] a, long[] b, long[] r) {");
result.incrIndent();
for (int i = 0; i < 2 * params.getNumLimbs() - 1; i++) {
result.appendIndent();
Expand All @@ -804,9 +804,6 @@ private String generate(FieldParams params) throws IOException {
}
}
result.append(");\n");
result.appendIndent();
result.append("return 0;");
result.appendLine();
result.decrIndent();
result.appendLine("}");

Expand Down Expand Up @@ -836,7 +833,7 @@ private String generate(FieldParams params) throws IOException {
// }
// }
result.appendLine("@Override");
result.appendLine("protected int square(long[] a, long[] r) {");
result.appendLine("protected void square(long[] a, long[] r) {");
result.incrIndent();
for (int i = 0; i < 2 * params.getNumLimbs() - 1; i++) {
result.appendIndent();
Expand Down Expand Up @@ -877,9 +874,6 @@ private String generate(FieldParams params) throws IOException {
}
}
result.append(");\n");
result.appendIndent();
result.append("return 0;");
result.appendLine();
result.decrIndent();
result.appendLine("}");

Expand Down
31 changes: 2 additions & 29 deletions src/hotspot/cpu/riscv/riscv.ad
Original file line number Diff line number Diff line change
Expand Up @@ -1926,6 +1926,8 @@ bool Matcher::match_rule_supported(int opcode) {

case Op_ReverseBytesI:
case Op_ReverseBytesL:
case Op_ReverseBytesS:
case Op_ReverseBytesUS:
case Op_RotateRight:
case Op_RotateLeft:
case Op_CountLeadingZerosI:
Expand Down Expand Up @@ -7880,35 +7882,6 @@ instruct xorL_reg_imm(iRegLNoSp dst, iRegL src1, immLAdd src2) %{
ins_pipe(ialu_reg_imm);
%}

// ============================================================================
// BSWAP Instructions

instruct bytes_reverse_unsigned_short(iRegINoSp dst, iRegIorL2I src) %{
match(Set dst (ReverseBytesUS src));

ins_cost(ALU_COST * 5);
format %{ "revb_h_h_u $dst, $src\t#@bytes_reverse_unsigned_short" %}

ins_encode %{
__ revb_h_h_u(as_Register($dst$$reg), as_Register($src$$reg));
%}

ins_pipe(pipe_class_default);
%}

instruct bytes_reverse_short(iRegINoSp dst, iRegIorL2I src) %{
match(Set dst (ReverseBytesS src));

ins_cost(ALU_COST * 5);
format %{ "revb_h_h $dst, $src\t#@bytes_reverse_short" %}

ins_encode %{
__ revb_h_h(as_Register($dst$$reg), as_Register($src$$reg));
%}

ins_pipe(pipe_class_default);
%}

// ============================================================================
// MemBar Instruction

Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/cpu/riscv/riscv_b.ad
Original file line number Diff line number Diff line change
Expand Up @@ -206,27 +206,27 @@ instruct bytes_reverse_long_b(iRegLNoSp dst, iRegL src) %{
%}

instruct bytes_reverse_unsigned_short_b(iRegINoSp dst, iRegIorL2I src) %{
predicate(UseZbb);
match(Set dst (ReverseBytesUS src));

ins_cost(ALU_COST * 2);
format %{ "revb_h_h_u $dst, $src\t#@bytes_reverse_unsigned_short_b" %}

ins_encode %{
assert(UseZbb, "must be");
__ revb_h_h_u(as_Register($dst$$reg), as_Register($src$$reg));
%}

ins_pipe(ialu_reg);
%}

instruct bytes_reverse_short_b(iRegINoSp dst, iRegIorL2I src) %{
predicate(UseZbb);
match(Set dst (ReverseBytesS src));

ins_cost(ALU_COST * 2);
format %{ "revb_h_h $dst, $src\t#@bytes_reverse_short_b" %}

ins_encode %{
assert(UseZbb, "must be");
__ revb_h_h(as_Register($dst$$reg), as_Register($src$$reg));
%}

Expand Down
12 changes: 4 additions & 8 deletions src/hotspot/cpu/riscv/vm_version_riscv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,11 @@ void VM_Version::c2_initialize() {
FLAG_SET_DEFAULT(MaxVectorSize, 0);
FLAG_SET_DEFAULT(UseRVVForBigIntegerShiftIntrinsics, false);
} else {
if (FLAG_IS_DEFAULT(MaxVectorSize)) {
MaxVectorSize = _initial_vector_length;
} else if (!is_power_of_2(MaxVectorSize)) {
vm_exit_during_initialization(err_msg("Unsupported MaxVectorSize: %d, must be a power of 2", (int)MaxVectorSize));
} else if (MaxVectorSize > _initial_vector_length) {
warning("Current system only supports max RVV vector length %d. Set MaxVectorSize to %d",
_initial_vector_length, _initial_vector_length);
MaxVectorSize = _initial_vector_length;
if (!FLAG_IS_DEFAULT(MaxVectorSize) && MaxVectorSize != _initial_vector_length) {
warning("Current system does not support RVV vector length for MaxVectorSize %d. Set MaxVectorSize to %d",
(int)MaxVectorSize, _initial_vector_length);
}
MaxVectorSize = _initial_vector_length;
if (MaxVectorSize < 16) {
warning("RVV does not support vector length less than 16 bytes. Disabling RVV.");
UseRVV = false;
Expand Down
1 change: 0 additions & 1 deletion src/hotspot/cpu/x86/stubGenerator_x86_64_poly_mont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ address StubGenerator::generate_intpoly_montgomeryMult_P256() {
const Register tmp = r9;

montgomeryMultiply(aLimbs, bLimbs, rLimbs, tmp, _masm);
__ mov64(rax, 0x1); // Return 1 (Fig. 5, Step 6 [1] skipped in montgomeryMultiply)

__ leave();
__ ret(0);
Expand Down
75 changes: 0 additions & 75 deletions src/hotspot/os/linux/os_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3525,81 +3525,6 @@ static address get_stack_commited_bottom(address bottom, size_t size) {
return nbot;
}

bool os::committed_in_range(address start, size_t size, address& committed_start, size_t& committed_size) {
int mincore_return_value;
const size_t stripe = 1024; // query this many pages each time
unsigned char vec[stripe + 1];
// set a guard
vec[stripe] = 'X';

const size_t page_sz = os::vm_page_size();
uintx pages = size / page_sz;

assert(is_aligned(start, page_sz), "Start address must be page aligned");
assert(is_aligned(size, page_sz), "Size must be page aligned");

committed_start = nullptr;

int loops = checked_cast<int>((pages + stripe - 1) / stripe);
int committed_pages = 0;
address loop_base = start;
bool found_range = false;

for (int index = 0; index < loops && !found_range; index ++) {
assert(pages > 0, "Nothing to do");
uintx pages_to_query = (pages >= stripe) ? stripe : pages;
pages -= pages_to_query;

// Get stable read
while ((mincore_return_value = mincore(loop_base, pages_to_query * page_sz, vec)) == -1 && errno == EAGAIN);

// During shutdown, some memory goes away without properly notifying NMT,
// E.g. ConcurrentGCThread/WatcherThread can exit without deleting thread object.
// Bailout and return as not committed for now.
if (mincore_return_value == -1 && errno == ENOMEM) {
return false;
}

// If mincore is not supported.
if (mincore_return_value == -1 && errno == ENOSYS) {
return false;
}

assert(vec[stripe] == 'X', "overflow guard");
assert(mincore_return_value == 0, "Range must be valid");
// Process this stripe
for (uintx vecIdx = 0; vecIdx < pages_to_query; vecIdx ++) {
if ((vec[vecIdx] & 0x01) == 0) { // not committed
// End of current contiguous region
if (committed_start != nullptr) {
found_range = true;
break;
}
} else { // committed
// Start of region
if (committed_start == nullptr) {
committed_start = loop_base + page_sz * vecIdx;
}
committed_pages ++;
}
}

loop_base += pages_to_query * page_sz;
}

if (committed_start != nullptr) {
assert(committed_pages > 0, "Must have committed region");
assert(committed_pages <= int(size / page_sz), "Can not commit more than it has");
assert(committed_start >= start && committed_start < start + size, "Out of range");
committed_size = page_sz * committed_pages;
return true;
} else {
assert(committed_pages == 0, "Should not have committed region");
return false;
}
}


// Linux uses a growable mapping for the stack, and if the mapping for
// the stack guard pages is not removed when we detach a thread the
// stack cannot grow beyond the pages where the stack guard was
Expand Down
91 changes: 91 additions & 0 deletions src/hotspot/os/posix/os_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
#define MAP_ANONYMOUS MAP_ANON
#endif

/* Input/Output types for mincore(2) */
typedef LINUX_ONLY(unsigned) char mincore_vec_t;

static jlong initial_time_count = 0;

static int clock_tics_per_sec = 100;
Expand Down Expand Up @@ -146,6 +149,94 @@ void os::check_dump_limit(char* buffer, size_t bufferSize) {
VMError::record_coredump_status(buffer, success);
}

bool os::committed_in_range(address start, size_t size, address& committed_start, size_t& committed_size) {

#ifdef _AIX
committed_start = start;
committed_size = size;
return true;
#else

int mincore_return_value;
constexpr size_t stripe = 1024; // query this many pages each time
mincore_vec_t vec [stripe + 1];

// set a guard
DEBUG_ONLY(vec[stripe] = 'X');

size_t page_sz = os::vm_page_size();
uintx pages = size / page_sz;

assert(is_aligned(start, page_sz), "Start address must be page aligned");
assert(is_aligned(size, page_sz), "Size must be page aligned");

committed_start = nullptr;

int loops = checked_cast<int>((pages + stripe - 1) / stripe);
int committed_pages = 0;
address loop_base = start;
bool found_range = false;

for (int index = 0; index < loops && !found_range; index ++) {
assert(pages > 0, "Nothing to do");
uintx pages_to_query = (pages >= stripe) ? stripe : pages;
pages -= pages_to_query;

// Get stable read
int fail_count = 0;
while ((mincore_return_value = mincore(loop_base, pages_to_query * page_sz, vec)) == -1 && errno == EAGAIN){
if (++fail_count == 1000){
return false;
}
}

// During shutdown, some memory goes away without properly notifying NMT,
// E.g. ConcurrentGCThread/WatcherThread can exit without deleting thread object.
// Bailout and return as not committed for now.
if (mincore_return_value == -1 && errno == ENOMEM) {
return false;
}

// If mincore is not supported.
if (mincore_return_value == -1 && errno == ENOSYS) {
return false;
}

assert(vec[stripe] == 'X', "overflow guard");
assert(mincore_return_value == 0, "Range must be valid");
// Process this stripe
for (uintx vecIdx = 0; vecIdx < pages_to_query; vecIdx ++) {
if ((vec[vecIdx] & 0x01) == 0) { // not committed
// End of current contiguous region
if (committed_start != nullptr) {
found_range = true;
break;
}
} else { // committed
// Start of region
if (committed_start == nullptr) {
committed_start = loop_base + page_sz * vecIdx;
}
committed_pages ++;
}
}

loop_base += pages_to_query * page_sz;
}

if (committed_start != nullptr) {
assert(committed_pages > 0, "Must have committed region");
assert(committed_pages <= int(size / page_sz), "Can not commit more than it has");
assert(committed_start >= start && committed_start < start + size, "Out of range");
committed_size = page_sz * committed_pages;
return true;
} else {
assert(committed_pages == 0, "Should not have committed region");
return false;
}
#endif
}

int os::get_native_stack(address* stack, int frames, int toSkip) {
int frame_idx = 0;
int num_of_frames; // number of frames captured
Expand Down
7 changes: 0 additions & 7 deletions src/hotspot/share/cds/archiveBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1412,10 +1412,3 @@ void ArchiveBuilder::report_out_of_space(const char* name, size_t needed_bytes)
log_error(cds)("Unable to allocate from '%s' region: Please reduce the number of shared classes.", name);
MetaspaceShared::unrecoverable_writing_error();
}


#ifndef PRODUCT
void ArchiveBuilder::assert_is_vm_thread() {
assert(Thread::current()->is_VM_thread(), "ArchiveBuilder should be used only inside the VMThread");
}
#endif
3 changes: 0 additions & 3 deletions src/hotspot/share/cds/archiveBuilder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,6 @@ class ArchiveBuilder : public StackObj {
return to_offset_u4(offset);
}

static void assert_is_vm_thread() PRODUCT_RETURN;

public:
ArchiveBuilder();
~ArchiveBuilder();
Expand Down Expand Up @@ -432,7 +430,6 @@ class ArchiveBuilder : public StackObj {
}

static ArchiveBuilder* current() {
assert_is_vm_thread();
assert(_current != nullptr, "ArchiveBuilder must be active");
return _current;
}
Expand Down
Loading

0 comments on commit 78a240a

Please sign in to comment.