Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: jit.c 7229 2007-01-22 00:58:36Z twisti $
-
*/
#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/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))
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: ");