1 /* src/vm/jit/jit.c - calls the code generation functions
3 Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4 C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5 E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6 J. Wenninger, Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 Contact: cacao@cacaojvm.org
27 Authors: Andreas Krall
30 Changes: Edwin Steiner
34 $Id: jit.c 5785 2006-10-15 22:25:54Z edwin $
44 #include "mm/memory.h"
45 #include "native/native.h"
46 #include "toolbox/logging.h"
48 #if defined(ENABLE_THREADS)
49 # include "threads/native/lock.h"
51 # include "threads/none/lock.h"
55 #include "vm/global.h"
56 #include "vm/initialize.h"
57 #include "vm/loader.h"
58 #include "vm/method.h"
59 #include "vm/options.h"
60 #include "vm/statistics.h"
61 #include "vm/jit/asmpart.h"
63 # include "vm/jit/cfg.h"
65 #include "vm/jit/codegen-common.h"
66 #include "vm/jit/disass.h"
67 #include "vm/jit/dseg.h"
68 #include "vm/jit/jit.h"
69 #include "vm/jit/parse.h"
70 #include "vm/jit/reg.h"
72 # include "vm/jit/reorder.h"
74 #include "vm/jit/show.h"
75 #include "vm/jit/stack.h"
77 #include "vm/jit/allocator/simplereg.h"
78 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
79 # include "vm/jit/allocator/lsra.h"
81 #if defined(ENABLE_SSA)
82 # include "vm/jit/optimizing/lsra.h"
83 # include "vm/jit/optimizing/ssa.h"
87 #if defined(ENABLE_IFCONV)
88 # include "vm/jit/ifconv/ifconv.h"
91 #include "vm/jit/loop/analyze.h"
92 #include "vm/jit/loop/graph.h"
93 #include "vm/jit/loop/loop.h"
94 #include "vm/jit/verify/typecheck.h"
95 #include "vm/rt-timing.h"
97 #if defined(ENABLE_THREADS)
98 # include "threads/native/threads.h"
102 /* debug macros ***************************************************************/
105 #define DEBUG_JIT_COMPILEVERBOSE(x) \
107 if (compileverbose) { \
108 log_message_method(x, m); \
112 #define DEBUG_JIT_COMPILEVERBOSE(x) /* nothing */
116 /* the ICMD table ************************************************************/
119 #define N(name) name,
124 /* abbreviations for flags */
126 #define PEI ICMDTABLE_PEI
127 #define CALLS ICMDTABLE_CALLS
129 /* some machine dependent values */
134 #define IDIV_CALLS ICMDTABLE_CALLS
137 #if (SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
140 #define LDIV_CALLS ICMDTABLE_CALLS
143 /* include the actual table */
145 icmdtable_entry_t icmd_table[256] = {
146 #include <vm/jit/icmdtable.inc>
153 /* XXX hack until the old "PEI" definition is removed */
157 /* stackelement requirements of Java opcodes **********************************/
159 int stackreq[256] = {
161 1, /* JAVA_ACONST 1 */
162 1, /* JAVA_ICONST_M1 2 */
163 1, /* JAVA_ICONST_0 3 */
164 1, /* JAVA_ICONST_1 4 */
165 1, /* JAVA_ICONST_2 5 */
166 1, /* JAVA_ICONST_3 6 */
167 1, /* JAVA_ICONST_4 7 */
168 1, /* JAVA_ICONST_5 8 */
169 1, /* JAVA_LCONST_0 9 */
170 1, /* JAVA_LCONST_1 10 */
171 1, /* JAVA_FCONST_0 11 */
172 1, /* JAVA_FCONST_1 12 */
173 1, /* JAVA_FCONST_2 13 */
174 1, /* JAVA_DCONST_0 14 */
175 1, /* JAVA_DCONST_1 15 */
176 1, /* JAVA_BIPUSH 16 */
177 1, /* JAVA_SIPUSH 17 */
179 1, /* JAVA_LDC_W 19 */
180 1, /* JAVA_LDC2_W 20 */
181 1, /* JAVA_ILOAD 21 */
182 1, /* JAVA_LLOAD 22 */
183 1, /* JAVA_FLOAD 23 */
184 1, /* JAVA_DLOAD 24 */
185 1, /* JAVA_ALOAD 25 */
186 1, /* JAVA_ILOAD_0 26 */
187 1, /* JAVA_ILOAD_1 27 */
188 1, /* JAVA_ILOAD_2 28 */
189 1, /* JAVA_ILOAD_3 29 */
190 1, /* JAVA_LLOAD_0 30 */
191 1, /* JAVA_LLOAD_1 31 */
192 1, /* JAVA_LLOAD_2 32 */
193 1, /* JAVA_LLOAD_3 33 */
194 1, /* JAVA_FLOAD_0 34 */
195 1, /* JAVA_FLOAD_1 35 */
196 1, /* JAVA_FLOAD_2 36 */
197 1, /* JAVA_FLOAD_3 37 */
198 1, /* JAVA_DLOAD_0 38 */
199 1, /* JAVA_DLOAD_1 39 */
200 1, /* JAVA_DLOAD_2 40 */
201 1, /* JAVA_DLOAD_3 41 */
202 1, /* JAVA_ALOAD_0 42 */
203 1, /* JAVA_ALOAD_1 43 */
204 1, /* JAVA_ALOAD_2 44 */
205 1, /* JAVA_ALOAD_3 45 */
206 1, /* JAVA_IALOAD 46 */
207 1, /* JAVA_LALOAD 47 */
208 1, /* JAVA_FALOAD 48 */
209 1, /* JAVA_DALOAD 49 */
210 1, /* JAVA_AALOAD 50 */
211 1, /* JAVA_BALOAD 51 */
212 1, /* JAVA_CALOAD 52 */
213 1, /* JAVA_SALOAD 53 */
214 0, /* JAVA_ISTORE 54 */
215 0, /* JAVA_LSTORE 55 */
216 0, /* JAVA_FSTORE 56 */
217 0, /* JAVA_DSTORE 57 */
218 0, /* JAVA_ASTORE 58 */
219 0, /* JAVA_ISTORE_0 59 */
220 0, /* JAVA_ISTORE_1 60 */
221 0, /* JAVA_ISTORE_2 61 */
222 0, /* JAVA_ISTORE_3 62 */
223 0, /* JAVA_LSTORE_0 63 */
224 0, /* JAVA_LSTORE_1 64 */
225 0, /* JAVA_LSTORE_2 65 */
226 0, /* JAVA_LSTORE_3 66 */
227 0, /* JAVA_FSTORE_0 67 */
228 0, /* JAVA_FSTORE_1 68 */
229 0, /* JAVA_FSTORE_2 69 */
230 0, /* JAVA_FSTORE_3 70 */
231 0, /* JAVA_DSTORE_0 71 */
232 0, /* JAVA_DSTORE_1 72 */
233 0, /* JAVA_DSTORE_2 73 */
234 0, /* JAVA_DSTORE_3 74 */
235 0, /* JAVA_ASTORE_0 75 */
236 0, /* JAVA_ASTORE_1 76 */
237 0, /* JAVA_ASTORE_2 77 */
238 0, /* JAVA_ASTORE_3 78 */
239 0, /* JAVA_IASTORE 79 */
240 0, /* JAVA_LASTORE 80 */
241 0, /* JAVA_FASTORE 81 */
242 0, /* JAVA_DASTORE 82 */
243 0, /* JAVA_AASTORE 83 */
244 0, /* JAVA_BASTORE 84 */
245 0, /* JAVA_CASTORE 85 */
246 0, /* JAVA_SASTORE 86 */
248 0, /* JAVA_POP2 88 */
250 3, /* JAVA_DUP_X1 90 */
251 4, /* JAVA_DUP_X2 91 */
252 2, /* JAVA_DUP2 92 */
253 3, /* JAVA_DUP2_X1 93 */
254 4, /* JAVA_DUP2_X2 94 */
255 2, /* JAVA_SWAP 95 */
256 1, /* JAVA_IADD 96 */
257 1, /* JAVA_LADD 97 */
258 1, /* JAVA_FADD 98 */
259 1, /* JAVA_DADD 99 */
260 1, /* JAVA_ISUB 100 */
261 1, /* JAVA_LSUB 101 */
262 1, /* JAVA_FSUB 102 */
263 1, /* JAVA_DSUB 103 */
264 1, /* JAVA_IMUL 104 */
265 1, /* JAVA_LMUL 105 */
266 1, /* JAVA_FMUL 106 */
267 1, /* JAVA_DMUL 107 */
268 1, /* JAVA_IDIV 108 */
269 1, /* JAVA_LDIV 109 */
270 1, /* JAVA_FDIV 110 */
271 1, /* JAVA_DDIV 111 */
272 1, /* JAVA_IREM 112 */
273 1, /* JAVA_LREM 113 */
274 1, /* JAVA_FREM 114 */
275 1, /* JAVA_DREM 115 */
276 1, /* JAVA_INEG 116 */
277 1, /* JAVA_LNEG 117 */
278 1, /* JAVA_FNEG 118 */
279 1, /* JAVA_DNEG 119 */
280 1, /* JAVA_ISHL 120 */
281 1, /* JAVA_LSHL 121 */
282 1, /* JAVA_ISHR 122 */
283 1, /* JAVA_LSHR 123 */
284 1, /* JAVA_IUSHR 124 */
285 1, /* JAVA_LUSHR 125 */
286 1, /* JAVA_IAND 126 */
287 1, /* JAVA_LAND 127 */
288 1, /* JAVA_IOR 128 */
289 1, /* JAVA_LOR 129 */
290 1, /* JAVA_IXOR 130 */
291 1, /* JAVA_LXOR 131 */
292 0, /* JAVA_IINC 132 */
293 1, /* JAVA_I2L 133 */
294 1, /* JAVA_I2F 134 */
295 1, /* JAVA_I2D 135 */
296 1, /* JAVA_L2I 136 */
297 1, /* JAVA_L2F 137 */
298 1, /* JAVA_L2D 138 */
299 1, /* JAVA_F2I 139 */
300 1, /* JAVA_F2L 140 */
301 1, /* JAVA_F2D 141 */
302 1, /* JAVA_D2I 142 */
303 1, /* JAVA_D2L 143 */
304 1, /* JAVA_D2F 144 */
305 1, /* JAVA_INT2BYTE 145 */
306 1, /* JAVA_INT2CHAR 146 */
307 1, /* JAVA_INT2SHORT 147 */
308 1, /* JAVA_LCMP 148 */
309 1, /* JAVA_FCMPL 149 */
310 1, /* JAVA_FCMPG 150 */
311 1, /* JAVA_DCMPL 151 */
312 1, /* JAVA_DCMPG 152 */
313 0, /* JAVA_IFEQ 153 */
314 0, /* JAVA_IFNE 154 */
315 0, /* JAVA_IFLT 155 */
316 0, /* JAVA_IFGE 156 */
317 0, /* JAVA_IFGT 157 */
318 0, /* JAVA_IFLE 158 */
319 0, /* JAVA_IF_ICMPEQ 159 */
320 0, /* JAVA_IF_ICMPNE 160 */
321 0, /* JAVA_IF_ICMPLT 161 */
322 0, /* JAVA_IF_ICMPGE 162 */
323 0, /* JAVA_IF_ICMPGT 163 */
324 0, /* JAVA_IF_ICMPLE 164 */
325 0, /* JAVA_IF_ACMPEQ 165 */
326 0, /* JAVA_IF_ACMPNE 166 */
327 0, /* JAVA_GOTO 167 */
328 1, /* JAVA_JSR 168 */
329 0, /* JAVA_RET 169 */
330 0, /* JAVA_TABLESWITCH 170 */
331 0, /* JAVA_LOOKUPSWITCH 171 */
332 0, /* JAVA_IRETURN 172 */
333 0, /* JAVA_LRETURN 173 */
334 0, /* JAVA_FRETURN 174 */
335 0, /* JAVA_DRETURN 175 */
336 0, /* JAVA_ARETURN 176 */
337 0, /* JAVA_RETURN 177 */
338 1, /* JAVA_GETSTATIC 178 */
339 0, /* JAVA_PUTSTATIC 179 */
340 1, /* JAVA_GETFIELD 180 */
341 0, /* JAVA_PUTFIELD 181 */
342 1, /* JAVA_INVOKEVIRTUAL 182 */
343 1, /* JAVA_INVOKESPECIAL 183 */
344 1, /* JAVA_INVOKESTATIC 184 */
345 1, /* JAVA_INVOKEINTERFACE 185 */
346 1, /* JAVA_UNDEF186 186 */
347 1, /* JAVA_NEW 187 */
348 1, /* JAVA_NEWARRAY 188 */
349 1, /* JAVA_ANEWARRAY 189 */
350 1, /* JAVA_ARRAYLENGTH 190 */
351 1, /* JAVA_ATHROW 191 */
352 1, /* JAVA_CHECKCAST 192 */
353 1, /* JAVA_INSTANCEOF 193 */
354 0, /* JAVA_MONITORENTER 194 */
355 0, /* JAVA_MONITOREXIT 195 */
356 0, /* JAVA_WIDE 196 */
357 1, /* JAVA_MULTIANEWARRAY 197 */
358 0, /* JAVA_IFNULL 198 */
359 0, /* JAVA_IFNONNULL 199 */
360 0, /* JAVA_GOTO_W 200 */
361 1, /* JAVA_JSR_W 201 */
362 0, /* JAVA_BREAKPOINT 202 */
363 1, /* JAVA_UNDEF203 203 */
364 1, /* JAVA_UNDEF204 204 */
365 1, /* JAVA_UNDEF205 205 */
366 1, /* JAVA_UNDEF206 206 */
367 1, /* JAVA_UNDEF207 207 */
368 1, /* JAVA_UNDEF208 208 */
369 1, /* JAVA_UNDEF209 209 */
370 1, /* JAVA_UNDEF210 210 */
371 1, /* JAVA_UNDEF211 211 */
372 1, /* JAVA_UNDEF212 212 */
373 1, /* JAVA_UNDEF213 213 */
374 1, /* JAVA_UNDEF214 214 */
375 1, /* JAVA_UNDEF215 215 */
376 1, /* JAVA_UNDEF216 216 */
377 1, /* JAVA_UNDEF217 217 */
378 1, /* JAVA_UNDEF218 218 */
379 1, /* JAVA_UNDEF219 219 */
380 1, /* JAVA_UNDEF220 220 */
381 1, /* JAVA_UNDEF221 221 */
382 1, /* JAVA_UNDEF222 222 */
383 1, /* JAVA_UNDEF223 223 */
384 1, /* JAVA_UNDEF224 224 */
385 1, /* JAVA_UNDEF225 225 */
386 1, /* JAVA_UNDEF226 226 */
387 1, /* JAVA_UNDEF227 227 */
388 1, /* JAVA_UNDEF228 228 */
389 1, /* JAVA_UNDEF229 229 */
390 1, /* JAVA_UNDEF230 230 */
391 1, /* JAVA_UNDEF231 231 */
392 1, /* JAVA_UNDEF232 232 */
393 1, /* JAVA_UNDEF233 233 */
394 1, /* JAVA_UNDEF234 234 */
395 1, /* JAVA_UNDEF235 235 */
396 1, /* JAVA_UNDEF236 236 */
397 1, /* JAVA_UNDEF237 237 */
398 1, /* JAVA_UNDEF238 238 */
399 1, /* JAVA_UNDEF239 239 */
400 1, /* JAVA_UNDEF240 240 */
401 1, /* JAVA_UNDEF241 241 */
402 1, /* JAVA_UNDEF242 242 */
403 1, /* JAVA_UNDEF243 243 */
404 1, /* JAVA_UNDEF244 244 */
405 1, /* JAVA_UNDEF245 245 */
406 1, /* JAVA_UNDEF246 246 */
407 1, /* JAVA_UNDEF247 247 */
408 1, /* JAVA_UNDEF248 248 */
409 1, /* JAVA_UNDEF249 249 */
410 1, /* JAVA_UNDEF250 250 */
411 1, /* JAVA_UNDEF251 251 */
412 1, /* JAVA_UNDEF252 252 */
413 1, /* JAVA_UNDEF253 253 */
414 1, /* JAVA_UNDEF254 254 */
415 1, /* JAVA_UNDEF255 255 */
419 /* size in bytes of Java opcodes **********************************************/
421 int jcommandsize[256] = {
424 1, /* JAVA_ACONST_NULL 1 */
425 1, /* JAVA_ICONST_M1 2 */
426 1, /* JAVA_ICONST_0 3 */
427 1, /* JAVA_ICONST_1 4 */
428 1, /* JAVA_ICONST_2 5 */
429 1, /* JAVA_ICONST_3 6 */
430 1, /* JAVA_ICONST_4 7 */
431 1, /* JAVA_ICONST_5 8 */
432 1, /* JAVA_LCONST_0 9 */
433 1, /* JAVA_LCONST_1 10 */
434 1, /* JAVA_FCONST_0 11 */
435 1, /* JAVA_FCONST_1 12 */
436 1, /* JAVA_FCONST_2 13 */
437 1, /* JAVA_DCONST_0 14 */
438 1, /* JAVA_DCONST_1 15 */
439 2, /* JAVA_BIPUSH 16 */
440 3, /* JAVA_SIPUSH 17 */
441 2, /* JAVA_LDC1 18 */
442 3, /* JAVA_LDC2 19 */
443 3, /* JAVA_LDC2W 20 */
444 2, /* JAVA_ILOAD 21 */
445 2, /* JAVA_LLOAD 22 */
446 2, /* JAVA_FLOAD 23 */
447 2, /* JAVA_DLOAD 24 */
448 2, /* JAVA_ALOAD 25 */
449 1, /* JAVA_ILOAD_0 26 */
450 1, /* JAVA_ILOAD_1 27 */
451 1, /* JAVA_ILOAD_2 28 */
452 1, /* JAVA_ILOAD_3 29 */
453 1, /* JAVA_LLOAD_0 30 */
454 1, /* JAVA_LLOAD_1 31 */
455 1, /* JAVA_LLOAD_2 32 */
456 1, /* JAVA_LLOAD_3 33 */
457 1, /* JAVA_FLOAD_0 34 */
458 1, /* JAVA_FLOAD_1 35 */
459 1, /* JAVA_FLOAD_2 36 */
460 1, /* JAVA_FLOAD_3 37 */
461 1, /* JAVA_DLOAD_0 38 */
462 1, /* JAVA_DLOAD_1 39 */
463 1, /* JAVA_DLOAD_2 40 */
464 1, /* JAVA_DLOAD_3 41 */
465 1, /* JAVA_ALOAD_0 42 */
466 1, /* JAVA_ALOAD_1 43 */
467 1, /* JAVA_ALOAD_2 44 */
468 1, /* JAVA_ALOAD_3 45 */
469 1, /* JAVA_IALOAD 46 */
470 1, /* JAVA_LALOAD 47 */
471 1, /* JAVA_FALOAD 48 */
472 1, /* JAVA_DALOAD 49 */
473 1, /* JAVA_AALOAD 50 */
474 1, /* JAVA_BALOAD 51 */
475 1, /* JAVA_CALOAD 52 */
476 1, /* JAVA_SALOAD 53 */
477 2, /* JAVA_ISTORE 54 */
478 2, /* JAVA_LSTORE 55 */
479 2, /* JAVA_FSTORE 56 */
480 2, /* JAVA_DSTORE 57 */
481 2, /* JAVA_ASTORE 58 */
482 1, /* JAVA_ISTORE_0 59 */
483 1, /* JAVA_ISTORE_1 60 */
484 1, /* JAVA_ISTORE_2 61 */
485 1, /* JAVA_ISTORE_3 62 */
486 1, /* JAVA_LSTORE_0 63 */
487 1, /* JAVA_LSTORE_1 64 */
488 1, /* JAVA_LSTORE_2 65 */
489 1, /* JAVA_LSTORE_3 66 */
490 1, /* JAVA_FSTORE_0 67 */
491 1, /* JAVA_FSTORE_1 68 */
492 1, /* JAVA_FSTORE_2 69 */
493 1, /* JAVA_FSTORE_3 70 */
494 1, /* JAVA_DSTORE_0 71 */
495 1, /* JAVA_DSTORE_1 72 */
496 1, /* JAVA_DSTORE_2 73 */
497 1, /* JAVA_DSTORE_3 74 */
498 1, /* JAVA_ASTORE_0 75 */
499 1, /* JAVA_ASTORE_1 76 */
500 1, /* JAVA_ASTORE_2 77 */
501 1, /* JAVA_ASTORE_3 78 */
502 1, /* JAVA_IASTORE 79 */
503 1, /* JAVA_LASTORE 80 */
504 1, /* JAVA_FASTORE 81 */
505 1, /* JAVA_DASTORE 82 */
506 1, /* JAVA_AASTORE 83 */
507 1, /* JAVA_BASTORE 84 */
508 1, /* JAVA_CASTORE 85 */
509 1, /* JAVA_SASTORE 86 */
511 1, /* JAVA_POP2 88 */
513 1, /* JAVA_DUP_X1 90 */
514 1, /* JAVA_DUP_X2 91 */
515 1, /* JAVA_DUP2 92 */
516 1, /* JAVA_DUP2_X1 93 */
517 1, /* JAVA_DUP2_X2 94 */
518 1, /* JAVA_SWAP 95 */
519 1, /* JAVA_IADD 96 */
520 1, /* JAVA_LADD 97 */
521 1, /* JAVA_FADD 98 */
522 1, /* JAVA_DADD 99 */
523 1, /* JAVA_ISUB 100 */
524 1, /* JAVA_LSUB 101 */
525 1, /* JAVA_FSUB 102 */
526 1, /* JAVA_DSUB 103 */
527 1, /* JAVA_IMUL 104 */
528 1, /* JAVA_LMUL 105 */
529 1, /* JAVA_FMUL 106 */
530 1, /* JAVA_DMUL 107 */
531 1, /* JAVA_IDIV 108 */
532 1, /* JAVA_LDIV 109 */
533 1, /* JAVA_FDIV 110 */
534 1, /* JAVA_DDIV 111 */
535 1, /* JAVA_IREM 112 */
536 1, /* JAVA_LREM 113 */
537 1, /* JAVA_FREM 114 */
538 1, /* JAVA_DREM 115 */
539 1, /* JAVA_INEG 116 */
540 1, /* JAVA_LNEG 117 */
541 1, /* JAVA_FNEG 118 */
542 1, /* JAVA_DNEG 119 */
543 1, /* JAVA_ISHL 120 */
544 1, /* JAVA_LSHL 121 */
545 1, /* JAVA_ISHR 122 */
546 1, /* JAVA_LSHR 123 */
547 1, /* JAVA_IUSHR 124 */
548 1, /* JAVA_LUSHR 125 */
549 1, /* JAVA_IAND 126 */
550 1, /* JAVA_LAND 127 */
551 1, /* JAVA_IOR 128 */
552 1, /* JAVA_LOR 129 */
553 1, /* JAVA_IXOR 130 */
554 1, /* JAVA_LXOR 131 */
555 3, /* JAVA_IINC 132 */
556 1, /* JAVA_I2L 133 */
557 1, /* JAVA_I2F 134 */
558 1, /* JAVA_I2D 135 */
559 1, /* JAVA_L2I 136 */
560 1, /* JAVA_L2F 137 */
561 1, /* JAVA_L2D 138 */
562 1, /* JAVA_F2I 139 */
563 1, /* JAVA_F2L 140 */
564 1, /* JAVA_F2D 141 */
565 1, /* JAVA_D2I 142 */
566 1, /* JAVA_D2L 143 */
567 1, /* JAVA_D2F 144 */
568 1, /* JAVA_INT2BYTE 145 */
569 1, /* JAVA_INT2CHAR 146 */
570 1, /* JAVA_INT2SHORT 147 */
571 1, /* JAVA_LCMP 148 */
572 1, /* JAVA_FCMPL 149 */
573 1, /* JAVA_FCMPG 150 */
574 1, /* JAVA_DCMPL 151 */
575 1, /* JAVA_DCMPG 152 */
576 3, /* JAVA_IFEQ 153 */
577 3, /* JAVA_IFNE 154 */
578 3, /* JAVA_IFLT 155 */
579 3, /* JAVA_IFGE 156 */
580 3, /* JAVA_IFGT 157 */
581 3, /* JAVA_IFLE 158 */
582 3, /* JAVA_IF_ICMPEQ 159 */
583 3, /* JAVA_IF_ICMPNE 160 */
584 3, /* JAVA_IF_ICMPLT 161 */
585 3, /* JAVA_IF_ICMPGE 162 */
586 3, /* JAVA_IF_ICMPGT 163 */
587 3, /* JAVA_IF_ICMPLE 164 */
588 3, /* JAVA_IF_ACMPEQ 165 */
589 3, /* JAVA_IF_ACMPNE 166 */
590 3, /* JAVA_GOTO 167 */
591 3, /* JAVA_JSR 168 */
592 2, /* JAVA_RET 169 */
593 0, /* JAVA_TABLESWITCH 170 */ /* variable length */
594 0, /* JAVA_LOOKUPSWITCH 171 */ /* variable length */
595 1, /* JAVA_IRETURN 172 */
596 1, /* JAVA_LRETURN 173 */
597 1, /* JAVA_FRETURN 174 */
598 1, /* JAVA_DRETURN 175 */
599 1, /* JAVA_ARETURN 176 */
600 1, /* JAVA_RETURN 177 */
601 3, /* JAVA_GETSTATIC 178 */
602 3, /* JAVA_PUTSTATIC 179 */
603 3, /* JAVA_GETFIELD 180 */
604 3, /* JAVA_PUTFIELD 181 */
605 3, /* JAVA_INVOKEVIRTUAL 182 */
606 3, /* JAVA_INVOKESPECIAL 183 */
607 3, /* JAVA_INVOKESTATIC 184 */
608 5, /* JAVA_INVOKEINTERFACE 185 */
610 3, /* JAVA_NEW 187 */
611 2, /* JAVA_NEWARRAY 188 */
612 3, /* JAVA_ANEWARRAY 189 */
613 1, /* JAVA_ARRAYLENGTH 190 */
614 1, /* JAVA_ATHROW 191 */
615 3, /* JAVA_CHECKCAST 192 */
616 3, /* JAVA_INSTANCEOF 193 */
617 1, /* JAVA_MONITORENTER 194 */
618 1, /* JAVA_MONITOREXIT 195 */
619 0, /* JAVA_WIDE 196 */ /* variable length */
620 4, /* JAVA_MULTIANEWARRAY 197 */
621 3, /* JAVA_IFNULL 198 */
622 3, /* JAVA_IFNONNULL 199 */
623 5, /* JAVA_GOTO_W 200 */
624 5, /* JAVA_JSR_W 201 */
625 1, /* JAVA_BREAKPOINT 202 */
662 1,1,1,1,1,1,1,1,1,1,
667 /* Java opcode names *********************************************************/
669 char *opcode_names[256] = {
672 "ICONST_M1 ", /* ICONST_M1 2 */
673 "ICONST_0 ", /* ICONST_0 3 */
674 "ICONST_1 ", /* ICONST_1 4 */
675 "ICONST_2 ", /* ICONST_2 5 */
676 "ICONST_3 ", /* ICONST_3 6 */
677 "ICONST_4 ", /* ICONST_4 7 */
678 "ICONST_5 ", /* ICONST_5 8 */
679 "LCONST_0 ", /* LCONST_0 9 */
680 "LCONST_1 ", /* LCONST_1 10 */
681 "FCONST_0 ", /* FCONST_0 11 */
682 "FCONST_1 ", /* FCONST_1 12 */
683 "FCONST_2 ", /* FCONST_2 13 */
684 "DCONST_0 ", /* DCONST_0 14 */
685 "DCONST_1 ", /* DCONST_1 15 */
686 "BIPUSH ", /* BIPUSH 16 */
687 "SIPUSH ", /* SIPUSH 17 */
689 "LDC_W ", /* LDC_W 19 */
690 "LDC2_W ", /* LDC2_W 20 */
696 "ILOAD_0 ", /* ILOAD_0 26 */
697 "ILOAD_1 ", /* ILOAD_1 27 */
698 "ILOAD_2 ", /* ILOAD_2 28 */
699 "ILOAD_3 ", /* ILOAD_3 29 */
700 "LLOAD_0 ", /* LLOAD_0 30 */
701 "LLOAD_1 ", /* LLOAD_1 31 */
702 "LLOAD_2 ", /* LLOAD_2 32 */
703 "LLOAD_3 ", /* LLOAD_3 33 */
704 "FLOAD_0 ", /* FLOAD_0 34 */
705 "FLOAD_1 ", /* FLOAD_1 35 */
706 "FLOAD_2 ", /* FLOAD_2 36 */
707 "FLOAD_3 ", /* FLOAD_3 37 */
708 "DLOAD_0 ", /* DLOAD_0 38 */
709 "DLOAD_1 ", /* DLOAD_1 39 */
710 "DLOAD_2 ", /* DLOAD_2 40 */
711 "DLOAD_3 ", /* DLOAD_3 41 */
712 "ALOAD_0 ", /* ALOAD_0 42 */
713 "ALOAD_1 ", /* ALOAD_1 43 */
714 "ALOAD_2 ", /* ALOAD_2 44 */
715 "ALOAD_3 ", /* ALOAD_3 45 */
729 "ISTORE_0 ", /* ISTORE_0 59 */
730 "ISTORE_1 ", /* ISTORE_1 60 */
731 "ISTORE_2 ", /* ISTORE_2 61 */
732 "ISTORE_3 ", /* ISTORE_3 62 */
733 "LSTORE_0 ", /* LSTORE_0 63 */
734 "LSTORE_1 ", /* LSTORE_1 64 */
735 "LSTORE_2 ", /* LSTORE_2 65 */
736 "LSTORE_3 ", /* LSTORE_3 66 */
737 "FSTORE_0 ", /* FSTORE_0 67 */
738 "FSTORE_1 ", /* FSTORE_1 68 */
739 "FSTORE_2 ", /* FSTORE_2 69 */
740 "FSTORE_3 ", /* FSTORE_3 70 */
741 "DSTORE_0 ", /* DSTORE_0 71 */
742 "DSTORE_1 ", /* DSTORE_1 72 */
743 "DSTORE_2 ", /* DSTORE_2 73 */
744 "DSTORE_3 ", /* DSTORE_3 74 */
745 "ASTORE_0 ", /* ASTORE_0 75 */
746 "ASTORE_1 ", /* ASTORE_1 76 */
747 "ASTORE_2 ", /* ASTORE_2 77 */
748 "ASTORE_3 ", /* ASTORE_3 78 */
815 "INT2BYTE ", /* 145 */
816 "INT2CHAR ", /* 146 */
817 "INT2SHORT ", /* 147 */
829 "IF_ICMPEQ ", /* 159 */
830 "IF_ICMPNE ", /* 160 */
831 "IF_ICMPLT ", /* 161 */
832 "IF_ICMPGE ", /* 162 */
833 "IF_ICMPGT ", /* 163 */
834 "IF_ICMPLE ", /* 164 */
835 "IF_ACMPEQ ", /* 165 */
836 "IF_ACMPNE ", /* 166 */
840 "TABLESWITCH ", /* 170 */
841 "LOOKUPSWITCH ", /* 171 */
842 "IRETURN ", /* 172 */
843 "LRETURN ", /* 173 */
844 "FRETURN ", /* 174 */
845 "DRETURN ", /* 175 */
846 "ARETURN ", /* 176 */
848 "GETSTATIC ", /* 178 */
849 "PUTSTATIC ", /* 179 */
850 "GETFIELD ", /* 180 */
851 "PUTFIELD ", /* 181 */
852 "INVOKEVIRTUAL ", /* 182 */
853 "INVOKESPECIAL ", /* 183 */
854 "INVOKESTATIC ", /* 184 */
855 "INVOKEINTERFACE", /* 185 */
856 "UNDEF186 ", /* 186 */
858 "NEWARRAY ", /* 188 */
859 "ANEWARRAY ", /* 189 */
860 "ARRAYLENGTH ", /* 190 */
862 "CHECKCAST ", /* 192 */
863 "INSTANCEOF ", /* 193 */
864 "MONITORENTER ", /* 194 */
865 "MONITOREXIT ", /* 195 */
866 "WIDE ", /* WIDE 196 */
867 "MULTIANEWARRAY ", /* 197 */
869 "IFNONNULL ", /* 199 */
870 "GOTO_W ", /* GOTO_W 200 */
871 "JSR_W ", /* JSR_W 201 */
872 "BREAKPOINT ", /* BREAKPOINT 202 */
874 "UNDEF203", "UNDEF204", "UNDEF205",
875 "UNDEF206", "UNDEF207", "UNDEF208", "UNDEF209", "UNDEF210",
876 "UNDEF211", "UNDEF212", "UNDEF213", "UNDEF214", "UNDEF215",
877 "UNDEF216", "UNDEF217", "UNDEF218", "UNDEF219", "UNDEF220",
878 "UNDEF221", "UNDEF222", "UNDEF223", "UNDEF224", "UNDEF225",
879 "UNDEF226", "UNDEF227", "UNDEF228", "UNDEF229", "UNDEF230",
880 "UNDEF231", "UNDEF232", "UNDEF233", "UNDEF234", "UNDEF235",
881 "UNDEF236", "UNDEF237", "UNDEF238", "UNDEF239", "UNDEF240",
882 "UNDEF241", "UNDEF242", "UNDEF243", "UNDEF244", "UNDEF245",
883 "UNDEF246", "UNDEF247", "UNDEF248", "UNDEF249", "UNDEF250",
884 "UNDEF251", "UNDEF252", "UNDEF253", "UNDEF254", "UNDEF255"
888 /* jit_init ********************************************************************
890 Initializes the JIT subsystem.
892 *******************************************************************************/
896 /* initialize stack analysis subsystem */
900 /* initialize show subsystem */
906 /* initialize codegen subsystem */
912 /* jit_close *******************************************************************
914 Close the JIT subsystem.
916 *******************************************************************************/
924 /* dummy function, used when there is no JavaVM code available */
926 static u1 *do_nothing_function(void)
932 /* jit_jitdata_new *************************************************************
934 Allocates and initalizes a new jitdata structure.
936 *******************************************************************************/
938 static jitdata *jit_jitdata_new(methodinfo *m)
942 /* allocate jitdata structure and fill it */
947 jd->cd = DNEW(codegendata);
948 jd->rd = DNEW(registerdata);
949 #if defined(ENABLE_LOOP)
950 jd->ld = DNEW(loopdata);
953 /* Allocate codeinfo memory from the heap as we need to keep them. */
955 jd->code = code_codeinfo_new(m);
957 /* initialize variables */
960 jd->isleafmethod = true;
961 jd->exceptiontable = NULL;
962 jd->exceptiontablelength = 0;
968 /* jit_compile *****************************************************************
970 Translates one method to machine code.
972 *******************************************************************************/
974 static u1 *jit_compile_intern(jitdata *jd);
976 u1 *jit_compile(methodinfo *m)
982 STATISTICS(count_jit_calls++);
984 /* Initialize the static function's class. */
986 /* ATTENTION: This MUST be done before the method lock is aquired,
987 otherwise we could run into a deadlock with <clinit>'s that
988 call static methods of it's own class. */
990 if ((m->flags & ACC_STATIC) && !(m->class->state & CLASS_INITIALIZED)) {
993 log_message_class("Initialize class ", m->class);
996 if (!initialize_class(m->class))
999 /* check if the method has been compiled during initialization */
1001 if ((m->code != NULL) && (m->code->entrypoint != NULL))
1002 return m->code->entrypoint;
1005 /* enter a monitor on the method */
1007 LOCK_MONITOR_ENTER(m);
1009 /* if method has been already compiled return immediately */
1011 if (m->code != NULL) {
1012 LOCK_MONITOR_EXIT(m);
1014 assert(m->code->entrypoint);
1015 return m->code->entrypoint;
1018 STATISTICS(count_methods++);
1020 #if defined(ENABLE_STATISTICS)
1023 if (opt_getcompilingtime)
1024 compilingtime_start();
1027 /* mark start of dump memory area */
1029 dumpsize = dump_size();
1031 /* create jitdata structure */
1033 jd = jit_jitdata_new(m);
1035 /* set the flags for the current JIT run */
1037 jd->flags = JITDATA_FLAG_PARSE;
1039 #if defined(ENABLE_VERIFIER)
1041 jd->flags |= JITDATA_FLAG_VERIFY;
1045 jd->flags |= JITDATA_FLAG_INSTRUMENT;
1047 #if defined(ENABLE_IFCONV)
1049 jd->flags |= JITDATA_FLAG_IFCONV;
1052 if (opt_showintermediate)
1053 jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
1055 if (opt_showdisassemble)
1056 jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
1058 if (opt_verbosecall)
1059 jd->flags |= JITDATA_FLAG_VERBOSECALL;
1061 #if defined(ENABLE_JIT)
1062 # if defined(ENABLE_INTRP)
1065 /* initialize the register allocator */
1071 /* setup the codegendata memory */
1075 /* now call internal compile function */
1077 r = jit_compile_intern(jd);
1080 /* We had an exception! Finish stuff here if necessary. */
1082 /* release codeinfo */
1084 code_codeinfo_free(jd->code);
1086 /* Release memory for basic block profiling information. */
1088 if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
1089 if (jd->code->bbfrequency != NULL)
1090 MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount);
1093 DEBUG_JIT_COMPILEVERBOSE("Running: ");
1096 /* release dump area */
1098 dump_release(dumpsize);
1100 #if defined(ENABLE_STATISTICS)
1103 if (opt_getcompilingtime)
1104 compilingtime_stop();
1107 /* leave the monitor */
1109 LOCK_MONITOR_EXIT(m);
1111 /* return pointer to the methods entry point */
1117 /* jit_recompile ***************************************************************
1119 Recompiles a Java method.
1121 *******************************************************************************/
1123 u1 *jit_recompile(methodinfo *m)
1130 /* check for max. optimization level */
1132 optlevel = m->code->optlevel;
1134 if (optlevel == 1) {
1135 /* log_message_method("not recompiling: ", m); */
1139 log_message_method("Recompiling start: ", m);
1141 STATISTICS(count_jit_calls++);
1143 #if defined(ENABLE_STATISTICS)
1146 if (opt_getcompilingtime)
1147 compilingtime_start();
1150 /* mark start of dump memory area */
1152 dumpsize = dump_size();
1154 /* create jitdata structure */
1156 jd = jit_jitdata_new(m);
1158 /* set the current optimization level to the previous one plus 1 */
1160 jd->code->optlevel = optlevel + 1;
1162 /* get the optimization flags for the current JIT run */
1164 jd->flags |= JITDATA_FLAG_REORDER;
1165 jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
1166 jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
1167 /* jd->flags |= JITDATA_FLAG_VERBOSECALL; */
1169 #if defined(ENABLE_JIT)
1170 # if defined(ENABLE_INTRP)
1173 /* initialize the register allocator */
1178 /* setup the codegendata memory */
1182 /* now call internal compile function */
1184 r = jit_compile_intern(jd);
1187 /* We had an exception! Finish stuff here if necessary. */
1189 /* release codeinfo */
1191 code_codeinfo_free(jd->code);
1194 /* release dump area */
1196 dump_release(dumpsize);
1198 #if defined(ENABLE_STATISTICS)
1201 if (opt_getcompilingtime)
1202 compilingtime_stop();
1205 log_message_method("Recompiling done: ", m);
1207 /* return pointer to the methods entry point */
1213 /* jit_compile_intern **********************************************************
1215 Static internal function which does the actual compilation.
1217 *******************************************************************************/
1219 static u1 *jit_compile_intern(jitdata *jd)
1225 #if defined(ENABLE_RT_TIMING)
1226 struct timespec time_start,time_checks,time_parse,time_stack,
1227 time_typecheck,time_loop,time_ifconv,time_alloc,
1228 time_rplpoints,time_codegen;
1231 RT_TIMING_GET_TIME(time_start);
1233 /* get required compiler data */
1235 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
1242 /* print log message for compiled method */
1244 DEBUG_JIT_COMPILEVERBOSE("Compiling: ");
1246 /* handle native methods and create a native stub */
1248 if (m->flags & ACC_NATIVE) {
1251 #if defined(WITH_STATIC_CLASSPATH)
1252 f = native_findfunction(m->class->name, m->name, m->descriptor,
1253 (m->flags & ACC_STATIC));
1260 code = codegen_createnativestub(f, m);
1262 assert(!m->code); /* native methods are never recompiled */
1265 return code->entrypoint;
1268 /* if there is no javacode, print error message and return empty method */
1270 if (m->jcode == NULL) {
1271 DEBUG_JIT_COMPILEVERBOSE("No code given for: ");
1273 code->entrypoint = (u1 *) (ptrint) do_nothing_function;
1276 return code->entrypoint; /* return empty method */
1279 #if defined(ENABLE_STATISTICS)
1281 count_tryblocks += m->exceptiontablelength;
1282 count_javacodesize += m->jcodelength + 18;
1283 count_javaexcsize += m->exceptiontablelength * SIZEOF_VOID_P;
1287 RT_TIMING_GET_TIME(time_checks);
1289 /* call the compiler passes ***********************************************/
1291 DEBUG_JIT_COMPILEVERBOSE("Parsing: ");
1293 /* call parse pass */
1296 DEBUG_JIT_COMPILEVERBOSE("Exception while parsing: ");
1300 RT_TIMING_GET_TIME(time_parse);
1302 DEBUG_JIT_COMPILEVERBOSE("Parsing done: ");
1304 #if defined(ENABLE_JIT)
1305 # if defined(ENABLE_INTRP)
1308 DEBUG_JIT_COMPILEVERBOSE("Analysing: ");
1310 /* call stack analysis pass */
1312 if (!stack_analyse(jd)) {
1313 DEBUG_JIT_COMPILEVERBOSE("Exception while analysing: ");
1317 RT_TIMING_GET_TIME(time_stack);
1319 DEBUG_JIT_COMPILEVERBOSE("Analysing done: ");
1321 /* Build the CFG. This has to be done after stack_analyse, as
1322 there happens the JSR elimination. */
1327 #ifdef ENABLE_VERIFIER
1328 if (jd->flags & JITDATA_FLAG_VERIFY) {
1329 DEBUG_JIT_COMPILEVERBOSE("Typechecking: ");
1331 /* call typecheck pass */
1332 if (!typecheck(jd)) {
1333 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: ");
1338 DEBUG_JIT_COMPILEVERBOSE("Typechecking done: ");
1341 RT_TIMING_GET_TIME(time_typecheck);
1343 #if defined(ENABLE_LOOP)
1348 jit_renumber_basicblocks(jd);
1351 RT_TIMING_GET_TIME(time_loop);
1353 #if defined(ENABLE_IFCONV)
1354 if (JITDATA_HAS_FLAG_IFCONV(jd)) {
1355 if (!ifconv_static(jd))
1357 jit_renumber_basicblocks(jd);
1360 RT_TIMING_GET_TIME(time_ifconv);
1362 /* Basic block reordering. I think this should be done after
1363 if-conversion, as we could lose the ability to do the
1366 if (JITDATA_HAS_FLAG_REORDER(jd)) {
1369 jit_renumber_basicblocks(jd);
1372 DEBUG_JIT_COMPILEVERBOSE("Allocating registers: ");
1374 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
1375 /* allocate registers */
1380 STATISTICS(count_methods_allocated_by_lsra++);
1383 # endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */
1384 #if defined(ENABLE_SSA)
1385 /* allocate registers */
1386 if ((opt_lsra) && (jd->exceptiontablelength == 0)) {
1387 jd->ls = DNEW(lsradata);
1390 STATISTICS(count_methods_allocated_by_lsra++);
1393 # endif /* defined(ENABLE_SSA) */
1395 STATISTICS(count_locals_conflicts += (cd->maxlocals - 1) * (cd->maxlocals));
1400 STATISTICS(simplereg_make_statistics(jd));
1402 DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: ");
1403 # if defined(ENABLE_INTRP)
1406 #endif /* defined(ENABLE_JIT) */
1407 RT_TIMING_GET_TIME(time_alloc);
1409 /* Allocate memory for basic block profiling information. This
1410 _must_ be done after loop optimization and register allocation,
1411 since they can change the basic block count. */
1413 if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
1414 code->bbfrequency = MNEW(u4, jd->basicblockcount);
1416 DEBUG_JIT_COMPILEVERBOSE("Generating code: ");
1418 /* create the replacement points */
1420 if (!replace_create_replacement_points(jd))
1423 RT_TIMING_GET_TIME(time_rplpoints);
1425 /* now generate the machine code */
1427 #if defined(ENABLE_JIT)
1428 # if defined(ENABLE_INTRP)
1430 #if defined(ENABLE_VERIFIER)
1432 DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): ");
1434 if (!typecheck_stackbased(jd)) {
1435 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): ");
1440 if (!intrp_codegen(jd)) {
1441 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
1449 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
1455 if (!intrp_codegen(jd)) {
1456 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
1461 RT_TIMING_GET_TIME(time_codegen);
1463 DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
1465 #if !defined(NDEBUG)
1466 /* intermediate and assembly code listings */
1468 if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
1469 show_method(jd, SHOW_CODE);
1471 else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
1472 # if defined(ENABLE_DISASSEMBLER)
1473 DISASSEMBLE(code->entrypoint,
1474 code->entrypoint + (code->mcodelength - cd->dseglen));
1478 if (opt_showddatasegment)
1482 DEBUG_JIT_COMPILEVERBOSE("Compiling done: ");
1484 /* switch to the newly generated code */
1487 assert(code->entrypoint);
1489 /* add the current compile version to the methodinfo */
1491 code->prev = m->code;
1494 RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS);
1495 RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE);
1496 RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK);
1497 RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK);
1498 RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP);
1499 RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC);
1500 RT_TIMING_TIME_DIFF(time_alloc,time_rplpoints,RT_TIMING_JIT_RPLPOINTS);
1501 RT_TIMING_TIME_DIFF(time_rplpoints,time_codegen,RT_TIMING_JIT_CODEGEN);
1502 RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL);
1504 /* return pointer to the methods entry point */
1506 return code->entrypoint;
1510 /* jit_asm_compile *************************************************************
1512 This method is called from asm_vm_call_method and does:
1514 - create stackframe info for exceptions
1515 - compile the method
1516 - patch the entrypoint of the method into the calculated address in
1518 - flushes the instruction cache.
1520 *******************************************************************************/
1522 u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra)
1529 /* create the stackframeinfo (XPC is equal to RA) */
1531 stacktrace_create_extern_stackframeinfo(&sfi, NULL, sp, ra, ra);
1533 /* actually compile the method */
1535 entrypoint = jit_compile(m);
1537 /* remove the stackframeinfo */
1539 stacktrace_remove_stackframeinfo(&sfi);
1541 /* there was a problem during compilation */
1543 if (entrypoint == NULL)
1546 /* get the method patch address */
1548 pa = md_get_method_patch_address(ra, &sfi, mptr);
1550 /* patch the method entry point */
1554 *p = (ptrint) entrypoint;
1556 /* flush the instruction cache */
1558 md_icacheflush(pa, SIZEOF_VOID_P);
1564 /* jit_complement_condition ****************************************************
1566 Returns the complement of the passed conditional instruction.
1568 We use the order of the different conditions, e.g.:
1573 If the passed opcode is odd, we simply add 1 to get the complement.
1574 If the opcode is even, we subtract 1.
1581 *******************************************************************************/
1583 s4 jit_complement_condition(s4 opcode)
1587 return ICMD_IFNONNULL;
1589 case ICMD_IFNONNULL:
1593 /* check if opcode is odd */
1603 /* jit_renumber_basicblocks ****************************************************
1605 Set the ->nr of all blocks so it increases when traversing ->next.
1608 jitdata..........the current jitdata
1610 *******************************************************************************/
1612 void jit_renumber_basicblocks(jitdata *jd)
1618 for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1622 /* we have one block more than jd->basicblockcount (the end marker) */
1624 assert(nr == jd->basicblockcount + 1);
1628 /* jit_check_basicblock_numbers ************************************************
1630 Assert that the ->nr of the first block is zero and increases by 1 each
1631 time ->next is traversed.
1632 This function should be called before any analysis that relies on
1633 the basicblock numbers.
1636 jitdata..........the current jitdata
1638 NOTE: Aborts with an assertion if the condition is not met!
1640 *******************************************************************************/
1642 #if !defined(NDEBUG)
1643 void jit_check_basicblock_numbers(jitdata *jd)
1649 for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1650 assert(bptr->nr == nr);
1654 /* we have one block more than jd->basicblockcount (the end marker) */
1656 assert(nr == jd->basicblockcount + 1);
1658 #endif /* !defined(NDEBUG) */
1662 * These are local overrides for various environment variables in Emacs.
1663 * Please do not remove this and leave it at the end of the file, where
1664 * Emacs will automagically detect them.
1665 * ---------------------------------------------------------------------
1668 * indent-tabs-mode: t
1672 * vim:noexpandtab:sw=4:ts=4: