github.com/golang-haiku/go-1.4.3@v0.0.0-20190609233734-1f5ae41cc308/src/sync/atomic/asm_amd64p32.s (about)

     1  // Copyright 2011 The Go Authors.  All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  #include "textflag.h"
     6  
     7  TEXT ·SwapInt32(SB),NOSPLIT,$0-12
     8  	JMP	·SwapUint32(SB)
     9  
    10  TEXT ·SwapUint32(SB),NOSPLIT,$0-12
    11  	MOVL	addr+0(FP), BX
    12  	MOVL	new+4(FP), AX
    13  	XCHGL	AX, 0(BX)
    14  	MOVL	AX, old+8(FP)
    15  	RET
    16  
    17  TEXT ·SwapInt64(SB),NOSPLIT,$0-24
    18  	JMP	·SwapUint64(SB)
    19  
    20  TEXT ·SwapUint64(SB),NOSPLIT,$0-24
    21  	MOVL	addr+0(FP), BX
    22  	TESTL	$7, BX
    23  	JZ	2(PC)
    24  	MOVL	0, BX // crash with nil ptr deref
    25  	MOVQ	new+8(FP), AX
    26  	XCHGQ	AX, 0(BX)
    27  	MOVQ	AX, old+16(FP)
    28  	RET
    29  
    30  TEXT ·SwapUintptr(SB),NOSPLIT,$0-12
    31  	JMP	·SwapUint32(SB)
    32  
    33  TEXT ·SwapPointer(SB),NOSPLIT,$0-12
    34  	JMP	·SwapUint32(SB)
    35  
    36  TEXT ·CompareAndSwapInt32(SB),NOSPLIT,$0-17
    37  	JMP	·CompareAndSwapUint32(SB)
    38  
    39  TEXT ·CompareAndSwapUint32(SB),NOSPLIT,$0-17
    40  	MOVL	addr+0(FP), BX
    41  	MOVL	old+4(FP), AX
    42  	MOVL	new+8(FP), CX
    43  	LOCK
    44  	CMPXCHGL	CX, 0(BX)
    45  	SETEQ	swapped+16(FP)
    46  	RET
    47  
    48  TEXT ·CompareAndSwapUintptr(SB),NOSPLIT,$0-17
    49  	JMP	·CompareAndSwapUint32(SB)
    50  
    51  TEXT ·CompareAndSwapPointer(SB),NOSPLIT,$0-17
    52  	JMP	·CompareAndSwapUint32(SB)
    53  
    54  TEXT ·CompareAndSwapInt64(SB),NOSPLIT,$0-25
    55  	JMP	·CompareAndSwapUint64(SB)
    56  
    57  TEXT ·CompareAndSwapUint64(SB),NOSPLIT,$0-25
    58  	MOVL	addr+0(FP), BX
    59  	TESTL	$7, BX
    60  	JZ	2(PC)
    61  	MOVL	0, BX // crash with nil ptr deref
    62  	MOVQ	old+8(FP), AX
    63  	MOVQ	new+16(FP), CX
    64  	LOCK
    65  	CMPXCHGQ	CX, 0(BX)
    66  	SETEQ	swapped+24(FP)
    67  	RET
    68  
    69  TEXT ·AddInt32(SB),NOSPLIT,$0-12
    70  	JMP	·AddUint32(SB)
    71  
    72  TEXT ·AddUint32(SB),NOSPLIT,$0-12
    73  	MOVL	addr+0(FP), BX
    74  	MOVL	delta+4(FP), AX
    75  	MOVL	AX, CX
    76  	LOCK
    77  	XADDL	AX, 0(BX)
    78  	ADDL	AX, CX
    79  	MOVL	CX, new+8(FP)
    80  	RET
    81  
    82  TEXT ·AddUintptr(SB),NOSPLIT,$0-12
    83  	JMP	·AddUint32(SB)
    84  
    85  TEXT ·AddInt64(SB),NOSPLIT,$0-24
    86  	JMP	·AddUint64(SB)
    87  
    88  TEXT ·AddUint64(SB),NOSPLIT,$0-24
    89  	MOVL	addr+0(FP), BX
    90  	TESTL	$7, BX
    91  	JZ	2(PC)
    92  	MOVL	0, BX // crash with nil ptr deref
    93  	MOVQ	delta+8(FP), AX
    94  	MOVQ	AX, CX
    95  	LOCK
    96  	XADDQ	AX, 0(BX)
    97  	ADDQ	AX, CX
    98  	MOVQ	CX, new+16(FP)
    99  	RET
   100  
   101  TEXT ·LoadInt32(SB),NOSPLIT,$0-12
   102  	JMP	·LoadUint32(SB)
   103  
   104  TEXT ·LoadUint32(SB),NOSPLIT,$0-12
   105  	MOVL	addr+0(FP), AX
   106  	MOVL	0(AX), AX
   107  	MOVL	AX, val+8(FP)
   108  	RET
   109  
   110  TEXT ·LoadInt64(SB),NOSPLIT,$0-16
   111  	JMP	·LoadUint64(SB)
   112  
   113  TEXT ·LoadUint64(SB),NOSPLIT,$0-16
   114  	MOVL	addr+0(FP), AX
   115  	TESTL	$7, AX
   116  	JZ	2(PC)
   117  	MOVL	0, AX // crash with nil ptr deref
   118  	MOVQ	0(AX), AX
   119  	MOVQ	AX, val+8(FP)
   120  	RET
   121  
   122  TEXT ·LoadUintptr(SB),NOSPLIT,$0-12
   123  	JMP	·LoadPointer(SB)
   124  
   125  TEXT ·LoadPointer(SB),NOSPLIT,$0-12
   126  	MOVL	addr+0(FP), AX
   127  	MOVL	0(AX), AX
   128  	MOVL	AX, val+8(FP)
   129  	RET
   130  
   131  TEXT ·StoreInt32(SB),NOSPLIT,$0-8
   132  	JMP	·StoreUint32(SB)
   133  
   134  TEXT ·StoreUint32(SB),NOSPLIT,$0-8
   135  	MOVL	addr+0(FP), BX
   136  	MOVL	val+4(FP), AX
   137  	XCHGL	AX, 0(BX)
   138  	RET
   139  
   140  TEXT ·StoreInt64(SB),NOSPLIT,$0-16
   141  	JMP	·StoreUint64(SB)
   142  
   143  TEXT ·StoreUint64(SB),NOSPLIT,$0-16
   144  	MOVL	addr+0(FP), BX
   145  	TESTL	$7, BX
   146  	JZ	2(PC)
   147  	MOVL	0, BX // crash with nil ptr deref
   148  	MOVQ	val+8(FP), AX
   149  	XCHGQ	AX, 0(BX)
   150  	RET
   151  
   152  TEXT ·StoreUintptr(SB),NOSPLIT,$0-8
   153  	JMP	·StorePointer(SB)
   154  
   155  TEXT ·StorePointer(SB),NOSPLIT,$0-8
   156  	MOVL	addr+0(FP), BX
   157  	MOVL	val+4(FP), AX
   158  	XCHGL	AX, 0(BX)
   159  	RET