cb032b8e66bc46937643a2a908ed81471fd544b0
[cacao.git] / src / vm / jit / optimizing / ifconv.c
1 /* src/vm/jit/ifconv/ifconv.c - if-conversion
2
3    Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    $Id: stack.c 4455 2006-02-06 01:02:59Z edwin $
26
27 */
28
29
30 #include "config.h"
31
32 #include <assert.h>
33
34 #include "vm/types.h"
35
36 #include "vm/vm.h"
37
38 #include "vm/jit/codegen-common.h"
39 #include "vm/jit/jit.h"
40 #include "vm/jit/reg.h"
41 #include "vm/jit/show.h"
42
43 #include "vmcore/method.h"
44
45
46 /* patterns for a total number of 3 instructions ******************************/
47
48 #define IFCONV_PATTERN_3_SIZE    sizeof(ifconv_pattern_3) / (sizeof(s4) * 3 * 2)
49
50 static s4 ifconv_pattern_3[][2][3] = {
51         /* PATTERN 1 */
52
53         {
54                 {
55                         ICMD_ICONST,
56                         ICMD_GOTO,
57
58                         ICMD_ICONST,
59                 },
60                 {
61                         ICMD_ICONST,
62                         ICMD_NOP,
63
64                         ICMD_ICONST,
65                 }
66         },
67 };
68
69
70 /* patterns for a total number of 4 instructions ******************************/
71
72 #define IFCONV_PATTERN_4_SIZE    sizeof(ifconv_pattern_4) / (sizeof(s4) * 4 * 2)
73
74 static s4 ifconv_pattern_4[][2][4] = {
75         /* PATTERN 1 */
76
77         {
78                 {
79                         ICMD_ICONST,
80                         ICMD_IRETURN,
81
82                         ICMD_ICONST,
83                         ICMD_IRETURN
84                 },
85                 {
86                         ICMD_ICONST,
87                         ICMD_NOP,
88
89                         ICMD_ICONST,
90                         ICMD_IRETURN
91                 }
92         },
93 };
94
95
96 /* ifconv_condition_complement *************************************************
97
98    Table of conditions and their complement.  Index with:
99
100    (ICMD_IFxx - ICMD_IFEQ)
101
102    ATTENTION: Don't change order!  It depends on the Java bytecode opcode!
103
104 *******************************************************************************/
105
106 static s4 ifconv_condition_complement[6] = {
107         /* !ICMD_IFEQ */    ICMD_IFNE,
108         /* !ICMD_IFNE */    ICMD_IFEQ,
109         /* !ICMD_IFLT */    ICMD_IFGE,
110         /* !ICMD_IFGE */    ICMD_IFLT,
111         /* !ICMD_IFGT */    ICMD_IFLE,
112         /* !ICMD_IFLE */    ICMD_IFGT,
113 };
114
115
116 /* ifconv_static ***************************************************************
117
118    Does if-conversion with static data based on pattern matching.
119
120 *******************************************************************************/
121
122 static void check(jitdata *jd, basicblock *bptr);
123
124 bool ifconv_static(jitdata *jd)
125 {
126         methodinfo  *m;
127         basicblock  *bptr;
128         instruction *iptr;
129         instruction *tiptr;
130         s4           bcount;
131         s4           icount;
132         s4          *pattern;
133         s4           patternsize;
134         s4          *p;
135         u2           opcode;
136         u2           condition;
137         u2           complement;
138         s4           i;
139         s4           j;
140
141         /* get required compiler data */
142
143         m  = jd->m;
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->flags == BBDELETED)
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 = *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 = *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 = *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 |= 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].flags = BBDELETED;
410                                 bptr[2].flags = BBDELETED;
411                                 bptr[1].icount = 0;
412                                 bptr[2].icount = 0;
413
414                                 /* we had a match, exit this iteration */
415
416                                 break;
417
418                         nomatch:
419                                 ;
420                         }
421                 }
422         }
423
424         /* everything's ok */
425
426         return true;
427 }
428
429 static void check(jitdata *jd, basicblock *bptr)
430 {
431         methodinfo *m;
432         int pattern = 0;
433
434         /* get required compiler data */
435
436         m  = jd->m;
437
438         /*
439           generated by jikes.
440
441           java.lang.reflect.Modifier.isPublic(I)Z
442
443           [            ] L000(5 - 0) flags=1:
444           [         i00]     0 (line:   227)  ICONST          0 (0x00000000)
445           [     l00 i00]     1 (line:   227)  ILOAD           0
446           [     r15 i00]     2 (line:   227)  IANDCONST       1 (0x00000001)
447           [     r15 i00]     3 (line:   227)  NOP            
448           [         i00]     4 (line:   227)  IFEQ            0 (0x00000000) L002
449
450           [         i00] L001(2 - 1) flags=1:
451           [            ]     0 (line:   227)  POP            
452           [         i00]     1 (line:   227)  ICONST          1 (0x00000001)
453
454           [         i00] L002(1 - 2) flags=1:
455           [            ]     0 (line:   227)  IRETURN        
456         */
457                                                                 
458         if ((bptr[1].icount == 2) &&
459                 (bptr[1].iinstr[0].opc == ICMD_POP) &&
460                 (bptr[1].iinstr[1].opc == ICMD_ICONST))
461                 {
462                         pattern = 1;
463                 }
464
465         /*
466           generated by ecj.
467
468           java.util.Hashtable.isEmpty()Z PUBLIC SYNCHRONIZED
469
470           [    ] L000(3 - 0) flags=1:
471           [ l00]     0 (line:   292)  ALOAD           0
472           [ rdi]     1 (line:   292)  GETFIELD        36, java.util.Hashtable.size (type I
473           )
474           [    ]     2 (line:   292)  IFNE            0 (0x00000000) L002
475
476           [    ] L001(2 - 1) flags=1:
477           [ rdi]     0 (line:   292)  ICONST          1 (0x00000001)
478           [    ]     1 (line:   292)  IRETURN        
479
480           [    ] L002(2 - 1) flags=1:
481           [ rdi]     0 (line:   292)  ICONST          0 (0x00000000)
482           [    ]     1 (line:   292)  IRETURN        
483         */
484
485         if ((bptr[1].icount == 2) &&
486                 (bptr[1].iinstr[0].opc == ICMD_ICONST) &&
487                 (bptr[1].iinstr[1].opc == ICMD_IRETURN) &&
488
489                 (bptr[2].icount == 2) &&
490                 (bptr[2].iinstr[0].opc == ICMD_ICONST) &&
491                 (bptr[2].iinstr[1].opc == ICMD_IRETURN))
492                 {
493                         pattern = 2;
494                 }
495
496         /*
497           this seems to be the most common and simplest if, check for all types
498         */
499
500         /* xCONST */
501
502         if ((bptr[1].icount == 2) &&
503                 (bptr[1].iinstr[0].opc == ICMD_ICONST) &&
504                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
505
506                 (bptr[2].icount == 1) &&
507                 (bptr[2].iinstr[0].opc == ICMD_ICONST))
508                 {
509                         pattern = 3;
510                 }
511
512         if ((bptr[1].icount == 2) &&
513                 (bptr[1].iinstr[0].opc == ICMD_LCONST) &&
514                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
515
516                 (bptr[2].icount == 1) &&
517                 (bptr[2].iinstr[0].opc == ICMD_LCONST))
518                 {
519                         pattern = 4;
520                 }
521
522         if ((bptr[1].icount == 2) &&
523                 (bptr[1].iinstr[0].opc == ICMD_ACONST) &&
524                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
525
526                 (bptr[2].icount == 1) &&
527                 (bptr[2].iinstr[0].opc == ICMD_ACONST))
528                 {
529                         pattern = 5;
530                 }
531
532         if ((bptr[1].icount == 2) &&
533                 (bptr[1].iinstr[0].opc == ICMD_FCONST) &&
534                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
535
536                 (bptr[2].icount == 1) &&
537                 (bptr[2].iinstr[0].opc == ICMD_FCONST))
538                 {
539                         pattern = 6;
540                 }
541
542         if ((bptr[1].icount == 2) &&
543                 (bptr[1].iinstr[0].opc == ICMD_DCONST) &&
544                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
545
546                 (bptr[2].icount == 1) &&
547                 (bptr[2].iinstr[0].opc == ICMD_DCONST))
548                 {
549                         pattern = 7;
550                 }
551
552         /* xLOAD */
553
554
555         if ((bptr[1].icount == 2) &&
556                 (bptr[1].iinstr[0].opc == ICMD_ILOAD) &&
557                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
558
559                 (bptr[2].icount == 1) &&
560                 (bptr[2].iinstr[0].opc == ICMD_ILOAD))
561                 {
562                         pattern = 8;
563                 }
564
565         if ((bptr[1].icount == 2) &&
566                 (bptr[1].iinstr[0].opc == ICMD_LLOAD) &&
567                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
568
569                 (bptr[2].icount == 1) &&
570                 (bptr[2].iinstr[0].opc == ICMD_LLOAD))
571                 {
572                         pattern = 9;
573                 }
574
575         if ((bptr[1].icount == 2) &&
576                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
577                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
578
579                 (bptr[2].icount == 1) &&
580                 (bptr[2].iinstr[0].opc == ICMD_ALOAD))
581                 {
582                         pattern = 10;
583                 }
584
585         if ((bptr[1].icount == 2) &&
586                 (bptr[1].iinstr[0].opc == ICMD_FLOAD) &&
587                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
588
589                 (bptr[2].icount == 1) &&
590                 (bptr[2].iinstr[0].opc == ICMD_FLOAD))
591                 {
592                         pattern = 11;
593                 }
594
595         if ((bptr[1].icount == 2) &&
596                 (bptr[1].iinstr[0].opc == ICMD_DLOAD) &&
597                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
598
599                 (bptr[2].icount == 1) &&
600                 (bptr[2].iinstr[0].opc == ICMD_DLOAD))
601                 {
602                         pattern = 12;
603                 }
604
605         /* xCONST, GOTO - xLOAD */
606
607         if ((bptr[1].icount == 2) &&
608                 (bptr[1].iinstr[0].opc == ICMD_ICONST) &&
609                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
610
611                 (bptr[2].icount == 1) &&
612                 (bptr[2].iinstr[0].opc == ICMD_ILOAD))
613                 {
614                         pattern = 13;
615                 }
616
617         if ((bptr[1].icount == 2) &&
618                 (bptr[1].iinstr[0].opc == ICMD_LCONST) &&
619                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
620
621                 (bptr[2].icount == 1) &&
622                 (bptr[2].iinstr[0].opc == ICMD_LLOAD))
623                 {
624                         pattern = 14;
625                 }
626
627         if ((bptr[1].icount == 2) &&
628                 (bptr[1].iinstr[0].opc == ICMD_ACONST) &&
629                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
630
631                 (bptr[2].icount == 1) &&
632                 (bptr[2].iinstr[0].opc == ICMD_ALOAD))
633                 {
634                         pattern = 15;
635                 }
636
637         if ((bptr[1].icount == 2) &&
638                 (bptr[1].iinstr[0].opc == ICMD_FCONST) &&
639                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
640
641                 (bptr[2].icount == 1) &&
642                 (bptr[2].iinstr[0].opc == ICMD_FLOAD))
643                 {
644                         pattern = 16;
645                 }
646
647         if ((bptr[1].icount == 2) &&
648                 (bptr[1].iinstr[0].opc == ICMD_DCONST) &&
649                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
650
651                 (bptr[2].icount == 1) &&
652                 (bptr[2].iinstr[0].opc == ICMD_DLOAD))
653                 {
654                         pattern = 17;
655                 }
656
657         /* xLOAD, GOTO - xCONST */
658
659         if ((bptr[1].icount == 2) &&
660                 (bptr[1].iinstr[0].opc == ICMD_ILOAD) &&
661                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
662
663                 (bptr[2].icount == 1) &&
664                 (bptr[2].iinstr[0].opc == ICMD_ICONST))
665                 {
666                         pattern = 18;
667                 }
668
669         if ((bptr[1].icount == 2) &&
670                 (bptr[1].iinstr[0].opc == ICMD_LLOAD) &&
671                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
672
673                 (bptr[2].icount == 1) &&
674                 (bptr[2].iinstr[0].opc == ICMD_LCONST))
675                 {
676                         pattern = 19;
677                 }
678
679         if ((bptr[1].icount == 2) &&
680                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
681                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
682
683                 (bptr[2].icount == 1) &&
684                 (bptr[2].iinstr[0].opc == ICMD_ACONST))
685                 {
686                         pattern = 20;
687                 }
688
689         if ((bptr[1].icount == 2) &&
690                 (bptr[1].iinstr[0].opc == ICMD_FLOAD) &&
691                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
692
693                 (bptr[2].icount == 1) &&
694                 (bptr[2].iinstr[0].opc == ICMD_FCONST))
695                 {
696                         pattern = 21;
697                 }
698
699         if ((bptr[1].icount == 2) &&
700                 (bptr[1].iinstr[0].opc == ICMD_DLOAD) &&
701                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
702
703                 (bptr[2].icount == 1) &&
704                 (bptr[2].iinstr[0].opc == ICMD_DCONST))
705                 {
706                         pattern = 22;
707                 }
708
709         /*
710           check for different ISTORE destinations or handle them properly
711         */
712
713         if ((bptr[1].icount == 3) &&
714                 (bptr[1].iinstr[0].opc == ICMD_ICONST) &&
715                 (bptr[1].iinstr[1].opc == ICMD_ISTORE) &&
716                 (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
717
718                 (bptr[2].icount == 2) &&
719                 (bptr[2].iinstr[0].opc == ICMD_ICONST) &&
720                 (bptr[2].iinstr[1].opc == ICMD_ISTORE))
721                 {
722                         pattern = 23;
723                 }
724
725         if ((bptr[1].icount == 3) &&
726                 (bptr[1].iinstr[0].opc == ICMD_ILOAD) &&
727                 (bptr[1].iinstr[1].opc == ICMD_ISTORE) &&
728                 (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
729
730                 (bptr[2].icount == 2) &&
731                 (bptr[2].iinstr[0].opc == ICMD_ILOAD) &&
732                 (bptr[2].iinstr[1].opc == ICMD_ISTORE))
733                 {
734                         pattern = 24;
735                 }
736
737         if ((bptr[1].icount == 3) &&
738                 (bptr[1].iinstr[0].opc == ICMD_ICONST) &&
739                 (bptr[1].iinstr[1].opc == ICMD_ISTORE) &&
740                 (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
741
742                 (bptr[2].icount == 2) &&
743                 (bptr[2].iinstr[0].opc == ICMD_ILOAD) &&
744                 (bptr[2].iinstr[1].opc == ICMD_ISTORE))
745                 {
746                         pattern = 25;
747                 }
748
749
750         /* ALOAD, GETFIELD - ALOAD, GETFIELD */
751
752         if ((bptr[1].icount == 3) &&
753                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
754                 (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
755                 (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
756
757                 (bptr[2].icount == 2) &&
758                 (bptr[2].iinstr[0].opc == ICMD_ALOAD) &&
759                 (bptr[2].iinstr[1].opc == ICMD_GETFIELD))
760                 {
761                         pattern = 26;
762                 }
763
764
765         /* ALOAD, ICONST, PUTFIELD - ALOAD, ICONST, PUTFIELD */
766
767         if ((bptr[1].icount == 4) &&
768                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
769                 (bptr[1].iinstr[1].opc == ICMD_ICONST) &&
770                 (bptr[1].iinstr[2].opc == ICMD_PUTFIELD) &&
771                 (bptr[1].iinstr[3].opc == ICMD_GOTO) &&
772
773                 (bptr[2].icount == 3) &&
774                 (bptr[2].iinstr[0].opc == ICMD_ALOAD) &&
775                 (bptr[2].iinstr[1].opc == ICMD_ICONST) &&
776                 (bptr[2].iinstr[2].opc == ICMD_PUTFIELD)
777                 )
778                 {
779                         pattern = 27;
780                 }
781
782         if ((bptr[1].icount == 4) &&
783                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
784                 (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
785                 (bptr[1].iinstr[2].opc == ICMD_ASTORE) &&
786                 (bptr[1].iinstr[3].opc == ICMD_GOTO) &&
787
788                 (bptr[2].icount == 3) &&
789                 (bptr[2].iinstr[0].opc == ICMD_ALOAD) &&
790                 (bptr[2].iinstr[1].opc == ICMD_GETFIELD) &&
791                 (bptr[2].iinstr[2].opc == ICMD_ASTORE)
792                 )
793                 {
794                         pattern = 28;
795                 }
796
797         if ((bptr[1].icount == 2) &&
798                 (bptr[1].iinstr[0].opc == ICMD_GETSTATIC) &&
799                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
800
801                 (bptr[2].icount == 1) &&
802                 (bptr[2].iinstr[0].opc == ICMD_GETSTATIC))
803                 {
804                         pattern = 29;
805                 }
806
807         if ((bptr[1].icount == 3) &&
808                 (bptr[1].iinstr[0].opc == ICMD_GETSTATIC) &&
809                 (bptr[1].iinstr[1].opc == ICMD_ASTORE) &&
810                 (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
811
812                 (bptr[2].icount == 2) &&
813                 (bptr[2].iinstr[0].opc == ICMD_GETSTATIC) &&
814                 (bptr[2].iinstr[1].opc == ICMD_ASTORE))
815                 {
816                         pattern = 30;
817                 }
818
819         if ((bptr[1].icount == 2) &&
820                 (bptr[1].iinstr[0].opc == ICMD_GETSTATIC) &&
821                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
822
823                 (bptr[2].icount == 1) &&
824                 (bptr[2].iinstr[0].opc == ICMD_ALOAD))
825                 {
826                         pattern = 31;
827                 }
828
829         if ((bptr[1].icount == 2) &&
830                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
831                 (bptr[1].iinstr[1].opc == ICMD_GOTO) &&
832
833                 (bptr[2].icount == 1) &&
834                 (bptr[2].iinstr[0].opc == ICMD_GETSTATIC))
835                 {
836                         pattern = 32;
837                 }
838
839
840         if ((bptr[1].icount == 3) &&
841                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
842                 (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
843                 (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
844
845                 (bptr[2].icount == 1) &&
846                 (bptr[2].iinstr[0].opc == ICMD_ICONST))
847                 {
848                         pattern = 33;
849                 }
850
851         if ((bptr[1].icount == 3) &&
852                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
853                 (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
854                 (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
855
856                 (bptr[2].icount == 1) &&
857                 (bptr[2].iinstr[0].opc == ICMD_LCONST))
858                 {
859                         pattern = 34;
860                 }
861
862         if ((bptr[1].icount == 3) &&
863                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
864                 (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
865                 (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
866
867                 (bptr[2].icount == 1) &&
868                 (bptr[2].iinstr[0].opc == ICMD_ACONST))
869                 {
870                         pattern = 35;
871                 }
872
873         if ((bptr[1].icount == 3) &&
874                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
875                 (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
876                 (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
877
878                 (bptr[2].icount == 1) &&
879                 (bptr[2].iinstr[0].opc == ICMD_ILOAD))
880                 {
881                         pattern = 36;
882                 }
883
884         if ((bptr[1].icount == 3) &&
885                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
886                 (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
887                 (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
888
889                 (bptr[2].icount == 1) &&
890                 (bptr[2].iinstr[0].opc == ICMD_LLOAD))
891                 {
892                         pattern = 37;
893                 }
894
895         if ((bptr[1].icount == 3) &&
896                 (bptr[1].iinstr[0].opc == ICMD_ALOAD) &&
897                 (bptr[1].iinstr[1].opc == ICMD_GETFIELD) &&
898                 (bptr[1].iinstr[2].opc == ICMD_GOTO) &&
899
900                 (bptr[2].icount == 1) &&
901                 (bptr[2].iinstr[0].opc == ICMD_ALOAD))
902                 {
903                         pattern = 38;
904                 }
905
906         /*
907
908         CHECK 3   : (BB:   0) IFEQ            javax.swing.plaf.basic.BasicInternalFrameTitlePane.paintTitleBackground(Ljava/awt/Graphics;)V PROTECTED
909         [ ?   ?   ?   ?   ?  ] L001(instruction count: 4, predecessors: 1):
910         [ ?   ?   ?   ?   ?  ]     0 (line:   909)  ALOAD           0
911         [ ?   ?   ?   ?   ?  ]     1 (line:   909)  GETFIELD        (NOT RESOLVED), javax.swing.plaf.basic.BasicInternalFrameTitlePane.selectedTitleColor (type Ljava/awt/Color;)
912         [ ?   ?   ?   ?   ?  ]     2 (line:   909)  ASTORE          4
913         [ ?   ?   ?   ?   ?  ]     3 (line:   909)  GOTO            op1=41
914         [ ?   ?   ?   ?   ?  ] L002(instruction count: 3, predecessors: 1):
915         [ ?   ?   ?   ?   ?  ]     0 (line:   911)  ALOAD           0
916         [ ?   ?   ?   ?   ?  ]     1 (line:   911)  GETFIELD        (NOT RESOLVED), javax.swing.plaf.basic.BasicInternalFrameTitlePane.notSelectedTitleColor (type Ljava/awt/Color;)
917         [ ?   ?   ?   ?   ?  ]     2 (line:   911)  ASTORE          4
918
919
920         CHECK 3   : (BB:   3) IFEQ            javax.swing.plaf.basic.BasicTreeUI$MouseHandler.mousePressed(Ljava/awt/event/MouseEvent;)V PUBLIC
921         [ ?   ?   ?   ?   ?  ] L004(instruction count: 4, predecessors: 1):
922         [ ?   ?   ?   ?   ?  ]     0 (line:  2244)  ACONST          0x3602d30, String = "Tree.openIcon"
923         [ ?   ?   ?   ?   ?  ]     1 (line:  2244)  INVOKESTATIC    (NOT RESOLVED) javax.swing.UIManager.getIcon(Ljava/lang/Object;)Ljavax/swing/Icon;
924         [ ?   ?   ?   ?   ?  ]     2 (line:  2244)  ASTORE          8
925         [ ?   ?   ?   ?   ?  ]     3 (line:  2244)  GOTO            op1=155
926         [ ?   ?   ?   ?   ?  ] L005(instruction count: 3, predecessors: 1):
927         [ ?   ?   ?   ?   ?  ]     0 (line:  2246)  ACONST          0x3602e00, String = "Tree.closedIcon"
928         [ ?   ?   ?   ?   ?  ]     1 (line:  2246)  INVOKESTATIC    (NOT RESOLVED) javax.swing.UIManager.getIcon(Ljava/lang/Object;)Ljavax/swing/Icon;
929         [ ?   ?   ?   ?   ?  ]     2 (line:  2246)  ASTORE          8
930
931
932         CHECK 3   : (BB:   2) IFEQ            javax.naming.CompoundName.initializeSyntax()V PRIVATE FINAL
933         [ ?   ?   ?   ?  ] L003(instruction count: 4, predecessors: 1):
934         [ ?   ?   ?   ?  ]     0 (line:   445)  ALOAD           0
935         [ ?   ?   ?   ?  ]     1 (line:   445)  ICONST          1 (0x00000001)
936         [ ?   ?   ?   ?  ]     2 (line:   445)  PUTFIELD        (NOT RESOLVED), javax.naming.CompoundName.direction (type I)
937         [ ?   ?   ?   ?  ]     3 (line:   445)  GOTO            op1=51
938         [ ?   ?   ?   ?  ] L004(instruction count: 3, predecessors: 1):
939         [ ?   ?   ?   ?  ]     0 (line:   449)  ALOAD           0
940         [ ?   ?   ?   ?  ]     1 (line:   449)  ICONST          0 (0x00000000)
941         [ ?   ?   ?   ?  ]     2 (line:   449)  PUTFIELD        (NOT RESOLVED), javax.naming.CompoundName.direction (type I)
942
943
944         CHECK 3   : (BB:  15) IFNE            java.awt.Scrollbar.setValues(IIII)V PUBLIC SYNCHRONIZED
945         [ ?   ?   ?   ?   ?  ] L016(instruction count: 4, predecessors: 1):
946         [ ?   ?   ?   ?   ?  ]     0 (line:   371)  ALOAD           0
947         [ ?   ?   ?   ?   ?  ]     1 (line:   371)  ICONST          1 (0x00000001)
948         [ ?   ?   ?   ?   ?  ]     2 (line:   371)  PUTFIELD        (NOT RESOLVED), java.awt.Scrollbar.lineIncrement (type I)
949         [ ?   ?   ?   ?   ?  ]     3 (line:   371)  GOTO            op1=152
950         [ ?   ?   ?   ?   ?  ] L017(instruction count: 3, predecessors: 1):
951         [ ?   ?   ?   ?   ?  ]     0 (line:   373)  ALOAD           0
952         [ ?   ?   ?   ?   ?  ]     1 (line:   373)  ILOAD           6
953         [ ?   ?   ?   ?   ?  ]     2 (line:   373)  PUTFIELD        (NOT RESOLVED), java.awt.Scrollbar.lineIncrement (type I)
954
955
956         CHECK 3   : (BB:   1) IFEQ            javax.swing.JInternalFrame.setIcon(Z)V PUBLIC
957         [ ?   ?   ?   ?  ] L002(instruction count: 4, predecessors: 1):
958         [ ?   ?   ?   ?  ]     0 (line:  1395)  ALOAD           0
959         [ ?   ?   ?   ?  ]     1 (line:  1395)  ICONST          25552 (0x000063d0)
960         [ ?   ?   ?   ?  ]     2 (line:  1395)  INVOKEVIRTUAL   (NOT RESOLVED) javax.swing.JInternalFrame.fireInternalFrameEvent(I)V
961         [ ?   ?   ?   ?  ]     3 (line:  1395)  GOTO            op1=61
962         [ ?   ?   ?   ?  ] L003(instruction count: 3, predecessors: 1):
963         [ ?   ?   ?   ?  ]     0 (line:  1397)  ALOAD           0
964         [ ?   ?   ?   ?  ]     1 (line:  1397)  ICONST          25553 (0x000063d1)
965         [ ?   ?   ?   ?  ]     2 (line:  1397)  INVOKEVIRTUAL   (NOT RESOLVED) javax.swing.JInternalFrame.fireInternalFrameEvent(I)V
966
967         */
968
969 #if !defined(NDEBUG)
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  */