1 /***************************** ncomp/nblock.c **********************************
3 Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst
5 See file COPYRIGHT for information on usage and disclaimer of warranties
7 Basic block handling functions.
9 Authors: Andreas Krall EMAIL: cacao@complang.tuwien.ac.at
10 Reinhard Grafl EMAIL: cacao@complang.tuwien.ac.at
12 Last Change: 1997/11/05
14 *******************************************************************************/
17 /******************** function determine_basic_blocks **************************
19 Scans the JavaVM code of a method and marks each instruction which is the
20 start of a basic block.
22 *******************************************************************************/
24 static void allocate_literals()
30 while (p < jcodelength) {
33 nextp = p + jcommandsize[opcode];
37 switch (code_get_u1(p + 1)) {
38 case JAVA_RET: nextp = p + 4;
40 case JAVA_IINC: nextp = p + 6;
42 default: nextp = p + 4;
47 case JAVA_LOOKUPSWITCH:
51 nextp = ALIGN((p + 1), 4);
52 num = code_get_u4(nextp + 4);
53 nextp = nextp + 8 + 8 * num;
57 case JAVA_TABLESWITCH:
61 nextp = ALIGN ((p + 1),4);
62 num = code_get_s4(nextp + 4);
63 num = code_get_s4(nextp + 8) - num;
64 nextp = nextp + 16 + 4 * num;
70 goto pushconstantitem;
73 i = code_get_u2(p + 1);
75 if (class_constanttype(class, i) == CONSTANT_String) {
77 s = class_getconstant(class, i, CONSTANT_String);
78 (void) literalstring_new(s);