CACAO
ifconv.cpp
Go to the documentation of this file.
1 /* src/vm/jit/optimizing/ifconv.c - if-conversion
2 
3  Copyright (C) 1996-2014
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
26 
27 
28 #include "config.h"
29 
30 #include <assert.h>
31 
32 #include "vm/types.hpp"
33 
34 #include "vm/method.hpp"
35 #include "vm/vm.hpp"
36 
38 #include "vm/jit/jit.hpp"
39 #include "vm/jit/reg.hpp"
40 #include "vm/jit/show.hpp"
41 
43 
44 /* patterns for a total number of 3 instructions ******************************/
45 
46 #define IFCONV_PATTERN_3_SIZE sizeof(ifconv_pattern_3) / (sizeof(s4) * 3 * 2)
47 
48 static s4 ifconv_pattern_3[][2][3] = {
49  /* PATTERN 1 */
50 
51  {
52  {
54  ICMD_GOTO,
55 
57  },
58  {
60  ICMD_NOP,
61 
63  }
64  },
65 };
66 
67 
68 /* patterns for a total number of 4 instructions ******************************/
69 
70 #define IFCONV_PATTERN_4_SIZE sizeof(ifconv_pattern_4) / (sizeof(s4) * 4 * 2)
71 
72 static s4 ifconv_pattern_4[][2][4] = {
73  /* PATTERN 1 */
74 
75  {
76  {
79 
81  ICMD_IRETURN
82  },
83  {
85  ICMD_NOP,
86 
89  }
90  },
91 };
92 
93 
94 /* ifconv_condition_complement *************************************************
95 
96  Table of conditions and their complement. Index with:
97 
98  (ICMD_IFxx - ICMD_IFEQ)
99 
100  ATTENTION: Don't change order! It depends on the Java bytecode opcode!
101 
102 *******************************************************************************/
103 #if 0
104 static s4 ifconv_condition_complement[6] = {
105  /* !ICMD_IFEQ */ ICMD_IFNE,
106  /* !ICMD_IFNE */ ICMD_IFEQ,
107  /* !ICMD_IFLT */ ICMD_IFGE,
108  /* !ICMD_IFGE */ ICMD_IFLT,
109  /* !ICMD_IFGT */ ICMD_IFLE,
110  /* !ICMD_IFLE */ ICMD_IFGT,
111 };
112 #endif
113 
114 
115 /* ifconv_static ***************************************************************
116 
117  Does if-conversion with static data based on pattern matching.
118 
119 *******************************************************************************/
120 
121 static void check(jitdata *jd, basicblock *bptr);
122 
124 {
125  basicblock *bptr;
126  instruction *iptr;
127  instruction *tiptr;
128  s4 bcount;
129  s4 icount = 0;
130  s4 *pattern = NULL;
131  s4 patternsize = 0;
132  s4 *p;
133  ICMD opcode;
134  u2 condition;
135  //u2 complement;
136  s4 i = 0;
137  s4 j;
138 
139  /* get required compiler data */
140 
141 #if !defined(NDEBUG)
142  methodinfo *m = jd->m;
143 #endif
144 
145  /* iterate over all basic blocks */
146 
147  bptr = jd->basicblocks;
148  bcount = jd->basicblockcount;
149 
150  for (; bcount >= 0; bcount--, bptr++) {
151  /* Deleted basic blocks are just skipped. */
152 
153  if (bptr->state == basicblock::DELETED)
154  continue;
155 
156  /* We need at least 3 basic blocks including the current one. */
157 
158  if (bcount < 3)
159  continue;
160 
161  /* Only look at the last instruction of the current basic
162  block. All conditional branch instructions are suitable
163  for if-conversion. */
164 
165  iptr = bptr->iinstr + bptr->icount - 1;
166 
167  switch (iptr->opc) {
168  case ICMD_IFNULL:
169  case ICMD_IFNONNULL:
170 
171  case ICMD_IF_ICMPEQ:
172  case ICMD_IF_ICMPNE:
173  case ICMD_IF_ICMPLT:
174  case ICMD_IF_ICMPGE:
175  case ICMD_IF_ICMPGT:
176  case ICMD_IF_ICMPLE:
177 
178  case ICMD_IFEQ:
179  case ICMD_IFNE:
180  case ICMD_IFLT:
181  case ICMD_IFGE:
182  case ICMD_IFGT:
183  case ICMD_IFLE:
184 
185  case ICMD_LCMP:
186 
187  case ICMD_IF_LEQ:
188  case ICMD_IF_LNE:
189  case ICMD_IF_LLT:
190  case ICMD_IF_LGE:
191  case ICMD_IF_LGT:
192  case ICMD_IF_LLE:
193 
194  case ICMD_IF_LCMPEQ:
195  case ICMD_IF_LCMPNE:
196  case ICMD_IF_LCMPLT:
197  case ICMD_IF_LCMPGE:
198  case ICMD_IF_LCMPGT:
199  case ICMD_IF_LCMPLE:
200 
201  case ICMD_IF_ACMPEQ:
202  case ICMD_IF_ACMPNE:
203  /* basic blocks can only have 1 predecessor */
204 
205  if ((bptr[1].predecessorcount != 1) ||
206  (bptr[2].predecessorcount != 1))
207  break;
208 
209  check(jd, bptr);
210 
211  /* only use a fixed size of instructions */
212 
213  icount = bptr[1].icount + bptr[2].icount;
214 
215  /* we only convert less than or equal 4 instructions */
216 
217  if (icount > 4)
218  break;
219 
220  /* check which pattern to use */
221 
222  switch (icount) {
223  case 2:
224  /* just skip basic blocks with length 1 */
225 
226  pattern = NULL;
227  patternsize = 0;
228  break;
229 
230  case 3:
231  pattern = (s4 *) ifconv_pattern_3;
232  patternsize = IFCONV_PATTERN_3_SIZE;
233  break;
234 
235  case 4:
236  pattern = (s4 *) ifconv_pattern_4;
237  patternsize = IFCONV_PATTERN_4_SIZE;
238  break;
239 
240  default:
241  /* keep compiler happy */
242 
243  pattern = NULL;
244  patternsize = 0;
245 
246  /* that should not happen */
247 
248  vm_abort("ifconv_static: invalid instruction count %d", icount);
249  }
250 
251  /* Iterate over all patterns of the given pattern. */
252 
253  for (i = 0; i < patternsize; i++) {
254  /* Check the first and the second basic block at the
255  same time. The instructions _MUST NOT_ be
256  reordered in the array before. */
257 
258  tiptr = bptr[1].iinstr;
259 
260  for (j = 0; j < icount; j++, tiptr++) {
261  /* get the opcode */
262 
263  p = pattern + (icount * 2 * i) + (icount * 0) + j;
264 
265  opcode = (ICMD) *p;
266 
267  if (tiptr->opc != opcode)
268  goto nomatch;
269  }
270 
271  /* found a matching pattern */
272 
273 #if !defined(NDEBUG)
274  method_println(m);
275 #if 0
276  show_basicblock(jd, &bptr[0]);
277  show_basicblock(jd, &bptr[1]);
278  show_basicblock(jd, &bptr[2]);
279  show_basicblock(jd, &bptr[3]);
280 #endif
281 #endif
282 
283  /* check the condition */
284 
285  switch (iptr->opc) {
286  case ICMD_IFEQ:
287  case ICMD_IF_ICMPEQ:
288  case ICMD_IF_LEQ:
289  case ICMD_IF_LCMPEQ:
290  case ICMD_IF_ACMPEQ:
291  case ICMD_IFNULL:
292  condition = ICMD_IFEQ;
293  break;
294 
295  case ICMD_IFNE:
296  case ICMD_IF_ICMPNE:
297  case ICMD_IF_LNE:
298  case ICMD_IF_LCMPNE:
299  case ICMD_IF_ACMPNE:
300  case ICMD_IFNONNULL:
301  condition = ICMD_IFNE;
302  break;
303 
304  case ICMD_IFLT:
305  case ICMD_IF_ICMPLT:
306  case ICMD_IF_LLT:
307  case ICMD_IF_LCMPLT:
308  condition = ICMD_IFLT;
309  break;
310 
311  case ICMD_IFGE:
312  case ICMD_IF_ICMPGE:
313  case ICMD_IF_LGE:
314  case ICMD_IF_LCMPGE:
315  condition = ICMD_IFGE;
316  break;
317 
318  case ICMD_IFGT:
319  case ICMD_IF_ICMPGT:
320  case ICMD_IF_LGT:
321  case ICMD_IF_LCMPGT:
322  condition = ICMD_IFGT;
323  break;
324 
325  case ICMD_IFLE:
326  case ICMD_IF_ICMPLE:
327  case ICMD_IF_LLE:
328  case ICMD_IF_LCMPLE:
329  condition = ICMD_IFLE;
330  break;
331 
332  case ICMD_LCMP:
333  assert(0);
334 
335  default:
336  /* keep compiler happy */
337 
338  condition = 0;
339 
340  vm_abort("ifconv_static: invalid opcode: %d", iptr->opc);
341  }
342 
343  /* get the condition array index */
344 
345  //complement = ifconv_condition_complement[condition - ICMD_IFEQ];
346 
347  /* Set the new instructions, first basic block 1... */
348 
349  tiptr = bptr[1].iinstr;
350  j = 0;
351 
352  for (; j < bptr[1].icount; j++, tiptr++) {
353  /* get the replacing opcode */
354 
355  p = pattern + (icount * 2 * i) + (icount * 1) + j;
356 
357  opcode = (ICMD) *p;
358 
359  /* If we add a NOP, skip the current instruction
360  and set the stack of the next instruction
361  to the previous one. */
362 
363  if (opcode == ICMD_NOP) {
364  tiptr[1].dst = tiptr[-1].dst;
365  }
366 
367  /* For the first basic block we have to set the
368  complementary condition. */
369 
370 /* tiptr->opc = opcode | (complement << 8); */
371  tiptr->opc = opcode;
372  }
373 
374  /* ...then basic block 2. We split this step, as we
375  have to set different conditions in the blocks. */
376 
377  for (; j < bptr[1].icount + bptr[2].icount; j++, tiptr++) {
378  p = pattern + (icount * 2 * i) + (icount * 1) + j;
379 
380  /* For the first basic block we have to set the
381  complementary condition. */
382 
383  tiptr->opc = (ICMD) (*p | (condition << 8));
384 
385  /* if we add a NOP, set the stacks correctly */
386 
387  if (tiptr->opc == ICMD_NOP) {
388  assert(0);
389  }
390  }
391 
392  /* tag the conditional branch instruction as conditional */
393 
394  iptr->opc = (ICMD) (iptr->opc | (condition << 8));
395 
396  /* add the instructions to the current basic block */
397 
398  bptr->icount += icount;
399 
400 #if !defined(NDEBUG)
401  method_println(m);
402 #if 0
403  show_basicblock(jd, &bptr[0]);
404 #endif
405 #endif
406 
407  /* delete the 2 following basic blocks */
408 
409  bptr[1].state = basicblock::DELETED;
410  bptr[2].state = basicblock::DELETED;
411  bptr[1].icount = 0;
412  bptr[2].icount = 0;
413 
414  /* we had a match, exit this iteration */
415 
416  break;
417 
418  default:
419  nomatch:
420  ;
421  }
422  }
423  }
424 
425  /* everything's ok */
426 
427  return true;
428 }
429 
430 static void check(jitdata *jd, basicblock *bptr)
431 {
432 #if !defined(NDEBUG)
433  int pattern = 0;
434 
435  /* get required compiler data */
436 
437  methodinfo *m = jd->m;
438 
439  /*
440  generated by jikes.
441 
442  java.lang.reflect.Modifier.isPublic(I)Z
443 
444  [ ] L000(5 - 0) flags=1:
445  [ i00] 0 (line: 227) ICONST 0 (0x00000000)
446  [ l00 i00] 1 (line: 227) ILOAD 0
447  [ r15 i00] 2 (line: 227) IANDCONST 1 (0x00000001)
448  [ r15 i00] 3 (line: 227) NOP
449  [ i00] 4 (line: 227) IFEQ 0 (0x00000000) L002
450 
451  [ i00] L001(2 - 1) flags=1:
452  [ ] 0 (line: 227) POP
453  [ i00] 1 (line: 227) ICONST 1 (0x00000001)
454 
455  [ i00] L002(1 - 2) flags=1:
456  [ ] 0 (line: 227) IRETURN
457  */
458 
459  if ((bptr[1].icount == 2) &&
460  (bptr[1].iinstr[0].opc == ICMD_POP) &&
461  (bptr[1].iinstr[1].opc == ICMD_ICONST))
462  {
463  pattern = 1;
464  }
465 
466  /*
467  generated by ecj.
468 
469  java.util.Hashtable.isEmpty()Z PUBLIC SYNCHRONIZED
470 
471  [ ] L000(3 - 0) flags=1:
472  [ l00] 0 (line: 292) ALOAD 0
473  [ rdi] 1 (line: 292) GETFIELD 36, java.util.Hashtable.size (type I
474  )
475  [ ] 2 (line: 292) IFNE 0 (0x00000000) L002
476 
477  [ ] L001(2 - 1) flags=1:
478  [ rdi] 0 (line: 292) ICONST 1 (0x00000001)
479  [ ] 1 (line: 292) IRETURN
480 
481  [ ] L002(2 - 1) flags=1:
482  [ rdi] 0 (line: 292) ICONST 0 (0x00000000)
483  [ ] 1 (line: 292) IRETURN
484  */
485 
486  if ((bptr[1].icount == 2) &&
487  (bptr[1].iinstr[0].opc == ICMD_ICONST) &&
488  (bptr[1].iinstr[1].opc == ICMD_IRETURN) &&
489 
490  (bptr[2].icount == 2) &&
491  (bptr[2].iinstr[0].opc == ICMD_ICONST) &&
492  (bptr[2].iinstr[1].opc == ICMD_IRETURN))
493  {
494  pattern = 2;
495  }
496 
497  /*
498  this seems to be the most common and simplest if, check for all types
499  */
500 
501  /* xCONST */
502 
503  if ((bptr[1].icount == 2) &&
504  (bptr[1].iinstr[0].opc == ICMD_ICONST) &&
505  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
506 
507  (bptr[2].icount == 1) &&
508  (bptr[2].iinstr[0].opc == ICMD_ICONST))
509  {
510  pattern = 3;
511  }
512 
513  if ((bptr[1].icount == 2) &&
514  (bptr[1].iinstr[0].opc == ICMD_LCONST) &&
515  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
516 
517  (bptr[2].icount == 1) &&
518  (bptr[2].iinstr[0].opc == ICMD_LCONST))
519  {
520  pattern = 4;
521  }
522 
523  if ((bptr[1].icount == 2) &&
524  (bptr[1].iinstr[0].opc == ICMD_ACONST) &&
525  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
526 
527  (bptr[2].icount == 1) &&
528  (bptr[2].iinstr[0].opc == ICMD_ACONST))
529  {
530  pattern = 5;
531  }
532 
533  if ((bptr[1].icount == 2) &&
534  (bptr[1].iinstr[0].opc == ICMD_FCONST) &&
535  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
536 
537  (bptr[2].icount == 1) &&
538  (bptr[2].iinstr[0].opc == ICMD_FCONST))
539  {
540  pattern = 6;
541  }
542 
543  if ((bptr[1].icount == 2) &&
544  (bptr[1].iinstr[0].opc == ICMD_DCONST) &&
545  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
546 
547  (bptr[2].icount == 1) &&
548  (bptr[2].iinstr[0].opc == ICMD_DCONST))
549  {
550  pattern = 7;
551  }
552 
553  /* xLOAD */
554 
555 
556  if ((bptr[1].icount == 2) &&
557  (bptr[1].iinstr[0].opc == ICMD_ILOAD) &&
558  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
559 
560  (bptr[2].icount == 1) &&
561  (bptr[2].iinstr[0].opc == ICMD_ILOAD))
562  {
563  pattern = 8;
564  }
565 
566  if ((bptr[1].icount == 2) &&
567  (bptr[1].iinstr[0].opc == ICMD_LLOAD) &&
568  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
569 
570  (bptr[2].icount == 1) &&
571  (bptr[2].iinstr[0].opc == ICMD_LLOAD))
572  {
573  pattern = 9;
574  }
575 
576  if ((bptr[1].icount == 2) &&
577  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
578  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
579 
580  (bptr[2].icount == 1) &&
581  (bptr[2].iinstr[0].opc == ICMD_ALOAD))
582  {
583  pattern = 10;
584  }
585 
586  if ((bptr[1].icount == 2) &&
587  (bptr[1].iinstr[0].opc == ICMD_FLOAD) &&
588  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
589 
590  (bptr[2].icount == 1) &&
591  (bptr[2].iinstr[0].opc == ICMD_FLOAD))
592  {
593  pattern = 11;
594  }
595 
596  if ((bptr[1].icount == 2) &&
597  (bptr[1].iinstr[0].opc == ICMD_DLOAD) &&
598  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
599 
600  (bptr[2].icount == 1) &&
601  (bptr[2].iinstr[0].opc == ICMD_DLOAD))
602  {
603  pattern = 12;
604  }
605 
606  /* xCONST, GOTO - xLOAD */
607 
608  if ((bptr[1].icount == 2) &&
609  (bptr[1].iinstr[0].opc == ICMD_ICONST) &&
610  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
611 
612  (bptr[2].icount == 1) &&
613  (bptr[2].iinstr[0].opc == ICMD_ILOAD))
614  {
615  pattern = 13;
616  }
617 
618  if ((bptr[1].icount == 2) &&
619  (bptr[1].iinstr[0].opc == ICMD_LCONST) &&
620  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
621 
622  (bptr[2].icount == 1) &&
623  (bptr[2].iinstr[0].opc == ICMD_LLOAD))
624  {
625  pattern = 14;
626  }
627 
628  if ((bptr[1].icount == 2) &&
629  (bptr[1].iinstr[0].opc == ICMD_ACONST) &&
630  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
631 
632  (bptr[2].icount == 1) &&
633  (bptr[2].iinstr[0].opc == ICMD_ALOAD))
634  {
635  pattern = 15;
636  }
637 
638  if ((bptr[1].icount == 2) &&
639  (bptr[1].iinstr[0].opc == ICMD_FCONST) &&
640  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
641 
642  (bptr[2].icount == 1) &&
643  (bptr[2].iinstr[0].opc == ICMD_FLOAD))
644  {
645  pattern = 16;
646  }
647 
648  if ((bptr[1].icount == 2) &&
649  (bptr[1].iinstr[0].opc == ICMD_DCONST) &&
650  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
651 
652  (bptr[2].icount == 1) &&
653  (bptr[2].iinstr[0].opc == ICMD_DLOAD))
654  {
655  pattern = 17;
656  }
657 
658  /* xLOAD, GOTO - xCONST */
659 
660  if ((bptr[1].icount == 2) &&
661  (bptr[1].iinstr[0].opc == ICMD_ILOAD) &&
662  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
663 
664  (bptr[2].icount == 1) &&
665  (bptr[2].iinstr[0].opc == ICMD_ICONST))
666  {
667  pattern = 18;
668  }
669 
670  if ((bptr[1].icount == 2) &&
671  (bptr[1].iinstr[0].opc == ICMD_LLOAD) &&
672  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
673 
674  (bptr[2].icount == 1) &&
675  (bptr[2].iinstr[0].opc == ICMD_LCONST))
676  {
677  pattern = 19;
678  }
679 
680  if ((bptr[1].icount == 2) &&
681  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
682  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
683 
684  (bptr[2].icount == 1) &&
685  (bptr[2].iinstr[0].opc == ICMD_ACONST))
686  {
687  pattern = 20;
688  }
689 
690  if ((bptr[1].icount == 2) &&
691  (bptr[1].iinstr[0].opc == ICMD_FLOAD) &&
692  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
693 
694  (bptr[2].icount == 1) &&
695  (bptr[2].iinstr[0].opc == ICMD_FCONST))
696  {
697  pattern = 21;
698  }
699 
700  if ((bptr[1].icount == 2) &&
701  (bptr[1].iinstr[0].opc == ICMD_DLOAD) &&
702  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
703 
704  (bptr[2].icount == 1) &&
705  (bptr[2].iinstr[0].opc == ICMD_DCONST))
706  {
707  pattern = 22;
708  }
709 
710  /*
711  check for different ISTORE destinations or handle them properly
712  */
713 
714  if ((bptr[1].icount == 3) &&
715  (bptr[1].iinstr[0].opc == ICMD_ICONST) &&
716  (bptr[1].iinstr[1].opc == ICMD_ISTORE) &&
717  (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
718 
719  (bptr[2].icount == 2) &&
720  (bptr[2].iinstr[0].opc == ICMD_ICONST) &&
721  (bptr[2].iinstr[1].opc == ICMD_ISTORE))
722  {
723  pattern = 23;
724  }
725 
726  if ((bptr[1].icount == 3) &&
727  (bptr[1].iinstr[0].opc == ICMD_ILOAD) &&
728  (bptr[1].iinstr[1].opc == ICMD_ISTORE) &&
729  (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
730 
731  (bptr[2].icount == 2) &&
732  (bptr[2].iinstr[0].opc == ICMD_ILOAD) &&
733  (bptr[2].iinstr[1].opc == ICMD_ISTORE))
734  {
735  pattern = 24;
736  }
737 
738  if ((bptr[1].icount == 3) &&
739  (bptr[1].iinstr[0].opc == ICMD_ICONST) &&
740  (bptr[1].iinstr[1].opc == ICMD_ISTORE) &&
741  (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
742 
743  (bptr[2].icount == 2) &&
744  (bptr[2].iinstr[0].opc == ICMD_ILOAD) &&
745  (bptr[2].iinstr[1].opc == ICMD_ISTORE))
746  {
747  pattern = 25;
748  }
749 
750 
751  /* ALOAD, GETFIELD - ALOAD, GETFIELD */
752 
753  if ((bptr[1].icount == 3) &&
754  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
755  (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
756  (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
757 
758  (bptr[2].icount == 2) &&
759  (bptr[2].iinstr[0].opc == ICMD_ALOAD) &&
760  (bptr[2].iinstr[1].opc == ICMD_GETFIELD))
761  {
762  pattern = 26;
763  }
764 
765 
766  /* ALOAD, ICONST, PUTFIELD - ALOAD, ICONST, PUTFIELD */
767 
768  if ((bptr[1].icount == 4) &&
769  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
770  (bptr[1].iinstr[1].opc == ICMD_ICONST) &&
771  (bptr[1].iinstr[2].opc == ICMD_PUTFIELD) &&
772  (bptr[1].iinstr[3].opc == ICMD_GOTO) &&
773 
774  (bptr[2].icount == 3) &&
775  (bptr[2].iinstr[0].opc == ICMD_ALOAD) &&
776  (bptr[2].iinstr[1].opc == ICMD_ICONST) &&
777  (bptr[2].iinstr[2].opc == ICMD_PUTFIELD)
778  )
779  {
780  pattern = 27;
781  }
782 
783  if ((bptr[1].icount == 4) &&
784  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
785  (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
786  (bptr[1].iinstr[2].opc == ICMD_ASTORE) &&
787  (bptr[1].iinstr[3].opc == ICMD_GOTO) &&
788 
789  (bptr[2].icount == 3) &&
790  (bptr[2].iinstr[0].opc == ICMD_ALOAD) &&
791  (bptr[2].iinstr[1].opc == ICMD_GETFIELD) &&
792  (bptr[2].iinstr[2].opc == ICMD_ASTORE)
793  )
794  {
795  pattern = 28;
796  }
797 
798  if ((bptr[1].icount == 2) &&
799  (bptr[1].iinstr[0].opc == ICMD_GETSTATIC) &&
800  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
801 
802  (bptr[2].icount == 1) &&
803  (bptr[2].iinstr[0].opc == ICMD_GETSTATIC))
804  {
805  pattern = 29;
806  }
807 
808  if ((bptr[1].icount == 3) &&
809  (bptr[1].iinstr[0].opc == ICMD_GETSTATIC) &&
810  (bptr[1].iinstr[1].opc == ICMD_ASTORE) &&
811  (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
812 
813  (bptr[2].icount == 2) &&
814  (bptr[2].iinstr[0].opc == ICMD_GETSTATIC) &&
815  (bptr[2].iinstr[1].opc == ICMD_ASTORE))
816  {
817  pattern = 30;
818  }
819 
820  if ((bptr[1].icount == 2) &&
821  (bptr[1].iinstr[0].opc == ICMD_GETSTATIC) &&
822  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
823 
824  (bptr[2].icount == 1) &&
825  (bptr[2].iinstr[0].opc == ICMD_ALOAD))
826  {
827  pattern = 31;
828  }
829 
830  if ((bptr[1].icount == 2) &&
831  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
832  (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
833 
834  (bptr[2].icount == 1) &&
835  (bptr[2].iinstr[0].opc == ICMD_GETSTATIC))
836  {
837  pattern = 32;
838  }
839 
840 
841  if ((bptr[1].icount == 3) &&
842  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
843  (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
844  (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
845 
846  (bptr[2].icount == 1) &&
847  (bptr[2].iinstr[0].opc == ICMD_ICONST))
848  {
849  pattern = 33;
850  }
851 
852  if ((bptr[1].icount == 3) &&
853  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
854  (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
855  (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
856 
857  (bptr[2].icount == 1) &&
858  (bptr[2].iinstr[0].opc == ICMD_LCONST))
859  {
860  pattern = 34;
861  }
862 
863  if ((bptr[1].icount == 3) &&
864  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
865  (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
866  (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
867 
868  (bptr[2].icount == 1) &&
869  (bptr[2].iinstr[0].opc == ICMD_ACONST))
870  {
871  pattern = 35;
872  }
873 
874  if ((bptr[1].icount == 3) &&
875  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
876  (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
877  (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
878 
879  (bptr[2].icount == 1) &&
880  (bptr[2].iinstr[0].opc == ICMD_ILOAD))
881  {
882  pattern = 36;
883  }
884 
885  if ((bptr[1].icount == 3) &&
886  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
887  (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
888  (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
889 
890  (bptr[2].icount == 1) &&
891  (bptr[2].iinstr[0].opc == ICMD_LLOAD))
892  {
893  pattern = 37;
894  }
895 
896  if ((bptr[1].icount == 3) &&
897  (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
898  (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
899  (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
900 
901  (bptr[2].icount == 1) &&
902  (bptr[2].iinstr[0].opc == ICMD_ALOAD))
903  {
904  pattern = 38;
905  }
906 
907  /*
908 
909  CHECK 3 : (BB: 0) IFEQ javax.swing.plaf.basic.BasicInternalFrameTitlePane.paintTitleBackground(Ljava/awt/Graphics;)V PROTECTED
910  [ ? ? ? ? ? ] L001(instruction count: 4, predecessors: 1):
911  [ ? ? ? ? ? ] 0 (line: 909) ALOAD 0
912  [ ? ? ? ? ? ] 1 (line: 909) GETFIELD (NOT RESOLVED), javax.swing.plaf.basic.BasicInternalFrameTitlePane.selectedTitleColor (type Ljava/awt/Color;)
913  [ ? ? ? ? ? ] 2 (line: 909) ASTORE 4
914  [ ? ? ? ? ? ] 3 (line: 909) GOTO op1=41
915  [ ? ? ? ? ? ] L002(instruction count: 3, predecessors: 1):
916  [ ? ? ? ? ? ] 0 (line: 911) ALOAD 0
917  [ ? ? ? ? ? ] 1 (line: 911) GETFIELD (NOT RESOLVED), javax.swing.plaf.basic.BasicInternalFrameTitlePane.notSelectedTitleColor (type Ljava/awt/Color;)
918  [ ? ? ? ? ? ] 2 (line: 911) ASTORE 4
919 
920 
921  CHECK 3 : (BB: 3) IFEQ javax.swing.plaf.basic.BasicTreeUI$MouseHandler.mousePressed(Ljava/awt/event/MouseEvent;)V PUBLIC
922  [ ? ? ? ? ? ] L004(instruction count: 4, predecessors: 1):
923  [ ? ? ? ? ? ] 0 (line: 2244) ACONST 0x3602d30, String = "Tree.openIcon"
924  [ ? ? ? ? ? ] 1 (line: 2244) INVOKESTATIC (NOT RESOLVED) javax.swing.UIManager.getIcon(Ljava/lang/Object;)Ljavax/swing/Icon;
925  [ ? ? ? ? ? ] 2 (line: 2244) ASTORE 8
926  [ ? ? ? ? ? ] 3 (line: 2244) GOTO op1=155
927  [ ? ? ? ? ? ] L005(instruction count: 3, predecessors: 1):
928  [ ? ? ? ? ? ] 0 (line: 2246) ACONST 0x3602e00, String = "Tree.closedIcon"
929  [ ? ? ? ? ? ] 1 (line: 2246) INVOKESTATIC (NOT RESOLVED) javax.swing.UIManager.getIcon(Ljava/lang/Object;)Ljavax/swing/Icon;
930  [ ? ? ? ? ? ] 2 (line: 2246) ASTORE 8
931 
932 
933  CHECK 3 : (BB: 2) IFEQ javax.naming.CompoundName.initializeSyntax()V PRIVATE FINAL
934  [ ? ? ? ? ] L003(instruction count: 4, predecessors: 1):
935  [ ? ? ? ? ] 0 (line: 445) ALOAD 0
936  [ ? ? ? ? ] 1 (line: 445) ICONST 1 (0x00000001)
937  [ ? ? ? ? ] 2 (line: 445) PUTFIELD (NOT RESOLVED), javax.naming.CompoundName.direction (type I)
938  [ ? ? ? ? ] 3 (line: 445) GOTO op1=51
939  [ ? ? ? ? ] L004(instruction count: 3, predecessors: 1):
940  [ ? ? ? ? ] 0 (line: 449) ALOAD 0
941  [ ? ? ? ? ] 1 (line: 449) ICONST 0 (0x00000000)
942  [ ? ? ? ? ] 2 (line: 449) PUTFIELD (NOT RESOLVED), javax.naming.CompoundName.direction (type I)
943 
944 
945  CHECK 3 : (BB: 15) IFNE java.awt.Scrollbar.setValues(IIII)V PUBLIC SYNCHRONIZED
946  [ ? ? ? ? ? ] L016(instruction count: 4, predecessors: 1):
947  [ ? ? ? ? ? ] 0 (line: 371) ALOAD 0
948  [ ? ? ? ? ? ] 1 (line: 371) ICONST 1 (0x00000001)
949  [ ? ? ? ? ? ] 2 (line: 371) PUTFIELD (NOT RESOLVED), java.awt.Scrollbar.lineIncrement (type I)
950  [ ? ? ? ? ? ] 3 (line: 371) GOTO op1=152
951  [ ? ? ? ? ? ] L017(instruction count: 3, predecessors: 1):
952  [ ? ? ? ? ? ] 0 (line: 373) ALOAD 0
953  [ ? ? ? ? ? ] 1 (line: 373) ILOAD 6
954  [ ? ? ? ? ? ] 2 (line: 373) PUTFIELD (NOT RESOLVED), java.awt.Scrollbar.lineIncrement (type I)
955 
956 
957  CHECK 3 : (BB: 1) IFEQ javax.swing.JInternalFrame.setIcon(Z)V PUBLIC
958  [ ? ? ? ? ] L002(instruction count: 4, predecessors: 1):
959  [ ? ? ? ? ] 0 (line: 1395) ALOAD 0
960  [ ? ? ? ? ] 1 (line: 1395) ICONST 25552 (0x000063d0)
961  [ ? ? ? ? ] 2 (line: 1395) INVOKEVIRTUAL (NOT RESOLVED) javax.swing.JInternalFrame.fireInternalFrameEvent(I)V
962  [ ? ? ? ? ] 3 (line: 1395) GOTO op1=61
963  [ ? ? ? ? ] L003(instruction count: 3, predecessors: 1):
964  [ ? ? ? ? ] 0 (line: 1397) ALOAD 0
965  [ ? ? ? ? ] 1 (line: 1397) ICONST 25553 (0x000063d1)
966  [ ? ? ? ? ] 2 (line: 1397) INVOKEVIRTUAL (NOT RESOLVED) javax.swing.JInternalFrame.fireInternalFrameEvent(I)V
967 
968  */
969 
970  if (pattern != 0) {
971  printf("PATTERN %02d: (BB: %3d) ", pattern, jd->basicblockcount - bptr->nr);
972  method_println(m);
973 
974  /* if (pattern == 27) { */
975  /* show_basicblock(m, cd, &bptr[1]); */
976  /* show_basicblock(m, cd, &bptr[2]); */
977  /* } */
978 
979  fflush(stdout);
980 
981  } else {
982  if ((bptr[1].icount == 2) &&
983  (bptr[2].icount == 1) &&
984 
985  (bptr[1].iinstr[1].opc == ICMD_GOTO))
986  {
987  printf("CHECK 1 : (BB: %3d) ", jd->basicblockcount - bptr->nr);
988  method_println(m);
989 #if 0
990  show_basicblock(jd, &bptr[1]);
991  show_basicblock(jd, &bptr[2]);
992 #endif
993  fflush(stdout);
994  }
995 
996  if ((bptr[1].icount == 3) &&
997  (bptr[2].icount == 2) &&
998 
999  (bptr[1].iinstr[2].opc == ICMD_GOTO))
1000  {
1001  printf("CHECK 2 : (BB: %3d) ", jd->basicblockcount - bptr->nr);
1002  method_println(m);
1003 #if 0
1004  show_basicblock(jd, &bptr[1]);
1005  show_basicblock(jd, &bptr[2]);
1006 #endif
1007  fflush(stdout);
1008  }
1009 
1010  if ((bptr[1].icount == 4) &&
1011  (bptr[2].icount == 3) &&
1012 
1013  (bptr[1].iinstr[3].opc == ICMD_GOTO))
1014  {
1015  printf("CHECK 3 : (BB: %3d) ", jd->basicblockcount - bptr->nr);
1016  method_println(m);
1017 #if 0
1018  show_basicblock(jd, &bptr[1]);
1019  show_basicblock(jd, &bptr[2]);
1020 #endif
1021  fflush(stdout);
1022  }
1023 
1024  if ((bptr[1].icount == 3) &&
1025  (bptr[2].icount == 1) &&
1026 
1027  (bptr[1].iinstr[2].opc == ICMD_GOTO))
1028  {
1029  printf("CHECK 4 : (BB: %3d) ", jd->basicblockcount - bptr->nr);
1030  method_println(m);
1031 #if 0
1032  show_basicblock(jd, &bptr[1]);
1033  show_basicblock(jd, &bptr[2]);
1034 #endif
1035  fflush(stdout);
1036  }
1037  }
1038 #endif /* !defined(NDEBUG) */
1039 }
1040 
1041 
1042 /*
1043  * These are local overrides for various environment variables in Emacs.
1044  * Please do not remove this and leave it at the end of the file, where
1045  * Emacs will automagically detect them.
1046  * ---------------------------------------------------------------------
1047  * Local variables:
1048  * mode: c++
1049  * indent-tabs-mode: t
1050  * c-basic-offset: 4
1051  * tab-width: 4
1052  * End:
1053  * vim:noexpandtab:sw=4:ts=4:
1054  */
#define IFCONV_PATTERN_3_SIZE
Definition: ifconv.cpp:46
basicblock * basicblocks
Definition: jit.hpp:141
Definition: jit.hpp:126
State state
Definition: jit.hpp:313
instruction * iinstr
Definition: jit.hpp:319
s4 icount
Definition: jit.hpp:318
void vm_abort(const char *text,...)
Definition: vm.cpp:2586
static s4 ifconv_pattern_4[][2][4]
Definition: ifconv.cpp:72
void show_basicblock(jitdata *jd, basicblock *bptr, int stage)
Definition: show.cpp:449
dst_operand_t dst
uint16_t u2
Definition: types.hpp:43
void method_println(methodinfo *m)
Definition: method.cpp:1218
MIIterator i
int32_t s4
Definition: types.hpp:45
ICMD
Definition: icmd.hpp:37
#define IFCONV_PATTERN_4_SIZE
Definition: ifconv.cpp:70
methodinfo * m
Definition: jit.hpp:127
static s4 ifconv_pattern_3[][2][3]
Definition: ifconv.cpp:48
static void check(jitdata *jd, basicblock *bptr)
Definition: ifconv.cpp:430
s4 nr
Definition: jit.hpp:312
s4 basicblockcount
Definition: jit.hpp:144
bool ifconv_static(jitdata *jd)
Definition: ifconv.cpp:123
#define printf(...)
Definition: ssa2.cpp:40