diff options
| author | Cherry Mui <cherryyz@google.com> | 2022-05-27 15:44:40 -0400 |
|---|---|---|
| committer | Cherry Mui <cherryyz@google.com> | 2023-05-12 21:11:33 +0000 |
| commit | 0ac72f8b96166c8aa3953d27f4fd3d33fb9e51cf (patch) | |
| tree | 6d1c2857be291091937a043cad77707d234c0e5d /src/runtime | |
| parent | cce67690b82faef7d12a86f20e8e6a158d15f2a3 (diff) | |
| download | go-0ac72f8b96166c8aa3953d27f4fd3d33fb9e51cf.tar.xz | |
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>
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/chan.go | 2 | ||||
| -rw-r--r-- | src/runtime/map.go | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/runtime/chan.go b/src/runtime/chan.go index 98e0836670..aff4cf87b7 100644 --- a/src/runtime/chan.go +++ b/src/runtime/chan.go @@ -714,7 +714,7 @@ func selectnbrecv(elem unsafe.Pointer, c *hchan) (selected, received bool) { return chanrecv(c, elem, false) } -//go:linkname reflect_chansend reflect.chansend +//go:linkname reflect_chansend reflect.chansend0 func reflect_chansend(c *hchan, elem unsafe.Pointer, nb bool) (selected bool) { return chansend(c, elem, !nb, getcallerpc()) } diff --git a/src/runtime/map.go b/src/runtime/map.go index 7488945926..a1fe08f758 100644 --- a/src/runtime/map.go +++ b/src/runtime/map.go @@ -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) |
