* src/vm/jit/powerpc/patcher.c (patcher_get_putfield): Fixed severe bug for
authormichi <none@none>
Fri, 10 Aug 2007 10:46:17 +0000 (10:46 +0000)
committermichi <none@none>
Fri, 10 Aug 2007 10:46:17 +0000 (10:46 +0000)
unalligned long field offsets.

* src/vmcore/linker.c [__POWERPC__ && __DARWIN__]: Long fields are 4-byte
alligned in structs.

* src/vm/jit/patcher-common.c [TRACE_PATCHER]: Left patcher trace code hanging
around, might come handy again.

src/vm/jit/patcher-common.c
src/vm/jit/powerpc/patcher.c
src/vmcore/linker.c

index 5823054be89a431370f87a1cb1e500149af77a84..30c99e37fb9ed45560b2ee02d71aad2f1f6cede1 100644 (file)
@@ -188,12 +188,24 @@ void patcher_add_patch_ref(jitdata *jd, functionptr patcher, voidptr ref,
 
 *******************************************************************************/
 
+/*#define TRACE_PATCHER*/
+
+#ifdef TRACE_PATCHER
+/* XXX this indent is not thread safe! */
+/* XXX if you want it thread safe, place patcher_depth in threadobject! */
+static int patcher_depth = 0;
+# define TRACE_PATCHER_INDENT for (i=0; i<patcher_depth; i++) printf("\t")
+#endif
+
 java_objectheader *patcher_handler(u1 *pc)
 {
        codeinfo          *code;
        patchref_t        *pr;
        bool               result;
        java_objectheader *e;
+#ifdef TRACE_PATCHER
+       int                i;
+#endif
 
        /* define the patcher function */
 
@@ -221,6 +233,14 @@ java_objectheader *patcher_handler(u1 *pc)
                return NULL;
        }
 
+#ifdef TRACE_PATCHER
+       TRACE_PATCHER_INDENT; printf("patching in "); method_print(code->m); printf("\n");
+       TRACE_PATCHER_INDENT; printf("\texception program counter = %p\n", (void *) pr->mpc);
+       TRACE_PATCHER_INDENT; printf("\tmcodes before = "); for (i=0; i<5; i++) printf("0x%08x ", *((u4 *) pr->mpc + i)); printf("\n");
+       patcher_depth++;
+       assert(patcher_depth > 0);
+#endif
+
        /* cast the passed function to a patcher function */
 
        patcher_function = (bool (*)(patchref_t *)) (ptrint) pr->patcher;
@@ -229,6 +249,15 @@ java_objectheader *patcher_handler(u1 *pc)
 
        result = (patcher_function)(pr);
 
+#ifdef TRACE_PATCHER
+       assert(patcher_depth > 0);
+       patcher_depth--;
+       TRACE_PATCHER_INDENT; printf("\tmcodes after  = "); for (i=0; i<5; i++) printf("0x%08x ", *((u4 *) pr->mpc + i)); printf("\n");
+       if (result == false) {
+               TRACE_PATCHER_INDENT; printf("\tPATCHER EXCEPTION!\n");
+       }
+#endif
+
        /* check for return value and exit accordingly */
 
        if (result == false) {
index 653b04f4f2b1b72d0cdf64a619104e9696eacdb8..2bdbf42aa61c9c063c4dc34b24c0e1ae7abddbf4 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: patcher.c 8268 2007-08-07 13:24:43Z twisti $
+   $Id: patcher.c 8286 2007-08-10 10:46:17Z michi $
 
 */
 
@@ -390,11 +390,13 @@ bool patcher_get_putfield(patchref_t *pr)
                disp = *((u4 *) (ra + 0 * 4));
 
                if (disp == 4) {
+                       *((u4 *) (ra + 0 * 4)) &= 0xffff0000;
                        *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
                        *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
                }
                else {
                        *((u4 *) (ra + 0 * 4)) |= (s2) ((fi->offset + 0) & 0x0000ffff);
+                       *((u4 *) (ra + 1 * 4)) &= 0xffff0000;
                        *((u4 *) (ra + 1 * 4)) |= (s2) ((fi->offset + 4) & 0x0000ffff);
                }
        }
index af1a2ac43a3028938c74b125a9477034562ec077..1181b4aed680bd4d4881bf784c939007a4f0c742 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: linker.c 8277 2007-08-08 16:42:11Z michi $
+   $Id: linker.c 8286 2007-08-10 10:46:17Z michi $
 
 */
 
@@ -115,7 +115,7 @@ bool linker_init(void)
        /* Check for if alignment for long and double matches what we
           assume for the current architecture. */
 
-#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__))
+#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) || (defined(__POWERPC__) && defined(__DARWIN__))
        if (OFFSET(dummy_alignment_long_t, l) != 4)
                vm_abort("linker_init: long alignment is different from what assumed: %d != %d",
                                 OFFSET(dummy_alignment_long_t, l), 4);
@@ -882,7 +882,7 @@ static classinfo *link_class_intern(classinfo *c)
                if (!(f->flags & ACC_STATIC)) {
                        dsize = descriptor_typesize(f->parseddesc);
 
-#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__))
+#if defined(__I386__) || (defined(__ARM__) && !defined(__ARM_EABI__)) || (defined(__POWERPC__) && defined(__DARWIN__))
                        /* On i386 and ARM we align double and s8 fields to
                           4-bytes.  This matches what GCC does for struct
                           members. We must do the same as gcc here because the