#define PATCHER_TRACE
+
+/* patcher_patch_code **********************************************************
+
+ Just patches back the original machine code.
+
+*******************************************************************************/
+
+void patcher_patch_code(patchref_t *pr)
+{
+ PATCH_BACK_ORIGINAL_MCODE;
+}
+
+
/* patcher_get_putstatic *******************************************************
Machine code:
/* patch correct offset */
if (fi->type == TYPE_LNG) {
- assert(N_VALID_DISP(fi->offset + 4));
+ ASSERT_VALID_DISP(fi->offset + 4);
/* 2 RX operations, for 2 words; each already contains a 0 or 4 offset. */
- *((u4 *) ra ) |= (fi->offset + (*((u4 *) ra) & 0xF));
- ra += 4;
- *((u4 *) ra ) |= (fi->offset + (*((u4 *) ra) & 0xF));
+ N_RX_SET_DISP(ra, fi->offset + N_RX_GET_DISP(ra));
+ ra += SZ_RX;
+ N_RX_SET_DISP(ra, fi->offset + N_RX_GET_DISP(ra));
} else {
- assert(N_VALID_DISP(fi->offset));
+ ASSERT_VALID_DISP(fi->offset);
/* 1 RX operation */
- *((u4 *) ra) |= fi->offset;
+ N_RX_SET_DISP(ra, fi->offset);
}
return true;
off = (s4) (OFFSET(vftbl_t, table[0]) +
sizeof(methodptr) * m->vftblindex);
- assert(N_VALID_DISP(off));
+ ASSERT_VALID_DISP(off);
- *((s4 *)(ra + 4)) |= off;
+ N_RX_SET_DISP(ra + SZ_RX, off);
return true;
}
off =
(s4) (sizeof(methodptr) * (m - m->class->methods));
+
ASSERT_VALID_DISP(off);
/* patch them */
- *((s4 *)(ra + 4)) |= (u2)idx;
- *((s4 *)(ra + 4 + 4 + 4)) |= off;
+ N_RI_SET_IMM(ra + SZ_L, idx);
+ N_RX_SET_DISP(ra + SZ_L + SZ_LHI + SZ_L, off);
return true;
}
/* From here, split your editor and open codegen.c */
- switch (*(ra + 1) >> 4) {
+ switch (N_RX_GET_REG(ra)) {
case REG_ITMP1:
/* First M_ALD is into ITMP1 */
/* INSTANCEOF code */
- *(u4 *)(ra + SZ_L + SZ_L) |= (u2)(s2)(- c->index);
- *(u4 *)(ra + SZ_L + SZ_L + SZ_AHI + SZ_BRC) |=
- (u2)(s2)(OFFSET(vftbl_t, interfacetable[0]) -
- c->index * sizeof(methodptr*));
-
+ N_RI_SET_IMM(ra + SZ_L + SZ_L, - c->index);
+ N_RI_SET_IMM(
+ ra + SZ_L + SZ_L + SZ_AHI + SZ_BRC,
+ (int16_t)(OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*))
+ );
break;
case REG_ITMP2:
/* First M_ALD is into ITMP2 */
/* CHECKCAST code */
- *(u4 *)(ra + SZ_L + SZ_L) |= (u2)(s2)(- c->index);
- *(u4 *)(ra + SZ_L + SZ_L + SZ_AHI + SZ_BRC + SZ_ILL) |=
- (u2)(s2)(OFFSET(vftbl_t, interfacetable[0]) -
- c->index * sizeof(methodptr*));
-
+ N_RI_SET_IMM(ra + SZ_L + SZ_L, - c->index);
+ N_RI_SET_IMM(
+ ra + SZ_L + SZ_L + SZ_AHI + SZ_BRC + SZ_ILL,
+ (int16_t)(OFFSET(vftbl_t, interfacetable[0]) - c->index * sizeof(methodptr*))
+ );
break;
default:
return true;
}
-/* patcher_clinit **************************************************************
-
- May be used for GET/PUTSTATIC and in native stub.
-
- Machine code:
-
-*******************************************************************************/
-
-bool patcher_clinit(patchref_t *pr)
-{
- classinfo *c;
-
- PATCHER_TRACE;
-
- /* get stuff from the stack */
-
- c = (classinfo *)pr->ref;
-
- /* check if the class is initialized */
-
- if (!(c->state & CLASS_INITIALIZED))
- if (!initialize_class(c))
- return false;
-
- /* patch back original code */
-
- PATCH_BACK_ORIGINAL_MCODE;
-
- return true;
-}
-
-
-/* patcher_athrow_areturn ******************************************************
-
- Machine code:
-
- <patched call position>
-
-*******************************************************************************/
-
-#ifdef ENABLE_VERIFIER
-bool patcher_athrow_areturn(patchref_t *pr)
-{
- unresolved_class *uc;
-
- PATCHER_TRACE;
-
- /* get stuff from the stack */
-
- uc = (unresolved_class *) pr->ref;
-
- /* resolve the class and check subtype constraints */
-
- if (!resolve_class_eager_no_access_check(uc))
- return false;
-
- /* patch back original code */
-
- PATCH_BACK_ORIGINAL_MCODE;
-
- return true;
-}
-#endif /* ENABLE_VERIFIER */
-
-
-/* patcher_resolve_native ******************************************************
-
-*******************************************************************************/
-
-#if !defined(WITH_STATIC_CLASSPATH)
-bool patcher_resolve_native_function(patchref_t *pr)
-{
- methodinfo *m;
- u1 *datap;
- functionptr f;
-
- PATCHER_TRACE;
-
- /* get stuff from the stack */
-
- m = (methodinfo *) pr->ref;
- datap = (u1 *) pr->datap;
-
- /* resolve native function */
-
- if (!(f = native_resolve_function(m)))
- return false;
-
- PATCH_BACK_ORIGINAL_MCODE;
-
- /* patch native function pointer */
-
- *((ptrint *) datap) = (ptrint) f;
-
- return true;
-}
-#endif /* !defined(WITH_STATIC_CLASSPATH) */
/*
* These are local overrides for various environment variables in Emacs.