-/* asm_call_jit_compiler ************************************************************************************
- * Invokes compiler for untranslated java methods.
- * C prototype: void asm_call_jit_compiler(void);
- * BUT: this does not match reality, arguments _ARE_ passed via createcompilerstub and asm_vm_call_method...
- * arguments passed via %a2(methodinfo) == REG_ATMP1
- * %a3(mptr) == REG_ATMP2
- ************************************************************************************************************/
-asm_call_jit_compiler:
- addal #(-4*4),%sp /* create stackframe to save registers */
- moveml %a0/%a1/%d0/%d1,%sp@ /* save volatile registers */
-#if !defined(ENABLE_SOFTFLOAT)
- addal #-8*2, %sp
- fmovemd %fp0/%fp1, %sp@
- movel %sp@(8*4), %sp@-
- pea %sp@(8*4+8)
-#else
- movel %sp@(4*4), %sp@- /* push arguments onto stack (ra)*/
- pea %sp@(4*4+8) /* the old stack pointer*/
-#endif
- movel %a3,%sp@- /* mptr */
- movel %a2,%sp@- /* methodinfo */
-
- /* C prototype: u1 *jit_asm_compile(methodinfo *m, u1 *mptr, u1 *sp, u1 *ra); */
- jsr jit_asm_compile /* invoke compiler */
- addal #(4*4),%sp /* pop arguments off stack */
- moveal %d0, %a2 /* to tmp register */
-
-#if !defined(ENABLE_SOFTFLOAT)
- fmovemd %sp@, %fp0/%fp1
- addal #8*2, %sp
-#endif
-
- moveml %sp@,%a0/%a1/%d0/%d1 /* restore volatile registers */
- addal #(4*4),%sp /* remove stackframe */
-
- tstl %a2 /* check for exception */
- beq L_asm_call_jit_compiler_exception
-
- jmp %a2@ /* invoke java method */
- jsr 0 /* we should not ever return here */
-
-L_asm_call_jit_compiler_exception:
- jsr exceptions_get_and_clear_exception /* exception object in %d0 now */
- moveal %d0, %a2 /* move exception object into sptr register */
- moveal %sp@+, %a3 /* pop return address into exception address reg */
- jmp asm_handle_exception /* handle exception */
-
-
-/* asm_patcher_wrapper ********************************************************
-
- prepares arguments on stack
- calls patcher_wrapper signature: java_objectheader *patcher_wrapper(u1 *sp, u1 *pv, u1 *ra);
-
- Stack layout:
- 24 return address
- 20 REG_ITMP3
- 16 pointer to virtual java_objectheader
- 12 last byte of machine code (xmcode)
- 8 machine code (which is patched back later)
- 4 unresolved field reference
- 0 patcher function pointer to call
-*******************************************************************************/
-asm_patcher_wrapper:
-
- /* save scratch registers */
- movel %a0, %sp@-
- movel %a1, %sp@-
- movel %d0, %sp@-
- movel %d1, %sp@-
-
-#if defined(ENABLE_SOFTFLOAT)
- /* calculate original value of sp */
- movel %sp, %d0
- addil #4*4, %d0
-#else
- addal #-8*2, %sp
- fmovemd %fp0/%fp1, %sp@
-
- movel %sp, %d0
- addil #8*4, %d0
-#endif
-
- clrl %sp@- /* pass ra */
- clrl %sp@- /* pass pv, if null use findmethod */
- movel %d0, %sp@- /* pass sp of patcher stub */
- jsr patcher_wrapper /* return value in %d0 */
-
- lea %sp@(3*4), %sp /* pop arguments off stack */
- tst %d0 /* test if exception occured */
- bne L_asm_patcher_wrapper_exception
-
-#if !defined(ENABLE_SOFTFLOAT)
- fmovemd %sp@, %fp0/%fp1
- addal #8*2, %sp
-#endif
- movel %sp@+, %d1
- movel %sp@+, %d0
- movel %sp@+, %a1
- movel %sp@+, %a0
-
- lea %sp@(6*4), %sp /* restore stack and remove patcher stub*/
- rts /* back to jit code */
-
-L_asm_patcher_wrapper_exception:
- /* WARNING: the stack is still disturbed, look at asm_patcher_wrapper for details */
- /* we do not need to restore the content of the registers, I hope */
-#if !defined(ENABLE_SOFTFLOAT)
- lea %sp@(8*4), %sp
-#else
- lea %sp@(4*4), %sp
-#endif
-
- lea %sp@(5*4), %sp /* restore stack and remove patcher stub*/
- movel %sp@+, %d4 /* restore REG_ITMP3, stored in emit_patcher_stubs */
- moveal %d0, %a2 /* xptr, pointer to exception object */
- moveal %sp@+, %a3 /* pop return address into exception address register */
- jmp asm_handle_exception /* handle exception */
- illegal /* XXX: we never come back */
-
-/********************************************************************************
- Reads a few values atomically.
- C signature:
- void asm_getclassvalues_atomic(vftbl_t *super, vftbl_t *sub, castinfo *out);
-
- super ... sp@(4)
- sub ... sp@(8)
- out ... sp@(12)
-********************************************************************************/
-asm_getclassvalues_atomic:
-_crit_restart:
-_crit_begin:
- moveal %sp@(4), %a0
- movel %a0@(offbaseval), %d0
- movel %a0@(offdiffval), %d1
-
- moveal %sp@(8), %a0
- moveal %a0@(offbaseval), %a0
-_crit_end:
- moveal %sp@(12), %a1
- movel %d0, %a1@(offcast_super_baseval)
- movel %d1, %a1@(offcast_super_diffval)
- movel %a0, %a1@(offcast_sub_baseval)
-
- rts
-.data
-asm_criticalsections:
-#if defined(ENABLE_THREADS)
- .long _crit_begin
- .long _crit_end
- .long _crit_restart
-#endif
- .long 0
-.text
-