Skip to content

Commit 2ba3cd6

Browse files
Satyen SubramaniamPaul Hohensee
authored andcommitted
8328107: Shenandoah/C2: TestVerifyLoopOptimizations test failure
Backport-of: b5212d7bfe78b18c18e45c42c724a22365709328
1 parent b2225c8 commit 2ba3cd6

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,6 +1322,14 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) {
13221322
OuterStripMinedLoopNode* outer = head->as_OuterStripMinedLoop();
13231323
hide_strip_mined_loop(outer, outer->unique_ctrl_out()->as_CountedLoop(), phase);
13241324
}
1325+
if (head->is_BaseCountedLoop() && ctrl->is_IfProj() && ctrl->in(0)->is_BaseCountedLoopEnd() &&
1326+
head->as_BaseCountedLoop()->loopexit() == ctrl->in(0)) {
1327+
Node* entry = head->in(LoopNode::EntryControl);
1328+
Node* backedge = head->in(LoopNode::LoopBackControl);
1329+
Node* new_head = new LoopNode(entry, backedge);
1330+
phase->register_control(new_head, phase->get_loop(entry), entry);
1331+
phase->lazy_replace(head, new_head);
1332+
}
13251333
}
13261334

13271335
// Expand load-reference-barriers
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright (c) 2024, Red Hat, Inc. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/**
25+
* @test
26+
* @bug 8328107
27+
* @summary Barrier expanded on backedge break loop verification code
28+
* @requires vm.gc.Shenandoah
29+
*
30+
* @run main/othervm -XX:+UseShenandoahGC -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestBarrierOnLoopBackedge::notInlined
31+
* -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyLoopOptimizations TestBarrierOnLoopBackedge
32+
* @run main/othervm -XX:+UseShenandoahGC -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestBarrierOnLoopBackedge::notInlined
33+
* -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyLoopOptimizations -XX:-UseCountedLoopSafepoints TestBarrierOnLoopBackedge
34+
*/
35+
36+
public class TestBarrierOnLoopBackedge {
37+
private static A field = new A();
38+
private static final A finalField = new A();
39+
private static float floatField;
40+
41+
public static void main(String[] args) {
42+
A[] array = new A[1];
43+
array[0] = finalField;
44+
for (int i = 0; i < 20_000; i++) {
45+
test1();
46+
test2();
47+
}
48+
}
49+
50+
private static void test1() {
51+
floatField = field.f;
52+
for (int i = 0; i < 1000; i++) {
53+
notInlined(field); // load barrier split thru phi and ends up on back edge
54+
if (i % 2 == 0) {
55+
field = finalField;
56+
}
57+
}
58+
}
59+
60+
private static void test2() {
61+
A[] array = new A[1];
62+
notInlined(array);
63+
int i = 0;
64+
A a = array[0];
65+
for (;;) {
66+
synchronized (new Object()) {
67+
}
68+
notInlined(a);
69+
i++;
70+
if (i >= 1000) {
71+
break;
72+
}
73+
a = array[0]; // load barrier pinned on backedge
74+
}
75+
}
76+
77+
private static void notInlined(Object a) {
78+
79+
}
80+
81+
private static class A {
82+
float f;
83+
}
84+
}

0 commit comments

Comments
 (0)