mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: do not escape Value.Type
Types are either static (for compiler-created types) or heap allocated and always reachable (for reflection-created types, held in the central map). So there is no need to escape types. With CL 408826 reflect.Value does not always escape. Some functions that escapes Value.typ would make the Value escape without this CL. Had to add a special case for the inliner to keep (*Value).Type still inlineable. Change-Id: I7c14d35fd26328347b509a06eb5bd1534d40775f Reviewed-on: https://go-review.googlesource.com/c/go/+/413474 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
0ac72f8b96
commit
be4fe08b57
7 changed files with 170 additions and 122 deletions
|
|
@ -229,6 +229,9 @@ func SetEnvs(e []string) { envs = e }
|
|||
// For benchmarking.
|
||||
|
||||
func BenchSetType(n int, x any) {
|
||||
// Escape x to ensure it is allocated on the heap, as we are
|
||||
// working on the heap bits here.
|
||||
Escape(x)
|
||||
e := *efaceOf(&x)
|
||||
t := e._type
|
||||
var size uintptr
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue