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