/* src/vm/jit/inline/inline.c - method inlining
- 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
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
This file is part of CACAO.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: inline.c 7766 2007-04-19 13:24:48Z michi $
-
*/
#include "mm/memory.h"
-#if defined(ENABLE_THREADS)
-# include "threads/native/threads.h"
-#endif
+#include "threads/lock.hpp"
+#include "threads/mutex.hpp"
+#include "threads/thread.hpp"
#include "toolbox/logging.h"
-#include "vm/builtin.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
#include "vm/global.h"
-#include "vm/initialize.h"
+#include "vm/initialize.hpp"
+#include "vm/method.h"
+#include "vm/options.h"
+#include "vm/statistics.h"
-#include "vm/jit/jit.h"
-#include "vm/jit/parse.h"
+#include "vm/jit/jit.hpp"
+#include "vm/jit/parse.hpp"
#include "vm/jit/reg.h"
-#include "vm/jit/show.h"
+#include "vm/jit/show.hpp"
#include "vm/jit/stack.h"
#include "vm/jit/inline/inline.h"
#include "vm/jit/verify/typecheck.h"
-#include "vmcore/class.h"
-#include "vmcore/method.h"
-#include "vmcore/options.h"
-#include "vmcore/statistics.h"
-
/* algorithm tuning constants *************************************************/
#if !defined(NDEBUG)
#define INLINE_VERBOSE
-#define DOLOG(code) do{ if (opt_inline_debug_log) { code; } }while(0)
+#define DOLOG(code) do{ if (opt_TraceInlining >= 2) { code; } }while(0)
+#define DOLOG_SHORT(code) do{ if (opt_TraceInlining >= 1) { code; } }while(0)
#else
#define DOLOG(code)
#endif
/* call parse pass */
- DOLOG( log_message_class("Parsing ", m->class) );
+ DOLOG( log_message_class("Parsing ", m->clazz) );
if (!parse(jd)) {
return false;
}
m = iln->m;
assert(m);
-#if defined(ENABLE_THREADS)
/* enter a monitor on the method */
- lock_monitor_enter((java_objectheader *) m);
-#endif
+
+ Mutex_lock(m->mutex);
/* allocate jitdata structure and fill it */
#endif
-#if defined(ENABLE_THREADS)
/* leave the monitor */
- lock_monitor_exit((java_objectheader *) m );
-#endif
+
+ Mutex_unlock(m->mutex);
return r;
}
}
+#if 0
static void inline_add_blocknr_reference(inline_node *iln, s4 *nrp)
{
inline_target_ref *ref;
ref->next = iln->refs;
iln->refs = ref;
}
+#endif
static void inline_block_translation(inline_node *iln, basicblock *o_bptr, basicblock *n_bptr)
syncvar = inline_new_temp_variable(iln->ctx->resultjd, TYPE_ADR);
n_ins = inline_instruction(iln, ICMD_ACONST, o_iptr);
- n_ins->sx.val.c.cls = callee->m->class;
+ n_ins->sx.val.c.cls = callee->m->clazz;
n_ins->dst.varindex = syncvar;
n_ins->flags.bits |= INS_FLAG_CLASS;
}
n_ins = master->inlined_iinstr_cursor++;
if (iln->m->flags & ACC_STATIC) {
n_ins->opc = ICMD_ACONST;
- n_ins->sx.val.c.cls = iln->m->class;
+ n_ins->sx.val.c.cls = iln->m->clazz;
n_ins->flags.bits = INS_FLAG_CLASS;
}
else {
debug_verify_inlined_code = 0;
DOLOG( printf("VERIFYING INLINED RESULT...\n"); fflush(stdout); );
if (!typecheck(n_jd)) {
- *exceptionptr = NULL;
+ exceptions_clear_exception();
DOLOG( printf("XXX INLINED RESULT DID NOT PASS VERIFIER XXX\n") );
return false;
}
/* we need bigger free memory stacks (XXX these should not be allocated in reg_setup) */
n_jd->rd->freemem = DMNEW(s4, iln->ctx->maxinoutdepth + 1000) /* XXX max vars/block */;
-#if defined(HAS_4BYTE_STACKSLOT)
- n_jd->rd->freemem_2 = DMNEW(s4, iln->ctx->maxinoutdepth + 1000) /* XXX max vars/block */;
-#endif
#if defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG)
- if ( (n_jd->instructioncount >= opt_inline_debug_min_size)
- && (n_jd->instructioncount <= opt_inline_debug_max_size))
+ if ( (n_jd->instructioncount >= opt_InlineMinSize)
+ && (n_jd->instructioncount <= opt_InlineMaxSize))
{
- if (debug_counter <= opt_inline_debug_end_counter)
+ if (debug_counter < opt_InlineCount)
#endif /* defined(ENABLE_INLINING_DEBUG) || !defined(NDEBUG) */
{
/* install the inlined result */
#if !defined(NDEBUG)
inline_stat_roots++;
- DOLOG(
+ DOLOG_SHORT(
printf("==== %d.INLINE ==================================================================\n",
debug_counter);
printf("\ninline tree:\n");
static void inline_post_process(jitdata *jd)
{
+ codeinfo *code;
basicblock *bptr;
instruction *iptr;
instruction *iend;
methoddesc *md;
builtintable_entry *bte;
+ /* Get required compiler data. */
+
+ code = jd->code;
+
/* reset the SAVEDVAR flag of all variables */
for (i=0; i<jd->vartop; ++i)
POSTPROCESS_SRCOP(s1);
case DF_0_TO_0:
if (icmdt->flags & ICMDTABLE_CALLS) {
- jd->isleafmethod = false;
+ code_unflag_leafmethod(code);
MARK_ALL_SAVED;
}
break;
POSTPROCESS_SRCOP(s1);
case DF_0_TO_1:
if (icmdt->flags & ICMDTABLE_CALLS) {
- jd->isleafmethod = false;
+ code_unflag_leafmethod(code);
MARK_ALL_SAVED;
}
case DF_COPY:
POSTPROCESS_SRC(iptr->sx.s23.s2.args[i]);
}
if (icmdt->flags & ICMDTABLE_CALLS) {
- jd->isleafmethod = false;
+ code_unflag_leafmethod(code);
MARK_ALL_SAVED;
}
POSTPROCESS_DSTOP(dst);
case DF_INVOKE:
INSTRUCTION_GET_METHODDESC(iptr, md);
post_process_call:
- jd->isleafmethod = false;
+ code_unflag_leafmethod(code);
for (i=0; i<md->paramcount; ++i) {
POSTPROCESS_SRC(iptr->sx.s23.s2.args[i]);
}