#include "mm/memory.h"
-#include "native/native.h"
+#include "native/native.hpp"
#include "toolbox/logging.h"
-#include "threads/lock-common.h"
+#include "threads/mutex.hpp"
-#include "vm/class.h"
+#include "vm/class.hpp"
#include "vm/global.h"
#include "vm/globals.hpp"
-#include "vm/initialize.h"
+#include "vm/initialize.hpp"
#include "vm/loader.hpp"
#include "vm/method.h"
#include "vm/options.h"
#include "vm/jit/cfg.h"
-#include "vm/jit/codegen-common.h"
+#include "vm/jit/codegen-common.hpp"
#include "vm/jit/disass.h"
#include "vm/jit/dseg.h"
#include "vm/jit/jit.hpp"
#include "vm/jit/parse.h"
#include "vm/jit/reg.h"
-#include "vm/jit/show.h"
+#include "vm/jit/show.hpp"
#include "vm/jit/stack.h"
#include "vm/jit/stubs.hpp"
#if defined(ENABLE_OPAGENT)
if (opt_EnableOpagent)
- OprofileAgent_initialize();
+ OprofileAgent::initialize();
#endif
}
{
#if defined(ENABLE_OPAGENT)
if (opt_EnableOpagent)
- OprofileAgent_close();
+ OprofileAgent::close();
#endif
}
/* allocate jitdata structure and fill it */
- jd = DNEW(jitdata);
+ jd = (jitdata*) DumpMemory::allocate(sizeof(jitdata));
jd->m = m;
- jd->cd = DNEW(codegendata);
- jd->rd = DNEW(registerdata);
+ jd->cd = (codegendata*) DumpMemory::allocate(sizeof(codegendata));
+ jd->rd = (registerdata*) DumpMemory::allocate(sizeof(registerdata));
#if defined(ENABLE_LOOP)
- jd->ld = DNEW(loopdata);
+ jd->ld = (loopdata*) DumpMemory::allocate(sizeof(loopdata));
#endif
/* Allocate codeinfo memory from the heap as we need to keep them. */
{
u1 *r;
jitdata *jd;
- int32_t dumpmarker;
STATISTICS(count_jit_calls++);
/* enter a monitor on the method */
- LOCK_MONITOR_ENTER(m);
+ m->mutex->lock();
/* if method has been already compiled return immediately */
if (m->code != NULL) {
- LOCK_MONITOR_EXIT(m);
+ m->mutex->unlock();
assert(m->code->entrypoint);
return m->code->entrypoint;
compilingtime_start();
#endif
- /* mark start of dump memory area */
-
- DMARKER;
+ // Create new dump memory area.
+ DumpMemoryArea dma;
/* create jitdata structure */
DEBUG_JIT_COMPILEVERBOSE("Running: ");
}
- /* release dump area */
-
- DRELEASE;
-
#if defined(ENABLE_STATISTICS)
/* measure time */
#if defined(ENABLE_OPAGENT)
if (opt_EnableOpagent)
- OprofileAgent_newmethod(m);
+ OprofileAgent::newmethod(m);
#endif
/* leave the monitor */
- LOCK_MONITOR_EXIT(m);
+ m->mutex->unlock();
/* return pointer to the methods entry point */
u1 *r;
jitdata *jd;
u1 optlevel;
- int32_t dumpmarker;
/* check for max. optimization level */
compilingtime_start();
#endif
- /* mark start of dump memory area */
-
- DMARKER;
+ // Create new dump memory area.
+ DumpMemoryArea dma;
/* create jitdata structure */
code_codeinfo_free(jd->code);
}
- /* release dump area */
-
- DRELEASE;
-
#if defined(ENABLE_STATISTICS)
/* measure time */
#if defined(ENABLE_OPAGENT)
if (opt_EnableOpagent)
- OprofileAgent_newmethod(m);
+ OprofileAgent::newmethod(m);
#endif
DEBUG_JIT_COMPILEVERBOSE("Recompiling done: ");
show_filters_apply(jd->m);
#endif
- /* Handle native methods and create a native stub. */
-
+ // Handle native methods and create a native stub.
if (m->flags & ACC_NATIVE) {
- functionptr f;
-
- f = native_method_resolve(m);
+ NativeMethods& nm = VM::get_current()->get_nativemethods();
+ void* f = nm.resolve_method(m);
if (f == NULL)
return NULL;
- code = NativeStub::generate(m, f);
+ code = NativeStub::generate(m, (functionptr) f);
/* Native methods are never recompiled. */
/*&& jd->exceptiontablelength == 0*/
) {
/*printf("=== %s ===\n", jd->m->name->text);*/
- jd->ls = DNEW(lsradata);
+ jd->ls = (lsradata*) DumpMemory::allocate(sizeof(lsradata));
jd->ls = NULL;
ssa(jd);
/*lsra(jd);*/ regalloc(jd);
#if defined(ENABLE_JIT)
#if !defined(JIT_COMPILER_VIA_SIGNAL)
-u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra)
+extern "C" {
+void* jit_asm_compile(methodinfo *m, void* mptr, void* sp, void* ra)
{
stackframeinfo_t sfi;
- u1 *entrypoint;
- u1 *pa;
- ptrint *p;
+ void *entrypoint;
+ void *pa;
+ uintptr_t *p;
/* create the stackframeinfo (subtract 1 from RA as it points to the */
/* instruction after the call) */
- stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ra-1);
+ stacktrace_stackframeinfo_add(&sfi, NULL, sp, ra, ((uint8_t*) ra) - 1);
/* actually compile the method */
/* patch the method entry point */
- p = (ptrint *) pa;
+ p = (uintptr_t*) pa;
- *p = (ptrint) entrypoint;
+ *p = (uintptr_t) entrypoint;
/* flush the instruction cache */
return entrypoint;
}
+}
#endif
/* jit_compile_handle **********************************************************