From f6ff38ab4292762a35fb151b6886e58df60824d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20H=C3=A4ssig?= Date: Tue, 24 Jun 2025 06:55:05 +0000 Subject: [PATCH] 8353815: [ubsan] compilationPolicy.cpp: division by zero related to tiered compilation flags Reviewed-by: mbaesken, kvn --- src/hotspot/share/compiler/compilationPolicy.cpp | 2 +- src/hotspot/share/compiler/compiler_globals.hpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hotspot/share/compiler/compilationPolicy.cpp b/src/hotspot/share/compiler/compilationPolicy.cpp index 1240fd21bbf..02dec8d957b 100644 --- a/src/hotspot/share/compiler/compilationPolicy.cpp +++ b/src/hotspot/share/compiler/compilationPolicy.cpp @@ -385,7 +385,7 @@ public: double CompilationPolicy::threshold_scale(CompLevel level, int feedback_k) { int comp_count = compiler_count(level); - if (comp_count > 0) { + if (comp_count > 0 && feedback_k > 0) { double queue_size = CompileBroker::queue_size(level); double k = (double)queue_size / ((double)feedback_k * (double)comp_count) + 1; diff --git a/src/hotspot/share/compiler/compiler_globals.hpp b/src/hotspot/share/compiler/compiler_globals.hpp index 3c47b991120..605c0c58869 100644 --- a/src/hotspot/share/compiler/compiler_globals.hpp +++ b/src/hotspot/share/compiler/compiler_globals.hpp @@ -234,12 +234,14 @@ \ product(intx, Tier3LoadFeedback, 5, \ "Tier 3 thresholds will increase twofold when C1 queue size " \ - "reaches this amount per compiler thread") \ + "reaches this amount per compiler thread" \ + "Passing 0 disables the threshold scaling") \ range(0, max_jint) \ \ product(intx, Tier4LoadFeedback, 3, \ "Tier 4 thresholds will increase twofold when C2 queue size " \ - "reaches this amount per compiler thread") \ + "reaches this amount per compiler thread" \ + "Passing 0 disables the threshold scaling") \ range(0, max_jint) \ \ product(intx, TieredCompileTaskTimeout, 50, \ @@ -263,11 +265,11 @@ \ product(intx, TieredRateUpdateMinTime, 1, \ "Minimum rate sampling interval (in milliseconds)") \ - range(0, max_intx) \ + range(1, max_intx) \ \ product(intx, TieredRateUpdateMaxTime, 25, \ "Maximum rate sampling interval (in milliseconds)") \ - range(0, max_intx) \ + range(1, max_intx) \ \ product(double, Tier0ProfileDelayFactor, 100.0, DIAGNOSTIC, \ "Delay profiling/compiling of methods that were " \