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