diff --git a/src/hotspot/cpu/arm/c1_FrameMap_arm.cpp b/src/hotspot/cpu/arm/c1_FrameMap_arm.cpp index a820da4d283..96ec170504f 100644 --- a/src/hotspot/cpu/arm/c1_FrameMap_arm.cpp +++ b/src/hotspot/cpu/arm/c1_FrameMap_arm.cpp @@ -48,6 +48,7 @@ LIR_Opr FrameMap::R3_metadata_opr; LIR_Opr FrameMap::R4_metadata_opr; LIR_Opr FrameMap::R5_metadata_opr; +LIR_Opr FrameMap::profile_rng_opr; LIR_Opr FrameMap::LR_opr; LIR_Opr FrameMap::LR_oop_opr; @@ -142,6 +143,10 @@ void FrameMap::initialize() { SP_opr = as_pointer_opr(SP); Rthread_opr = as_pointer_opr(Rthread); + if (ProfileCaptureRatio > 1) { + profile_rng_opr = LIR_OprFact::single_cpu(cpu_reg2rnr(r_profile_rng)); + } + // LIR operands for result Int_result_opr = R0_opr; Object_result_opr = R0_oop_opr; diff --git a/src/hotspot/cpu/arm/c1_FrameMap_arm.hpp b/src/hotspot/cpu/arm/c1_FrameMap_arm.hpp index 6d1a202fe55..b9d0a3181d4 100644 --- a/src/hotspot/cpu/arm/c1_FrameMap_arm.hpp +++ b/src/hotspot/cpu/arm/c1_FrameMap_arm.hpp @@ -54,6 +54,7 @@ static LIR_Opr R4_metadata_opr; static LIR_Opr R5_metadata_opr; + static LIR_Opr profile_rng_opr; static LIR_Opr LR_opr; static LIR_Opr LR_oop_opr; diff --git a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp index 83c942a156e..b9a621bfb27 100644 --- a/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/c1_LIRAssembler_arm.cpp @@ -2473,14 +2473,13 @@ void LIR_Assembler::increment_profile_ctr(LIR_Opr step, LIR_Opr dest_opr, } #endif - int profile_capture_ratio = ProfileCaptureRatio; - int ratio_shift = exact_log2(profile_capture_ratio); + int ratio_shift = exact_log2(ProfileCaptureRatio); uint64_t threshold = (UCONST64(1) << 32) >> ratio_shift; assert(threshold > 0, "must be"); ProfileStub *counter_stub - = profile_capture_ratio > 1 ? new ProfileStub() : nullptr; + = ProfileCaptureRatio > 1 ? new ProfileStub() : nullptr; Register dest = dest_opr->as_register(); @@ -2544,7 +2543,7 @@ void LIR_Assembler::increment_profile_ctr(LIR_Opr step, LIR_Opr dest_opr, } } - if (overflow_stub) { + if (overflow_stub != nullptr) { guarantee(step->is_valid(), "must be"); if (!freq_opr->is_valid()) { if (!step->is_constant()) { @@ -2562,9 +2561,16 @@ void LIR_Assembler::increment_profile_ctr(LIR_Opr step, LIR_Opr dest_opr, } juint mask = freq_opr->as_jint(); __ mov_slow(Rtemp, mask); - __ tst(dest, Rtemp); - __ b(*overflow_stub->entry(), eq); + __ andr(dest, dest, Rtemp); + + if (step->is_register()) { + __ cmp(dest, AsmOperand(step->as_register(), lsl, ratio_shift)); + } else { + __ mov(Rtemp, step->as_constant_ptr()->as_jint_bits() << ratio_shift); + __ cmp(dest, Rtemp); + } } + __ b(*overflow_stub->entry(), lo); } if (counter_stub != nullptr) { diff --git a/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp b/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp index eb43e47c93b..fc0f8e12300 100644 --- a/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp +++ b/src/hotspot/cpu/arm/c1_LIRGenerator_arm.cpp @@ -93,6 +93,10 @@ LIR_Opr LIRGenerator::atomicLockOpr() { return LIR_OprFact::illegalOpr; } +LIR_Opr LIRGenerator::profile_rng_opr() { + return FrameMap::profile_rng_opr; +} + LIR_Opr LIRGenerator::result_register_for(ValueType* type, bool callee) { LIR_Opr opr; switch (type->tag()) { diff --git a/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp b/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp index b5d5bdd774c..9def72d934d 100644 --- a/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp +++ b/src/hotspot/cpu/arm/c1_MacroAssembler_arm.cpp @@ -252,6 +252,7 @@ void C1_MacroAssembler::step_random(Register state, Register temp, Register data https://www.researchgate.net/publication/2683298_A_Collection_of_Selected_Pseudorandom_Number_Generators_With_Linear_Structures */ mov_slow(temp, 69069); mul(state, state, temp); + add(state, state, 1); } void C1_MacroAssembler::save_profile_rng() {