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 #include "vm/jit/allocator/simplereg.h"
61 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
62 # include "vm/jit/allocator/lsra.h"
65 #if defined(ENABLE_SSA)
66 # include "vm/jit/optimizing/lsra.h"
67 # include "vm/jit/optimizing/ssa.h"
70 #if defined(ENABLE_INLINING)
71 # include "vm/jit/inline/inline.h"
74 #include "vm/jit/ir/bytecode.h"
76 #include "vm/jit/loop/analyze.h"
77 #include "vm/jit/loop/graph.h"
78 #include "vm/jit/loop/loop.h"
80 #if defined(ENABLE_IFCONV)
81 # include "vm/jit/optimizing/ifconv.h"
84 #include "vm/jit/optimizing/reorder.h"
86 #if defined(ENABLE_PYTHON)
87 # include "vm/jit/python.h"
90 #include "vm/jit/verify/typecheck.h"
92 #include "vmcore/class.h"
93 #include "vmcore/loader.h"
94 #include "vmcore/method.h"
95 #include "vmcore/options.h"
96 #include "vmcore/rt-timing.h"
97 #include "vmcore/statistics.h"
100 /* debug macros ***************************************************************/
103 #define DEBUG_JIT_COMPILEVERBOSE(x) \
105 if (compileverbose) { \
106 log_message_method(x, m); \
110 #define DEBUG_JIT_COMPILEVERBOSE(x) /* nothing */
114 # define TRACECOMPILERCALLS() \
116 if (opt_TraceCompilerCalls) { \
118 log_print("[JIT compiler started: method="); \
125 # define TRACECOMPILERCALLS()
129 /* the ICMD table ************************************************************/
132 #define N(name) name,
137 /* abbreviations for flags */
139 #define PEI ICMDTABLE_PEI
140 #define CALLS ICMDTABLE_CALLS
142 /* some machine dependent values */
147 #define IDIV_CALLS ICMDTABLE_CALLS
150 #if (SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
153 #define LDIV_CALLS ICMDTABLE_CALLS
156 /* include the actual table */
158 icmdtable_entry_t icmd_table[256] = {
159 #include <vm/jit/icmdtable.inc>
166 /* XXX hack until the old "PEI" definition is removed */
170 /* jit_init ********************************************************************
172 Initializes the JIT subsystem.
174 *******************************************************************************/
178 TRACESUBSYSTEMINITIALIZATION("jit_init");
180 #if defined(ENABLE_JIT)
181 /* initialize stack analysis subsystem */
186 /* initialize show subsystem */
192 /* initialize codegen subsystem */
196 /* initialize code subsystem */
200 /* Machine dependent initialization. */
202 #if defined(ENABLE_JIT)
203 # if defined(ENABLE_INTRP)
215 /* jit_close *******************************************************************
217 Close the JIT subsystem.
219 *******************************************************************************/
227 /* dummy function, used when there is no JavaVM code available */
229 static u1 *do_nothing_function(void)
235 /* jit_jitdata_new *************************************************************
237 Allocates and initalizes a new jitdata structure.
239 *******************************************************************************/
241 jitdata *jit_jitdata_new(methodinfo *m)
246 /* allocate jitdata structure and fill it */
251 jd->cd = DNEW(codegendata);
252 jd->rd = DNEW(registerdata);
253 #if defined(ENABLE_LOOP)
254 jd->ld = DNEW(loopdata);
257 /* Allocate codeinfo memory from the heap as we need to keep them. */
259 code = code_codeinfo_new(m);
261 /* Set codeinfo flags. */
263 #if defined(ENABLE_THREADS)
264 if (checksync && (m->flags & ACC_SYNCHRONIZED))
265 code_flag_synchronized(code);
267 if (checksync && (m->flags & ACC_SYNCHRONIZED))
268 code_unflag_leafmethod(code);
271 code_flag_leafmethod(code);
273 /* initialize variables */
277 jd->exceptiontable = NULL;
278 jd->exceptiontablelength = 0;
280 jd->branchtoentry = false;
281 jd->branchtoend = false;
283 jd->returnblock = NULL;
284 jd->maxlocals = m->maxlocals;
290 /* jit_compile *****************************************************************
292 Translates one method to machine code.
294 *******************************************************************************/
296 static u1 *jit_compile_intern(jitdata *jd);
298 u1 *jit_compile(methodinfo *m)
304 STATISTICS(count_jit_calls++);
306 /* Initialize the static function's class. */
308 /* ATTENTION: This MUST be done before the method lock is aquired,
309 otherwise we could run into a deadlock with <clinit>'s that
310 call static methods of it's own class. */
312 if ((m->flags & ACC_STATIC) && !(m->clazz->state & CLASS_INITIALIZED)) {
315 log_message_class("Initialize class ", m->clazz);
318 if (!initialize_class(m->clazz))
321 /* check if the method has been compiled during initialization */
323 if ((m->code != NULL) && (m->code->entrypoint != NULL))
324 return m->code->entrypoint;
327 /* enter a monitor on the method */
329 LOCK_MONITOR_ENTER(m);
331 /* if method has been already compiled return immediately */
333 if (m->code != NULL) {
334 LOCK_MONITOR_EXIT(m);
336 assert(m->code->entrypoint);
337 return m->code->entrypoint;
340 TRACECOMPILERCALLS();
342 STATISTICS(count_methods++);
344 #if defined(ENABLE_STATISTICS)
347 if (opt_getcompilingtime)
348 compilingtime_start();
351 /* mark start of dump memory area */
355 /* create jitdata structure */
357 jd = jit_jitdata_new(m);
359 /* set the flags for the current JIT run */
361 jd->flags = JITDATA_FLAG_PARSE;
363 #if defined(ENABLE_VERIFIER)
365 jd->flags |= JITDATA_FLAG_VERIFY;
368 #if defined(ENABLE_PROFILING)
370 jd->flags |= JITDATA_FLAG_INSTRUMENT;
373 #if defined(ENABLE_IFCONV)
375 jd->flags |= JITDATA_FLAG_IFCONV;
378 #if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG)
379 if (opt_Inline && opt_InlineAll)
380 jd->flags |= JITDATA_FLAG_INLINE;
383 if (opt_showintermediate)
384 jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
386 if (opt_showdisassemble)
387 jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
390 jd->flags |= JITDATA_FLAG_VERBOSECALL;
392 #if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING)
393 if (opt_Inline && (jd->m->hitcountdown > 0) && (jd->code->optlevel == 0)) {
394 jd->flags |= JITDATA_FLAG_COUNTDOWN;
398 #if defined(ENABLE_JIT)
399 # if defined(ENABLE_INTRP)
402 /* initialize the register allocator */
408 /* setup the codegendata memory */
412 /* now call internal compile function */
414 r = jit_compile_intern(jd);
417 /* We had an exception! Finish stuff here if necessary. */
419 /* release codeinfo */
421 code_codeinfo_free(jd->code);
423 #if defined(ENABLE_PROFILING)
424 /* Release memory for basic block profiling information. */
426 if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
427 if (jd->code->bbfrequency != NULL)
428 MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount);
432 DEBUG_JIT_COMPILEVERBOSE("Running: ");
435 /* release dump area */
439 #if defined(ENABLE_STATISTICS)
442 if (opt_getcompilingtime)
443 compilingtime_stop();
446 /* leave the monitor */
448 LOCK_MONITOR_EXIT(m);
450 /* return pointer to the methods entry point */
456 /* jit_recompile ***************************************************************
458 Recompiles a Java method.
460 *******************************************************************************/
462 u1 *jit_recompile(methodinfo *m)
469 /* check for max. optimization level */
471 optlevel = (m->code) ? m->code->optlevel : 0;
475 /* log_message_method("not recompiling: ", m); */
480 DEBUG_JIT_COMPILEVERBOSE("Recompiling start: ");
482 STATISTICS(count_jit_calls++);
484 #if defined(ENABLE_STATISTICS)
487 if (opt_getcompilingtime)
488 compilingtime_start();
491 /* mark start of dump memory area */
495 /* create jitdata structure */
497 jd = jit_jitdata_new(m);
499 /* set the current optimization level to the previous one plus 1 */
501 jd->code->optlevel = optlevel + 1;
503 /* get the optimization flags for the current JIT run */
505 #if defined(ENABLE_VERIFIER)
506 jd->flags |= JITDATA_FLAG_VERIFY;
509 /* jd->flags |= JITDATA_FLAG_REORDER; */
510 if (opt_showintermediate)
511 jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
512 if (opt_showdisassemble)
513 jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
515 jd->flags |= JITDATA_FLAG_VERBOSECALL;
517 #if defined(ENABLE_INLINING)
519 jd->flags |= JITDATA_FLAG_INLINE;
522 #if defined(ENABLE_JIT)
523 # if defined(ENABLE_INTRP)
526 /* initialize the register allocator */
531 /* setup the codegendata memory */
535 /* now call internal compile function */
537 r = jit_compile_intern(jd);
540 /* We had an exception! Finish stuff here if necessary. */
542 /* release codeinfo */
544 code_codeinfo_free(jd->code);
547 /* release dump area */
551 #if defined(ENABLE_STATISTICS)
554 if (opt_getcompilingtime)
555 compilingtime_stop();
558 DEBUG_JIT_COMPILEVERBOSE("Recompiling done: ");
560 /* return pointer to the methods entry point */
565 #if defined(ENABLE_PM_HACKS)
566 #include "vm/jit/jit_pm_1.inc"
569 /* jit_compile_intern **********************************************************
571 Static internal function which does the actual compilation.
573 *******************************************************************************/
575 static u1 *jit_compile_intern(jitdata *jd)
581 #if defined(ENABLE_RT_TIMING)
582 struct timespec time_start,time_checks,time_parse,time_stack,
583 time_typecheck,time_loop,time_ifconv,time_alloc,
587 RT_TIMING_GET_TIME(time_start);
589 /* get required compiler data */
591 #if defined(ENABLE_LSRA) || defined(ENABLE_SSA)
598 #if defined(ENABLE_DEBUG_FILTER)
599 show_filters_apply(jd->m);
602 /* Handle native methods and create a native stub. */
604 if (m->flags & ACC_NATIVE) {
607 f = native_method_resolve(m);
612 code = codegen_generate_stub_native(m, f);
614 /* Native methods are never recompiled. */
620 return code->entrypoint;
623 /* if there is no javacode, print error message and return empty method */
625 if (m->jcode == NULL) {
626 DEBUG_JIT_COMPILEVERBOSE("No code given for: ");
628 code->entrypoint = (u1 *) (ptrint) do_nothing_function;
631 return code->entrypoint; /* return empty method */
634 #if defined(ENABLE_STATISTICS)
636 count_javacodesize += m->jcodelength + 18;
637 count_tryblocks += jd->exceptiontablelength;
638 count_javaexcsize += jd->exceptiontablelength * SIZEOF_VOID_P;
642 RT_TIMING_GET_TIME(time_checks);
644 #if defined(WITH_JAVA_RUNTIME_LIBRARY_OPENJDK)
645 /* Code for Sun's OpenJDK (see
646 hotspot/src/share/vm/classfile/verifier.cpp
647 (Verifier::is_eligible_for_verification)): Don't verify
648 dynamically-generated bytecodes. */
650 # if defined(ENABLE_VERIFIER)
651 if (class_issubclass(m->clazz, class_sun_reflect_MagicAccessorImpl))
652 jd->flags &= ~JITDATA_FLAG_VERIFY;
656 /* call the compiler passes ***********************************************/
658 DEBUG_JIT_COMPILEVERBOSE("Parsing: ");
660 /* call parse pass */
663 DEBUG_JIT_COMPILEVERBOSE("Exception while parsing: ");
667 RT_TIMING_GET_TIME(time_parse);
669 DEBUG_JIT_COMPILEVERBOSE("Parsing done: ");
671 #if defined(ENABLE_JIT)
672 # if defined(ENABLE_INTRP)
675 DEBUG_JIT_COMPILEVERBOSE("Analysing: ");
677 /* call stack analysis pass */
679 if (!stack_analyse(jd)) {
680 DEBUG_JIT_COMPILEVERBOSE("Exception while analysing: ");
684 RT_TIMING_GET_TIME(time_stack);
686 DEBUG_JIT_COMPILEVERBOSE("Analysing done: ");
688 #ifdef ENABLE_VERIFIER
689 if (JITDATA_HAS_FLAG_VERIFY(jd)) {
690 DEBUG_JIT_COMPILEVERBOSE("Typechecking: ");
692 /* call typecheck pass */
693 if (!typecheck(jd)) {
694 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: ");
699 DEBUG_JIT_COMPILEVERBOSE("Typechecking done: ");
702 RT_TIMING_GET_TIME(time_typecheck);
704 #if defined(ENABLE_LOOP)
709 jit_renumber_basicblocks(jd);
712 RT_TIMING_GET_TIME(time_loop);
714 #if defined(ENABLE_IFCONV)
715 if (JITDATA_HAS_FLAG_IFCONV(jd)) {
716 if (!ifconv_static(jd))
718 jit_renumber_basicblocks(jd);
721 RT_TIMING_GET_TIME(time_ifconv);
725 #if defined(ENABLE_INLINING) && !defined(ENABLE_ESCAPE) || 1
726 if (JITDATA_HAS_FLAG_INLINE(jd)) {
727 if (!inline_inline(jd))
732 #if defined(ENABLE_SSA)
734 fix_exception_handlers(jd);
738 /* Build the CFG. This has to be done after stack_analyse, as
739 there happens the JSR elimination. */
744 #if defined(ENABLE_PROFILING)
745 /* Basic block reordering. I think this should be done after
746 if-conversion, as we could lose the ability to do the
749 if (JITDATA_HAS_FLAG_REORDER(jd)) {
752 jit_renumber_basicblocks(jd);
756 #if defined(ENABLE_PM_HACKS)
757 #include "vm/jit/jit_pm_2.inc"
759 DEBUG_JIT_COMPILEVERBOSE("Allocating registers: ");
761 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
762 /* allocate registers */
767 STATISTICS(count_methods_allocated_by_lsra++);
770 # endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */
771 #if defined(ENABLE_SSA)
772 /* allocate registers */
775 jd->code->optlevel > 0)
776 /* strncmp(jd->m->name->text, "hottie", 6) == 0*/
777 /*&& jd->exceptiontablelength == 0*/
779 /*printf("=== %s ===\n", jd->m->name->text);*/
780 jd->ls = DNEW(lsradata);
783 /*lsra(jd);*/ regalloc(jd);
784 /*eliminate_subbasicblocks(jd);*/
785 STATISTICS(count_methods_allocated_by_lsra++);
788 # endif /* defined(ENABLE_SSA) */
790 STATISTICS(count_locals_conflicts += (jd->maxlocals - 1) * (jd->maxlocals));
795 STATISTICS(simplereg_make_statistics(jd));
797 DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: ");
798 # if defined(ENABLE_INTRP)
801 #endif /* defined(ENABLE_JIT) */
802 RT_TIMING_GET_TIME(time_alloc);
804 #if defined(ENABLE_PROFILING)
805 /* Allocate memory for basic block profiling information. This
806 _must_ be done after loop optimization and register allocation,
807 since they can change the basic block count. */
809 if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
810 code->bbfrequency = MNEW(u4, jd->basicblockcount);
813 DEBUG_JIT_COMPILEVERBOSE("Generating code: ");
815 /* now generate the machine code */
817 #if defined(ENABLE_JIT)
818 # if defined(ENABLE_INTRP)
820 #if defined(ENABLE_VERIFIER)
822 DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): ");
824 if (!typecheck_stackbased(jd)) {
825 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): ");
830 if (!intrp_codegen(jd)) {
831 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
838 if (!codegen_generate(jd)) {
839 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
845 if (!intrp_codegen(jd)) {
846 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
851 RT_TIMING_GET_TIME(time_codegen);
853 DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
855 #if !defined(NDEBUG) && defined(ENABLE_REPLACEMENT)
856 /* activate replacement points inside newly created code */
858 if (opt_TestReplacement)
859 replace_activate_replacement_points(code, false);
863 #if defined(ENABLE_DEBUG_FILTER)
864 if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
867 /* intermediate and assembly code listings */
869 if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
870 show_method(jd, SHOW_CODE);
872 else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
873 # if defined(ENABLE_DISASSEMBLER)
874 DISASSEMBLE(code->entrypoint,
875 code->entrypoint + (code->mcodelength - cd->dseglen));
879 if (opt_showddatasegment)
884 /* switch to the newly generated code */
887 assert(code->entrypoint);
889 /* add the current compile version to the methodinfo */
891 code->prev = m->code;
894 RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS);
895 RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE);
896 RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK);
897 RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK);
898 RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP);
899 RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC);
900 RT_TIMING_TIME_DIFF(time_alloc,time_codegen,RT_TIMING_JIT_CODEGEN);
901 RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL);
903 /* return pointer to the methods entry point */
905 return code->entrypoint;
909 /* jit_invalidate_code *********************************************************
911 Mark the compiled code of the given method as invalid and take care that
912 it is replaced if necessary.
914 XXX Not fully implemented, yet.
916 *******************************************************************************/
918 void jit_invalidate_code(methodinfo *m)
924 if (code == NULL || code_is_invalid(code))
927 code_flag_invalid(code);
929 /* activate mappable replacement points */
931 #if defined(ENABLE_REPLACEMENT)
932 replace_activate_replacement_points(code, true);
934 vm_abort("invalidating code only works with ENABLE_REPLACEMENT");
939 /* jit_request_optimization ****************************************************
941 Request optimization of the given method. If the code of the method is
942 unoptimized, it will be invalidated, so the next jit_get_current_code(m)
943 triggers an optimized recompilation.
944 If the method is already optimized, this function does nothing.
947 m................the method
949 *******************************************************************************/
951 void jit_request_optimization(methodinfo *m)
957 if (code && code->optlevel == 0)
958 jit_invalidate_code(m);
962 /* jit_get_current_code ********************************************************
964 Get the currently valid code for the given method. If there is no valid
965 code, (re)compile the method.
968 m................the method
971 the codeinfo* for the current code, or
972 NULL if an exception has been thrown during recompilation.
974 *******************************************************************************/
976 codeinfo *jit_get_current_code(methodinfo *m)
980 /* if we have valid code, return it */
982 if (m->code && !code_is_invalid(m->code))
985 /* otherwise: recompile */
987 if (!jit_recompile(m))
996 /* jit_asm_compile *************************************************************
998 This method is called from asm_vm_call_method and does:
1000 - create stackframe info for exceptions
1001 - compile the method
1002 - patch the entrypoint of the method into the calculated address in
1004 - flushes the instruction cache.
1006 *******************************************************************************/
1008 #if defined(ENABLE_JIT)
1009 #if !defined(JIT_COMPILER_VIA_SIGNAL)
1010 u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra)
1012 stackframeinfo_t sfi;
1017 /* create the stackframeinfo (subtract 1 from RA as it points to the */
1018 /* instruction after the call) */
1020 stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra-1);
1022 /* actually compile the method */
1024 entrypoint = jit_compile(m);
1026 /* remove the stackframeinfo */
1028 stacktrace_stackframeinfo_remove(&sfi);
1030 /* there was a problem during compilation */
1032 if (entrypoint == NULL)
1035 /* get the method patch address */
1037 pa = md_jit_method_patch_address(sfi.pv, (void *) ra, mptr);
1039 /* patch the method entry point */
1043 *p = (ptrint) entrypoint;
1045 /* flush the instruction cache */
1047 md_icacheflush(pa, SIZEOF_VOID_P);
1053 /* jit_compile_handle **********************************************************
1055 This method is called from the appropriate signal handler which
1056 handles compiler-traps and does the following:
1058 - compile the method
1059 - patch the entrypoint of the method into the calculated address in
1061 - flush the instruction cache
1063 *******************************************************************************/
1065 void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
1067 void *newpv; /* new compiled method PV */
1068 void *pa; /* patch address */
1069 uintptr_t *p; /* convenience pointer */
1071 /* Compile the method. */
1073 newpv = jit_compile(m);
1075 /* There was a problem during compilation. */
1080 /* Get the method patch address. */
1082 pa = md_jit_method_patch_address(pv, ra, mptr);
1084 /* Patch the method entry point. */
1086 p = (uintptr_t *) pa;
1088 *p = (uintptr_t) newpv;
1090 /* Flush both caches. */
1092 md_cacheflush(pa, SIZEOF_VOID_P);
1096 #endif /* defined(ENABLE_JIT) */
1099 /* jit_complement_condition ****************************************************
1101 Returns the complement of the passed conditional instruction.
1103 We use the order of the different conditions, e.g.:
1108 If the passed opcode is odd, we simply add 1 to get the complement.
1109 If the opcode is even, we subtract 1.
1116 *******************************************************************************/
1118 s4 jit_complement_condition(s4 opcode)
1122 return ICMD_IFNONNULL;
1124 case ICMD_IFNONNULL:
1128 /* check if opcode is odd */
1138 /* jit_renumber_basicblocks ****************************************************
1140 Set the ->nr of all blocks so it increases when traversing ->next.
1143 jitdata..........the current jitdata
1145 *******************************************************************************/
1147 void jit_renumber_basicblocks(jitdata *jd)
1153 for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1157 /* we have one block more than jd->basicblockcount (the end marker) */
1159 assert(nr == jd->basicblockcount + 1);
1163 /* jit_check_basicblock_numbers ************************************************
1165 Assert that the ->nr of the first block is zero and increases by 1 each
1166 time ->next is traversed.
1167 This function should be called before any analysis that relies on
1168 the basicblock numbers.
1171 jitdata..........the current jitdata
1173 NOTE: Aborts with an assertion if the condition is not met!
1175 *******************************************************************************/
1177 #if !defined(NDEBUG)
1178 void jit_check_basicblock_numbers(jitdata *jd)
1184 for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1185 assert(bptr->nr == nr);
1189 /* we have one block more than jd->basicblockcount (the end marker) */
1191 assert(nr == jd->basicblockcount + 1);
1193 #endif /* !defined(NDEBUG) */
1195 methoddesc *instruction_call_site(const instruction *iptr) {
1196 if (iptr->opc == ICMD_BUILTIN) {
1197 return iptr->sx.s23.s3.bte->md;
1198 } else if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
1199 return iptr->sx.s23.s3.um->methodref->parseddesc.md;
1201 return iptr->sx.s23.s3.fmiref->p.method->parseddesc;
1206 * These are local overrides for various environment variables in Emacs.
1207 * Please do not remove this and leave it at the end of the file, where
1208 * Emacs will automagically detect them.
1209 * ---------------------------------------------------------------------
1212 * indent-tabs-mode: t
1216 * vim:noexpandtab:sw=4:ts=4: