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: Andreas Krall EMAIL: cacao@complang.tuwien.ac.at *
12 * Reinhard Grafl EMAIL: cacao@complang.tuwien.ac.at *
14 * Last Change: 1998/11/01 *
16 *******************************************************************************/
85 /********************* exported functions and variables ***********************/
87 .globl has_no_x_instr_set
88 .globl synchronize_caches
89 .globl asm_calljavamethod
90 .globl asm_calljavafunction
91 .globl asm_call_jit_compiler
92 .globl asm_dumpregistersandcall
93 .globl asm_handle_exception
94 .globl asm_handle_nat_exception
95 .globl asm_builtin_checkcast
96 .globl asm_builtin_checkarraycast
97 .globl asm_builtin_aastore
98 .globl asm_builtin_monitorenter
99 .globl asm_builtin_monitorexit
100 .globl asm_builtin_idiv
101 .globl asm_builtin_irem
102 .globl asm_builtin_ldiv
103 .globl asm_builtin_lrem
104 .globl asm_perform_threadswitch
105 .globl asm_initialize_thread_stack
106 .globl asm_switchstackandcall
107 .globl asm_getcallingmethod
109 /*************************** imported variables *******************************/
114 /*************************** imported functions *******************************/
117 .globl builtin_monitorexit
118 .globl builtin_throw_exception
119 .globl builtin_trace_exception
120 .globl class_java_lang_Object
123 /*********************** function has_no_x_instr_set ***************************
125 * determines if the byte support instruction set (21164a and higher) *
128 *******************************************************************************/
130 .ent has_no_x_instr_set
133 .long 0x47e03c20 /* amask 1,v0 */
134 jmp zero,(ra) /* return */
136 .end has_no_x_instr_set
139 /********************* function synchronize_caches ****************************/
141 .ent synchronize_caches
144 call_pal PAL_imb /* synchronise instruction cache */
145 jmp zero,(ra) /* return */
147 .end synchronize_caches
150 /********************* function asm_calljavamethod *****************************
152 * This function calls a Java-method (which possibly needs compilation) *
153 * with up to 4 parameters. *
155 * This functions calls the JIT-compiler which eventually translates the *
156 * method into machine code. *
158 * An possibly throwed exception will be returned to the caller as function *
159 * return value, so the java method cannot return a fucntion value (this *
160 * function usually calls 'main' and '<clinit>' which do not return a *
164 * javaobject_header *asm_calljavamethod (methodinfo *m, *
165 * void *arg1, void *arg2, void *arg3, void *arg4); *
167 *******************************************************************************/
169 #define MethodPointer -8
170 #define FrameSize -12
175 #define ExTableSize -32
176 #define ExTableStart -32
178 #define ExEntrySize -32
181 #define ExHandlerPC -24
182 #define ExCatchType -32
184 .ent asm_calljavamethod
187 .ascii "calljavamethod\0\0"
190 .quad 0 /* catch type all */
191 .quad calljava_xhandler /* handler pc */
192 .quad calljava_xhandler /* end pc */
193 .quad asm_calljavamethod /* start pc */
194 .long 1 /* extable size */
195 .long 0 /* fltsave */
196 .long 0 /* intsave */
199 .long 32 /* frame size */
200 .quad 0 /* method pointer (pointer to name) */
205 lda sp,-32(sp) /* allocate stack space */
206 stq gp,24(sp) /* save global pointer */
207 stq ra,0(sp) /* save return address */
209 stq a0,16(sp) /* save method pointer for compiler */
210 lda v0,16(sp) /* pass pointer to method pointer via v0*/
212 mov a1,a0 /* pass the remaining parameters */
217 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
218 stq $28,8(sp) /* store function address */
219 mov sp,$28 /* set method pointer */
221 ldq pv,8($28) /* method call as in Java */
222 jmp ra,(pv) /* call JIT compiler */
224 lda pv,-64(ra) /* asm_calljavamethod-calljava_jit !!!!!*/
228 ldq ra,0(sp) /* restore return address */
229 ldq gp,24(sp) /* restore global pointer */
230 lda sp,32(sp) /* free stack space */
231 ldl v0,newcompiler /* load newcompiler flag */
232 subq v0,1,v0 /* negate for clearing v0 */
233 beq v0,calljava_ret /* if newcompiler skip ex copying */
234 mov $1,v0 /* pass exception to caller (C) */
240 ldq gp,24(sp) /* restore global pointer */
242 jsr ra,builtin_throw_exception
243 ldq ra,0(sp) /* restore return address */
244 lda sp,32(sp) /* free stack space */
246 .end asm_calljavamethod
249 /********************* function asm_calljavafunction ***************************
251 * This function calls a Java-method (which possibly needs compilation) *
252 * with up to 4 address parameters. *
254 * This functions calls the JIT-compiler which eventually translates the *
255 * method into machine code. *
258 * javaobject_header *asm_calljavamethod (methodinfo *m, *
259 * void *arg1, void *arg2, void *arg3, void *arg4); *
261 *******************************************************************************/
263 .ent asm_calljavafunction
266 .ascii "calljavafunction\0\0"
269 .quad 0 /* catch type all */
270 .quad calljava_xhandler2 /* handler pc */
271 .quad calljava_xhandler2 /* end pc */
272 .quad asm_calljavafunction /* start pc */
273 .long 1 /* extable size */
274 .long 0 /* fltsave */
275 .long 0 /* intsave */
278 .long 32 /* frame size */
279 .quad 0 /* method pointer (pointer to name) */
281 asm_calljavafunction:
284 lda sp,-32(sp) /* allocate stack space */
285 stq gp,24(sp) /* save global pointer */
286 stq ra,0(sp) /* save return address */
288 stq a0,16(sp) /* save method pointer for compiler */
289 lda v0,16(sp) /* pass pointer to method pointer via v0*/
291 mov a1,a0 /* pass the remaining parameters */
296 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
297 stq $28,8(sp) /* store function address */
298 mov sp,$28 /* set method pointer */
300 ldq pv,8($28) /* method call as in Java */
301 jmp ra,(pv) /* call JIT compiler */
303 lda pv,-64(ra) /* asm_calljavafunction-calljava_jit !!!!!*/
307 ldq ra,0(sp) /* restore return address */
308 ldq gp,24(sp) /* restore global pointer */
309 lda sp,32(sp) /* free stack space */
311 /* ldl v0,newcompiler */ /* load newcompiler flag */
312 /* subq v0,1,v0 */ /* negate for clearing v0 */
313 /* beq v0,calljava_ret*/ /* if newcompiler skip ex copying */
314 /* mov $1,v0 */ /* pass exception to caller (C) */
320 ldq gp,24(sp) /* restore global pointer */
322 jsr ra,builtin_throw_exception
323 ldq ra,0(sp) /* restore return address */
324 lda sp,32(sp) /* free stack space */
326 .end asm_calljavafunction
329 /****************** function asm_call_jit_compiler *****************************
331 * invokes the compiler for untranslated JavaVM methods. *
333 * Register R0 contains a pointer to the method info structure (prepared *
334 * by createcompilerstub). Using the return address in R26 and the *
335 * offset in the LDA instruction or using the value in methodptr R28 the *
336 * patching address for storing the method address can be computed: *
338 * method address was either loaded using *
339 * M_LDQ (REG_PV, REG_PV, a) ; invokestatic/special ($27) *
340 * M_LDA (REG_PV, REG_RA, low) *
341 * M_LDAH(REG_PV, REG_RA, high) ; optional *
343 * M_LDQ (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($28) *
344 * in the static case the method pointer can be computed using the *
345 * return address and the lda function following the jmp instruction *
347 *******************************************************************************/
350 .ent asm_call_jit_compiler
351 asm_call_jit_compiler:
354 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
355 srl t8,16,t8 /* shift right register number $yy */
356 and t8,31,t8 /* isolate register number */
357 subl t8,28,t8 /* test for REG_METHODPTR */
359 ldl t8,0(ra) /* load instruction LDA PV,xxx(RA) */
361 sra t8,48,t8 /* isolate offset */
362 addq t8,ra,$28 /* compute update address */
363 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
364 srl t8,16,t8 /* isolate instruction code */
365 lda t8,-0x177b(t8) /* test for LDAH */
367 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
368 sll t8,16,t8 /* compute high offset */
369 addl t8,0,t8 /* sign extend high offset */
370 addq t8,$28,$28 /* compute update address */
372 lda sp,-14*8(sp) /* reserve stack space */
373 stq a0,0*8(sp) /* save all argument registers */
374 stq a1,1*8(sp) /* they could be used by method */
385 stq $28,12*8(sp) /* save method pointer */
386 stq ra,13*8(sp) /* save return address */
388 ldq a0,0(v0) /* pass 'methodinfo' pointer to */
389 jsr ra,jit_compile /* jit compiler */
392 call_pal PAL_imb /* synchronise instruction cache */
394 ldq a0,0*8(sp) /* load argument registers */
406 ldq $28,12*8(sp) /* load method pointer */
407 ldq ra,13*8(sp) /* load return address */
408 lda sp,14*8(sp) /* deallocate stack area */
410 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
412 sra t8,48,t8 /* isolate offset */
414 addq t8,$28,t8 /* compute update address via method pointer*/
415 stq v0,0(t8) /* save new method address there */
417 mov v0,pv /* load method address into pv */
419 jmp zero,(pv) /* and call method. The method returns */
420 /* directly to the caller (ra). */
422 .end asm_call_jit_compiler
425 /****************** function asm_dumpregistersandcall **************************
427 * This funtion saves all callee saved registers and calls the function *
428 * which is passed as parameter. *
430 * This function is needed by the garbage collector, which needs to access *
431 * all registers which are stored on the stack. Unused registers are *
432 * cleared to avoid interferances with the GC. *
434 * void asm_dumpregistersandcall (functionptr f); *
436 *******************************************************************************/
438 .ent asm_dumpregistersandcall
439 asm_dumpregistersandcall:
440 lda sp,-16*8(sp) /* allocate stack */
441 stq ra,0(sp) /* save return address */
443 stq s0,1*8(sp) /* save all callee saved registers */
444 stq s1,2*8(sp) /* intialize the remaining registers */
459 clr v0 /* intialize the remaining registers */
504 mov a0,pv /* load function pointer */
505 jmp ra,(pv) /* and call function */
507 ldq ra,0(sp) /* load return address */
508 lda sp,16*8(sp) /* deallocate stack */
509 jmp zero,(ra) /* return */
511 .end asm_dumpregistersandcall
514 /********************* function asm_handle_exception ***************************
516 * This function handles an exception. It does not use the usual calling *
517 * conventions. The exception pointer is passed in REG_ITMP1 and the *
518 * pc from the exception raising position is passed in REG_ITMP2. It searches *
519 * the local exception table for a handler. If no one is found, it unwinds *
520 * stacks and continues searching the callers. *
522 * void asm_handle_exception (exceptionptr, exceptionpc); *
524 *******************************************************************************/
526 .ent asm_handle_nat_exception
527 asm_handle_nat_exception:
529 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
531 sra t0,48,t0 /* isolate offset */
532 addq t0,ra,pv /* compute update address */
533 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
534 srl t0,16,t0 /* isolate instruction code */
535 lda t0,-0x177b(t0) /* test for LDAH */
536 bne t0,asm_handle_exception
537 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
538 sll t0,16,t0 /* compute high offset */
539 addl t0,0,t0 /* sign extend high offset */
540 addq t0,pv,pv /* compute update address */
542 .aent asm_handle_exception
543 asm_handle_exception:
545 lda sp,-18*8(sp) /* allocate stack */
546 stq t0,0*8(sp) /* save possible used registers */
547 stq t1,1*8(sp) /* also registers used by trace_exception */
565 lda t3,1(zero) /* set no unwind flag */
567 lda sp,-5*8(sp) /* allocate stack */
568 stq xptr,0*8(sp) /* save used register */
575 ldq a1,MethodPointer(pv)
578 br ra,ex_trace /* set ra for gp loading */
580 ldgp gp,0(ra) /* load gp */
581 jsr ra,builtin_trace_exception /* trace_exception(xptr,methodptr) */
583 ldq xptr,0*8(sp) /* restore used register */
588 lda sp,5*8(sp) /* deallocate stack */
590 ldl t0,ExTableSize(pv) /* t0 = exception table size */
591 beq t0,empty_table /* if empty table skip */
592 lda t1,ExTableStart(pv) /* t1 = start of exception table */
595 ldq t2,ExStartPC(t1) /* t2 = exception start pc */
596 cmple t2,xpc,t2 /* t2 = (startpc <= xpc) */
597 beq t2,ex_table_cont /* if (false) continue */
598 ldq t2,ExEndPC(t1) /* t2 = exception end pc */
599 cmplt xpc,t2,t2 /* t2 = (xpc < endpc) */
600 beq t2,ex_table_cont /* if (false) continue */
601 ldq a1,ExCatchType(t1) /* arg1 = exception catch type */
602 beq a1,ex_handle_it /* NULL catches everything */
604 ldq a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
605 ldq a1,offobjvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
606 ldl a0,offbaseval(a0) /* a0 = baseval(xptr) */
607 ldl v0,offbaseval(a1) /* a2 = baseval(catchtype) */
608 ldl a1,offdiffval(a1) /* a1 = diffval(catchtype) */
609 subl a0,v0,a0 /* a0 = baseval(xptr) - baseval(catchtype) */
610 cmpule a0,a1,v0 /* v0 = xptr is instanceof catchtype */
611 beq v0,ex_table_cont /* if (false) continue */
615 ldq xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
617 beq t3,ex_jump /* if (!(no stack unwinding) skip */
619 ldq t0,0*8(sp) /* restore possible used registers */
620 ldq t1,1*8(sp) /* also registers used by trace_exception */
637 lda sp,18*8(sp) /* deallocate stack */
640 jmp zero,(xpc) /* jump to the handler */
643 lda t1,ExEntrySize(t1) /* next exception table entry */
644 subl t0,1,t0 /* decrement entry counter */
645 bgt t0,ex_table_loop /* if (t0 > 0) next entry */
648 beq t3,ex_already_cleared /* if here the first time, then */
649 lda sp,18*8(sp) /* deallocate stack and */
650 clr t3 /* clear the no unwind flag */
652 ldl t0,IsSync(pv) /* t0 = SyncOffset */
653 beq t0,no_monitor_exit /* if zero no monitorexit */
654 addq sp,t0,t0 /* add stackptr to Offset */
655 ldq a0,-8(t0) /* load monitorexit pointer */
657 lda sp,-7*8(sp) /* allocate stack */
658 stq t0,0*8(sp) /* save used register */
666 br ra,ex_mon_load /* set ra for gp loading */
668 ldgp gp,0(ra) /* load gp */
669 jsr ra,builtin_monitorexit/* builtin_monitorexit(objectptr) */
671 ldq t0,0*8(sp) /* restore used register */
678 lda sp,7*8(sp) /* deallocate stack */
681 ldl t0,FrameSize(pv) /* t0 = frame size */
682 addq sp,t0,sp /* unwind stack */
683 mov sp,t0 /* t0 = pointer to save area */
684 ldl t1,IsLeaf(pv) /* t1 = is leaf procedure */
685 bne t1,ex_no_restore /* if (leaf) skip */
686 ldq ra,-8(t0) /* restore ra */
687 lda t0,-8(t0) /* t0-- */
689 mov ra,xpc /* the new xpc is ra */
690 ldl t1,IntSave(pv) /* t1 = saved int register count */
691 br t2,ex_int1 /* t2 = current pc */
693 lda t2,44(t2) /* lda t2,ex_int2-ex_int1(t2) !!!!!!!!!!!!! */
694 negl t1,t1 /* negate register count */
695 s4addq t1,t2,t2 /* t2 = ex_int_sav - 4 * register count */
696 jmp zero,(t2) /* jump to save position */
705 s8addq t1,t0,t0 /* t0 = t0 - 8 * register count */
707 ldl t1,FltSave(pv) /* t1 = saved flt register count */
708 br t2,ex_flt1 /* t2 = current pc */
710 lda t2,48(t2) /* lda t2,ex_flt2-ex_flt1(t2) !!!!!!!!!!!!! */
711 negl t1,t1 /* negate register count */
712 s4addq t1,t2,t2 /* t2 = ex_flt_sav - 4 * register count */
713 jmp zero,(t2) /* jump to save position */
723 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
725 sra t0,48,t0 /* isolate offset */
726 addq t0,ra,pv /* compute update address */
727 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
728 srl t0,16,t0 /* isolate instruction code */
729 lda t0,-0x177b(t0) /* test for LDAH */
731 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
732 sll t0,16,t0 /* compute high offset */
733 addl t0,0,t0 /* sign extend high offset */
734 addq t0,pv,pv /* compute update address */
737 .end asm_handle_nat_exception
740 /********************* function asm_builtin_monitorenter ***********************
742 * Does null check and calls monitorenter or throws an exception *
744 *******************************************************************************/
746 .ent asm_builtin_monitorenter
747 asm_builtin_monitorenter:
750 lda pv,builtin_monitorenter
751 beq a0,nb_monitorenter /* if (null) throw exception */
752 jmp zero,(pv) /* else call builtin_monitorenter */
755 ldq xptr,proto_java_lang_NullPointerException
756 lda xpc,-4(ra) /* faulting address is return adress - 4*/
757 br asm_handle_nat_exception
758 .end asm_builtin_monitorenter
761 /********************* function asm_builtin_monitorexit ************************
763 * Does null check and calls monitorexit or throws an exception *
765 *******************************************************************************/
767 .ent asm_builtin_monitorexit
768 asm_builtin_monitorexit:
771 lda pv,builtin_monitorexit
772 beq a0,nb_monitorexit /* if (null) throw exception */
773 jmp zero,(pv) /* else call builtin_monitorexit */
776 ldq xptr,proto_java_lang_NullPointerException
777 lda xpc,-4(ra) /* faulting address is return adress - 4*/
778 br asm_handle_nat_exception
779 .end asm_builtin_monitorexit
782 /************************ function asm_builtin_idiv ****************************
784 * Does null check and calls idiv or throws an exception *
786 *******************************************************************************/
788 .ent asm_builtin_idiv
793 beq a1,nb_idiv /* if (null) throw exception */
794 jmp zero,(pv) /* else call builtin_idiv */
797 ldq xptr,proto_java_lang_ArithmeticException
798 lda xpc,-4(ra) /* faulting address is return adress - 4*/
799 br asm_handle_nat_exception
800 .end asm_builtin_idiv
803 /************************ function asm_builtin_ldiv ****************************
805 * Does null check and calls ldiv or throws an exception *
807 *******************************************************************************/
809 .ent asm_builtin_ldiv
814 beq a1,nb_ldiv /* if (null) throw exception */
815 jmp zero,(pv) /* else call builtin_ldiv */
818 ldq xptr,proto_java_lang_ArithmeticException
819 lda xpc,-4(ra) /* faulting address is return adress - 4*/
820 br asm_handle_nat_exception
821 .end asm_builtin_ldiv
824 /************************ function asm_builtin_irem ****************************
826 * Does null check and calls irem or throws an exception *
828 *******************************************************************************/
830 .ent asm_builtin_irem
835 beq a1,nb_irem /* if (null) throw exception */
836 jmp zero,(pv) /* else call builtin_irem */
839 ldq xptr,proto_java_lang_ArithmeticException
840 lda xpc,-4(ra) /* faulting address is return adress - 4*/
841 br asm_handle_nat_exception
842 .end asm_builtin_irem
845 /************************ function asm_builtin_lrem ****************************
847 * Does null check and calls lrem or throws an exception *
849 *******************************************************************************/
851 .ent asm_builtin_lrem
856 beq a1,nb_lrem /* if (null) throw exception */
857 jmp zero,(pv) /* else call builtin_lrem */
860 ldq xptr,proto_java_lang_ArithmeticException
861 lda xpc,-4(ra) /* faulting address is return adress - 4*/
862 br asm_handle_nat_exception
863 .end asm_builtin_lrem
866 /*********************** function new_builtin_checkcast ************************
868 * Does the cast check and eventually throws an exception *
870 *******************************************************************************/
872 .ent asm_builtin_checkcast
873 asm_builtin_checkcast:
876 lda sp,-16(sp) # allocate stack space
877 stq ra,0(sp) # save return address
878 stq a0,8(sp) # save object pointer
879 jsr ra,builtin_checkcast # builtin_checkcast
881 beq v0,nb_ccast_throw # if (false) throw exception
882 ldq ra,0(sp) # restore return address
883 ldq v0,8(sp) # return object pointer
884 lda sp,16(sp) # free stack space
888 ldq xptr,proto_java_lang_ClassCastException
889 ldq ra,0(sp) # restore return address
890 lda sp,16(sp) # free stack space
891 lda xpc,-4(ra) # faulting address is return adress - 4
892 br asm_handle_nat_exception
893 .end asm_builtin_checkcast
896 /******************* function asm_builtin_checkarraycast ***********************
898 * Does the cast check and eventually throws an exception *
900 *******************************************************************************/
902 .ent asm_builtin_checkarraycast
903 asm_builtin_checkarraycast:
906 lda sp,-16(sp) /* allocate stack space */
907 stq ra,0(sp) /* save return address */
908 stq a0,8(sp) /* save object pointer */
909 jsr ra,builtin_checkarraycast /* builtin_checkarraycast */
911 beq v0,nb_carray_throw /* if (false) throw exception */
912 ldq ra,0(sp) /* restore return address */
913 ldq v0,8(sp) /* return object pointer */
914 lda sp,16(sp) /* free stack space */
918 ldq xptr,proto_java_lang_ClassCastException
919 ldq ra,0(sp) /* restore return address */
920 lda sp,16(sp) /* free stack space */
921 lda xpc,-4(ra) /* faulting address is return adress - 4*/
922 br asm_handle_nat_exception
923 .end asm_builtin_checkarraycast
926 /******************* function asm_builtin_aastore ******************************
928 * Does the cast check and eventually throws an exception *
930 *******************************************************************************/
932 .ent asm_builtin_aastore
936 beq a0,nb_aastore_null /* if null pointer throw exception */
937 ldl t0,offarraysize(a0) /* load size */
938 lda sp,-24(sp) /* allocate stack space */
939 stq ra,0(sp) /* save return address */
940 s8addq a1,a0,t1 /* add index*8 to arrayref */
941 cmpult a1,t0,t0 /* do bound check */
942 beq t0,nb_aastore_bound /* if out of bounds throw exception */
943 mov a2,a1 /* object is second argument */
944 stq t1,8(sp) /* save store position */
945 stq a1,16(sp) /* save object */
946 jsr ra,builtin_canstore /* builtin_canstore(arrayref,object) */
948 ldq ra,0(sp) /* restore return address */
949 ldq a0,8(sp) /* restore store position */
950 ldq a1,16(sp) /* restore object */
951 lda sp,24(sp) /* free stack space */
952 beq v0,nb_aastore_throw /* if (false) throw exception */
953 stq a1,offobjarrdata(a0) /* store objectptr in array */
957 ldq xptr,proto_java_lang_NullPointerException
958 mov ra,xpc /* faulting address is return adress */
959 br asm_handle_nat_exception
962 ldq xptr,proto_java_lang_ArrayIndexOutOfBoundsException
963 lda sp,24(sp) /* free stack space */
964 mov ra,xpc /* faulting address is return adress */
965 br asm_handle_nat_exception
968 ldq xptr,proto_java_lang_ArrayStoreException
969 mov ra,xpc /* faulting address is return adress */
970 br asm_handle_nat_exception
972 .end asm_builtin_aastore
975 /******************* function asm_initialize_thread_stack **********************
977 * initialized a thread stack *
979 *******************************************************************************/
981 .ent asm_initialize_thread_stack
982 asm_initialize_thread_stack:
1003 .end asm_initialize_thread_stack
1006 /******************* function asm_perform_threadswitch *************************
1008 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1010 * performs a threadswitch *
1012 *******************************************************************************/
1014 .ent asm_perform_threadswitch
1015 asm_perform_threadswitch:
1056 .end asm_perform_threadswitch
1059 /********************* function asm_switchstackandcall *************************
1061 * void asm_switchstackandcall (void *stack, void *func, void **stacktopsave); *
1063 * Switches to a new stack, calls a function and switches back. *
1064 * a0 new stack pointer *
1065 * a1 function pointer *
1066 * a2 pointer to variable where stack top should be stored *
1068 *******************************************************************************/
1071 .ent asm_switchstackandcall
1072 asm_switchstackandcall:
1073 lda a0,-2*8(a0) /* allocate new stack */
1074 stq ra,0(a0) /* save return address on new stack */
1075 stq sp,1*8(a0) /* save old stack pointer on new stack */
1076 stq sp,0(a2) /* save old stack pointer to variable */
1077 mov a0,sp /* switch to new stack */
1079 mov a1,pv /* load function pointer */
1080 jmp ra,(pv) /* and call function */
1082 ldq ra,0(sp) /* load return address */
1083 ldq sp,1*8(sp) /* switch to old stack */
1085 jmp zero,(ra) /* return */
1087 .end asm_switchstackandcall
1090 /********************* function asm_getcallingmethod ***************************
1092 * classinfo *asm_getcallingmethodclass (); *
1094 * goes back stack frames to get the calling method *
1100 *******************************************************************************/
1103 .ent asm_getcallingmethod
1104 asm_getcallingmethod:
1106 ldq t3,16(sp) /* load return address of native function */
1107 addq sp,24,t2 /* skip frames of C-Function and nativestub */
1109 /* determine pv (t3) of java-function from ra */
1111 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1113 sra t0,48,t0 /* isolate offset */
1114 addq t0,t3,t4 /* compute update address */
1115 ldl t0,4(t3) /* load instruction LDAH PV,xxx(PV) */
1116 srl t0,16,t0 /* isolate instruction code */
1117 lda t0,-0x177b(t0) /* test for LDAH */
1119 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1120 sll t0,16,t0 /* compute high offset */
1121 addl t0,0,t0 /* sign extend high offset */
1122 addq t0,t4,t4 /* compute update address */
1125 ldl t0,FrameSize(t4) /* t0 = frame size */
1126 addq t2,t0,t2 /* skip frame of java function */
1127 ldq t3,-8(t2) /* load new ra */
1129 /* determine pv (t3) of java-function from ra */
1131 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1133 sra t0,48,t0 /* isolate offset */
1134 addq t0,t3,t4 /* compute update address */
1135 ldl t0,4(t3) /* load instruction LDAH PV,xxx(PV) */
1136 srl t0,16,t0 /* isolate instruction code */
1137 lda t0,-0x177b(t0) /* test for LDAH */
1139 ldl t0,0(t3) /* load instruction LDA PV,xxx(RA) */
1140 sll t0,16,t0 /* compute high offset */
1141 addl t0,0,t0 /* sign extend high offset */
1142 addq t0,t4,t4 /* compute update address */
1145 ldq v0,MethodPointer(t4) /* */
1148 jmp zero,(ra) /* return */
1150 .end asm_getcallingmethod