Skip to content

Commit 01af2b4

Browse files
author
Quan Anh Mai
committed
8336003: [lworld] TestLWorld::test151 triggers "Should have been buffered" assert
Reviewed-by: thartmann
1 parent a565d8b commit 01af2b4

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

src/hotspot/share/opto/cfgnode.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,10 @@ Node* PhiNode::Identity(PhaseGVN* phase) {
14761476
if (uin != nullptr) {
14771477
return uin;
14781478
}
1479+
uin = unique_input_recursive(phase);
1480+
if (uin != nullptr) {
1481+
return uin;
1482+
}
14791483

14801484
int true_path = is_diamond_phi();
14811485
// Delay CMove'ing identity if Ideal has not had the chance to handle unsafe cases, yet.
@@ -1575,6 +1579,39 @@ Node* PhiNode::unique_input(PhaseValues* phase, bool uncast) {
15751579
return nullptr;
15761580
}
15771581

1582+
// Find the unique input, try to look recursively through input Phis
1583+
Node* PhiNode::unique_input_recursive(PhaseGVN* phase) {
1584+
if (!phase->is_IterGVN()) {
1585+
return nullptr;
1586+
}
1587+
1588+
ResourceMark rm;
1589+
Node* unique = nullptr;
1590+
Unique_Node_List visited;
1591+
visited.push(this);
1592+
1593+
for (uint visited_idx = 0; visited_idx < visited.size(); visited_idx++) {
1594+
Node* current = visited.at(visited_idx);
1595+
for (uint i = 1; i < current->req(); i++) {
1596+
Node* phi_in = current->in(i);
1597+
if (phi_in == nullptr) {
1598+
continue;
1599+
}
1600+
1601+
if (phi_in->is_Phi()) {
1602+
visited.push(phi_in);
1603+
} else {
1604+
if (unique == nullptr) {
1605+
unique = phi_in;
1606+
} else if (unique != phi_in) {
1607+
return nullptr;
1608+
}
1609+
}
1610+
}
1611+
}
1612+
return unique;
1613+
}
1614+
15781615
//------------------------------is_x2logic-------------------------------------
15791616
// Check for simple convert-to-boolean pattern
15801617
// If:(C Bool) Region:(IfF IfT) Phi:(Region 0 1)

src/hotspot/share/opto/cfgnode.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ class PhiNode : public TypeNode {
232232
}
233233
return uin;
234234
}
235+
Node* unique_input_recursive(PhaseGVN* phase);
235236

236237
// Check for a simple dead loop.
237238
enum LoopSafety { Safe = 0, Unsafe, UnsafeLoop };

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4156,13 +4156,14 @@ public void test150_verifier() {
41564156
Asserts.assertEquals(test150(), testValue2.hash());
41574157
}
41584158

4159-
// TODO 8336003 This triggers # assert(false) failed: Should have been buffered
4160-
/*
4161-
// Same as test150 but with val not being allocated in the scope of the method
4159+
// Same as test150 but with a real loop and val not being allocated in the scope of the method
41624160
@Test
4161+
// Dynamic call does not null check the receiver, so it cannot be strength reduced to a static
4162+
// call without an explicit null check
41634163
@IR(failOn = {compiler.lib.ir_framework.IRNode.DYNAMIC_CALL_OF_METHOD, "MyValue2::hash"},
41644164
counts = {compiler.lib.ir_framework.IRNode.STATIC_CALL_OF_METHOD, "MyValue2::hash", "= 1"})
41654165
public long test151(MyValue2 val) {
4166+
val = Objects.requireNonNull(val);
41664167
MyAbstract receiver = MyValue1.createWithFieldsInline(rI, rL);
41674168

41684169
for (int i = 0; i < 100; i++) {
@@ -4180,7 +4181,6 @@ public long test151(MyValue2 val) {
41804181
public void test151_verifier() {
41814182
Asserts.assertEquals(test151(testValue2), testValue2.hash());
41824183
}
4183-
*/
41844184

41854185
static interface MyInterface2 {
41864186
public int val();

0 commit comments

Comments
 (0)