Skip to content

Commit

Permalink
8281811: assert(_base == Tuple) failed: Not a Tuple after JDK-8280799
Browse files Browse the repository at this point in the history
Reviewed-by: kvn, thartmann
  • Loading branch information
rwestrel committed Mar 1, 2022
1 parent a95edee commit fcce24c
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 14 deletions.
22 changes: 11 additions & 11 deletions src/hotspot/share/opto/loopnode.cpp
Expand Up @@ -4089,11 +4089,11 @@ bool PhaseIdealLoop::only_has_infinite_loops() {
//----------------------------build_and_optimize-------------------------------
// Create a PhaseLoop. Build the ideal Loop tree. Map each Ideal Node to
// its corresponding LoopNode. If 'optimize' is true, do some loop cleanups.
void PhaseIdealLoop::build_and_optimize(LoopOptsMode mode) {
void PhaseIdealLoop::build_and_optimize() {
assert(!C->post_loop_opts_phase(), "no loop opts allowed");

bool do_split_ifs = (mode == LoopOptsDefault);
bool skip_loop_opts = (mode == LoopOptsNone);
bool do_split_ifs = (_mode == LoopOptsDefault);
bool skip_loop_opts = (_mode == LoopOptsNone);

int old_progress = C->major_progress();
uint orig_worklist_size = _igvn._worklist.size();
Expand Down Expand Up @@ -4164,9 +4164,9 @@ void PhaseIdealLoop::build_and_optimize(LoopOptsMode mode) {
BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
// Nothing to do, so get out
bool stop_early = !C->has_loops() && !skip_loop_opts && !do_split_ifs && !_verify_me && !_verify_only &&
!bs->is_gc_specific_loop_opts_pass(mode);
!bs->is_gc_specific_loop_opts_pass(_mode);
bool do_expensive_nodes = C->should_optimize_expensive_nodes(_igvn);
bool strip_mined_loops_expanded = bs->strip_mined_loops_expanded(mode);
bool strip_mined_loops_expanded = bs->strip_mined_loops_expanded(_mode);
if (stop_early && !do_expensive_nodes) {
return;
}
Expand Down Expand Up @@ -4258,7 +4258,7 @@ void PhaseIdealLoop::build_and_optimize(LoopOptsMode mode) {

if (_verify_only) {
C->restore_major_progress(old_progress);
assert(C->unique() == unique, "verification mode made Nodes? ? ?");
assert(C->unique() == unique, "verification _mode made Nodes? ? ?");
assert(_igvn._worklist.size() == orig_worklist_size, "shouldn't push anything");
return;
}
Expand Down Expand Up @@ -4288,8 +4288,8 @@ void PhaseIdealLoop::build_and_optimize(LoopOptsMode mode) {
#ifndef PRODUCT
C->verify_graph_edges();
if (_verify_me) { // Nested verify pass?
// Check to see if the verify mode is broken
assert(C->unique() == unique, "non-optimize mode made Nodes? ? ?");
// Check to see if the verify _mode is broken
assert(C->unique() == unique, "non-optimize _mode made Nodes? ? ?");
return;
}
if (VerifyLoopOptimizations) verify();
Expand All @@ -4303,7 +4303,7 @@ void PhaseIdealLoop::build_and_optimize(LoopOptsMode mode) {
return;
}

if (mode == LoopOptsMaxUnroll) {
if (_mode == LoopOptsMaxUnroll) {
for (LoopTreeIterator iter(_ltree_root); !iter.done(); iter.next()) {
IdealLoopTree* lpt = iter.current();
if (lpt->is_innermost() && lpt->_allow_optimizations && !lpt->_has_call && lpt->is_counted()) {
Expand All @@ -4324,7 +4324,7 @@ void PhaseIdealLoop::build_and_optimize(LoopOptsMode mode) {
return;
}

if (bs->optimize_loops(this, mode, visited, nstack, worklist)) {
if (bs->optimize_loops(this, _mode, visited, nstack, worklist)) {
return;
}

Expand Down Expand Up @@ -5755,7 +5755,7 @@ void PhaseIdealLoop::build_loop_late_post_work(Node *n, bool pinned) {
}
// Try not to place code on a loop entry projection
// which can inhibit range check elimination.
if (least != early) {
if (least != early && !BarrierSet::barrier_set()->barrier_set_c2()->is_gc_specific_loop_opts_pass(_mode)) {
Node* ctrl_out = least->unique_ctrl_out_or_null();
if (ctrl_out != NULL && ctrl_out->is_Loop() &&
least == ctrl_out->in(LoopNode::EntryControl) &&
Expand Down
9 changes: 6 additions & 3 deletions src/hotspot/share/opto/loopnode.hpp
Expand Up @@ -1042,9 +1042,10 @@ class PhaseIdealLoop : public PhaseTransform {
Node **_idom; // Array of immediate dominators
uint *_dom_depth; // Used for fast LCA test
GrowableArray<uint>* _dom_stk; // For recomputation of dom depth
LoopOptsMode _mode;

// build the loop tree and perform any requested optimizations
void build_and_optimize(LoopOptsMode mode);
void build_and_optimize();

// Dominators for the sea of nodes
void Dominators();
Expand All @@ -1055,9 +1056,10 @@ class PhaseIdealLoop : public PhaseTransform {
_igvn(igvn),
_verify_me(nullptr),
_verify_only(false),
_mode(mode),
_nodes_required(UINT_MAX) {
assert(mode != LoopOptsVerify, "wrong constructor to verify IdealLoop");
build_and_optimize(mode);
build_and_optimize();
}

#ifndef PRODUCT
Expand All @@ -1068,8 +1070,9 @@ class PhaseIdealLoop : public PhaseTransform {
_igvn(igvn),
_verify_me(verify_me),
_verify_only(verify_me == nullptr),
_mode(LoopOptsVerify),
_nodes_required(UINT_MAX) {
build_and_optimize(LoopOptsVerify);
build_and_optimize();
}
#endif

Expand Down
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2022, 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 8281811
* @summary assert(_base == Tuple) failed: Not a Tuple after JDK-8280799
* @requires vm.gc.Shenandoah
* @run main/othervm -XX:+UseShenandoahGC -XX:-BackgroundCompilation -XX:LoopMaxUnroll=1 TestBarrierAboveProj
*/


public class TestBarrierAboveProj {
private static C objField = new C();
private static final Object[] arrayField = new Object[1000];
private static volatile int volatileField;

public static void main(String[] args) {
for (int i = 0; i < 20_000; i++) {
test1();
test2();
}
}

private static float test1() {
float v = 1;
for (int i = 1; i < 1000; i++) {
if (objField == arrayField[i]) {
return v;
}
v *= 2;
}
return v;
}

private static float test2() {
float v = 1;
volatileField = 0x42;
for (int i = 1; i < 1000; i++) {
if (objField == arrayField[i]) {
return v;
}
v *= 2;
}
return v;
}

private static class C {
public float floatField;
}
}

1 comment on commit fcce24c

@openjdk-notifier
Copy link

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.