99b23a1f0a1d7c5e5ed697b8c02b0360bf9c9e0a
[cacao.git] / src / vm / jit / mips / asmpart.S
1 /* src/vm/jit/mips/asmpart.S - Java-C interface functions for MIPS
2
3    Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25 */
26
27
28 #include "config.h"
29
30 #include "vm/jit/mips/md-abi.h"
31 #include "vm/jit/mips/md-asm.h"
32
33 #include "vm/jit/abi-asm.h"
34 #include "vm/jit/methodheader.h"
35
36
37         .text
38         .set    noat
39
40
41 /* export functions ***********************************************************/
42
43         .globl asm_vm_call_method
44         .globl asm_vm_call_method_int
45         .globl asm_vm_call_method_long
46         .globl asm_vm_call_method_float
47         .globl asm_vm_call_method_double
48         .globl asm_vm_call_method_exception_handler
49         .globl asm_vm_call_method_end
50
51         .globl asm_call_jit_compiler
52
53         .globl asm_handle_exception
54         .globl asm_handle_nat_exception
55
56         .globl asm_abstractmethoderror
57
58         .globl compare_and_swap
59
60
61 /* asm_vm_call_method **********************************************************
62 *                                                                              *
63 *   This function calls a Java-method (which possibly needs compilation)       *
64 *   with up to 4 address parameters.                                           *
65 *                                                                              *
66 *   This functions calls the JIT-compiler which eventually translates the      *
67 *   method into machine code.                                                  *
68 *                                                                              *
69 *   A possibly throwed exception will be returned to the caller as function    *
70 *   return value, so the java method cannot return a fucntion value (this      *
71 *   function usually calls 'main' and '<clinit>' which do not return a         *
72 *   function value).                                                           *
73 *                                                                              *
74 *   C-prototype:                                                               *
75 *    javaobject_header *asm_calljavafunction (methodinfo *m,                   *
76 *         void *arg1, void *arg2, void *arg3, void *arg4);                     *
77 *                                                                              *
78 *******************************************************************************/
79
80         .ent    asm_vm_call_method
81
82         .align  3
83
84 #if SIZEOF_VOID_P == 8
85
86         .dword  0                           /* catch type all                     */
87         .dword  0                           /* handler pc                         */
88         .dword  0                           /* end pc                             */
89         .dword  0                           /* start pc                           */
90         .word   1                           /* extable size                       */
91         .word   0                           /* 4-byte ALIGNMENT PADDING           */
92         .dword  0                           /* line number table start            */
93         .dword  0                           /* line number table size             */
94         .word   0                           /* fltsave                            */
95         .word   0                           /* intsave                            */
96         .word   0                           /* isleaf                             */
97         .word   0                           /* frame size                         */
98         .dword  0                           /* codeinfo pointer                   */
99
100 #else /* SIZEOF_VOID_P == 8 */
101
102         .word   0                           /* catch type all                     */
103         .word   0                           /* handler pc                         */
104         .word   0                           /* end pc                             */
105         .word   0                           /* start pc                           */
106         .word   1                           /* extable size                       */
107         .word   0                           /* line number table start            */
108         .word   0                           /* line number table size             */
109         .word   0                           /* fltsave                            */
110         .word   0                           /* intsave                            */
111         .word   0                           /* isleaf                             */
112         .word   0                           /* frame size                         */
113         .word   0                           /* method pointer (pointer to name)   */
114
115 #endif /* SIZEOF_VOID_P == 8 */
116
117 asm_vm_call_method:
118 asm_vm_call_method_int:
119 asm_vm_call_method_long:
120 asm_vm_call_method_float:
121 asm_vm_call_method_double:
122         .set    noreorder                 /* XXX we need to recompute pv          */
123
124         aaddiu  sp,sp,-12*8               /* allocate stack space (only 11 needed)*/
125         ast     ra,0*8(sp)                /* save return address                  */
126
127         bal     L_asm_vm_call_method_compute_pv
128         ast     pv,1*8(sp)                /* procedure vector                     */
129 L_asm_vm_call_method_compute_pv:
130         aaddiu  pv,ra,-4*4
131
132         ast     s0,3*8(sp)                /* save callee saved register           */
133         ast     a0,4*8(sp)                /* save method PV                       */
134
135 #if SIZEOF_VOID_P == 8
136         sdc1    fss0,5*8(sp)              /* save non JavaABI saved flt registers */
137         sdc1    fss1,6*8(sp)
138         sdc1    fss2,7*8(sp)
139         sdc1    fss3,8*8(sp)
140         sdc1    fss4,9*8(sp)
141         sdc1    fss5,10*8(sp)
142 #endif
143
144         move    t0,a1                     /* address of data structure            */
145         move    t1,a2                     /* stack argument count                 */
146         move    s0,sp                     /* save stack pointer                   */
147
148 #if SIZEOF_VOID_P == 8
149
150         ld      a0,0*8(t0)
151         ld      a1,1*8(t0)
152         ld      a2,2*8(t0)
153         ld      a3,3*8(t0)
154         ld      a4,4*8(t0)
155         ld      a5,5*8(t0)
156         ld      a6,6*8(t0)
157         ld      a7,7*8(t0)
158
159         ldc1    fa0,8*8(t0)
160         ldc1    fa1,9*8(t0)
161         ldc1    fa2,10*8(t0)
162         ldc1    fa3,11*8(t0)
163         ldc1    fa4,12*8(t0)
164         ldc1    fa5,13*8(t0)
165         ldc1    fa6,14*8(t0)
166         ldc1    fa7,15*8(t0)
167
168 #else /* SIZEOF_VOID_P == 8 */
169
170 # if WORDS_BIGENDIAN == 1
171         lw      a0,0*8+4(t0)
172         lw      a1,1*8+4(t0)
173         lw      a2,2*8+4(t0)
174         lw      a3,3*8+4(t0)
175 # else
176         lw      a0,0*8(t0)
177         lw      a1,1*8(t0)
178         lw      a2,2*8(t0)
179         lw      a3,3*8(t0)
180 # endif
181
182 # if !defined(ENABLE_SOFT_FLOAT)
183         ldc1    fa0,4*8(t0)
184         ldc1    fa1,5*8(t0)
185 # endif
186
187 #endif /* SIZEOF_VOID_P == 8 */
188
189         beqz    t1,L_asm_vm_call_method_stack_copy_done
190         nop
191
192         sll     t2,t1,3                   /* calculate stackframe size (* 8)      */
193         asubu   sp,sp,t2                  /* create stackframe                    */
194         move    t2,sp                     /* temporary stack pointer              */
195
196 L_asm_vm_call_method_stack_copy_loop:
197 #if SIZEOF_VOID_P == 8
198         ld      t3,16*8(t0)               /* load argument                        */
199         sd      t3,0(t2)                  /* store argument on stack              */
200 #else
201 # if !defined(ENABLE_SOFT_FLOAT)
202         lw      t3,6*8+0(t0)              /* load argument                        */
203         lw      t4,6*8+4(t0)
204         sw      t3,0(t2)                  /* store argument on stack              */
205         sw      t4,4(t2)
206 # else
207 #  error implement me
208 # endif
209 #endif
210
211         aaddi   t1,t1,-1                  /* subtract 1 argument                  */
212         aaddi   t0,t0,8                   /* load address of next argument        */
213         aaddi   t2,t2,8                   /* increase stack pointer               */
214
215         bgtz    t1,L_asm_vm_call_method_stack_copy_loop
216         nop
217
218 L_asm_vm_call_method_stack_copy_done:
219         ala     mptr,4*8(s0)              /* get address of PV                    */
220         ald     pv,0*8(mptr)              /* load PV                              */
221         jalr    pv
222         nop
223 L_asm_vm_call_method_recompute_pv:
224 #if SIZEOF_VOID_P == 8
225         aaddiu  pv,ra,-76*4               /* recompute procedure vector           */
226 #else
227         aaddiu  pv,ra,(asm_vm_call_method - L_asm_vm_call_method_recompute_pv)
228 #endif
229
230         .set    reorder                   /* XXX we need to recompute pv          */
231
232         move    sp,s0                     /* restore stack pointer                */
233
234 calljava_return2:
235         ald     ra,0*8(sp)                /* restore return address               */
236         ald     pv,1*8(sp)                /* restore procedure vector             */
237         ald     s0,3*8(sp)
238
239 #if SIZEOF_VOID_P == 8
240         ldc1    fss0,5*8(sp)              /* restore non JavaABI saved flt regs   */
241         ldc1    fss1,6*8(sp)
242         ldc1    fss2,7*8(sp)
243         ldc1    fss3,8*8(sp)
244         ldc1    fss4,9*8(sp)
245         ldc1    fss5,10*8(sp)
246 #endif
247
248         aaddiu  sp,sp,12*8                /* free stack space                     */
249         j       ra                        /* return                               */
250
251 asm_vm_call_method_exception_handler:
252         move    sp,s0                     /* restore stack pointer                */
253 #if SIZEOF_VOID_P == 4
254         aaddiu  sp,sp,-4*4                /* reserve space for 1 argument         */
255 #endif
256
257         move    a0,itmp1                  
258         jal     builtin_throw_exception
259 #if SIZEOF_VOID_P == 4
260         aaddiu  sp,sp,4*4
261 #endif
262 asm_vm_call_method_end:
263         b       calljava_return2
264
265         .end    asm_vm_call_method
266
267
268 /****************** function asm_call_jit_compiler *****************************
269 *                                                                              *
270 *   invokes the compiler for untranslated JavaVM methods.                      *
271 *                                                                              *
272 *   Register REG_ITEMP1 contains a pointer to the method info structure        *
273 *   (prepared by createcompilerstub). Using the return address in R31 and the  *
274 *   offset in the LDA instruction or using the value in methodptr R25 the      *
275 *   patching address for storing the method address can be computed:           *
276 *                                                                              *
277 *   method address was either loaded using                                     *
278 *   M_ALD (REG_PV, REG_PV, a)        ; invokestatic/special    ($28)           *
279 *   M_JSR (REG_RA, REG_PV);                                                    *
280 *   M_NOP                                                                      *
281 *   M_LDA (REG_PV, REG_RA, val)                                                *
282 *   or                                                                         *
283 *   M_ALD (REG_PV, REG_METHODPTR, m) ; invokevirtual/interface ($25)           *
284 *   M_JSR (REG_RA, REG_PV);                                                    *
285 *   M_NOP                                                                      *
286 *   in the static case the method pointer can be computed using the            *
287 *   return address and the lda function following the jmp instruction          *
288 *                                                                              *
289 *******************************************************************************/
290
291         .ent    asm_call_jit_compiler
292
293 asm_call_jit_compiler:
294 #if SIZEOF_VOID_P == 8
295
296         aaddiu  sp,sp,-(ARG_CNT+2)*8  /* +2: keep stack 16-bytes aligned          */
297
298         ast     ra,0*8(sp)            /* save return address                      */
299
300         SAVE_ARGUMENT_REGISTERS(1)
301
302         move    a0,itmp1              /* pass methodinfo pointer                  */
303         move    a1,mptr               /* pass method pointer                      */
304         aaddiu  a2,sp,(ARG_CNT+2)*8   /* pass java sp                             */
305         move    a3,ra
306         jal     jit_asm_compile       /* call jit compiler                        */
307         move    pv,v0
308
309         ald     ra,0*8(sp)            /* restore return address                   */
310
311         RESTORE_ARGUMENT_REGISTERS(1)
312
313         aaddiu  sp,sp,(ARG_CNT+2)*8   /* remove stack frame                       */
314
315 #else /* SIZEOF_VOID_P == 8 */
316
317         aaddiu  sp,sp,-(ARG_CNT+2)*8  /* +4: keep stack 16-bytes aligned          */
318
319         ast     ra,4*4+0*4(sp)        /* save return address                      */
320
321         SAVE_ARGUMENT_REGISTERS(6)
322
323         move    a0,itmp1              /* pass methodinfo pointer                  */
324         move    a1,mptr               /* pass method pointer                      */
325         aaddiu  a2,sp,(ARG_CNT+2)*8   /* pass java sp                             */
326         move    a3,ra
327         jal     jit_asm_compile       /* call jit compiler                        */
328         move    pv,v0
329
330         ald     ra,4*4+0*4(sp)        /* restore return address                   */
331
332         RESTORE_ARGUMENT_REGISTERS(6)
333
334         aaddiu  sp,sp,(ARG_CNT+2)*8   /* remove stack frame                       */
335
336 #endif /* SIZEOF_VOID_P == 8 */
337
338         beqz    pv,L_asm_call_jit_compiler_exception
339
340         jr      pv                    /* and call method. The method returns      */
341                                       /* directly to the caller (ra).             */
342
343 L_asm_call_jit_compiler_exception:
344         aaddiu  sp,sp,-2*8
345         ast     ra,0*8(sp)
346         jal     exceptions_get_and_clear_exception
347         ald     ra,0*8(sp)
348         aaddiu  sp,sp,2*8
349
350         move    xptr,v0               /* get exception                            */
351         aaddiu  xpc,ra,-4             /* exception address is RA - 4              */
352         b       asm_handle_nat_exception
353
354         .end    asm_call_jit_compiler
355
356
357 /* asm_handle_exception ********************************************************
358
359    This function handles an exception. It does not use the usual calling
360    conventions. The exception pointer is passed in REG_ITMP1 and the
361    pc from the exception raising position is passed in REG_ITMP2. It searches
362    the local exception table for a handler. If no one is found, it unwinds
363    stacks and continues searching the callers.
364
365 *******************************************************************************/
366
367         .ent    asm_handle_nat_exception
368
369 asm_handle_nat_exception:
370 L_asm_handle_exception_stack_loop:
371 #if SIZEOF_VOID_P == 8
372         aaddiu  sp,sp,-6*8                  /* keep stack 16-byte aligned         */
373         ast     xptr,0*8(sp)                /* save exception pointer             */
374         ast     xpc,1*8(sp)                 /* save exception pc                  */
375         ast     ra,3*8(sp)                  /* save RA                            */
376         ast     zero,4*8(sp)                /* save maybe-leaf flag (cleared)     */
377 #else
378         aaddiu  sp,sp,-(4*4+6*8)            /* allocate stack                     */
379         ast     xptr,4*4+0*8(sp)            /* save exception pointer             */
380         ast     xpc,4*4+1*8(sp)             /* save exception pc                  */
381         ast     ra,4*4+3*8(sp)              /* save return address                */
382         ast     zero,4*4+4*8(sp)            /* save maybe-leaf flag (cleared)     */
383 #endif
384
385         move    a0,ra                       /* pass RA                            */
386         jal     md_codegen_get_pv_from_pc   /* get PV from RA                     */
387
388 #if SIZEOF_VOID_P == 8
389         ast     v0,2*8(sp)                  /* save PV                            */
390
391         ald     a0,0*8(sp)                  /* pass xptr                          */
392         ald     a1,1*8(sp)                  /* pass xpc                           */
393         move    a2,v0                       /* pass PV                            */
394         aaddiu  a3,sp,6*8                   /* pass Java SP                       */
395 #else
396         ast     v0,4*4+2*8(sp)              /* save data segment pointer          */
397
398         ald     a0,4*4+0*8(sp)              /* pass exception pointer             */
399         ald     a1,4*4+1*8(sp)              /* pass exception pc                  */
400         move    a2,v0                       /* pass data segment pointer          */
401         aaddiu  a3,sp,(4*4+6*8)             /* pass Java stack pointer            */
402 #endif
403
404         b       L_asm_handle_exception_continue
405
406         .aent    asm_handle_exception
407
408 asm_handle_exception:
409         aaddiu  sp,sp,-(ARG_CNT+TMP_CNT)*8  /* create maybe-leaf stackframe       */
410
411         SAVE_ARGUMENT_REGISTERS(0)          /* we save arg and temp registers in  */
412         SAVE_TEMPORARY_REGISTERS(ARG_CNT)   /* case this is a leaf method         */
413
414 #if SIZEOF_VOID_P == 8
415         aaddiu  sp,sp,-6*8                  /* allocate stack                     */
416         ast     xptr,0*8(sp)                /* save exception pointer             */
417         ast     pv,2*8(sp)                  /* save PV                            */
418         ast     ra,3*8(sp)                  /* save RA                            */
419         addu    t0,zero,1                   /* set maybe-leaf flag                */
420         ast     t0,4*8(sp)                  /* save maybe-leaf flag               */
421 #else
422         aaddiu  sp,sp,-(4*4+6*8)            /* allocate stack                     */
423         ast     xptr,4*4+0*8(sp)            /* save exception pointer             */
424         ast     xpc,4*4+1*8(sp)             /* save exception pc                  */
425         ast     pv,4*4+2*8(sp)              /* save data segment pointer          */
426         ast     ra,4*4+3*8(sp)              /* save return address                */
427         addu    t0,zero,1                   /* set maybe-leaf flag                */
428         ast     t0,4*4+4*8(sp)              /* save maybe-leaf flag               */
429 #endif
430
431         move    a0,xptr                     /* pass xptr                          */
432         move    a1,xpc                      /* pass xpc                           */
433         move    a2,pv                       /* pass PV                            */
434
435 #if SIZEOF_VOID_P == 8
436         aaddiu  a3,sp,(ARG_CNT+TMP_CNT+6)*8 /* pass Java SP                       */
437 #else
438         aaddiu  a3,sp,4*4+(ARG_CNT+TMP_CNT+6)*8 /* pass Java stack pointer        */
439 #endif
440
441 L_asm_handle_exception_continue:
442         jal     exceptions_handle_exception
443         
444         beqz    v0,L_asm_handle_exception_not_catched
445
446         move    xpc,v0                      /* move handlerpc into xpc            */
447
448 #if SIZEOF_VOID_P == 8
449         ald     xptr,0*8(sp)                /* restore exception pointer          */
450         ald     pv,2*8(sp)                  /* restore PV                         */
451         ald     ra,3*8(sp)                  /* restore RA                         */
452         ald     t0,4*8(sp)                  /* get maybe-leaf flag                */
453         aaddiu  sp,sp,6*8                   /* free stackframe                    */
454 #else
455         ald     xptr,4*4+0*8(sp)            /* restore exception pointer          */
456         ald     pv,4*4+2*8(sp)              /* restore data segment pointer       */
457         ald     ra,4*4+3*8(sp)              /* restore return address             */
458         ald     t0,4*4+4*8(sp)              /* get maybe-leaf flag                */
459         aaddiu  sp,sp,4*4+6*8               /* free stackframe                    */
460 #endif
461         
462         beqz    t0,L_asm_handle_exception_no_leaf
463
464         RESTORE_ARGUMENT_REGISTERS(0)       /* if this is a leaf method, we have  */
465         RESTORE_TEMPORARY_REGISTERS(ARG_CNT)/* to restore arg and temp registers  */
466         
467         aaddiu  sp,sp,(ARG_CNT+TMP_CNT)*8   /* remove maybe-leaf stackframe       */
468
469 L_asm_handle_exception_no_leaf:
470         jr      xpc                         /* jump to the handler                */
471
472 L_asm_handle_exception_not_catched:
473 #if SIZEOF_VOID_P == 8
474         ald     xptr,0*8(sp)                /* restore xptr                       */
475         ald     pv,2*8(sp)                  /* restore PV                         */
476         ald     ra,3*8(sp)                  /* restore RA                         */
477         ald     t0,4*8(sp)                  /* get maybe-leaf flag                */
478         aaddiu  sp,sp,6*8                   /* free stackframe                    */
479 #else
480         ald     xptr,4*4+0*8(sp)            /* restore xptr                       */
481         ald     pv,4*4+2*8(sp)              /* restore PV                         */
482         ald     ra,4*4+3*8(sp)              /* restore RA                         */
483         ald     t0,4*4+4*8(sp)              /* get maybe-leaf flag                */
484         aaddiu  sp,sp,4*4+6*8               /* free stackframe                    */
485 #endif
486         
487         beqz    t0,L_asm_handle_exception_no_leaf_stack
488
489         aaddiu  sp,sp,(ARG_CNT+TMP_CNT)*8   /* remove maybe-leaf stackframe       */
490         move    t0,zero                     /* clear the maybe-leaf flag          */
491
492 L_asm_handle_exception_no_leaf_stack:
493         lw      t1,FrameSize(pv)            /* get frame size                     */
494         aaddu   t1,sp,t1                    /* pointer to save area               */
495
496         lw      t2,IsLeaf(pv)               /* is leaf procedure                  */
497         bnez    t2,L_asm_handle_exception_no_ra_restore
498
499         ald     ra,-1*8(t1)                 /* restore ra                         */
500         aaddiu  t1,t1,-8                    /* t1--                               */
501
502 L_asm_handle_exception_no_ra_restore:
503         move    xpc,ra                      /* the new xpc is ra                  */
504         lw      t2,IntSave(pv)              /* t1 = saved int register count      */
505         ala     t3,ex_int2                  /* t3 = current pc                    */
506         sll     t2,t2,2                     /* t2 = register count * 4            */
507         asubu   t3,t3,t2                    /* t3 = IntSave - 4 * register count  */
508         jr      t3                          /* jump to save position              */
509
510         ald     s0,-8*8(t1)
511         ald     s1,-7*8(t1)
512         ald     s2,-6*8(t1)
513         ald     s3,-5*8(t1)
514         ald     s4,-4*8(t1)
515         ald     s5,-3*8(t1)
516         ald     s6,-2*8(t1)
517         ald     s7,-1*8(t1)
518
519 ex_int2:
520         sll     t2,t2,1               /* t2 = register count * 4 * 2              */
521         asubu   t1,t1,t2              /* t1 = t0 - 8 * register count             */
522
523         lw      t2,FltSave(pv)        /* t2 = saved flt register count            */
524         ala     t3,ex_flt2            /* t3 = current pc                          */
525         sll     t2,t2,2               /* t2 = register count * 4                  */
526         asubu   t3,t3,t2              /* t3 = ex_int_sav - 4 * register count     */
527         jr      t3                          /* jump to save position              */
528
529 #if SIZEOF_VOID_P == 8
530         ldc1    fs0,-4*8(t1)
531         ldc1    fs1,-3*8(t1)
532         ldc1    fs2,-2*8(t1)
533         ldc1    fs3,-1*8(t1)
534 #else /* SIZEOF_VOID_P == 8 */
535 # if !defined(ENABLE_SOFT_FLOAT)
536         ldc1    fs0,-4*8(t1)
537         ldc1    fs1,-3*8(t1)
538         ldc1    fs2,-2*8(t1)
539         ldc1    fs3,-1*8(t1)
540         ldc1    fs4,-1*8(t1)
541         ldc1    fs5,-1*8(t1)
542 # endif /* !defined(ENABLE_SOFT_FLOAT) */
543 #endif /* SIZEOF_VOID_P == 8 */
544
545 ex_flt2:
546         lw      t1,FrameSize(pv)            /* get frame size                     */
547         aaddu   sp,sp,t1                    /* unwind stack                       */
548         b       L_asm_handle_exception_stack_loop
549
550         .end    asm_handle_nat_exception
551
552
553 /* asm_abstractmethoderror *****************************************************
554
555    Creates and throws an AbstractMethodError.
556
557 *******************************************************************************/
558
559         .ent    asm_abstractmethoderror
560
561 asm_abstractmethoderror:
562         aaddiu  sp,sp,-2*8                  /* create stackframe                  */
563         ast     ra,0*8(sp)                  /* save return address                */
564         aaddiu  a0,sp,2*8                   /* pass java sp                       */
565         move    a1,ra                       /* pass exception address             */
566         jal     exceptions_asm_new_abstractmethoderror
567         ald     ra,0*8(sp)                  /* restore return address             */
568         aaddiu  sp,sp,2*8                   /* remove stackframe                  */
569
570         move    xptr,v0                     /* get exception pointer              */
571         aaddiu  xpc,ra,-4                   /* exception address is ra - 4        */
572         b       asm_handle_nat_exception
573
574         .end    asm_abstractmethoderror
575
576
577         .ent    compare_and_swap
578
579 compare_and_swap:
580 1:
581         all     v0,0(a0)
582         bne     v0,a1,2f
583         move    t0,a2
584         asc     t0,0(a0)
585         beqz    t0,1b
586 2:
587         sync
588         j       ra
589
590         .end    compare_and_swap
591
592
593 /* disable exec-stacks ********************************************************/
594
595 #if defined(__linux__) && defined(__ELF__)
596         .section .note.GNU-stack,"",%progbits
597 #endif
598
599
600 /*
601  * These are local overrides for various environment variables in Emacs.
602  * Please do not remove this and leave it at the end of the file, where
603  * Emacs will automagically detect them.
604  * ---------------------------------------------------------------------
605  * Local variables:
606  * mode: asm
607  * indent-tabs-mode: t
608  * c-basic-offset: 4
609  * tab-width: 4
610  * End:
611  * vim:noexpandtab:sw=4:ts=4:
612  */