* src/vm/jit/emit-common.h (emit_trap): Added prototype.
* src/vm/jit/alpha/emit.c (emit_patcher_traps): Removed (moved to emit-common).
(emit_trap): Implemented.
* src/vm/jit/arm/emit.c: Likewise.
* src/vm/jit/powerpc/emit.c: Likewise.
* src/vm/jit/s390/emit.c: Likewise.
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: emit.c 8211 2007-07-18 19:52:23Z michi $
+ $Id: emit.c 8260 2007-08-06 12:19:01Z michi $
*/
#include "vm/types.h"
#include <assert.h>
+#include <stdint.h>
#include "md-abi.h"
}
-/* emit_patcher_traps **********************************************************
+/* emit_trap *******************************************************************
- Generates the code for the patcher traps.
+ Emit a trap instruction and return the original machine code.
*******************************************************************************/
-void emit_patcher_traps(jitdata *jd)
+uint32_t emit_trap(codegendata *cd)
{
- codegendata *cd;
- codeinfo *code;
- patchref_t *pr;
- u1 *savedmcodeptr;
- u1 *tmpmcodeptr;
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-
- /* generate patcher traps code */
+ uint32_t mcode;
- for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) {
+ /* Get machine code which is patched back in later. The
+ trap is 1 instruction word long. */
- /* Get machine code which is patched back in later. The
- trap is 1 instruction word long. */
+ mcode = *((u4 *) cd->mcodeptr);
- tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
- pr->mcode = *((u4 *) tmpmcodeptr);
+ /* Destination register must not be REG_ZERO, because then no
+ SIGSEGV is thrown. */
+ M_ALD_INTERN(REG_RESULT, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
- /* Patch in the trap to call the signal handler (done at
- compile time). */
-
- savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */
- cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */
-
- M_ALD_INTERN(REG_RESULT, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
-
- cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */
- }
+ return mcode;
}
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
}
-/* emit_patcher_traps **********************************************************
+/* emit_trap *******************************************************************
- Generates the code for the patcher traps.
+ Emit a trap instruction and return the original machine code.
*******************************************************************************/
-void emit_patcher_traps(jitdata *jd)
+uint32_t emit_trap(codegendata *cd)
{
- codegendata *cd;
- codeinfo *code;
- patchref_t *pr;
- u1 *savedmcodeptr;
- u1 *tmpmcodeptr;
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-
- /* generate patcher traps code */
+ uint32_t mcode;
- for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) {
+ /* Get machine code which is patched back in later. The
+ trap is 1 instruction word long. */
- /* Get machine code which is patched back in later. The
- trap is 1 instruction word long. */
+ mcode = *((u4 *) cd->mcodeptr);
- tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
+ M_TRAP(0, EXCEPTION_HARDWARE_PATCHER);
- pr->mcode = *((u4 *) tmpmcodeptr);
-
- /* Patch in the trap to call the signal handler (done at
- compile time). */
-
- savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */
- cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */
-
- M_TRAP(0, EXCEPTION_HARDWARE_PATCHER);
-
- cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */
- }
+ return mcode;
}
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "vm/types.h"
#include "vm/jit/emit-common.h"
#include "vm/jit/jit.h"
+#include "vm/jit/patcher-common.h"
#include "vmcore/options.h"
#include "vmcore/statistics.h"
}
+/* emit_patcher_traps **********************************************************
+
+ Generates the code for the patcher traps.
+
+*******************************************************************************/
+
+void emit_patcher_traps(jitdata *jd)
+{
+ codegendata *cd;
+ codeinfo *code;
+ patchref_t *pr;
+ u1 *savedmcodeptr;
+ u1 *tmpmcodeptr;
+ uint32_t mcode;
+
+ /* get required compiler data */
+
+ cd = jd->cd;
+ code = jd->code;
+
+ /* generate patcher traps code */
+
+ for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) {
+
+ /* Calculate the patch position where the original machine
+ code is located and the trap should be placed. */
+
+ tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
+
+ /* Patch in the trap to call the signal handler (done at
+ compile time). */
+
+ savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */
+ cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */
+
+ mcode = emit_trap(cd);
+
+ cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */
+
+ /* Remember the original machine code which is patched
+ back in later (done at runtime). */
+
+ pr->mcode = mcode;
+ }
+}
+
+
/* emit_bccz *******************************************************************
Emit conditional and unconditional branch instructions on integer
void emit_nullpointer_check(codegendata *cd, instruction *iptr, s4 reg);
void emit_exception_check(codegendata *cd, instruction *iptr);
+uint32_t emit_trap(codegendata *cd);
+
void emit_patcher_stubs(jitdata *jd);
void emit_patcher_traps(jitdata *jd);
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: emit.c 8216 2007-07-19 13:51:21Z michi $
+ $Id: emit.c 8260 2007-08-06 12:19:01Z michi $
*/
#include "vm/jit/dseg.h"
#include "vm/jit/emit-common.h"
#include "vm/jit/jit.h"
-#include "vm/jit/patcher-common.h"
#include "vm/jit/replace.h"
#include "vmcore/options.h"
}
-/* emit_patcher_traps **********************************************************
+/* emit_trap *******************************************************************
- Generates the code for the patcher stubs.
+ Emit a trap instruction and return the original machine code.
*******************************************************************************/
-void emit_patcher_traps(jitdata *jd)
+uint32_t emit_trap(codegendata *cd)
{
- codegendata *cd;
- codeinfo *code;
- patchref_t *pr;
- u1 *savedmcodeptr;
- u1 *tmpmcodeptr;
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-
- /* generate code patching stub call code */
+ uint32_t mcode;
- for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) {
+ /* Get machine code which is patched back in later. The
+ trap is 1 instruction word long. */
- /* Get machine code which is patched back in later. The
- trap is 1 instruction word long. */
+ mcode = *((u4 *) cd->mcodeptr);
- tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
+ M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
- pr->mcode = *((u4 *) tmpmcodeptr);
-
- /* Patch in the trap to call the signal handler (done at
- compile time). */
-
- savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */
- cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */
-
- M_ALD_INTERN(REG_ZERO, REG_ZERO, EXCEPTION_HARDWARE_PATCHER);
-
- cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */
- }
+ return mcode;
}
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
- $Id: emit.c 8251 2007-08-01 15:26:59Z pm $
+ $Id: emit.c 8260 2007-08-06 12:19:01Z michi $
*/
#include "config.h"
#include <assert.h>
+#include <stdint.h>
#include "mm/memory.h"
#if defined(ENABLE_THREADS)
}
}
-/* emit_patcher_traps **********************************************************
+/* emit_trap *******************************************************************
- Generates the code for the patcher traps.
+ Emit a trap instruction and return the original machine code.
*******************************************************************************/
-void emit_patcher_traps(jitdata *jd)
+uint32_t emit_trap(codegendata *cd)
{
- codegendata *cd;
- codeinfo *code;
- patchref_t *pr;
- u1 *savedmcodeptr;
- u1 *tmpmcodeptr;
-
- /* get required compiler data */
-
- cd = jd->cd;
- code = jd->code;
-
- /* generate patcher traps code */
-
- for (pr = list_first_unsynced(code->patchers); pr != NULL; pr = list_next_unsynced(code->patchers, pr)) {
+ uint32_t mcode;
- /* Get machine code which is patched back in later. The
- trap is 2 bytes long. */
+ /* Get machine code which is patched back in later. The
+ trap is 2 bytes long. */
- tmpmcodeptr = (u1 *) (cd->mcodebase + pr->mpc);
- pr->mcode = *((u2 *) tmpmcodeptr);
+ mcode = *((u2 *) cd->mcodeptr);
- /* Patch in the trap to call the signal handler (done at
- compile time). */
+ M_ILL(EXCEPTION_HARDWARE_PATCHER);
- savedmcodeptr = cd->mcodeptr; /* save current mcodeptr */
- cd->mcodeptr = tmpmcodeptr; /* set mcodeptr to patch position */
-
- M_ILL(EXCEPTION_HARDWARE_PATCHER);
-
- cd->mcodeptr = savedmcodeptr; /* restore the current mcodeptr */
- }
+ return mcode;
}
/* emit_replacement_stubs ******************************************************