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 1119 2004-06-02 11:12:03Z 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 /*************************** imported functions *******************************/
190 .globl builtin_monitorexit
191 .globl builtin_throw_exception
192 .globl builtin_trace_exception
193 .globl class_java_lang_Object
196 /********************* function asm_calljavafunction ****************************
198 * This function calls a Java-method (which possibly needs compilation) *
199 * with up to 4 address parameters. *
201 * This functions calls the JIT-compiler which eventually translates the *
202 * method into machine code. *
204 * A possibly throwed exception will be returned to the caller as function *
205 * return value, so the java method cannot return a fucntion value (this *
206 * function usually calls 'main' and '<clinit>' which do not return a *
210 * javaobject_header *asm_calljavafunction (methodinfo *m, *
211 * void *arg1, void *arg2, void *arg3, void *arg4); *
213 *******************************************************************************/
215 .ent asm_calljavafunction
218 .ascii "calljavafunction\0\0"
221 .quad 0 /* catch type all */
222 .quad calljava_xhandler /* handler pc */
223 .quad calljava_xhandler /* end pc */
224 .quad asm_calljavafunction /* start pc */
225 .long 1 /* extable size */
226 .long 0 /* fltsave */
227 .long 0 /* intsave */
230 .long 10*8 /* frame size */
231 .quad 0 /* method pointer (pointer to name) */
233 asm_calljavafunction:
234 aaddiu sp,sp,-10*8 /* allocate stack space */
235 sd ra,0(sp) /* save return address */
239 sd pv,3*8(sp) /* procedure vector */
245 sdc1 fss0,4*8(sp) /* save non JavaABI saved flt registers */
251 sd a0,2*8(sp) /* save method pointer for compiler */
252 aaddiu itmp1,sp,16 /* pass pointer to methodptr via itmp1 */
254 move a0,a1 /* pass the remaining parameters */
259 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
260 ast mptr,1*8(sp) /* store function address */
261 move mptr,sp /* set method pointer */
265 ald pv,1*8(mptr) /* method call as in Java */
266 jalr pv /* call JIT compiler */
268 aaddiu pv,ra,-23*4 /* recompute procedure vector */
270 move v0,zero /* clear return value (exception ptr) */
276 ld ra,0(sp) /* restore return address */
277 ld pv,3*8(sp) /* restore procedure vector */
279 ldc1 fss0,4*8(sp) /* restore non JavaABI saved flt regs */
286 aaddiu sp,sp,10*8 /* free stack space */
292 jal builtin_throw_exception
295 .end asm_calljavafunction
298 .ent asm_calljavafunction2
301 .ascii "calljavafunction2\0\0"
304 .quad 0 /* catch type all */
305 .quad calljava_xhandler2 /* handler pc */
306 .quad calljava_xhandler2 /* end pc */
307 .quad asm_calljavafunction2 /* start pc */
308 .long 1 /* extable size */
309 .long 0 /* fltsave */
310 .long 1 /* intsave */
313 .long 96 /* frame size */
314 .quad 0 /* method pointer (pointer to name) */
316 asm_calljavafunction2:
317 asm_calljavafunction2double:
318 asm_calljavafunction2long:
319 aaddiu sp,sp,-12*8 /* allocate stack space (only 11 needed)*/
320 sd ra,0(sp) /* save return address */
324 sd pv,1*8(sp) /* procedure vector */
331 sdc1 fss0,5*8(sp) /* save non JavaABI saved flt registers */
337 sd a0,4*8(sp) /* save method pointer for compiler */
341 blez s7,calljava_argsloaded
342 ald a0,offjniitem(t0)
343 ldc1 fa0,offjniitem(t0)
345 blez s7,calljava_argsloaded
347 ald a1,offjniitem+sizejniblock*1(t0)
348 ldc1 fa1,offjniitem+sizejniblock*1(t0)
350 blez s7,calljava_argsloaded
352 ald a2,offjniitem+sizejniblock*2(t0)
353 ldc1 fa2,offjniitem+sizejniblock*2(t0)
355 blez s7,calljava_argsloaded
357 ald a3,offjniitem+sizejniblock*3(t0)
358 ldc1 fa3,offjniitem+sizejniblock*3(t0)
360 blez s7,calljava_argsloaded
362 ald a4,offjniitem+sizejniblock*4(t0)
363 ldc1 fa4,offjniitem+sizejniblock*4(t0)
365 blez s7,calljava_argsloaded
367 ald a5,offjniitem+sizejniblock*5(t0)
368 ldc1 fa5,offjniitem+sizejniblock*5(t0)
370 blez s7,calljava_argsloaded
372 ald a6,offjniitem+sizejniblock*6(t0)
373 ldc1 fa6,offjniitem+sizejniblock*6(t0)
375 blez s7,calljava_argsloaded
377 ald a7,offjniitem+sizejniblock*7(t0)
378 ldc1 fa7,offjniitem+sizejniblock*7(t0)
383 blez s7,calljava_nocopy
390 ald t3,offjniitem+sizejniblock*8(t0)
393 ala t0,sizejniblock(t0)
395 bnez t1,calljava_copyloop
398 ala itmp1,32(t4) /* pass pointer to methodptr via itmp1 */
400 ala mptr,asm_call_jit_compiler/* fake virtual function call (2 instr) */
401 ast mptr,16(sp) /* store function address */
402 ala mptr,8(t4) /* set method pointer */
406 ald pv,8(mptr) /* method call as in Java */
407 jalr pv /* call JIT compiler */
409 aaddiu pv,ra,-76*4 /* recompute procedure vector */
412 ld ra,0(sp) /* restore return address */
413 ld pv,8(sp) /* restore procedure vector */
416 ldc1 fss0,5*8(sp) /* restore non JavaABI saved flt regs */
423 aaddiu sp,sp,12*8 /* free stack space */
431 jal builtin_throw_exception
434 .end asm_calljavafunction2
437 /****************** function asm_call_jit_compiler *****************************
439 * invokes the compiler for untranslated JavaVM methods. *
441 * Register REG_ITEMP1 contains a pointer to the method info structure *
442 * (prepared by createcompilerstub). Using the return address in R31 and the *
443 * offset in the LDA instruction or using the value in methodptr R25 the *
444 * patching address for storing the method address can be computed: *
446 * method address was either loaded using *
447 * M_ALD (REG_PV, REG_PV, a) ; invokestatic/special ($28) *
448 * M_JSR (REG_RA, REG_PV); *
450 * M_LDA (REG_PV, REG_RA, val) *
452 * M_ALD (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($25) *
453 * M_JSR (REG_RA, REG_PV); *
455 * in the static case the method pointer can be computed using the *
456 * return address and the lda function following the jmp instruction *
458 *******************************************************************************/
461 .ent asm_call_jit_compiler
463 asm_call_jit_compiler:
464 lw t0,-12(ra) /* load instruction LD PV,xxx($y) */
465 srl t0,t0,21 /* shift right register number $y */
466 and t0,t0,31 /* isolate register number */
467 addiu t0,t0,-mptrreg /* test for REG_METHODPTR */
470 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
472 sra t0,t0,16 /* isolate offset */
473 aaddu mptr,t0,ra /* compute update address */
476 aaddiu sp,sp,-18*8 /* allocate stack space */
477 sd a0,0*8(sp) /* save all argument registers */
478 sd a1,1*8(sp) /* they could be used by method */
493 sd mptr,16*8(sp) /* save method pointer */
494 sd ra,17*8(sp) /* save return address */
496 ald a0,0(itmp1) /* pass 'methodinfo' pointer to */
497 jal jit_compile /* jit compiler */
499 ld a0,0*8(sp) /* restore argument registers */
500 ld a1,1*8(sp) /* they could be used by method */
515 ld mptr,16*8(sp) /* restore method pointer */
516 ld ra,17*8(sp) /* restore return address */
517 aaddiu sp,sp,18*8 /* deallocate stack area */
519 lw t0,-12(ra) /* load instruction LDQ PV,xxx($yy) */
521 sra t0,t0,16 /* isolate offset */
523 aaddu t0,t0,mptr /* compute update address via method pointer*/
524 ast v0,0(t0) /* save new method address there */
526 move pv,v0 /* move method address into pv */
528 jr pv /* and call method. The method returns */
529 /* directly to the caller (ra). */
531 .end asm_call_jit_compiler
534 /********************* function asm_handle_exception ***************************
536 * This function handles an exception. It does not use the usual calling *
537 * conventions. The exception pointer is passed in REG_ITMP1 and the *
538 * pc from the exception raising position is passed in REG_ITMP2. It searches *
539 * the local exception table for a handler. If no one is found, it unwinds *
540 * stacks and continues searching the callers. *
542 * void asm_handle_exception (exceptionptr, exceptionpc); *
544 *******************************************************************************/
546 .ent asm_handle_nat_exception
548 asm_handle_nat_exception:
549 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
551 sra t0,t0,16 /* isolate offset */
552 aaddu pv,t0,ra /* compute update address */
554 .aent asm_handle_exception
556 asm_handle_exception:
557 aaddiu sp,sp,-14*8 /* allocate stack */
558 sd v0,0*8(sp) /* save possible used registers */
559 sd t0,1*8(sp) /* also registers used by trace_exception */
573 addu t3,zero,1 /* set no unwind flag */
575 aaddiu sp,sp,-6*8 /* allocate stack */
576 sd xptr,0*8(sp) /* save used registers */
583 ald a1,MethodPointer(pv)
588 jal builtin_trace_exception /* trace_exception(xptr,methodptr) */
590 ld xptr,0*8(sp) /* restore used register */
595 aaddiu sp,sp,6*8 /* deallocate stack */
597 lw t0,ExTableSize(pv) /* t0 = exception table size */
598 beqz t0,empty_table /* if empty table skip */
599 aaddiu t1,pv,ExTableStart /* t1 = start of exception table */
602 ald t2,ExStartPC(t1) /* t2 = exception start pc */
603 sle t2,t2,xpc /* t2 = (startpc <= xpc) */
604 beqz t2,ex_table_cont /* if (false) continue */
605 ald t2,ExEndPC(t1) /* t2 = exception end pc */
606 slt t2,xpc,t2 /* t2 = (xpc < endpc) */
607 beqz t2,ex_table_cont /* if (false) continue */
608 ald a1,ExCatchType(t1) /* arg1 = exception catch type */
609 beqz a1,ex_handle_it /* NULL catches everything */
611 lw itmp3,offclassloaded(a1)
612 bnez itmp3,L_class_loaded
614 aaddiu sp,sp,-8*8 /* allocate stack */
615 sd t0,0*8(sp) /* save used register */
627 ld t0,0*8(sp) /* restore used register */
635 aaddiu sp,sp,8*8 /* deallocate stack */
638 lw itmp3,offclasslinked(a1)
639 bnez itmp3,L_class_linked
641 aaddiu sp,sp,-8*8 /* allocate stack */
642 sd t0,0*8(sp) /* save used register */
654 ld t0,0*8(sp) /* restore used register */
662 aaddiu sp,sp,8*8 /* deallocate stack */
665 ald a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
666 ald a1,offclassvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
667 lw a0,offbaseval(a0) /* a0 = baseval(xptr) */
668 lw v0,offbaseval(a1) /* a2 = baseval(catchtype) */
669 lw a1,offdiffval(a1) /* a1 = diffval(catchtype) */
670 subu a0,a0,v0 /* a0 = baseval(xptr) - baseval(catchtype) */
671 sltu v0,a1,a0 /* v0 = xptr is instanceof catchtype */
672 bnez v0,ex_table_cont /* if (false) continue */
675 ald xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
677 beqz t3,ex_jump /* if (!(no stack unwinding) skip */
679 ld v0,0*8(sp) /* restore possible used registers */
680 ld t0,1*8(sp) /* also registers used by trace_exception */
694 aaddiu sp,sp,14*8 /* deallocate stack */
697 jr xpc /* jump to the handler */
700 aaddiu t1,t1,ExEntrySize /* next exception table entry */
701 addiu t0,t0,-1 /* decrement entry counter */
702 bgtz t0,ex_table_loop /* if (t0 > 0) next entry */
705 beqz t3,ex_already_cleared /* if here the first time, then */
706 aaddiu sp,sp,14*8 /* deallocate stack and */
707 move t3,zero /* clear the no unwind flag */
709 lw t0,IsSync(pv) /* t0 = SyncOffset */
710 beqz t0,no_monitor_exit /* if zero no monitorexit */
711 aaddu t0,sp,t0 /* add stackptr to Offset */
712 ald a0,-8(t0) /* load monitorexit pointer */
714 aaddiu sp,sp,-8*8 /* allocate stack */
715 sd t0,0*8(sp) /* save used register */
723 jal builtin_monitorexit /* builtin_monitorexit(objectptr) */
725 ld t0,0*8(sp) /* restore used register */
732 aaddiu sp,sp,8*8 /* deallocate stack */
735 lw t0,FrameSize(pv) /* t0 = frame size */
736 aaddu sp,sp,t0 /* unwind stack */
737 move t0,sp /* t0 = pointer to save area */
738 lw t1,IsLeaf(pv) /* t1 = is leaf procedure */
739 bnez t1,ex_no_restore /* if (leaf) skip */
740 ld ra,-8(t0) /* restore ra */
741 aaddiu t0,t0,-8 /* t0-- */
743 move xpc,ra /* the new xpc is ra */
744 lw t1,IntSave(pv) /* t1 = saved int register count */
745 ala t2,ex_int2 /* t2 = current pc */
746 sll t1,t1,2 /* t1 = register count * 4 */
747 asubu t2,t2,t1 /* t2 = ex_int_sav - 4 * register count */
748 jr t2 /* jump to save position */
758 sll t1,t1,1 /* t1 = register count * 4 * 2 */
759 asubu t0,t0,t1 /* t0 = t0 - 8 * register count */
761 lw t1,FltSave(pv) /* t1 = saved flt register count */
762 ala t2,ex_flt2 /* t2 = current pc */
763 sll t1,t1,2 /* t1 = register count * 4 */
764 asubu t2,t2,t1 /* t2 = ex_int_sav - 4 * register count */
765 jr t2 /* jump to save position */
771 lw t0,0(ra) /* load instruction LDA PV,xxx(RA) */
773 sra t0,t0,16 /* isolate offset */
774 aaddu pv,t0,ra /* compute update address */
777 .end asm_handle_nat_exception
780 /********************* asm_check_clinit ****************************************
782 * Checks if class is initialized. If not, do it right now. *
784 *******************************************************************************/
786 .ent asm_check_clinit
789 lw itmp2,offclassinit(itmp1)
790 bnez itmp2,L_is_initialized
794 sd a0,1*8(sp) /* save argument registers for leaf funcs */
815 ld a0,1*8(sp) /* restore argument registers */
833 beqz v0,L_initializererror
836 move itmp1,ra /* now patch the calling code */
837 daddiu itmp1,itmp1,-4*4 /* go back 4 instructions */
838 lui itmp2,0x1000 /* b */
839 daddiu itmp2,itmp2,3 /* jump over 3 instructions */
840 sw itmp2,0(itmp1) /* store the new branch: br +3 */
841 sw zero,4(itmp1) /* and a nop delay slot */
846 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
847 #error TODO TWISTI please check me for correctness
850 jal builtin_asm_get_exceptionptrptr
855 la itmp3,_exceptionptr
860 aaddiu xpc,ra,-4 /* faulting address is return adress - 4 */
861 b asm_handle_exception
863 .end asm_check_clinit
866 /********************* function asm_builtin_monitorenter ***********************
868 * Does null check and calls monitorenter or throws an exception *
870 *******************************************************************************/
872 .ent asm_builtin_monitorenter
874 asm_builtin_monitorenter:
875 beqz a0,nb_monitorenter /* if (null) throw exception */
876 ala t9,builtin_monitorenter /* else call builtin_monitorenter */
882 ald a0,string_java_lang_NullPointerException
888 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
889 b asm_handle_nat_exception
891 .end asm_builtin_monitorenter
894 /********************* function asm_builtin_monitorexit ************************
896 * Does null check and calls monitorexit or throws an exception *
898 *******************************************************************************/
900 .ent asm_builtin_monitorexit
902 asm_builtin_monitorexit:
903 beqz a0,nb_monitorexit /* if (null) throw exception */
904 ala t9,builtin_monitorexit /* else call builtin_monitorexit */
910 ald a0,string_java_lang_NullPointerException
916 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
917 b asm_handle_nat_exception
919 .end asm_builtin_monitorexit
922 /************************ function asm_builtin_idiv ****************************
924 * Does null check and calls idiv or throws an exception *
926 *******************************************************************************/
928 .ent asm_builtin_idiv
931 beqz a1,nb_idiv /* if (null) throw exception */
932 ala itmp3,builtin_idiv /* else call builtin_idiv */
938 ald a0,string_java_lang_ArithmeticException
939 ald a1,string_java_lang_ArithmeticException_message
940 jal new_exception_message
945 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
946 b asm_handle_nat_exception
948 .end asm_builtin_idiv
951 /************************ function asm_builtin_ldiv ****************************
953 * Does null check and calls ldiv or throws an exception *
955 *******************************************************************************/
957 .ent asm_builtin_ldiv
960 beqz a1,nb_ldiv /* if (null) throw exception */
961 ala itmp3,builtin_ldiv /* else call builtin_ldiv */
967 ald a0,string_java_lang_ArithmeticException
968 ald a1,string_java_lang_ArithmeticException_message
969 jal new_exception_message
974 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
975 b asm_handle_nat_exception
977 .end asm_builtin_ldiv
980 /************************ function asm_builtin_irem ****************************
982 * Does null check and calls irem or throws an exception *
984 *******************************************************************************/
986 .ent asm_builtin_irem
989 beqz a1,nb_irem /* if (null) throw exception */
990 ala t9,builtin_irem /* else call builtin_irem */
996 ald a0,string_java_lang_ArithmeticException
997 ald a1,string_java_lang_ArithmeticException_message
998 jal new_exception_message
1003 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1004 b asm_handle_nat_exception
1006 .end asm_builtin_irem
1009 /************************ function asm_builtin_lrem ****************************
1011 * Does null check and calls lrem or throws an exception *
1013 *******************************************************************************/
1015 .ent asm_builtin_lrem
1018 beqz a1,nb_lrem /* if (null) throw exception */
1019 ala t9,builtin_lrem /* else call builtin_lrem */
1025 ald a0,string_java_lang_ArithmeticException
1026 ald a1,string_java_lang_ArithmeticException_message
1027 jal new_exception_message
1032 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1033 b asm_handle_nat_exception
1035 .end asm_builtin_lrem
1038 /******************* function asm_builtin_checkarraycast ***********************
1040 * Does the cast check and eventually throws an exception *
1042 *******************************************************************************/
1044 .ent asm_builtin_checkarraycast
1046 asm_builtin_checkarraycast:
1047 aaddiu sp,sp,-16 /* allocate stack space */
1048 sd ra,0(sp) /* save return address */
1049 sd a0,8(sp) /* save object pointer */
1050 jal builtin_checkarraycast /* builtin_checkarraycast */
1051 beqz v0,nb_carray_throw /* if (false) throw exception */
1052 ld ra,0(sp) /* restore return address */
1053 ld v0,8(sp) /* return object pointer */
1054 aaddiu sp,sp,16 /* deallocate stack */
1058 ald a0,string_java_lang_ClassCastException
1062 ld ra,0(sp) /* restore return address */
1063 aaddiu sp,sp,16 /* free stack space */
1064 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1065 b asm_handle_nat_exception
1067 .end asm_builtin_checkarraycast
1070 /********************* function asm_builtin_checkcast **************************
1072 * Does the cast check and eventually throws an exception *
1074 *******************************************************************************/
1076 .ent asm_builtin_checkcast
1078 asm_builtin_checkcast:
1079 aaddiu sp,sp,-16 /* allocate stack space */
1080 sd ra,0(sp) /* save return address */
1081 sd a0,8(sp) /* save object pointer */
1082 jal builtin_checkcast /* builtin_checkcast */
1083 beqz v0,nb_ccast_throw /* if (false) throw exception */
1084 ld ra,0(sp) /* restore return address */
1085 ld v0,8(sp) /* return object pointer */
1086 aaddiu sp,sp,16 /* deallocate stack */
1090 ald a0,string_java_lang_ClassCastException
1094 ld ra,0(sp) /* restore return address */
1095 aaddiu sp,sp,16 /* free stack space */
1096 aaddiu xpc,ra,-4 /* faulting address is return adress - 4*/
1097 b asm_handle_nat_exception
1099 .end asm_builtin_checkcast
1102 /******************* function asm_builtin_aastore ******************************
1104 * Does the cast check and eventually throws an exception *
1105 * a0 = arrayref, a1 = index, a2 = value *
1107 *******************************************************************************/
1109 .ent asm_builtin_aastore
1111 asm_builtin_aastore:
1112 beqz a0,nb_aastore_null /* if null pointer throw exception */
1113 lw t0,offarraysize(a0) /* load size */
1114 aaddiu sp,sp,-32 /* allocate stack space */
1115 sd ra,0(sp) /* save return address */
1116 asll t1,a1,ashift /* add index*8 to arrayref */
1117 aaddu t1,a0,t1 /* add index * ashift to arrayref */
1118 sltu t0,a1,t0 /* do bound check */
1119 beqz t0,nb_aastore_bound /* if out of bounds throw exception */
1120 move a1,a2 /* object is second argument */
1121 sd t1,8(sp) /* save store position */
1122 sd a1,16(sp) /* save object */
1123 jal builtin_canstore /* builtin_canstore(arrayref,object) */
1124 ld ra,0(sp) /* restore return address */
1125 ld a0,8(sp) /* restore store position */
1126 ld a1,16(sp) /* restore object */
1127 aaddiu sp,sp,32 /* free stack space */
1128 beqz v0,nb_aastore_store /* if (false) throw exception */
1129 ast a1,offobjarrdata(a0) /* store objectptr in array */
1135 ald a0,string_java_lang_NullPointerException
1141 move xpc,ra /* faulting address is return adress */
1142 b asm_handle_nat_exception
1147 ald a0,string_java_lang_ArrayIndexOutOfBoundsException
1148 jal new_exception_int /* a1 already contains the index */
1153 aaddiu sp,sp,32 /* free stack space */
1154 move xpc,ra /* faulting address is return adress */
1155 b asm_handle_nat_exception
1160 ald a0,string_java_lang_ArrayStoreException
1166 move xpc,ra /* faulting address is return adress */
1167 b asm_handle_nat_exception
1169 .end asm_builtin_aastore
1172 /******************* function asm_initialize_thread_stack **********************
1174 * u1* asm_initialize_thread_stack (void *func, u1 *stack); *
1176 * initialize a thread stack *
1178 *******************************************************************************/
1180 .ent asm_initialize_thread_stack
1182 asm_initialize_thread_stack:
1183 aaddiu a1,a1,-14*8 /* allocate save area */
1184 sd zero, 0*8(a1) /* s0 initalize thread area */
1185 sd zero, 1*8(a1) /* s1 */
1186 sd zero, 2*8(a1) /* s2 */
1187 sd zero, 3*8(a1) /* s3 */
1188 sd zero, 4*8(a1) /* s4 */
1189 sd zero, 5*8(a1) /* s5 */
1190 sd zero, 6*8(a1) /* s6 */
1191 sd zero, 7*8(a1) /* s7 */
1192 sd zero, 8*8(a1) /* s8 */
1193 sd zero, 9*8(a1) /* fs0 */
1194 sd zero,10*8(a1) /* fs1 */
1195 sd zero,11*8(a1) /* fs2 */
1196 sd zero,12*8(a1) /* fs3 */
1201 .end asm_initialize_thread_stack
1204 /******************* function asm_perform_threadswitch *************************
1206 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1208 * performs a threadswitch *
1210 *******************************************************************************/
1212 .ent asm_perform_threadswitch
1214 asm_perform_threadswitch:
1215 aaddiu sp,sp,-14*8 /* allocate new stack */
1216 sd s0, 0*8(sp) /* save saved registers of old thread */
1230 ast sp,0(a0) /* save old stack pointer */
1231 ast sp,0(a2) /* stackTop = old stack pointer */
1232 ald sp,0(a1) /* load new stack pointer */
1233 ld s0, 0*8(sp) /* load saved registers of new thread */
1247 aaddiu sp,sp,14*8 /* deallocate new stack */
1251 .end asm_perform_threadswitch
1254 /********************* function asm_switchstackandcall *************************
1256 * void asm_switchstackandcall (void *stack, void *func, void **stacktopsave); *
1258 * Switches to a new stack, calls a function and switches back. *
1259 * a0 new stack pointer *
1260 * a1 function pointer *
1261 * a2 pointer to variable where stack top should be stored *
1263 *******************************************************************************/
1265 .ent asm_switchstackandcall
1267 asm_switchstackandcall:
1268 aaddiu a0,a0,-16 /* allocate new stack */
1269 sd ra,0(a0) /* save return address on new stack */
1270 sd sp,8(a0) /* save old stack pointer on new stack */
1271 sd sp,0(a2) /* save old stack pointer to variable */
1272 move sp,a0 /* switch to new stack */
1276 jalr itmp3 /* and call function */
1278 ld ra,0(sp) /* load return address */
1279 ld sp,8(sp) /* switch to old stack */
1283 .end asm_switchstackandcall
1286 .ent asm_getclassvalues_atomic
1288 asm_getclassvalues_atomic:
1291 lw t0,offbaseval(a0)
1292 lw t1,offdiffval(a0)
1293 lw t2,offbaseval(a1)
1295 sw t0,offcast_super_baseval(a2)
1296 sw t1,offcast_super_diffval(a2)
1297 sw t2,offcast_sub_baseval(a2)
1300 .end asm_getclassvalues_atomic
1304 asm_criticalsections:
1305 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
1308 .quad _crit_restart1
1311 .quad _crit_restart2
1317 * These are local overrides for various environment variables in Emacs.
1318 * Please do not remove this and leave it at the end of the file, where
1319 * Emacs will automagically detect them.
1320 * ---------------------------------------------------------------------
1323 * indent-tabs-mode: t