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