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 1484 2004-11-11 14:40:48Z 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
185 .globl compare_and_swap
188 /*************************** imported functions *******************************/
192 .globl builtin_monitorexit
193 .globl builtin_throw_exception
194 .globl builtin_trace_exception
195 .globl class_java_lang_Object
198 /********************* function asm_calljavafunction ***************************
200 * This function calls a Java-method (which possibly needs compilation) *
201 * with up to 4 address parameters. *
203 * This functions calls the JIT-compiler which eventually translates the *
204 * method into machine code. *
206 * A possibly throwed exception will be returned to the caller as function *
207 * return value, so the java method cannot return a fucntion value (this *
208 * function usually calls 'main' and '<clinit>' which do not return a *
212 * javaobject_header *asm_calljavafunction (methodinfo *m, *
213 * void *arg1, void *arg2, void *arg3, void *arg4); *
215 *******************************************************************************/
217 .ent asm_calljavafunction
220 .ascii "calljavafunction\0\0"
223 .quad 0 /* catch type all */
224 .quad calljava_xhandler /* handler pc */
225 .quad calljava_xhandler /* end pc */
226 .quad asm_calljavafunction /* start pc */
227 .long 1 /* extable size */
228 .long 0 /* fltsave */
229 .long 0 /* intsave */
232 .long 10*8 /* frame size */
233 .quad 0 /* method pointer (pointer to name) */
235 asm_calljavafunction:
236 aaddiu sp,sp,-10*8 /* allocate stack space */
237 sd ra,0(sp) /* save return address */
241 sd pv,3*8(sp) /* procedure vector */
247 sdc1 fss0,4*8(sp) /* save non JavaABI saved flt registers */
253 sd a0,2*8(sp) /* save method pointer for compiler */
254 aaddiu itmp1,sp,16 /* pass pointer to methodptr via itmp1 */
256 move a0,a1 /* pass the remaining parameters */
261 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
262 ast mptr,1*8(sp) /* store function address */
263 move mptr,sp /* set method pointer */
267 ald pv,1*8(mptr) /* method call as in Java */
268 jalr pv /* call JIT compiler */
270 aaddiu pv,ra,-23*4 /* recompute procedure vector */
272 move v0,zero /* clear return value (exception ptr) */
278 ld ra,0(sp) /* restore return address */
279 ld pv,3*8(sp) /* restore procedure vector */
281 ldc1 fss0,4*8(sp) /* restore non JavaABI saved flt regs */
288 aaddiu sp,sp,10*8 /* free stack space */
294 jal builtin_throw_exception
297 .end asm_calljavafunction
300 .ent asm_calljavafunction2
303 .ascii "calljavafunction2\0\0"
306 .quad 0 /* catch type all */
307 .quad calljava_xhandler2 /* handler pc */
308 .quad calljava_xhandler2 /* end pc */
309 .quad asm_calljavafunction2 /* start pc */
310 .long 1 /* extable size */
311 .long 0 /* fltsave */
312 .long 1 /* intsave */
315 .long 96 /* frame size */
316 .quad 0 /* method pointer (pointer to name) */
318 asm_calljavafunction2:
319 asm_calljavafunction2double:
320 asm_calljavafunction2long:
321 aaddiu sp,sp,-12*8 /* allocate stack space (only 11 needed)*/
322 sd ra,0(sp) /* save return address */
326 sd pv,1*8(sp) /* procedure vector */
333 sdc1 fss0,5*8(sp) /* save non JavaABI saved flt registers */
339 sd a0,4*8(sp) /* save method pointer for compiler */
343 blez s7,calljava_argsloaded
344 ald a0,offjniitem(t0)
345 ldc1 fa0,offjniitem(t0)
347 blez s7,calljava_argsloaded
349 ald a1,offjniitem+sizejniblock*1(t0)
350 ldc1 fa1,offjniitem+sizejniblock*1(t0)
352 blez s7,calljava_argsloaded
354 ald a2,offjniitem+sizejniblock*2(t0)
355 ldc1 fa2,offjniitem+sizejniblock*2(t0)
357 blez s7,calljava_argsloaded
359 ald a3,offjniitem+sizejniblock*3(t0)
360 ldc1 fa3,offjniitem+sizejniblock*3(t0)
362 blez s7,calljava_argsloaded
364 ald a4,offjniitem+sizejniblock*4(t0)
365 ldc1 fa4,offjniitem+sizejniblock*4(t0)
367 blez s7,calljava_argsloaded
369 ald a5,offjniitem+sizejniblock*5(t0)
370 ldc1 fa5,offjniitem+sizejniblock*5(t0)
372 blez s7,calljava_argsloaded
374 ald a6,offjniitem+sizejniblock*6(t0)
375 ldc1 fa6,offjniitem+sizejniblock*6(t0)
377 blez s7,calljava_argsloaded
379 ald a7,offjniitem+sizejniblock*7(t0)
380 ldc1 fa7,offjniitem+sizejniblock*7(t0)
385 blez s7,calljava_nocopy
392 ald t3,offjniitem+sizejniblock*8(t0)
395 ala t0,sizejniblock(t0)
397 bnez t1,calljava_copyloop
400 ala itmp1,32(t8) /* pass pointer to methodptr via itmp1 */
402 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
403 ast mptr,16(sp) /* store function address */
404 ala mptr,8(t8) /* set method pointer */
408 ald pv,8(mptr) /* method call as in Java */
409 jalr pv /* call JIT compiler */
411 aaddiu pv,ra,-76*4 /* recompute procedure vector */
414 ld ra,0(sp) /* restore return address */
415 ld pv,8(sp) /* restore procedure vector */
418 ldc1 fss0,5*8(sp) /* restore non JavaABI saved flt regs */
425 aaddiu sp,sp,12*8 /* free stack space */
433 jal builtin_throw_exception
436 .end asm_calljavafunction2
439 /****************** function asm_call_jit_compiler *****************************
441 * invokes the compiler for untranslated JavaVM methods. *
443 * Register REG_ITEMP1 contains a pointer to the method info structure *
444 * (prepared by createcompilerstub). Using the return address in R31 and the *
445 * offset in the LDA instruction or using the value in methodptr R25 the *
446 * patching address for storing the method address can be computed: *
448 * method address was either loaded using *
449 * M_ALD (REG_PV, REG_PV, a) ; invokestatic/special ($28) *
450 * M_JSR (REG_RA, REG_PV); *
452 * M_LDA (REG_PV, REG_RA, val) *
454 * M_ALD (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($25) *
455 * M_JSR (REG_RA, REG_PV); *
457 * in the static case the method pointer can be computed using the *
458 * return address and the lda function following the jmp instruction *
460 *******************************************************************************/
463 .ent asm_call_jit_compiler
465 asm_call_jit_compiler:
466 lw t0,-12(ra) /* load instruction LD PV,xxx($y) */
467 srl t0,t0,21 /* shift right register number $y */
468 and t0,t0,31 /* isolate register number */
469 addiu t0,t0,-mptrreg /* test for REG_METHODPTR */
472 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
474 sra t0,t0,16 /* isolate offset */
475 aaddu mptr,t0,ra /* compute update address */
478 aaddiu sp,sp,-18*8 /* allocate stack space */
479 sd a0,0*8(sp) /* save all argument registers */
480 sd a1,1*8(sp) /* they could be used by method */
495 sd mptr,16*8(sp) /* save method pointer */
496 sd ra,17*8(sp) /* save return address */
498 ald a0,0(itmp1) /* pass 'methodinfo' pointer to */
499 jal jit_compile /* jit compiler */
501 ld a0,0*8(sp) /* restore argument registers */
502 ld a1,1*8(sp) /* they could be used by method */
517 ld mptr,16*8(sp) /* restore method pointer */
518 ld ra,17*8(sp) /* restore return address */
519 aaddiu sp,sp,18*8 /* deallocate stack area */
521 lw t0,-12(ra) /* load instruction LDQ PV,xxx($yy) */
523 sra t0,t0,16 /* isolate offset */
525 aaddu t0,t0,mptr /* compute update address via method pointer*/
526 ast v0,0(t0) /* save new method address there */
528 move pv,v0 /* move method address into pv */
530 jr pv /* and call method. The method returns */
531 /* directly to the caller (ra). */
533 .end asm_call_jit_compiler
536 /********************* function asm_handle_exception ***************************
538 * This function handles an exception. It does not use the usual calling *
539 * conventions. The exception pointer is passed in REG_ITMP1 and the *
540 * pc from the exception raising position is passed in REG_ITMP2. It searches *
541 * the local exception table for a handler. If no one is found, it unwinds *
542 * stacks and continues searching the callers. *
544 * void asm_handle_exception (exceptionptr, exceptionpc); *
546 *******************************************************************************/
548 .ent asm_handle_nat_exception
550 asm_handle_nat_exception:
551 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
553 sra t0,t0,16 /* isolate offset */
554 aaddu pv,t0,ra /* compute update address */
556 .aent asm_handle_exception
558 asm_handle_exception:
559 aaddiu sp,sp,-14*8 /* allocate stack */
560 sd v0,0*8(sp) /* save possible used registers */
561 sd t0,1*8(sp) /* also registers used by trace_exception */
575 addu t3,zero,1 /* set no unwind flag */
577 aaddiu sp,sp,-6*8 /* allocate stack */
578 sd xptr,0*8(sp) /* save used registers */
585 ald a1,MethodPointer(pv)
590 jal builtin_trace_exception /* trace_exception(xptr,methodptr) */
592 ld xptr,0*8(sp) /* restore used register */
597 aaddiu sp,sp,6*8 /* deallocate stack */
599 lw t0,ExTableSize(pv) /* t0 = exception table size */
600 beqz t0,empty_table /* if empty table skip */
601 aaddiu t1,pv,ExTableStart /* t1 = start of exception table */
604 ald t2,ExStartPC(t1) /* t2 = exception start pc */
605 sle t2,t2,xpc /* t2 = (startpc <= xpc) */
606 beqz t2,ex_table_cont /* if (false) continue */
607 ald t2,ExEndPC(t1) /* t2 = exception end pc */
608 slt t2,xpc,t2 /* t2 = (xpc < endpc) */
609 beqz t2,ex_table_cont /* if (false) continue */
610 ald a1,ExCatchType(t1) /* arg1 = exception catch type */
611 beqz a1,ex_handle_it /* NULL catches everything */
613 lw itmp3,offclassloaded(a1)
614 bnez itmp3,L_class_loaded
616 aaddiu sp,sp,-8*8 /* allocate stack */
617 sd t0,0*8(sp) /* save used register */
629 ld t0,0*8(sp) /* restore used register */
637 aaddiu sp,sp,8*8 /* deallocate stack */
640 lw itmp3,offclasslinked(a1)
641 aaddiu sp,sp,-8*8 /* allocate stack */
643 bnez itmp3,L_class_linked
645 sd t0,0*8(sp) /* save used register */
656 ld t0,0*8(sp) /* restore used register */
668 ald a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
669 ald a1,offclassvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
670 lw a0,offbaseval(a0) /* a0 = baseval(xptr) */
671 lw v0,offbaseval(a1) /* a2 = baseval(catchtype) */
672 lw a1,offdiffval(a1) /* a1 = diffval(catchtype) */
674 subu a0,a0,v0 /* a0 = baseval(xptr) - baseval(catchtype) */
675 sltu v0,a1,a0 /* v0 = xptr is instanceof catchtype */
676 aaddiu sp,sp,8*8 /* deallocate stack */
677 bnez v0,ex_table_cont /* if (false) continue */
680 ald xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
682 beqz t3,ex_jump /* if (!(no stack unwinding) skip */
684 ld v0,0*8(sp) /* restore possible used registers */
685 ld t0,1*8(sp) /* also registers used by trace_exception */
699 aaddiu sp,sp,14*8 /* deallocate stack */
702 jr xpc /* jump to the handler */
705 aaddiu t1,t1,ExEntrySize /* next exception table entry */
706 addiu t0,t0,-1 /* decrement entry counter */
707 bgtz t0,ex_table_loop /* if (t0 > 0) next entry */
710 beqz t3,ex_already_cleared /* if here the first time, then */
711 aaddiu sp,sp,14*8 /* deallocate stack and */
712 move t3,zero /* clear the no unwind flag */
714 lw t0,IsSync(pv) /* t0 = SyncOffset */
715 beqz t0,no_monitor_exit /* if zero no monitorexit */
716 aaddu t0,sp,t0 /* add stackptr to Offset */
717 ald a0,-8(t0) /* load monitorexit pointer */
719 aaddiu sp,sp,-8*8 /* allocate stack */
720 sd t0,0*8(sp) /* save used register */
728 jal builtin_monitorexit /* builtin_monitorexit(objectptr) */
730 ld t0,0*8(sp) /* restore used register */
737 aaddiu sp,sp,8*8 /* deallocate stack */
740 lw t0,FrameSize(pv) /* t0 = frame size */
741 aaddu sp,sp,t0 /* unwind stack */
742 move t0,sp /* t0 = pointer to save area */
743 lw t1,IsLeaf(pv) /* t1 = is leaf procedure */
744 bnez t1,ex_no_restore /* if (leaf) skip */
745 ld ra,-8(t0) /* restore ra */
746 aaddiu t0,t0,-8 /* t0-- */
748 move xpc,ra /* the new xpc is ra */
749 lw t1,IntSave(pv) /* t1 = saved int register count */
750 ala t2,ex_int2 /* t2 = current pc */
751 sll t1,t1,2 /* t1 = register count * 4 */
752 asubu t2,t2,t1 /* t2 = ex_int_sav - 4 * register count */
753 jr t2 /* jump to save position */
763 sll t1,t1,1 /* t1 = register count * 4 * 2 */
764 asubu t0,t0,t1 /* t0 = t0 - 8 * register count */
766 lw t1,FltSave(pv) /* t1 = saved flt register count */
767 ala t2,ex_flt2 /* t2 = current pc */
768 sll t1,t1,2 /* t1 = register count * 4 */
769 asubu t2,t2,t1 /* t2 = ex_int_sav - 4 * register count */
770 jr t2 /* jump to save position */
776 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
778 sra t0,t0,16 /* isolate offset */
779 aaddu pv,t0,ra /* compute update address */
782 .end asm_handle_nat_exception
785 /********************* asm_check_clinit ****************************************
787 * Checks if class is initialized. If not, do it right now. *
789 *******************************************************************************/
791 .ent asm_check_clinit
794 lw itmp2,offclassinit(itmp1)
795 bnez itmp2,L_is_initialized
800 sd a0,1*8(sp) /* save argument registers for leaf funcs */
829 ld a0,1*8(sp) /* restore argument registers */
855 beqz v0,L_initializererror
859 move itmp1,ra /* now patch the calling code */
860 daddiu itmp1,itmp1,-4*4 /* go back 4 instructions */
861 lui itmp2,0x1000 /* b */
862 daddiu itmp2,itmp2,3 /* jump over 3 instructions */
863 sw itmp2,0(itmp1) /* store the new branch: br +3 */
864 sw zero,4(itmp1) /* and a nop delay slot */
870 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
873 jal builtin_asm_get_exceptionptrptr
876 ld xptr,0(v0) /* get the exception pointer */
877 sd zero,0(v0) /* clear the exception pointer */
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 jal new_nullpointerexception
939 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
940 b asm_handle_nat_exception
942 .end asm_builtin_monitorexit
945 /************************ function asm_builtin_idiv ****************************
947 * Does null check and calls idiv or throws an exception *
949 *******************************************************************************/
951 .ent asm_builtin_idiv
954 beqz a1,nb_idiv /* if (null) throw exception */
955 ala itmp3,builtin_idiv /* else call builtin_idiv */
961 jal new_arithmeticexception
966 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
967 b asm_handle_nat_exception
969 .end asm_builtin_idiv
972 /************************ function asm_builtin_ldiv ****************************
974 * Does null check and calls ldiv or throws an exception *
976 *******************************************************************************/
978 .ent asm_builtin_ldiv
981 beqz a1,nb_ldiv /* if (null) throw exception */
982 ala itmp3,builtin_ldiv /* else call builtin_ldiv */
988 jal new_arithmeticexception
993 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
994 b asm_handle_nat_exception
996 .end asm_builtin_ldiv
999 /************************ function asm_builtin_irem ****************************
1001 * Does null check and calls irem or throws an exception *
1003 *******************************************************************************/
1005 .ent asm_builtin_irem
1008 beqz a1,nb_irem /* if (null) throw exception */
1009 ala t9,builtin_irem /* else call builtin_irem */
1015 jal new_arithmeticexception
1020 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1021 b asm_handle_nat_exception
1023 .end asm_builtin_irem
1026 /************************ function asm_builtin_lrem ****************************
1028 * Does null check and calls lrem or throws an exception *
1030 *******************************************************************************/
1032 .ent asm_builtin_lrem
1035 beqz a1,nb_lrem /* if (null) throw exception */
1036 ala t9,builtin_lrem /* else call builtin_lrem */
1042 jal new_arithmeticexception
1047 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1048 b asm_handle_nat_exception
1050 .end asm_builtin_lrem
1053 /******************* function asm_builtin_checkarraycast ***********************
1055 * Does the cast check and eventually throws an exception *
1057 *******************************************************************************/
1059 .ent asm_builtin_checkarraycast
1061 asm_builtin_checkarraycast:
1062 aaddiu sp,sp,-16 /* allocate stack space */
1063 sd ra,0(sp) /* save return address */
1064 sd a0,8(sp) /* save object pointer */
1065 jal builtin_checkarraycast /* builtin_checkarraycast */
1066 beqz v0,nb_carray_throw /* if (false) throw exception */
1067 ld ra,0(sp) /* restore return address */
1068 ld v0,8(sp) /* return object pointer */
1069 aaddiu sp,sp,16 /* deallocate stack */
1073 jal new_classcastexception
1076 ld ra,0(sp) /* restore return address */
1077 aaddiu sp,sp,16 /* free stack space */
1078 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1079 b asm_handle_nat_exception
1081 .end asm_builtin_checkarraycast
1084 /********************* function asm_builtin_checkcast **************************
1086 * Does the cast check and eventually throws an exception *
1088 *******************************************************************************/
1090 .ent asm_builtin_checkcast
1092 asm_builtin_checkcast:
1093 aaddiu sp,sp,-16 /* allocate stack space */
1094 sd ra,0(sp) /* save return address */
1095 sd a0,8(sp) /* save object pointer */
1096 jal builtin_checkcast /* builtin_checkcast */
1097 beqz v0,nb_ccast_throw /* if (false) throw exception */
1098 ld ra,0(sp) /* restore return address */
1099 ld v0,8(sp) /* return object pointer */
1100 aaddiu sp,sp,16 /* deallocate stack */
1104 jal new_classcastexception
1107 ld ra,0(sp) /* restore return address */
1108 aaddiu sp,sp,16 /* free stack space */
1109 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1110 b asm_handle_nat_exception
1112 .end asm_builtin_checkcast
1115 /******************* function asm_builtin_aastore ******************************
1117 * Does the cast check and eventually throws an exception *
1118 * a0 = arrayref, a1 = index, a2 = value *
1120 *******************************************************************************/
1122 .ent asm_builtin_aastore
1124 asm_builtin_aastore:
1125 beqz a0,nb_aastore_null /* if null pointer throw exception */
1126 lw t0,offarraysize(a0) /* load size */
1127 aaddiu sp,sp,-32 /* allocate stack space */
1128 sd ra,0(sp) /* save return address */
1129 asll t1,a1,ashift /* add index*8 to arrayref */
1130 aaddu t1,a0,t1 /* add index * ashift to arrayref */
1131 sltu t0,a1,t0 /* do bound check */
1132 beqz t0,nb_aastore_bound /* if out of bounds throw exception */
1133 move a1,a2 /* object is second argument */
1134 sd t1,8(sp) /* save store position */
1135 sd a1,16(sp) /* save object */
1136 jal builtin_canstore /* builtin_canstore(arrayref,object) */
1137 ld ra,0(sp) /* restore return address */
1138 ld a0,8(sp) /* restore store position */
1139 ld a1,16(sp) /* restore object */
1140 aaddiu sp,sp,32 /* free stack space */
1141 beqz v0,nb_aastore_store /* if (false) throw exception */
1142 ast a1,offobjarrdata(a0) /* store objectptr in array */
1148 jal new_nullpointerexception
1153 move xpc,ra /* faulting address is return adress */
1154 b asm_handle_nat_exception
1159 move a0,a1 /* move index into a0 */
1160 jal new_arrayindexoutofboundsexception
1165 aaddiu sp,sp,32 /* free stack space */
1166 move xpc,ra /* faulting address is return adress */
1167 b asm_handle_nat_exception
1172 jal new_arraystoreexception
1177 move xpc,ra /* faulting address is return adress */
1178 b asm_handle_nat_exception
1180 .end asm_builtin_aastore
1183 /******************* function asm_initialize_thread_stack **********************
1185 * u1* asm_initialize_thread_stack (void *func, u1 *stack); *
1187 * initialize a thread stack *
1189 *******************************************************************************/
1191 .ent asm_initialize_thread_stack
1193 asm_initialize_thread_stack:
1194 aaddiu a1,a1,-14*8 /* allocate save area */
1195 sd zero, 0*8(a1) /* s0 initalize thread area */
1196 sd zero, 1*8(a1) /* s1 */
1197 sd zero, 2*8(a1) /* s2 */
1198 sd zero, 3*8(a1) /* s3 */
1199 sd zero, 4*8(a1) /* s4 */
1200 sd zero, 5*8(a1) /* s5 */
1201 sd zero, 6*8(a1) /* s6 */
1202 sd zero, 7*8(a1) /* s7 */
1203 sd zero, 8*8(a1) /* s8 */
1204 sd zero, 9*8(a1) /* fs0 */
1205 sd zero,10*8(a1) /* fs1 */
1206 sd zero,11*8(a1) /* fs2 */
1207 sd zero,12*8(a1) /* fs3 */
1212 .end asm_initialize_thread_stack
1215 /******************* function asm_perform_threadswitch *************************
1217 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1219 * performs a threadswitch *
1221 *******************************************************************************/
1223 .ent asm_perform_threadswitch
1225 asm_perform_threadswitch:
1226 aaddiu sp,sp,-14*8 /* allocate new stack */
1227 sd s0, 0*8(sp) /* save saved registers of old thread */
1241 ast sp,0(a0) /* save old stack pointer */
1242 ast sp,0(a2) /* stackTop = old stack pointer */
1243 ald sp,0(a1) /* load new stack pointer */
1244 ld s0, 0*8(sp) /* load saved registers of new thread */
1258 aaddiu sp,sp,14*8 /* deallocate new stack */
1262 .end asm_perform_threadswitch
1265 /********************* function asm_switchstackandcall *************************
1267 * void asm_switchstackandcall (void *stack, void *func, void **stacktopsave); *
1269 * Switches to a new stack, calls a function and switches back. *
1270 * a0 new stack pointer *
1271 * a1 function pointer *
1272 * a2 pointer to variable where stack top should be stored *
1274 *******************************************************************************/
1276 .ent asm_switchstackandcall
1278 asm_switchstackandcall:
1279 aaddiu a0,a0,-16 /* allocate new stack */
1280 sd ra,0(a0) /* save return address on new stack */
1281 sd sp,8(a0) /* save old stack pointer on new stack */
1282 sd sp,0(a2) /* save old stack pointer to variable */
1283 move sp,a0 /* switch to new stack */
1287 jalr itmp3 /* and call function */
1289 ld ra,0(sp) /* load return address */
1290 ld sp,8(sp) /* switch to old stack */
1294 .end asm_switchstackandcall
1297 .ent asm_getclassvalues_atomic
1299 asm_getclassvalues_atomic:
1302 lw t0,offbaseval(a0)
1303 lw t1,offdiffval(a0)
1304 lw t2,offbaseval(a1)
1306 sw t0,offcast_super_baseval(a2)
1307 sw t1,offcast_super_diffval(a2)
1308 sw t2,offcast_sub_baseval(a2)
1311 .end asm_getclassvalues_atomic
1315 asm_criticalsections:
1316 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
1319 .quad _crit_restart1
1322 .quad _crit_restart2
1329 .ent compare_and_swap
1340 .end compare_and_swap
1342 * These are local overrides for various environment variables in Emacs.
1343 * Please do not remove this and leave it at the end of the file, where
1344 * Emacs will automagically detect them.
1345 * ---------------------------------------------------------------------
1348 * indent-tabs-mode: t