1 /* jit/alpha/asmpart.S - Java-C interface functions for alpha
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
31 $Id: asmpart.S 899 2004-01-22 13:24:36Z twisti $
103 /********************* exported functions and variables ***********************/
105 .globl has_no_x_instr_set
106 .globl synchronize_caches
107 .globl asm_calljavafunction
108 .globl asm_calljavafunction2
109 .globl asm_calljavafunction2double
110 .globl asm_calljavafunction2long
111 .globl asm_call_jit_compiler
112 .globl asm_dumpregistersandcall
113 .globl asm_handle_exception
114 .globl asm_handle_nat_exception
115 .globl asm_check_clinit
116 .globl asm_builtin_checkcast
117 .globl asm_builtin_checkarraycast
118 .globl asm_builtin_aastore
119 .globl asm_builtin_monitorenter
120 .globl asm_builtin_monitorexit
121 .globl asm_builtin_idiv
122 .globl asm_builtin_irem
123 .globl asm_builtin_ldiv
124 .globl asm_builtin_lrem
125 .globl asm_perform_threadswitch
126 .globl asm_initialize_thread_stack
127 .globl asm_switchstackandcall
128 .globl asm_getcallingmethod
129 .globl asm_builtin_trace
130 .globl asm_builtin_exittrace
132 /*************************** imported functions *******************************/
135 .globl builtin_monitorexit
136 .globl builtin_throw_exception
137 .globl builtin_trace_exception
138 .globl class_java_lang_Object
141 /*********************** function has_no_x_instr_set ***************************
143 * determines if the byte support instruction set (21164a and higher) *
146 *******************************************************************************/
148 .ent has_no_x_instr_set
151 .long 0x47e03c20 /* amask 1,v0 */
152 jmp zero,(ra) /* return */
154 .end has_no_x_instr_set
157 /********************* function synchronize_caches ****************************/
159 .ent synchronize_caches
162 call_pal PAL_imb /* synchronise instruction cache */
163 jmp zero,(ra) /* return */
165 .end synchronize_caches
168 #define MethodPointer -8
169 #define FrameSize -12
174 #define ExTableSize -32
175 #define ExTableStart -32
177 #define ExEntrySize -32
180 #define ExHandlerPC -24
181 #define ExCatchType -32
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. *
192 * javaobject_header *asm_calljavafunction (methodinfo *m, *
193 * void *arg1, void *arg2, void *arg3, void *arg4); *
195 *******************************************************************************/
197 .ent asm_calljavafunction
200 .ascii "calljavafunction\0\0"
203 .quad 0 /* catch type all */
204 .quad calljava_xhandler2 /* handler pc */
205 .quad calljava_xhandler2 /* end pc */
206 .quad asm_calljavafunction /* start pc */
207 .long 1 /* extable size */
208 .long 0 /* fltsave */
209 .long 0 /* intsave */
212 .long 32 /* frame size */
213 .quad 0 /* method pointer (pointer to name) */
215 asm_calljavafunction:
218 lda sp,-32(sp) /* allocate stack space */
219 stq gp,24(sp) /* save global pointer */
220 stq ra,0(sp) /* save return address */
222 stq a0,16(sp) /* save method pointer for compiler */
223 lda v0,16(sp) /* pass pointer to method pointer via v0*/
225 mov a1,a0 /* pass the remaining parameters */
230 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
231 stq $28,8(sp) /* store function address */
232 mov sp,$28 /* set method pointer */
234 ldq pv,8($28) /* method call as in Java */
235 jmp ra,(pv) /* call JIT compiler */
237 lda pv,-64(ra) /* asm_calljavafunction-calljava_jit !!!!!*/
241 ldq ra,0(sp) /* restore return address */
242 ldq gp,24(sp) /* restore global pointer */
243 lda sp,32(sp) /* free stack space */
250 ldq gp,24(sp) /* restore global pointer */
252 jsr ra,builtin_throw_exception
253 ldq ra,0(sp) /* restore return address */
254 lda sp,32(sp) /* free stack space */
256 .end asm_calljavafunction
261 .ent asm_calljavafunction2
264 .ascii "calljavafunction2\0\0"
267 .quad 0 /* catch type all */
268 .quad calljava_xhandler3 /* handler pc */
269 .quad calljava_xhandler3 /* end pc */
270 .quad asm_calljavafunction2 /* start pc */
271 .long 1 /* extable size */
272 .long 0 /* fltsave */
273 .long 1 /* intsave */
276 .long 40 /* frame size */
277 .quad 0 /* method pointer (pointer to name) */
279 asm_calljavafunction2:
280 asm_calljavafunction2double:
281 asm_calljavafunction2long:
284 lda sp,-40(sp) /* allocate stack space */
285 stq ra,0(sp) /* save return address */
287 stq gp,8(sp) /* save global pointer */
289 stq a0,32(sp) /* save method pointer for compiler */
290 mov a3,t0 /* pointer to arg block */
291 mov a1,s6 /* arg count */
293 ble s6,calljava_argsloaded
295 ldq a0,offjniitem(t0)
296 ldt $f16,offjniitem(t0)
297 ble s6,calljava_argsloaded
299 ldq a1,offjniitem+sizejniblock*1(t0)
300 ldt $f17,offjniitem+sizejniblock*1(t0)
301 ble s6,calljava_argsloaded
303 ldq a2,offjniitem+sizejniblock*2(t0)
304 ldt $f18,offjniitem+sizejniblock*2(t0)
305 ble s6,calljava_argsloaded
307 ldq a3,offjniitem+sizejniblock*3(t0)
308 ldt $f19,offjniitem+sizejniblock*3(t0)
309 ble s6,calljava_argsloaded
311 ldq a4,offjniitem+sizejniblock*4(t0)
312 ldt $f20,offjniitem+sizejniblock*4(t0)
313 ble s6,calljava_argsloaded
315 ldq a5,offjniitem+sizejniblock*5(t0)
316 ldt $f21,offjniitem+sizejniblock*5(t0)
319 ble s6,calljava_nocopy
325 ldq t3,offjniitem+sizejniblock*6(t0)
328 lda t0,sizejniblock(t0)
330 bne t1,calljava_copyloop
333 lda v0,32(t4) /* pass pointer to method pointer via v0*/
335 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
336 stq $28,16(t4) /* store function address */
337 lda $28,8(t4) /* set method pointer */
339 ldq pv,8($28) /* method call as in Java */
340 jmp ra,(pv) /* call JIT compiler */
342 lda pv,-200(ra) /* asm_calljavafunction-calljava_jit !!!*/
347 ldq ra,0(sp) /* restore return address */
348 ldq gp,8(sp) /* restore global pointer */
350 lda sp,40(sp) /* free stack space */
358 ldq gp,8(sp) /* restore global pointer */
360 jsr ra,builtin_throw_exception
361 ldq ra,0(sp) /* restore return address */
363 lda sp,40(sp) /* free stack space */
365 .end asm_calljavafunction2
368 /****************** function asm_call_jit_compiler *****************************
370 * invokes the compiler for untranslated JavaVM methods. *
372 * Register R0 contains a pointer to the method info structure (prepared *
373 * by createcompilerstub). Using the return address in R26 and the *
374 * offset in the LDA instruction or using the value in methodptr R28 the *
375 * patching address for storing the method address can be computed: *
377 * method address was either loaded using *
378 * M_LDQ (REG_PV, REG_PV, a) ; invokestatic/special ($27) *
379 * M_LDA (REG_PV, REG_RA, low) *
380 * M_LDAH(REG_PV, REG_RA, high) ; optional *
382 * M_LDQ (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($28) *
383 * in the static case the method pointer can be computed using the *
384 * return address and the lda function following the jmp instruction *
386 *******************************************************************************/
389 .ent asm_call_jit_compiler
390 asm_call_jit_compiler:
393 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
394 srl t8,16,t8 /* shift right register number $yy */
395 and t8,31,t8 /* isolate register number */
396 subl t8,28,t8 /* test for REG_METHODPTR */
398 ldl t8,0(ra) /* load instruction LDA PV,xxx(RA) */
400 sra t8,48,t8 /* isolate offset */
401 addq t8,ra,$28 /* compute update address */
402 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
403 srl t8,16,t8 /* isolate instruction code */
404 lda t8,-0x177b(t8) /* test for LDAH */
406 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
407 sll t8,16,t8 /* compute high offset */
408 addl t8,0,t8 /* sign extend high offset */
409 addq t8,$28,$28 /* compute update address */
411 lda sp,-14*8(sp) /* reserve stack space */
412 stq a0,0*8(sp) /* save all argument registers */
413 stq a1,1*8(sp) /* they could be used by method */
424 stq $28,12*8(sp) /* save method pointer */
425 stq ra,13*8(sp) /* save return address */
427 ldq a0,0(v0) /* pass 'methodinfo' pointer to */
428 jsr ra,jit_compile /* jit compiler */
431 call_pal PAL_imb /* synchronise instruction cache */
433 ldq a0,0*8(sp) /* load argument registers */
445 ldq $28,12*8(sp) /* load method pointer */
446 ldq ra,13*8(sp) /* load return address */
447 lda sp,14*8(sp) /* deallocate stack area */
449 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
451 sra t8,48,t8 /* isolate offset */
453 addq t8,$28,t8 /* compute update address via method pointer*/
454 stq v0,0(t8) /* save new method address there */
456 mov v0,pv /* load method address into pv */
458 jmp zero,(pv) /* and call method. The method returns */
459 /* directly to the caller (ra). */
461 .end asm_call_jit_compiler
464 /****************** function asm_dumpregistersandcall **************************
466 * This funtion saves all callee saved registers and calls the function *
467 * which is passed as parameter. *
469 * This function is needed by the garbage collector, which needs to access *
470 * all registers which are stored on the stack. Unused registers are *
471 * cleared to avoid interferances with the GC. *
473 * void asm_dumpregistersandcall (functionptr f); *
475 *******************************************************************************/
477 .ent asm_dumpregistersandcall
478 asm_dumpregistersandcall:
479 lda sp,-16*8(sp) /* allocate stack */
480 stq ra,0(sp) /* save return address */
482 stq s0,1*8(sp) /* save all callee saved registers */
483 stq s1,2*8(sp) /* intialize the remaining registers */
498 clr v0 /* intialize the remaining registers */
543 mov a0,pv /* load function pointer */
544 jmp ra,(pv) /* and call function */
546 ldq ra,0(sp) /* load return address */
547 lda sp,16*8(sp) /* deallocate stack */
548 jmp zero,(ra) /* return */
550 .end asm_dumpregistersandcall
553 /********************* function asm_handle_exception ***************************
555 * This function handles an exception. It does not use the usual calling *
556 * conventions. The exception pointer is passed in REG_ITMP1 and the *
557 * pc from the exception raising position is passed in REG_ITMP2. It searches *
558 * the local exception table for a handler. If no one is found, it unwinds *
559 * stacks and continues searching the callers. *
561 * void asm_handle_exception (exceptionptr, exceptionpc); *
563 *******************************************************************************/
565 .ent asm_handle_nat_exception
566 asm_handle_nat_exception:
568 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
570 sra t0,48,t0 /* isolate offset */
571 addq t0,ra,pv /* compute update address */
572 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
573 srl t0,16,t0 /* isolate instruction code */
574 lda t0,-0x177b(t0) /* test for LDAH */
575 bne t0,asm_handle_exception
576 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
577 sll t0,16,t0 /* compute high offset */
578 addl t0,0,t0 /* sign extend high offset */
579 addq t0,pv,pv /* compute update address */
581 .aent asm_handle_exception
582 asm_handle_exception:
584 lda sp,-18*8(sp) /* allocate stack */
585 stq t0,0*8(sp) /* save possible used registers */
586 stq t1,1*8(sp) /* also registers used by trace_exception */
604 lda t3,1(zero) /* set no unwind flag */
606 lda sp,-5*8(sp) /* allocate stack */
607 stq xptr,0*8(sp) /* save used register */
614 ldq a1,MethodPointer(pv)
618 br ra,ex_trace /* set ra for gp loading */
620 ldgp gp,0(ra) /* load gp */
621 jsr ra,builtin_trace_exception /* trace_exception(xptr,methodptr) */
623 ldq xptr,0*8(sp) /* restore used register */
628 lda sp,5*8(sp) /* deallocate stack */
630 ldl t0,ExTableSize(pv) /* t0 = exception table size */
631 beq t0,empty_table /* if empty table skip */
632 lda t1,ExTableStart(pv) /* t1 = start of exception table */
635 ldq t2,ExStartPC(t1) /* t2 = exception start pc */
636 cmple t2,xpc,t2 /* t2 = (startpc <= xpc) */
637 beq t2,ex_table_cont /* if (false) continue */
638 ldq t2,ExEndPC(t1) /* t2 = exception end pc */
639 cmplt xpc,t2,t2 /* t2 = (xpc < endpc) */
640 beq t2,ex_table_cont /* if (false) continue */
641 ldq a1,ExCatchType(t1) /* arg1 = exception catch type */
642 beq a1,ex_handle_it /* NULL catches everything */
644 ldq a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
645 ldq a1,offclassvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
646 ldl a0,offbaseval(a0) /* a0 = baseval(xptr) */
647 ldl v0,offbaseval(a1) /* a2 = baseval(catchtype) */
648 ldl a1,offdiffval(a1) /* a1 = diffval(catchtype) */
649 subl a0,v0,a0 /* a0 = baseval(xptr) - baseval(catchtype) */
650 cmpule a0,a1,v0 /* v0 = xptr is instanceof catchtype */
651 beq v0,ex_table_cont /* if (false) continue */
655 ldq xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
657 beq t3,ex_jump /* if (!(no stack unwinding) skip */
659 ldq t0,0*8(sp) /* restore possible used registers */
660 ldq t1,1*8(sp) /* also registers used by trace_exception */
677 lda sp,18*8(sp) /* deallocate stack */
680 jmp zero,(xpc) /* jump to the handler */
683 lda t1,ExEntrySize(t1) /* next exception table entry */
684 subl t0,1,t0 /* decrement entry counter */
685 bgt t0,ex_table_loop /* if (t0 > 0) next entry */
688 beq t3,ex_already_cleared /* if here the first time, then */
689 lda sp,18*8(sp) /* deallocate stack and */
690 clr t3 /* clear the no unwind flag */
692 ldl t0,IsSync(pv) /* t0 = SyncOffset */
693 beq t0,no_monitor_exit /* if zero no monitorexit */
694 addq sp,t0,t0 /* add stackptr to Offset */
695 ldq a0,-8(t0) /* load monitorexit pointer */
697 lda sp,-7*8(sp) /* allocate stack */
698 stq t0,0*8(sp) /* save used register */
706 br ra,ex_mon_load /* set ra for gp loading */
708 ldgp gp,0(ra) /* load gp */
709 jsr ra,builtin_monitorexit/* builtin_monitorexit(objectptr) */
711 ldq t0,0*8(sp) /* restore used register */
718 lda sp,7*8(sp) /* deallocate stack */
721 ldl t0,FrameSize(pv) /* t0 = frame size */
722 addq sp,t0,sp /* unwind stack */
723 mov sp,t0 /* t0 = pointer to save area */
724 ldl t1,IsLeaf(pv) /* t1 = is leaf procedure */
725 bne t1,ex_no_restore /* if (leaf) skip */
726 ldq ra,-8(t0) /* restore ra */
727 lda t0,-8(t0) /* t0-- */
729 mov ra,xpc /* the new xpc is ra */
730 ldl t1,IntSave(pv) /* t1 = saved int register count */
731 br t2,ex_int1 /* t2 = current pc */
733 lda t2,44(t2) /* lda t2,ex_int2-ex_int1(t2) !!!!!!!!!!!!! */
734 negl t1,t1 /* negate register count */
735 s4addq t1,t2,t2 /* t2 = ex_int_sav - 4 * register count */
736 jmp zero,(t2) /* jump to save position */
745 s8addq t1,t0,t0 /* t0 = t0 - 8 * register count */
747 ldl t1,FltSave(pv) /* t1 = saved flt register count */
748 br t2,ex_flt1 /* t2 = current pc */
750 lda t2,48(t2) /* lda t2,ex_flt2-ex_flt1(t2) !!!!!!!!!!!!! */
751 negl t1,t1 /* negate register count */
752 s4addq t1,t2,t2 /* t2 = ex_flt_sav - 4 * register count */
753 jmp zero,(t2) /* jump to save position */
763 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
765 sra t0,48,t0 /* isolate offset */
766 addq t0,ra,pv /* compute update address */
767 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
768 srl t0,16,t0 /* isolate instruction code */
769 lda t0,-0x177b(t0) /* test for LDAH */
771 ldl t0,4(ra) /* load instruction LDAH PV,xxx(RA) */
772 sll t0,16,t0 /* compute high offset */
773 addl t0,0,t0 /* sign extend high offset */
774 addq t0,pv,pv /* compute update address */
777 .end asm_handle_nat_exception
780 /********************* asm_check_clinit ****************************************
782 * Does null check and calls monitorenter or throws an exception *
784 *******************************************************************************/
786 .ent asm_check_clinit
790 ldl itmp2,offclassinit(itmp1)
791 bne itmp2,L_is_initialized
795 stq a0,1*8(sp) /* save argument registers for leaf funcs */
805 ldq a0,1*8(sp) /* restore argument registers */
816 .end asm_check_clinit
819 /********************* function asm_builtin_monitorenter ***********************
821 * Does null check and calls monitorenter or throws an exception *
823 *******************************************************************************/
825 .ent asm_builtin_monitorenter
826 asm_builtin_monitorenter:
829 lda pv,builtin_monitorenter
830 beq a0,nb_monitorenter /* if (null) throw exception */
831 jmp zero,(pv) /* else call builtin_monitorenter */
834 ldq xptr,proto_java_lang_NullPointerException
835 lda xpc,-4(ra) /* faulting address is return adress - 4*/
836 br asm_handle_nat_exception
837 .end asm_builtin_monitorenter
840 /********************* function asm_builtin_monitorexit ************************
842 * Does null check and calls monitorexit or throws an exception *
844 *******************************************************************************/
846 .ent asm_builtin_monitorexit
847 asm_builtin_monitorexit:
850 lda pv,builtin_monitorexit
851 beq a0,nb_monitorexit /* if (null) throw exception */
852 jmp zero,(pv) /* else call builtin_monitorexit */
855 ldq xptr,proto_java_lang_NullPointerException
856 lda xpc,-4(ra) /* faulting address is return adress - 4*/
857 br asm_handle_nat_exception
858 .end asm_builtin_monitorexit
861 /************************ function asm_builtin_idiv ****************************
863 * Does null check and calls idiv or throws an exception *
865 *******************************************************************************/
867 .ent asm_builtin_idiv
872 beq a1,nb_idiv /* if (null) throw exception */
873 jmp zero,(pv) /* else call builtin_idiv */
876 ldq xptr,proto_java_lang_ArithmeticException
877 lda xpc,-4(ra) /* faulting address is return adress - 4*/
878 br asm_handle_nat_exception
879 .end asm_builtin_idiv
882 /************************ function asm_builtin_ldiv ****************************
884 * Does null check and calls ldiv or throws an exception *
886 *******************************************************************************/
888 .ent asm_builtin_ldiv
893 beq a1,nb_ldiv /* if (null) throw exception */
894 jmp zero,(pv) /* else call builtin_ldiv */
897 ldq xptr,proto_java_lang_ArithmeticException
898 lda xpc,-4(ra) /* faulting address is return adress - 4*/
899 br asm_handle_nat_exception
900 .end asm_builtin_ldiv
903 /************************ function asm_builtin_irem ****************************
905 * Does null check and calls irem or throws an exception *
907 *******************************************************************************/
909 .ent asm_builtin_irem
914 beq a1,nb_irem /* if (null) throw exception */
915 jmp zero,(pv) /* else call builtin_irem */
918 ldq xptr,proto_java_lang_ArithmeticException
919 lda xpc,-4(ra) /* faulting address is return adress - 4*/
920 br asm_handle_nat_exception
921 .end asm_builtin_irem
924 /************************ function asm_builtin_lrem ****************************
926 * Does null check and calls lrem or throws an exception *
928 *******************************************************************************/
930 .ent asm_builtin_lrem
935 beq a1,nb_lrem /* if (null) throw exception */
936 jmp zero,(pv) /* else call builtin_lrem */
939 ldq xptr,proto_java_lang_ArithmeticException
940 lda xpc,-4(ra) /* faulting address is return adress - 4*/
941 br asm_handle_nat_exception
942 .end asm_builtin_lrem
945 /*********************** function new_builtin_checkcast ************************
947 * Does the cast check and eventually throws an exception *
949 *******************************************************************************/
951 .ent asm_builtin_checkcast
952 asm_builtin_checkcast:
955 lda sp,-16(sp) # allocate stack space
956 stq ra,0(sp) # save return address
957 stq a0,8(sp) # save object pointer
958 jsr ra,builtin_checkcast # builtin_checkcast
960 beq v0,nb_ccast_throw # if (false) throw exception
961 ldq ra,0(sp) # restore return address
962 ldq v0,8(sp) # return object pointer
963 lda sp,16(sp) # free stack space
967 ldq xptr,proto_java_lang_ClassCastException
968 ldq ra,0(sp) # restore return address
969 lda sp,16(sp) # free stack space
970 lda xpc,-4(ra) # faulting address is return adress - 4
971 br asm_handle_nat_exception
972 .end asm_builtin_checkcast
975 /******************* function asm_builtin_checkarraycast ***********************
977 * Does the cast check and eventually throws an exception *
979 *******************************************************************************/
981 .ent asm_builtin_checkarraycast
982 asm_builtin_checkarraycast:
985 lda sp,-16(sp) /* allocate stack space */
986 stq ra,0(sp) /* save return address */
987 stq a0,8(sp) /* save object pointer */
988 jsr ra,builtin_checkarraycast /* builtin_checkarraycast */
990 beq v0,nb_carray_throw /* if (false) throw exception */
991 ldq ra,0(sp) /* restore return address */
992 ldq v0,8(sp) /* return object pointer */
993 lda sp,16(sp) /* free stack space */
997 ldq xptr,proto_java_lang_ClassCastException
998 ldq ra,0(sp) /* restore return address */
999 lda sp,16(sp) /* free stack space */
1000 lda xpc,-4(ra) /* faulting address is return adress - 4*/
1001 br asm_handle_nat_exception
1002 .end asm_builtin_checkarraycast
1005 /******************* function asm_builtin_aastore ******************************
1007 * Does the cast check and eventually throws an exception *
1009 *******************************************************************************/
1011 .ent asm_builtin_aastore
1012 asm_builtin_aastore:
1015 beq a0,nb_aastore_null /* if null pointer throw exception */
1016 ldl t0,offarraysize(a0) /* load size */
1017 lda sp,-24(sp) /* allocate stack space */
1018 stq ra,0(sp) /* save return address */
1019 s8addq a1,a0,t1 /* add index*8 to arrayref */
1020 cmpult a1,t0,t0 /* do bound check */
1021 beq t0,nb_aastore_bound /* if out of bounds throw exception */
1022 mov a2,a1 /* object is second argument */
1023 stq t1,8(sp) /* save store position */
1024 stq a1,16(sp) /* save object */
1025 jsr ra,builtin_canstore /* builtin_canstore(arrayref,object) */
1027 ldq ra,0(sp) /* restore return address */
1028 ldq a0,8(sp) /* restore store position */
1029 ldq a1,16(sp) /* restore object */
1030 lda sp,24(sp) /* free stack space */
1031 beq v0,nb_aastore_throw /* if (false) throw exception */
1032 stq a1,offobjarrdata(a0) /* store objectptr in array */
1036 ldq xptr,proto_java_lang_NullPointerException
1037 mov ra,xpc /* faulting address is return adress */
1038 br asm_handle_nat_exception
1041 ldq xptr,proto_java_lang_ArrayIndexOutOfBoundsException
1042 lda sp,24(sp) /* free stack space */
1043 mov ra,xpc /* faulting address is return adress */
1044 br asm_handle_nat_exception
1047 ldq xptr,proto_java_lang_ArrayStoreException
1048 mov ra,xpc /* faulting address is return adress */
1049 br asm_handle_nat_exception
1051 .end asm_builtin_aastore
1054 /******************* function asm_initialize_thread_stack **********************
1056 * initialized a thread stack *
1058 *******************************************************************************/
1060 .ent asm_initialize_thread_stack
1061 asm_initialize_thread_stack:
1082 .end asm_initialize_thread_stack
1085 /******************* function asm_perform_threadswitch *************************
1087 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1089 * performs a threadswitch *
1091 *******************************************************************************/
1093 .ent asm_perform_threadswitch
1094 asm_perform_threadswitch:
1135 .end asm_perform_threadswitch
1138 /********************* function asm_switchstackandcall *************************
1140 * void *asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
1143 * Switches to a new stack, calls a function and switches back. *
1144 * a0 new stack pointer *
1145 * a1 function pointer *
1146 * a2 pointer to variable where stack top should be stored *
1147 * a3 pointer to user data, is passed to the function *
1149 *******************************************************************************/
1152 .ent asm_switchstackandcall
1153 asm_switchstackandcall:
1154 lda a0,-2*8(a0) /* allocate new stack */
1155 stq ra,0(a0) /* save return address on new stack */
1156 stq sp,1*8(a0) /* save old stack pointer on new stack */
1157 stq sp,0(a2) /* save old stack pointer to variable */
1158 mov a0,sp /* switch to new stack */
1160 mov a1,pv /* load function pointer */
1161 mov a3,a0 /* pass pointer */
1162 jmp ra,(pv) /* and call function */
1164 ldq ra,0(sp) /* load return address */
1165 ldq sp,1*8(sp) /* switch to old stack */
1167 jmp zero,(ra) /* return */
1169 .end asm_switchstackandcall
1172 /********************* function asm_getcallingmethod ***************************
1174 * classinfo *asm_getcallingmethodclass (); *
1176 * goes back stack frames to get the calling method *
1182 *******************************************************************************/
1185 .ent asm_getcallingmethod
1186 asm_getcallingmethod:
1188 ldq t3,16(sp) /* load return address of native function */
1189 addq sp,24,t2 /* skip frames of C-Function and nativestub */
1191 /* determine pv (t3) of java-function from ra */
1193 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1195 sra t0,48,t0 /* isolate offset */
1196 addq t0,t3,t4 /* compute update address */
1197 ldl t0,4(t3) /* load instruction LDAH PV,xxx(PV) */
1198 srl t0,16,t0 /* isolate instruction code */
1199 lda t0,-0x177b(t0) /* test for LDAH */
1201 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1202 sll t0,16,t0 /* compute high offset */
1203 addl t0,0,t0 /* sign extend high offset */
1204 addq t0,t4,t4 /* compute update address */
1207 ldl t0,FrameSize(t4) /* t0 = frame size */
1208 addq t2,t0,t2 /* skip frame of java function */
1209 ldq t3,-8(t2) /* load new ra */
1211 /* determine pv (t3) of java-function from ra */
1213 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1215 sra t0,48,t0 /* isolate offset */
1216 addq t0,t3,t4 /* compute update address */
1217 ldl t0,4(t3) /* load instruction LDAH PV,xxx(PV) */
1218 srl t0,16,t0 /* isolate instruction code */
1219 lda t0,-0x177b(t0) /* test for LDAH */
1221 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1222 sll t0,16,t0 /* compute high offset */
1223 addl t0,0,t0 /* sign extend high offset */
1224 addq t0,t4,t4 /* compute update address */
1227 ldq v0,MethodPointer(t4) /* */
1230 jmp zero,(ra) /* return */
1232 .end asm_getcallingmethod
1236 * These are local overrides for various environment variables in Emacs.
1237 * Please do not remove this and leave it at the end of the file, where
1238 * Emacs will automagically detect them.
1239 * ---------------------------------------------------------------------
1242 * indent-tabs-mode: t