8239335: C2: assert((Value(phase) == t) || (t != TypeInt::CC_GT && t != TypeInt::CC_EQ)) failed: missing Value() optimization

Reviewed-by: kvn, thartmann
This commit is contained in:
Roland Westrelin 2020-03-05 15:56:49 +01:00
parent 1c1fb44ac1
commit b58c8601bb
2 changed files with 56 additions and 2 deletions
src/hotspot/share/opto
test/hotspot/jtreg/compiler/types

@ -34,13 +34,17 @@ const Type* SubTypeCheckNode::sub(const Type* sub_t, const Type* super_t) const
ciKlass* superk = super_t->is_klassptr()->klass();
ciKlass* subk = sub_t->isa_klassptr() ? sub_t->is_klassptr()->klass() : sub_t->is_oopptr()->klass();
bool xsuperk = super_t->is_klassptr()->klass_is_exact();
bool xsubk = sub_t->isa_klassptr() ? sub_t->is_klassptr()->klass_is_exact() : sub_t->is_oopptr()->klass_is_exact();
// Similar to logic in CmpPNode::sub()
// Interfaces can't be trusted unless the subclass is an exact
// interface (it can then only be a constant) or the subclass is an
// exact array of interfaces (a newly allocated array of interfaces
// for instance)
if (superk && subk &&
superk->is_loaded() && !superk->is_interface() &&
subk->is_loaded() && !subk->is_interface() &&
subk->is_loaded() && (!subk->is_interface() || xsubk) &&
(!superk->is_obj_array_klass() ||
!superk->as_obj_array_klass()->base_element_klass()->is_interface()) &&
(!subk->is_obj_array_klass() ||
@ -50,10 +54,15 @@ const Type* SubTypeCheckNode::sub(const Type* sub_t, const Type* super_t) const
if (superk->equals(subk)) {
// skip
} else if (superk->is_subtype_of(subk)) {
// If the subclass is exact then the superclass is a subtype of
// the subclass. Given they're no equals, that subtype check can
// only fail.
unrelated_classes = xsubk;
} else if (subk->is_subtype_of(superk)) {
// skip
} else {
// Neither class subtypes the other: they are unrelated and this
// type check is known to fail.
unrelated_classes = true;
}
if (unrelated_classes) {

@ -0,0 +1,45 @@
/*
* Copyright (c) 2020, 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 8239335
* @summary C2: assert((Value(phase) == t) || (t != TypeInt::CC_GT && t != TypeInt::CC_EQ)) failed: missing Value() optimization
* @requires vm.compiler2.enabled
*
* @run main/othervm -XX:-BackgroundCompilation TestIntArraySubTypeOfCloneableDoesnotFold
*
*/
public class TestIntArraySubTypeOfCloneableDoesnotFold {
public static void main(String[] args) {
for (int i = 0; i < 20_000; i++) {
test();
}
}
private static boolean test() {
return int[].class.isAssignableFrom(Cloneable.class);
}
}