* src/vm/jit/jit.c (jit_compile_intern): Use native_method_resolve and
[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
955         /* allocate jitdata structure and fill it */
956
957         jd = DNEW(jitdata);
958
959         jd->m     = m;
960         jd->cd    = DNEW(codegendata);
961         jd->rd    = DNEW(registerdata);
962 #if defined(ENABLE_LOOP)
963         jd->ld    = DNEW(loopdata);
964 #endif
965
966         /* Allocate codeinfo memory from the heap as we need to keep them. */
967
968         jd->code  = code_codeinfo_new(m);
969
970         /* initialize variables */
971
972         jd->flags                = 0;
973         jd->exceptiontable       = NULL;
974         jd->exceptiontablelength = 0;
975         jd->returncount          = 0;
976         jd->branchtoentry        = false;
977         jd->branchtoend          = false;
978         jd->returncount          = 0;
979         jd->returnblock          = NULL;
980         jd->maxlocals            = m->maxlocals;
981
982 #if defined(ENABLE_THREADS)
983         if (checksync && (m->flags & ACC_SYNCHRONIZED))
984                 jd->isleafmethod = false;
985         else
986 #endif
987                 jd->isleafmethod = true;
988
989         return jd;
990 }
991
992
993 /* jit_compile *****************************************************************
994
995    Translates one method to machine code.
996
997 *******************************************************************************/
998
999 static u1 *jit_compile_intern(jitdata *jd);
1000
1001 u1 *jit_compile(methodinfo *m)
1002 {
1003         u1      *r;
1004         jitdata *jd;
1005         s4       dumpsize;
1006
1007         STATISTICS(count_jit_calls++);
1008
1009         /* Initialize the static function's class. */
1010
1011         /* ATTENTION: This MUST be done before the method lock is aquired,
1012            otherwise we could run into a deadlock with <clinit>'s that
1013            call static methods of it's own class. */
1014
1015         if ((m->flags & ACC_STATIC) && !(m->class->state & CLASS_INITIALIZED)) {
1016 #if !defined(NDEBUG)
1017                 if (initverbose)
1018                         log_message_class("Initialize class ", m->class);
1019 #endif
1020
1021                 if (!initialize_class(m->class))
1022                         return NULL;
1023
1024                 /* check if the method has been compiled during initialization */
1025
1026                 if ((m->code != NULL) && (m->code->entrypoint != NULL))
1027                         return m->code->entrypoint;
1028         }
1029
1030         /* enter a monitor on the method */
1031
1032         LOCK_MONITOR_ENTER(m);
1033
1034         /* if method has been already compiled return immediately */
1035
1036         if (m->code != NULL) {
1037                 LOCK_MONITOR_EXIT(m);
1038
1039                 assert(m->code->entrypoint);
1040                 return m->code->entrypoint;
1041         }
1042
1043         TRACECOMPILERCALLS();
1044
1045         STATISTICS(count_methods++);
1046
1047 #if defined(ENABLE_STATISTICS)
1048         /* measure time */
1049
1050         if (opt_getcompilingtime)
1051                 compilingtime_start();
1052 #endif
1053
1054         /* mark start of dump memory area */
1055
1056         dumpsize = dump_size();
1057
1058         /* create jitdata structure */
1059
1060         jd = jit_jitdata_new(m);
1061
1062         /* set the flags for the current JIT run */
1063
1064         jd->flags = JITDATA_FLAG_PARSE;
1065
1066 #if defined(ENABLE_VERIFIER)
1067         if (opt_verify)
1068                 jd->flags |= JITDATA_FLAG_VERIFY;
1069 #endif
1070
1071 #if defined(ENABLE_PROFILING)
1072         if (opt_prof)
1073                 jd->flags |= JITDATA_FLAG_INSTRUMENT;
1074 #endif
1075
1076 #if defined(ENABLE_IFCONV)
1077         if (opt_ifconv)
1078                 jd->flags |= JITDATA_FLAG_IFCONV;
1079 #endif
1080
1081 #if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG)
1082         if (opt_inlining && opt_inline_debug_all)
1083                 jd->flags |= JITDATA_FLAG_INLINE;
1084 #endif
1085
1086         if (opt_showintermediate)
1087                 jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
1088
1089         if (opt_showdisassemble)
1090                 jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
1091
1092         if (opt_verbosecall)
1093                 jd->flags |= JITDATA_FLAG_VERBOSECALL;
1094
1095 #if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING)
1096         if (opt_inlining)
1097                 jd->flags |= JITDATA_FLAG_COUNTDOWN;
1098 #endif
1099
1100 #if defined(ENABLE_JIT)
1101 # if defined(ENABLE_INTRP)
1102         if (!opt_intrp)
1103 # endif
1104                 /* initialize the register allocator */
1105         {
1106                 reg_setup(jd);
1107         }
1108 #endif
1109
1110         /* setup the codegendata memory */
1111
1112         codegen_setup(jd);
1113
1114         /* now call internal compile function */
1115
1116         r = jit_compile_intern(jd);
1117
1118         if (r == NULL) {
1119                 /* We had an exception! Finish stuff here if necessary. */
1120
1121                 /* release codeinfo */
1122
1123                 code_codeinfo_free(jd->code);
1124
1125 #if defined(ENABLE_PROFILING)
1126                 /* Release memory for basic block profiling information. */
1127
1128                 if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
1129                         if (jd->code->bbfrequency != NULL)
1130                                 MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount);
1131 #endif
1132         }
1133         else {
1134                 DEBUG_JIT_COMPILEVERBOSE("Running: ");
1135         }
1136
1137         /* release dump area */
1138
1139         dump_release(dumpsize);
1140
1141 #if defined(ENABLE_STATISTICS)
1142         /* measure time */
1143
1144         if (opt_getcompilingtime)
1145                 compilingtime_stop();
1146 #endif
1147
1148         /* leave the monitor */
1149
1150         LOCK_MONITOR_EXIT(m);
1151
1152         /* return pointer to the methods entry point */
1153
1154         return r;
1155 }
1156
1157
1158 /* jit_recompile ***************************************************************
1159
1160    Recompiles a Java method.
1161
1162 *******************************************************************************/
1163
1164 u1 *jit_recompile(methodinfo *m)
1165 {
1166         u1      *r;
1167         jitdata *jd;
1168         u1       optlevel;
1169         s4       dumpsize;
1170
1171         /* check for max. optimization level */
1172
1173         optlevel = (m->code) ? m->code->optlevel : 0;
1174
1175 #if 0
1176         if (optlevel == 1) {
1177 /*              log_message_method("not recompiling: ", m); */
1178                 return NULL;
1179         }
1180 #endif
1181
1182         DEBUG_JIT_COMPILEVERBOSE("Recompiling start: ");
1183
1184         STATISTICS(count_jit_calls++);
1185
1186 #if defined(ENABLE_STATISTICS)
1187         /* measure time */
1188
1189         if (opt_getcompilingtime)
1190                 compilingtime_start();
1191 #endif
1192
1193         /* mark start of dump memory area */
1194
1195         dumpsize = dump_size();
1196
1197         /* create jitdata structure */
1198
1199         jd = jit_jitdata_new(m);
1200
1201         /* set the current optimization level to the previous one plus 1 */
1202
1203         jd->code->optlevel = optlevel + 1;
1204
1205         /* get the optimization flags for the current JIT run */
1206
1207 #if defined(ENABLE_VERIFIER)
1208         jd->flags |= JITDATA_FLAG_VERIFY;
1209 #endif
1210
1211         /* jd->flags |= JITDATA_FLAG_REORDER; */
1212         if (opt_showintermediate)
1213                 jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
1214         if (opt_showdisassemble)
1215                 jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
1216         if (opt_verbosecall)
1217                 jd->flags |= JITDATA_FLAG_VERBOSECALL;
1218
1219 #if defined(ENABLE_INLINING)
1220         if (opt_inlining)
1221                 jd->flags |= JITDATA_FLAG_INLINE;
1222 #endif
1223
1224 #if defined(ENABLE_JIT)
1225 # if defined(ENABLE_INTRP)
1226         if (!opt_intrp)
1227 # endif
1228                 /* initialize the register allocator */
1229
1230                 reg_setup(jd);
1231 #endif
1232
1233         /* setup the codegendata memory */
1234
1235         codegen_setup(jd);
1236
1237         /* now call internal compile function */
1238
1239         r = jit_compile_intern(jd);
1240
1241         if (r == NULL) {
1242                 /* We had an exception! Finish stuff here if necessary. */
1243
1244                 /* release codeinfo */
1245
1246                 code_codeinfo_free(jd->code);
1247         }
1248
1249         /* release dump area */
1250
1251         dump_release(dumpsize);
1252
1253 #if defined(ENABLE_STATISTICS)
1254         /* measure time */
1255
1256         if (opt_getcompilingtime)
1257                 compilingtime_stop();
1258 #endif
1259
1260         DEBUG_JIT_COMPILEVERBOSE("Recompiling done: ");
1261
1262         /* return pointer to the methods entry point */
1263
1264         return r;
1265 }
1266
1267
1268 /* jit_compile_intern **********************************************************
1269
1270    Static internal function which does the actual compilation.
1271
1272 *******************************************************************************/
1273
1274 static u1 *jit_compile_intern(jitdata *jd)
1275 {
1276         methodinfo  *m;
1277         codegendata *cd;
1278         codeinfo    *code;
1279
1280 #if defined(ENABLE_RT_TIMING)
1281         struct timespec time_start,time_checks,time_parse,time_stack,
1282                                         time_typecheck,time_loop,time_ifconv,time_alloc,
1283                                         time_codegen;
1284 #endif
1285         
1286         RT_TIMING_GET_TIME(time_start);
1287
1288         /* get required compiler data */
1289
1290 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
1291         jd->ls = NULL;
1292 #endif
1293         m    = jd->m;
1294         code = jd->code;
1295         cd   = jd->cd;
1296         
1297 #if defined(ENABLE_DEBUG_FILTER)
1298         show_filters_apply(jd->m);
1299 #endif
1300
1301         /* handle native methods and create a native stub */
1302
1303         if (m->flags & ACC_NATIVE) {
1304                 functionptr f;
1305
1306                 f = native_method_resolve(m);
1307
1308                 if (f == NULL)
1309                         return NULL;
1310
1311                 code = codegen_generate_stub_native(m, f);
1312
1313                 /* Native methods are never recompiled. */
1314                 
1315                 assert(!m->code);
1316
1317                 m->code = code;
1318                 
1319                 return code->entrypoint;
1320         }
1321
1322         /* if there is no javacode, print error message and return empty method   */
1323
1324         if (m->jcode == NULL) {
1325                 DEBUG_JIT_COMPILEVERBOSE("No code given for: ");
1326
1327                 code->entrypoint = (u1 *) (ptrint) do_nothing_function;
1328                 m->code = code;
1329
1330                 return code->entrypoint;        /* return empty method                */
1331         }
1332
1333 #if defined(ENABLE_STATISTICS)
1334         if (opt_stat) {
1335                 count_javacodesize += m->jcodelength + 18;
1336                 count_tryblocks    += jd->exceptiontablelength;
1337                 count_javaexcsize  += jd->exceptiontablelength * SIZEOF_VOID_P;
1338         }
1339 #endif
1340
1341         RT_TIMING_GET_TIME(time_checks);
1342
1343 #if defined(WITH_CLASSPATH_SUN)
1344         /* Code for Sun's OpenJDK (see
1345            hotspot/src/share/vm/classfile/verifier.cpp
1346            (Verifier::is_eligible_for_verification)): Don't verify
1347            dynamically-generated bytecodes. */
1348
1349 # if defined(ENABLE_VERIFIER)
1350         if (class_issubclass(m->class, class_sun_reflect_MagicAccessorImpl))
1351                 jd->flags &= ~JITDATA_FLAG_VERIFY;
1352 # endif
1353 #endif
1354
1355         /* call the compiler passes ***********************************************/
1356
1357         DEBUG_JIT_COMPILEVERBOSE("Parsing: ");
1358
1359         /* call parse pass */
1360
1361         if (!parse(jd)) {
1362                 DEBUG_JIT_COMPILEVERBOSE("Exception while parsing: ");
1363
1364                 return NULL;
1365         }
1366         RT_TIMING_GET_TIME(time_parse);
1367
1368         DEBUG_JIT_COMPILEVERBOSE("Parsing done: ");
1369         
1370 #if defined(ENABLE_JIT)
1371 # if defined(ENABLE_INTRP)
1372         if (!opt_intrp) {
1373 # endif
1374                 DEBUG_JIT_COMPILEVERBOSE("Analysing: ");
1375
1376                 /* call stack analysis pass */
1377
1378                 if (!stack_analyse(jd)) {
1379                         DEBUG_JIT_COMPILEVERBOSE("Exception while analysing: ");
1380
1381                         return NULL;
1382                 }
1383                 RT_TIMING_GET_TIME(time_stack);
1384
1385                 DEBUG_JIT_COMPILEVERBOSE("Analysing done: ");
1386
1387                 /* Build the CFG.  This has to be done after stack_analyse, as
1388                    there happens the JSR elimination. */
1389
1390                 if (!cfg_build(jd))
1391                         return NULL;
1392
1393 #ifdef ENABLE_VERIFIER
1394                 if (JITDATA_HAS_FLAG_VERIFY(jd)) {
1395                         DEBUG_JIT_COMPILEVERBOSE("Typechecking: ");
1396
1397                         /* call typecheck pass */
1398                         if (!typecheck(jd)) {
1399                                 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: ");
1400
1401                                 return NULL;
1402                         }
1403
1404                         DEBUG_JIT_COMPILEVERBOSE("Typechecking done: ");
1405                 }
1406 #endif
1407                 RT_TIMING_GET_TIME(time_typecheck);
1408
1409 #if defined(ENABLE_LOOP)
1410                 if (opt_loops) {
1411                         depthFirst(jd);
1412                         analyseGraph(jd);
1413                         optimize_loops(jd);
1414                         jit_renumber_basicblocks(jd);
1415                 }
1416 #endif
1417                 RT_TIMING_GET_TIME(time_loop);
1418
1419 #if defined(ENABLE_IFCONV)
1420                 if (JITDATA_HAS_FLAG_IFCONV(jd)) {
1421                         if (!ifconv_static(jd))
1422                                 return NULL;
1423                         jit_renumber_basicblocks(jd);
1424                 }
1425 #endif
1426                 RT_TIMING_GET_TIME(time_ifconv);
1427
1428                 /* inlining */
1429
1430 #if defined(ENABLE_INLINING)
1431                 if (JITDATA_HAS_FLAG_INLINE(jd)) {
1432                         if (!inline_inline(jd))
1433                                 return NULL;
1434                 }
1435 #endif
1436
1437 #if defined(ENABLE_PROFILING)
1438                 /* Basic block reordering.  I think this should be done after
1439                    if-conversion, as we could lose the ability to do the
1440                    if-conversion. */
1441
1442                 if (JITDATA_HAS_FLAG_REORDER(jd)) {
1443                         if (!reorder(jd))
1444                                 return NULL;
1445                         jit_renumber_basicblocks(jd);
1446                 }
1447 #endif
1448
1449                 DEBUG_JIT_COMPILEVERBOSE("Allocating registers: ");
1450
1451 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
1452                 /* allocate registers */
1453                 if (opt_lsra) {
1454                         if (!lsra(jd))
1455                                 return NULL;
1456
1457                         STATISTICS(count_methods_allocated_by_lsra++);
1458
1459                 } else
1460 # endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */
1461 #if defined(ENABLE_SSA)
1462                 /* allocate registers */
1463                 if ((opt_lsra) && (jd->exceptiontablelength == 0)) {
1464                         jd->ls = DNEW(lsradata);
1465                         lsra(jd);
1466
1467                         STATISTICS(count_methods_allocated_by_lsra++);
1468
1469                 } else
1470 # endif /* defined(ENABLE_SSA) */
1471                 {
1472                         STATISTICS(count_locals_conflicts += (jd->maxlocals - 1) * (jd->maxlocals));
1473
1474                         regalloc(jd);
1475                 }
1476
1477                 STATISTICS(simplereg_make_statistics(jd));
1478
1479                 DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: ");
1480 # if defined(ENABLE_INTRP)
1481         }
1482 # endif
1483 #endif /* defined(ENABLE_JIT) */
1484         RT_TIMING_GET_TIME(time_alloc);
1485
1486 #if defined(ENABLE_PROFILING)
1487         /* Allocate memory for basic block profiling information. This
1488            _must_ be done after loop optimization and register allocation,
1489            since they can change the basic block count. */
1490
1491         if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
1492                 code->bbfrequency = MNEW(u4, jd->basicblockcount);
1493 #endif
1494
1495         DEBUG_JIT_COMPILEVERBOSE("Generating code: ");
1496
1497         /* now generate the machine code */
1498
1499 #if defined(ENABLE_JIT)
1500 # if defined(ENABLE_INTRP)
1501         if (opt_intrp) {
1502 #if defined(ENABLE_VERIFIER)
1503                 if (opt_verify) {
1504                         DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): ");
1505
1506                         if (!typecheck_stackbased(jd)) {
1507                                 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): ");
1508                                 return NULL;
1509                         }
1510                 }
1511 #endif
1512                 if (!intrp_codegen(jd)) {
1513                         DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
1514
1515                         return NULL;
1516                 }
1517         } else
1518 # endif
1519                 {
1520                         if (!codegen_generate(jd)) {
1521                                 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
1522
1523                                 return NULL;
1524                         }
1525                 }
1526 #else
1527         if (!intrp_codegen(jd)) {
1528                 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
1529
1530                 return NULL;
1531         }
1532 #endif
1533         RT_TIMING_GET_TIME(time_codegen);
1534
1535         DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
1536
1537 #if !defined(NDEBUG) && defined(ENABLE_REPLACEMENT)
1538         /* activate replacement points inside newly created code */
1539
1540         if (opt_TestReplacement)
1541                 replace_activate_replacement_points(code, false);
1542 #endif
1543
1544 #if !defined(NDEBUG)
1545 #if defined(ENABLE_DEBUG_FILTER)
1546         if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
1547 #endif
1548         {
1549                 /* intermediate and assembly code listings */
1550                 
1551                 if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
1552                         show_method(jd, SHOW_CODE);
1553                 }
1554                 else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
1555 # if defined(ENABLE_DISASSEMBLER)
1556                         DISASSEMBLE(code->entrypoint,
1557                                                 code->entrypoint + (code->mcodelength - cd->dseglen));
1558 # endif
1559                 }
1560
1561                 if (opt_showddatasegment)
1562                         dseg_display(jd);
1563         }
1564 #endif
1565
1566         /* switch to the newly generated code */
1567
1568         assert(code);
1569         assert(code->entrypoint);
1570
1571         /* add the current compile version to the methodinfo */
1572
1573         code->prev = m->code;
1574         m->code = code;
1575
1576         RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS);
1577         RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE);
1578         RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK);
1579         RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK);
1580         RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP);
1581         RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC);
1582         RT_TIMING_TIME_DIFF(time_alloc,time_codegen,RT_TIMING_JIT_CODEGEN);
1583         RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL);
1584
1585         /* return pointer to the methods entry point */
1586
1587         return code->entrypoint;
1588
1589
1590
1591 /* jit_invalidate_code *********************************************************
1592
1593    Mark the compiled code of the given method as invalid and take care that
1594    it is replaced if necessary.
1595
1596    XXX Not fully implemented, yet.
1597
1598 *******************************************************************************/
1599
1600 void jit_invalidate_code(methodinfo *m)
1601 {
1602         codeinfo *code;
1603
1604         code = m->code;
1605         if (code == NULL || CODE_IS_INVALID(code))
1606                 return;
1607
1608         CODE_SETFLAG_INVALID(code);
1609
1610         /* activate mappable replacement points */
1611
1612 #if defined(ENABLE_REPLACEMENT)
1613         replace_activate_replacement_points(code, true);
1614 #else
1615         vm_abort("invalidating code only works with ENABLE_REPLACEMENT");
1616 #endif
1617 }
1618
1619
1620 /* jit_request_optimization ****************************************************
1621
1622    Request optimization of the given method. If the code of the method is
1623    unoptimized, it will be invalidated, so the next jit_get_current_code(m)
1624    triggers an optimized recompilation.
1625    If the method is already optimized, this function does nothing.
1626
1627    IN:
1628        m................the method
1629
1630 *******************************************************************************/
1631
1632 void jit_request_optimization(methodinfo *m)
1633 {
1634         codeinfo *code;
1635
1636         code = m->code;
1637
1638         if (code && code->optlevel == 0)
1639                 jit_invalidate_code(m);
1640 }
1641
1642
1643 /* jit_get_current_code ********************************************************
1644
1645    Get the currently valid code for the given method. If there is no valid
1646    code, (re)compile the method.
1647
1648    IN:
1649        m................the method
1650
1651    RETURN VALUE:
1652        the codeinfo* for the current code, or
1653            NULL if an exception has been thrown during recompilation.
1654
1655 *******************************************************************************/
1656
1657 codeinfo *jit_get_current_code(methodinfo *m)
1658 {
1659         assert(m);
1660
1661         /* if we have valid code, return it */
1662
1663         if (m->code && CODE_IS_VALID(m->code))
1664                 return m->code;
1665
1666         /* otherwise: recompile */
1667
1668         if (!jit_recompile(m))
1669                 return NULL;
1670
1671         assert(m->code);
1672
1673         return m->code;
1674 }
1675
1676
1677 /* jit_asm_compile *************************************************************
1678
1679    This method is called from asm_vm_call_method and does:
1680
1681      - create stackframe info for exceptions
1682      - compile the method
1683      - patch the entrypoint of the method into the calculated address in
1684        the JIT code
1685      - flushes the instruction cache.
1686
1687 *******************************************************************************/
1688
1689 #if defined(ENABLE_JIT)
1690 #if !defined(JIT_COMPILER_VIA_SIGNAL)
1691 u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra)
1692 {
1693         stackframeinfo  sfi;
1694         u1             *entrypoint;
1695         u1             *pa;
1696         ptrint         *p;
1697
1698         /* create the stackframeinfo (subtract 1 from RA as it points to the */
1699         /* instruction after the call)                                       */
1700
1701         stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra-1);
1702
1703         /* actually compile the method */
1704
1705         entrypoint = jit_compile(m);
1706
1707         /* remove the stackframeinfo */
1708
1709         stacktrace_stackframeinfo_remove(&sfi);
1710
1711         /* there was a problem during compilation */
1712
1713         if (entrypoint == NULL)
1714                 return NULL;
1715
1716         /* get the method patch address */
1717
1718         pa = md_jit_method_patch_address(sfi.pv, (void *) ra, mptr);
1719
1720         /* patch the method entry point */
1721
1722         p = (ptrint *) pa;
1723
1724         *p = (ptrint) entrypoint;
1725
1726         /* flush the instruction cache */
1727
1728         md_icacheflush(pa, SIZEOF_VOID_P);
1729
1730         return entrypoint;
1731 }
1732 #endif
1733
1734 /* jit_compile_handle **********************************************************
1735
1736    This method is called from the appropriate signal handler which
1737    handles compiler-traps and does the following:
1738
1739      - compile the method
1740      - patch the entrypoint of the method into the calculated address in
1741        the JIT code
1742      - flush the instruction cache
1743
1744 *******************************************************************************/
1745
1746 void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
1747 {
1748         void      *newpv;                               /* new compiled method PV */
1749         void      *pa;                                           /* patch address */
1750         uintptr_t *p;                                      /* convenience pointer */
1751
1752         /* Compile the method. */
1753
1754         newpv = jit_compile(m);
1755
1756         /* There was a problem during compilation. */
1757
1758         if (newpv == NULL)
1759                 return NULL;
1760
1761         /* Get the method patch address. */
1762
1763         pa = md_jit_method_patch_address(pv, ra, mptr);
1764
1765         /* Patch the method entry point. */
1766
1767         p = (uintptr_t *) pa;
1768
1769         *p = (uintptr_t) newpv;
1770
1771         /* Flush both caches. */
1772
1773         md_cacheflush(pa, SIZEOF_VOID_P);
1774
1775         return newpv;
1776 }
1777 #endif /* defined(ENABLE_JIT) */
1778
1779
1780 /* jit_complement_condition ****************************************************
1781
1782    Returns the complement of the passed conditional instruction.
1783
1784    We use the order of the different conditions, e.g.:
1785
1786    ICMD_IFEQ         153
1787    ICMD_IFNE         154
1788
1789    If the passed opcode is odd, we simply add 1 to get the complement.
1790    If the opcode is even, we subtract 1.
1791
1792    Exception:
1793
1794    ICMD_IFNULL       198
1795    ICMD_IFNONNULL    199
1796
1797 *******************************************************************************/
1798
1799 s4 jit_complement_condition(s4 opcode)
1800 {
1801         switch (opcode) {
1802         case ICMD_IFNULL:
1803                 return ICMD_IFNONNULL;
1804
1805         case ICMD_IFNONNULL:
1806                 return ICMD_IFNULL;
1807
1808         default:
1809                 /* check if opcode is odd */
1810
1811                 if (opcode & 0x1)
1812                         return opcode + 1;
1813                 else
1814                         return opcode - 1;
1815         }
1816 }
1817
1818
1819 /* jit_renumber_basicblocks ****************************************************
1820
1821    Set the ->nr of all blocks so it increases when traversing ->next.
1822
1823    IN:
1824        jitdata..........the current jitdata
1825
1826 *******************************************************************************/
1827
1828 void jit_renumber_basicblocks(jitdata *jd)
1829 {
1830         s4          nr;
1831         basicblock *bptr;
1832
1833         nr = 0;
1834         for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1835                 bptr->nr = nr++;
1836         }
1837
1838         /* we have one block more than jd->basicblockcount (the end marker) */
1839
1840         assert(nr == jd->basicblockcount + 1);
1841 }
1842
1843
1844 /* jit_check_basicblock_numbers ************************************************
1845
1846    Assert that the ->nr of the first block is zero and increases by 1 each
1847    time ->next is traversed.
1848    This function should be called before any analysis that relies on
1849    the basicblock numbers.
1850
1851    IN:
1852        jitdata..........the current jitdata
1853
1854    NOTE: Aborts with an assertion if the condition is not met!
1855
1856 *******************************************************************************/
1857
1858 #if !defined(NDEBUG)
1859 void jit_check_basicblock_numbers(jitdata *jd)
1860 {
1861         s4          nr;
1862         basicblock *bptr;
1863
1864         nr = 0;
1865         for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1866                 assert(bptr->nr == nr);
1867                 nr++;
1868         }
1869
1870         /* we have one block more than jd->basicblockcount (the end marker) */
1871
1872         assert(nr == jd->basicblockcount + 1);
1873 }
1874 #endif /* !defined(NDEBUG) */
1875
1876
1877 /*
1878  * These are local overrides for various environment variables in Emacs.
1879  * Please do not remove this and leave it at the end of the file, where
1880  * Emacs will automagically detect them.
1881  * ---------------------------------------------------------------------
1882  * Local variables:
1883  * mode: c
1884  * indent-tabs-mode: t
1885  * c-basic-offset: 4
1886  * tab-width: 4
1887  * End:
1888  * vim:noexpandtab:sw=4:ts=4:
1889  */