1 /* 2 * Copyright (C) 2016 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 static class ExpectedError extends Error {} 19 localStaticNopAndThrow()20 public static void localStaticNopAndThrow() { 21 // Pattern matching replaces the invoke even in a block that ends with a `throw`. 22 $inline$localStaticNop(); 23 throw new ExpectedError(); 24 } 25 $inline$localStaticNop()26 public static void $inline$localStaticNop() {} 27 28 /// CHECK-START: void Main.staticNopNeverInline() inliner (before) 29 /// CHECK: InvokeStaticOrDirect 30 31 /// CHECK-START: void Main.staticNopNeverInline() inliner (after) 32 /// CHECK: InvokeStaticOrDirect 33 staticNopNeverInline()34 public static void staticNopNeverInline() { 35 Second.staticNopNeverInline(11); 36 } 37 38 /// CHECK-START: void Main.staticNop() inliner (before) 39 /// CHECK: InvokeStaticOrDirect 40 41 /// CHECK-START: void Main.staticNop() inliner (after) 42 /// CHECK-NOT: InvokeStaticOrDirect 43 staticNop()44 public static void staticNop() { 45 Second.staticNop(11); 46 } 47 48 /// CHECK-START: void Main.nop(Second) inliner (before) 49 /// CHECK: InvokeVirtual 50 51 /// CHECK-START: void Main.nop(Second) inliner (after) 52 /// CHECK-NOT: InvokeVirtual 53 nop(Second s)54 public static void nop(Second s) { 55 s.nop(); 56 } 57 58 /// CHECK-START: java.lang.Object Main.staticReturnArg2(java.lang.String) inliner (before) 59 /// CHECK-DAG: <<Value:l\d+>> ParameterValue 60 /// CHECK-DAG: <<Ignored:i\d+>> IntConstant 77 61 /// CHECK-DAG: <<ClinitCk:l\d+>> ClinitCheck 62 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 63 /// CHECK-DAG: <<Invoke:l\d+>> InvokeStaticOrDirect [<<Ignored>>,<<Value>>{{(,[ij]\d+)?}},<<ClinitCk>>] 64 /// CHECK-DAG: Return [<<Invoke>>] 65 66 /// CHECK-START: java.lang.Object Main.staticReturnArg2(java.lang.String) inliner (after) 67 /// CHECK-DAG: <<Value:l\d+>> ParameterValue 68 /// CHECK-DAG: Return [<<Value>>] 69 70 /// CHECK-START: java.lang.Object Main.staticReturnArg2(java.lang.String) inliner (after) 71 /// CHECK-NOT: InvokeStaticOrDirect 72 staticReturnArg2(String value)73 public static Object staticReturnArg2(String value) { 74 return Second.staticReturnArg2(77, value); 75 } 76 77 /// CHECK-START: long Main.returnArg1(Second, long) inliner (before) 78 /// CHECK-DAG: <<Second:l\d+>> ParameterValue 79 /// CHECK-DAG: <<Value:j\d+>> ParameterValue 80 /// CHECK-DAG: <<NullCk:l\d+>> NullCheck [<<Second>>] 81 /// CHECK-DAG: <<Invoke:j\d+>> InvokeVirtual [<<NullCk>>,<<Value>>] 82 /// CHECK-DAG: Return [<<Invoke>>] 83 84 /// CHECK-START: long Main.returnArg1(Second, long) inliner (after) 85 /// CHECK-DAG: <<Value:j\d+>> ParameterValue 86 /// CHECK-DAG: Return [<<Value>>] 87 88 /// CHECK-START: long Main.returnArg1(Second, long) inliner (after) 89 /// CHECK-NOT: InvokeVirtual 90 returnArg1(Second s, long value)91 public static long returnArg1(Second s, long value) { 92 return s.returnArg1(value); 93 } 94 95 /// CHECK-START: int Main.staticReturn9() inliner (before) 96 /// CHECK: {{i\d+}} InvokeStaticOrDirect 97 98 /// CHECK-START: int Main.staticReturn9() inliner (before) 99 /// CHECK-NOT: IntConstant 9 100 101 /// CHECK-START: int Main.staticReturn9() inliner (after) 102 /// CHECK-DAG: <<Const9:i\d+>> IntConstant 9 103 /// CHECK-DAG: Return [<<Const9>>] 104 105 /// CHECK-START: int Main.staticReturn9() inliner (after) 106 /// CHECK-NOT: InvokeStaticOrDirect 107 staticReturn9()108 public static int staticReturn9() { 109 return Second.staticReturn9(); 110 } 111 112 /// CHECK-START: int Main.return7(Second) inliner (before) 113 /// CHECK: {{i\d+}} InvokeVirtual 114 115 /// CHECK-START: int Main.return7(Second) inliner (before) 116 /// CHECK-NOT: IntConstant 7 117 118 /// CHECK-START: int Main.return7(Second) inliner (after) 119 /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 120 /// CHECK-DAG: Return [<<Const7>>] 121 122 /// CHECK-START: int Main.return7(Second) inliner (after) 123 /// CHECK-NOT: InvokeVirtual 124 return7(Second s)125 public static int return7(Second s) { 126 return s.return7(null); 127 } 128 129 /// CHECK-START: float Main.return42f(Second) inliner (before) 130 /// CHECK: {{f\d+}} InvokeVirtual 131 132 /// CHECK-START: float Main.return42f(Second) inliner (before) 133 /// CHECK-NOT: FloatConstant 42 134 135 /// CHECK-START: float Main.return42f(Second) inliner (after) 136 /// CHECK-DAG: <<Const42f:f\d+>> FloatConstant 42 137 /// CHECK-DAG: Return [<<Const42f>>] 138 139 /// CHECK-START: float Main.return42f(Second) inliner (after) 140 /// CHECK-NOT: InvokeVirtual 141 return42f(Second s)142 public static float return42f(Second s) { 143 return s.return42f(); 144 } 145 146 /// CHECK-START: java.lang.String Main.staticReturnNull() inliner (before) 147 /// CHECK: {{l\d+}} InvokeStaticOrDirect 148 149 /// CHECK-START: java.lang.String Main.staticReturnNull() inliner (before) 150 /// CHECK-NOT: NullConstant 151 152 /// CHECK-START: java.lang.String Main.staticReturnNull() inliner (after) 153 /// CHECK-DAG: <<Null:l\d+>> NullConstant 154 /// CHECK-DAG: Return [<<Null>>] 155 156 /// CHECK-START: java.lang.String Main.staticReturnNull() inliner (after) 157 /// CHECK-NOT: InvokeStaticOrDirect 158 staticReturnNull()159 public static String staticReturnNull() { 160 return Second.staticReturnNull(); 161 } 162 163 /// CHECK-START: java.lang.Object Main.returnNull(Second) inliner (before) 164 /// CHECK: {{l\d+}} InvokeVirtual 165 166 /// CHECK-START: java.lang.Object Main.returnNull(Second) inliner (before) 167 /// CHECK-NOT: NullConstant 168 169 /// CHECK-START: java.lang.Object Main.returnNull(Second) inliner (after) 170 /// CHECK-DAG: <<Null:l\d+>> NullConstant 171 /// CHECK-DAG: Return [<<Null>>] 172 173 /// CHECK-START: java.lang.Object Main.returnNull(Second) inliner (after) 174 /// CHECK-NOT: InvokeVirtual 175 returnNull(Second s)176 public static Object returnNull(Second s) { 177 return s.returnNull(); 178 } 179 180 /// CHECK-START: int Main.getInt(Second) inliner (before) 181 /// CHECK: {{i\d+}} InvokeVirtual 182 183 /// CHECK-START: int Main.getInt(Second) inliner (after) 184 /// CHECK: {{i\d+}} InstanceFieldGet 185 186 /// CHECK-START: int Main.getInt(Second) inliner (after) 187 /// CHECK-NOT: InvokeVirtual 188 getInt(Second s)189 public static int getInt(Second s) { 190 return s.getInstanceIntField(); 191 } 192 193 /// CHECK-START: double Main.getDouble(Second) inliner (before) 194 /// CHECK: {{d\d+}} InvokeVirtual 195 196 /// CHECK-START: double Main.getDouble(Second) inliner (after) 197 /// CHECK: {{d\d+}} InstanceFieldGet 198 199 /// CHECK-START: double Main.getDouble(Second) inliner (after) 200 /// CHECK-NOT: InvokeVirtual 201 getDouble(Second s)202 public static double getDouble(Second s) { 203 return s.getInstanceDoubleField(22); 204 } 205 206 /// CHECK-START: java.lang.Object Main.getObject(Second) inliner (before) 207 /// CHECK: {{l\d+}} InvokeVirtual 208 209 /// CHECK-START: java.lang.Object Main.getObject(Second) inliner (after) 210 /// CHECK: {{l\d+}} InstanceFieldGet 211 212 /// CHECK-START: java.lang.Object Main.getObject(Second) inliner (after) 213 /// CHECK-NOT: InvokeVirtual 214 getObject(Second s)215 public static Object getObject(Second s) { 216 return s.getInstanceObjectField(-1L); 217 } 218 219 /// CHECK-START: java.lang.String Main.getString(Second) inliner (before) 220 /// CHECK: {{l\d+}} InvokeVirtual 221 222 /// CHECK-START: java.lang.String Main.getString(Second) inliner (after) 223 /// CHECK: {{l\d+}} InstanceFieldGet 224 225 /// CHECK-START: java.lang.String Main.getString(Second) inliner (after) 226 /// CHECK-NOT: InvokeVirtual 227 getString(Second s)228 public static String getString(Second s) { 229 return s.getInstanceStringField(null, "whatever", 1234L); 230 } 231 232 /// CHECK-START: int Main.staticGetInt(Second) inliner (before) 233 /// CHECK: {{i\d+}} InvokeStaticOrDirect 234 235 /// CHECK-START: int Main.staticGetInt(Second) inliner (after) 236 /// CHECK: {{i\d+}} InvokeStaticOrDirect 237 238 /// CHECK-START: int Main.staticGetInt(Second) inliner (after) 239 /// CHECK-NOT: InstanceFieldGet 240 staticGetInt(Second s)241 public static int staticGetInt(Second s) { 242 return Second.staticGetInstanceIntField(s); 243 } 244 245 /// CHECK-START: double Main.getDoubleFromParam(Second) inliner (before) 246 /// CHECK: {{d\d+}} InvokeVirtual 247 248 /// CHECK-START: double Main.getDoubleFromParam(Second) inliner (after) 249 /// CHECK: {{d\d+}} InvokeStaticOrDirect 250 251 /// CHECK-START: double Main.getDoubleFromParam(Second) inliner (after) 252 /// CHECK-NOT: InstanceFieldGet 253 /// CHECK-NOT: InvokeVirtual 254 getDoubleFromParam(Second s)255 public static double getDoubleFromParam(Second s) { 256 return s.getInstanceDoubleFieldFromParam(s); 257 } 258 259 /// CHECK-START: int Main.getStaticInt(Second) inliner (before) 260 /// CHECK: {{i\d+}} InvokeVirtual 261 262 /// CHECK-START: int Main.getStaticInt(Second) inliner (after) 263 /// CHECK: {{i\d+}} InvokeStaticOrDirect 264 265 /// CHECK-START: int Main.getStaticInt(Second) inliner (after) 266 /// CHECK-NOT: InstanceFieldGet 267 /// CHECK-NOT: StaticFieldGet 268 /// CHECK-NOT: InvokeVirtual 269 getStaticInt(Second s)270 public static int getStaticInt(Second s) { 271 return s.getStaticIntField(); 272 } 273 274 /// CHECK-START: long Main.setLong(Second, long) inliner (before) 275 /// CHECK: InvokeVirtual 276 277 /// CHECK-START: long Main.setLong(Second, long) inliner (after) 278 /// CHECK: InstanceFieldSet 279 280 /// CHECK-START: long Main.setLong(Second, long) inliner (after) 281 /// CHECK-NOT: InvokeVirtual 282 setLong(Second s, long value)283 public static long setLong(Second s, long value) { 284 s.setInstanceLongField(-1, value); 285 return s.instanceLongField; 286 } 287 288 /// CHECK-START: long Main.setLongReturnArg2(Second, long, int) inliner (before) 289 /// CHECK: InvokeVirtual 290 291 /// CHECK-START: long Main.setLongReturnArg2(Second, long, int) inliner (after) 292 /// CHECK-DAG: <<Second:l\d+>> ParameterValue 293 /// CHECK-DAG: <<Value:j\d+>> ParameterValue 294 /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue 295 /// CHECK-DAG: <<NullCk:l\d+>> NullCheck [<<Second>>] 296 /// CHECK-DAG: InstanceFieldSet [<<NullCk>>,<<Value>>] 297 /// CHECK-DAG: <<NullCk2:l\d+>> NullCheck [<<Second>>] 298 /// CHECK-DAG: <<IGet:j\d+>> InstanceFieldGet [<<NullCk2>>] 299 /// CHECK-DAG: <<Conv:j\d+>> TypeConversion [<<Arg2>>] 300 /// CHECK-DAG: <<Add:j\d+>> Add [<<IGet>>,<<Conv>>] 301 /// CHECK-DAG: Return [<<Add>>] 302 303 /// CHECK-START: long Main.setLongReturnArg2(Second, long, int) inliner (after) 304 /// CHECK-NOT: InvokeVirtual 305 setLongReturnArg2(Second s, long value, int arg2)306 public static long setLongReturnArg2(Second s, long value, int arg2) { 307 int result = s.setInstanceLongFieldReturnArg2(value, arg2); 308 return s.instanceLongField + result; 309 } 310 311 /// CHECK-START: long Main.staticSetLong(Second, long) inliner (before) 312 /// CHECK: InvokeStaticOrDirect 313 314 /// CHECK-START: long Main.staticSetLong(Second, long) inliner (after) 315 /// CHECK: InvokeStaticOrDirect 316 317 /// CHECK-START: long Main.staticSetLong(Second, long) inliner (after) 318 /// CHECK-NOT: InstanceFieldSet 319 staticSetLong(Second s, long value)320 public static long staticSetLong(Second s, long value) { 321 Second.staticSetInstanceLongField(s, value); 322 return s.instanceLongField; 323 } 324 325 /// CHECK-START: long Main.setLongThroughParam(Second, long) inliner (before) 326 /// CHECK: InvokeVirtual 327 328 /// CHECK-START: long Main.setLongThroughParam(Second, long) inliner (after) 329 /// CHECK: InvokeStaticOrDirect 330 331 /// CHECK-START: long Main.setLongThroughParam(Second, long) inliner (after) 332 /// CHECK-NOT: InstanceFieldSet 333 /// CHECK-NOT: InvokeVirtual 334 setLongThroughParam(Second s, long value)335 public static long setLongThroughParam(Second s, long value) { 336 s.setInstanceLongFieldThroughParam(s, value); 337 return s.instanceLongField; 338 } 339 340 /// CHECK-START: float Main.setStaticFloat(Second, float) inliner (before) 341 /// CHECK: InvokeVirtual 342 343 /// CHECK-START: float Main.setStaticFloat(Second, float) inliner (after) 344 /// CHECK: InvokeStaticOrDirect 345 346 /// CHECK-START: float Main.setStaticFloat(Second, float) inliner (after) 347 /// CHECK-NOT: InstanceFieldSet 348 /// CHECK-NOT: StaticFieldSet 349 /// CHECK-NOT: InvokeVirtual 350 setStaticFloat(Second s, float value)351 public static float setStaticFloat(Second s, float value) { 352 s.setStaticFloatField(value); 353 return s.staticFloatField; 354 } 355 356 /// CHECK-START: java.lang.Object Main.newObject() inliner (before) 357 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 358 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 359 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>{{(,[ij]\d+)?}}] method_name:java.lang.Object.<init> 360 361 /// CHECK-START: java.lang.Object Main.newObject() inliner (after) 362 /// CHECK-NOT: InvokeStaticOrDirect 363 newObject()364 public static Object newObject() { 365 return new Object(); 366 } 367 368 /// CHECK-START: double Main.constructBase() inliner (before) 369 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 370 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 371 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>{{(,[ij]\d+)?}}] method_name:Base.<init> 372 373 /// CHECK-START: double Main.constructBase() inliner (after) 374 /// CHECK: ConstructorFence 375 /// CHECK-NOT: InvokeStaticOrDirect 376 /// CHECK-NOT: ConstructorFence 377 /// CHECK-NOT: InstanceFieldSet 378 constructBase()379 public static double constructBase() { 380 Base b = new Base(); 381 return b.intField + b.doubleField; 382 } 383 384 /// CHECK-START: double Main.constructBase(int) inliner (before) 385 /// CHECK-DAG: <<Value:i\d+>> ParameterValue 386 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 387 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 388 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:Base.<init> 389 390 /// CHECK-START: double Main.constructBase(int) inliner (after) 391 /// CHECK: ConstructorFence 392 /// CHECK-NOT: InvokeStaticOrDirect 393 /// CHECK-NOT: ConstructorFence 394 395 /// CHECK-START: double Main.constructBase(int) inliner (after) 396 /// CHECK-DAG: <<Value:i\d+>> ParameterValue 397 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 398 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<Value>>] 399 400 /// CHECK-START: double Main.constructBase(int) inliner (after) 401 /// CHECK-DAG: InstanceFieldSet 402 /// CHECK-NOT: InstanceFieldSet 403 constructBase(int intValue)404 public static double constructBase(int intValue) { 405 Base b = new Base(intValue); 406 return b.intField + b.doubleField; 407 } 408 409 /// CHECK-START: double Main.constructBaseWith0() inliner (before) 410 /// CHECK-DAG: <<Value:i\d+>> IntConstant 0 411 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 412 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 413 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:Base.<init> 414 415 /// CHECK-START: double Main.constructBaseWith0() inliner (after) 416 /// CHECK: ConstructorFence 417 /// CHECK-NOT: InvokeStaticOrDirect 418 /// CHECK-NOT: ConstructorFence 419 /// CHECK-NOT: InstanceFieldSet 420 constructBaseWith0()421 public static double constructBaseWith0() { 422 Base b = new Base(0); 423 return b.intField + b.doubleField; 424 } 425 426 /// CHECK-START: java.lang.String Main.constructBase(java.lang.String) inliner (before) 427 /// CHECK-DAG: <<Value:l\d+>> ParameterValue 428 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 429 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 430 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:Base.<init> 431 432 /// CHECK-START: java.lang.String Main.constructBase(java.lang.String) inliner (after) 433 /// CHECK: ConstructorFence 434 /// CHECK-NOT: InvokeStaticOrDirect 435 /// CHECK-NOT: ConstructorFence 436 437 /// CHECK-START: java.lang.String Main.constructBase(java.lang.String) inliner (after) 438 /// CHECK-DAG: <<Value:l\d+>> ParameterValue 439 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 440 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<Value>>] 441 442 /// CHECK-START: java.lang.String Main.constructBase(java.lang.String) inliner (after) 443 /// CHECK-DAG: InstanceFieldSet 444 /// CHECK-NOT: InstanceFieldSet 445 constructBase(String stringValue)446 public static String constructBase(String stringValue) { 447 Base b = new Base(stringValue); 448 return b.stringField; 449 } 450 451 /// CHECK-START: java.lang.String Main.constructBaseWithNullString() inliner (before) 452 /// CHECK-DAG: <<Null:l\d+>> NullConstant 453 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 454 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 455 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Null>>{{(,[ij]\d+)?}}] method_name:Base.<init> 456 457 /// CHECK-START: java.lang.String Main.constructBaseWithNullString() inliner (after) 458 /// CHECK: ConstructorFence 459 /// CHECK-NOT: InvokeStaticOrDirect 460 /// CHECK-NOT: ConstructorFence 461 462 /// CHECK-START: java.lang.String Main.constructBaseWithNullString() inliner (after) 463 /// CHECK-NOT: InstanceFieldSet 464 constructBaseWithNullString()465 public static String constructBaseWithNullString() { 466 String stringValue = null; 467 Base b = new Base(stringValue); 468 return b.stringField; 469 } 470 471 /// CHECK-START: double Main.constructBase(double, java.lang.Object) inliner (before) 472 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 473 /// CHECK-DAG: <<OValue:l\d+>> ParameterValue 474 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 475 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 476 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<DValue>>,<<OValue>>{{(,[ij]\d+)?}}] method_name:Base.<init> 477 478 /// CHECK-START: double Main.constructBase(double, java.lang.Object) inliner (after) 479 /// CHECK: ConstructorFence 480 /// CHECK-NOT: InvokeStaticOrDirect 481 /// CHECK-NOT: ConstructorFence 482 483 /// CHECK-START: double Main.constructBase(double, java.lang.Object) inliner (after) 484 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 485 /// CHECK-DAG: <<OValue:l\d+>> ParameterValue 486 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 487 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<DValue>>] 488 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<OValue>>] 489 490 /// CHECK-START: double Main.constructBase(double, java.lang.Object) inliner (after) 491 /// CHECK-DAG: InstanceFieldSet 492 /// CHECK-DAG: InstanceFieldSet 493 /// CHECK-NOT: InstanceFieldSet 494 constructBase(double doubleValue, Object objectValue)495 public static double constructBase(double doubleValue, Object objectValue) { 496 Base b = new Base(doubleValue, objectValue); 497 return (b.objectField != null) ? b.doubleField : -b.doubleField; 498 } 499 500 /// CHECK-START: double Main.constructBase(int, double, java.lang.Object) inliner (before) 501 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 502 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 503 /// CHECK-DAG: <<OValue:l\d+>> ParameterValue 504 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 505 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 506 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<IValue>>,<<DValue>>,<<OValue>>{{(,[ij]\d+)?}}] method_name:Base.<init> 507 508 /// CHECK-START: double Main.constructBase(int, double, java.lang.Object) inliner (after) 509 /// CHECK: ConstructorFence 510 /// CHECK-NOT: InvokeStaticOrDirect 511 /// CHECK-NOT: ConstructorFence 512 513 /// CHECK-START: double Main.constructBase(int, double, java.lang.Object) inliner (after) 514 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 515 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 516 /// CHECK-DAG: <<OValue:l\d+>> ParameterValue 517 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 518 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<IValue>>] 519 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<DValue>>] 520 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<OValue>>] 521 522 /// CHECK-START: double Main.constructBase(int, double, java.lang.Object) inliner (after) 523 /// CHECK-DAG: InstanceFieldSet 524 /// CHECK-DAG: InstanceFieldSet 525 /// CHECK-DAG: InstanceFieldSet 526 /// CHECK-NOT: InstanceFieldSet 527 constructBase(int intValue, double doubleValue, Object objectValue)528 public static double constructBase(int intValue, double doubleValue, Object objectValue) { 529 Base b = new Base(intValue, doubleValue, objectValue); 530 double tmp = b.intField + b.doubleField; 531 return (b.objectField != null) ? tmp : -tmp; 532 } 533 534 /// CHECK-START: double Main.constructBaseWith0DoubleNull(double) inliner (before) 535 /// CHECK-DAG: <<IValue:i\d+>> IntConstant 0 536 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 537 /// CHECK-DAG: <<OValue:l\d+>> NullConstant 538 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 539 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 540 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<IValue>>,<<DValue>>,<<OValue>>{{(,[ij]\d+)?}}] method_name:Base.<init> 541 542 /// CHECK-START: double Main.constructBaseWith0DoubleNull(double) inliner (after) 543 /// CHECK: ConstructorFence 544 /// CHECK-NOT: InvokeStaticOrDirect 545 /// CHECK-NOT: ConstructorFence 546 547 /// CHECK-START: double Main.constructBaseWith0DoubleNull(double) inliner (after) 548 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 549 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 550 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<DValue>>] 551 552 /// CHECK-START: double Main.constructBaseWith0DoubleNull(double) inliner (after) 553 /// CHECK-DAG: InstanceFieldSet 554 /// CHECK-NOT: InstanceFieldSet 555 constructBaseWith0DoubleNull(double doubleValue)556 public static double constructBaseWith0DoubleNull(double doubleValue) { 557 Base b = new Base(0, doubleValue, null); 558 double tmp = b.intField + b.doubleField; 559 return (b.objectField != null) ? tmp : -tmp; 560 } 561 562 /// CHECK-START: double Main.constructBase(int, double, java.lang.Object, java.lang.String) inliner (before) 563 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 564 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 565 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 566 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 567 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<IValue>>,<<DValue>>,{{l\d+}},{{l\d+}}{{(,[ij]\d+)?}}] method_name:Base.<init> 568 569 /// CHECK-START: double Main.constructBase(int, double, java.lang.Object, java.lang.String) inliner (after) 570 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 571 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 572 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 573 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 574 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<IValue>>,<<DValue>>,{{l\d+}},{{l\d+}}{{(,[ij]\d+)?}}] method_name:Base.<init> 575 576 /// CHECK-START: double Main.constructBase(int, double, java.lang.Object, java.lang.String) inliner (after) 577 /// CHECK-NOT: InstanceFieldSet 578 constructBase( int intValue, double doubleValue, Object objectValue, String stringValue)579 public static double constructBase( 580 int intValue, double doubleValue, Object objectValue, String stringValue) { 581 Base b = new Base(intValue, doubleValue, objectValue, stringValue); 582 double tmp = b.intField + b.doubleField; 583 tmp = (b.objectField != null) ? tmp : -tmp; 584 return (b.stringField != null) ? 2.0 * tmp : 0.5 * tmp; 585 } 586 587 /// CHECK-START: double Main.constructBase(double) inliner (before) 588 /// CHECK-DAG: <<Value:d\d+>> ParameterValue 589 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 590 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 591 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:Base.<init> 592 593 /// CHECK-START: double Main.constructBase(double) inliner (after) 594 /// CHECK: ConstructorFence 595 /// CHECK-NOT: InvokeStaticOrDirect 596 /// CHECK-NOT: ConstructorFence 597 598 /// CHECK-START: double Main.constructBase(double) inliner (after) 599 /// CHECK-DAG: <<Value:d\d+>> ParameterValue 600 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 601 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<Value>>] 602 603 /// CHECK-START: double Main.constructBase(double) inliner (after) 604 /// CHECK-DAG: InstanceFieldSet 605 /// CHECK-NOT: InstanceFieldSet 606 constructBase(double doubleValue)607 public static double constructBase(double doubleValue) { 608 Base b = new Base(doubleValue); 609 return b.intField + b.doubleField; 610 } 611 612 /// CHECK-START: double Main.constructBaseWith0d() inliner (before) 613 /// CHECK-DAG: <<Value:d\d+>> DoubleConstant 614 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 615 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 616 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:Base.<init> 617 618 /// CHECK-START: double Main.constructBaseWith0d() inliner (after) 619 /// CHECK: ConstructorFence 620 /// CHECK-NOT: InvokeStaticOrDirect 621 /// CHECK-NOT: ConstructorFence 622 /// CHECK-NOT: InstanceFieldSet 623 constructBaseWith0d()624 public static double constructBaseWith0d() { 625 Base b = new Base(0.0); 626 return b.intField + b.doubleField; 627 } 628 629 /// CHECK-START: double Main.constructBase(java.lang.Object) inliner (before) 630 /// CHECK-DAG: <<OValue:l\d+>> ParameterValue 631 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 632 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 633 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<OValue>>{{(,[ij]\d+)?}}] method_name:Base.<init> 634 635 /// CHECK-START: double Main.constructBase(java.lang.Object) inliner (after) 636 /// CHECK-DAG: <<OValue:l\d+>> ParameterValue 637 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 638 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 639 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<OValue>>{{(,[ij]\d+)?}}] method_name:Base.<init> 640 641 /// CHECK-START: double Main.constructBase(java.lang.Object) inliner (after) 642 /// CHECK-NOT: InstanceFieldSet 643 constructBase(Object objectValue)644 public static double constructBase(Object objectValue) { 645 Base b = new Base(objectValue); 646 double tmp = b.intField + b.doubleField; 647 return (b.objectField != null) ? tmp + 1.0 : tmp - 1.0; 648 } 649 650 /// CHECK-START: double Main.constructBase(int, long) inliner (before) 651 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 652 /// CHECK-DAG: <<JValue:j\d+>> ParameterValue 653 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 654 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 655 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<IValue>>,<<JValue>>{{(,[ij]\d+)?}}] method_name:Base.<init> 656 657 /// CHECK-START: double Main.constructBase(int, long) inliner (after) 658 /// CHECK: ConstructorFence 659 /// CHECK-NOT: InvokeStaticOrDirect 660 /// CHECK-NOT: ConstructorFence 661 662 /// CHECK-START: double Main.constructBase(int, long) inliner (after) 663 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 664 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 665 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<IValue>>] 666 667 /// CHECK-START: double Main.constructBase(int, long) inliner (after) 668 /// CHECK-DAG: InstanceFieldSet 669 /// CHECK-NOT: InstanceFieldSet 670 constructBase(int intValue, long placeholder)671 public static double constructBase(int intValue, long placeholder) { 672 Base b = new Base(intValue, placeholder); 673 return b.intField + b.doubleField; 674 } 675 676 /// CHECK-START: double Main.constructDerived() inliner (before) 677 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 678 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 679 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>{{(,[ij]\d+)?}}] method_name:Derived.<init> 680 681 /// CHECK-START: double Main.constructDerived() inliner (after) 682 /// CHECK: ConstructorFence 683 /// CHECK-NOT: InvokeStaticOrDirect 684 /// CHECK-NOT: ConstructorFence 685 /// CHECK-NOT: InstanceFieldSet 686 constructDerived()687 public static double constructDerived() { 688 Derived d = new Derived(); 689 return d.intField + d.doubleField; 690 } 691 692 /// CHECK-START: double Main.constructDerived(int) inliner (before) 693 /// CHECK-DAG: <<Value:i\d+>> ParameterValue 694 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 695 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 696 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:Derived.<init> 697 698 /// CHECK-START: double Main.constructDerived(int) inliner (after) 699 /// CHECK: ConstructorFence 700 /// CHECK-NOT: InvokeStaticOrDirect 701 /// CHECK-NOT: ConstructorFence 702 703 /// CHECK-START: double Main.constructDerived(int) inliner (after) 704 /// CHECK-DAG: <<Value:i\d+>> ParameterValue 705 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 706 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<Value>>] 707 708 /// CHECK-START: double Main.constructDerived(int) inliner (after) 709 /// CHECK-DAG: InstanceFieldSet 710 /// CHECK-NOT: InstanceFieldSet 711 constructDerived(int intValue)712 public static double constructDerived(int intValue) { 713 Derived d = new Derived(intValue); 714 return d.intField + d.doubleField; 715 } 716 717 /// CHECK-START: double Main.constructDerivedWith0() inliner (before) 718 /// CHECK-DAG: <<Value:i\d+>> IntConstant 0 719 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 720 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 721 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:Derived.<init> 722 723 /// CHECK-START: double Main.constructDerivedWith0() inliner (after) 724 /// CHECK: ConstructorFence 725 /// CHECK-NOT: InvokeStaticOrDirect 726 /// CHECK-NOT: ConstructorFence 727 /// CHECK-NOT: InstanceFieldSet 728 constructDerivedWith0()729 public static double constructDerivedWith0() { 730 Derived d = new Derived(0); 731 return d.intField + d.doubleField; 732 } 733 734 /// CHECK-START: java.lang.String Main.constructDerived(java.lang.String) inliner (before) 735 /// CHECK-DAG: <<Value:l\d+>> ParameterValue 736 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 737 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 738 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:Derived.<init> 739 740 /// CHECK-START: java.lang.String Main.constructDerived(java.lang.String) inliner (after) 741 /// CHECK: ConstructorFence 742 /// CHECK-NOT: InvokeStaticOrDirect 743 /// CHECK-NOT: ConstructorFence 744 745 /// CHECK-START: java.lang.String Main.constructDerived(java.lang.String) inliner (after) 746 /// CHECK-NOT: InstanceFieldSet 747 constructDerived(String stringValue)748 public static String constructDerived(String stringValue) { 749 Derived d = new Derived(stringValue); 750 return d.stringField; 751 } 752 753 /// CHECK-START: double Main.constructDerived(double) inliner (before) 754 /// CHECK-DAG: <<Value:d\d+>> ParameterValue 755 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 756 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 757 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:Derived.<init> 758 759 /// CHECK-START: double Main.constructDerived(double) inliner (after) 760 /// CHECK: ConstructorFence 761 /// CHECK-NOT: InvokeStaticOrDirect 762 /// CHECK-NOT: ConstructorFence 763 764 /// CHECK-START: double Main.constructDerived(double) inliner (after) 765 /// CHECK-DAG: <<Value:d\d+>> ParameterValue 766 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 767 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<Value>>] 768 769 /// CHECK-START: double Main.constructDerived(double) inliner (after) 770 /// CHECK-DAG: InstanceFieldSet 771 /// CHECK-NOT: InstanceFieldSet 772 constructDerived(double doubleValue)773 public static double constructDerived(double doubleValue) { 774 Derived d = new Derived(doubleValue); 775 return d.intField + d.doubleField; 776 } 777 778 /// CHECK-START: double Main.constructDerivedWith0d() inliner (before) 779 /// CHECK-DAG: <<Value:d\d+>> DoubleConstant 780 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 781 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 782 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:Derived.<init> 783 784 /// CHECK-START: double Main.constructDerivedWith0d() inliner (after) 785 /// CHECK: ConstructorFence 786 /// CHECK-NOT: InvokeStaticOrDirect 787 /// CHECK-NOT: ConstructorFence 788 /// CHECK-NOT: InstanceFieldSet 789 constructDerivedWith0d()790 public static double constructDerivedWith0d() { 791 Derived d = new Derived(0.0); 792 return d.intField + d.doubleField; 793 } 794 795 /// CHECK-START: double Main.constructDerived(int, double, java.lang.Object) inliner (before) 796 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 797 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 798 /// CHECK-DAG: <<OValue:l\d+>> ParameterValue 799 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 800 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 801 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<IValue>>,<<DValue>>,<<OValue>>{{(,[ij]\d+)?}}] method_name:Derived.<init> 802 803 /// CHECK-START: double Main.constructDerived(int, double, java.lang.Object) inliner (after) 804 /// CHECK: ConstructorFence 805 /// CHECK-NOT: InvokeStaticOrDirect 806 /// CHECK-NOT: ConstructorFence 807 808 /// CHECK-START: double Main.constructDerived(int, double, java.lang.Object) inliner (after) 809 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 810 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 811 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<DValue>>] 812 813 /// CHECK-START: double Main.constructDerived(int, double, java.lang.Object) inliner (after) 814 /// CHECK-DAG: InstanceFieldSet 815 /// CHECK-NOT: InstanceFieldSet 816 constructDerived(int intValue, double doubleValue, Object objectValue)817 public static double constructDerived(int intValue, double doubleValue, Object objectValue) { 818 Derived d = new Derived(intValue, doubleValue, objectValue); 819 double tmp = d.intField + d.doubleField; 820 return (d.objectField != null) ? tmp : -tmp; 821 } 822 823 /// CHECK-START: double Main.constructDerived(int, double, java.lang.Object, java.lang.String) inliner (before) 824 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 825 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 826 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 827 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 828 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<IValue>>,<<DValue>>,{{l\d+}},{{l\d+}}{{(,[ij]\d+)?}}] method_name:Derived.<init> 829 830 /// CHECK-START: double Main.constructDerived(int, double, java.lang.Object, java.lang.String) inliner (after) 831 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 832 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 833 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 834 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 835 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<IValue>>,<<DValue>>,{{l\d+}},{{l\d+}}{{(,[ij]\d+)?}}] method_name:Derived.<init> 836 837 /// CHECK-START: double Main.constructDerived(int, double, java.lang.Object, java.lang.String) inliner (after) 838 /// CHECK-NOT: InstanceFieldSet 839 constructDerived( int intValue, double doubleValue, Object objectValue, String stringValue)840 public static double constructDerived( 841 int intValue, double doubleValue, Object objectValue, String stringValue) { 842 Derived d = new Derived(intValue, doubleValue, objectValue, stringValue); 843 double tmp = d.intField + d.doubleField; 844 tmp = (d.objectField != null) ? tmp : -tmp; 845 return (d.stringField != null) ? 2.0 * tmp : 0.5 * tmp; 846 } 847 848 /// CHECK-START: double Main.constructDerived(float) inliner (before) 849 /// CHECK-DAG: <<Value:f\d+>> ParameterValue 850 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 851 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 852 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:Derived.<init> 853 854 /// CHECK-START: double Main.constructDerived(float) inliner (after) 855 /// CHECK: ConstructorFence 856 /// CHECK-NOT: InvokeStaticOrDirect 857 /// CHECK-NOT: ConstructorFence 858 859 /// CHECK-START: double Main.constructDerived(float) inliner (after) 860 /// CHECK-DAG: <<Value:f\d+>> ParameterValue 861 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 862 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<Value>>] 863 864 /// CHECK-START: double Main.constructDerived(float) inliner (after) 865 /// CHECK-DAG: InstanceFieldSet 866 /// CHECK-NOT: InstanceFieldSet 867 constructDerived(float floatValue)868 public static double constructDerived(float floatValue) { 869 Derived d = new Derived(floatValue); 870 return d.intField + d.doubleField + d.floatField; 871 } 872 873 /// CHECK-START: double Main.constructDerived(int, double, java.lang.Object, float) inliner (before) 874 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 875 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 876 /// CHECK-DAG: <<OValue:l\d+>> ParameterValue 877 /// CHECK-DAG: <<FValue:f\d+>> ParameterValue 878 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 879 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 880 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<IValue>>,<<DValue>>,<<OValue>>,<<FValue>>{{(,[ij]\d+)?}}] method_name:Derived.<init> 881 882 /// CHECK-START: double Main.constructDerived(int, double, java.lang.Object, float) inliner (after) 883 /// CHECK: ConstructorFence 884 /// CHECK-NOT: InvokeStaticOrDirect 885 /// CHECK-NOT: ConstructorFence 886 887 /// CHECK-START: double Main.constructDerived(int, double, java.lang.Object, float) inliner (after) 888 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 889 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 890 /// CHECK-DAG: <<FValue:f\d+>> ParameterValue 891 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 892 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<IValue>>] 893 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<DValue>>] 894 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<FValue>>] 895 896 /// CHECK-START: double Main.constructDerived(int, double, java.lang.Object, float) inliner (after) 897 /// CHECK-DAG: InstanceFieldSet 898 /// CHECK-DAG: InstanceFieldSet 899 /// CHECK-DAG: InstanceFieldSet 900 /// CHECK-NOT: InstanceFieldSet 901 constructDerived( int intValue, double doubleValue, Object objectValue, float floatValue)902 public static double constructDerived( 903 int intValue, double doubleValue, Object objectValue, float floatValue) { 904 Derived d = new Derived(intValue, doubleValue, objectValue, floatValue); 905 double tmp = d.intField + d.doubleField + d.floatField; 906 return (d.objectField != null) ? tmp : -tmp; 907 } 908 909 /// CHECK-START: int Main.constructBaseWithFinalField() inliner (before) 910 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 911 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 912 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>{{(,[ij]\d+)?}}] method_name:BaseWithFinalField.<init> 913 914 /// CHECK-START: int Main.constructBaseWithFinalField() inliner (after) 915 /// CHECK: ConstructorFence 916 /// CHECK-NOT: InvokeStaticOrDirect 917 /// CHECK-NOT: ConstructorFence 918 /// CHECK-NOT: InstanceFieldSet 919 constructBaseWithFinalField()920 public static int constructBaseWithFinalField() { 921 BaseWithFinalField b = new BaseWithFinalField(); 922 return b.intField; 923 } 924 925 /// CHECK-START: int Main.constructBaseWithFinalField(int) inliner (before) 926 /// CHECK-DAG: <<Value:i\d+>> ParameterValue 927 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 928 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 929 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:BaseWithFinalField.<init> 930 931 /// CHECK-START: int Main.constructBaseWithFinalField(int) inliner (after) 932 /// CHECK-NOT: InvokeStaticOrDirect 933 934 /// CHECK-START: int Main.constructBaseWithFinalField(int) inliner (after) 935 /// CHECK-DAG: <<Value:i\d+>> ParameterValue 936 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 937 /// CHECK-DAG: ConstructorFence 938 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<Value>>] 939 /// CHECK-DAG: ConstructorFence 940 941 /// CHECK-START: int Main.constructBaseWithFinalField(int) inliner (after) 942 /// CHECK-DAG: InstanceFieldSet 943 /// CHECK-NOT: InstanceFieldSet 944 constructBaseWithFinalField(int intValue)945 public static int constructBaseWithFinalField(int intValue) { 946 BaseWithFinalField b = new BaseWithFinalField(intValue); 947 return b.intField; 948 } 949 950 /// CHECK-START: int Main.constructBaseWithFinalFieldWith0() inliner (before) 951 /// CHECK-DAG: <<Value:i\d+>> IntConstant 0 952 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 953 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 954 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:BaseWithFinalField.<init> 955 956 /// CHECK-START: int Main.constructBaseWithFinalFieldWith0() inliner (after) 957 /// CHECK: ConstructorFence 958 /// CHECK-NOT: InvokeStaticOrDirect 959 /// CHECK-NOT: ConstructorFence 960 /// CHECK-NOT: InstanceFieldSet 961 constructBaseWithFinalFieldWith0()962 public static int constructBaseWithFinalFieldWith0() { 963 BaseWithFinalField b = new BaseWithFinalField(0); 964 return b.intField; 965 } 966 967 /// CHECK-START: double Main.constructDerivedWithFinalField() inliner (before) 968 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 969 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 970 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>{{(,[ij]\d+)?}}] method_name:DerivedWithFinalField.<init> 971 972 /// CHECK-START: double Main.constructDerivedWithFinalField() inliner (after) 973 /// CHECK: ConstructorFence 974 /// CHECK-NOT: InvokeStaticOrDirect 975 /// CHECK-NOT: ConstructorFence 976 /// CHECK-NOT: InstanceFieldSet 977 constructDerivedWithFinalField()978 public static double constructDerivedWithFinalField() { 979 DerivedWithFinalField d = new DerivedWithFinalField(); 980 return d.intField + d.doubleField; 981 } 982 983 /// CHECK-START: double Main.constructDerivedWithFinalField(int) inliner (before) 984 /// CHECK-DAG: <<Value:i\d+>> ParameterValue 985 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 986 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 987 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:DerivedWithFinalField.<init> 988 989 /// CHECK-START: double Main.constructDerivedWithFinalField(int) inliner (after) 990 /// CHECK-NOT: InvokeStaticOrDirect 991 992 /// CHECK-START: double Main.constructDerivedWithFinalField(int) inliner (after) 993 /// CHECK-DAG: <<Value:i\d+>> ParameterValue 994 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 995 /// CHECK-DAG: ConstructorFence 996 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<Value>>] 997 /// CHECK-DAG: ConstructorFence 998 999 /// CHECK-START: double Main.constructDerivedWithFinalField(int) inliner (after) 1000 /// CHECK-DAG: InstanceFieldSet 1001 /// CHECK-NOT: InstanceFieldSet 1002 constructDerivedWithFinalField(int intValue)1003 public static double constructDerivedWithFinalField(int intValue) { 1004 DerivedWithFinalField d = new DerivedWithFinalField(intValue); 1005 return d.intField + d.doubleField; 1006 } 1007 1008 /// CHECK-START: double Main.constructDerivedWithFinalFieldWith0() inliner (before) 1009 /// CHECK-DAG: <<Value:i\d+>> IntConstant 0 1010 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1011 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 1012 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:DerivedWithFinalField.<init> 1013 1014 /// CHECK-START: double Main.constructDerivedWithFinalFieldWith0() inliner (after) 1015 /// CHECK: ConstructorFence 1016 /// CHECK-NOT: InvokeStaticOrDirect 1017 /// CHECK-NOT: ConstructorFence 1018 /// CHECK-NOT: InstanceFieldSet 1019 constructDerivedWithFinalFieldWith0()1020 public static double constructDerivedWithFinalFieldWith0() { 1021 DerivedWithFinalField d = new DerivedWithFinalField(0); 1022 return d.intField + d.doubleField; 1023 } 1024 1025 /// CHECK-START: double Main.constructDerivedWithFinalField(double) inliner (before) 1026 /// CHECK-DAG: <<Value:d\d+>> ParameterValue 1027 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1028 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 1029 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:DerivedWithFinalField.<init> 1030 1031 /// CHECK-START: double Main.constructDerivedWithFinalField(double) inliner (after) 1032 /// CHECK-NOT: InvokeStaticOrDirect 1033 1034 /// CHECK-START: double Main.constructDerivedWithFinalField(double) inliner (after) 1035 /// CHECK-DAG: <<Value:d\d+>> ParameterValue 1036 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1037 /// CHECK-DAG: ConstructorFence 1038 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<Value>>] 1039 /// CHECK-DAG: ConstructorFence 1040 1041 /// CHECK-START: double Main.constructDerivedWithFinalField(double) inliner (after) 1042 /// CHECK-DAG: InstanceFieldSet 1043 /// CHECK-NOT: InstanceFieldSet 1044 constructDerivedWithFinalField(double doubleValue)1045 public static double constructDerivedWithFinalField(double doubleValue) { 1046 DerivedWithFinalField d = new DerivedWithFinalField(doubleValue); 1047 return d.intField + d.doubleField; 1048 } 1049 1050 /// CHECK-START: double Main.constructDerivedWithFinalFieldWith0d() inliner (before) 1051 /// CHECK-DAG: <<Value:d\d+>> DoubleConstant 1052 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1053 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 1054 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:DerivedWithFinalField.<init> 1055 1056 /// CHECK-START: double Main.constructDerivedWithFinalFieldWith0d() inliner (after) 1057 /// CHECK: ConstructorFence 1058 /// CHECK-NOT: InvokeStaticOrDirect 1059 /// CHECK-NOT: ConstructorFence 1060 /// CHECK-NOT: InstanceFieldSet 1061 constructDerivedWithFinalFieldWith0d()1062 public static double constructDerivedWithFinalFieldWith0d() { 1063 DerivedWithFinalField d = new DerivedWithFinalField(0.0); 1064 return d.intField + d.doubleField; 1065 } 1066 1067 /// CHECK-START: double Main.constructDerivedWithFinalField(int, double) inliner (before) 1068 /// CHECK-DAG: <<IValue:i\d+>> ParameterValue 1069 /// CHECK-DAG: <<DValue:d\d+>> ParameterValue 1070 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1071 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 1072 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<IValue>>,<<DValue>>{{(,[ij]\d+)?}}] method_name:DerivedWithFinalField.<init> 1073 1074 /// CHECK-START: double Main.constructDerivedWithFinalField(int, double) inliner (after) 1075 /// CHECK-NOT: InvokeStaticOrDirect 1076 1077 /// CHECK-START: double Main.constructDerivedWithFinalField(int, double) inliner (after) 1078 /// CHECK-DAG: <<Value:d\d+>> ParameterValue 1079 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1080 /// CHECK-DAG: ConstructorFence 1081 /// CHECK-DAG: InstanceFieldSet [<<Obj>>,<<Value>>] 1082 /// CHECK-DAG: ConstructorFence 1083 1084 /// CHECK-START: double Main.constructDerivedWithFinalField(int, double) inliner (after) 1085 /// CHECK-DAG: InstanceFieldSet 1086 /// CHECK-DAG: InstanceFieldSet 1087 /// CHECK-NOT: InstanceFieldSet 1088 1089 /// CHECK-START: double Main.constructDerivedWithFinalField(int, double) inliner (after) 1090 /// CHECK-DAG: ConstructorFence 1091 /// CHECK-DAG: ConstructorFence 1092 /// CHECK-NOT: ConstructorFence 1093 constructDerivedWithFinalField(int intValue, double doubleValue)1094 public static double constructDerivedWithFinalField(int intValue, double doubleValue) { 1095 DerivedWithFinalField d = new DerivedWithFinalField(intValue, doubleValue); 1096 return d.intField + d.doubleField; 1097 } 1098 1099 /// CHECK-START: double Main.constructDerivedWithFinalFieldWith0And0d() inliner (before) 1100 /// CHECK-DAG: <<IValue:i\d+>> IntConstant 0 1101 /// CHECK-DAG: <<DValue:d\d+>> DoubleConstant 1102 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1103 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 1104 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<IValue>>,<<DValue>>{{(,[ij]\d+)?}}] method_name:DerivedWithFinalField.<init> 1105 1106 /// CHECK-START: double Main.constructDerivedWithFinalFieldWith0And0d() inliner (after) 1107 /// CHECK: ConstructorFence 1108 /// CHECK-NOT: InvokeStaticOrDirect 1109 /// CHECK-NOT: ConstructorFence 1110 /// CHECK-NOT: InstanceFieldSet 1111 constructDerivedWithFinalFieldWith0And0d()1112 public static double constructDerivedWithFinalFieldWith0And0d() { 1113 DerivedWithFinalField d = new DerivedWithFinalField(0, 0.0); 1114 return d.intField + d.doubleField; 1115 } 1116 1117 /// CHECK-START: int Main.constructDerivedInSecondDex() inliner (before) 1118 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1119 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 1120 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>{{(,[ij]\d+)?}}] method_name:DerivedInSecondDex.<init> 1121 1122 /// CHECK-START: int Main.constructDerivedInSecondDex() inliner (after) 1123 /// CHECK: ConstructorFence 1124 /// CHECK-NOT: InvokeStaticOrDirect 1125 /// CHECK-NOT: ConstructorFence 1126 /// CHECK-NOT: InstanceFieldSet 1127 constructDerivedInSecondDex()1128 public static int constructDerivedInSecondDex() { 1129 DerivedInSecondDex d = new DerivedInSecondDex(); 1130 return d.intField; 1131 } 1132 1133 /// CHECK-START: int Main.constructDerivedInSecondDex(int) inliner (before) 1134 /// CHECK-DAG: <<Value:i\d+>> ParameterValue 1135 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1136 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 1137 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:DerivedInSecondDex.<init> 1138 1139 /// CHECK-START: int Main.constructDerivedInSecondDex(int) inliner (after) 1140 /// CHECK-DAG: <<Value:i\d+>> ParameterValue 1141 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1142 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 1143 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:DerivedInSecondDex.<init> 1144 1145 /// CHECK-START: int Main.constructDerivedInSecondDex(int) inliner (after) 1146 /// CHECK: ConstructorFence 1147 /// CHECK-NOT: ConstructorFence 1148 /// CHECK-NOT: InstanceFieldSet 1149 constructDerivedInSecondDex(int intValue)1150 public static int constructDerivedInSecondDex(int intValue) { 1151 DerivedInSecondDex d = new DerivedInSecondDex(intValue); 1152 return d.intField; 1153 } 1154 1155 /// CHECK-START: int Main.constructDerivedInSecondDexWith0() inliner (before) 1156 /// CHECK-DAG: <<Value:i\d+>> IntConstant 0 1157 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1158 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 1159 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:DerivedInSecondDex.<init> 1160 1161 /// CHECK-START: int Main.constructDerivedInSecondDexWith0() inliner (after) 1162 /// CHECK-DAG: <<Value:i\d+>> IntConstant 0 1163 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1164 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 1165 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:DerivedInSecondDex.<init> 1166 1167 /// CHECK-START: int Main.constructDerivedInSecondDexWith0() inliner (after) 1168 /// CHECK: ConstructorFence 1169 /// CHECK-NOT: ConstructorFence 1170 /// CHECK-NOT: InstanceFieldSet 1171 constructDerivedInSecondDexWith0()1172 public static int constructDerivedInSecondDexWith0() { 1173 DerivedInSecondDex d = new DerivedInSecondDex(0); 1174 return d.intField; 1175 } 1176 1177 /// CHECK-START: int Main.constructDerivedInSecondDex(long) inliner (before) 1178 /// CHECK-DAG: <<Value:j\d+>> ParameterValue 1179 /// CHECK-DAG: <<Obj:l\d+>> NewInstance 1180 // Note: The ArtMethod* (typed as int or long) is optional after sharpening. 1181 /// CHECK-DAG: InvokeStaticOrDirect [<<Obj>>,<<Value>>{{(,[ij]\d+)?}}] method_name:DerivedInSecondDex.<init> 1182 1183 /// CHECK-START: int Main.constructDerivedInSecondDex(long) inliner (after) 1184 /// CHECK: ConstructorFence 1185 /// CHECK-NOT: InvokeStaticOrDirect 1186 /// CHECK-NOT: ConstructorFence 1187 /// CHECK-NOT: InstanceFieldSet 1188 constructDerivedInSecondDex(long placeholder)1189 public static int constructDerivedInSecondDex(long placeholder) { 1190 DerivedInSecondDex d = new DerivedInSecondDex(placeholder); 1191 return d.intField; 1192 } 1193 main(String[] args)1194 public static void main(String[] args) throws Exception { 1195 Second s = new Second(); 1196 1197 // Replaced NOP pattern. 1198 staticNop(); 1199 nop(s); 1200 // Not replaced NOP pattern. 1201 staticNopNeverInline(); 1202 // Replaced "return arg" pattern. 1203 assertEquals("arbitrary string", staticReturnArg2("arbitrary string")); 1204 assertEquals(4321L, returnArg1(s, 4321L)); 1205 // Replaced "return const" pattern. 1206 assertEquals(9, staticReturn9()); 1207 assertEquals(7, return7(s)); 1208 assertEquals(42.0f, return42f(s)); 1209 assertEquals(null, staticReturnNull()); 1210 assertEquals(null, returnNull(s)); 1211 // Replaced IGET pattern. 1212 assertEquals(42, getInt(s)); 1213 assertEquals(-42.0, getDouble(s)); 1214 assertEquals(null, getObject(s)); 1215 assertEquals("placeholder", getString(s)); 1216 // Not replaced IGET pattern. 1217 assertEquals(42, staticGetInt(s)); 1218 assertEquals(-42.0, getDoubleFromParam(s)); 1219 // SGET. 1220 assertEquals(4242, getStaticInt(s)); 1221 // Replaced IPUT pattern. 1222 assertEquals(111L, setLong(s, 111L)); 1223 assertEquals(345L, setLongReturnArg2(s, 222L, 123)); 1224 // Not replaced IPUT pattern. 1225 assertEquals(222L, staticSetLong(s, 222L)); 1226 assertEquals(333L, setLongThroughParam(s, 333L)); 1227 // SPUT. 1228 assertEquals(-11.5f, setStaticFloat(s, -11.5f)); 1229 1230 if (newObject() == null) { 1231 throw new AssertionError("new Object() cannot be null."); 1232 } 1233 1234 assertEquals(0.0, constructBase()); 1235 assertEquals(42.0, constructBase(42)); 1236 assertEquals(0.0, constructBaseWith0()); 1237 assertEquals("something", constructBase("something")); 1238 assertEquals(null, constructBaseWithNullString()); 1239 assertEquals(11.0, constructBase(11.0, new Object())); 1240 assertEquals(-12.0, constructBase(12.0, null)); 1241 assertEquals(30.0, constructBase(17, 13.0, new Object())); 1242 assertEquals(-34.0, constructBase(19, 15.0, null)); 1243 assertEquals(-22.5, constructBaseWith0DoubleNull(22.5)); 1244 assertEquals(-8.0, constructBase(2, 14.0, null, null)); 1245 assertEquals(-64.0, constructBase(4, 28.0, null, "placeholder")); 1246 assertEquals(13.0, constructBase(24, 2.0, new Object(), null)); 1247 assertEquals(30.0, constructBase(11, 4.0, new Object(), "placeholder")); 1248 assertEquals(43.0, constructBase(43.0)); 1249 assertEquals(0.0, constructBaseWith0d()); 1250 assertEquals(1.0, constructBase(new Object())); 1251 assertEquals(-1.0, constructBase((Object) null)); 1252 assertEquals(123.0, constructBase(123, 65L)); 1253 1254 assertEquals(0.0, constructDerived()); 1255 assertEquals(73.0, constructDerived(73)); 1256 assertEquals(0.0, constructDerivedWith0()); 1257 assertEquals(null, constructDerived("something else")); 1258 assertEquals(18.0, constructDerived(18.0)); 1259 assertEquals(0.0, constructDerivedWith0d()); 1260 assertEquals(-7.0, constructDerived(5, 7.0, new Object())); 1261 assertEquals(-4.0, constructDerived(9, 4.0, null)); 1262 assertEquals(0.0, constructDerived(1, 9.0, null, null)); 1263 assertEquals(0.0, constructDerived(2, 8.0, null, "placeholder")); 1264 assertEquals(0.0, constructDerived(3, 7.0, new Object(), null)); 1265 assertEquals(0.0, constructDerived(4, 6.0, new Object(), "placeholder")); 1266 assertEquals(17.0, constructDerived(17.0f)); 1267 assertEquals(-5.5, constructDerived(6, -7.0, new Object(), 6.5f)); 1268 1269 assertEquals(0, constructBaseWithFinalField()); 1270 assertEquals(77, constructBaseWithFinalField(77)); 1271 assertEquals(0, constructBaseWithFinalFieldWith0()); 1272 assertEquals(0.0, constructDerivedWithFinalField()); 1273 assertEquals(-33.0, constructDerivedWithFinalField(-33)); 1274 assertEquals(0.0, constructDerivedWithFinalFieldWith0()); 1275 assertEquals(-44.0, constructDerivedWithFinalField(-44.0)); 1276 assertEquals(0.0, constructDerivedWithFinalFieldWith0d()); 1277 assertEquals(88, constructDerivedWithFinalField(22, 66.0)); 1278 assertEquals(0.0, constructDerivedWithFinalFieldWith0And0d()); 1279 1280 assertEquals(0, constructDerivedInSecondDex()); 1281 assertEquals(123, constructDerivedInSecondDex(123)); 1282 assertEquals(0, constructDerivedInSecondDexWith0()); 1283 assertEquals(0, constructDerivedInSecondDex(7L)); 1284 1285 try { 1286 localStaticNopAndThrow(); 1287 throw new Error("Unreachable"); 1288 } catch (ExpectedError expected) {} 1289 } 1290 assertEquals(int expected, int actual)1291 private static void assertEquals(int expected, int actual) { 1292 if (expected != actual) { 1293 throw new AssertionError("Wrong result: " + expected + " != " + actual); 1294 } 1295 } 1296 assertEquals(float expected, float actual)1297 private static void assertEquals(float expected, float actual) { 1298 if (expected != actual) { 1299 throw new AssertionError("Wrong result: " + expected + " != " + actual); 1300 } 1301 } 1302 assertEquals(double expected, double actual)1303 private static void assertEquals(double expected, double actual) { 1304 if (expected != actual) { 1305 throw new AssertionError("Wrong result: " + expected + " != " + actual); 1306 } 1307 } 1308 assertEquals(Object expected, Object actual)1309 private static void assertEquals(Object expected, Object actual) { 1310 if (expected != actual && (expected == null || !expected.equals(actual))) { 1311 throw new AssertionError("Wrong result: " + expected + " != " + actual); 1312 } 1313 } 1314 } 1315