1 /* 2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 public class compiler/c1/TestGotoIf version 52:0 { 26 public Field f1:"I"; 27 public Field f2:"I"; 28 public static Field i:"I"; 29 30 Method "<init>":"()V" stack 1 locals 1 { 31 aload_0; 32 invokespecial Method java/lang/Object."<init>":"()V"; 33 return; 34 } 35 36 public Method test1:"()I" stack 3 locals 1 { 37 aload_0; 38 getfield Field f1:"I"; 39 aload_0; 40 getfield Field f2:"I"; 41 iconst_1; 42 isub; 43 // If will be eliminated by CEE 44 if_icmpgt Null; 45 iconst_1; 46 Return: stack_frame_type stack1; 47 stack_map int; 48 ireturn; 49 Null: stack_frame_type same; 50 iconst_0; 51 goto Return; // Backbranch (t_goto) with safepoint 52 } 53 54 public Method test2:"()I" stack 3 locals 1 { 55 aload_0; 56 getfield Field f1:"I"; 57 aload_0; 58 getfield Field f2:"I"; 59 iconst_1; 60 isub; 61 goto Skip; 62 Return: stack_frame_type full; 63 stack_map int; 64 ireturn; 65 Skip: stack_frame_type full; 66 stack_map int, int; 67 // If will be eliminated by CEE 68 if_icmpgt Null; 69 iconst_1; 70 goto Return; // Backbranch (f_goto) with safepoint 71 Null: stack_frame_type full; 72 stack_map; 73 iconst_0; 74 goto Return; // Backbranch (t_goto) with safepoint 75 } 76 77 public Method test3:"()I" stack 3 locals 1 { 78 aload_0; 79 getfield Field f1:"I"; 80 aload_0; 81 getfield Field f2:"I"; 82 iconst_1; 83 isub; 84 goto Skip; 85 Return: stack_frame_type full; 86 stack_map int; 87 ireturn; 88 Null: stack_frame_type full; 89 stack_map; 90 iconst_0; 91 goto Return; // Backbranch (t_goto) with safepoint 92 Skip: stack_frame_type full; 93 stack_map int, int; 94 // If will be eliminated by CEE 95 if_icmpgt Null; // Backbranch (if) with safepoint 96 iconst_1; 97 goto Return; // Backbranch (f_goto) with safepoint 98 } 99 100 public Method test4:"()I" stack 3 locals 1 { 101 aload_0; 102 getfield Field f1:"I"; 103 aload_0; 104 getfield Field f2:"I"; 105 iconst_1; 106 isub; 107 goto Skip; 108 Null: stack_frame_type full; 109 stack_map; 110 iconst_0; 111 Return: stack_frame_type full; 112 stack_map int; 113 ireturn; 114 Skip: stack_frame_type full; 115 stack_map int, int; 116 // If will be eliminated by CEE 117 if_icmpgt Null; // Backbranch (if) with safepoint 118 iconst_1; 119 goto Return; // Backbranch (f_goto) with safepoint 120 } 121 122 public Method test5:"()I" stack 3 locals 2 { 123 aload_0; 124 getfield Field f1:"I"; 125 aload_0; 126 getfield Field f2:"I"; 127 iconst_1; 128 isub; 129 goto Skip; 130 Null: stack_frame_type full; 131 stack_map; 132 iconst_0; 133 goto Return; 134 Skip: stack_frame_type full; 135 stack_map int, int; 136 // If will be eliminated by CEE 137 if_icmpgt Null; // Backbranch (if) with safepoint 138 iconst_1; 139 Return: stack_frame_type full; 140 stack_map int; 141 ireturn; 142 } 143 144 public Method test6:"()I" stack 4 locals 1 { 145 getstatic Field i:"I"; 146 Loop: stack_frame_type full; 147 stack_map int; 148 // Decrement i and exit loop if < 0 149 iconst_0; 150 getstatic Field i:"I"; 151 iconst_1; 152 isub; 153 dup; 154 putstatic Field i:"I"; 155 if_icmpgt Exit; 156 157 iconst_1; 158 // If will be eliminated by CEE 159 if_icmpgt Null; 160 iconst_1; 161 goto Loop; // Backbranch (f_goto) with safepoint 162 Null: stack_frame_type same; 163 iconst_0; 164 goto Loop; // Backbranch (t_goto) with safepoint 165 166 Exit: stack_frame_type full; 167 stack_map int; 168 iconst_0; 169 ireturn; 170 } 171 }