New source tree.
[cacao.git] / src / vm / jit / alpha / asmpart.S
1 /* vm/jit/alpha/asmpart.S - Java-C interface functions for alpha
2
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,
7    J. Wenninger
8
9    This file is part of CACAO.
10
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.
15
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.
20
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
24    02111-1307, USA.
25
26    Contact: cacao@complang.tuwien.ac.at
27
28    Authors: Andreas Krall
29             Reinhard Grafl
30
31    $Id: asmpart.S 1624 2004-11-30 14:49:45Z twisti $
32
33 */
34
35
36 #include "config.h"        
37 #include "vm/jit/alpha/offsets.h"
38
39
40 #define         MethodPointer   -8
41 #define         FrameSize       -12
42 #define     IsSync          -16
43 #define     IsLeaf          -20
44 #define     IntSave         -24
45 #define     FltSave         -28
46 /* DEFINE LINE NUMBER STUFF HERE */
47 #define     ExTableSize     -56
48 #define     ExTableStart    -56
49
50 #define     ExEntrySize     -32
51 #define     ExStartPC       -8
52 #define     ExEndPC         -16
53 #define     ExHandlerPC     -24
54 #define     ExCatchType     -32
55
56
57 #define v0      $0
58
59 #define t0      $1
60 #define t1      $2
61 #define t2      $3
62 #define t3      $4
63 #define t4      $5
64 #define t5      $6
65 #define t6      $7
66 #define t7      $8
67
68 #define s0      $9
69 #define s1      $10
70 #define s2      $11
71 #define s3      $12
72 #define s4      $13
73 #define s5      $14
74 #define s6      $15
75
76 #define a0      $16
77 #define a1      $17
78 #define a2      $18
79 #define a3      $19
80 #define a4      $20
81 #define a5      $21
82
83 #define t8      $22
84 #define t9      $23
85 #define t10     $24
86 #define t11     $25
87 #define ra      $26
88 #define t12     $27
89
90 #define pv      t12
91 #define AT      $at
92 #define gp      $29
93 #define sp      $30
94 #define zero    $31
95
96 #define itmp1   $25
97 #define itmp2   $28
98 #define itmp3   $29
99
100 #define xptr    itmp1
101 #define xpc     itmp2
102
103 #define sf0     $f2
104 #define sf1     $f3
105 #define sf2     $f4
106 #define sf3     $f5
107 #define sf4     $f6
108 #define sf5     $f7
109 #define sf6     $f8
110 #define sf7     $f9
111
112 #define fzero   $f31
113
114
115 #define PAL_imb 0x86
116
117         .text
118         .set    noat
119         .set    noreorder
120
121
122 /********************* exported functions and variables ***********************/
123
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
150
151 /*************************** imported functions *******************************/
152
153         .globl jit_compile
154         .globl builtin_monitorexit
155         .globl builtin_throw_exception
156         .globl builtin_trace_exception
157         .globl class_java_lang_Object
158
159
160 /*********************** function has_no_x_instr_set ***************************
161 *                                                                              *
162 *   determines if the byte support instruction set (21164a and higher)         *
163 *   is available.                                                              *
164 *                                                                              *
165 *******************************************************************************/
166
167         .ent    has_no_x_instr_set
168 has_no_x_instr_set:
169
170         .long   0x47e03c20                /* amask   1,v0                         */
171         jmp     zero,(ra)                 /* return                               */
172
173         .end    has_no_x_instr_set
174
175
176 /********************* function asm_calljavafunction ***************************
177 *                                                                              *
178 *   This function calls a Java-method (which possibly needs compilation)       *
179 *   with up to 4 address parameters.                                           *
180 *                                                                              *
181 *   This functions calls the JIT-compiler which eventually translates the      *
182 *   method into machine code.                                                  *
183 *                                                                              *
184 *   C-prototype:                                                               *
185 *    javaobject_header *asm_calljavafunction (methodinfo *m,                   *
186 *         void *arg1, void *arg2, void *arg3, void *arg4);                     *
187 *                                                                              *
188 *******************************************************************************/
189
190         .ent    asm_calljavafunction
191
192 call_name:
193         .ascii  "calljavafunction\0\0"
194
195         .align  2 /*3*/
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                              */
207         .long   0                         /* isleaf                               */
208         .long   0                         /* IsSync                               */
209         .long   32                        /* frame size                           */
210         .quad   0                         /* method pointer (pointer to name)     */
211
212 asm_calljavafunction:
213         ldgp    gp,0(pv)
214         lda     sp,-32(sp)                /* allocate stack space                 */
215         stq     gp,24(sp)                 /* save global pointer                  */
216         stq     ra,0(sp)                  /* save return address                  */
217
218         stq     a0,16(sp)                 /* save method pointer for compiler     */
219         lda     v0,16(sp)                 /* pass pointer to method pointer via v0*/
220
221         mov     a1,a0                     /* pass the remaining parameters        */
222         mov     a2,a1
223         mov     a3,a2
224         mov     a4,a3
225
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                   */
229
230         ldq     pv,8($28)                 /* method call as in Java               */
231         jmp     ra,(pv)                   /* call JIT compiler                    */
232 calljava_jit:
233         lda     pv,-64(ra)                /* asm_calljavafunction-calljava_jit !!!!!*/
234
235 calljava_return:
236         ldq     ra,0(sp)                  /* restore return address               */
237         ldq     gp,24(sp)                 /* restore global pointer               */
238         lda     sp,32(sp)                 /* free stack space                     */
239
240 calljava_ret:
241         jmp     zero,(ra)
242
243 calljava_xhandler:
244         ldq     gp,24(sp)                 /* restore global pointer               */
245         mov     itmp1,a0
246         jsr     ra,builtin_throw_exception
247         ldq     ra,0(sp)                  /* restore return address               */
248         lda     sp,32(sp)                 /* free stack space                     */
249         jmp     zero,(ra)
250         .end    asm_calljavafunction
251
252
253
254
255         .ent    asm_calljavafunction2
256
257 call_name2:
258         .ascii  "calljavafunction2\0\0"
259
260         .align  3
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                              */
272         .long   0                         /* isleaf                               */
273         .long   0                         /* IsSync                               */
274         .long   40                        /* frame size                           */
275         .quad   0                         /* method pointer (pointer to name)     */
276
277 asm_calljavafunction2:
278 asm_calljavafunction2double:
279 asm_calljavafunction2long:
280         ldgp    gp,0(pv)
281         lda     sp,-40(sp)                /* allocate stack space                 */
282         stq     ra,0(sp)                  /* save return address                  */
283         stq     s6,24(sp)
284         stq     gp,8(sp)                  /* save global pointer                  */
285
286         stq     a0,32(sp)                 /* save method pointer for compiler     */
287         mov     a3,t0                     /* pointer to arg block                 */
288         mov     a1,s6                     /* arg count                            */
289
290         ble     s6,calljava_argsloaded
291         lda     s6,-1(s6)
292         ldq     a0,offjniitem(t0)
293         ldt     $f16,offjniitem(t0)
294         ble     s6,calljava_argsloaded
295         lda     s6,-1(s6)
296         ldq     a1,offjniitem+sizejniblock*1(t0)
297         ldt     $f17,offjniitem+sizejniblock*1(t0)
298         ble     s6,calljava_argsloaded
299         lda     s6,-1(s6)
300         ldq     a2,offjniitem+sizejniblock*2(t0)
301         ldt     $f18,offjniitem+sizejniblock*2(t0)
302         ble     s6,calljava_argsloaded
303         lda     s6,-1(s6)
304         ldq     a3,offjniitem+sizejniblock*3(t0)
305         ldt     $f19,offjniitem+sizejniblock*3(t0)
306         ble     s6,calljava_argsloaded
307         lda     s6,-1(s6)
308         ldq     a4,offjniitem+sizejniblock*4(t0)
309         ldt     $f20,offjniitem+sizejniblock*4(t0)
310         ble     s6,calljava_argsloaded
311         lda     s6,-1(s6)
312         ldq     a5,offjniitem+sizejniblock*5(t0)
313         ldt     $f21,offjniitem+sizejniblock*5(t0)
314 calljava_argsloaded:
315         mov     sp,t4
316         ble     s6,calljava_nocopy
317         negq    s6,t1
318         s8addq  t1,sp,sp
319         s8addq  t1,t4,t2
320
321 calljava_copyloop:
322         ldq     t3,offjniitem+sizejniblock*6(t0)
323         stq     t3,0(t2)
324         lda     t1,1(t1)
325         lda     t0,sizejniblock(t0)
326         lda     t2,8(t2)
327         bne     t1,calljava_copyloop
328
329 calljava_nocopy:
330         lda     v0,32(t4)                 /* pass pointer to method pointer via v0*/
331
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                   */
335
336         ldq     pv,8($28)                 /* method call as in Java               */
337         jmp     ra,(pv)                   /* call JIT compiler                    */
338 calljava_jit2:
339         lda     pv,-200(ra)               /* asm_calljavafunction-calljava_jit !!!*/
340
341         s8addq  s6,sp,sp
342 calljava_return2:
343         ldq     ra,0(sp)                  /* restore return address               */
344         ldq     gp,8(sp)                  /* restore global pointer               */
345         ldq     s6,24(sp)
346         lda     sp,40(sp)                 /* free stack space                     */
347
348 calljava_ret2:
349         jmp     zero,(ra)
350
351 calljava_xhandler2:
352         s8addq  s6,sp,sp
353         ldq     gp,8(sp)                  /* restore global pointer               */
354         mov     itmp1,a0
355         jsr     ra,builtin_throw_exception
356         ldq     ra,0(sp)                  /* restore return address               */
357         ldq     s6,24(sp)
358         lda     sp,40(sp)                 /* free stack space                     */
359         jmp     zero,(ra)
360         .end    asm_calljavafunction2
361                                                 
362
363 /****************** function asm_call_jit_compiler *****************************
364 *                                                                              *
365 *   invokes the compiler for untranslated JavaVM methods.                      *
366 *                                                                              *
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:           *
371 *                                                                              *
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                                *
376 *   or                                                                         *
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          *
380 *                                                                              *
381 *******************************************************************************/
382
383
384         .ent    asm_call_jit_compiler
385 asm_call_jit_compiler:
386
387         ldgp    gp,0(pv)
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                   */
392         beq     t8,noregchange       
393         ldl     t8,0(ra)              /* load instruction LDA PV,xxx(RA)          */
394         sll     t8,48,t8
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                            */
400         bne     t8,noregchange       
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                   */
405 noregchange:
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             */
409         stq     a2,2*8(sp)
410         stq     a3,3*8(sp)
411         stq     a4,4*8(sp)
412         stq     a5,5*8(sp)
413         stt     $f16,6*8(sp)
414         stt     $f17,7*8(sp)
415         stt     $f18,8*8(sp)
416         stt     $f19,9*8(sp)
417         stt     $f20,10*8(sp)
418         stt     $f21,11*8(sp)
419         stq     $28,12*8(sp)          /* save method pointer                      */
420         stq     ra,13*8(sp)           /* save return address                      */
421
422         ldq     a0,0(v0)              /* pass 'methodinfo' pointer to             */
423         jsr     ra,jit_compile        /* jit compiler                             */
424         ldgp    gp,0(ra)
425
426         ldq     a0,0*8(sp)            /* load argument registers                  */
427         ldq     a1,1*8(sp)
428         ldq     a2,2*8(sp)
429         ldq     a3,3*8(sp)
430         ldq     a4,4*8(sp)
431         ldq     a5,5*8(sp)
432         ldt     $f16,6*8(sp)
433         ldt     $f17,7*8(sp)
434         ldt     $f18,8*8(sp)
435         ldt     $f19,9*8(sp)
436         ldt     $f20,10*8(sp)
437         ldt     $f21,11*8(sp)
438         ldq     $28,12*8(sp)          /* load method pointer                      */
439         ldq     ra,13*8(sp)           /* load return address                      */
440         lda     sp,14*8(sp)           /* deallocate stack area                    */
441
442         ldl     t8,-8(ra)             /* load instruction LDQ PV,xxx($yy)         */
443         sll     t8,48,t8
444         sra     t8,48,t8              /* isolate offset                           */
445
446         addq    t8,$28,t8             /* compute update address via method pointer*/
447         stq     v0,0(t8)              /* save new method address there            */
448
449         call_pal PAL_imb              /* synchronise instruction cache            */
450
451         mov     v0,pv                 /* load method address into pv              */
452
453         jmp     zero,(pv)             /* and call method. The method returns      */
454                                       /* directly to the caller (ra).             */
455
456         .end    asm_call_jit_compiler
457
458
459 /********************* function asm_handle_exception ***************************
460 *                                                                              *
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.                                *
466 *                                                                              *
467 *   void asm_handle_exception (exceptionptr, exceptionpc);                     *
468 *                                                                              *
469 *******************************************************************************/
470
471         .ent    asm_handle_nat_exception
472 asm_handle_nat_exception:
473         ldl     t0,0(ra)              /* load instruction LDA PV,xxx(RA)          */
474         sll     t0,48,t0
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                   */
485
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   */
491         stq     t2,2*8(sp)
492         stq     t3,3*8(sp)
493         stq     t4,4*8(sp)
494         stq     t5,5*8(sp)
495         stq     t6,6*8(sp)
496         stq     t7,7*8(sp)
497         stq     t8,8*8(sp)
498         stq     t9,9*8(sp)
499         stq     t10,10*8(sp)
500         stq     v0,11*8(sp)
501         stq     a0,12*8(sp)
502         stq     a1,13*8(sp)
503         stq     a2,14*8(sp)
504         stq     a3,15*8(sp)
505         stq     a4,16*8(sp)
506         stq     a5,17*8(sp)
507
508         lda     t3,1(zero)            /* set no unwind flag                       */
509 ex_stack_loop:
510         lda     sp,-5*8(sp)           /* allocate stack                           */
511         stq     xptr,0*8(sp)          /* save used register                       */
512         stq     xpc,1*8(sp)
513         stq     pv,2*8(sp)
514         stq     ra,3*8(sp)
515         stq     t3,4*8(sp)
516
517         mov     xptr,a0
518         ldq     a1,MethodPointer(pv)
519         mov     xpc,a2
520 /*      mov     t3,a3 */
521         lda             a3,0(zero)
522         lda             a4,1(zero)
523         br      ra,ex_trace           /* set ra for gp loading                    */
524 ex_trace:
525         ldgp    gp,0(ra)              /* load gp                                  */
526         jsr     ra,builtin_trace_exception /* trace_exception(xptr,methodptr)     */
527         
528         ldq     xptr,0*8(sp)          /* restore used register                    */
529         ldq     xpc,1*8(sp)
530         ldq     pv,2*8(sp)
531         ldq     ra,3*8(sp)
532         ldq     t3,4*8(sp)
533         lda     sp,5*8(sp)            /* deallocate stack                         */
534         
535         ldl     t0,ExTableSize(pv)    /* t0 = exception table size                */
536         beq     t0,empty_table        /* if empty table skip                      */
537
538         lda     t1,ExTableStart(pv)   /* t1 = start of exception table            */
539
540 ex_table_loop:
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                  */
549
550         ldl     itmp3,offclassloaded(a1)
551         bne     itmp3,L_class_loaded
552
553         subq    sp,8*8,sp             /* allocate stack                           */
554         stq     t0,0*8(sp)            /* save used register                       */
555         stq     t1,1*8(sp)
556         stq     t3,2*8(sp)
557         stq     xptr,3*8(sp)
558         stq     xpc,4*8(sp)
559         stq     pv,5*8(sp)
560         stq     ra,6*8(sp)
561         stq     a1,7*8(sp)
562
563         mov     a1,a0
564
565         br      ra,L_class_load_ra    /* set ra for gp loading                    */
566 L_class_load_ra:
567         ldgp    gp,0(ra)              /* load gp                                  */
568         jsr     ra,class_load         /* class_load(exceptionclass)               */
569
570         ldq     t0,0*8(sp)            /* restore used register                    */
571         ldq     t1,1*8(sp)
572         ldq     t3,2*8(sp)
573         ldq     xptr,3*8(sp)
574         ldq     xpc,4*8(sp)
575         ldq     pv,5*8(sp)
576         ldq     ra,6*8(sp)
577         ldq     a1,7*8(sp)
578         addq    sp,8*8,sp             /* deallocate stack                         */
579
580 L_class_loaded:
581         ldl     itmp3,offclasslinked(a1)
582         subq    sp,8*8,sp             /* allocate stack                           */
583         stq     a1,7*8(sp)
584         bne     itmp3,L_class_linked
585
586         stq     t0,0*8(sp)            /* save used register                       */
587         stq     t1,1*8(sp)
588         stq     t3,2*8(sp)
589         stq     xptr,3*8(sp)
590         stq     xpc,4*8(sp)
591         stq     pv,5*8(sp)
592         stq     ra,6*8(sp)
593
594         mov     a1,a0
595
596         br      ra,L_class_link_ra    /* set ra for gp loading                    */
597 L_class_link_ra:
598         ldgp    gp,0(ra)              /* load gp                                  */
599         jsr     ra,class_link         /* class_load(exceptionclass)               */
600
601         ldq     t0,0*8(sp)            /* restore used register                    */
602         ldq     t1,1*8(sp)
603         ldq     t3,2*8(sp)
604         ldq     xptr,3*8(sp)
605         ldq     xpc,4*8(sp)
606         ldq     pv,5*8(sp)
607         ldq     ra,6*8(sp)
608
609 L_class_linked:
610 _crit_restart1:
611         ldq     a1,7*8(sp)
612 _crit_begin1:
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)                  */
618 _crit_end1:
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                      */
623
624 ex_handle_it:
625         ldq     xpc,ExHandlerPC(t1)   /* xpc = exception handler pc               */
626
627         beq     t3,ex_jump            /* if (!(no stack unwinding) skip           */
628
629         ldq     t0,0*8(sp)            /* restore possible used registers          */
630         ldq     t1,1*8(sp)            /* also registers used by trace_exception   */
631         ldq     t2,2*8(sp)
632         ldq     t3,3*8(sp)
633         ldq     t4,4*8(sp)
634         ldq     t5,5*8(sp)
635         ldq     t6,6*8(sp)
636         ldq     t7,7*8(sp)
637         ldq     t8,8*8(sp)
638         ldq     t9,9*8(sp)
639         ldq     t10,10*8(sp)
640         ldq     v0,11*8(sp)
641         ldq     a0,12*8(sp)
642         ldq     a1,13*8(sp)
643         ldq     a2,14*8(sp)
644         ldq     a3,15*8(sp)
645         ldq     a4,16*8(sp)
646         ldq     a5,17*8(sp)
647         lda     sp,18*8(sp)           /* deallocate stack                         */
648
649 ex_jump:
650         jmp     zero,(xpc)            /* jump to the handler                      */
651
652 ex_table_cont:
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                   */
656
657 empty_table:
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                 */
661 ex_already_cleared:
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                 */
666
667         lda     sp,-7*8(sp)           /* allocate stack                           */
668         stq     t0,0*8(sp)            /* save used register                       */
669         stq     t1,1*8(sp)
670         stq     t3,2*8(sp)
671         stq     xptr,3*8(sp)
672         stq     xpc,4*8(sp)
673         stq     pv,5*8(sp)
674         stq     ra,6*8(sp)
675
676         br      ra,ex_mon_load        /* set ra for gp loading                    */
677 ex_mon_load:
678         ldgp    gp,0(ra)              /* load gp                                  */
679         jsr     ra,builtin_monitorexit/* builtin_monitorexit(objectptr)           */
680         
681         ldq     t0,0*8(sp)            /* restore used register                    */
682         ldq     t1,1*8(sp)
683         ldq     t3,2*8(sp)
684         ldq     xptr,3*8(sp)
685         ldq     xpc,4*8(sp)
686         ldq     pv,5*8(sp)
687         ldq     ra,6*8(sp)
688         lda     sp,7*8(sp)            /* deallocate stack                         */
689
690 no_monitor_exit:
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--                                     */
698 ex_no_restore:
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                          */
702 ex_int1:
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                    */
707         ldq     s0,-56(t0)
708         ldq     s1,-48(t0)
709         ldq     s2,-40(t0)
710         ldq     s3,-32(t0)
711         ldq     s4,-24(t0)
712         ldq     s5,-16(t0)
713         ldq     s6,-8(t0)
714 ex_int2:
715         s8addq  t1,t0,t0              /* t0 = t0 - 8 * register count             */
716
717         ldl     t1,FltSave(pv)        /* t1 = saved flt register count            */
718         br      t2,ex_flt1            /* t2 = current pc                          */
719 ex_flt1:
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                    */
724         ldt     $f2,-64(t0)
725         ldt     $f3,-56(t0)
726         ldt     $f4,-48(t0)
727         ldt     $f5,-40(t0)
728         ldt     $f6,-32(t0)
729         ldt     $f7,-24(t0)
730         ldt     $f8,-16(t0)
731         ldt     $f9,-8(t0)
732 ex_flt2:
733         ldl     t0,0(ra)              /* load instruction LDA PV,xxx(RA)          */
734         sll     t0,48,t0
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                            */
740         bne     t0,ex_stack_loop       
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                   */
745         br      ex_stack_loop
746
747         .end    asm_handle_nat_exception
748
749
750 /* asm_check_clinit ************************************************************
751
752    DOCUMENT ME!!!
753
754    Arguments:
755
756         itmp1: pointer to class
757
758    Stack layout:
759
760         0   mcode  ; machine code to patch back in
761
762 *******************************************************************************/
763                 
764     .ent    asm_check_clinit
765
766 asm_check_clinit:
767         ldgp    gp,0(itmp2)           /* function is called via `jsr ra,itmp1'    */
768
769         ldl             itmp2,offclassinit(itmp1)
770         bne             itmp2,L_is_initialized
771         
772         subq    sp,9*8,sp
773
774         stq             ra,0*8(sp)            /* save return address                      */
775         stq     pv,1*8(sp)            /* save pv of calling java function         */
776         stq             a0,2*8(sp)            /* save argument registers for leaf         */
777         stq             a1,3*8(sp)            /* functions and native stub                */
778         stq             a2,4*8(sp)
779         stq             a3,5*8(sp)
780         stq             a4,6*8(sp)
781         stq             a5,7*8(sp)
782                 
783         mov             itmp1,a0              /* move class pointer to a0                 */
784         jsr             ra,class_init
785     ldgp    gp,0(ra)
786                 
787         ldq             ra,0*8(sp)            /* restore return address                   */
788         ldq     pv,1*8(sp)            /* restore pv of calling java function      */
789         ldq             a0,2*8(sp)            /* restore argument registers               */
790         ldq             a1,3*8(sp)
791         ldq             a2,4*8(sp)
792         ldq             a3,5*8(sp)
793         ldq             a4,6*8(sp)
794         ldq             a5,7*8(sp)
795
796         addq    sp,9*8,sp
797
798         beq     v0,L_initializererror
799
800 L_is_initialized:
801         subq    ra,1*4,ra             /* go back 1 instructions                   */
802         ldl     itmp1,0(sp)           /* load machine code from stack             */
803         addq    sp,1*8,sp             /* remove stack frame                       */
804         stl     itmp1,0(ra)           /* store the machine code                   */
805
806         call_pal PAL_imb              /* synchronise instruction cache            */
807
808         jmp             zero,(ra)             /* jump to the new code                     */
809
810 L_initializererror:
811         addq    sp,1*8,sp             /* remove stack frame                       */
812
813 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
814         subq    sp,1*8,sp
815         stq     ra,0*8(sp)
816         jsr     ra,builtin_asm_get_exceptionptrptr
817         ldq     ra,0*8(sp)
818         addq    sp,1*8,sp
819         ldq     xptr,0(v0)            /* get the exception pointer                */
820         stq     zero,0(v0)            /* clear the exception pointer              */
821 #else
822         lda     itmp3,_exceptionptr
823         ldq     xptr,0(itmp3)
824         stq     zero,0(itmp3)
825 #endif
826
827         subq    ra,4,xpc
828         br      asm_handle_nat_exception
829
830         .end    asm_check_clinit
831
832                 
833 /********************* function asm_builtin_monitorenter ***********************
834 *                                                                              *
835 *   Does null check and calls monitorenter or throws an exception              *
836 *                                                                              *
837 *******************************************************************************/
838
839         .ent    asm_builtin_monitorenter
840
841 asm_builtin_monitorenter:
842         ldgp    gp,0(pv)
843         lda     pv,builtin_monitorenter
844         beq     a0,nb_monitorenter        /* if (null) throw exception            */
845         jmp     zero,(pv)                 /* else call builtin_monitorenter       */
846
847 nb_monitorenter:
848         subq    sp,8,sp
849     stq     ra,0(sp)
850         ldq     a0,string_java_lang_NullPointerException
851     jsr     ra,new_exception
852     ldgp    gp,0(ra)
853         mov     v0,xptr
854     ldq     ra,0(sp)
855         addq    sp,8,sp
856         
857         lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
858         br      asm_handle_nat_exception
859
860         .end    asm_builtin_monitorenter
861
862
863 /********************* function asm_builtin_monitorexit ************************
864 *                                                                              *
865 *   Does null check and calls monitorexit or throws an exception               *
866 *                                                                              *
867 *******************************************************************************/
868
869         .ent    asm_builtin_monitorexit
870
871 asm_builtin_monitorexit:
872         ldgp    gp,0(pv)
873         lda     pv,builtin_monitorexit
874         beq     a0,nb_monitorexit         /* if (null) throw exception            */
875         jmp     zero,(pv)                 /* else call builtin_monitorexit        */
876
877 nb_monitorexit:
878         subq    sp,8,sp
879     stq     ra,0(sp)
880         ldq     a0,string_java_lang_NullPointerException
881     jsr     ra,new_exception
882     ldgp    gp,0(ra)
883         mov     v0,xptr
884     ldq     ra,0(sp)
885         addq    sp,8,sp
886         
887         lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
888         br      asm_handle_nat_exception
889
890         .end    asm_builtin_monitorexit
891
892
893 /************************ function asm_builtin_idiv ****************************
894 *                                                                              *
895 *   Does null check and calls idiv or throws an exception                      *
896 *                                                                              *
897 *******************************************************************************/
898
899         .ent    asm_builtin_idiv
900
901 asm_builtin_idiv:
902         ldgp    gp,0(pv)
903         lda     pv,builtin_idiv
904         beq     a1,nb_idiv                /* if (null) throw exception            */
905         jmp     zero,(pv)                 /* else call builtin_idiv               */
906
907 nb_idiv:
908         subq    sp,8,sp
909         stq     ra,0(sp)
910         ldq     a0,string_java_lang_ArithmeticException
911         ldq     a1,string_java_lang_ArithmeticException_message
912         jsr     ra,new_exception_message
913         ldgp    gp,0(ra)
914         mov     v0,xptr
915         ldq     ra,0(sp)
916         addq    sp,8,sp
917         
918         lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
919         br      asm_handle_nat_exception
920
921         .end    asm_builtin_idiv
922
923
924 /************************ function asm_builtin_ldiv ****************************
925 *                                                                              *
926 *   Does null check and calls ldiv or throws an exception                      *
927 *                                                                              *
928 *******************************************************************************/
929
930         .ent    asm_builtin_ldiv
931
932 asm_builtin_ldiv:
933         ldgp    gp,0(pv)
934         lda     pv,builtin_ldiv
935         beq     a1,nb_ldiv                /* if (null) throw exception            */
936         jmp     zero,(pv)                 /* else call builtin_ldiv               */
937
938 nb_ldiv:
939         subq    sp,8,sp
940         stq     ra,0(sp)
941         ldq     a0,string_java_lang_ArithmeticException
942         ldq     a1,string_java_lang_ArithmeticException_message
943         jsr     ra,new_exception_message
944         ldgp    gp,0(ra)
945         mov     v0,xptr
946         ldq     ra,0(sp)
947         addq    sp,8,sp
948
949         lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
950         br      asm_handle_nat_exception
951
952         .end    asm_builtin_ldiv
953
954
955 /************************ function asm_builtin_irem ****************************
956 *                                                                              *
957 *   Does null check and calls irem or throws an exception                      *
958 *                                                                              *
959 *******************************************************************************/
960
961         .ent    asm_builtin_irem
962
963 asm_builtin_irem:
964         ldgp    gp,0(pv)
965         lda     pv,builtin_irem
966         beq     a1,nb_irem                /* if (null) throw exception            */
967         jmp     zero,(pv)                 /* else call builtin_irem               */
968
969 nb_irem:
970         subq    sp,8,sp
971         stq     ra,0(sp)
972         ldq     a0,string_java_lang_ArithmeticException
973         ldq     a1,string_java_lang_ArithmeticException_message
974         jsr     ra,new_exception_message
975         ldgp    gp,0(ra)
976         mov     v0,xptr
977         ldq     ra,0(sp)
978         addq    sp,8,sp
979
980         lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
981         br      asm_handle_nat_exception
982
983         .end    asm_builtin_irem
984
985
986 /************************ function asm_builtin_lrem ****************************
987 *                                                                              *
988 *   Does null check and calls lrem or throws an exception                      *
989 *                                                                              *
990 *******************************************************************************/
991
992         .ent    asm_builtin_lrem
993
994 asm_builtin_lrem:
995         ldgp    gp,0(pv)
996         lda     pv,builtin_lrem
997         beq     a1,nb_lrem                /* if (null) throw exception            */
998         jmp     zero,(pv)                 /* else call builtin_lrem               */
999
1000 nb_lrem:
1001         subq    sp,8,sp
1002         stq     ra,0(sp)
1003         ldq     a0,string_java_lang_ArithmeticException
1004         ldq     a1,string_java_lang_ArithmeticException_message
1005         jsr     ra,new_exception_message
1006         ldgp    gp,0(ra)
1007         mov     v0,xptr
1008         ldq     ra,0(sp)
1009         addq    sp,8,sp
1010
1011         lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
1012         br      asm_handle_nat_exception
1013
1014         .end    asm_builtin_lrem
1015
1016
1017 /******************* function asm_builtin_checkarraycast ***********************
1018 *                                                                              *
1019 *   Does the cast check and eventually throws an exception                     *
1020 *                                                                              *
1021 *******************************************************************************/
1022
1023         .ent    asm_builtin_checkarraycast
1024
1025 asm_builtin_checkarraycast:
1026         ldgp    gp,0(pv)
1027         lda     sp,-16(sp)                /* allocate stack space                 */
1028         stq     ra,0(sp)                  /* save return address                  */
1029         stq     a0,8(sp)                  /* save object pointer                  */
1030         jsr     ra,builtin_checkarraycast /* builtin_checkarraycast               */
1031         ldgp    gp,0(ra)
1032         beq     v0,nb_carray_throw        /* if (false) throw exception           */
1033         ldq     ra,0(sp)                  /* restore return address               */
1034         ldq     v0,8(sp)                  /* return object pointer                */
1035         lda     sp,16(sp)                 /* free stack space                     */
1036         jmp     zero,(ra)
1037
1038 nb_carray_throw:
1039         ldq     a0,string_java_lang_ClassCastException
1040     jsr     ra,new_exception
1041     ldgp    gp,0(ra)
1042         mov     v0,xptr
1043
1044         ldq     ra,0(sp)                  /* restore return address               */
1045         lda     sp,16(sp)                 /* free stack space                     */
1046         lda     xpc,-4(ra)                /* faulting address is return adress - 4*/
1047         br      asm_handle_nat_exception
1048
1049         .end    asm_builtin_checkarraycast
1050
1051
1052 /******************* function asm_builtin_aastore ******************************
1053 *                                                                              *
1054 *   Does the cast check and eventually throws an exception                     *
1055 *                                                                              *
1056 *******************************************************************************/
1057
1058         .ent    asm_builtin_aastore
1059
1060 asm_builtin_aastore:
1061         ldgp    gp,0(pv)
1062         beq     a0,nb_aastore_null        /* if null pointer throw exception      */
1063         ldl     t0,offarraysize(a0)       /* load size                            */
1064         lda     sp,-24(sp)                /* allocate stack space                 */
1065         stq     ra,0(sp)                  /* save return address                  */
1066         s8addq  a1,a0,t1                  /* add index*8 to arrayref              */
1067         cmpult  a1,t0,t0                  /* do bound check                       */
1068         beq     t0,nb_aastore_bound       /* if out of bounds throw exception     */
1069         mov     a2,a1                     /* object is second argument            */
1070         stq     t1,8(sp)                  /* save store position                  */
1071         stq     a1,16(sp)                 /* save object                          */
1072         jsr     ra,builtin_canstore       /* builtin_canstore(arrayref,object)    */
1073         ldgp    gp,0(ra)
1074         ldq     ra,0(sp)                  /* restore return address               */
1075         ldq     a0,8(sp)                  /* restore store position               */
1076         ldq     a1,16(sp)                 /* restore object                       */
1077         lda     sp,24(sp)                 /* free stack space                     */
1078         beq     v0,nb_aastore_throw       /* if (false) throw exception           */
1079         stq     a1,offobjarrdata(a0)      /* store objectptr in array             */
1080         jmp     zero,(ra)
1081
1082 nb_aastore_null:        
1083         subq    sp,8,sp                   /* allocate stack space                 */
1084         stq     ra,0(sp)                  /* save return address                  */
1085         ldq     a0,string_java_lang_NullPointerException
1086     jsr     ra,new_exception
1087     ldgp    gp,0(ra)
1088         mov     v0,xptr
1089         ldq     ra,0(sp)
1090         addq    sp,8,sp
1091
1092         mov     ra,xpc                    /* faulting address is return adress    */
1093         br      asm_handle_nat_exception
1094
1095 nb_aastore_bound:
1096         ldq     a0,string_java_lang_ArrayIndexOutOfBoundsException
1097     jsr     ra,new_exception_int      /* a1 already contains the index        */
1098     ldgp    gp,0(ra)
1099         mov     v0,xptr
1100
1101         ldq     ra,0(sp)                  /* restore return address               */
1102         lda     sp,24(sp)                 /* free stack space                     */
1103         mov     ra,xpc                    /* faulting address is return adress    */
1104         br      asm_handle_nat_exception
1105
1106 nb_aastore_throw:
1107         subq    sp,8,sp                   /* allocate stack space                 */
1108         stq     ra,0(sp)                  /* save return address                  */
1109         ldq     a0,string_java_lang_ArrayStoreException
1110     jsr     ra,new_exception
1111     ldgp    gp,0(ra)
1112         mov     v0,xptr
1113         ldq     ra,0(sp)
1114         addq    sp,8,sp
1115
1116         mov     ra,xpc                    /* faulting address is return adress    */
1117         br      asm_handle_nat_exception
1118
1119         .end    asm_builtin_aastore
1120
1121
1122 /******************* function asm_initialize_thread_stack **********************
1123 *                                                                              *
1124 *   initialized a thread stack                                                 *
1125 *                                                                              *
1126 *******************************************************************************/
1127
1128         .ent    asm_initialize_thread_stack
1129
1130 asm_initialize_thread_stack:
1131         lda     a1,-128(a1)
1132         stq     zero, 0(a1)
1133         stq     zero, 8(a1)
1134         stq     zero, 16(a1)
1135         stq     zero, 24(a1)
1136         stq     zero, 32(a1)
1137         stq     zero, 40(a1)
1138         stq     zero, 48(a1)
1139         stt     fzero, 56(a1)
1140         stt     fzero, 64(a1)
1141         stt     fzero, 72(a1)
1142         stt     fzero, 80(a1)
1143         stt     fzero, 88(a1)
1144         stt     fzero, 96(a1)
1145         stt     fzero, 104(a1)
1146         stt     fzero, 112(a1)
1147         stq     a0, 120(a1)
1148         mov     a1, v0
1149         jmp     zero,(ra)
1150
1151         .end    asm_initialize_thread_stack
1152
1153
1154 /******************* function asm_perform_threadswitch *************************
1155 *                                                                              *
1156 *   void asm_perform_threadswitch (u1 **from, u1 **to, u1 **stackTop);         *
1157 *                                                                              *
1158 *   performs a threadswitch                                                    *
1159 *                                                                              *
1160 *******************************************************************************/
1161
1162         .ent    asm_perform_threadswitch
1163
1164 asm_perform_threadswitch:
1165         subq    sp,128,sp
1166         stq     s0, 0(sp)
1167         stq     s1, 8(sp)
1168         stq     s2, 16(sp)
1169         stq     s3, 24(sp)
1170         stq     s4, 32(sp)
1171         stq     s5, 40(sp)
1172         stq     s6, 48(sp)
1173         stt     sf0, 56(sp)
1174         stt     sf1, 64(sp)
1175         stt     sf2, 72(sp)
1176         stt     sf3, 80(sp)
1177         stt     sf4, 88(sp)
1178         stt     sf5, 96(sp)
1179         stt     sf6, 104(sp)
1180         stt     sf7, 112(sp)
1181         stq     ra, 120(sp)
1182         stq     sp, 0(a0)
1183         stq     sp, 0(a2)
1184         ldq     sp, 0(a1)
1185         ldq     s0, 0(sp)
1186         ldq     s1, 8(sp)
1187         ldq     s2, 16(sp)
1188         ldq     s3, 24(sp)
1189         ldq     s4, 32(sp)
1190         ldq     s5, 40(sp)
1191         ldq     s6, 48(sp)
1192         ldt     sf0, 56(sp)
1193         ldt     sf1, 64(sp)
1194         ldt     sf2, 72(sp)
1195         ldt     sf3, 80(sp)
1196         ldt     sf4, 88(sp)
1197         ldt     sf5, 96(sp)
1198         ldt     sf6, 104(sp)
1199         ldt     sf7, 112(sp)
1200         ldq     ra, 120(sp)
1201         mov     ra, pv
1202         addq    sp, 128, sp
1203         jmp     zero,(ra)
1204
1205         .end    asm_perform_threadswitch
1206
1207
1208 /********************* function asm_switchstackandcall *************************
1209 *                                                                              *
1210 *  void *asm_switchstackandcall (void *stack, void *func, void **stacktopsave, *
1211 *                               void *p);                                      *
1212 *                                                                              *
1213 *   Switches to a new stack, calls a function and switches back.               *
1214 *       a0      new stack pointer                                              *
1215 *       a1      function pointer                                               *
1216 *               a2              pointer to variable where stack top should be stored           *
1217 *               a3      pointer to user data, is passed to the function                *
1218 *                                                                              *
1219 *******************************************************************************/
1220
1221
1222         .ent    asm_switchstackandcall
1223
1224 asm_switchstackandcall:
1225         lda     a0,-2*8(a0)     /* allocate new stack                                 */
1226         stq     ra,0(a0)        /* save return address on new stack                   */
1227         stq     sp,1*8(a0)      /* save old stack pointer on new stack                */
1228         stq sp,0(a2)        /* save old stack pointer to variable                 */
1229         mov     a0,sp           /* switch to new stack                                */
1230         
1231         mov     a1,pv           /* load function pointer                              */
1232         mov a3,a0           /* pass pointer */
1233         jmp     ra,(pv)         /* and call function                                  */
1234
1235         ldq     ra,0(sp)        /* load return address                                */
1236         ldq     sp,1*8(sp)      /* switch to old stack                                */
1237
1238         jmp     zero,(ra)       /* return                                             */
1239
1240         .end    asm_switchstackandcall
1241
1242         .ent    asm_getclassvalues_atomic
1243
1244 asm_getclassvalues_atomic:
1245 _crit_restart2:
1246 _crit_begin2:
1247         ldl     t0,offbaseval(a0)
1248         ldl     t1,offdiffval(a0)
1249         ldl     t2,offbaseval(a1)
1250 _crit_end2:
1251         stl     t0,offcast_super_baseval(a2)
1252         stl     t1,offcast_super_diffval(a2)
1253         stl     t2,offcast_sub_baseval(a2)
1254         jmp      zero,(ra)
1255
1256         .end    asm_getclassvalues_atomic
1257
1258     .data
1259
1260 asm_criticalsections:
1261 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
1262     .quad   _crit_begin1
1263     .quad   _crit_end1
1264     .quad   _crit_restart1
1265     .quad   _crit_begin2
1266     .quad   _crit_end2
1267     .quad   _crit_restart2
1268 #endif
1269     .quad   0
1270
1271
1272 /*
1273  * These are local overrides for various environment variables in Emacs.
1274  * Please do not remove this and leave it at the end of the file, where
1275  * Emacs will automagically detect them.
1276  * ---------------------------------------------------------------------
1277  * Local variables:
1278  * mode: asm
1279  * indent-tabs-mode: t
1280  * c-basic-offset: 4
1281  * tab-width: 4
1282  * End:
1283  */