Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | public class Main { |
| 18 | |
| 19 | public static void assertIntEquals(int expected, int result) { |
| 20 | if (expected != result) { |
| 21 | throw new Error("Expected: " + expected + ", found: " + result); |
| 22 | } |
| 23 | } |
| 24 | |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 25 | public static void assertStringEquals(String expected, String result) { |
| 26 | if (expected != null ? !expected.equals(result) : result != null) { |
| 27 | throw new Error("Expected: " + expected + ", found: " + result); |
| 28 | } |
| 29 | } |
| 30 | |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 31 | public static void assertClassEquals(Class<?> expected, Class<?> result) { |
| 32 | if (expected != result) { |
| 33 | throw new Error("Expected: " + expected + ", found: " + result); |
| 34 | } |
| 35 | } |
| 36 | |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 37 | public static boolean doThrow = false; |
| 38 | |
| 39 | private static int $noinline$foo(int x) { |
| 40 | if (doThrow) { throw new Error(); } |
| 41 | return x; |
| 42 | } |
| 43 | |
| 44 | /// CHECK-START: int Main.testSimple(int) sharpening (before) |
| 45 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_via_method |
| 46 | |
| 47 | /// CHECK-START-ARM: int Main.testSimple(int) sharpening (after) |
| 48 | /// CHECK-NOT: ArmDexCacheArraysBase |
| 49 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 50 | |
| 51 | /// CHECK-START-ARM64: int Main.testSimple(int) sharpening (after) |
| 52 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 53 | |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 54 | /// CHECK-START-MIPS: int Main.testSimple(int) sharpening (after) |
| 55 | /// CHECK-NOT: MipsDexCacheArraysBase |
| 56 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 57 | |
Alexey Frunze | f63f569 | 2016-12-13 17:43:11 -0800 | [diff] [blame] | 58 | /// CHECK-START-MIPS64: int Main.testSimple(int) sharpening (after) |
| 59 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 60 | |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 61 | /// CHECK-START-X86: int Main.testSimple(int) sharpening (after) |
| 62 | /// CHECK-NOT: X86ComputeBaseMethodAddress |
| 63 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 64 | |
| 65 | /// CHECK-START-X86_64: int Main.testSimple(int) sharpening (after) |
| 66 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 67 | |
| 68 | /// CHECK-START-ARM: int Main.testSimple(int) dex_cache_array_fixups_arm (after) |
| 69 | /// CHECK: ArmDexCacheArraysBase |
| 70 | /// CHECK-NOT: ArmDexCacheArraysBase |
| 71 | |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 72 | /// CHECK-START-MIPS: int Main.testSimple(int) dex_cache_array_fixups_mips (after) |
| 73 | /// CHECK: MipsDexCacheArraysBase |
| 74 | /// CHECK-NOT: MipsDexCacheArraysBase |
| 75 | |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 76 | /// CHECK-START-X86: int Main.testSimple(int) pc_relative_fixups_x86 (after) |
| 77 | /// CHECK: X86ComputeBaseMethodAddress |
| 78 | /// CHECK-NOT: X86ComputeBaseMethodAddress |
| 79 | |
| 80 | public static int testSimple(int x) { |
| 81 | // This call should use PC-relative dex cache array load to retrieve the target method. |
| 82 | return $noinline$foo(x); |
| 83 | } |
| 84 | |
| 85 | /// CHECK-START: int Main.testDiamond(boolean, int) sharpening (before) |
| 86 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_via_method |
| 87 | |
| 88 | /// CHECK-START-ARM: int Main.testDiamond(boolean, int) sharpening (after) |
| 89 | /// CHECK-NOT: ArmDexCacheArraysBase |
| 90 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 91 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 92 | |
| 93 | /// CHECK-START-ARM64: int Main.testDiamond(boolean, int) sharpening (after) |
| 94 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 95 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 96 | |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 97 | /// CHECK-START-MIPS: int Main.testDiamond(boolean, int) sharpening (after) |
| 98 | /// CHECK-NOT: MipsDexCacheArraysBase |
| 99 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 100 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 101 | |
Alexey Frunze | f63f569 | 2016-12-13 17:43:11 -0800 | [diff] [blame] | 102 | /// CHECK-START-MIPS64: int Main.testDiamond(boolean, int) sharpening (after) |
| 103 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 104 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 105 | |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 106 | /// CHECK-START-X86: int Main.testDiamond(boolean, int) sharpening (after) |
| 107 | /// CHECK-NOT: X86ComputeBaseMethodAddress |
| 108 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 109 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 110 | |
| 111 | /// CHECK-START-X86_64: int Main.testDiamond(boolean, int) sharpening (after) |
| 112 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 113 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 114 | |
| 115 | /// CHECK-START-ARM: int Main.testDiamond(boolean, int) dex_cache_array_fixups_arm (after) |
| 116 | /// CHECK: ArmDexCacheArraysBase |
| 117 | /// CHECK-NOT: ArmDexCacheArraysBase |
| 118 | |
| 119 | /// CHECK-START-ARM: int Main.testDiamond(boolean, int) dex_cache_array_fixups_arm (after) |
| 120 | /// CHECK: ArmDexCacheArraysBase |
| 121 | /// CHECK-NEXT: If |
| 122 | |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 123 | /// CHECK-START-MIPS: int Main.testDiamond(boolean, int) dex_cache_array_fixups_mips (after) |
| 124 | /// CHECK: MipsDexCacheArraysBase |
| 125 | /// CHECK-NOT: MipsDexCacheArraysBase |
| 126 | |
| 127 | /// CHECK-START-MIPS: int Main.testDiamond(boolean, int) dex_cache_array_fixups_mips (after) |
| 128 | /// CHECK: MipsDexCacheArraysBase |
| 129 | /// CHECK-NEXT: If |
| 130 | |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 131 | /// CHECK-START-X86: int Main.testDiamond(boolean, int) pc_relative_fixups_x86 (after) |
| 132 | /// CHECK: X86ComputeBaseMethodAddress |
| 133 | /// CHECK-NOT: X86ComputeBaseMethodAddress |
| 134 | |
| 135 | /// CHECK-START-X86: int Main.testDiamond(boolean, int) pc_relative_fixups_x86 (after) |
| 136 | /// CHECK: X86ComputeBaseMethodAddress |
| 137 | /// CHECK-NEXT: If |
| 138 | |
| 139 | public static int testDiamond(boolean negate, int x) { |
| 140 | // These calls should use PC-relative dex cache array loads to retrieve the target method. |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 141 | // PC-relative bases used by ARM, MIPS and X86 should be pulled before the If. |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 142 | if (negate) { |
| 143 | return $noinline$foo(-x); |
| 144 | } else { |
| 145 | return $noinline$foo(x); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | /// CHECK-START-X86: int Main.testLoop(int[], int) pc_relative_fixups_x86 (before) |
| 150 | /// CHECK-NOT: X86ComputeBaseMethodAddress |
| 151 | |
| 152 | /// CHECK-START-X86: int Main.testLoop(int[], int) pc_relative_fixups_x86 (after) |
| 153 | /// CHECK: X86ComputeBaseMethodAddress |
| 154 | /// CHECK-NOT: X86ComputeBaseMethodAddress |
| 155 | |
| 156 | /// CHECK-START-X86: int Main.testLoop(int[], int) pc_relative_fixups_x86 (after) |
| 157 | /// CHECK: InvokeStaticOrDirect |
| 158 | /// CHECK-NOT: InvokeStaticOrDirect |
| 159 | |
| 160 | /// CHECK-START-X86: int Main.testLoop(int[], int) pc_relative_fixups_x86 (after) |
| 161 | /// CHECK: ArrayLength |
| 162 | /// CHECK-NEXT: X86ComputeBaseMethodAddress |
| 163 | /// CHECK-NEXT: Goto |
| 164 | /// CHECK: begin_block |
| 165 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 166 | |
| 167 | /// CHECK-START-ARM: int Main.testLoop(int[], int) dex_cache_array_fixups_arm (before) |
| 168 | /// CHECK-NOT: ArmDexCacheArraysBase |
| 169 | |
| 170 | /// CHECK-START-ARM: int Main.testLoop(int[], int) dex_cache_array_fixups_arm (after) |
| 171 | /// CHECK: ArmDexCacheArraysBase |
| 172 | /// CHECK-NOT: ArmDexCacheArraysBase |
| 173 | |
| 174 | /// CHECK-START-ARM: int Main.testLoop(int[], int) dex_cache_array_fixups_arm (after) |
| 175 | /// CHECK: InvokeStaticOrDirect |
| 176 | /// CHECK-NOT: InvokeStaticOrDirect |
| 177 | |
| 178 | /// CHECK-START-ARM: int Main.testLoop(int[], int) dex_cache_array_fixups_arm (after) |
| 179 | /// CHECK: ArrayLength |
| 180 | /// CHECK-NEXT: ArmDexCacheArraysBase |
| 181 | /// CHECK-NEXT: Goto |
| 182 | /// CHECK: begin_block |
| 183 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 184 | |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 185 | /// CHECK-START-MIPS: int Main.testLoop(int[], int) dex_cache_array_fixups_mips (before) |
| 186 | /// CHECK-NOT: MipsDexCacheArraysBase |
| 187 | |
| 188 | /// CHECK-START-MIPS: int Main.testLoop(int[], int) dex_cache_array_fixups_mips (after) |
| 189 | /// CHECK: MipsDexCacheArraysBase |
| 190 | /// CHECK-NOT: MipsDexCacheArraysBase |
| 191 | |
| 192 | /// CHECK-START-MIPS: int Main.testLoop(int[], int) dex_cache_array_fixups_mips (after) |
| 193 | /// CHECK: InvokeStaticOrDirect |
| 194 | /// CHECK-NOT: InvokeStaticOrDirect |
| 195 | |
| 196 | /// CHECK-START-MIPS: int Main.testLoop(int[], int) dex_cache_array_fixups_mips (after) |
| 197 | /// CHECK: ArrayLength |
| 198 | /// CHECK-NEXT: MipsDexCacheArraysBase |
| 199 | /// CHECK-NEXT: Goto |
| 200 | /// CHECK: begin_block |
| 201 | /// CHECK: InvokeStaticOrDirect method_load_kind:dex_cache_pc_relative |
| 202 | |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 203 | public static int testLoop(int[] array, int x) { |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 204 | // PC-relative bases used by ARM, MIPS and X86 should be pulled before the loop. |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 205 | for (int i : array) { |
| 206 | x += $noinline$foo(i); |
| 207 | } |
| 208 | return x; |
| 209 | } |
| 210 | |
| 211 | /// CHECK-START-X86: int Main.testLoopWithDiamond(int[], boolean, int) pc_relative_fixups_x86 (before) |
| 212 | /// CHECK-NOT: X86ComputeBaseMethodAddress |
| 213 | |
| 214 | /// CHECK-START-X86: int Main.testLoopWithDiamond(int[], boolean, int) pc_relative_fixups_x86 (after) |
| 215 | /// CHECK: If |
| 216 | /// CHECK: begin_block |
| 217 | /// CHECK: ArrayLength |
| 218 | /// CHECK-NEXT: X86ComputeBaseMethodAddress |
| 219 | /// CHECK-NEXT: Goto |
| 220 | |
| 221 | /// CHECK-START-ARM: int Main.testLoopWithDiamond(int[], boolean, int) dex_cache_array_fixups_arm (before) |
| 222 | /// CHECK-NOT: ArmDexCacheArraysBase |
| 223 | |
| 224 | /// CHECK-START-ARM: int Main.testLoopWithDiamond(int[], boolean, int) dex_cache_array_fixups_arm (after) |
| 225 | /// CHECK: If |
| 226 | /// CHECK: begin_block |
| 227 | /// CHECK: ArrayLength |
| 228 | /// CHECK-NEXT: ArmDexCacheArraysBase |
| 229 | /// CHECK-NEXT: Goto |
| 230 | |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 231 | /// CHECK-START-MIPS: int Main.testLoopWithDiamond(int[], boolean, int) dex_cache_array_fixups_mips (before) |
| 232 | /// CHECK-NOT: MipsDexCacheArraysBase |
| 233 | |
| 234 | /// CHECK-START-MIPS: int Main.testLoopWithDiamond(int[], boolean, int) dex_cache_array_fixups_mips (after) |
| 235 | /// CHECK: If |
| 236 | /// CHECK: begin_block |
| 237 | /// CHECK: ArrayLength |
| 238 | /// CHECK-NEXT: MipsDexCacheArraysBase |
| 239 | /// CHECK-NEXT: Goto |
| 240 | |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 241 | public static int testLoopWithDiamond(int[] array, boolean negate, int x) { |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 242 | // PC-relative bases used by ARM, MIPS and X86 should be pulled before the loop |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 243 | // but not outside the if. |
| 244 | if (array != null) { |
| 245 | for (int i : array) { |
| 246 | if (negate) { |
| 247 | x += $noinline$foo(-i); |
| 248 | } else { |
| 249 | x += $noinline$foo(i); |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | return x; |
| 254 | } |
| 255 | |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 256 | /// CHECK-START: java.lang.String Main.$noinline$getBootImageString() sharpening (before) |
| 257 | /// CHECK: LoadString load_kind:DexCacheViaMethod |
| 258 | |
| 259 | /// CHECK-START-X86: java.lang.String Main.$noinline$getBootImageString() sharpening (after) |
| 260 | // Note: load kind depends on PIC/non-PIC |
| 261 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
Vladimir Marko | 54d6a20 | 2016-11-09 12:46:38 +0000 | [diff] [blame] | 262 | /// CHECK: LoadString load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 263 | |
| 264 | /// CHECK-START-X86_64: java.lang.String Main.$noinline$getBootImageString() sharpening (after) |
| 265 | // Note: load kind depends on PIC/non-PIC |
| 266 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
Vladimir Marko | 54d6a20 | 2016-11-09 12:46:38 +0000 | [diff] [blame] | 267 | /// CHECK: LoadString load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 268 | |
| 269 | /// CHECK-START-ARM: java.lang.String Main.$noinline$getBootImageString() sharpening (after) |
| 270 | // Note: load kind depends on PIC/non-PIC |
| 271 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
Vladimir Marko | 54d6a20 | 2016-11-09 12:46:38 +0000 | [diff] [blame] | 272 | /// CHECK: LoadString load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 273 | |
| 274 | /// CHECK-START-ARM64: java.lang.String Main.$noinline$getBootImageString() sharpening (after) |
| 275 | // Note: load kind depends on PIC/non-PIC |
| 276 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
Vladimir Marko | 54d6a20 | 2016-11-09 12:46:38 +0000 | [diff] [blame] | 277 | /// CHECK: LoadString load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 278 | |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 279 | /// CHECK-START-MIPS: java.lang.String Main.$noinline$getBootImageString() sharpening (after) |
| 280 | // Note: load kind depends on PIC/non-PIC |
| 281 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
Vladimir Marko | 54d6a20 | 2016-11-09 12:46:38 +0000 | [diff] [blame] | 282 | /// CHECK: LoadString load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 283 | |
Alexey Frunze | f63f569 | 2016-12-13 17:43:11 -0800 | [diff] [blame] | 284 | /// CHECK-START-MIPS64: java.lang.String Main.$noinline$getBootImageString() sharpening (after) |
| 285 | // Note: load kind depends on PIC/non-PIC |
| 286 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
| 287 | /// CHECK: LoadString load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} |
| 288 | |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 289 | public static String $noinline$getBootImageString() { |
| 290 | // Prevent inlining to avoid the string comparison being optimized away. |
| 291 | if (doThrow) { throw new Error(); } |
| 292 | // Empty string is known to be in the boot image. |
| 293 | return ""; |
| 294 | } |
| 295 | |
| 296 | /// CHECK-START: java.lang.String Main.$noinline$getNonBootImageString() sharpening (before) |
| 297 | /// CHECK: LoadString load_kind:DexCacheViaMethod |
| 298 | |
Vladimir Marko | 1bc4b17 | 2016-10-24 16:53:39 +0000 | [diff] [blame] | 299 | /// CHECK-START-X86: java.lang.String Main.$noinline$getNonBootImageString() sharpening (after) |
| 300 | /// CHECK: LoadString load_kind:BssEntry |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 301 | |
Vladimir Marko | 1bc4b17 | 2016-10-24 16:53:39 +0000 | [diff] [blame] | 302 | /// CHECK-START-X86: java.lang.String Main.$noinline$getNonBootImageString() pc_relative_fixups_x86 (after) |
| 303 | /// CHECK-DAG: X86ComputeBaseMethodAddress |
| 304 | /// CHECK-DAG: LoadString load_kind:BssEntry |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 305 | |
Vladimir Marko | 1bc4b17 | 2016-10-24 16:53:39 +0000 | [diff] [blame] | 306 | /// CHECK-START-X86_64: java.lang.String Main.$noinline$getNonBootImageString() sharpening (after) |
| 307 | /// CHECK: LoadString load_kind:BssEntry |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 308 | |
Vladimir Marko | 1bc4b17 | 2016-10-24 16:53:39 +0000 | [diff] [blame] | 309 | /// CHECK-START-ARM: java.lang.String Main.$noinline$getNonBootImageString() sharpening (after) |
| 310 | /// CHECK: LoadString load_kind:BssEntry |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 311 | |
Vladimir Marko | 1bc4b17 | 2016-10-24 16:53:39 +0000 | [diff] [blame] | 312 | /// CHECK-START-ARM64: java.lang.String Main.$noinline$getNonBootImageString() sharpening (after) |
| 313 | /// CHECK: LoadString load_kind:BssEntry |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 314 | |
Vladimir Marko | 1bc4b17 | 2016-10-24 16:53:39 +0000 | [diff] [blame] | 315 | /// CHECK-START-MIPS: java.lang.String Main.$noinline$getNonBootImageString() sharpening (after) |
| 316 | /// CHECK: LoadString load_kind:BssEntry |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 317 | |
Alexey Frunze | f63f569 | 2016-12-13 17:43:11 -0800 | [diff] [blame] | 318 | /// CHECK-START-MIPS64: java.lang.String Main.$noinline$getNonBootImageString() sharpening (after) |
| 319 | /// CHECK: LoadString load_kind:BssEntry |
| 320 | |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 321 | public static String $noinline$getNonBootImageString() { |
| 322 | // Prevent inlining to avoid the string comparison being optimized away. |
| 323 | if (doThrow) { throw new Error(); } |
| 324 | // This string is not in the boot image. |
| 325 | return "non-boot-image-string"; |
| 326 | } |
| 327 | |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 328 | /// CHECK-START: java.lang.Class Main.$noinline$getStringClass() sharpening (before) |
| 329 | /// CHECK: LoadClass load_kind:DexCacheViaMethod class_name:java.lang.String |
| 330 | |
| 331 | /// CHECK-START-X86: java.lang.Class Main.$noinline$getStringClass() sharpening (after) |
| 332 | // Note: load kind depends on PIC/non-PIC |
| 333 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 334 | /// CHECK: LoadClass load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} class_name:java.lang.String |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 335 | |
| 336 | /// CHECK-START-X86_64: java.lang.Class Main.$noinline$getStringClass() sharpening (after) |
| 337 | // Note: load kind depends on PIC/non-PIC |
| 338 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 339 | /// CHECK: LoadClass load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} class_name:java.lang.String |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 340 | |
| 341 | /// CHECK-START-ARM: java.lang.Class Main.$noinline$getStringClass() sharpening (after) |
| 342 | // Note: load kind depends on PIC/non-PIC |
| 343 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 344 | /// CHECK: LoadClass load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} class_name:java.lang.String |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 345 | |
| 346 | /// CHECK-START-ARM64: java.lang.Class Main.$noinline$getStringClass() sharpening (after) |
| 347 | // Note: load kind depends on PIC/non-PIC |
| 348 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 349 | /// CHECK: LoadClass load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} class_name:java.lang.String |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 350 | |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 351 | /// CHECK-START-MIPS: java.lang.Class Main.$noinline$getStringClass() sharpening (after) |
| 352 | // Note: load kind depends on PIC/non-PIC |
| 353 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 354 | /// CHECK: LoadClass load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} class_name:java.lang.String |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 355 | |
Alexey Frunze | f63f569 | 2016-12-13 17:43:11 -0800 | [diff] [blame] | 356 | /// CHECK-START-MIPS64: java.lang.Class Main.$noinline$getStringClass() sharpening (after) |
| 357 | // Note: load kind depends on PIC/non-PIC |
| 358 | // TODO: Remove DexCacheViaMethod when read barrier config supports BootImageAddress. |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 359 | /// CHECK: LoadClass load_kind:{{BootImageAddress|BssEntry|DexCacheViaMethod}} class_name:java.lang.String |
Alexey Frunze | f63f569 | 2016-12-13 17:43:11 -0800 | [diff] [blame] | 360 | |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 361 | public static Class<?> $noinline$getStringClass() { |
| 362 | // Prevent inlining to avoid the string comparison being optimized away. |
| 363 | if (doThrow) { throw new Error(); } |
| 364 | // String class is known to be in the boot image. |
| 365 | return String.class; |
| 366 | } |
| 367 | |
| 368 | /// CHECK-START: java.lang.Class Main.$noinline$getOtherClass() sharpening (before) |
| 369 | /// CHECK: LoadClass load_kind:DexCacheViaMethod class_name:Other |
| 370 | |
| 371 | /// CHECK-START-X86: java.lang.Class Main.$noinline$getOtherClass() sharpening (after) |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 372 | /// CHECK: LoadClass load_kind:BssEntry class_name:Other |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 373 | |
| 374 | /// CHECK-START-X86: java.lang.Class Main.$noinline$getOtherClass() pc_relative_fixups_x86 (after) |
| 375 | /// CHECK-DAG: X86ComputeBaseMethodAddress |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 376 | /// CHECK-DAG: LoadClass load_kind:BssEntry class_name:Other |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 377 | |
| 378 | /// CHECK-START-X86_64: java.lang.Class Main.$noinline$getOtherClass() sharpening (after) |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 379 | /// CHECK: LoadClass load_kind:BssEntry class_name:Other |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 380 | |
| 381 | /// CHECK-START-ARM: java.lang.Class Main.$noinline$getOtherClass() sharpening (after) |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 382 | /// CHECK: LoadClass load_kind:BssEntry class_name:Other |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 383 | |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 384 | /// CHECK-START-ARM64: java.lang.Class Main.$noinline$getOtherClass() sharpening (after) |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 385 | /// CHECK: LoadClass load_kind:BssEntry class_name:Other |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 386 | |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 387 | /// CHECK-START-MIPS: java.lang.Class Main.$noinline$getOtherClass() sharpening (after) |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 388 | /// CHECK: LoadClass load_kind:BssEntry class_name:Other |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 389 | |
| 390 | /// CHECK-START-MIPS: java.lang.Class Main.$noinline$getOtherClass() dex_cache_array_fixups_mips (after) |
| 391 | /// CHECK-DAG: MipsDexCacheArraysBase |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 392 | /// CHECK-DAG: LoadClass load_kind:BssEntry class_name:Other |
Alexey Frunze | 06a46c4 | 2016-07-19 15:00:40 -0700 | [diff] [blame] | 393 | |
Alexey Frunze | f63f569 | 2016-12-13 17:43:11 -0800 | [diff] [blame] | 394 | /// CHECK-START-MIPS64: java.lang.Class Main.$noinline$getOtherClass() sharpening (after) |
Vladimir Marko | 6bec91c | 2017-01-09 15:03:12 +0000 | [diff] [blame] | 395 | /// CHECK: LoadClass load_kind:BssEntry class_name:Other |
Alexey Frunze | f63f569 | 2016-12-13 17:43:11 -0800 | [diff] [blame] | 396 | |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 397 | public static Class<?> $noinline$getOtherClass() { |
| 398 | // Prevent inlining to avoid the string comparison being optimized away. |
| 399 | if (doThrow) { throw new Error(); } |
| 400 | // Other class is not in the boot image. |
| 401 | return Other.class; |
| 402 | } |
| 403 | |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 404 | public static void main(String[] args) { |
| 405 | assertIntEquals(1, testSimple(1)); |
| 406 | assertIntEquals(1, testDiamond(false, 1)); |
| 407 | assertIntEquals(-1, testDiamond(true, 1)); |
| 408 | assertIntEquals(3, testLoop(new int[]{ 2 }, 1)); |
| 409 | assertIntEquals(8, testLoop(new int[]{ 3, 4 }, 1)); |
| 410 | assertIntEquals(1, testLoopWithDiamond(null, false, 1)); |
| 411 | assertIntEquals(3, testLoopWithDiamond(new int[]{ 2 }, false, 1)); |
| 412 | assertIntEquals(-6, testLoopWithDiamond(new int[]{ 3, 4 }, true, 1)); |
Vladimir Marko | cac5a7e | 2016-02-22 10:39:50 +0000 | [diff] [blame] | 413 | assertStringEquals("", $noinline$getBootImageString()); |
| 414 | assertStringEquals("non-boot-image-string", $noinline$getNonBootImageString()); |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 415 | assertClassEquals(String.class, $noinline$getStringClass()); |
| 416 | assertClassEquals(Other.class, $noinline$getOtherClass()); |
Vladimir Marko | f64242a | 2015-12-01 14:58:23 +0000 | [diff] [blame] | 417 | } |
| 418 | } |
Vladimir Marko | dbb7f5b | 2016-03-30 13:23:58 +0100 | [diff] [blame] | 419 | |
| 420 | class Other { |
| 421 | } |