1 /* src/vm/jit/parse.c - parser for JavaVM to intermediate code translation
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
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., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
29 Changes: Carolyn Oates
34 $Id: parse.c 4742 2006-04-05 20:31:38Z 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/loop/loop.h"
64 /*******************************************************************************
66 function 'parse' scans the JavaVM code and generates intermediate code
68 During parsing the block index table is used to store at bit pos 0
69 a flag which marks basic block starts and at position 1 to 31 the
70 intermediate instruction index. After parsing the block index table
71 is scanned, for marked positions a block is generated and the block
72 number is stored in the block index table.
74 *******************************************************************************/
76 static exceptiontable * fillextable(methodinfo *m,
77 exceptiontable *extable,
78 exceptiontable *raw_extable,
79 int exceptiontablelength,
84 if (exceptiontablelength == 0)
87 b_count = *block_count;
89 for (src = exceptiontablelength-1; src >=0; src--) {
90 /* the start of the handled region becomes a basic block start */
91 p = raw_extable[src].startpc;
92 CHECK_BYTECODE_INDEX(p);
96 p = raw_extable[src].endpc; /* see JVM Spec 4.7.3 */
97 CHECK_BYTECODE_INDEX_EXCLUSIVE(p);
99 #if defined(ENABLE_VERIFIER)
100 if (p <= raw_extable[src].startpc) {
101 *exceptionptr = new_verifyerror(m,
102 "Invalid exception handler range");
108 /* end of handled region becomes a basic block boundary */
109 /* (If it is the bytecode end, we'll use the special */
110 /* end block that is created anyway.) */
111 if (p < m->jcodelength)
114 /* the start of the handler becomes a basic block start */
115 p = raw_extable[src].handlerpc;
116 CHECK_BYTECODE_INDEX(p);
117 extable->handlerpc = p;
120 extable->catchtype = raw_extable[src].catchtype;
121 extable->next = NULL;
122 extable->down = &extable[1];
126 *block_count = b_count;
131 #if defined(ENABLE_VERIFIER)
132 throw_invalid_bytecode_index:
134 new_verifyerror(m, "Illegal bytecode index in exception table");
139 /*** macro for checking the length of the bytecode ***/
141 #if defined(ENABLE_VERIFIER)
142 #define CHECK_END_OF_BYTECODE(neededlength) \
144 if ((neededlength) > m->jcodelength) \
145 goto throw_unexpected_end_of_bytecode; \
147 #else /* !ENABLE_VERIFIER */
148 #define CHECK_END_OF_BYTECODE(neededlength)
149 #endif /* ENABLE_VERIFIER */
151 bool parse(jitdata *jd)
155 int p; /* java instruction counter */
156 int nextp; /* start of next java instruction */
157 int opcode; /* java opcode */
158 int i; /* temporary for different uses (ctrs)*/
159 int ipc = 0; /* intermediate instruction counter */
160 int b_count = 0; /* basic block counter */
161 int s_count = 0; /* stack element counter */
162 bool blockend = false; /* true if basic block end has been reached */
163 bool iswide = false; /* true if last instruction was a wide*/
164 instruction *iptr; /* current ptr into instruction array */
165 int gp; /* global java instruction counter */
167 u1 *instructionstart; /* 1 for pcs which are valid instr. starts */
169 constant_classref *cr;
170 constant_classref *compr;
172 builtintable_entry *bte;
178 /* get required compiler data */
183 /* allocate instruction array and block index table */
185 /* 1 additional for end ipc */
186 m->basicblockindex = DMNEW(s4, m->jcodelength + 1);
187 memset(m->basicblockindex, 0, sizeof(s4) * (m->jcodelength + 1));
189 instructionstart = DMNEW(u1, m->jcodelength + 1);
190 memset(instructionstart, 0, sizeof(u1) * (m->jcodelength + 1));
192 /* 1 additional for TRACEBUILTIN and 4 for MONITORENTER/EXIT */
193 /* additional MONITOREXITS are reached by branches which are 3 bytes */
195 iptr = m->instructions = DMNEW(instruction, m->jcodelength + 5);
197 /* Zero the intermediate instructions array so we don't have any
198 * invalid pointers in it if we cannot finish analyse_stack(). */
200 memset(iptr, 0, sizeof(instruction) * (m->jcodelength + 5));
202 /* compute branch targets of exception table */
205 &(cd->exceptiontable[cd->exceptiontablelength-1]),
207 m->exceptiontablelength,
213 s_count = 1 + m->exceptiontablelength; /* initialize stack element counter */
215 #if defined(USE_THREADS)
216 if (checksync && (m->flags & ACC_SYNCHRONIZED)) {
217 m->isleafmethod = false;
221 /* scan all java instructions */
225 if (m->linenumbercount == 0) {
229 linepcchange = m->linenumbers[0].start_pc;
232 for (p = 0, gp = 0; p < m->jcodelength; gp += (nextp - p), p = nextp) {
234 /* mark this position as a valid instruction start */
235 instructionstart[gp] = 1;
236 if (linepcchange==p) {
237 if (m->linenumbercount > lineindex) {
238 currentline = m->linenumbers[lineindex].line_number;
240 if (lineindex < m->linenumbercount)
241 linepcchange = m->linenumbers[lineindex].start_pc;
245 /* fetch next opcode */
247 opcode = code_get_u1(p, m);
249 m->basicblockindex[gp] |= (ipc << 1); /*store intermed cnt*/
251 /* some compilers put a JAVA_NOP after a blockend instruction */
253 if (blockend && (opcode != JAVA_NOP)) {
254 /* start new block */
260 nextp = p + jcommandsize[opcode]; /* compute next instruction start */
262 CHECK_END_OF_BYTECODE(nextp);
264 s_count += stackreq[opcode]; /* compute stack element count */
269 /* pushing constants onto the stack p */
272 LOADCONST_I(code_get_s1(p+1,m));
276 LOADCONST_I(code_get_s2(p+1,m));
280 i = code_get_u1(p + 1, m);
281 goto pushconstantitem;
285 i = code_get_u2(p + 1, m);
289 #if defined(ENABLE_VERIFIER)
290 if (i >= m->class->cpcount) {
291 *exceptionptr = new_verifyerror(m,
292 "Attempt to access constant outside range");
297 switch (m->class->cptags[i]) {
298 case CONSTANT_Integer:
299 LOADCONST_I(((constant_integer *) (m->class->cpinfos[i]))->value);
302 LOADCONST_L(((constant_long *) (m->class->cpinfos[i]))->value);
305 LOADCONST_F(((constant_float *) (m->class->cpinfos[i]))->value);
307 case CONSTANT_Double:
308 LOADCONST_D(((constant_double *) (m->class->cpinfos[i]))->value);
310 case CONSTANT_String:
311 LOADCONST_A(literalstring_new((utf *) (m->class->cpinfos[i])));
314 cr = (constant_classref *) (m->class->cpinfos[i]);
316 if (!resolve_classref(m, cr, resolveLazy, true,
320 /* if not resolved, c == NULL */
322 LOADCONST_A_CLASS(c, cr);
325 #if defined(ENABLE_VERIFIER)
327 *exceptionptr = new_verifyerror(m,
328 "Invalid constant type to push");
334 case JAVA_ACONST_NULL:
345 LOADCONST_I(opcode - JAVA_ICONST_0);
350 LOADCONST_L(opcode - JAVA_LCONST_0);
356 LOADCONST_F(opcode - JAVA_FCONST_0);
361 LOADCONST_D(opcode - JAVA_DCONST_0);
364 /* loading variables onto the stack */
370 i = code_get_u1(p + 1,m);
373 i = code_get_u2(p + 1,m);
377 OP1LOAD_ONEWORD(opcode, i);
383 i = code_get_u1(p + 1,m);
386 i = code_get_u2(p + 1,m);
390 OP1LOAD_TWOWORD(opcode, i);
397 OP1LOAD_ONEWORD(ICMD_ILOAD, opcode - JAVA_ILOAD_0);
404 OP1LOAD_TWOWORD(ICMD_LLOAD, opcode - JAVA_LLOAD_0);
411 OP1LOAD_ONEWORD(ICMD_FLOAD, opcode - JAVA_FLOAD_0);
418 OP1LOAD_TWOWORD(ICMD_DLOAD, opcode - JAVA_DLOAD_0);
425 OP1LOAD_ONEWORD(ICMD_ALOAD, opcode - JAVA_ALOAD_0);
428 /* storing stack values into local variables */
434 i = code_get_u1(p + 1,m);
437 i = code_get_u2(p + 1,m);
441 OP1STORE_ONEWORD(opcode, i);
447 i = code_get_u1(p + 1,m);
450 i = code_get_u2(p + 1,m);
454 OP1STORE_TWOWORD(opcode, i);
461 OP1STORE_ONEWORD(ICMD_ISTORE, opcode - JAVA_ISTORE_0);
468 OP1STORE_TWOWORD(ICMD_LSTORE, opcode - JAVA_LSTORE_0);
475 OP1STORE_ONEWORD(ICMD_FSTORE, opcode - JAVA_FSTORE_0);
482 OP1STORE_TWOWORD(ICMD_DSTORE, opcode - JAVA_DSTORE_0);
489 OP1STORE_ONEWORD(ICMD_ASTORE, opcode - JAVA_ASTORE_0);
497 i = code_get_u1(p + 1,m);
498 v = code_get_s1(p + 2,m);
502 i = code_get_u2(p + 1,m);
503 v = code_get_s2(p + 3,m);
512 /* wider index for loading, storing and incrementing */
520 /* managing arrays ****************************************************/
523 switch (code_get_s1(p + 1, m)) {
525 bte = builtintable_get_internal(BUILTIN_newarray_boolean);
528 bte = builtintable_get_internal(BUILTIN_newarray_char);
531 bte = builtintable_get_internal(BUILTIN_newarray_float);
534 bte = builtintable_get_internal(BUILTIN_newarray_double);
537 bte = builtintable_get_internal(BUILTIN_newarray_byte);
540 bte = builtintable_get_internal(BUILTIN_newarray_short);
543 bte = builtintable_get_internal(BUILTIN_newarray_int);
546 bte = builtintable_get_internal(BUILTIN_newarray_long);
548 #if defined(ENABLE_VERIFIER)
550 *exceptionptr = new_verifyerror(m,
551 "Invalid array-type to create");
555 BUILTIN(bte, true, NULL, currentline);
559 i = code_get_u2(p + 1, m);
560 compr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
564 if (!(cr = class_get_classref_multiarray_of(1, compr)))
567 if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
570 LOADCONST_A_BUILTIN(c, cr);
571 bte = builtintable_get_internal(BUILTIN_newarray);
572 BUILTIN(bte, true, NULL, currentline);
576 case JAVA_MULTIANEWARRAY:
577 m->isleafmethod = false;
578 i = code_get_u2(p + 1, m);
580 s4 v = code_get_u1(p + 3, m);
582 cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
586 if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
589 /* if unresolved, c == NULL */
590 OP2AT(opcode, v, c, cr, currentline);
612 i = p + code_get_s2(p + 1,m);
613 CHECK_BYTECODE_INDEX(i);
621 i = p + code_get_s4(p + 1,m);
622 CHECK_BYTECODE_INDEX(i);
630 i = code_get_u1(p + 1,m);
633 i = code_get_u2(p + 1,m);
639 OP1LOAD_ONEWORD(opcode, i);
649 /* zero val.a so no patcher is inserted */
650 /* the type checker may set this later */
657 /* zero val.a so no patcher is inserted */
658 /* the type checker may set this later */
664 /* table jumps ********************************************************/
666 case JAVA_LOOKUPSWITCH:
670 #if defined(ENABLE_VERIFIER)
675 nextp = ALIGN((p + 1), 4);
677 CHECK_END_OF_BYTECODE(nextp + 8);
679 tablep = (s4 *) (m->jcode + nextp);
681 OP2A(opcode, 0, tablep, currentline);
685 j = p + code_get_s4(nextp, m);
686 *tablep = j; /* restore for little endian */
689 CHECK_BYTECODE_INDEX(j);
692 /* number of pairs */
694 num = code_get_u4(nextp, m);
699 CHECK_END_OF_BYTECODE(nextp + 8 * num);
701 for (i = 0; i < num; i++) {
704 j = code_get_s4(nextp, m);
705 *tablep = j; /* restore for little endian */
709 #if defined(ENABLE_VERIFIER)
710 /* check if the lookup table is sorted correctly */
712 if (i && (j <= prevvalue)) {
713 *exceptionptr = new_verifyerror(m, "Unsorted lookup switch");
721 j = p + code_get_s4(nextp,m);
722 *tablep = j; /* restore for little endian */
725 CHECK_BYTECODE_INDEX(j);
733 case JAVA_TABLESWITCH:
739 nextp = ALIGN((p + 1), 4);
741 CHECK_END_OF_BYTECODE(nextp + 12);
743 tablep = (s4 *) (m->jcode + nextp);
745 OP2A(opcode, 0, tablep, currentline);
749 j = p + code_get_s4(nextp, m);
750 *tablep = j; /* restore for little endian */
753 CHECK_BYTECODE_INDEX(j);
758 j = code_get_s4(nextp, m);
759 *tablep = j; /* restore for little endian */
765 num = code_get_s4(nextp, m);
766 *tablep = num; /* restore for little endian */
770 num -= j; /* difference of upper - lower */
772 #if defined(ENABLE_VERIFIER)
774 *exceptionptr = new_verifyerror(m,
775 "invalid TABLESWITCH: upper bound < lower bound");
780 CHECK_END_OF_BYTECODE(nextp + 4 * (num + 1));
782 for (i = 0; i <= num; i++) {
783 j = p + code_get_s4(nextp,m);
784 *tablep = j; /* restore for little endian */
787 CHECK_BYTECODE_INDEX(j);
795 /* load and store of object fields ************************************/
799 m->isleafmethod = false;
808 unresolved_field *uf;
811 i = code_get_u2(p + 1, m);
812 fr = class_getconstant(m->class, i,
817 OP2A_NOINC(opcode, fr->parseddesc.fd->type, fr, currentline);
819 if (!(uf = create_unresolved_field(m->class,
824 /* store unresolved_field pointer */
828 /* only with -noverify, otherwise the typechecker does this */
831 if (!resolve_field(uf, resolveLazy, &fi))
845 /* method invocation **************************************************/
847 case JAVA_INVOKESTATIC:
848 i = code_get_u2(p + 1, m);
852 unresolved_method *um;
855 m->isleafmethod = false;
857 mr = class_getconstant(m->class, i,
862 md = mr->parseddesc.md;
865 if (!descriptor_params_from_paramtypes(md, ACC_STATIC))
868 OP2A_NOINC(opcode, 0, mr, currentline);
870 um = create_unresolved_method(m->class,
876 /* store the unresolved_method pointer */
880 /* only with -noverify, otherwise the typechecker does this */
883 if (!resolve_method(um, resolveLazy, &mi))
895 case JAVA_INVOKESPECIAL:
896 case JAVA_INVOKEVIRTUAL:
900 unresolved_method *um;
903 m->isleafmethod = false;
905 i = code_get_u2(p + 1, m);
906 mr = class_getconstant(m->class, i,
911 md = mr->parseddesc.md;
914 if (!descriptor_params_from_paramtypes(md, 0))
917 OP2A_NOINC(opcode, 0, mr, currentline);
919 um = create_unresolved_method(m->class,
925 /* store the unresolved_method* */
929 /* only with -noverify, otherwise the typechecker does this */
932 if (!resolve_method(um, resolveLazy, &mi))
944 case JAVA_INVOKEINTERFACE:
945 i = code_get_u2(p + 1, m);
949 unresolved_method *um;
952 m->isleafmethod = false;
954 mr = class_getconstant(m->class, i,
955 CONSTANT_InterfaceMethodref);
959 md = mr->parseddesc.md;
962 if (!descriptor_params_from_paramtypes(md, 0))
965 OP2A_NOINC(opcode, 0, mr, currentline);
967 um = create_unresolved_method(m->class,
973 /* store the unresolved_method* */
977 /* only with -noverify, otherwise the typechecker does this */
980 if (!resolve_method(um, resolveLazy, &mi))
992 /* miscellaneous object operations ************************************/
995 i = code_get_u2(p + 1, m);
996 cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
1000 if (!resolve_classref(m, cr, resolveLazy, true, true,
1004 LOADCONST_A_BUILTIN(c, cr);
1005 bte = builtintable_get_internal(BUILTIN_new);
1006 BUILTIN(bte, true, NULL, currentline);
1010 case JAVA_CHECKCAST:
1011 i = code_get_u2(p + 1, m);
1012 cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
1016 if (!resolve_classref(m, cr, resolveLazy, true,
1020 if (cr->name->text[0] == '[') {
1021 /* array type cast-check */
1022 OP2AT(opcode, 0, c, cr, currentline);
1023 m->isleafmethod = false;
1027 /* object type cast-check */
1028 OP2AT(opcode, 1, c, cr, currentline);
1032 case JAVA_INSTANCEOF:
1033 i = code_get_u2(p + 1,m);
1034 cr = (constant_classref *) class_getconstant(m->class, i, CONSTANT_Class);
1038 if (!resolve_classref(m, cr, resolveLazy, true, true, &c))
1041 if (cr->name->text[0] == '[') {
1042 /* array type cast-check */
1043 LOADCONST_A_BUILTIN(c, cr);
1044 bte = builtintable_get_internal(BUILTIN_arrayinstanceof);
1045 BUILTIN(bte, false, NULL, currentline);
1050 /* object type cast-check */
1051 OP2AT(opcode, 1, c, cr, currentline);
1055 case JAVA_MONITORENTER:
1056 #if defined(USE_THREADS)
1059 bte = builtintable_get_internal(BUILTIN_monitorenter);
1060 BUILTIN(bte, false, NULL, currentline);
1070 case JAVA_MONITOREXIT:
1071 #if defined(USE_THREADS)
1073 bte = builtintable_get_internal(BUILTIN_monitorexit);
1074 BUILTIN(bte, false, NULL, currentline);
1083 /* any other basic operation ******************************************/
1086 #if !SUPPORT_DIVISION
1087 bte = builtintable_get_internal(BUILTIN_idiv);
1088 OP2A(opcode, bte->md->paramcount, bte, currentline);
1089 m->isleafmethod = false;
1096 #if !SUPPORT_DIVISION
1097 bte = builtintable_get_internal(BUILTIN_irem);
1098 OP2A(opcode, bte->md->paramcount, bte, currentline);
1099 m->isleafmethod = false;
1106 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1107 bte = builtintable_get_internal(BUILTIN_ldiv);
1108 OP2A(opcode, bte->md->paramcount, bte, currentline);
1109 m->isleafmethod = false;
1116 #if !(SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
1117 bte = builtintable_get_internal(BUILTIN_lrem);
1118 OP2A(opcode, bte->md->paramcount, bte, currentline);
1119 m->isleafmethod = false;
1126 #if defined(__I386__)
1129 bte = builtintable_get_internal(BUILTIN_frem);
1130 BUILTIN(bte, false, NULL, currentline);
1135 #if defined(__I386__)
1138 bte = builtintable_get_internal(BUILTIN_drem);
1139 BUILTIN(bte, false, NULL, currentline);
1144 #if defined(__ALPHA__)
1146 bte = builtintable_get_internal(BUILTIN_f2i);
1147 BUILTIN(bte, false, NULL, currentline);
1157 #if defined(__ALPHA__)
1159 bte = builtintable_get_internal(BUILTIN_f2l);
1160 BUILTIN(bte, false, NULL, currentline);
1170 #if defined(__ALPHA__)
1172 bte = builtintable_get_internal(BUILTIN_d2i);
1173 BUILTIN(bte, false, NULL, currentline);
1183 #if defined(__ALPHA__)
1185 bte = builtintable_get_internal(BUILTIN_d2l);
1186 BUILTIN(bte, false, NULL, currentline);
1195 /* check for invalid opcodes if the verifier is enabled */
1196 #if defined(ENABLE_VERIFIER)
1197 case JAVA_BREAKPOINT:
1199 new_verifyerror(m, "Quick instructions shouldn't appear yet.");
1202 case 186: /* unused opcode */
1257 new_verifyerror(m,"Illegal opcode %d at instr %d\n",
1261 #endif /* defined(ENABLE_VERIFIER) */
1264 /* straight-forward translation to ICMD */
1270 #if defined(ENABLE_VERIFIER)
1271 /* If WIDE was used correctly, iswide should have been reset by now. */
1273 *exceptionptr = new_verifyerror(m,
1274 "Illegal instruction: WIDE before incompatible opcode");
1277 #endif /* defined(ENABLE_VERIFIER) */
1281 #if defined(ENABLE_VERIFIER)
1282 if (p != m->jcodelength) {
1283 *exceptionptr = new_verifyerror(m,
1284 "Command-sequence crosses code-boundary");
1289 *exceptionptr = new_verifyerror(m, "Falling off the end of the code");
1292 #endif /* defined(ENABLE_VERIFIER) */
1294 /* adjust block count if target 0 is not first intermediate instruction */
1296 if (!m->basicblockindex[0] || (m->basicblockindex[0] > 1))
1299 /* copy local to method variables */
1301 m->instructioncount = ipc;
1302 m->basicblockcount = b_count;
1303 m->stackcount = s_count + m->basicblockcount * m->maxstack;
1305 /* allocate stack table */
1307 m->stack = DMNEW(stackelement, m->stackcount);
1312 bptr = m->basicblocks = DMNEW(basicblock, b_count + 1); /* one more for end ipc */
1317 /* additional block if target 0 is not first intermediate instruction */
1319 if (!m->basicblockindex[0] || (m->basicblockindex[0] > 1)) {
1320 BASICBLOCK_INIT(bptr,m);
1322 bptr->iinstr = m->instructions;
1323 /* bptr->icount is set when the next block is allocated */
1327 bptr[-1].next = bptr;
1330 /* allocate blocks */
1332 for (p = 0; p < m->jcodelength; p++) {
1333 if (m->basicblockindex[p] & 1) {
1334 /* Check if this block starts at the beginning of an */
1336 #if defined(ENABLE_VERIFIER)
1337 if (!instructionstart[p]) {
1338 *exceptionptr = new_verifyerror(m,
1339 "Branch into middle of instruction");
1344 /* allocate the block */
1346 BASICBLOCK_INIT(bptr,m);
1348 bptr->iinstr = m->instructions + (m->basicblockindex[p] >> 1);
1350 bptr[-1].icount = bptr->iinstr - bptr[-1].iinstr;
1352 /* bptr->icount is set when the next block is allocated */
1354 m->basicblockindex[p] = b_count;
1358 bptr[-1].next = bptr;
1362 /* set instruction count of last real block */
1365 bptr[-1].icount = (m->instructions + m->instructioncount) - bptr[-1].iinstr;
1368 /* allocate additional block at end */
1370 BASICBLOCK_INIT(bptr,m);
1372 bptr->instack = bptr->outstack = NULL;
1373 bptr->indepth = bptr->outdepth = 0;
1374 bptr->iinstr = NULL;
1378 /* set basicblock pointers in exception table */
1380 if (cd->exceptiontablelength > 0) {
1381 cd->exceptiontable[cd->exceptiontablelength - 1].down = NULL;
1384 for (i = 0; i < cd->exceptiontablelength; ++i) {
1385 p = cd->exceptiontable[i].startpc;
1386 cd->exceptiontable[i].start = m->basicblocks + m->basicblockindex[p];
1388 p = cd->exceptiontable[i].endpc;
1389 cd->exceptiontable[i].end = (p == m->jcodelength) ? (m->basicblocks + m->basicblockcount /*+ 1*/) : (m->basicblocks + m->basicblockindex[p]);
1391 p = cd->exceptiontable[i].handlerpc;
1392 cd->exceptiontable[i].handler = m->basicblocks + m->basicblockindex[p];
1395 /* XXX activate this if you want to try inlining */
1397 for (i = 0; i < m->exceptiontablelength; ++i) {
1398 p = m->exceptiontable[i].startpc;
1399 m->exceptiontable[i].start = m->basicblocks + m->basicblockindex[p];
1401 p = m->exceptiontable[i].endpc;
1402 m->exceptiontable[i].end = (p == m->jcodelength) ? (m->basicblocks + m->basicblockcount /*+ 1*/) : (m->basicblocks + m->basicblockindex[p]);
1404 p = m->exceptiontable[i].handlerpc;
1405 m->exceptiontable[i].handler = m->basicblocks + m->basicblockindex[p];
1411 /* everything's ok */
1415 #if defined(ENABLE_VERIFIER)
1417 throw_unexpected_end_of_bytecode:
1418 *exceptionptr = new_verifyerror(m, "Unexpected end of bytecode");
1421 throw_invalid_bytecode_index:
1423 new_verifyerror(m, "Illegal target of branch instruction");
1426 throw_illegal_local_variable_number:
1428 new_verifyerror(m, "Illegal local variable number");
1431 #endif /* ENABLE_VERIFIER */
1436 * These are local overrides for various environment variables in Emacs.
1437 * Please do not remove this and leave it at the end of the file, where
1438 * Emacs will automagically detect them.
1439 * ---------------------------------------------------------------------
1442 * indent-tabs-mode: t
1446 * vim:noexpandtab:sw=4:ts=4: