Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] 8225776: Optimize branch frequency of G1's write post-barrier in C2 #769

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,8 @@ void G1BarrierSetC2::post_barrier(GraphKit* kit,
Node* tls = __ thread(); // ThreadLocalStorage

Node* no_base = __ top();
float unlikely = PROB_UNLIKELY(0.999);
float likely = PROB_LIKELY_MAG(3);
float unlikely = PROB_UNLIKELY_MAG(3);
Node* young_card = __ ConI((jint)G1CardTable::g1_young_card_val());
Node* dirty_card = __ ConI((jint)G1CardTable::dirty_card_val());
Node* zeroX = __ ConX(0);
Expand Down Expand Up @@ -457,17 +458,17 @@ void G1BarrierSetC2::post_barrier(GraphKit* kit,
Node* xor_res = __ URShiftX ( __ XorX( cast, __ CastPX(__ ctrl(), val)), __ ConI(HeapRegion::LogOfHRGrainBytes));

// if (xor_res == 0) same region so skip
__ if_then(xor_res, BoolTest::ne, zeroX); {
__ if_then(xor_res, BoolTest::ne, zeroX, likely); {

// No barrier if we are storing a NULL
__ if_then(val, BoolTest::ne, kit->null(), unlikely); {
__ if_then(val, BoolTest::ne, kit->null(), likely); {

// Ok must mark the card if not already dirty

// load the original value of the card
Node* card_val = __ load(__ ctrl(), card_adr, TypeInt::INT, T_BYTE, Compile::AliasIdxRaw);

__ if_then(card_val, BoolTest::ne, young_card); {
__ if_then(card_val, BoolTest::ne, young_card, unlikely); {
kit->sync_kit(ideal);
kit->insert_mem_bar(Op_MemBarVolatile, oop_store);
__ sync_kit(kit);
Expand Down
84 changes: 58 additions & 26 deletions test/hotspot/jtreg/compiler/c2/aarch64/TestVolatiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,14 +331,18 @@ private void checkstore(OutputAnalyzer output, String testType, boolean useBarri
case "G1":
// a card mark volatile barrier should be generated
// before the card mark strb
//
// following the fix for 8225776 the G1 barrier is now
// scheduled out of line after the membar volatile and
// and subsequent return
matches = new String[] {
"membar_release \\(elided\\)",
useCompressedOops ? "stlrw?" : "stlr",
"membar_volatile \\(elided\\)",
"ret",
"membar_volatile",
"dmb ish",
"strb",
"membar_volatile \\(elided\\)",
"ret"
"strb"
};
break;
case "CMSCondMark":
Expand Down Expand Up @@ -399,16 +403,20 @@ private void checkstore(OutputAnalyzer output, String testType, boolean useBarri
case "G1":
// a card mark volatile barrier should be generated
// before the card mark strb
//
// following the fix for 8225776 the G1 barrier is now
// scheduled out of line after the membar volatile and
// and subsequent return
matches = new String[] {
"membar_release",
"dmb ish",
useCompressedOops ? "strw?" : "str",
"membar_volatile",
"dmb ish",
"strb",
"ret",
"membar_volatile",
"dmb ish",
"ret"
"strb"
};
break;
case "CMSCondMark":
Expand Down Expand Up @@ -522,14 +530,18 @@ private void checkcas(OutputAnalyzer output, String testType, boolean useBarrier
case "G1":
// a card mark volatile barrier should be generated
// before the card mark strb
//
// following the fix for 8225776 the G1 barrier is now
// scheduled out of line after the membar acquire and
// and subsequent return
matches = new String[] {
"membar_release \\(elided\\)",
useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
"membar_acquire \\(elided\\)",
"ret",
"membar_volatile",
"dmb ish",
"strb",
"membar_acquire \\(elided\\)",
"ret"
"strb"
};
break;
case "CMSCondMark":
Expand Down Expand Up @@ -589,16 +601,20 @@ private void checkcas(OutputAnalyzer output, String testType, boolean useBarrier
case "G1":
// a card mark volatile barrier should be generated
// before the card mark strb
//
// following the fix for 8225776 the G1 barrier is now
// scheduled out of line after the membar acquire and
// and subsequent return
matches = new String[] {
"membar_release",
"dmb ish",
useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
"membar_volatile",
"dmb ish",
"strb",
"membar_acquire",
"dmb ish",
"ret"
"ret",
"membar_volatile",
"dmb ish",
"strb"
};
break;
case "CMSCondMark":
Expand Down Expand Up @@ -725,14 +741,18 @@ private void checkcae(OutputAnalyzer output, String testType, boolean useBarrier
case "G1":
// a card mark volatile barrier should be generated
// before the card mark strb
//
// following the fix for 8225776 the G1 barrier is now
// scheduled out of line after the membar acquire and
// and subsequent return
matches = new String[] {
"membar_release \\(elided\\)",
useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
"membar_acquire \\(elided\\)",
"ret",
"membar_volatile",
"dmb ish",
"strb",
"membar_acquire \\(elided\\)",
"ret"
"strb"
};
break;
case "CMSCondMark":
Expand Down Expand Up @@ -781,16 +801,20 @@ private void checkcae(OutputAnalyzer output, String testType, boolean useBarrier
case "G1":
// a card mark volatile barrier should be generated
// before the card mark strb
//
// following the fix for 8225776 the G1 barrier is now
// scheduled out of line after the membar acquire and
// and subsequent return
matches = new String[] {
"membar_release",
"dmb ish",
useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
"membar_volatile",
"dmb ish",
"strb",
"membar_acquire",
"dmb ish",
"ret"
"ret",
"membar_volatile",
"dmb ish",
"strb"
};
break;
case "CMSCondMark":
Expand Down Expand Up @@ -899,14 +923,18 @@ private void checkgas(OutputAnalyzer output, String testType, boolean useBarrier
case "G1":
// a card mark volatile barrier should be generated
// before the card mark strb
//
// following the fix for 8225776 the G1 barrier is now
// scheduled out of line after the membar acquire and
// and subsequent return
matches = new String[] {
"membar_release \\(elided\\)",
useCompressedOops ? "atomic_xchgw?_acq" : "atomic_xchg_acq",
"membar_acquire \\(elided\\)",
"ret",
"membar_volatile",
"dmb ish",
"strb",
"membar_acquire \\(elided\\)",
"ret"
"strb"
};
break;
case "CMSCondMark":
Expand Down Expand Up @@ -955,16 +983,20 @@ private void checkgas(OutputAnalyzer output, String testType, boolean useBarrier
case "G1":
// a card mark volatile barrier should be generated
// before the card mark strb
//
// following the fix for 8225776 the G1 barrier is now
// scheduled out of line after the membar acquire and
// and subsequent return
matches = new String[] {
"membar_release",
"dmb ish",
useCompressedOops ? "atomic_xchgw? " : "atomic_xchg ",
"membar_volatile",
"dmb ish",
"strb",
"membar_acquire",
"dmb ish",
"ret"
"ret",
"membar_volatile",
"dmb ish",
"strb"
};
break;
case "CMSCondMark":
Expand Down
Loading