1
0
mirror of https://github.com/golang/go synced 2024-11-18 09:34:53 -07:00

runtime/internal/atomic: add Store8

We already have Load8, And8, and Or8.

For #10958, #24543, but makes sense on its own.

Change-Id: I478529fc643edc57efdeccaae413c99edd19b2eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/203283
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
Austin Clements 2019-10-23 09:47:53 -04:00
parent fd1e60f6e3
commit d2101e5490
18 changed files with 118 additions and 0 deletions

View File

@ -229,3 +229,9 @@ TEXT runtimeinternalatomic·And8(SB), NOSPLIT, $0-5
LOCK LOCK
ANDB BX, (AX) ANDB BX, (AX)
RET RET
TEXT runtimeinternalatomic·Store8(SB), NOSPLIT, $0-5
MOVL ptr+0(FP), BX
MOVB val+4(FP), AX
XCHGB AX, 0(BX)
RET

View File

@ -136,6 +136,12 @@ TEXT runtimeinternalatomic·Store(SB), NOSPLIT, $0-12
TEXT runtimeinternalatomic·StoreRel(SB), NOSPLIT, $0-12 TEXT runtimeinternalatomic·StoreRel(SB), NOSPLIT, $0-12
JMP runtimeinternalatomic·Store(SB) JMP runtimeinternalatomic·Store(SB)
TEXT runtimeinternalatomic·Store8(SB), NOSPLIT, $0-9
MOVQ ptr+0(FP), BX
MOVB val+8(FP), AX
XCHGB AX, 0(BX)
RET
TEXT runtimeinternalatomic·Store64(SB), NOSPLIT, $0-16 TEXT runtimeinternalatomic·Store64(SB), NOSPLIT, $0-16
MOVQ ptr+0(FP), BX MOVQ ptr+0(FP), BX
MOVQ val+8(FP), AX MOVQ val+8(FP), AX

View File

@ -166,6 +166,14 @@ TEXT ·Store(SB), NOSPLIT, $0-12
SYNC SYNC
RET RET
TEXT ·Store8(SB), NOSPLIT, $0-9
MOVV ptr+0(FP), R1
MOVB val+8(FP), R2
SYNC
MOVB R2, 0(R1)
SYNC
RET
TEXT ·Store64(SB), NOSPLIT, $0-16 TEXT ·Store64(SB), NOSPLIT, $0-16
MOVV ptr+0(FP), R1 MOVV ptr+0(FP), R1
MOVV val+8(FP), R2 MOVV val+8(FP), R2

View File

@ -32,6 +32,14 @@ TEXT ·Store(SB),NOSPLIT,$0-8
SYNC SYNC
RET RET
TEXT ·Store8(SB),NOSPLIT,$0-5
MOVW ptr+0(FP), R1
MOVB val+4(FP), R2
SYNC
MOVB R2, 0(R1)
SYNC
RET
TEXT ·Load(SB),NOSPLIT,$0-8 TEXT ·Load(SB),NOSPLIT,$0-8
MOVW ptr+0(FP), R1 MOVW ptr+0(FP), R1
SYNC SYNC

View File

@ -170,6 +170,13 @@ TEXT runtimeinternalatomic·Store(SB), NOSPLIT, $0-12
MOVW R4, 0(R3) MOVW R4, 0(R3)
RET RET
TEXT runtimeinternalatomic·Store8(SB), NOSPLIT, $0-9
MOVD ptr+0(FP), R3
MOVB val+8(FP), R4
SYNC
MOVB R4, 0(R3)
RET
TEXT runtimeinternalatomic·Store64(SB), NOSPLIT, $0-16 TEXT runtimeinternalatomic·Store64(SB), NOSPLIT, $0-16
MOVD ptr+0(FP), R3 MOVD ptr+0(FP), R3
MOVD val+8(FP), R4 MOVD val+8(FP), R4

View File

@ -12,6 +12,14 @@ TEXT ·Store(SB), NOSPLIT, $0
SYNC SYNC
RET RET
// func Store8(ptr *uint8, val uint8)
TEXT ·Store8(SB), NOSPLIT, $0
MOVD ptr+0(FP), R2
MOVB val+8(FP), R3
MOVB R3, 0(R2)
SYNC
RET
// func Store64(ptr *uint64, val uint64) // func Store64(ptr *uint64, val uint64)
TEXT ·Store64(SB), NOSPLIT, $0 TEXT ·Store64(SB), NOSPLIT, $0
MOVD ptr+0(FP), R2 MOVD ptr+0(FP), R2

View File

@ -74,6 +74,9 @@ func CasRel(ptr *uint32, old, new uint32) bool
//go:noescape //go:noescape
func Store(ptr *uint32, val uint32) func Store(ptr *uint32, val uint32)
//go:noescape
func Store8(ptr *uint8, val uint8)
//go:noescape //go:noescape
func Store64(ptr *uint64, val uint64) func Store64(ptr *uint64, val uint64)

View File

@ -76,6 +76,9 @@ func CasRel(ptr *uint32, old, new uint32) bool
//go:noescape //go:noescape
func Store(ptr *uint32, val uint32) func Store(ptr *uint32, val uint32)
//go:noescape
func Store8(ptr *uint8, val uint8)
//go:noescape //go:noescape
func Store64(ptr *uint64, val uint64) func Store64(ptr *uint64, val uint64)

View File

@ -209,5 +209,8 @@ func Xchg64(addr *uint64, v uint64) uint64
//go:noescape //go:noescape
func Load64(addr *uint64) uint64 func Load64(addr *uint64) uint64
//go:noescape
func Store8(addr *uint8, v uint8)
//go:noescape //go:noescape
func Store64(addr *uint64, v uint64) func Store64(addr *uint64, v uint64)

View File

@ -56,6 +56,9 @@ func CasRel(ptr *uint32, old, new uint32) bool
//go:noescape //go:noescape
func Store(ptr *uint32, val uint32) func Store(ptr *uint32, val uint32)
//go:noescape
func Store8(ptr *uint8, val uint8)
//go:noescape //go:noescape
func Store64(ptr *uint64, val uint64) func Store64(ptr *uint64, val uint64)

View File

@ -48,6 +48,12 @@ TEXT runtimeinternalatomic·Store(SB), NOSPLIT, $0-12
STLRW R1, (R0) STLRW R1, (R0)
RET RET
TEXT runtimeinternalatomic·Store8(SB), NOSPLIT, $0-9
MOVD ptr+0(FP), R0
MOVB val+8(FP), R1
STLRB R1, (R0)
RET
TEXT runtimeinternalatomic·Store64(SB), NOSPLIT, $0-16 TEXT runtimeinternalatomic·Store64(SB), NOSPLIT, $0-16
MOVD ptr+0(FP), R0 MOVD ptr+0(FP), R0
MOVD val+8(FP), R1 MOVD val+8(FP), R1

View File

@ -58,6 +58,9 @@ func CasRel(ptr *uint32, old, new uint32) bool
//go:noescape //go:noescape
func Store(ptr *uint32, val uint32) func Store(ptr *uint32, val uint32)
//go:noescape
func Store8(ptr *uint8, val uint8)
//go:noescape //go:noescape
func Store64(ptr *uint64, val uint64) func Store64(ptr *uint64, val uint64)

View File

@ -141,6 +141,9 @@ func Or8(ptr *uint8, val uint8)
//go:noescape //go:noescape
func Store(ptr *uint32, val uint32) func Store(ptr *uint32, val uint32)
//go:noescape
func Store8(ptr *uint8, val uint8)
// NO go:noescape annotation; see atomic_pointer.go. // NO go:noescape annotation; see atomic_pointer.go.
func StorepNoWB(ptr unsafe.Pointer, val unsafe.Pointer) func StorepNoWB(ptr unsafe.Pointer, val unsafe.Pointer)

View File

@ -58,6 +58,9 @@ func CasRel(ptr *uint32, old, new uint32) bool
//go:noescape //go:noescape
func Store(ptr *uint32, val uint32) func Store(ptr *uint32, val uint32)
//go:noescape
func Store8(ptr *uint8, val uint8)
//go:noescape //go:noescape
func Store64(ptr *uint64, val uint64) func Store64(ptr *uint64, val uint64)

View File

@ -44,6 +44,9 @@ func LoadAcq(ptr *uint32) uint32 {
//go:noescape //go:noescape
func Store(ptr *uint32, val uint32) func Store(ptr *uint32, val uint32)
//go:noescape
func Store8(ptr *uint8, val uint8)
//go:noescape //go:noescape
func Store64(ptr *uint64, val uint64) func Store64(ptr *uint64, val uint64)

View File

@ -141,6 +141,12 @@ func StoreRel(ptr *uint32, val uint32) {
*ptr = val *ptr = val
} }
//go:nosplit
//go:noinline
func Store8(ptr *uint8, val uint8) {
*ptr = val
}
//go:nosplit //go:nosplit
//go:noinline //go:noinline
func Store64(ptr *uint64, val uint64) { func Store64(ptr *uint64, val uint64) {

View File

@ -120,3 +120,25 @@ end:
MOVB R1, ret+4(FP) MOVB R1, ret+4(FP)
RET RET
TEXT ·Store8(SB),NOSPLIT,$0-5
MOVW addr+0(FP), R1
MOVB v+4(FP), R2
MOVB runtime·goarm(SB), R8
CMP $7, R8
BGE native_barrier
BL memory_barrier<>(SB)
B store
native_barrier:
DMB MB_ISH
store:
MOVB R2, (R1)
CMP $7, R8
BGE native_barrier2
BL memory_barrier<>(SB)
RET
native_barrier2:
DMB MB_ISH
RET

View File

@ -60,3 +60,20 @@ TEXT ·Load8(SB),NOSPLIT|NOFRAME,$0-5
MOVB R1, ret+4(FP) MOVB R1, ret+4(FP)
RET RET
TEXT ·Store8(SB),NOSPLIT,$0-5
MOVW addr+0(FP), R1
MOVB v+4(FP), R2
MOVB runtime·goarm(SB), R8
CMP $7, R8
BLT 2(PC)
DMB MB_ISH
MOVB R2, (R1)
CMP $7, R8
BLT 2(PC)
DMB MB_ISH
RET