8026735: Stream tests throw java.lang.IncompatibleClassChangeError
Put a band-aid to disable CHA-based inlining for interfaces with default methods in C1 Reviewed-by: kvn, twisti
This commit is contained in:
parent
612252d7a2
commit
e43ac25584
@ -1873,7 +1873,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) {
|
|||||||
// number of implementors for decl_interface is 0 or 1. If
|
// number of implementors for decl_interface is 0 or 1. If
|
||||||
// it's 0 then no class implements decl_interface and there's
|
// it's 0 then no class implements decl_interface and there's
|
||||||
// no point in inlining.
|
// no point in inlining.
|
||||||
if (!holder->is_loaded() || decl_interface->nof_implementors() != 1) {
|
if (!holder->is_loaded() || decl_interface->nof_implementors() != 1 || decl_interface->has_default_methods()) {
|
||||||
singleton = NULL;
|
singleton = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) :
|
|||||||
_init_state = ik->init_state();
|
_init_state = ik->init_state();
|
||||||
_nonstatic_field_size = ik->nonstatic_field_size();
|
_nonstatic_field_size = ik->nonstatic_field_size();
|
||||||
_has_nonstatic_fields = ik->has_nonstatic_fields();
|
_has_nonstatic_fields = ik->has_nonstatic_fields();
|
||||||
|
_has_default_methods = ik->has_default_methods();
|
||||||
_nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
|
_nonstatic_fields = NULL; // initialized lazily by compute_nonstatic_fields:
|
||||||
|
|
||||||
_implementor = NULL; // we will fill these lazily
|
_implementor = NULL; // we will fill these lazily
|
||||||
|
@ -52,6 +52,7 @@ private:
|
|||||||
bool _has_finalizer;
|
bool _has_finalizer;
|
||||||
bool _has_subklass;
|
bool _has_subklass;
|
||||||
bool _has_nonstatic_fields;
|
bool _has_nonstatic_fields;
|
||||||
|
bool _has_default_methods;
|
||||||
|
|
||||||
ciFlags _flags;
|
ciFlags _flags;
|
||||||
jint _nonstatic_field_size;
|
jint _nonstatic_field_size;
|
||||||
@ -171,6 +172,11 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool has_default_methods() {
|
||||||
|
assert(is_loaded(), "must be loaded");
|
||||||
|
return _has_default_methods;
|
||||||
|
}
|
||||||
|
|
||||||
ciInstanceKlass* get_canonical_holder(int offset);
|
ciInstanceKlass* get_canonical_holder(int offset);
|
||||||
ciField* get_field_by_offset(int field_offset, bool is_static);
|
ciField* get_field_by_offset(int field_offset, bool is_static);
|
||||||
ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
|
ciField* get_field_by_name(ciSymbol* name, ciSymbol* signature, bool is_static);
|
||||||
|
64
hotspot/test/compiler/inlining/InlineDefaultMethod.java
Normal file
64
hotspot/test/compiler/inlining/InlineDefaultMethod.java
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013, Oracle and/or its affiliates. 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 8026735
|
||||||
|
* @summary CHA in C1 should make correct decisions about default methods
|
||||||
|
* @run main/othervm -Xcomp -XX:CompileOnly=InlineDefaultMethod::test -XX:TieredStopAtLevel=1 InlineDefaultMethod
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
interface InterfaceWithDefaultMethod0 {
|
||||||
|
default public int defaultMethod() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InterfaceWithDefaultMethod1 extends InterfaceWithDefaultMethod0 { }
|
||||||
|
|
||||||
|
abstract class Subtype implements InterfaceWithDefaultMethod1 { }
|
||||||
|
|
||||||
|
class Decoy extends Subtype {
|
||||||
|
public int defaultMethod() {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Instance extends Subtype { }
|
||||||
|
|
||||||
|
public class InlineDefaultMethod {
|
||||||
|
public static int test(InterfaceWithDefaultMethod1 x) {
|
||||||
|
return x.defaultMethod();
|
||||||
|
}
|
||||||
|
public static void main(String[] args) {
|
||||||
|
InterfaceWithDefaultMethod1 a = new Decoy();
|
||||||
|
InterfaceWithDefaultMethod1 b = new Instance();
|
||||||
|
if (test(a) != 2 ||
|
||||||
|
test(b) != 1) {
|
||||||
|
System.err.println("FAILED");
|
||||||
|
System.exit(97);
|
||||||
|
}
|
||||||
|
System.err.println("PASSED");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user