8180612: [ppc] assert failure in cpu/ppc/vm/assembler_ppc.hpp due to immediate value out of range
Summary: change RTM flags type to 'int' and set value range
Reviewed-by: simonis, kvn
--- a/hotspot/src/cpu/ppc/vm/globals_ppc.hpp Wed May 24 22:27:40 2017 +0200
+++ b/hotspot/src/cpu/ppc/vm/globals_ppc.hpp Wed May 24 17:30:45 2017 -0700
@@ -164,7 +164,7 @@
product(bool, ZapMemory, false, "Write 0x0101... to empty memory." \
" Use this to ease debugging.") \
\
- /* Use Restricted Transactional Memory for lock eliding */ \
+ /* Use Restricted Transactional Memory for lock elision */ \
product(bool, UseRTMLocking, false, \
"Enable RTM lock eliding for inflated locks in compiled code") \
\
@@ -174,24 +174,30 @@
product(bool, UseRTMDeopt, false, \
"Perform deopt and recompilation based on RTM abort ratio") \
\
- product(uintx, RTMRetryCount, 5, \
+ product(int, RTMRetryCount, 5, \
"Number of RTM retries on lock abort or busy") \
+ range(0, max_jint) \
\
- experimental(intx, RTMSpinLoopCount, 100, \
+ experimental(int, RTMSpinLoopCount, 100, \
"Spin count for lock to become free before RTM retry") \
+ range(0, 32767) /* immediate operand limit on ppc */ \
\
- experimental(intx, RTMAbortThreshold, 1000, \
+ experimental(int, RTMAbortThreshold, 1000, \
"Calculate abort ratio after this number of aborts") \
+ range(0, max_jint) \
\
- experimental(intx, RTMLockingThreshold, 10000, \
+ experimental(int, RTMLockingThreshold, 10000, \
"Lock count at which to do RTM lock eliding without " \
"abort ratio calculation") \
+ range(0, max_jint) \
\
- experimental(intx, RTMAbortRatio, 50, \
+ experimental(int, RTMAbortRatio, 50, \
"Lock abort ratio at which to stop use RTM lock eliding") \
+ range(0, 100) /* natural range, checked in vm_version_ppc.cpp */ \
\
- experimental(intx, RTMTotalCountIncrRate, 64, \
+ experimental(int, RTMTotalCountIncrRate, 64, \
"Increment total RTM attempted lock count once every n times") \
+ range(1, 32767) /* immediate operand limit on ppc */ \
\
experimental(intx, RTMLockingCalculationDelay, 0, \
"Number of milliseconds to wait before start calculating aborts " \
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp Wed May 24 22:27:40 2017 +0200
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp Wed May 24 17:30:45 2017 -0700
@@ -2498,14 +2498,20 @@
// All transactions = total_count * RTMTotalCountIncrRate
// Set no_rtm bit if (Aborted transactions >= All transactions * RTMAbortRatio)
ld(R0, RTMLockingCounters::abort_count_offset(), rtm_counters_Reg);
- cmpdi(CCR0, R0, RTMAbortThreshold);
- blt(CCR0, L_check_always_rtm2);
+ if (is_simm(RTMAbortThreshold, 16)) { // cmpdi can handle 16bit immediate only.
+ cmpdi(CCR0, R0, RTMAbortThreshold);
+ blt(CCR0, L_check_always_rtm2); // reload of rtm_counters_Reg not necessary
+ } else {
+ load_const_optimized(rtm_counters_Reg, RTMAbortThreshold);
+ cmpd(CCR0, R0, rtm_counters_Reg);
+ blt(CCR0, L_check_always_rtm1); // reload of rtm_counters_Reg required
+ }
mulli(R0, R0, 100);
const Register tmpReg = rtm_counters_Reg;
ld(tmpReg, RTMLockingCounters::total_count_offset(), rtm_counters_Reg);
- mulli(tmpReg, tmpReg, RTMTotalCountIncrRate);
- mulli(tmpReg, tmpReg, RTMAbortRatio);
+ mulli(tmpReg, tmpReg, RTMTotalCountIncrRate); // allowable range: int16
+ mulli(tmpReg, tmpReg, RTMAbortRatio); // allowable range: int16
cmpd(CCR0, R0, tmpReg);
blt(CCR0, L_check_always_rtm1); // jump to reload
if (method_data != NULL) {
@@ -2521,7 +2527,13 @@
load_const_optimized(rtm_counters_Reg, (address)rtm_counters, R0); // reload
bind(L_check_always_rtm2);
ld(tmpReg, RTMLockingCounters::total_count_offset(), rtm_counters_Reg);
- cmpdi(CCR0, tmpReg, RTMLockingThreshold / RTMTotalCountIncrRate);
+ int64_t thresholdValue = RTMLockingThreshold / RTMTotalCountIncrRate;
+ if (is_simm(thresholdValue, 16)) { // cmpdi can handle 16bit immediate only.
+ cmpdi(CCR0, tmpReg, thresholdValue);
+ } else {
+ load_const_optimized(R0, thresholdValue);
+ cmpd(CCR0, tmpReg, R0);
+ }
blt(CCR0, L_done);
if (method_data != NULL) {
// Set rtm_state to "always rtm" in MDO.
@@ -2620,7 +2632,7 @@
if (PrintPreciseRTMLockingStatistics || profile_rtm) {
Label L_noincrement;
if (RTMTotalCountIncrRate > 1) {
- branch_on_random_using_tb(tmp, (int)RTMTotalCountIncrRate, L_noincrement);
+ branch_on_random_using_tb(tmp, RTMTotalCountIncrRate, L_noincrement);
}
assert(stack_rtm_counters != NULL, "should not be NULL when profiling RTM");
load_const_optimized(tmp, (address)stack_rtm_counters->total_count_addr(), R0);
@@ -2687,7 +2699,7 @@
if (PrintPreciseRTMLockingStatistics || profile_rtm) {
Label L_noincrement;
if (RTMTotalCountIncrRate > 1) {
- branch_on_random_using_tb(R0, (int)RTMTotalCountIncrRate, L_noincrement);
+ branch_on_random_using_tb(R0, RTMTotalCountIncrRate, L_noincrement);
}
assert(rtm_counters != NULL, "should not be NULL when profiling RTM");
load_const(R0, (address)rtm_counters->total_count_addr(), tmpReg);
--- a/hotspot/src/cpu/x86/vm/globals_x86.hpp Wed May 24 22:27:40 2017 +0200
+++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp Wed May 24 17:30:45 2017 -0700
@@ -160,25 +160,30 @@
product(bool, UseRTMDeopt, false, \
"Perform deopt and recompilation based on RTM abort ratio") \
\
- product(uintx, RTMRetryCount, 5, \
+ product(int, RTMRetryCount, 5, \
"Number of RTM retries on lock abort or busy") \
- range(0, max_uintx) \
+ range(0, max_jint) \
\
- experimental(intx, RTMSpinLoopCount, 100, \
+ experimental(int, RTMSpinLoopCount, 100, \
"Spin count for lock to become free before RTM retry") \
+ range(0, max_jint) \
\
- experimental(intx, RTMAbortThreshold, 1000, \
+ experimental(int, RTMAbortThreshold, 1000, \
"Calculate abort ratio after this number of aborts") \
+ range(0, max_jint) \
\
- experimental(intx, RTMLockingThreshold, 10000, \
+ experimental(int, RTMLockingThreshold, 10000, \
"Lock count at which to do RTM lock eliding without " \
"abort ratio calculation") \
+ range(0, max_jint) \
\
- experimental(intx, RTMAbortRatio, 50, \
+ experimental(int, RTMAbortRatio, 50, \
"Lock abort ratio at which to stop use RTM lock eliding") \
+ range(0, 100) /* natural range, checked in vm_version_x86.cpp */ \
\
- experimental(intx, RTMTotalCountIncrRate, 64, \
+ experimental(int, RTMTotalCountIncrRate, 64, \
"Increment total RTM attempted lock count once every n times") \
+ range(1, max_jint) \
\
experimental(intx, RTMLockingCalculationDelay, 0, \
"Number of milliseconds to wait before start calculating aborts " \
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp Wed May 24 22:27:40 2017 +0200
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp Wed May 24 17:30:45 2017 -0700
@@ -1492,7 +1492,7 @@
Label L_noincrement;
if (RTMTotalCountIncrRate > 1) {
// tmpReg, scrReg and flags are killed
- branch_on_random_using_rdtsc(tmpReg, scrReg, (int)RTMTotalCountIncrRate, L_noincrement);
+ branch_on_random_using_rdtsc(tmpReg, scrReg, RTMTotalCountIncrRate, L_noincrement);
}
assert(stack_rtm_counters != NULL, "should not be NULL when profiling RTM");
atomic_incptr(ExternalAddress((address)stack_rtm_counters->total_count_addr()), scrReg);
@@ -1553,7 +1553,7 @@
Label L_noincrement;
if (RTMTotalCountIncrRate > 1) {
// tmpReg, scrReg and flags are killed
- branch_on_random_using_rdtsc(tmpReg, scrReg, (int)RTMTotalCountIncrRate, L_noincrement);
+ branch_on_random_using_rdtsc(tmpReg, scrReg, RTMTotalCountIncrRate, L_noincrement);
}
assert(rtm_counters != NULL, "should not be NULL when profiling RTM");
atomic_incptr(ExternalAddress((address)rtm_counters->total_count_addr()), scrReg);