Skip to content

Commit 6739b41

Browse files
author
Datadog Syncup Service
committed
Merge branch 'upstream-master'
2 parents 4be8d2f + 1f0efc0 commit 6739b41

File tree

107 files changed

+560
-509
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+560
-509
lines changed

make/test/BuildTestLib.gmk

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -64,7 +64,6 @@ $(eval $(call SetupJavaCompilation, BUILD_TEST_LIB_JAR, \
6464
BIN := $(TEST_LIB_SUPPORT)/test-lib_classes, \
6565
HEADERS := $(TEST_LIB_SUPPORT)/test-lib_headers, \
6666
JAR := $(TEST_LIB_SUPPORT)/test-lib.jar, \
67-
DISABLED_WARNINGS := try deprecation rawtypes unchecked serial cast removal preview restricted dangling-doc-comments, \
6867
JAVAC_FLAGS := --add-exports java.base/sun.security.util=ALL-UNNAMED \
6968
--add-exports java.base/jdk.internal.classfile=ALL-UNNAMED \
7069
--add-exports java.base/jdk.internal.classfile.attribute=ALL-UNNAMED \

src/hotspot/cpu/riscv/assembler_riscv.hpp

Lines changed: 51 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3070,42 +3070,63 @@ enum Nf {
30703070
#undef INSN
30713071

30723072
// Cache Management Operations
3073-
#define INSN(NAME, funct) \
3074-
void NAME(Register Rs1) { \
3075-
unsigned insn = 0; \
3076-
patch((address)&insn, 6, 0, 0b0001111); \
3077-
patch((address)&insn, 14, 12, 0b010); \
3078-
patch_reg((address)&insn, 15, Rs1); \
3079-
patch((address)&insn, 31, 20, funct); \
3080-
emit(insn); \
3073+
// These instruction may be turned off for user space.
3074+
private:
3075+
enum CBO_FUNCT : unsigned int {
3076+
CBO_INVAL = 0b0000000000000,
3077+
CBO_CLEAN = 0b0000000000001,
3078+
CBO_FLUSH = 0b0000000000010,
3079+
CBO_ZERO = 0b0000000000100
3080+
};
3081+
3082+
template <CBO_FUNCT FUNCT>
3083+
void cbo_base(Register Rs1) {
3084+
assert((UseZicbom && FUNCT != CBO_ZERO) || UseZicboz, "sanity");
3085+
unsigned insn = 0;
3086+
patch((address)&insn, 6, 0, 0b0001111);
3087+
patch((address)&insn, 14, 12, 0b010);
3088+
patch_reg((address)&insn, 15, Rs1);
3089+
patch((address)&insn, 31, 20, FUNCT);
3090+
emit(insn);
30813091
}
30823092

3083-
INSN(cbo_inval, 0b0000000000000);
3084-
INSN(cbo_clean, 0b0000000000001);
3085-
INSN(cbo_flush, 0b0000000000010);
3086-
INSN(cbo_zero, 0b0000000000100);
3093+
// This instruction have some security implication.
3094+
// At this time it's not likely to be enabled for user mode.
3095+
void cbo_inval(Register Rs1) { cbo_base<CBO_INVAL>(Rs1); }
3096+
public:
3097+
// Zicbom
3098+
void cbo_clean(Register Rs1) { cbo_base<CBO_CLEAN>(Rs1); }
3099+
void cbo_flush(Register Rs1) { cbo_base<CBO_FLUSH>(Rs1); }
3100+
// Zicboz
3101+
void cbo_zero(Register Rs1) { cbo_base<CBO_ZERO>(Rs1); }
30873102

3088-
#undef INSN
3103+
private:
3104+
enum PREFETCH_FUNCT : unsigned int {
3105+
PREFETCH_I = 0b0000000000000,
3106+
PREFETCH_R = 0b0000000000001,
3107+
PREFETCH_W = 0b0000000000011
3108+
};
30893109

3090-
#define INSN(NAME, funct) \
3091-
void NAME(Register Rs1, int32_t offset) { \
3092-
guarantee((offset & 0x1f) == 0, "offset lowest 5 bits must be zero"); \
3093-
int32_t upperOffset = offset >> 5; \
3094-
unsigned insn = 0; \
3095-
patch((address)&insn, 6, 0, 0b0010011); \
3096-
patch((address)&insn, 14, 12, 0b110); \
3097-
patch_reg((address)&insn, 15, Rs1); \
3098-
patch((address)&insn, 24, 20, funct); \
3099-
upperOffset &= 0x7f; \
3100-
patch((address)&insn, 31, 25, upperOffset); \
3101-
emit(insn); \
3110+
template <PREFETCH_FUNCT FUNCT>
3111+
void prefetch_base(Register Rs1, int32_t offset) {
3112+
assert_cond(UseZicbop);
3113+
guarantee((offset & 0x1f) == 0, "offset lowest 5 bits must be zero");
3114+
int32_t upperOffset = offset >> 5;
3115+
unsigned insn = 0;
3116+
patch((address)&insn, 6, 0, 0b0010011);
3117+
patch((address)&insn, 14, 12, 0b110);
3118+
patch_reg((address)&insn, 15, Rs1);
3119+
patch((address)&insn, 24, 20, FUNCT);
3120+
upperOffset &= 0x7f;
3121+
patch((address)&insn, 31, 25, upperOffset);
3122+
emit(insn);
31023123
}
31033124

3104-
INSN(prefetch_i, 0b0000000000000);
3105-
INSN(prefetch_r, 0b0000000000001);
3106-
INSN(prefetch_w, 0b0000000000011);
3107-
3108-
#undef INSN
3125+
public:
3126+
// Zicbop
3127+
void prefetch_i(Register Rs1, int32_t offset) { prefetch_base<PREFETCH_I>(Rs1, offset); }
3128+
void prefetch_r(Register Rs1, int32_t offset) { prefetch_base<PREFETCH_R>(Rs1, offset); }
3129+
void prefetch_w(Register Rs1, int32_t offset) { prefetch_base<PREFETCH_W>(Rs1, offset); }
31093130

31103131
// -------------- Zicond Instruction Definitions --------------
31113132
// Zicond conditional operations extension

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,22 +1333,11 @@ void MacroAssembler::cmov_gtu(Register cmp1, Register cmp2, Register dst, Regist
13331333

13341334
#undef INSN
13351335

1336-
1337-
#define INSN(NAME, CSR) \
1338-
void MacroAssembler::NAME(Register Rd) { \
1339-
csrr(Rd, CSR); \
1340-
}
1341-
1342-
INSN(rdinstret, CSR_INSTRET);
1343-
INSN(rdcycle, CSR_CYCLE);
1344-
INSN(rdtime, CSR_TIME);
1345-
INSN(frcsr, CSR_FCSR);
1346-
INSN(frrm, CSR_FRM);
1347-
INSN(frflags, CSR_FFLAGS);
1348-
1349-
#undef INSN
1350-
13511336
void MacroAssembler::csrr(Register Rd, unsigned csr) {
1337+
// These three are specified in zicntr and are unused.
1338+
// Before adding use-cases add the appropriate hwprobe and flag.
1339+
assert(csr != CSR_INSTRET && csr != CSR_CYCLE && csr != CSR_TIME,
1340+
"Not intended for use without enabling zicntr.");
13521341
csrrs(Rd, csr, x0);
13531342
}
13541343

src/hotspot/cpu/riscv/macroAssembler_riscv.hpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -626,29 +626,30 @@ class MacroAssembler: public Assembler {
626626
}
627627

628628
// Control and status pseudo instructions
629-
void rdinstret(Register Rd); // read instruction-retired counter
630-
void rdcycle(Register Rd); // read cycle counter
631-
void rdtime(Register Rd); // read time
632629
void csrr(Register Rd, unsigned csr); // read csr
633630
void csrw(unsigned csr, Register Rs); // write csr
634631
void csrs(unsigned csr, Register Rs); // set bits in csr
635632
void csrc(unsigned csr, Register Rs); // clear bits in csr
636633
void csrwi(unsigned csr, unsigned imm);
637634
void csrsi(unsigned csr, unsigned imm);
638635
void csrci(unsigned csr, unsigned imm);
639-
void frcsr(Register Rd); // read float-point csr
640-
void fscsr(Register Rd, Register Rs); // swap float-point csr
641-
void fscsr(Register Rs); // write float-point csr
642-
void frrm(Register Rd); // read float-point rounding mode
643-
void fsrm(Register Rd, Register Rs); // swap float-point rounding mode
644-
void fsrm(Register Rs); // write float-point rounding mode
636+
void frcsr(Register Rd) { csrr(Rd, CSR_FCSR); }; // read float-point csr
637+
void fscsr(Register Rd, Register Rs); // swap float-point csr
638+
void fscsr(Register Rs); // write float-point csr
639+
void frrm(Register Rd) { csrr(Rd, CSR_FRM); }; // read float-point rounding mode
640+
void fsrm(Register Rd, Register Rs); // swap float-point rounding mode
641+
void fsrm(Register Rs); // write float-point rounding mode
645642
void fsrmi(Register Rd, unsigned imm);
646643
void fsrmi(unsigned imm);
647-
void frflags(Register Rd); // read float-point exception flags
648-
void fsflags(Register Rd, Register Rs); // swap float-point exception flags
649-
void fsflags(Register Rs); // write float-point exception flags
644+
void frflags(Register Rd) { csrr(Rd, CSR_FFLAGS); }; // read float-point exception flags
645+
void fsflags(Register Rd, Register Rs); // swap float-point exception flags
646+
void fsflags(Register Rs); // write float-point exception flags
650647
void fsflagsi(Register Rd, unsigned imm);
651648
void fsflagsi(unsigned imm);
649+
// Requires Zicntr
650+
void rdinstret(Register Rd) { csrr(Rd, CSR_INSTRET); }; // read instruction-retired counter
651+
void rdcycle(Register Rd) { csrr(Rd, CSR_CYCLE); }; // read cycle counter
652+
void rdtime(Register Rd) { csrr(Rd, CSR_TIME); }; // read time
652653

653654
// Restore cpu control state after JNI call
654655
void restore_cpu_control_state_after_jni(Register tmp);

src/hotspot/cpu/riscv/vm_version_riscv.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class VM_Version : public Abstract_VM_Version {
158158
decl(ext_Zcb , "Zcb" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZcb)) \
159159
decl(ext_Zfh , "Zfh" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZfh)) \
160160
decl(ext_Zicsr , "Zicsr" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \
161+
decl(ext_Zicntr , "Zicntr" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \
161162
decl(ext_Zifencei , "Zifencei" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \
162163
decl(ext_Zic64b , "Zic64b" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZic64b)) \
163164
decl(ext_Ztso , "Ztso" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZtso)) \

src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,7 +3020,7 @@ SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address cal
30203020

30213021
// Allocate space for the code. Setup code generation tools.
30223022
const char* name = SharedRuntime::stub_name(id);
3023-
CodeBuffer buffer(name, 2348, 1024);
3023+
CodeBuffer buffer(name, 2548, 1024);
30243024
MacroAssembler* masm = new MacroAssembler(&buffer);
30253025

30263026
address start = __ pc();
@@ -3086,11 +3086,11 @@ SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address cal
30863086
Label bail;
30873087
#endif
30883088
if (!cause_return) {
3089-
Label no_prefix, not_special;
3089+
Label no_prefix, not_special, check_rex_prefix;
30903090

30913091
// If our stashed return pc was modified by the runtime we avoid touching it
30923092
__ cmpptr(rbx, Address(rbp, wordSize));
3093-
__ jccb(Assembler::notEqual, no_adjust);
3093+
__ jcc(Assembler::notEqual, no_adjust);
30943094

30953095
// Skip over the poll instruction.
30963096
// See NativeInstruction::is_safepoint_poll()
@@ -3113,9 +3113,29 @@ SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address cal
31133113
// 41 85 04 24 test %eax,(%r12)
31143114
// 85 45 00 test %eax,0x0(%rbp)
31153115
// 41 85 45 00 test %eax,0x0(%r13)
3116-
3116+
//
3117+
// Notes:
3118+
// Format of legacy MAP0 test instruction:-
3119+
// [REX/REX2] [OPCODE] [ModRM] [SIB] [DISP] [IMM32]
3120+
// o For safepoint polling instruction "test %eax,(%rax)", encoding of first register
3121+
// operand and base register of memory operand is b/w [0-8), hence we do not require
3122+
// additional REX prefix where REX.B bit stores MSB bit of register encoding, which
3123+
// is why two bytes encoding is sufficient here.
3124+
// o For safepoint polling instruction like "test %eax,(%r8)", register encoding of BASE
3125+
// register of memory operand is 1000, thus we need additional REX prefix in this case,
3126+
// there by adding additional byte to instruction encoding.
3127+
// o In case BASE register is one of the 32 extended GPR registers available only on targets
3128+
// supporting Intel APX extension, then we need to emit two bytes REX2 prefix to hold
3129+
// most significant two bits of 5 bit register encoding.
3130+
3131+
if (VM_Version::supports_apx_f()) {
3132+
__ cmpb(Address(rbx, 0), Assembler::REX2);
3133+
__ jccb(Assembler::notEqual, check_rex_prefix);
3134+
__ addptr(rbx, 2);
3135+
__ bind(check_rex_prefix);
3136+
}
31173137
__ cmpb(Address(rbx, 0), NativeTstRegMem::instruction_rex_b_prefix);
3118-
__ jcc(Assembler::notEqual, no_prefix);
3138+
__ jccb(Assembler::notEqual, no_prefix);
31193139
__ addptr(rbx, 1);
31203140
__ bind(no_prefix);
31213141
#ifdef ASSERT
@@ -3128,7 +3148,7 @@ SafepointBlob* SharedRuntime::generate_handler_blob(SharedStubId id, address cal
31283148
__ andptr(rcx, 0x07); // looking for 0x04 .. 0x05
31293149
__ subptr(rcx, 4); // looking for 0x00 .. 0x01
31303150
__ cmpptr(rcx, 1);
3131-
__ jcc(Assembler::above, not_special);
3151+
__ jccb(Assembler::above, not_special);
31323152
__ addptr(rbx, 1);
31333153
__ bind(not_special);
31343154
#ifdef ASSERT

src/hotspot/share/cds/aotLinkedClassBulkLoader.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -89,7 +89,7 @@ void AOTLinkedClassBulkLoader::exit_on_exception(JavaThread* current) {
8989
ResourceMark rm(current);
9090
if (current->pending_exception()->is_a(vmClasses::OutOfMemoryError_klass())) {
9191
log_error(cds)("Out of memory. Please run with a larger Java heap, current MaxHeapSize = "
92-
SIZE_FORMAT "M", MaxHeapSize/M);
92+
"%zuM", MaxHeapSize/M);
9393
} else {
9494
log_error(cds)("%s: %s", current->pending_exception()->klass()->external_name(),
9595
java_lang_String::as_utf8_string(java_lang_Throwable::message(current->pending_exception())));

src/hotspot/share/cds/archiveBuilder.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,14 @@ address ArchiveBuilder::reserve_buffer() {
312312
MetaspaceShared::core_region_alignment(),
313313
os::vm_page_size());
314314
if (!rs.is_reserved()) {
315-
log_error(cds)("Failed to reserve " SIZE_FORMAT " bytes of output buffer.", buffer_size);
315+
log_error(cds)("Failed to reserve %zu bytes of output buffer.", buffer_size);
316316
MetaspaceShared::unrecoverable_writing_error();
317317
}
318318

319319
// buffer_bottom is the lowest address of the 2 core regions (rw, ro) when
320320
// we are copying the class metadata into the buffer.
321321
address buffer_bottom = (address)rs.base();
322-
log_info(cds)("Reserved output buffer space at " PTR_FORMAT " [" SIZE_FORMAT " bytes]",
322+
log_info(cds)("Reserved output buffer space at " PTR_FORMAT " [%zu bytes]",
323323
p2i(buffer_bottom), buffer_size);
324324
_shared_rs = rs;
325325

@@ -1184,7 +1184,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
11841184

11851185
log_as_hex(last_obj_base, last_obj_end, last_obj_base + buffer_to_runtime_delta());
11861186
if (last_obj_end < region_end) {
1187-
log_debug(cds, map)(PTR_FORMAT ": @@ Misc data " SIZE_FORMAT " bytes",
1187+
log_debug(cds, map)(PTR_FORMAT ": @@ Misc data %zu bytes",
11881188
p2i(last_obj_end + buffer_to_runtime_delta()),
11891189
size_t(region_end - last_obj_end));
11901190
log_as_hex(last_obj_end, region_end, last_obj_end + buffer_to_runtime_delta());
@@ -1204,7 +1204,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
12041204
size_t size = top - base;
12051205
base = requested_base;
12061206
top = requested_base + size;
1207-
log_info(cds, map)("[%-18s " PTR_FORMAT " - " PTR_FORMAT " " SIZE_FORMAT_W(9) " bytes]",
1207+
log_info(cds, map)("[%-18s " PTR_FORMAT " - " PTR_FORMAT " %9zu bytes]",
12081208
name, p2i(base), p2i(top), size);
12091209
}
12101210

@@ -1245,7 +1245,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
12451245
// We have a filler oop, which also does not exist in BufferOffsetToSourceObjectTable.
12461246
// Example:
12471247
// 0x00000007ffc3ffd8: @@ Object filler 40 bytes
1248-
st.print_cr("filler " SIZE_FORMAT " bytes", byte_size);
1248+
st.print_cr("filler %zu bytes", byte_size);
12491249
} else {
12501250
ShouldNotReachHere();
12511251
}
@@ -1348,7 +1348,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
13481348
print_oop_info_cr(&st, obj);
13491349
}
13501350
} else {
1351-
st.print_cr(" - fields (" SIZE_FORMAT " words):", source_oop->size());
1351+
st.print_cr(" - fields (%zu words):", source_oop->size());
13521352
ArchivedFieldPrinter print_field(heap_info, &st, source_oop, buffered_addr);
13531353
InstanceKlass::cast(source_klass)->print_nonstatic_fields(&print_field);
13541354

@@ -1573,20 +1573,20 @@ void ArchiveBuilder::print_region_stats(FileMapInfo *mapinfo, ArchiveHeapInfo* h
15731573
print_heap_region_stats(heap_info, total_reserved);
15741574
}
15751575

1576-
log_debug(cds)("total : " SIZE_FORMAT_W(9) " [100.0%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used]",
1576+
log_debug(cds)("total : %9zu [100.0%% of total] out of %9zu bytes [%5.1f%% used]",
15771577
total_bytes, total_reserved, total_u_perc);
15781578
}
15791579

15801580
void ArchiveBuilder::print_bitmap_region_stats(size_t size, size_t total_size) {
1581-
log_debug(cds)("bm space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [100.0%% used]",
1581+
log_debug(cds)("bm space: %9zu [ %4.1f%% of total] out of %9zu bytes [100.0%% used]",
15821582
size, size/double(total_size)*100.0, size);
15831583
}
15841584

15851585
void ArchiveBuilder::print_heap_region_stats(ArchiveHeapInfo *info, size_t total_size) {
15861586
char* start = info->buffer_start();
15871587
size_t size = info->buffer_byte_size();
15881588
char* top = start + size;
1589-
log_debug(cds)("hp space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [100.0%% used] at " INTPTR_FORMAT,
1589+
log_debug(cds)("hp space: %9zu [ %4.1f%% of total] out of %9zu bytes [100.0%% used] at " INTPTR_FORMAT,
15901590
size, size/double(total_size)*100.0, size, p2i(start));
15911591
}
15921592

src/hotspot/share/cds/archiveHeapLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ bool ArchiveHeapLoader::load_heap_region_impl(FileMapInfo* mapinfo, LoadedArchiv
308308
}
309309
assert(r->mapped_base() == (char*)load_address, "sanity");
310310
log_info(cds)("Loaded heap region #%d at base " INTPTR_FORMAT " top " INTPTR_FORMAT
311-
" size " SIZE_FORMAT_W(6) " delta %zd",
311+
" size %6zu delta %zd",
312312
loaded_region->_region_index, load_address, load_address + loaded_region->_region_size,
313313
loaded_region->_region_size, loaded_region->_runtime_offset);
314314

0 commit comments

Comments
 (0)