1 /* jit/mips/asmpart.S - Java-C interface functions for mips
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 Institut f. Computersprachen, TU Wien
5 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Probst,
6 S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich,
9 This file is part of CACAO.
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2, or (at
14 your option) any later version.
16 This program is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 Contact: cacao@complang.tuwien.ac.at
28 Authors: Andreas Krall
30 $Id: asmpart.S 902 2004-01-22 21:38:58Z twisti $
127 #define aaddiu daddiu
134 #define MethodPointer -8
135 #define FrameSize -12
140 #define ExTableSize -32
141 #define ExTableStart -32
143 #define ExEntrySize -32
146 #define ExHandlerPC -24
147 #define ExCatchType -32
154 /********************* exported functions and variables ***********************/
156 .globl synchronize_caches
157 .globl asm_calljavafunction
158 .globl asm_calljavafunction2
159 .globl asm_calljavafunction2long
160 .globl asm_calljavafunction2double
161 .globl asm_call_jit_compiler
162 .globl asm_dumpregistersandcall
163 .globl asm_handle_exception
164 .globl asm_handle_nat_exception
165 .globl asm_check_clinit
166 .globl asm_builtin_checkarraycast
167 .globl asm_builtin_checkcast
168 .globl asm_builtin_aastore
169 .globl asm_builtin_monitorenter
170 .globl asm_builtin_monitorexit
171 .globl asm_builtin_idiv
172 .globl asm_builtin_irem
173 .globl asm_builtin_ldiv
174 .globl asm_builtin_lrem
175 .globl asm_perform_threadswitch
176 .globl asm_initialize_thread_stack
177 .globl asm_switchstackandcall
178 .globl asm_getcallingmethod
179 .globl asm_builtin_trace
180 .globl asm_builtin_exittrace
183 /*************************** imported functions *******************************/
186 .globl builtin_monitorexit
187 .globl builtin_throw_exception
188 .globl builtin_trace_exception
189 .globl class_java_lang_Object
192 /********************* function synchronize_caches ****************************/
194 .ent synchronize_caches
197 /* li a0,BCACHE */ /* flush both caches */
198 /* li v0,SYS_cacheflush */ /* Syscall number for cacheflush() */
199 /* syscall */ /* call cacheflush() */
202 .end synchronize_caches
205 /********************* function asm_calljavafunction ****************************
207 * This function calls a Java-method (which possibly needs compilation) *
208 * with up to 4 address parameters. *
210 * This functions calls the JIT-compiler which eventually translates the *
211 * method into machine code. *
213 * A possibly throwed exception will be returned to the caller as function *
214 * return value, so the java method cannot return a fucntion value (this *
215 * function usually calls 'main' and '<clinit>' which do not return a *
219 * javaobject_header *asm_calljavafunction (methodinfo *m, *
220 * void *arg1, void *arg2, void *arg3, void *arg4); *
222 *******************************************************************************/
224 .ent asm_calljavafunction
227 .ascii "calljavafunction\0\0"
230 .quad 0 /* catch type all */
231 .quad calljava_xhandler /* handler pc */
232 .quad calljava_xhandler /* end pc */
233 .quad asm_calljavafunction /* start pc */
234 .long 1 /* extable size */
235 .long 0 /* fltsave */
236 .long 0 /* intsave */
239 .long 80 /* frame size */
240 .quad 0 /* method pointer (pointer to name) */
242 asm_calljavafunction:
243 aaddiu sp,sp,-10*8 /* allocate stack space */
244 sd ra,0(sp) /* save return address */
248 sd pv,3*8(sp) /* procedure vector */
254 sdc1 fss0,4*8(sp) /* save non JavaABI saved flt registers */
260 sd a0,2*8(sp) /* save method pointer for compiler */
261 aaddiu itmp1,sp,16 /* pass pointer to methodptr via itmp1 */
263 move a0,a1 /* pass the remaining parameters */
268 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
269 ast mptr,1*8(sp) /* store function address */
270 move mptr,sp /* set method pointer */
274 ald pv,1*8(mptr) /* method call as in Java */
275 jalr pv /* call JIT compiler */
277 aaddiu pv,ra,-23*4 /* recompute procedure vector */
279 move v0,zero /* clear return value (exception ptr) */
285 ld ra,0(sp) /* restore return address */
286 ld pv,3*8(sp) /* restore procedure vector */
288 ldc1 fss0,4*8(sp) /* restore non JavaABI saved flt regs */
295 aaddiu sp,sp,10*8 /* free stack space */
301 jal builtin_throw_exception
304 .end asm_calljavafunction
307 .ent asm_calljavafunction2
310 .ascii "calljavafunction2\0\0"
313 .quad 0 /* catch type all */
314 .quad calljava_xhandler2 /* handler pc */
315 .quad calljava_xhandler2 /* end pc */
316 .quad asm_calljavafunction2 /* start pc */
317 .long 1 /* extable size */
318 .long 0 /* fltsave */
319 .long 1 /* intsave */
322 .long 96 /* frame size */
323 .quad 0 /* method pointer (pointer to name) */
325 asm_calljavafunction2:
326 asm_calljavafunction2double:
327 asm_calljavafunction2long:
328 aaddiu sp,sp,-12*8 /* allocate stack space (only 11 needed)*/
329 sd ra,0(sp) /* save return address */
333 sd pv,1*8(sp) /* procedure vector */
340 sdc1 fss0,5*8(sp) /* save non JavaABI saved flt registers */
346 sd a0,4*8(sp) /* save method pointer for compiler */
350 blez s7,calljava_argsloaded
351 ald a0,offjniitem(t0)
352 ldc1 fa0,offjniitem(t0)
354 blez s7,calljava_argsloaded
356 ald a1,offjniitem+sizejniblock*1(t0)
357 ldc1 fa1,offjniitem+sizejniblock*1(t0)
359 blez s7,calljava_argsloaded
361 ald a2,offjniitem+sizejniblock*2(t0)
362 ldc1 fa2,offjniitem+sizejniblock*2(t0)
364 blez s7,calljava_argsloaded
366 ald a3,offjniitem+sizejniblock*3(t0)
367 ldc1 fa3,offjniitem+sizejniblock*3(t0)
369 blez s7,calljava_argsloaded
371 ald a4,offjniitem+sizejniblock*4(t0)
372 ldc1 fa4,offjniitem+sizejniblock*4(t0)
374 blez s7,calljava_argsloaded
376 ald a5,offjniitem+sizejniblock*5(t0)
377 ldc1 fa5,offjniitem+sizejniblock*5(t0)
379 blez s7,calljava_argsloaded
381 ald a6,offjniitem+sizejniblock*6(t0)
382 ldc1 fa6,offjniitem+sizejniblock*6(t0)
384 blez s7,calljava_argsloaded
386 ald a7,offjniitem+sizejniblock*7(t0)
387 ldc1 fa7,offjniitem+sizejniblock*7(t0)
392 blez s7,calljava_nocopy
399 ald t3,offjniitem+sizejniblock*8(t0)
402 ala t0,sizejniblock(t0)
404 bnez t1,calljava_copyloop
407 ala itmp1,32(t4) /* pass pointer to methodptr via itmp1 */
409 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
410 ast mptr,16(sp) /* store function address */
411 ala mptr,8(t4) /* set method pointer */
415 ald pv,8(mptr) /* method call as in Java */
416 jalr pv /* call JIT compiler */
418 aaddiu pv,ra,-76*4 /* recompute procedure vector */
421 ld ra,0(sp) /* restore return address */
422 ld pv,8(sp) /* restore procedure vector */
425 ldc1 fss0,5*8(sp) /* restore non JavaABI saved flt regs */
432 aaddiu sp,sp,12*8 /* free stack space */
440 jal builtin_throw_exception
443 .end asm_calljavafunction2
446 /****************** function asm_call_jit_compiler *****************************
448 * invokes the compiler for untranslated JavaVM methods. *
450 * Register REG_ITEMP1 contains a pointer to the method info structure *
451 * (prepared by createcompilerstub). Using the return address in R31 and the *
452 * offset in the LDA instruction or using the value in methodptr R25 the *
453 * patching address for storing the method address can be computed: *
455 * method address was either loaded using *
456 * M_ALD (REG_PV, REG_PV, a) ; invokestatic/special ($28) *
457 * M_JSR (REG_RA, REG_PV); *
459 * M_LDA (REG_PV, REG_RA, val) *
461 * M_ALD (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($25) *
462 * M_JSR (REG_RA, REG_PV); *
464 * in the static case the method pointer can be computed using the *
465 * return address and the lda function following the jmp instruction *
467 *******************************************************************************/
470 .ent asm_call_jit_compiler
471 asm_call_jit_compiler:
473 lw t0,-12(ra) /* load instruction LD PV,xxx($y) */
474 srl t0,t0,21 /* shift right register number $y */
475 and t0,t0,31 /* isolate register number */
476 addiu t0,t0,-mptrreg /* test for REG_METHODPTR */
479 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
481 sra t0,t0,16 /* isolate offset */
482 aaddu mptr,t0,ra /* compute update address */
486 aaddiu sp,sp,-18*8 /* allocate stack space */
487 sd a0,0*8(sp) /* save all argument registers */
488 sd a1,1*8(sp) /* they could be used by method */
503 sd mptr,16*8(sp) /* save method pointer */
504 sd ra,17*8(sp) /* save return address */
506 ald a0,0(itmp1) /* pass 'methodinfo' pointer to */
507 jal jit_compile /* jit compiler */
509 ld a0,0*8(sp) /* restore argument registers */
510 ld a1,1*8(sp) /* they could be used by method */
525 ld mptr,16*8(sp) /* restore method pointer */
526 ld ra,17*8(sp) /* restore return address */
527 aaddiu sp,sp,18*8 /* deallocate stack area */
529 lw t0,-12(ra) /* load instruction LDQ PV,xxx($yy) */
531 sra t0,t0,16 /* isolate offset */
533 aaddu t0,t0,mptr /* compute update address via method pointer*/
534 ast v0,0(t0) /* save new method address there */
536 move pv,v0 /* move method address into pv */
538 jr pv /* and call method. The method returns */
539 /* directly to the caller (ra). */
541 .end asm_call_jit_compiler
544 /****************** function asm_dumpregistersandcall **************************
546 * This funtion saves all callee saved (address) registers and calls the *
547 * function which is passed as parameter. *
549 * This function is needed by the garbage collector, which needs to access *
550 * all registers which are stored on the stack. Unused registers are *
551 * cleared to avoid interferances with the GC. *
553 * void asm_dumpregistersandcall (functionptr f); *
555 *******************************************************************************/
557 .ent asm_dumpregistersandcall
558 asm_dumpregistersandcall:
559 aaddiu sp,sp,-10*8 /* allocate stack */
560 sd ra,0(sp) /* save return address */
562 sd s0,1*8(sp) /* save all callee saved registers */
573 jalr itmp3 /* and call function */
575 ld ra,0(sp) /* restore return address */
576 aaddiu sp,sp,10*8 /* deallocate stack */
579 .end asm_dumpregistersandcall
582 /********************* function asm_handle_exception ***************************
584 * This function handles an exception. It does not use the usual calling *
585 * conventions. The exception pointer is passed in REG_ITMP1 and the *
586 * pc from the exception raising position is passed in REG_ITMP2. It searches *
587 * the local exception table for a handler. If no one is found, it unwinds *
588 * stacks and continues searching the callers. *
590 * void asm_handle_exception (exceptionptr, exceptionpc); *
592 *******************************************************************************/
594 .ent asm_handle_nat_exception
595 asm_handle_nat_exception:
597 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
599 sra t0,t0,16 /* isolate offset */
600 aaddu pv,t0,ra /* compute update address */
602 .aent asm_handle_exception
603 asm_handle_exception:
605 aaddiu sp,sp,-14*8 /* allocate stack */
606 sd v0,0*8(sp) /* save possible used registers */
607 sd t0,1*8(sp) /* also registers used by trace_exception */
621 addu t3,zero,1 /* set no unwind flag */
623 aaddiu sp,sp,-6*8 /* allocate stack */
624 sd xptr,0*8(sp) /* save used registers */
631 ald a1,MethodPointer(pv)
635 jal builtin_trace_exception /* trace_exception(xptr,methodptr) */
637 ld xptr,0*8(sp) /* restore used register */
642 aaddiu sp,sp,6*8 /* deallocate stack */
644 lw t0,ExTableSize(pv) /* t0 = exception table size */
645 beqz t0,empty_table /* if empty table skip */
646 aaddiu t1,pv,ExTableStart /* t1 = start of exception table */
649 ald t2,ExStartPC(t1) /* t2 = exception start pc */
650 slt t2,xpc,t2 /* t2 = (xpc < startpc) */
651 bnez t2,ex_table_cont /* if (true) continue */
652 ald t2,ExEndPC(t1) /* t2 = exception end pc */
653 slt t2,xpc,t2 /* t2 = (xpc < endpc) */
654 beqz t2,ex_table_cont /* if (false) continue */
655 ald a1,ExCatchType(t1) /* arg1 = exception catch type */
656 beqz a1,ex_handle_it /* NULL catches everything */
658 ald a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
659 ald a1,offclassvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
660 lw a0,offbaseval(a0) /* a0 = baseval(xptr) */
661 lw v0,offbaseval(a1) /* a2 = baseval(catchtype) */
662 lw a1,offdiffval(a1) /* a1 = diffval(catchtype) */
663 subu a0,a0,v0 /* a0 = baseval(xptr) - baseval(catchtype) */
664 sltu v0,a1,a0 /* v0 = xptr is instanceof catchtype */
665 bnez v0,ex_table_cont /* if (false) continue */
669 ald xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
671 beqz t3,ex_jump /* if (!(no stack unwinding) skip */
673 ld v0,0*8(sp) /* restore possible used registers */
674 ld t0,1*8(sp) /* also registers used by trace_exception */
688 aaddiu sp,sp,14*8 /* deallocate stack */
691 jr xpc /* jump to the handler */
694 aaddiu t1,t1,ExEntrySize /* next exception table entry */
695 addiu t0,t0,-1 /* decrement entry counter */
696 bgtz t0,ex_table_loop /* if (t0 > 0) next entry */
699 beqz t3,ex_already_cleared /* if here the first time, then */
700 aaddiu sp,sp,14*8 /* deallocate stack and */
701 move t3,zero /* clear the no unwind flag */
703 lw t0,IsSync(pv) /* t0 = SyncOffset */
704 beqz t0,no_monitor_exit /* if zero no monitorexit */
705 aaddu t0,sp,t0 /* add stackptr to Offset */
706 ald a0,-8(t0) /* load monitorexit pointer */
708 aaddiu sp,sp,-8*8 /* allocate stack */
709 sd t0,0*8(sp) /* save used register */
717 jal builtin_monitorexit /* builtin_monitorexit(objectptr) */
719 ld t0,0*8(sp) /* restore used register */
726 aaddiu sp,sp,8*8 /* deallocate stack */
729 lw t0,FrameSize(pv) /* t0 = frame size */
730 aaddu sp,sp,t0 /* unwind stack */
731 move t0,sp /* t0 = pointer to save area */
732 lw t1,IsLeaf(pv) /* t1 = is leaf procedure */
733 bnez t1,ex_no_restore /* if (leaf) skip */
734 ld ra,-8(t0) /* restore ra */
735 aaddiu t0,t0,-8 /* t0-- */
737 move xpc,ra /* the new xpc is ra */
738 lw t1,IntSave(pv) /* t1 = saved int register count */
739 ala t2,ex_int2 /* t2 = current pc */
740 sll t1,t1,2 /* t1 = register count * 4 */
741 asubu t2,t2,t1 /* t2 = ex_int_sav - 4 * register count */
742 jr t2 /* jump to save position */
752 sll t1,t1,1 /* t1 = register count * 4 * 2 */
753 asubu t0,t0,t1 /* t0 = t0 - 8 * register count */
755 lw t1,FltSave(pv) /* t1 = saved flt register count */
756 ala t2,ex_flt2 /* t2 = current pc */
757 sll t1,t1,2 /* t1 = register count * 4 */
758 asubu t2,t2,t1 /* t2 = ex_int_sav - 4 * register count */
759 jr t2 /* jump to save position */
765 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
767 sra t0,t0,16 /* isolate offset */
768 aaddu pv,t0,ra /* compute update address */
771 .end asm_handle_nat_exception
774 /********************* asm_check_clinit ****************************************
776 * Checks if class is initialized. If not, do it right now. *
778 *******************************************************************************/
780 .ent asm_check_clinit
782 lw itmp2,offclassinit(itmp1)
783 bnez itmp2,L_is_initialized
787 sd a0,1*8(sp) /* save argument registers for leaf funcs */
808 ld a0,1*8(sp) /* restore argument registers */
827 move itmp1,ra /* now patch the calling code */
828 daddiu itmp1,itmp1,-4*4 /* go back 4 instructions */
829 lui itmp2,0x1000 /* b */
830 daddiu itmp2,itmp2,3 /* jump over 3 instructions */
831 sw itmp2,0(itmp1) /* store the new branch: br +3 */
832 sw zero,4(itmp1) /* and a nop delay slot */
836 .end asm_check_clinit
839 /********************* function asm_builtin_monitorenter ***********************
841 * Does null check and calls monitorenter or throws an exception *
843 *******************************************************************************/
845 .ent asm_builtin_monitorenter
846 asm_builtin_monitorenter:
848 beqz a0,nb_monitorenter /* if (null) throw exception */
849 ala t9,builtin_monitorenter /* else call builtin_monitorenter */
853 ald xptr,proto_java_lang_NullPointerException
854 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
855 b asm_handle_nat_exception
856 .end asm_builtin_monitorenter
859 /********************* function asm_builtin_monitorexit ************************
861 * Does null check and calls monitorexit or throws an exception *
863 *******************************************************************************/
865 .ent asm_builtin_monitorexit
866 asm_builtin_monitorexit:
868 beqz a0,nb_monitorexit /* if (null) throw exception */
869 ala t9,builtin_monitorexit /* else call builtin_monitorexit */
873 ald xptr,proto_java_lang_NullPointerException
874 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
875 b asm_handle_nat_exception
876 .end asm_builtin_monitorexit
879 /************************ function asm_builtin_idiv ****************************
881 * Does null check and calls idiv or throws an exception *
883 *******************************************************************************/
885 .ent asm_builtin_idiv
888 beqz a1,nb_idiv /* if (null) throw exception */
889 ala itmp3,builtin_idiv /* else call builtin_idiv */
893 ald xptr,proto_java_lang_ArithmeticException
894 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
895 b asm_handle_nat_exception
896 .end asm_builtin_idiv
899 /************************ function asm_builtin_ldiv ****************************
901 * Does null check and calls ldiv or throws an exception *
903 *******************************************************************************/
905 .ent asm_builtin_ldiv
908 beqz a1,nb_ldiv /* if (null) throw exception */
909 ala itmp3,builtin_ldiv /* else call builtin_ldiv */
913 ald xptr,proto_java_lang_ArithmeticException
914 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
915 b asm_handle_nat_exception
916 .end asm_builtin_ldiv
919 /************************ function asm_builtin_irem ****************************
921 * Does null check and calls irem or throws an exception *
923 *******************************************************************************/
925 .ent asm_builtin_irem
928 beqz a1,nb_irem /* if (null) throw exception */
929 ala t9,builtin_irem /* else call builtin_irem */
933 ald xptr,proto_java_lang_ArithmeticException
934 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
935 b asm_handle_nat_exception
936 .end asm_builtin_irem
939 /************************ function asm_builtin_lrem ****************************
941 * Does null check and calls lrem or throws an exception *
943 *******************************************************************************/
945 .ent asm_builtin_lrem
948 beqz a1,nb_lrem /* if (null) throw exception */
949 ala t9,builtin_lrem /* else call builtin_lrem */
953 ald xptr,proto_java_lang_ArithmeticException
954 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
955 b asm_handle_nat_exception
956 .end asm_builtin_lrem
959 /******************* function asm_builtin_checkarraycast ***********************
961 * Does the cast check and eventually throws an exception *
963 *******************************************************************************/
965 .ent asm_builtin_checkarraycast
966 asm_builtin_checkarraycast:
968 aaddiu sp,sp,-16 /* allocate stack space */
969 sd ra,0(sp) /* save return address */
970 sd a0,8(sp) /* save object pointer */
971 jal builtin_checkarraycast /* builtin_checkarraycast */
972 beqz v0,nb_carray_throw /* if (false) throw exception */
973 ld ra,0(sp) /* restore return address */
974 ld v0,8(sp) /* return object pointer */
975 aaddiu sp,sp,16 /* deallocate stack */
979 ald xptr,proto_java_lang_ClassCastException
980 ld ra,0(sp) /* restore return address */
981 aaddiu sp,sp,16 /* free stack space */
982 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
983 b asm_handle_nat_exception
984 .end asm_builtin_checkarraycast
987 /********************* function asm_builtin_checkcast **************************
989 * Does the cast check and eventually throws an exception *
991 *******************************************************************************/
993 .ent asm_builtin_checkcast
994 asm_builtin_checkcast:
996 aaddiu sp,sp,-16 /* allocate stack space */
997 sd ra,0(sp) /* save return address */
998 sd a0,8(sp) /* save object pointer */
999 jal builtin_checkcast /* builtin_checkcast */
1000 beqz v0,nb_ccast_throw /* if (false) throw exception */
1001 ld ra,0(sp) /* restore return address */
1002 ld v0,8(sp) /* return object pointer */
1003 aaddiu sp,sp,16 /* deallocate stack */
1007 ald xptr,proto_java_lang_ClassCastException
1008 ld ra,0(sp) /* restore return address */
1009 aaddiu sp,sp,16 /* free stack space */
1010 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1011 b asm_handle_nat_exception
1012 .end asm_builtin_checkcast
1015 /******************* function asm_builtin_aastore ******************************
1017 * Does the cast check and eventually throws an exception *
1018 * a0 = arrayref, a1 = index, a2 = value *
1020 *******************************************************************************/
1022 .ent asm_builtin_aastore
1023 asm_builtin_aastore:
1025 beqz a0,nb_aastore_null /* if null pointer throw exception */
1026 lw t0,offarraysize(a0) /* load size */
1027 aaddiu sp,sp,-32 /* allocate stack space */
1028 sd ra,0(sp) /* save return address */
1029 asll t1,a1,ashift /* add index*8 to arrayref */
1030 aaddu t1,a0,t1 /* add index * ashift to arrayref */
1031 sltu t0,a1,t0 /* do bound check */
1032 beqz t0,nb_aastore_bound /* if out of bounds throw exception */
1033 move a1,a2 /* object is second argument */
1034 sd t1,8(sp) /* save store position */
1035 sd a1,16(sp) /* save object */
1036 jal builtin_canstore /* builtin_canstore(arrayref,object) */
1037 ld ra,0(sp) /* restore return address */
1038 ld a0,8(sp) /* restore store position */
1039 ld a1,16(sp) /* restore object */
1040 aaddiu sp,sp,32 /* free stack space */
1041 beqz v0,nb_aastore_throw /* if (false) throw exception */
1042 ast a1,offobjarrdata(a0) /* store objectptr in array */
1046 ald xptr,proto_java_lang_NullPointerException
1047 move xpc,ra /* faulting address is return adress */
1048 b asm_handle_nat_exception
1051 ald xptr,proto_java_lang_ArrayIndexOutOfBoundsException
1052 aaddiu sp,sp,32 /* free stack space */
1053 move xpc,ra /* faulting address is return adress */
1054 b asm_handle_nat_exception
1057 ald xptr,proto_java_lang_ArrayStoreException
1058 move xpc,ra /* faulting address is return adress */
1059 b asm_handle_nat_exception
1061 .end asm_builtin_aastore
1064 /******************* function asm_initialize_thread_stack **********************
1066 * u1* asm_initialize_thread_stack (void *func, u1 *stack); *
1068 * initialize a thread stack *
1070 *******************************************************************************/
1072 .ent asm_initialize_thread_stack
1073 asm_initialize_thread_stack:
1075 aaddiu a1,a1,-14*8 /* allocate save area */
1076 sd zero, 0*8(a1) /* s0 initalize thread area */
1077 sd zero, 1*8(a1) /* s1 */
1078 sd zero, 2*8(a1) /* s2 */
1079 sd zero, 3*8(a1) /* s3 */
1080 sd zero, 4*8(a1) /* s4 */
1081 sd zero, 5*8(a1) /* s5 */
1082 sd zero, 6*8(a1) /* s6 */
1083 sd zero, 7*8(a1) /* s7 */
1084 sd zero, 8*8(a1) /* s8 */
1085 sd zero, 9*8(a1) /* fs0 */
1086 sd zero,10*8(a1) /* fs1 */
1087 sd zero,11*8(a1) /* fs2 */
1088 sd zero,12*8(a1) /* fs3 */
1092 .end asm_initialize_thread_stack
1095 /******************* function asm_perform_threadswitch *************************
1097 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1099 * performs a threadswitch *
1101 *******************************************************************************/
1103 .ent asm_perform_threadswitch
1104 asm_perform_threadswitch:
1106 aaddiu sp,sp,-14*8 /* allocate new stack */
1107 sd s0, 0*8(sp) /* save saved registers of old thread */
1121 ast sp,0(a0) /* save old stack pointer */
1122 ast sp,0(a2) /* stackTop = old stack pointer */
1123 ald sp,0(a1) /* load new stack pointer */
1124 ld s0, 0*8(sp) /* load saved registers of new thread */
1138 aaddiu sp,sp,14*8 /* deallocate new stack */
1141 .end asm_perform_threadswitch
1144 /********************* function asm_switchstackandcall *************************
1146 * void asm_switchstackandcall (void *stack, void *func, void **stacktopsave); *
1148 * Switches to a new stack, calls a function and switches back. *
1149 * a0 new stack pointer *
1150 * a1 function pointer *
1151 * a2 pointer to variable where stack top should be stored *
1153 *******************************************************************************/
1155 .ent asm_switchstackandcall
1156 asm_switchstackandcall:
1157 aaddiu a0,a0,-16 /* allocate new stack */
1158 sd ra,0(a0) /* save return address on new stack */
1159 sd sp,8(a0) /* save old stack pointer on new stack */
1160 sd sp,0(a2) /* save old stack pointer to variable */
1161 move sp,a0 /* switch to new stack */
1165 jalr itmp3 /* and call function */
1167 ld ra,0(sp) /* load return address */
1168 ld sp,8(sp) /* switch to old stack */
1172 .end asm_switchstackandcall
1174 .ent asm_getcallingmethod
1175 asm_getcallingmethod:
1178 .end asm_getcallingmethod
1182 * These are local overrides for various environment variables in Emacs.
1183 * Please do not remove this and leave it at the end of the file, where
1184 * Emacs will automagically detect them.
1185 * ---------------------------------------------------------------------
1188 * indent-tabs-mode: t