From 09f6af58dfb0073f62789394e8e5c0033963fa3e Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Thu, 16 Jul 2026 12:05:44 +0100 Subject: [PATCH 1/3] x86 review fixes --- src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp | 2 +- src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp index 2faaa6f9ce6..f1c3175f6cc 100644 --- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp @@ -1464,8 +1464,8 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { Label* success_target = &done; Label* failure_target = stub->entry(); - __ testptr(value, value); if (op->should_profile()) { + __ testptr(value, value); Label not_null; Register mdo = klass_RInfo; __ mov_metadata(mdo, md->constant_encoding()); diff --git a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp index 30470e023c7..de8dea7dd8a 100644 --- a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp @@ -275,7 +275,7 @@ void C1_MacroAssembler::step_random(Register state, Register temp) { /* CRC used as a pseudo-random-number generator */ // In effect, the CRC instruction is being used here for its // linear feedback shift register. - movl(temp, 0); + xorl(temp, temp); crc32(state, temp, /*sizeInBytes*/2); } else { /* LCG by Marsaglia. From Karl Entacher, From c3b5fb565c25cf55fec06c7e1b8088c5534a4d51 Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Thu, 16 Jul 2026 12:19:39 +0100 Subject: [PATCH 2/3] x86 review fixes --- src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp index f1c3175f6cc..61644e46f39 100644 --- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp @@ -1464,8 +1464,8 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { Label* success_target = &done; Label* failure_target = stub->entry(); + __ testptr(value, value); if (op->should_profile()) { - __ testptr(value, value); Label not_null; Register mdo = klass_RInfo; __ mov_metadata(mdo, md->constant_encoding()); @@ -1481,7 +1481,6 @@ void LIR_Assembler::emit_opTypeCheck(LIR_OpTypeCheck* op) { __ load_klass(recv, value, tmp_load_klass); type_profile_helper(mdo, md, data, recv, Rtmp1); } else { - __ testptr(value, value); __ jcc(Assembler::equal, done); } From 6ef108653373c38540c161ca421fbf9900c42adc Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Thu, 16 Jul 2026 12:41:32 +0100 Subject: [PATCH 3/3] x86 review fixes --- src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp index de8dea7dd8a..99358c023d0 100644 --- a/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp @@ -272,6 +272,13 @@ void C1_MacroAssembler::step_random(Register state, Register temp) { // One of these will be the best for a particular CPU. if (VM_Version::supports_sse4_2()) { +#ifndef PRODUCT + Label not_zero; + orl(r_profile_rng, r_profile_rng); + jcc(Assembler::notZero, not_zero); + stop("non-zero required before step"); + bind(not_zero); +#endif /* CRC used as a pseudo-random-number generator */ // In effect, the CRC instruction is being used here for its // linear feedback shift register. @@ -288,6 +295,13 @@ void C1_MacroAssembler::step_random(Register state, Register temp) { void C1_MacroAssembler::save_profile_rng() { if (ProfileCaptureRatio > 1) { +#ifndef PRODUCT + Label not_zero; + orl(r_profile_rng, r_profile_rng); + jcc(Assembler::notZero, not_zero); + stop("non-zero required before save"); + bind(not_zero); +#endif movl(Address(r15_thread, JavaThread::profile_rng_offset()), r_profile_rng); } } @@ -295,6 +309,13 @@ void C1_MacroAssembler::save_profile_rng() { void C1_MacroAssembler::restore_profile_rng() { if (ProfileCaptureRatio > 1) { movl(r_profile_rng, Address(r15_thread, JavaThread::profile_rng_offset())); +#ifndef PRODUCT + Label not_zero; + orl(r_profile_rng, r_profile_rng); + jcc(Assembler::notZero, not_zero); + stop("non-zero required after restore"); + bind(not_zero); +#endif } }