/* src/vm/jit/jit.c - calls the code generation functions
- Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+ Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
J. Wenninger, Institut f. Computersprachen - TU Wien
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- Contact: cacao@cacaojvm.org
-
- Authors: Andreas Krall
- Reinhard Grafl
-
- Changes: Edwin Steiner
- Christian Thalinger
- Christian Ullrich
-
- $Id: jit.c 7210 2007-01-13 22:37:26Z edwin $
-
*/
#include "config.h"
-#include "vm/types.h"
#include <assert.h>
+#include "vm/types.h"
+
#include "mm/memory.h"
+
#include "native/native.h"
+
#include "toolbox/logging.h"
-#if defined(ENABLE_THREADS)
-# include "threads/native/lock.h"
-#else
-# include "threads/none/lock.h"
-#endif
+#include "threads/lock-common.h"
+#include "threads/threads-common.h"
-#include "vm/class.h"
#include "vm/global.h"
#include "vm/initialize.h"
-#include "vm/loader.h"
-#include "vm/method.h"
-#include "vm/options.h"
-#include "vm/statistics.h"
+
#include "vm/jit/asmpart.h"
# include "vm/jit/cfg.h"
#include "vm/jit/disass.h"
#include "vm/jit/dseg.h"
#include "vm/jit/jit.h"
+#include "vm/jit/md.h"
#include "vm/jit/parse.h"
#include "vm/jit/reg.h"
# include "vm/jit/optimizing/ssa.h"
#endif
+#if defined(ENABLE_INLINING)
+# include "vm/jit/inline/inline.h"
+#endif
+
#include "vm/jit/loop/analyze.h"
#include "vm/jit/loop/graph.h"
#include "vm/jit/loop/loop.h"
#include "vm/jit/optimizing/reorder.h"
#include "vm/jit/verify/typecheck.h"
-#include "vm/rt-timing.h"
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#endif
+#include "vmcore/class.h"
+#include "vmcore/loader.h"
+#include "vmcore/method.h"
+#include "vmcore/options.h"
+#include "vmcore/rt-timing.h"
+#include "vmcore/statistics.h"
/* debug macros ***************************************************************/
/* initialize variables */
- jd->flags = 0;
- jd->exceptiontable = NULL;
+ jd->flags = 0;
+ jd->exceptiontable = NULL;
jd->exceptiontablelength = 0;
- jd->returncount = 0;
- jd->branchtoentry = false;
- jd->branchtoend = false;
- jd->returncount = 0;
- jd->returnblock = NULL;
- jd->maxlocals = m->maxlocals;
+ jd->returncount = 0;
+ jd->branchtoentry = false;
+ jd->branchtoend = false;
+ jd->returncount = 0;
+ jd->returnblock = NULL;
+ jd->maxlocals = m->maxlocals;
#if defined(ENABLE_THREADS)
if (checksync && (m->flags & ACC_SYNCHRONIZED))
jd->flags |= JITDATA_FLAG_IFCONV;
#endif
+#if defined(ENABLE_INLINING) && defined(ENABLE_INLINING_DEBUG)
+ if (opt_inlining && opt_inline_debug_all)
+ jd->flags |= JITDATA_FLAG_INLINE;
+#endif
+
if (opt_showintermediate)
jd->flags |= JITDATA_FLAG_SHOWINTERMEDIATE;
if (opt_verbosecall)
jd->flags |= JITDATA_FLAG_VERBOSECALL;
+#if defined(ENABLE_REPLACEMENT) && defined(ENABLE_INLINING)
+ if (opt_inlining)
+ jd->flags |= JITDATA_FLAG_COUNTDOWN;
+#endif
+
#if defined(ENABLE_JIT)
# if defined(ENABLE_INTRP)
if (!opt_intrp)
code_codeinfo_free(jd->code);
+#if defined(ENABLE_PROFILING)
/* Release memory for basic block profiling information. */
if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
if (jd->code->bbfrequency != NULL)
MFREE(jd->code->bbfrequency, u4, jd->code->basicblockcount);
+#endif
}
else {
DEBUG_JIT_COMPILEVERBOSE("Running: ");
if (opt_verbosecall)
jd->flags |= JITDATA_FLAG_VERBOSECALL;
+#if defined(ENABLE_INLINING)
+ if (opt_inlining)
+ jd->flags |= JITDATA_FLAG_INLINE;
+#endif
+
#if defined(ENABLE_JIT)
# if defined(ENABLE_INTRP)
if (!opt_intrp)
DEBUG_JIT_COMPILEVERBOSE("Compiling: ");
+#if defined(ENABLE_DEBUG_FILTER)
+ show_filters_apply(jd->m);
+#endif
+
/* handle native methods and create a native stub */
if (m->flags & ACC_NATIVE) {
f = NULL;
#endif
- code = codegen_createnativestub(f, m);
+ code = codegen_generate_stub_native(m, f);
assert(!m->code); /* native methods are never recompiled */
m->code = code;
}
#endif
+#if defined(ENABLE_PROFILING)
/* Basic block reordering. I think this should be done after
if-conversion, as we could lose the ability to do the
if-conversion. */
return NULL;
jit_renumber_basicblocks(jd);
}
+#endif
DEBUG_JIT_COMPILEVERBOSE("Allocating registers: ");
#endif /* defined(ENABLE_JIT) */
RT_TIMING_GET_TIME(time_alloc);
+#if defined(ENABLE_PROFILING)
/* Allocate memory for basic block profiling information. This
_must_ be done after loop optimization and register allocation,
since they can change the basic block count. */
if (JITDATA_HAS_FLAG_INSTRUMENT(jd))
code->bbfrequency = MNEW(u4, jd->basicblockcount);
+#endif
DEBUG_JIT_COMPILEVERBOSE("Generating code: ");
} else
# endif
{
- if (!codegen(jd)) {
+ if (!codegen_generate(jd)) {
DEBUG_JIT_COMPILEVERBOSE("Exception while generating code: ");
return NULL;
DEBUG_JIT_COMPILEVERBOSE("Generating code done: ");
#if !defined(NDEBUG)
- /* intermediate and assembly code listings */
+#if defined(ENABLE_DEBUG_FILTER)
+ if (jd->m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
+#endif
+ {
+ /* intermediate and assembly code listings */
- if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
- show_method(jd, SHOW_CODE);
- }
- else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
+ if (JITDATA_HAS_FLAG_SHOWINTERMEDIATE(jd)) {
+ show_method(jd, SHOW_CODE);
+ }
+ else if (JITDATA_HAS_FLAG_SHOWDISASSEMBLE(jd)) {
# if defined(ENABLE_DISASSEMBLER)
- DISASSEMBLE(code->entrypoint,
- code->entrypoint + (code->mcodelength - cd->dseglen));
+ DISASSEMBLE(code->entrypoint,
+ code->entrypoint + (code->mcodelength - cd->dseglen));
# endif
- }
+ }
- if (opt_showddatasegment)
- dseg_display(jd);
+ if (opt_showddatasegment)
+ dseg_display(jd);
+ }
#endif
DEBUG_JIT_COMPILEVERBOSE("Compiling done: ");