* src/vm/jit/md.h: Removed.
authorChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 5 Nov 2007 12:58:22 +0000 (13:58 +0100)
committerChristian Thalinger <twisti@complang.tuwien.ac.at>
Mon, 5 Nov 2007 12:58:22 +0000 (13:58 +0100)
* src/vm/jit/Makefile.am (noinst_HEADERS): Removed md.h.

* src/vm/jit/asmpart.h (md_asm_codegen_get_pv_from_pc): Added
temporarily.

* src/vm/jit/codegen-common.c (md.h): Added.
(vm/jit/md.h): Removed.
(md_asm_codegen_get_pv_from_pc): Added temporarily.

* src/vm/jit/codegen-common.h (md_codegen_get_pv_from_pc): Removed.

* src/vm/jit/jit.c (stdint.h): Added.
(md.h): Likewise.

* src/vm/jit/patcher-common.c (md.h): Added.
(vm/jit/md.h): Removed.
* src/vm/jit/replace.c: Likewise.

* src/vm/jit/stacktrace.c (md.h): Added.
* src/vm/jit/stacktrace.h (md_stacktrace_get_returnaddress): Removed.

* src/vm/jit/alpha/asmpart.S,
src/vm/jit/alpha/linux/md-os.c,
src/vm/jit/alpha/md.c,
src/vm/jit/alpha/md.h,
src/vm/jit/alpha/patcher.c,
src/vm/jit/arm/asmpart.S,
src/vm/jit/arm/codegen.c,
src/vm/jit/arm/md.c,
src/vm/jit/arm/md.h,
src/vm/jit/arm/patcher.c,
src/vm/jit/i386/linux/md-os.c,
src/vm/jit/i386/md.c,
src/vm/jit/i386/md.h,
src/vm/jit/m68k/asmpart.S,
src/vm/jit/m68k/codegen.c,
src/vm/jit/m68k/md.c,
src/vm/jit/m68k/md.h,
src/vm/jit/m68k/patcher.c,
src/vm/jit/mips/asmpart.S,
src/vm/jit/mips/codegen.c,
src/vm/jit/mips/linux/md-os.c,
src/vm/jit/mips/md.c,
src/vm/jit/mips/md.h,
src/vm/jit/mips/patcher.c,
src/vm/jit/powerpc/asmpart.S,
src/vm/jit/powerpc/codegen.c,
src/vm/jit/powerpc/darwin/md-asm.h,
src/vm/jit/powerpc/linux/md-os.c,
src/vm/jit/powerpc/md.c,
src/vm/jit/powerpc/md.h,
src/vm/jit/powerpc/patcher.c,
src/vm/jit/powerpc64/asmpart.S,
src/vm/jit/powerpc64/codegen.c,
src/vm/jit/powerpc64/linux/md-os.c,
src/vm/jit/powerpc64/md.c,
src/vm/jit/powerpc64/md.h,
src/vm/jit/powerpc64/patcher.c,
src/vm/jit/s390/md.c,
src/vm/jit/s390/md.h,
src/vm/jit/sparc64/md.c,
src/vm/jit/sparc64/md.h,
src/vm/jit/sparc64/patcher.c,
src/vm/jit/x86_64/linux/md-os.c,
src/vm/jit/x86_64/md.c,
src/vm/jit/x86_64/md.h
(md_stacktrace_get_returnaddress): Made inline function.
(md_codegen_get_pv_from_pc): Likewise.
(md_cacheflush): Likewise.
(md_icacheflush): Likewise.
(md_dcacheflush): Likewise.

55 files changed:
src/vm/jit/Makefile.am
src/vm/jit/alpha/asmpart.S
src/vm/jit/alpha/linux/md-os.c
src/vm/jit/alpha/md.c
src/vm/jit/alpha/md.h
src/vm/jit/alpha/patcher.c
src/vm/jit/arm/asmpart.S
src/vm/jit/arm/codegen.c
src/vm/jit/arm/md.c
src/vm/jit/arm/md.h [new file with mode: 0644]
src/vm/jit/arm/patcher.c
src/vm/jit/asmpart.h
src/vm/jit/codegen-common.c
src/vm/jit/codegen-common.h
src/vm/jit/i386/linux/md-os.c
src/vm/jit/i386/md.c
src/vm/jit/i386/md.h [new file with mode: 0644]
src/vm/jit/jit.c
src/vm/jit/m68k/asmpart.S
src/vm/jit/m68k/codegen.c
src/vm/jit/m68k/md.c
src/vm/jit/m68k/md.h [new file with mode: 0644]
src/vm/jit/m68k/patcher.c
src/vm/jit/md.h [deleted file]
src/vm/jit/mips/asmpart.S
src/vm/jit/mips/codegen.c
src/vm/jit/mips/linux/md-os.c
src/vm/jit/mips/md.c
src/vm/jit/mips/md.h [new file with mode: 0644]
src/vm/jit/mips/patcher.c
src/vm/jit/patcher-common.c
src/vm/jit/powerpc/asmpart.S
src/vm/jit/powerpc/codegen.c
src/vm/jit/powerpc/darwin/md-asm.h
src/vm/jit/powerpc/linux/md-os.c
src/vm/jit/powerpc/md.c
src/vm/jit/powerpc/md.h [new file with mode: 0644]
src/vm/jit/powerpc/patcher.c
src/vm/jit/powerpc64/asmpart.S
src/vm/jit/powerpc64/codegen.c
src/vm/jit/powerpc64/linux/md-os.c
src/vm/jit/powerpc64/md.c
src/vm/jit/powerpc64/md.h [new file with mode: 0644]
src/vm/jit/powerpc64/patcher.c
src/vm/jit/replace.c
src/vm/jit/s390/md.c
src/vm/jit/s390/md.h [new file with mode: 0644]
src/vm/jit/sparc64/md.c
src/vm/jit/sparc64/md.h [new file with mode: 0644]
src/vm/jit/sparc64/patcher.c
src/vm/jit/stacktrace.c
src/vm/jit/stacktrace.h
src/vm/jit/x86_64/linux/md-os.c
src/vm/jit/x86_64/md.c
src/vm/jit/x86_64/md.h [new file with mode: 0644]

index 4e6da4e88583155cc311b201e700580da244f65a..51956cdc2bf45f1f4518c4f6e0e9bac592842ed8 100644 (file)
@@ -131,7 +131,6 @@ noinst_HEADERS = \
        abi.h \
        abi-asm.h \
        asmpart.h \
-       md.h \
        methodheader.h
 
 noinst_LTLIBRARIES = \
index 41981513db6c6c053b79bbf38cc9063f7e6e7ce0..4fced813c98bc3a74840e3b01d2394d8d809c8bb 100644 (file)
@@ -190,7 +190,7 @@ L_asm_handle_exception_stack_loop:
 L_asm_handle_exception_load_gp:
        ldgp    gp,0(ra)                    /* load gp                            */
 
-       jsr     ra,md_codegen_get_pv_from_pc/* get PV from RA                     */
+       jsr     ra,md_asm_codegen_get_pv_from_pc /* get PV from RA                */
        stq     v0,2*8(sp)                  /* save PV                            */
 
        ldq     a0,0*8(sp)                  /* pass xptr                          */
index 64179d8aaeb2058a3c22f3178c6d83fdf91ba85b..006c7009d8d645edc259905c3b1870bc1ee16ea1 100644 (file)
@@ -34,6 +34,7 @@
 #include "vm/types.h"
 
 #include "vm/jit/alpha/codegen.h"
+#include "vm/jit/alpha/md.h"
 #include "vm/jit/alpha/md-abi.h"
 
 #if defined(ENABLE_THREADS)
index cc15090d287cca6f2cc61278356e6ae4aacf5f1e..125ff089211127a14b9eeb2db0d541ecc0e209fd 100644 (file)
@@ -38,17 +38,13 @@ extern unsigned long ieee_get_fp_control();
 extern void ieee_set_fp_control(unsigned long fp_control);
 #endif
 
-#include "vm/types.h"
-
 #include "vm/jit/alpha/codegen.h"
-#include "vm/jit/alpha/md-abi.h"
+#include "vm/jit/alpha/md.h"
 
 #include "vm/exceptions.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
 #include "vm/jit/jit.h"
-#include "vm/jit/md.h"
 
 
 /* global variables ***********************************************************/
@@ -102,25 +98,6 @@ void md_init(void)
 }
 
 
-/* md_stacktrace_get_returnaddress *********************************************
-
-   Returns the return address of the current stackframe, specified by
-   the passed stack pointer and the stack frame size.
-
-*******************************************************************************/
-
-u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
-{
-       u1 *ra;
-
-       /* on Alpha the return address is located on the top of the stackframe */
-
-       ra = *((u1 **) (sp + framesize - SIZEOF_VOID_P));
-
-       return ra;
-}
-
-
 /* md_jit_method_patch_address *************************************************
 
    Gets the patch address of the currently compiled method. The offset
@@ -216,104 +193,6 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
 }
 
 
-/* md_codegen_get_pv_from_pc ***************************************************
-
-   Machine code:
-
-   6b5b4000    jsr     (pv)
-   277afffe    ldah    pv,-2(ra)
-   237ba61c    lda     pv,-23012(pv)
-
-*******************************************************************************/
-
-u1 *md_codegen_get_pv_from_pc(u1 *ra)
-{
-       uint32_t *pc;
-       uint32_t  mcode;
-       int       opcode;
-       int32_t   disp;
-       void     *pv;
-
-       pc = (uint32_t *) ra;
-
-       /* Get first instruction word after jump. */
-
-       mcode = pc[0];
-
-       /* Get opcode and displacement. */
-
-       opcode = M_MEM_GET_Opcode(mcode);
-       disp   = M_MEM_GET_Memory_disp(mcode);
-
-       /* Check for short or long load (2 instructions). */
-
-       switch (opcode) {
-       case 0x08: /* LDA: TODO use define */
-               assert((mcode >> 16) == 0x237a);
-
-               pv = ((uint8_t *) pc) + disp;
-               break;
-
-       case 0x09: /* LDAH: TODO use define */
-               pv = ((uint8_t *) pc) + (disp << 16);
-
-               /* Get displacement of second instruction (LDA). */
-
-               mcode = pc[1];
-
-               assert((mcode >> 16) == 0x237b);
-
-               disp = M_MEM_GET_Memory_disp(mcode);
-
-               pv = ((uint8_t *) pv) + disp;
-               break;
-
-       default:
-               vm_abort_disassemble(pc, 2, "md_codegen_get_pv_from_pc: unknown instruction %x", mcode);
-               return NULL;
-       }
-
-       return pv;
-}
-
-
-/* md_cacheflush ***************************************************************
-
-   Calls the system's function to flush the instruction and data
-   cache.
-
-*******************************************************************************/
-
-void md_cacheflush(u1 *addr, s4 nbytes)
-{
-       asm_cacheflush(addr, nbytes);
-}
-
-
-/* md_icacheflush **************************************************************
-
-   Calls the system's function to flush the instruction cache.
-
-*******************************************************************************/
-
-void md_icacheflush(u1 *addr, s4 nbytes)
-{
-       asm_cacheflush(addr, nbytes);
-}
-
-
-/* md_dcacheflush **************************************************************
-
-   Calls the system's function to flush the data cache.
-
-*******************************************************************************/
-
-void md_dcacheflush(u1 *addr, s4 nbytes)
-{
-       /* do nothing */
-}
-
-
 /* md_patch_replacement_point **************************************************
 
    Patch the given replacement point.
index 40908469833aab177e6788f5ecafe88c1bafb65f..4899d8f9ffd15d347773cd52eb5a4575ff4f8d57 100644 (file)
@@ -1,6 +1,6 @@
 /* src/vm/jit/alpha/md.h - machine dependent Alpha functions
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
    J. Wenninger, Institut f. Computersprachen - TU Wien
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Contact: cacao@cacaojvm.org
+*/
 
-   Authors: Christian Thalinger
 
-   Changes:
+#ifndef _VM_JIT_ALPHA_MD_H
+#define _VM_JIT_ALPHA_MD_H
 
-*/
+#include "config.h"
 
+#include <assert.h>
+#include <stdint.h>
 
-#ifndef _MD_H
-#define _MD_H
+#include "vm/jit/alpha/codegen.h"
 
-#include "config.h"
 #include "vm/global.h"
+#include "vm/vm.h"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/codegen-common.h"
 
 
 /* global variables ***********************************************************/
 
 extern bool has_ext_instr_set;
 
-/* function prototypes ********************************************************/
 
-#endif /* _MD_H_ */
+/* inline functions ***********************************************************/
+
+/* md_stacktrace_get_returnaddress *********************************************
+
+   Returns the return address of the current stackframe, specified by
+   the passed stack pointer and the stack frame size.
+
+*******************************************************************************/
+
+inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
+{
+       void *ra;
+
+       /* On Alpha the return address is located on the top of the
+          stackframe. */
+
+       ra = *((void **) (((uintptr_t) sp) + stackframesize - SIZEOF_VOID_P));
+
+       return ra;
+}
+
+
+/* md_codegen_get_pv_from_pc ***************************************************
+
+   Machine code:
+
+   6b5b4000    jsr     (pv)
+   277afffe    ldah    pv,-2(ra)
+   237ba61c    lda     pv,-23012(pv)
+
+*******************************************************************************/
+
+inline static void *md_codegen_get_pv_from_pc(void *ra)
+{
+       uint32_t *pc;
+       uint32_t  mcode;
+       int       opcode;
+       int32_t   disp;
+       void     *pv;
+
+       pc = (uint32_t *) ra;
+
+       /* Get first instruction word after jump. */
+
+       mcode = pc[0];
+
+       /* Get opcode and displacement. */
+
+       opcode = M_MEM_GET_Opcode(mcode);
+       disp   = M_MEM_GET_Memory_disp(mcode);
+
+       /* Check for short or long load (2 instructions). */
+
+       switch (opcode) {
+       case 0x08: /* LDA: TODO use define */
+               assert((mcode >> 16) == 0x237a);
+
+               pv = ((uint8_t *) pc) + disp;
+               break;
+
+       case 0x09: /* LDAH: TODO use define */
+               pv = ((uint8_t *) pc) + (disp << 16);
+
+               /* Get displacement of second instruction (LDA). */
+
+               mcode = pc[1];
+
+               assert((mcode >> 16) == 0x237b);
+
+               disp = M_MEM_GET_Memory_disp(mcode);
+
+               pv = ((uint8_t *) pv) + disp;
+               break;
+
+       default:
+               vm_abort_disassemble(pc, 2, "md_codegen_get_pv_from_pc: unknown instruction %x", mcode);
+               return NULL;
+       }
+
+       return pv;
+}
+
+
+/* md_cacheflush ***************************************************************
+
+   Calls the system's function to flush the instruction and data
+   cache.
+
+*******************************************************************************/
+
+inline static void md_cacheflush(void *addr, int nbytes)
+{
+       asm_cacheflush(addr, nbytes);
+}
+
+
+/* md_icacheflush **************************************************************
+
+   Calls the system's function to flush the instruction cache.
+
+*******************************************************************************/
+
+inline static void md_icacheflush(void *addr, int nbytes)
+{
+       asm_cacheflush(addr, nbytes);
+}
+
+
+/* md_dcacheflush **************************************************************
+
+   Calls the system's function to flush the data cache.
+
+*******************************************************************************/
+
+inline static void md_dcacheflush(void *addr, int nbytes)
+{
+       /* do nothing */
+}
+
+#endif /* _VM_JIT_ALPHA_MD_H */
 
 
 /*
index a8ec011797b3e6c95ea32700fc1fffe547f4a439..253465b71d9e6d22f99f17f97de0b75cde0d2e80 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "vm/types.h"
 
+#include "vm/jit/alpha/md.h"
+
 #include "mm/memory.h"
 
 #include "native/native.h"
@@ -41,7 +43,6 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/patcher-common.h"
-#include "vm/jit/md.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/stacktrace.h"
 
index 065f2de79dd66746ef5f1ee77a3ac88afaa807c5..54875ce23717f24660824b9cef5a37484056727d 100644 (file)
@@ -212,7 +212,7 @@ asm_handle_nat_exception:
        /*TODO:maybe make a macro out of it!!!*/
        SAVE_ARGUMENT_REGISTERS  
        mov   a0, lr
-       bl    md_codegen_get_pv_from_pc
+       bl    md_asm_codegen_get_pv_from_pc
        mov   ip, res1
        RESTORE_ARGUMENT_REGISTERS  
        /* fall through */
@@ -269,7 +269,7 @@ asm_handle_exception_not_catched:
        /*TODO:maybe make a macro out of it!!!*/
        SAVE_ARGUMENT_REGISTERS  
        mov   a0, lr
-       bl    md_codegen_get_pv_from_pc
+       bl    md_asm_codegen_get_pv_from_pc
        mov   ip, res1
        RESTORE_ARGUMENT_REGISTERS  
 
index e2faf6df211116a7aa118496741cce054cbb3d26..9ff1c63e5b45695a6572322c66fdee4c947b3870 100644 (file)
@@ -56,7 +56,6 @@
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
 #include "vm/jit/linenumbertable.h"
-#include "vm/jit/md.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.h"
index e749926cfb967aab9f4f9f29589462eb92c6bb96..b6450a27858e90ca53d6140ccbdc0734746d9968 100644 (file)
 #include <assert.h>
 #include <stdint.h>
 
-#include "vm/types.h"
-
+#include "vm/jit/arm/md.h"
 #include "vm/jit/arm/md-abi.h"
 
-#include "vm/exceptions.h"
-#include "vm/global.h"
-
-#include "vm/jit/asmpart.h"
-#include "vm/jit/md.h"
-
 
 /* md_init *********************************************************************
 
@@ -53,27 +46,6 @@ void md_init(void)
 }
 
 
-/* md_stacktrace_get_returnaddress *********************************************
-
-   Returns the return address of the current stackframe, specified by
-   the passed stack pointer and the stack frame size.
-
-*******************************************************************************/
-
-u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
-{
-       u1 *ra;
-
-       /* On ARM the return address is located on the top of the
-          stackframe. */
-       /* ATTENTION: This is only true for non-leaf methods!!! */
-
-       ra = *((u1 **) (sp + framesize - SIZEOF_VOID_P));
-
-       return ra;
-}
-
-
 /* md_jit_method_patch_address *************************************************
 
    Gets the patch address of the currently compiled method. The offset
@@ -166,83 +138,9 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
 }
 
 
-/* md_codegen_get_pv_from_pc ***************************************************
-
-   TODO: document me
-
-*******************************************************************************/
-
-u1 *md_codegen_get_pv_from_pc(u1 *ra)
-{
-       u1 *pv;
-       u4  mcode1, mcode2, mcode3;
-
-       pv = ra;
-
-       /* this can either be a RECOMPUTE_IP in JIT code or a fake in asm_calljavafunction */
-       mcode1 = *((u4*) ra);
-       if ((mcode1 & 0xffffff00) == 0xe24fcf00 /*sub ip,pc,#__*/)
-               pv -= (s4) ((mcode1 & 0x000000ff) <<  2);
-       else if ((mcode1 & 0xffffff00) == 0xe24fc000 /*sub ip,pc,#__*/)
-               pv -= (s4) (mcode1 & 0x000000ff);
-       else {
-               /* if this happens, we got an unexpected instruction at (*ra) */
-               vm_abort("Unable to find method: %p (instr=%x)", ra, mcode1);
-       }
-
-       /* if we have a RECOMPUTE_IP there can be more than one instruction */
-       mcode2 = *((u4*) (ra + 4));
-       mcode3 = *((u4*) (ra + 8));
-       if ((mcode2 & 0xffffff00) == 0xe24ccb00 /*sub ip,ip,#__*/)
-               pv -= (s4) ((mcode2 & 0x000000ff) << 10);
-       if ((mcode3 & 0xffffff00) == 0xe24cc700 /*sub ip,ip,#__*/)
-               pv -= (s4) ((mcode3 & 0x000000ff) << 18);
-
-       /* we used PC-relative adressing; but now it is LR-relative */
-       pv += 8;
-
-       /* if we found our method the data segment has to be valid */
-       /* we check this by looking up the IsLeaf field, which has to be boolean */
-/*     assert( *((s4*)pv-8) == (s4)true || *((s4*)pv-8) == (s4)false );  */
-
-       return pv;
-}
-
-
-/* md_cacheflush ***************************************************************
-
-   Calls the system's function to flush the instruction and data
-   cache.
-
-*******************************************************************************/
-
-void md_cacheflush(u1 *addr, s4 nbytes)
-{
-       asm_cacheflush(addr, nbytes);
-}
-
-
-/* md_icacheflush **************************************************************
-
-   Calls the system's function to flush the instruction cache.
-
-*******************************************************************************/
-
-void md_icacheflush(u1 *addr, s4 nbytes)
-{
-       asm_cacheflush(addr, nbytes);
-}
-
-
-/* md_dcacheflush **************************************************************
-
-   Calls the system's function to flush the data cache.
-
-*******************************************************************************/
-
-void md_dcacheflush(u1 *addr, s4 nbytes)
+void *md_asm_codegen_get_pv_from_pc(void *ra)
 {
-       /* do nothing */
+       return md_codegen_get_pv_from_pc(ra);
 }
 
 
diff --git a/src/vm/jit/arm/md.h b/src/vm/jit/arm/md.h
new file mode 100644 (file)
index 0000000..04774df
--- /dev/null
@@ -0,0 +1,157 @@
+/* src/vm/jit/arm/md.h - machine dependent Arm functions
+
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _VM_JIT_ARM_MD_H
+#define _VM_JIT_ARM_MD_H
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "vm/types.h"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/codegen-common.h"
+
+
+/* md_stacktrace_get_returnaddress *********************************************
+
+   Returns the return address of the current stackframe, specified by
+   the passed stack pointer and the stack frame size.
+
+*******************************************************************************/
+
+inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
+{
+       void *ra;
+
+       /* On ARM the return address is located on the top of the
+          stackframe. */
+       /* ATTENTION: This is only true for non-leaf methods!!! */
+
+       ra = *((void **) (((uintptr_t) sp) + stackframesize - SIZEOF_VOID_P));
+
+       return ra;
+}
+
+
+/* md_codegen_get_pv_from_pc ***************************************************
+
+   TODO: document me
+
+*******************************************************************************/
+
+inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
+{
+       u1 *pv;
+       u4  mcode1, mcode2, mcode3;
+
+       pv = ra;
+
+       /* this can either be a RECOMPUTE_IP in JIT code or a fake in asm_calljavafunction */
+       mcode1 = *((u4*) ra);
+       if ((mcode1 & 0xffffff00) == 0xe24fcf00 /*sub ip,pc,#__*/)
+               pv -= (s4) ((mcode1 & 0x000000ff) <<  2);
+       else if ((mcode1 & 0xffffff00) == 0xe24fc000 /*sub ip,pc,#__*/)
+               pv -= (s4) (mcode1 & 0x000000ff);
+       else {
+               /* if this happens, we got an unexpected instruction at (*ra) */
+               vm_abort("Unable to find method: %p (instr=%x)", ra, mcode1);
+       }
+
+       /* if we have a RECOMPUTE_IP there can be more than one instruction */
+       mcode2 = *((u4*) (ra + 4));
+       mcode3 = *((u4*) (ra + 8));
+       if ((mcode2 & 0xffffff00) == 0xe24ccb00 /*sub ip,ip,#__*/)
+               pv -= (s4) ((mcode2 & 0x000000ff) << 10);
+       if ((mcode3 & 0xffffff00) == 0xe24cc700 /*sub ip,ip,#__*/)
+               pv -= (s4) ((mcode3 & 0x000000ff) << 18);
+
+       /* we used PC-relative adressing; but now it is LR-relative */
+       pv += 8;
+
+       /* if we found our method the data segment has to be valid */
+       /* we check this by looking up the IsLeaf field, which has to be boolean */
+/*     assert( *((s4*)pv-8) == (s4)true || *((s4*)pv-8) == (s4)false );  */
+
+       return pv;
+}
+
+
+/* md_cacheflush ***************************************************************
+
+   Calls the system's function to flush the instruction and data
+   cache.
+
+*******************************************************************************/
+
+inline static void md_cacheflush(void *addr, int nbytes)
+{
+       asm_cacheflush(addr, nbytes);
+}
+
+
+/* md_icacheflush **************************************************************
+
+   Calls the system's function to flush the instruction cache.
+
+*******************************************************************************/
+
+inline static void md_icacheflush(void *addr, int nbytes)
+{
+       asm_cacheflush(addr, nbytes);
+}
+
+
+/* md_dcacheflush **************************************************************
+
+   Calls the system's function to flush the data cache.
+
+*******************************************************************************/
+
+inline static void md_dcacheflush(void *addr, int nbytes)
+{
+       /* do nothing */
+}
+
+#endif /* _VM_JIT_ARM_MD_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index 24afdb7fb2ff4059009902205ae0262ce4c4a1e3..36e128a599e7bcb0dce2e8ac34926330461d6bfc 100644 (file)
@@ -32,6 +32,8 @@
 
 #include "vm/types.h"
 
+#include "vm/jit/arm/md.h"
+
 #include "mm/memory.h"
 
 #include "native/native.h"
@@ -41,7 +43,6 @@
 #include "vm/initialize.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/md.h"
 #include "vm/jit/patcher-common.h"
 
 #include "vmcore/field.h"
index cb549c55f6c56242366b1853f8c94623cba42c02..76c6dcc8ee7eb7c0a7b0ea5de92bd3f66d14d12b 100644 (file)
@@ -111,6 +111,8 @@ void asm_cacheflush(u1 *addr, s4 nbytes);
 
 u8 asm_get_cycle_count(void);
 
+void *md_asm_codegen_get_pv_from_pc(void *ra);
+
 #endif /* _ASMPART_H */
 
 
index 346ba5c73d9126b97834b582f019f93097e794b7..c17ddcb3c02832ed2390401333ce97ceb354303c 100644 (file)
@@ -50,6 +50,7 @@
 #include "vm/types.h"
 
 #include "codegen.h"
+#include "md.h"
 #include "md-abi.h"
 
 #include "mm/memory.h"
@@ -91,7 +92,6 @@
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
 #include "vm/jit/linenumbertable.h"
-#include "vm/jit/md.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/replace.h"
@@ -1812,6 +1812,13 @@ void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr)
 #endif /* defined(ENABLE_SSA) */
 
 
+/* REMOVEME When we have exception handling in C. */
+
+void *md_asm_codegen_get_pv_from_pc(void *ra)
+{
+       return md_codegen_get_pv_from_pc(ra);
+}
+
 
 /*
  * These are local overrides for various environment variables in Emacs.
index 893ad7f9815ea1cf18d655fb9a89e59c65bc496d..33598a77b7bcbbd1563db32bc67f074adc38c921 100644 (file)
@@ -319,10 +319,6 @@ void codegen_critical_section_end(codegendata *cd);
 # define CODEGEN_CRITICAL_SECTION_END      /* no-op */
 #endif
 
-/* machine dependent functions */
-u1 *md_codegen_get_pv_from_pc(u1 *ra);
-
-
 #if defined(ENABLE_SSA)
 void codegen_emit_phi_moves(jitdata *jd, basicblock *bptr);
 #endif
index ca69b31193187d55b81ef857aeb49f273a2c5fa0..d8d6f8181d399124fae1cc8c5db75baed4cae8f3 100644 (file)
@@ -35,6 +35,7 @@
 #include "vm/types.h"
 
 #include "vm/jit/i386/codegen.h"
+#include "vm/jit/i386/md.h"
 
 #include "threads/threads-common.h"
 
index 0d13f23098dd69b7c11d0c4dccb2b404fc77220e..48664ef1fddd22e7084106164fcab40f35011947 100644 (file)
@@ -36,9 +36,7 @@
 #include "vm/vm.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
 #include "vm/jit/jit.h"
-#include "vm/jit/md.h"
 
 
 /* md_init *********************************************************************
@@ -53,25 +51,6 @@ void md_init(void)
 }
 
 
-/* md_stacktrace_get_returnaddress *********************************************
-
-   Returns the return address of the current stackframe, specified by
-   the passed stack pointer and the stack frame size.
-
-*******************************************************************************/
-
-u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
-{
-       u1 *ra;
-
-       /* on i386 the return address is above the current stack frame */
-
-       ra = *((u1 **) (sp + framesize));
-
-       return ra;
-}
-
-
 /* md_jit_method_patch_address *************************************************
 
    Gets the patch address of the currently compiled method. The offset
@@ -152,63 +131,6 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
 }
 
 
-/* md_codegen_get_pv_from_pc ***************************************************
-
-   On this architecture just a wrapper function to
-   codegen_get_pv_from_pc.
-
-*******************************************************************************/
-
-u1 *md_codegen_get_pv_from_pc(u1 *ra)
-{
-       u1 *pv;
-
-       /* Get the start address of the function which contains this
-       address from the method table. */
-
-       pv = codegen_get_pv_from_pc(ra);
-
-       return pv;
-}
-
-
-/* md_cacheflush ***************************************************************
-
-   Calls the system's function to flush the instruction and data
-   cache.
-
-*******************************************************************************/
-
-void md_cacheflush(u1 *addr, s4 nbytes)
-{
-       /* do nothing */
-}
-
-
-/* md_icacheflush **************************************************************
-
-   Calls the system's function to flush the instruction cache.
-
-*******************************************************************************/
-
-void md_icacheflush(u1 *addr, s4 nbytes)
-{
-       /* do nothing */
-}
-
-
-/* md_dcacheflush **************************************************************
-
-   Calls the system's function to flush the data cache.
-
-*******************************************************************************/
-
-void md_dcacheflush(u1 *addr, s4 nbytes)
-{
-       /* do nothing */
-}
-
-
 /* md_patch_replacement_point **************************************************
 
    Patch the given replacement point.
diff --git a/src/vm/jit/i386/md.h b/src/vm/jit/i386/md.h
new file mode 100644 (file)
index 0000000..f5289c8
--- /dev/null
@@ -0,0 +1,131 @@
+/* src/vm/jit/i386/md.h - machine dependent i386 functions
+
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _VM_JIT_I386_MD_H
+#define _VM_JIT_I386_MD_H
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "vm/jit/codegen-common.h"
+
+
+/* inline functions ***********************************************************/
+
+/* md_stacktrace_get_returnaddress *********************************************
+
+   Returns the return address of the current stackframe, specified by
+   the passed stack pointer and the stack frame size.
+
+*******************************************************************************/
+
+inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
+{
+       void *ra;
+
+       /* On i386 the return address is above the current stack frame. */
+
+       ra = *((void **) (((uintptr_t) sp) + stackframesize));
+
+       return ra;
+}
+
+
+/* md_codegen_get_pv_from_pc ***************************************************
+
+   On this architecture just a wrapper function to
+   codegen_get_pv_from_pc.
+
+*******************************************************************************/
+
+inline static void *md_codegen_get_pv_from_pc(void *ra)
+{
+       void *pv;
+
+       /* Get the start address of the function which contains this
+       address from the method table. */
+
+       pv = codegen_get_pv_from_pc(ra);
+
+       return pv;
+}
+
+
+/* md_cacheflush ***************************************************************
+
+   Calls the system's function to flush the instruction and data
+   cache.
+
+*******************************************************************************/
+
+inline static void md_cacheflush(void *addr, int nbytes)
+{
+       /* do nothing */
+}
+
+
+/* md_icacheflush **************************************************************
+
+   Calls the system's function to flush the instruction cache.
+
+*******************************************************************************/
+
+inline static void md_icacheflush(void *addr, int nbytes)
+{
+       /* do nothing */
+}
+
+
+/* md_dcacheflush **************************************************************
+
+   Calls the system's function to flush the data cache.
+
+*******************************************************************************/
+
+inline static void md_dcacheflush(void *addr, int nbytes)
+{
+       /* do nothing */
+}
+
+#endif /* _VM_JIT_I386_MD_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index 2c3607551902c857f6fa14afa5a7e4f9f59a1a2b..488103b81a61cd416cb1b26687df5944538065c2 100644 (file)
 #include "config.h"
 
 #include <assert.h>
+#include <stdint.h>
 
 #include "vm/types.h"
 
+#include "md.h"
+
 #include "mm/memory.h"
 
 #include "native/native.h"
index 9c504ff4630f48edf0359cc4d2fb4ffe05abb96a..1a6ee282740e4d7fb408a7870f9cfe7618d1af73 100644 (file)
@@ -197,7 +197,7 @@ L_asm_handle_exception_stack_loop:
 
        /* we need the dseg, figure it out */
        movel   %a3, %sp@-                              /* push ra argument */
-       jsr     md_codegen_get_pv_from_pc       /* pv in %d0 now */
+       jsr     md_asm_codegen_get_pv_from_pc   /* pv in %d0 now */
        movel   %d0, %d2                                /* move to safe register */
        lea     %sp@(4), %sp                            /* pop args off stack */
 
index 7015749811f0232790382db8654abb16c8e9d3ec..2b3ae563dc142e8225f26d7ceec344e3d34636c6 100644 (file)
@@ -62,7 +62,6 @@
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/stacktrace.h"
-#include "vm/jit/md.h"
 
 #include "vmcore/loader.h"
 #include "vmcore/options.h"
index 45abc87287c3e084c9318c3193bab2597bee6ab5..b9b6e33bff92d044ea401a8cfcf935f44c8524c1 100644 (file)
 #include <assert.h>
 #include <stdint.h>
 
-#include "md-os.h"
-
 #include "vm/types.h"
-#include "vm/jit/codegen-common.h"
-#include "vm/jit/md.h"
 
 #include "vm/vm.h"
-#include "vmcore/class.h"
-#include "vmcore/linker.h"
-#include "vmcore/method.h"
-#include "mm/memory.h"
-#include "vm/jit/asmpart.h"
 
 
 /*
@@ -56,19 +47,6 @@ void md_init(void)
 {
 }
 
-/* md_codegen_get_pv_from_pc ***************************************************
-
-   On this architecture just a wrapper function to
-   codegen_get_pv_from_pc.
-
-*******************************************************************************/
-u1* md_codegen_get_pv_from_pc(u1 *ra) 
-{ 
-       u1 *pv;
-       pv = codegen_get_pv_from_pc(ra);
-
-       return pv;
-}
 
 /* md_jit_method_patch_address *************************************************
  
@@ -133,94 +111,6 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
        return pa;
 }
 
-/* XXX i can't find a definition of cacheflush in any installed header files but i can find the symbol in libc */
-/* lets extract the signature from the assembler code*/
-/*
-    000e7158 <cacheflush>:
-    e7158:       707b            moveq #123,%d0
-    e715a:       2f04            movel %d4,%sp@-
-    e715c:       282f 0014       movel %sp@(20),%d4                    arg 
-    e7160:       2243            moveal %d3,%a1
-    e7162:       262f 0010       movel %sp@(16),%d3                    arg 
-    e7166:       2042            moveal %d2,%a0
-    e7168:       242f 000c       movel %sp@(12),%d2                    arg 
-    e716c:       222f 0008       movel %sp@(8),%d1                     arg 
-    e7170:       4e40            trap #0                               traps into system i guess
-    e7172:       2408            movel %a0,%d2
-    e7174:       2609            movel %a1,%d3
-    e7176:       281f            movel %sp@+,%d4
-    e7178:       223c ffff f001  movel #-4095,%d1
-    e717e:       b081            cmpl %d1,%d0
-    e7180:       6402            bccs e7184 <cacheflush+0x2c>
-    e7182:       4e75            rts
-    e7184:       4480            negl %d0
-    e7186:       2f00            movel %d0,%sp@-
-    e7188:       61ff fff3 82e2  bsrl 1f46c <D_MAX_EXP+0x1ec6d>
-    e718e:       209f            movel %sp@+,%a0@
-    e7190:       70ff            moveq #-1,%d0
-    e7192:       2040            moveal %d0,%a0
-    e7194:       4e75            rts
-    e7196:       4e75            rts
-                                                                       */
-
-/* seems to have 4 arguments */
-/* best guess: it is this syscall */
-/* asmlinkage int sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len) */
-/* kernel 2.6.10 with freescale patches (the one I develop against) needs a patch of */
-/* arch/m68k/kernel/sys_m68k.c(sys_cacheflush) */
-/* evil hack: */
-/*
-void DcacheFlushInvalidateCacheBlock(void *start, unsigned long size);
-void IcacheInvalidateCacheBlock(void *start, unsigned long size);
-
-asmlinkage int
-sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
-{
-       lock_kernel();
-       DcacheFlushInvalidateCacheBlock(addr, len);
-       IcacheInvalidateCacheBlock(addr, len);
-       unlock_kernel();
-       return 0;
-}
-*/
-extern int cacheflush(unsigned long addr, int scope, int cache, unsigned long len);
-
-#include "asm/cachectl.h"      /* found more traces of the cacheflush function */
-#include "errno.h"
-
-void md_cacheflush(u1 *addr, s4 nbytes)  { cacheflush((unsigned long)addr, FLUSH_SCOPE_PAGE, FLUSH_CACHE_BOTH, nbytes); }
-void md_dcacheflush(u1 *addr, s4 nbytes) { cacheflush((unsigned long)addr, FLUSH_SCOPE_PAGE, FLUSH_CACHE_DATA, nbytes); }
-void md_icacheflush(u1* addr, s4 nbytes) { cacheflush((unsigned long)addr, FLUSH_SCOPE_LINE, FLUSH_CACHE_INSN, nbytes); }
-
-/* md_stacktrace_get_returnaddress *********************************************
-
-   Returns the return address of the current stackframe, specified by
-   the passed stack pointer and the stack frame size.
-
-*******************************************************************************/
-u1* md_stacktrace_get_returnaddress(u1* sp, u4 framesize) 
-{ 
-       /* return address is above stackpointer */
-       u1 *ra = *((u1**)(sp + framesize));
-       
-       /* XXX: This helps for now, but it's a ugly hack
-        * the problem _may_ be: the link instruction is used
-        * by some gcc generated code, and we get an additional word
-        * on the stack, the old framepointer. Its address is somewhere
-        * near sp, but that all depends the code generated by the compiler.
-        * I'm unsure about a clean solution.
-        */
-       #if 0
-       if (!(ra > 0x40000000 && ra < 0x80000000))      {
-               ra = *((u1**)(sp + framesize + 4));
-       }
-       #endif
-       /* assert(ra > 0x40000000 && ra < 0x80000000);
-       printf("XXXXXX=%x\n", ra);
-        */
-       return ra;
-}
-
 
 /*
  * These are local overrides for various environment variables in Emacs.
diff --git a/src/vm/jit/m68k/md.h b/src/vm/jit/m68k/md.h
new file mode 100644 (file)
index 0000000..de87abb
--- /dev/null
@@ -0,0 +1,200 @@
+/*     src/vm/jit/m68k/md.h
+
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _VM_JIT_M68K_MD_H
+#define _VM_JIT_M68K_MD_H
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "vm/jit/codegen-common.h"
+
+
+/* md_stacktrace_get_returnaddress *********************************************
+
+   Returns the return address of the current stackframe, specified by
+   the passed stack pointer and the stack frame size.
+
+*******************************************************************************/
+
+inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
+{
+       void *ra;
+
+       /* return address is above stackpointer */
+
+       ra = *((void **) (((uintptr_t) sp) + stackframesize));
+       
+       /* XXX: This helps for now, but it's a ugly hack
+        * the problem _may_ be: the link instruction is used
+        * by some gcc generated code, and we get an additional word
+        * on the stack, the old framepointer. Its address is somewhere
+        * near sp, but that all depends the code generated by the compiler.
+        * I'm unsure about a clean solution.
+        */
+#if 0
+       if (!(ra > 0x40000000 && ra < 0x80000000))      {
+               ra = *((u1**)(sp + framesize + 4));
+       }
+#endif
+
+       /* assert(ra > 0x40000000 && ra < 0x80000000);
+       printf("XXXXXX=%x\n", ra);
+        */
+
+       return ra;
+}
+
+
+/* md_codegen_get_pv_from_pc ***************************************************
+
+   On this architecture just a wrapper function to
+   codegen_get_pv_from_pc.
+
+*******************************************************************************/
+
+inline static void *md_codegen_get_pv_from_pc(void *ra)
+{
+       void *pv;
+
+       pv = codegen_get_pv_from_pc(ra);
+
+       return pv;
+}
+
+
+/* XXX i can't find a definition of cacheflush in any installed header files but i can find the symbol in libc */
+/* lets extract the signature from the assembler code*/
+/*
+    000e7158 <cacheflush>:
+    e7158:       707b            moveq #123,%d0
+    e715a:       2f04            movel %d4,%sp@-
+    e715c:       282f 0014       movel %sp@(20),%d4                    arg 
+    e7160:       2243            moveal %d3,%a1
+    e7162:       262f 0010       movel %sp@(16),%d3                    arg 
+    e7166:       2042            moveal %d2,%a0
+    e7168:       242f 000c       movel %sp@(12),%d2                    arg 
+    e716c:       222f 0008       movel %sp@(8),%d1                     arg 
+    e7170:       4e40            trap #0                               traps into system i guess
+    e7172:       2408            movel %a0,%d2
+    e7174:       2609            movel %a1,%d3
+    e7176:       281f            movel %sp@+,%d4
+    e7178:       223c ffff f001  movel #-4095,%d1
+    e717e:       b081            cmpl %d1,%d0
+    e7180:       6402            bccs e7184 <cacheflush+0x2c>
+    e7182:       4e75            rts
+    e7184:       4480            negl %d0
+    e7186:       2f00            movel %d0,%sp@-
+    e7188:       61ff fff3 82e2  bsrl 1f46c <D_MAX_EXP+0x1ec6d>
+    e718e:       209f            movel %sp@+,%a0@
+    e7190:       70ff            moveq #-1,%d0
+    e7192:       2040            moveal %d0,%a0
+    e7194:       4e75            rts
+    e7196:       4e75            rts
+                                                                       */
+
+/* seems to have 4 arguments */
+/* best guess: it is this syscall */
+/* asmlinkage int sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len) */
+/* kernel 2.6.10 with freescale patches (the one I develop against) needs a patch of */
+/* arch/m68k/kernel/sys_m68k.c(sys_cacheflush) */
+/* evil hack: */
+/*
+void DcacheFlushInvalidateCacheBlock(void *start, unsigned long size);
+void IcacheInvalidateCacheBlock(void *start, unsigned long size);
+
+asmlinkage int
+sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
+{
+       lock_kernel();
+       DcacheFlushInvalidateCacheBlock(addr, len);
+       IcacheInvalidateCacheBlock(addr, len);
+       unlock_kernel();
+       return 0;
+}
+*/
+
+extern int cacheflush(unsigned long addr, int scope, int cache, unsigned long len);
+
+#include "asm/cachectl.h"      /* found more traces of the cacheflush function */
+#include "errno.h"
+
+
+/* md_cacheflush ***************************************************************
+
+   Calls the system's function to flush the instruction and data
+   cache.
+
+*******************************************************************************/
+
+inline static void md_cacheflush(void *addr, int nbytes)
+{
+       cacheflush((unsigned long)addr, FLUSH_SCOPE_PAGE, FLUSH_CACHE_BOTH, nbytes);
+}
+
+
+/* md_icacheflush **************************************************************
+
+   Calls the system's function to flush the instruction cache.
+
+*******************************************************************************/
+
+inline static void md_icacheflush(void *addr, int nbytes)
+{
+       cacheflush((unsigned long)addr, FLUSH_SCOPE_LINE, FLUSH_CACHE_INSN, nbytes);
+}
+
+
+/* md_dcacheflush **************************************************************
+
+   Calls the system's function to flush the data cache.
+
+*******************************************************************************/
+
+inline static void md_dcacheflush(void *addr, int nbytes)
+{
+       cacheflush((unsigned long)addr, FLUSH_SCOPE_PAGE, FLUSH_CACHE_DATA, nbytes);
+}
+
+#endif /* _VM_JIT_M68K_MD_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index f75cba413b8230298b348a4c92cc0045800f857d..e304865cf8a8dc8d93560509dd9da1b3ad3f1200 100644 (file)
@@ -31,6 +31,8 @@
 
 #include "vm/types.h"
 
+#include "vm/jit/m68k/md.h"
+
 #include "mm/memory.h"
 #include "native/native.h"
 
@@ -41,7 +43,6 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/patcher-common.h"
-#include "vm/jit/md.h"
 #include "vm/jit/stacktrace.h"
 
 #include "vmcore/class.h"
diff --git a/src/vm/jit/md.h b/src/vm/jit/md.h
deleted file mode 100644 (file)
index cedd528..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/* src/vm/jit/md.h - machine dependent functions
-
-   Copyright (C) 2007 R. Grafl, A. Krall, C. Kruegel,
-   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
-   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
-   J. Wenninger, Institut f. Computersprachen - TU Wien
-
-   This file is part of CACAO.
-
-   This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2, or (at
-   your option) any later version.
-
-   This program is distributed in the hope that it will be useful, but
-   WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-   02110-1301, USA.
-
-*/
-
-
-#ifndef _MD_H
-#define _MD_H
-
-#include "config.h"
-#include "vm/types.h"
-
-#include "vm/jit/stacktrace.h"
-
-
-/* function prototypes ********************************************************/
-
-#if defined(ENABLE_JIT)
-void md_cacheflush(u1 *addr, s4 nbytes);
-void md_icacheflush(u1 *addr, s4 nbytes);
-void md_dcacheflush(u1 *addr, s4 nbytes);
-#endif
-
-#endif /* _MD_H */
-
-
-/*
- * These are local overrides for various environment variables in Emacs.
- * Please do not remove this and leave it at the end of the file, where
- * Emacs will automagically detect them.
- * ---------------------------------------------------------------------
- * Local variables:
- * mode: c
- * indent-tabs-mode: t
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- * vim:noexpandtab:sw=4:ts=4:
- */
index 3070c34fa2b24bc11f7bec7dca14b5af8bde9c4d..8cefe558a5ddc508f9cbfcbd315c660090098dc7 100644 (file)
@@ -277,7 +277,7 @@ L_asm_handle_exception_stack_loop:
 #endif
 
        move    a0,ra                       /* pass RA                            */
-       jal     md_codegen_get_pv_from_pc   /* get PV from RA                     */
+       jal     md_asm_codegen_get_pv_from_pc /* get PV from RA                   */
 
 #if SIZEOF_VOID_P == 8
        ast     v0,2*8(sp)                  /* save PV                            */
index dcaf66ce91963958201b79b36e6ac858430ff174..35502fe003154eb2f90b2b97ebbea77fc77366c3 100644 (file)
@@ -55,7 +55,6 @@
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
 #include "vm/jit/linenumbertable.h"
-#include "vm/jit/md.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/reg.h"
 #include "vm/jit/replace.h"
index 65b21d4126e73c43465aee2a2fe90ef944481cd4..bcaef12e3ebe3cab31233b9e8db740a7f3aca103 100644 (file)
@@ -36,6 +36,7 @@
 #include "vm/types.h"
 
 #include "vm/jit/mips/codegen.h"
+#include "vm/jit/mips/md.h"
 #include "vm/jit/mips/md-abi.h"
 
 #include "mm/gc-common.h"
index 2154c9a120edcf675df9033cb9b13ae6f5a323ee..61e5113ee000d5382eff5ba3e8a61d9b59413556 100644 (file)
 
 #include <assert.h>
 #include <stdint.h>
-#include <unistd.h>
-#include <sys/cachectl.h>
 
 #include "vm/types.h"
 
-#include "toolbox/logging.h"
+#include "vm/jit/mips/md.h"
 
 #include "vm/global.h"
 #include "vm/vm.h"
 
-#include "vm/jit/codegen-common.h"
 #include "vm/jit/jit.h"
 
 
-/* md_stacktrace_get_returnaddress *********************************************
-
-   Returns the return address of the current stackframe, specified by
-   the passed stack pointer and the stack frame size.
-
-*******************************************************************************/
-
-u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
-{
-       u1 *ra;
-
-       /* on MIPS the return address is located on the top of the stackframe */
-
-       /* XXX change this if we ever want to use 4-byte stackslots */
-       /* ra = *((u1 **) (sp + framesize - SIZEOF_VOID_P)); */
-       ra = *((u1 **) (sp + framesize - 8));
-
-       return ra;
-}
-
-
 /* md_jit_method_patch_address *************************************************
 
    Gets the patch address of the currently compiled method. The offset
@@ -168,106 +144,6 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
 }
 
 
-/* md_codegen_get_pv_from_pc ***************************************************
-
-   Machine code:
-
-   03c0f809    jalr     s8
-   00000000    nop
-   27feff9c    addiu    s8,ra,-100
-
-*******************************************************************************/
-
-u1 *md_codegen_get_pv_from_pc(u1 *ra)
-{
-       u1 *pv;
-       u4  mcode;
-       s4  offset;
-
-       /* get the offset of the instructions */
-
-       /* get first instruction word after jump */
-
-       mcode = *((u4 *) ra);
-
-       /* check if we have 2 instructions (lui, daddiu) */
-
-       if ((mcode >> 16) == 0x3c19) {
-               /* get displacement of first instruction (lui) */
-
-               offset = (s4) (mcode << 16);
-
-               /* get displacement of second instruction (daddiu) */
-
-               mcode = *((u4 *) (ra + 1 * 4));
-
-#if SIZEOF_VOID_P == 8
-               assert((mcode >> 16) == 0x6739);
-#else
-               assert((mcode >> 16) == 0x2739);
-#endif
-
-               offset += (s2) (mcode & 0x0000ffff);
-       }
-       else {
-               /* get offset of first instruction (daddiu) */
-
-               mcode = *((u4 *) ra);
-
-#if SIZEOF_VOID_P == 8
-               assert((mcode >> 16) == 0x67fe);
-#else
-               assert((mcode >> 16) == 0x27fe);
-#endif
-
-               offset = (s2) (mcode & 0x0000ffff);
-       }
-
-       /* calculate PV via RA + offset */
-
-       pv = ra + offset;
-
-       return pv;
-}
-
-
-/* md_cacheflush ***************************************************************
-
-   Calls the system's function to flush the instruction and data
-   cache.
-
-*******************************************************************************/
-
-void md_cacheflush(u1 *addr, s4 nbytes)
-{
-       cacheflush(addr, nbytes, BCACHE);
-}
-
-
-/* md_icacheflush **************************************************************
-
-   Calls the system's function to flush the instruction cache.
-
-*******************************************************************************/
-
-void md_icacheflush(u1 *addr, s4 nbytes)
-{
-       cacheflush(addr, nbytes, ICACHE);
-}
-
-
-/* md_dcacheflush **************************************************************
-
-   Calls the system's function to flush the data cache.
-
-*******************************************************************************/
-
-void md_dcacheflush(u1 *addr, s4 nbytes)
-{
-       cacheflush(addr, nbytes, DCACHE);
-}
-
-
 /* md_patch_replacement_point **************************************************
 
    Patch the given replacement point.
@@ -303,6 +179,7 @@ void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert)
 }
 #endif /* defined(ENABLE_REPLACEMENT) */
 
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where
diff --git a/src/vm/jit/mips/md.h b/src/vm/jit/mips/md.h
new file mode 100644 (file)
index 0000000..fc70b19
--- /dev/null
@@ -0,0 +1,177 @@
+/* src/vm/jit/mips/md.h - machine dependent MIPS functions
+
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _VM_JIT_MIPS_MD_H
+#define _VM_JIT_MIPS_MD_H
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+#include <unistd.h>
+#include <sys/cachectl.h>
+
+#include "vm/types.h"
+
+#include "vm/vm.h"
+
+
+/* md_stacktrace_get_returnaddress *********************************************
+
+   Returns the return address of the current stackframe, specified by
+   the passed stack pointer and the stack frame size.
+
+*******************************************************************************/
+
+inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
+{
+       void *ra;
+
+       /* On MIPS the return address is located on the top of the
+          stackframe. */
+
+       ra = *((void **) (((uintptr_t) sp) + stackframesize - 8));
+
+       return ra;
+}
+
+
+/* md_codegen_get_pv_from_pc ***************************************************
+
+   Machine code:
+
+   03c0f809    jalr     s8
+   00000000    nop
+   27feff9c    addiu    s8,ra,-100
+
+*******************************************************************************/
+
+inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
+{
+       u1 *pv;
+       u4  mcode;
+       s4  offset;
+
+       /* get the offset of the instructions */
+
+       /* get first instruction word after jump */
+
+       mcode = *((u4 *) ra);
+
+       /* check if we have 2 instructions (lui, daddiu) */
+
+       if ((mcode >> 16) == 0x3c19) {
+               /* get displacement of first instruction (lui) */
+
+               offset = (s4) (mcode << 16);
+
+               /* get displacement of second instruction (daddiu) */
+
+               mcode = *((u4 *) (ra + 1 * 4));
+
+#if SIZEOF_VOID_P == 8
+               assert((mcode >> 16) == 0x6739);
+#else
+               assert((mcode >> 16) == 0x2739);
+#endif
+
+               offset += (s2) (mcode & 0x0000ffff);
+       }
+       else {
+               /* get offset of first instruction (daddiu) */
+
+               mcode = *((u4 *) ra);
+
+#if SIZEOF_VOID_P == 8
+               assert((mcode >> 16) == 0x67fe);
+#else
+               assert((mcode >> 16) == 0x27fe);
+#endif
+
+               offset = (s2) (mcode & 0x0000ffff);
+       }
+
+       /* calculate PV via RA + offset */
+
+       pv = ra + offset;
+
+       return pv;
+}
+
+
+/* md_cacheflush ***************************************************************
+
+   Calls the system's function to flush the instruction and data
+   cache.
+
+*******************************************************************************/
+
+inline static void md_cacheflush(void *addr, int nbytes)
+{
+       cacheflush(addr, nbytes, BCACHE);
+}
+
+
+/* md_icacheflush **************************************************************
+
+   Calls the system's function to flush the instruction cache.
+
+*******************************************************************************/
+
+inline static void md_icacheflush(void *addr, int nbytes)
+{
+       cacheflush(addr, nbytes, ICACHE);
+}
+
+
+/* md_dcacheflush **************************************************************
+
+   Calls the system's function to flush the data cache.
+
+*******************************************************************************/
+
+inline static void md_dcacheflush(void *addr, int nbytes)
+{
+       cacheflush(addr, nbytes, DCACHE);
+}
+
+#endif /* _VM_JIT_MIPS_MD_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index 11265f4ddb8e72d83af87cf676456b7b34688d29..dbf03fd6c72d15411c8dbb41551ef016e86b7acb 100644 (file)
@@ -33,6 +33,7 @@
 #include "vm/types.h"
 
 #include "vm/jit/mips/codegen.h"
+#include "vm/jit/mips/md.h"
 
 #include "mm/memory.h"
 
@@ -43,7 +44,6 @@
 #include "vm/initialize.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/md.h"
 #include "vm/jit/patcher-common.h"
 
 #include "vmcore/class.h"
index b8e1c712974646d303fe63f96b41962c4ae37e75..6a37ef6ec0b9e9241b87f3661b70ad1c8f392702 100644 (file)
@@ -31,6 +31,7 @@
 #include <stdint.h>
 
 #include "codegen.h"                   /* for PATCHER_NOPS */
+#include "md.h"
 
 #include "mm/memory.h"
 
@@ -48,7 +49,6 @@
 
 #include "vm/jit/code.h"
 #include "vm/jit/jit.h"
-#include "vm/jit/md.h"
 #include "vm/jit/patcher-common.h"
 
 #include "vmcore/options.h"
index 6356ef8613644fe2ee4184d26f4bec4526257a2d..3413a354f16384a5bb3df4b84558db4a4aa7543d 100644 (file)
@@ -262,7 +262,7 @@ L_asm_handle_exception_stack_loop:
        stw     itmp3,LA_SIZE+(4+4)*4(sp)   /* save maybe-leaf flag (cleared)     */
 
        mr      a0,r0                       /* pass return address                */
-       bl      md_codegen_get_pv_from_pc   /* get PV from RA                     */
+       bl      md_asm_codegen_get_pv_from_pc /* get PV from RA                   */
        stw     v0,LA_SIZE+(4+2)*4(sp)      /* save data segment pointer          */
 
        lwz     a0,LA_SIZE+(4+0)*4(sp)      /* pass xptr                          */
@@ -517,21 +517,21 @@ L_builtin_throw_exception$lazy_ptr:
 
 .section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32
        .align 2
-L_md_codegen_get_pv_from_pc$stub:
-       .indirect_symbol _md_codegen_get_pv_from_pc
+L_md_asm_codegen_get_pv_from_pc$stub:
+       .indirect_symbol _md_asm_codegen_get_pv_from_pc
        mflr r0
-       bcl 20,31,L00$_md_codegen_get_pv_from_pc
-L00$_md_codegen_get_pv_from_pc:
+       bcl 20,31,L00$_md_asm_codegen_get_pv_from_pc
+L00$_md_asm_codegen_get_pv_from_pc:
        mflr r11
-       addis r11,r11,ha16(L_md_codegen_get_pv_from_pc$lazy_ptr - L00$_md_codegen_get_pv_from_pc)
+       addis r11,r11,ha16(L_md_asm_codegen_get_pv_from_pc$lazy_ptr - L00$_md_asm_codegen_get_pv_from_pc)
        mtlr r0
-       lwzu r12,lo16(L_md_codegen_get_pv_from_pc$lazy_ptr - L00$_md_codegen_get_pv_from_pc)(r11)
+       lwzu r12,lo16(L_md_asm_codegen_get_pv_from_pc$lazy_ptr - L00$_md_asm_codegen_get_pv_from_pc)(r11)
        mtctr r12
        bctr
 .data
 .lazy_symbol_pointer
-L_md_codegen_get_pv_from_pc$lazy_ptr:
-       .indirect_symbol _md_codegen_get_pv_from_pc
+L_md_asm_codegen_get_pv_from_pc$lazy_ptr:
+       .indirect_symbol _md_asm_codegen_get_pv_from_pc
        .long dyld_stub_binding_helper
 
 
index d164016bea0218f011434c8bf377a4eb217c2964..f2c88abb2641e558ccb747aca03eb49b5e19b016 100644 (file)
@@ -59,7 +59,6 @@
 #include "vm/jit/emit-common.h"
 #include "vm/jit/jit.h"
 #include "vm/jit/linenumbertable.h"
-#include "vm/jit/md.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/parse.h"
 #include "vm/jit/patcher-common.h"
index 12c4a0a9e25a5c214ce56327775b7d65aaff7bbc..dd1276118d781af000360367659970f0eeb54578 100644 (file)
 
 #define builtin_throw_exception               L_builtin_throw_exception$stub
 
-#define md_codegen_get_pv_from_pc             L_md_codegen_get_pv_from_pc$stub
+#define md_asm_codegen_get_pv_from_pc         L_md_asm_codegen_get_pv_from_pc$stub
 #define exceptions_handle_exception           L_exceptions_handle_exception$stub
 
 #define exceptions_asm_new_abstractmethoderror \
index 81863aee40306b211eb3b7fe9feb7ca57862e73b..f7c78127169267787b329349073101d6a7d0e7d1 100644 (file)
@@ -34,6 +34,7 @@
 #include "vm/types.h"
 
 #include "vm/jit/powerpc/codegen.h"
+#include "vm/jit/powerpc/md.h"
 #include "vm/jit/powerpc/linux/md-abi.h"
 
 #if defined(ENABLE_THREADS)
index aaee85b6c24352f3d6a88ed20be4c9d2c0ec07fa..b85321c9d7f4ab89d4efe3a6802d00dcf1bd99c9 100644 (file)
 
 #include "md-abi.h"
 #include "vm/jit/powerpc/codegen.h"
+#include "vm/jit/powerpc/md.h"
 
 #include "vm/global.h"
 #include "vm/vm.h"
 
-#include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
 #include "vm/jit/jit.h"
-#include "vm/jit/md.h"
 
 
 /* md_init *********************************************************************
@@ -56,25 +54,6 @@ void md_init(void)
 }
 
 
-/* md_stacktrace_get_returnaddress *********************************************
-
-   Returns the return address of the current stackframe, specified by
-   the passed stack pointer and the stack frame size.
-
-*******************************************************************************/
-
-u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
-{
-       u1 *ra;
-
-       /* on PowerPC the return address is located in the linkage area */
-
-       ra = *((u1 **) (sp + framesize + LA_LR_OFFSET));
-
-       return ra;
-}
-
-
 /* md_jit_method_patch_address *************************************************
 
    Gets the patch address of the currently compiled method. The offset
@@ -176,103 +155,6 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
 }
 
 
-/* md_codegen_get_pv_from_pc ***************************************************
-
-   Machine code:
-
-   7d6802a6    mflr    r11
-   39abffe0    addi    r13,r11,-32
-
-   or
-
-   7d6802a6    mflr    r11
-   3dabffff    addis   r13,r11,-1
-   39ad68b0    addi    r13,r13,26800
-
-*******************************************************************************/
-
-u1 *md_codegen_get_pv_from_pc(u1 *ra)
-{
-       u1 *pv;
-       u4  mcode;
-       s4  offset;
-
-       /* get first instruction word after jump */
-
-       mcode = *((u4 *) (ra + 1 * 4));
-
-       /* check if we have 2 instructions (addis, addi) */
-
-       if ((mcode >> 16) == 0x3dab) {
-               /* get displacement of first instruction (addis) */
-
-               offset = (s4) (mcode << 16);
-
-               /* get displacement of second instruction (addi) */
-
-               mcode = *((u4 *) (ra + 2 * 4));
-
-               /* check for addi instruction */
-
-               assert((mcode >> 16) == 0x39ad);
-
-               offset += (s2) (mcode & 0x0000ffff);
-
-       } else {
-               /* check for addi instruction */
-
-               assert((mcode >> 16) == 0x39ab);
-
-               /* get offset of first instruction (addi) */
-
-               offset = (s2) (mcode & 0x0000ffff);
-       }
-
-       /* calculate PV via RA + offset */
-
-       pv = ra + offset;
-
-       return pv;
-}
-
-
-/* md_cacheflush ***************************************************************
-
-   Calls the system's function to flush the instruction and data
-   cache.
-
-*******************************************************************************/
-
-void md_cacheflush(u1 *addr, s4 nbytes)
-{
-       asm_cacheflush(addr, nbytes);
-}
-
-
-/* md_icacheflush **************************************************************
-
-   Calls the system's function to flush the instruction cache.
-
-*******************************************************************************/
-
-void md_icacheflush(u1 *addr, s4 nbytes)
-{
-       asm_cacheflush(addr, nbytes);
-}
-
-
-/* md_dcacheflush **************************************************************
-
-   Calls the system's function to flush the data cache.
-
-*******************************************************************************/
-
-void md_dcacheflush(u1 *addr, s4 nbytes)
-{
-       asm_cacheflush(addr, nbytes);
-}
-
-
 /* md_patch_replacement_point **************************************************
 
    Patch the given replacement point.
@@ -305,6 +187,7 @@ void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert)
 }
 #endif /* defined(ENABLE_REPLACEMENT) */
 
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where
diff --git a/src/vm/jit/powerpc/md.h b/src/vm/jit/powerpc/md.h
new file mode 100644 (file)
index 0000000..6572885
--- /dev/null
@@ -0,0 +1,176 @@
+/* src/vm/jit/powerpc/md.h - machine dependent PowerPC functions
+
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _VM_JIT_POWERPC_MD_H
+#define _VM_JIT_POWERPC_MD_H
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "vm/jit/powerpc/codegen.h"
+
+#include "vm/global.h"
+#include "vm/vm.h"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/codegen-common.h"
+
+
+/* md_stacktrace_get_returnaddress *********************************************
+
+   Returns the return address of the current stackframe, specified by
+   the passed stack pointer and the stack frame size.
+
+*******************************************************************************/
+
+inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
+{
+       void *ra;
+
+       /* Pn PowerPC the return address is located in the linkage
+          area. */
+
+       ra = *((void **) (((uintptr_t) sp) + stackframesize + LA_LR_OFFSET));
+
+       return ra;
+}
+
+
+/* md_codegen_get_pv_from_pc ***************************************************
+
+   Machine code:
+
+   7d6802a6    mflr    r11
+   39abffe0    addi    r13,r11,-32
+
+   or
+
+   7d6802a6    mflr    r11
+   3dabffff    addis   r13,r11,-1
+   39ad68b0    addi    r13,r13,26800
+
+*******************************************************************************/
+
+inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
+{
+       u1 *pv;
+       u4  mcode;
+       s4  offset;
+
+       /* get first instruction word after jump */
+
+       mcode = *((u4 *) (ra + 1 * 4));
+
+       /* check if we have 2 instructions (addis, addi) */
+
+       if ((mcode >> 16) == 0x3dab) {
+               /* get displacement of first instruction (addis) */
+
+               offset = (s4) (mcode << 16);
+
+               /* get displacement of second instruction (addi) */
+
+               mcode = *((u4 *) (ra + 2 * 4));
+
+               /* check for addi instruction */
+
+               assert((mcode >> 16) == 0x39ad);
+
+               offset += (s2) (mcode & 0x0000ffff);
+
+       } else {
+               /* check for addi instruction */
+
+               assert((mcode >> 16) == 0x39ab);
+
+               /* get offset of first instruction (addi) */
+
+               offset = (s2) (mcode & 0x0000ffff);
+       }
+
+       /* calculate PV via RA + offset */
+
+       pv = ra + offset;
+
+       return pv;
+}
+
+
+/* md_cacheflush ***************************************************************
+
+   Calls the system's function to flush the instruction and data
+   cache.
+
+*******************************************************************************/
+
+inline static void md_cacheflush(void *addr, int nbytes)
+{
+       asm_cacheflush(addr, nbytes);
+}
+
+
+/* md_icacheflush **************************************************************
+
+   Calls the system's function to flush the instruction cache.
+
+*******************************************************************************/
+
+inline static void md_icacheflush(void *addr, int nbytes)
+{
+       asm_cacheflush(addr, nbytes);
+}
+
+
+/* md_dcacheflush **************************************************************
+
+   Calls the system's function to flush the data cache.
+
+*******************************************************************************/
+
+inline static void md_dcacheflush(void *addr, int nbytes)
+{
+       asm_cacheflush(addr, nbytes);
+}
+
+#endif /* _VM_JIT_POWERPC_MD_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index a543d00a25592ac27efb00ad8639375e3faa9e4c..3c9a3b1e587f500bd63d41a4238cb93f94f7dd0d 100644 (file)
 
 #include "vm/types.h"
 
+#include "vm/jit/powerpc/md.h"
+
 #include "mm/memory.h"
+
 #include "native/native.h"
 
 #include "vm/builtin.h"
@@ -40,7 +43,6 @@
 #include "vm/initialize.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/md.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/stacktrace.h"
index 1fea8c0c131a93fd5b92bf52753fae5eb533621d..37da5a685c0a7cc49c0be39b277617ee8a3a509c 100644 (file)
@@ -241,7 +241,7 @@ L_asm_handle_exception_stack_loop:
        std     itmp3,LA_SIZE+PA_SIZE+(4+4)*8(sp)   /* save maybe-leaf flag (cleared)     */
 
        mr      a0,r0                       /* pass return address                */
-       bl      md_codegen_get_pv_from_pc   /* get PV from RA                     */
+       bl      md_asm_codegen_get_pv_from_pc   /* get PV from RA                 */
        std     v0,LA_SIZE+PA_SIZE+(4+2)*8(sp)      /* save data segment pointer          */
 
        ld      a0,LA_SIZE+PA_SIZE+(4+0)*8(sp)      /* pass xptr                          */
index 0bc598658875e1e99ae526f8c87ebb63640e68e7..488acfe5ae78ad3ef04de3440a743fd37e4bbc89 100644 (file)
@@ -54,7 +54,6 @@
 
 #include "vm/jit/abi.h"
 #include "vm/jit/abi-asm.h"
-#include "vm/jit/md.h"
 #include "vm/jit/asmpart.h"
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/dseg.h"
index 7701801b3255c5718c0f1a69defcc2c686fa4958..771551676f370e7c922c57eb3d7fe504ffb54e80 100644 (file)
@@ -34,6 +34,7 @@
 #include "vm/types.h"
 
 #include "vm/jit/powerpc64/codegen.h"
+#include "vm/jit/powerpc64/md.h"
 #include "vm/jit/powerpc64/linux/md-abi.h"
 
 #if defined(ENABLE_THREADS)
index e1c516f42f7a29a0d682ad726679d3765d69707a..4b5aab7190c7a19571f3afd0fe6f5f86e6c76dd3 100644 (file)
 #include "md-abi.h"
 
 #include "vm/jit/powerpc64/codegen.h"
+#include "vm/jit/powerpc64/md.h"
 
 #include "vm/exceptions.h"
 #include "vm/global.h"
 
-#include "vm/jit/asmpart.h"
-#include "vm/jit/codegen-common.h"
 #include "vm/jit/jit.h"
-#include "vm/jit/md.h"
 
 
 /* md_init *********************************************************************
@@ -57,25 +55,6 @@ void md_init(void)
 }
 
 
-/* md_stacktrace_get_returnaddress *********************************************
-
-   Returns the return address of the current stackframe, specified by
-   the passed stack pointer and the stack frame size.
-
-*******************************************************************************/
-
-u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
-{
-       u1 *ra;
-
-       /* on PowerPC the return address is located in the linkage area */
-
-       ra = *((u1 **) (sp + framesize + LA_LR_OFFSET));
-
-       return ra;
-}
-
-
 /* md_jit_method_patch_address *************************************************
 
    Gets the patch address of the currently compiled method. The offset
@@ -178,106 +157,6 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
 }
 
 
-/* md_codegen_get_pv_from_pc ***************************************************
-
-   Machine code:
-
-   7d6802a6    mflr    r11
-   39cbffe0    addi    r14,r11,-32
-
-   or
-
-   7d6802a6    mflr    r11
-   3dcbffff    addis   r14,r11,-1
-   39ce68b0    addi    r14,r13,26800
-
-*******************************************************************************/
-
-u1 *md_codegen_get_pv_from_pc(u1 *ra)
-{
-       u1 *pv;
-       u4  mcode;
-       s4  offset;
-
-       /* get first instruction word after jump */
-
-       mcode = *((u4 *) (ra + 1 * 4));
-
-       /* check if we have 2 instructions (addis, addi) */
-
-       if ((mcode >> 16) == 0x3dcb) {
-               /* get displacement of first instruction (addis) */
-
-               offset = (s4) (mcode << 16);
-
-               /* get displacement of second instruction (addi) */
-
-               mcode = *((u4 *) (ra + 2 * 4));
-
-               /* check for addi instruction */
-
-               assert((mcode >> 16) == 0x39ce);
-
-               offset += (s2) (mcode & 0x0000ffff);
-       }
-       else if ((mcode >> 16) == 0x39cb) {
-               /* get offset of first instruction (addi) */
-
-               offset = (s2) (mcode & 0x0000ffff);
-       }
-       else {
-               vm_abort("md_codegen_get_pv_from_pc: unknown instruction %x", mcode);
-
-               /* keep compiler happy */
-
-               offset = 0;
-       }
-
-       /* calculate PV via RA + offset */
-
-       pv = ra + offset;
-
-       return pv;
-}
-
-
-/* md_cacheflush ***************************************************************
-
-   Calls the system's function to flush the instruction and data
-   cache.
-
-*******************************************************************************/
-
-void md_cacheflush(u1 *addr, s4 nbytes)
-{
-       asm_cacheflush(addr, nbytes);
-}
-
-
-/* md_icacheflush **************************************************************
-
-   Calls the system's function to flush the instruction cache.
-
-*******************************************************************************/
-
-void md_icacheflush(u1 *addr, s4 nbytes)
-{
-       asm_cacheflush(addr, nbytes);
-}
-
-
-/* md_dcacheflush **************************************************************
-
-   Calls the system's function to flush the data cache.
-
-*******************************************************************************/
-
-void md_dcacheflush(u1 *addr, s4 nbytes)
-{
-       asm_cacheflush(addr, nbytes);
-}
-
-
 /* md_patch_replacement_point **************************************************
 
    Patch the given replacement point.
@@ -309,6 +188,7 @@ void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert)
 }
 #endif /* defined(ENABLE_REPLACEMENT) */
 
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where
diff --git a/src/vm/jit/powerpc64/md.h b/src/vm/jit/powerpc64/md.h
new file mode 100644 (file)
index 0000000..4a4d165
--- /dev/null
@@ -0,0 +1,179 @@
+/* src/vm/jit/powerpc64/md.h - machine dependent PowerPC functions
+
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _VM_JIT_POWERPC64_MD_H
+#define _VM_JIT_POWERPC64_MD_H
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "vm/jit/powerpc64/codegen.h"
+
+#include "vm/global.h"
+#include "vm/vm.h"
+
+#include "vm/jit/asmpart.h"
+#include "vm/jit/jit.h"
+
+
+/* md_stacktrace_get_returnaddress *********************************************
+
+   Returns the return address of the current stackframe, specified by
+   the passed stack pointer and the stack frame size.
+
+*******************************************************************************/
+
+inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
+{
+       void *ra;
+
+       /* On PowerPC64 the return address is located in the linkage
+          area. */
+
+       ra = *((void **) (((uintptr_t) sp) + stackframesize + LA_LR_OFFSET));
+
+       return ra;
+}
+
+
+/* md_codegen_get_pv_from_pc ***************************************************
+
+   Machine code:
+
+   7d6802a6    mflr    r11
+   39cbffe0    addi    r14,r11,-32
+
+   or
+
+   7d6802a6    mflr    r11
+   3dcbffff    addis   r14,r11,-1
+   39ce68b0    addi    r14,r13,26800
+
+*******************************************************************************/
+
+inline static u1 *md_codegen_get_pv_from_pc(u1 *ra)
+{
+       u1 *pv;
+       u4  mcode;
+       s4  offset;
+
+       /* get first instruction word after jump */
+
+       mcode = *((u4 *) (ra + 1 * 4));
+
+       /* check if we have 2 instructions (addis, addi) */
+
+       if ((mcode >> 16) == 0x3dcb) {
+               /* get displacement of first instruction (addis) */
+
+               offset = (s4) (mcode << 16);
+
+               /* get displacement of second instruction (addi) */
+
+               mcode = *((u4 *) (ra + 2 * 4));
+
+               /* check for addi instruction */
+
+               assert((mcode >> 16) == 0x39ce);
+
+               offset += (s2) (mcode & 0x0000ffff);
+       }
+       else if ((mcode >> 16) == 0x39cb) {
+               /* get offset of first instruction (addi) */
+
+               offset = (s2) (mcode & 0x0000ffff);
+       }
+       else {
+               vm_abort("md_codegen_get_pv_from_pc: unknown instruction %x", mcode);
+
+               /* keep compiler happy */
+
+               offset = 0;
+       }
+
+       /* calculate PV via RA + offset */
+
+       pv = ra + offset;
+
+       return pv;
+}
+
+
+/* md_cacheflush ***************************************************************
+
+   Calls the system's function to flush the instruction and data
+   cache.
+
+*******************************************************************************/
+
+inline static void md_cacheflush(void *addr, int nbytes)
+{
+       asm_cacheflush(addr, nbytes);
+}
+
+
+/* md_icacheflush **************************************************************
+
+   Calls the system's function to flush the instruction cache.
+
+*******************************************************************************/
+
+inline static void md_icacheflush(void *addr, int nbytes)
+{
+       asm_cacheflush(addr, nbytes);
+}
+
+
+/* md_dcacheflush **************************************************************
+
+   Calls the system's function to flush the data cache.
+
+*******************************************************************************/
+
+inline static void md_dcacheflush(void *addr, int nbytes)
+{
+       asm_cacheflush(addr, nbytes);
+}
+
+#endif /* _VM_JIT_POWERPC64_MD_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index e61b3627aa9de50d3446d44eb253eb8429c1eed6..b2ccfdeceb9c91ec385e3cf4a217125b4d6410e0 100644 (file)
@@ -32,6 +32,8 @@
 
 #include "vm/types.h"
 
+#include "vm/jit/powerpc64/md.h"
+
 #include "mm/memory.h"
 
 #include "native/native.h"
@@ -41,7 +43,6 @@
 #include "vm/initialize.h"
 
 #include "vm/jit/asmpart.h"
-#include "vm/jit/md.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/patcher-common.h"
 #include "vm/jit/stacktrace.h"
index c0b170231bfd8be55c1e4c2b871644bebbf7fc5f..c0c7ea52adb38d855d5dc5bed3cc6a20bdc92a68 100644 (file)
@@ -32,6 +32,7 @@
 #include <stdlib.h>
 
 #include "arch.h"
+#include "md.h"
 
 #if defined(ENABLE_GC_CACAO)
 # include "mm/cacao-gc/gc.h"
@@ -49,7 +50,6 @@
 #include "vm/jit/asmpart.h"
 #include "vm/jit/disass.h"
 #include "vm/jit/jit.h"
-#include "vm/jit/md.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/replace.h"
 #include "vm/jit/show.h"
index 1371bc1ccc9847ba207e6f031e54856bb1bf4f6e..52c6bbc46e8da20b40dd077522dc3075ef33b53d 100644 (file)
@@ -56,7 +56,6 @@
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/s390/codegen.h"
 
-#include <assert.h>
 
 /* prototypes *****************************************************************/
 
@@ -412,25 +411,6 @@ void md_critical_section_restart(ucontext_t *_uc)
 #endif
 
 
-/* md_stacktrace_get_returnaddress *********************************************
-
-   Returns the return address of the current stackframe, specified by
-   the passed stack pointer and the stack frame size.
-
-*******************************************************************************/
-
-u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
-{
-       u1 *ra;
-
-       /* on S390 the return address is located on the top of the stackframe */
-
-       ra = *((u1 **) (sp + framesize - 8));
-
-       return ra;
-}
-
-
 /* md_jit_method_patch_address *************************************************
 
    Gets the patch address of the currently compiled method. The offset
@@ -528,63 +508,6 @@ void *md_jit_method_patch_address(void* pv, void *ra, void *mptr)
 }
 
 
-/* md_codegen_get_pv_from_pc ***************************************************
-
-   On this architecture just a wrapper function to
-   codegen_get_pv_from_pc.
-
-*******************************************************************************/
-
-u1 *md_codegen_get_pv_from_pc(u1 *ra)
-{
-       u1 *pv;
-
-       /* Get the start address of the function which contains this
-       address from the method table. */
-
-       pv = codegen_get_pv_from_pc(ra);
-
-       return pv;
-}
-
-
-/* md_cacheflush ***************************************************************
-
-   Calls the system's function to flush the instruction and data
-   cache.
-
-*******************************************************************************/
-
-void md_cacheflush(u1 *addr, s4 nbytes)
-{
-       /* do nothing */
-}
-
-
-/* md_icacheflush **************************************************************
-
-   Calls the system's function to flush the instruction cache.
-
-*******************************************************************************/
-
-void md_icacheflush(u1 *addr, s4 nbytes)
-{
-       /* do nothing */
-}
-
-
-/* md_dcacheflush **************************************************************
-
-   Calls the system's function to flush the data cache.
-
-*******************************************************************************/
-
-void md_dcacheflush(u1 *addr, s4 nbytes)
-{
-       /* do nothing */
-}
-
-
 /* md_patch_replacement_point **************************************************
 
    Patch the given replacement point.
diff --git a/src/vm/jit/s390/md.h b/src/vm/jit/s390/md.h
new file mode 100644 (file)
index 0000000..cd9f977
--- /dev/null
@@ -0,0 +1,130 @@
+/* src/vm/jit/s390/md.h - machine dependent s390 Linux functions
+
+   Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _VM_JIT_S390_MD_H
+#define _VM_JIT_S390_MD_H
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "vm/jit/codegen-common.h"
+
+
+/* md_stacktrace_get_returnaddress *********************************************
+
+   Returns the return address of the current stackframe, specified by
+   the passed stack pointer and the stack frame size.
+
+*******************************************************************************/
+
+inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
+{
+       void *ra;
+
+       /* On S390 the return address is located on the top of the
+          stackframe. */
+
+       ra = *((void **) (((uintptr_t) sp) + stackframesize - 8));
+
+       return ra;
+}
+
+
+/* md_codegen_get_pv_from_pc ***************************************************
+
+   On this architecture just a wrapper function to
+   codegen_get_pv_from_pc.
+
+*******************************************************************************/
+
+inline static void *md_codegen_get_pv_from_pc(void *ra)
+{
+       void *pv;
+
+       /* Get the start address of the function which contains this
+       address from the method table. */
+
+       pv = codegen_get_pv_from_pc(ra);
+
+       return pv;
+}
+
+
+/* md_cacheflush ***************************************************************
+
+   Calls the system's function to flush the instruction and data
+   cache.
+
+*******************************************************************************/
+
+inline static void md_cacheflush(void *addr, int nbytes)
+{
+       /* do nothing */
+}
+
+
+/* md_icacheflush **************************************************************
+
+   Calls the system's function to flush the instruction cache.
+
+*******************************************************************************/
+
+inline static void md_icacheflush(void *addr, int nbytes)
+{
+       /* do nothing */
+}
+
+
+/* md_dcacheflush **************************************************************
+
+   Calls the system's function to flush the data cache.
+
+*******************************************************************************/
+
+inline static void md_dcacheflush(void *addr, int nbytes)
+{
+       /* do nothing */
+}
+
+#endif /* _VM_JIT_S390_MD_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index 73552d6e01e3b114c242dbdb48d07c9a4b74f6e1..caf2d003deb8f4591850efb02b7be285e9dfcafd 100644 (file)
@@ -1,6 +1,6 @@
-/* src/vm/jit/sparc64/md.c - machine dependent SPARC functions
+/* src/vm/jit/sparc64/md.c - machine dependent SPARC64 functions
 
-   Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
    J. Wenninger, Institut f. Computersprachen - TU Wien
@@ -47,11 +47,6 @@ void asm_store_fp_state_reg(u8 *mem);
 void asm_load_fp_state_reg(u8 *mem);
 
 
-
-/* shift away 13-bit immediate,  mask rd and rs1    */
-#define SHIFT_AND_MASK(instr) \
-       ((instr >> 13) & 0x60fc1)
-
 /* NOP is defined as a SETHI instruction with rd and imm. set to zero */
 /* therefore we check if the 22-bit immediate is zero */
 #define IS_SETHI(instr) \
@@ -89,108 +84,6 @@ void md_init(void)
 }
 
 
-/* md_stacktrace_get_returnaddress *********************************************
-
-   Returns the return address of the current stackframe, specified by
-   the passed stack pointer and the stack frame size.
-
-*******************************************************************************/
-
-u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
-{
-       u1 *ra;
-       /* flush register windows to the stack */
-       __asm__ ("flushw");
-
-       /* the return address resides in register i7, the last register in the
-        * 16-extended-word save area
-        */
-       ra = *((u1 **) (sp + 120 + BIAS));
-       
-       /* NOTE: on SPARC ra is the address of the call instruction */
-
-       return ra;
-}
-
-u1 *md_get_framepointer(u1 *sp)
-{
-       u1 *fp;
-       /* flush register windows to the stack */
-       __asm__ ("flushw");
-
-       fp = *((u1 **) (sp + 112 + BIAS));
-
-       return fp;
-}
-
-u1 *md_get_pv_from_stackframe(u1 *sp)
-{
-       u1 *pv;
-       /* flush register windows to the stack */
-       __asm__ ("flushw");
-
-       pv = *((u1 **) (sp + 104 + BIAS));
-
-       return pv;
-}
-
-
-/* md_codegen_get_pv_from_pc ***************************************************
-
-   This reconstructs and returns the PV of a method given a return address
-   pointer. (basically, same was as the generated code following the jump does)
-   
-   Machine code:
-
-   6b5b4000    jmpl    (pv)
-   10000000    nop
-   277afffe    ldah    pv,-2(ra)
-   237ba61c    lda     pv,-23012(pv)
-
-*******************************************************************************/
-
-u1 *md_codegen_get_pv_from_pc(u1 *ra)
-{
-       u1 *pv;
-       u8  mcode;
-       s4  offset;
-
-       pv = ra;
-
-       /* get the instruction word after jump and nop */
-       mcode = *((u4 *) (ra+8) );
-
-       /* check if we have a sethi insruction */
-       if (IS_SETHI(mcode)) {
-               s4 xor_imm;
-                               
-               /* get 22-bit immediate of sethi instruction */
-               offset = (s4) (mcode & 0x3fffff);
-               offset = offset << 10;
-               
-               /* now the xor */
-               mcode = *((u4 *) (ra+12) );
-               xor_imm = decode_13bit_imm(mcode);
-               
-               offset ^= xor_imm;       
-       }
-       else {
-               u4 mcode_masked;
-               
-               mcode_masked = SHIFT_AND_MASK(mcode);
-
-               assert(mcode_masked == 0x40001);
-
-               /* mask and extend the negative sign for the 13 bit immediate */
-               offset = decode_13bit_imm(mcode);
-       }
-       
-       pv += offset;
-
-       return pv;
-}
-
-
 /* md_jit_method_patch_address *************************************************
 
    Gets the patch address of the currently compiled method. The offset
@@ -320,33 +213,6 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
 }
 
 
-/* md_cacheflush ***************************************************************
-
-   Calls the system's function to flush the instruction and data
-   cache.
-
-*******************************************************************************/
-
-void md_cacheflush(u1 *addr, s4 nbytes)
-{
-       /* don't know yet */    
-}
-
-
-/* md_dcacheflush **************************************************************
-
-   Calls the system's function to flush the data cache.
-
-*******************************************************************************/
-
-void md_dcacheflush(u1 *addr, s4 nbytes)
-{
-       /* XXX don't know yet */        
-       /* printf("md_dcacheflush\n"); */
-       __asm__ __volatile__ ( "membar 0x7F" : : : "memory" );
-}
-
-
 /* md_patch_replacement_point **************************************************
 
    Patch the given replacement point.
diff --git a/src/vm/jit/sparc64/md.h b/src/vm/jit/sparc64/md.h
new file mode 100644 (file)
index 0000000..a66b255
--- /dev/null
@@ -0,0 +1,212 @@
+/* src/vm/jit/sparc64/md.c - machine dependent SPARC64 functions
+
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _VM_JIT_SPARC64_MD_H
+#define _VM_JIT_SPARC64_MD_H
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "vm/types.h"
+
+#include "vm/jit/codegen-common.h"
+
+
+/* md_stacktrace_get_returnaddress *********************************************
+
+   Returns the return address of the current stackframe, specified by
+   the passed stack pointer and the stack frame size.
+
+*******************************************************************************/
+
+inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
+{
+       void *ra;
+
+       /* flush register windows to the stack */
+       __asm__ ("flushw");
+
+       /* the return address resides in register i7, the last register in the
+        * 16-extended-word save area
+        */
+       ra = *((void **) (((uintptr_t) sp) + 120 + BIAS));
+       
+       /* NOTE: on SPARC ra is the address of the call instruction */
+
+       return ra;
+}
+
+inline static void *md_get_framepointer(void *sp)
+{
+       void *fp;
+
+       /* flush register windows to the stack */
+       __asm__ ("flushw");
+
+       fp = *((void **) (((uintptr_t) sp) + 112 + BIAS));
+
+       return fp;
+}
+
+inline static void *md_get_pv_from_stackframe(void *sp)
+{
+       void *pv;
+
+       /* flush register windows to the stack */
+       __asm__ ("flushw");
+
+       pv = *((void **) (((uintptr_t) sp) + 104 + BIAS));
+
+       return pv;
+}
+
+
+/* md_codegen_get_pv_from_pc ***************************************************
+
+   This reconstructs and returns the PV of a method given a return address
+   pointer. (basically, same was as the generated code following the jump does)
+   
+   Machine code:
+
+   6b5b4000    jmpl    (pv)
+   10000000    nop
+   277afffe    ldah    pv,-2(ra)
+   237ba61c    lda     pv,-23012(pv)
+
+*******************************************************************************/
+
+/* TODO Move these macros into the code generator. */
+
+/* shift away 13-bit immediate,  mask rd and rs1    */
+#define SHIFT_AND_MASK(instr) \
+       ((instr >> 13) & 0x60fc1)
+
+/* NOP is defined as a SETHI instruction with rd and imm. set to zero */
+/* therefore we check if the 22-bit immediate is zero */
+#define IS_SETHI(instr) \
+       (((instr & 0xc1c00000)  == 0x01000000) \
+       && ((instr & 0x3fffff) != 0x0))
+
+inline s2 decode_13bit_imm(u4 instr) {
+       s2 imm;
+
+       /* mask everything else in the instruction */
+       imm = instr & 0x00001fff;
+
+       /* sign extend 13-bit to 16-bit */
+       imm <<= 3;
+       imm >>= 3;
+
+       return imm;
+}
+
+inline static void *md_codegen_get_pv_from_pc(void *ra)
+{
+       uint8_t *pv;
+       u8  mcode;
+       s4  offset;
+
+       pv = ra;
+
+       /* get the instruction word after jump and nop */
+       mcode = *((u4 *) (ra+8) );
+
+       /* check if we have a sethi insruction */
+       if (IS_SETHI(mcode)) {
+               s4 xor_imm;
+                               
+               /* get 22-bit immediate of sethi instruction */
+               offset = (s4) (mcode & 0x3fffff);
+               offset = offset << 10;
+               
+               /* now the xor */
+               mcode = *((u4 *) (ra+12) );
+               xor_imm = decode_13bit_imm(mcode);
+               
+               offset ^= xor_imm;       
+       }
+       else {
+               u4 mcode_masked;
+               
+               mcode_masked = SHIFT_AND_MASK(mcode);
+
+               assert(mcode_masked == 0x40001);
+
+               /* mask and extend the negative sign for the 13 bit immediate */
+               offset = decode_13bit_imm(mcode);
+       }
+       
+       pv += offset;
+
+       return pv;
+}
+
+
+/* md_cacheflush ***************************************************************
+
+   Calls the system's function to flush the instruction and data
+   cache.
+
+*******************************************************************************/
+
+inline static void md_cacheflush(void *addr, int nbytes)
+{
+       /* don't know yet */    
+}
+
+
+/* md_dcacheflush **************************************************************
+
+   Calls the system's function to flush the data cache.
+
+*******************************************************************************/
+
+inline static void md_dcacheflush(void *addr, int nbytes)
+{
+       /* XXX don't know yet */        
+       /* printf("md_dcacheflush\n"); */
+       __asm__ __volatile__ ( "membar 0x7F" : : : "memory" );
+}
+
+#endif /* _VM_JIT_SPARC64_MD_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */
index ea8122b2da54f621eb308782afd08be6be88e6be..d20b2a793047d4c272bd6a1535f5d855c32839a7 100644 (file)
@@ -34,8 +34,9 @@
 
 #include "mm/memory.h"
 
-#include "vm/jit/sparc64/md-abi.h"
 #include "vm/jit/sparc64/codegen.h"
+#include "vm/jit/sparc64/md.h"
+#include "vm/jit/sparc64/md-abi.h"
 
 #include "native/native.h"
 #include "vm/builtin.h"
@@ -44,7 +45,6 @@
 
 #include "vm/jit/asmpart.h"
 #include "vm/jit/patcher.h"
-#include "vm/jit/md.h"
 #include "vm/jit/methodheader.h"
 #include "vm/jit/stacktrace.h"
 
@@ -56,6 +56,7 @@
 
 #include "vm/jit/sparc64/solaris/macro_rename.h"
 
+
 /* patcher_wrapper *************************************************************
 
    Wrapper for all patchers.  It also creates the stackframe info
index a6854317917c7822a369e1552b2637c03827b19c..077fcb8a9fd270b5453cc225c14fedbd7dac8dac 100644 (file)
@@ -34,6 +34,8 @@
 
 #include "vm/types.h"
 
+#include "md.h"
+
 #include "mm/gc-common.h"
 #include "mm/memory.h"
 
index e464e886527397904c21557e3f95cac8cfd0b6d4..f330178f1584277c0ac9959680872f436402e547 100644 (file)
@@ -120,7 +120,6 @@ void stacktrace_print_exception(java_handle_t *h);
 /* machine dependent functions (code in ARCH_DIR/md.c) */
 
 #if defined(ENABLE_JIT)
-u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize);
 # if defined(__SPARC_64__)
 u1 *md_get_framepointer(u1 *sp);
 u1 *md_get_pv_from_stackframe(u1 *sp);
index ced1cbee47c3965e4e7c78c5f8aaf40a28f5daff..fae1c417f7a688b915f2514821dfb0686869de46 100644 (file)
@@ -37,6 +37,7 @@
 #include "vm/types.h"
 
 #include "vm/jit/x86_64/codegen.h"
+#include "vm/jit/x86_64/md.h"
 
 #if defined(ENABLE_THREADS)
 # include "threads/native/threads.h"
index c28d38584f172f4809478c4014ab086029d59317..dc4b3fab1820ca149ac1d34817c35a15200c9e92 100644 (file)
@@ -37,7 +37,6 @@
 
 #include "vm/jit/codegen-common.h"
 #include "vm/jit/jit.h"
-#include "vm/jit/md.h"
 
 
 /* md_init *********************************************************************
@@ -52,25 +51,6 @@ void md_init(void)
 }
 
 
-/* md_stacktrace_get_returnaddress *********************************************
-
-   Returns the return address of the current stackframe, specified by
-   the passed stack pointer and the stack frame size.
-
-*******************************************************************************/
-
-u1 *md_stacktrace_get_returnaddress(u1 *sp, u4 framesize)
-{
-       u1 *ra;
-
-       /* on x86_64 the return address is above the current stack frame */
-
-       ra = *((u1 **) (sp + framesize));
-
-       return ra;
-}
-
-
 /* md_jit_method_patch_address *************************************************
 
    Gets the patch address of the currently compiled method. The offset
@@ -157,63 +137,6 @@ void *md_jit_method_patch_address(void *pv, void *ra, void *mptr)
 }
 
 
-/* md_codegen_get_pv_from_pc ***************************************************
-
-   On this architecture just a wrapper function to
-   codegen_get_pv_from_pc.
-
-*******************************************************************************/
-
-u1 *md_codegen_get_pv_from_pc(u1 *ra)
-{
-       u1 *pv;
-
-       /* Get the start address of the function which contains this
-       address from the method table. */
-
-       pv = codegen_get_pv_from_pc(ra);
-
-       return pv;
-}
-
-
-/* md_cacheflush ***************************************************************
-
-   Calls the system's function to flush the instruction and data
-   cache.
-
-*******************************************************************************/
-
-void md_cacheflush(u1 *addr, s4 nbytes)
-{
-       /* do nothing */
-}
-
-
-/* md_icacheflush **************************************************************
-
-   Calls the system's function to flush the instruction cache.
-
-*******************************************************************************/
-
-void md_icacheflush(u1 *addr, s4 nbytes)
-{
-       /* do nothing */
-}
-
-
-/* md_dcacheflush **************************************************************
-
-   Calls the system's function to flush the data cache.
-
-*******************************************************************************/
-
-void md_dcacheflush(u1 *addr, s4 nbytes)
-{
-       /* do nothing */
-}
-
-
 /* md_patch_replacement_point **************************************************
 
    Patch the given replacement point.
@@ -244,6 +167,7 @@ void md_patch_replacement_point(u1 *pc, u1 *savedmcode, bool revert)
 }
 #endif /* defined(ENABLE_REPLACEMENT) */
 
+
 /*
  * These are local overrides for various environment variables in Emacs.
  * Please do not remove this and leave it at the end of the file, where
diff --git a/src/vm/jit/x86_64/md.h b/src/vm/jit/x86_64/md.h
new file mode 100644 (file)
index 0000000..ffe59b4
--- /dev/null
@@ -0,0 +1,132 @@
+/* src/vm/jit/x86_64/md.c - machine dependent x86_64 functions
+
+   Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
+   C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
+   E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
+   J. Wenninger, Institut f. Computersprachen - TU Wien
+
+   This file is part of CACAO.
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA.
+
+*/
+
+
+#ifndef _VM_JIT_X86_64_MD_H
+#define _VM_JIT_X86_64_MD_H
+
+#include "config.h"
+
+#include <assert.h>
+#include <stdint.h>
+
+#include "vm/jit/codegen-common.h"
+
+
+/* inline functions ***********************************************************/
+
+/* md_stacktrace_get_returnaddress *********************************************
+
+   Returns the return address of the current stackframe, specified by
+   the passed stack pointer and the stack frame size.
+
+*******************************************************************************/
+
+inline static void *md_stacktrace_get_returnaddress(void *sp, int32_t stackframesize)
+{
+       void *ra;
+
+       /* On x86_64 the return address is above the current stack
+          frame. */
+
+       ra = *((void **) (((uintptr_t) sp) + stackframesize));
+
+       return ra;
+}
+
+
+/* md_codegen_get_pv_from_pc ***************************************************
+
+   On this architecture just a wrapper function to
+   codegen_get_pv_from_pc.
+
+*******************************************************************************/
+
+inline static void *md_codegen_get_pv_from_pc(void *ra)
+{
+       void *pv;
+
+       /* Get the start address of the function which contains this
+       address from the method table. */
+
+       pv = codegen_get_pv_from_pc(ra);
+
+       return pv;
+}
+
+
+/* md_cacheflush ***************************************************************
+
+   Calls the system's function to flush the instruction and data
+   cache.
+
+*******************************************************************************/
+
+inline static void md_cacheflush(u1 *addr, s4 nbytes)
+{
+       /* do nothing */
+}
+
+
+/* md_icacheflush **************************************************************
+
+   Calls the system's function to flush the instruction cache.
+
+*******************************************************************************/
+
+inline static void md_icacheflush(u1 *addr, s4 nbytes)
+{
+       /* do nothing */
+}
+
+
+/* md_dcacheflush **************************************************************
+
+   Calls the system's function to flush the data cache.
+
+*******************************************************************************/
+
+inline static void md_dcacheflush(u1 *addr, s4 nbytes)
+{
+       /* do nothing */
+}
+
+#endif /* _VM_JIT_X86_64_MD_H */
+
+
+/*
+ * These are local overrides for various environment variables in Emacs.
+ * Please do not remove this and leave it at the end of the file, where
+ * Emacs will automagically detect them.
+ * ---------------------------------------------------------------------
+ * Local variables:
+ * mode: c
+ * indent-tabs-mode: t
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim:noexpandtab:sw=4:ts=4:
+ */