Skip to content

Commit c1df518

Browse files
committed
runtime: simplify some pointer conversions
Use efaceOf to safely convert from *interface{} to *_eface, and to make it clearer what the pointer arithmetic is computing. Incidentally, remove a spurious unsafe.Pointer->*uint8->unsafe.Pointer round trip conversion in newproc. No behavior change. Change-Id: I2ad9d791d35d8bd008ef43b03dad1589713c5fd4 Reviewed-on: https://go-review.googlesource.com/c/go/+/190457 Run-TryBot: Matthew Dempsky <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 94bf9a8 commit c1df518

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/runtime/proc.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ func releaseSudog(s *sudog) {
413413
// use the result as an address at which to start executing code.
414414
//go:nosplit
415415
func funcPC(f interface{}) uintptr {
416-
return **(**uintptr)(add(unsafe.Pointer(&f), sys.PtrSize))
416+
return *(*uintptr)(efaceOf(&f).data)
417417
}
418418

419419
// called from assembly
@@ -3253,14 +3253,14 @@ func newproc(siz int32, fn *funcval) {
32533253
gp := getg()
32543254
pc := getcallerpc()
32553255
systemstack(func() {
3256-
newproc1(fn, (*uint8)(argp), siz, gp, pc)
3256+
newproc1(fn, argp, siz, gp, pc)
32573257
})
32583258
}
32593259

32603260
// Create a new g running fn with narg bytes of arguments starting
32613261
// at argp. callerpc is the address of the go statement that created
32623262
// this. The new g is put on the queue of g's waiting to run.
3263-
func newproc1(fn *funcval, argp *uint8, narg int32, callergp *g, callerpc uintptr) {
3263+
func newproc1(fn *funcval, argp unsafe.Pointer, narg int32, callergp *g, callerpc uintptr) {
32643264
_g_ := getg()
32653265

32663266
if fn == nil {
@@ -3305,7 +3305,7 @@ func newproc1(fn *funcval, argp *uint8, narg int32, callergp *g, callerpc uintpt
33053305
spArg += sys.MinFrameSize
33063306
}
33073307
if narg > 0 {
3308-
memmove(unsafe.Pointer(spArg), unsafe.Pointer(argp), uintptr(narg))
3308+
memmove(unsafe.Pointer(spArg), argp, uintptr(narg))
33093309
// This is a stack-to-stack copy. If write barriers
33103310
// are enabled and the source stack is grey (the
33113311
// destination is always black), then perform a

0 commit comments

Comments
 (0)