Mercurial > hg > graal-jvmci-8
diff src/share/vm/opto/parse2.cpp @ 129:c0939256690b
6646019: array subscript expressions become top() with -d64
Summary: stop compilation after negative array allocation
Reviewed-by: never, jrose
author | rasbold |
---|---|
date | Thu, 24 Apr 2008 14:02:13 -0700 |
parents | ba764ed4b6f2 |
children | d1605aabd0a1 1e026f8da827 |
line wrap: on
line diff
--- a/src/share/vm/opto/parse2.cpp Thu Apr 24 11:13:03 2008 -0700 +++ b/src/share/vm/opto/parse2.cpp Thu Apr 24 14:02:13 2008 -0700 @@ -105,10 +105,19 @@ if (GenerateRangeChecks && need_range_check) { // Range is constant in array-oop, so we can use the original state of mem Node* len = load_array_length(ary); - // Test length vs index (standard trick using unsigned compare) - Node* chk = _gvn.transform( new (C, 3) CmpUNode(idx, len) ); - BoolTest::mask btest = BoolTest::lt; - Node* tst = _gvn.transform( new (C, 2) BoolNode(chk, btest) ); + Node* tst; + if (sizetype->_hi <= 0) { + // If the greatest array bound is negative, we can conclude that we're + // compiling unreachable code, but the unsigned compare trick used below + // only works with non-negative lengths. Instead, hack "tst" to be zero so + // the uncommon_trap path will always be taken. + tst = _gvn.intcon(0); + } else { + // Test length vs index (standard trick using unsigned compare) + Node* chk = _gvn.transform( new (C, 3) CmpUNode(idx, len) ); + BoolTest::mask btest = BoolTest::lt; + tst = _gvn.transform( new (C, 2) BoolNode(chk, btest) ); + } // Branch to failure if out of bounds { BuildCutout unless(this, tst, PROB_MAX); if (C->allow_range_check_smearing()) {