From 9f8d833f8654cb4280d002ef86ce3ae9d709eddc Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 17 Mar 2025 07:57:45 +0000 Subject: [PATCH] 8346194: Improve G1 pre-barrier C2 cost estimate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Roberto CastaƱeda Lozano Reviewed-by: rcastanedalo, ayang --- src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp index 71fd3ec6610..57e481668f8 100644 --- a/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp +++ b/src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp @@ -287,15 +287,15 @@ bool G1BarrierSetC2::expand_barriers(Compile* C, PhaseIterGVN& igvn) const { } uint G1BarrierSetC2::estimated_barrier_size(const Node* node) const { - // These Ideal node counts are extracted from the pre-matching Ideal graph - // generated when compiling the following method with early barrier expansion: - // static void write(MyObject obj1, Object o) { - // obj1.o1 = o; - // } uint8_t barrier_data = MemNode::barrier_data(node); uint nodes = 0; if ((barrier_data & G1C2BarrierPre) != 0) { - nodes += 50; + // Only consider the fast path for the barrier that is + // actually inlined into the main code stream. + // The slow path is laid out separately and does not + // directly affect performance. + // It has a cost of 6 (AddP, LoadB, Cmp, Bool, If, IfProj). + nodes += 6; } if ((barrier_data & G1C2BarrierPost) != 0) { nodes += 60;