1 /* vm/jit/mips/asmpart.S - Java-C interface functions for mips
3 Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4 R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5 C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6 Institut f. Computersprachen - TU Wien
8 This file is part of CACAO.
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2, or (at
13 your option) any later version.
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 Contact: cacao@complang.tuwien.ac.at
27 Authors: Andreas Krall
29 $Id: asmpart.S 1814 2004-12-22 12:37:58Z twisti $
35 #include "vm/jit/mips/offsets.h"
36 #include "vm/jit/mips/asmoffsets.h"
129 #define aaddiu daddiu
141 /********************* exported functions and variables ***********************/
143 .globl asm_calljavafunction
144 .globl asm_calljavafunction2
145 .globl asm_calljavafunction2long
146 .globl asm_calljavafunction2double
147 .globl asm_call_jit_compiler
148 .globl asm_dumpregistersandcall
149 .globl asm_handle_exception
150 .globl asm_handle_nat_exception
151 .globl asm_check_clinit
152 .globl asm_builtin_checkarraycast
153 .globl asm_builtin_checkcast
154 .globl asm_builtin_aastore
156 #if defined(USE_THREADS)
157 .globl asm_builtin_monitorenter
158 .globl asm_builtin_monitorexit
161 .globl asm_builtin_idiv
162 .globl asm_builtin_irem
163 .globl asm_builtin_ldiv
164 .globl asm_builtin_lrem
165 .globl asm_perform_threadswitch
166 .globl asm_initialize_thread_stack
167 .globl asm_switchstackandcall
168 .globl asm_builtin_trace
169 .globl asm_builtin_exittrace
170 .globl asm_getclassvalues_atomic
171 .globl asm_criticalsections
173 .globl compare_and_swap
176 /********************* function asm_calljavafunction ***************************
178 * This function calls a Java-method (which possibly needs compilation) *
179 * with up to 4 address parameters. *
181 * This functions calls the JIT-compiler which eventually translates the *
182 * method into machine code. *
184 * A possibly throwed exception will be returned to the caller as function *
185 * return value, so the java method cannot return a fucntion value (this *
186 * function usually calls 'main' and '<clinit>' which do not return a *
190 * javaobject_header *asm_calljavafunction (methodinfo *m, *
191 * void *arg1, void *arg2, void *arg3, void *arg4); *
193 *******************************************************************************/
195 .ent asm_calljavafunction
200 .dword 0 /* catch type all */
201 .dword calljava_xhandler /* handler pc */
202 .dword calljava_xhandler /* end pc */
203 .dword asm_calljavafunction /* start pc */
204 .word 1 /* extable size */
205 .word 0 /* fltsave */
206 .word 0 /* intsave */
209 .word 10*8 /* frame size */
210 .dword 0 /* method pointer (pointer to name) */
212 asm_calljavafunction:
213 aaddiu sp,sp,-10*8 /* allocate stack space */
214 sd ra,0(sp) /* save return address */
218 sd pv,3*8(sp) /* procedure vector */
224 sdc1 fss0,4*8(sp) /* save non JavaABI saved flt registers */
230 sd a0,2*8(sp) /* save method pointer for compiler */
231 aaddiu itmp1,sp,16 /* pass pointer to methodptr via itmp1 */
233 move a0,a1 /* pass the remaining parameters */
238 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
239 ast mptr,1*8(sp) /* store function address */
240 move mptr,sp /* set method pointer */
244 ald pv,1*8(mptr) /* method call as in Java */
245 jalr pv /* call JIT compiler */
247 aaddiu pv,ra,-23*4 /* recompute procedure vector */
249 move v0,zero /* clear return value (exception ptr) */
255 ld ra,0(sp) /* restore return address */
256 ld pv,3*8(sp) /* restore procedure vector */
258 ldc1 fss0,4*8(sp) /* restore non JavaABI saved flt regs */
265 aaddiu sp,sp,10*8 /* free stack space */
271 jal builtin_throw_exception
274 .end asm_calljavafunction
277 .ent asm_calljavafunction2
282 .dword 0 /* catch type all */
283 .dword calljava_xhandler2 /* handler pc */
284 .dword calljava_xhandler2 /* end pc */
285 .dword asm_calljavafunction2 /* start pc */
286 .word 1 /* extable size */
287 .word 0 /* fltsave */
288 .word 1 /* intsave */
291 .word 12*8 /* frame size */
292 .dword 0 /* method pointer (pointer to name) */
294 asm_calljavafunction2:
295 asm_calljavafunction2double:
296 asm_calljavafunction2long:
297 aaddiu sp,sp,-12*8 /* allocate stack space (only 11 needed)*/
298 sd ra,0(sp) /* save return address */
302 sd pv,1*8(sp) /* procedure vector */
309 sdc1 fss0,5*8(sp) /* save non JavaABI saved flt registers */
315 sd a0,4*8(sp) /* save method pointer for compiler */
319 blez s7,calljava_argsloaded
320 ald a0,offjniitem(t0)
321 ldc1 fa0,offjniitem(t0)
323 blez s7,calljava_argsloaded
325 ald a1,offjniitem+sizejniblock*1(t0)
326 ldc1 fa1,offjniitem+sizejniblock*1(t0)
328 blez s7,calljava_argsloaded
330 ald a2,offjniitem+sizejniblock*2(t0)
331 ldc1 fa2,offjniitem+sizejniblock*2(t0)
333 blez s7,calljava_argsloaded
335 ald a3,offjniitem+sizejniblock*3(t0)
336 ldc1 fa3,offjniitem+sizejniblock*3(t0)
338 blez s7,calljava_argsloaded
340 ald a4,offjniitem+sizejniblock*4(t0)
341 ldc1 fa4,offjniitem+sizejniblock*4(t0)
343 blez s7,calljava_argsloaded
345 ald a5,offjniitem+sizejniblock*5(t0)
346 ldc1 fa5,offjniitem+sizejniblock*5(t0)
348 blez s7,calljava_argsloaded
350 ald a6,offjniitem+sizejniblock*6(t0)
351 ldc1 fa6,offjniitem+sizejniblock*6(t0)
353 blez s7,calljava_argsloaded
355 ald a7,offjniitem+sizejniblock*7(t0)
356 ldc1 fa7,offjniitem+sizejniblock*7(t0)
361 blez s7,calljava_nocopy
368 ald t3,offjniitem+sizejniblock*8(t0)
371 ala t0,sizejniblock(t0)
373 bnez t1,calljava_copyloop
376 ala itmp1,32(t8) /* pass pointer to methodptr via itmp1 */
378 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
379 ast mptr,16(sp) /* store function address */
380 ala mptr,8(t8) /* set method pointer */
384 ald pv,8(mptr) /* method call as in Java */
385 jalr pv /* call JIT compiler */
387 aaddiu pv,ra,-76*4 /* recompute procedure vector */
390 ld ra,0(sp) /* restore return address */
391 ld pv,8(sp) /* restore procedure vector */
394 ldc1 fss0,5*8(sp) /* restore non JavaABI saved flt regs */
401 aaddiu sp,sp,12*8 /* free stack space */
409 jal builtin_throw_exception
412 .end asm_calljavafunction2
415 /****************** function asm_call_jit_compiler *****************************
417 * invokes the compiler for untranslated JavaVM methods. *
419 * Register REG_ITEMP1 contains a pointer to the method info structure *
420 * (prepared by createcompilerstub). Using the return address in R31 and the *
421 * offset in the LDA instruction or using the value in methodptr R25 the *
422 * patching address for storing the method address can be computed: *
424 * method address was either loaded using *
425 * M_ALD (REG_PV, REG_PV, a) ; invokestatic/special ($28) *
426 * M_JSR (REG_RA, REG_PV); *
428 * M_LDA (REG_PV, REG_RA, val) *
430 * M_ALD (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($25) *
431 * M_JSR (REG_RA, REG_PV); *
433 * in the static case the method pointer can be computed using the *
434 * return address and the lda function following the jmp instruction *
436 *******************************************************************************/
439 .ent asm_call_jit_compiler
441 asm_call_jit_compiler:
442 lw t0,-12(ra) /* load instruction LD PV,xxx($y) */
443 srl t0,t0,21 /* shift right register number $y */
444 and t0,t0,31 /* isolate register number */
445 addiu t0,t0,-mptrreg /* test for REG_METHODPTR */
448 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
450 sra t0,t0,16 /* isolate offset */
451 aaddu mptr,t0,ra /* compute update address */
454 aaddiu sp,sp,-18*8 /* allocate stack space */
455 sd a0,0*8(sp) /* save all argument registers */
456 sd a1,1*8(sp) /* they could be used by method */
471 sd mptr,16*8(sp) /* save method pointer */
472 sd ra,17*8(sp) /* save return address */
474 ald a0,0(itmp1) /* pass 'methodinfo' pointer to */
475 jal jit_compile /* jit compiler */
477 ld a0,0*8(sp) /* restore argument registers */
478 ld a1,1*8(sp) /* they could be used by method */
493 ld mptr,16*8(sp) /* restore method pointer */
494 ld ra,17*8(sp) /* restore return address */
495 aaddiu sp,sp,18*8 /* deallocate stack area */
497 lw t0,-12(ra) /* load instruction LDQ PV,xxx($yy) */
499 sra t0,t0,16 /* isolate offset */
501 aaddu t0,t0,mptr /* compute update address via method pointer*/
502 ast v0,0(t0) /* save new method address there */
504 move pv,v0 /* move method address into pv */
506 jr pv /* and call method. The method returns */
507 /* directly to the caller (ra). */
509 .end asm_call_jit_compiler
512 /********************* function asm_handle_exception ***************************
514 * This function handles an exception. It does not use the usual calling *
515 * conventions. The exception pointer is passed in REG_ITMP1 and the *
516 * pc from the exception raising position is passed in REG_ITMP2. It searches *
517 * the local exception table for a handler. If no one is found, it unwinds *
518 * stacks and continues searching the callers. *
520 * void asm_handle_exception (exceptionptr, exceptionpc); *
522 *******************************************************************************/
524 .ent asm_handle_nat_exception
526 asm_handle_nat_exception:
527 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
529 sra t0,t0,16 /* isolate offset */
530 aaddu pv,t0,ra /* compute update address */
532 .aent asm_handle_exception
534 asm_handle_exception:
535 aaddiu sp,sp,-14*8 /* allocate stack */
536 sd v0,0*8(sp) /* save possible used registers */
537 sd t0,1*8(sp) /* also registers used by trace_exception */
551 addu t3,zero,1 /* set no unwind flag */
553 aaddiu sp,sp,-6*8 /* allocate stack */
554 sd xptr,0*8(sp) /* save used registers */
561 ald a1,MethodPointer(pv)
566 jal builtin_trace_exception /* trace_exception(xptr,methodptr) */
568 ld xptr,0*8(sp) /* restore used register */
573 aaddiu sp,sp,6*8 /* deallocate stack */
575 lw t0,ExTableSize(pv) /* t0 = exception table size */
576 beqz t0,empty_table /* if empty table skip */
577 aaddiu t1,pv,ExTableStart /* t1 = start of exception table */
580 ald t2,ExStartPC(t1) /* t2 = exception start pc */
581 sle t2,t2,xpc /* t2 = (startpc <= xpc) */
582 beqz t2,ex_table_cont /* if (false) continue */
583 ald t2,ExEndPC(t1) /* t2 = exception end pc */
584 slt t2,xpc,t2 /* t2 = (xpc < endpc) */
585 beqz t2,ex_table_cont /* if (false) continue */
586 ald a1,ExCatchType(t1) /* arg1 = exception catch type */
587 beqz a1,ex_handle_it /* NULL catches everything */
589 lw itmp3,offclassloaded(a1)
590 bnez itmp3,L_class_loaded
592 aaddiu sp,sp,-8*8 /* allocate stack */
593 sd t0,0*8(sp) /* save used register */
605 ld t0,0*8(sp) /* restore used register */
613 aaddiu sp,sp,8*8 /* deallocate stack */
616 lw itmp3,offclasslinked(a1)
617 aaddiu sp,sp,-8*8 /* allocate stack */
619 bnez itmp3,L_class_linked
621 sd t0,0*8(sp) /* save used register */
632 ld t0,0*8(sp) /* restore used register */
644 ald a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
645 ald a1,offclassvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
646 lw a0,offbaseval(a0) /* a0 = baseval(xptr) */
647 lw v0,offbaseval(a1) /* a2 = baseval(catchtype) */
648 lw a1,offdiffval(a1) /* a1 = diffval(catchtype) */
650 subu a0,a0,v0 /* a0 = baseval(xptr) - baseval(catchtype) */
651 sltu v0,a1,a0 /* v0 = xptr is instanceof catchtype */
652 aaddiu sp,sp,8*8 /* deallocate stack */
653 bnez v0,ex_table_cont /* if (false) continue */
656 ald xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
658 beqz t3,ex_jump /* if (!(no stack unwinding) skip */
660 ld v0,0*8(sp) /* restore possible used registers */
661 ld t0,1*8(sp) /* also registers used by trace_exception */
675 aaddiu sp,sp,14*8 /* deallocate stack */
678 jr xpc /* jump to the handler */
681 aaddiu t1,t1,ExEntrySize /* next exception table entry */
682 addiu t0,t0,-1 /* decrement entry counter */
683 bgtz t0,ex_table_loop /* if (t0 > 0) next entry */
686 beqz t3,ex_already_cleared /* if here the first time, then */
687 aaddiu sp,sp,14*8 /* deallocate stack and */
688 move t3,zero /* clear the no unwind flag */
690 lw t0,IsSync(pv) /* t0 = SyncOffset */
691 beqz t0,no_monitor_exit /* if zero no monitorexit */
693 #if defined(USE_THREADS)
694 aaddu t0,sp,t0 /* add stackptr to Offset */
695 ald a0,-8(t0) /* load monitorexit pointer */
697 aaddiu sp,sp,-8*8 /* allocate stack */
698 sd t0,0*8(sp) /* save used register */
706 jal builtin_monitorexit /* builtin_monitorexit(objectptr) */
708 ld t0,0*8(sp) /* restore used register */
715 aaddiu sp,sp,8*8 /* deallocate stack */
719 lw t0,FrameSize(pv) /* t0 = frame size */
720 aaddu sp,sp,t0 /* unwind stack */
721 move t0,sp /* t0 = pointer to save area */
722 lw t1,IsLeaf(pv) /* t1 = is leaf procedure */
723 bnez t1,ex_no_restore /* if (leaf) skip */
724 ld ra,-8(t0) /* restore ra */
725 aaddiu t0,t0,-8 /* t0-- */
727 move xpc,ra /* the new xpc is ra */
728 lw t1,IntSave(pv) /* t1 = saved int register count */
729 ala t2,ex_int2 /* t2 = current pc */
730 sll t1,t1,2 /* t1 = register count * 4 */
731 asubu t2,t2,t1 /* t2 = ex_int_sav - 4 * register count */
732 jr t2 /* jump to save position */
742 sll t1,t1,1 /* t1 = register count * 4 * 2 */
743 asubu t0,t0,t1 /* t0 = t0 - 8 * register count */
745 lw t1,FltSave(pv) /* t1 = saved flt register count */
746 ala t2,ex_flt2 /* t2 = current pc */
747 sll t1,t1,2 /* t1 = register count * 4 */
748 asubu t2,t2,t1 /* t2 = ex_int_sav - 4 * register count */
749 jr t2 /* jump to save position */
755 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
757 sra t0,t0,16 /* isolate offset */
758 aaddu pv,t0,ra /* compute update address */
761 .end asm_handle_nat_exception
764 /********************* asm_check_clinit ****************************************
766 * Checks if class is initialized. If not, do it right now. *
768 *******************************************************************************/
770 .ent asm_check_clinit
775 sd ra,0*8(sp) /* save return address */
777 sd a0,1*8(sp) /* save argument registers for leaf funcs */
801 sd itmp2,22*8(sp) /* save machine code */
803 /* check if class is initialized */
804 lw itmp3,offclassinit(itmp1)
805 bnez itmp3,L_is_initialized
807 move a0,itmp1 /* move class pointer to a0 */
810 beqz v0,L_initializererror
813 ld ra,0*8(sp) /* get return address */
814 ld itmp1,22*8(sp) /* get machine code */
816 daddiu ra,ra,-2*4 /* go back 2 instructions (jal + nop delay) */
817 sw itmp1,0(ra) /* patch first instruction */
818 dsrl32 itmp1,itmp1,0 /* get high 32 bit */
819 sw itmp1,4(ra) /* patch second instruction */
821 move a0,ra /* start of flush area */
822 addiu a1,zero,2*4 /* 2 instruction words long */
823 jal docacheflush /* flush! */
825 ld ra,0*8(sp) /* restore return address */
827 ld a0,1*8(sp) /* restore argument registers */
853 daddiu ra,ra,-2*4 /* go back 2 instructions (jal + nop delay) */
857 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
858 jal builtin_asm_get_exceptionptrptr
862 ld xptr,0(v0) /* get the exception pointer */
863 sd zero,0(v0) /* clear the exception pointer */
865 ld ra,0*8(sp) /* restore return address */
867 ld a0,1*8(sp) /* restore argument registers */
893 aaddiu xpc,ra,-4 /* faulting address is return adress - 4 */
894 b asm_handle_exception
896 .end asm_check_clinit
899 /********************* function asm_builtin_monitorenter ***********************
901 * Does null check and calls monitorenter or throws an exception *
903 *******************************************************************************/
905 #if defined(USE_THREADS)
906 .ent asm_builtin_monitorenter
908 asm_builtin_monitorenter:
909 beqz a0,nb_monitorenter /* if (null) throw exception */
910 ala t9,builtin_monitorenter /* else call builtin_monitorenter */
916 ald a0,string_java_lang_NullPointerException
922 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
923 b asm_handle_nat_exception
925 .end asm_builtin_monitorenter
929 /********************* function asm_builtin_monitorexit ************************
931 * Does null check and calls monitorexit or throws an exception *
933 *******************************************************************************/
935 #if defined(USE_THREADS)
936 .ent asm_builtin_monitorexit
938 asm_builtin_monitorexit:
939 beqz a0,nb_monitorexit /* if (null) throw exception */
940 ala t9,builtin_monitorexit /* else call builtin_monitorexit */
946 jal new_nullpointerexception
951 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
952 b asm_handle_nat_exception
954 .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