]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: make TestGcSys actually test something
authorIan Lance Taylor <iant@golang.org>
Sat, 7 Jul 2018 05:57:35 +0000 (22:57 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 22 Aug 2018 19:47:55 +0000 (19:47 +0000)
The workthegc function was being inlined, and the slice did not
escape, so there was no memory allocation. Use a sink variable to
force memory allocation, at least for now.

Fixes #23343

Change-Id: I02f4618e343c8b6cb552cb4e9f272e112785f7cf
Reviewed-on: https://go-review.googlesource.com/122576
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/runtime/testdata/testprog/gc.go

index 744b6108e2bc3cf0bd9fc97b21a1c448ee9365e9..3ca74ba5feefab20803586922b714fb18c2f1fb0 100644 (file)
@@ -48,8 +48,11 @@ func GCSys() {
        fmt.Printf("OK\n")
 }
 
+var sink []byte
+
 func workthegc() []byte {
-       return make([]byte, 1029)
+       sink = make([]byte, 1029)
+       return sink
 }
 
 func GCFairness() {