test/compiler/c1/TestGotoIf.jasm

changeset 9715
e0e66aba375a
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/test/compiler/c1/TestGotoIf.jasm	Tue Feb 19 08:58:55 2019 +0100
     1.3 @@ -0,0 +1,171 @@
     1.4 +/*
     1.5 + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +public class compiler/c1/TestGotoIf version 52:0 {
    1.29 +    public Field f1:"I";
    1.30 +    public Field f2:"I";
    1.31 +    public static Field i:"I";
    1.32 +
    1.33 +    Method "<init>":"()V" stack 1 locals 1 {
    1.34 +        aload_0;
    1.35 +        invokespecial Method java/lang/Object."<init>":"()V";
    1.36 +        return;
    1.37 +    }
    1.38 +
    1.39 +    public Method test1:"()I" stack 3 locals 1 {
    1.40 +        aload_0;
    1.41 +        getfield Field f1:"I";
    1.42 +        aload_0;
    1.43 +        getfield Field f2:"I";
    1.44 +        iconst_1;
    1.45 +        isub;
    1.46 +        // Without the fix, if got eliminated by CEE
    1.47 +        if_icmpgt Null;
    1.48 +        iconst_1;
    1.49 +      Return: stack_frame_type stack1;
    1.50 +      stack_map int;
    1.51 +        ireturn;
    1.52 +      Null: stack_frame_type same;
    1.53 +        iconst_0;
    1.54 +        goto Return; // Backbranch (t_goto) with safepoint
    1.55 +    }
    1.56 +
    1.57 +    public Method test2:"()I" stack 3 locals 1 {
    1.58 +        aload_0;
    1.59 +        getfield Field f1:"I";
    1.60 +        aload_0;
    1.61 +        getfield Field f2:"I";
    1.62 +        iconst_1;
    1.63 +        isub;
    1.64 +        goto Skip;
    1.65 +      Return: stack_frame_type full;
    1.66 +      stack_map int;
    1.67 +        ireturn;
    1.68 +      Skip: stack_frame_type full;
    1.69 +      stack_map int, int;
    1.70 +        // Without the fix, if got eliminated by CEE
    1.71 +        if_icmpgt Null;
    1.72 +        iconst_1;
    1.73 +        goto Return; // Backbranch (f_goto) with safepoint
    1.74 +      Null: stack_frame_type full;
    1.75 +      stack_map;
    1.76 +        iconst_0;
    1.77 +        goto Return; // Backbranch (t_goto) with safepoint
    1.78 +    }
    1.79 +
    1.80 +    public Method test3:"()I" stack 3 locals 1 {
    1.81 +        aload_0;
    1.82 +        getfield Field f1:"I";
    1.83 +        aload_0;
    1.84 +        getfield Field f2:"I";
    1.85 +        iconst_1;
    1.86 +        isub;
    1.87 +        goto Skip;
    1.88 +      Return: stack_frame_type full;
    1.89 +      stack_map int;
    1.90 +        ireturn;
    1.91 +      Null: stack_frame_type full;
    1.92 +      stack_map;
    1.93 +        iconst_0;
    1.94 +        goto Return; // Backbranch (t_goto) with safepoint
    1.95 +      Skip: stack_frame_type full;
    1.96 +      stack_map int, int;
    1.97 +        // If will be eliminated by CEE
    1.98 +        if_icmpgt Null; // Backbranch (if) with safepoint
    1.99 +        iconst_1;
   1.100 +        goto Return; // Backbranch (f_goto) with safepoint
   1.101 +    }
   1.102 +
   1.103 +    public Method test4:"()I" stack 3 locals 1 {
   1.104 +        aload_0;
   1.105 +        getfield Field f1:"I";
   1.106 +        aload_0;
   1.107 +        getfield Field f2:"I";
   1.108 +        iconst_1;
   1.109 +        isub;
   1.110 +        goto Skip;
   1.111 +      Null: stack_frame_type full;
   1.112 +      stack_map;
   1.113 +        iconst_0;
   1.114 +      Return: stack_frame_type full;
   1.115 +      stack_map int;
   1.116 +        ireturn; 
   1.117 +      Skip: stack_frame_type full;
   1.118 +      stack_map int, int;
   1.119 +        // If will be eliminated by CEE
   1.120 +        if_icmpgt Null; // Backbranch (if) with safepoint
   1.121 +        iconst_1;
   1.122 +        goto Return; // Backbranch (f_goto) with safepoint
   1.123 +    }
   1.124 +
   1.125 +    public Method test5:"()I" stack 3 locals 2 {
   1.126 +        aload_0;
   1.127 +        getfield Field f1:"I";
   1.128 +        aload_0;
   1.129 +        getfield Field f2:"I";
   1.130 +        iconst_1;
   1.131 +        isub;
   1.132 +        goto Skip;
   1.133 +      Null: stack_frame_type full;
   1.134 +      stack_map;
   1.135 +        iconst_0;
   1.136 +        goto Return;
   1.137 +      Skip: stack_frame_type full;
   1.138 +      stack_map int, int;
   1.139 +        // If will be eliminated by CEE
   1.140 +        if_icmpgt Null; // Backbranch (if) with safepoint
   1.141 +        iconst_1;
   1.142 +      Return: stack_frame_type full;
   1.143 +      stack_map int;
   1.144 +        ireturn; 
   1.145 +    }
   1.146 +
   1.147 +    public Method test6:"()I" stack 4 locals 1 {
   1.148 +        getstatic Field i:"I";
   1.149 +      Loop: stack_frame_type full;
   1.150 +      stack_map int;
   1.151 +        // Decrement i and exit loop if < 0
   1.152 +        iconst_0;
   1.153 +        getstatic Field i:"I";
   1.154 +        iconst_1;
   1.155 +        isub;
   1.156 +        dup;
   1.157 +        putstatic Field i:"I";
   1.158 +        if_icmpgt Exit;
   1.159 +
   1.160 +        iconst_1;
   1.161 +        // Without the fix, if got eliminated by CEE
   1.162 +        if_icmpgt Null;
   1.163 +        iconst_1;
   1.164 +        goto Loop; // Backbranch (f_goto) with safepoint
   1.165 +      Null: stack_frame_type same;
   1.166 +        iconst_0;
   1.167 +        goto Loop; // Backbranch (t_goto) with safepoint
   1.168 +
   1.169 +      Exit: stack_frame_type full;
   1.170 +      stack_map int;
   1.171 +        iconst_0;
   1.172 +        ireturn; 
   1.173 +    }
   1.174 +}

mercurial