Skip to content

Commit 1f9acd0

Browse files
[GR-67735] Merge in jdk-25+32 (25.0)
PullRequest: labsjdk-ce/192
2 parents 73ae5cb + fc33c97 commit 1f9acd0

File tree

111 files changed

+2534
-576
lines changed

Some content is hidden

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

111 files changed

+2534
-576
lines changed

src/hotspot/cpu/arm/arm.ad

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8888,13 +8888,8 @@ instruct TailCalljmpInd(IPRegP jump_target, inline_cache_regP method_ptr) %{
88888888
match(TailCall jump_target method_ptr);
88898889

88908890
ins_cost(CALL_COST);
8891-
format %{ "MOV Rexception_pc, LR\n\t"
8892-
"jump $jump_target \t! $method_ptr holds method" %}
8891+
format %{ "jump $jump_target \t! $method_ptr holds method" %}
88938892
ins_encode %{
8894-
__ mov(Rexception_pc, LR); // this is used only to call
8895-
// StubRoutines::forward_exception_entry()
8896-
// which expects PC of exception in
8897-
// R5. FIXME?
88988893
__ jump($jump_target$$Register);
88998894
%}
89008895
ins_pipe(tail_call);
@@ -8939,8 +8934,10 @@ instruct ForwardExceptionjmp()
89398934
match(ForwardException);
89408935
ins_cost(CALL_COST);
89418936

8942-
format %{ "b forward_exception_stub" %}
8937+
format %{ "MOV Rexception_pc, LR\n\t"
8938+
"b forward_exception_entry" %}
89438939
ins_encode %{
8940+
__ mov(Rexception_pc, LR);
89448941
// OK to trash Rtemp, because Rtemp is used by stub
89458942
__ jump(StubRoutines::forward_exception_entry(), relocInfo::runtime_call_type, Rtemp);
89468943
%}

src/hotspot/cpu/x86/assembler_x86.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15681,6 +15681,8 @@ void Assembler::pusha_uncached() { // 64bit
1568115681
// Push pair of original stack pointer along with remaining registers
1568215682
// at 16B aligned boundary.
1568315683
push2p(rax, r31);
15684+
// Restore the original contents of RAX register.
15685+
movq(rax, Address(rax));
1568415686
push2p(r30, r29);
1568515687
push2p(r28, r27);
1568615688
push2p(r26, r25);

src/hotspot/cpu/x86/gc/shenandoah/shenandoahBarrierSetAssembler_x86.cpp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ void ShenandoahBarrierSetAssembler::load_reference_barrier(MacroAssembler* masm,
353353

354354
// The rest is saved with the optimized path
355355

356-
uint num_saved_regs = 4 + (dst != rax ? 1 : 0) + 4;
356+
uint num_saved_regs = 4 + (dst != rax ? 1 : 0) + 4 + (UseAPX ? 16 : 0);
357357
__ subptr(rsp, num_saved_regs * wordSize);
358358
uint slot = num_saved_regs;
359359
if (dst != rax) {
@@ -367,6 +367,25 @@ void ShenandoahBarrierSetAssembler::load_reference_barrier(MacroAssembler* masm,
367367
__ movptr(Address(rsp, (--slot) * wordSize), r9);
368368
__ movptr(Address(rsp, (--slot) * wordSize), r10);
369369
__ movptr(Address(rsp, (--slot) * wordSize), r11);
370+
// Save APX extended registers r16–r31 if enabled
371+
if (UseAPX) {
372+
__ movptr(Address(rsp, (--slot) * wordSize), r16);
373+
__ movptr(Address(rsp, (--slot) * wordSize), r17);
374+
__ movptr(Address(rsp, (--slot) * wordSize), r18);
375+
__ movptr(Address(rsp, (--slot) * wordSize), r19);
376+
__ movptr(Address(rsp, (--slot) * wordSize), r20);
377+
__ movptr(Address(rsp, (--slot) * wordSize), r21);
378+
__ movptr(Address(rsp, (--slot) * wordSize), r22);
379+
__ movptr(Address(rsp, (--slot) * wordSize), r23);
380+
__ movptr(Address(rsp, (--slot) * wordSize), r24);
381+
__ movptr(Address(rsp, (--slot) * wordSize), r25);
382+
__ movptr(Address(rsp, (--slot) * wordSize), r26);
383+
__ movptr(Address(rsp, (--slot) * wordSize), r27);
384+
__ movptr(Address(rsp, (--slot) * wordSize), r28);
385+
__ movptr(Address(rsp, (--slot) * wordSize), r29);
386+
__ movptr(Address(rsp, (--slot) * wordSize), r30);
387+
__ movptr(Address(rsp, (--slot) * wordSize), r31);
388+
}
370389
// r12-r15 are callee saved in all calling conventions
371390
assert(slot == 0, "must use all slots");
372391

@@ -398,6 +417,25 @@ void ShenandoahBarrierSetAssembler::load_reference_barrier(MacroAssembler* masm,
398417
__ super_call_VM_leaf(CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_phantom), arg0, arg1);
399418
}
400419

420+
// Restore APX extended registers r31–r16 if previously saved
421+
if (UseAPX) {
422+
__ movptr(r31, Address(rsp, (slot++) * wordSize));
423+
__ movptr(r30, Address(rsp, (slot++) * wordSize));
424+
__ movptr(r29, Address(rsp, (slot++) * wordSize));
425+
__ movptr(r28, Address(rsp, (slot++) * wordSize));
426+
__ movptr(r27, Address(rsp, (slot++) * wordSize));
427+
__ movptr(r26, Address(rsp, (slot++) * wordSize));
428+
__ movptr(r25, Address(rsp, (slot++) * wordSize));
429+
__ movptr(r24, Address(rsp, (slot++) * wordSize));
430+
__ movptr(r23, Address(rsp, (slot++) * wordSize));
431+
__ movptr(r22, Address(rsp, (slot++) * wordSize));
432+
__ movptr(r21, Address(rsp, (slot++) * wordSize));
433+
__ movptr(r20, Address(rsp, (slot++) * wordSize));
434+
__ movptr(r19, Address(rsp, (slot++) * wordSize));
435+
__ movptr(r18, Address(rsp, (slot++) * wordSize));
436+
__ movptr(r17, Address(rsp, (slot++) * wordSize));
437+
__ movptr(r16, Address(rsp, (slot++) * wordSize));
438+
}
401439
__ movptr(r11, Address(rsp, (slot++) * wordSize));
402440
__ movptr(r10, Address(rsp, (slot++) * wordSize));
403441
__ movptr(r9, Address(rsp, (slot++) * wordSize));

src/hotspot/cpu/x86/vm_version_x86.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
440440
__ andl(rax, Address(rbp, in_bytes(VM_Version::xem_xcr0_offset()))); // xcr0 bits apx_f
441441
__ jcc(Assembler::equal, vector_save_restore);
442442

443-
#ifndef PRODUCT
444443
bool save_apx = UseAPX;
445444
VM_Version::set_apx_cpuFeatures();
446445
UseAPX = true;
@@ -457,7 +456,6 @@ class VM_Version_StubGenerator: public StubCodeGenerator {
457456
__ movq(Address(rsi, 8), r31);
458457

459458
UseAPX = save_apx;
460-
#endif
461459
__ bind(vector_save_restore);
462460
//
463461
// Check if OS has enabled XGETBV instruction to access XCR0
@@ -1022,8 +1020,6 @@ void VM_Version::get_processor_features() {
10221020
if (UseAPX && !apx_supported) {
10231021
warning("UseAPX is not supported on this CPU, setting it to false");
10241022
FLAG_SET_DEFAULT(UseAPX, false);
1025-
} else if (FLAG_IS_DEFAULT(UseAPX)) {
1026-
FLAG_SET_DEFAULT(UseAPX, apx_supported ? true : false);
10271023
}
10281024

10291025
if (!UseAPX) {
@@ -3151,17 +3147,11 @@ bool VM_Version::os_supports_apx_egprs() {
31513147
if (!supports_apx_f()) {
31523148
return false;
31533149
}
3154-
// Enable APX support for product builds after
3155-
// completion of planned features listed in JDK-8329030.
3156-
#if !defined(PRODUCT)
31573150
if (_cpuid_info.apx_save[0] != egpr_test_value() ||
31583151
_cpuid_info.apx_save[1] != egpr_test_value()) {
31593152
return false;
31603153
}
31613154
return true;
3162-
#else
3163-
return false;
3164-
#endif
31653155
}
31663156

31673157
uint VM_Version::cores_per_cpu() {

src/hotspot/os/windows/os_windows.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2623,15 +2623,13 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
26232623
return Handle_Exception(exceptionInfo, VM_Version::cpuinfo_cont_addr());
26242624
}
26252625

2626-
#if !defined(PRODUCT)
26272626
if ((exception_code == EXCEPTION_ACCESS_VIOLATION) &&
26282627
VM_Version::is_cpuinfo_segv_addr_apx(pc)) {
26292628
// Verify that OS save/restore APX registers.
26302629
VM_Version::clear_apx_test_state();
26312630
return Handle_Exception(exceptionInfo, VM_Version::cpuinfo_cont_addr_apx());
26322631
}
26332632
#endif
2634-
#endif
26352633

26362634
#ifdef CAN_SHOW_REGISTERS_ON_ASSERT
26372635
if (VMError::was_assert_poison_crash(exception_record)) {

src/hotspot/os_cpu/bsd_x86/os_bsd_x86.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,13 +429,11 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
429429
stub = VM_Version::cpuinfo_cont_addr();
430430
}
431431

432-
#if !defined(PRODUCT) && defined(_LP64)
433432
if ((sig == SIGSEGV || sig == SIGBUS) && VM_Version::is_cpuinfo_segv_addr_apx(pc)) {
434433
// Verify that OS save/restore APX registers.
435434
stub = VM_Version::cpuinfo_cont_addr_apx();
436435
VM_Version::clear_apx_test_state();
437436
}
438-
#endif
439437

440438
// We test if stub is already set (by the stack overflow code
441439
// above) so it is not overwritten by the code that follows. This

src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,11 @@ bool PosixSignals::pd_hotspot_signal_handler(int sig, siginfo_t* info,
255255
stub = VM_Version::cpuinfo_cont_addr();
256256
}
257257

258-
#if !defined(PRODUCT) && defined(_LP64)
259258
if ((sig == SIGSEGV) && VM_Version::is_cpuinfo_segv_addr_apx(pc)) {
260259
// Verify that OS save/restore APX registers.
261260
stub = VM_Version::cpuinfo_cont_addr_apx();
262261
VM_Version::clear_apx_test_state();
263262
}
264-
#endif
265263

266264
if (thread->thread_state() == _thread_in_Java) {
267265
// Java thread running in Java code => find exception handler if any

src/hotspot/share/cds/metaspaceShared.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -837,11 +837,10 @@ void MetaspaceShared::preload_and_dump(TRAPS) {
837837
struct stat st;
838838
if (os::stat(AOTCache, &st) != 0) {
839839
tty->print_cr("AOTCache creation failed: %s", AOTCache);
840-
vm_exit(0);
841840
} else {
842841
tty->print_cr("AOTCache creation is complete: %s " INT64_FORMAT " bytes", AOTCache, (int64_t)(st.st_size));
843-
vm_exit(0);
844842
}
843+
vm_direct_exit(0);
845844
}
846845
}
847846
}

src/hotspot/share/classfile/stringTable.cpp

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "classfile/javaClasses.inline.hpp"
3333
#include "classfile/stringTable.hpp"
3434
#include "classfile/vmClasses.hpp"
35+
#include "compiler/compileBroker.hpp"
3536
#include "gc/shared/collectedHeap.hpp"
3637
#include "gc/shared/oopStorage.inline.hpp"
3738
#include "gc/shared/oopStorageSet.hpp"
@@ -115,6 +116,7 @@ OopStorage* StringTable::_oop_storage;
115116

116117
static size_t _current_size = 0;
117118
static volatile size_t _items_count = 0;
119+
DEBUG_ONLY(static bool _disable_interning_during_cds_dump = false);
118120

119121
volatile bool _alt_hash = false;
120122

@@ -346,6 +348,10 @@ bool StringTable::has_work() {
346348
return Atomic::load_acquire(&_has_work);
347349
}
348350

351+
size_t StringTable::items_count_acquire() {
352+
return Atomic::load_acquire(&_items_count);
353+
}
354+
349355
void StringTable::trigger_concurrent_work() {
350356
// Avoid churn on ServiceThread
351357
if (!has_work()) {
@@ -504,6 +510,9 @@ oop StringTable::intern(const char* utf8_string, TRAPS) {
504510
}
505511

506512
oop StringTable::intern(const StringWrapper& name, TRAPS) {
513+
assert(!Atomic::load_acquire(&_disable_interning_during_cds_dump),
514+
"All threads that may intern strings should have been stopped before CDS starts copying the interned string table");
515+
507516
// shared table always uses java_lang_String::hash_code
508517
unsigned int hash = hash_wrapped_string(name);
509518
oop found_string = lookup_shared(name, hash);
@@ -793,7 +802,7 @@ void StringTable::verify() {
793802
}
794803

795804
// Verification and comp
796-
class VerifyCompStrings : StackObj {
805+
class StringTable::VerifyCompStrings : StackObj {
797806
static unsigned string_hash(oop const& str) {
798807
return java_lang_String::hash_code_noupdate(str);
799808
}
@@ -805,7 +814,7 @@ class VerifyCompStrings : StackObj {
805814
string_hash, string_equals> _table;
806815
public:
807816
size_t _errors;
808-
VerifyCompStrings() : _table(unsigned(_items_count / 8) + 1, 0 /* do not resize */), _errors(0) {}
817+
VerifyCompStrings() : _table(unsigned(items_count_acquire() / 8) + 1, 0 /* do not resize */), _errors(0) {}
809818
bool operator()(WeakHandle* val) {
810819
oop s = val->resolve();
811820
if (s == nullptr) {
@@ -939,20 +948,31 @@ oop StringTable::lookup_shared(const jchar* name, int len) {
939948
return _shared_table.lookup(wrapped_name, java_lang_String::hash_code(name, len), 0);
940949
}
941950

942-
// This is called BEFORE we enter the CDS safepoint. We can allocate heap objects.
943-
// This should be called when we know no more strings will be added (which will be easy
944-
// to guarantee because CDS runs with a single Java thread. See JDK-8253495.)
951+
// This is called BEFORE we enter the CDS safepoint. We can still allocate Java object arrays to
952+
// be used by the shared strings table.
945953
void StringTable::allocate_shared_strings_array(TRAPS) {
946954
if (!CDSConfig::is_dumping_heap()) {
947955
return;
948956
}
949-
assert(CDSConfig::allow_only_single_java_thread(), "No more interned strings can be added");
950957

951-
if (_items_count > (size_t)max_jint) {
952-
fatal("Too many strings to be archived: %zu", _items_count);
958+
CompileBroker::wait_for_no_active_tasks();
959+
960+
precond(CDSConfig::allow_only_single_java_thread());
961+
962+
// At this point, no more strings will be added:
963+
// - There's only a single Java thread (this thread). It no longer executes Java bytecodes
964+
// so JIT compilation will eventually stop.
965+
// - CompileBroker has no more active tasks, so all JIT requests have been processed.
966+
967+
// This flag will be cleared after intern table dumping has completed, so we can run the
968+
// compiler again (for future AOT method compilation, etc).
969+
DEBUG_ONLY(Atomic::release_store(&_disable_interning_during_cds_dump, true));
970+
971+
if (items_count_acquire() > (size_t)max_jint) {
972+
fatal("Too many strings to be archived: %zu", items_count_acquire());
953973
}
954974

955-
int total = (int)_items_count;
975+
int total = (int)items_count_acquire();
956976
size_t single_array_size = objArrayOopDesc::object_size(total);
957977

958978
log_info(aot)("allocated string table for %d strings", total);
@@ -972,7 +992,7 @@ void StringTable::allocate_shared_strings_array(TRAPS) {
972992
// This can only happen if you have an extremely large number of classes that
973993
// refer to more than 16384 * 16384 = 26M interned strings! Not a practical concern
974994
// but bail out for safety.
975-
log_error(aot)("Too many strings to be archived: %zu", _items_count);
995+
log_error(aot)("Too many strings to be archived: %zu", items_count_acquire());
976996
MetaspaceShared::unrecoverable_writing_error();
977997
}
978998

@@ -1070,7 +1090,7 @@ oop StringTable::init_shared_strings_array() {
10701090

10711091
void StringTable::write_shared_table() {
10721092
_shared_table.reset();
1073-
CompactHashtableWriter writer((int)_items_count, ArchiveBuilder::string_stats());
1093+
CompactHashtableWriter writer((int)items_count_acquire(), ArchiveBuilder::string_stats());
10741094

10751095
int index = 0;
10761096
auto copy_into_shared_table = [&] (WeakHandle* val) {
@@ -1084,6 +1104,8 @@ void StringTable::write_shared_table() {
10841104
};
10851105
_local_table->do_safepoint_scan(copy_into_shared_table);
10861106
writer.dump(&_shared_table, "string");
1107+
1108+
DEBUG_ONLY(Atomic::release_store(&_disable_interning_during_cds_dump, false));
10871109
}
10881110

10891111
void StringTable::set_shared_strings_array_index(int root_index) {

src/hotspot/share/classfile/stringTable.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class StringTableConfig;
4040

4141
class StringTable : AllStatic {
4242
friend class StringTableConfig;
43-
43+
class VerifyCompStrings;
4444
static volatile bool _has_work;
4545

4646
// Set if one bucket is out of balance due to hash algorithm deficiency
@@ -74,6 +74,7 @@ class StringTable : AllStatic {
7474

7575
static void item_added();
7676
static void item_removed();
77+
static size_t items_count_acquire();
7778

7879
static oop intern(const StringWrapper& name, TRAPS);
7980
static oop do_intern(const StringWrapper& name, uintx hash, TRAPS);

0 commit comments

Comments
 (0)