* src/vm/jit/i386/emit.c: Added emit_patcher_alignment.
* src/vm/jit/x86_64/emit.c: Likewise.
* src/vm/jit/i386/md-trap.h: Added emit_patcher_alignment, defined
ALIGN_PATCHER_TRAP.
* src/vm/jit/x86_64/md-trap.h: Likewise.
* src/vm/jit/patcher-common.cpp (patcher_add_patch_ref): Use
emit_patcher_alignment if requested.
M_ALD_MEM(REG_METHODPTR, TRAP_COUNTDOWN);
}
+/* emit_patcher_alignment ******************************************************
+
+ Emit NOP to ensure placement at an even address.
+
+*******************************************************************************/
+
+void emit_patcher_alignment(codegendata *cd)
+{
+ if ((uintptr_t) cd->mcodeptr & 1)
+ M_NOP;
+}
+
+
/* emit_trap *******************************************************************
Emit a trap instruction and return the original machine code.
(xpc) = (void*) (((uintptr_t) (ra)) - 2); \
} while(0)
+/**
+ * Align traps so they don't cross cache line boundaries.
+ */
+
+#define ALIGN_PATCHER_TRAP
+
+void emit_patcher_alignment(codegendata *cd);
#endif /* _MD_TRAP_H */
#include "codegen.h" /* for PATCHER_NOPS */
#include "md.h"
+#include "trap.hpp"
#include "mm/memory.hpp"
code = jd->code;
patchmpc = cd->mcodeptr - cd->mcodebase;
+#if defined(ALIGN_PATCHER_TRAP)
+ emit_patcher_alignment(cd);
+ patchmpc = cd->mcodeptr - cd->mcodebase;
+#endif
+
#if !defined(NDEBUG)
if (patcher_list_find(code, (void*) (intptr_t) patchmpc) != NULL)
vm_abort("patcher_add_patch_ref: different patchers at same position.");
}
+/* emit_patcher_alignment ******************************************************
+
+ Emit NOP to ensure placement at an even address.
+
+*******************************************************************************/
+
+void emit_patcher_alignment(codegendata *cd)
+{
+ if ((uintptr_t) cd->mcodeptr & 1)
+ M_NOP;
+}
+
+
/* emit_trap *******************************************************************
Emit a trap instruction and return the original machine code.
} while(0)
+/**
+ * Align traps so they don't cross cache line boundaries.
+ */
+
+#define ALIGN_PATCHER_TRAP
+
+void emit_patcher_alignment(codegendata *cd);
+
#endif /* _MD_TRAP_H */