Skip to content

Commit 480b508

Browse files
danieloghVladimir Kozlov
authored and
Vladimir Kozlov
committed
8345156: C2: Add bailouts next to a few asserts
Reviewed-by: kvn, epeter
1 parent b120404 commit 480b508

File tree

8 files changed

+63
-12
lines changed

8 files changed

+63
-12
lines changed

src/hotspot/share/opto/block.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,9 @@ void PhaseCFG::verify() const {
13561356
verify_memory_writer_placement(block, n);
13571357
if (n->needs_anti_dependence_check()) {
13581358
verify_anti_dependences(block, n);
1359+
if (C->failing()) {
1360+
return;
1361+
}
13591362
}
13601363
for (uint k = 0; k < n->req(); k++) {
13611364
Node *def = n->in(k);

src/hotspot/share/opto/chaitin.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -2563,6 +2563,9 @@ void PhaseChaitin::verify_base_ptrs(ResourceArea* a) const {
25632563
void PhaseChaitin::verify(ResourceArea* a, bool verify_ifg) const {
25642564
if (VerifyRegisterAllocator) {
25652565
_cfg.verify();
2566+
if (C->failing()) {
2567+
return;
2568+
}
25662569
verify_base_ptrs(a);
25672570
if (verify_ifg) {
25682571
_ifg->verify(this);

src/hotspot/share/opto/compile.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -2969,6 +2969,9 @@ void Compile::Code_Gen() {
29692969
print_method(PHASE_GLOBAL_CODE_MOTION, 2);
29702970
NOT_PRODUCT( verify_graph_edges(); )
29712971
cfg.verify();
2972+
if (failing()) {
2973+
return;
2974+
}
29722975
}
29732976

29742977
PhaseChaitin regalloc(unique(), cfg, matcher, false);
@@ -5041,7 +5044,6 @@ bool Compile::fail_randomly() {
50415044
}
50425045

50435046
bool Compile::failure_is_artificial() {
5044-
assert(failing_internal(), "should be failing");
50455047
return C->failure_reason_is("StressBailout");
50465048
}
50475049
#endif

src/hotspot/share/opto/gcm.cpp

+29-7
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,6 @@ void PhaseCFG::schedule_pinned_nodes(VectorSet &visited) {
243243
}
244244
}
245245

246-
#ifdef ASSERT
247246
// Assert that new input b2 is dominated by all previous inputs.
248247
// Check this by by seeing that it is dominated by b1, the deepest
249248
// input observed until b2.
@@ -255,6 +254,7 @@ static void assert_dom(Block* b1, Block* b2, Node* n, const PhaseCFG* cfg) {
255254
tmp = tmp->_idom;
256255
}
257256
if (tmp != b1) {
257+
#ifdef ASSERT
258258
// Detected an unschedulable graph. Print some nice stuff and die.
259259
tty->print_cr("!!! Unschedulable graph !!!");
260260
for (uint j=0; j<n->len(); j++) { // For all inputs
@@ -267,10 +267,11 @@ static void assert_dom(Block* b1, Block* b2, Node* n, const PhaseCFG* cfg) {
267267
}
268268
tty->print("Failing node: ");
269269
n->dump();
270-
assert(false, "unscheduable graph");
270+
assert(false, "unschedulable graph");
271+
#endif
272+
cfg->C->record_failure("unschedulable graph");
271273
}
272274
}
273-
#endif
274275

275276
static Block* find_deepest_input(Node* n, const PhaseCFG* cfg) {
276277
// Find the last input dominated by all other inputs.
@@ -285,7 +286,10 @@ static Block* find_deepest_input(Node* n, const PhaseCFG* cfg) {
285286
// The new inb must be dominated by the previous deepb.
286287
// The various inputs must be linearly ordered in the dom
287288
// tree, or else there will not be a unique deepest block.
288-
DEBUG_ONLY(assert_dom(deepb, inb, n, cfg));
289+
assert_dom(deepb, inb, n, cfg);
290+
if (cfg->C->failing()) {
291+
return nullptr;
292+
}
289293
deepb = inb; // Save deepest block
290294
deepb_dom_depth = deepb->_dom_depth;
291295
}
@@ -372,6 +376,9 @@ bool PhaseCFG::schedule_early(VectorSet &visited, Node_Stack &roots) {
372376
if (!parent_node->pinned()) {
373377
// Set earliest legal block.
374378
Block* earliest_block = find_deepest_input(parent_node, this);
379+
if (C->failing()) {
380+
return false;
381+
}
375382
map_node_to_block(parent_node, earliest_block);
376383
} else {
377384
assert(get_block_for_node(parent_node) == get_block_for_node(parent_node->in(0)), "Pinned Node should be at the same block as its control edge");
@@ -523,7 +530,10 @@ static Block* memory_early_block(Node* load, Block* early, const PhaseCFG* cfg)
523530
// The new inb must be dominated by the previous deepb.
524531
// The various inputs must be linearly ordered in the dom
525532
// tree, or else there will not be a unique deepest block.
526-
DEBUG_ONLY(assert_dom(deepb, inb, load, cfg));
533+
assert_dom(deepb, inb, load, cfg);
534+
if (cfg->C->failing()) {
535+
return nullptr;
536+
}
527537
deepb = inb; // Save deepest block
528538
deepb_dom_depth = deepb->_dom_depth;
529539
}
@@ -715,6 +725,9 @@ Block* PhaseCFG::insert_anti_dependences(Block* LCA, Node* load, bool verify) {
715725
// dominator tree, and allow for a broader discovery of anti-dependences.
716726
if (C->subsume_loads()) {
717727
early = memory_early_block(load, early, this);
728+
if (C->failing()) {
729+
return nullptr;
730+
}
718731
}
719732

720733
ResourceArea* area = Thread::current()->resource_area();
@@ -1519,6 +1532,9 @@ void PhaseCFG::schedule_late(VectorSet &visited, Node_Stack &stack) {
15191532
// Hoist LCA above possible-defs and insert anti-dependences to
15201533
// defs in new LCA block.
15211534
LCA = insert_anti_dependences(LCA, self);
1535+
if (C->failing()) {
1536+
return;
1537+
}
15221538
}
15231539

15241540
if (early->_dom_depth > LCA->_dom_depth) {
@@ -1611,8 +1627,8 @@ void PhaseCFG::global_code_motion() {
16111627
Node_Stack stack((C->live_nodes() >> 2) + 16); // pre-grow
16121628
if (!schedule_early(visited, stack)) {
16131629
// Bailout without retry
1614-
assert(false, "early schedule failed");
1615-
C->record_method_not_compilable("early schedule failed");
1630+
assert(C->failure_is_artificial(), "early schedule failed");
1631+
C->record_method_not_compilable("early schedule failed" DEBUG_ONLY(COMMA true));
16161632
return;
16171633
}
16181634

@@ -1657,6 +1673,9 @@ void PhaseCFG::global_code_motion() {
16571673
// uncommon trap. Combined with the too_many_traps guards
16581674
// above, this prevents SEGV storms reported in 6366351,
16591675
// by recompiling offending methods without this optimization.
1676+
if (C->failing()) {
1677+
return;
1678+
}
16601679
}
16611680
}
16621681

@@ -1726,6 +1745,9 @@ void PhaseCFG::global_code_motion() {
17261745
for (uint i = 0; i < number_of_blocks(); i++) {
17271746
Block* block = get_block(i);
17281747
call_catch_cleanup(block);
1748+
if (C->failing()) {
1749+
return;
1750+
}
17291751
}
17301752

17311753
#ifndef PRODUCT

src/hotspot/share/opto/lcm.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,9 @@ void PhaseCFG::implicit_null_check(Block* block, Node *proj, Node *val, int allo
493493
n->in(LoadNode::Memory) == best->in(StoreNode::Memory)) {
494494
// Found anti-dependent load
495495
insert_anti_dependences(block, n);
496+
if (C->failing()) {
497+
return;
498+
}
496499
}
497500
}
498501
}
@@ -1362,6 +1365,9 @@ void PhaseCFG::call_catch_cleanup(Block* block) {
13621365
map_node_to_block(clone, sb);
13631366
if (clone->needs_anti_dependence_check()) {
13641367
insert_anti_dependences(sb, clone);
1368+
if (C->failing()) {
1369+
return;
1370+
}
13651371
}
13661372
}
13671373
}

src/hotspot/share/opto/loopnode.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -4899,7 +4899,10 @@ void PhaseIdealLoop::build_and_optimize() {
48994899
// that require basic-block info (like cloning through Phi's)
49004900
if (!C->major_progress() && SplitIfBlocks && do_split_ifs) {
49014901
visited.clear();
4902-
split_if_with_blocks( visited, nstack);
4902+
split_if_with_blocks(visited, nstack);
4903+
if (C->failing()) {
4904+
return;
4905+
}
49034906
DEBUG_ONLY( if (VerifyLoopOptimizations) { verify(); } );
49044907
}
49054908

@@ -6423,6 +6426,7 @@ void PhaseIdealLoop::build_loop_late_post_work(Node *n, bool pinned) {
64236426
#ifdef ASSERT
64246427
if (_verify_only && !n->is_CFG()) {
64256428
// Check def-use domination.
6429+
// We would like to expose this check in product but it appears to be expensive.
64266430
compute_lca_of_uses(n, get_ctrl(n), true /* verify */);
64276431
}
64286432
#endif

src/hotspot/share/opto/loopopts.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -1548,6 +1548,9 @@ void PhaseIdealLoop::split_if_with_blocks_post(Node *n) {
15481548
}
15491549

15501550
try_sink_out_of_loop(n);
1551+
if (C->failing()) {
1552+
return;
1553+
}
15511554

15521555
try_move_store_after_loop(n);
15531556
}
@@ -1735,7 +1738,11 @@ void PhaseIdealLoop::try_sink_out_of_loop(Node* n) {
17351738
Node* early_ctrl = compute_early_ctrl(n, n_ctrl);
17361739
if (n_loop->is_member(get_loop(early_ctrl)) && // check that this one can't be hoisted now
17371740
ctrl_of_all_uses_out_of_loop(n, early_ctrl, n_loop)) { // All uses in outer loops!
1738-
assert(!n->is_Store() && !n->is_LoadStore(), "no node with a side effect");
1741+
if (n->is_Store() || n->is_LoadStore()) {
1742+
assert(false, "no node with a side effect");
1743+
C->record_failure("no node with a side effect");
1744+
return;
1745+
}
17391746
Node* outer_loop_clone = nullptr;
17401747
for (DUIterator_Last jmin, j = n->last_outs(jmin); j >= jmin;) {
17411748
Node* u = n->last_out(j); // Clone private computation per use
@@ -1983,6 +1990,9 @@ void PhaseIdealLoop::split_if_with_blocks(VectorSet &visited, Node_Stack &nstack
19831990
if (cnt != 0 && !n->is_Con()) {
19841991
assert(has_node(n), "no dead nodes");
19851992
split_if_with_blocks_post(n);
1993+
if (C->failing()) {
1994+
return;
1995+
}
19861996
}
19871997
if (must_throttle_split_if()) {
19881998
nstack.clear();

src/hotspot/share/opto/matcher.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1753,18 +1753,19 @@ Node* Matcher::Label_Root(const Node* n, State* svec, Node* control, Node*& mem)
17531753
// Call DFA to match this node, and return
17541754
svec->DFA( n->Opcode(), n );
17551755

1756-
#ifdef ASSERT
17571756
uint x;
17581757
for( x = 0; x < _LAST_MACH_OPER; x++ )
17591758
if( svec->valid(x) )
17601759
break;
17611760

17621761
if (x >= _LAST_MACH_OPER) {
1762+
#ifdef ASSERT
17631763
n->dump();
17641764
svec->dump();
1765+
#endif
17651766
assert( false, "bad AD file" );
1767+
C->record_failure("bad AD file");
17661768
}
1767-
#endif
17681769
return control;
17691770
}
17701771

0 commit comments

Comments
 (0)