From a53535f594b4d27f3c8a33efd920f40300cc3553 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Fri, 4 Oct 2024 15:37:50 +0530 Subject: [PATCH 1/3] intx to double conversion --- src/hotspot/share/compiler/compilationPolicy.hpp | 2 +- src/hotspot/share/compiler/compiler_globals.hpp | 16 ++++++++-------- src/hotspot/share/opto/bytecodeInfo.cpp | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/hotspot/share/compiler/compilationPolicy.hpp b/src/hotspot/share/compiler/compilationPolicy.hpp index fe33fb8cfba28..efb34f6aa3101 100644 --- a/src/hotspot/share/compiler/compilationPolicy.hpp +++ b/src/hotspot/share/compiler/compilationPolicy.hpp @@ -248,7 +248,7 @@ class CompilationPolicy : AllStatic { // m must be compiled before executing it static bool must_be_compiled(const methodHandle& m, int comp_level = CompLevel_any); public: - static int min_invocations() { return Tier4MinInvocationThreshold; } + static double min_invocations() { return Tier4MinInvocationThreshold; } static int c1_count() { return _c1_count; } static int c2_count() { return _c2_count; } static int compiler_count(CompLevel comp_level); diff --git a/src/hotspot/share/compiler/compiler_globals.hpp b/src/hotspot/share/compiler/compiler_globals.hpp index a811cd8b3bae6..a1c9df88389f9 100644 --- a/src/hotspot/share/compiler/compiler_globals.hpp +++ b/src/hotspot/share/compiler/compiler_globals.hpp @@ -175,39 +175,39 @@ "Back edge threshold at which tier 2 compilation is invoked") \ range(0, max_jint) \ \ - product(intx, Tier3InvocationThreshold, 200, \ + product(double, Tier3InvocationThreshold, 200, \ "Compile if number of method invocations crosses this " \ "threshold") \ range(0, max_jint) \ \ - product(intx, Tier3MinInvocationThreshold, 100, \ + product(double, Tier3MinInvocationThreshold, 100, \ "Minimum invocation to compile at tier 3") \ range(0, max_jint) \ \ - product(intx, Tier3CompileThreshold, 2000, \ + product(double, Tier3CompileThreshold, 2000, \ "Threshold at which tier 3 compilation is invoked (invocation " \ "minimum must be satisfied)") \ range(0, max_jint) \ \ - product(intx, Tier3BackEdgeThreshold, 60000, \ + product(double, Tier3BackEdgeThreshold, 60000, \ "Back edge threshold at which tier 3 OSR compilation is invoked") \ range(0, max_jint) \ \ - product(intx, Tier4InvocationThreshold, 5000, \ + product(double, Tier4InvocationThreshold, 5000, \ "Compile if number of method invocations crosses this " \ "threshold") \ range(0, max_jint) \ \ - product(intx, Tier4MinInvocationThreshold, 600, \ + product(double, Tier4MinInvocationThreshold, 600, \ "Minimum invocation to compile at tier 4") \ range(0, max_jint) \ \ - product(intx, Tier4CompileThreshold, 15000, \ + product(double, Tier4CompileThreshold, 15000, \ "Threshold at which tier 4 compilation is invoked (invocation " \ "minimum must be satisfied)") \ range(0, max_jint) \ \ - product(intx, Tier4BackEdgeThreshold, 40000, \ + product(double, Tier4BackEdgeThreshold, 40000, \ "Back edge threshold at which tier 4 OSR compilation is invoked") \ range(0, max_jint) \ \ diff --git a/src/hotspot/share/opto/bytecodeInfo.cpp b/src/hotspot/share/opto/bytecodeInfo.cpp index 35365f37f485f..891899e25f081 100644 --- a/src/hotspot/share/opto/bytecodeInfo.cpp +++ b/src/hotspot/share/opto/bytecodeInfo.cpp @@ -313,10 +313,10 @@ bool InlineTree::should_not_inline(ciMethod* callee_method, ciMethod* caller_met if (MinInlineFrequencyRatio > 0) { int call_site_count = caller_method->scale_count(profile.count()); int invoke_count = caller_method->interpreter_invocation_count(); - assert(invoke_count != 0, "require invocation count greater than zero"); + assert(invoke_count >= 0, "require invocation count greater than zero"); double freq = (double)call_site_count / (double)invoke_count; // avoid division by 0, set divisor to at least 1 - int cp_min_inv = MAX2(1, CompilationPolicy::min_invocations()); + double cp_min_inv = MAX2(1.0, CompilationPolicy::min_invocations()); double min_freq = MAX2(MinInlineFrequencyRatio, 1.0 / cp_min_inv); if (freq < min_freq) { From ce4ff5804d403c4b12c0d4c6e8efe84d55edb9b1 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Tue, 15 Oct 2024 06:39:28 +0000 Subject: [PATCH 2/3] updates tier2 threshold datatype --- src/hotspot/share/compiler/compiler_globals.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/compiler/compiler_globals.hpp b/src/hotspot/share/compiler/compiler_globals.hpp index a1c9df88389f9..9e19f45be1476 100644 --- a/src/hotspot/share/compiler/compiler_globals.hpp +++ b/src/hotspot/share/compiler/compiler_globals.hpp @@ -167,11 +167,11 @@ "frequency") \ range(0, 30) \ \ - product(intx, Tier2CompileThreshold, 0, \ + product(double, Tier2CompileThreshold, 0, \ "threshold at which tier 2 compilation is invoked") \ range(0, max_jint) \ \ - product(intx, Tier2BackEdgeThreshold, 0, \ + product(double, Tier2BackEdgeThreshold, 0, \ "Back edge threshold at which tier 2 compilation is invoked") \ range(0, max_jint) \ \ From 97d63a29ee0261786a7195c468e349cf122aca69 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Fri, 18 Oct 2024 09:14:16 +0530 Subject: [PATCH 3/3] review/comments --- .../share/compiler/compilationPolicy.cpp | 12 +++++------ .../share/compiler/compilationPolicy.hpp | 2 +- .../share/compiler/compiler_globals.hpp | 20 +++++++++---------- src/hotspot/share/opto/bytecodeInfo.cpp | 4 ++-- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/hotspot/share/compiler/compilationPolicy.cpp b/src/hotspot/share/compiler/compilationPolicy.cpp index 8fc70619abe7e..17c1f1df1e445 100644 --- a/src/hotspot/share/compiler/compilationPolicy.cpp +++ b/src/hotspot/share/compiler/compilationPolicy.cpp @@ -235,9 +235,9 @@ class LoopPredicate : AllStatic { switch(cur_level) { case CompLevel_none: case CompLevel_limited_profile: - return b >= Tier3BackEdgeThreshold * scale; + return b >= (double)Tier3BackEdgeThreshold * scale; case CompLevel_full_profile: - return b >= Tier4BackEdgeThreshold * scale; + return b >= (double)Tier4BackEdgeThreshold * scale; default: return true; } @@ -273,11 +273,11 @@ class CallPredicate : AllStatic { switch(cur_level) { case CompLevel_none: case CompLevel_limited_profile: - return (i >= Tier3InvocationThreshold * scale) || - (i >= Tier3MinInvocationThreshold * scale && i + b >= Tier3CompileThreshold * scale); + return (i >= (double)Tier3InvocationThreshold * scale) || + (i >= (double)Tier3MinInvocationThreshold * scale && i + b >= (double)Tier3CompileThreshold * scale); case CompLevel_full_profile: - return (i >= Tier4InvocationThreshold * scale) || - (i >= Tier4MinInvocationThreshold * scale && i + b >= Tier4CompileThreshold * scale); + return (i >= (double)Tier4InvocationThreshold * scale) || + (i >= (double)Tier4MinInvocationThreshold * scale && i + b >= (double)Tier4CompileThreshold * scale); default: return true; } diff --git a/src/hotspot/share/compiler/compilationPolicy.hpp b/src/hotspot/share/compiler/compilationPolicy.hpp index efb34f6aa3101..fe33fb8cfba28 100644 --- a/src/hotspot/share/compiler/compilationPolicy.hpp +++ b/src/hotspot/share/compiler/compilationPolicy.hpp @@ -248,7 +248,7 @@ class CompilationPolicy : AllStatic { // m must be compiled before executing it static bool must_be_compiled(const methodHandle& m, int comp_level = CompLevel_any); public: - static double min_invocations() { return Tier4MinInvocationThreshold; } + static int min_invocations() { return Tier4MinInvocationThreshold; } static int c1_count() { return _c1_count; } static int c2_count() { return _c2_count; } static int compiler_count(CompLevel comp_level); diff --git a/src/hotspot/share/compiler/compiler_globals.hpp b/src/hotspot/share/compiler/compiler_globals.hpp index 9e19f45be1476..a811cd8b3bae6 100644 --- a/src/hotspot/share/compiler/compiler_globals.hpp +++ b/src/hotspot/share/compiler/compiler_globals.hpp @@ -167,47 +167,47 @@ "frequency") \ range(0, 30) \ \ - product(double, Tier2CompileThreshold, 0, \ + product(intx, Tier2CompileThreshold, 0, \ "threshold at which tier 2 compilation is invoked") \ range(0, max_jint) \ \ - product(double, Tier2BackEdgeThreshold, 0, \ + product(intx, Tier2BackEdgeThreshold, 0, \ "Back edge threshold at which tier 2 compilation is invoked") \ range(0, max_jint) \ \ - product(double, Tier3InvocationThreshold, 200, \ + product(intx, Tier3InvocationThreshold, 200, \ "Compile if number of method invocations crosses this " \ "threshold") \ range(0, max_jint) \ \ - product(double, Tier3MinInvocationThreshold, 100, \ + product(intx, Tier3MinInvocationThreshold, 100, \ "Minimum invocation to compile at tier 3") \ range(0, max_jint) \ \ - product(double, Tier3CompileThreshold, 2000, \ + product(intx, Tier3CompileThreshold, 2000, \ "Threshold at which tier 3 compilation is invoked (invocation " \ "minimum must be satisfied)") \ range(0, max_jint) \ \ - product(double, Tier3BackEdgeThreshold, 60000, \ + product(intx, Tier3BackEdgeThreshold, 60000, \ "Back edge threshold at which tier 3 OSR compilation is invoked") \ range(0, max_jint) \ \ - product(double, Tier4InvocationThreshold, 5000, \ + product(intx, Tier4InvocationThreshold, 5000, \ "Compile if number of method invocations crosses this " \ "threshold") \ range(0, max_jint) \ \ - product(double, Tier4MinInvocationThreshold, 600, \ + product(intx, Tier4MinInvocationThreshold, 600, \ "Minimum invocation to compile at tier 4") \ range(0, max_jint) \ \ - product(double, Tier4CompileThreshold, 15000, \ + product(intx, Tier4CompileThreshold, 15000, \ "Threshold at which tier 4 compilation is invoked (invocation " \ "minimum must be satisfied)") \ range(0, max_jint) \ \ - product(double, Tier4BackEdgeThreshold, 40000, \ + product(intx, Tier4BackEdgeThreshold, 40000, \ "Back edge threshold at which tier 4 OSR compilation is invoked") \ range(0, max_jint) \ \ diff --git a/src/hotspot/share/opto/bytecodeInfo.cpp b/src/hotspot/share/opto/bytecodeInfo.cpp index 891899e25f081..fe8775790240c 100644 --- a/src/hotspot/share/opto/bytecodeInfo.cpp +++ b/src/hotspot/share/opto/bytecodeInfo.cpp @@ -313,10 +313,10 @@ bool InlineTree::should_not_inline(ciMethod* callee_method, ciMethod* caller_met if (MinInlineFrequencyRatio > 0) { int call_site_count = caller_method->scale_count(profile.count()); int invoke_count = caller_method->interpreter_invocation_count(); - assert(invoke_count >= 0, "require invocation count greater than zero"); + assert(invoke_count > 0, "require invocation count greater than zero"); double freq = (double)call_site_count / (double)invoke_count; // avoid division by 0, set divisor to at least 1 - double cp_min_inv = MAX2(1.0, CompilationPolicy::min_invocations()); + int cp_min_inv = MAX2(1, CompilationPolicy::min_invocations()); double min_freq = MAX2(MinInlineFrequencyRatio, 1.0 / cp_min_inv); if (freq < min_freq) {