Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
8258393: Shenandoah: "graph should be schedulable" assert failure
Reviewed-by: rkennke, thartmann
  • Loading branch information
rwestrel committed Jan 5, 2021
1 parent 4ffbe84 commit 6775113ce88cc819e7c3242730837e4afd7733b0
Showing 3 changed files with 112 additions and 7 deletions.
@@ -2459,6 +2459,21 @@ bool MemoryGraphFixer::mem_is_valid(Node* m, Node* c) const {

Node* MemoryGraphFixer::find_mem(Node* ctrl, Node* n) const {
assert(n == NULL || _phase->ctrl_or_self(n) == ctrl, "");
assert(!ctrl->is_Call() || ctrl == n, "projection expected");
#ifdef ASSERT
if ((ctrl->is_Proj() && ctrl->in(0)->is_Call()) ||
(ctrl->is_Catch() && ctrl->in(0)->in(0)->is_Call())) {
CallNode* call = ctrl->is_Proj() ? ctrl->in(0)->as_Call() : ctrl->in(0)->in(0)->as_Call();
int mems = 0;
for (DUIterator_Fast imax, i = call->fast_outs(imax); i < imax; i++) {
Node* u = call->fast_out(i);
if (u->bottom_type() == Type::MEMORY) {
mems++;
}
}
assert(mems <= 1, "No node right after call if multiple mem projections");
}
#endif
Node* mem = _memory_nodes[ctrl->_idx];
Node* c = ctrl;
while (!mem_is_valid(mem, c) &&
@@ -4968,26 +4968,26 @@ Node *PhaseIdealLoop::get_late_ctrl( Node *n, Node *early ) {
if (n->is_Load() && LCA != early) {
int load_alias_idx = C->get_alias_index(n->adr_type());
if (C->alias_type(load_alias_idx)->is_rewritable()) {
Unique_Node_List worklist;

Node_List worklist;

Node *mem = n->in(MemNode::Memory);
Node* mem = n->in(MemNode::Memory);
for (DUIterator_Fast imax, i = mem->fast_outs(imax); i < imax; i++) {
Node* s = mem->fast_out(i);
worklist.push(s);
}
while(worklist.size() != 0 && LCA != early) {
Node* s = worklist.pop();
for (uint i = 0; i < worklist.size() && LCA != early; i++) {
Node* s = worklist.at(i);
if (s->is_Load() || s->Opcode() == Op_SafePoint ||
(s->is_CallStaticJava() && s->as_CallStaticJava()->uncommon_trap_request() != 0)) {
(s->is_CallStaticJava() && s->as_CallStaticJava()->uncommon_trap_request() != 0) ||
s->is_Phi()) {
continue;
} else if (s->is_MergeMem()) {
for (DUIterator_Fast imax, i = s->fast_outs(imax); i < imax; i++) {
Node* s1 = s->fast_out(i);
worklist.push(s1);
}
} else {
Node *sctrl = has_ctrl(s) ? get_ctrl(s) : s->in(0);
Node* sctrl = has_ctrl(s) ? get_ctrl(s) : s->in(0);
assert(sctrl != NULL || !s->is_reachable_from_root(), "must have control");
if (sctrl != NULL && !sctrl->is_top() && is_dominator(early, sctrl)) {
const TypePtr* adr_type = s->adr_type();
@@ -5011,6 +5011,22 @@ Node *PhaseIdealLoop::get_late_ctrl( Node *n, Node *early ) {
}
}
}
// For Phis only consider Region's inputs that were reached by following the memory edges
if (LCA != early) {
for (uint i = 0; i < worklist.size(); i++) {
Node* s = worklist.at(i);
if (s->is_Phi() && C->can_alias(s->adr_type(), load_alias_idx)) {
Node* r = s->in(0);
for (uint j = 1; j < s->req(); j++) {
Node* in = s->in(j);
Node* r_in = r->in(j);
if (worklist.member(in) && is_dominator(early, r_in)) {
LCA = dom_lca_for_get_late_ctrl(LCA, r_in, n);
}
}
}
}
}
}
}

@@ -0,0 +1,74 @@
/*
* Copyright (c) 2021, Red Hat, Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/**
* @test
* @bug 8258393
* @summary Shenandoah: "graph should be schedulable" assert failure
* @requires vm.flavor == "server"
* @requires vm.gc.Shenandoah
*
* @run main/othervm -XX:+UseShenandoahGC -XX:-BackgroundCompilation TestBadRawMemoryAfterCall
*
*/

public class TestBadRawMemoryAfterCall {
public static void main(String[] args) {
A a = new A();
B b = new B();
C c = new C();
for (int i = 0; i < 20_000; i++) {
test(a);
test(b);
test(c);
}
}

private static Object test(A a) {
if (a.getClass() == A.class) {
}

Object o = null;
try {
a.m();
o = a.getClass();
} catch (Exception e) {

}
return o;
}

private static class A {
void m() throws Exception {
throw new Exception();
}
}
private static class B extends A {
void m() {
}
}
private static class C extends B {
void m() {
}
}
}

1 comment on commit 6775113

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 6775113 Jan 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.