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 1392 2004-08-03 16:46:41Z stefan $
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_builtin_trace
147 .globl asm_builtin_exittrace
148 .globl asm_criticalsections
149 .globl asm_getclassvalues_atomic
151 /*************************** imported functions *******************************/
154 .globl builtin_monitorexit
155 .globl builtin_throw_exception
156 .globl builtin_trace_exception
157 .globl class_java_lang_Object
160 /*********************** function has_no_x_instr_set ***************************
162 * determines if the byte support instruction set (21164a and higher) *
165 *******************************************************************************/
167 .ent has_no_x_instr_set
170 .long 0x47e03c20 /* amask 1,v0 */
171 jmp zero,(ra) /* return */
173 .end has_no_x_instr_set
176 /********************* function asm_calljavafunction ***************************
178 * This function calls a Java-method (which possibly needs compilation) *
179 * with up to 4 address parameters. *
181 * This functions calls the JIT-compiler which eventually translates the *
182 * method into machine code. *
185 * javaobject_header *asm_calljavafunction (methodinfo *m, *
186 * void *arg1, void *arg2, void *arg3, void *arg4); *
188 *******************************************************************************/
190 .ent asm_calljavafunction
193 .ascii "calljavafunction\0\0"
196 .quad 0 /* catch type all */
197 .quad calljava_xhandler /* handler pc */
198 .quad calljava_xhandler /* end pc */
199 .quad asm_calljavafunction /* start pc */
200 .long 1 /* extable size */
201 .long 0 /* PADDING */
202 .quad 0 /* line number table start */
203 .quad 0 /* line number table size */
204 .long 0 /* PADDING */
205 .long 0 /* fltsave */
206 .long 0 /* intsave */
209 .long 32 /* frame size */
210 .quad 0 /* method pointer (pointer to name) */
212 asm_calljavafunction:
214 lda sp,-32(sp) /* allocate stack space */
215 stq gp,24(sp) /* save global pointer */
216 stq ra,0(sp) /* save return address */
218 stq a0,16(sp) /* save method pointer for compiler */
219 lda v0,16(sp) /* pass pointer to method pointer via v0*/
221 mov a1,a0 /* pass the remaining parameters */
226 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
227 stq $28,8(sp) /* store function address */
228 mov sp,$28 /* set method pointer */
230 ldq pv,8($28) /* method call as in Java */
231 jmp ra,(pv) /* call JIT compiler */
233 lda pv,-64(ra) /* asm_calljavafunction-calljava_jit !!!!!*/
236 ldq ra,0(sp) /* restore return address */
237 ldq gp,24(sp) /* restore global pointer */
238 lda sp,32(sp) /* free stack space */
244 ldq gp,24(sp) /* restore global pointer */
246 jsr ra,builtin_throw_exception
247 ldq ra,0(sp) /* restore return address */
248 lda sp,32(sp) /* free stack space */
250 .end asm_calljavafunction
255 .ent asm_calljavafunction2
258 .ascii "calljavafunction2\0\0"
261 .quad 0 /* catch type all */
262 .quad calljava_xhandler2 /* handler pc */
263 .quad calljava_xhandler2 /* end pc */
264 .quad asm_calljavafunction2 /* start pc */
265 .long 1 /* extable size */
266 .long 0 /* PADDING */
267 .quad 0 /* line number table start */
268 .quad 0 /* line number table size */
269 .long 0 /* PADDING */
270 .long 0 /* fltsave */
271 .long 1 /* intsave */
274 .long 40 /* frame size */
275 .quad 0 /* method pointer (pointer to name) */
277 asm_calljavafunction2:
278 asm_calljavafunction2double:
279 asm_calljavafunction2long:
281 lda sp,-40(sp) /* allocate stack space */
282 stq ra,0(sp) /* save return address */
284 stq gp,8(sp) /* save global pointer */
286 stq a0,32(sp) /* save method pointer for compiler */
287 mov a3,t0 /* pointer to arg block */
288 mov a1,s6 /* arg count */
290 ble s6,calljava_argsloaded
292 ldq a0,offjniitem(t0)
293 ldt $f16,offjniitem(t0)
294 ble s6,calljava_argsloaded
296 ldq a1,offjniitem+sizejniblock*1(t0)
297 ldt $f17,offjniitem+sizejniblock*1(t0)
298 ble s6,calljava_argsloaded
300 ldq a2,offjniitem+sizejniblock*2(t0)
301 ldt $f18,offjniitem+sizejniblock*2(t0)
302 ble s6,calljava_argsloaded
304 ldq a3,offjniitem+sizejniblock*3(t0)
305 ldt $f19,offjniitem+sizejniblock*3(t0)
306 ble s6,calljava_argsloaded
308 ldq a4,offjniitem+sizejniblock*4(t0)
309 ldt $f20,offjniitem+sizejniblock*4(t0)
310 ble s6,calljava_argsloaded
312 ldq a5,offjniitem+sizejniblock*5(t0)
313 ldt $f21,offjniitem+sizejniblock*5(t0)
316 ble s6,calljava_nocopy
322 ldq t3,offjniitem+sizejniblock*6(t0)
325 lda t0,sizejniblock(t0)
327 bne t1,calljava_copyloop
330 lda v0,32(t4) /* pass pointer to method pointer via v0*/
332 lda $28,asm_call_jit_compiler /* fake virtual function call (2 instr) */
333 stq $28,16(t4) /* store function address */
334 lda $28,8(t4) /* set method pointer */
336 ldq pv,8($28) /* method call as in Java */
337 jmp ra,(pv) /* call JIT compiler */
339 lda pv,-200(ra) /* asm_calljavafunction-calljava_jit !!!*/
343 ldq ra,0(sp) /* restore return address */
344 ldq gp,8(sp) /* restore global pointer */
346 lda sp,40(sp) /* free stack space */
353 ldq gp,8(sp) /* restore global pointer */
355 jsr ra,builtin_throw_exception
356 ldq ra,0(sp) /* restore return address */
358 lda sp,40(sp) /* free stack space */
360 .end asm_calljavafunction2
363 /****************** function asm_call_jit_compiler *****************************
365 * invokes the compiler for untranslated JavaVM methods. *
367 * Register R0 contains a pointer to the method info structure (prepared *
368 * by createcompilerstub). Using the return address in R26 and the *
369 * offset in the LDA instruction or using the value in methodptr R28 the *
370 * patching address for storing the method address can be computed: *
372 * method address was either loaded using *
373 * M_LDQ (REG_PV, REG_PV, a) ; invokestatic/special ($27) *
374 * M_LDA (REG_PV, REG_RA, low) *
375 * M_LDAH(REG_PV, REG_RA, high) ; optional *
377 * M_LDQ (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($28) *
378 * in the static case the method pointer can be computed using the *
379 * return address and the lda function following the jmp instruction *
381 *******************************************************************************/
384 .ent asm_call_jit_compiler
385 asm_call_jit_compiler:
388 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
389 srl t8,16,t8 /* shift right register number $yy */
390 and t8,31,t8 /* isolate register number */
391 subl t8,28,t8 /* test for REG_METHODPTR */
393 ldl t8,0(ra) /* load instruction LDA PV,xxx(RA) */
395 sra t8,48,t8 /* isolate offset */
396 addq t8,ra,$28 /* compute update address */
397 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
398 srl t8,16,t8 /* isolate instruction code */
399 lda t8,-0x177b(t8) /* test for LDAH */
401 ldl t8,4(ra) /* load instruction LDAH PV,xxx(PV) */
402 sll t8,16,t8 /* compute high offset */
403 addl t8,0,t8 /* sign extend high offset */
404 addq t8,$28,$28 /* compute update address */
406 lda sp,-14*8(sp) /* reserve stack space */
407 stq a0,0*8(sp) /* save all argument registers */
408 stq a1,1*8(sp) /* they could be used by method */
419 stq $28,12*8(sp) /* save method pointer */
420 stq ra,13*8(sp) /* save return address */
422 ldq a0,0(v0) /* pass 'methodinfo' pointer to */
423 jsr ra,jit_compile /* jit compiler */
426 call_pal PAL_imb /* synchronise instruction cache */
428 ldq a0,0*8(sp) /* load argument registers */
440 ldq $28,12*8(sp) /* load method pointer */
441 ldq ra,13*8(sp) /* load return address */
442 lda sp,14*8(sp) /* deallocate stack area */
444 ldl t8,-8(ra) /* load instruction LDQ PV,xxx($yy) */
446 sra t8,48,t8 /* isolate offset */
448 addq t8,$28,t8 /* compute update address via method pointer*/
449 stq v0,0(t8) /* save new method address there */
451 mov v0,pv /* load method address into pv */
453 jmp zero,(pv) /* and call method. The method returns */
454 /* directly to the caller (ra). */
456 .end asm_call_jit_compiler
459 /********************* function asm_handle_exception ***************************
461 * This function handles an exception. It does not use the usual calling *
462 * conventions. The exception pointer is passed in REG_ITMP1 and the *
463 * pc from the exception raising position is passed in REG_ITMP2. It searches *
464 * the local exception table for a handler. If no one is found, it unwinds *
465 * stacks and continues searching the callers. *
467 * void asm_handle_exception (exceptionptr, exceptionpc); *
469 *******************************************************************************/
471 .ent asm_handle_nat_exception
472 asm_handle_nat_exception:
473 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
475 sra t0,48,t0 /* isolate offset */
476 addq t0,ra,pv /* compute update address */
477 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
478 srl t0,16,t0 /* isolate instruction code */
479 lda t0,-0x177b(t0) /* test for LDAH */
480 bne t0,asm_handle_exception
481 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
482 sll t0,16,t0 /* compute high offset */
483 addl t0,0,t0 /* sign extend high offset */
484 addq t0,pv,pv /* compute update address */
486 .aent asm_handle_exception
487 asm_handle_exception:
488 lda sp,-18*8(sp) /* allocate stack */
489 stq t0,0*8(sp) /* save possible used registers */
490 stq t1,1*8(sp) /* also registers used by trace_exception */
508 lda t3,1(zero) /* set no unwind flag */
510 lda sp,-5*8(sp) /* allocate stack */
511 stq xptr,0*8(sp) /* save used register */
518 ldq a1,MethodPointer(pv)
523 br ra,ex_trace /* set ra for gp loading */
525 ldgp gp,0(ra) /* load gp */
526 jsr ra,builtin_trace_exception /* trace_exception(xptr,methodptr) */
528 ldq xptr,0*8(sp) /* restore used register */
533 lda sp,5*8(sp) /* deallocate stack */
535 ldl t0,ExTableSize(pv) /* t0 = exception table size */
536 beq t0,empty_table /* if empty table skip */
538 lda t1,ExTableStart(pv) /* t1 = start of exception table */
541 ldq t2,ExStartPC(t1) /* t2 = exception start pc */
542 cmple t2,xpc,t2 /* t2 = (startpc <= xpc) */
543 beq t2,ex_table_cont /* if (false) continue */
544 ldq t2,ExEndPC(t1) /* t2 = exception end pc */
545 cmplt xpc,t2,t2 /* t2 = (xpc < endpc) */
546 beq t2,ex_table_cont /* if (false) continue */
547 ldq a1,ExCatchType(t1) /* arg1 = exception catch type */
548 beq a1,ex_handle_it /* NULL catches everything */
550 ldl itmp3,offclassloaded(a1)
551 bne itmp3,L_class_loaded
553 subq sp,8*8,sp /* allocate stack */
554 stq t0,0*8(sp) /* save used register */
565 br ra,L_class_load_ra /* set ra for gp loading */
567 ldgp gp,0(ra) /* load gp */
568 jsr ra,class_load /* class_load(exceptionclass) */
570 ldq t0,0*8(sp) /* restore used register */
578 addq sp,8*8,sp /* deallocate stack */
581 ldl itmp3,offclasslinked(a1)
582 subq sp,8*8,sp /* allocate stack */
584 bne itmp3,L_class_linked
586 stq t0,0*8(sp) /* save used register */
596 br ra,L_class_link_ra /* set ra for gp loading */
598 ldgp gp,0(ra) /* load gp */
599 jsr ra,class_link /* class_load(exceptionclass) */
601 ldq t0,0*8(sp) /* restore used register */
613 ldq a0,offobjvftbl(xptr) /* a0 = vftblptr(xptr) */
614 ldq a1,offclassvftbl(a1) /* a1 = vftblptr(catchtype) class (not obj) */
615 ldl a0,offbaseval(a0) /* a0 = baseval(xptr) */
616 ldl v0,offbaseval(a1) /* a2 = baseval(catchtype) */
617 ldl a1,offdiffval(a1) /* a1 = diffval(catchtype) */
619 subl a0,v0,a0 /* a0 = baseval(xptr) - baseval(catchtype) */
620 cmpule a0,a1,v0 /* v0 = xptr is instanceof catchtype */
621 addq sp,8*8,sp /* deallocate stack */
622 beq v0,ex_table_cont /* if (false) continue */
625 ldq xpc,ExHandlerPC(t1) /* xpc = exception handler pc */
627 beq t3,ex_jump /* if (!(no stack unwinding) skip */
629 ldq t0,0*8(sp) /* restore possible used registers */
630 ldq t1,1*8(sp) /* also registers used by trace_exception */
647 lda sp,18*8(sp) /* deallocate stack */
650 jmp zero,(xpc) /* jump to the handler */
653 lda t1,ExEntrySize(t1) /* next exception table entry */
654 subl t0,1,t0 /* decrement entry counter */
655 bgt t0,ex_table_loop /* if (t0 > 0) next entry */
658 beq t3,ex_already_cleared /* if here the first time, then */
659 lda sp,18*8(sp) /* deallocate stack and */
660 clr t3 /* clear the no unwind flag */
662 ldl t0,IsSync(pv) /* t0 = SyncOffset */
663 beq t0,no_monitor_exit /* if zero no monitorexit */
664 addq sp,t0,t0 /* add stackptr to Offset */
665 ldq a0,-8(t0) /* load monitorexit pointer */
667 lda sp,-7*8(sp) /* allocate stack */
668 stq t0,0*8(sp) /* save used register */
676 br ra,ex_mon_load /* set ra for gp loading */
678 ldgp gp,0(ra) /* load gp */
679 jsr ra,builtin_monitorexit/* builtin_monitorexit(objectptr) */
681 ldq t0,0*8(sp) /* restore used register */
688 lda sp,7*8(sp) /* deallocate stack */
691 ldl t0,FrameSize(pv) /* t0 = frame size */
692 addq sp,t0,sp /* unwind stack */
693 mov sp,t0 /* t0 = pointer to save area */
694 ldl t1,IsLeaf(pv) /* t1 = is leaf procedure */
695 bne t1,ex_no_restore /* if (leaf) skip */
696 ldq ra,-8(t0) /* restore ra */
697 lda t0,-8(t0) /* t0-- */
699 mov ra,xpc /* the new xpc is ra */
700 ldl t1,IntSave(pv) /* t1 = saved int register count */
701 br t2,ex_int1 /* t2 = current pc */
703 lda t2,44(t2) /* lda t2,ex_int2-ex_int1(t2) !!!!!!!!!!!!! */
704 negl t1,t1 /* negate register count */
705 s4addq t1,t2,t2 /* t2 = ex_int_sav - 4 * register count */
706 jmp zero,(t2) /* jump to save position */
715 s8addq t1,t0,t0 /* t0 = t0 - 8 * register count */
717 ldl t1,FltSave(pv) /* t1 = saved flt register count */
718 br t2,ex_flt1 /* t2 = current pc */
720 lda t2,48(t2) /* lda t2,ex_flt2-ex_flt1(t2) !!!!!!!!!!!!! */
721 negl t1,t1 /* negate register count */
722 s4addq t1,t2,t2 /* t2 = ex_flt_sav - 4 * register count */
723 jmp zero,(t2) /* jump to save position */
733 ldl t0,0(ra) /* load instruction LDA PV,xxx(RA) */
735 sra t0,48,t0 /* isolate offset */
736 addq t0,ra,pv /* compute update address */
737 ldl t0,4(ra) /* load instruction LDAH PV,xxx(PV) */
738 srl t0,16,t0 /* isolate instruction code */
739 lda t0,-0x177b(t0) /* test for LDAH */
741 ldl t0,4(ra) /* load instruction LDAH PV,xxx(RA) */
742 sll t0,16,t0 /* compute high offset */
743 addl t0,0,t0 /* sign extend high offset */
744 addq t0,pv,pv /* compute update address */
747 .end asm_handle_nat_exception
750 /********************* asm_check_clinit ****************************************
752 * Does null check and calls monitorenter or throws an exception *
754 *******************************************************************************/
756 .ent asm_check_clinit
761 ldl itmp2,offclassinit(itmp1)
762 bne itmp2,L_is_initialized
766 stq a0,1*8(sp) /* save argument registers for leaf */
767 stq a1,2*8(sp) /* functions and native stub */
778 ldq a0,1*8(sp) /* restore argument registers */
786 beq v0,L_initializererror
789 mov ra,itmp1 /* now patch the calling code */
790 subq itmp1,(3*4),itmp1 /* go back 3 instructions */
791 ldah itmp2,-15392(zero) /* br -- 0xc3e0 == -15392 */
792 lda itmp2,4(itmp2) /* jump over 4 instructions */
793 stl itmp2,0(itmp1) /* store the new branch: br +4 */
798 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
801 jsr ra,builtin_asm_get_exceptionptrptr
804 ldq xptr,0(v0) /* get the exception pointer */
805 stq zero,0(v0) /* clear the exception pointer */
807 lda itmp3,_exceptionptr
813 br asm_handle_nat_exception
815 .end asm_check_clinit
818 /********************* function asm_builtin_monitorenter ***********************
820 * Does null check and calls monitorenter or throws an exception *
822 *******************************************************************************/
824 .ent asm_builtin_monitorenter
826 asm_builtin_monitorenter:
828 lda pv,builtin_monitorenter
829 beq a0,nb_monitorenter /* if (null) throw exception */
830 jmp zero,(pv) /* else call builtin_monitorenter */
835 ldq a0,string_java_lang_NullPointerException
842 lda xpc,-4(ra) /* faulting address is return adress - 4*/
843 br asm_handle_nat_exception
845 .end asm_builtin_monitorenter
848 /********************* function asm_builtin_monitorexit ************************
850 * Does null check and calls monitorexit or throws an exception *
852 *******************************************************************************/
854 .ent asm_builtin_monitorexit
856 asm_builtin_monitorexit:
858 lda pv,builtin_monitorexit
859 beq a0,nb_monitorexit /* if (null) throw exception */
860 jmp zero,(pv) /* else call builtin_monitorexit */
865 ldq a0,string_java_lang_NullPointerException
872 lda xpc,-4(ra) /* faulting address is return adress - 4*/
873 br asm_handle_nat_exception
875 .end asm_builtin_monitorexit
878 /************************ function asm_builtin_idiv ****************************
880 * Does null check and calls idiv or throws an exception *
882 *******************************************************************************/
884 .ent asm_builtin_idiv
889 beq a1,nb_idiv /* if (null) throw exception */
890 jmp zero,(pv) /* else call builtin_idiv */
895 ldq a0,string_java_lang_ArithmeticException
896 ldq a1,string_java_lang_ArithmeticException_message
897 jsr ra,new_exception_message
903 lda xpc,-4(ra) /* faulting address is return adress - 4*/
904 br asm_handle_nat_exception
906 .end asm_builtin_idiv
909 /************************ function asm_builtin_ldiv ****************************
911 * Does null check and calls ldiv or throws an exception *
913 *******************************************************************************/
915 .ent asm_builtin_ldiv
920 beq a1,nb_ldiv /* if (null) throw exception */
921 jmp zero,(pv) /* else call builtin_ldiv */
926 ldq a0,string_java_lang_ArithmeticException
927 ldq a1,string_java_lang_ArithmeticException_message
928 jsr ra,new_exception_message
934 lda xpc,-4(ra) /* faulting address is return adress - 4*/
935 br asm_handle_nat_exception
937 .end asm_builtin_ldiv
940 /************************ function asm_builtin_irem ****************************
942 * Does null check and calls irem or throws an exception *
944 *******************************************************************************/
946 .ent asm_builtin_irem
951 beq a1,nb_irem /* if (null) throw exception */
952 jmp zero,(pv) /* else call builtin_irem */
957 ldq a0,string_java_lang_ArithmeticException
958 ldq a1,string_java_lang_ArithmeticException_message
959 jsr ra,new_exception_message
965 lda xpc,-4(ra) /* faulting address is return adress - 4*/
966 br asm_handle_nat_exception
968 .end asm_builtin_irem
971 /************************ function asm_builtin_lrem ****************************
973 * Does null check and calls lrem or throws an exception *
975 *******************************************************************************/
977 .ent asm_builtin_lrem
982 beq a1,nb_lrem /* if (null) throw exception */
983 jmp zero,(pv) /* else call builtin_lrem */
988 ldq a0,string_java_lang_ArithmeticException
989 ldq a1,string_java_lang_ArithmeticException_message
990 jsr ra,new_exception_message
996 lda xpc,-4(ra) /* faulting address is return adress - 4*/
997 br asm_handle_nat_exception
999 .end asm_builtin_lrem
1002 /******************* function asm_builtin_checkarraycast ***********************
1004 * Does the cast check and eventually throws an exception *
1006 *******************************************************************************/
1008 .ent asm_builtin_checkarraycast
1010 asm_builtin_checkarraycast:
1012 lda sp,-16(sp) /* allocate stack space */
1013 stq ra,0(sp) /* save return address */
1014 stq a0,8(sp) /* save object pointer */
1015 jsr ra,builtin_checkarraycast /* builtin_checkarraycast */
1017 beq v0,nb_carray_throw /* if (false) throw exception */
1018 ldq ra,0(sp) /* restore return address */
1019 ldq v0,8(sp) /* return object pointer */
1020 lda sp,16(sp) /* free stack space */
1024 ldq a0,string_java_lang_ClassCastException
1025 jsr ra,new_exception
1029 ldq ra,0(sp) /* restore return address */
1030 lda sp,16(sp) /* free stack space */
1031 lda xpc,-4(ra) /* faulting address is return adress - 4*/
1032 br asm_handle_nat_exception
1034 .end asm_builtin_checkarraycast
1037 /******************* function asm_builtin_aastore ******************************
1039 * Does the cast check and eventually throws an exception *
1041 *******************************************************************************/
1043 .ent asm_builtin_aastore
1045 asm_builtin_aastore:
1047 beq a0,nb_aastore_null /* if null pointer throw exception */
1048 ldl t0,offarraysize(a0) /* load size */
1049 lda sp,-24(sp) /* allocate stack space */
1050 stq ra,0(sp) /* save return address */
1051 s8addq a1,a0,t1 /* add index*8 to arrayref */
1052 cmpult a1,t0,t0 /* do bound check */
1053 beq t0,nb_aastore_bound /* if out of bounds throw exception */
1054 mov a2,a1 /* object is second argument */
1055 stq t1,8(sp) /* save store position */
1056 stq a1,16(sp) /* save object */
1057 jsr ra,builtin_canstore /* builtin_canstore(arrayref,object) */
1059 ldq ra,0(sp) /* restore return address */
1060 ldq a0,8(sp) /* restore store position */
1061 ldq a1,16(sp) /* restore object */
1062 lda sp,24(sp) /* free stack space */
1063 beq v0,nb_aastore_throw /* if (false) throw exception */
1064 stq a1,offobjarrdata(a0) /* store objectptr in array */
1068 subq sp,8,sp /* allocate stack space */
1069 stq ra,0(sp) /* save return address */
1070 ldq a0,string_java_lang_NullPointerException
1071 jsr ra,new_exception
1077 mov ra,xpc /* faulting address is return adress */
1078 br asm_handle_nat_exception
1081 ldq a0,string_java_lang_ArrayIndexOutOfBoundsException
1082 jsr ra,new_exception_int /* a1 already contains the index */
1086 ldq ra,0(sp) /* restore return address */
1087 lda sp,24(sp) /* free stack space */
1088 mov ra,xpc /* faulting address is return adress */
1089 br asm_handle_nat_exception
1092 subq sp,8,sp /* allocate stack space */
1093 stq ra,0(sp) /* save return address */
1094 ldq a0,string_java_lang_ArrayStoreException
1095 jsr ra,new_exception
1101 mov ra,xpc /* faulting address is return adress */
1102 br asm_handle_nat_exception
1104 .end asm_builtin_aastore
1107 /******************* function asm_initialize_thread_stack **********************
1109 * initialized a thread stack *
1111 *******************************************************************************/
1113 .ent asm_initialize_thread_stack
1115 asm_initialize_thread_stack:
1136 .end asm_initialize_thread_stack
1139 /******************* function asm_perform_threadswitch *************************
1141 * void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop); *
1143 * performs a threadswitch *
1145 *******************************************************************************/
1147 .ent asm_perform_threadswitch
1149 asm_perform_threadswitch:
1190 .end asm_perform_threadswitch
1193 /********************* function asm_switchstackandcall *************************
1195 * void *asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
1198 * Switches to a new stack, calls a function and switches back. *
1199 * a0 new stack pointer *
1200 * a1 function pointer *
1201 * a2 pointer to variable where stack top should be stored *
1202 * a3 pointer to user data, is passed to the function *
1204 *******************************************************************************/
1207 .ent asm_switchstackandcall
1209 asm_switchstackandcall:
1210 lda a0,-2*8(a0) /* allocate new stack */
1211 stq ra,0(a0) /* save return address on new stack */
1212 stq sp,1*8(a0) /* save old stack pointer on new stack */
1213 stq sp,0(a2) /* save old stack pointer to variable */
1214 mov a0,sp /* switch to new stack */
1216 mov a1,pv /* load function pointer */
1217 mov a3,a0 /* pass pointer */
1218 jmp ra,(pv) /* and call function */
1220 ldq ra,0(sp) /* load return address */
1221 ldq sp,1*8(sp) /* switch to old stack */
1223 jmp zero,(ra) /* return */
1225 .end asm_switchstackandcall
1227 .ent asm_getclassvalues_atomic
1229 asm_getclassvalues_atomic:
1232 ldl t0,offbaseval(a0)
1233 ldl t1,offdiffval(a0)
1234 ldl t2,offbaseval(a1)
1236 stl t0,offcast_super_baseval(a2)
1237 stl t1,offcast_super_diffval(a2)
1238 stl t2,offcast_sub_baseval(a2)
1241 .end asm_getclassvalues_atomic
1245 asm_criticalsections:
1246 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
1249 .quad _crit_restart1
1252 .quad _crit_restart2
1258 * These are local overrides for various environment variables in Emacs.
1259 * Please do not remove this and leave it at the end of the file, where
1260 * Emacs will automagically detect them.
1261 * ---------------------------------------------------------------------
1264 * indent-tabs-mode: t