From 0eca30db2fe14f1c1786752f7c565ddda1c02064 Mon Sep 17 00:00:00 2001 From: vamsi-parasa Date: Thu, 12 Jun 2025 12:33:07 -0700 Subject: [PATCH 1/3] 8359386: Fix incorrect value for max_size of C2CodeStub when APX is used --- src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp index 177be6e59f74a..d36430ad0c0f7 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp @@ -4687,7 +4687,9 @@ void C2_MacroAssembler::convertF2I(BasicType dst_bt, BasicType src_bt, Register } } - auto stub = C2CodeStub::make(dst, src, slowpath_target, 23, convertF2I_slowpath); + // Using the APX extended general purpose registers increases the instruction encoding size by 4 bytes. + int max_size = dst->encoding() <= 15 ? 23 : 27; + auto stub = C2CodeStub::make(dst, src, slowpath_target, max_size, convertF2I_slowpath); jcc(Assembler::equal, stub->entry()); bind(stub->continuation()); } From 37dede6e7a5b2b253958d3092a6ac9883f77fdc8 Mon Sep 17 00:00:00 2001 From: vamsi-parasa Date: Mon, 16 Jun 2025 12:37:08 -0700 Subject: [PATCH 2/3] update max_size computation to be explicit --- src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp index d36430ad0c0f7..4ff288472d4b3 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp @@ -4688,7 +4688,7 @@ void C2_MacroAssembler::convertF2I(BasicType dst_bt, BasicType src_bt, Register } // Using the APX extended general purpose registers increases the instruction encoding size by 4 bytes. - int max_size = dst->encoding() <= 15 ? 23 : 27; + int max_size = 23 + (UseAPX ? 4 : 0); auto stub = C2CodeStub::make(dst, src, slowpath_target, max_size, convertF2I_slowpath); jcc(Assembler::equal, stub->entry()); bind(stub->continuation()); From 4fe56be6bf1845b305d76c78633780381450190f Mon Sep 17 00:00:00 2001 From: vamsi-parasa Date: Mon, 16 Jun 2025 20:59:47 -0700 Subject: [PATCH 3/3] Fix the change in the stub size by 1 byte --- src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp index 4ff288472d4b3..4317bb3d01825 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp @@ -4655,6 +4655,7 @@ static void convertF2I_slowpath(C2_MacroAssembler& masm, C2GeneralStub(dst, src, slowpath_target, max_size, convertF2I_slowpath); jcc(Assembler::equal, stub->entry()); bind(stub->continuation());