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