#include "vm/types.h"
#include "vm/jit/i386/codegen.h"
+#include "vm/jit/i386/md.h"
-#include "mm/memory.h"
+#include "mm/memory.hpp"
-#include "native/native.h"
+#include "native/native.hpp"
-#include "vm/builtin.h"
-#include "vm/exceptions.h"
-#include "vm/initialize.h"
+#include "vm/jit/builtin.hpp"
+#include "vm/class.hpp"
+#include "vm/field.hpp"
+#include "vm/initialize.hpp"
+#include "vm/options.h"
+#include "vm/references.h"
+#include "vm/resolve.hpp"
-#include "vm/jit/patcher-common.h"
-#include "vm/jit/stacktrace.h"
+#include "vm/jit/patcher-common.hpp"
-#include "vmcore/class.h"
-#include "vmcore/field.h"
-#include "vmcore/options.h"
-#include "vm/resolve.h"
-#include "vmcore/references.h"
-
-#define PATCH_BACK_ORIGINAL_MCODE *((u2 *) pr->mpc) = (u2) pr->mcode
+#define PATCH_BACK_ORIGINAL_MCODE \
+ do { \
+ *((uint16_t*) pr->mpc) = (uint16_t) pr->mcode; \
+ md_icacheflush((void*) pr->mpc, PATCHER_CALL_SIZE); \
+ } while (0)
/* patcher_patch_code **********************************************************
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch the field value's address */
*((intptr_t *) (ra + 1)) = (intptr_t) fi->value;
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch the field's offset */
*((u4 *) (ra + 2)) = (u4) (fi->offset);
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch the field's offset */
if (fi->type != TYPE_LNG) {
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch the field's offset */
if (!IS_2_WORD_TYPE(fi->type)) {
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch the classinfo pointer */
*((ptrint *) (ra + 1)) = (ptrint) c;
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch the classinfo pointer */
*((ptrint *) (ra + 7 + 4)) = (ptrint) c;
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch the classinfo pointer */
*((ptrint *) (ra + 4)) = (ptrint) c;
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch stubroutine */
*((ptrint *) (ra + 1)) = (ptrint) m->stubroutine;
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch vftbl index */
*((s4 *) (ra + 2 + 2)) = (s4) (OFFSET(vftbl_t, table[0]) +
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch interfacetable index */
*((s4 *) (ra + 2 + 2)) = (s4) (OFFSET(vftbl_t, interfacetable[0]) -
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch class flags */
*((s4 *) (ra + 1)) = (s4) c->flags;
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch super class index */
*((s4 *) (ra + 6 + 2)) = (s4) c->index;
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch super class index */
*((s4 *) (ra + 6 + 2)) = (s4) c->index;
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch super class' vftbl */
*((ptrint *) (ra + 1)) = (ptrint) c->vftbl;
PATCH_BACK_ORIGINAL_MCODE;
- /* if we show disassembly, we have to skip the nop's */
-
- if (opt_shownops)
- ra = ra + PATCHER_CALL_SIZE;
-
/* patch super class' vftbl */
*((ptrint *) (ra + 1)) = (ptrint) c->vftbl;