Skip to content

Commit a0ec244

Browse files
mhaessigchhagedorn
authored andcommitted
8367244: [lworld] C2 compilation fails with assert "no node with a side effect"
Reviewed-by: chagedorn
1 parent a747808 commit a0ec244

File tree

4 files changed

+83
-8
lines changed

4 files changed

+83
-8
lines changed

src/hotspot/share/opto/parse.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ class Parse : public GraphKit {
572572
bool path_is_suitable_for_uncommon_trap(float prob) const;
573573

574574
void do_ifnull(BoolTest::mask btest, Node* c);
575-
void do_if(BoolTest::mask btest, Node* c, bool can_trap = true, bool new_path = false, Node** ctrl_taken = nullptr);
575+
void do_if(BoolTest::mask btest, Node* c, bool can_trap = true, bool new_path = false, Node** ctrl_taken = nullptr, Node** stress_count_mem = nullptr);
576576
void do_acmp(BoolTest::mask btest, Node* left, Node* right);
577577
void acmp_always_null_input(Node* input, const TypeOopPtr* tinput, BoolTest::mask btest, Node* eq_region);
578578
void acmp_known_non_inline_type_input(Node* input, const TypeOopPtr* tinput, ProfilePtrKind input_ptr, ciKlass* input_type, BoolTest::mask btest, Node* eq_region);

src/hotspot/share/opto/parse2.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1819,7 +1819,7 @@ void Parse::do_ifnull(BoolTest::mask btest, Node *c) {
18191819
}
18201820

18211821
//------------------------------------do_if------------------------------------
1822-
void Parse::do_if(BoolTest::mask btest, Node* c, bool can_trap, bool new_path, Node** ctrl_taken) {
1822+
void Parse::do_if(BoolTest::mask btest, Node* c, bool can_trap, bool new_path, Node** ctrl_taken, Node** stress_count_mem) {
18231823
int target_bci = iter().get_dest();
18241824

18251825
Block* branch_block = successor_for_bci(target_bci);
@@ -1850,6 +1850,9 @@ void Parse::do_if(BoolTest::mask btest, Node* c, bool can_trap, bool new_path, N
18501850
bool do_stress_trap = StressUnstableIfTraps && ((C->random() % 2) == 0);
18511851
if (do_stress_trap) {
18521852
increment_trap_stress_counter(counter, incr_store);
1853+
if (stress_count_mem != nullptr) {
1854+
*stress_count_mem = incr_store;
1855+
}
18531856
}
18541857

18551858
// Sanity check the probability value
@@ -2314,22 +2317,26 @@ void Parse::do_acmp(BoolTest::mask btest, Node* left, Node* right) {
23142317
// This is the last check, do_if can emit traps now.
23152318
Node* subst_cmp = _gvn.transform(new CmpINode(ret, intcon(1)));
23162319
Node* ctl = C->top();
2320+
Node* stress_count_mem = nullptr;
23172321
if (btest == BoolTest::eq) {
23182322
PreserveJVMState pjvms(this);
2319-
do_if(btest, subst_cmp, can_trap);
2323+
do_if(btest, subst_cmp, can_trap, false, nullptr, &stress_count_mem);
23202324
if (!stopped()) {
23212325
ctl = control();
23222326
}
23232327
} else {
23242328
assert(btest == BoolTest::ne, "only eq or ne");
23252329
PreserveJVMState pjvms(this);
2326-
do_if(btest, subst_cmp, can_trap, false, &ctl);
2330+
do_if(btest, subst_cmp, can_trap, false, &ctl, &stress_count_mem);
23272331
if (!stopped()) {
23282332
eq_region->init_req(2, control());
23292333
eq_io_phi->init_req(2, i_o());
23302334
eq_mem_phi->init_req(2, reset_memory());
23312335
}
23322336
}
2337+
if (stress_count_mem != nullptr) {
2338+
set_memory(stress_count_mem, stress_count_mem->adr_type());
2339+
}
23332340
ne_region->init_req(5, ctl);
23342341
ne_io_phi->init_req(5, i_o());
23352342
ne_mem_phi->init_req(5, reset_memory());
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. 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+
* @key randomness
27+
* @bug 8367244
28+
* @summary Ensure the stress counter is wired correctly with StressUnstableIf for acmp.
29+
* @enablePreview
30+
* @run main/othervm -Xbatch -XX:-TieredCompilation
31+
* -XX:CompileCommand=compileonly,compiler/valhalla/inlinetypes/TestAcmpStressUnstableIf.test
32+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressUnstableIfTraps -XX:StressSeed=3862475856
33+
* compiler.valhalla.inlinetypes.TestAcmpStressUnstableIf
34+
* @run main/othervm -Xbatch -XX:-TieredCompilation
35+
* -XX:CompileCommand=compileonly,compiler/valhalla/inlinetypes/TestAcmpStressUnstableIf.test
36+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressUnstableIfTraps
37+
* compiler.valhalla.inlinetypes.TestAcmpStressUnstableIf
38+
* @run main compiler.valhalla.inlinetypes.TestAcmpStressUnstableIf
39+
*/
40+
41+
package compiler.valhalla.inlinetypes;
42+
43+
public class TestAcmpStressUnstableIf {
44+
static value class MyValue {
45+
int x;
46+
47+
public MyValue(int x) {
48+
this.x = x;
49+
}
50+
}
51+
52+
public static void main(String[] args) {
53+
MyValue val = new MyValue(123456);
54+
MyValue val_copy = new MyValue(123456);
55+
MyValue val_diff = new MyValue(123456 + 1);
56+
57+
test(val, val_copy, val_diff);
58+
}
59+
60+
public static void test(MyValue val, MyValue val_copy, MyValue val_diff) {
61+
for (int i = 0; i < 30_000; ++i) {
62+
if (val != val_copy) {
63+
return;
64+
}
65+
if (val == val_diff) {
66+
return;
67+
}
68+
}
69+
}
70+
}

test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestAcmpWithUnstableIf.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@
2727
* @summary Test that deoptimization at unstable ifs in acmp works as expected.
2828
* @library /test/lib
2929
* @enablePreview
30-
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:-StressUnstableIfTraps compiler.valhalla.inlinetypes.TestAcmpWithUnstableIf
30+
* @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+StressUnstableIfTraps compiler.valhalla.inlinetypes.TestAcmpWithUnstableIf
3131
* @run main/othervm -XX:CompileCommand=compileonly,compiler.valhalla.inlinetypes.TestAcmpWithUnstableIf::test* -Xbatch
32-
* -XX:+UnlockDiagnosticVMOptions -XX:-StressUnstableIfTraps compiler.valhalla.inlinetypes.TestAcmpWithUnstableIf
32+
* -XX:+UnlockDiagnosticVMOptions -XX:+StressUnstableIfTraps compiler.valhalla.inlinetypes.TestAcmpWithUnstableIf
3333
*/
3434

35-
// TODO 8367244: Remove -XX:-StressUnstableIfTraps again.
36-
3735
package compiler.valhalla.inlinetypes;
3836

3937
import jdk.test.lib.Asserts;

0 commit comments

Comments
 (0)