* src/vm/jit/jit.h (jitdata): Removed isleafmethod.
[cacao.git] / src / vm / jit / jit.c
1 /* src/vm/jit/jit.c - calls the code generation functions
2
3    Copyright (C) 1996-2005, 2006, 2007 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 */
26
27
28 #include "config.h"
29
30 #include <assert.h>
31
32 #include "vm/types.h"
33
34 #include "mm/memory.h"
35
36 #include "native/native.h"
37
38 #include "toolbox/logging.h"
39
40 #include "threads/lock-common.h"
41 #include "threads/threads-common.h"
42
43 #include "vm/global.h"
44 #include "vm/initialize.h"
45
46 #include "vm/jit/asmpart.h"
47
48 # include "vm/jit/cfg.h"
49
50 #include "vm/jit/codegen-common.h"
51 #include "vm/jit/disass.h"
52 #include "vm/jit/dseg.h"
53 #include "vm/jit/jit.h"
54 #include "vm/jit/md.h"
55 #include "vm/jit/parse.h"
56 #include "vm/jit/reg.h"
57
58 #include "vm/jit/show.h"
59 #include "vm/jit/stack.h"
60
61 #include "vm/jit/allocator/simplereg.h"
62 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
63 # include "vm/jit/allocator/lsra.h"
64 #endif
65 #if defined(ENABLE_SSA)
66 # include "vm/jit/optimizing/lsra.h"
67 # include "vm/jit/optimizing/ssa.h"
68 #endif
69
70 #if defined(ENABLE_INLINING)
71 # include "vm/jit/inline/inline.h"
72 #endif
73
74 #include "vm/jit/loop/analyze.h"
75 #include "vm/jit/loop/graph.h"
76 #include "vm/jit/loop/loop.h"
77
78 #if defined(ENABLE_IFCONV)
79 # include "vm/jit/optimizing/ifconv.h"
80 #endif
81
82 #include "vm/jit/optimizing/reorder.h"
83
84 #include "vm/jit/verify/typecheck.h"
85
86 #include "vmcore/class.h"
87 #include "vmcore/loader.h"
88 #include "vmcore/method.h"
89 #include "vmcore/options.h"
90 #include "vmcore/rt-timing.h"
91 #include "vmcore/statistics.h"
92
93
94 /* debug macros ***************************************************************/
95
96 #if !defined(NDEBUG)
97 #define DEBUG_JIT_COMPILEVERBOSE(x)                             \
98     do {                                                                                \
99         if (compileverbose) {                                   \
100             log_message_method(x, m);                   \
101         }                                                                               \
102     } while (0)
103 #else
104 #define DEBUG_JIT_COMPILEVERBOSE(x)    /* nothing */
105 #endif
106
107 #if !defined(NDEBUG)
108 # define TRACECOMPILERCALLS()                                                           \
109         do {                                                                                                    \
110                 if (opt_TraceCompilerCalls) {                                           \
111                         log_start();                                                                    \
112                         log_print("[JIT compiler started: method=");    \
113                         method_print(m);                                                                \
114                         log_print("]");                                                                 \
115                         log_finish();                                                                   \
116                 }                                                                                                       \
117         } while (0)
118 #else
119 # define TRACECOMPILERCALLS()
120 #endif
121
122
123 /* the ICMD table ************************************************************/
124
125 #if !defined(NDEBUG)
126 #define N(name)  name,
127 #else
128 #define N(name)
129 #endif
130
131 /* abbreviations for flags */
132
133 #define PEI     ICMDTABLE_PEI
134 #define CALLS   ICMDTABLE_CALLS
135
136 /* some machine dependent values */
137
138 #if SUPPORT_DIVISION
139 #define IDIV_CALLS  0
140 #else
141 #define IDIV_CALLS  ICMDTABLE_CALLS
142 #endif
143
144 #if (SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
145 #define LDIV_CALLS  0
146 #else
147 #define LDIV_CALLS  ICMDTABLE_CALLS
148 #endif
149
150 /* include the actual table */
151
152 icmdtable_entry_t icmd_table[256] = {
153 #include <vm/jit/icmdtable.inc>
154 };
155
156 #undef N
157 #undef PEI
158 #undef CALLS
159
160 /* XXX hack until the old "PEI" definition is removed */
161 #define PEI 1
162
163
164 /* stackelement requirements of Java opcodes **********************************/
165
166 int stackreq[256] = {
167         0,    /* JAVA_NOP                         0 */
168         1,    /* JAVA_ACONST                      1 */
169         1,    /* JAVA_ICONST_M1                   2 */
170         1,    /* JAVA_ICONST_0                    3 */
171         1,    /* JAVA_ICONST_1                    4 */
172         1,    /* JAVA_ICONST_2                    5 */
173         1,    /* JAVA_ICONST_3                    6 */
174         1,    /* JAVA_ICONST_4                    7 */
175         1,    /* JAVA_ICONST_5                    8 */
176         1,    /* JAVA_LCONST_0                    9 */
177         1,    /* JAVA_LCONST_1                   10 */
178         1,    /* JAVA_FCONST_0                   11 */
179         1,    /* JAVA_FCONST_1                   12 */
180         1,    /* JAVA_FCONST_2                   13 */
181         1,    /* JAVA_DCONST_0                   14 */
182         1,    /* JAVA_DCONST_1                   15 */
183         1,    /* JAVA_BIPUSH                     16 */
184         1,    /* JAVA_SIPUSH                     17 */
185         1,    /* JAVA_LDC                        18 */
186         1,    /* JAVA_LDC_W                      19 */
187         1,    /* JAVA_LDC2_W                     20 */
188         1,    /* JAVA_ILOAD                      21 */
189         1,    /* JAVA_LLOAD                      22 */
190         1,    /* JAVA_FLOAD                      23 */
191         1,    /* JAVA_DLOAD                      24 */
192         1,    /* JAVA_ALOAD                      25 */
193         1,    /* JAVA_ILOAD_0                    26 */
194         1,    /* JAVA_ILOAD_1                    27 */
195         1,    /* JAVA_ILOAD_2                    28 */
196         1,    /* JAVA_ILOAD_3                    29 */
197         1,    /* JAVA_LLOAD_0                    30 */
198         1,    /* JAVA_LLOAD_1                    31 */
199         1,    /* JAVA_LLOAD_2                    32 */
200         1,    /* JAVA_LLOAD_3                    33 */
201         1,    /* JAVA_FLOAD_0                    34 */
202         1,    /* JAVA_FLOAD_1                    35 */
203         1,    /* JAVA_FLOAD_2                    36 */
204         1,    /* JAVA_FLOAD_3                    37 */
205         1,    /* JAVA_DLOAD_0                    38 */
206         1,    /* JAVA_DLOAD_1                    39 */
207         1,    /* JAVA_DLOAD_2                    40 */
208         1,    /* JAVA_DLOAD_3                    41 */
209         1,    /* JAVA_ALOAD_0                    42 */
210         1,    /* JAVA_ALOAD_1                    43 */
211         1,    /* JAVA_ALOAD_2                    44 */
212         1,    /* JAVA_ALOAD_3                    45 */
213         1,    /* JAVA_IALOAD                     46 */
214         1,    /* JAVA_LALOAD                     47 */
215         1,    /* JAVA_FALOAD                     48 */
216         1,    /* JAVA_DALOAD                     49 */
217         1,    /* JAVA_AALOAD                     50 */
218         1,    /* JAVA_BALOAD                     51 */
219         1,    /* JAVA_CALOAD                     52 */
220         1,    /* JAVA_SALOAD                     53 */
221         0,    /* JAVA_ISTORE                     54 */
222         0,    /* JAVA_LSTORE                     55 */
223         0,    /* JAVA_FSTORE                     56 */
224         0,    /* JAVA_DSTORE                     57 */
225         0,    /* JAVA_ASTORE                     58 */
226         0,    /* JAVA_ISTORE_0                   59 */
227         0,    /* JAVA_ISTORE_1                   60 */
228         0,    /* JAVA_ISTORE_2                   61 */
229         0,    /* JAVA_ISTORE_3                   62 */
230         0,    /* JAVA_LSTORE_0                   63 */
231         0,    /* JAVA_LSTORE_1                   64 */
232         0,    /* JAVA_LSTORE_2                   65 */
233         0,    /* JAVA_LSTORE_3                   66 */
234         0,    /* JAVA_FSTORE_0                   67 */
235         0,    /* JAVA_FSTORE_1                   68 */
236         0,    /* JAVA_FSTORE_2                   69 */
237         0,    /* JAVA_FSTORE_3                   70 */
238         0,    /* JAVA_DSTORE_0                   71 */
239         0,    /* JAVA_DSTORE_1                   72 */
240         0,    /* JAVA_DSTORE_2                   73 */
241         0,    /* JAVA_DSTORE_3                   74 */
242         0,    /* JAVA_ASTORE_0                   75 */
243         0,    /* JAVA_ASTORE_1                   76 */
244         0,    /* JAVA_ASTORE_2                   77 */
245         0,    /* JAVA_ASTORE_3                   78 */
246         0,    /* JAVA_IASTORE                    79 */
247         0,    /* JAVA_LASTORE                    80 */
248         0,    /* JAVA_FASTORE                    81 */
249         0,    /* JAVA_DASTORE                    82 */
250         0,    /* JAVA_AASTORE                    83 */
251         0,    /* JAVA_BASTORE                    84 */
252         0,    /* JAVA_CASTORE                    85 */
253         0,    /* JAVA_SASTORE                    86 */
254         0,    /* JAVA_POP                        87 */
255         0,    /* JAVA_POP2                       88 */
256         1,    /* JAVA_DUP                        89 */
257         1+3,  /* JAVA_DUP_X1                     90 */
258         2+4,  /* JAVA_DUP_X2                     91 */
259         2,    /* JAVA_DUP2                       92 */
260         2+5,  /* JAVA_DUP2_X1                    93 */
261         3+6,  /* JAVA_DUP2_X2                    94 */
262         1+2,  /* JAVA_SWAP                       95 */
263         1,    /* JAVA_IADD                       96 */
264         1,    /* JAVA_LADD                       97 */
265         1,    /* JAVA_FADD                       98 */
266         1,    /* JAVA_DADD                       99 */
267         1,    /* JAVA_ISUB                      100 */
268         1,    /* JAVA_LSUB                      101 */
269         1,    /* JAVA_FSUB                      102 */
270         1,    /* JAVA_DSUB                      103 */
271         1,    /* JAVA_IMUL                      104 */
272         1,    /* JAVA_LMUL                      105 */
273         1,    /* JAVA_FMUL                      106 */
274         1,    /* JAVA_DMUL                      107 */
275         1,    /* JAVA_IDIV                      108 */
276         1,    /* JAVA_LDIV                      109 */
277         1,    /* JAVA_FDIV                      110 */
278         1,    /* JAVA_DDIV                      111 */
279         1,    /* JAVA_IREM                      112 */
280         1,    /* JAVA_LREM                      113 */
281         1,    /* JAVA_FREM                      114 */
282         1,    /* JAVA_DREM                      115 */
283         1,    /* JAVA_INEG                      116 */
284         1,    /* JAVA_LNEG                      117 */
285         1,    /* JAVA_FNEG                      118 */
286         1,    /* JAVA_DNEG                      119 */
287         1,    /* JAVA_ISHL                      120 */
288         1,    /* JAVA_LSHL                      121 */
289         1,    /* JAVA_ISHR                      122 */
290         1,    /* JAVA_LSHR                      123 */
291         1,    /* JAVA_IUSHR                     124 */
292         1,    /* JAVA_LUSHR                     125 */
293         1,    /* JAVA_IAND                      126 */
294         1,    /* JAVA_LAND                      127 */
295         1,    /* JAVA_IOR                       128 */
296         1,    /* JAVA_LOR                       129 */
297         1,    /* JAVA_IXOR                      130 */
298         1,    /* JAVA_LXOR                      131 */
299         0,    /* JAVA_IINC                      132 */
300         1,    /* JAVA_I2L                       133 */
301         1,    /* JAVA_I2F                       134 */
302         1,    /* JAVA_I2D                       135 */
303         1,    /* JAVA_L2I                       136 */
304         1,    /* JAVA_L2F                       137 */
305         1,    /* JAVA_L2D                       138 */
306         1,    /* JAVA_F2I                       139 */
307         1,    /* JAVA_F2L                       140 */
308         1,    /* JAVA_F2D                       141 */
309         1,    /* JAVA_D2I                       142 */
310         1,    /* JAVA_D2L                       143 */
311         1,    /* JAVA_D2F                       144 */
312         1,    /* JAVA_INT2BYTE                  145 */
313         1,    /* JAVA_INT2CHAR                  146 */
314         1,    /* JAVA_INT2SHORT                 147 */
315         1,    /* JAVA_LCMP                      148 */
316         1,    /* JAVA_FCMPL                     149 */
317         1,    /* JAVA_FCMPG                     150 */
318         1,    /* JAVA_DCMPL                     151 */
319         1,    /* JAVA_DCMPG                     152 */
320         0,    /* JAVA_IFEQ                      153 */
321         0,    /* JAVA_IFNE                      154 */
322         0,    /* JAVA_IFLT                      155 */
323         0,    /* JAVA_IFGE                      156 */
324         0,    /* JAVA_IFGT                      157 */
325         0,    /* JAVA_IFLE                      158 */
326         0,    /* JAVA_IF_ICMPEQ                 159 */
327         0,    /* JAVA_IF_ICMPNE                 160 */
328         0,    /* JAVA_IF_ICMPLT                 161 */
329         0,    /* JAVA_IF_ICMPGE                 162 */
330         0,    /* JAVA_IF_ICMPGT                 163 */
331         0,    /* JAVA_IF_ICMPLE                 164 */
332         0,    /* JAVA_IF_ACMPEQ                 165 */
333         0,    /* JAVA_IF_ACMPNE                 166 */
334         0,    /* JAVA_GOTO                      167 */
335         1,    /* JAVA_JSR                       168 */
336         0,    /* JAVA_RET                       169 */
337         0,    /* JAVA_TABLESWITCH               170 */
338         0,    /* JAVA_LOOKUPSWITCH              171 */
339         0,    /* JAVA_IRETURN                   172 */
340         0,    /* JAVA_LRETURN                   173 */
341         0,    /* JAVA_FRETURN                   174 */
342         0,    /* JAVA_DRETURN                   175 */
343         0,    /* JAVA_ARETURN                   176 */
344         0,    /* JAVA_RETURN                    177 */
345         1,    /* JAVA_GETSTATIC                 178 */
346         0,    /* JAVA_PUTSTATIC                 179 */
347         1,    /* JAVA_GETFIELD                  180 */
348         0,    /* JAVA_PUTFIELD                  181 */
349         1,    /* JAVA_INVOKEVIRTUAL             182 */
350         1,    /* JAVA_INVOKESPECIAL             183 */
351         1,    /* JAVA_INVOKESTATIC              184 */
352         1,    /* JAVA_INVOKEINTERFACE           185 */
353         1,    /* JAVA_UNDEF186                  186 */
354         1,    /* JAVA_NEW                       187 */
355         1,    /* JAVA_NEWARRAY                  188 */
356         1,    /* JAVA_ANEWARRAY                 189 */
357         1,    /* JAVA_ARRAYLENGTH               190 */
358         1,    /* JAVA_ATHROW                    191 */
359         1,    /* JAVA_CHECKCAST                 192 */
360         1,    /* JAVA_INSTANCEOF                193 */
361         0,    /* JAVA_MONITORENTER              194 */
362         0,    /* JAVA_MONITOREXIT               195 */
363         0,    /* JAVA_WIDE                      196 */
364         1,    /* JAVA_MULTIANEWARRAY            197 */
365         0,    /* JAVA_IFNULL                    198 */
366         0,    /* JAVA_IFNONNULL                 199 */
367         0,    /* JAVA_GOTO_W                    200 */
368         1,    /* JAVA_JSR_W                     201 */
369         0,    /* JAVA_BREAKPOINT                202 */
370         1,    /* JAVA_UNDEF203                  203 */
371         1,    /* JAVA_UNDEF204                  204 */
372         1,    /* JAVA_UNDEF205                  205 */
373         1,    /* JAVA_UNDEF206                  206 */
374         1,    /* JAVA_UNDEF207                  207 */
375         1,    /* JAVA_UNDEF208                  208 */
376         1,    /* JAVA_UNDEF209                  209 */
377         1,    /* JAVA_UNDEF210                  210 */
378         1,    /* JAVA_UNDEF211                  211 */
379         1,    /* JAVA_UNDEF212                  212 */
380         1,    /* JAVA_UNDEF213                  213 */
381         1,    /* JAVA_UNDEF214                  214 */
382         1,    /* JAVA_UNDEF215                  215 */
383         1,    /* JAVA_UNDEF216                  216 */
384         1,    /* JAVA_UNDEF217                  217 */
385         1,    /* JAVA_UNDEF218                  218 */
386         1,    /* JAVA_UNDEF219                  219 */
387         1,    /* JAVA_UNDEF220                  220 */
388         1,    /* JAVA_UNDEF221                  221 */
389         1,    /* JAVA_UNDEF222                  222 */
390         1,    /* JAVA_UNDEF223                  223 */
391         1,    /* JAVA_UNDEF224                  224 */
392         1,    /* JAVA_UNDEF225                  225 */
393         1,    /* JAVA_UNDEF226                  226 */
394         1,    /* JAVA_UNDEF227                  227 */
395         1,    /* JAVA_UNDEF228                  228 */
396         1,    /* JAVA_UNDEF229                  229 */
397         1,    /* JAVA_UNDEF230                  230 */
398         1,    /* JAVA_UNDEF231                  231 */
399         1,    /* JAVA_UNDEF232                  232 */
400         1,    /* JAVA_UNDEF233                  233 */
401         1,    /* JAVA_UNDEF234                  234 */
402         1,    /* JAVA_UNDEF235                  235 */
403         1,    /* JAVA_UNDEF236                  236 */
404         1,    /* JAVA_UNDEF237                  237 */
405         1,    /* JAVA_UNDEF238                  238 */
406         1,    /* JAVA_UNDEF239                  239 */
407         1,    /* JAVA_UNDEF240                  240 */
408         1,    /* JAVA_UNDEF241                  241 */
409         1,    /* JAVA_UNDEF242                  242 */
410         1,    /* JAVA_UNDEF243                  243 */
411         1,    /* JAVA_UNDEF244                  244 */
412         1,    /* JAVA_UNDEF245                  245 */
413         1,    /* JAVA_UNDEF246                  246 */
414         1,    /* JAVA_UNDEF247                  247 */
415         1,    /* JAVA_UNDEF248                  248 */
416         1,    /* JAVA_UNDEF249                  249 */
417         1,    /* JAVA_UNDEF250                  250 */
418         1,    /* JAVA_UNDEF251                  251 */
419         1,    /* JAVA_UNDEF252                  252 */
420         1,    /* JAVA_UNDEF253                  253 */
421         1,    /* JAVA_UNDEF254                  254 */
422         1,    /* JAVA_UNDEF255                  255 */
423 };
424
425
426 /* size in bytes of Java opcodes **********************************************/
427                                 
428 int jcommandsize[256] = {
429
430         1,    /* JAVA_NOP                         0 */
431         1,    /* JAVA_ACONST_NULL                 1 */
432         1,    /* JAVA_ICONST_M1                   2 */
433         1,    /* JAVA_ICONST_0                    3 */
434         1,    /* JAVA_ICONST_1                    4 */
435         1,    /* JAVA_ICONST_2                    5 */
436         1,    /* JAVA_ICONST_3                    6 */
437         1,    /* JAVA_ICONST_4                    7 */
438         1,    /* JAVA_ICONST_5                    8 */
439         1,    /* JAVA_LCONST_0                    9 */
440         1,    /* JAVA_LCONST_1                   10 */
441         1,    /* JAVA_FCONST_0                   11 */
442         1,    /* JAVA_FCONST_1                   12 */
443         1,    /* JAVA_FCONST_2                   13 */
444         1,    /* JAVA_DCONST_0                   14 */
445         1,    /* JAVA_DCONST_1                   15 */
446         2,    /* JAVA_BIPUSH                     16 */
447         3,    /* JAVA_SIPUSH                     17 */
448         2,    /* JAVA_LDC1                       18 */
449         3,    /* JAVA_LDC2                       19 */
450         3,    /* JAVA_LDC2W                      20 */
451         2,    /* JAVA_ILOAD                      21 */
452         2,    /* JAVA_LLOAD                      22 */
453         2,    /* JAVA_FLOAD                      23 */
454         2,    /* JAVA_DLOAD                      24 */
455         2,    /* JAVA_ALOAD                      25 */
456         1,    /* JAVA_ILOAD_0                    26 */
457         1,    /* JAVA_ILOAD_1                    27 */
458         1,    /* JAVA_ILOAD_2                    28 */
459         1,    /* JAVA_ILOAD_3                    29 */
460         1,    /* JAVA_LLOAD_0                    30 */
461         1,    /* JAVA_LLOAD_1                    31 */
462         1,    /* JAVA_LLOAD_2                    32 */
463         1,    /* JAVA_LLOAD_3                    33 */
464         1,    /* JAVA_FLOAD_0                    34 */
465         1,    /* JAVA_FLOAD_1                    35 */
466         1,    /* JAVA_FLOAD_2                    36 */
467         1,    /* JAVA_FLOAD_3                    37 */
468         1,    /* JAVA_DLOAD_0                    38 */
469         1,    /* JAVA_DLOAD_1                    39 */
470         1,    /* JAVA_DLOAD_2                    40 */
471         1,    /* JAVA_DLOAD_3                    41 */
472         1,    /* JAVA_ALOAD_0                    42 */
473         1,    /* JAVA_ALOAD_1                    43 */
474         1,    /* JAVA_ALOAD_2                    44 */
475         1,    /* JAVA_ALOAD_3                    45 */
476         1,    /* JAVA_IALOAD                     46 */
477         1,    /* JAVA_LALOAD                     47 */
478         1,    /* JAVA_FALOAD                     48 */
479         1,    /* JAVA_DALOAD                     49 */
480         1,    /* JAVA_AALOAD                     50 */
481         1,    /* JAVA_BALOAD                     51 */
482         1,    /* JAVA_CALOAD                     52 */
483         1,    /* JAVA_SALOAD                     53 */
484         2,    /* JAVA_ISTORE                     54 */
485         2,    /* JAVA_LSTORE                     55 */
486         2,    /* JAVA_FSTORE                     56 */
487         2,    /* JAVA_DSTORE                     57 */
488         2,    /* JAVA_ASTORE                     58 */
489         1,    /* JAVA_ISTORE_0                   59 */
490         1,    /* JAVA_ISTORE_1                   60 */
491         1,    /* JAVA_ISTORE_2                   61 */
492         1,    /* JAVA_ISTORE_3                   62 */
493         1,    /* JAVA_LSTORE_0                   63 */
494         1,    /* JAVA_LSTORE_1                   64 */
495         1,    /* JAVA_LSTORE_2                   65 */
496         1,    /* JAVA_LSTORE_3                   66 */
497         1,    /* JAVA_FSTORE_0                   67 */
498         1,    /* JAVA_FSTORE_1                   68 */
499         1,    /* JAVA_FSTORE_2                   69 */
500         1,    /* JAVA_FSTORE_3                   70 */
501         1,    /* JAVA_DSTORE_0                   71 */
502         1,    /* JAVA_DSTORE_1                   72 */
503         1,    /* JAVA_DSTORE_2                   73 */
504         1,    /* JAVA_DSTORE_3                   74 */
505         1,    /* JAVA_ASTORE_0                   75 */
506         1,    /* JAVA_ASTORE_1                   76 */
507         1,    /* JAVA_ASTORE_2                   77 */
508         1,    /* JAVA_ASTORE_3                   78 */
509         1,    /* JAVA_IASTORE                    79 */
510         1,    /* JAVA_LASTORE                    80 */
511         1,    /* JAVA_FASTORE                    81 */
512         1,    /* JAVA_DASTORE                    82 */
513         1,    /* JAVA_AASTORE                    83 */
514         1,    /* JAVA_BASTORE                    84 */
515         1,    /* JAVA_CASTORE                    85 */
516         1,    /* JAVA_SASTORE                    86 */
517         1,    /* JAVA_POP                        87 */
518         1,    /* JAVA_POP2                       88 */
519         1,    /* JAVA_DUP                        89 */
520         1,    /* JAVA_DUP_X1                     90 */
521         1,    /* JAVA_DUP_X2                     91 */
522         1,    /* JAVA_DUP2                       92 */
523         1,    /* JAVA_DUP2_X1                    93 */
524         1,    /* JAVA_DUP2_X2                    94 */
525         1,    /* JAVA_SWAP                       95 */
526         1,    /* JAVA_IADD                       96 */
527         1,    /* JAVA_LADD                       97 */
528         1,    /* JAVA_FADD                       98 */
529         1,    /* JAVA_DADD                       99 */
530         1,    /* JAVA_ISUB                      100 */
531         1,    /* JAVA_LSUB                      101 */
532         1,    /* JAVA_FSUB                      102 */
533         1,    /* JAVA_DSUB                      103 */
534         1,    /* JAVA_IMUL                      104 */
535         1,    /* JAVA_LMUL                      105 */
536         1,    /* JAVA_FMUL                      106 */
537         1,    /* JAVA_DMUL                      107 */
538         1,    /* JAVA_IDIV                      108 */
539         1,    /* JAVA_LDIV                      109 */
540         1,    /* JAVA_FDIV                      110 */
541         1,    /* JAVA_DDIV                      111 */
542         1,    /* JAVA_IREM                      112 */
543         1,    /* JAVA_LREM                      113 */
544         1,    /* JAVA_FREM                      114 */
545         1,    /* JAVA_DREM                      115 */
546         1,    /* JAVA_INEG                      116 */
547         1,    /* JAVA_LNEG                      117 */
548         1,    /* JAVA_FNEG                      118 */
549         1,    /* JAVA_DNEG                      119 */
550         1,    /* JAVA_ISHL                      120 */
551         1,    /* JAVA_LSHL                      121 */
552         1,    /* JAVA_ISHR                      122 */
553         1,    /* JAVA_LSHR                      123 */
554         1,    /* JAVA_IUSHR                     124 */
555         1,    /* JAVA_LUSHR                     125 */
556         1,    /* JAVA_IAND                      126 */
557         1,    /* JAVA_LAND                      127 */
558         1,    /* JAVA_IOR                       128 */
559         1,    /* JAVA_LOR                       129 */
560         1,    /* JAVA_IXOR                      130 */
561         1,    /* JAVA_LXOR                      131 */
562         3,    /* JAVA_IINC                      132 */
563         1,    /* JAVA_I2L                       133 */
564         1,    /* JAVA_I2F                       134 */
565         1,    /* JAVA_I2D                       135 */
566         1,    /* JAVA_L2I                       136 */
567         1,    /* JAVA_L2F                       137 */
568         1,    /* JAVA_L2D                       138 */
569         1,    /* JAVA_F2I                       139 */
570         1,    /* JAVA_F2L                       140 */
571         1,    /* JAVA_F2D                       141 */
572         1,    /* JAVA_D2I                       142 */
573         1,    /* JAVA_D2L                       143 */
574         1,    /* JAVA_D2F                       144 */
575         1,    /* JAVA_INT2BYTE                  145 */
576         1,    /* JAVA_INT2CHAR                  146 */
577         1,    /* JAVA_INT2SHORT                 147 */
578         1,    /* JAVA_LCMP                      148 */
579         1,    /* JAVA_FCMPL                     149 */
580         1,    /* JAVA_FCMPG                     150 */
581         1,    /* JAVA_DCMPL                     151 */
582         1,    /* JAVA_DCMPG                     152 */
583         3,    /* JAVA_IFEQ                      153 */
584         3,    /* JAVA_IFNE                      154 */
585         3,    /* JAVA_IFLT                      155 */
586         3,    /* JAVA_IFGE                      156 */
587         3,    /* JAVA_IFGT                      157 */
588         3,    /* JAVA_IFLE                      158 */
589         3,    /* JAVA_IF_ICMPEQ                 159 */
590         3,    /* JAVA_IF_ICMPNE                 160 */
591         3,    /* JAVA_IF_ICMPLT                 161 */
592         3,    /* JAVA_IF_ICMPGE                 162 */
593         3,    /* JAVA_IF_ICMPGT                 163 */
594         3,    /* JAVA_IF_ICMPLE                 164 */
595         3,    /* JAVA_IF_ACMPEQ                 165 */
596         3,    /* JAVA_IF_ACMPNE                 166 */
597         3,    /* JAVA_GOTO                      167 */
598         3,    /* JAVA_JSR                       168 */
599         2,    /* JAVA_RET                       169 */
600         0,    /* JAVA_TABLESWITCH               170 */ /* variable length */
601         0,    /* JAVA_LOOKUPSWITCH              171 */ /* variable length */
602         1,    /* JAVA_IRETURN                   172 */
603         1,    /* JAVA_LRETURN                   173 */
604         1,    /* JAVA_FRETURN                   174 */
605         1,    /* JAVA_DRETURN                   175 */
606         1,    /* JAVA_ARETURN                   176 */
607         1,    /* JAVA_RETURN                    177 */
608         3,    /* JAVA_GETSTATIC                 178 */
609         3,    /* JAVA_PUTSTATIC                 179 */
610         3,    /* JAVA_GETFIELD                  180 */
611         3,    /* JAVA_PUTFIELD                  181 */
612         3,    /* JAVA_INVOKEVIRTUAL             182 */
613         3,    /* JAVA_INVOKESPECIAL             183 */
614         3,    /* JAVA_INVOKESTATIC              184 */
615         5,    /* JAVA_INVOKEINTERFACE           185 */
616         1,    /* UNDEF186 */
617         3,    /* JAVA_NEW                       187 */
618         2,    /* JAVA_NEWARRAY                  188 */
619         3,    /* JAVA_ANEWARRAY                 189 */
620         1,    /* JAVA_ARRAYLENGTH               190 */
621         1,    /* JAVA_ATHROW                    191 */
622         3,    /* JAVA_CHECKCAST                 192 */
623         3,    /* JAVA_INSTANCEOF                193 */
624         1,    /* JAVA_MONITORENTER              194 */
625         1,    /* JAVA_MONITOREXIT               195 */
626         0,    /* JAVA_WIDE                      196 */ /* variable length */
627         4,    /* JAVA_MULTIANEWARRAY            197 */
628         3,    /* JAVA_IFNULL                    198 */
629         3,    /* JAVA_IFNONNULL                 199 */
630         5,    /* JAVA_GOTO_W                    200 */
631         5,    /* JAVA_JSR_W                     201 */
632         1,    /* JAVA_BREAKPOINT                202 */
633
634         1,    /* UNDEF203 */
635         1,
636         1,
637         1,
638         1,
639         1,
640         1,
641         1,    /* UNDEF210 */
642         1,
643         1,
644         1,
645         1,
646         1,
647         1,
648         1,
649         1,
650         1,
651         1,    /* UNDEF220 */
652         1,
653         1,
654         1,
655         1,
656         1,
657         1,
658         1,
659         1,
660         1,
661         1,    /* UNDEF230 */
662         1,
663         1,
664         1,
665         1,
666
667         /* unused */
668                 1,1,1,1,1,1,
669         1,1,1,1,1,1,1,1,1,1,
670         1,1,1,1,1
671 };
672
673
674 /* Java opcode names *********************************************************/
675
676 char *opcode_names[256] = {
677         "NOP            ", /*               0 */
678         "ACONST         ", /*               1 */
679         "ICONST_M1      ", /* ICONST_M1     2 */
680         "ICONST_0       ", /* ICONST_0      3 */
681         "ICONST_1       ", /* ICONST_1      4 */
682         "ICONST_2       ", /* ICONST_2      5 */
683         "ICONST_3       ", /* ICONST_3      6 */
684         "ICONST_4       ", /* ICONST_4      7 */
685         "ICONST_5       ", /* ICONST_5      8 */
686         "LCONST_0       ", /* LCONST_0      9 */
687         "LCONST_1       ", /* LCONST_1     10 */
688         "FCONST_0       ", /* FCONST_0     11 */
689         "FCONST_1       ", /* FCONST_1     12 */
690         "FCONST_2       ", /* FCONST_2     13 */
691         "DCONST_0       ", /* DCONST_0     14 */
692         "DCONST_1       ", /* DCONST_1     15 */
693         "BIPUSH         ", /* BIPUSH       16 */
694         "SIPUSH         ", /* SIPUSH       17 */
695         "LDC            ", /* LDC          18 */
696         "LDC_W          ", /* LDC_W        19 */
697         "LDC2_W         ", /* LDC2_W       20 */
698         "ILOAD          ", /*              21 */
699         "LLOAD          ", /*              22 */
700         "FLOAD          ", /*              23 */
701         "DLOAD          ", /*              24 */
702         "ALOAD          ", /*              25 */
703         "ILOAD_0        ", /* ILOAD_0      26 */
704         "ILOAD_1        ", /* ILOAD_1      27 */
705         "ILOAD_2        ", /* ILOAD_2      28 */
706         "ILOAD_3        ", /* ILOAD_3      29 */
707         "LLOAD_0        ", /* LLOAD_0      30 */
708         "LLOAD_1        ", /* LLOAD_1      31 */
709         "LLOAD_2        ", /* LLOAD_2      32 */
710         "LLOAD_3        ", /* LLOAD_3      33 */
711         "FLOAD_0        ", /* FLOAD_0      34 */
712         "FLOAD_1        ", /* FLOAD_1      35 */
713         "FLOAD_2        ", /* FLOAD_2      36 */
714         "FLOAD_3        ", /* FLOAD_3      37 */
715         "DLOAD_0        ", /* DLOAD_0      38 */
716         "DLOAD_1        ", /* DLOAD_1      39 */
717         "DLOAD_2        ", /* DLOAD_2      40 */ 
718         "DLOAD_3        ", /* DLOAD_3      41 */
719         "ALOAD_0        ", /* ALOAD_0      42 */
720         "ALOAD_1        ", /* ALOAD_1      43 */
721         "ALOAD_2        ", /* ALOAD_2      44 */
722         "ALOAD_3        ", /* ALOAD_3      45 */
723         "IALOAD         ", /*              46 */
724         "LALOAD         ", /*              47 */
725         "FALOAD         ", /*              48 */
726         "DALOAD         ", /*              49 */
727         "AALOAD         ", /*              50 */
728         "BALOAD         ", /*              51 */
729         "CALOAD         ", /*              52 */
730         "SALOAD         ", /*              53 */
731         "ISTORE         ", /*              54 */
732         "LSTORE         ", /*              55 */
733         "FSTORE         ", /*              56 */
734         "DSTORE         ", /*              57 */
735         "ASTORE         ", /*              58 */
736         "ISTORE_0       ", /* ISTORE_0     59 */
737         "ISTORE_1       ", /* ISTORE_1     60 */
738         "ISTORE_2       ", /* ISTORE_2     61 */
739         "ISTORE_3       ", /* ISTORE_3     62 */
740         "LSTORE_0       ", /* LSTORE_0     63 */
741         "LSTORE_1       ", /* LSTORE_1     64 */
742         "LSTORE_2       ", /* LSTORE_2     65 */
743         "LSTORE_3       ", /* LSTORE_3     66 */
744         "FSTORE_0       ", /* FSTORE_0     67 */
745         "FSTORE_1       ", /* FSTORE_1     68 */
746         "FSTORE_2       ", /* FSTORE_2     69 */
747         "FSTORE_3       ", /* FSTORE_3     70 */
748         "DSTORE_0       ", /* DSTORE_0     71 */
749         "DSTORE_1       ", /* DSTORE_1     72 */
750         "DSTORE_2       ", /* DSTORE_2     73 */
751         "DSTORE_3       ", /* DSTORE_3     74 */
752         "ASTORE_0       ", /* ASTORE_0     75 */
753         "ASTORE_1       ", /* ASTORE_1     76 */
754         "ASTORE_2       ", /* ASTORE_2     77 */
755         "ASTORE_3       ", /* ASTORE_3     78 */
756         "IASTORE        ", /*              79 */
757         "LASTORE        ", /*              80 */
758         "FASTORE        ", /*              81 */
759         "DASTORE        ", /*              82 */
760         "AASTORE        ", /*              83 */
761         "BASTORE        ", /*              84 */
762         "CASTORE        ", /*              85 */
763         "SASTORE        ", /*              86 */
764         "POP            ", /*              87 */
765         "POP2           ", /*              88 */
766         "DUP            ", /*              89 */
767         "DUP_X1         ", /*              90 */
768         "DUP_X2         ", /*              91 */
769         "DUP2           ", /*              92 */
770         "DUP2_X1        ", /*              93 */
771         "DUP2_X2        ", /*              94 */
772         "SWAP           ", /*              95 */
773         "IADD           ", /*              96 */
774         "LADD           ", /*              97 */
775         "FADD           ", /*              98 */
776         "DADD           ", /*              99 */
777         "ISUB           ", /*             100 */
778         "LSUB           ", /*             101 */
779         "FSUB           ", /*             102 */
780         "DSUB           ", /*             103 */
781         "IMUL           ", /*             104 */
782         "LMUL           ", /*             105 */
783         "FMUL           ", /*             106 */
784         "DMUL           ", /*             107 */
785         "IDIV           ", /*             108 */
786         "LDIV           ", /*             109 */
787         "FDIV           ", /*             110 */
788         "DDIV           ", /*             111 */
789         "IREM           ", /*             112 */
790         "LREM           ", /*             113 */
791         "FREM           ", /*             114 */
792         "DREM           ", /*             115 */
793         "INEG           ", /*             116 */
794         "LNEG           ", /*             117 */
795         "FNEG           ", /*             118 */
796         "DNEG           ", /*             119 */
797         "ISHL           ", /*             120 */
798         "LSHL           ", /*             121 */
799         "ISHR           ", /*             122 */
800         "LSHR           ", /*             123 */
801         "IUSHR          ", /*             124 */
802         "LUSHR          ", /*             125 */
803         "IAND           ", /*             126 */
804         "LAND           ", /*             127 */
805         "IOR            ", /*             128 */
806         "LOR            ", /*             129 */
807         "IXOR           ", /*             130 */
808         "LXOR           ", /*             131 */
809         "IINC           ", /*             132 */
810         "I2L            ", /*             133 */
811         "I2F            ", /*             134 */
812         "I2D            ", /*             135 */
813         "L2I            ", /*             136 */
814         "L2F            ", /*             137 */
815         "L2D            ", /*             138 */
816         "F2I            ", /*             139 */
817         "F2L            ", /*             140 */
818         "F2D            ", /*             141 */
819         "D2I            ", /*             142 */
820         "D2L            ", /*             143 */
821         "D2F            ", /*             144 */
822         "INT2BYTE       ", /*             145 */
823         "INT2CHAR       ", /*             146 */
824         "INT2SHORT      ", /*             147 */
825         "LCMP           ", /*             148 */
826         "FCMPL          ", /*             149 */
827         "FCMPG          ", /*             150 */
828         "DCMPL          ", /*             151 */
829         "DCMPG          ", /*             152 */
830         "IFEQ           ", /*             153 */
831         "IFNE           ", /*             154 */
832         "IFLT           ", /*             155 */
833         "IFGE           ", /*             156 */
834         "IFGT           ", /*             157 */
835         "IFLE           ", /*             158 */
836         "IF_ICMPEQ      ", /*             159 */
837         "IF_ICMPNE      ", /*             160 */
838         "IF_ICMPLT      ", /*             161 */
839         "IF_ICMPGE      ", /*             162 */
840         "IF_ICMPGT      ", /*             163 */
841         "IF_ICMPLE      ", /*             164 */
842         "IF_ACMPEQ      ", /*             165 */
843         "IF_ACMPNE      ", /*             166 */
844         "GOTO           ", /*             167 */
845         "JSR            ", /*             168 */
846         "RET            ", /*             169 */
847         "TABLESWITCH    ", /*             170 */
848         "LOOKUPSWITCH   ", /*             171 */
849         "IRETURN        ", /*             172 */
850         "LRETURN        ", /*             173 */
851         "FRETURN        ", /*             174 */
852         "DRETURN        ", /*             175 */
853         "ARETURN        ", /*             176 */
854         "RETURN         ", /*             177 */
855         "GETSTATIC      ", /*             178 */
856         "PUTSTATIC      ", /*             179 */
857         "GETFIELD       ", /*             180 */
858         "PUTFIELD       ", /*             181 */
859         "INVOKEVIRTUAL  ", /*             182 */
860         "INVOKESPECIAL  ", /*             183 */
861         "INVOKESTATIC   ", /*             184 */
862         "INVOKEINTERFACE", /*             185 */
863         "UNDEF186       ", /*             186 */
864         "NEW            ", /*             187 */
865         "NEWARRAY       ", /*             188 */
866         "ANEWARRAY      ", /*             189 */
867         "ARRAYLENGTH    ", /*             190 */
868         "ATHROW         ", /*             191 */
869         "CHECKCAST      ", /*             192 */
870         "INSTANCEOF     ", /*             193 */
871         "MONITORENTER   ", /*             194 */
872         "MONITOREXIT    ", /*             195 */
873         "WIDE           ", /* WIDE        196 */
874         "MULTIANEWARRAY ", /*             197 */
875         "IFNULL         ", /*             198 */
876         "IFNONNULL      ", /*             199 */
877         "GOTO_W         ", /* GOTO_W      200 */
878         "JSR_W          ", /* JSR_W       201 */
879         "BREAKPOINT     ", /* BREAKPOINT  202 */
880
881                                 "UNDEF203", "UNDEF204", "UNDEF205",
882         "UNDEF206", "UNDEF207", "UNDEF208", "UNDEF209", "UNDEF210",
883         "UNDEF211", "UNDEF212", "UNDEF213", "UNDEF214", "UNDEF215",
884         "UNDEF216", "UNDEF217", "UNDEF218", "UNDEF219", "UNDEF220",
885         "UNDEF221", "UNDEF222", "UNDEF223", "UNDEF224", "UNDEF225",
886         "UNDEF226", "UNDEF227", "UNDEF228", "UNDEF229", "UNDEF230",
887         "UNDEF231", "UNDEF232", "UNDEF233", "UNDEF234", "UNDEF235",
888         "UNDEF236", "UNDEF237", "UNDEF238", "UNDEF239", "UNDEF240",
889         "UNDEF241", "UNDEF242", "UNDEF243", "UNDEF244", "UNDEF245",
890         "UNDEF246", "UNDEF247", "UNDEF248", "UNDEF249", "UNDEF250",
891         "UNDEF251", "UNDEF252", "UNDEF253", "UNDEF254", "UNDEF255"
892 };
893
894
895 /* jit_init ********************************************************************
896
897    Initializes the JIT subsystem.
898
899 *******************************************************************************/
900
901 void jit_init(void)
902 {
903 #if defined(ENABLE_JIT)
904         /* initialize stack analysis subsystem */
905
906         (void) stack_init();
907 #endif
908
909         /* initialize show subsystem */
910
911 #if !defined(NDEBUG)
912         (void) show_init();
913 #endif
914
915         /* initialize codegen subsystem */
916
917         codegen_init();
918
919         /* initialize code subsystem */
920
921         (void) code_init();
922 }
923
924
925 /* jit_close *******************************************************************
926
927    Close the JIT subsystem.
928
929 *******************************************************************************/
930
931 void jit_close(void)
932 {
933         /* do nothing */
934 }
935
936
937 /* dummy function, used when there is no JavaVM code available                */
938
939 static u1 *do_nothing_function(void)
940 {
941         return NULL;
942 }
943
944
945 /* jit_jitdata_new *************************************************************
946
947    Allocates and initalizes a new jitdata structure.
948
949 *******************************************************************************/
950
951 jitdata *jit_jitdata_new(methodinfo *m)
952 {
953         jitdata  *jd;
954         codeinfo *code;
955
956         /* allocate jitdata structure and fill it */
957
958         jd = DNEW(jitdata);
959
960         jd->m     = m;
961         jd->cd    = DNEW(codegendata);
962         jd->rd    = DNEW(registerdata);
963 #if defined(ENABLE_LOOP)
964         jd->ld    = DNEW(loopdata);
965 #endif
966
967         /* Allocate codeinfo memory from the heap as we need to keep them. */
968
969         code = code_codeinfo_new(m);
970
971         /* Set codeinfo flags. */
972
973 #if defined(ENABLE_THREADS)
974         if (checksync && (m->flags & ACC_SYNCHRONIZED))
975                 code_flag_synchronized(code);
976
977         if (checksync && (m->flags & ACC_SYNCHRONIZED))
978                 code_unflag_leafmethod(code);
979 #endif
980         else
981                 code_flag_leafmethod(code);
982
983         /* initialize variables */
984
985         jd->code                 = code;
986         jd->flags                = 0;
987         jd->exceptiontable       = NULL;
988         jd->exceptiontablelength = 0;
989         jd->returncount          = 0;
990         jd->branchtoentry        = false;
991         jd->branchtoend          = false;
992         jd->returncount          = 0;
993         jd->returnblock          = NULL;
994         jd->maxlocals            = m->maxlocals;
995
996         return jd;
997 }
998
999
1000 /* jit_compile *****************************************************************
1001
1002    Translates one method to machine code.
1003
1004 *******************************************************************************/
1005
1006 static u1 *jit_compile_intern(jitdata *jd);
1007
1008 u1 *jit_compile(methodinfo *m)
1009 {
1010         u1      *r;
1011         jitdata *jd;
1012         s4       dumpsize;
1013
1014         STATISTICS(count_jit_calls++);
1015
1016         /* Initialize the static function's class. */
1017
1018         /* ATTENTION: This MUST be done before the method lock is aquired,
1019            otherwise we could run into a deadlock with <clinit>'s that
1020            call static methods of it's own class. */
1021
1022         if ((m->flags & ACC_STATIC) && !(m->class->state & CLASS_INITIALIZED)) {
1023 #if !defined(NDEBUG)
1024                 if (initverbose)
1025                         log_message_class("Initialize class ", m->class);
1026 #endif
1027
1028                 if (!initialize_class(m->class))
1029                         return NULL;
1030
1031                 /* check if the method has been compiled during initialization */
1032
1033                 if ((m->code != NULL) && (m->code->entrypoint != NULL))
1034                         return m->code->entrypoint;
1035         }
1036
1037         /* enter a monitor on the method */
1038
1039         LOCK_MONITOR_ENTER(m);
1040
1041         /* if method has been already compiled return immediately */
1042
1043         if (m->code != NULL) {
1044                 LOCK_MONITOR_EXIT(m);
1045
1046                 assert(m->code->entrypoint);
1047                 return m->code->entrypoint;
1048         }
1049
1050         TRACECOMPILERCALLS();
1051
1052         STATISTICS(count_methods++);
1053
1054 #if defined(ENABLE_STATISTICS)
1055         /* measure time */
1056
1057         if (opt_getcompilingtime)
1058                 compilingtime_start();
1059 #endif
1060
1061         /* mark start of dump memory area */
1062
1063         dumpsize = dump_size();
1064
1065         /* create jitdata structure */
1066
1067         jd = jit_jitdata_new(m);
1068
1069         /* set the flags for the current JIT run */
1070
1071         jd->flags = JITDATA_FLAG_PARSE;
1072
1073 #if defined(ENABLE_VERIFIER)
1074         if (opt_verify)
1075                 jd->flags |= JITDATA_FLAG_VERIFY;
1076 #endif
1077
1078 #if defined(ENABLE_PROFILING)
1079         if (opt_prof)
1080                 jd->flags |= JITDATA_FLAG_INSTRUMENT;
1081 #endif
1082
1083 #if defined(ENABLE_IFCONV)
1084         if (opt_ifconv)
1085                 jd->flags |= JITDATA_FLAG_IFCONV;
1086 #endif
1087
1088 #if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG)
1089         if (opt_inlining && opt_inline_debug_all)
1090                 jd->flags |= JITDATA_FLAG_INLINE;
1091 #endif
1092
1093         if (opt_showintermediate)
1094                 jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
1095
1096         if (opt_showdisassemble)
1097                 jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
1098
1099         if (opt_verbosecall)
1100                 jd->flags |= JITDATA_FLAG_VERBOSECALL;
1101
1102 #if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING)
1103         if (opt_inlining)
1104                 jd->flags |= JITDATA_FLAG_COUNTDOWN;
1105 #endif
1106
1107 #if defined(ENABLE_JIT)
1108 # if defined(ENABLE_INTRP)
1109         if (!opt_intrp)
1110 # endif
1111                 /* initialize the register allocator */
1112         {
1113                 reg_setup(jd);
1114         }
1115 #endif
1116
1117         /* setup the codegendata memory */
1118
1119         codegen_setup(jd);
1120
1121         /* now call internal compile function */
1122
1123         r = jit_compile_intern(jd);
1124
1125         if (r == NULL) {
1126                 /* We had an exception! Finish stuff here if necessary. */
1127
1128                 /* release codeinfo */
1129
1130                 code_codeinfo_free(jd->code);
1131
1132 #if defined(ENABLE_PROFILING)
1133                 /* Release memory for basic block profiling information. */
1134
1135                 if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
1136                         if (jd->code->bbfrequency != NULL)
1137                                 MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount);
1138 #endif
1139         }
1140         else {
1141                 DEBUG_JIT_COMPILEVERBOSE("Running: ");
1142         }
1143
1144         /* release dump area */
1145
1146         dump_release(dumpsize);
1147
1148 #if defined(ENABLE_STATISTICS)
1149         /* measure time */
1150
1151         if (opt_getcompilingtime)
1152                 compilingtime_stop();
1153 #endif
1154
1155         /* leave the monitor */
1156
1157         LOCK_MONITOR_EXIT(m);
1158
1159         /* return pointer to the methods entry point */
1160
1161         return r;
1162 }
1163
1164
1165 /* jit_recompile ***************************************************************
1166
1167    Recompiles a Java method.
1168
1169 *******************************************************************************/
1170
1171 u1 *jit_recompile(methodinfo *m)
1172 {
1173         u1      *r;
1174         jitdata *jd;
1175         u1       optlevel;
1176         s4       dumpsize;
1177
1178         /* check for max. optimization level */
1179
1180         optlevel = (m->code) ? m->code->optlevel : 0;
1181
1182 #if 0
1183         if (optlevel == 1) {
1184 /*              log_message_method("not recompiling: ", m); */
1185                 return NULL;
1186         }
1187 #endif
1188
1189         DEBUG_JIT_COMPILEVERBOSE("Recompiling start: ");
1190
1191         STATISTICS(count_jit_calls++);
1192
1193 #if defined(ENABLE_STATISTICS)
1194         /* measure time */
1195
1196         if (opt_getcompilingtime)
1197                 compilingtime_start();
1198 #endif
1199
1200         /* mark start of dump memory area */
1201
1202         dumpsize = dump_size();
1203
1204         /* create jitdata structure */
1205
1206         jd = jit_jitdata_new(m);
1207
1208         /* set the current optimization level to the previous one plus 1 */
1209
1210         jd->code->optlevel = optlevel + 1;
1211
1212         /* get the optimization flags for the current JIT run */
1213
1214 #if defined(ENABLE_VERIFIER)
1215         jd->flags |= JITDATA_FLAG_VERIFY;
1216 #endif
1217
1218         /* jd->flags |= JITDATA_FLAG_REORDER; */
1219         if (opt_showintermediate)
1220                 jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
1221         if (opt_showdisassemble)
1222                 jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
1223         if (opt_verbosecall)
1224                 jd->flags |= JITDATA_FLAG_VERBOSECALL;
1225
1226 #if defined(ENABLE_INLINING)
1227         if (opt_inlining)
1228                 jd->flags |= JITDATA_FLAG_INLINE;
1229 #endif
1230
1231 #if defined(ENABLE_JIT)
1232 # if defined(ENABLE_INTRP)
1233         if (!opt_intrp)
1234 # endif
1235                 /* initialize the register allocator */
1236
1237                 reg_setup(jd);
1238 #endif
1239
1240         /* setup the codegendata memory */
1241
1242         codegen_setup(jd);
1243
1244         /* now call internal compile function */
1245
1246         r = jit_compile_intern(jd);
1247
1248         if (r == NULL) {
1249                 /* We had an exception! Finish stuff here if necessary. */
1250
1251                 /* release codeinfo */
1252
1253                 code_codeinfo_free(jd->code);
1254         }
1255
1256         /* release dump area */
1257
1258         dump_release(dumpsize);
1259
1260 #if defined(ENABLE_STATISTICS)
1261         /* measure time */
1262
1263         if (opt_getcompilingtime)
1264                 compilingtime_stop();
1265 #endif
1266
1267         DEBUG_JIT_COMPILEVERBOSE("Recompiling done: ");
1268
1269         /* return pointer to the methods entry point */
1270
1271         return r;
1272 }
1273
1274
1275 /* jit_compile_intern **********************************************************
1276
1277    Static internal function which does the actual compilation.
1278
1279 *******************************************************************************/
1280
1281 static u1 *jit_compile_intern(jitdata *jd)
1282 {
1283         methodinfo  *m;
1284         codegendata *cd;
1285         codeinfo    *code;
1286
1287 #if defined(ENABLE_RT_TIMING)
1288         struct timespec time_start,time_checks,time_parse,time_stack,
1289                                         time_typecheck,time_loop,time_ifconv,time_alloc,
1290                                         time_codegen;
1291 #endif
1292         
1293         RT_TIMING_GET_TIME(time_start);
1294
1295         /* get required compiler data */
1296
1297 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
1298         jd->ls = NULL;
1299 #endif
1300         m    = jd->m;
1301         code = jd->code;
1302         cd   = jd->cd;
1303         
1304 #if defined(ENABLE_DEBUG_FILTER)
1305         show_filters_apply(jd->m);
1306 #endif
1307
1308         /* handle native methods and create a native stub */
1309
1310         if (m->flags & ACC_NATIVE) {
1311                 functionptr f;
1312
1313                 f = native_method_resolve(m);
1314
1315                 if (f == NULL)
1316                         return NULL;
1317
1318                 code = codegen_generate_stub_native(m, f);
1319
1320                 /* Native methods are never recompiled. */
1321                 
1322                 assert(!m->code);
1323
1324                 m->code = code;
1325                 
1326                 return code->entrypoint;
1327         }
1328
1329         /* if there is no javacode, print error message and return empty method   */
1330
1331         if (m->jcode == NULL) {
1332                 DEBUG_JIT_COMPILEVERBOSE("No code given for: ");
1333
1334                 code->entrypoint = (u1 *) (ptrint) do_nothing_function;
1335                 m->code = code;
1336
1337                 return code->entrypoint;        /* return empty method                */
1338         }
1339
1340 #if defined(ENABLE_STATISTICS)
1341         if (opt_stat) {
1342                 count_javacodesize += m->jcodelength + 18;
1343                 count_tryblocks    += jd->exceptiontablelength;
1344                 count_javaexcsize  += jd->exceptiontablelength * SIZEOF_VOID_P;
1345         }
1346 #endif
1347
1348         RT_TIMING_GET_TIME(time_checks);
1349
1350 #if defined(WITH_CLASSPATH_SUN)
1351         /* Code for Sun's OpenJDK (see
1352            hotspot/src/share/vm/classfile/verifier.cpp
1353            (Verifier::is_eligible_for_verification)): Don't verify
1354            dynamically-generated bytecodes. */
1355
1356 # if defined(ENABLE_VERIFIER)
1357         if (class_issubclass(m->class, class_sun_reflect_MagicAccessorImpl))
1358                 jd->flags &= ~JITDATA_FLAG_VERIFY;
1359 # endif
1360 #endif
1361
1362         /* call the compiler passes ***********************************************/
1363
1364         DEBUG_JIT_COMPILEVERBOSE("Parsing: ");
1365
1366         /* call parse pass */
1367
1368         if (!parse(jd)) {
1369                 DEBUG_JIT_COMPILEVERBOSE("Exception while parsing: ");
1370
1371                 return NULL;
1372         }
1373         RT_TIMING_GET_TIME(time_parse);
1374
1375         DEBUG_JIT_COMPILEVERBOSE("Parsing done: ");
1376         
1377 #if defined(ENABLE_JIT)
1378 # if defined(ENABLE_INTRP)
1379         if (!opt_intrp) {
1380 # endif
1381                 DEBUG_JIT_COMPILEVERBOSE("Analysing: ");
1382
1383                 /* call stack analysis pass */
1384
1385                 if (!stack_analyse(jd)) {
1386                         DEBUG_JIT_COMPILEVERBOSE("Exception while analysing: ");
1387
1388                         return NULL;
1389                 }
1390                 RT_TIMING_GET_TIME(time_stack);
1391
1392                 DEBUG_JIT_COMPILEVERBOSE("Analysing done: ");
1393
1394                 /* Build the CFG.  This has to be done after stack_analyse, as
1395                    there happens the JSR elimination. */
1396
1397                 if (!cfg_build(jd))
1398                         return NULL;
1399
1400 #ifdef ENABLE_VERIFIER
1401                 if (JITDATA_HAS_FLAG_VERIFY(jd)) {
1402                         DEBUG_JIT_COMPILEVERBOSE("Typechecking: ");
1403
1404                         /* call typecheck pass */
1405                         if (!typecheck(jd)) {
1406                                 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: ");
1407
1408                                 return NULL;
1409                         }
1410
1411                         DEBUG_JIT_COMPILEVERBOSE("Typechecking done: ");
1412                 }
1413 #endif
1414                 RT_TIMING_GET_TIME(time_typecheck);
1415
1416 #if defined(ENABLE_LOOP)
1417                 if (opt_loops) {
1418                         depthFirst(jd);
1419                         analyseGraph(jd);
1420                         optimize_loops(jd);
1421                         jit_renumber_basicblocks(jd);
1422                 }
1423 #endif
1424                 RT_TIMING_GET_TIME(time_loop);
1425
1426 #if defined(ENABLE_IFCONV)
1427                 if (JITDATA_HAS_FLAG_IFCONV(jd)) {
1428                         if (!ifconv_static(jd))
1429                                 return NULL;
1430                         jit_renumber_basicblocks(jd);
1431                 }
1432 #endif
1433                 RT_TIMING_GET_TIME(time_ifconv);
1434
1435                 /* inlining */
1436
1437 #if defined(ENABLE_INLINING)
1438                 if (JITDATA_HAS_FLAG_INLINE(jd)) {
1439                         if (!inline_inline(jd))
1440                                 return NULL;
1441                 }
1442 #endif
1443
1444 #if defined(ENABLE_PROFILING)
1445                 /* Basic block reordering.  I think this should be done after
1446                    if-conversion, as we could lose the ability to do the
1447                    if-conversion. */
1448
1449                 if (JITDATA_HAS_FLAG_REORDER(jd)) {
1450                         if (!reorder(jd))
1451                                 return NULL;
1452                         jit_renumber_basicblocks(jd);
1453                 }
1454 #endif
1455
1456                 DEBUG_JIT_COMPILEVERBOSE("Allocating registers: ");
1457
1458 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
1459                 /* allocate registers */
1460                 if (opt_lsra) {
1461                         if (!lsra(jd))
1462                                 return NULL;
1463
1464                         STATISTICS(count_methods_allocated_by_lsra++);
1465
1466                 } else
1467 # endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */
1468 #if defined(ENABLE_SSA)
1469                 /* allocate registers */
1470                 if ((opt_lsra) && (jd->exceptiontablelength == 0)) {
1471                         jd->ls = DNEW(lsradata);
1472                         lsra(jd);
1473
1474                         STATISTICS(count_methods_allocated_by_lsra++);
1475
1476                 } else
1477 # endif /* defined(ENABLE_SSA) */
1478                 {
1479                         STATISTICS(count_locals_conflicts += (jd->maxlocals - 1) * (jd->maxlocals));
1480
1481                         regalloc(jd);
1482                 }
1483
1484                 STATISTICS(simplereg_make_statistics(jd));
1485
1486                 DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: ");
1487 # if defined(ENABLE_INTRP)
1488         }
1489 # endif
1490 #endif /* defined(ENABLE_JIT) */
1491         RT_TIMING_GET_TIME(time_alloc);
1492
1493 #if defined(ENABLE_PROFILING)
1494         /* Allocate memory for basic block profiling information. This
1495            _must_ be done after loop optimization and register allocation,
1496            since they can change the basic block count. */
1497
1498         if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
1499                 code->bbfrequency = MNEW(u4, jd->basicblockcount);
1500 #endif
1501
1502         DEBUG_JIT_COMPILEVERBOSE("Generating code: ");
1503
1504         /* now generate the machine code */
1505
1506 #if defined(ENABLE_JIT)
1507 # if defined(ENABLE_INTRP)
1508         if (opt_intrp) {
1509 #if defined(ENABLE_VERIFIER)
1510                 if (opt_verify) {
1511                         DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): ");
1512
1513                         if (!typecheck_stackbased(jd)) {
1514                                 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): ");
1515                                 return NULL;
1516                         }
1517                 }
1518 #endif
1519                 if (!intrp_codegen(jd)) {
1520                         DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
1521
1522                         return NULL;
1523                 }
1524         } else
1525 # endif
1526                 {
1527                         if (!codegen_generate(jd)) {
1528                                 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
1529
1530                                 return NULL;
1531                         }
1532                 }
1533 #else
1534         if (!intrp_codegen(jd)) {
1535                 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
1536
1537                 return NULL;
1538         }
1539 #endif
1540         RT_TIMING_GET_TIME(time_codegen);
1541
1542         DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
1543
1544 #if !defined(NDEBUG) && defined(ENABLE_REPLACEMENT)
1545         /* activate replacement points inside newly created code */
1546
1547         if (opt_TestReplacement)
1548                 replace_activate_replacement_points(code, false);
1549 #endif
1550
1551 #if !defined(NDEBUG)
1552 #if defined(ENABLE_DEBUG_FILTER)
1553         if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
1554 #endif
1555         {
1556                 /* intermediate and assembly code listings */
1557                 
1558                 if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
1559                         show_method(jd, SHOW_CODE);
1560                 }
1561                 else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
1562 # if defined(ENABLE_DISASSEMBLER)
1563                         DISASSEMBLE(code->entrypoint,
1564                                                 code->entrypoint + (code->mcodelength - cd->dseglen));
1565 # endif
1566                 }
1567
1568                 if (opt_showddatasegment)
1569                         dseg_display(jd);
1570         }
1571 #endif
1572
1573         /* switch to the newly generated code */
1574
1575         assert(code);
1576         assert(code->entrypoint);
1577
1578         /* add the current compile version to the methodinfo */
1579
1580         code->prev = m->code;
1581         m->code = code;
1582
1583         RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS);
1584         RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE);
1585         RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK);
1586         RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK);
1587         RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP);
1588         RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC);
1589         RT_TIMING_TIME_DIFF(time_alloc,time_codegen,RT_TIMING_JIT_CODEGEN);
1590         RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL);
1591
1592         /* return pointer to the methods entry point */
1593
1594         return code->entrypoint;
1595
1596
1597
1598 /* jit_invalidate_code *********************************************************
1599
1600    Mark the compiled code of the given method as invalid and take care that
1601    it is replaced if necessary.
1602
1603    XXX Not fully implemented, yet.
1604
1605 *******************************************************************************/
1606
1607 void jit_invalidate_code(methodinfo *m)
1608 {
1609         codeinfo *code;
1610
1611         code = m->code;
1612
1613         if (code == NULL || code_is_invalid(code))
1614                 return;
1615
1616         code_flag_invalid(code);
1617
1618         /* activate mappable replacement points */
1619
1620 #if defined(ENABLE_REPLACEMENT)
1621         replace_activate_replacement_points(code, true);
1622 #else
1623         vm_abort("invalidating code only works with ENABLE_REPLACEMENT");
1624 #endif
1625 }
1626
1627
1628 /* jit_request_optimization ****************************************************
1629
1630    Request optimization of the given method. If the code of the method is
1631    unoptimized, it will be invalidated, so the next jit_get_current_code(m)
1632    triggers an optimized recompilation.
1633    If the method is already optimized, this function does nothing.
1634
1635    IN:
1636        m................the method
1637
1638 *******************************************************************************/
1639
1640 void jit_request_optimization(methodinfo *m)
1641 {
1642         codeinfo *code;
1643
1644         code = m->code;
1645
1646         if (code && code->optlevel == 0)
1647                 jit_invalidate_code(m);
1648 }
1649
1650
1651 /* jit_get_current_code ********************************************************
1652
1653    Get the currently valid code for the given method. If there is no valid
1654    code, (re)compile the method.
1655
1656    IN:
1657        m................the method
1658
1659    RETURN VALUE:
1660        the codeinfo* for the current code, or
1661            NULL if an exception has been thrown during recompilation.
1662
1663 *******************************************************************************/
1664
1665 codeinfo *jit_get_current_code(methodinfo *m)
1666 {
1667         assert(m);
1668
1669         /* if we have valid code, return it */
1670
1671         if (m->code && !code_is_invalid(m->code))
1672                 return m->code;
1673
1674         /* otherwise: recompile */
1675
1676         if (!jit_recompile(m))
1677                 return NULL;
1678
1679         assert(m->code);
1680
1681         return m->code;
1682 }
1683
1684
1685 /* jit_asm_compile *************************************************************
1686
1687    This method is called from asm_vm_call_method and does:
1688
1689      - create stackframe info for exceptions
1690      - compile the method
1691      - patch the entrypoint of the method into the calculated address in
1692        the JIT code
1693      - flushes the instruction cache.
1694
1695 *******************************************************************************/
1696
1697 #if defined(ENABLE_JIT)
1698 #if !defined(JIT_COMPILER_VIA_SIGNAL)
1699 u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra)
1700 {
1701         stackframeinfo  sfi;
1702         u1             *entrypoint;
1703         u1             *pa;
1704         ptrint         *p;
1705
1706         /* create the stackframeinfo (subtract 1 from RA as it points to the */
1707         /* instruction after the call)                                       */
1708
1709         stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra-1);
1710
1711         /* actually compile the method */
1712
1713         entrypoint = jit_compile(m);
1714
1715         /* remove the stackframeinfo */
1716
1717         stacktrace_stackframeinfo_remove(&sfi);
1718
1719         /* there was a problem during compilation */
1720
1721         if (entrypoint == NULL)
1722                 return NULL;
1723
1724         /* get the method patch address */
1725
1726         pa = md_jit_method_patch_address(sfi.pv, (void *) ra, mptr);
1727
1728         /* patch the method entry point */
1729
1730         p = (ptrint *) pa;
1731
1732         *p = (ptrint) entrypoint;
1733
1734         /* flush the instruction cache */
1735
1736         md_icacheflush(pa, SIZEOF_VOID_P);
1737
1738         return entrypoint;
1739 }
1740 #endif
1741
1742 /* jit_compile_handle **********************************************************
1743
1744    This method is called from the appropriate signal handler which
1745    handles compiler-traps and does the following:
1746
1747      - compile the method
1748      - patch the entrypoint of the method into the calculated address in
1749        the JIT code
1750      - flush the instruction cache
1751
1752 *******************************************************************************/
1753
1754 void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
1755 {
1756         void      *newpv;                               /* new compiled method PV */
1757         void      *pa;                                           /* patch address */
1758         uintptr_t *p;                                      /* convenience pointer */
1759
1760         /* Compile the method. */
1761
1762         newpv = jit_compile(m);
1763
1764         /* There was a problem during compilation. */
1765
1766         if (newpv == NULL)
1767                 return NULL;
1768
1769         /* Get the method patch address. */
1770
1771         pa = md_jit_method_patch_address(pv, ra, mptr);
1772
1773         /* Patch the method entry point. */
1774
1775         p = (uintptr_t *) pa;
1776
1777         *p = (uintptr_t) newpv;
1778
1779         /* Flush both caches. */
1780
1781         md_cacheflush(pa, SIZEOF_VOID_P);
1782
1783         return newpv;
1784 }
1785 #endif /* defined(ENABLE_JIT) */
1786
1787
1788 /* jit_complement_condition ****************************************************
1789
1790    Returns the complement of the passed conditional instruction.
1791
1792    We use the order of the different conditions, e.g.:
1793
1794    ICMD_IFEQ         153
1795    ICMD_IFNE         154
1796
1797    If the passed opcode is odd, we simply add 1 to get the complement.
1798    If the opcode is even, we subtract 1.
1799
1800    Exception:
1801
1802    ICMD_IFNULL       198
1803    ICMD_IFNONNULL    199
1804
1805 *******************************************************************************/
1806
1807 s4 jit_complement_condition(s4 opcode)
1808 {
1809         switch (opcode) {
1810         case ICMD_IFNULL:
1811                 return ICMD_IFNONNULL;
1812
1813         case ICMD_IFNONNULL:
1814                 return ICMD_IFNULL;
1815
1816         default:
1817                 /* check if opcode is odd */
1818
1819                 if (opcode & 0x1)
1820                         return opcode + 1;
1821                 else
1822                         return opcode - 1;
1823         }
1824 }
1825
1826
1827 /* jit_renumber_basicblocks ****************************************************
1828
1829    Set the ->nr of all blocks so it increases when traversing ->next.
1830
1831    IN:
1832        jitdata..........the current jitdata
1833
1834 *******************************************************************************/
1835
1836 void jit_renumber_basicblocks(jitdata *jd)
1837 {
1838         s4          nr;
1839         basicblock *bptr;
1840
1841         nr = 0;
1842         for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1843                 bptr->nr = nr++;
1844         }
1845
1846         /* we have one block more than jd->basicblockcount (the end marker) */
1847
1848         assert(nr == jd->basicblockcount + 1);
1849 }
1850
1851
1852 /* jit_check_basicblock_numbers ************************************************
1853
1854    Assert that the ->nr of the first block is zero and increases by 1 each
1855    time ->next is traversed.
1856    This function should be called before any analysis that relies on
1857    the basicblock numbers.
1858
1859    IN:
1860        jitdata..........the current jitdata
1861
1862    NOTE: Aborts with an assertion if the condition is not met!
1863
1864 *******************************************************************************/
1865
1866 #if !defined(NDEBUG)
1867 void jit_check_basicblock_numbers(jitdata *jd)
1868 {
1869         s4          nr;
1870         basicblock *bptr;
1871
1872         nr = 0;
1873         for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1874                 assert(bptr->nr == nr);
1875                 nr++;
1876         }
1877
1878         /* we have one block more than jd->basicblockcount (the end marker) */
1879
1880         assert(nr == jd->basicblockcount + 1);
1881 }
1882 #endif /* !defined(NDEBUG) */
1883
1884
1885 /*
1886  * These are local overrides for various environment variables in Emacs.
1887  * Please do not remove this and leave it at the end of the file, where
1888  * Emacs will automagically detect them.
1889  * ---------------------------------------------------------------------
1890  * Local variables:
1891  * mode: c
1892  * indent-tabs-mode: t
1893  * c-basic-offset: 4
1894  * tab-width: 4
1895  * End:
1896  * vim:noexpandtab:sw=4:ts=4:
1897  */