mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
cce67690b8
commit
0ac72f8b96
3 changed files with 69 additions and 16 deletions
|
|
@ -1365,13 +1365,13 @@ func reflect_mapaccess_faststr(t *maptype, h *hmap, key string) unsafe.Pointer {
|
|||
return elem
|
||||
}
|
||||
|
||||
//go:linkname reflect_mapassign reflect.mapassign
|
||||
//go:linkname reflect_mapassign reflect.mapassign0
|
||||
func reflect_mapassign(t *maptype, h *hmap, key unsafe.Pointer, elem unsafe.Pointer) {
|
||||
p := mapassign(t, h, key)
|
||||
typedmemmove(t.Elem, p, elem)
|
||||
}
|
||||
|
||||
//go:linkname reflect_mapassign_faststr reflect.mapassign_faststr
|
||||
//go:linkname reflect_mapassign_faststr reflect.mapassign_faststr0
|
||||
func reflect_mapassign_faststr(t *maptype, h *hmap, key string, elem unsafe.Pointer) {
|
||||
p := mapassign_faststr(t, h, key)
|
||||
typedmemmove(t.Elem, p, elem)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue