1 /* -*- mode: asm; tab-width: 4 -*- */
2 /****************************** asmpart.c **************************************
4 * is an assembly language file, but called .c to fake the preprocessor. *
5 * It contains the Java-C interface functions for Alpha processors. *
7 * Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst *
9 * See file COPYRIGHT for information on usage and disclaimer of warranties *
11 * Authors: Reinhard Grafl EMAIL: cacao@complang.tuwien.ac.at *
12 * Andreas Krall EMAIL: cacao@complang.tuwien.ac.at *
14 * Last Change: 1997/04/26 *
16 *******************************************************************************/
87 /********************* exported functions and variables ***********************/
89 .globl has_no_x_instr_set
90 .globl synchronize_caches
91 .globl asm_calljavamethod
92 .globl asm_call_jit_compiler
93 .globl asm_dumpregistersandcall
94 .globl asm_handle_exception
95 .globl asm_handle_nat_exception
96 .globl asm_signal_exception
97 .globl new_builtin_checkcast
98 .globl new_builtin_checkclasscast
99 .globl new_builtin_checkintercast
100 .globl new_builtin_checkarraycast
101 .globl new_builtin_aastore
102 .globl new_builtin_monitorenter
103 .globl new_builtin_monitorexit
104 .globl new_builtin_idiv
105 .globl new_builtin_irem
106 .globl new_builtin_ldiv
107 .globl new_builtin_lrem
108 .globl perform_alpha_threadswitch
109 .globl initialize_thread_stack
110 .globl asm_switchstackandcall
113 /*************************** imported variables *******************************/
118 /*************************** imported functions *******************************/
120 .globl compiler_compile
121 .globl builtin_monitorexit
122 .globl builtin_throw_exception
123 .globl builtin_trace_exception
124 .globl class_java_lang_Object
126 /*********************** function has_no_x_instr_set ***************************
128 * determines if the byte support instruction set (21164a and higher) *
131 *******************************************************************************/
133 .ent has_no_x_instr_set
136 .long 0x47e03c20 # amask 1,$0
137 jmp zero,(ra) # return
139 .end has_no_x_instr_set
142 /********************* function synchronize_caches ****************************/
144 .ent synchronize_caches
147 call_pal PAL_imb # synchronise instruction cache
148 jmp zero,(ra) # return
150 .end synchronize_caches
153 /********************* function asm_calljavamethod *****************************
155 * This function calls a Java-method (which possibly needs compilation) *
156 * with up to 4 parameters. *
158 * This functions calls the JIT-compiler which eventually translates the *
159 * method into machine code. *
161 * An possibly throwed exception will be returned to the caller as function *
162 * return value, so the java method cannot return a fucntion value (this *
163 * function usually calls 'main' and '<clinit>' which do not return a *
167 * javaobject_header *asm_calljavamethod (methodinfo *m, *
168 * void *arg1, void *arg2, void *arg3, void *arg4); *
170 *******************************************************************************/
172 #define MethodPointer -8
173 #define FrameSize -12
178 #define ExTableSize -32
179 #define ExTableStart -32
181 #define ExEntrySize -32
184 #define ExHandlerPC -24
185 #define ExCatchType -32
187 .ent asm_calljavamethod
190 .ascii "calljavamethod\0\0"
193 .quad 0 # catch type all
194 .quad calljava_xhandler # end pc
195 .quad calljava_xhandler # end pc
196 .quad asm_calljavamethod # start pc
197 .long 1 # extable size
202 .long 32 # frame size
203 .quad 0 # method pointer (pointer to name) @@@@@
208 lda sp,-32(sp) # allocate stack space
209 stq gp,24(sp) # save global pointer
210 stq ra,0(sp) # save return address
212 stq $16,16(sp) # save method pointer for compiler
213 lda $0,16(sp) # pass pointer to method pointer via $0
215 bis $17,$17,$16 # pass the remaining parameters
220 lda $28,asm_call_jit_compiler # fake virtual function call
221 stq $28,8(sp) # store function address
222 bis sp,sp,$28 # set method pointer
224 ldq pv,8($28) # method call as in Java
225 jmp ra,(pv) # call JIT compiler
227 lda pv,-64(ra) # asm_calljavamethod-calljava_jit(ra) !!!!!!
231 ldq ra,0(sp) # restore return address
232 ldq gp,24(sp) # restore global pointer
233 lda sp,32(sp) # free stack space
234 ldl $0,newcompiler # load newcompiler flag
235 subq $0,1,$0 # negate for clearing $0
236 beq $0,calljava_ret # if newcompiler skip ex copying
237 bis $1,$1,$0 # pass exception to caller (C)
243 ldq gp,24(sp) # restore global pointer
245 jsr ra,builtin_throw_exception
246 ldq ra,0(sp) # restore return address
247 lda sp,32(sp) # free stack space
249 .end asm_calljavamethod
252 /****************** function asm_call_jit_compiler *****************************
254 * invokes the compiler for untranslated JavaVM methods. *
256 * Register R0 contains a pointer to the method info structure (prepared *
257 * by createcompilerstub). Using the return address in R26 and the *
258 * offset in the LDA instruction or using the value in methodptr R28 the *
259 * patching address for storing the method address can be computed: *
261 * method address was either loaded using *
262 * M_LDQ (REG_PV, REG_PV, a) # invokestatic/special ($27) *
263 * M_LDA (REG_PV, REG_RA, low) *
264 * M_LDAH(REG_PV, REG_RA, high) # optional *
266 * M_LDQ (REG_PV, REG_METHODPTR, m) # invokevirtual/interface ($28) *
267 * in the static case the method pointer can be computed using the *
268 * return address and the lda function following the jmp instruction *
270 *******************************************************************************/
273 .ent asm_call_jit_compiler
274 asm_call_jit_compiler:
277 ldl $22,-8(ra) # load instruction LDQ PV,xxx($yy)
278 srl $22,16,$22 # shift right register number $yy
279 and $22,31,$22 # isolate register number
280 subl $22,28,$22 # test for REG_METHODPTR
282 ldl $22,0(ra) # load instruction LDA PV,xxx(RA)
284 sra $22,48,$22 # isolate offset
285 addq $22,ra,$28 # compute update address
286 ldl $22,4(ra) # load instruction LDAH PV,xxx(PV)
287 srl $22,16,$22 # isolate instruction code
288 lda $22,-0x177b($22) # test for LDAH
290 ldl $22,0(ra) # load instruction LDA PV,xxx(RA)
291 sll $22,16,$22 # compute high offset
292 addl $22,0,$22 # sign extend high offset
293 addq $22,$28,$28 # compute update address
295 lda sp,-14*8(sp) # reserve stack space
296 stq $16,0*8(sp) # save all argument registers
297 stq $17,1*8(sp) # they could be used by method
308 stq $28,12*8(sp) # save method pointer
309 stq ra,13*8(sp) # save return address
311 ldq $16,0($0) # pass 'methodinfo' pointer to
312 jsr ra,compiler_compile # compiler
315 call_pal PAL_imb # synchronise instruction cache
317 ldq $16,0*8(sp) # load argument registers
329 ldq $28,12*8(sp) # load method pointer
330 ldq ra,13*8(sp) # load return address
331 lda sp,14*8(sp) # deallocate stack area
333 ldl $22,-8(ra) # load instruction LDQ PV,xxx($yy)
335 sra $22,48,$22 # isolate offset
337 addq $22,$28,$22 # compute update address via method pointer
338 stq $0,0($22) # save new method address there
340 bis $0,$0,pv # load method address into pv
342 jmp zero, (pv) # and call method. The method returns
343 # directly to the caller (ra).
345 .end asm_call_jit_compiler
348 /****************** function asm_dumpregistersandcall **************************
350 * This funtion saves all callee saved registers and calls the function *
351 * which is passed as parameter. *
353 * This function is needed by the garbage collector, which needs to access *
354 * all registers which are stored on the stack. Unused registers are *
355 * cleared to avoid interferances with the GC. *
357 * void asm_dumpregistersandcall (functionptr f); *
359 *******************************************************************************/
361 .ent asm_dumpregistersandcall
362 asm_dumpregistersandcall:
363 lda sp,-16*8(sp) # allocate stack
364 stq ra,0(sp) # save return address
366 stq $9,1*8(sp) # save all callee saved registers
367 stq $10,2*8(sp) # intialize the remaining registers
382 bis zero,zero,$0 # intialize the remaining registers
428 bis $16,$16,pv # load function pointer
429 jmp ra,(pv) # and call function
431 ldq ra,0(sp) # load return address
432 lda sp,16*8(sp) # deallocate stack
433 jmp zero,(ra) # return
435 .end asm_dumpregistersandcall
438 /********************* function asm_handle_exception ***************************
440 * This function handles an exception. It does not use the usual calling *
441 * conventions. The exception pointer is passed in REG_ITMP1 and the *
442 * pc from the exception raising position is passed in REG_ITMP2. It searches *
443 * the local exception table for a handler. If no one is found, it unwinds *
444 * stacks and continues searching the callers. *
446 * void asm_handle_exception (exceptionptr, exceptionpc); *
448 *******************************************************************************/
450 .ent asm_handle_nat_exception
451 asm_handle_nat_exception:
453 ldl t0,0(ra) # load instruction LDA PV,xxx(RA)
455 sra t0,48,t0 # isolate offset
456 addq t0,ra,pv # compute update address
457 ldl t0,4(ra) # load instruction LDAH PV,xxx(PV)
458 srl t0,16,t0 # isolate instruction code
459 lda t0,-0x177b(t0) # test for LDAH
460 bne t0,asm_handle_exception
461 ldl t0,0(ra) # load instruction LDA PV,xxx(RA)
462 sll t0,16,t0 # compute high offset
463 addl t0,0,t0 # sign extend high offset
464 addq t0,pv,pv # compute update address
466 .aent asm_handle_exception
467 asm_handle_exception:
469 lda sp,-18*8(sp) # allocate stack
470 stq t0,0*8(sp) # save possible used registers
471 stq t1,1*8(sp) # also registers used by builtin_checkcast
489 lda t3,1(zero) # set no unwind flag
491 lda sp,-5*8(sp) # allocate stack
492 stq xptr,0*8(sp) # save used register
499 ldq a1,MethodPointer(pv)
502 br ra,ex_trace # set ra for gp loading
504 ldgp gp,0(ra) # load gp
505 jsr ra,builtin_trace_exception # builtin_trace_exception(xptr,methodptr)
507 ldq xptr,0*8(sp) # restore used register
512 lda sp,5*8(sp) # deallocate stack
514 ldl t0,ExTableSize(pv) # t0 = exception table size
515 beq t0,empty_table # if empty table skip
516 lda t1,ExTableStart(pv) # t1 = start of exception table
519 ldq t2,ExStartPC(t1) # t2 = exception start pc
520 cmple t2,xpc,t2 # t2 = (startpc <= xpc)
521 beq t2,ex_table_cont # if (false) continue
522 ldq t2,ExEndPC(t1) # t2 = exception end pc
523 cmplt xpc,t2,t2 # t2 = (xpc < endpc)
524 beq t2,ex_table_cont # if (false) continue
525 ldq a1,ExCatchType(t1) # arg1 = exception catch type
526 beq a1,ex_handle_it # NULL catches everything
527 mov xptr,a0 # arg0 = exception pointer
529 lda sp,-7*8(sp) # allocate stack
530 stq t0,0*8(sp) # save used register
538 br ra,ex_gpload # set ra for gp loading
540 ldgp gp,0(ra) # load gp
541 jsr ra,builtin_checkcast # builtin_checkcast(xptr,catchtype)
543 ldq t0,0*8(sp) # restore used register
550 lda sp,7*8(sp) # deallocate stack
552 beq v0,ex_table_cont # if (false) continue
556 ldq xpc,ExHandlerPC(t1) # xpc = exception handler pc
558 beq t3,ex_jump # if (!(no stack unwinding) skip
560 ldq t0,0*8(sp) # restore possible used registers
561 ldq t1,1*8(sp) # also registers used by builtin_checkcast
578 lda sp,18*8(sp) # deallocate stack
581 jmp zero,(xpc) # jump to the handler
584 lda t1,ExEntrySize(t1) # next exception table entry
585 subl t0,1,t0 # decrement entry counter
586 bgt t0,ex_table_loop # if (t0 > 0) next entry
589 beq t3,ex_already_cleared # if here the first time, then
590 lda sp,18*8(sp) # deallocate stack and
591 clr t3 # clear the no unwind flag
593 ldl t0,IsSync(pv) # t0 = SyncOffset
594 beq t0,no_monitor_exit # if zero no monitorexit
595 addq sp,t0,t0 # add Offset to stackptr
596 ldq a0,-8(t0) # load monitorexit pointer
598 lda sp,-7*8(sp) # allocate stack
599 stq t0,0*8(sp) # save used register
607 br ra,ex_mon_load # set ra for gp loading
609 ldgp gp,0(ra) # load gp
610 jsr ra,builtin_monitorexit # builtin_monitorexit(objectptr)
612 ldq t0,0*8(sp) # restore used register
619 lda sp,7*8(sp) # deallocate stack
622 ldl t0,FrameSize(pv) # t0 = frame size
623 addq sp,t0,sp # unwind stack
624 mov sp,t0 # t0 = pointer to save area
625 ldl t1,IsLeaf(pv) # t1 = is leaf procedure
626 bne t1,ex_no_restore # if (leaf) skip
627 ldq ra,-8(t0) # restore ra
630 mov ra,xpc # the new xpc is ra
631 ldl t1,IntSave(pv) # t1 = saved int register count
632 br t2,ex_int1 # t2 = current pc
634 lda t2,44(t2) # lda t2,ex_int2-ex_int1(t2) !!!!!!!!!!!!!!!
635 negl t1,t1 # negate register count
636 s4addq t1,t2,t2 # t2 = ex_int_sav - 4 * register count
637 jmp zero,(t2) # jump to save position
646 s8addq t1,t0,t0 # t0 = t0 - 8 * register count
648 ldl t1,FltSave(pv) # t1 = saved flt register count
649 br t2,ex_flt1 # t2 = current pc
651 lda t2,48(t2) # lda t2,ex_flt2-ex_flt1(t2) !!!!!!!!!!!!!!!
652 negl t1,t1 # negate register count
653 s4addq t1,t2,t2 # t2 = ex_flt_sav - 4 * register count
654 jmp zero,(t2) # jump to save position
664 ldl t0,0(ra) # load instruction LDA PV,xxx(RA)
666 sra t0,48,t0 # isolate offset
667 addq t0,ra,pv # compute update address
668 ldl t0,4(ra) # load instruction LDAH PV,xxx(PV)
669 srl t0,16,t0 # isolate instruction code
670 lda t0,-0x177b(t0) # test for LDAH
672 ldl t0,0(ra) # load instruction LDA PV,xxx(RA)
673 sll t0,16,t0 # compute high offset
674 addl t0,0,t0 # sign extend high offset
675 addq t0,pv,pv # compute update address
678 .end asm_handle_exception
681 /********************* function asm_signal_exception ***************************
683 * This function handles an exception which was catched by a signal. *
685 * void asm_signal_exception (exceptionptr, signalcontext); *
687 *******************************************************************************/
689 #define sigctxstack 0*8 /* sigstack state to restore */
690 #define sigctxmask 1*8 /* signal mask to restore */
691 #define sigctxpc 2*8 /* pc at time of signal */
692 #define sigctxpsl 3*8 /* psl to retore */
693 #define sigctxr00 4*8 /* processor regs 0 to 31 */
694 #define sigctxr01 5*8
695 #define sigctxr02 6*8
696 #define sigctxr03 7*8
697 #define sigctxr04 8*8
698 #define sigctxr05 9*8
699 #define sigctxr06 10*8
700 #define sigctxr07 11*8
701 #define sigctxr08 12*8
702 #define sigctxr09 13*8
703 #define sigctxr10 14*8
704 #define sigctxr11 15*8
705 #define sigctxr12 16*8
706 #define sigctxr13 17*8
707 #define sigctxr14 18*8
708 #define sigctxr15 19*8
709 #define sigctxr16 20*8
710 #define sigctxr17 21*8
711 #define sigctxr18 22*8
712 #define sigctxr19 23*8
713 #define sigctxr20 24*8
714 #define sigctxr21 25*8
715 #define sigctxr22 26*8
716 #define sigctxr23 27*8
717 #define sigctxr24 28*8
718 #define sigctxr25 29*8
719 #define sigctxr26 30*8
720 #define sigctxr27 31*8
721 #define sigctxr28 32*8
722 #define sigctxr29 33*8
723 #define sigctxr30 34*8
724 #define sigctxr31 35*8
726 #define sigctxfpuse 36*8 /* fp has been used */
727 #define sigctxf00 37*8 /* fp regs 0 to 31 */
728 #define sigctxf01 38*8
729 #define sigctxf02 39*8
730 #define sigctxf03 40*8
731 #define sigctxf04 41*8
732 #define sigctxf05 42*8
733 #define sigctxf06 43*8
734 #define sigctxf07 44*8
735 #define sigctxf08 45*8
736 #define sigctxf09 46*8
737 #define sigctxf10 47*8
738 #define sigctxf11 48*8
739 #define sigctxf12 49*8
740 #define sigctxf13 50*8
741 #define sigctxf14 51*8
742 #define sigctxf15 52*8
743 #define sigctxf16 53*8
744 #define sigctxf17 54*8
745 #define sigctxf18 55*8
746 #define sigctxf19 56*8
747 #define sigctxf20 57*8
748 #define sigctxf21 58*8
749 #define sigctxf22 59*8
750 #define sigctxf23 60*8
751 #define sigctxf24 61*8
752 #define sigctxf25 62*8
753 #define sigctxf26 63*8
754 #define sigctxf27 64*8
755 #define sigctxf28 65*8
756 #define sigctxf29 66*8
757 #define sigctxf30 67*8
758 #define sigctxf31 68*8
760 #define sigctxhfpcr 69*8 /* floating point control register */
761 #define sigctxsfpcr 70*8 /* software fpcr */
763 .ent asm_signal_exception
764 asm_signal_exception:
769 ldq v0,sigctxr00(sp) # restore possible used registers
793 ldq t10,sigctxr24(sp)
797 br asm_handle_nat_exception
798 .end asm_signal_exception
801 /********************* function new_builtin_monitorenter ***********************
803 * Does null check and calls monitorenter or throws an exception *
805 *******************************************************************************/
807 .ent new_builtin_monitorenter
808 new_builtin_monitorenter:
811 lda pv,builtin_monitorenter
812 beq a0,nb_monitorenter # if (null) throw exception
813 jmp zero,(pv) # else call builtin_monitorenter
816 ldq xptr,proto_java_lang_NullPointerException
817 lda xpc,-4(ra) # faulting address is return adress - 4
818 br asm_handle_nat_exception
819 .end new_builtin_monitorenter
822 /********************* function new_builtin_monitorexit ************************
824 * Does null check and calls monitorexit or throws an exception *
826 *******************************************************************************/
828 .ent new_builtin_monitorexit
829 new_builtin_monitorexit:
832 lda pv,builtin_monitorexit
833 beq a0,nb_monitorexit # if (null) throw exception
834 jmp zero,(pv) # else call builtin_monitorexit
837 ldq xptr,proto_java_lang_NullPointerException
838 lda xpc,-4(ra) # faulting address is return adress - 4
839 br asm_handle_nat_exception
840 .end new_builtin_monitorenter
843 /************************ function new_builtin_idiv ****************************
845 * Does null check and calls idiv or throws an exception *
847 *******************************************************************************/
849 .ent new_builtin_idiv
854 beq a1,nb_idiv # if (null) throw exception
855 jmp zero,(pv) # else call builtin_idiv
858 ldq xptr,proto_java_lang_ArithmeticException
859 lda xpc,-4(ra) # faulting address is return adress - 4
860 br asm_handle_nat_exception
861 .end new_builtin_idiv
864 /************************ function new_builtin_ldiv ****************************
866 * Does null check and calls ldiv or throws an exception *
868 *******************************************************************************/
870 .ent new_builtin_ldiv
875 beq a1,nb_ldiv # if (null) throw exception
876 jmp zero,(pv) # else call builtin_ldiv
879 ldq xptr,proto_java_lang_ArithmeticException
880 lda xpc,-4(ra) # faulting address is return adress - 4
881 br asm_handle_nat_exception
882 .end new_builtin_ldiv
885 /************************ function new_builtin_irem ****************************
887 * Does null check and calls irem or throws an exception *
889 *******************************************************************************/
891 .ent new_builtin_irem
896 beq a1,nb_irem # if (null) throw exception
897 jmp zero,(pv) # else call builtin_irem
900 ldq xptr,proto_java_lang_ArithmeticException
901 lda xpc,-4(ra) # faulting address is return adress - 4
902 br asm_handle_nat_exception
903 .end new_builtin_irem
906 /************************ function new_builtin_lrem ****************************
908 * Does null check and calls lrem or throws an exception *
910 *******************************************************************************/
912 .ent new_builtin_lrem
917 beq a1,nb_lrem # if (null) throw exception
918 jmp zero,(pv) # else call builtin_lrem
921 ldq xptr,proto_java_lang_ArithmeticException
922 lda xpc,-4(ra) # faulting address is return adress - 4
923 br asm_handle_nat_exception
924 .end new_builtin_lrem
927 /*********************** function new_builtin_checkcast ************************
929 * Does the cast check and eventually throws an exception *
931 *******************************************************************************/
933 .ent new_builtin_checkcast
934 new_builtin_checkcast:
937 lda sp,-16(sp) # allocate stack space
938 stq ra,0(sp) # save return address
939 stq a0,8(sp) # save object pointer
940 jsr ra,new_builtin_checkcast # new_builtin_checkcast
942 beq v0,nb_ccast_throw # if (false) throw exception
943 ldq ra,0(sp) # restore return address
944 ldq v0,8(sp) # return object pointer
945 lda sp,16(sp) # free stack space
949 ldq xptr,proto_java_lang_ClassCastException
950 ldq ra,0(sp) # restore return address
951 lda sp,16(sp) # free stack space
952 lda xpc,-4(ra) # faulting address is return adress - 4
953 br asm_handle_nat_exception
954 .end new_builtin_checkcast
957 /****************** function new_builtin_checkclasscast ************************
959 * Does the cast check and eventually throws an exception *
961 *******************************************************************************/
963 .ent new_builtin_checkclasscast
964 new_builtin_checkclasscast:
967 lda sp,-16(sp) # allocate stack space
968 stq ra,0(sp) # save return address
969 stq a0,8(sp) # save object pointer
970 jsr ra,builtin_checkclasscast # builtin_checkclasscast
972 beq v0,nb_cclass_throw # if (false) throw exception
973 ldq ra,0(sp) # restore return address
974 ldq v0,8(sp) # return object pointer
975 lda sp,16(sp) # free stack space
979 ldq xptr,proto_java_lang_ClassCastException
980 ldq ra,0(sp) # restore return address
981 lda sp,16(sp) # free stack space
982 lda xpc,-4(ra) # faulting address is return adress - 4
983 br asm_handle_nat_exception
984 .end new_builtin_checkclasscast
987 /****************** function new_builtin_checkintercast ************************
989 * Does the cast check and eventually throws an exception *
991 *******************************************************************************/
993 .ent new_builtin_checkintercast
994 new_builtin_checkintercast:
997 lda sp,-16(sp) # allocate stack space
998 stq ra,0(sp) # save return address
999 stq a0,8(sp) # save object pointer
1000 jsr ra,builtin_checkintercast # builtin_checkintercast
1002 beq v0,nb_cinter_throw # if (false) throw exception
1003 ldq ra,0(sp) # restore return address
1004 ldq v0,8(sp) # return object pointer
1005 lda sp,16(sp) # free stack space
1009 ldq xptr,proto_java_lang_ClassCastException
1010 ldq ra,0(sp) # restore return address
1011 lda sp,16(sp) # free stack space
1012 lda xpc,-4(ra) # faulting address is return adress - 4
1013 br asm_handle_nat_exception
1014 .end new_builtin_checkintercast
1017 /******************* function new_builtin_checkarraycast ***********************
1019 * Does the cast check and eventually throws an exception *
1021 *******************************************************************************/
1023 .ent new_builtin_checkarraycast
1024 new_builtin_checkarraycast:
1027 lda sp,-16(sp) # allocate stack space
1028 stq ra,0(sp) # save return address
1029 stq a0,8(sp) # save object pointer
1030 jsr ra,builtin_checkarraycast # builtin_checkarraycast
1032 beq v0,nb_carray_throw # if (false) throw exception
1033 ldq ra,0(sp) # restore return address
1034 ldq v0,8(sp) # return object pointer
1035 lda sp,16(sp) # free stack space
1039 ldq xptr,proto_java_lang_ClassCastException
1040 ldq ra,0(sp) # restore return address
1041 lda sp,16(sp) # free stack space
1042 lda xpc,-4(ra) # faulting address is return adress - 4
1043 br asm_handle_nat_exception
1044 .end new_builtin_checkarraycast
1047 /******************* function new_builtin_aastore ******************************
1049 * Does the cast check and eventually throws an exception *
1051 *******************************************************************************/
1053 .ent new_builtin_aastore
1054 new_builtin_aastore:
1057 beq a0,nb_aastore_null # if null pointer throw exception
1058 ldl t0,offarrsize(a0) # load size
1059 lda sp,-24(sp) # allocate stack space
1060 stq ra,0(sp) # save return address
1061 s8addq a1,a0,t1 # add index*8 to arrayref
1062 cmpult a1,t0,t0 # do bound check
1063 beq t0,nb_aastore_bound # if out of bounds throw exception
1064 mov a2,a1 # object is second argument
1065 stq t1,8(sp) # save store position
1066 stq a1,16(sp) # save object
1067 jsr ra,builtin_canstore # builtin_canstore(arrayref,object)
1069 ldq ra,0(sp) # restore return address
1070 ldq a0,8(sp) # restore store position
1071 ldq a1,16(sp) # restore object
1072 lda sp,24(sp) # free stack space
1073 beq v0,nb_aastore_throw # if (false) throw exception
1074 stq a1,offobjarr(a0) # store objectptr in array
1078 ldq xptr,proto_java_lang_NullPointerException
1079 mov ra,xpc # faulting address is return adress
1080 br asm_handle_nat_exception
1083 ldq xptr,proto_java_lang_ArrayIndexOutOfBoundsException
1084 lda sp,24(sp) # free stack space
1085 mov ra,xpc # faulting address is return adress
1086 br asm_handle_nat_exception
1089 ldq xptr,proto_java_lang_ArrayStoreException
1090 mov ra,xpc # faulting address is return adress
1091 br asm_handle_nat_exception
1093 .end new_builtin_aastore
1096 /********************** function initialize_thread_stack ***********************
1098 * initialized a thread stack *
1100 *******************************************************************************/
1102 .ent initialize_thread_stack
1103 initialize_thread_stack:
1124 .end initialize_thread_stack
1127 /******************* function perform_alpha_threadswitch ***********************
1129 * void perform_alpha_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1130 * performs a threadswitch *
1132 *******************************************************************************/
1134 .ent perform_alpha_threadswitch
1135 perform_alpha_threadswitch:
1176 .end perform_alpha_threadswitch
1179 /********************* function asm_switchstackandcall *************************
1181 * Switches to a new stack, calls a function and switches back. *
1182 * a0 new stack pointer *
1183 * a1 function pointer *
1185 *******************************************************************************/
1188 .ent asm_switchstackandcall
1189 asm_switchstackandcall:
1190 lda a0,-2*8(a0) # allocate new stack
1191 stq ra,0(a0) # save return address
1192 stq sp,1*8(a0) # save old stack pointer
1193 mov a0,sp # switch to new stack
1195 mov a1,pv # load function pointer
1196 jmp ra,(pv) # and call funciton
1198 ldq ra,0(sp) # load return address
1199 ldq sp,1*8(sp) # switch to old stack
1201 jmp zero,(ra) # return
1203 .end asm_switchstackandcall