Skip to content

Commit a3aad11

Browse files
committed
8255400: Shenandoah: C2 failures after JDK-8255000
Reviewed-by: rkennke
1 parent 1769c48 commit a3aad11

File tree

2 files changed

+87
-6
lines changed

2 files changed

+87
-6
lines changed

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,12 +2314,12 @@ void MemoryGraphFixer::collect_memory_nodes() {
23142314
Node* m = _memory_nodes[c->in(k)->_idx];
23152315
assert(m != NULL, "expect memory state");
23162316
if (u->in(k) != m) {
2317-
phi = NULL;
2317+
phi = NodeSentinel;
23182318
}
23192319
}
23202320
}
23212321
}
2322-
if (phi == NULL) {
2322+
if (phi == NodeSentinel) {
23232323
phi = new PhiNode(c, Type::MEMORY, _phase->C->get_adr_type(_alias));
23242324
for (uint k = 1; k < c->req(); k++) {
23252325
Node* m = _memory_nodes[c->in(k)->_idx];
@@ -2328,8 +2328,11 @@ void MemoryGraphFixer::collect_memory_nodes() {
23282328
}
23292329
}
23302330
}
2331-
assert(phi != NULL, "");
2332-
regions.map(c->_idx, phi);
2331+
if (phi != NULL) {
2332+
regions.map(c->_idx, phi);
2333+
} else {
2334+
assert(c->unique_ctrl_out()->Opcode() == Op_Halt, "expected memory state");
2335+
}
23332336
}
23342337
Node* current_region = regions[c->_idx];
23352338
if (current_region != prev_region) {
@@ -2340,7 +2343,7 @@ void MemoryGraphFixer::collect_memory_nodes() {
23402343
}
23412344
} else if (prev_mem == NULL || prev_mem->is_Phi() || ctrl_or_self(prev_mem) != c) {
23422345
Node* m = _memory_nodes[_phase->idom(c)->_idx];
2343-
assert(m != NULL, "expect memory state");
2346+
assert(m != NULL || c->Opcode() == Op_Halt, "expect memory state");
23442347
if (m != prev_mem) {
23452348
_memory_nodes.map(c->_idx, m);
23462349
progress = true;
@@ -2364,7 +2367,8 @@ void MemoryGraphFixer::collect_memory_nodes() {
23642367
Node* c = rpo_list.at(i);
23652368
if (c->is_Region() && (_include_lsm || !c->is_OuterStripMinedLoop())) {
23662369
Node* n = regions[c->_idx];
2367-
if (n->is_Phi() && n->_idx >= last && n->in(0) == c) {
2370+
assert(n != NULL || c->unique_ctrl_out()->Opcode() == Op_Halt, "expected memory state");
2371+
if (n != NULL && n->is_Phi() && n->_idx >= last && n->in(0) == c) {
23682372
_phase->register_new_node(n, c);
23692373
}
23702374
}
@@ -2373,10 +2377,12 @@ void MemoryGraphFixer::collect_memory_nodes() {
23732377
Node* c = rpo_list.at(i);
23742378
if (c->is_Region() && (_include_lsm || !c->is_OuterStripMinedLoop())) {
23752379
Node* n = regions[c->_idx];
2380+
assert(n != NULL || c->unique_ctrl_out()->Opcode() == Op_Halt, "expected memory state");
23762381
for (DUIterator_Fast imax, i = c->fast_outs(imax); i < imax; i++) {
23772382
Node* u = c->fast_out(i);
23782383
if (u->is_Phi() && u->bottom_type() == Type::MEMORY &&
23792384
u != n) {
2385+
assert(c->unique_ctrl_out()->Opcode() != Op_Halt, "expected memory state");
23802386
if (u->adr_type() == TypePtr::BOTTOM) {
23812387
fix_memory_uses(u, n, n, c);
23822388
} else if (_phase->C->get_alias_index(u->adr_type()) == _alias) {
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (c) 2020, 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 8255400
27+
* @summary C2 failures after JDK-8255000
28+
* @requires vm.gc.Shenandoah
29+
* @modules java.base/jdk.internal.misc:+open
30+
*
31+
* @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:-TieredCompilation -XX:+UseShenandoahGC TestBarrierExpansionDeadMemPhi
32+
*
33+
*
34+
*/
35+
36+
import jdk.internal.misc.Unsafe;
37+
import java.util.Arrays;
38+
import java.lang.reflect.Field;
39+
40+
public class TestBarrierExpansionDeadMemPhi {
41+
42+
static final jdk.internal.misc.Unsafe UNSAFE = Unsafe.getUnsafe();
43+
44+
static final long F_OFFSET;
45+
46+
static class A {
47+
int f;
48+
}
49+
50+
static {
51+
try {
52+
Field fField = A.class.getDeclaredField("f");
53+
F_OFFSET = UNSAFE.objectFieldOffset(fField);
54+
} catch (Exception e) {
55+
throw new RuntimeException(e);
56+
}
57+
}
58+
59+
static int test(Object[] array) {
60+
int f = 0;
61+
for (int i = 0; i < 100; i++) {
62+
f += UNSAFE.getInt(array[i], F_OFFSET);
63+
}
64+
return f;
65+
}
66+
67+
static public void main(String[] args) {
68+
Object[] array = new Object[100];
69+
Arrays.fill(array, new A());
70+
71+
for (int i = 0; i < 20000; i++) {
72+
test(array);
73+
}
74+
}
75+
}

0 commit comments

Comments
 (0)