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