aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorthepudds <thepudds1460@gmail.com>2023-06-21 13:27:11 -0400
committert hepudds <thepudds1460@gmail.com>2026-01-30 14:22:48 -0800
commit045fe9aa8c7e175b5894b6f0c85d76a1ec27a91c (patch)
treeb1267b256c569f207f310f5f90eea4ace15517e7 /src/runtime
parentf14d8975a21e24aa33e0b496e822fdcb285879b9 (diff)
downloadgo-045fe9aa8c7e175b5894b6f0c85d76a1ec27a91c.tar.xz
fmt: avoid storing input arguments on pp to help escape analysis
This is part of a series of CLs that aim to reduce how often interface arguments escape for the print functions in fmt, such as val here: func f(val int) { fmt.Sprintf("%d", val) } Prior to this change, arguments immediately escape in doPrintf because they are stored on the *pp in printArg: parameter a leaks to <heap> for (*pp).doPrintf with derefs=1: flow: <heap> ← *a: from a[argNum] (dot of pointer) at .\print.go:1077:18 from (*pp).printArg(p, a[argNum], rune(c)) (call parameter) at .\print.go:1077:16 parameter arg leaks to <heap> for (*pp).printArg with derefs=0: flow: <heap> ← arg: from p.arg = arg (assign) at .\print.go:682:8 The *pp is heap allocated, and the heap cannot point to stack variables, so the arguments currently cannot be on the stack. This change instead threads through the input arguments as individual type any and reflect.Value parameters, rather than storing on the *pp. After this change, input arguments still escape, but now for other reasons. Updates #8618 Updates #62653 Change-Id: I81984daeceb761ce4ce269b150b888950ce2c5d4 Reviewed-on: https://go-review.googlesource.com/c/go/+/524938 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Diffstat (limited to 'src/runtime')
0 files changed, 0 insertions, 0 deletions