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 1077 2004-05-20 18:06:55Z 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 *******************************/
156 .globl builtin_monitorexit
157 .globl builtin_throw_exception
158 .globl builtin_trace_exception
159 .globl class_java_lang_Object
162 /*********************** function has_no_x_instr_set ***************************
164 * determines if the byte support instruction set (21164a and higher) *
167 *******************************************************************************/
169 .ent has_no_x_instr_set
172 .long 0x47e03c20 /* amask 1,v0 */
173 jmp zero,(ra) /* return */
175 .end has_no_x_instr_set
178 /********************* function asm_calljavafunction ***************************
180 * This function calls a Java-method (which possibly needs compilation) *
181 * with up to 4 address parameters. *
183 * This functions calls the JIT-compiler which eventually translates the *
184 * method into machine code. *
187 * javaobject_header *asm_calljavafunction (methodinfo *m, *
188 * void *arg1, void *arg2, void *arg3, void *arg4); *
190 *******************************************************************************/
192 .ent asm_calljavafunction
195 .ascii "calljavafunction\0\0"
198 .quad 0 /* catch type all */
199 .quad calljava_xhandler /* handler pc */
200 .quad calljava_xhandler /* end pc */
201 .quad asm_calljavafunction /* start pc */
202 .long 1 /* extable size */
203 .long 0 /* PADDING */
204 .quad 0 /* line number table start */
205 .quad 0 /* line number table size */
206 .long 0 /* PADDING */
207 .long 0 /* fltsave */
208 .long 0 /* intsave */
211 .long 32 /* frame size */
212 .quad 0 /* method pointer (pointer to name) */
214 asm_calljavafunction:
216 lda sp,-32(sp) /* allocate stack space */
217 stq gp,24(sp) /* save global pointer */
218 stq ra,0(sp) /* save return address */
220 stq a0,16(sp) /* save method pointer for compiler */
221 lda v0,16(sp) /* pass pointer to method pointer via v0*/
223 mov a1,a0 /* pass the remaining parameters */
228 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
229 stq $28,8(sp) /* store function address */
230 mov sp,$28 /* set method pointer */
232 ldq pv,8($28) /* method call as in Java */
233 jmp ra,(pv) /* call JIT compiler */
235 lda pv,-64(ra) /* asm_calljavafunction-calljava_jit !!!!!*/
238 ldq ra,0(sp) /* restore return address */
239 ldq gp,24(sp) /* restore global pointer */
240 lda sp,32(sp) /* free stack space */
246 ldq gp,24(sp) /* restore global pointer */
248 jsr ra,builtin_throw_exception
249 ldq ra,0(sp) /* restore return address */
250 lda sp,32(sp) /* free stack space */
252 .end asm_calljavafunction
257 .ent asm_calljavafunction2
260 .ascii "calljavafunction2\0\0"
263 .quad 0 /* catch type all */
264 .quad calljava_xhandler2 /* handler pc */
265 .quad calljava_xhandler2 /* end pc */
266 .quad asm_calljavafunction2 /* start pc */
267 .long 1 /* extable size */
268 .long 0 /* PADDING */
269 .quad 0 /* line number table start */
270 .quad 0 /* line number table size */
271 .long 0 /* PADDING */
272 .long 0 /* fltsave */
273 .long 1 /* intsave */
276 .long 40 /* frame size */
277 .quad 0 /* method pointer (pointer to name) */
279 asm_calljavafunction2:
280 asm_calljavafunction2double:
281 asm_calljavafunction2long:
283 lda sp,-40(sp) /* allocate stack space */
284 stq ra,0(sp) /* save return address */
286 stq gp,8(sp) /* save global pointer */
288 stq a0,32(sp) /* save method pointer for compiler */
289 mov a3,t0 /* pointer to arg block */
290 mov a1,s6 /* arg count */
292 ble s6,calljava_argsloaded
294 ldq a0,offjniitem(t0)
295 ldt $f16,offjniitem(t0)
296 ble s6,calljava_argsloaded
298 ldq a1,offjniitem+sizejniblock*1(t0)
299 ldt $f17,offjniitem+sizejniblock*1(t0)
300 ble s6,calljava_argsloaded
302 ldq a2,offjniitem+sizejniblock*2(t0)
303 ldt $f18,offjniitem+sizejniblock*2(t0)
304 ble s6,calljava_argsloaded
306 ldq a3,offjniitem+sizejniblock*3(t0)
307 ldt $f19,offjniitem+sizejniblock*3(t0)
308 ble s6,calljava_argsloaded
310 ldq a4,offjniitem+sizejniblock*4(t0)
311 ldt $f20,offjniitem+sizejniblock*4(t0)
312 ble s6,calljava_argsloaded
314 ldq a5,offjniitem+sizejniblock*5(t0)
315 ldt $f21,offjniitem+sizejniblock*5(t0)
318 ble s6,calljava_nocopy
324 ldq t3,offjniitem+sizejniblock*6(t0)
327 lda t0,sizejniblock(t0)
329 bne t1,calljava_copyloop
332 lda v0,32(t4) /* pass pointer to method pointer via v0*/
334 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
335 stq $28,16(t4) /* store function address */
336 lda $28,8(t4) /* set method pointer */
338 ldq pv,8($28) /* method call as in Java */
339 jmp ra,(pv) /* call JIT compiler */
341 lda pv,-200(ra) /* asm_calljavafunction-calljava_jit !!!*/
345 ldq ra,0(sp) /* restore return address */
346 ldq gp,8(sp) /* restore global pointer */
348 lda sp,40(sp) /* free stack space */
355 ldq gp,8(sp) /* restore global pointer */
357 jsr ra,builtin_throw_exception
358 ldq ra,0(sp) /* restore return address */
360 lda sp,40(sp) /* free stack space */
362 .end asm_calljavafunction2
365 /****************** function asm_call_jit_compiler *****************************
367 * invokes the compiler for untranslated JavaVM methods. *
369 * Register R0 contains a pointer to the method info structure (prepared *
370 * by createcompilerstub). Using the return address in R26 and the *
371 * offset in the LDA instruction or using the value in methodptr R28 the *
372 * patching address for storing the method address can be computed: *
374 * method address was either loaded using *
375 * M_LDQ (REG_PV, REG_PV, a) ; invokestatic/special ($27) *
376 * M_LDA (REG_PV, REG_RA, low) *
377 * M_LDAH(REG_PV, REG_RA, high) ; optional *
379 * M_LDQ (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($28) *
380 * in the static case the method pointer can be computed using the *
381 * return address and the lda function following the jmp instruction *
383 *******************************************************************************/
386 .ent asm_call_jit_compiler
387 asm_call_jit_compiler:
390 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
391 srl t8,16,t8 /* shift right register number $yy */
392 and t8,31,t8 /* isolate register number */
393 subl t8,28,t8 /* test for REG_METHODPTR */
395 ldl t8,0(ra) /* load instruction LDA PV,xxx(RA) */
397 sra t8,48,t8 /* isolate offset */
398 addq t8,ra,$28 /* compute update address */
399 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
400 srl t8,16,t8 /* isolate instruction code */
401 lda t8,-0x177b(t8) /* test for LDAH */
403 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
404 sll t8,16,t8 /* compute high offset */
405 addl t8,0,t8 /* sign extend high offset */
406 addq t8,$28,$28 /* compute update address */
408 lda sp,-14*8(sp) /* reserve stack space */
409 stq a0,0*8(sp) /* save all argument registers */
410 stq a1,1*8(sp) /* they could be used by method */
421 stq $28,12*8(sp) /* save method pointer */
422 stq ra,13*8(sp) /* save return address */
424 ldq a0,0(v0) /* pass 'methodinfo' pointer to */
425 jsr ra,jit_compile /* jit compiler */
428 call_pal PAL_imb /* synchronise instruction cache */
430 ldq a0,0*8(sp) /* load argument registers */
442 ldq $28,12*8(sp) /* load method pointer */
443 ldq ra,13*8(sp) /* load return address */
444 lda sp,14*8(sp) /* deallocate stack area */
446 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
448 sra t8,48,t8 /* isolate offset */
450 addq t8,$28,t8 /* compute update address via method pointer*/
451 stq v0,0(t8) /* save new method address there */
453 mov v0,pv /* load method address into pv */
455 jmp zero,(pv) /* and call method. The method returns */
456 /* directly to the caller (ra). */
458 .end asm_call_jit_compiler
461 /********************* function asm_handle_exception ***************************
463 * This function handles an exception. It does not use the usual calling *
464 * conventions. The exception pointer is passed in REG_ITMP1 and the *
465 * pc from the exception raising position is passed in REG_ITMP2. It searches *
466 * the local exception table for a handler. If no one is found, it unwinds *
467 * stacks and continues searching the callers. *
469 * void asm_handle_exception (exceptionptr, exceptionpc); *
471 *******************************************************************************/
473 .ent asm_handle_nat_exception
474 asm_handle_nat_exception:
475 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
477 sra t0,48,t0 /* isolate offset */
478 addq t0,ra,pv /* compute update address */
479 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
480 srl t0,16,t0 /* isolate instruction code */
481 lda t0,-0x177b(t0) /* test for LDAH */
482 bne t0,asm_handle_exception
483 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
484 sll t0,16,t0 /* compute high offset */
485 addl t0,0,t0 /* sign extend high offset */
486 addq t0,pv,pv /* compute update address */
488 .aent asm_handle_exception
489 asm_handle_exception:
490 lda sp,-18*8(sp) /* allocate stack */
491 stq t0,0*8(sp) /* save possible used registers */
492 stq t1,1*8(sp) /* also registers used by trace_exception */
510 lda t3,1(zero) /* set no unwind flag */
512 lda sp,-5*8(sp) /* allocate stack */
513 stq xptr,0*8(sp) /* save used register */
520 ldq a1,MethodPointer(pv)
525 br ra,ex_trace /* set ra for gp loading */
527 ldgp gp,0(ra) /* load gp */
528 jsr ra,builtin_trace_exception /* trace_exception(xptr,methodptr) */
530 ldq xptr,0*8(sp) /* restore used register */
535 lda sp,5*8(sp) /* deallocate stack */
537 ldl t0,ExTableSize(pv) /* t0 = exception table size */
538 beq t0,empty_table /* if empty table skip */
540 lda t1,ExTableStart(pv) /* t1 = start of exception table */
543 ldq t2,ExStartPC(t1) /* t2 = exception start pc */
544 cmple t2,xpc,t2 /* t2 = (startpc <= xpc) */
545 beq t2,ex_table_cont /* if (false) continue */
546 ldq t2,ExEndPC(t1) /* t2 = exception end pc */
547 cmplt xpc,t2,t2 /* t2 = (xpc < endpc) */
548 beq t2,ex_table_cont /* if (false) continue */
549 ldq a1,ExCatchType(t1) /* arg1 = exception catch type */
550 beq a1,ex_handle_it /* NULL catches everything */
552 ldl itmp3,offclassloaded(a1)
553 bne itmp3,L_class_loaded
555 subq sp,8*8,sp /* allocate stack */
556 stq t0,0*8(sp) /* save used register */
567 br ra,L_class_load_ra /* set ra for gp loading */
569 ldgp gp,0(ra) /* load gp */
570 jsr ra,class_load /* class_load(exceptionclass) */
572 ldq t0,0*8(sp) /* restore used register */
580 addq sp,8*8,sp /* deallocate stack */
583 ldl itmp3,offclasslinked(a1)
584 subq sp,8*8,sp /* allocate stack */
586 bne itmp3,L_class_linked
588 stq t0,0*8(sp) /* save used register */
598 br ra,L_class_link_ra /* set ra for gp loading */
600 ldgp gp,0(ra) /* load gp */
601 jsr ra,class_link /* class_load(exceptionclass) */
603 ldq t0,0*8(sp) /* restore used register */
615 ldq a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
616 ldq a1,offclassvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
617 ldl a0,offbaseval(a0) /* a0 = baseval(xptr) */
618 ldl v0,offbaseval(a1) /* a2 = baseval(catchtype) */
619 ldl a1,offdiffval(a1) /* a1 = diffval(catchtype) */
621 subl a0,v0,a0 /* a0 = baseval(xptr) - baseval(catchtype) */
622 cmpule a0,a1,v0 /* v0 = xptr is instanceof catchtype */
623 addq sp,8*8,sp /* deallocate stack */
624 beq v0,ex_table_cont /* if (false) continue */
627 ldq xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
629 beq t3,ex_jump /* if (!(no stack unwinding) skip */
631 ldq t0,0*8(sp) /* restore possible used registers */
632 ldq t1,1*8(sp) /* also registers used by trace_exception */
649 lda sp,18*8(sp) /* deallocate stack */
652 jmp zero,(xpc) /* jump to the handler */
655 lda t1,ExEntrySize(t1) /* next exception table entry */
656 subl t0,1,t0 /* decrement entry counter */
657 bgt t0,ex_table_loop /* if (t0 > 0) next entry */
660 beq t3,ex_already_cleared /* if here the first time, then */
661 lda sp,18*8(sp) /* deallocate stack and */
662 clr t3 /* clear the no unwind flag */
664 ldl t0,IsSync(pv) /* t0 = SyncOffset */
665 beq t0,no_monitor_exit /* if zero no monitorexit */
666 addq sp,t0,t0 /* add stackptr to Offset */
667 ldq a0,-8(t0) /* load monitorexit pointer */
669 lda sp,-7*8(sp) /* allocate stack */
670 stq t0,0*8(sp) /* save used register */
678 br ra,ex_mon_load /* set ra for gp loading */
680 ldgp gp,0(ra) /* load gp */
681 jsr ra,builtin_monitorexit/* builtin_monitorexit(objectptr) */
683 ldq t0,0*8(sp) /* restore used register */
690 lda sp,7*8(sp) /* deallocate stack */
693 ldl t0,FrameSize(pv) /* t0 = frame size */
694 addq sp,t0,sp /* unwind stack */
695 mov sp,t0 /* t0 = pointer to save area */
696 ldl t1,IsLeaf(pv) /* t1 = is leaf procedure */
697 bne t1,ex_no_restore /* if (leaf) skip */
698 ldq ra,-8(t0) /* restore ra */
699 lda t0,-8(t0) /* t0-- */
701 mov ra,xpc /* the new xpc is ra */
702 ldl t1,IntSave(pv) /* t1 = saved int register count */
703 br t2,ex_int1 /* t2 = current pc */
705 lda t2,44(t2) /* lda t2,ex_int2-ex_int1(t2) !!!!!!!!!!!!! */
706 negl t1,t1 /* negate register count */
707 s4addq t1,t2,t2 /* t2 = ex_int_sav - 4 * register count */
708 jmp zero,(t2) /* jump to save position */
717 s8addq t1,t0,t0 /* t0 = t0 - 8 * register count */
719 ldl t1,FltSave(pv) /* t1 = saved flt register count */
720 br t2,ex_flt1 /* t2 = current pc */
722 lda t2,48(t2) /* lda t2,ex_flt2-ex_flt1(t2) !!!!!!!!!!!!! */
723 negl t1,t1 /* negate register count */
724 s4addq t1,t2,t2 /* t2 = ex_flt_sav - 4 * register count */
725 jmp zero,(t2) /* jump to save position */
735 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
737 sra t0,48,t0 /* isolate offset */
738 addq t0,ra,pv /* compute update address */
739 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
740 srl t0,16,t0 /* isolate instruction code */
741 lda t0,-0x177b(t0) /* test for LDAH */
743 ldl t0,4(ra) /* load instruction LDAH PV,xxx(RA) */
744 sll t0,16,t0 /* compute high offset */
745 addl t0,0,t0 /* sign extend high offset */
746 addq t0,pv,pv /* compute update address */
749 .end asm_handle_nat_exception
752 /********************* asm_check_clinit ****************************************
754 * Does null check and calls monitorenter or throws an exception *
756 *******************************************************************************/
758 .ent asm_check_clinit
763 ldl itmp2,offclassinit(itmp1)
764 bne itmp2,L_is_initialized
768 stq a0,1*8(sp) /* save argument registers for leaf */
769 stq a1,2*8(sp) /* functions and native stub */
780 ldq a0,1*8(sp) /* restore argument registers */
788 beq v0,L_initializererror
791 mov ra,itmp1 /* now patch the calling code */
792 subq itmp1,(3*4),itmp1 /* go back 3 instructions */
793 ldah itmp2,-15392(zero) /* br -- 0xc3e0 == -15392 */
794 lda itmp2,4(itmp2) /* jump over 4 instructions */
795 stl itmp2,0(itmp1) /* store the new branch: br +4 */
800 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
803 jsr ra,builtin_asm_get_exceptionptrptr
806 ldq xptr,0(v0) /* get the exception pointer */
807 stq zero,0(v0) /* clear the exception pointer */
809 lda itmp3,_exceptionptr
815 br asm_handle_nat_exception
817 .end asm_check_clinit
820 /********************* function asm_builtin_monitorenter ***********************
822 * Does null check and calls monitorenter or throws an exception *
824 *******************************************************************************/
826 .ent asm_builtin_monitorenter
828 asm_builtin_monitorenter:
830 lda pv,builtin_monitorenter
831 beq a0,nb_monitorenter /* if (null) throw exception */
832 jmp zero,(pv) /* else call builtin_monitorenter */
837 ldq a0,string_java_lang_NullPointerException
844 lda xpc,-4(ra) /* faulting address is return adress - 4*/
845 br asm_handle_nat_exception
847 .end asm_builtin_monitorenter
850 /********************* function asm_builtin_monitorexit ************************
852 * Does null check and calls monitorexit or throws an exception *
854 *******************************************************************************/
856 .ent asm_builtin_monitorexit
858 asm_builtin_monitorexit:
860 lda pv,builtin_monitorexit
861 beq a0,nb_monitorexit /* if (null) throw exception */
862 jmp zero,(pv) /* else call builtin_monitorexit */
867 ldq a0,string_java_lang_NullPointerException
874 lda xpc,-4(ra) /* faulting address is return adress - 4*/
875 br asm_handle_nat_exception
877 .end asm_builtin_monitorexit
880 /************************ function asm_builtin_idiv ****************************
882 * Does null check and calls idiv or throws an exception *
884 *******************************************************************************/
886 .ent asm_builtin_idiv
891 beq a1,nb_idiv /* if (null) throw exception */
892 jmp zero,(pv) /* else call builtin_idiv */
897 ldq a0,string_java_lang_ArithmeticException
898 ldq a1,string_java_lang_ArithmeticException_message
899 jsr ra,new_exception_message
905 lda xpc,-4(ra) /* faulting address is return adress - 4*/
906 br asm_handle_nat_exception
908 .end asm_builtin_idiv
911 /************************ function asm_builtin_ldiv ****************************
913 * Does null check and calls ldiv or throws an exception *
915 *******************************************************************************/
917 .ent asm_builtin_ldiv
922 beq a1,nb_ldiv /* if (null) throw exception */
923 jmp zero,(pv) /* else call builtin_ldiv */
928 ldq a0,string_java_lang_ArithmeticException
929 ldq a1,string_java_lang_ArithmeticException_message
930 jsr ra,new_exception_message
936 lda xpc,-4(ra) /* faulting address is return adress - 4*/
937 br asm_handle_nat_exception
939 .end asm_builtin_ldiv
942 /************************ function asm_builtin_irem ****************************
944 * Does null check and calls irem or throws an exception *
946 *******************************************************************************/
948 .ent asm_builtin_irem
953 beq a1,nb_irem /* if (null) throw exception */
954 jmp zero,(pv) /* else call builtin_irem */
959 ldq a0,string_java_lang_ArithmeticException
960 ldq a1,string_java_lang_ArithmeticException_message
961 jsr ra,new_exception_message
967 lda xpc,-4(ra) /* faulting address is return adress - 4*/
968 br asm_handle_nat_exception
970 .end asm_builtin_irem
973 /************************ function asm_builtin_lrem ****************************
975 * Does null check and calls lrem or throws an exception *
977 *******************************************************************************/
979 .ent asm_builtin_lrem
984 beq a1,nb_lrem /* if (null) throw exception */
985 jmp zero,(pv) /* else call builtin_lrem */
990 ldq a0,string_java_lang_ArithmeticException
991 ldq a1,string_java_lang_ArithmeticException_message
992 jsr ra,new_exception_message
998 lda xpc,-4(ra) /* faulting address is return adress - 4*/
999 br asm_handle_nat_exception
1001 .end asm_builtin_lrem
1004 /******************* function asm_builtin_checkarraycast ***********************
1006 * Does the cast check and eventually throws an exception *
1008 *******************************************************************************/
1010 .ent asm_builtin_checkarraycast
1012 asm_builtin_checkarraycast:
1014 lda sp,-16(sp) /* allocate stack space */
1015 stq ra,0(sp) /* save return address */
1016 stq a0,8(sp) /* save object pointer */
1017 jsr ra,builtin_checkarraycast /* builtin_checkarraycast */
1019 beq v0,nb_carray_throw /* if (false) throw exception */
1020 ldq ra,0(sp) /* restore return address */
1021 ldq v0,8(sp) /* return object pointer */
1022 lda sp,16(sp) /* free stack space */
1026 ldq a0,string_java_lang_ClassCastException
1027 jsr ra,new_exception
1031 ldq ra,0(sp) /* restore return address */
1032 lda sp,16(sp) /* free stack space */
1033 lda xpc,-4(ra) /* faulting address is return adress - 4*/
1034 br asm_handle_nat_exception
1036 .end asm_builtin_checkarraycast
1039 /******************* function asm_builtin_aastore ******************************
1041 * Does the cast check and eventually throws an exception *
1043 *******************************************************************************/
1045 .ent asm_builtin_aastore
1047 asm_builtin_aastore:
1049 beq a0,nb_aastore_null /* if null pointer throw exception */
1050 ldl t0,offarraysize(a0) /* load size */
1051 lda sp,-24(sp) /* allocate stack space */
1052 stq ra,0(sp) /* save return address */
1053 s8addq a1,a0,t1 /* add index*8 to arrayref */
1054 cmpult a1,t0,t0 /* do bound check */
1055 beq t0,nb_aastore_bound /* if out of bounds throw exception */
1056 mov a2,a1 /* object is second argument */
1057 stq t1,8(sp) /* save store position */
1058 stq a1,16(sp) /* save object */
1059 jsr ra,builtin_canstore /* builtin_canstore(arrayref,object) */
1061 ldq ra,0(sp) /* restore return address */
1062 ldq a0,8(sp) /* restore store position */
1063 ldq a1,16(sp) /* restore object */
1064 lda sp,24(sp) /* free stack space */
1065 beq v0,nb_aastore_throw /* if (false) throw exception */
1066 stq a1,offobjarrdata(a0) /* store objectptr in array */
1070 subq sp,8,sp /* allocate stack space */
1071 stq ra,0(sp) /* save return address */
1072 ldq a0,string_java_lang_NullPointerException
1073 jsr ra,new_exception
1079 mov ra,xpc /* faulting address is return adress */
1080 br asm_handle_nat_exception
1083 ldq a0,string_java_lang_ArrayIndexOutOfBoundsException
1084 jsr ra,new_exception_int /* a1 already contains the index */
1088 ldq ra,0(sp) /* restore return address */
1089 lda sp,24(sp) /* free stack space */
1090 mov ra,xpc /* faulting address is return adress */
1091 br asm_handle_nat_exception
1094 subq sp,8,sp /* allocate stack space */
1095 stq ra,0(sp) /* save return address */
1096 ldq a0,string_java_lang_ArrayStoreException
1097 jsr ra,new_exception
1103 mov ra,xpc /* faulting address is return adress */
1104 br asm_handle_nat_exception
1106 .end asm_builtin_aastore
1109 /******************* function asm_initialize_thread_stack **********************
1111 * initialized a thread stack *
1113 *******************************************************************************/
1115 .ent asm_initialize_thread_stack
1117 asm_initialize_thread_stack:
1138 .end asm_initialize_thread_stack
1141 /******************* function asm_perform_threadswitch *************************
1143 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1145 * performs a threadswitch *
1147 *******************************************************************************/
1149 .ent asm_perform_threadswitch
1151 asm_perform_threadswitch:
1192 .end asm_perform_threadswitch
1195 /********************* function asm_switchstackandcall *************************
1197 * void *asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
1200 * Switches to a new stack, calls a function and switches back. *
1201 * a0 new stack pointer *
1202 * a1 function pointer *
1203 * a2 pointer to variable where stack top should be stored *
1204 * a3 pointer to user data, is passed to the function *
1206 *******************************************************************************/
1209 .ent asm_switchstackandcall
1211 asm_switchstackandcall:
1212 lda a0,-2*8(a0) /* allocate new stack */
1213 stq ra,0(a0) /* save return address on new stack */
1214 stq sp,1*8(a0) /* save old stack pointer on new stack */
1215 stq sp,0(a2) /* save old stack pointer to variable */
1216 mov a0,sp /* switch to new stack */
1218 mov a1,pv /* load function pointer */
1219 mov a3,a0 /* pass pointer */
1220 jmp ra,(pv) /* and call function */
1222 ldq ra,0(sp) /* load return address */
1223 ldq sp,1*8(sp) /* switch to old stack */
1225 jmp zero,(ra) /* return */
1227 .end asm_switchstackandcall
1229 .ent asm_getclassvalues_atomic
1231 asm_getclassvalues_atomic:
1234 ldq t0,offbaseval(a0)
1235 ldq t1,offdiffval(a0)
1236 ldq t2,offbaseval(a1)
1238 stq t0,offcast_super_baseval(a2)
1239 stq t1,offcast_super_diffval(a2)
1240 stq t2,offcast_sub_baseval(a2)
1243 .end asm_getclassvalues_atomic
1247 asm_criticalsections:
1248 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
1251 .quad _crit_restart1
1254 .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