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