X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fjit%2Fs390%2Fpatcher.c;h=af32a263e2e35fc16c82c9854cce64348b79c44b;hb=5af9d866895ef5f354f3e35595fc4a859f4520ee;hp=f93f5868611bbf29eaf1881978e95b84266fee1c;hpb=0c006b0b5ce06dfa211b305bdc0bf1672b77801b;p=cacao.git diff --git a/src/vm/jit/s390/patcher.c b/src/vm/jit/s390/patcher.c index f93f58686..af32a263e 100644 --- a/src/vm/jit/s390/patcher.c +++ b/src/vm/jit/s390/patcher.c @@ -57,6 +57,19 @@ #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: @@ -137,15 +150,15 @@ bool patcher_get_putfield(patchref_t *pr) /* 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; @@ -224,9 +237,9 @@ bool patcher_invokevirtual(patchref_t *pr) 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; } @@ -277,12 +290,13 @@ bool patcher_invokeinterface(patchref_t *pr) 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; } @@ -430,27 +444,27 @@ bool patcher_checkcast_instanceof_interface(patchref_t *pr) /* 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: @@ -461,102 +475,6 @@ bool patcher_checkcast_instanceof_interface(patchref_t *pr) return true; } -/* patcher_initialize_class **************************************************** - - May be used for GET/PUTSTATIC and in native stub. - - Machine code: - -*******************************************************************************/ - -bool patcher_initialize_class(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: - - - -*******************************************************************************/ - -#ifdef ENABLE_VERIFIER -bool patcher_resolve_class(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 ****************************************************** - -*******************************************************************************/ - -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; -} - /* * These are local overrides for various environment variables in Emacs.