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"
42 #include "threads/threads-common.h"
44 #include "vm/global.h"
45 #include "vm/initialize.h"
47 #include "vm/jit/asmpart.h"
49 #include "vm/jit/cfg.h"
51 #include "vm/jit/codegen-common.h"
52 #include "vm/jit/disass.h"
53 #include "vm/jit/dseg.h"
54 #include "vm/jit/jit.h"
55 #include "vm/jit/parse.h"
56 #include "vm/jit/reg.h"
58 #include "vm/jit/show.h"
59 #include "vm/jit/stack.h"
61 #include "vm/jit/allocator/simplereg.h"
62 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
63 # include "vm/jit/allocator/lsra.h"
66 #if defined(ENABLE_SSA)
67 # include "vm/jit/optimizing/lsra.h"
68 # include "vm/jit/optimizing/ssa.h"
71 #if defined(ENABLE_INLINING)
72 # include "vm/jit/inline/inline.h"
75 #include "vm/jit/ir/bytecode.h"
77 #include "vm/jit/loop/analyze.h"
78 #include "vm/jit/loop/graph.h"
79 #include "vm/jit/loop/loop.h"
81 #if defined(ENABLE_IFCONV)
82 # include "vm/jit/optimizing/ifconv.h"
85 #include "vm/jit/optimizing/reorder.h"
87 #if defined(ENABLE_PYTHON)
88 # include "vm/jit/python.h"
91 #include "vm/jit/verify/typecheck.h"
93 #include "vmcore/class.h"
94 #include "vmcore/loader.h"
95 #include "vmcore/method.h"
96 #include "vmcore/options.h"
97 #include "vmcore/rt-timing.h"
98 #include "vmcore/statistics.h"
101 /* debug macros ***************************************************************/
104 #define DEBUG_JIT_COMPILEVERBOSE(x) \
106 if (compileverbose) { \
107 log_message_method(x, m); \
111 #define DEBUG_JIT_COMPILEVERBOSE(x) /* nothing */
115 # define TRACECOMPILERCALLS() \
117 if (opt_TraceCompilerCalls) { \
119 log_print("[JIT compiler started: method="); \
126 # define TRACECOMPILERCALLS()
130 /* the ICMD table ************************************************************/
133 #define N(name) name,
138 /* abbreviations for flags */
140 #define PEI ICMDTABLE_PEI
141 #define CALLS ICMDTABLE_CALLS
143 /* some machine dependent values */
148 #define IDIV_CALLS ICMDTABLE_CALLS
151 #if (SUPPORT_DIVISION && SUPPORT_LONG && SUPPORT_LONG_DIV)
154 #define LDIV_CALLS ICMDTABLE_CALLS
157 /* include the actual table */
159 icmdtable_entry_t icmd_table[256] = {
160 #include <vm/jit/icmdtable.inc>
167 /* XXX hack until the old "PEI" definition is removed */
171 /* jit_init ********************************************************************
173 Initializes the JIT subsystem.
175 *******************************************************************************/
179 TRACESUBSYSTEMINITIALIZATION("jit_init");
181 #if defined(ENABLE_JIT)
182 /* initialize stack analysis subsystem */
187 /* initialize show subsystem */
193 /* initialize codegen subsystem */
197 /* initialize code subsystem */
201 /* Machine dependent initialization. */
203 #if defined(ENABLE_JIT)
204 # if defined(ENABLE_INTRP)
216 /* jit_close *******************************************************************
218 Close the JIT subsystem.
220 *******************************************************************************/
228 /* dummy function, used when there is no JavaVM code available */
230 static u1 *do_nothing_function(void)
236 /* jit_jitdata_new *************************************************************
238 Allocates and initalizes a new jitdata structure.
240 *******************************************************************************/
242 jitdata *jit_jitdata_new(methodinfo *m)
247 /* allocate jitdata structure and fill it */
252 jd->cd = DNEW(codegendata);
253 jd->rd = DNEW(registerdata);
254 #if defined(ENABLE_LOOP)
255 jd->ld = DNEW(loopdata);
258 /* Allocate codeinfo memory from the heap as we need to keep them. */
260 code = code_codeinfo_new(m);
262 /* Set codeinfo flags. */
264 #if defined(ENABLE_THREADS)
265 if (checksync && (m->flags & ACC_SYNCHRONIZED))
266 code_flag_synchronized(code);
268 if (checksync && (m->flags & ACC_SYNCHRONIZED))
269 code_unflag_leafmethod(code);
272 code_flag_leafmethod(code);
274 /* initialize variables */
278 jd->exceptiontable = NULL;
279 jd->exceptiontablelength = 0;
281 jd->branchtoentry = false;
282 jd->branchtoend = false;
284 jd->returnblock = NULL;
285 jd->maxlocals = m->maxlocals;
291 /* jit_compile *****************************************************************
293 Translates one method to machine code.
295 *******************************************************************************/
297 static u1 *jit_compile_intern(jitdata *jd);
299 u1 *jit_compile(methodinfo *m)
305 STATISTICS(count_jit_calls++);
307 /* Initialize the static function's class. */
309 /* ATTENTION: This MUST be done before the method lock is aquired,
310 otherwise we could run into a deadlock with <clinit>'s that
311 call static methods of it's own class. */
313 if ((m->flags & ACC_STATIC) && !(m->class->state & CLASS_INITIALIZED)) {
316 log_message_class("Initialize class ", m->class);
319 if (!initialize_class(m->class))
322 /* check if the method has been compiled during initialization */
324 if ((m->code != NULL) && (m->code->entrypoint != NULL))
325 return m->code->entrypoint;
328 /* enter a monitor on the method */
330 LOCK_MONITOR_ENTER(m);
332 /* if method has been already compiled return immediately */
334 if (m->code != NULL) {
335 LOCK_MONITOR_EXIT(m);
337 assert(m->code->entrypoint);
338 return m->code->entrypoint;
341 TRACECOMPILERCALLS();
343 STATISTICS(count_methods++);
345 #if defined(ENABLE_STATISTICS)
348 if (opt_getcompilingtime)
349 compilingtime_start();
352 /* mark start of dump memory area */
356 /* create jitdata structure */
358 jd = jit_jitdata_new(m);
360 /* set the flags for the current JIT run */
362 jd->flags = JITDATA_FLAG_PARSE;
364 #if defined(ENABLE_VERIFIER)
366 jd->flags |= JITDATA_FLAG_VERIFY;
369 #if defined(ENABLE_PROFILING)
371 jd->flags |= JITDATA_FLAG_INSTRUMENT;
374 #if defined(ENABLE_IFCONV)
376 jd->flags |= JITDATA_FLAG_IFCONV;
379 #if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG)
380 if (opt_Inline && opt_InlineAll)
381 jd->flags |= JITDATA_FLAG_INLINE;
384 if (opt_showintermediate)
385 jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
387 if (opt_showdisassemble)
388 jd->flags |= JITDATA_FLAG_SHOWDISASSEMBLE;
391 jd->flags |= JITDATA_FLAG_VERBOSECALL;
393 #if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING)
395 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_CLASSPATH_SUN)
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->class, 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 /* Build the CFG. This has to be done after stack_analyse, as
689 there happens the JSR elimination. */
694 #ifdef ENABLE_VERIFIER
695 if (JITDATA_HAS_FLAG_VERIFY(jd)) {
696 DEBUG_JIT_COMPILEVERBOSE("Typechecking: ");
698 /* call typecheck pass */
699 if (!typecheck(jd)) {
700 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking: ");
705 DEBUG_JIT_COMPILEVERBOSE("Typechecking done: ");
708 RT_TIMING_GET_TIME(time_typecheck);
710 #if defined(ENABLE_LOOP)
715 jit_renumber_basicblocks(jd);
718 RT_TIMING_GET_TIME(time_loop);
720 #if defined(ENABLE_IFCONV)
721 if (JITDATA_HAS_FLAG_IFCONV(jd)) {
722 if (!ifconv_static(jd))
724 jit_renumber_basicblocks(jd);
727 RT_TIMING_GET_TIME(time_ifconv);
731 #if defined(ENABLE_INLINING)
732 if (JITDATA_HAS_FLAG_INLINE(jd)) {
733 if (!inline_inline(jd))
738 #if defined(ENABLE_PROFILING)
739 /* Basic block reordering. I think this should be done after
740 if-conversion, as we could lose the ability to do the
743 if (JITDATA_HAS_FLAG_REORDER(jd)) {
746 jit_renumber_basicblocks(jd);
750 #if defined(ENABLE_PM_HACKS)
751 #include "vm/jit/jit_pm_2.inc"
753 DEBUG_JIT_COMPILEVERBOSE("Allocating registers: ");
755 #if defined(ENABLE_LSRA) && !defined(ENABLE_SSA)
756 /* allocate registers */
761 STATISTICS(count_methods_allocated_by_lsra++);
764 # endif /* defined(ENABLE_LSRA) && !defined(ENABLE_SSA) */
765 #if defined(ENABLE_SSA)
766 /* allocate registers */
767 if ((opt_lsra) /*&& strcmp(jd->m->name->text, "findClass") != 0*/) {
768 jd->ls = DNEW(lsradata);
771 /*lsra(jd);*/ regalloc(jd);
772 eliminate_subbasicblocks(jd);
773 STATISTICS(count_methods_allocated_by_lsra++);
776 # endif /* defined(ENABLE_SSA) */
778 STATISTICS(count_locals_conflicts += (jd->maxlocals - 1) * (jd->maxlocals));
783 STATISTICS(simplereg_make_statistics(jd));
785 DEBUG_JIT_COMPILEVERBOSE("Allocating registers done: ");
786 # if defined(ENABLE_INTRP)
789 #endif /* defined(ENABLE_JIT) */
790 RT_TIMING_GET_TIME(time_alloc);
792 #if defined(ENABLE_PROFILING)
793 /* Allocate memory for basic block profiling information. This
794 _must_ be done after loop optimization and register allocation,
795 since they can change the basic block count. */
797 if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
798 code->bbfrequency = MNEW(u4, jd->basicblockcount);
801 DEBUG_JIT_COMPILEVERBOSE("Generating code: ");
803 /* now generate the machine code */
805 #if defined(ENABLE_JIT)
806 # if defined(ENABLE_INTRP)
808 #if defined(ENABLE_VERIFIER)
810 DEBUG_JIT_COMPILEVERBOSE("Typechecking (stackbased): ");
812 if (!typecheck_stackbased(jd)) {
813 DEBUG_JIT_COMPILEVERBOSE("Exception while typechecking (stackbased): ");
818 if (!intrp_codegen(jd)) {
819 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
826 if (!codegen_generate(jd)) {
827 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
833 if (!intrp_codegen(jd)) {
834 DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
839 RT_TIMING_GET_TIME(time_codegen);
841 DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
843 #if !defined(NDEBUG) && defined(ENABLE_REPLACEMENT)
844 /* activate replacement points inside newly created code */
846 if (opt_TestReplacement)
847 replace_activate_replacement_points(code, false);
851 #if defined(ENABLE_DEBUG_FILTER)
852 if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
855 /* intermediate and assembly code listings */
857 if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
858 show_method(jd, SHOW_CODE);
860 else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
861 # if defined(ENABLE_DISASSEMBLER)
862 DISASSEMBLE(code->entrypoint,
863 code->entrypoint + (code->mcodelength - cd->dseglen));
867 if (opt_showddatasegment)
872 /* switch to the newly generated code */
875 assert(code->entrypoint);
877 /* add the current compile version to the methodinfo */
879 code->prev = m->code;
882 RT_TIMING_TIME_DIFF(time_start,time_checks,RT_TIMING_JIT_CHECKS);
883 RT_TIMING_TIME_DIFF(time_checks,time_parse,RT_TIMING_JIT_PARSE);
884 RT_TIMING_TIME_DIFF(time_parse,time_stack,RT_TIMING_JIT_STACK);
885 RT_TIMING_TIME_DIFF(time_stack,time_typecheck,RT_TIMING_JIT_TYPECHECK);
886 RT_TIMING_TIME_DIFF(time_typecheck,time_loop,RT_TIMING_JIT_LOOP);
887 RT_TIMING_TIME_DIFF(time_loop,time_alloc,RT_TIMING_JIT_ALLOC);
888 RT_TIMING_TIME_DIFF(time_alloc,time_codegen,RT_TIMING_JIT_CODEGEN);
889 RT_TIMING_TIME_DIFF(time_start,time_codegen,RT_TIMING_JIT_TOTAL);
891 /* return pointer to the methods entry point */
893 return code->entrypoint;
897 /* jit_invalidate_code *********************************************************
899 Mark the compiled code of the given method as invalid and take care that
900 it is replaced if necessary.
902 XXX Not fully implemented, yet.
904 *******************************************************************************/
906 void jit_invalidate_code(methodinfo *m)
912 if (code == NULL || code_is_invalid(code))
915 code_flag_invalid(code);
917 /* activate mappable replacement points */
919 #if defined(ENABLE_REPLACEMENT)
920 replace_activate_replacement_points(code, true);
922 vm_abort("invalidating code only works with ENABLE_REPLACEMENT");
927 /* jit_request_optimization ****************************************************
929 Request optimization of the given method. If the code of the method is
930 unoptimized, it will be invalidated, so the next jit_get_current_code(m)
931 triggers an optimized recompilation.
932 If the method is already optimized, this function does nothing.
935 m................the method
937 *******************************************************************************/
939 void jit_request_optimization(methodinfo *m)
945 if (code && code->optlevel == 0)
946 jit_invalidate_code(m);
950 /* jit_get_current_code ********************************************************
952 Get the currently valid code for the given method. If there is no valid
953 code, (re)compile the method.
956 m................the method
959 the codeinfo* for the current code, or
960 NULL if an exception has been thrown during recompilation.
962 *******************************************************************************/
964 codeinfo *jit_get_current_code(methodinfo *m)
968 /* if we have valid code, return it */
970 if (m->code && !code_is_invalid(m->code))
973 /* otherwise: recompile */
975 if (!jit_recompile(m))
984 /* jit_asm_compile *************************************************************
986 This method is called from asm_vm_call_method and does:
988 - create stackframe info for exceptions
990 - patch the entrypoint of the method into the calculated address in
992 - flushes the instruction cache.
994 *******************************************************************************/
996 #if defined(ENABLE_JIT)
997 #if !defined(JIT_COMPILER_VIA_SIGNAL)
998 u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra)
1000 stackframeinfo_t sfi;
1005 /* create the stackframeinfo (subtract 1 from RA as it points to the */
1006 /* instruction after the call) */
1008 stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra-1);
1010 /* actually compile the method */
1012 entrypoint = jit_compile(m);
1014 /* remove the stackframeinfo */
1016 stacktrace_stackframeinfo_remove(&sfi);
1018 /* there was a problem during compilation */
1020 if (entrypoint == NULL)
1023 /* get the method patch address */
1025 pa = md_jit_method_patch_address(sfi.pv, (void *) ra, mptr);
1027 /* patch the method entry point */
1031 *p = (ptrint) entrypoint;
1033 /* flush the instruction cache */
1035 md_icacheflush(pa, SIZEOF_VOID_P);
1041 /* jit_compile_handle **********************************************************
1043 This method is called from the appropriate signal handler which
1044 handles compiler-traps and does the following:
1046 - compile the method
1047 - patch the entrypoint of the method into the calculated address in
1049 - flush the instruction cache
1051 *******************************************************************************/
1053 void *jit_compile_handle(methodinfo *m, void *pv, void *ra, void *mptr)
1055 void *newpv; /* new compiled method PV */
1056 void *pa; /* patch address */
1057 uintptr_t *p; /* convenience pointer */
1059 /* Compile the method. */
1061 newpv = jit_compile(m);
1063 /* There was a problem during compilation. */
1068 /* Get the method patch address. */
1070 pa = md_jit_method_patch_address(pv, ra, mptr);
1072 /* Patch the method entry point. */
1074 p = (uintptr_t *) pa;
1076 *p = (uintptr_t) newpv;
1078 /* Flush both caches. */
1080 md_cacheflush(pa, SIZEOF_VOID_P);
1084 #endif /* defined(ENABLE_JIT) */
1087 /* jit_complement_condition ****************************************************
1089 Returns the complement of the passed conditional instruction.
1091 We use the order of the different conditions, e.g.:
1096 If the passed opcode is odd, we simply add 1 to get the complement.
1097 If the opcode is even, we subtract 1.
1104 *******************************************************************************/
1106 s4 jit_complement_condition(s4 opcode)
1110 return ICMD_IFNONNULL;
1112 case ICMD_IFNONNULL:
1116 /* check if opcode is odd */
1126 /* jit_renumber_basicblocks ****************************************************
1128 Set the ->nr of all blocks so it increases when traversing ->next.
1131 jitdata..........the current jitdata
1133 *******************************************************************************/
1135 void jit_renumber_basicblocks(jitdata *jd)
1141 for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1145 /* we have one block more than jd->basicblockcount (the end marker) */
1147 assert(nr == jd->basicblockcount + 1);
1151 /* jit_check_basicblock_numbers ************************************************
1153 Assert that the ->nr of the first block is zero and increases by 1 each
1154 time ->next is traversed.
1155 This function should be called before any analysis that relies on
1156 the basicblock numbers.
1159 jitdata..........the current jitdata
1161 NOTE: Aborts with an assertion if the condition is not met!
1163 *******************************************************************************/
1165 #if !defined(NDEBUG)
1166 void jit_check_basicblock_numbers(jitdata *jd)
1172 for (bptr = jd->basicblocks; bptr != NULL; bptr = bptr->next) {
1173 assert(bptr->nr == nr);
1177 /* we have one block more than jd->basicblockcount (the end marker) */
1179 assert(nr == jd->basicblockcount + 1);
1181 #endif /* !defined(NDEBUG) */
1183 methoddesc *instruction_call_site(const instruction *iptr) {
1184 if (iptr->opc == ICMD_BUILTIN) {
1185 return iptr->sx.s23.s3.bte->md;
1186 } else if (INSTRUCTION_IS_UNRESOLVED(iptr)) {
1187 return iptr->sx.s23.s3.um->methodref->parseddesc.md;
1189 return iptr->sx.s23.s3.fmiref->p.method->parseddesc;
1194 * These are local overrides for various environment variables in Emacs.
1195 * Please do not remove this and leave it at the end of the file, where
1196 * Emacs will automagically detect them.
1197 * ---------------------------------------------------------------------
1200 * indent-tabs-mode: t
1204 * vim:noexpandtab:sw=4:ts=4: