diff options
Diffstat (limited to 'gcc/testsuite/go.test')
-rw-r--r-- | gcc/testsuite/go.test/test/chan/select2.go | 9 | ||||
-rw-r--r-- | gcc/testsuite/go.test/test/gc2.go | 8 | ||||
-rw-r--r-- | gcc/testsuite/go.test/test/malloc1.go | 5 | ||||
-rw-r--r-- | gcc/testsuite/go.test/test/mallocrand.go | 5 | ||||
-rw-r--r-- | gcc/testsuite/go.test/test/mallocrep.go | 24 | ||||
-rw-r--r-- | gcc/testsuite/go.test/test/mallocrep1.go | 14 |
6 files changed, 37 insertions, 28 deletions
diff --git a/gcc/testsuite/go.test/test/chan/select2.go b/gcc/testsuite/go.test/test/chan/select2.go index e24c51ed16c..2cbb86ec626 100644 --- a/gcc/testsuite/go.test/test/chan/select2.go +++ b/gcc/testsuite/go.test/test/chan/select2.go @@ -35,14 +35,17 @@ func main() { go sender(c, 100000) receiver(c, dummy, 100000) runtime.GC() - runtime.MemStats.Alloc = 0 + memstats := new(runtime.MemStats) + runtime.ReadMemStats(memstats) + alloc := memstats.Alloc // second time shouldn't increase footprint by much go sender(c, 100000) receiver(c, dummy, 100000) runtime.GC() + runtime.ReadMemStats(memstats) - if runtime.MemStats.Alloc > 1e5 { - println("BUG: too much memory for 100,000 selects:", runtime.MemStats.Alloc) + if memstats.Alloc-alloc > 1e5 { + println("BUG: too much memory for 100,000 selects:", memstats.Alloc-alloc) } } diff --git a/gcc/testsuite/go.test/test/gc2.go b/gcc/testsuite/go.test/test/gc2.go index c54d807df72..772f9810daa 100644 --- a/gcc/testsuite/go.test/test/gc2.go +++ b/gcc/testsuite/go.test/test/gc2.go @@ -19,7 +19,9 @@ import ( func main() { const N = 10000 - st := runtime.MemStats + st := new(runtime.MemStats) + memstats := new(runtime.MemStats) + runtime.ReadMemStats(st) for i := 0; i < N; i++ { c := make(chan int, 10) _ = c @@ -33,8 +35,8 @@ func main() { } } - runtime.UpdateMemStats() - obj := runtime.MemStats.HeapObjects - st.HeapObjects + runtime.ReadMemStats(memstats) + obj := memstats.HeapObjects - st.HeapObjects if obj > N/5 { fmt.Println("too many objects left:", obj) os.Exit(1) diff --git a/gcc/testsuite/go.test/test/malloc1.go b/gcc/testsuite/go.test/test/malloc1.go index 61f1797c75d..0f7f0b267a0 100644 --- a/gcc/testsuite/go.test/test/malloc1.go +++ b/gcc/testsuite/go.test/test/malloc1.go @@ -17,9 +17,10 @@ import ( var chatty = flag.Bool("v", false, "chatty") func main() { + memstats := new(runtime.MemStats) runtime.Free(runtime.Alloc(1)) - runtime.UpdateMemStats() + runtime.ReadMemStats(memstats) if *chatty { - fmt.Printf("%+v %v\n", runtime.MemStats, uint64(0)) + fmt.Printf("%+v %v\n", memstats, uint64(0)) } } diff --git a/gcc/testsuite/go.test/test/mallocrand.go b/gcc/testsuite/go.test/test/mallocrand.go index 726e36799a8..69d07cec5d2 100644 --- a/gcc/testsuite/go.test/test/mallocrand.go +++ b/gcc/testsuite/go.test/test/mallocrand.go @@ -21,8 +21,9 @@ var footprint uint64 var allocated uint64 func bigger() { - runtime.UpdateMemStats() - if f := runtime.MemStats.Sys; footprint < f { + memstats := new(runtime.MemStats) + runtime.ReadMemStats(memstats) + if f := memstats.Sys; footprint < f { footprint = f if *chatty { println("Footprint", footprint, " for ", allocated) diff --git a/gcc/testsuite/go.test/test/mallocrep.go b/gcc/testsuite/go.test/test/mallocrep.go index cffcd1638fc..4188da9b833 100644 --- a/gcc/testsuite/go.test/test/mallocrep.go +++ b/gcc/testsuite/go.test/test/mallocrep.go @@ -16,10 +16,12 @@ import ( var chatty = flag.Bool("v", false, "chatty") var oldsys uint64 +var memstats runtime.MemStats func bigger() { - runtime.UpdateMemStats() - if st := runtime.MemStats; oldsys < st.Sys { + st := &memstats + runtime.ReadMemStats(st) + if oldsys < st.Sys { oldsys = st.Sys if *chatty { println(st.Sys, " system bytes for ", st.Alloc, " Go bytes") @@ -32,26 +34,26 @@ func bigger() { } func main() { - runtime.GC() // clean up garbage from init - runtime.UpdateMemStats() // first call can do some allocations - runtime.MemProfileRate = 0 // disable profiler - runtime.MemStats.Alloc = 0 // ignore stacks + runtime.GC() // clean up garbage from init + runtime.ReadMemStats(&memstats) // first call can do some allocations + runtime.MemProfileRate = 0 // disable profiler + stacks := memstats.Alloc // ignore stacks flag.Parse() for i := 0; i < 1<<7; i++ { for j := 1; j <= 1<<22; j <<= 1 { if i == 0 && *chatty { println("First alloc:", j) } - if a := runtime.MemStats.Alloc; a != 0 { + if a := memstats.Alloc - stacks; a != 0 { println("no allocations but stats report", a, "bytes allocated") panic("fail") } b := runtime.Alloc(uintptr(j)) - runtime.UpdateMemStats() - during := runtime.MemStats.Alloc + runtime.ReadMemStats(&memstats) + during := memstats.Alloc - stacks runtime.Free(b) - runtime.UpdateMemStats() - if a := runtime.MemStats.Alloc; a != 0 { + runtime.ReadMemStats(&memstats) + if a := memstats.Alloc - stacks; a != 0 { println("allocated ", j, ": wrong stats: during=", during, " after=", a, " (want 0)") panic("fail") } diff --git a/gcc/testsuite/go.test/test/mallocrep1.go b/gcc/testsuite/go.test/test/mallocrep1.go index 0b1479900e6..f9d7286efd9 100644 --- a/gcc/testsuite/go.test/test/mallocrep1.go +++ b/gcc/testsuite/go.test/test/mallocrep1.go @@ -20,7 +20,7 @@ var reverse = flag.Bool("r", false, "reverse") var longtest = flag.Bool("l", false, "long test") var b []*byte -var stats = &runtime.MemStats +var stats = new(runtime.MemStats) func OkAmount(size, n uintptr) bool { if n < size { @@ -42,7 +42,7 @@ func AllocAndFree(size, count int) { if *chatty { fmt.Printf("size=%d count=%d ...\n", size, count) } - runtime.UpdateMemStats() + runtime.ReadMemStats(stats) n1 := stats.Alloc for i := 0; i < count; i++ { b[i] = runtime.Alloc(uintptr(size)) @@ -51,13 +51,13 @@ func AllocAndFree(size, count int) { println("lookup failed: got", base, n, "for", b[i]) panic("fail") } - runtime.UpdateMemStats() + runtime.ReadMemStats(stats) if stats.Sys > 1e9 { println("too much memory allocated") panic("fail") } } - runtime.UpdateMemStats() + runtime.ReadMemStats(stats) n2 := stats.Alloc if *chatty { fmt.Printf("size=%d count=%d stats=%+v\n", size, count, *stats) @@ -75,17 +75,17 @@ func AllocAndFree(size, count int) { panic("fail") } runtime.Free(b[i]) - runtime.UpdateMemStats() + runtime.ReadMemStats(stats) if stats.Alloc != uint64(alloc-n) { println("free alloc got", stats.Alloc, "expected", alloc-n, "after free of", n) panic("fail") } - if runtime.MemStats.Sys > 1e9 { + if stats.Sys > 1e9 { println("too much memory allocated") panic("fail") } } - runtime.UpdateMemStats() + runtime.ReadMemStats(stats) n4 := stats.Alloc if *chatty { |