mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
reflect: uncomment allocation test
We no longer force Value content to escape and the compiler's escape analysis can handle it now. Change-Id: I0628f3241e6ef37dce710c2394725e280790479a Reviewed-on: https://go-review.googlesource.com/c/go/+/542975 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
23ca330095
commit
0434ca9ce8
1 changed files with 18 additions and 10 deletions
|
|
@ -3503,16 +3503,24 @@ func TestAllocations(t *testing.T) {
|
||||||
var i any
|
var i any
|
||||||
var v Value
|
var v Value
|
||||||
|
|
||||||
// We can uncomment this when compiler escape analysis
|
i = 42 + j
|
||||||
// is good enough to see that the integer assigned to i
|
v = ValueOf(i)
|
||||||
// does not escape and therefore need not be allocated.
|
if int(v.Int()) != 42+j {
|
||||||
//
|
panic("wrong int")
|
||||||
// i = 42 + j
|
}
|
||||||
// v = ValueOf(i)
|
})
|
||||||
// if int(v.Int()) != 42+j {
|
noAlloc(t, 100, func(j int) {
|
||||||
// panic("wrong int")
|
var i any
|
||||||
// }
|
var v Value
|
||||||
|
i = [3]int{j, j, j}
|
||||||
|
v = ValueOf(i)
|
||||||
|
if v.Len() != 3 {
|
||||||
|
panic("wrong length")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
noAlloc(t, 100, func(j int) {
|
||||||
|
var i any
|
||||||
|
var v Value
|
||||||
i = func(j int) int { return j }
|
i = func(j int) int { return j }
|
||||||
v = ValueOf(i)
|
v = ValueOf(i)
|
||||||
if v.Interface().(func(int) int)(j) != j {
|
if v.Interface().(func(int) int)(j) != j {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue