1 /* src/vm/jit/parse.c - parser for JavaVM to intermediate code translation
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
29 Changes: Carolyn Oates
34 $Id: parse.c 4313 2006-01-19 22:11:34Z edwin $
46 #include "mm/memory.h"
47 #include "native/native.h"
48 #include "toolbox/logging.h"
49 #include "vm/builtin.h"
50 #include "vm/exceptions.h"
51 #include "vm/global.h"
52 #include "vm/linker.h"
53 #include "vm/loader.h"
54 #include "vm/resolve.h"
55 #include "vm/options.h"
56 #include "vm/statistics.h"
57 #include "vm/stringlocal.h"
58 #include "vm/jit/asmpart.h"
59 #include "vm/jit/jit.h"
60 #include "vm/jit/parse.h"
61 #include "vm/jit/patcher.h"
62 #include "vm/jit/inline/parseRT.h"
63 #include "vm/jit/inline/parseXTA.h"
64 #include "vm/jit/inline/inline.h"
65 #include "vm/jit/loop/loop.h"
66 #include "vm/jit/inline/parseRTprint.h"
68 /*******************************************************************************
70 function 'parse' scans the JavaVM code and generates intermediate code
72 During parsing the block index table is used to store at bit pos 0
73 a flag which marks basic block starts and at position 1 to 31 the
74 intermediate instruction index. After parsing the block index table
75 is scanned, for marked positions a block is generated and the block
76 number is stored in the block index table.
78 *******************************************************************************/
80 static exceptiontable * fillextable(methodinfo *m,
81 exceptiontable *extable,
82 exceptiontable *raw_extable,
83 int exceptiontablelength,
86 t_inlining_globals *inline_env)
88 int b_count, p, src, insertBlock;
90 if (exceptiontablelength == 0)
93 b_count = *block_count;
95 for (src = exceptiontablelength-1; src >=0; src--) {
96 p = raw_extable[src].startpc;
97 if (label_index != NULL) p = label_index[p];
102 p = raw_extable[src].endpc; /* see JVM Spec 4.7.3 */
103 if (p <= raw_extable[src].startpc) {
104 *exceptionptr = new_verifyerror(inline_env->method,
105 "Invalid exception handler range");
109 if (p >inline_env->method->jcodelength) {
110 *exceptionptr = new_verifyerror(inline_env->method,
111 "Invalid exception handler end is after code end");
115 if (p<inline_env->method->jcodelength) insertBlock=1; else insertBlock=0;
116 if (label_index != NULL) p = label_index[p];
119 /* if (p < inline_env->method->jcodelength) block_insert(p); */
123 p = raw_extable[src].handlerpc;
124 if (label_index != NULL) p = label_index[p];
125 extable->handlerpc = p;
129 extable->catchtype = raw_extable[src].catchtype;
130 extable->next = NULL;
131 extable->down = &extable[1];
135 *block_count = b_count;
136 return extable; /*&extable[i];*/ /* return the next free xtable* */
141 methodinfo *parse(methodinfo *m, codegendata *cd, t_inlining_globals *inline_env)
143 int p; /* java instruction counter */
144 int nextp; /* start of next java instruction */
145 int opcode; /* java opcode */
146 int i; /* temporary for different uses (ctrs)*/
147 int ipc = 0; /* intermediate instruction counter */
148 int b_count = 0; /* basic block counter */
149 int s_count = 0; /* stack element counter */
150 bool blockend = false; /* true if basic block end has been reached */
151 bool iswide = false; /* true if last instruction was a wide*/
152 instruction *iptr; /* current ptr into instruction array */
153 int gp; /* global java instruction counter */
154 /* inlining info for current method */
156 inlining_methodinfo *inlinfo = inline_env->inlining_rootinfo;
157 inlining_methodinfo *tmpinlinf;
158 int nextgp = -1; /* start of next method to be inlined */
159 int *label_index = NULL; /* label redirection table */
160 int firstlocal = 0; /* first local variable of method */
161 exceptiontable* nextex; /* points next free entry in extable */
162 u1 *instructionstart; /* 1 for pcs which are valid instr. starts */
164 constant_classref *cr;
165 constant_classref *compr;
167 builtintable_entry *bte;
173 u2 skipBasicBlockChange;
175 /* allocate instruction array and block index table */
177 /* 1 additional for end ipc * # cum inline methods*/
179 m->basicblockindex = DMNEW(s4, inline_env->cumjcodelength + inline_env->cummethods);
180 memset(m->basicblockindex, 0, sizeof(s4) * (inline_env->cumjcodelength + inline_env->cummethods));
182 instructionstart = DMNEW(u1, inline_env->cumjcodelength + inline_env->cummethods);
183 memset(instructionstart, 0, sizeof(u1) * (inline_env->cumjcodelength + inline_env->cummethods));
185 /* 1 additional for TRACEBUILTIN and 4 for MONITORENTER/EXIT */
186 /* additional MONITOREXITS are reached by branches which are 3 bytes */
188 iptr = m->instructions = DMNEW(instruction, inline_env->cumjcodelength + 5);
190 /* Zero the intermediate instructions array so we don't have any
191 * invalid pointers in it if we cannot finish analyse_stack(). */
193 memset(iptr, 0, sizeof(instruction) * (inline_env->cumjcodelength + 5));
195 /* compute branch targets of exception table */
197 nextex = fillextable(m,
198 &(cd->exceptiontable[cd->exceptiontablelength-1]), m->exceptiontable, m->exceptiontablelength,
199 label_index, &b_count, inline_env);
202 s_count = 1 + m->exceptiontablelength; /* initialize stack element counter */
204 #if defined(USE_THREADS)
205 if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
206 m->isleafmethod = false;
207 inline_env->method->isleafmethod = false;
211 /* scan all java instructions */
215 if (m->linenumbercount == 0) {
218 linepcchange = m->linenumbers[0].start_pc;
221 skipBasicBlockChange=0;
222 for (p = 0, gp = 0; p < inline_env->method->jcodelength; gp += (nextp - p), p = nextp) {
224 /* mark this position as a valid instruction start */
226 instructionstart[gp] = 1;
227 if (linepcchange==p) {
228 if (inline_env->method->linenumbercount > lineindex) {
229 currentline = inline_env->method->linenumbers[lineindex].line_number;
231 if (lineindex < inline_env->method->linenumbercount)
232 linepcchange = inline_env->method->linenumbers[lineindex].start_pc;
237 /* fetch next opcode */
239 opcode = code_get_u1(p, inline_env->method);
241 if (!skipBasicBlockChange) {
242 m->basicblockindex[gp] |= (ipc << 1); /*store intermed cnt*/
243 } else skipBasicBlockChange=0;
245 /* some compilers put a JAVA_NOP after a blockend instruction */
247 if ((opcode != JAVA_NOP) && (blockend == true)) {
248 /* start new block */
254 nextp = p + jcommandsize[opcode]; /* compute next instruction start */
256 if (nextp > inline_env->method->jcodelength) {
257 *exceptionptr = new_verifyerror(inline_env->method,
258 "Unexpected end of bytecode");
262 s_count += stackreq[opcode]; /* compute stack element count */
267 /* pushing constants onto the stack p */
270 LOADCONST_I(code_get_s1(p+1,inline_env->method));
274 LOADCONST_I(code_get_s2(p+1,inline_env->method));
278 i = code_get_u1(p + 1, inline_env->method);
279 goto pushconstantitem;
283 i = code_get_u2(p + 1, inline_env->method);
287 if (i >= inline_env->method->class->cpcount) {
288 *exceptionptr = new_verifyerror(inline_env->method,
289 "Attempt to access constant outside range");
293 switch (inline_env->method->class->cptags[i]) {
294 case CONSTANT_Integer:
295 LOADCONST_I(((constant_integer *) (inline_env->method->class->cpinfos[i]))->value);
298 LOADCONST_L(((constant_long *) (inline_env->method->class->cpinfos[i]))->value);
301 LOADCONST_F(((constant_float *) (inline_env->method->class->cpinfos[i]))->value);
303 case CONSTANT_Double:
304 LOADCONST_D(((constant_double *) (inline_env->method->class->cpinfos[i]))->value);
306 case CONSTANT_String:
307 LOADCONST_A(literalstring_new((utf *) (inline_env->method->class->cpinfos[i])));
310 cr = (constant_classref *) (inline_env->method->class->cpinfos[i]);
312 if (!resolve_classref(inline_env->method, cr, resolveLazy, true,
316 /* if not resolved, c == NULL */
318 LOADCONST_A_CLASS(c, cr);
321 *exceptionptr = new_verifyerror(inline_env->method,
322 "Invalid constant type to push");
327 case JAVA_ACONST_NULL:
338 LOADCONST_I(opcode - JAVA_ICONST_0);
343 LOADCONST_L(opcode - JAVA_LCONST_0);
349 LOADCONST_F(opcode - JAVA_FCONST_0);
354 LOADCONST_D(opcode - JAVA_DCONST_0);
357 /* loading variables onto the stack */
365 i = code_get_u1(p + 1,inline_env->method);
367 i = code_get_u2(p + 1,inline_env->method);
371 OP1LOAD(opcode, i + firstlocal);
378 OP1LOAD(ICMD_ILOAD, opcode - JAVA_ILOAD_0 + firstlocal);
385 OP1LOAD(ICMD_LLOAD, opcode - JAVA_LLOAD_0 + firstlocal);
392 OP1LOAD(ICMD_FLOAD, opcode - JAVA_FLOAD_0 + firstlocal);
399 OP1LOAD(ICMD_DLOAD, opcode - JAVA_DLOAD_0 + firstlocal);
406 OP1LOAD(ICMD_ALOAD, opcode - JAVA_ALOAD_0 + firstlocal);
409 /* storing stack values into local variables */
417 i = code_get_u1(p + 1,inline_env->method);
419 i = code_get_u2(p + 1,inline_env->method);
423 OP1STORE(opcode, i + firstlocal);
430 OP1STORE(ICMD_ISTORE, opcode - JAVA_ISTORE_0 + firstlocal);
437 OP1STORE(ICMD_LSTORE, opcode - JAVA_LSTORE_0 + firstlocal);
444 OP1STORE(ICMD_FSTORE, opcode - JAVA_FSTORE_0 + firstlocal);
451 OP1STORE(ICMD_DSTORE, opcode - JAVA_DSTORE_0 + firstlocal);
458 OP1STORE(ICMD_ASTORE, opcode - JAVA_ASTORE_0 + firstlocal);
466 i = code_get_u1(p + 1,inline_env->method);
467 v = code_get_s1(p + 2,inline_env->method);
470 i = code_get_u2(p + 1,inline_env->method);
471 v = code_get_s2(p + 3,inline_env->method);
475 INDEX_ONEWORD(i + firstlocal);
476 OP2I(opcode, i + firstlocal, v);
480 /* wider index for loading, storing and incrementing */
487 /* managing arrays ****************************************************/
490 switch (code_get_s1(p + 1, inline_env->method)) {
492 bte = builtintable_get_internal(BUILTIN_newarray_boolean);
495 bte = builtintable_get_internal(BUILTIN_newarray_char);
498 bte = builtintable_get_internal(BUILTIN_newarray_float);
501 bte = builtintable_get_internal(BUILTIN_newarray_double);
504 bte = builtintable_get_internal(BUILTIN_newarray_byte);
507 bte = builtintable_get_internal(BUILTIN_newarray_short);
510 bte = builtintable_get_internal(BUILTIN_newarray_int);
513 bte = builtintable_get_internal(BUILTIN_newarray_long);
516 *exceptionptr = new_verifyerror(inline_env->method,
517 "Invalid array-type to create");
520 BUILTIN(bte, true, NULL, currentline);
524 i = code_get_u2(p + 1, inline_env->method);
525 compr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
529 if (!(cr = class_get_classref_multiarray_of(1, compr)))
532 if (!resolve_classref(inline_env->method, cr, resolveLazy, true, true, &c))
535 LOADCONST_A_BUILTIN(c, cr);
536 bte = builtintable_get_internal(BUILTIN_newarray);
537 BUILTIN(bte, true, NULL, currentline);
541 case JAVA_MULTIANEWARRAY:
542 inline_env->method->isleafmethod = false;
543 i = code_get_u2(p + 1, inline_env->method);
545 s4 v = code_get_u1(p + 3, inline_env->method);
547 cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
551 if (!resolve_classref(inline_env->method, cr, resolveLazy, true, true, &c))
554 /* if unresolved, c == NULL */
555 OP2AT(opcode, v, c, cr, currentline);
577 i = p + code_get_s2(p + 1,inline_env->method);
589 i = p + code_get_s4(p + 1,inline_env->method);
601 i = code_get_u1(p + 1,inline_env->method);
603 i = code_get_u2(p + 1,inline_env->method);
610 if (inline_env->isinlinedmethod) {
611 OP1(ICMD_GOTO, inlinfo->stopgp);
615 OP1LOAD(opcode, i + firstlocal);
624 if (inline_env->isinlinedmethod) {
625 /* if (p==m->jcodelength-1) {*/ /* return is at end of inlined method */
629 if (nextp>inline_env->method->jcodelength-1) {
630 /* OP1(ICMD_GOTO, inlinfo->stopgp);
638 OP1(ICMD_GOTO, inlinfo->stopgp);
643 /* zero val.a so no patcher is inserted */
644 /* the type checker may set this later */
651 /* zero val.a so no patcher is inserted */
652 /* the type checker may set this later */
658 /* table jumps ********************************************************/
660 case JAVA_LOOKUPSWITCH:
667 nextp = ALIGN((p + 1), 4);
669 if (nextp + 8 > inline_env->method->jcodelength) {
670 *exceptionptr = new_verifyerror(inline_env->method,
671 "Unexpected end of bytecode");
676 tablep = (s4 *) (inline_env->method->jcode + nextp);
679 num = code_get_u4(nextp + 4, inline_env->method);
680 tablep = DMNEW(s4, num * 2 + 2);
683 OP2A(opcode, 0, tablep, currentline);
687 j = p + code_get_s4(nextp, inline_env->method);
690 *tablep = j; /* restore for little endian */
696 /* number of pairs */
698 num = code_get_u4(nextp, inline_env->method);
703 if (nextp + 8 * num > inline_env->method->jcodelength) {
704 *exceptionptr = new_verifyerror(inline_env->method,
705 "Unexpected end of bytecode");
709 for (i = 0; i < num; i++) {
712 j = code_get_s4(nextp, inline_env->method);
713 *tablep = j; /* restore for little endian */
717 /* check if the lookup table is sorted correctly */
719 if (i && (j <= prevvalue)) {
720 *exceptionptr = new_verifyerror(m, "Unsorted lookup switch");
727 j = p + code_get_s4(nextp,inline_env->method);
730 *tablep = j; /* restore for little endian */
741 case JAVA_TABLESWITCH:
747 nextp = ALIGN((p + 1), 4);
748 if (nextp + 12 > inline_env->method->jcodelength) {
749 *exceptionptr = new_verifyerror(inline_env->method,
750 "Unexpected end of bytecode");
755 tablep = (s4 *) (inline_env->method->jcode + nextp);
758 num = code_get_u4(nextp + 8,inline_env->method) - code_get_u4(nextp + 4,inline_env->method);
759 tablep = DMNEW(s4, num + 1 + 3);
762 OP2A(opcode, 0, tablep, currentline);
766 j = p + code_get_s4(nextp, inline_env->method);
769 *tablep = j; /* restore for little endian */
777 j = code_get_s4(nextp, inline_env->method);
778 *tablep = j; /* restore for little endian */
784 num = code_get_s4(nextp, inline_env->method);
785 *tablep = num; /* restore for little endian */
789 num -= j; /* difference of upper - lower */
792 *exceptionptr = new_verifyerror(inline_env->method,
793 "invalid TABLESWITCH: upper bound < lower bound");
797 if (nextp + 4 * (num + 1) > inline_env->method->jcodelength) {
798 *exceptionptr = new_verifyerror(inline_env->method,
799 "Unexpected end of bytecode");
803 for (i = 0; i <= num; i++) {
804 j = p + code_get_s4(nextp,inline_env->method);
808 *tablep = j; /* restore for little endian */
819 /* load and store of object fields ************************************/
823 inline_env->method->isleafmethod = false;
832 unresolved_field *uf;
835 i = code_get_u2(p + 1, inline_env->method);
836 fr = class_getconstant(inline_env->method->class, i,
841 OP2A_NOINC(opcode, fr->parseddesc.fd->type, fr, currentline);
843 if (!(uf = create_unresolved_field(inline_env->method->class,
848 /* store unresolved_field pointer */
852 /* only with -noverify, otherwise the typechecker does this */
855 if (!resolve_field(uf, resolveLazy, &fi))
868 /* method invocation **************************************************/
870 case JAVA_INVOKESTATIC:
871 i = code_get_u2(p + 1, inline_env->method);
875 unresolved_method *um;
878 inline_env->method->isleafmethod = false;
880 mr = class_getconstant(inline_env->method->class, i,
885 md = mr->parseddesc.md;
888 if (!descriptor_params_from_paramtypes(md, ACC_STATIC))
891 OP2A_NOINC(opcode, 0, mr, currentline);
893 um = create_unresolved_method(inline_env->method->class,
894 inline_env->method, iptr);
899 /* store the unresolved_method pointer */
903 /* only with -noverify, otherwise the typechecker does this */
906 if (!resolve_method(um, resolveLazy, &mi))
918 case JAVA_INVOKESPECIAL:
919 case JAVA_INVOKEVIRTUAL:
923 unresolved_method *um;
926 inline_env->method->isleafmethod = false;
928 i = code_get_u2(p + 1, inline_env->method);
929 mr = class_getconstant(inline_env->method->class, i,
934 md = mr->parseddesc.md;
937 if (!descriptor_params_from_paramtypes(md, 0))
940 OP2A_NOINC(opcode, 0, mr, currentline);
942 um = create_unresolved_method(inline_env->method->class,
943 inline_env->method, iptr);
948 /* store the unresolved_method* */
952 /* only with -noverify, otherwise the typechecker does this */
955 if (!resolve_method(um, resolveLazy, &mi))
967 case JAVA_INVOKEINTERFACE:
968 i = code_get_u2(p + 1, inline_env->method);
972 unresolved_method *um;
975 inline_env->method->isleafmethod = false;
977 mr = class_getconstant(inline_env->method->class, i,
978 CONSTANT_InterfaceMethodref);
982 md = mr->parseddesc.md;
985 if (!descriptor_params_from_paramtypes(md, 0))
988 OP2A_NOINC(opcode, 0, mr, currentline);
990 um = create_unresolved_method(inline_env->method->class,
991 inline_env->method, iptr);
996 /* store the unresolved_method* */
1000 /* only with -noverify, otherwise the typechecker does this */
1003 if (!resolve_method(um, resolveLazy, &mi))
1015 /* miscellaneous object operations ************************************/
1018 i = code_get_u2(p + 1, inline_env->method);
1019 cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
1023 if (!resolve_classref(inline_env->method, cr, resolveLazy, true, true,
1027 LOADCONST_A_BUILTIN(c, cr);
1028 bte = builtintable_get_internal(BUILTIN_new);
1029 BUILTIN(bte, true, NULL, currentline);
1033 case JAVA_CHECKCAST:
1034 i = code_get_u2(p + 1, inline_env->method);
1035 cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
1039 if (!resolve_classref(inline_env->method, cr, resolveLazy, true,
1043 if (cr->name->text[0] == '[') {
1044 /* array type cast-check */
1045 OP2AT(opcode, 0, c, cr, currentline);
1046 inline_env->method->isleafmethod = false;
1049 /* object type cast-check */
1050 OP2AT(opcode, 1, c, cr, currentline);
1054 case JAVA_INSTANCEOF:
1055 i = code_get_u2(p + 1,inline_env->method);
1056 cr = (constant_classref *) class_getconstant(inline_env->method->class, i, CONSTANT_Class);
1060 if (!resolve_classref(inline_env->method, cr, resolveLazy, true, true, &c))
1063 if (cr->name->text[0] == '[') {
1064 /* array type cast-check */
1065 LOADCONST_A_BUILTIN(c, cr);
1066 bte = builtintable_get_internal(BUILTIN_arrayinstanceof);
1067 BUILTIN(bte, false, NULL, currentline);
1071 /* object type cast-check */
1072 OP2AT(opcode, 1, c, cr, currentline);
1076 case JAVA_MONITORENTER:
1077 #if defined(USE_THREADS)
1080 bte = builtintable_get_internal(BUILTIN_monitorenter);
1081 BUILTIN(bte, false, NULL, currentline);
1090 case JAVA_MONITOREXIT:
1091 #if defined(USE_THREADS)
1093 bte = builtintable_get_internal(BUILTIN_monitorexit);
1094 BUILTIN(bte, false, NULL, currentline);
1102 /* any other basic operation ******************************************/
1105 #if !SUPPORT_DIVISION
1106 bte = builtintable_get_internal(BUILTIN_idiv);
1107 OP2A(opcode, bte->md->paramcount, bte, currentline);
1108 inline_env->method->isleafmethod = false;
1115 #if !SUPPORT_DIVISION
1116 bte = builtintable_get_internal(BUILTIN_irem);
1117 OP2A(opcode, bte->md->paramcount, bte, currentline);
1118 inline_env->method->isleafmethod = false;
1125 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1126 bte = builtintable_get_internal(BUILTIN_ldiv);
1127 OP2A(opcode, bte->md->paramcount, bte, currentline);
1128 inline_env->method->isleafmethod = false;
1135 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1136 bte = builtintable_get_internal(BUILTIN_lrem);
1137 OP2A(opcode, bte->md->paramcount, bte, currentline);
1138 inline_env->method->isleafmethod = false;
1145 #if defined(__I386__)
1148 bte = builtintable_get_internal(BUILTIN_frem);
1149 BUILTIN(bte, false, NULL, currentline);
1154 #if defined(__I386__)
1157 bte = builtintable_get_internal(BUILTIN_drem);
1158 BUILTIN(bte, false, NULL, currentline);
1163 #if defined(__ALPHA__)
1165 bte = builtintable_get_internal(BUILTIN_f2i);
1166 BUILTIN(bte, false, NULL, currentline);
1175 #if defined(__ALPHA__)
1177 bte = builtintable_get_internal(BUILTIN_f2l);
1178 BUILTIN(bte, false, NULL, currentline);
1187 #if defined(__ALPHA__)
1189 bte = builtintable_get_internal(BUILTIN_d2i);
1190 BUILTIN(bte, false, NULL, currentline);
1199 #if defined(__ALPHA__)
1201 bte = builtintable_get_internal(BUILTIN_d2l);
1202 BUILTIN(bte, false, NULL, currentline);
1210 case JAVA_BREAKPOINT:
1212 new_verifyerror(m, "Quick instructions shouldn't appear yet.");
1215 case 186: /* unused opcode */
1270 new_verifyerror(inline_env->method,"Illegal opcode %d at instr %d\n",
1281 /* If WIDE was used correctly, iswide should have been reset by now. */
1282 if (iswide && opcode != JAVA_WIDE) {
1283 *exceptionptr = new_verifyerror(inline_env->method,
1284 "Illegal instruction: WIDE before incompatible opcode");
1288 #if defined(USE_INLINING)
1289 /* if (inline_env->isinlinedmethod && p == inline_env->method->jcodelength - 1) { */ /* end of an inlined method */
1290 if (inline_env->isinlinedmethod && (nextp >= inline_env->method->jcodelength) ) { /* end of an inlined method */
1291 gp = inlinfo->stopgp;
1292 inlining_restore_compiler_variables();
1293 OP(ICMD_INLINE_END);
1294 /*label_index = inlinfo->label_index;*/
1296 list_remove(inlinfo->inlinedmethods, list_first(inlinfo->inlinedmethods));
1297 if (inlinfo->inlinedmethods == NULL) { /* JJJJ */
1300 tmpinlinf = list_first(inlinfo->inlinedmethods);
1301 nextgp = (tmpinlinf != NULL) ? tmpinlinf->startgp : -1;
1303 label_index=inlinfo->label_index;
1304 firstlocal = inlinfo->firstlocal;
1306 #endif /* defined(USE_INLINING) */
1311 if (p != m->jcodelength) {
1312 printf("p (%d) != m->jcodelength (%d)\n",p,m->jcodelength);
1313 *exceptionptr = new_verifyerror(inline_env->method,
1314 "Command-sequence crosses code-boundary");
1319 *exceptionptr = new_verifyerror(m, "Falling off the end of the code");
1323 /* adjust block count if target 0 is not first intermediate instruction */
1325 if (!m->basicblockindex[0] || (m->basicblockindex[0] > 1))
1328 /* copy local to method variables */
1330 m->instructioncount = ipc;
1331 m->basicblockcount = b_count;
1332 m->stackcount = s_count + m->basicblockcount * m->maxstack;
1334 /* allocate stack table */
1336 m->stack = DMNEW(stackelement, m->stackcount);
1341 bptr = m->basicblocks = DMNEW(basicblock, b_count + 1); /* one more for end ipc */
1346 /* additional block if target 0 is not first intermediate instruction */
1348 if (!m->basicblockindex[0] || (m->basicblockindex[0] > 1)) {
1349 bptr->iinstr = m->instructions;
1352 bptr->type = BBTYPE_STD;
1353 bptr->branchrefs = NULL;
1354 bptr->pre_count = 0;
1355 bptr->debug_nr = m->c_debug_nr++;
1358 (bptr - 1)->next = bptr;
1361 /* allocate blocks */
1363 for (p = 0; p < inline_env->cumjcodelength; p++) {
1364 /* for (p = 0; p < m->jcodelength; p++) { */
1365 if (m->basicblockindex[p] & 1) {
1366 /* Check if this block starts at the beginning of an */
1369 if (!instructionstart[p]) {
1370 *exceptionptr = new_verifyerror(inline_env->method,
1371 "Branch into middle of instruction");
1375 /* allocate the block */
1376 bptr->iinstr = m->instructions + (m->basicblockindex[p] >> 1);
1377 bptr->debug_nr = m->c_debug_nr++;
1379 (bptr - 1)->icount = bptr->iinstr - (bptr - 1)->iinstr;
1383 bptr->type = BBTYPE_STD;
1384 bptr->branchrefs = NULL;
1385 m->basicblockindex[p] = b_count;
1386 bptr->pre_count = 0;
1389 (bptr - 1)->next = bptr;
1393 /* allocate additional block at end */
1395 bptr->instack = bptr->outstack = NULL;
1396 bptr->indepth = bptr->outdepth = 0;
1397 bptr->iinstr = NULL;
1398 (bptr - 1)->icount = (m->instructions + m->instructioncount) - (bptr - 1)->iinstr;
1403 bptr->type = BBTYPE_STD;
1404 bptr->branchrefs = NULL;
1405 bptr->pre_count = 0;
1406 bptr->debug_nr = m->c_debug_nr++;
1407 (bptr - 1)->next = bptr;
1410 if (cd->exceptiontablelength > 0) {
1411 cd->exceptiontable[cd->exceptiontablelength - 1].down = NULL;
1414 for (i = 0; i < cd->exceptiontablelength; ++i) {
1415 p = cd->exceptiontable[i].startpc;
1416 cd->exceptiontable[i].start = m->basicblocks + m->basicblockindex[p];
1418 p = cd->exceptiontable[i].endpc;
1419 cd->exceptiontable[i].end = (p == inline_env->method->jcodelength) ? (m->basicblocks + m->basicblockcount /*+ 1*/) : (m->basicblocks + m->basicblockindex[p]);
1421 p = cd->exceptiontable[i].handlerpc;
1422 cd->exceptiontable[i].handler = m->basicblocks + m->basicblockindex[p];
1426 /* just return methodinfo* to signal everything was ok */
1433 * These are local overrides for various environment variables in Emacs.
1434 * Please do not remove this and leave it at the end of the file, where
1435 * Emacs will automagically detect them.
1436 * ---------------------------------------------------------------------
1439 * indent-tabs-mode: t
1443 * vim:noexpandtab:sw=4:ts=4: