Skip to content

Commit 9107484

Browse files
cherrymuipull[bot]
authored andcommitted
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 <[email protected]> Reviewed-by: David Chase <[email protected]>
1 parent 2d95e79 commit 9107484

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

src/reflect/all_test.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3503,16 +3503,24 @@ func TestAllocations(t *testing.T) {
35033503
var i any
35043504
var v Value
35053505

3506-
// We can uncomment this when compiler escape analysis
3507-
// is good enough to see that the integer assigned to i
3508-
// does not escape and therefore need not be allocated.
3509-
//
3510-
// i = 42 + j
3511-
// v = ValueOf(i)
3512-
// if int(v.Int()) != 42+j {
3513-
// panic("wrong int")
3514-
// }
3515-
3506+
i = 42 + j
3507+
v = ValueOf(i)
3508+
if int(v.Int()) != 42+j {
3509+
panic("wrong int")
3510+
}
3511+
})
3512+
noAlloc(t, 100, func(j int) {
3513+
var i any
3514+
var v Value
3515+
i = [3]int{j, j, j}
3516+
v = ValueOf(i)
3517+
if v.Len() != 3 {
3518+
panic("wrong length")
3519+
}
3520+
})
3521+
noAlloc(t, 100, func(j int) {
3522+
var i any
3523+
var v Value
35163524
i = func(j int) int { return j }
35173525
v = ValueOf(i)
35183526
if v.Interface().(func(int) int)(j) != j {

0 commit comments

Comments
 (0)