Merged trunk and subtype.
[cacao.git] / src / vm / jit / arm / asmpart.S
index 99e16a9f3ea7ead2887203a86e5a1eebc3b8f97e..d3f4b93fdddcc5802cb94e47dfe1b484b5dd327c 100644 (file)
@@ -1,9 +1,7 @@
 /* src/vm/jit/arm/asmpart.S - Java-C interface functions for ARM
 
-   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
+   Copyright (C) 1996-2005, 2006, 2007, 2008
+   CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
 
    This file is part of CACAO.
 
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: asmpart.S 8127 2007-06-21 11:55:56Z michi $
-
 */
 
 
 #include "config.h"
 
-#include "vm/jit/arm/offsets.h"
+#include <sys/syscall.h>
+
 #include "vm/jit/arm/md-asm.h"
 
 #include "vm/jit/methodheader.h"
 
        .globl asm_abstractmethoderror
 
-       .globl asm_patcher_wrapper
-
        .globl asm_cacheflush
 
-       .globl asm_getclassvalues_atomic
-       .globl asm_criticalsections
-
-
-#if !defined(ENABLE_THREADS)
-asm_exceptionptr:
-       .word _no_threads_exceptionptr
-#endif
-
-asm_criticalsections:
-#if defined(ENABLE_THREADS)
-       .word _crit_begin
-       .word _crit_end
-       .word _crit_restart
-#endif
-       .word 0
-
 
 /* asm_vm_call_method **********************************************************
 
@@ -91,25 +69,17 @@ asm_criticalsections:
 
        .align  2
 
-       .word   0                           /* catch type all                     */
-       .word   0                           /* handler pc                         */
-       .word   0                           /* end pc                             */
-       .word   0                           /* start pc                           */
-       .word   1                           /* extable size                       */
-       .word   0                           /* line number table start            */
-       .word   0                           /* line number table size             */
        .word   0                           /* FltSave                            */
        .word   0                           /* IntSave                            */
        .word   0                           /* IsLeaf                             */
-       .word   0                           /* IsSync                             */
        .word   0                           /* FrameSize                          */
        .word   0                           /* CodeinfoPointer                    */
 
 asm_vm_call_method:
 asm_vm_call_method_int:
 asm_vm_call_method_long:
-/* asm_vm_call_method_float:
-asm_vm_call_method_double: */
+asm_vm_call_method_float:
+asm_vm_call_method_double:
        SAVE_SCRATCH_REGISTERS            /* save our personal scratch regs   */
        stmfd sp!, {v1}                   /* V1 is used to remember SP        */
        str   a0, [sp, #-4]!              /* store methods entrypoint         */
@@ -164,13 +134,6 @@ asm_vm_call_method_exception_handler:
        ldmfd sp!, {v1}
        RESTORE_SCRATCH_REGS_AND_RETURN   /* return to caller, restore regs   */
 
-asm_vm_call_method_float:
-       mov a0,#0x51
-       b asm_debug
-asm_vm_call_method_double:
-       mov a0,#0x52
-       b asm_debug
-
 asm_vm_call_method_end:
 
 
@@ -240,7 +203,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 */
@@ -297,66 +260,13 @@ 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  
 
        b     asm_handle_exception_loop
 
 
-/* asm_patcher_wrapper *********************************************************
-*                                                                              *
-*   TODO: document me                                                          *
-*                                                                              *
-*   Stack layout when calling patcher function:                                *
-*    28   empty because stack needs to be aligned                              *
-*    24   saved REG_ITMP3, should be restored                ( -8)             *
-*    20   data segment displacement from load instructions   (-12)             *
-*    16   return address into JIT code (patch position)      (-16)             *
-*    12   pointer to virtual java_objectheader                                 *
-*     8   machine code (which is patched back later)                           *
-*   [ 8   result of patcher function (indicates exception)  ]                  *
-*     4   unresolved class/method/field reference                              *
-*   [ 0   patcher function pointer to call                  ]                  *
-*     0   saved IP of caller (caller needs it!)                                *
-*                                                                              *
-*******************************************************************************/
-
-#define PATCHSTACKSIZE 8*4
-
-asm_patcher_wrapper:
-       mov   itmp3, sp                     /* preserve original SP in ITMP3      */
-
-       SAVE_ARGUMENT_REGISTERS_IP          /* save our argument registers & LR   */
-       SAVE_FLOAT_REGISTERS                /* save our float registers here      */
-
-       mov   a0, itmp3                     /* pass SP of patcher stub            */
-       mov   a1, ip                        /* pass PV                            */
-       mov   a2, lr                        /* pass RA (correct for leafs)        */
-       bl    patcher_wrapper
-       mov   itmp3, res1                   /* save return value                  */
-
-       RESTORE_FLOAT_REGISTERS             /* restore our float registers here   */
-       RESTORE_ARGUMENT_REGISTERS_IP       /* load our argument registers & LR   */
-
-       add   sp, sp, #PATCHSTACKSIZE       /* remove patcher stack frame         */
-
-       tst   itmp3, itmp3                  /* check for an exception             */
-       bne   L_asm_patcher_wrapper_exception
-
-       ldr   itmp3, [sp, #-8]              /* restore ITMP3 for calling method   */
-       ldr   pc, [sp, #-16]                /* jump to new patched code           */
-
-L_asm_patcher_wrapper_exception:
-       mov   xptr, itmp3                   /* get exception                      */
-       ldr   xpc, [sp, #-16]               /* RA is xpc                          */
-
-       /* Note: A normal branch instruction could modify the PV here,            */
-       /*       so we use this construct instead.                                */
-       ldr   pc, [pc, #-4]
-       .word asm_handle_exception
-
-
 /* asm_abstractmethoderror *****************************************************
 
    Creates and throws an AbstractMethodError.
@@ -383,39 +293,32 @@ asm_abstractmethoderror:
 *                                                                              *
 *******************************************************************************/
 
-#if 1
-.equ sys_cacheflush, 0x9f0002
+L___ARM_NR_cacheflush:
+       .align 2
+       .word __ARM_NR_cacheflush
+
 asm_cacheflush:
        add   a1, a0, a1
        mov   a2, #0
 
-#if 0
+#if defined(__ARM_EABI__)
+       /* According to EABI, the syscall number should be passed via R7,
+          see "http://wiki.debian.org/ArmEabiPort" for additional details. */
+
+       stmfd sp!, {r7}
+       ldr   r7, L___ARM_NR_cacheflush
+       swi   0x0
+       ldmfd sp!, {r7}
+#else
+# if 0
        /* TWISTI: required on iyonix, maybe a linux-2.4 bug */
-       /* TODO: repeair this! */
-       /* cacheflush is messed up beyond all repair! */
-       mov a0, #0x0
-       mov a1, #0xff000000
-#endif
+       mov   a0, #0x0
+       mov   a1, #0xff000000
+# endif
 
-       swi   #sys_cacheflush
-       mov   pc, lr
+       swi   __ARM_NR_cacheflush
 #endif
 
-
-/********************* function asm_getclassvalues_atomic *********************/
-
-asm_getclassvalues_atomic:
-       stmfd sp!, {r4, r5, r6}
-_crit_restart:
-_crit_begin:
-       ldr   r4,[a0,#offbaseval]
-       ldr   r5,[a0,#offdiffval]
-       ldr   r6,[a1,#offbaseval]
-_crit_end:
-       str   r4,[a2,#offcast_super_baseval]
-       str   r5,[a2,#offcast_super_diffval]
-       str   r6,[a2,#offcast_sub_baseval]
-       ldmfd sp!, {r4, r5, r6}
        mov   pc, lr