1 /* jit/alpha/asmpart.S - Java-C interface functions for alpha
3 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 Institut f. Computersprachen, TU Wien
5 R. Grafl, A. Krall, C. Kruegel, C. Oates, R. Obermaisser, M. Probst,
6 S. Ring, E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich,
9 This file is part of CACAO.
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2, or (at
14 your option) any later version.
16 This program is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 Contact: cacao@complang.tuwien.ac.at
28 Authors: Andreas Krall
31 $Id: asmpart.S 1218 2004-06-29 14:11:16Z twisti $
40 #define MethodPointer -8
46 /* DEFINE LINE NUMBER STUFF HERE */
47 #define ExTableSize -56
48 #define ExTableStart -56
50 #define ExEntrySize -32
53 #define ExHandlerPC -24
54 #define ExCatchType -32
122 /********************* exported functions and variables ***********************/
124 .globl has_no_x_instr_set
125 .globl synchronize_caches
126 .globl asm_calljavafunction
127 .globl asm_calljavafunction2
128 .globl asm_calljavafunction2double
129 .globl asm_calljavafunction2long
130 .globl asm_call_jit_compiler
131 .globl asm_handle_exception
132 .globl asm_handle_nat_exception
133 .globl asm_check_clinit
134 .globl asm_builtin_checkcast
135 .globl asm_builtin_checkarraycast
136 .globl asm_builtin_aastore
137 .globl asm_builtin_monitorenter
138 .globl asm_builtin_monitorexit
139 .globl asm_builtin_idiv
140 .globl asm_builtin_irem
141 .globl asm_builtin_ldiv
142 .globl asm_builtin_lrem
143 .globl asm_perform_threadswitch
144 .globl asm_initialize_thread_stack
145 .globl asm_switchstackandcall
146 .globl asm_getcallingmethod
147 .globl asm_builtin_trace
148 .globl asm_builtin_exittrace
149 .globl asm_criticalsections
150 .globl asm_getclassvalues_atomic
152 /*************************** imported functions *******************************/
155 .globl builtin_monitorexit
156 .globl builtin_throw_exception
157 .globl builtin_trace_exception
158 .globl class_java_lang_Object
161 /*********************** function has_no_x_instr_set ***************************
163 * determines if the byte support instruction set (21164a and higher) *
166 *******************************************************************************/
168 .ent has_no_x_instr_set
171 .long 0x47e03c20 /* amask 1,v0 */
172 jmp zero,(ra) /* return */
174 .end has_no_x_instr_set
177 /********************* function asm_calljavafunction ***************************
179 * This function calls a Java-method (which possibly needs compilation) *
180 * with up to 4 address parameters. *
182 * This functions calls the JIT-compiler which eventually translates the *
183 * method into machine code. *
186 * javaobject_header *asm_calljavafunction (methodinfo *m, *
187 * void *arg1, void *arg2, void *arg3, void *arg4); *
189 *******************************************************************************/
191 .ent asm_calljavafunction
194 .ascii "calljavafunction\0\0"
197 .quad 0 /* catch type all */
198 .quad calljava_xhandler /* handler pc */
199 .quad calljava_xhandler /* end pc */
200 .quad asm_calljavafunction /* start pc */
201 .long 1 /* extable size */
202 .long 0 /* PADDING */
203 .quad 0 /* line number table start */
204 .quad 0 /* line number table size */
205 .long 0 /* PADDING */
206 .long 0 /* fltsave */
207 .long 0 /* intsave */
210 .long 32 /* frame size */
211 .quad 0 /* method pointer (pointer to name) */
213 asm_calljavafunction:
215 lda sp,-32(sp) /* allocate stack space */
216 stq gp,24(sp) /* save global pointer */
217 stq ra,0(sp) /* save return address */
219 stq a0,16(sp) /* save method pointer for compiler */
220 lda v0,16(sp) /* pass pointer to method pointer via v0*/
222 mov a1,a0 /* pass the remaining parameters */
227 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
228 stq $28,8(sp) /* store function address */
229 mov sp,$28 /* set method pointer */
231 ldq pv,8($28) /* method call as in Java */
232 jmp ra,(pv) /* call JIT compiler */
234 lda pv,-64(ra) /* asm_calljavafunction-calljava_jit !!!!!*/
237 ldq ra,0(sp) /* restore return address */
238 ldq gp,24(sp) /* restore global pointer */
239 lda sp,32(sp) /* free stack space */
245 ldq gp,24(sp) /* restore global pointer */
247 jsr ra,builtin_throw_exception
248 ldq ra,0(sp) /* restore return address */
249 lda sp,32(sp) /* free stack space */
251 .end asm_calljavafunction
256 .ent asm_calljavafunction2
259 .ascii "calljavafunction2\0\0"
262 .quad 0 /* catch type all */
263 .quad calljava_xhandler2 /* handler pc */
264 .quad calljava_xhandler2 /* end pc */
265 .quad asm_calljavafunction2 /* start pc */
266 .long 1 /* extable size */
267 .long 0 /* PADDING */
268 .quad 0 /* line number table start */
269 .quad 0 /* line number table size */
270 .long 0 /* PADDING */
271 .long 0 /* fltsave */
272 .long 1 /* intsave */
275 .long 40 /* frame size */
276 .quad 0 /* method pointer (pointer to name) */
278 asm_calljavafunction2:
279 asm_calljavafunction2double:
280 asm_calljavafunction2long:
282 lda sp,-40(sp) /* allocate stack space */
283 stq ra,0(sp) /* save return address */
285 stq gp,8(sp) /* save global pointer */
287 stq a0,32(sp) /* save method pointer for compiler */
288 mov a3,t0 /* pointer to arg block */
289 mov a1,s6 /* arg count */
291 ble s6,calljava_argsloaded
293 ldq a0,offjniitem(t0)
294 ldt $f16,offjniitem(t0)
295 ble s6,calljava_argsloaded
297 ldq a1,offjniitem+sizejniblock*1(t0)
298 ldt $f17,offjniitem+sizejniblock*1(t0)
299 ble s6,calljava_argsloaded
301 ldq a2,offjniitem+sizejniblock*2(t0)
302 ldt $f18,offjniitem+sizejniblock*2(t0)
303 ble s6,calljava_argsloaded
305 ldq a3,offjniitem+sizejniblock*3(t0)
306 ldt $f19,offjniitem+sizejniblock*3(t0)
307 ble s6,calljava_argsloaded
309 ldq a4,offjniitem+sizejniblock*4(t0)
310 ldt $f20,offjniitem+sizejniblock*4(t0)
311 ble s6,calljava_argsloaded
313 ldq a5,offjniitem+sizejniblock*5(t0)
314 ldt $f21,offjniitem+sizejniblock*5(t0)
317 ble s6,calljava_nocopy
323 ldq t3,offjniitem+sizejniblock*6(t0)
326 lda t0,sizejniblock(t0)
328 bne t1,calljava_copyloop
331 lda v0,32(t4) /* pass pointer to method pointer via v0*/
333 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
334 stq $28,16(t4) /* store function address */
335 lda $28,8(t4) /* set method pointer */
337 ldq pv,8($28) /* method call as in Java */
338 jmp ra,(pv) /* call JIT compiler */
340 lda pv,-200(ra) /* asm_calljavafunction-calljava_jit !!!*/
344 ldq ra,0(sp) /* restore return address */
345 ldq gp,8(sp) /* restore global pointer */
347 lda sp,40(sp) /* free stack space */
354 ldq gp,8(sp) /* restore global pointer */
356 jsr ra,builtin_throw_exception
357 ldq ra,0(sp) /* restore return address */
359 lda sp,40(sp) /* free stack space */
361 .end asm_calljavafunction2
364 /****************** function asm_call_jit_compiler *****************************
366 * invokes the compiler for untranslated JavaVM methods. *
368 * Register R0 contains a pointer to the method info structure (prepared *
369 * by createcompilerstub). Using the return address in R26 and the *
370 * offset in the LDA instruction or using the value in methodptr R28 the *
371 * patching address for storing the method address can be computed: *
373 * method address was either loaded using *
374 * M_LDQ (REG_PV, REG_PV, a) ; invokestatic/special ($27) *
375 * M_LDA (REG_PV, REG_RA, low) *
376 * M_LDAH(REG_PV, REG_RA, high) ; optional *
378 * M_LDQ (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($28) *
379 * in the static case the method pointer can be computed using the *
380 * return address and the lda function following the jmp instruction *
382 *******************************************************************************/
385 .ent asm_call_jit_compiler
386 asm_call_jit_compiler:
389 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
390 srl t8,16,t8 /* shift right register number $yy */
391 and t8,31,t8 /* isolate register number */
392 subl t8,28,t8 /* test for REG_METHODPTR */
394 ldl t8,0(ra) /* load instruction LDA PV,xxx(RA) */
396 sra t8,48,t8 /* isolate offset */
397 addq t8,ra,$28 /* compute update address */
398 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
399 srl t8,16,t8 /* isolate instruction code */
400 lda t8,-0x177b(t8) /* test for LDAH */
402 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
403 sll t8,16,t8 /* compute high offset */
404 addl t8,0,t8 /* sign extend high offset */
405 addq t8,$28,$28 /* compute update address */
407 lda sp,-14*8(sp) /* reserve stack space */
408 stq a0,0*8(sp) /* save all argument registers */
409 stq a1,1*8(sp) /* they could be used by method */
420 stq $28,12*8(sp) /* save method pointer */
421 stq ra,13*8(sp) /* save return address */
423 ldq a0,0(v0) /* pass 'methodinfo' pointer to */
424 jsr ra,jit_compile /* jit compiler */
427 call_pal PAL_imb /* synchronise instruction cache */
429 ldq a0,0*8(sp) /* load argument registers */
441 ldq $28,12*8(sp) /* load method pointer */
442 ldq ra,13*8(sp) /* load return address */
443 lda sp,14*8(sp) /* deallocate stack area */
445 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
447 sra t8,48,t8 /* isolate offset */
449 addq t8,$28,t8 /* compute update address via method pointer*/
450 stq v0,0(t8) /* save new method address there */
452 mov v0,pv /* load method address into pv */
454 jmp zero,(pv) /* and call method. The method returns */
455 /* directly to the caller (ra). */
457 .end asm_call_jit_compiler
460 /********************* function asm_handle_exception ***************************
462 * This function handles an exception. It does not use the usual calling *
463 * conventions. The exception pointer is passed in REG_ITMP1 and the *
464 * pc from the exception raising position is passed in REG_ITMP2. It searches *
465 * the local exception table for a handler. If no one is found, it unwinds *
466 * stacks and continues searching the callers. *
468 * void asm_handle_exception (exceptionptr, exceptionpc); *
470 *******************************************************************************/
472 .ent asm_handle_nat_exception
473 asm_handle_nat_exception:
474 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
476 sra t0,48,t0 /* isolate offset */
477 addq t0,ra,pv /* compute update address */
478 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
479 srl t0,16,t0 /* isolate instruction code */
480 lda t0,-0x177b(t0) /* test for LDAH */
481 bne t0,asm_handle_exception
482 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
483 sll t0,16,t0 /* compute high offset */
484 addl t0,0,t0 /* sign extend high offset */
485 addq t0,pv,pv /* compute update address */
487 .aent asm_handle_exception
488 asm_handle_exception:
489 lda sp,-18*8(sp) /* allocate stack */
490 stq t0,0*8(sp) /* save possible used registers */
491 stq t1,1*8(sp) /* also registers used by trace_exception */
509 lda t3,1(zero) /* set no unwind flag */
511 lda sp,-5*8(sp) /* allocate stack */
512 stq xptr,0*8(sp) /* save used register */
519 ldq a1,MethodPointer(pv)
524 br ra,ex_trace /* set ra for gp loading */
526 ldgp gp,0(ra) /* load gp */
527 jsr ra,builtin_trace_exception /* trace_exception(xptr,methodptr) */
529 ldq xptr,0*8(sp) /* restore used register */
534 lda sp,5*8(sp) /* deallocate stack */
536 ldl t0,ExTableSize(pv) /* t0 = exception table size */
537 beq t0,empty_table /* if empty table skip */
539 lda t1,ExTableStart(pv) /* t1 = start of exception table */
542 ldq t2,ExStartPC(t1) /* t2 = exception start pc */
543 cmple t2,xpc,t2 /* t2 = (startpc <= xpc) */
544 beq t2,ex_table_cont /* if (false) continue */
545 ldq t2,ExEndPC(t1) /* t2 = exception end pc */
546 cmplt xpc,t2,t2 /* t2 = (xpc < endpc) */
547 beq t2,ex_table_cont /* if (false) continue */
548 ldq a1,ExCatchType(t1) /* arg1 = exception catch type */
549 beq a1,ex_handle_it /* NULL catches everything */
551 ldl itmp3,offclassloaded(a1)
552 bne itmp3,L_class_loaded
554 subq sp,8*8,sp /* allocate stack */
555 stq t0,0*8(sp) /* save used register */
566 br ra,L_class_load_ra /* set ra for gp loading */
568 ldgp gp,0(ra) /* load gp */
569 jsr ra,class_load /* class_load(exceptionclass) */
571 ldq t0,0*8(sp) /* restore used register */
579 addq sp,8*8,sp /* deallocate stack */
582 ldl itmp3,offclasslinked(a1)
583 subq sp,8*8,sp /* allocate stack */
585 bne itmp3,L_class_linked
587 stq t0,0*8(sp) /* save used register */
597 br ra,L_class_link_ra /* set ra for gp loading */
599 ldgp gp,0(ra) /* load gp */
600 jsr ra,class_link /* class_load(exceptionclass) */
602 ldq t0,0*8(sp) /* restore used register */
614 ldq a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
615 ldq a1,offclassvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
616 ldl a0,offbaseval(a0) /* a0 = baseval(xptr) */
617 ldl v0,offbaseval(a1) /* a2 = baseval(catchtype) */
618 ldl a1,offdiffval(a1) /* a1 = diffval(catchtype) */
620 subl a0,v0,a0 /* a0 = baseval(xptr) - baseval(catchtype) */
621 cmpule a0,a1,v0 /* v0 = xptr is instanceof catchtype */
622 addq sp,8*8,sp /* deallocate stack */
623 beq v0,ex_table_cont /* if (false) continue */
626 ldq xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
628 beq t3,ex_jump /* if (!(no stack unwinding) skip */
630 ldq t0,0*8(sp) /* restore possible used registers */
631 ldq t1,1*8(sp) /* also registers used by trace_exception */
648 lda sp,18*8(sp) /* deallocate stack */
651 jmp zero,(xpc) /* jump to the handler */
654 lda t1,ExEntrySize(t1) /* next exception table entry */
655 subl t0,1,t0 /* decrement entry counter */
656 bgt t0,ex_table_loop /* if (t0 > 0) next entry */
659 beq t3,ex_already_cleared /* if here the first time, then */
660 lda sp,18*8(sp) /* deallocate stack and */
661 clr t3 /* clear the no unwind flag */
663 ldl t0,IsSync(pv) /* t0 = SyncOffset */
664 beq t0,no_monitor_exit /* if zero no monitorexit */
665 addq sp,t0,t0 /* add stackptr to Offset */
666 ldq a0,-8(t0) /* load monitorexit pointer */
668 lda sp,-7*8(sp) /* allocate stack */
669 stq t0,0*8(sp) /* save used register */
677 br ra,ex_mon_load /* set ra for gp loading */
679 ldgp gp,0(ra) /* load gp */
680 jsr ra,builtin_monitorexit/* builtin_monitorexit(objectptr) */
682 ldq t0,0*8(sp) /* restore used register */
689 lda sp,7*8(sp) /* deallocate stack */
692 ldl t0,FrameSize(pv) /* t0 = frame size */
693 addq sp,t0,sp /* unwind stack */
694 mov sp,t0 /* t0 = pointer to save area */
695 ldl t1,IsLeaf(pv) /* t1 = is leaf procedure */
696 bne t1,ex_no_restore /* if (leaf) skip */
697 ldq ra,-8(t0) /* restore ra */
698 lda t0,-8(t0) /* t0-- */
700 mov ra,xpc /* the new xpc is ra */
701 ldl t1,IntSave(pv) /* t1 = saved int register count */
702 br t2,ex_int1 /* t2 = current pc */
704 lda t2,44(t2) /* lda t2,ex_int2-ex_int1(t2) !!!!!!!!!!!!! */
705 negl t1,t1 /* negate register count */
706 s4addq t1,t2,t2 /* t2 = ex_int_sav - 4 * register count */
707 jmp zero,(t2) /* jump to save position */
716 s8addq t1,t0,t0 /* t0 = t0 - 8 * register count */
718 ldl t1,FltSave(pv) /* t1 = saved flt register count */
719 br t2,ex_flt1 /* t2 = current pc */
721 lda t2,48(t2) /* lda t2,ex_flt2-ex_flt1(t2) !!!!!!!!!!!!! */
722 negl t1,t1 /* negate register count */
723 s4addq t1,t2,t2 /* t2 = ex_flt_sav - 4 * register count */
724 jmp zero,(t2) /* jump to save position */
734 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
736 sra t0,48,t0 /* isolate offset */
737 addq t0,ra,pv /* compute update address */
738 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
739 srl t0,16,t0 /* isolate instruction code */
740 lda t0,-0x177b(t0) /* test for LDAH */
742 ldl t0,4(ra) /* load instruction LDAH PV,xxx(RA) */
743 sll t0,16,t0 /* compute high offset */
744 addl t0,0,t0 /* sign extend high offset */
745 addq t0,pv,pv /* compute update address */
748 .end asm_handle_nat_exception
751 /********************* asm_check_clinit ****************************************
753 * Does null check and calls monitorenter or throws an exception *
755 *******************************************************************************/
757 .ent asm_check_clinit
762 ldl itmp2,offclassinit(itmp1)
763 bne itmp2,L_is_initialized
767 stq a0,1*8(sp) /* save argument registers for leaf */
768 stq a1,2*8(sp) /* functions and native stub */
779 ldq a0,1*8(sp) /* restore argument registers */
787 beq v0,L_initializererror
790 mov ra,itmp1 /* now patch the calling code */
791 subq itmp1,(3*4),itmp1 /* go back 3 instructions */
792 ldah itmp2,-15392(zero) /* br -- 0xc3e0 == -15392 */
793 lda itmp2,4(itmp2) /* jump over 4 instructions */
794 stl itmp2,0(itmp1) /* store the new branch: br +4 */
799 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
802 jsr ra,builtin_asm_get_exceptionptrptr
805 ldq xptr,0(v0) /* get the exception pointer */
806 stq zero,0(v0) /* clear the exception pointer */
808 lda itmp3,_exceptionptr
814 br asm_handle_nat_exception
816 .end asm_check_clinit
819 /********************* function asm_builtin_monitorenter ***********************
821 * Does null check and calls monitorenter or throws an exception *
823 *******************************************************************************/
825 .ent asm_builtin_monitorenter
827 asm_builtin_monitorenter:
829 lda pv,builtin_monitorenter
830 beq a0,nb_monitorenter /* if (null) throw exception */
831 jmp zero,(pv) /* else call builtin_monitorenter */
836 ldq a0,string_java_lang_NullPointerException
843 lda xpc,-4(ra) /* faulting address is return adress - 4*/
844 br asm_handle_nat_exception
846 .end asm_builtin_monitorenter
849 /********************* function asm_builtin_monitorexit ************************
851 * Does null check and calls monitorexit or throws an exception *
853 *******************************************************************************/
855 .ent asm_builtin_monitorexit
857 asm_builtin_monitorexit:
859 lda pv,builtin_monitorexit
860 beq a0,nb_monitorexit /* if (null) throw exception */
861 jmp zero,(pv) /* else call builtin_monitorexit */
866 ldq a0,string_java_lang_NullPointerException
873 lda xpc,-4(ra) /* faulting address is return adress - 4*/
874 br asm_handle_nat_exception
876 .end asm_builtin_monitorexit
879 /************************ function asm_builtin_idiv ****************************
881 * Does null check and calls idiv or throws an exception *
883 *******************************************************************************/
885 .ent asm_builtin_idiv
890 beq a1,nb_idiv /* if (null) throw exception */
891 jmp zero,(pv) /* else call builtin_idiv */
896 ldq a0,string_java_lang_ArithmeticException
897 ldq a1,string_java_lang_ArithmeticException_message
898 jsr ra,new_exception_message
904 lda xpc,-4(ra) /* faulting address is return adress - 4*/
905 br asm_handle_nat_exception
907 .end asm_builtin_idiv
910 /************************ function asm_builtin_ldiv ****************************
912 * Does null check and calls ldiv or throws an exception *
914 *******************************************************************************/
916 .ent asm_builtin_ldiv
921 beq a1,nb_ldiv /* if (null) throw exception */
922 jmp zero,(pv) /* else call builtin_ldiv */
927 ldq a0,string_java_lang_ArithmeticException
928 ldq a1,string_java_lang_ArithmeticException_message
929 jsr ra,new_exception_message
935 lda xpc,-4(ra) /* faulting address is return adress - 4*/
936 br asm_handle_nat_exception
938 .end asm_builtin_ldiv
941 /************************ function asm_builtin_irem ****************************
943 * Does null check and calls irem or throws an exception *
945 *******************************************************************************/
947 .ent asm_builtin_irem
952 beq a1,nb_irem /* if (null) throw exception */
953 jmp zero,(pv) /* else call builtin_irem */
958 ldq a0,string_java_lang_ArithmeticException
959 ldq a1,string_java_lang_ArithmeticException_message
960 jsr ra,new_exception_message
966 lda xpc,-4(ra) /* faulting address is return adress - 4*/
967 br asm_handle_nat_exception
969 .end asm_builtin_irem
972 /************************ function asm_builtin_lrem ****************************
974 * Does null check and calls lrem or throws an exception *
976 *******************************************************************************/
978 .ent asm_builtin_lrem
983 beq a1,nb_lrem /* if (null) throw exception */
984 jmp zero,(pv) /* else call builtin_lrem */
989 ldq a0,string_java_lang_ArithmeticException
990 ldq a1,string_java_lang_ArithmeticException_message
991 jsr ra,new_exception_message
997 lda xpc,-4(ra) /* faulting address is return adress - 4*/
998 br asm_handle_nat_exception
1000 .end asm_builtin_lrem
1003 /******************* function asm_builtin_checkarraycast ***********************
1005 * Does the cast check and eventually throws an exception *
1007 *******************************************************************************/
1009 .ent asm_builtin_checkarraycast
1011 asm_builtin_checkarraycast:
1013 lda sp,-16(sp) /* allocate stack space */
1014 stq ra,0(sp) /* save return address */
1015 stq a0,8(sp) /* save object pointer */
1016 jsr ra,builtin_checkarraycast /* builtin_checkarraycast */
1018 beq v0,nb_carray_throw /* if (false) throw exception */
1019 ldq ra,0(sp) /* restore return address */
1020 ldq v0,8(sp) /* return object pointer */
1021 lda sp,16(sp) /* free stack space */
1025 ldq a0,string_java_lang_ClassCastException
1026 jsr ra,new_exception
1030 ldq ra,0(sp) /* restore return address */
1031 lda sp,16(sp) /* free stack space */
1032 lda xpc,-4(ra) /* faulting address is return adress - 4*/
1033 br asm_handle_nat_exception
1035 .end asm_builtin_checkarraycast
1038 /******************* function asm_builtin_aastore ******************************
1040 * Does the cast check and eventually throws an exception *
1042 *******************************************************************************/
1044 .ent asm_builtin_aastore
1046 asm_builtin_aastore:
1048 beq a0,nb_aastore_null /* if null pointer throw exception */
1049 ldl t0,offarraysize(a0) /* load size */
1050 lda sp,-24(sp) /* allocate stack space */
1051 stq ra,0(sp) /* save return address */
1052 s8addq a1,a0,t1 /* add index*8 to arrayref */
1053 cmpult a1,t0,t0 /* do bound check */
1054 beq t0,nb_aastore_bound /* if out of bounds throw exception */
1055 mov a2,a1 /* object is second argument */
1056 stq t1,8(sp) /* save store position */
1057 stq a1,16(sp) /* save object */
1058 jsr ra,builtin_canstore /* builtin_canstore(arrayref,object) */
1060 ldq ra,0(sp) /* restore return address */
1061 ldq a0,8(sp) /* restore store position */
1062 ldq a1,16(sp) /* restore object */
1063 lda sp,24(sp) /* free stack space */
1064 beq v0,nb_aastore_throw /* if (false) throw exception */
1065 stq a1,offobjarrdata(a0) /* store objectptr in array */
1069 subq sp,8,sp /* allocate stack space */
1070 stq ra,0(sp) /* save return address */
1071 ldq a0,string_java_lang_NullPointerException
1072 jsr ra,new_exception
1078 mov ra,xpc /* faulting address is return adress */
1079 br asm_handle_nat_exception
1082 ldq a0,string_java_lang_ArrayIndexOutOfBoundsException
1083 jsr ra,new_exception_int /* a1 already contains the index */
1087 ldq ra,0(sp) /* restore return address */
1088 lda sp,24(sp) /* free stack space */
1089 mov ra,xpc /* faulting address is return adress */
1090 br asm_handle_nat_exception
1093 subq sp,8,sp /* allocate stack space */
1094 stq ra,0(sp) /* save return address */
1095 ldq a0,string_java_lang_ArrayStoreException
1096 jsr ra,new_exception
1102 mov ra,xpc /* faulting address is return adress */
1103 br asm_handle_nat_exception
1105 .end asm_builtin_aastore
1108 /******************* function asm_initialize_thread_stack **********************
1110 * initialized a thread stack *
1112 *******************************************************************************/
1114 .ent asm_initialize_thread_stack
1116 asm_initialize_thread_stack:
1137 .end asm_initialize_thread_stack
1140 /******************* function asm_perform_threadswitch *************************
1142 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1144 * performs a threadswitch *
1146 *******************************************************************************/
1148 .ent asm_perform_threadswitch
1150 asm_perform_threadswitch:
1191 .end asm_perform_threadswitch
1194 /********************* function asm_switchstackandcall *************************
1196 * void *asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
1199 * Switches to a new stack, calls a function and switches back. *
1200 * a0 new stack pointer *
1201 * a1 function pointer *
1202 * a2 pointer to variable where stack top should be stored *
1203 * a3 pointer to user data, is passed to the function *
1205 *******************************************************************************/
1208 .ent asm_switchstackandcall
1210 asm_switchstackandcall:
1211 lda a0,-2*8(a0) /* allocate new stack */
1212 stq ra,0(a0) /* save return address on new stack */
1213 stq sp,1*8(a0) /* save old stack pointer on new stack */
1214 stq sp,0(a2) /* save old stack pointer to variable */
1215 mov a0,sp /* switch to new stack */
1217 mov a1,pv /* load function pointer */
1218 mov a3,a0 /* pass pointer */
1219 jmp ra,(pv) /* and call function */
1221 ldq ra,0(sp) /* load return address */
1222 ldq sp,1*8(sp) /* switch to old stack */
1224 jmp zero,(ra) /* return */
1226 .end asm_switchstackandcall
1228 .ent asm_getclassvalues_atomic
1230 asm_getclassvalues_atomic:
1233 ldl t0,offbaseval(a0)
1234 ldl t1,offdiffval(a0)
1235 ldl t2,offbaseval(a1)
1237 stl t0,offcast_super_baseval(a2)
1238 stl t1,offcast_super_diffval(a2)
1239 stl t2,offcast_sub_baseval(a2)
1242 .end asm_getclassvalues_atomic
1246 asm_criticalsections:
1247 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
1250 .quad _crit_restart1
1253 .quad _crit_restart2
1259 * These are local overrides for various environment variables in Emacs.
1260 * Please do not remove this and leave it at the end of the file, where
1261 * Emacs will automagically detect them.
1262 * ---------------------------------------------------------------------
1265 * indent-tabs-mode: t