]> Cypherpunks repositories - gostls13.git/commit
reflect: allow Value be stack allocated
authorCherry Mui <cherryyz@google.com>
Fri, 27 May 2022 19:44:40 +0000 (15:44 -0400)
committerCherry Mui <cherryyz@google.com>
Fri, 12 May 2023 21:11:33 +0000 (21:11 +0000)
commit0ac72f8b96166c8aa3953d27f4fd3d33fb9e51cf
tree6d1c2857be291091937a043cad77707d234c0e5d
parentcce67690b82faef7d12a86f20e8e6a158d15f2a3
reflect: allow Value be stack allocated

Currently, reflect.ValueOf forces the referenced object to be heap
allocated. This CL makes it possible to be stack allocated. We
need to be careful to make sure the compiler's escape analysis can
do the right thing, e.g. channel send, map assignment, unsafe
pointer conversions.

Tests will be added in a later CL.

CL 408827 might help ensure the correctness.

Change-Id: I8663651370c7c8108584902235062dd2b3f65954
Reviewed-on: https://go-review.googlesource.com/c/go/+/408826
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/reflect/value.go
src/runtime/chan.go
src/runtime/map.go