8346194: Improve G1 pre-barrier C2 cost estimate

Co-authored-by: Roberto Castañeda Lozano <rcastanedalo@openjdk.org>
Reviewed-by: rcastanedalo, ayang
This commit is contained in:
Thomas Schatzl 2025-03-17 07:57:45 +00:00
parent 2672c40bf1
commit 9f8d833f86

View File

@ -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;