Skip to content

Commit c060260

Browse files
committed
runtime: implement StorepNoWB for wasm in assembly
The second argument of StorepNoWB must be forced to escape. The current Go code does not explicitly enforce that property. By implementing in assembly, and not using go:noescape, we force the issue. Test is in CL 249761. Issue golang#40975. This CL is needed for CL 249917, which changes how go:notinheap works and breaks the previous StorepNoWB wasm code. I checked for other possible errors like this. This is the only go:notinheap that isn't in the runtime itself. Change-Id: I43400a806662655727c4a3baa8902b63bdc9fa57 Reviewed-on: https://go-review.googlesource.com/c/go/+/249962 Run-TryBot: Keith Randall <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
1 parent 623652e commit c060260

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Copyright 2020 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 runtime∕internal∕atomic·StorepNoWB(SB), NOSPLIT, $0-16
8+
MOVD ptr+0(FP), R0
9+
MOVD val+8(FP), 0(R0)
10+
RET

src/runtime/internal/atomic/atomic_wasm.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,11 @@ func Store64(ptr *uint64, val uint64) {
153153
*ptr = val
154154
}
155155

156-
//go:notinheap
157-
type noWB struct{}
158-
159-
//go:noinline
160-
//go:nosplit
161-
func StorepNoWB(ptr unsafe.Pointer, val unsafe.Pointer) {
162-
*(**noWB)(ptr) = (*noWB)(val)
163-
}
156+
// StorepNoWB performs *ptr = val atomically and without a write
157+
// barrier.
158+
//
159+
// NO go:noescape annotation; see atomic_pointer.go.
160+
func StorepNoWB(ptr unsafe.Pointer, val unsafe.Pointer)
164161

165162
//go:nosplit
166163
//go:noinline

0 commit comments

Comments
 (0)