OpenJDK / valhalla / valhalla
changeset 57334:d022bcd97043 nestmates
[nestmates] revert test changes due to lambda host class with bad NestHost attribute
author | mchung |
---|---|
date | Tue, 08 Oct 2019 17:58:39 -0700 |
parents | 603407e5775f |
children | 3696d32b89d9 |
files | test/hotspot/jtreg/compiler/cha/ObjectHashCode.java test/hotspot/jtreg/compiler/cha/ObjectToString.java test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java test/hotspot/jtreg/compiler/cha/ThreeLevelDefaultHierarchy.java test/hotspot/jtreg/compiler/cha/ThreeLevelDefaultHierarchy1.java test/hotspot/jtreg/compiler/cha/ThreeLevelHierarchyAbstractVsDefault.java test/hotspot/jtreg/compiler/cha/ThreeLevelHierarchyLinear.java test/hotspot/jtreg/compiler/cha/TwoLevelHierarchyLinear.java test/langtools/jdk/javadoc/tool/DOption.java test/langtools/jdk/javadoc/tool/OptionSyntaxTest.java test/langtools/tools/javac/modules/AnnotationsOnModules.java test/langtools/tools/javac/modules/ProxyTypeValidator.java test/langtools/tools/javac/processing/model/element/ListMembersAP.java test/langtools/tools/javac/processing/model/element/TestOrigin.java |
diffstat | 14 files changed, 714 insertions(+), 1018 deletions(-) [+] |
line wrap: on
line diff
--- a/test/hotspot/jtreg/compiler/cha/ObjectHashCode.java Tue Oct 08 14:26:57 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,115 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ - -package compiler.cha; - -import static compiler.cha.StrengthReduceInterfaceCall.*; - -public class ObjectHashCode extends ATest<ObjectHashCode.I> { - public ObjectHashCode() { - super(I.class, C.class); - } - - interface J {} - interface I extends J {} - - static class C implements I {} - - interface K1 extends I {} - interface K2 extends I { int hashCode(); } // K2.hC() ABSTRACT - // interface K3 extends I { default int hashCode() { return CORRECT; } // K2.hC() DEFAULT - - static class D implements I { public int hashCode() { return super.hashCode(); }} - - static class DJ1 implements J {} - static class DJ2 implements J { public int hashCode() { return super.hashCode(); }} - - @Override - public Object test(I i) { - return ObjectHashCodeHelper.test(i); /* invokeinterface I.hashCode() */ - } - - @TestCase - public void testMono() { - // 0. Trigger compilation of a monomorphic call site - compile(monomophic()); // C1 <: C <: intf I <: intf J <: Object.hashCode() - assertCompiled(); - - // Dependency: none - - call(new C() { public int hashCode() { return super.hashCode(); }}); // Cn.hC <: C.hC <: intf I - assertCompiled(); - } - - @TestCase - public void testBi() { - // 0. Trigger compilation of a bimorphic call site - compile(bimorphic()); // C1 <: C <: intf I <: intf J <: Object.toString() - assertCompiled(); - - // Dependency: none - - call(new C() { public int hashCode() { return super.hashCode(); }}); // Cn.hC <: C.hC <: intf I - assertCompiled(); - } - - @TestCase - public void testMega() { - // 0. Trigger compilation of a megamorphic call site - compile(megamorphic()); // C1,C2,C3 <: C <: intf I <: intf J <: Object.hashCode() - assertCompiled(); - - // Dependency: none - - // No dependency - no invalidation - repeat(100, () -> call(new C(){})); // Cn <: C <: intf I - assertCompiled(); - - initialize(K1.class, // intf K1 <: intf I <: intf J - K2.class, // intf K2.hC ABSTRACT <: intf I <: intf J - DJ1.class, // DJ1 <: intf J - DJ2.class); // DJ2.hC <: intf J - assertCompiled(); - - initialize(D.class); // D.hC <: intf I <: intf J - assertCompiled(); - - call(new C() { public int hashCode() { return super.hashCode(); }}); // Cn.hC <: C.hC <: intf I - assertCompiled(); - } - - @Override - public void checkInvalidReceiver() { - shouldThrow(IncompatibleClassChangeError.class, () -> { - I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated - test(o); - }); - assertCompiled(); - - shouldThrow(IncompatibleClassChangeError.class, () -> { - I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J() {}); // super interface - test(j); - }); - assertCompiled(); - } -}
--- a/test/hotspot/jtreg/compiler/cha/ObjectToString.java Tue Oct 08 14:26:57 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ - -package compiler.cha; - -import static compiler.cha.StrengthReduceInterfaceCall.*; - -public class ObjectToString extends ATest<ObjectToString.I> { - public ObjectToString() { - super(I.class, C.class); - } - - interface J { String toString(); } - interface I extends J {} - - static class C implements I {} - - interface K1 extends I {} - interface K2 extends I { String toString(); } // K2.tS() ABSTRACT - // interface K3 extends I { default String toString() { return "K3"; } // K2.tS() DEFAULT - - static class D implements I { public String toString() { return "D"; }} - - static class DJ1 implements J {} - static class DJ2 implements J { public String toString() { return "DJ2"; }} - - @Override - public Object test(I i) { return ObjectToStringHelper.test(i); /* invokeinterface I.toString() */ } - - @TestCase - public void testMono() { - // 0. Trigger compilation of a monomorphic call site - compile(monomophic()); // C1 <: C <: intf I <: intf J <: Object.toString() - assertCompiled(); - - // Dependency: none - - call(new C() { public String toString() { return "Cn"; }}); // Cn.tS <: C.tS <: intf I - assertCompiled(); - } - - @TestCase - public void testBi() { - // 0. Trigger compilation of a bimorphic call site - compile(bimorphic()); // C1 <: C <: intf I <: intf J <: Object.toString() - assertCompiled(); - - // Dependency: none - - call(new C() { public String toString() { return "Cn"; }}); // Cn.tS <: C.tS <: intf I - assertCompiled(); - } - - @TestCase - public void testMega() { - // 0. Trigger compilation of a megamorphic call site - compile(megamorphic()); // C1,C2,C3 <: C <: intf I <: intf J <: Object.toString() - assertCompiled(); - - // Dependency: none - // compiler.cha.StrengthReduceInterfaceCall$ObjectToString::test (5 bytes) - // @ 1 compiler.cha.StrengthReduceInterfaceCall$ObjectToStringHelper::test (7 bytes) inline (hot) - // @ 1 java.lang.Object::toString (36 bytes) virtual call - - // No dependency - no invalidation - repeat(100, () -> call(new C(){})); // Cn <: C <: intf I - assertCompiled(); - - initialize(K1.class, // intf K1 <: intf I <: intf J - K2.class, // intf K2.tS ABSTRACT <: intf I <: intf J - DJ1.class, // DJ1 <: intf J - DJ2.class); // DJ2.tS <: intf J - assertCompiled(); - - initialize(D.class); // D.tS <: intf I <: intf J - assertCompiled(); - - call(new C() { public String toString() { return "Cn"; }}); // Cn.tS <: C.tS <: intf I - assertCompiled(); - } - - @Override - public void checkInvalidReceiver() { - shouldThrow(IncompatibleClassChangeError.class, () -> { - I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated - test(o); - }); - assertCompiled(); - - shouldThrow(IncompatibleClassChangeError.class, () -> { - I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J() {}); // super interface - test(j); - }); - assertCompiled(); - } -} - -
--- a/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java Tue Oct 08 14:26:57 2019 -0700 +++ b/test/hotspot/jtreg/compiler/cha/StrengthReduceInterfaceCall.java Tue Oct 08 17:58:39 2019 -0700 @@ -79,6 +79,614 @@ run(ThreeLevelDefaultHierarchy1.class); } + public static class ObjectToString extends ATest<ObjectToString.I> { + public ObjectToString() { super(I.class, C.class); } + + interface J { String toString(); } + interface I extends J {} + + static class C implements I {} + + interface K1 extends I {} + interface K2 extends I { String toString(); } // K2.tS() ABSTRACT + // interface K3 extends I { default String toString() { return "K3"; } // K2.tS() DEFAULT + + static class D implements I { public String toString() { return "D"; }} + + static class DJ1 implements J {} + static class DJ2 implements J { public String toString() { return "DJ2"; }} + + @Override + public Object test(I i) { return ObjectToStringHelper.test(i); /* invokeinterface I.toString() */ } + + @TestCase + public void testMono() { + // 0. Trigger compilation of a monomorphic call site + compile(monomophic()); // C1 <: C <: intf I <: intf J <: Object.toString() + assertCompiled(); + + // Dependency: none + + call(new C() { public String toString() { return "Cn"; }}); // Cn.tS <: C.tS <: intf I + assertCompiled(); + } + + @TestCase + public void testBi() { + // 0. Trigger compilation of a bimorphic call site + compile(bimorphic()); // C1 <: C <: intf I <: intf J <: Object.toString() + assertCompiled(); + + // Dependency: none + + call(new C() { public String toString() { return "Cn"; }}); // Cn.tS <: C.tS <: intf I + assertCompiled(); + } + + @TestCase + public void testMega() { + // 0. Trigger compilation of a megamorphic call site + compile(megamorphic()); // C1,C2,C3 <: C <: intf I <: intf J <: Object.toString() + assertCompiled(); + + // Dependency: none + // compiler.cha.StrengthReduceInterfaceCall$ObjectToString::test (5 bytes) + // @ 1 compiler.cha.StrengthReduceInterfaceCall$ObjectToStringHelper::test (7 bytes) inline (hot) + // @ 1 java.lang.Object::toString (36 bytes) virtual call + + // No dependency - no invalidation + repeat(100, () -> call(new C(){})); // Cn <: C <: intf I + assertCompiled(); + + initialize(K1.class, // intf K1 <: intf I <: intf J + K2.class, // intf K2.tS ABSTRACT <: intf I <: intf J + DJ1.class, // DJ1 <: intf J + DJ2.class); // DJ2.tS <: intf J + assertCompiled(); + + initialize(D.class); // D.tS <: intf I <: intf J + assertCompiled(); + + call(new C() { public String toString() { return "Cn"; }}); // Cn.tS <: C.tS <: intf I + assertCompiled(); + } + + @Override + public void checkInvalidReceiver() { + shouldThrow(IncompatibleClassChangeError.class, () -> { + I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated + test(o); + }); + assertCompiled(); + + shouldThrow(IncompatibleClassChangeError.class, () -> { + I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J() {}); // super interface + test(j); + }); + assertCompiled(); + } + } + + public static class ObjectHashCode extends ATest<ObjectHashCode.I> { + public ObjectHashCode() { super(I.class, C.class); } + + interface J {} + interface I extends J {} + + static class C implements I {} + + interface K1 extends I {} + interface K2 extends I { int hashCode(); } // K2.hC() ABSTRACT + // interface K3 extends I { default int hashCode() { return CORRECT; } // K2.hC() DEFAULT + + static class D implements I { public int hashCode() { return super.hashCode(); }} + + static class DJ1 implements J {} + static class DJ2 implements J { public int hashCode() { return super.hashCode(); }} + + @Override + public Object test(I i) { + return ObjectHashCodeHelper.test(i); /* invokeinterface I.hashCode() */ + } + + @TestCase + public void testMono() { + // 0. Trigger compilation of a monomorphic call site + compile(monomophic()); // C1 <: C <: intf I <: intf J <: Object.hashCode() + assertCompiled(); + + // Dependency: none + + call(new C() { public int hashCode() { return super.hashCode(); }}); // Cn.hC <: C.hC <: intf I + assertCompiled(); + } + + @TestCase + public void testBi() { + // 0. Trigger compilation of a bimorphic call site + compile(bimorphic()); // C1 <: C <: intf I <: intf J <: Object.toString() + assertCompiled(); + + // Dependency: none + + call(new C() { public int hashCode() { return super.hashCode(); }}); // Cn.hC <: C.hC <: intf I + assertCompiled(); + } + + @TestCase + public void testMega() { + // 0. Trigger compilation of a megamorphic call site + compile(megamorphic()); // C1,C2,C3 <: C <: intf I <: intf J <: Object.hashCode() + assertCompiled(); + + // Dependency: none + + // No dependency - no invalidation + repeat(100, () -> call(new C(){})); // Cn <: C <: intf I + assertCompiled(); + + initialize(K1.class, // intf K1 <: intf I <: intf J + K2.class, // intf K2.hC ABSTRACT <: intf I <: intf J + DJ1.class, // DJ1 <: intf J + DJ2.class); // DJ2.hC <: intf J + assertCompiled(); + + initialize(D.class); // D.hC <: intf I <: intf J + assertCompiled(); + + call(new C() { public int hashCode() { return super.hashCode(); }}); // Cn.hC <: C.hC <: intf I + assertCompiled(); + } + + @Override + public void checkInvalidReceiver() { + shouldThrow(IncompatibleClassChangeError.class, () -> { + I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated + test(o); + }); + assertCompiled(); + + shouldThrow(IncompatibleClassChangeError.class, () -> { + I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J() {}); // super interface + test(j); + }); + assertCompiled(); + } + } + + public static class TwoLevelHierarchyLinear extends ATest<TwoLevelHierarchyLinear.I> { + public TwoLevelHierarchyLinear() { super(I.class, C.class); } + + interface J { default Object m() { return WRONG; } } + + interface I extends J { Object m(); } + static class C implements I { public Object m() { return CORRECT; }} + + interface K1 extends I {} + interface K2 extends I { Object m(); } + interface K3 extends I { default Object m() { return WRONG; }} + + static class D implements I { public Object m() { return WRONG; }} + + static class DJ1 implements J {} + static class DJ2 implements J { public Object m() { return WRONG; }} + + @DontInline + public Object test(I i) { + return i.m(); + } + + @TestCase + public void testMega1() { + // 0. Trigger compilation of a megamorphic call site + compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I.m ABSTRACT <: intf J.m ABSTRACT + assertCompiled(); + + // Dependency: type = unique_concrete_method, context = I, method = C.m + + checkInvalidReceiver(); // ensure proper type check is preserved + + // 1. No deoptimization/invalidation on not-yet-seen receiver + repeat(100, () -> call(new C(){})); // Cn <: C.m <: intf I.m ABSTRACT <: intf J.m DEFAULT + assertCompiled(); + + // 2. No dependency invalidation on class loading of unrelated classes: different context + initialize(K1.class, // intf K1 <: intf I.m ABSTRACT <: intf J.m DEFAULT + K2.class, // intf K2.m ABSTRACT <: intf I.m ABSTRACT <: intf J.m DEFAULT + DJ1.class, // DJ1 <: intf J.m DEFAULT + DJ2.class); // DJ2.m <: intf J.m DEFAULT + assertCompiled(); + + // 3. Dependency invalidation on D <: I + initialize(D.class); // D.m <: intf I.m ABSTRACT <: intf J.m DEFAULT + assertNotCompiled(); + + // 4. Recompilation: no inlining, no dependencies + compile(megamorphic()); + call(new C() { public Object m() { return CORRECT; }}); // Cn.m <: C.m <: intf I.m ABSTRACT <: intf J.m DEFAULT + assertCompiled(); + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + } + + @TestCase + public void testMega2() { + // 0. Trigger compilation of a megamorphic call site + compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I.m ABSTRACT <: intf J.m DEFAULT + assertCompiled(); + + // Dependency: type = unique_concrete_method, context = I, method = C.m + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + + // 1. Dependency invalidation + initialize(K3.class); // intf K3.m DEFAULT <: intf I.m ABSTRACT <: intf J.m DEFAULT + assertNotCompiled(); + + // 2. Recompilation: still inlines + // FIXME: no default method support in CHA yet + compile(megamorphic()); + call(new K3() { public Object m() { return CORRECT; }}); // K3n.m <: intf K3.m DEFAULT <: intf I.m ABSTRACT <: intf J.m ABSTRACT + assertNotCompiled(); + + // 3. Recompilation: no inlining, no dependencies + compile(megamorphic()); + call(new K3() { public Object m() { return CORRECT; }}); // Kn.m <: intf K3.m DEFAULT <: intf I.m ABSTRACT <: intf J.m DEFAULT + assertCompiled(); + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + } + + @Override + public void checkInvalidReceiver() { + shouldThrow(IncompatibleClassChangeError.class, () -> { + I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated + test(o); + }); + assertCompiled(); + + shouldThrow(IncompatibleClassChangeError.class, () -> { + I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J() {}); // super interface + test(j); + }); + assertCompiled(); + } + } + + public static class ThreeLevelHierarchyLinear extends ATest<ThreeLevelHierarchyLinear.I> { + public ThreeLevelHierarchyLinear() { super(I.class, C.class); } + + interface J { Object m(); } + interface I extends J {} + + interface K1 extends I {} + interface K2 extends I { Object m(); } + interface K3 extends I { default Object m() { return WRONG; }} + + static class C implements I { public Object m() { return CORRECT; }} + + static class DI implements I { public Object m() { return WRONG; }} + static class DJ implements J { public Object m() { return WRONG; }} + + @DontInline + public Object test(I i) { + return i.m(); // I <: J.m ABSTRACT + } + + @TestCase + public void testMega1() { + // 0. Trigger compilation of a megamorphic call site + compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I <: intf J.m ABSTRACT + assertCompiled(); + + // Dependency: type = unique_concrete_method, context = I, method = C.m + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + + // 1. No deoptimization/invalidation on not-yet-seen receiver + repeat(100, () -> call(new C(){})); // Cn <: C.m <: intf I + assertCompiled(); // No deopt on not-yet-seen receiver + + // 2. No dependency invalidation: different context + initialize(DJ.class, // DJ.m <: intf J.m ABSTRACT + K1.class, // intf K1 <: intf I <: intf J.m ABSTRACT + K2.class); // intf K2.m ABSTRACT <: intf I <: intf J.m ABSTRACT + assertCompiled(); + + // 3. Dependency invalidation: DI.m <: I + initialize(DI.class); // DI.m <: intf I <: intf J.m ABSTRACT + assertNotCompiled(); + + // 4. Recompilation w/o a dependency + compile(megamorphic()); + call(new C() { public Object m() { return CORRECT; }}); // Cn.m <: C.m <: intf I <: intf J.m ABSTRACT + assertCompiled(); // no dependency + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + } + + @TestCase + public void testMega2() { + compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I <: intf J.m ABSTRACT + assertCompiled(); + + // Dependency: type = unique_concrete_method, context = I, method = C.m + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + + // Dependency invalidation + initialize(K3.class); // intf K3.m DEFAULT <: intf I; + assertNotCompiled(); // FIXME: default methods in sub-interfaces shouldn't be taken into account by CHA + + // Recompilation with a dependency + compile(megamorphic()); + assertCompiled(); + + // Dependency: type = unique_concrete_method, context = I, method = C.m + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + + call(new K3() { public Object m() { return CORRECT; }}); // Kn.m <: K3.m DEFAULT <: intf I <: intf J.m ABSTRACT + assertNotCompiled(); + + // Recompilation w/o a dependency + compile(megamorphic()); + // Dependency: none + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + call(new C() { public Object m() { return CORRECT; }}); // Cn.m <: C.m <: intf I <: intf J.m ABSTRACT + assertCompiled(); + } + + @Override + public void checkInvalidReceiver() { + shouldThrow(IncompatibleClassChangeError.class, () -> { + I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated + test(o); + }); + assertCompiled(); + + shouldThrow(IncompatibleClassChangeError.class, () -> { + I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J() { public Object m() { return WRONG; }}); // super interface + test(j); + }); + assertCompiled(); + } + } + + public static class ThreeLevelHierarchyAbstractVsDefault extends ATest<ThreeLevelHierarchyAbstractVsDefault.I> { + public ThreeLevelHierarchyAbstractVsDefault() { super(I.class, C.class); } + + interface J1 { default Object m() { return WRONG; } } // intf J1.m DEFAULT + interface J2 extends J1 { Object m(); } // intf J2.m ABSTRACT <: intf J1 + interface I extends J1, J2 {} // intf I.m OVERPASS <: intf J1,J2 + + static class C implements I { public Object m() { return CORRECT; }} + + @DontInline + public Object test(I i) { + return i.m(); // intf I.m OVERPASS + } + + static class DI implements I { public Object m() { return WRONG; }} + + static class DJ11 implements J1 {} + static class DJ12 implements J1 { public Object m() { return WRONG; }} + + static class DJ2 implements J2 { public Object m() { return WRONG; }} + + interface K11 extends J1 {} + interface K12 extends J1 { Object m(); } + interface K13 extends J1 { default Object m() { return WRONG; }} + interface K21 extends J2 {} + interface K22 extends J2 { Object m(); } + interface K23 extends J2 { default Object m() { return WRONG; }} + + + public void testMega1() { + // 0. Trigger compilation of megamorphic call site + compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I.m OVERPASS <: intf J2.m ABSTRACT <: intf J1.m DEFAULT + assertCompiled(); + + // Dependency: type = unique_concrete_method, context = I, method = C.m + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + + // 1. No deopt/invalidation on not-yet-seen receiver + repeat(100, () -> call(new C(){})); // Cn <: C.m <: intf I.m OVERPASS <: intf J2.m ABSTRACT <: intf J1.m DEFAULT + assertCompiled(); + + // 2. No dependency invalidation: different context + initialize(K11.class, K12.class, K13.class, + K21.class, K22.class, K23.class); + + // 3. Dependency invalidation: Cn.m <: C <: I + call(new C() { public Object m() { return CORRECT; }}); // Cn.m <: C.m <: intf I.m OVERPASS <: intf J2.m ABSTRACT <: intf J1.m DEFAULT + assertNotCompiled(); + + // 4. Recompilation w/o a dependency + compile(megamorphic()); + call(new C() { public Object m() { return CORRECT; }}); + assertCompiled(); // no inlining + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + } + + public void testMega2() { + // 0. Trigger compilation of a megamorphic call site + compile(megamorphic()); + assertCompiled(); + + // Dependency: type = unique_concrete_method, context = I, method = C.m + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + + // 1. No dependency invalidation: different context + initialize(DJ11.class, + DJ12.class, + DJ2.class); + assertCompiled(); + + // 2. Dependency invalidation: DI.m <: I + initialize(DI.class); + assertNotCompiled(); + + // 3. Recompilation w/o a dependency + compile(megamorphic()); + call(new C() { public Object m() { return CORRECT; }}); + assertCompiled(); // no inlining + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + } + + @Override + public void checkInvalidReceiver() { + shouldThrow(IncompatibleClassChangeError.class, () -> { + I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated + test(o); + }); + assertCompiled(); + + shouldThrow(IncompatibleClassChangeError.class, () -> { + I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J1() {}); // super interface + test(j); + }); + assertCompiled(); + + shouldThrow(IncompatibleClassChangeError.class, () -> { + I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J2() { public Object m() { return WRONG; }}); // super interface + test(j); + }); + assertCompiled(); + } + } + + public static class ThreeLevelDefaultHierarchy extends ATest<ThreeLevelDefaultHierarchy.I> { + public ThreeLevelDefaultHierarchy() { super(I.class, C.class); } + + interface J { default Object m() { return WRONG; }} + interface I extends J {} + + static class C implements I { public Object m() { return CORRECT; }} + + interface K1 extends I {} + interface K2 extends I { Object m(); } + interface K3 extends I { default Object m() { return WRONG; }} + + static class DI implements I { public Object m() { return WRONG; }} + static class DJ implements J { public Object m() { return WRONG; }} + + @DontInline + public Object test(I i) { + return i.m(); // no inlining since J.m is a default method + } + + @TestCase + public void testMega() { + // 0. Trigger compilation of a megamorphic call site + compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I <: intf J.m ABSTRACT + assertCompiled(); + + // Dependency: none + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + + // 1. No deoptimization/invalidation on not-yet-seen receiver + repeat(100, () -> call(new C() {})); + assertCompiled(); + + // 2. No dependency and no inlining + initialize(DJ.class, // DJ.m <: intf J.m ABSTRACT + DI.class, // DI.m <: intf I <: intf J.m ABSTRACT + K1.class, // intf K1 <: intf I <: intf J.m ABSTRACT + K2.class); // intf K2.m ABSTRACT <: intf I <: intf J.m ABSTRACT + assertCompiled(); + } + + @Override + public void checkInvalidReceiver() { + shouldThrow(IncompatibleClassChangeError.class, () -> { + I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated + test(o); + }); + assertCompiled(); + + shouldThrow(IncompatibleClassChangeError.class, () -> { + I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J() {}); // super interface + test(j); + }); + assertCompiled(); + } + } + + public static class ThreeLevelDefaultHierarchy1 extends ATest<ThreeLevelDefaultHierarchy1.I> { + public ThreeLevelDefaultHierarchy1() { super(I.class, C.class); } + + interface J1 { Object m();} + interface J2 extends J1 { default Object m() { return WRONG; } } + interface I extends J1, J2 {} + + static class C implements I { public Object m() { return CORRECT; }} + + interface K1 extends I {} + interface K2 extends I { Object m(); } + interface K3 extends I { default Object m() { return WRONG; }} + + static class DI implements I { public Object m() { return WRONG; }} + static class DJ1 implements J1 { public Object m() { return WRONG; }} + static class DJ2 implements J2 { public Object m() { return WRONG; }} + + @DontInline + public Object test(I i) { + return i.m(); // no inlining since J.m is a default method + } + + @TestCase + public void testMega() { + // 0. Trigger compilation of a megamorphic call site + compile(megamorphic()); + assertCompiled(); + + // Dependency: none + + checkInvalidReceiver(); // ensure proper type check on receiver is preserved + + // 1. No deoptimization/invalidation on not-yet-seen receiver + repeat(100, () -> call(new C() {})); + assertCompiled(); + + // 2. No dependency, no inlining + // CHA doesn't support default methods yet. + initialize(DJ1.class, + DJ2.class, + DI.class, + K1.class, + K2.class, + K3.class); + assertCompiled(); + } + + @Override + public void checkInvalidReceiver() { + shouldThrow(IncompatibleClassChangeError.class, () -> { + I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated + test(o); + }); + assertCompiled(); + + shouldThrow(IncompatibleClassChangeError.class, () -> { + I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J1() { public Object m() { return WRONG; } }); // super interface + test(j); + }); + assertCompiled(); + + shouldThrow(IncompatibleClassChangeError.class, () -> { + I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J2() {}); // super interface + test(j); + }); + assertCompiled(); + } + } + /* =========================================================== */ interface Action {
--- a/test/hotspot/jtreg/compiler/cha/ThreeLevelDefaultHierarchy.java Tue Oct 08 14:26:57 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ - -package compiler.cha; - -import jdk.internal.vm.annotation.DontInline; -import static compiler.cha.StrengthReduceInterfaceCall.*; - -public class ThreeLevelDefaultHierarchy extends ATest<ThreeLevelDefaultHierarchy.I> { - public ThreeLevelDefaultHierarchy() { - super(I.class, C.class); - } - - interface J { default Object m() { return WRONG; }} - interface I extends J {} - - static class C implements I { public Object m() { return CORRECT; }} - - interface K1 extends I {} - interface K2 extends I { Object m(); } - interface K3 extends I { default Object m() { return WRONG; }} - - static class DI implements I { public Object m() { return WRONG; }} - static class DJ implements J { public Object m() { return WRONG; }} - - @DontInline - public Object test(I i) { - return i.m(); // no inlining since J.m is a default method - } - - @TestCase - public void testMega() { - // 0. Trigger compilation of a megamorphic call site - compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I <: intf J.m ABSTRACT - assertCompiled(); - - // Dependency: none - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - - // 1. No deoptimization/invalidation on not-yet-seen receiver - repeat(100, () -> call(new C() {})); - assertCompiled(); - - // 2. No dependency and no inlining - initialize(DJ.class, // DJ.m <: intf J.m ABSTRACT - DI.class, // DI.m <: intf I <: intf J.m ABSTRACT - K1.class, // intf K1 <: intf I <: intf J.m ABSTRACT - K2.class); // intf K2.m ABSTRACT <: intf I <: intf J.m ABSTRACT - assertCompiled(); - } - - @Override - public void checkInvalidReceiver() { - shouldThrow(IncompatibleClassChangeError.class, () -> { - I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated - test(o); - }); - assertCompiled(); - - shouldThrow(IncompatibleClassChangeError.class, () -> { - I j = (I) unsafeCastMH(I.class).invokeExact((Object) new J() { - }); // super interface - test(j); - }); - assertCompiled(); - } -}
--- a/test/hotspot/jtreg/compiler/cha/ThreeLevelDefaultHierarchy1.java Tue Oct 08 14:26:57 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ - -package compiler.cha; - -import jdk.internal.vm.annotation.DontInline; -import static compiler.cha.StrengthReduceInterfaceCall.*; - -public class ThreeLevelDefaultHierarchy1 extends ATest<ThreeLevelDefaultHierarchy1.I> { - public ThreeLevelDefaultHierarchy1() { - super(I.class, C.class); - } - - interface J1 { Object m();} - interface J2 extends J1 { default Object m() { return WRONG; } } - interface I extends J1, J2 {} - - static class C implements I { public Object m() { return CORRECT; }} - - interface K1 extends I {} - interface K2 extends I { Object m(); } - interface K3 extends I { default Object m() { return WRONG; }} - - static class DI implements I { public Object m() { return WRONG; }} - static class DJ1 implements J1 { public Object m() { return WRONG; }} - static class DJ2 implements J2 { public Object m() { return WRONG; }} - - @DontInline - public Object test(I i) { - return i.m(); // no inlining since J.m is a default method - } - - @TestCase - public void testMega() { - // 0. Trigger compilation of a megamorphic call site - compile(megamorphic()); - assertCompiled(); - - // Dependency: none - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - - // 1. No deoptimization/invalidation on not-yet-seen receiver - repeat(100, () -> call(new C() {})); - assertCompiled(); - - // 2. No dependency, no inlining - // CHA doesn't support default methods yet. - initialize(DJ1.class, - DJ2.class, - DI.class, - K1.class, - K2.class, - K3.class); - assertCompiled(); - } - - @Override - public void checkInvalidReceiver() { - shouldThrow(IncompatibleClassChangeError.class, () -> { - I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated - test(o); - }); - assertCompiled(); - - shouldThrow(IncompatibleClassChangeError.class, () -> { - I j = (I) unsafeCastMH(I.class).invokeExact((Object) new J1() { - public Object m() { - return WRONG; - } - }); // super interface - test(j); - }); - assertCompiled(); - - shouldThrow(IncompatibleClassChangeError.class, () -> { - I j = (I) unsafeCastMH(I.class).invokeExact((Object) new J2() { - }); // super interface - test(j); - }); - assertCompiled(); - } -}
--- a/test/hotspot/jtreg/compiler/cha/ThreeLevelHierarchyAbstractVsDefault.java Tue Oct 08 14:26:57 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ - -package compiler.cha; - -import jdk.internal.vm.annotation.DontInline; -import static compiler.cha.StrengthReduceInterfaceCall.*; - -public class ThreeLevelHierarchyAbstractVsDefault extends ATest<ThreeLevelHierarchyAbstractVsDefault.I> { - public ThreeLevelHierarchyAbstractVsDefault() { - super(I.class, C.class); - } - - interface J1 { default Object m() { return WRONG; } } // intf J1.m DEFAULT - interface J2 extends J1 { Object m(); } // intf J2.m ABSTRACT <: intf J1 - interface I extends J1, J2 {} // intf I.m OVERPASS <: intf J1,J2 - - static class C implements I { public Object m() { return CORRECT; }} - - @DontInline - public Object test(I i) { - return i.m(); // intf I.m OVERPASS - } - - static class DI implements I { public Object m() { return WRONG; }} - - static class DJ11 implements J1 {} - static class DJ12 implements J1 { public Object m() { return WRONG; }} - - static class DJ2 implements J2 { public Object m() { return WRONG; }} - - interface K11 extends J1 {} - interface K12 extends J1 { Object m(); } - interface K13 extends J1 { default Object m() { return WRONG; }} - interface K21 extends J2 {} - interface K22 extends J2 { Object m(); } - interface K23 extends J2 { default Object m() { return WRONG; }} - - public void testMega1() { - // 0. Trigger compilation of megamorphic call site - compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I.m OVERPASS <: intf J2.m ABSTRACT <: intf J1.m DEFAULT - assertCompiled(); - - // Dependency: type = unique_concrete_method, context = I, method = C.m - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - - // 1. No deopt/invalidation on not-yet-seen receiver - repeat(100, () -> call(new C(){})); // Cn <: C.m <: intf I.m OVERPASS <: intf J2.m ABSTRACT <: intf J1.m DEFAULT - assertCompiled(); - - // 2. No dependency invalidation: different context - initialize(K11.class, K12.class, K13.class, - K21.class, K22.class, K23.class); - - // 3. Dependency invalidation: Cn.m <: C <: I - call(new C() { public Object m() { return CORRECT; }}); // Cn.m <: C.m <: intf I.m OVERPASS <: intf J2.m ABSTRACT <: intf J1.m DEFAULT - assertNotCompiled(); - - // 4. Recompilation w/o a dependency - compile(megamorphic()); - call(new C() { public Object m() { return CORRECT; }}); - assertCompiled(); // no inlining - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - } - - public void testMega2() { - // 0. Trigger compilation of a megamorphic call site - compile(megamorphic()); - assertCompiled(); - - // Dependency: type = unique_concrete_method, context = I, method = C.m - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - - // 1. No dependency invalidation: different context - initialize(DJ11.class, - DJ12.class, - DJ2.class); - assertCompiled(); - - // 2. Dependency invalidation: DI.m <: I - initialize(DI.class); - assertNotCompiled(); - - // 3. Recompilation w/o a dependency - compile(megamorphic()); - call(new C() { public Object m() { return CORRECT; }}); - assertCompiled(); // no inlining - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - } - - @Override - public void checkInvalidReceiver() { - shouldThrow(IncompatibleClassChangeError.class, () -> { - I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated - test(o); - }); - assertCompiled(); - - shouldThrow(IncompatibleClassChangeError.class, () -> { - I j = (I) unsafeCastMH(I.class).invokeExact((Object) new J1() { - }); // super interface - test(j); - }); - assertCompiled(); - - shouldThrow(IncompatibleClassChangeError.class, () -> { - I j = (I) unsafeCastMH(I.class).invokeExact((Object) new J2() { - public Object m() { - return WRONG; - } - }); // super interface - test(j); - }); - assertCompiled(); - } -} -
--- a/test/hotspot/jtreg/compiler/cha/ThreeLevelHierarchyLinear.java Tue Oct 08 14:26:57 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ - -package compiler.cha; - -import jdk.internal.vm.annotation.DontInline; -import static compiler.cha.StrengthReduceInterfaceCall.*; - -public class ThreeLevelHierarchyLinear extends ATest<ThreeLevelHierarchyLinear.I> { - public ThreeLevelHierarchyLinear() { - super(I.class, C.class); - } - - interface J { Object m(); } - interface I extends J {} - - interface K1 extends I {} - interface K2 extends I { Object m(); } - interface K3 extends I { default Object m() { return WRONG; }} - - static class C implements I { public Object m() { return CORRECT; }} - - static class DI implements I { public Object m() { return WRONG; }} - static class DJ implements J { public Object m() { return WRONG; }} - - @DontInline - public Object test(I i) { - return i.m(); // I <: J.m ABSTRACT - } - - @TestCase - public void testMega1() { - // 0. Trigger compilation of a megamorphic call site - compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I <: intf J.m ABSTRACT - assertCompiled(); - - // Dependency: type = unique_concrete_method, context = I, method = C.m - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - - // 1. No deoptimization/invalidation on not-yet-seen receiver - repeat(100, () -> call(new C(){})); // Cn <: C.m <: intf I - assertCompiled(); // No deopt on not-yet-seen receiver - - // 2. No dependency invalidation: different context - initialize(DJ.class, // DJ.m <: intf J.m ABSTRACT - K1.class, // intf K1 <: intf I <: intf J.m ABSTRACT - K2.class); // intf K2.m ABSTRACT <: intf I <: intf J.m ABSTRACT - assertCompiled(); - - // 3. Dependency invalidation: DI.m <: I - initialize(DI.class); // DI.m <: intf I <: intf J.m ABSTRACT - assertNotCompiled(); - - // 4. Recompilation w/o a dependency - compile(megamorphic()); - call(new C() { public Object m() { return CORRECT; }}); // Cn.m <: C.m <: intf I <: intf J.m ABSTRACT - - assertCompiled(); // no dependency - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - } - - @TestCase - public void testMega2() { - compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I <: intf J.m ABSTRACT - assertCompiled(); - - // Dependency: type = unique_concrete_method, context = I, method = C.m - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - - // Dependency invalidation - initialize(K3.class); // intf K3.m DEFAULT <: intf I; - assertNotCompiled(); // FIXME: default methods in sub-interfaces shouldn't be taken into account by CHA - - // Recompilation with a dependency - compile(megamorphic()); - assertCompiled(); - - // Dependency: type = unique_concrete_method, context = I, method = C.m - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - - call(new K3() { public Object m() { return CORRECT; }}); // Kn.m <: K3.m DEFAULT <: intf I <: intf J.m ABSTRACT - assertNotCompiled(); - - // Recompilation w/o a dependency - compile(megamorphic()); - // Dependency: none - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - call(new C() { public Object m() { return CORRECT; }}); // Cn.m <: C.m <: intf I <: intf J.m ABSTRACT - assertCompiled(); - } - - @Override - public void checkInvalidReceiver() { - shouldThrow(IncompatibleClassChangeError.class, () -> { - I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated - test(o); - }); - assertCompiled(); - - shouldThrow(IncompatibleClassChangeError.class, () -> { - I j = (I) unsafeCastMH(I.class).invokeExact((Object) new J() { - public Object m() { - return WRONG; - } - }); // super interface - test(j); - }); - assertCompiled(); - } -}
--- a/test/hotspot/jtreg/compiler/cha/TwoLevelHierarchyLinear.java Tue Oct 08 14:26:57 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ - -package compiler.cha; - -import jdk.internal.vm.annotation.DontInline; -import static compiler.cha.StrengthReduceInterfaceCall.*; - -public class TwoLevelHierarchyLinear extends ATest<TwoLevelHierarchyLinear.I> { - public TwoLevelHierarchyLinear() { - super(I.class, C.class); - } - - interface J { default Object m() { return WRONG; } } - - interface I extends J { Object m(); } - static class C implements I { public Object m() { return CORRECT; }} - - interface K1 extends I {} - interface K2 extends I { Object m(); } - interface K3 extends I { default Object m() { return WRONG; }} - - static class D implements I { public Object m() { return WRONG; }} - - static class DJ1 implements J {} - static class DJ2 implements J { public Object m() { return WRONG; }} - - @DontInline - public Object test(I i) { - return i.m(); - } - - @TestCase - public void testMega1() { - // 0. Trigger compilation of a megamorphic call site - compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I.m ABSTRACT <: intf J.m ABSTRACT - assertCompiled(); - - // Dependency: type = unique_concrete_method, context = I, method = C.m - - checkInvalidReceiver(); // ensure proper type check is preserved - - // 1. No deoptimization/invalidation on not-yet-seen receiver - repeat(100, () -> call(new C(){})); // Cn <: C.m <: intf I.m ABSTRACT <: intf J.m DEFAULT - assertCompiled(); - - // 2. No dependency invalidation on class loading of unrelated classes: different context - initialize(K1.class, // intf K1 <: intf I.m ABSTRACT <: intf J.m DEFAULT - K2.class, // intf K2.m ABSTRACT <: intf I.m ABSTRACT <: intf J.m DEFAULT - DJ1.class, // DJ1 <: intf J.m DEFAULT - DJ2.class); // DJ2.m <: intf J.m DEFAULT - assertCompiled(); - - // 3. Dependency invalidation on D <: I - initialize(D.class); // D.m <: intf I.m ABSTRACT <: intf J.m DEFAULT - assertNotCompiled(); - - // 4. Recompilation: no inlining, no dependencies - compile(megamorphic()); - call(new C() { public Object m() { return CORRECT; }}); // Cn.m <: C.m <: intf I.m ABSTRACT <: intf J.m DEFAULT - assertCompiled(); - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - } - - @TestCase - public void testMega2() { - // 0. Trigger compilation of a megamorphic call site - compile(megamorphic()); // C1,C2,C3 <: C.m <: intf I.m ABSTRACT <: intf J.m DEFAULT - assertCompiled(); - - // Dependency: type = unique_concrete_method, context = I, method = C.m - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - - // 1. Dependency invalidation - initialize(K3.class); // intf K3.m DEFAULT <: intf I.m ABSTRACT <: intf J.m DEFAULT - assertNotCompiled(); - - // 2. Recompilation: still inlines - // FIXME: no default method support in CHA yet - compile(megamorphic()); - call(new K3() { public Object m() { return CORRECT; }}); // K3n.m <: intf K3.m DEFAULT <: intf I.m ABSTRACT <: intf J.m ABSTRACT - assertNotCompiled(); - - // 3. Recompilation: no inlining, no dependencies - compile(megamorphic()); - call(new K3() { public Object m() { return CORRECT; }}); // Kn.m <: intf K3.m DEFAULT <: intf I.m ABSTRACT <: intf J.m DEFAULT - assertCompiled(); - - checkInvalidReceiver(); // ensure proper type check on receiver is preserved - } - - @Override - public void checkInvalidReceiver() { - shouldThrow(IncompatibleClassChangeError.class, () -> { - I o = (I) unsafeCastMH(I.class).invokeExact(new Object()); // unrelated - test(o); - }); - assertCompiled(); - - shouldThrow(IncompatibleClassChangeError.class, () -> { - I j = (I) unsafeCastMH(I.class).invokeExact((Object)new J() {}); // super interface - test(j); - }); - assertCompiled(); - } -} -
--- a/test/langtools/jdk/javadoc/tool/DOption.java Tue Oct 08 14:26:57 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ - -import jdk.javadoc.doclet.Doclet; - -import java.util.ArrayList; -import java.util.List; - -class DOption implements Doclet.Option { - private final List<String> names = new ArrayList<>(); - private final int argCount; - - DOption(String name, int argCount) { - this.names.add(name); - this.argCount = argCount; - } - - @Override - public int getArgumentCount() { - return argCount; - } - - @Override - public String getDescription() { - return "description[" + names.get(0) + "]"; - } - - @Override - public Kind getKind() { - return Doclet.Option.Kind.STANDARD; - } - - @Override - public List<String> getNames() { - return names; - } - - @Override - public String getParameters() { - return argCount > 0 ? "parameters[" + names.get(0) + "," + argCount + "]" : null; - } - - @Override - public boolean process(String option, List<String> arguments) { - List<String> args = new ArrayList<>(); - for (int i = 0; i < argCount && i < arguments.size(); i++) { - args.add(arguments.get(i)); - } - System.out.println("process " + option + " " + args); - return args.stream().filter(s -> s.startsWith("arg")).count() == argCount; - } -}
--- a/test/langtools/jdk/javadoc/tool/OptionSyntaxTest.java Tue Oct 08 14:26:57 2019 -0700 +++ b/test/langtools/jdk/javadoc/tool/OptionSyntaxTest.java Tue Oct 08 17:58:39 2019 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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 @@ -31,14 +31,15 @@ * @modules jdk.javadoc/jdk.javadoc.internal.tool * @library /tools/lib * @build toolbox.JavacTask toolbox.JavadocTask toolbox.ModuleBuilder toolbox.TestRunner toolbox.ToolBox - * @build DOption * @run main OptionSyntaxTest */ import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; +import java.util.List; import java.util.Locale; import java.util.Set; @@ -93,6 +94,50 @@ } + static class DOption implements Doclet.Option { + private final List<String> names = new ArrayList<>(); + private final int argCount; + + DOption(String name, int argCount) { + this.names.add(name); + this.argCount = argCount; + } + + @Override + public int getArgumentCount() { + return argCount; + } + + @Override + public String getDescription() { + return "description[" + names.get(0) + "]"; + } + + @Override + public Kind getKind() { + return Doclet.Option.Kind.STANDARD; + } + + @Override + public List<String> getNames() { + return names; + } + + @Override + public String getParameters() { + return argCount > 0 ? "parameters[" + names.get(0) + "," + argCount + "]" : null; + } + + @Override + public boolean process(String option, List<String> arguments) { + List<String> args = new ArrayList<>(); + for (int i = 0; i < argCount && i < arguments.size(); i++) { + args.add(arguments.get(i)); + } + System.out.println("process " + option + " " + args); + return args.stream().filter(s -> s.startsWith("arg")).count() == argCount; + } + } public static void main(String... args) throws Exception { OptionSyntaxTest t = new OptionSyntaxTest();
--- a/test/langtools/tools/javac/modules/AnnotationsOnModules.java Tue Oct 08 14:26:57 2019 -0700 +++ b/test/langtools/tools/javac/modules/AnnotationsOnModules.java Tue Oct 08 17:58:39 2019 -0700 @@ -29,7 +29,7 @@ * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main * jdk.jdeps/com.sun.tools.classfile - * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase ProxyTypeValidator + * @build toolbox.ToolBox toolbox.JavacTask ModuleTestBase * @run main AnnotationsOnModules */ @@ -39,7 +39,9 @@ import java.util.Arrays; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.RoundEnvironment; @@ -677,7 +679,7 @@ .options("--module-path", modulePath.toString(), "--add-modules", "m", "-processorpath", System.getProperty("test.classes"), - "-processor", "ProxyTypeValidator", + "-processor", ProxyTypeValidator.class.getName(), "-A" + OPT_EXPECTED_ANNOTATIONS + "=" + tc.expectedAnnotations) .outdir(classes) .files(findJavaFiles(extraSrc)) @@ -687,4 +689,24 @@ } private static final String OPT_EXPECTED_ANNOTATIONS = "expectedAnnotations"; + + @SupportedAnnotationTypes("*") + @SupportedOptions(OPT_EXPECTED_ANNOTATIONS) + public static final class ProxyTypeValidator extends AbstractProcessor { + + @Override + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { + ModuleElement m = processingEnv.getElementUtils().getModuleElement("m"); + String actualTypes = m.getAnnotationMirrors() + .stream() + .map(am -> am.toString()) + .collect(Collectors.joining(", ")); + if (!Objects.equals(actualTypes, processingEnv.getOptions().get(OPT_EXPECTED_ANNOTATIONS))) { + throw new IllegalStateException("Expected annotations not found, actual: " + actualTypes); + } + return false; + } + + } + }
--- a/test/langtools/tools/javac/modules/ProxyTypeValidator.java Tue Oct 08 14:26:57 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ - -import javax.annotation.processing.AbstractProcessor; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedAnnotationTypes; -import javax.annotation.processing.SupportedOptions; -import javax.lang.model.element.ModuleElement; -import javax.lang.model.element.TypeElement; -import java.util.Objects; -import java.util.Set; -import java.util.stream.Collectors; - -@SupportedAnnotationTypes("*") -@SupportedOptions("expectedAnnotations") -public final class ProxyTypeValidator extends AbstractProcessor { - - @Override - public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { - ModuleElement m = processingEnv.getElementUtils().getModuleElement("m"); - String actualTypes = m.getAnnotationMirrors() - .stream() - .map(am -> am.toString()) - .collect(Collectors.joining(", ")); - if (!Objects.equals(actualTypes, processingEnv.getOptions().get("expectedAnnotations"))) { - throw new IllegalStateException("Expected annotations not found, actual: " + actualTypes); - } - return false; - } -}
--- a/test/langtools/tools/javac/processing/model/element/ListMembersAP.java Tue Oct 08 14:26:57 2019 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2019, 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. - */ - -import javax.annotation.processing.*; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.*; -import javax.lang.model.util.Elements; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -@SupportedAnnotationTypes("*") -public final class ListMembersAP extends AbstractProcessor { - - @Override - public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { - if (!roundEnv.processingOver()) - return false; - - Elements elements = processingEnv.getElementUtils(); - TypeElement test = elements.getTypeElement("test.Test"); - List<? extends Element> members = new ArrayList<>(test.getEnclosedElements()); - - Collections.sort(members, - (e1, e2) -> e1.getSimpleName().toString().compareTo(e2.getSimpleName().toString())); - - for (Element el : members) { - System.out.println(el.getSimpleName() + ":" + elements.getOrigin(el)); - } - - return false; - } - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latestSupported(); - } - -}
--- a/test/langtools/tools/javac/processing/model/element/TestOrigin.java Tue Oct 08 14:26:57 2019 -0700 +++ b/test/langtools/tools/javac/processing/model/element/TestOrigin.java Tue Oct 08 17:58:39 2019 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2015, 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 @@ -30,7 +30,7 @@ * jdk.compiler/com.sun.tools.javac.main * jdk.jdeps/com.sun.tools.classfile * @build toolbox.ToolBox toolbox.JavacTask toolbox.TestRunner - * @build TestOrigin ListMembersAP + * @build TestOrigin * @run main TestOrigin */ @@ -38,7 +38,9 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -93,7 +95,7 @@ //from source: log = new JavacTask(tb) - .options("-processor", "ListMembersAP") + .options("-processor", ListMembersAP.class.getName()) .outdir(classes) .files(tb.findJavaFiles(src)) .run() @@ -111,7 +113,7 @@ log = new JavacTask(tb) .options("-classpath", classes.toString(), "-processorpath", System.getProperty("test.classes"), - "-processor", "ListMembersAP") + "-processor", ListMembersAP.class.getName()) .outdir(classes) .files(src.resolve("Dummy.java")) .run() @@ -126,6 +128,35 @@ throw new AssertionError("expected output not found: " + log); } + @SupportedAnnotationTypes("*") + public static final class ListMembersAP extends AbstractProcessor { + + @Override + public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { + if (!roundEnv.processingOver()) + return false; + + Elements elements = processingEnv.getElementUtils(); + TypeElement test = elements.getTypeElement("test.Test"); + List<? extends Element> members = new ArrayList<>(test.getEnclosedElements()); + + Collections.sort(members, + (e1, e2) -> e1.getSimpleName().toString().compareTo(e2.getSimpleName().toString())); + + for (Element el : members) { + System.out.println(el.getSimpleName() + ":" + elements.getOrigin(el)); + } + + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latestSupported(); + } + + } + @Test public void testRepeatableAnnotations(Path base) throws Exception { Path src = base.resolve("src");