From 5abae02d273d586b13975bca0e5fda67f4f51e2f Mon Sep 17 00:00:00 2001 From: Mauri de Souza Meneguzzo Date: Tue, 21 Nov 2023 19:34:36 +0000 Subject: [PATCH] runtime/internal/atomic: deduplicate And/Or code on wasm When I initially added the wasm code for these ops I did not saw that wasm actually has the Cas operations implemented, although they are merely pointer assignments since wasm is single threaded. Now with a generic implementation for And/Or we can add wasm to the build tags. For #61395 Change-Id: I997dc90477c772882d6703df1b795dfc0d90a699 GitHub-Last-Rev: 92736a6e34104a9d234c791673fe0bb79fc97b0b GitHub-Pull-Request: golang/go#64300 Reviewed-on: https://go-review.googlesource.com/c/go/+/544116 Run-TryBot: Mauri de Souza Meneguzzo Reviewed-by: Keith Randall Reviewed-by: Dmitri Shuralyov Auto-Submit: Dmitri Shuralyov Reviewed-by: Keith Randall TryBot-Result: Gopher Robot --- .../internal/atomic/atomic_andor_generic.go | 2 +- src/runtime/internal/atomic/atomic_wasm.go | 48 ------------------- 2 files changed, 1 insertion(+), 49 deletions(-) diff --git a/src/runtime/internal/atomic/atomic_andor_generic.go b/src/runtime/internal/atomic/atomic_andor_generic.go index 57f80ff871604..00b402681ed6a 100644 --- a/src/runtime/internal/atomic/atomic_andor_generic.go +++ b/src/runtime/internal/atomic/atomic_andor_generic.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build arm || s390x || loong64 || mips || mipsle || mips64 || mips64le +//go:build arm || s390x || loong64 || mips || mipsle || mips64 || mips64le || wasm package atomic diff --git a/src/runtime/internal/atomic/atomic_wasm.go b/src/runtime/internal/atomic/atomic_wasm.go index d1ca994205213..835fc43ccf9f6 100644 --- a/src/runtime/internal/atomic/atomic_wasm.go +++ b/src/runtime/internal/atomic/atomic_wasm.go @@ -339,51 +339,3 @@ func Xaddint64(ptr *int64, delta int64) int64 { *ptr = new return new } - -//go:nosplit -//go:noinline -func And32(ptr *uint32, val uint32) uint32 { - old := *ptr - *ptr = old & val - return old -} - -//go:nosplit -//go:noinline -func And64(ptr *uint64, val uint64) uint64 { - old := *ptr - *ptr = old & val - return old -} - -//go:nosplit -//go:noinline -func Anduintptr(ptr *uintptr, val uintptr) uintptr { - old := *ptr - *ptr = old & val - return old -} - -//go:nosplit -//go:noinline -func Or32(ptr *uint32, val uint32) uint32 { - old := *ptr - *ptr = old | val - return old -} - -//go:nosplit -//go:noinline -func Or64(ptr *uint64, val uint64) uint64 { - old := *ptr - *ptr = old | val - return old -} - -//go:nosplit -//go:noinline -func Oruintptr(ptr *uintptr, val uintptr) uintptr { - old := *ptr - *ptr = old | val - return old -}