* src/vm/jit/stubs.hpp: Likewise.
* src/vm/jit/alpha/md-stubs.hpp,
src/vm/jit/arm/md-stubs.hpp,
src/vm/jit/i386/md-stubs.hpp,
src/vm/jit/m68k/md-stubs.hpp,
src/vm/jit/mips/md-stubs.hpp,
src/vm/jit/powerpc/md-stubs.hpp,
src/vm/jit/powerpc64/md-stubs.hpp,
src/vm/jit/s390/md-stubs.hpp,
src/vm/jit/sparc64/md-stubs.hpp,
src/vm/jit/x86_64/md-stubs.hpp: Likewise.
* src/vm/jit/alpha/Makefile.am,
src/vm/jit/arm/Makefile.am,
src/vm/jit/i386/Makefile.am,
src/vm/jit/m68k/Makefile.am,
src/vm/jit/mips/Makefile.am,
src/vm/jit/powerpc/Makefile.am,
src/vm/jit/powerpc64/Makefile.am,
src/vm/jit/s390/Makefile.am,
src/vm/jit/sparc64/Makefile.am,
src/vm/jit/x86_64/Makefile.am (libarch_la_SOURCES): Added
md-stubs.hpp.
* src/vm/jit/alpha/codegen.h,
src/vm/jit/arm/codegen.h,
src/vm/jit/i386/codegen.h,
src/vm/jit/m68k/codegen.h,
src/vm/jit/mips/codegen.h,
src/vm/jit/powerpc/codegen.h,
src/vm/jit/powerpc64/codegen.h,
src/vm/jit/s390/codegen.h,
src/vm/jit/sparc64/codegen.h,
src/vm/jit/x86_64/codegen.h (COMPILERSTUB_CODESIZE): Removed.
* src/vm/builtin.c,
src/vm/jit/Makefile.am,
src/vm/jit/abi.h,
src/vm/jit/codegen-common.c,
src/vm/jit/codegen-common.h,
src/vm/jit/dseg.h,
src/vm/jit/emit-common.h,
src/vm/jit/jit.c,
src/vm/jit/jit.h,
src/vm/jit/reg.h,
src/vm/linker.c,
src/vm/loader.c,
src/vm/method.c: Changes regarding new stub files.
#include "vm/string.hpp"
#include "vm/jit/asmpart.h"
+#include "vm/jit/stubs.hpp"
#include "vm/jit/trace.hpp"
#if defined(ENABLE_VMLOG)
if (bte->flags & BUILTINTABLE_FLAG_STUB) {
m = method_new_builtin(bte);
- codegen_generate_stub_builtin(m, bte);
+ BuiltinStub_generate(m, bte);
}
}
if (bte->flags & BUILTINTABLE_FLAG_STUB) {
m = method_new_builtin(bte);
- codegen_generate_stub_builtin(m, bte);
+ BuiltinStub_generate(m, bte);
}
}
$(STACK_SOURCES) \
stacktrace.cpp \
stacktrace.hpp \
+ stubs.cpp \
+ stubs.hpp \
trace.cpp \
trace.hpp \
$(TRAP_SOURCES) \
/* function prototypes ********************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* machine dependent descriptor function */
void md_param_alloc(methoddesc *md);
void md_param_alloc_native(methoddesc *md);
/* machine dependent return value handling function */
void md_return_alloc(jitdata *jd, stackelement_t *stackslot);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _ABI_H */
\
md-abi.c \
md-abi.h \
+ md-stubs.hpp \
md-trap.h \
md.c \
md.h
} while (0)
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE 1 * 4
-
-
/* macros to create code ******************************************************/
/* M_MEM - memory instruction format *******************************************
--- /dev/null
+/* src/vm/jit/alpha/md-stubs.hpp - Alpha JIT stubs
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on an Alpha architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+ return 1 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
\
md-abi.c \
md-abi.h \
+ md-stubs.hpp \
md-trap.h \
md.c \
md.h
/* src/vm/jit/arm/codegen.h - code generation macros and definitions for ARM
- 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.
} while (0)
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE 2 * 4
-
-
/* lazy debugger **************************************************************/
#if !defined(NDEBUG)
--- /dev/null
+/* src/vm/jit/arm/md-stubs.hpp - ARM JIT stubs
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on an ARM architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+ return 2 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
}
-/* codegen_generate_stub_compiler **********************************************
-
- Wrapper for codegen_emit_stub_compiler.
-
- Returns:
- pointer to the compiler stub code.
-
-*******************************************************************************/
-
-u1 *codegen_generate_stub_compiler(methodinfo *m)
-{
- jitdata *jd;
- codegendata *cd;
- ptrint *d; /* pointer to data memory */
- u1 *c; /* pointer to code memory */
- int32_t dumpmarker;
-
- /* mark dump memory */
-
- DMARKER;
-
- /* allocate required data structures */
-
- jd = DNEW(jitdata);
-
- jd->m = m;
- jd->cd = DNEW(codegendata);
- jd->flags = 0;
-
- /* get required compiler data */
-
- cd = jd->cd;
-
-#if !defined(JIT_COMPILER_VIA_SIGNAL)
- /* allocate code memory */
-
- c = CNEW(u1, 3 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE);
-
- /* set pointers correctly */
-
- d = (ptrint *) c;
-
- cd->mcodebase = c;
-
- c = c + 3 * SIZEOF_VOID_P;
- cd->mcodeptr = c;
-
- /* NOTE: The codeinfo pointer is actually a pointer to the
- methodinfo (this fakes a codeinfo structure). */
-
- d[0] = (ptrint) asm_call_jit_compiler;
- d[1] = (ptrint) m;
- d[2] = (ptrint) &d[1]; /* fake code->m */
-
- /* call the emit function */
-
- codegen_emit_stub_compiler(jd);
-
-#if defined(ENABLE_STATISTICS)
- if (opt_stat)
- count_cstub_len += 3 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE;
-#endif
-
- /* flush caches */
-
- md_cacheflush(cd->mcodebase, 3 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE);
-#else
- /* Allocate code memory. */
-
- c = CNEW(uint8_t, 2 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE);
-
- /* Set pointers correctly. */
-
- d = (ptrint *) c;
-
- cd->mcodebase = c;
-
- c = c + 2 * SIZEOF_VOID_P;
- cd->mcodeptr = c;
-
- /* NOTE: The codeinfo pointer is actually a pointer to the
- methodinfo (this fakes a codeinfo structure). */
-
- d[0] = (ptrint) m;
- d[1] = (ptrint) &d[0]; /* fake code->m */
-
- /* Emit the trap instruction. */
-
- emit_trap_compiler(cd);
-
-#if defined(ENABLE_STATISTICS)
- if (opt_stat)
- count_cstub_len += 2 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE;
-#endif
-
- /* Flush caches. */
-
- md_cacheflush(cd->mcodebase, 2 * SIZEOF_VOID_P + COMPILERSTUB_CODESIZE);
-#endif
-
- /* release dump memory */
-
- DRELEASE;
-
- /* return native stub code */
-
- return c;
-}
-
-
-/* codegen_generate_stub_builtin ***********************************************
-
- Wrapper for codegen_emit_stub_native.
-
-*******************************************************************************/
-
-void codegen_generate_stub_builtin(methodinfo *m, builtintable_entry *bte)
-{
- jitdata *jd;
- codeinfo *code;
- int skipparams;
- int32_t dumpmarker;
-
- /* mark dump memory */
-
- DMARKER;
-
- /* Create JIT data structure. */
-
- jd = jit_jitdata_new(m);
-
- /* Get required compiler data. */
-
- code = jd->code;
-
- /* Stubs are non-leaf methods. */
-
- code_unflag_leafmethod(code);
-
- /* setup code generation stuff */
-
- codegen_setup(jd);
-
- /* Set the number of native arguments we need to skip. */
-
- skipparams = 0;
-
- /* generate the code */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
- if (!opt_intrp) {
-# endif
- assert(bte->fp != NULL);
- codegen_emit_stub_native(jd, bte->md, bte->fp, skipparams);
-# if defined(ENABLE_INTRP)
- }
-# endif
-#endif
-
- /* reallocate the memory and finish the code generation */
-
- codegen_finish(jd);
-
- /* set the stub entry point in the builtin table */
-
- bte->stub = code->entrypoint;
-
-#if defined(ENABLE_STATISTICS)
- if (opt_stat)
- size_stub_native += code->mcodelength;
-#endif
-
-#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
- /* disassemble native stub */
-
- if (opt_DisassembleStubs) {
- codegen_disassemble_stub(m,
- (u1 *) (ptrint) code->entrypoint,
- (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen));
-
- /* show data segment */
-
- if (opt_showddatasegment)
- dseg_display(jd);
- }
-#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */
-
- /* release memory */
-
- DRELEASE;
-}
-
-
-/* codegen_generate_stub_native ************************************************
-
- Wrapper for codegen_emit_stub_native.
-
- Returns:
- the codeinfo representing the stub code.
-
-*******************************************************************************/
-
-codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f)
-{
- jitdata *jd;
- codeinfo *code;
- methoddesc *md;
- methoddesc *nmd;
- int skipparams;
- int32_t dumpmarker;
-
- /* mark dump memory */
-
- DMARKER;
-
- /* Create JIT data structure. */
-
- jd = jit_jitdata_new(m);
-
- /* Get required compiler data. */
-
- code = jd->code;
-
- /* Stubs are non-leaf methods. */
-
- code_unflag_leafmethod(code);
-
- /* set the flags for the current JIT run */
-
-#if defined(ENABLE_PROFILING)
- if (opt_prof)
- jd->flags |= JITDATA_FLAG_INSTRUMENT;
-#endif
-
- if (opt_verbosecall)
- jd->flags |= JITDATA_FLAG_VERBOSECALL;
-
- /* setup code generation stuff */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
- if (!opt_intrp)
-# endif
- reg_setup(jd);
-#endif
-
- codegen_setup(jd);
-
- /* create new method descriptor with additional native parameters */
-
- md = m->parseddesc;
-
- /* Set the number of native arguments we need to skip. */
-
- if (m->flags & ACC_STATIC)
- skipparams = 2;
- else
- skipparams = 1;
-
- nmd = (methoddesc *) DMNEW(u1, sizeof(methoddesc) - sizeof(typedesc) +
- md->paramcount * sizeof(typedesc) +
- skipparams * sizeof(typedesc));
-
- nmd->paramcount = md->paramcount + skipparams;
-
- nmd->params = DMNEW(paramdesc, nmd->paramcount);
-
- nmd->paramtypes[0].type = TYPE_ADR; /* add environment pointer */
-
- if (m->flags & ACC_STATIC)
- nmd->paramtypes[1].type = TYPE_ADR; /* add class pointer */
-
- MCOPY(nmd->paramtypes + skipparams, md->paramtypes, typedesc,
- md->paramcount);
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
- if (!opt_intrp)
-# endif
- /* pre-allocate the arguments for the native ABI */
-
- md_param_alloc_native(nmd);
-#endif
-
- /* generate the code */
-
-#if defined(ENABLE_JIT)
-# if defined(ENABLE_INTRP)
- if (opt_intrp)
- intrp_createnativestub(f, jd, nmd);
- else
-# endif
- codegen_emit_stub_native(jd, nmd, f, skipparams);
-#else
- intrp_createnativestub(f, jd, nmd);
-#endif
-
- /* reallocate the memory and finish the code generation */
-
- codegen_finish(jd);
-
-#if defined(ENABLE_STATISTICS)
- /* must be done after codegen_finish() */
-
- if (opt_stat)
- size_stub_native += code->mcodelength;
-#endif
-
-#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
- /* disassemble native stub */
-
- if (opt_DisassembleStubs) {
-# if defined(ENABLE_DEBUG_FILTER)
- if (m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
-# endif
- {
- codegen_disassemble_stub(m,
- (u1 *) (ptrint) code->entrypoint,
- (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen));
-
- /* show data segment */
-
- if (opt_showddatasegment)
- dseg_display(jd);
- }
- }
-#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */
-
- /* release memory */
-
- DRELEASE;
-
- /* return native stub code */
-
- return code;
-}
-
-
-/* codegen_disassemble_nativestub **********************************************
-
- Disassembles the generated builtin or native stub.
-
-*******************************************************************************/
-
-#if defined(ENABLE_DISASSEMBLER)
-void codegen_disassemble_stub(methodinfo *m, u1 *start, u1 *end)
-{
- printf("Stub code: ");
- if (m->clazz != NULL)
- utf_fprint_printable_ascii_classname(stdout, m->clazz->name);
- else
- printf("NULL");
- printf(".");
- utf_fprint_printable_ascii(stdout, m->name);
- utf_fprint_printable_ascii(stdout, m->descriptor);
- printf("\nLength: %d\n\n", (s4) (end - start));
-
- DISASSEMBLE(start, end);
-}
-#endif
-
-
/* codegen_start_native_call ***************************************************
Prepares the stuff required for a native (JNI) function call:
}
-/* removecompilerstub **********************************************************
-
- Deletes a compilerstub from memory (simply by freeing it).
-
-*******************************************************************************/
-
-void removecompilerstub(u1 *stub)
-{
- /* pass size 1 to keep the intern function happy */
-
- CFREE((void *) stub, 1);
-}
-
-
-/* removenativestub ************************************************************
-
- Removes a previously created native-stub from memory.
-
-*******************************************************************************/
-
-void removenativestub(u1 *stub)
-{
- /* pass size 1 to keep the intern function happy */
-
- CFREE((void *) stub, 1);
-}
-
-
/* codegen_reg_of_var **********************************************************
This function determines a register, to which the result of an
/* function prototypes ********************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void codegen_init(void);
void codegen_setup(jitdata *jd);
void codegen_finish(jitdata *jd);
-#if defined(ENABLE_DISASSEMBLER)
-void codegen_disassemble_stub(methodinfo *m, u1 *start, u1 *end);
-#endif
-
-/* stub functions */
-
-u1 *codegen_generate_stub_compiler(methodinfo *m);
-void codegen_generate_stub_builtin(methodinfo *m, builtintable_entry *bte);
-codeinfo *codegen_generate_stub_native(methodinfo *m, functionptr f);
-
-#if !defined(JIT_COMPILER_VIA_SIGNAL)
-void codegen_emit_stub_compiler(jitdata *jd);
-#endif
-void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int skipparams);
-
-#if defined(ENABLE_INTRP)
-u1 *intrp_createcompilerstub(methodinfo *m);
-u1 *intrp_createnativestub(functionptr f, jitdata *jd, methoddesc *md);
-#endif
-
-void removecompilerstub(u1 *stub);
-void removenativestub(u1 *stub);
-
java_handle_t *codegen_start_native_call(u1 *currentsp, u1 *pv);
java_object_t *codegen_finish_native_call(u1 *currentsp, u1 *pv);
void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr);
#endif
+// REMOVEME
+void codegen_emit_stub_compiler(jitdata *jd);
+void codegen_emit_stub_native(jitdata *jd, methoddesc *nmd, functionptr f, int skipparams);
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _CODEGEN_COMMON_H */
/* function prototypes ********************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void dseg_finish(jitdata *jd);
s4 dseg_add_unique_s4(codegendata *cd, s4 value);
void dseg_display(jitdata *jd);
#endif
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _DSEG_H */
/* code generation functions **************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
s4 emit_load(jitdata *jd, instruction *iptr, varinfo *src, s4 tempreg);
s4 emit_load_s1(jitdata *jd, instruction *iptr, s4 tempreg);
s4 emit_load_s2(jitdata *jd, instruction *iptr, s4 tempreg);
void emit_verbosecall_enter(jitdata *jd);
void emit_verbosecall_exit(jitdata *jd);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _EMIT_COMMON_H */
\
md-abi.c \
md-abi.h \
+ md-stubs.hpp \
md-trap.h \
md.c \
md.h
/* src/vm/jit/i386/codegen.h - code generation macros and definitions for i386
- 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.
} while (0)
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE 6
-
-
/* macros to create code ******************************************************/
#define M_BYTE1(a) \
--- /dev/null
+/* src/vm/jit/i386/md-stubs.hpp - i386 JIT stubs
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on an i386 architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+ return 6;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
#include "vm/jit/show.h"
#include "vm/jit/stack.h"
+#include "vm/jit/stubs.hpp"
#if defined(ENABLE_OPAGENT)
#include "vm/jit/oprofile-agent.hpp"
if (f == NULL)
return NULL;
- code = codegen_generate_stub_native(m, f);
+ code = NativeStub_generate(m, f);
/* Native methods are never recompiled. */
/* function prototypes ********************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* compiler initialisation */
void jit_init(void);
void *md_jit_method_patch_address(void *pv, void *ra, void *mptr);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _JIT_H */
emit.c \
patcher.c \
\
+ md-stubs.hpp \
md-trap.h \
md.c \
md.h
/* src/vm/jit/m68k/codegen.h
- 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.
#define PATCHER_CALL_SIZE 2
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE (2+2)
-
/* coldfire instruction format:
* -----------------------------
--- /dev/null
+/* src/vm/jit/m68k/md-stubs.hpp - m68k JIT stubs
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a m68k architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+ return 2 + 2;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
\
md-abi.c \
md-abi.h \
+ md-stubs.hpp \
md-trap.h \
md.c \
md.h
/* src/vm/jit/mips/codegen.h - code generation macros and definitions for MIPS
- 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.
} while (0)
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE 1 * 4
-
-
/* macros to create code ******************************************************/
/* code generation macros operands:
--- /dev/null
+/* src/vm/jit/mips/md-stubs.hpp - MIPS JIT stubs
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a MIPS architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+ return 1 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
emit.c \
patcher.c \
\
+ md-stubs.hpp \
md-trap.h \
md.c \
md.h
} while (0)
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE 1 * 4
-
-
/* macros to create code ******************************************************/
#define M_OP3(opcode,y,oe,rc,d,a,b) \
--- /dev/null
+/* src/vm/jit/powerpc/md-stubs.hpp - PowerPC JIT stubs
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a PowerPC architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+ return 1 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
emit.c \
patcher.c \
\
+ md-stubs.hpp \
md-trap.h \
md.c \
md.h
-/* src/vm/jit/powerpc64/codegen.h - code generation macros and definitions for
- 64-bit PowerPC
+/* src/vm/jit/powerpc64/codegen.h - code generation macros and
+ definitions for PowerPC64
- 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.
- Contact: cacao@cacaojvm.org
-
- Authors: Andreas Krall
- Stefan Ring
- Christian Thalinger
- Christian Ullrich
-
-
*/
} while (0)
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE 1 * 4
-
-
/* macros to create code ******************************************************/
#define M_OP3(opcode,y,oe,rc,d,a,b) \
--- /dev/null
+/* src/vm/jit/powerpc64/md-stubs.hpp - PowerPC64 JIT stubs
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a PowerPC64 architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+ return 1 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
/* function prototypes ********************************************************/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
void reg_setup(jitdata *jd);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _REG_H */
\
md-abi.c \
md-abi.h \
+ md-stubs.hpp \
md-trap.h \
md.c \
md.h
/* src/vm/jit/s390/codegen.h - code generation macros for s390
- 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.
} \
} while (0)
-/* stub defines **************************************************************/
-
-#define COMPILERSTUB_CODESIZE (SZ_AHI + SZ_L + SZ_L + SZ_BCR)
/* *** BIG TODO ***
* Make all this inline functions !!!!!!!!!!
--- /dev/null
+/* src/vm/jit/s390/md-stubs.hpp - s390 JIT stubs
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+#include "vm/jit/s390/codegen.h"
+
+
+/**
+ * Return the code size of a compiler on a s390 architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+ return (SZ_AHI + SZ_L + SZ_L + SZ_BCR);
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
\
md-abi.c \
md-abi.h \
+ md-stubs.hpp \
md-trap.h \
md.c \
md.h
-/* src/vm/jit/sparc64/codegen.h - code generation macros and definitions for
- Sparc64
+/* src/vm/jit/sparc64/codegen.h - code generation macros and
+ definitions for SPARC64
- 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.
} while (0)
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE 4 * 4
-
-
/* additional functions and macros to generate code ***************************/
--- /dev/null
+/* src/vm/jit/sparc64/md-stubs.hpp - SPARC64 JIT stubs
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a SPARC64 architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+ return 4 * 4;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
--- /dev/null
+/* src/vm/jit/stubs.cpp - JIT stubs
+
+ Copyright (C) 1996-2005, 2006, 2007, 2008
+ CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#include "config.h"
+
+#include <stdint.h>
+
+// Include machine dependent headers.
+#include "md.h"
+
+#include "mm/dumpmemory.h"
+
+#include "vm/method.h"
+#include "vm/options.h"
+
+#include "vm/jit/abi.h"
+#include "vm/jit/code.h"
+#include "vm/jit/codegen-common.h"
+#include "vm/jit/disass.h"
+#include "vm/jit/emit-common.h"
+#include "vm/jit/jit.h"
+#include "vm/jit/show.h"
+#include "vm/jit/stubs.hpp"
+
+
+/**
+ * Wrapper for codegen_emit_stub_compiler.
+ *
+ * @param m Method object.
+ *
+ * @return Pointer to the compiler stub code.
+ */
+void* CompilerStub::generate(methodinfo *m)
+{
+ jitdata *jd;
+ codegendata *cd;
+ ptrint *d; /* pointer to data memory */
+ u1 *c; /* pointer to code memory */
+ int32_t dumpmarker;
+
+ /* mark dump memory */
+
+ DMARKER;
+
+ /* allocate required data structures */
+
+ jd = DNEW(jitdata);
+
+ jd->m = m;
+ jd->cd = DNEW(codegendata);
+ jd->flags = 0;
+
+ /* get required compiler data */
+
+ cd = jd->cd;
+
+#if !defined(JIT_COMPILER_VIA_SIGNAL)
+ /* allocate code memory */
+
+ c = CNEW(u1, 3 * SIZEOF_VOID_P + get_code_size());
+
+ /* set pointers correctly */
+
+ d = (ptrint *) c;
+
+ cd->mcodebase = c;
+
+ c = c + 3 * SIZEOF_VOID_P;
+ cd->mcodeptr = c;
+
+ /* NOTE: The codeinfo pointer is actually a pointer to the
+ methodinfo (this fakes a codeinfo structure). */
+
+ d[0] = (ptrint) asm_call_jit_compiler;
+ d[1] = (ptrint) m;
+ d[2] = (ptrint) &d[1]; /* fake code->m */
+
+ /* call the emit function */
+
+ codegen_emit_stub_compiler(jd);
+
+#if defined(ENABLE_STATISTICS)
+ if (opt_stat)
+ count_cstub_len += 3 * SIZEOF_VOID_P + get_code_size();
+#endif
+
+ /* flush caches */
+
+ md_cacheflush(cd->mcodebase, 3 * SIZEOF_VOID_P + get_code_size());
+#else
+ /* Allocate code memory. */
+
+ c = CNEW(uint8_t, 2 * SIZEOF_VOID_P + get_code_size());
+
+ /* Set pointers correctly. */
+
+ d = (ptrint *) c;
+
+ cd->mcodebase = c;
+
+ c = c + 2 * SIZEOF_VOID_P;
+ cd->mcodeptr = c;
+
+ /* NOTE: The codeinfo pointer is actually a pointer to the
+ methodinfo (this fakes a codeinfo structure). */
+
+ d[0] = (ptrint) m;
+ d[1] = (ptrint) &d[0]; /* fake code->m */
+
+ /* Emit the trap instruction. */
+
+ emit_trap_compiler(cd);
+
+#if defined(ENABLE_STATISTICS)
+ if (opt_stat)
+ count_cstub_len += 2 * SIZEOF_VOID_P + get_code_size();
+#endif
+
+ /* Flush caches. */
+
+ md_cacheflush(cd->mcodebase, 2 * SIZEOF_VOID_P + get_code_size());
+#endif
+
+ /* release dump memory */
+
+ DRELEASE;
+
+ /* return native stub code */
+
+ return c;
+}
+
+
+/**
+ * Free a compiler stub from memory.
+ *
+ * @param
+ */
+void CompilerStub::remove(void* stub)
+{
+ // Pass size 1 to keep the intern function happy.
+ CFREE(stub, 1);
+}
+
+
+/* codegen_disassemble_nativestub **********************************************
+
+ Disassembles the generated builtin or native stub.
+
+*******************************************************************************/
+
+#if defined(ENABLE_DISASSEMBLER)
+static void codegen_disassemble_stub(methodinfo *m, u1 *start, u1 *end)
+{
+ printf("Stub code: ");
+ if (m->clazz != NULL)
+ utf_fprint_printable_ascii_classname(stdout, m->clazz->name);
+ else
+ printf("NULL");
+ printf(".");
+ utf_fprint_printable_ascii(stdout, m->name);
+ utf_fprint_printable_ascii(stdout, m->descriptor);
+ printf("\nLength: %d\n\n", (s4) (end - start));
+
+ DISASSEMBLE(start, end);
+}
+#endif
+
+
+/**
+ * Wrapper for codegen_emit_stub_native.
+ *
+ * @param m Method object.
+ * @param bte Builtin function structure.
+ */
+void BuiltinStub::generate(methodinfo* m, builtintable_entry* bte)
+{
+ jitdata *jd;
+ codeinfo *code;
+ int skipparams;
+ int32_t dumpmarker;
+
+ /* mark dump memory */
+
+ DMARKER;
+
+ /* Create JIT data structure. */
+
+ jd = jit_jitdata_new(m);
+
+ /* Get required compiler data. */
+
+ code = jd->code;
+
+ /* Stubs are non-leaf methods. */
+
+ code_unflag_leafmethod(code);
+
+ /* setup code generation stuff */
+
+ codegen_setup(jd);
+
+ /* Set the number of native arguments we need to skip. */
+
+ skipparams = 0;
+
+ /* generate the code */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (!opt_intrp) {
+# endif
+ assert(bte->fp != NULL);
+ codegen_emit_stub_native(jd, bte->md, bte->fp, skipparams);
+# if defined(ENABLE_INTRP)
+ }
+# endif
+#endif
+
+ /* reallocate the memory and finish the code generation */
+
+ codegen_finish(jd);
+
+ /* set the stub entry point in the builtin table */
+
+ bte->stub = code->entrypoint;
+
+#if defined(ENABLE_STATISTICS)
+ if (opt_stat)
+ size_stub_native += code->mcodelength;
+#endif
+
+#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
+ /* disassemble native stub */
+
+ if (opt_DisassembleStubs) {
+ codegen_disassemble_stub(m,
+ (u1 *) (ptrint) code->entrypoint,
+ (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen));
+
+ /* show data segment */
+
+ if (opt_showddatasegment)
+ dseg_display(jd);
+ }
+#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */
+
+ /* release memory */
+
+ DRELEASE;
+}
+
+
+/**
+ * Wrapper for codegen_emit_stub_native.
+ *
+ * @param m Method object of the native function.
+ * @param f Native function pointer.
+ *
+ * @return The codeinfo representing the stub code.
+ */
+codeinfo* NativeStub::generate(methodinfo* m, functionptr f)
+{
+ jitdata *jd;
+ codeinfo *code;
+ methoddesc *md;
+ methoddesc *nmd;
+ int skipparams;
+ int32_t dumpmarker;
+
+ /* mark dump memory */
+
+ DMARKER;
+
+ /* Create JIT data structure. */
+
+ jd = jit_jitdata_new(m);
+
+ /* Get required compiler data. */
+
+ code = jd->code;
+
+ /* Stubs are non-leaf methods. */
+
+ code_unflag_leafmethod(code);
+
+ /* set the flags for the current JIT run */
+
+#if defined(ENABLE_PROFILING)
+ if (opt_prof)
+ jd->flags |= JITDATA_FLAG_INSTRUMENT;
+#endif
+
+ if (opt_verbosecall)
+ jd->flags |= JITDATA_FLAG_VERBOSECALL;
+
+ /* setup code generation stuff */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (!opt_intrp)
+# endif
+ reg_setup(jd);
+#endif
+
+ codegen_setup(jd);
+
+ /* create new method descriptor with additional native parameters */
+
+ md = m->parseddesc;
+
+ /* Set the number of native arguments we need to skip. */
+
+ if (m->flags & ACC_STATIC)
+ skipparams = 2;
+ else
+ skipparams = 1;
+
+ nmd = (methoddesc *) DMNEW(u1, sizeof(methoddesc) - sizeof(typedesc) +
+ md->paramcount * sizeof(typedesc) +
+ skipparams * sizeof(typedesc));
+
+ nmd->paramcount = md->paramcount + skipparams;
+
+ nmd->params = DMNEW(paramdesc, nmd->paramcount);
+
+ nmd->paramtypes[0].type = TYPE_ADR; /* add environment pointer */
+
+ if (m->flags & ACC_STATIC)
+ nmd->paramtypes[1].type = TYPE_ADR; /* add class pointer */
+
+ MCOPY(nmd->paramtypes + skipparams, md->paramtypes, typedesc,
+ md->paramcount);
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (!opt_intrp)
+# endif
+ /* pre-allocate the arguments for the native ABI */
+
+ md_param_alloc_native(nmd);
+#endif
+
+ /* generate the code */
+
+#if defined(ENABLE_JIT)
+# if defined(ENABLE_INTRP)
+ if (opt_intrp)
+ intrp_createnativestub(f, jd, nmd);
+ else
+# endif
+ codegen_emit_stub_native(jd, nmd, f, skipparams);
+#else
+ intrp_createnativestub(f, jd, nmd);
+#endif
+
+ /* reallocate the memory and finish the code generation */
+
+ codegen_finish(jd);
+
+#if defined(ENABLE_STATISTICS)
+ /* must be done after codegen_finish() */
+
+ if (opt_stat)
+ size_stub_native += code->mcodelength;
+#endif
+
+#if !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER)
+ /* disassemble native stub */
+
+ if (opt_DisassembleStubs) {
+# if defined(ENABLE_DEBUG_FILTER)
+ if (m->filtermatches & SHOW_FILTER_FLAG_SHOW_METHOD)
+# endif
+ {
+ codegen_disassemble_stub(m,
+ (u1 *) (ptrint) code->entrypoint,
+ (u1 *) (ptrint) code->entrypoint + (code->mcodelength - jd->cd->dseglen));
+
+ /* show data segment */
+
+ if (opt_showddatasegment)
+ dseg_display(jd);
+ }
+ }
+#endif /* !defined(NDEBUG) && defined(ENABLE_DISASSEMBLER) */
+
+ /* release memory */
+
+ DRELEASE;
+
+ /* return native stub code */
+
+ return code;
+}
+
+
+/**
+ * Free a native stub from memory.
+ *
+ * @param stub Pointer to stub memory.
+ */
+void NativeStub::remove(void* stub)
+{
+ // Pass size 1 to keep the intern function happy.
+ CFREE(stub, 1);
+}
+
+
+// Legacy C interface.
+
+extern "C" {
+ void* CompilerStub_generate(methodinfo* m) { return CompilerStub::generate(m); }
+ void CompilerStub_remove(void* stub) { CompilerStub::remove(stub); }
+
+ void BuiltinStub_generate(methodinfo* m, builtintable_entry* bte) { BuiltinStub::generate(m, bte); }
+
+ codeinfo* NativeStub_generate(methodinfo* m, functionptr f) { return NativeStub::generate(m, f); }
+ void NativeStub_remove(void* stub) { NativeStub::remove(stub); }
+}
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
--- /dev/null
+/* src/vm/jit/stubs.hpp - JIT stubs
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _STUBS_HPP
+#define _STUBS_HPP
+
+#include "config.h"
+
+#include <stdint.h>
+
+#include "vm/method.h"
+
+#include "vm/jit/code.h"
+
+
+#ifdef __cplusplus
+
+/**
+ * Class for compiler stub generation.
+ */
+class CompilerStub {
+public:
+ static inline int get_code_size();
+
+ static void* generate(methodinfo* m);
+ static void remove(void* stub);
+};
+
+
+/**
+ * Class for builtin stub generation.
+ */
+class BuiltinStub {
+public:
+ static void generate(methodinfo* m, builtintable_entry* bte);
+};
+
+
+/**
+ * Class for native stub generation.
+ */
+class NativeStub {
+public:
+ static codeinfo* generate(methodinfo* m, functionptr f);
+ static void remove(void* stub);
+};
+
+
+// Include machine dependent implementation.
+#include "md-stubs.hpp"
+
+#else
+
+// Legacy C interface.
+
+void* CompilerStub_generate(methodinfo* m);
+void* CompilerStub_remove(void* stub);
+void BuiltinStub_generate(methodinfo* m, builtintable_entry* bte);
+codeinfo* NativeStub_generate(methodinfo* m, functionptr f);
+void NativeStub_remove(void* stub);
+
+#endif
+
+#endif // _STUBS_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
\
md-abi.c \
md-abi.h \
+ md-stubs.hpp \
md-trap.h \
md.c \
md.h
/* src/vm/jit/x86_64/codegen.h - code generation macros for x86_64
- 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.
} while (0)
-/* stub defines ***************************************************************/
-
-#define COMPILERSTUB_CODESIZE 8
-
-
/* macros to create code ******************************************************/
#define M_BYTE1(a) \
--- /dev/null
+/* src/vm/jit/x86_64/md-stubs.hpp - x86_64 JIT stubs
+
+ Copyright (C) 2008 Theobroma Systems Ltd.
+
+ This file is part of CACAO.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+*/
+
+
+#ifndef _MD_STUBS_HPP
+#define _MD_STUBS_HPP
+
+#include "config.h"
+
+
+/**
+ * Return the code size of a compiler on a x86_64 architecture.
+ *
+ * @return Code size in bytes.
+ */
+int CompilerStub::get_code_size()
+{
+ return 8;
+}
+
+#endif // _MD_STUBS_HPP
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c++
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
#include "vm/vm.hpp"
#include "vm/jit/asmpart.h"
+#include "vm/jit/stubs.hpp"
/* debugging macros ***********************************************************/
m->stubroutine = intrp_createcompilerstub(m);
else
#endif
- m->stubroutine = codegen_generate_stub_compiler(m);
+ m->stubroutine = CompilerStub_generate(m);
#else
m->stubroutine = intrp_createcompilerstub(m);
#endif
if (!descriptor_params_from_paramtypes(clonedesc, clone->flags))
return false;
- clone->code = codegen_generate_stub_native(clone, BUILTIN_clone);
+ clone->code = NativeStub_generate(clone, BUILTIN_clone);
/* XXX: field: length? */
#include "vm/jit/code.h"
#include "vm/jit/methodheader.h"
+#include "vm/jit/stubs.hpp"
#if !defined(NDEBUG) && defined(ENABLE_INLINING)
if (m->stubroutine) {
if (m->flags & ACC_NATIVE) {
- removenativestub(m->stubroutine);
-
- } else {
- removecompilerstub(m->stubroutine);
+ NativeStub_remove(m->stubroutine);
+ }
+ else {
+ CompilerStub_remove(m->stubroutine);
}
}
}