1 /* -*- mode: asm; tab-width: 4 -*- */
2 /****************************** asmpart.S **************************************
4 * It contains the Java-C interface functions for Alpha processors. *
6 * Copyright (c) 1997 A. Krall, R. Grafl, M. Gschwind, M. Probst *
8 * See file COPYRIGHT for information on usage and disclaimer of warranties *
10 * Authors: Andreas Krall EMAIL: cacao@complang.tuwien.ac.at *
11 * Reinhard Grafl EMAIL: cacao@complang.tuwien.ac.at *
13 * Last Change: 2003/02/17 *
15 *******************************************************************************/
84 /********************* exported functions and variables ***********************/
86 .globl has_no_x_instr_set
87 .globl synchronize_caches
88 .globl asm_calljavamethod
89 .globl asm_calljavafunction
90 .globl asm_call_jit_compiler
91 .globl asm_dumpregistersandcall
92 .globl asm_handle_exception
93 .globl asm_handle_nat_exception
94 .globl asm_builtin_checkcast
95 .globl asm_builtin_checkarraycast
96 .globl asm_builtin_aastore
97 .globl asm_builtin_monitorenter
98 .globl asm_builtin_monitorexit
99 .globl asm_builtin_idiv
100 .globl asm_builtin_irem
101 .globl asm_builtin_ldiv
102 .globl asm_builtin_lrem
103 .globl asm_perform_threadswitch
104 .globl asm_initialize_thread_stack
105 .globl asm_switchstackandcall
106 .globl asm_getcallingmethod
107 .globl asm_builtin_trace
108 .globl asm_builtin_exittrace
110 /*************************** imported variables *******************************/
115 /*************************** imported functions *******************************/
118 .globl builtin_monitorexit
119 .globl builtin_throw_exception
120 .globl builtin_trace_exception
121 .globl class_java_lang_Object
124 /*********************** function has_no_x_instr_set ***************************
126 * determines if the byte support instruction set (21164a and higher) *
129 *******************************************************************************/
131 .ent has_no_x_instr_set
134 .long 0x47e03c20 /* amask 1,v0 */
135 jmp zero,(ra) /* return */
137 .end has_no_x_instr_set
140 /********************* function synchronize_caches ****************************/
142 .ent synchronize_caches
145 call_pal PAL_imb /* synchronise instruction cache */
146 jmp zero,(ra) /* return */
148 .end synchronize_caches
151 /********************* function asm_calljavamethod *****************************
153 * This function calls a Java-method (which possibly needs compilation) *
154 * with up to 4 parameters. *
156 * This functions calls the JIT-compiler which eventually translates the *
157 * method into machine code. *
159 * An possibly throwed exception will be returned to the caller as function *
160 * return value, so the java method cannot return a fucntion value (this *
161 * function usually calls 'main' and '<clinit>' which do not return a *
165 * javaobject_header *asm_calljavamethod (methodinfo *m, *
166 * void *arg1, void *arg2, void *arg3, void *arg4); *
168 *******************************************************************************/
170 #define MethodPointer -8
171 #define FrameSize -12
176 #define ExTableSize -32
177 #define ExTableStart -32
179 #define ExEntrySize -32
182 #define ExHandlerPC -24
183 #define ExCatchType -32
185 .ent asm_calljavamethod
188 .ascii "calljavamethod\0\0"
191 .quad 0 /* catch type all */
192 .quad calljava_xhandler /* handler pc */
193 .quad calljava_xhandler /* end pc */
194 .quad asm_calljavamethod /* start pc */
195 .long 1 /* extable size */
196 .long 0 /* fltsave */
197 .long 0 /* intsave */
200 .long 32 /* frame size */
201 .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 */
213 stq a0,16(sp) /* save method pointer for compiler */
214 lda v0,16(sp) /* pass pointer to method pointer via v0*/
216 mov a1,a0 /* pass the remaining parameters */
221 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
222 stq $28,8(sp) /* store function address */
223 mov sp,$28 /* set method pointer */
225 ldq pv,8($28) /* method call as in Java */
226 jmp ra,(pv) /* call JIT compiler */
228 lda pv,-64(ra) /* asm_calljavamethod-calljava_jit !!!!!*/
232 ldq ra,0(sp) /* restore return address */
233 ldq gp,24(sp) /* restore global pointer */
234 lda sp,32(sp) /* free stack space */
235 ldl v0,newcompiler /* load newcompiler flag */
236 subq v0,1,v0 /* negate for clearing v0 */
237 beq v0,calljava_ret /* if newcompiler skip ex copying */
238 mov $1,v0 /* pass exception to caller (C) */
244 ldq gp,24(sp) /* restore global pointer */
246 jsr ra,builtin_throw_exception
247 ldq ra,0(sp) /* restore return address */
248 lda sp,32(sp) /* free stack space */
250 .end asm_calljavamethod
253 /********************* function asm_calljavafunction ***************************
255 * This function calls a Java-method (which possibly needs compilation) *
256 * with up to 4 address parameters. *
258 * This functions calls the JIT-compiler which eventually translates the *
259 * method into machine code. *
262 * javaobject_header *asm_calljavamethod (methodinfo *m, *
263 * void *arg1, void *arg2, void *arg3, void *arg4); *
265 *******************************************************************************/
267 .ent asm_calljavafunction
270 .ascii "calljavafunction\0\0"
273 .quad 0 /* catch type all */
274 .quad calljava_xhandler2 /* handler pc */
275 .quad calljava_xhandler2 /* end pc */
276 .quad asm_calljavafunction /* start pc */
277 .long 1 /* extable size */
278 .long 0 /* fltsave */
279 .long 0 /* intsave */
282 .long 32 /* frame size */
283 .quad 0 /* method pointer (pointer to name) */
285 asm_calljavafunction:
290 lda sp,-32(sp) /* allocate stack space */
291 stq gp,24(sp) /* save global pointer */
292 stq ra,0(sp) /* save return address */
295 stq a0,16(sp) /* save method pointer for compiler */
296 lda v0,16(sp) /* pass pointer to method pointer via v0*/
298 mov a1,a0 /* pass the remaining parameters */
303 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
304 stq $28,8(sp) /* store function address */
305 mov sp,$28 /* set method pointer */
307 ldq pv,8($28) /* method call as in Java */
308 jmp ra,(pv) /* call JIT compiler */
310 lda pv,-64(ra) /* asm_calljavafunction-calljava_jit !!!!!*/
314 ldq ra,0(sp) /* restore return address */
315 ldq gp,24(sp) /* restore global pointer */
316 lda sp,32(sp) /* free stack space */
318 /* ldl v0,newcompiler */ /* load newcompiler flag */
319 /* subq v0,1,v0 */ /* negate for clearing v0 */
320 /* beq v0,calljava_ret*/ /* if newcompiler skip ex copying */
321 /* mov $1,v0 */ /* pass exception to caller (C) */
327 ldq gp,24(sp) /* restore global pointer */
329 jsr ra,builtin_throw_exception
330 ldq ra,0(sp) /* restore return address */
331 lda sp,32(sp) /* free stack space */
333 .end asm_calljavafunction
336 /****************** function asm_call_jit_compiler *****************************
338 * invokes the compiler for untranslated JavaVM methods. *
340 * Register R0 contains a pointer to the method info structure (prepared *
341 * by createcompilerstub). Using the return address in R26 and the *
342 * offset in the LDA instruction or using the value in methodptr R28 the *
343 * patching address for storing the method address can be computed: *
345 * method address was either loaded using *
346 * M_LDQ (REG_PV, REG_PV, a) ; invokestatic/special ($27) *
347 * M_LDA (REG_PV, REG_RA, low) *
348 * M_LDAH(REG_PV, REG_RA, high) ; optional *
350 * M_LDQ (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($28) *
351 * in the static case the method pointer can be computed using the *
352 * return address and the lda function following the jmp instruction *
354 *******************************************************************************/
357 .ent asm_call_jit_compiler
358 asm_call_jit_compiler:
362 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
363 srl t8,16,t8 /* shift right register number $yy */
364 and t8,31,t8 /* isolate register number */
365 subl t8,28,t8 /* test for REG_METHODPTR */
367 ldl t8,0(ra) /* load instruction LDA PV,xxx(RA) */
369 sra t8,48,t8 /* isolate offset */
370 addq t8,ra,$28 /* compute update address */
371 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
372 srl t8,16,t8 /* isolate instruction code */
373 lda t8,-0x177b(t8) /* test for LDAH */
375 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
376 sll t8,16,t8 /* compute high offset */
377 addl t8,0,t8 /* sign extend high offset */
378 addq t8,$28,$28 /* compute update address */
380 lda sp,-14*8(sp) /* reserve stack space */
381 stq a0,0*8(sp) /* save all argument registers */
382 stq a1,1*8(sp) /* they could be used by method */
393 stq $28,12*8(sp) /* save method pointer */
394 stq ra,13*8(sp) /* save return address */
396 ldq a0,0(v0) /* pass 'methodinfo' pointer to */
397 jsr ra,jit_compile /* jit compiler */
400 call_pal PAL_imb /* synchronise instruction cache */
402 ldq a0,0*8(sp) /* load argument registers */
414 ldq $28,12*8(sp) /* load method pointer */
415 ldq ra,13*8(sp) /* load return address */
416 lda sp,14*8(sp) /* deallocate stack area */
418 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
420 sra t8,48,t8 /* isolate offset */
422 addq t8,$28,t8 /* compute update address via method pointer*/
423 stq v0,0(t8) /* save new method address there */
425 mov v0,pv /* load method address into pv */
427 jmp zero,(pv) /* and call method. The method returns */
428 /* directly to the caller (ra). */
430 .end asm_call_jit_compiler
433 /****************** function asm_dumpregistersandcall **************************
435 * This funtion saves all callee saved registers and calls the function *
436 * which is passed as parameter. *
438 * This function is needed by the garbage collector, which needs to access *
439 * all registers which are stored on the stack. Unused registers are *
440 * cleared to avoid interferances with the GC. *
442 * void asm_dumpregistersandcall (functionptr f); *
444 *******************************************************************************/
446 .ent asm_dumpregistersandcall
447 asm_dumpregistersandcall:
448 lda sp,-16*8(sp) /* allocate stack */
449 stq ra,0(sp) /* save return address */
451 stq s0,1*8(sp) /* save all callee saved registers */
452 stq s1,2*8(sp) /* intialize the remaining registers */
467 clr v0 /* intialize the remaining registers */
512 mov a0,pv /* load function pointer */
513 jmp ra,(pv) /* and call function */
515 ldq ra,0(sp) /* load return address */
516 lda sp,16*8(sp) /* deallocate stack */
517 jmp zero,(ra) /* return */
519 .end asm_dumpregistersandcall
522 /********************* function asm_handle_exception ***************************
524 * This function handles an exception. It does not use the usual calling *
525 * conventions. The exception pointer is passed in REG_ITMP1 and the *
526 * pc from the exception raising position is passed in REG_ITMP2. It searches *
527 * the local exception table for a handler. If no one is found, it unwinds *
528 * stacks and continues searching the callers. *
530 * void asm_handle_exception (exceptionptr, exceptionpc); *
532 *******************************************************************************/
534 .ent asm_handle_nat_exception
535 asm_handle_nat_exception:
537 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
539 sra t0,48,t0 /* isolate offset */
540 addq t0,ra,pv /* compute update address */
541 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
542 srl t0,16,t0 /* isolate instruction code */
543 lda t0,-0x177b(t0) /* test for LDAH */
544 bne t0,asm_handle_exception
545 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
546 sll t0,16,t0 /* compute high offset */
547 addl t0,0,t0 /* sign extend high offset */
548 addq t0,pv,pv /* compute update address */
550 .aent asm_handle_exception
551 asm_handle_exception:
553 lda sp,-18*8(sp) /* allocate stack */
554 stq t0,0*8(sp) /* save possible used registers */
555 stq t1,1*8(sp) /* also registers used by trace_exception */
573 lda t3,1(zero) /* set no unwind flag */
575 lda sp,-5*8(sp) /* allocate stack */
576 stq xptr,0*8(sp) /* save used register */
583 ldq a1,MethodPointer(pv)
586 br ra,ex_trace /* set ra for gp loading */
588 ldgp gp,0(ra) /* load gp */
589 jsr ra,builtin_trace_exception /* trace_exception(xptr,methodptr) */
591 ldq xptr,0*8(sp) /* restore used register */
596 lda sp,5*8(sp) /* deallocate stack */
598 ldl t0,ExTableSize(pv) /* t0 = exception table size */
599 beq t0,empty_table /* if empty table skip */
600 lda t1,ExTableStart(pv) /* t1 = start of exception table */
603 ldq t2,ExStartPC(t1) /* t2 = exception start pc */
604 cmple t2,xpc,t2 /* t2 = (startpc <= xpc) */
605 beq t2,ex_table_cont /* if (false) continue */
606 ldq t2,ExEndPC(t1) /* t2 = exception end pc */
607 cmplt xpc,t2,t2 /* t2 = (xpc < endpc) */
608 beq t2,ex_table_cont /* if (false) continue */
609 ldq a1,ExCatchType(t1) /* arg1 = exception catch type */
610 beq a1,ex_handle_it /* NULL catches everything */
612 ldq a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
613 ldq a1,offobjvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
614 ldl a0,offbaseval(a0) /* a0 = baseval(xptr) */
615 ldl v0,offbaseval(a1) /* a2 = baseval(catchtype) */
616 ldl a1,offdiffval(a1) /* a1 = diffval(catchtype) */
617 subl a0,v0,a0 /* a0 = baseval(xptr) - baseval(catchtype) */
618 cmpule a0,a1,v0 /* v0 = xptr is instanceof catchtype */
619 beq v0,ex_table_cont /* if (false) continue */
623 ldq xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
625 beq t3,ex_jump /* if (!(no stack unwinding) skip */
627 ldq t0,0*8(sp) /* restore possible used registers */
628 ldq t1,1*8(sp) /* also registers used by trace_exception */
645 lda sp,18*8(sp) /* deallocate stack */
648 jmp zero,(xpc) /* jump to the handler */
651 lda t1,ExEntrySize(t1) /* next exception table entry */
652 subl t0,1,t0 /* decrement entry counter */
653 bgt t0,ex_table_loop /* if (t0 > 0) next entry */
656 beq t3,ex_already_cleared /* if here the first time, then */
657 lda sp,18*8(sp) /* deallocate stack and */
658 clr t3 /* clear the no unwind flag */
660 ldl t0,IsSync(pv) /* t0 = SyncOffset */
661 beq t0,no_monitor_exit /* if zero no monitorexit */
662 addq sp,t0,t0 /* add stackptr to Offset */
663 ldq a0,-8(t0) /* load monitorexit pointer */
665 lda sp,-7*8(sp) /* allocate stack */
666 stq t0,0*8(sp) /* save used register */
674 br ra,ex_mon_load /* set ra for gp loading */
676 ldgp gp,0(ra) /* load gp */
677 jsr ra,builtin_monitorexit/* builtin_monitorexit(objectptr) */
679 ldq t0,0*8(sp) /* restore used register */
686 lda sp,7*8(sp) /* deallocate stack */
689 ldl t0,FrameSize(pv) /* t0 = frame size */
690 addq sp,t0,sp /* unwind stack */
691 mov sp,t0 /* t0 = pointer to save area */
692 ldl t1,IsLeaf(pv) /* t1 = is leaf procedure */
693 bne t1,ex_no_restore /* if (leaf) skip */
694 ldq ra,-8(t0) /* restore ra */
695 lda t0,-8(t0) /* t0-- */
697 mov ra,xpc /* the new xpc is ra */
698 ldl t1,IntSave(pv) /* t1 = saved int register count */
699 br t2,ex_int1 /* t2 = current pc */
701 lda t2,44(t2) /* lda t2,ex_int2-ex_int1(t2) !!!!!!!!!!!!! */
702 negl t1,t1 /* negate register count */
703 s4addq t1,t2,t2 /* t2 = ex_int_sav - 4 * register count */
704 jmp zero,(t2) /* jump to save position */
713 s8addq t1,t0,t0 /* t0 = t0 - 8 * register count */
715 ldl t1,FltSave(pv) /* t1 = saved flt register count */
716 br t2,ex_flt1 /* t2 = current pc */
718 lda t2,48(t2) /* lda t2,ex_flt2-ex_flt1(t2) !!!!!!!!!!!!! */
719 negl t1,t1 /* negate register count */
720 s4addq t1,t2,t2 /* t2 = ex_flt_sav - 4 * register count */
721 jmp zero,(t2) /* jump to save position */
731 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
733 sra t0,48,t0 /* isolate offset */
734 addq t0,ra,pv /* compute update address */
735 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
736 srl t0,16,t0 /* isolate instruction code */
737 lda t0,-0x177b(t0) /* test for LDAH */
739 ldl t0,4(ra) /* load instruction LDAH PV,xxx(RA) */
740 sll t0,16,t0 /* compute high offset */
741 addl t0,0,t0 /* sign extend high offset */
742 addq t0,pv,pv /* compute update address */
745 .end asm_handle_nat_exception
748 /********************* function asm_builtin_monitorenter ***********************
750 * Does null check and calls monitorenter or throws an exception *
752 *******************************************************************************/
754 .ent asm_builtin_monitorenter
755 asm_builtin_monitorenter:
758 lda pv,builtin_monitorenter
759 beq a0,nb_monitorenter /* if (null) throw exception */
760 jmp zero,(pv) /* else call builtin_monitorenter */
763 ldq xptr,proto_java_lang_NullPointerException
764 lda xpc,-4(ra) /* faulting address is return adress - 4*/
765 br asm_handle_nat_exception
766 .end asm_builtin_monitorenter
769 /********************* function asm_builtin_monitorexit ************************
771 * Does null check and calls monitorexit or throws an exception *
773 *******************************************************************************/
775 .ent asm_builtin_monitorexit
776 asm_builtin_monitorexit:
779 lda pv,builtin_monitorexit
780 beq a0,nb_monitorexit /* if (null) throw exception */
781 jmp zero,(pv) /* else call builtin_monitorexit */
784 ldq xptr,proto_java_lang_NullPointerException
785 lda xpc,-4(ra) /* faulting address is return adress - 4*/
786 br asm_handle_nat_exception
787 .end asm_builtin_monitorexit
790 /************************ function asm_builtin_idiv ****************************
792 * Does null check and calls idiv or throws an exception *
794 *******************************************************************************/
796 .ent asm_builtin_idiv
801 beq a1,nb_idiv /* if (null) throw exception */
802 jmp zero,(pv) /* else call builtin_idiv */
805 ldq xptr,proto_java_lang_ArithmeticException
806 lda xpc,-4(ra) /* faulting address is return adress - 4*/
807 br asm_handle_nat_exception
808 .end asm_builtin_idiv
811 /************************ function asm_builtin_ldiv ****************************
813 * Does null check and calls ldiv or throws an exception *
815 *******************************************************************************/
817 .ent asm_builtin_ldiv
822 beq a1,nb_ldiv /* if (null) throw exception */
823 jmp zero,(pv) /* else call builtin_ldiv */
826 ldq xptr,proto_java_lang_ArithmeticException
827 lda xpc,-4(ra) /* faulting address is return adress - 4*/
828 br asm_handle_nat_exception
829 .end asm_builtin_ldiv
832 /************************ function asm_builtin_irem ****************************
834 * Does null check and calls irem or throws an exception *
836 *******************************************************************************/
838 .ent asm_builtin_irem
843 beq a1,nb_irem /* if (null) throw exception */
844 jmp zero,(pv) /* else call builtin_irem */
847 ldq xptr,proto_java_lang_ArithmeticException
848 lda xpc,-4(ra) /* faulting address is return adress - 4*/
849 br asm_handle_nat_exception
850 .end asm_builtin_irem
853 /************************ function asm_builtin_lrem ****************************
855 * Does null check and calls lrem or throws an exception *
857 *******************************************************************************/
859 .ent asm_builtin_lrem
864 beq a1,nb_lrem /* if (null) throw exception */
865 jmp zero,(pv) /* else call builtin_lrem */
868 ldq xptr,proto_java_lang_ArithmeticException
869 lda xpc,-4(ra) /* faulting address is return adress - 4*/
870 br asm_handle_nat_exception
871 .end asm_builtin_lrem
874 /*********************** function new_builtin_checkcast ************************
876 * Does the cast check and eventually throws an exception *
878 *******************************************************************************/
880 .ent asm_builtin_checkcast
881 asm_builtin_checkcast:
884 lda sp,-16(sp) # allocate stack space
885 stq ra,0(sp) # save return address
886 stq a0,8(sp) # save object pointer
887 jsr ra,builtin_checkcast # builtin_checkcast
889 beq v0,nb_ccast_throw # if (false) throw exception
890 ldq ra,0(sp) # restore return address
891 ldq v0,8(sp) # return object pointer
892 lda sp,16(sp) # free stack space
896 ldq xptr,proto_java_lang_ClassCastException
897 ldq ra,0(sp) # restore return address
898 lda sp,16(sp) # free stack space
899 lda xpc,-4(ra) # faulting address is return adress - 4
900 br asm_handle_nat_exception
901 .end asm_builtin_checkcast
904 /******************* function asm_builtin_checkarraycast ***********************
906 * Does the cast check and eventually throws an exception *
908 *******************************************************************************/
910 .ent asm_builtin_checkarraycast
911 asm_builtin_checkarraycast:
914 lda sp,-16(sp) /* allocate stack space */
915 stq ra,0(sp) /* save return address */
916 stq a0,8(sp) /* save object pointer */
917 jsr ra,builtin_checkarraycast /* builtin_checkarraycast */
919 beq v0,nb_carray_throw /* if (false) throw exception */
920 ldq ra,0(sp) /* restore return address */
921 ldq v0,8(sp) /* return object pointer */
922 lda sp,16(sp) /* free stack space */
926 ldq xptr,proto_java_lang_ClassCastException
927 ldq ra,0(sp) /* restore return address */
928 lda sp,16(sp) /* free stack space */
929 lda xpc,-4(ra) /* faulting address is return adress - 4*/
930 br asm_handle_nat_exception
931 .end asm_builtin_checkarraycast
934 /******************* function asm_builtin_aastore ******************************
936 * Does the cast check and eventually throws an exception *
938 *******************************************************************************/
940 .ent asm_builtin_aastore
944 beq a0,nb_aastore_null /* if null pointer throw exception */
945 ldl t0,offarraysize(a0) /* load size */
946 lda sp,-24(sp) /* allocate stack space */
947 stq ra,0(sp) /* save return address */
948 s8addq a1,a0,t1 /* add index*8 to arrayref */
949 cmpult a1,t0,t0 /* do bound check */
950 beq t0,nb_aastore_bound /* if out of bounds throw exception */
951 mov a2,a1 /* object is second argument */
952 stq t1,8(sp) /* save store position */
953 stq a1,16(sp) /* save object */
954 jsr ra,builtin_canstore /* builtin_canstore(arrayref,object) */
956 ldq ra,0(sp) /* restore return address */
957 ldq a0,8(sp) /* restore store position */
958 ldq a1,16(sp) /* restore object */
959 lda sp,24(sp) /* free stack space */
960 beq v0,nb_aastore_throw /* if (false) throw exception */
961 stq a1,offobjarrdata(a0) /* store objectptr in array */
965 ldq xptr,proto_java_lang_NullPointerException
966 mov ra,xpc /* faulting address is return adress */
967 br asm_handle_nat_exception
970 ldq xptr,proto_java_lang_ArrayIndexOutOfBoundsException
971 lda sp,24(sp) /* free stack space */
972 mov ra,xpc /* faulting address is return adress */
973 br asm_handle_nat_exception
976 ldq xptr,proto_java_lang_ArrayStoreException
977 mov ra,xpc /* faulting address is return adress */
978 br asm_handle_nat_exception
980 .end asm_builtin_aastore
983 /******************* function asm_initialize_thread_stack **********************
985 * initialized a thread stack *
987 *******************************************************************************/
989 .ent asm_initialize_thread_stack
990 asm_initialize_thread_stack:
1011 .end asm_initialize_thread_stack
1014 /******************* function asm_perform_threadswitch *************************
1016 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1018 * performs a threadswitch *
1020 *******************************************************************************/
1022 .ent asm_perform_threadswitch
1023 asm_perform_threadswitch:
1064 .end asm_perform_threadswitch
1067 /********************* function asm_switchstackandcall *************************
1069 * void *asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
1072 * Switches to a new stack, calls a function and switches back. *
1073 * a0 new stack pointer *
1074 * a1 function pointer *
1075 * a2 pointer to variable where stack top should be stored *
1076 * a3 pointer to user data, is passed to the function *
1078 *******************************************************************************/
1081 .ent asm_switchstackandcall
1082 asm_switchstackandcall:
1083 lda a0,-2*8(a0) /* allocate new stack */
1084 stq ra,0(a0) /* save return address on new stack */
1085 stq sp,1*8(a0) /* save old stack pointer on new stack */
1086 stq sp,0(a2) /* save old stack pointer to variable */
1087 mov a0,sp /* switch to new stack */
1089 mov a1,pv /* load function pointer */
1090 mov a3,a0 /* pass pointer */
1091 jmp ra,(pv) /* and call function */
1093 ldq ra,0(sp) /* load return address */
1094 ldq sp,1*8(sp) /* switch to old stack */
1096 jmp zero,(ra) /* return */
1098 .end asm_switchstackandcall
1101 /********************* function asm_getcallingmethod ***************************
1103 * classinfo *asm_getcallingmethodclass (); *
1105 * goes back stack frames to get the calling method *
1111 *******************************************************************************/
1114 .ent asm_getcallingmethod
1115 asm_getcallingmethod:
1117 ldq t3,16(sp) /* load return address of native function */
1118 addq sp,24,t2 /* skip frames of C-Function and nativestub */
1120 /* determine pv (t3) of java-function from ra */
1122 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1124 sra t0,48,t0 /* isolate offset */
1125 addq t0,t3,t4 /* compute update address */
1126 ldl t0,4(t3) /* load instruction LDAH PV,xxx(PV) */
1127 srl t0,16,t0 /* isolate instruction code */
1128 lda t0,-0x177b(t0) /* test for LDAH */
1130 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1131 sll t0,16,t0 /* compute high offset */
1132 addl t0,0,t0 /* sign extend high offset */
1133 addq t0,t4,t4 /* compute update address */
1136 ldl t0,FrameSize(t4) /* t0 = frame size */
1137 addq t2,t0,t2 /* skip frame of java function */
1138 ldq t3,-8(t2) /* load new ra */
1140 /* determine pv (t3) of java-function from ra */
1142 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1144 sra t0,48,t0 /* isolate offset */
1145 addq t0,t3,t4 /* compute update address */
1146 ldl t0,4(t3) /* load instruction LDAH PV,xxx(PV) */
1147 srl t0,16,t0 /* isolate instruction code */
1148 lda t0,-0x177b(t0) /* test for LDAH */
1150 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1151 sll t0,16,t0 /* compute high offset */
1152 addl t0,0,t0 /* sign extend high offset */
1153 addq t0,t4,t4 /* compute update address */
1156 ldq v0,MethodPointer(t4) /* */
1159 jmp zero,(ra) /* return */
1161 .end asm_getcallingmethod
1170 /*********************** function asm_builtin_trace ****************************
1172 * Intended to be called from the native stub. Saves all argument registers *
1173 * and calls builtin_trace_args. *
1175 *******************************************************************************/
1177 .ent asm_builtin_trace
1196 jsr ra,builtin_trace_args
1214 .end asm_builtin_trace
1217 /********************* function asm_builtin_exittrace **************************
1219 * Intended to be called from the native stub. Saves return value and calls *
1220 * builtin_displaymethodstop. *
1222 *******************************************************************************/
1224 .ent asm_builtin_exittrace
1225 asm_builtin_exittrace:
1232 jsr ra,builtin_displaymethodstop
1240 .end asm_builtin_exittrace