1
0
mirror of https://github.com/golang/go synced 2024-11-23 20:30:04 -07:00

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 #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 <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Keith Randall 2020-08-23 11:52:53 -07:00
parent 623652e73f
commit c0602603b2
2 changed files with 15 additions and 8 deletions

View File

@ -0,0 +1,10 @@
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#include "textflag.h"
TEXT runtimeinternalatomic·StorepNoWB(SB), NOSPLIT, $0-16
MOVD ptr+0(FP), R0
MOVD val+8(FP), 0(R0)
RET

View File

@ -153,14 +153,11 @@ func Store64(ptr *uint64, val uint64) {
*ptr = val *ptr = val
} }
//go:notinheap // StorepNoWB performs *ptr = val atomically and without a write
type noWB struct{} // barrier.
//
//go:noinline // NO go:noescape annotation; see atomic_pointer.go.
//go:nosplit func StorepNoWB(ptr unsafe.Pointer, val unsafe.Pointer)
func StorepNoWB(ptr unsafe.Pointer, val unsafe.Pointer) {
*(**noWB)(ptr) = (*noWB)(val)
}
//go:nosplit //go:nosplit
//go:noinline //go:noinline