X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=src%2Fvm%2Fjit%2Farm%2Fasmpart.S;h=a5154c1db68acfab4b245681f82630ce3f34e21f;hb=9f859ad50d3d5d98c185d40b86b2179bc4dc9aeb;hp=ff95759430d0a2c356e854d359eab3712ccc876a;hpb=d618789d14ccf54bd2f7343f67763983158d1b3b;p=cacao.git diff --git a/src/vm/jit/arm/asmpart.S b/src/vm/jit/arm/asmpart.S index ff9575943..a5154c1db 100644 --- a/src/vm/jit/arm/asmpart.S +++ b/src/vm/jit/arm/asmpart.S @@ -22,14 +22,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - $Id: asmpart.S 7454 2007-03-05 15:40:48Z tbfg $ - */ #include "config.h" -#include "vm/jit/arm/offsets.h" #include "vm/jit/arm/md-asm.h" #include "vm/jit/methodheader.h" @@ -57,30 +54,13 @@ .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_jitcompilerptr: - .word asm_call_jit_compiler - -asm_criticalsections: -#if defined(ENABLE_THREADS) - .word _crit_begin - .word _crit_end - .word _crit_restart -#endif - .word 0 - /* asm_vm_call_method ********************************************************** @@ -114,70 +94,45 @@ asm_vm_call_method_long: /* 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 recompute SP ... */ - mov v1, #0 /* ... when using stack arguments */ - ldr ip, asm_jitcompilerptr - str ip, [sp, #-4]! /* store fake address */ - mov mptr, sp /* set method pointer */ + stmfd sp!, {v1} /* V1 is used to remember SP */ + str a0, [sp, #-4]! /* store methods entrypoint */ - mov itmp1, a0 /* pass methodinfo* via ITMP1 */ + mov v1, sp /* remember SP */ - cmp a1, #0 /* do we have arguments? */ - ble asm_calljava_copyfinish /* no -> do not care :-) */ + mov itmp1, a1 /* address of data structure */ + mov itmp3, a2 /* stack argument count */ + + ldr a0, [itmp1], #8 /* load argument registers */ + ldr a1, [itmp1], #8 + ldr a2, [itmp1], #8 + ldr a3, [itmp1], #8 - /* REMEMBER: stack space for arguments is reserved here! */ - /* TODO: we possibly reserve to much here */ - mov v1, a1, lsl #3 /* how much stack do we alloc? */ - sub sp, sp, v1 /* allocate stack for arguments! */ + cmp itmp3, #0 /* do we have stack arguments? */ + ble asm_calljava_copyfinish /* no -> do not care :-) */ - mov itmp3, #0 /* stack position */ + mov itmp2, #0 + sub sp, sp, itmp3, lsl #3 /* create stackframe for arguments */ asm_calljava_copyloop: /* reorder stack arguments! */ -#if defined(__ARMEL__) - ldr ip, [a2,#offvmargdata] /* get LOW word of argument */ - str ip, [sp, itmp3] - add itmp3, itmp3, #4 - ldr ip, [a2,#offvmargtype] /* is it a 2_WORD_TYPE? */ - tst ip, #1 - ldrne ip, [a2,#offvmargdata + 4] /* yes -> get HIGH word of argument */ - strne ip, [sp, itmp3] - addne itmp3, itmp3, #4 -#else /* defined(__ARMEB__) */ - ldr ip, [a2,#offvmargtype + 4] /* get our item type (it is u8) */ - teq ip, #2 /* is it a TYPE_FLOAT? */ - ldreq ip, [a2,#offvmargdata] /* yes -> get LOW word of float */ - streq ip, [sp, itmp3] - addeq itmp3, itmp3, #4 - beq asm_calljava_copydone - tst ip, #1 /* is it a 2_WORD_TYPE? */ - ldrne ip, [a2,#offvmargdata] /* yes -> get HIGH word of argument */ - strne ip, [sp, itmp3] - addne itmp3, itmp3, #4 - ldr ip, [a2,#offvmargdata + 4] /* get LOW word of argument */ - str ip, [sp, itmp3] - add itmp3, itmp3, #4 -asm_calljava_copydone: -#endif - add a2, a2, #sizevmarg /* next argument block */ - subs a1, a1, #1 + ldr ip, [itmp1], #4 /* load argument */ + str ip, [sp, itmp2] /* store argument on stack */ + add itmp2, itmp2, #4 /* next stackslot */ + ldr ip, [itmp1], #4 /* load argument */ + str ip, [sp, itmp2] /* store argument on stack */ + add itmp2, itmp2, #4 /* next stackslot */ + subs itmp3, itmp3, #1 /* next argument */ bgt asm_calljava_copyloop - /* REMEMBER: first four args are passed in regs, take them out again */ - ldmfd sp, {a0, a1, a2, a3} /* load first four args to register */ - cmp v1, #16 /* do we have four arguments? */ - addlt sp, sp, v1 - movlt v1, #0 - addge sp, sp, #16 - subge v1, v1, #16 - asm_calljava_copyfinish: + mov mptr, v1 /* set method pointer */ + /* REMEMBER: do the method call just like in java! */ ldr ip, [mptr] /* fake virtual function call */ - mov lr, pc - mov pc, ip -fake2: - sub ip, pc, #(fake2 - asm_vm_call_method)+8 + mov lr, pc + mov pc, ip +fake: + sub ip, pc, #(fake - asm_vm_call_method)+8 - add sp, sp, v1 /* free stack arguments! */ + mov sp, v1 /* restore SP */ add sp, sp, #4 /* free fake address */ ldmfd sp!, {v1} RESTORE_SCRATCH_REGS_AND_RETURN /* return to caller, restore regs */ @@ -187,18 +142,19 @@ asm_vm_call_method_exception_handler: bl builtin_throw_exception /* throw the exception */ mov res1, #0 /* return NULL */ mov res2, #0 /* return NULL */ - add sp, sp, v1 /* free stack arguments! */ + mov sp, v1 /* restore SP */ add sp, sp, #4 /* free fake address */ ldmfd sp!, {v1} RESTORE_SCRATCH_REGS_AND_RETURN /* return to caller, restore regs */ asm_vm_call_method_float: - mov a0,#0x51 - b asm_debug + mov a0,#0x51 + b asm_debug asm_vm_call_method_double: - mov a0,#0x52 + mov a0,#0x52 + b asm_debug + asm_vm_call_method_end: - b asm_debug /****************** function asm_call_jit_compiler ***************************** @@ -331,57 +287,6 @@ asm_handle_exception_not_catched: b asm_handle_exception_loop -/* asm_patcher_wrapper ********************************************************* -* * -* TODO: document me * -* * -* Stack layout when calling patcher function: * -* 24 saved REG_ITMP3, should be restored ( -4) * -* 20 data segment displacement from load instructions ( -8) * -* 16 return address into JIT code (patch position) (-12) * -* 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 */ - - tst itmp3, itmp3 /* check for an exception */ - bne L_asm_patcher_wrapper_exception - - add sp, sp, #PATCHSTACKSIZE /* remove patcher stack frame */ - - 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 */ - - add sp, sp, #PATCHSTACKSIZE /* remove patcher stack frame */ - - b asm_handle_exception - - /* asm_abstractmethoderror ***************************************************** Creates and throws an AbstractMethodError. @@ -427,27 +332,10 @@ asm_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 - - -/* Disable exec-stacks, required for Gentoo ***********************************/ +/* disable exec-stacks ********************************************************/ -#if defined(__GCC__) && defined(__ELF__) - .section .note.GNU-stack,"",@progbits +#if defined(__linux__) && defined(__ELF__) + .section .note.GNU-stack,"",%progbits #endif