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 functions *******************************/
113 .globl builtin_monitorexit
114 .globl builtin_throw_exception
115 .globl builtin_trace_exception
116 .globl class_java_lang_Object
119 /*********************** function has_no_x_instr_set ***************************
121 * determines if the byte support instruction set (21164a and higher) *
124 *******************************************************************************/
126 .ent has_no_x_instr_set
129 .long 0x47e03c20 /* amask 1,v0 */
130 jmp zero,(ra) /* return */
132 .end has_no_x_instr_set
135 /********************* function synchronize_caches ****************************/
137 .ent synchronize_caches
140 call_pal PAL_imb /* synchronise instruction cache */
141 jmp zero,(ra) /* return */
143 .end synchronize_caches
146 /********************* function asm_calljavamethod *****************************
148 * This function calls a Java-method (which possibly needs compilation) *
149 * with up to 4 parameters. *
151 * This functions calls the JIT-compiler which eventually translates the *
152 * method into machine code. *
154 * An possibly throwed exception will be returned to the caller as function *
155 * return value, so the java method cannot return a fucntion value (this *
156 * function usually calls 'main' and '<clinit>' which do not return a *
160 * javaobject_header *asm_calljavamethod (methodinfo *m, *
161 * void *arg1, void *arg2, void *arg3, void *arg4); *
163 *******************************************************************************/
165 #define MethodPointer -8
166 #define FrameSize -12
171 #define ExTableSize -32
172 #define ExTableStart -32
174 #define ExEntrySize -32
177 #define ExHandlerPC -24
178 #define ExCatchType -32
180 .ent asm_calljavamethod
183 .ascii "calljavamethod\0\0"
186 .quad 0 /* catch type all */
187 .quad calljava_xhandler /* handler pc */
188 .quad calljava_xhandler /* end pc */
189 .quad asm_calljavamethod /* start pc */
190 .long 1 /* extable size */
191 .long 0 /* fltsave */
192 .long 0 /* intsave */
195 .long 32 /* frame size */
196 .quad 0 /* method pointer (pointer to name) */
203 lda sp,-32(sp) /* allocate stack space */
204 stq gp,24(sp) /* save global pointer */
205 stq ra,0(sp) /* save return address */
208 stq a0,16(sp) /* save method pointer for compiler */
209 lda v0,16(sp) /* pass pointer to method pointer via v0*/
211 mov a1,a0 /* pass the remaining parameters */
216 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
217 stq $28,8(sp) /* store function address */
218 mov sp,$28 /* set method pointer */
220 ldq pv,8($28) /* method call as in Java */
221 jmp ra,(pv) /* call JIT compiler */
223 lda pv,-64(ra) /* asm_calljavamethod-calljava_jit !!!!!*/
227 ldq ra,0(sp) /* restore return address */
228 ldq gp,24(sp) /* restore global pointer */
229 lda sp,32(sp) /* free stack space */
237 ldq gp,24(sp) /* restore global pointer */
239 jsr ra,builtin_throw_exception
240 ldq ra,0(sp) /* restore return address */
241 lda sp,32(sp) /* free stack space */
243 .end asm_calljavamethod
246 /********************* function asm_calljavafunction ***************************
248 * This function calls a Java-method (which possibly needs compilation) *
249 * with up to 4 address parameters. *
251 * This functions calls the JIT-compiler which eventually translates the *
252 * method into machine code. *
255 * javaobject_header *asm_calljavamethod (methodinfo *m, *
256 * void *arg1, void *arg2, void *arg3, void *arg4); *
258 *******************************************************************************/
260 .ent asm_calljavafunction
263 .ascii "calljavafunction\0\0"
266 .quad 0 /* catch type all */
267 .quad calljava_xhandler2 /* handler pc */
268 .quad calljava_xhandler2 /* end pc */
269 .quad asm_calljavafunction /* start pc */
270 .long 1 /* extable size */
271 .long 0 /* fltsave */
272 .long 0 /* intsave */
275 .long 32 /* frame size */
276 .quad 0 /* method pointer (pointer to name) */
278 asm_calljavafunction:
283 lda sp,-32(sp) /* allocate stack space */
284 stq gp,24(sp) /* save global pointer */
285 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 */
316 ldq gp,24(sp) /* restore global pointer */
318 jsr ra,builtin_throw_exception
319 ldq ra,0(sp) /* restore return address */
320 lda sp,32(sp) /* free stack space */
322 .end asm_calljavafunction
325 /****************** function asm_call_jit_compiler *****************************
327 * invokes the compiler for untranslated JavaVM methods. *
329 * Register R0 contains a pointer to the method info structure (prepared *
330 * by createcompilerstub). Using the return address in R26 and the *
331 * offset in the LDA instruction or using the value in methodptr R28 the *
332 * patching address for storing the method address can be computed: *
334 * method address was either loaded using *
335 * M_LDQ (REG_PV, REG_PV, a) ; invokestatic/special ($27) *
336 * M_LDA (REG_PV, REG_RA, low) *
337 * M_LDAH(REG_PV, REG_RA, high) ; optional *
339 * M_LDQ (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($28) *
340 * in the static case the method pointer can be computed using the *
341 * return address and the lda function following the jmp instruction *
343 *******************************************************************************/
346 .ent asm_call_jit_compiler
347 asm_call_jit_compiler:
351 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
352 srl t8,16,t8 /* shift right register number $yy */
353 and t8,31,t8 /* isolate register number */
354 subl t8,28,t8 /* test for REG_METHODPTR */
356 ldl t8,0(ra) /* load instruction LDA PV,xxx(RA) */
358 sra t8,48,t8 /* isolate offset */
359 addq t8,ra,$28 /* compute update address */
360 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
361 srl t8,16,t8 /* isolate instruction code */
362 lda t8,-0x177b(t8) /* test for LDAH */
364 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
365 sll t8,16,t8 /* compute high offset */
366 addl t8,0,t8 /* sign extend high offset */
367 addq t8,$28,$28 /* compute update address */
369 lda sp,-14*8(sp) /* reserve stack space */
370 stq a0,0*8(sp) /* save all argument registers */
371 stq a1,1*8(sp) /* they could be used by method */
382 stq $28,12*8(sp) /* save method pointer */
383 stq ra,13*8(sp) /* save return address */
385 ldq a0,0(v0) /* pass 'methodinfo' pointer to */
386 jsr ra,jit_compile /* jit compiler */
389 call_pal PAL_imb /* synchronise instruction cache */
391 ldq a0,0*8(sp) /* load argument registers */
403 ldq $28,12*8(sp) /* load method pointer */
404 ldq ra,13*8(sp) /* load return address */
405 lda sp,14*8(sp) /* deallocate stack area */
407 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
409 sra t8,48,t8 /* isolate offset */
411 addq t8,$28,t8 /* compute update address via method pointer*/
412 stq v0,0(t8) /* save new method address there */
414 mov v0,pv /* load method address into pv */
416 jmp zero,(pv) /* and call method. The method returns */
417 /* directly to the caller (ra). */
419 .end asm_call_jit_compiler
422 /****************** function asm_dumpregistersandcall **************************
424 * This funtion saves all callee saved registers and calls the function *
425 * which is passed as parameter. *
427 * This function is needed by the garbage collector, which needs to access *
428 * all registers which are stored on the stack. Unused registers are *
429 * cleared to avoid interferances with the GC. *
431 * void asm_dumpregistersandcall (functionptr f); *
433 *******************************************************************************/
435 .ent asm_dumpregistersandcall
436 asm_dumpregistersandcall:
437 lda sp,-16*8(sp) /* allocate stack */
438 stq ra,0(sp) /* save return address */
440 stq s0,1*8(sp) /* save all callee saved registers */
441 stq s1,2*8(sp) /* intialize the remaining registers */
456 clr v0 /* intialize the remaining registers */
501 mov a0,pv /* load function pointer */
502 jmp ra,(pv) /* and call function */
504 ldq ra,0(sp) /* load return address */
505 lda sp,16*8(sp) /* deallocate stack */
506 jmp zero,(ra) /* return */
508 .end asm_dumpregistersandcall
511 /********************* function asm_handle_exception ***************************
513 * This function handles an exception. It does not use the usual calling *
514 * conventions. The exception pointer is passed in REG_ITMP1 and the *
515 * pc from the exception raising position is passed in REG_ITMP2. It searches *
516 * the local exception table for a handler. If no one is found, it unwinds *
517 * stacks and continues searching the callers. *
519 * void asm_handle_exception (exceptionptr, exceptionpc); *
521 *******************************************************************************/
523 .ent asm_handle_nat_exception
524 asm_handle_nat_exception:
526 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
528 sra t0,48,t0 /* isolate offset */
529 addq t0,ra,pv /* compute update address */
530 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
531 srl t0,16,t0 /* isolate instruction code */
532 lda t0,-0x177b(t0) /* test for LDAH */
533 bne t0,asm_handle_exception
534 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
535 sll t0,16,t0 /* compute high offset */
536 addl t0,0,t0 /* sign extend high offset */
537 addq t0,pv,pv /* compute update address */
539 .aent asm_handle_exception
540 asm_handle_exception:
542 lda sp,-18*8(sp) /* allocate stack */
543 stq t0,0*8(sp) /* save possible used registers */
544 stq t1,1*8(sp) /* also registers used by trace_exception */
562 lda t3,1(zero) /* set no unwind flag */
564 lda sp,-5*8(sp) /* allocate stack */
565 stq xptr,0*8(sp) /* save used register */
572 ldq a1,MethodPointer(pv)
575 br ra,ex_trace /* set ra for gp loading */
577 ldgp gp,0(ra) /* load gp */
578 jsr ra,builtin_trace_exception /* trace_exception(xptr,methodptr) */
580 ldq xptr,0*8(sp) /* restore used register */
585 lda sp,5*8(sp) /* deallocate stack */
587 ldl t0,ExTableSize(pv) /* t0 = exception table size */
588 beq t0,empty_table /* if empty table skip */
589 lda t1,ExTableStart(pv) /* t1 = start of exception table */
592 ldq t2,ExStartPC(t1) /* t2 = exception start pc */
593 cmple t2,xpc,t2 /* t2 = (startpc <= xpc) */
594 beq t2,ex_table_cont /* if (false) continue */
595 ldq t2,ExEndPC(t1) /* t2 = exception end pc */
596 cmplt xpc,t2,t2 /* t2 = (xpc < endpc) */
597 beq t2,ex_table_cont /* if (false) continue */
598 ldq a1,ExCatchType(t1) /* arg1 = exception catch type */
599 beq a1,ex_handle_it /* NULL catches everything */
601 ldq a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
602 ldq a1,offobjvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
603 ldl a0,offbaseval(a0) /* a0 = baseval(xptr) */
604 ldl v0,offbaseval(a1) /* a2 = baseval(catchtype) */
605 ldl a1,offdiffval(a1) /* a1 = diffval(catchtype) */
606 subl a0,v0,a0 /* a0 = baseval(xptr) - baseval(catchtype) */
607 cmpule a0,a1,v0 /* v0 = xptr is instanceof catchtype */
608 beq v0,ex_table_cont /* if (false) continue */
612 ldq xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
614 beq t3,ex_jump /* if (!(no stack unwinding) skip */
616 ldq t0,0*8(sp) /* restore possible used registers */
617 ldq t1,1*8(sp) /* also registers used by trace_exception */
634 lda sp,18*8(sp) /* deallocate stack */
637 jmp zero,(xpc) /* jump to the handler */
640 lda t1,ExEntrySize(t1) /* next exception table entry */
641 subl t0,1,t0 /* decrement entry counter */
642 bgt t0,ex_table_loop /* if (t0 > 0) next entry */
645 beq t3,ex_already_cleared /* if here the first time, then */
646 lda sp,18*8(sp) /* deallocate stack and */
647 clr t3 /* clear the no unwind flag */
649 ldl t0,IsSync(pv) /* t0 = SyncOffset */
650 beq t0,no_monitor_exit /* if zero no monitorexit */
651 addq sp,t0,t0 /* add stackptr to Offset */
652 ldq a0,-8(t0) /* load monitorexit pointer */
654 lda sp,-7*8(sp) /* allocate stack */
655 stq t0,0*8(sp) /* save used register */
663 br ra,ex_mon_load /* set ra for gp loading */
665 ldgp gp,0(ra) /* load gp */
666 jsr ra,builtin_monitorexit/* builtin_monitorexit(objectptr) */
668 ldq t0,0*8(sp) /* restore used register */
675 lda sp,7*8(sp) /* deallocate stack */
678 ldl t0,FrameSize(pv) /* t0 = frame size */
679 addq sp,t0,sp /* unwind stack */
680 mov sp,t0 /* t0 = pointer to save area */
681 ldl t1,IsLeaf(pv) /* t1 = is leaf procedure */
682 bne t1,ex_no_restore /* if (leaf) skip */
683 ldq ra,-8(t0) /* restore ra */
684 lda t0,-8(t0) /* t0-- */
686 mov ra,xpc /* the new xpc is ra */
687 ldl t1,IntSave(pv) /* t1 = saved int register count */
688 br t2,ex_int1 /* t2 = current pc */
690 lda t2,44(t2) /* lda t2,ex_int2-ex_int1(t2) !!!!!!!!!!!!! */
691 negl t1,t1 /* negate register count */
692 s4addq t1,t2,t2 /* t2 = ex_int_sav - 4 * register count */
693 jmp zero,(t2) /* jump to save position */
702 s8addq t1,t0,t0 /* t0 = t0 - 8 * register count */
704 ldl t1,FltSave(pv) /* t1 = saved flt register count */
705 br t2,ex_flt1 /* t2 = current pc */
707 lda t2,48(t2) /* lda t2,ex_flt2-ex_flt1(t2) !!!!!!!!!!!!! */
708 negl t1,t1 /* negate register count */
709 s4addq t1,t2,t2 /* t2 = ex_flt_sav - 4 * register count */
710 jmp zero,(t2) /* jump to save position */
720 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
722 sra t0,48,t0 /* isolate offset */
723 addq t0,ra,pv /* compute update address */
724 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
725 srl t0,16,t0 /* isolate instruction code */
726 lda t0,-0x177b(t0) /* test for LDAH */
728 ldl t0,4(ra) /* load instruction LDAH PV,xxx(RA) */
729 sll t0,16,t0 /* compute high offset */
730 addl t0,0,t0 /* sign extend high offset */
731 addq t0,pv,pv /* compute update address */
734 .end asm_handle_nat_exception
737 /********************* function asm_builtin_monitorenter ***********************
739 * Does null check and calls monitorenter or throws an exception *
741 *******************************************************************************/
743 .ent asm_builtin_monitorenter
744 asm_builtin_monitorenter:
747 lda pv,builtin_monitorenter
748 beq a0,nb_monitorenter /* if (null) throw exception */
749 jmp zero,(pv) /* else call builtin_monitorenter */
752 ldq xptr,proto_java_lang_NullPointerException
753 lda xpc,-4(ra) /* faulting address is return adress - 4*/
754 br asm_handle_nat_exception
755 .end asm_builtin_monitorenter
758 /********************* function asm_builtin_monitorexit ************************
760 * Does null check and calls monitorexit or throws an exception *
762 *******************************************************************************/
764 .ent asm_builtin_monitorexit
765 asm_builtin_monitorexit:
768 lda pv,builtin_monitorexit
769 beq a0,nb_monitorexit /* if (null) throw exception */
770 jmp zero,(pv) /* else call builtin_monitorexit */
773 ldq xptr,proto_java_lang_NullPointerException
774 lda xpc,-4(ra) /* faulting address is return adress - 4*/
775 br asm_handle_nat_exception
776 .end asm_builtin_monitorexit
779 /************************ function asm_builtin_idiv ****************************
781 * Does null check and calls idiv or throws an exception *
783 *******************************************************************************/
785 .ent asm_builtin_idiv
790 beq a1,nb_idiv /* if (null) throw exception */
791 jmp zero,(pv) /* else call builtin_idiv */
794 ldq xptr,proto_java_lang_ArithmeticException
795 lda xpc,-4(ra) /* faulting address is return adress - 4*/
796 br asm_handle_nat_exception
797 .end asm_builtin_idiv
800 /************************ function asm_builtin_ldiv ****************************
802 * Does null check and calls ldiv or throws an exception *
804 *******************************************************************************/
806 .ent asm_builtin_ldiv
811 beq a1,nb_ldiv /* if (null) throw exception */
812 jmp zero,(pv) /* else call builtin_ldiv */
815 ldq xptr,proto_java_lang_ArithmeticException
816 lda xpc,-4(ra) /* faulting address is return adress - 4*/
817 br asm_handle_nat_exception
818 .end asm_builtin_ldiv
821 /************************ function asm_builtin_irem ****************************
823 * Does null check and calls irem or throws an exception *
825 *******************************************************************************/
827 .ent asm_builtin_irem
832 beq a1,nb_irem /* if (null) throw exception */
833 jmp zero,(pv) /* else call builtin_irem */
836 ldq xptr,proto_java_lang_ArithmeticException
837 lda xpc,-4(ra) /* faulting address is return adress - 4*/
838 br asm_handle_nat_exception
839 .end asm_builtin_irem
842 /************************ function asm_builtin_lrem ****************************
844 * Does null check and calls lrem or throws an exception *
846 *******************************************************************************/
848 .ent asm_builtin_lrem
853 beq a1,nb_lrem /* if (null) throw exception */
854 jmp zero,(pv) /* else call builtin_lrem */
857 ldq xptr,proto_java_lang_ArithmeticException
858 lda xpc,-4(ra) /* faulting address is return adress - 4*/
859 br asm_handle_nat_exception
860 .end asm_builtin_lrem
863 /*********************** function new_builtin_checkcast ************************
865 * Does the cast check and eventually throws an exception *
867 *******************************************************************************/
869 .ent asm_builtin_checkcast
870 asm_builtin_checkcast:
873 lda sp,-16(sp) # allocate stack space
874 stq ra,0(sp) # save return address
875 stq a0,8(sp) # save object pointer
876 jsr ra,builtin_checkcast # builtin_checkcast
878 beq v0,nb_ccast_throw # if (false) throw exception
879 ldq ra,0(sp) # restore return address
880 ldq v0,8(sp) # return object pointer
881 lda sp,16(sp) # free stack space
885 ldq xptr,proto_java_lang_ClassCastException
886 ldq ra,0(sp) # restore return address
887 lda sp,16(sp) # free stack space
888 lda xpc,-4(ra) # faulting address is return adress - 4
889 br asm_handle_nat_exception
890 .end asm_builtin_checkcast
893 /******************* function asm_builtin_checkarraycast ***********************
895 * Does the cast check and eventually throws an exception *
897 *******************************************************************************/
899 .ent asm_builtin_checkarraycast
900 asm_builtin_checkarraycast:
903 lda sp,-16(sp) /* allocate stack space */
904 stq ra,0(sp) /* save return address */
905 stq a0,8(sp) /* save object pointer */
906 jsr ra,builtin_checkarraycast /* builtin_checkarraycast */
908 beq v0,nb_carray_throw /* if (false) throw exception */
909 ldq ra,0(sp) /* restore return address */
910 ldq v0,8(sp) /* return object pointer */
911 lda sp,16(sp) /* free stack space */
915 ldq xptr,proto_java_lang_ClassCastException
916 ldq ra,0(sp) /* restore return address */
917 lda sp,16(sp) /* free stack space */
918 lda xpc,-4(ra) /* faulting address is return adress - 4*/
919 br asm_handle_nat_exception
920 .end asm_builtin_checkarraycast
923 /******************* function asm_builtin_aastore ******************************
925 * Does the cast check and eventually throws an exception *
927 *******************************************************************************/
929 .ent asm_builtin_aastore
933 beq a0,nb_aastore_null /* if null pointer throw exception */
934 ldl t0,offarraysize(a0) /* load size */
935 lda sp,-24(sp) /* allocate stack space */
936 stq ra,0(sp) /* save return address */
937 s8addq a1,a0,t1 /* add index*8 to arrayref */
938 cmpult a1,t0,t0 /* do bound check */
939 beq t0,nb_aastore_bound /* if out of bounds throw exception */
940 mov a2,a1 /* object is second argument */
941 stq t1,8(sp) /* save store position */
942 stq a1,16(sp) /* save object */
943 jsr ra,builtin_canstore /* builtin_canstore(arrayref,object) */
945 ldq ra,0(sp) /* restore return address */
946 ldq a0,8(sp) /* restore store position */
947 ldq a1,16(sp) /* restore object */
948 lda sp,24(sp) /* free stack space */
949 beq v0,nb_aastore_throw /* if (false) throw exception */
950 stq a1,offobjarrdata(a0) /* store objectptr in array */
954 ldq xptr,proto_java_lang_NullPointerException
955 mov ra,xpc /* faulting address is return adress */
956 br asm_handle_nat_exception
959 ldq xptr,proto_java_lang_ArrayIndexOutOfBoundsException
960 lda sp,24(sp) /* free stack space */
961 mov ra,xpc /* faulting address is return adress */
962 br asm_handle_nat_exception
965 ldq xptr,proto_java_lang_ArrayStoreException
966 mov ra,xpc /* faulting address is return adress */
967 br asm_handle_nat_exception
969 .end asm_builtin_aastore
972 /******************* function asm_initialize_thread_stack **********************
974 * initialized a thread stack *
976 *******************************************************************************/
978 .ent asm_initialize_thread_stack
979 asm_initialize_thread_stack:
1000 .end asm_initialize_thread_stack
1003 /******************* function asm_perform_threadswitch *************************
1005 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1007 * performs a threadswitch *
1009 *******************************************************************************/
1011 .ent asm_perform_threadswitch
1012 asm_perform_threadswitch:
1053 .end asm_perform_threadswitch
1056 /********************* function asm_switchstackandcall *************************
1058 * void *asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
1061 * Switches to a new stack, calls a function and switches back. *
1062 * a0 new stack pointer *
1063 * a1 function pointer *
1064 * a2 pointer to variable where stack top should be stored *
1065 * a3 pointer to user data, is passed to the function *
1067 *******************************************************************************/
1070 .ent asm_switchstackandcall
1071 asm_switchstackandcall:
1072 lda a0,-2*8(a0) /* allocate new stack */
1073 stq ra,0(a0) /* save return address on new stack */
1074 stq sp,1*8(a0) /* save old stack pointer on new stack */
1075 stq sp,0(a2) /* save old stack pointer to variable */
1076 mov a0,sp /* switch to new stack */
1078 mov a1,pv /* load function pointer */
1079 mov a3,a0 /* pass 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
1159 /*********************** function asm_builtin_trace ****************************
1161 * Intended to be called from the native stub. Saves all argument registers *
1162 * and calls builtin_trace_args. *
1164 *******************************************************************************/
1166 .ent asm_builtin_trace
1185 jsr ra,builtin_trace_args
1203 .end asm_builtin_trace
1206 /********************* function asm_builtin_exittrace **************************
1208 * Intended to be called from the native stub. Saves return value and calls *
1209 * builtin_displaymethodstop. *
1211 *******************************************************************************/
1213 .ent asm_builtin_exittrace
1214 asm_builtin_exittrace:
1221 jsr ra,builtin_displaymethodstop
1229 .end asm_builtin_exittrace