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