test/hotspot/jtreg/compiler/types/TestMeetIncompatibleInterfaceArrays.java
author kvn
Wed, 08 Aug 2018 18:38:34 -0700
changeset 51341 09cc8813ae51
parent 49654 16f53c9c7493
permissions -rw-r--r--
8207965: C2-only debug build fails Reviewed-by: kvn, iignatyev Contributed-by: xxinliu@amazon.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
     1
/*
49627
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
     2
 * Copyright (c) 2018 SAP SE. All rights reserved.
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
     4
 *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
     7
 * published by the Free Software Foundation.
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
     8
 *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    13
 * accompanied this code).
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    14
 *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    18
 *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    21
 * questions.
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    22
 */
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    23
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    24
/*
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    25
 * @test
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    26
 * @bug 8141551
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    27
 * @summary C2 can not handle returns with inccompatible interface arrays
49654
16f53c9c7493 8200461: MeetIncompatibleInterfaceArrays test fails with -Xcomp
kvn
parents: 49645
diff changeset
    28
 * @requires vm.compMode == "Xmixed" & vm.flavor == "server"
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    29
 * @modules java.base/jdk.internal.org.objectweb.asm
36851
03e2f4d0a421 8153737: Unsupported Module
chegar
parents: 35753
diff changeset
    30
 *          java.base/jdk.internal.misc
49627
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
    31
 * @library /test/lib /
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    32
 *
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    33
 * @build sun.hotspot.WhiteBox
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    34
 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    35
 *                                sun.hotspot.WhiteBox$WhiteBoxPermission
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    36
 * @run main/othervm
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    37
 *        -Xbootclasspath/a:.
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    38
 *        -XX:+UnlockDiagnosticVMOptions
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    39
 *        -XX:+WhiteBoxAPI
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    40
 *        -Xbatch
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    41
 *        -XX:-TieredCompilation
49645
2bf8f2fc0710 8200360: MeetIncompatibleInterfaceArrays fails with "MeetIncompatibleInterfaceArrays0ASM.run() must be compiled at tier 0 !"
simonis
parents: 49627
diff changeset
    42
 *        -XX:TieredStopAtLevel=4
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    43
 *        -XX:CICompilerCount=1
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    44
 *        -XX:+PrintCompilation
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    45
 *        -XX:+PrintInlining
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    46
 *        -XX:CompileCommand=compileonly,MeetIncompatibleInterfaceArrays*::run
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    47
 *        -XX:CompileCommand=dontinline,compiler.types.TestMeetIncompatibleInterfaceArrays$Helper::createI2*
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    48
 *        -XX:CompileCommand=quiet
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    49
 *        compiler.types.TestMeetIncompatibleInterfaceArrays 0
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    50
 * @run main/othervm
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    51
 *        -Xbootclasspath/a:.
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    52
 *        -XX:+UnlockDiagnosticVMOptions
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    53
 *        -XX:+WhiteBoxAPI
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    54
 *        -Xbatch
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    55
 *        -XX:-TieredCompilation
49645
2bf8f2fc0710 8200360: MeetIncompatibleInterfaceArrays fails with "MeetIncompatibleInterfaceArrays0ASM.run() must be compiled at tier 0 !"
simonis
parents: 49627
diff changeset
    56
 *        -XX:TieredStopAtLevel=4
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    57
 *        -XX:CICompilerCount=1
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    58
 *        -XX:+PrintCompilation
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    59
 *        -XX:+PrintInlining
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    60
 *        -XX:CompileCommand=compileonly,MeetIncompatibleInterfaceArrays*::run
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    61
 *        -XX:CompileCommand=inline,compiler.types.TestMeetIncompatibleInterfaceArrays$Helper::createI2*
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    62
 *        -XX:CompileCommand=quiet
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    63
 *        compiler.types.TestMeetIncompatibleInterfaceArrays 1
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    64
 * @run main/othervm
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    65
 *        -Xbootclasspath/a:.
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    66
 *        -XX:+UnlockDiagnosticVMOptions
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    67
 *        -XX:+WhiteBoxAPI
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    68
 *        -Xbatch
49645
2bf8f2fc0710 8200360: MeetIncompatibleInterfaceArrays fails with "MeetIncompatibleInterfaceArrays0ASM.run() must be compiled at tier 0 !"
simonis
parents: 49627
diff changeset
    69
 *        -XX:+TieredCompilation
2bf8f2fc0710 8200360: MeetIncompatibleInterfaceArrays fails with "MeetIncompatibleInterfaceArrays0ASM.run() must be compiled at tier 0 !"
simonis
parents: 49627
diff changeset
    70
 *        -XX:TieredStopAtLevel=4
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    71
 *        -XX:CICompilerCount=2
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    72
 *        -XX:+PrintCompilation
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    73
 *        -XX:+PrintInlining
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    74
 *        -XX:CompileCommand=compileonly,MeetIncompatibleInterfaceArrays*::run
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    75
 *        -XX:CompileCommand=compileonly,compiler.types.TestMeetIncompatibleInterfaceArrays$Helper::createI2*
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    76
 *        -XX:CompileCommand=inline,compiler.types.TestMeetIncompatibleInterfaceArrays$Helper::createI2*
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    77
 *        -XX:CompileCommand=quiet
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    78
 *        compiler.types.TestMeetIncompatibleInterfaceArrays 2
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    79
 *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    80
 * @author volker.simonis@gmail.com
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    81
 */
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    82
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    83
package compiler.types;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    84
49627
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
    85
import compiler.whitebox.CompilerWhiteBoxTest;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    86
import jdk.internal.org.objectweb.asm.ClassWriter;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    87
import jdk.internal.org.objectweb.asm.MethodVisitor;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    88
import sun.hotspot.WhiteBox;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    89
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    90
import java.io.FileOutputStream;
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    91
import java.lang.reflect.InvocationTargetException;
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
    92
import java.lang.reflect.Method;
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    93
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    94
import static jdk.internal.org.objectweb.asm.Opcodes.AALOAD;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    95
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    96
import static jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    97
import static jdk.internal.org.objectweb.asm.Opcodes.ALOAD;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    98
import static jdk.internal.org.objectweb.asm.Opcodes.ARETURN;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
    99
import static jdk.internal.org.objectweb.asm.Opcodes.ASTORE;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   100
import static jdk.internal.org.objectweb.asm.Opcodes.GETSTATIC;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   101
import static jdk.internal.org.objectweb.asm.Opcodes.ICONST_0;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   102
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKEINTERFACE;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   103
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESPECIAL;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   104
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESTATIC;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   105
import static jdk.internal.org.objectweb.asm.Opcodes.INVOKEVIRTUAL;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   106
import static jdk.internal.org.objectweb.asm.Opcodes.RETURN;
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   107
import static jdk.internal.org.objectweb.asm.Opcodes.V1_8;
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   108
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   109
public class TestMeetIncompatibleInterfaceArrays extends ClassLoader {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   110
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   111
    private static final WhiteBox WB = WhiteBox.getWhiteBox();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   112
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   113
    public static interface I1 { public String getName(); }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   114
    public static interface I2 { public String getName(); }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   115
    public static class I2C implements I2 { public String getName() { return "I2";} }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   116
    public static class I21C implements I2, I1 { public String getName() { return "I2 and I1";} }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   117
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   118
    public static class Helper {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   119
        public static I2 createI2Array0() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   120
            return new I2C();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   121
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   122
        public static I2[] createI2Array1() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   123
            return new I2C[] { new I2C() };
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   124
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   125
        public static I2[][] createI2Array2() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   126
            return new I2C[][] { new I2C[] { new I2C() } };
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   127
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   128
        public static I2[][][] createI2Array3() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   129
            return new I2C[][][] { new I2C[][] { new I2C[] { new I2C() } } };
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   130
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   131
        public static I2[][][][] createI2Array4() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   132
            return new I2C[][][][] { new I2C[][][] { new I2C[][] { new I2C[] { new I2C() } } } };
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   133
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   134
        public static I2[][][][][] createI2Array5() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   135
            return new I2C[][][][][] { new I2C[][][][] { new I2C[][][] { new I2C[][] { new I2C[] { new I2C() } } } } };
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   136
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   137
        public static I2 createI21Array0() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   138
            return new I21C();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   139
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   140
        public static I2[] createI21Array1() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   141
            return new I21C[] { new I21C() };
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   142
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   143
        public static I2[][] createI21Array2() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   144
            return new I21C[][] { new I21C[] { new I21C() } };
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   145
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   146
        public static I2[][][] createI21Array3() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   147
            return new I21C[][][] { new I21C[][] { new I21C[] { new I21C() } } };
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   148
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   149
        public static I2[][][][] createI21Array4() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   150
            return new I21C[][][][] { new I21C[][][] { new I21C[][] { new I21C[] { new I21C() } } } };
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   151
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   152
        public static I2[][][][][] createI21Array5() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   153
            return new I21C[][][][][] { new I21C[][][][] { new I21C[][][] { new I21C[][] { new I21C[] { new I21C() } } } } };
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   154
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   155
    }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   156
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   157
    // Location for the generated class files
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   158
    public static final String PATH = System.getProperty("test.classes", ".") + java.io.File.separator;
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   159
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   160
    /*
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   161
     * With 'good == false' this helper method creates the following classes
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   162
     * (using the nested 'Helper' class and the nested interfaces 'I1' and 'I2').
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   163
     * For brevity I omit the enclosing class 'TestMeetIncompatibleInterfaceArrays' in the
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   164
     * following examples:
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   165
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   166
     * public class MeetIncompatibleInterfaceArrays0ASM {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   167
     *   public static I1 run() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   168
     *     return Helper.createI2Array0(); // returns I2
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   169
     *   }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   170
     *   public static void test() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   171
     *     I1 i1 = run();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   172
     *     System.out.println(i1.getName());
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   173
     *   }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   174
     * }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   175
     * public class MeetIncompatibleInterfaceArrays1ASM {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   176
     *   public static I1[] run() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   177
     *     return Helper.createI2Array1(); // returns I2[]
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   178
     *   }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   179
     *   public static void test() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   180
     *     I1[] i1 = run();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   181
     *     System.out.println(i1[0].getName());
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   182
     *   }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   183
     * }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   184
     * ...
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   185
     * // MeetIncompatibleInterfaceArrays4ASM is special because it creates
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   186
     * // an illegal class which will be rejected by the verifier.
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   187
     * public class MeetIncompatibleInterfaceArrays4ASM {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   188
     *   public static I1[][][][] run() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   189
     *     return Helper.createI2Array3(); // returns I1[][][] which gives a verifier error because return expects I1[][][][]
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   190
     *   }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   191
     *   public static void test() {
49627
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   192
     *     I1[][][][] i1 = run();
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   193
     *     System.out.println(i1[0][0][0][0].getName());
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   194
     *   }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   195
     * ...
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   196
     * public class MeetIncompatibleInterfaceArrays5ASM {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   197
     *   public static I1[][][][][] run() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   198
     *     return Helper.createI2Array5(); // returns I2[][][][][]
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   199
     *   }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   200
     *   public static void test() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   201
     *     I1[][][][][] i1 = run();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   202
     *     System.out.println(i1[0][0][0][0][0].getName());
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   203
     *   }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   204
     * }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   205
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   206
     * Notice that this is not legal Java code. We would have to use a cast in "run()" to make it legal:
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   207
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   208
     *   public static I1[] run() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   209
     *     return (I1[])Helper.createI2Array1(); // returns I2[]
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   210
     *   }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   211
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   212
     * But in pure bytecode, the "run()" methods are perfectly legal:
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   213
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   214
     *   public static I1[] run();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   215
     *     Code:
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   216
     *       0: invokestatic  #16  // Method Helper.createI2Array1:()[LI2;
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   217
     *       3: areturn
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   218
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   219
     * The "test()" method calls the "getName()" function from I1 on the objects returned by "run()".
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   220
     * This will epectedly fail with an "IncompatibleClassChangeError" because the objects returned
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   221
     * by "run()" (and by createI2Array()) are actually of type "I2C" and only implement "I2" but not "I1".
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   222
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   223
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   224
     * With 'good == true' this helper method will create the following classes:
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   225
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   226
     * public class MeetIncompatibleInterfaceArraysGood0ASM {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   227
     *   public static I1 run() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   228
     *     return Helper.createI21Array0(); // returns I2
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   229
     *   }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   230
     *   public static void test() {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   231
     *     I1 i1 = run();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   232
     *     System.out.println(i1.getName());
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   233
     *   }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   234
     * }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   235
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   236
     * Calling "test()" on these objects will succeed and output "I2 and I1" because now the "run()"
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   237
     * method calls "createI21Array()" which actually return an object (or an array of objects) of
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   238
     * type "I21C" which implements both "I2" and "I1".
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   239
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   240
     * Notice that at the bytecode level, the code for the "run()" and "test()" methods in
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   241
     * "MeetIncompatibleInterfaceArraysASM" and "MeetIncompatibleInterfaceArraysGoodASM" look exactly
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   242
     * the same. I.e. the verifier has no chance to verify if the I2 object returned by "createI1Array()"
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   243
     * or "createI21Array()" implements "I1" or not. That's actually the reason why both versions of
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   244
     * generated classes are legal from a verifier point of view.
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   245
     *
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   246
     */
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   247
    static void generateTestClass(int dim, boolean good) throws Exception {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   248
        String baseClassName = "MeetIncompatibleInterfaceArrays";
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   249
        if (good)
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   250
            baseClassName += "Good";
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   251
        String createName = "createI2" + (good ? "1" : "") + "Array";
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   252
        String a = "";
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   253
        for (int i = 0; i < dim; i++)
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   254
            a += "[";
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   255
        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   256
        cw.visit(V1_8, ACC_PUBLIC, baseClassName + dim + "ASM", null, "java/lang/Object", null);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   257
        MethodVisitor constr = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   258
        constr.visitCode();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   259
        constr.visitVarInsn(ALOAD, 0);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   260
        constr.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   261
        constr.visitInsn(RETURN);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   262
        constr.visitMaxs(0, 0);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   263
        constr.visitEnd();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   264
        MethodVisitor run = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "run",
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   265
                "()" + a + "Lcompiler/types/TestMeetIncompatibleInterfaceArrays$I1;", null, null);
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   266
        run.visitCode();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   267
        if (dim == 4) {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   268
            run.visitMethodInsn(INVOKESTATIC, "compiler/types/TestMeetIncompatibleInterfaceArrays$Helper", createName + 3,
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   269
                    "()" + "[[[" + "Lcompiler/types/TestMeetIncompatibleInterfaceArrays$I2;", false);
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   270
        } else {
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   271
            run.visitMethodInsn(INVOKESTATIC, "compiler/types/TestMeetIncompatibleInterfaceArrays$Helper", createName + dim,
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   272
                    "()" + a + "Lcompiler/types/TestMeetIncompatibleInterfaceArrays$I2;", false);
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   273
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   274
        run.visitInsn(ARETURN);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   275
        run.visitMaxs(0, 0);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   276
        run.visitEnd();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   277
        MethodVisitor test = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "test", "()V", null, null);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   278
        test.visitCode();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   279
        test.visitMethodInsn(INVOKESTATIC, baseClassName + dim + "ASM", "run",
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   280
                "()" + a + "Lcompiler/types/TestMeetIncompatibleInterfaceArrays$I1;", false);
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   281
        test.visitVarInsn(ASTORE, 0);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   282
        if (dim > 0) {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   283
            test.visitVarInsn(ALOAD, 0);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   284
            for (int i = 1; i <= dim; i++) {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   285
                test.visitInsn(ICONST_0);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   286
                test.visitInsn(AALOAD);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   287
            }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   288
            test.visitVarInsn(ASTORE, 1);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   289
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   290
        test.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   291
        test.visitVarInsn(ALOAD, dim > 0 ? 1 : 0);
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   292
        test.visitMethodInsn(INVOKEINTERFACE, "compiler/types/TestMeetIncompatibleInterfaceArrays$I1", "getName",
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   293
                "()Ljava/lang/String;", true);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   294
        test.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/Object;)V", false);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   295
        test.visitInsn(RETURN);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   296
        test.visitMaxs(0, 0);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   297
        test.visitEnd();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   298
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   299
        // Get the bytes of the class..
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   300
        byte[] b = cw.toByteArray();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   301
        // ..and write them into a class file (for debugging)
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   302
        FileOutputStream fos = new FileOutputStream(PATH + baseClassName + dim + "ASM.class");
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   303
        fos.write(b);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   304
        fos.close();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   305
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   306
    }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   307
49627
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   308
    public static String[][] tier = { { "interpreted (tier 0)",
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   309
                                        "C2 (tier 4) without inlining",
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   310
                                        "C2 (tier 4) without inlining" },
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   311
                                      { "interpreted (tier 0)",
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   312
                                        "C2 (tier 4) with inlining",
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   313
                                        "C2 (tier 4) with inlining" },
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   314
                                      { "interpreted (tier 0)",
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   315
                                        "C1 (tier 3) with inlining",
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   316
                                        "C2 (tier 4) with inlining" } };
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   317
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   318
    public static int[][] level = { { CompilerWhiteBoxTest.COMP_LEVEL_NONE,
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   319
                                      CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION,
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   320
                                      CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION },
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   321
                                    { CompilerWhiteBoxTest.COMP_LEVEL_NONE,
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   322
                                      CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION,
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   323
                                      CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION },
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   324
                                    { CompilerWhiteBoxTest.COMP_LEVEL_NONE,
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   325
                                      CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE,
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   326
                                      CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION } };
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   327
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   328
    public static void main(String[] args) throws Exception {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   329
        final int pass = Integer.parseInt(args.length > 0 ? args[0] : "0");
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   330
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   331
        // Load and initialize some classes required for compilation
40059
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   332
        Class.forName("compiler.types.TestMeetIncompatibleInterfaceArrays$I1");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   333
        Class.forName("compiler.types.TestMeetIncompatibleInterfaceArrays$I2");
c2304140ed64 8132919: Put compiler tests in packages
tpivovarova
parents: 36851
diff changeset
   334
        Class.forName("compiler.types.TestMeetIncompatibleInterfaceArrays$Helper");
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   335
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   336
        for (int g = 0; g < 2; g++) {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   337
            String baseClassName = "MeetIncompatibleInterfaceArrays";
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   338
            boolean good = (g == 0) ? false : true;
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   339
            if (good)
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   340
                baseClassName += "Good";
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   341
            for (int i = 0; i < 6; i++) {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   342
                System.out.println();
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   343
                System.out.println("Creating " + baseClassName + i + "ASM.class");
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   344
                System.out.println("========================================" + "=" + "=========");
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   345
                // Create the "MeetIncompatibleInterfaceArrays<i>ASM" class
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   346
                generateTestClass(i, good);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   347
                Class<?> c = null;
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   348
                try {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   349
                    c = Class.forName(baseClassName + i + "ASM");
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   350
                } catch (VerifyError ve) {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   351
                    if (i == 4) {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   352
                        System.out.println("OK - must be (" + ve.getMessage() + ").");
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   353
                    } else {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   354
                        throw ve;
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   355
                    }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   356
                    continue;
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   357
                }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   358
                // Call MeetIncompatibleInterfaceArrays<i>ASM.test()
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   359
                Method m = c.getMethod("test");
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   360
                Method r = c.getMethod("run");
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   361
                for (int j = 0; j < 3; j++) {
49627
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   362
                    System.out.println((j + 1) + ". invokation of " + baseClassName + i + "ASM.test() [::" +
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   363
                                       r.getName() + "() should be '" + tier[pass][j] + "' compiled]");
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   364
51341
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 49654
diff changeset
   365
                    // Skip Profiling compilation (C1) when Tiered is disabled.
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 49654
diff changeset
   366
                    boolean profile = (level[pass][j] == CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE);
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 49654
diff changeset
   367
                    if (profile && CompilerWhiteBoxTest.skipOnTieredCompilation(false)) {
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 49654
diff changeset
   368
                        continue;
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 49654
diff changeset
   369
                    }
09cc8813ae51 8207965: C2-only debug build fails
kvn
parents: 49654
diff changeset
   370
49627
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   371
                    WB.enqueueMethodForCompilation(r, level[pass][j]);
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   372
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   373
                    try {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   374
                        m.invoke(null);
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   375
                    } catch (InvocationTargetException ite) {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   376
                        if (good) {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   377
                            throw ite;
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   378
                        } else {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   379
                            if (ite.getCause() instanceof IncompatibleClassChangeError) {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   380
                                System.out.println("  OK - catched InvocationTargetException("
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   381
                                        + ite.getCause().getMessage() + ").");
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   382
                            } else {
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   383
                                throw ite;
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   384
                            }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   385
                        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   386
                    }
49627
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   387
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   388
                    int r_comp_level = WB.getMethodCompilationLevel(r);
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   389
                    System.out.println("   invokation of " + baseClassName + i + "ASM.test() [::" +
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   390
                                       r.getName() + "() was compiled at tier " + r_comp_level + "]");
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   391
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   392
                    if (r_comp_level != level[pass][j]) {
49645
2bf8f2fc0710 8200360: MeetIncompatibleInterfaceArrays fails with "MeetIncompatibleInterfaceArrays0ASM.run() must be compiled at tier 0 !"
simonis
parents: 49627
diff changeset
   393
                      throw new Exception("Method " + r + " must be compiled at tier " + level[pass][j] +
2bf8f2fc0710 8200360: MeetIncompatibleInterfaceArrays fails with "MeetIncompatibleInterfaceArrays0ASM.run() must be compiled at tier 0 !"
simonis
parents: 49627
diff changeset
   394
                                          " but was compiled at " + r_comp_level + " instead!");
49627
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   395
                    }
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   396
32bdc65633a6 8198915: [Graal] 3rd testcase of compiler/types/TestMeetIncompatibleInterfaceArrays.java takes more than 10 mins
simonis
parents: 47216
diff changeset
   397
                    WB.deoptimizeMethod(r);
34202
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   398
                }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   399
            }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   400
        }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   401
    }
5d19ca9c25a8 8141551: C2 can not handle returns with inccompatible interface arrays
simonis
parents:
diff changeset
   402
}