Skip to content

Commit

Permalink
runtime/internal/atomic: deduplicate And/Or code on wasm
Browse files Browse the repository at this point in the history
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: 92736a6
GitHub-Pull-Request: #64300
Reviewed-on: https://go-review.googlesource.com/c/go/+/544116
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
  • Loading branch information
mauri870 authored and gopherbot committed Nov 22, 2023
1 parent 2c424ed commit 5abae02
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 49 deletions.
2 changes: 1 addition & 1 deletion src/runtime/internal/atomic/atomic_andor_generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
48 changes: 0 additions & 48 deletions src/runtime/internal/atomic/atomic_wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 5abae02

Please sign in to comment.