1 /* src/vm/jit/jit.c - calls the code generation functions
3 Copyright (C) 1996-2005, 2006, 2007, 2008
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
35 #include "mm/memory.h"
37 #include "native/native.h"
39 #include "toolbox/logging.h"
41 #include "threads/lock-common.h"
43 #include "vm/global.h"
44 #include "vm/initialize.h"
46 #include "vm/jit/asmpart.h"
48 #include "vm/jit/cfg.h"
50 #include "vm/jit/codegen-common.h"
51 #include "vm/jit/disass.h"
52 #include "vm/jit/dseg.h"
53 #include "vm/jit/jit.h"
54 #include "vm/jit/parse.h"
55 #include "vm/jit/reg.h"
57 #include "vm/jit/show.h"
58 #include "vm/jit/stack.h"
60 #if defined(ENABLE_JITCACHE)
61 # include "vm/jit/jitcache.h"
64 #include "vm/jit/allocator/simplereg.h"
65 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
66 # include "vm/jit/allocator/lsra.h"
69 #if defined(ENABLE_SSA)
70 # include "vm/jit/optimizing/lsra.h"
71 # include "vm/jit/optimizing/ssa.h"
74 #if defined(ENABLE_INLINING)
75 # include "vm/jit/inline/inline.h"
78 #include "vm/jit/ir/bytecode.h"
80 #include "vm/jit/loop/analyze.h"
81 #include "vm/jit/loop/graph.h"
82 #include "vm/jit/loop/loop.h"
84 #if defined(ENABLE_IFCONV)
85 # include "vm/jit/optimizing/ifconv.h"
88 #include "vm/jit/optimizing/reorder.h"
90 #if defined(ENABLE_PYTHON)
91 # include "vm/jit/python.h"
94 #include "vm/jit/verify/typecheck.h"
96 #include "vmcore/class.h"
97 #include "vmcore/loader.h"
98 #include "vmcore/method.h"
99 #include "vmcore/options.h"
100 #include "vmcore/rt-timing.h"
101 #include "vmcore/statistics.h"
104 /* debug macros ***************************************************************/
107 #define DEBUG_JIT_COMPILEVERBOSE(x) \
109 if (compileverbose) { \
110 log_message_method(x, m); \
114 #define DEBUG_JIT_COMPILEVERBOSE(x) /* nothing */
118 # define TRACECOMPILERCALLS() \
120 if (opt_TraceCompilerCalls) { \
122 log_print("[JIT compiler started: method="); \
129 # define TRACECOMPILERCALLS()
133 /* the ICMD table ************************************************************/
136 #define N(name) name,
141 /* abbreviations for flags */
143 #define PEI ICMDTABLE_PEI
144 #define CALLS ICMDTABLE_CALLS
146 /* some machine dependent values */
151 #define IDIV_CALLS ICMDTABLE_CALLS
154 #if (SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
157 #define LDIV_CALLS ICMDTABLE_CALLS
160 /* include the actual table */
162 icmdtable_entry_t icmd_table[256] = {
163 #include <vm/jit/icmdtable.inc>
170 /* XXX hack until the old "PEI" definition is removed */
174 /* jit_init ********************************************************************
176 Initializes the JIT subsystem.
178 *******************************************************************************/
182 TRACESUBSYSTEMINITIALIZATION("jit_init");
184 #if defined(ENABLE_JIT)
185 /* initialize stack analysis subsystem */
190 /* initialize show subsystem */
196 /* initialize codegen subsystem */
200 /* initialize code subsystem */
204 /* Machine dependent initialization. */
206 #if defined(ENABLE_JIT)
207 # if defined(ENABLE_INTRP)
219 /* jit_close *******************************************************************
221 Close the JIT subsystem.
223 *******************************************************************************/
231 /* dummy function, used when there is no JavaVM code available */
233 static u1 *do_nothing_function(void)
239 /* jit_jitdata_new *************************************************************
241 Allocates and initalizes a new jitdata structure.
243 *******************************************************************************/
245 jitdata *jit_jitdata_new(methodinfo *m)
250 /* allocate jitdata structure and fill it */
255 jd->cd = DNEW(codegendata);
256 jd->rd = DNEW(registerdata);
257 #if defined(ENABLE_LOOP)
258 jd->ld = DNEW(loopdata);
261 /* Allocate codeinfo memory from the heap as we need to keep them. */
263 code = code_codeinfo_new(m);
265 /* Set codeinfo flags. */
267 #if defined(ENABLE_THREADS)
268 if (checksync && (m->flags & ACC_SYNCHRONIZED))
269 code_flag_synchronized(code);
271 if (checksync && (m->flags & ACC_SYNCHRONIZED))
272 code_unflag_leafmethod(code);
275 code_flag_leafmethod(code);
277 /* initialize variables */
281 jd->exceptiontable = NULL;
282 jd->exceptiontablelength = 0;
284 jd->branchtoentry = false;
285 jd->branchtoend = false;
287 jd->returnblock = NULL;
288 jd->maxlocals = m->maxlocals;
294 /* jit_compile *****************************************************************
296 Translates one method to machine code.
298 *******************************************************************************/
300 static u1 *jit_compile_intern(jitdata *jd);
302 u1 *jit_compile(methodinfo *m)
308 STATISTICS(count_jit_calls++);
310 /* Initialize the static function's class. */
312 /* ATTENTION: This MUST be done before the method lock is aquired,
313 otherwise we could run into a deadlock with <clinit>'s that
314 call static methods of it's own class. */
316 if ((m->flags & ACC_STATIC) && !(m->clazz->state & CLASS_INITIALIZED)) {
319 log_message_class("Initialize class ", m->clazz);
322 if (!initialize_class(m->clazz))
325 /* check if the method has been compiled during initialization */
327 if ((m->code != NULL) && (m->code->entrypoint != NULL))
328 return m->code->entrypoint;
331 /* enter a monitor on the method */
333 LOCK_MONITOR_ENTER(m);
335 /* if method has been already compiled return immediately */
337 if (m->code != NULL) {
338 LOCK_MONITOR_EXIT(m);
340 assert(m->code->entrypoint);
341 return m->code->entrypoint;
344 TRACECOMPILERCALLS();
346 STATISTICS(count_methods++);
348 #if defined (ENABLE_JITCACHE)
350 if (jitcache_load (m))
352 LOCK_MONITOR_EXIT(m);
354 return m->code->entrypoint;
359 #if defined(ENABLE_STATISTICS)
362 if (opt_getcompilingtime)
363 compilingtime_start();
366 /* mark start of dump memory area */
370 /* create jitdata structure */
372 jd = jit_jitdata_new(m);
374 /* set the flags for the current JIT run */
376 jd->flags = JITDATA_FLAG_PARSE;
378 #if defined(ENABLE_VERIFIER)
380 jd->flags |= JITDATA_FLAG_VERIFY;
383 #if defined(ENABLE_PROFILING)
385 jd->flags |= JITDATA_FLAG_INSTRUMENT;
388 #if defined(ENABLE_IFCONV)
390 jd->flags |= JITDATA_FLAG_IFCONV;
393 #if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG)
394 if (opt_Inline && opt_InlineAll)
395 jd->flags |= JITDATA_FLAG_INLINE;
398 if (opt_showintermediate)
399 jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
401 if (opt_showdisassemble)
402 jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
405 jd->flags |= JITDATA_FLAG_VERBOSECALL;
407 #if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING)
409 jd->flags |= JITDATA_FLAG_COUNTDOWN;
412 #if defined(ENABLE_JIT)
413 # if defined(ENABLE_INTRP)
416 /* initialize the register allocator */
422 /* setup the codegendata memory */
426 /* now call internal compile function */
428 r = jit_compile_intern(jd);
431 /* We had an exception! Finish stuff here if necessary. */
433 /* release codeinfo */
435 code_codeinfo_free(jd->code);
437 #if defined(ENABLE_PROFILING)
438 /* Release memory for basic block profiling information. */
440 if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
441 if (jd->code->bbfrequency != NULL)
442 MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount);
446 DEBUG_JIT_COMPILEVERBOSE("Running: ");
449 #if defined (ENABLE_JITCACHE)
453 /* release dump area */
457 #if defined(ENABLE_STATISTICS)
460 if (opt_getcompilingtime)
461 compilingtime_stop();
464 /* leave the monitor */
466 LOCK_MONITOR_EXIT(m);
468 /* return pointer to the methods entry point */
474 /* jit_recompile ***************************************************************
476 Recompiles a Java method.
478 *******************************************************************************/
480 u1 *jit_recompile(methodinfo *m)
487 /* check for max. optimization level */
489 optlevel = (m->code) ? m->code->optlevel : 0;
493 /* log_message_method("not recompiling: ", m); */
498 DEBUG_JIT_COMPILEVERBOSE("Recompiling start: ");
500 STATISTICS(count_jit_calls++);
502 #if defined(ENABLE_STATISTICS)
505 if (opt_getcompilingtime)
506 compilingtime_start();
509 /* mark start of dump memory area */
513 /* create jitdata structure */
515 jd = jit_jitdata_new(m);
517 /* set the current optimization level to the previous one plus 1 */
519 jd->code->optlevel = optlevel + 1;
521 /* get the optimization flags for the current JIT run */
523 #if defined(ENABLE_VERIFIER)
524 jd->flags |= JITDATA_FLAG_VERIFY;
527 /* jd->flags |= JITDATA_FLAG_REORDER; */
528 if (opt_showintermediate)
529 jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
530 if (opt_showdisassemble)
531 jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
533 jd->flags |= JITDATA_FLAG_VERBOSECALL;
535 #if defined(ENABLE_INLINING)
537 jd->flags |= JITDATA_FLAG_INLINE;
540 #if defined(ENABLE_JIT)
541 # if defined(ENABLE_INTRP)
544 /* initialize the register allocator */
549 /* setup the codegendata memory */
553 /* now call internal compile function */
555 r = jit_compile_intern(jd);
558 /* We had an exception! Finish stuff here if necessary. */
560 /* release codeinfo */
562 code_codeinfo_free(jd->code);
565 /* release dump area */
569 #if defined(ENABLE_STATISTICS)
572 if (opt_getcompilingtime)
573 compilingtime_stop();
576 DEBUG_JIT_COMPILEVERBOSE("Recompiling done: ");
578 /* return pointer to the methods entry point */
583 #if defined(ENABLE_PM_HACKS)
584 #include "vm/jit/jit_pm_1.inc"
587 /* jit_compile_intern **********************************************************
589 Static internal function which does the actual compilation.
591 *******************************************************************************/
593 static u1 *jit_compile_intern(jitdata *jd)
599 #if defined(ENABLE_RT_TIMING)
600 struct timespec time_start,time_checks,time_parse,time_stack,
601 time_typecheck,time_loop,time_ifconv,time_alloc,
605 RT_TIMING_GET_TIME(time_start);
607 /* get required compiler data */
609 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
616 #if defined(ENABLE_DEBUG_FILTER)
617 show_filters_apply(jd->m);
620 /* Handle native methods and create a native stub. */
622 if (m->flags & ACC_NATIVE) {
625 f = native_method_resolve(m);
630 code = codegen_generate_stub_native(m, f);
632 /* Native methods are never recompiled. */
638 return code->entrypoint;
641 /* if there is no javacode, print error message and return empty method */
643 if (m->jcode == NULL) {
644 DEBUG_JIT_COMPILEVERBOSE("No code given for: ");
646 code->entrypoint = (u1 *) (ptrint) do_nothing_function;
649 return code->entrypoint; /* return empty method */
652 #if defined(ENABLE_STATISTICS)
654 count_javacodesize += m->jcodelength + 18;
655 count_tryblocks += jd->exceptiontablelength;
656 count_javaexcsize += jd->exceptiontablelength * SIZEOF_VOID_P;
660 RT_TIMING_GET_TIME(time_checks);
662 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
663 /* Code for Sun's OpenJDK (see
664 hotspot/src/share/vm/classfile/verifier.cpp
665 (Verifier::is_eligible_for_verification)): Don't verify
666 dynamically-generated bytecodes. */
668 # if defined(ENABLE_VERIFIER)
669 if (class_issubclass(m->clazz, class_sun_reflect_MagicAccessorImpl))
670 jd->flags &= ~JITDATA_FLAG_VERIFY;
674 /* call the compiler passes ***********************************************/
676 DEBUG_JIT_COMPILEVERBOSE("Parsing: ");
678 /* call parse pass */
681 DEBUG_JIT_COMPILEVERBOSE("Exception while parsing: ");
685 RT_TIMING_GET_TIME(time_parse);
687 DEBUG_JIT_COMPILEVERBOSE("Parsing done: ");
689 #if defined(ENABLE_JIT)
690 # if defined(ENABLE_INTRP)
693 DEBUG_JIT_COMPILEVERBOSE("Analysing: ");
695 /* call stack analysis pass */
697 if (!stack_analyse(jd)) {
698 DEBUG_JIT_COMPILEVERBOSE("Exception while analysing: ");
702 RT_TIMING_GET_TIME(time_stack);
704 DEBUG_JIT_COMPILEVERBOSE("Analysing done: ");
706 #ifdef ENABLE_VERIFIER
707 if (JITDATA_HAS_FLAG_VERIFY(jd)) {
708 DEBUG_JIT_COMPILEVERBOSE("Typechecking: ");
710 /* call typecheck pass */
711 if (!typecheck(jd)) {
712 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: ");
717 DEBUG_JIT_COMPILEVERBOSE("Typechecking done: ");
720 RT_TIMING_GET_TIME(time_typecheck);
722 #if defined(ENABLE_SSA)
724 fix_exception_handlers(jd);
728 /* Build the CFG. This has to be done after stack_analyse, as
729 there happens the JSR elimination. */
734 #if defined(ENABLE_LOOP)
739 jit_renumber_basicblocks(jd);
742 RT_TIMING_GET_TIME(time_loop);
744 #if defined(ENABLE_IFCONV)
745 if (JITDATA_HAS_FLAG_IFCONV(jd)) {
746 if (!ifconv_static(jd))
748 jit_renumber_basicblocks(jd);
751 RT_TIMING_GET_TIME(time_ifconv);
755 #if defined(ENABLE_INLINING)
756 if (JITDATA_HAS_FLAG_INLINE(jd)) {
757 if (!inline_inline(jd))
762 #if defined(ENABLE_PROFILING)
763 /* Basic block reordering. I think this should be done after
764 if-conversion, as we could lose the ability to do the
767 if (JITDATA_HAS_FLAG_REORDER(jd)) {
770 jit_renumber_basicblocks(jd);
774 #if defined(ENABLE_PM_HACKS)
775 #include "vm/jit/jit_pm_2.inc"
777 DEBUG_JIT_COMPILEVERBOSE("Allocating registers: ");
779 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
780 /* allocate registers */
785 STATISTICS(count_methods_allocated_by_lsra++);
788 # endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */
789 #if defined(ENABLE_SSA)
790 /* allocate registers */
793 /*&& strncmp(jd->m->name->text, "banana", 6) == 0*/
794 /*&& jd->exceptiontablelength == 0*/
796 /* printf("=== %s ===\n", jd->m->name->text); */
797 jd->ls = DNEW(lsradata);
800 /*lsra(jd);*/ regalloc(jd);
801 eliminate_subbasicblocks(jd);
802 STATISTICS(count_methods_allocated_by_lsra++);
805 # endif /* defined(ENABLE_SSA) */
807 STATISTICS(count_locals_conflicts += (jd->maxlocals - 1) * (jd->maxlocals));
812 STATISTICS(simplereg_make_statistics(jd));
814 DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: ");
815 # if defined(ENABLE_INTRP)
818 #endif /* defined(ENABLE_JIT) */
819 RT_TIMING_GET_TIME(time_alloc);
821 #if defined(ENABLE_PROFILING)
822 /* Allocate memory for basic block profiling information. This
823 _must_ be done after loop optimization and register allocation,
824 since they can change the basic block count. */
826 if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
827 code->bbfrequency = MNEW(u4, jd->basicblockcount);
830 DEBUG_JIT_COMPILEVERBOSE("Generating code: ");
832 /* now generate the machine code */
834 #if defined(ENABLE_JIT)
835 # if defined(ENABLE_INTRP)
837 #if defined(ENABLE_VERIFIER)
839 DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): ");
841 if (!typecheck_stackbased(jd)) {
842 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): ");
847 if (!intrp_codegen(jd)) {
848 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
855 if (!codegen_generate(jd)) {
856 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
862 if (!intrp_codegen(jd)) {
863 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
868 RT_TIMING_GET_TIME(time_codegen);
870 DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
872 #if !defined(NDEBUG) && defined(ENABLE_REPLACEMENT)
873 /* activate replacement points inside newly created code */
875 if (opt_TestReplacement)
876 replace_activate_replacement_points(code, false);
880 #if defined(ENABLE_DEBUG_FILTER)
881 if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
884 /* intermediate and assembly code listings */
886 if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
887 show_method(jd, SHOW_CODE);
889 else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
890 # if defined(ENABLE_DISASSEMBLER)
891 DISASSEMBLE(code->entrypoint,
892 code->entrypoint + (code->mcodelength - cd->dseglen));
896 if (opt_showddatasegment)
901 /* switch to the newly generated code */
904 assert(code->entrypoint);
906 /* add the current compile version to the methodinfo */
908 code->prev = m->code;
911 RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS);
912 RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE);
913 RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK);
914 RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK);
915 RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP);
916 RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC);
917 RT_TIMING_TIME_DIFF(time_alloc,time_codegen,RT_TIMING_JIT_CODEGEN);
918 RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL);
920 /* return pointer to the methods entry point */
922 return code->entrypoint;
926 /* jit_invalidate_code *********************************************************
928 Mark the compiled code of the given method as invalid and take care that
929 it is replaced if necessary.
931 XXX Not fully implemented, yet.
933 *******************************************************************************/
935 void jit_invalidate_code(methodinfo *m)
941 if (code == NULL || code_is_invalid(code))
944 code_flag_invalid(code);
946 /* activate mappable replacement points */
948 #if defined(ENABLE_REPLACEMENT)
949 replace_activate_replacement_points(code, true);
951 vm_abort("invalidating code only works with ENABLE_REPLACEMENT");
956 /* jit_request_optimization ****************************************************
958 Request optimization of the given method. If the code of the method is
959 unoptimized, it will be invalidated, so the next jit_get_current_code(m)
960 triggers an optimized recompilation.
961 If the method is already optimized, this function does nothing.
964 m................the method
966 *******************************************************************************/
968 void jit_request_optimization(methodinfo *m)
974 if (code && code->optlevel == 0)
975 jit_invalidate_code(m);
979 /* jit_get_current_code ********************************************************
981 Get the currently valid code for the given method. If there is no valid
982 code, (re)compile the method.
985 m................the method
988 the codeinfo* for the current code, or
989 NULL if an exception has been thrown during recompilation.
991 *******************************************************************************/
993 codeinfo *jit_get_current_code(methodinfo *m)
997 /* if we have valid code, return it */
999 if (m->code && !code_is_invalid(m->code))
1002 /* otherwise: recompile */
1004 if (!jit_recompile(m))
1013 /* jit_asm_compile *************************************************************
1015 This method is called from asm_vm_call_method and does:
1017 - create stackframe info for exceptions
1018 - compile the method
1019 - patch the entrypoint of the method into the calculated address in
1021 - flushes the instruction cache.
1023 *******************************************************************************/
1025 #if defined(ENABLE_JIT)
1026 #if !defined(JIT_COMPILER_VIA_SIGNAL)
1027 u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra)
1029 stackframeinfo_t sfi;
1034 /* create the stackframeinfo (subtract 1 from RA as it points to the */
1035 /* instruction after the call) */
1037 stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra-1);
1039 /* actually compile the method */
1041 entrypoint = jit_compile(m);
1043 /* remove the stackframeinfo */
1045 stacktrace_stackframeinfo_remove(&sfi);
1047 /* there was a problem during compilation */
1049 if (entrypoint == NULL)
1052 /* get the method patch address */
1054 pa = md_jit_method_patch_address(sfi.pv, (void *) ra, mptr);
1056 /* patch the method entry point */
1060 *p = (ptrint) entrypoint;
1062 /* flush the instruction cache */
1064 md_icacheflush(pa, SIZEOF_VOID_P);
1070 /* jit_compile_handle **********************************************************
1072 This method is called from the appropriate signal handler which
1073 handles compiler-traps and does the following:
1075 - compile the method
1076 - patch the entrypoint of the method into the calculated address in
1078 - flush the instruction cache
1080 *******************************************************************************/
1082 void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
1084 void *newpv; /* new compiled method PV */
1085 void *pa; /* patch address */
1086 uintptr_t *p; /* convenience pointer */
1088 /* Compile the method. */
1090 newpv = jit_compile(m);
1092 /* There was a problem during compilation. */
1097 /* Get the method patch address. */
1099 pa = md_jit_method_patch_address(pv, ra, mptr);
1101 /* Patch the method entry point. */
1103 p = (uintptr_t *) pa;
1105 *p = (uintptr_t) newpv;
1107 /* Flush both caches. */
1109 md_cacheflush(pa, SIZEOF_VOID_P);
1113 #endif /* defined(ENABLE_JIT) */
1116 /* jit_complement_condition ****************************************************
1118 Returns the complement of the passed conditional instruction.
1120 We use the order of the different conditions, e.g.:
1125 If the passed opcode is odd, we simply add 1 to get the complement.
1126 If the opcode is even, we subtract 1.
1133 *******************************************************************************/
1135 s4 jit_complement_condition(s4 opcode)
1139 return ICMD_IFNONNULL;
1141 case ICMD_IFNONNULL:
1145 /* check if opcode is odd */
1155 /* jit_renumber_basicblocks ****************************************************
1157 Set the ->nr of all blocks so it increases when traversing ->next.
1160 jitdata..........the current jitdata
1162 *******************************************************************************/
1164 void jit_renumber_basicblocks(jitdata *jd)
1170 for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1174 /* we have one block more than jd->basicblockcount (the end marker) */
1176 assert(nr == jd->basicblockcount + 1);
1180 /* jit_check_basicblock_numbers ************************************************
1182 Assert that the ->nr of the first block is zero and increases by 1 each
1183 time ->next is traversed.
1184 This function should be called before any analysis that relies on
1185 the basicblock numbers.
1188 jitdata..........the current jitdata
1190 NOTE: Aborts with an assertion if the condition is not met!
1192 *******************************************************************************/
1194 #if !defined(NDEBUG)
1195 void jit_check_basicblock_numbers(jitdata *jd)
1201 for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1202 assert(bptr->nr == nr);
1206 /* we have one block more than jd->basicblockcount (the end marker) */
1208 assert(nr == jd->basicblockcount + 1);
1210 #endif /* !defined(NDEBUG) */
1212 methoddesc *instruction_call_site(const instruction *iptr) {
1213 if (iptr->opc == ICMD_BUILTIN) {
1214 return iptr->sx.s23.s3.bte->md;
1215 } else if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
1216 return iptr->sx.s23.s3.um->methodref->parseddesc.md;
1218 return iptr->sx.s23.s3.fmiref->p.method->parseddesc;
1223 * These are local overrides for various environment variables in Emacs.
1224 * Please do not remove this and leave it at the end of the file, where
1225 * Emacs will automagically detect them.
1226 * ---------------------------------------------------------------------
1229 * indent-tabs-mode: t
1233 * vim:noexpandtab:sw=4:ts=4: