Skip to content

Commit 5cef73a

Browse files
author
Rahul Raghavan
committed
8238812: assert(false) failed: bad AD file
1 parent 90ac1bd commit 5cef73a

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

src/hotspot/share/opto/cfgnode.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ class IfNode : public MultiBranchNode {
288288

289289
private:
290290
// Helper methods for fold_compares
291-
bool cmpi_folds(PhaseIterGVN* igvn);
291+
bool cmp_folds(PhaseIterGVN* igvn);
292292
bool is_ctrl_folds(Node* ctrl, PhaseIterGVN* igvn);
293293
bool has_shared_region(ProjNode* proj, ProjNode*& success, ProjNode*& fail);
294294
bool has_only_uncommon_traps(ProjNode* proj, ProjNode*& success, ProjNode*& fail, PhaseIterGVN* igvn);

src/hotspot/share/opto/ifnode.cpp

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -634,9 +634,10 @@ const TypeInt* IfNode::filtered_int_type(PhaseGVN* gvn, Node* val, Node* if_proj
634634
return cmp2_t;
635635
case BoolTest::lt:
636636
if (is_unsigned && lo >= 0) {
637-
// val u< cmp2 only passes for val >= 0 if cmp2 >= 0
637+
// cmp2 >= 0: val u<= cmp2 can only pass if val >= 0. Set val->_lo to 0.
638638
lo = 0;
639639
} else {
640+
// The lower bound of val cannot be improved.
640641
lo = TypeInt::INT->_lo;
641642
}
642643
if (hi != min_jint) {
@@ -645,9 +646,10 @@ const TypeInt* IfNode::filtered_int_type(PhaseGVN* gvn, Node* val, Node* if_proj
645646
break;
646647
case BoolTest::le:
647648
if (is_unsigned && lo >= 0) {
648-
// val u<= cmp2 only passes for val >= 0 if cmp2 >= 0
649+
// cmp2 >= 0: val u<= cmp2 can only pass if val >= 0. Set val->_lo to 0.
649650
lo = 0;
650651
} else {
652+
// The lower bound of val cannot be improved.
651653
lo = TypeInt::INT->_lo;
652654
}
653655
break;
@@ -661,11 +663,11 @@ const TypeInt* IfNode::filtered_int_type(PhaseGVN* gvn, Node* val, Node* if_proj
661663
hi = TypeInt::INT->_hi;
662664
break;
663665
case BoolTest::ge:
664-
// lo unchanged
665666
if (is_unsigned && (val_t == NULL || val_t->_lo < 0)) {
666667
// val u>= cmp2 passes for val < 0
667668
lo = TypeInt::INT->_lo;
668669
}
670+
// else lo unchanged
669671
hi = TypeInt::INT->_hi;
670672
break;
671673
default:
@@ -720,7 +722,7 @@ const TypeInt* IfNode::filtered_int_type(PhaseGVN* gvn, Node* val, Node* if_proj
720722
//
721723

722724
// Is the comparison for this If suitable for folding?
723-
bool IfNode::cmpi_folds(PhaseIterGVN* igvn) {
725+
bool IfNode::cmp_folds(PhaseIterGVN* igvn) {
724726
return in(1) != NULL &&
725727
in(1)->is_Bool() &&
726728
in(1)->in(1) != NULL &&
@@ -740,7 +742,7 @@ bool IfNode::is_ctrl_folds(Node* ctrl, PhaseIterGVN* igvn) {
740742
ctrl->in(0) != NULL &&
741743
ctrl->in(0)->Opcode() == Op_If &&
742744
ctrl->in(0)->outcnt() == 2 &&
743-
ctrl->in(0)->as_If()->cmpi_folds(igvn) &&
745+
ctrl->in(0)->as_If()->cmp_folds(igvn) &&
744746
ctrl->in(0)->in(1)->in(1)->in(1) != NULL &&
745747
in(1)->in(1)->in(1) != NULL;
746748
}
@@ -872,28 +874,28 @@ bool IfNode::has_only_uncommon_traps(ProjNode* proj, ProjNode*& success, ProjNod
872874
// dom_cmp \ dom_cmp \ dom_cmp \
873875
// this_cmp this_cmp this_cmp
874876
bool IfNode::get_base_comparing_value (Node* dom_if, PhaseIterGVN* igvn, jint& this_adj_val, jint& dom_adj_val) {
875-
Node* this_cmp = in(1)->in(1)->as_Cmp();
876-
Node* dom_cmp = dom_if->in(1)->in(1)->as_Cmp();
877-
Node* dom_val = dom_cmp->in(1);
878-
Node* this_val = this_cmp->in(1);
877+
assert(dom_if->in(1)->in(1)->is_Cmp() && in(1)->in(1)->is_Cmp(), "compare expected");
878+
Node* dom_val = dom_if->in(1)->in(1)->in(1);
879+
Node* this_val = in(1)->in(1)->in(1);
880+
assert(dom_val != NULL && this_val != NULL, "sanity");
879881
if (this_val == dom_val) {
880882
// Variant 1
881883
return true;
882-
} else if (this_val->is_Add() && this_val->in(1) != NULL && this_val->in(1) == dom_val) {
884+
} else if (this_val->is_Add() && this_val->in(1) == dom_val) {
883885
const TypeInt* val_t = igvn->type(this_val->in(2))->isa_int();
884886
if (val_t != NULL && val_t->is_con()) {
885887
// Variant 2
886888
this_adj_val = val_t->get_con();
887889
return true;
888890
}
889-
} else if (dom_val->is_Add() && dom_val->in(1) != NULL && this_val == dom_val->in(1)) {
891+
} else if (dom_val->is_Add() && this_val == dom_val->in(1)) {
890892
const TypeInt* val_t = igvn->type(dom_val->in(2))->isa_int();
891893
if (val_t != NULL && val_t->is_con()) {
892894
// Variant 3
893895
dom_adj_val = val_t->get_con();
894896
return true;
895897
}
896-
} else if (this_val->is_Add() && dom_val->is_Add() && this_val->in(1) != NULL && dom_val->in(1) != NULL && this_val->in(1) == dom_val->in(1)) {
898+
} else if (this_val->is_Add() && dom_val->is_Add() && this_val->in(1) != NULL && this_val->in(1) == dom_val->in(1)) {
897899
const TypeInt* domval_t = igvn->type(dom_val->in(2))->isa_int();
898900
const TypeInt* thisval_t = igvn->type(this_val->in(2))->isa_int();
899901
if (thisval_t != NULL && domval_t != NULL && thisval_t->is_con() && domval_t->is_con()) {
@@ -1357,7 +1359,7 @@ void IfNode::reroute_side_effect_free_unc(ProjNode* proj, ProjNode* dom_proj, Ph
13571359
Node* IfNode::fold_compares(PhaseIterGVN* igvn) {
13581360
if (Opcode() != Op_If) return NULL;
13591361

1360-
if (cmpi_folds(igvn)) {
1362+
if (cmp_folds(igvn)) {
13611363
Node* ctrl = in(0);
13621364
Node* cmp = in(1)->in(1);
13631365
Node* val = cmp->in(1);

test/hotspot/jtreg/compiler/c2/TestJumpTable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static int test0() {
6363

6464
// Original (slightly simplified) fuzzer generated test
6565
public static void test1() {
66-
int i4, i5=99, i6, i9=89;
66+
int i4, i5 = 99, i6, i9 = 89;
6767
for (i4 = 12; i4 < 365; i4++) {
6868
for (i6 = 5; i6 > 1; i6--) {
6969
switch ((i6 * 5) + 11) {

0 commit comments

Comments
 (0)