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 1290 2004-07-09 13:19:56Z twisti $
129 #define aaddiu daddiu
137 #define MethodPointer -8
138 #define FrameSize -12
143 #define ExTableSize -32
144 #define ExTableStart -32
146 #define ExEntrySize -32
149 #define ExHandlerPC -24
150 #define ExCatchType -32
157 /********************* exported functions and variables ***********************/
159 .globl asm_calljavafunction
160 .globl asm_calljavafunction2
161 .globl asm_calljavafunction2long
162 .globl asm_calljavafunction2double
163 .globl asm_call_jit_compiler
164 .globl asm_dumpregistersandcall
165 .globl asm_handle_exception
166 .globl asm_handle_nat_exception
167 .globl asm_check_clinit
168 .globl asm_builtin_checkarraycast
169 .globl asm_builtin_checkcast
170 .globl asm_builtin_aastore
171 .globl asm_builtin_monitorenter
172 .globl asm_builtin_monitorexit
173 .globl asm_builtin_idiv
174 .globl asm_builtin_irem
175 .globl asm_builtin_ldiv
176 .globl asm_builtin_lrem
177 .globl asm_perform_threadswitch
178 .globl asm_initialize_thread_stack
179 .globl asm_switchstackandcall
180 .globl asm_builtin_trace
181 .globl asm_builtin_exittrace
182 .globl asm_getclassvalues_atomic
183 .globl asm_criticalsections
186 .globl compare_and_swap
189 /*************************** imported functions *******************************/
193 .globl builtin_monitorexit
194 .globl builtin_throw_exception
195 .globl builtin_trace_exception
196 .globl class_java_lang_Object
199 /********************* function asm_calljavafunction ***************************
201 * This function calls a Java-method (which possibly needs compilation) *
202 * with up to 4 address parameters. *
204 * This functions calls the JIT-compiler which eventually translates the *
205 * method into machine code. *
207 * A possibly throwed exception will be returned to the caller as function *
208 * return value, so the java method cannot return a fucntion value (this *
209 * function usually calls 'main' and '<clinit>' which do not return a *
213 * javaobject_header *asm_calljavafunction (methodinfo *m, *
214 * void *arg1, void *arg2, void *arg3, void *arg4); *
216 *******************************************************************************/
218 .ent asm_calljavafunction
221 .ascii "calljavafunction\0\0"
224 .quad 0 /* catch type all */
225 .quad calljava_xhandler /* handler pc */
226 .quad calljava_xhandler /* end pc */
227 .quad asm_calljavafunction /* start pc */
228 .long 1 /* extable size */
229 .long 0 /* fltsave */
230 .long 0 /* intsave */
233 .long 10*8 /* frame size */
234 .quad 0 /* method pointer (pointer to name) */
236 asm_calljavafunction:
237 aaddiu sp,sp,-10*8 /* allocate stack space */
238 sd ra,0(sp) /* save return address */
242 sd pv,3*8(sp) /* procedure vector */
248 sdc1 fss0,4*8(sp) /* save non JavaABI saved flt registers */
254 sd a0,2*8(sp) /* save method pointer for compiler */
255 aaddiu itmp1,sp,16 /* pass pointer to methodptr via itmp1 */
257 move a0,a1 /* pass the remaining parameters */
262 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
263 ast mptr,1*8(sp) /* store function address */
264 move mptr,sp /* set method pointer */
268 ald pv,1*8(mptr) /* method call as in Java */
269 jalr pv /* call JIT compiler */
271 aaddiu pv,ra,-23*4 /* recompute procedure vector */
273 move v0,zero /* clear return value (exception ptr) */
279 ld ra,0(sp) /* restore return address */
280 ld pv,3*8(sp) /* restore procedure vector */
282 ldc1 fss0,4*8(sp) /* restore non JavaABI saved flt regs */
289 aaddiu sp,sp,10*8 /* free stack space */
295 jal builtin_throw_exception
298 .end asm_calljavafunction
301 .ent asm_calljavafunction2
304 .ascii "calljavafunction2\0\0"
307 .quad 0 /* catch type all */
308 .quad calljava_xhandler2 /* handler pc */
309 .quad calljava_xhandler2 /* end pc */
310 .quad asm_calljavafunction2 /* start pc */
311 .long 1 /* extable size */
312 .long 0 /* fltsave */
313 .long 1 /* intsave */
316 .long 96 /* frame size */
317 .quad 0 /* method pointer (pointer to name) */
319 asm_calljavafunction2:
320 asm_calljavafunction2double:
321 asm_calljavafunction2long:
322 aaddiu sp,sp,-12*8 /* allocate stack space (only 11 needed)*/
323 sd ra,0(sp) /* save return address */
327 sd pv,1*8(sp) /* procedure vector */
334 sdc1 fss0,5*8(sp) /* save non JavaABI saved flt registers */
340 sd a0,4*8(sp) /* save method pointer for compiler */
344 blez s7,calljava_argsloaded
345 ald a0,offjniitem(t0)
346 ldc1 fa0,offjniitem(t0)
348 blez s7,calljava_argsloaded
350 ald a1,offjniitem+sizejniblock*1(t0)
351 ldc1 fa1,offjniitem+sizejniblock*1(t0)
353 blez s7,calljava_argsloaded
355 ald a2,offjniitem+sizejniblock*2(t0)
356 ldc1 fa2,offjniitem+sizejniblock*2(t0)
358 blez s7,calljava_argsloaded
360 ald a3,offjniitem+sizejniblock*3(t0)
361 ldc1 fa3,offjniitem+sizejniblock*3(t0)
363 blez s7,calljava_argsloaded
365 ald a4,offjniitem+sizejniblock*4(t0)
366 ldc1 fa4,offjniitem+sizejniblock*4(t0)
368 blez s7,calljava_argsloaded
370 ald a5,offjniitem+sizejniblock*5(t0)
371 ldc1 fa5,offjniitem+sizejniblock*5(t0)
373 blez s7,calljava_argsloaded
375 ald a6,offjniitem+sizejniblock*6(t0)
376 ldc1 fa6,offjniitem+sizejniblock*6(t0)
378 blez s7,calljava_argsloaded
380 ald a7,offjniitem+sizejniblock*7(t0)
381 ldc1 fa7,offjniitem+sizejniblock*7(t0)
386 blez s7,calljava_nocopy
393 ald t3,offjniitem+sizejniblock*8(t0)
396 ala t0,sizejniblock(t0)
398 bnez t1,calljava_copyloop
401 ala itmp1,32(t8) /* pass pointer to methodptr via itmp1 */
403 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
404 ast mptr,16(sp) /* store function address */
405 ala mptr,8(t8) /* set method pointer */
409 ald pv,8(mptr) /* method call as in Java */
410 jalr pv /* call JIT compiler */
412 aaddiu pv,ra,-76*4 /* recompute procedure vector */
415 ld ra,0(sp) /* restore return address */
416 ld pv,8(sp) /* restore procedure vector */
419 ldc1 fss0,5*8(sp) /* restore non JavaABI saved flt regs */
426 aaddiu sp,sp,12*8 /* free stack space */
434 jal builtin_throw_exception
437 .end asm_calljavafunction2
440 /****************** function asm_call_jit_compiler *****************************
442 * invokes the compiler for untranslated JavaVM methods. *
444 * Register REG_ITEMP1 contains a pointer to the method info structure *
445 * (prepared by createcompilerstub). Using the return address in R31 and the *
446 * offset in the LDA instruction or using the value in methodptr R25 the *
447 * patching address for storing the method address can be computed: *
449 * method address was either loaded using *
450 * M_ALD (REG_PV, REG_PV, a) ; invokestatic/special ($28) *
451 * M_JSR (REG_RA, REG_PV); *
453 * M_LDA (REG_PV, REG_RA, val) *
455 * M_ALD (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($25) *
456 * M_JSR (REG_RA, REG_PV); *
458 * in the static case the method pointer can be computed using the *
459 * return address and the lda function following the jmp instruction *
461 *******************************************************************************/
464 .ent asm_call_jit_compiler
466 asm_call_jit_compiler:
467 lw t0,-12(ra) /* load instruction LD PV,xxx($y) */
468 srl t0,t0,21 /* shift right register number $y */
469 and t0,t0,31 /* isolate register number */
470 addiu t0,t0,-mptrreg /* test for REG_METHODPTR */
473 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
475 sra t0,t0,16 /* isolate offset */
476 aaddu mptr,t0,ra /* compute update address */
479 aaddiu sp,sp,-18*8 /* allocate stack space */
480 sd a0,0*8(sp) /* save all argument registers */
481 sd a1,1*8(sp) /* they could be used by method */
496 sd mptr,16*8(sp) /* save method pointer */
497 sd ra,17*8(sp) /* save return address */
499 ald a0,0(itmp1) /* pass 'methodinfo' pointer to */
500 jal jit_compile /* jit compiler */
502 ld a0,0*8(sp) /* restore argument registers */
503 ld a1,1*8(sp) /* they could be used by method */
518 ld mptr,16*8(sp) /* restore method pointer */
519 ld ra,17*8(sp) /* restore return address */
520 aaddiu sp,sp,18*8 /* deallocate stack area */
522 lw t0,-12(ra) /* load instruction LDQ PV,xxx($yy) */
524 sra t0,t0,16 /* isolate offset */
526 aaddu t0,t0,mptr /* compute update address via method pointer*/
527 ast v0,0(t0) /* save new method address there */
529 move pv,v0 /* move method address into pv */
531 jr pv /* and call method. The method returns */
532 /* directly to the caller (ra). */
534 .end asm_call_jit_compiler
537 /********************* function asm_handle_exception ***************************
539 * This function handles an exception. It does not use the usual calling *
540 * conventions. The exception pointer is passed in REG_ITMP1 and the *
541 * pc from the exception raising position is passed in REG_ITMP2. It searches *
542 * the local exception table for a handler. If no one is found, it unwinds *
543 * stacks and continues searching the callers. *
545 * void asm_handle_exception (exceptionptr, exceptionpc); *
547 *******************************************************************************/
549 .ent asm_handle_nat_exception
551 asm_handle_nat_exception:
552 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
554 sra t0,t0,16 /* isolate offset */
555 aaddu pv,t0,ra /* compute update address */
557 .aent asm_handle_exception
559 asm_handle_exception:
560 aaddiu sp,sp,-14*8 /* allocate stack */
561 sd v0,0*8(sp) /* save possible used registers */
562 sd t0,1*8(sp) /* also registers used by trace_exception */
576 addu t3,zero,1 /* set no unwind flag */
578 aaddiu sp,sp,-6*8 /* allocate stack */
579 sd xptr,0*8(sp) /* save used registers */
586 ald a1,MethodPointer(pv)
591 jal builtin_trace_exception /* trace_exception(xptr,methodptr) */
593 ld xptr,0*8(sp) /* restore used register */
598 aaddiu sp,sp,6*8 /* deallocate stack */
600 lw t0,ExTableSize(pv) /* t0 = exception table size */
601 beqz t0,empty_table /* if empty table skip */
602 aaddiu t1,pv,ExTableStart /* t1 = start of exception table */
605 ald t2,ExStartPC(t1) /* t2 = exception start pc */
606 sle t2,t2,xpc /* t2 = (startpc <= xpc) */
607 beqz t2,ex_table_cont /* if (false) continue */
608 ald t2,ExEndPC(t1) /* t2 = exception end pc */
609 slt t2,xpc,t2 /* t2 = (xpc < endpc) */
610 beqz t2,ex_table_cont /* if (false) continue */
611 ald a1,ExCatchType(t1) /* arg1 = exception catch type */
612 beqz a1,ex_handle_it /* NULL catches everything */
614 lw itmp3,offclassloaded(a1)
615 bnez itmp3,L_class_loaded
617 aaddiu sp,sp,-8*8 /* allocate stack */
618 sd t0,0*8(sp) /* save used register */
630 ld t0,0*8(sp) /* restore used register */
638 aaddiu sp,sp,8*8 /* deallocate stack */
641 lw itmp3,offclasslinked(a1)
642 aaddiu sp,sp,-8*8 /* allocate stack */
644 bnez itmp3,L_class_linked
646 sd t0,0*8(sp) /* save used register */
657 ld t0,0*8(sp) /* restore used register */
669 ald a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
670 ald a1,offclassvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
671 lw a0,offbaseval(a0) /* a0 = baseval(xptr) */
672 lw v0,offbaseval(a1) /* a2 = baseval(catchtype) */
673 lw a1,offdiffval(a1) /* a1 = diffval(catchtype) */
675 subu a0,a0,v0 /* a0 = baseval(xptr) - baseval(catchtype) */
676 sltu v0,a1,a0 /* v0 = xptr is instanceof catchtype */
677 aaddiu sp,sp,8*8 /* deallocate stack */
678 bnez v0,ex_table_cont /* if (false) continue */
681 ald xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
683 beqz t3,ex_jump /* if (!(no stack unwinding) skip */
685 ld v0,0*8(sp) /* restore possible used registers */
686 ld t0,1*8(sp) /* also registers used by trace_exception */
700 aaddiu sp,sp,14*8 /* deallocate stack */
703 jr xpc /* jump to the handler */
706 aaddiu t1,t1,ExEntrySize /* next exception table entry */
707 addiu t0,t0,-1 /* decrement entry counter */
708 bgtz t0,ex_table_loop /* if (t0 > 0) next entry */
711 beqz t3,ex_already_cleared /* if here the first time, then */
712 aaddiu sp,sp,14*8 /* deallocate stack and */
713 move t3,zero /* clear the no unwind flag */
715 lw t0,IsSync(pv) /* t0 = SyncOffset */
716 beqz t0,no_monitor_exit /* if zero no monitorexit */
717 aaddu t0,sp,t0 /* add stackptr to Offset */
718 ald a0,-8(t0) /* load monitorexit pointer */
720 aaddiu sp,sp,-8*8 /* allocate stack */
721 sd t0,0*8(sp) /* save used register */
729 jal builtin_monitorexit /* builtin_monitorexit(objectptr) */
731 ld t0,0*8(sp) /* restore used register */
738 aaddiu sp,sp,8*8 /* deallocate stack */
741 lw t0,FrameSize(pv) /* t0 = frame size */
742 aaddu sp,sp,t0 /* unwind stack */
743 move t0,sp /* t0 = pointer to save area */
744 lw t1,IsLeaf(pv) /* t1 = is leaf procedure */
745 bnez t1,ex_no_restore /* if (leaf) skip */
746 ld ra,-8(t0) /* restore ra */
747 aaddiu t0,t0,-8 /* t0-- */
749 move xpc,ra /* the new xpc is ra */
750 lw t1,IntSave(pv) /* t1 = saved int register count */
751 ala t2,ex_int2 /* t2 = current pc */
752 sll t1,t1,2 /* t1 = register count * 4 */
753 asubu t2,t2,t1 /* t2 = ex_int_sav - 4 * register count */
754 jr t2 /* jump to save position */
764 sll t1,t1,1 /* t1 = register count * 4 * 2 */
765 asubu t0,t0,t1 /* t0 = t0 - 8 * register count */
767 lw t1,FltSave(pv) /* t1 = saved flt register count */
768 ala t2,ex_flt2 /* t2 = current pc */
769 sll t1,t1,2 /* t1 = register count * 4 */
770 asubu t2,t2,t1 /* t2 = ex_int_sav - 4 * register count */
771 jr t2 /* jump to save position */
777 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
779 sra t0,t0,16 /* isolate offset */
780 aaddu pv,t0,ra /* compute update address */
783 .end asm_handle_nat_exception
786 /********************* asm_check_clinit ****************************************
788 * Checks if class is initialized. If not, do it right now. *
790 *******************************************************************************/
792 .ent asm_check_clinit
795 lw itmp2,offclassinit(itmp1)
796 bnez itmp2,L_is_initialized
801 sd a0,1*8(sp) /* save argument registers for leaf funcs */
830 ld a0,1*8(sp) /* restore argument registers */
856 beqz v0,L_initializererror
860 move itmp1,ra /* now patch the calling code */
861 daddiu itmp1,itmp1,-4*4 /* go back 4 instructions */
862 lui itmp2,0x1000 /* b */
863 daddiu itmp2,itmp2,3 /* jump over 3 instructions */
864 sw itmp2,0(itmp1) /* store the new branch: br +3 */
865 sw zero,4(itmp1) /* and a nop delay slot */
871 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
874 jal builtin_asm_get_exceptionptrptr
879 la itmp3,_exceptionptr
884 aaddiu xpc,ra,-4 /* faulting address is return adress - 4 */
885 b asm_handle_exception
887 .end asm_check_clinit
890 /********************* function asm_builtin_monitorenter ***********************
892 * Does null check and calls monitorenter or throws an exception *
894 *******************************************************************************/
896 .ent asm_builtin_monitorenter
898 asm_builtin_monitorenter:
899 beqz a0,nb_monitorenter /* if (null) throw exception */
900 ala t9,builtin_monitorenter /* else call builtin_monitorenter */
906 ald a0,string_java_lang_NullPointerException
912 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
913 b asm_handle_nat_exception
915 .end asm_builtin_monitorenter
918 /********************* function asm_builtin_monitorexit ************************
920 * Does null check and calls monitorexit or throws an exception *
922 *******************************************************************************/
924 .ent asm_builtin_monitorexit
926 asm_builtin_monitorexit:
927 beqz a0,nb_monitorexit /* if (null) throw exception */
928 ala t9,builtin_monitorexit /* else call builtin_monitorexit */
934 ald a0,string_java_lang_NullPointerException
940 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
941 b asm_handle_nat_exception
943 .end asm_builtin_monitorexit
946 /************************ function asm_builtin_idiv ****************************
948 * Does null check and calls idiv or throws an exception *
950 *******************************************************************************/
952 .ent asm_builtin_idiv
955 beqz a1,nb_idiv /* if (null) throw exception */
956 ala itmp3,builtin_idiv /* else call builtin_idiv */
962 ald a0,string_java_lang_ArithmeticException
963 ald a1,string_java_lang_ArithmeticException_message
964 jal new_exception_message
969 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
970 b asm_handle_nat_exception
972 .end asm_builtin_idiv
975 /************************ function asm_builtin_ldiv ****************************
977 * Does null check and calls ldiv or throws an exception *
979 *******************************************************************************/
981 .ent asm_builtin_ldiv
984 beqz a1,nb_ldiv /* if (null) throw exception */
985 ala itmp3,builtin_ldiv /* else call builtin_ldiv */
991 ald a0,string_java_lang_ArithmeticException
992 ald a1,string_java_lang_ArithmeticException_message
993 jal new_exception_message
998 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
999 b asm_handle_nat_exception
1001 .end asm_builtin_ldiv
1004 /************************ function asm_builtin_irem ****************************
1006 * Does null check and calls irem or throws an exception *
1008 *******************************************************************************/
1010 .ent asm_builtin_irem
1013 beqz a1,nb_irem /* if (null) throw exception */
1014 ala t9,builtin_irem /* else call builtin_irem */
1020 ald a0,string_java_lang_ArithmeticException
1021 ald a1,string_java_lang_ArithmeticException_message
1022 jal new_exception_message
1027 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1028 b asm_handle_nat_exception
1030 .end asm_builtin_irem
1033 /************************ function asm_builtin_lrem ****************************
1035 * Does null check and calls lrem or throws an exception *
1037 *******************************************************************************/
1039 .ent asm_builtin_lrem
1042 beqz a1,nb_lrem /* if (null) throw exception */
1043 ala t9,builtin_lrem /* else call builtin_lrem */
1049 ald a0,string_java_lang_ArithmeticException
1050 ald a1,string_java_lang_ArithmeticException_message
1051 jal new_exception_message
1056 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1057 b asm_handle_nat_exception
1059 .end asm_builtin_lrem
1062 /******************* function asm_builtin_checkarraycast ***********************
1064 * Does the cast check and eventually throws an exception *
1066 *******************************************************************************/
1068 .ent asm_builtin_checkarraycast
1070 asm_builtin_checkarraycast:
1071 aaddiu sp,sp,-16 /* allocate stack space */
1072 sd ra,0(sp) /* save return address */
1073 sd a0,8(sp) /* save object pointer */
1074 jal builtin_checkarraycast /* builtin_checkarraycast */
1075 beqz v0,nb_carray_throw /* if (false) throw exception */
1076 ld ra,0(sp) /* restore return address */
1077 ld v0,8(sp) /* return object pointer */
1078 aaddiu sp,sp,16 /* deallocate stack */
1082 ald a0,string_java_lang_ClassCastException
1086 ld ra,0(sp) /* restore return address */
1087 aaddiu sp,sp,16 /* free stack space */
1088 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1089 b asm_handle_nat_exception
1091 .end asm_builtin_checkarraycast
1094 /********************* function asm_builtin_checkcast **************************
1096 * Does the cast check and eventually throws an exception *
1098 *******************************************************************************/
1100 .ent asm_builtin_checkcast
1102 asm_builtin_checkcast:
1103 aaddiu sp,sp,-16 /* allocate stack space */
1104 sd ra,0(sp) /* save return address */
1105 sd a0,8(sp) /* save object pointer */
1106 jal builtin_checkcast /* builtin_checkcast */
1107 beqz v0,nb_ccast_throw /* if (false) throw exception */
1108 ld ra,0(sp) /* restore return address */
1109 ld v0,8(sp) /* return object pointer */
1110 aaddiu sp,sp,16 /* deallocate stack */
1114 ald a0,string_java_lang_ClassCastException
1118 ld ra,0(sp) /* restore return address */
1119 aaddiu sp,sp,16 /* free stack space */
1120 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1121 b asm_handle_nat_exception
1123 .end asm_builtin_checkcast
1126 /******************* function asm_builtin_aastore ******************************
1128 * Does the cast check and eventually throws an exception *
1129 * a0 = arrayref, a1 = index, a2 = value *
1131 *******************************************************************************/
1133 .ent asm_builtin_aastore
1135 asm_builtin_aastore:
1136 beqz a0,nb_aastore_null /* if null pointer throw exception */
1137 lw t0,offarraysize(a0) /* load size */
1138 aaddiu sp,sp,-32 /* allocate stack space */
1139 sd ra,0(sp) /* save return address */
1140 asll t1,a1,ashift /* add index*8 to arrayref */
1141 aaddu t1,a0,t1 /* add index * ashift to arrayref */
1142 sltu t0,a1,t0 /* do bound check */
1143 beqz t0,nb_aastore_bound /* if out of bounds throw exception */
1144 move a1,a2 /* object is second argument */
1145 sd t1,8(sp) /* save store position */
1146 sd a1,16(sp) /* save object */
1147 jal builtin_canstore /* builtin_canstore(arrayref,object) */
1148 ld ra,0(sp) /* restore return address */
1149 ld a0,8(sp) /* restore store position */
1150 ld a1,16(sp) /* restore object */
1151 aaddiu sp,sp,32 /* free stack space */
1152 beqz v0,nb_aastore_store /* if (false) throw exception */
1153 ast a1,offobjarrdata(a0) /* store objectptr in array */
1159 ald a0,string_java_lang_NullPointerException
1165 move xpc,ra /* faulting address is return adress */
1166 b asm_handle_nat_exception
1171 ald a0,string_java_lang_ArrayIndexOutOfBoundsException
1172 jal new_exception_int /* a1 already contains the index */
1177 aaddiu sp,sp,32 /* free stack space */
1178 move xpc,ra /* faulting address is return adress */
1179 b asm_handle_nat_exception
1184 ald a0,string_java_lang_ArrayStoreException
1190 move xpc,ra /* faulting address is return adress */
1191 b asm_handle_nat_exception
1193 .end asm_builtin_aastore
1196 /******************* function asm_initialize_thread_stack **********************
1198 * u1* asm_initialize_thread_stack (void *func, u1 *stack); *
1200 * initialize a thread stack *
1202 *******************************************************************************/
1204 .ent asm_initialize_thread_stack
1206 asm_initialize_thread_stack:
1207 aaddiu a1,a1,-14*8 /* allocate save area */
1208 sd zero, 0*8(a1) /* s0 initalize thread area */
1209 sd zero, 1*8(a1) /* s1 */
1210 sd zero, 2*8(a1) /* s2 */
1211 sd zero, 3*8(a1) /* s3 */
1212 sd zero, 4*8(a1) /* s4 */
1213 sd zero, 5*8(a1) /* s5 */
1214 sd zero, 6*8(a1) /* s6 */
1215 sd zero, 7*8(a1) /* s7 */
1216 sd zero, 8*8(a1) /* s8 */
1217 sd zero, 9*8(a1) /* fs0 */
1218 sd zero,10*8(a1) /* fs1 */
1219 sd zero,11*8(a1) /* fs2 */
1220 sd zero,12*8(a1) /* fs3 */
1225 .end asm_initialize_thread_stack
1228 /******************* function asm_perform_threadswitch *************************
1230 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1232 * performs a threadswitch *
1234 *******************************************************************************/
1236 .ent asm_perform_threadswitch
1238 asm_perform_threadswitch:
1239 aaddiu sp,sp,-14*8 /* allocate new stack */
1240 sd s0, 0*8(sp) /* save saved registers of old thread */
1254 ast sp,0(a0) /* save old stack pointer */
1255 ast sp,0(a2) /* stackTop = old stack pointer */
1256 ald sp,0(a1) /* load new stack pointer */
1257 ld s0, 0*8(sp) /* load saved registers of new thread */
1271 aaddiu sp,sp,14*8 /* deallocate new stack */
1275 .end asm_perform_threadswitch
1278 /********************* function asm_switchstackandcall *************************
1280 * void asm_switchstackandcall (void *stack, void *func, void **stacktopsave); *
1282 * Switches to a new stack, calls a function and switches back. *
1283 * a0 new stack pointer *
1284 * a1 function pointer *
1285 * a2 pointer to variable where stack top should be stored *
1287 *******************************************************************************/
1289 .ent asm_switchstackandcall
1291 asm_switchstackandcall:
1292 aaddiu a0,a0,-16 /* allocate new stack */
1293 sd ra,0(a0) /* save return address on new stack */
1294 sd sp,8(a0) /* save old stack pointer on new stack */
1295 sd sp,0(a2) /* save old stack pointer to variable */
1296 move sp,a0 /* switch to new stack */
1300 jalr itmp3 /* and call function */
1302 ld ra,0(sp) /* load return address */
1303 ld sp,8(sp) /* switch to old stack */
1307 .end asm_switchstackandcall
1310 .ent asm_getclassvalues_atomic
1312 asm_getclassvalues_atomic:
1315 lw t0,offbaseval(a0)
1316 lw t1,offdiffval(a0)
1317 lw t2,offbaseval(a1)
1319 sw t0,offcast_super_baseval(a2)
1320 sw t1,offcast_super_diffval(a2)
1321 sw t2,offcast_sub_baseval(a2)
1324 .end asm_getclassvalues_atomic
1328 asm_criticalsections:
1329 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
1332 .quad _crit_restart1
1335 .quad _crit_restart2
1352 .ent compare_and_swap
1363 .end compare_and_swap
1365 * These are local overrides for various environment variables in Emacs.
1366 * Please do not remove this and leave it at the end of the file, where
1367 * Emacs will automagically detect them.
1368 * ---------------------------------------------------------------------
1371 * indent-tabs-mode: t