...
Run Format

Text file src/runtime/internal/atomic/asm_amd64p32.s

Documentation: runtime/internal/atomic

     1	// Copyright 2015 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	// bool Cas(int32 *val, int32 old, int32 new)
     8	// Atomically:
     9	//	if(*val == old){
    10	//		*val = new;
    11	//		return 1;
    12	//	} else
    13	//		return 0;
    14	TEXT runtime∕internal∕atomic·Cas(SB), NOSPLIT, $0-17
    15		MOVL	ptr+0(FP), BX
    16		MOVL	old+4(FP), AX
    17		MOVL	new+8(FP), CX
    18		LOCK
    19		CMPXCHGL	CX, 0(BX)
    20		SETEQ	ret+16(FP)
    21		RET
    22	
    23	TEXT runtime∕internal∕atomic·Casuintptr(SB), NOSPLIT, $0-17
    24		JMP	runtime∕internal∕atomic·Cas(SB)
    25	
    26	TEXT runtime∕internal∕atomic·Loaduintptr(SB), NOSPLIT, $0-12
    27		JMP	runtime∕internal∕atomic·Load(SB)
    28	
    29	TEXT runtime∕internal∕atomic·Loaduint(SB), NOSPLIT, $0-12
    30		JMP	runtime∕internal∕atomic·Load(SB)
    31	
    32	TEXT runtime∕internal∕atomic·Storeuintptr(SB), NOSPLIT, $0-8
    33		JMP	runtime∕internal∕atomic·Store(SB)
    34	
    35	TEXT runtime∕internal∕atomic·Loadint64(SB), NOSPLIT, $0-16
    36		JMP	runtime∕internal∕atomic·Load64(SB)
    37	
    38	TEXT runtime∕internal∕atomic·Xaddint64(SB), NOSPLIT, $0-24
    39		JMP	runtime∕internal∕atomic·Xadd64(SB)
    40	
    41	// bool	runtime∕internal∕atomic·cas64(uint64 *val, uint64 old, uint64 new)
    42	// Atomically:
    43	//	if(*val == *old){
    44	//		*val = new;
    45	//		return 1;
    46	//	} else {
    47	//		return 0;
    48	//	}
    49	TEXT runtime∕internal∕atomic·Cas64(SB), NOSPLIT, $0-25
    50		MOVL	ptr+0(FP), BX
    51		MOVQ	old+8(FP), AX
    52		MOVQ	new+16(FP), CX
    53		LOCK
    54		CMPXCHGQ	CX, 0(BX)
    55		SETEQ	ret+24(FP)
    56		RET
    57	
    58	// bool Casp1(void **val, void *old, void *new)
    59	// Atomically:
    60	//	if(*val == old){
    61	//		*val = new;
    62	//		return 1;
    63	//	} else
    64	//		return 0;
    65	TEXT runtime∕internal∕atomic·Casp1(SB), NOSPLIT, $0-17
    66		MOVL	ptr+0(FP), BX
    67		MOVL	old+4(FP), AX
    68		MOVL	new+8(FP), CX
    69		LOCK
    70		CMPXCHGL	CX, 0(BX)
    71		SETEQ	ret+16(FP)
    72		RET
    73	
    74	// uint32 Xadd(uint32 volatile *val, int32 delta)
    75	// Atomically:
    76	//	*val += delta;
    77	//	return *val;
    78	TEXT runtime∕internal∕atomic·Xadd(SB), NOSPLIT, $0-12
    79		MOVL	ptr+0(FP), BX
    80		MOVL	delta+4(FP), AX
    81		MOVL	AX, CX
    82		LOCK
    83		XADDL	AX, 0(BX)
    84		ADDL	CX, AX
    85		MOVL	AX, ret+8(FP)
    86		RET
    87	
    88	TEXT runtime∕internal∕atomic·Xadd64(SB), NOSPLIT, $0-24
    89		MOVL	ptr+0(FP), BX
    90		MOVQ	delta+8(FP), AX
    91		MOVQ	AX, CX
    92		LOCK
    93		XADDQ	AX, 0(BX)
    94		ADDQ	CX, AX
    95		MOVQ	AX, ret+16(FP)
    96		RET
    97	
    98	TEXT runtime∕internal∕atomic·Xadduintptr(SB), NOSPLIT, $0-12
    99		JMP	runtime∕internal∕atomic·Xadd(SB)
   100	
   101	TEXT runtime∕internal∕atomic·Xchg(SB), NOSPLIT, $0-12
   102		MOVL	ptr+0(FP), BX
   103		MOVL	new+4(FP), AX
   104		XCHGL	AX, 0(BX)
   105		MOVL	AX, ret+8(FP)
   106		RET
   107	
   108	TEXT runtime∕internal∕atomic·Xchg64(SB), NOSPLIT, $0-24
   109		MOVL	ptr+0(FP), BX
   110		MOVQ	new+8(FP), AX
   111		TESTL	$7, BX
   112		JZ	2(PC)
   113		MOVL	0, BX // crash when unaligned
   114		XCHGQ	AX, 0(BX)
   115		MOVQ	AX, ret+16(FP)
   116		RET
   117	
   118	TEXT runtime∕internal∕atomic·Xchguintptr(SB), NOSPLIT, $0-12
   119		JMP	runtime∕internal∕atomic·Xchg(SB)
   120	
   121	TEXT runtime∕internal∕atomic·StorepNoWB(SB), NOSPLIT, $0-8
   122		MOVL	ptr+0(FP), BX
   123		MOVL	val+4(FP), AX
   124		XCHGL	AX, 0(BX)
   125		RET
   126	
   127	TEXT runtime∕internal∕atomic·Store(SB), NOSPLIT, $0-8
   128		MOVL	ptr+0(FP), BX
   129		MOVL	val+4(FP), AX
   130		XCHGL	AX, 0(BX)
   131		RET
   132	
   133	TEXT runtime∕internal∕atomic·Store64(SB), NOSPLIT, $0-16
   134		MOVL	ptr+0(FP), BX
   135		MOVQ	val+8(FP), AX
   136		XCHGQ	AX, 0(BX)
   137		RET
   138	
   139	// void	runtime∕internal∕atomic·Or8(byte volatile*, byte);
   140	TEXT runtime∕internal∕atomic·Or8(SB), NOSPLIT, $0-5
   141		MOVL	ptr+0(FP), BX
   142		MOVB	val+4(FP), AX
   143		LOCK
   144		ORB	AX, 0(BX)
   145		RET
   146	
   147	// void	runtime∕internal∕atomic·And8(byte volatile*, byte);
   148	TEXT runtime∕internal∕atomic·And8(SB), NOSPLIT, $0-5
   149		MOVL	ptr+0(FP), BX
   150		MOVB	val+4(FP), AX
   151		LOCK
   152		ANDB	AX, 0(BX)
   153		RET

View as plain text