1 /* vm/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 1711 2004-12-06 16:17:40Z twisti $
36 #include "vm/jit/mips/offsets.h"
37 #include "vm/jit/mips/asmoffsets.h"
130 #define aaddiu daddiu
142 /********************* exported functions and variables ***********************/
144 .globl asm_calljavafunction
145 .globl asm_calljavafunction2
146 .globl asm_calljavafunction2long
147 .globl asm_calljavafunction2double
148 .globl asm_call_jit_compiler
149 .globl asm_dumpregistersandcall
150 .globl asm_handle_exception
151 .globl asm_handle_nat_exception
152 .globl asm_check_clinit
153 .globl asm_builtin_checkarraycast
154 .globl asm_builtin_checkcast
155 .globl asm_builtin_aastore
156 .globl asm_builtin_monitorenter
157 .globl asm_builtin_monitorexit
158 .globl asm_builtin_idiv
159 .globl asm_builtin_irem
160 .globl asm_builtin_ldiv
161 .globl asm_builtin_lrem
162 .globl asm_perform_threadswitch
163 .globl asm_initialize_thread_stack
164 .globl asm_switchstackandcall
165 .globl asm_builtin_trace
166 .globl asm_builtin_exittrace
167 .globl asm_getclassvalues_atomic
168 .globl asm_criticalsections
170 .globl compare_and_swap
173 /*************************** imported functions *******************************/
177 .globl builtin_monitorexit
178 .globl builtin_throw_exception
179 .globl builtin_trace_exception
180 .globl class_java_lang_Object
183 /********************* function asm_calljavafunction ***************************
185 * This function calls a Java-method (which possibly needs compilation) *
186 * with up to 4 address parameters. *
188 * This functions calls the JIT-compiler which eventually translates the *
189 * method into machine code. *
191 * A possibly throwed exception will be returned to the caller as function *
192 * return value, so the java method cannot return a fucntion value (this *
193 * function usually calls 'main' and '<clinit>' which do not return a *
197 * javaobject_header *asm_calljavafunction (methodinfo *m, *
198 * void *arg1, void *arg2, void *arg3, void *arg4); *
200 *******************************************************************************/
202 .ent asm_calljavafunction
207 .dword 0 /* catch type all */
208 .dword calljava_xhandler /* handler pc */
209 .dword calljava_xhandler /* end pc */
210 .dword asm_calljavafunction /* start pc */
211 .word 1 /* extable size */
212 .word 0 /* fltsave */
213 .word 0 /* intsave */
216 .word 10*8 /* frame size */
217 .dword 0 /* method pointer (pointer to name) */
219 asm_calljavafunction:
220 aaddiu sp,sp,-10*8 /* allocate stack space */
221 sd ra,0(sp) /* save return address */
225 sd pv,3*8(sp) /* procedure vector */
231 sdc1 fss0,4*8(sp) /* save non JavaABI saved flt registers */
237 sd a0,2*8(sp) /* save method pointer for compiler */
238 aaddiu itmp1,sp,16 /* pass pointer to methodptr via itmp1 */
240 move a0,a1 /* pass the remaining parameters */
245 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
246 ast mptr,1*8(sp) /* store function address */
247 move mptr,sp /* set method pointer */
251 ald pv,1*8(mptr) /* method call as in Java */
252 jalr pv /* call JIT compiler */
254 aaddiu pv,ra,-23*4 /* recompute procedure vector */
256 move v0,zero /* clear return value (exception ptr) */
262 ld ra,0(sp) /* restore return address */
263 ld pv,3*8(sp) /* restore procedure vector */
265 ldc1 fss0,4*8(sp) /* restore non JavaABI saved flt regs */
272 aaddiu sp,sp,10*8 /* free stack space */
278 jal builtin_throw_exception
281 .end asm_calljavafunction
284 .ent asm_calljavafunction2
289 .dword 0 /* catch type all */
290 .dword calljava_xhandler2 /* handler pc */
291 .dword calljava_xhandler2 /* end pc */
292 .dword asm_calljavafunction2 /* start pc */
293 .word 1 /* extable size */
294 .word 0 /* fltsave */
295 .word 1 /* intsave */
298 .word 12*8 /* frame size */
299 .dword 0 /* method pointer (pointer to name) */
301 asm_calljavafunction2:
302 asm_calljavafunction2double:
303 asm_calljavafunction2long:
304 aaddiu sp,sp,-12*8 /* allocate stack space (only 11 needed)*/
305 sd ra,0(sp) /* save return address */
309 sd pv,1*8(sp) /* procedure vector */
316 sdc1 fss0,5*8(sp) /* save non JavaABI saved flt registers */
322 sd a0,4*8(sp) /* save method pointer for compiler */
326 blez s7,calljava_argsloaded
327 ald a0,offjniitem(t0)
328 ldc1 fa0,offjniitem(t0)
330 blez s7,calljava_argsloaded
332 ald a1,offjniitem+sizejniblock*1(t0)
333 ldc1 fa1,offjniitem+sizejniblock*1(t0)
335 blez s7,calljava_argsloaded
337 ald a2,offjniitem+sizejniblock*2(t0)
338 ldc1 fa2,offjniitem+sizejniblock*2(t0)
340 blez s7,calljava_argsloaded
342 ald a3,offjniitem+sizejniblock*3(t0)
343 ldc1 fa3,offjniitem+sizejniblock*3(t0)
345 blez s7,calljava_argsloaded
347 ald a4,offjniitem+sizejniblock*4(t0)
348 ldc1 fa4,offjniitem+sizejniblock*4(t0)
350 blez s7,calljava_argsloaded
352 ald a5,offjniitem+sizejniblock*5(t0)
353 ldc1 fa5,offjniitem+sizejniblock*5(t0)
355 blez s7,calljava_argsloaded
357 ald a6,offjniitem+sizejniblock*6(t0)
358 ldc1 fa6,offjniitem+sizejniblock*6(t0)
360 blez s7,calljava_argsloaded
362 ald a7,offjniitem+sizejniblock*7(t0)
363 ldc1 fa7,offjniitem+sizejniblock*7(t0)
368 blez s7,calljava_nocopy
375 ald t3,offjniitem+sizejniblock*8(t0)
378 ala t0,sizejniblock(t0)
380 bnez t1,calljava_copyloop
383 ala itmp1,32(t8) /* pass pointer to methodptr via itmp1 */
385 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
386 ast mptr,16(sp) /* store function address */
387 ala mptr,8(t8) /* set method pointer */
391 ald pv,8(mptr) /* method call as in Java */
392 jalr pv /* call JIT compiler */
394 aaddiu pv,ra,-76*4 /* recompute procedure vector */
397 ld ra,0(sp) /* restore return address */
398 ld pv,8(sp) /* restore procedure vector */
401 ldc1 fss0,5*8(sp) /* restore non JavaABI saved flt regs */
408 aaddiu sp,sp,12*8 /* free stack space */
416 jal builtin_throw_exception
419 .end asm_calljavafunction2
422 /****************** function asm_call_jit_compiler *****************************
424 * invokes the compiler for untranslated JavaVM methods. *
426 * Register REG_ITEMP1 contains a pointer to the method info structure *
427 * (prepared by createcompilerstub). Using the return address in R31 and the *
428 * offset in the LDA instruction or using the value in methodptr R25 the *
429 * patching address for storing the method address can be computed: *
431 * method address was either loaded using *
432 * M_ALD (REG_PV, REG_PV, a) ; invokestatic/special ($28) *
433 * M_JSR (REG_RA, REG_PV); *
435 * M_LDA (REG_PV, REG_RA, val) *
437 * M_ALD (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($25) *
438 * M_JSR (REG_RA, REG_PV); *
440 * in the static case the method pointer can be computed using the *
441 * return address and the lda function following the jmp instruction *
443 *******************************************************************************/
446 .ent asm_call_jit_compiler
448 asm_call_jit_compiler:
449 lw t0,-12(ra) /* load instruction LD PV,xxx($y) */
450 srl t0,t0,21 /* shift right register number $y */
451 and t0,t0,31 /* isolate register number */
452 addiu t0,t0,-mptrreg /* test for REG_METHODPTR */
455 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
457 sra t0,t0,16 /* isolate offset */
458 aaddu mptr,t0,ra /* compute update address */
461 aaddiu sp,sp,-18*8 /* allocate stack space */
462 sd a0,0*8(sp) /* save all argument registers */
463 sd a1,1*8(sp) /* they could be used by method */
478 sd mptr,16*8(sp) /* save method pointer */
479 sd ra,17*8(sp) /* save return address */
481 ald a0,0(itmp1) /* pass 'methodinfo' pointer to */
482 jal jit_compile /* jit compiler */
484 ld a0,0*8(sp) /* restore argument registers */
485 ld a1,1*8(sp) /* they could be used by method */
500 ld mptr,16*8(sp) /* restore method pointer */
501 ld ra,17*8(sp) /* restore return address */
502 aaddiu sp,sp,18*8 /* deallocate stack area */
504 lw t0,-12(ra) /* load instruction LDQ PV,xxx($yy) */
506 sra t0,t0,16 /* isolate offset */
508 aaddu t0,t0,mptr /* compute update address via method pointer*/
509 ast v0,0(t0) /* save new method address there */
511 move pv,v0 /* move method address into pv */
513 jr pv /* and call method. The method returns */
514 /* directly to the caller (ra). */
516 .end asm_call_jit_compiler
519 /********************* function asm_handle_exception ***************************
521 * This function handles an exception. It does not use the usual calling *
522 * conventions. The exception pointer is passed in REG_ITMP1 and the *
523 * pc from the exception raising position is passed in REG_ITMP2. It searches *
524 * the local exception table for a handler. If no one is found, it unwinds *
525 * stacks and continues searching the callers. *
527 * void asm_handle_exception (exceptionptr, exceptionpc); *
529 *******************************************************************************/
531 .ent asm_handle_nat_exception
533 asm_handle_nat_exception:
534 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
536 sra t0,t0,16 /* isolate offset */
537 aaddu pv,t0,ra /* compute update address */
539 .aent asm_handle_exception
541 asm_handle_exception:
542 aaddiu sp,sp,-14*8 /* allocate stack */
543 sd v0,0*8(sp) /* save possible used registers */
544 sd t0,1*8(sp) /* also registers used by trace_exception */
558 addu t3,zero,1 /* set no unwind flag */
560 aaddiu sp,sp,-6*8 /* allocate stack */
561 sd xptr,0*8(sp) /* save used registers */
568 ald a1,MethodPointer(pv)
573 jal builtin_trace_exception /* trace_exception(xptr,methodptr) */
575 ld xptr,0*8(sp) /* restore used register */
580 aaddiu sp,sp,6*8 /* deallocate stack */
582 lw t0,ExTableSize(pv) /* t0 = exception table size */
583 beqz t0,empty_table /* if empty table skip */
584 aaddiu t1,pv,ExTableStart /* t1 = start of exception table */
587 ald t2,ExStartPC(t1) /* t2 = exception start pc */
588 sle t2,t2,xpc /* t2 = (startpc <= xpc) */
589 beqz t2,ex_table_cont /* if (false) continue */
590 ald t2,ExEndPC(t1) /* t2 = exception end pc */
591 slt t2,xpc,t2 /* t2 = (xpc < endpc) */
592 beqz t2,ex_table_cont /* if (false) continue */
593 ald a1,ExCatchType(t1) /* arg1 = exception catch type */
594 beqz a1,ex_handle_it /* NULL catches everything */
596 lw itmp3,offclassloaded(a1)
597 bnez itmp3,L_class_loaded
599 aaddiu sp,sp,-8*8 /* allocate stack */
600 sd t0,0*8(sp) /* save used register */
612 ld t0,0*8(sp) /* restore used register */
620 aaddiu sp,sp,8*8 /* deallocate stack */
623 lw itmp3,offclasslinked(a1)
624 aaddiu sp,sp,-8*8 /* allocate stack */
626 bnez itmp3,L_class_linked
628 sd t0,0*8(sp) /* save used register */
639 ld t0,0*8(sp) /* restore used register */
651 ald a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
652 ald a1,offclassvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
653 lw a0,offbaseval(a0) /* a0 = baseval(xptr) */
654 lw v0,offbaseval(a1) /* a2 = baseval(catchtype) */
655 lw a1,offdiffval(a1) /* a1 = diffval(catchtype) */
657 subu a0,a0,v0 /* a0 = baseval(xptr) - baseval(catchtype) */
658 sltu v0,a1,a0 /* v0 = xptr is instanceof catchtype */
659 aaddiu sp,sp,8*8 /* deallocate stack */
660 bnez v0,ex_table_cont /* if (false) continue */
663 ald xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
665 beqz t3,ex_jump /* if (!(no stack unwinding) skip */
667 ld v0,0*8(sp) /* restore possible used registers */
668 ld t0,1*8(sp) /* also registers used by trace_exception */
682 aaddiu sp,sp,14*8 /* deallocate stack */
685 jr xpc /* jump to the handler */
688 aaddiu t1,t1,ExEntrySize /* next exception table entry */
689 addiu t0,t0,-1 /* decrement entry counter */
690 bgtz t0,ex_table_loop /* if (t0 > 0) next entry */
693 beqz t3,ex_already_cleared /* if here the first time, then */
694 aaddiu sp,sp,14*8 /* deallocate stack and */
695 move t3,zero /* clear the no unwind flag */
697 lw t0,IsSync(pv) /* t0 = SyncOffset */
698 beqz t0,no_monitor_exit /* if zero no monitorexit */
699 aaddu t0,sp,t0 /* add stackptr to Offset */
700 ald a0,-8(t0) /* load monitorexit pointer */
702 aaddiu sp,sp,-8*8 /* allocate stack */
703 sd t0,0*8(sp) /* save used register */
711 jal builtin_monitorexit /* builtin_monitorexit(objectptr) */
713 ld t0,0*8(sp) /* restore used register */
720 aaddiu sp,sp,8*8 /* deallocate stack */
723 lw t0,FrameSize(pv) /* t0 = frame size */
724 aaddu sp,sp,t0 /* unwind stack */
725 move t0,sp /* t0 = pointer to save area */
726 lw t1,IsLeaf(pv) /* t1 = is leaf procedure */
727 bnez t1,ex_no_restore /* if (leaf) skip */
728 ld ra,-8(t0) /* restore ra */
729 aaddiu t0,t0,-8 /* t0-- */
731 move xpc,ra /* the new xpc is ra */
732 lw t1,IntSave(pv) /* t1 = saved int register count */
733 ala t2,ex_int2 /* t2 = current pc */
734 sll t1,t1,2 /* t1 = register count * 4 */
735 asubu t2,t2,t1 /* t2 = ex_int_sav - 4 * register count */
736 jr t2 /* jump to save position */
746 sll t1,t1,1 /* t1 = register count * 4 * 2 */
747 asubu t0,t0,t1 /* t0 = t0 - 8 * register count */
749 lw t1,FltSave(pv) /* t1 = saved flt register count */
750 ala t2,ex_flt2 /* 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 */
759 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
761 sra t0,t0,16 /* isolate offset */
762 aaddu pv,t0,ra /* compute update address */
765 .end asm_handle_nat_exception
768 /********************* asm_check_clinit ****************************************
770 * Checks if class is initialized. If not, do it right now. *
772 *******************************************************************************/
774 .ent asm_check_clinit
779 sd ra,0*8(sp) /* save return address */
781 sd a0,1*8(sp) /* save argument registers for leaf funcs */
805 sd itmp2,22*8(sp) /* save machine code */
807 /* check if class is initialized */
808 lw itmp3,offclassinit(itmp1)
809 bnez itmp3,L_is_initialized
811 move a0,itmp1 /* move class pointer to a0 */
814 beqz v0,L_initializererror
817 ld ra,0*8(sp) /* get return address */
818 ld itmp1,22*8(sp) /* get machine code */
820 daddiu ra,ra,-2*4 /* go back 2 instructions (jal + nop delay) */
821 sw itmp1,0(ra) /* patch first instruction */
822 dsrl32 itmp1,itmp1,0 /* get high 32 bit */
823 sw itmp1,4(ra) /* patch second instruction */
825 move a0,ra /* start of flush area */
826 addiu a1,zero,2*4 /* 2 instruction words long */
827 jal docacheflush /* flush! */
829 ld ra,0*8(sp) /* restore return address */
831 ld a0,1*8(sp) /* restore argument registers */
857 daddiu ra,ra,-2*4 /* go back 2 instructions (jal + nop delay) */
861 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
862 jal builtin_asm_get_exceptionptrptr
866 ld xptr,0(v0) /* get the exception pointer */
867 sd zero,0(v0) /* clear the exception pointer */
869 ld ra,0*8(sp) /* restore return address */
871 ld a0,1*8(sp) /* restore argument registers */
897 aaddiu xpc,ra,-4 /* faulting address is return adress - 4 */
898 b asm_handle_exception
900 .end asm_check_clinit
903 /********************* function asm_builtin_monitorenter ***********************
905 * Does null check and calls monitorenter or throws an exception *
907 *******************************************************************************/
909 .ent asm_builtin_monitorenter
911 asm_builtin_monitorenter:
912 beqz a0,nb_monitorenter /* if (null) throw exception */
913 ala t9,builtin_monitorenter /* else call builtin_monitorenter */
919 ald a0,string_java_lang_NullPointerException
925 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
926 b asm_handle_nat_exception
928 .end asm_builtin_monitorenter
931 /********************* function asm_builtin_monitorexit ************************
933 * Does null check and calls monitorexit or throws an exception *
935 *******************************************************************************/
937 .ent asm_builtin_monitorexit
939 asm_builtin_monitorexit:
940 beqz a0,nb_monitorexit /* if (null) throw exception */
941 ala t9,builtin_monitorexit /* else call builtin_monitorexit */
947 jal new_nullpointerexception
952 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
953 b asm_handle_nat_exception
955 .end asm_builtin_monitorexit
958 /************************ function asm_builtin_idiv ****************************
960 * Does null check and calls idiv or throws an exception *
962 *******************************************************************************/
964 .ent asm_builtin_idiv
967 beqz a1,nb_idiv /* if (null) throw exception */
968 ala itmp3,builtin_idiv /* else call builtin_idiv */
974 jal new_arithmeticexception
979 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
980 b asm_handle_nat_exception
982 .end asm_builtin_idiv
985 /************************ function asm_builtin_ldiv ****************************
987 * Does null check and calls ldiv or throws an exception *
989 *******************************************************************************/
991 .ent asm_builtin_ldiv
994 beqz a1,nb_ldiv /* if (null) throw exception */
995 ala itmp3,builtin_ldiv /* else call builtin_ldiv */
1001 jal new_arithmeticexception
1006 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1007 b asm_handle_nat_exception
1009 .end asm_builtin_ldiv
1012 /************************ function asm_builtin_irem ****************************
1014 * Does null check and calls irem or throws an exception *
1016 *******************************************************************************/
1018 .ent asm_builtin_irem
1021 beqz a1,nb_irem /* if (null) throw exception */
1022 ala t9,builtin_irem /* else call builtin_irem */
1028 jal new_arithmeticexception
1033 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1034 b asm_handle_nat_exception
1036 .end asm_builtin_irem
1039 /************************ function asm_builtin_lrem ****************************
1041 * Does null check and calls lrem or throws an exception *
1043 *******************************************************************************/
1045 .ent asm_builtin_lrem
1048 beqz a1,nb_lrem /* if (null) throw exception */
1049 ala t9,builtin_lrem /* else call builtin_lrem */
1055 jal new_arithmeticexception
1060 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1061 b asm_handle_nat_exception
1063 .end asm_builtin_lrem
1066 /******************* function asm_builtin_checkarraycast ***********************
1068 * Does the cast check and eventually throws an exception *
1070 *******************************************************************************/
1072 .ent asm_builtin_checkarraycast
1074 asm_builtin_checkarraycast:
1075 aaddiu sp,sp,-16 /* allocate stack space */
1076 sd ra,0(sp) /* save return address */
1077 sd a0,8(sp) /* save object pointer */
1078 jal builtin_checkarraycast /* builtin_checkarraycast */
1079 beqz v0,nb_carray_throw /* if (false) throw exception */
1080 ld ra,0(sp) /* restore return address */
1081 ld v0,8(sp) /* return object pointer */
1082 aaddiu sp,sp,16 /* deallocate stack */
1086 jal new_classcastexception
1089 ld ra,0(sp) /* restore return address */
1090 aaddiu sp,sp,16 /* free stack space */
1091 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1092 b asm_handle_nat_exception
1094 .end asm_builtin_checkarraycast
1097 /********************* function asm_builtin_checkcast **************************
1099 * Does the cast check and eventually throws an exception *
1101 *******************************************************************************/
1103 .ent asm_builtin_checkcast
1105 asm_builtin_checkcast:
1106 aaddiu sp,sp,-16 /* allocate stack space */
1107 sd ra,0(sp) /* save return address */
1108 sd a0,8(sp) /* save object pointer */
1109 jal builtin_checkcast /* builtin_checkcast */
1110 beqz v0,nb_ccast_throw /* if (false) throw exception */
1111 ld ra,0(sp) /* restore return address */
1112 ld v0,8(sp) /* return object pointer */
1113 aaddiu sp,sp,16 /* deallocate stack */
1117 jal new_classcastexception
1120 ld ra,0(sp) /* restore return address */
1121 aaddiu sp,sp,16 /* free stack space */
1122 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1123 b asm_handle_nat_exception
1125 .end asm_builtin_checkcast
1128 /******************* function asm_builtin_aastore ******************************
1130 * Does the cast check and eventually throws an exception *
1131 * a0 = arrayref, a1 = index, a2 = value *
1133 *******************************************************************************/
1135 .ent asm_builtin_aastore
1137 asm_builtin_aastore:
1138 beqz a0,nb_aastore_null /* if null pointer throw exception */
1139 lw t0,offarraysize(a0) /* load size */
1140 aaddiu sp,sp,-32 /* allocate stack space */
1141 sd ra,0(sp) /* save return address */
1142 asll t1,a1,ashift /* add index*8 to arrayref */
1143 aaddu t1,a0,t1 /* add index * ashift to arrayref */
1144 sltu t0,a1,t0 /* do bound check */
1145 beqz t0,nb_aastore_bound /* if out of bounds throw exception */
1146 move a1,a2 /* object is second argument */
1147 sd t1,8(sp) /* save store position */
1148 sd a1,16(sp) /* save object */
1149 jal builtin_canstore /* builtin_canstore(arrayref,object) */
1150 ld ra,0(sp) /* restore return address */
1151 ld a0,8(sp) /* restore store position */
1152 ld a1,16(sp) /* restore object */
1153 aaddiu sp,sp,32 /* free stack space */
1154 beqz v0,nb_aastore_store /* if (false) throw exception */
1155 ast a1,offobjarrdata(a0) /* store objectptr in array */
1161 jal new_nullpointerexception
1166 move xpc,ra /* faulting address is return adress */
1167 b asm_handle_nat_exception
1172 move a0,a1 /* move index into a0 */
1173 jal new_arrayindexoutofboundsexception
1178 aaddiu sp,sp,32 /* free stack space */
1179 move xpc,ra /* faulting address is return adress */
1180 b asm_handle_nat_exception
1185 jal new_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 .dword _crit_restart1
1335 .dword _crit_restart2
1342 .ent compare_and_swap
1353 .end compare_and_swap
1355 * These are local overrides for various environment variables in Emacs.
1356 * Please do not remove this and leave it at the end of the file, where
1357 * Emacs will automagically detect them.
1358 * ---------------------------------------------------------------------
1361 * indent-tabs-mode: t