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
108 /*************************** imported variables *******************************/
113 /*************************** imported functions *******************************/
116 .globl builtin_monitorexit
117 .globl builtin_throw_exception
118 .globl builtin_trace_exception
119 .globl class_java_lang_Object
122 /*********************** function has_no_x_instr_set ***************************
124 * determines if the byte support instruction set (21164a and higher) *
127 *******************************************************************************/
129 .ent has_no_x_instr_set
132 .long 0x47e03c20 /* amask 1,v0 */
133 jmp zero,(ra) /* return */
135 .end has_no_x_instr_set
138 /********************* function synchronize_caches ****************************/
140 .ent synchronize_caches
143 call_pal PAL_imb /* synchronise instruction cache */
144 jmp zero,(ra) /* return */
146 .end synchronize_caches
149 /********************* function asm_calljavamethod *****************************
151 * This function calls a Java-method (which possibly needs compilation) *
152 * with up to 4 parameters. *
154 * This functions calls the JIT-compiler which eventually translates the *
155 * method into machine code. *
157 * An possibly throwed exception will be returned to the caller as function *
158 * return value, so the java method cannot return a fucntion value (this *
159 * function usually calls 'main' and '<clinit>' which do not return a *
163 * javaobject_header *asm_calljavamethod (methodinfo *m, *
164 * void *arg1, void *arg2, void *arg3, void *arg4); *
166 *******************************************************************************/
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 .ent asm_calljavamethod
186 .ascii "calljavamethod\0\0"
189 .quad 0 /* catch type all */
190 .quad calljava_xhandler /* handler pc */
191 .quad calljava_xhandler /* end pc */
192 .quad asm_calljavamethod /* start pc */
193 .long 1 /* extable size */
194 .long 0 /* fltsave */
195 .long 0 /* intsave */
198 .long 32 /* frame size */
199 .quad 0 /* method pointer (pointer to name) */
206 lda sp,-32(sp) /* allocate stack space */
207 stq gp,24(sp) /* save global pointer */
208 stq ra,0(sp) /* save return address */
211 stq a0,16(sp) /* save method pointer for compiler */
212 lda v0,16(sp) /* pass pointer to method pointer via v0*/
214 mov a1,a0 /* pass the remaining parameters */
219 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
220 stq $28,8(sp) /* store function address */
221 mov sp,$28 /* set method pointer */
223 ldq pv,8($28) /* method call as in Java */
224 jmp ra,(pv) /* call JIT compiler */
226 lda pv,-64(ra) /* asm_calljavamethod-calljava_jit !!!!!*/
230 ldq ra,0(sp) /* restore return address */
231 ldq gp,24(sp) /* restore global pointer */
232 lda sp,32(sp) /* free stack space */
233 ldl v0,newcompiler /* load newcompiler flag */
234 subq v0,1,v0 /* negate for clearing v0 */
235 beq v0,calljava_ret /* if newcompiler skip ex copying */
236 mov $1,v0 /* pass exception to caller (C) */
242 ldq gp,24(sp) /* restore global pointer */
244 jsr ra,builtin_throw_exception
245 ldq ra,0(sp) /* restore return address */
246 lda sp,32(sp) /* free stack space */
248 .end asm_calljavamethod
251 /********************* function asm_calljavafunction ***************************
253 * This function calls a Java-method (which possibly needs compilation) *
254 * with up to 4 address parameters. *
256 * This functions calls the JIT-compiler which eventually translates the *
257 * method into machine code. *
260 * javaobject_header *asm_calljavamethod (methodinfo *m, *
261 * void *arg1, void *arg2, void *arg3, void *arg4); *
263 *******************************************************************************/
265 .ent asm_calljavafunction
268 .ascii "calljavafunction\0\0"
271 .quad 0 /* catch type all */
272 .quad calljava_xhandler2 /* handler pc */
273 .quad calljava_xhandler2 /* end pc */
274 .quad asm_calljavafunction /* start pc */
275 .long 1 /* extable size */
276 .long 0 /* fltsave */
277 .long 0 /* intsave */
280 .long 32 /* frame size */
281 .quad 0 /* method pointer (pointer to name) */
283 asm_calljavafunction:
288 lda sp,-32(sp) /* allocate stack space */
289 stq gp,24(sp) /* save global pointer */
290 stq ra,0(sp) /* save return address */
293 stq a0,16(sp) /* save method pointer for compiler */
294 lda v0,16(sp) /* pass pointer to method pointer via v0*/
296 mov a1,a0 /* pass the remaining parameters */
301 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
302 stq $28,8(sp) /* store function address */
303 mov sp,$28 /* set method pointer */
305 ldq pv,8($28) /* method call as in Java */
306 jmp ra,(pv) /* call JIT compiler */
308 lda pv,-64(ra) /* asm_calljavafunction-calljava_jit !!!!!*/
312 ldq ra,0(sp) /* restore return address */
313 ldq gp,24(sp) /* restore global pointer */
314 lda sp,32(sp) /* free stack space */
316 /* ldl v0,newcompiler */ /* load newcompiler flag */
317 /* subq v0,1,v0 */ /* negate for clearing v0 */
318 /* beq v0,calljava_ret*/ /* if newcompiler skip ex copying */
319 /* mov $1,v0 */ /* pass exception to caller (C) */
325 ldq gp,24(sp) /* restore global pointer */
327 jsr ra,builtin_throw_exception
328 ldq ra,0(sp) /* restore return address */
329 lda sp,32(sp) /* free stack space */
331 .end asm_calljavafunction
334 /****************** function asm_call_jit_compiler *****************************
336 * invokes the compiler for untranslated JavaVM methods. *
338 * Register R0 contains a pointer to the method info structure (prepared *
339 * by createcompilerstub). Using the return address in R26 and the *
340 * offset in the LDA instruction or using the value in methodptr R28 the *
341 * patching address for storing the method address can be computed: *
343 * method address was either loaded using *
344 * M_LDQ (REG_PV, REG_PV, a) ; invokestatic/special ($27) *
345 * M_LDA (REG_PV, REG_RA, low) *
346 * M_LDAH(REG_PV, REG_RA, high) ; optional *
348 * M_LDQ (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($28) *
349 * in the static case the method pointer can be computed using the *
350 * return address and the lda function following the jmp instruction *
352 *******************************************************************************/
355 .ent asm_call_jit_compiler
356 asm_call_jit_compiler:
360 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
361 srl t8,16,t8 /* shift right register number $yy */
362 and t8,31,t8 /* isolate register number */
363 subl t8,28,t8 /* test for REG_METHODPTR */
365 ldl t8,0(ra) /* load instruction LDA PV,xxx(RA) */
367 sra t8,48,t8 /* isolate offset */
368 addq t8,ra,$28 /* compute update address */
369 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
370 srl t8,16,t8 /* isolate instruction code */
371 lda t8,-0x177b(t8) /* test for LDAH */
373 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
374 sll t8,16,t8 /* compute high offset */
375 addl t8,0,t8 /* sign extend high offset */
376 addq t8,$28,$28 /* compute update address */
378 lda sp,-14*8(sp) /* reserve stack space */
379 stq a0,0*8(sp) /* save all argument registers */
380 stq a1,1*8(sp) /* they could be used by method */
391 stq $28,12*8(sp) /* save method pointer */
392 stq ra,13*8(sp) /* save return address */
394 ldq a0,0(v0) /* pass 'methodinfo' pointer to */
395 jsr ra,jit_compile /* jit compiler */
398 call_pal PAL_imb /* synchronise instruction cache */
400 ldq a0,0*8(sp) /* load argument registers */
412 ldq $28,12*8(sp) /* load method pointer */
413 ldq ra,13*8(sp) /* load return address */
414 lda sp,14*8(sp) /* deallocate stack area */
416 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
418 sra t8,48,t8 /* isolate offset */
420 addq t8,$28,t8 /* compute update address via method pointer*/
421 stq v0,0(t8) /* save new method address there */
423 mov v0,pv /* load method address into pv */
425 jmp zero,(pv) /* and call method. The method returns */
426 /* directly to the caller (ra). */
428 .end asm_call_jit_compiler
431 /****************** function asm_dumpregistersandcall **************************
433 * This funtion saves all callee saved registers and calls the function *
434 * which is passed as parameter. *
436 * This function is needed by the garbage collector, which needs to access *
437 * all registers which are stored on the stack. Unused registers are *
438 * cleared to avoid interferances with the GC. *
440 * void asm_dumpregistersandcall (functionptr f); *
442 *******************************************************************************/
444 .ent asm_dumpregistersandcall
445 asm_dumpregistersandcall:
446 lda sp,-16*8(sp) /* allocate stack */
447 stq ra,0(sp) /* save return address */
449 stq s0,1*8(sp) /* save all callee saved registers */
450 stq s1,2*8(sp) /* intialize the remaining registers */
465 clr v0 /* intialize the remaining registers */
510 mov a0,pv /* load function pointer */
511 jmp ra,(pv) /* and call function */
513 ldq ra,0(sp) /* load return address */
514 lda sp,16*8(sp) /* deallocate stack */
515 jmp zero,(ra) /* return */
517 .end asm_dumpregistersandcall
520 /********************* function asm_handle_exception ***************************
522 * This function handles an exception. It does not use the usual calling *
523 * conventions. The exception pointer is passed in REG_ITMP1 and the *
524 * pc from the exception raising position is passed in REG_ITMP2. It searches *
525 * the local exception table for a handler. If no one is found, it unwinds *
526 * stacks and continues searching the callers. *
528 * void asm_handle_exception (exceptionptr, exceptionpc); *
530 *******************************************************************************/
532 .ent asm_handle_nat_exception
533 asm_handle_nat_exception:
535 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
537 sra t0,48,t0 /* isolate offset */
538 addq t0,ra,pv /* compute update address */
539 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
540 srl t0,16,t0 /* isolate instruction code */
541 lda t0,-0x177b(t0) /* test for LDAH */
542 bne t0,asm_handle_exception
543 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
544 sll t0,16,t0 /* compute high offset */
545 addl t0,0,t0 /* sign extend high offset */
546 addq t0,pv,pv /* compute update address */
548 .aent asm_handle_exception
549 asm_handle_exception:
551 lda sp,-18*8(sp) /* allocate stack */
552 stq t0,0*8(sp) /* save possible used registers */
553 stq t1,1*8(sp) /* also registers used by trace_exception */
571 lda t3,1(zero) /* set no unwind flag */
573 lda sp,-5*8(sp) /* allocate stack */
574 stq xptr,0*8(sp) /* save used register */
581 ldq a1,MethodPointer(pv)
584 br ra,ex_trace /* set ra for gp loading */
586 ldgp gp,0(ra) /* load gp */
587 jsr ra,builtin_trace_exception /* trace_exception(xptr,methodptr) */
589 ldq xptr,0*8(sp) /* restore used register */
594 lda sp,5*8(sp) /* deallocate stack */
596 ldl t0,ExTableSize(pv) /* t0 = exception table size */
597 beq t0,empty_table /* if empty table skip */
598 lda t1,ExTableStart(pv) /* t1 = start of exception table */
601 ldq t2,ExStartPC(t1) /* t2 = exception start pc */
602 cmple t2,xpc,t2 /* t2 = (startpc <= xpc) */
603 beq t2,ex_table_cont /* if (false) continue */
604 ldq t2,ExEndPC(t1) /* t2 = exception end pc */
605 cmplt xpc,t2,t2 /* t2 = (xpc < endpc) */
606 beq t2,ex_table_cont /* if (false) continue */
607 ldq a1,ExCatchType(t1) /* arg1 = exception catch type */
608 beq a1,ex_handle_it /* NULL catches everything */
610 ldq a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
611 ldq a1,offobjvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
612 ldl a0,offbaseval(a0) /* a0 = baseval(xptr) */
613 ldl v0,offbaseval(a1) /* a2 = baseval(catchtype) */
614 ldl a1,offdiffval(a1) /* a1 = diffval(catchtype) */
615 subl a0,v0,a0 /* a0 = baseval(xptr) - baseval(catchtype) */
616 cmpule a0,a1,v0 /* v0 = xptr is instanceof catchtype */
617 beq v0,ex_table_cont /* if (false) continue */
621 ldq xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
623 beq t3,ex_jump /* if (!(no stack unwinding) skip */
625 ldq t0,0*8(sp) /* restore possible used registers */
626 ldq t1,1*8(sp) /* also registers used by trace_exception */
643 lda sp,18*8(sp) /* deallocate stack */
646 jmp zero,(xpc) /* jump to the handler */
649 lda t1,ExEntrySize(t1) /* next exception table entry */
650 subl t0,1,t0 /* decrement entry counter */
651 bgt t0,ex_table_loop /* if (t0 > 0) next entry */
654 beq t3,ex_already_cleared /* if here the first time, then */
655 lda sp,18*8(sp) /* deallocate stack and */
656 clr t3 /* clear the no unwind flag */
658 ldl t0,IsSync(pv) /* t0 = SyncOffset */
659 beq t0,no_monitor_exit /* if zero no monitorexit */
660 addq sp,t0,t0 /* add stackptr to Offset */
661 ldq a0,-8(t0) /* load monitorexit pointer */
663 lda sp,-7*8(sp) /* allocate stack */
664 stq t0,0*8(sp) /* save used register */
672 br ra,ex_mon_load /* set ra for gp loading */
674 ldgp gp,0(ra) /* load gp */
675 jsr ra,builtin_monitorexit/* builtin_monitorexit(objectptr) */
677 ldq t0,0*8(sp) /* restore used register */
684 lda sp,7*8(sp) /* deallocate stack */
687 ldl t0,FrameSize(pv) /* t0 = frame size */
688 addq sp,t0,sp /* unwind stack */
689 mov sp,t0 /* t0 = pointer to save area */
690 ldl t1,IsLeaf(pv) /* t1 = is leaf procedure */
691 bne t1,ex_no_restore /* if (leaf) skip */
692 ldq ra,-8(t0) /* restore ra */
693 lda t0,-8(t0) /* t0-- */
695 mov ra,xpc /* the new xpc is ra */
696 ldl t1,IntSave(pv) /* t1 = saved int register count */
697 br t2,ex_int1 /* t2 = current pc */
699 lda t2,44(t2) /* lda t2,ex_int2-ex_int1(t2) !!!!!!!!!!!!! */
700 negl t1,t1 /* negate register count */
701 s4addq t1,t2,t2 /* t2 = ex_int_sav - 4 * register count */
702 jmp zero,(t2) /* jump to save position */
711 s8addq t1,t0,t0 /* t0 = t0 - 8 * register count */
713 ldl t1,FltSave(pv) /* t1 = saved flt register count */
714 br t2,ex_flt1 /* t2 = current pc */
716 lda t2,48(t2) /* lda t2,ex_flt2-ex_flt1(t2) !!!!!!!!!!!!! */
717 negl t1,t1 /* negate register count */
718 s4addq t1,t2,t2 /* t2 = ex_flt_sav - 4 * register count */
719 jmp zero,(t2) /* jump to save position */
729 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
731 sra t0,48,t0 /* isolate offset */
732 addq t0,ra,pv /* compute update address */
733 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
734 srl t0,16,t0 /* isolate instruction code */
735 lda t0,-0x177b(t0) /* test for LDAH */
737 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
738 sll t0,16,t0 /* compute high offset */
739 addl t0,0,t0 /* sign extend high offset */
740 addq t0,pv,pv /* compute update address */
743 .end asm_handle_nat_exception
746 /********************* function asm_builtin_monitorenter ***********************
748 * Does null check and calls monitorenter or throws an exception *
750 *******************************************************************************/
752 .ent asm_builtin_monitorenter
753 asm_builtin_monitorenter:
756 lda pv,builtin_monitorenter
757 beq a0,nb_monitorenter /* if (null) throw exception */
758 jmp zero,(pv) /* else call builtin_monitorenter */
761 ldq xptr,proto_java_lang_NullPointerException
762 lda xpc,-4(ra) /* faulting address is return adress - 4*/
763 br asm_handle_nat_exception
764 .end asm_builtin_monitorenter
767 /********************* function asm_builtin_monitorexit ************************
769 * Does null check and calls monitorexit or throws an exception *
771 *******************************************************************************/
773 .ent asm_builtin_monitorexit
774 asm_builtin_monitorexit:
777 lda pv,builtin_monitorexit
778 beq a0,nb_monitorexit /* if (null) throw exception */
779 jmp zero,(pv) /* else call builtin_monitorexit */
782 ldq xptr,proto_java_lang_NullPointerException
783 lda xpc,-4(ra) /* faulting address is return adress - 4*/
784 br asm_handle_nat_exception
785 .end asm_builtin_monitorexit
788 /************************ function asm_builtin_idiv ****************************
790 * Does null check and calls idiv or throws an exception *
792 *******************************************************************************/
794 .ent asm_builtin_idiv
799 beq a1,nb_idiv /* if (null) throw exception */
800 jmp zero,(pv) /* else call builtin_idiv */
803 ldq xptr,proto_java_lang_ArithmeticException
804 lda xpc,-4(ra) /* faulting address is return adress - 4*/
805 br asm_handle_nat_exception
806 .end asm_builtin_idiv
809 /************************ function asm_builtin_ldiv ****************************
811 * Does null check and calls ldiv or throws an exception *
813 *******************************************************************************/
815 .ent asm_builtin_ldiv
820 beq a1,nb_ldiv /* if (null) throw exception */
821 jmp zero,(pv) /* else call builtin_ldiv */
824 ldq xptr,proto_java_lang_ArithmeticException
825 lda xpc,-4(ra) /* faulting address is return adress - 4*/
826 br asm_handle_nat_exception
827 .end asm_builtin_ldiv
830 /************************ function asm_builtin_irem ****************************
832 * Does null check and calls irem or throws an exception *
834 *******************************************************************************/
836 .ent asm_builtin_irem
841 beq a1,nb_irem /* if (null) throw exception */
842 jmp zero,(pv) /* else call builtin_irem */
845 ldq xptr,proto_java_lang_ArithmeticException
846 lda xpc,-4(ra) /* faulting address is return adress - 4*/
847 br asm_handle_nat_exception
848 .end asm_builtin_irem
851 /************************ function asm_builtin_lrem ****************************
853 * Does null check and calls lrem or throws an exception *
855 *******************************************************************************/
857 .ent asm_builtin_lrem
862 beq a1,nb_lrem /* if (null) throw exception */
863 jmp zero,(pv) /* else call builtin_lrem */
866 ldq xptr,proto_java_lang_ArithmeticException
867 lda xpc,-4(ra) /* faulting address is return adress - 4*/
868 br asm_handle_nat_exception
869 .end asm_builtin_lrem
872 /*********************** function new_builtin_checkcast ************************
874 * Does the cast check and eventually throws an exception *
876 *******************************************************************************/
878 .ent asm_builtin_checkcast
879 asm_builtin_checkcast:
882 lda sp,-16(sp) # allocate stack space
883 stq ra,0(sp) # save return address
884 stq a0,8(sp) # save object pointer
885 jsr ra,builtin_checkcast # builtin_checkcast
887 beq v0,nb_ccast_throw # if (false) throw exception
888 ldq ra,0(sp) # restore return address
889 ldq v0,8(sp) # return object pointer
890 lda sp,16(sp) # free stack space
894 ldq xptr,proto_java_lang_ClassCastException
895 ldq ra,0(sp) # restore return address
896 lda sp,16(sp) # free stack space
897 lda xpc,-4(ra) # faulting address is return adress - 4
898 br asm_handle_nat_exception
899 .end asm_builtin_checkcast
902 /******************* function asm_builtin_checkarraycast ***********************
904 * Does the cast check and eventually throws an exception *
906 *******************************************************************************/
908 .ent asm_builtin_checkarraycast
909 asm_builtin_checkarraycast:
912 lda sp,-16(sp) /* allocate stack space */
913 stq ra,0(sp) /* save return address */
914 stq a0,8(sp) /* save object pointer */
915 jsr ra,builtin_checkarraycast /* builtin_checkarraycast */
917 beq v0,nb_carray_throw /* if (false) throw exception */
918 ldq ra,0(sp) /* restore return address */
919 ldq v0,8(sp) /* return object pointer */
920 lda sp,16(sp) /* free stack space */
924 ldq xptr,proto_java_lang_ClassCastException
925 ldq ra,0(sp) /* restore return address */
926 lda sp,16(sp) /* free stack space */
927 lda xpc,-4(ra) /* faulting address is return adress - 4*/
928 br asm_handle_nat_exception
929 .end asm_builtin_checkarraycast
932 /******************* function asm_builtin_aastore ******************************
934 * Does the cast check and eventually throws an exception *
936 *******************************************************************************/
938 .ent asm_builtin_aastore
942 beq a0,nb_aastore_null /* if null pointer throw exception */
943 ldl t0,offarraysize(a0) /* load size */
944 lda sp,-24(sp) /* allocate stack space */
945 stq ra,0(sp) /* save return address */
946 s8addq a1,a0,t1 /* add index*8 to arrayref */
947 cmpult a1,t0,t0 /* do bound check */
948 beq t0,nb_aastore_bound /* if out of bounds throw exception */
949 mov a2,a1 /* object is second argument */
950 stq t1,8(sp) /* save store position */
951 stq a1,16(sp) /* save object */
952 jsr ra,builtin_canstore /* builtin_canstore(arrayref,object) */
954 ldq ra,0(sp) /* restore return address */
955 ldq a0,8(sp) /* restore store position */
956 ldq a1,16(sp) /* restore object */
957 lda sp,24(sp) /* free stack space */
958 beq v0,nb_aastore_throw /* if (false) throw exception */
959 stq a1,offobjarrdata(a0) /* store objectptr in array */
963 ldq xptr,proto_java_lang_NullPointerException
964 mov ra,xpc /* faulting address is return adress */
965 br asm_handle_nat_exception
968 ldq xptr,proto_java_lang_ArrayIndexOutOfBoundsException
969 lda sp,24(sp) /* free stack space */
970 mov ra,xpc /* faulting address is return adress */
971 br asm_handle_nat_exception
974 ldq xptr,proto_java_lang_ArrayStoreException
975 mov ra,xpc /* faulting address is return adress */
976 br asm_handle_nat_exception
978 .end asm_builtin_aastore
981 /******************* function asm_initialize_thread_stack **********************
983 * initialized a thread stack *
985 *******************************************************************************/
987 .ent asm_initialize_thread_stack
988 asm_initialize_thread_stack:
1009 .end asm_initialize_thread_stack
1012 /******************* function asm_perform_threadswitch *************************
1014 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1016 * performs a threadswitch *
1018 *******************************************************************************/
1020 .ent asm_perform_threadswitch
1021 asm_perform_threadswitch:
1062 .end asm_perform_threadswitch
1065 /********************* function asm_switchstackandcall *************************
1067 * void *asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
1070 * Switches to a new stack, calls a function and switches back. *
1071 * a0 new stack pointer *
1072 * a1 function pointer *
1073 * a2 pointer to variable where stack top should be stored *
1074 * a3 pointer to user data, is passed to the function *
1076 *******************************************************************************/
1079 .ent asm_switchstackandcall
1080 asm_switchstackandcall:
1081 lda a0,-2*8(a0) /* allocate new stack */
1082 stq ra,0(a0) /* save return address on new stack */
1083 stq sp,1*8(a0) /* save old stack pointer on new stack */
1084 stq sp,0(a2) /* save old stack pointer to variable */
1085 mov a0,sp /* switch to new stack */
1087 mov a1,pv /* load function pointer */
1088 mov a3,a0 /* pass pointer */
1089 jmp ra,(pv) /* and call function */
1091 ldq ra,0(sp) /* load return address */
1092 ldq sp,1*8(sp) /* switch to old stack */
1094 jmp zero,(ra) /* return */
1096 .end asm_switchstackandcall
1099 /********************* function asm_getcallingmethod ***************************
1101 * classinfo *asm_getcallingmethodclass (); *
1103 * goes back stack frames to get the calling method *
1109 *******************************************************************************/
1112 .ent asm_getcallingmethod
1113 asm_getcallingmethod:
1115 ldq t3,16(sp) /* load return address of native function */
1116 addq sp,24,t2 /* skip frames of C-Function and nativestub */
1118 /* determine pv (t3) of java-function from ra */
1120 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1122 sra t0,48,t0 /* isolate offset */
1123 addq t0,t3,t4 /* compute update address */
1124 ldl t0,4(t3) /* load instruction LDAH PV,xxx(PV) */
1125 srl t0,16,t0 /* isolate instruction code */
1126 lda t0,-0x177b(t0) /* test for LDAH */
1128 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1129 sll t0,16,t0 /* compute high offset */
1130 addl t0,0,t0 /* sign extend high offset */
1131 addq t0,t4,t4 /* compute update address */
1134 ldl t0,FrameSize(t4) /* t0 = frame size */
1135 addq t2,t0,t2 /* skip frame of java function */
1136 ldq t3,-8(t2) /* load new ra */
1138 /* determine pv (t3) of java-function from ra */
1140 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1142 sra t0,48,t0 /* isolate offset */
1143 addq t0,t3,t4 /* compute update address */
1144 ldl t0,4(t3) /* load instruction LDAH PV,xxx(PV) */
1145 srl t0,16,t0 /* isolate instruction code */
1146 lda t0,-0x177b(t0) /* test for LDAH */
1148 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1149 sll t0,16,t0 /* compute high offset */
1150 addl t0,0,t0 /* sign extend high offset */
1151 addq t0,t4,t4 /* compute update address */
1154 ldq v0,MethodPointer(t4) /* */
1157 jmp zero,(ra) /* return */
1159 .end asm_getcallingmethod