From 8f4fa3f8d5f34ebc80fb70f1b36aa67a8bd35211 Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Wed, 2 Dec 2020 02:31:08 +0000 Subject: [PATCH] 8257232: CompileThresholdScaling fails to work on 32-bit platforms Reviewed-by: kvn, redestad --- src/hotspot/share/compiler/compilerDefinitions.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hotspot/share/compiler/compilerDefinitions.cpp b/src/hotspot/share/compiler/compilerDefinitions.cpp index 2fcb359aa5e..dc8c726ce36 100644 --- a/src/hotspot/share/compiler/compilerDefinitions.cpp +++ b/src/hotspot/share/compiler/compilerDefinitions.cpp @@ -119,13 +119,17 @@ intx CompilerConfig::scaled_freq_log(intx freq_log, double scale) { // max_freq_bits accordingly. intx max_freq_bits = InvocationCounter::number_of_count_bits + 1; intx scaled_freq = scaled_compile_threshold((intx)1 << freq_log, scale); + if (scaled_freq == 0) { // Return 0 right away to avoid calculating log2 of 0. return 0; - } else if (scaled_freq > nth_bit(max_freq_bits)) { - return max_freq_bits; } else { - return log2_intptr(scaled_freq); + intx res = log2_intptr(scaled_freq); + if (res > max_freq_bits) { + return max_freq_bits; + } else { + return res; + } } }