Skip to content

Commit 39c775f

Browse files
committed
8256481: [lworld] C2 fails to eliminate GC barriers when replacing inline type buffer allocation
1 parent e9217da commit 39c775f

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

src/hotspot/share/gc/g1/c2/g1BarrierSetC2.cpp

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -698,24 +698,22 @@ void G1BarrierSetC2::eliminate_gc_barrier(PhaseIterGVN* igvn, Node* node) const
698698
// There is no G1 pre barrier if previous stored value is NULL
699699
// (for example, after initialization).
700700
if (this_region->is_Region() && this_region->req() == 3) {
701-
int ind = 1;
702-
if (!this_region->in(ind)->is_IfFalse()) {
703-
ind = 2;
704-
}
705-
if (this_region->in(ind)->is_IfFalse() &&
706-
this_region->in(ind)->in(0)->Opcode() == Op_If) {
707-
Node* bol = this_region->in(ind)->in(0)->in(1);
708-
assert(bol->is_Bool(), "");
709-
cmpx = bol->in(1);
710-
if (bol->as_Bool()->_test._test == BoolTest::ne &&
711-
cmpx->is_Cmp() && cmpx->in(2) == igvn->intcon(0) &&
712-
cmpx->in(1)->is_Load()) {
713-
Node* adr = cmpx->in(1)->as_Load()->in(MemNode::Address);
714-
const int marking_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset());
715-
if (adr->is_AddP() && adr->in(AddPNode::Base) == igvn->C->top() &&
716-
adr->in(AddPNode::Address)->Opcode() == Op_ThreadLocal &&
717-
adr->in(AddPNode::Offset) == igvn->MakeConX(marking_offset)) {
718-
igvn->replace_node(cmpx, igvn->makecon(TypeInt::CC_EQ));
701+
for (int i = 1; i < 3; ++i) {
702+
if (this_region->in(i)->is_IfFalse() &&
703+
this_region->in(i)->in(0)->is_If() &&
704+
this_region->in(i)->in(0)->in(1)->is_Bool()) {
705+
Node* bol = this_region->in(i)->in(0)->in(1);
706+
cmpx = bol->in(1);
707+
if (bol->as_Bool()->_test._test == BoolTest::ne &&
708+
cmpx->is_Cmp() && cmpx->in(2) == igvn->intcon(0) &&
709+
cmpx->in(1)->is_Load()) {
710+
Node* adr = cmpx->in(1)->as_Load()->in(MemNode::Address);
711+
const int marking_offset = in_bytes(G1ThreadLocalData::satb_mark_queue_active_offset());
712+
if (adr->is_AddP() && adr->in(AddPNode::Base) == igvn->C->top() &&
713+
adr->in(AddPNode::Address)->Opcode() == Op_ThreadLocal &&
714+
adr->in(AddPNode::Offset) == igvn->MakeConX(marking_offset)) {
715+
igvn->replace_node(cmpx, igvn->makecon(TypeInt::CC_EQ));
716+
}
719717
}
720718
}
721719
}

src/hotspot/share/gc/shared/c2/cardTableBarrierSetC2.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,23 @@ bool CardTableBarrierSetC2::is_gc_barrier_node(Node* node) const {
170170

171171
void CardTableBarrierSetC2::eliminate_gc_barrier(PhaseIterGVN* igvn, Node* node) const {
172172
assert(node->Opcode() == Op_CastP2X, "ConvP2XNode required");
173-
Node *shift = node->unique_out();
174-
Node *addp = shift->unique_out();
175-
for (DUIterator_Last jmin, j = addp->last_outs(jmin); j >= jmin; --j) {
176-
Node *mem = addp->last_out(j);
177-
if (UseCondCardMark && mem->is_Load()) {
178-
assert(mem->Opcode() == Op_LoadB, "unexpected code shape");
179-
// The load is checking if the card has been written so
180-
// replace it with zero to fold the test.
181-
igvn->replace_node(mem, igvn->intcon(0));
182-
continue;
173+
for (DUIterator_Last imin, i = node->last_outs(imin); i >= imin; --i) {
174+
Node* shift = node->last_out(i);
175+
for (DUIterator_Last jmin, j = shift->last_outs(jmin); j >= jmin; --j) {
176+
Node* addp = shift->last_out(j);
177+
for (DUIterator_Last kmin, k = addp->last_outs(kmin); k >= kmin; --k) {
178+
Node* mem = addp->last_out(k);
179+
if (UseCondCardMark && mem->is_Load()) {
180+
assert(mem->Opcode() == Op_LoadB, "unexpected code shape");
181+
// The load is checking if the card has been written so
182+
// replace it with zero to fold the test.
183+
igvn->replace_node(mem, igvn->intcon(0));
184+
continue;
185+
}
186+
assert(mem->is_Store(), "store required");
187+
igvn->replace_node(mem, mem->in(MemNode::Memory));
188+
}
183189
}
184-
assert(mem->is_Store(), "store required");
185-
igvn->replace_node(mem, mem->in(MemNode::Memory));
186190
}
187191
}
188192

0 commit comments

Comments
 (0)