From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/go.test/test/mallocrep.go | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 gcc/testsuite/go.test/test/mallocrep.go (limited to 'gcc/testsuite/go.test/test/mallocrep.go') diff --git a/gcc/testsuite/go.test/test/mallocrep.go b/gcc/testsuite/go.test/test/mallocrep.go new file mode 100644 index 000000000..762f3754f --- /dev/null +++ b/gcc/testsuite/go.test/test/mallocrep.go @@ -0,0 +1,66 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2009 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Repeated malloc test. + +package main + +import ( + "flag" + "runtime" +) + +var chatty = flag.Bool("v", false, "chatty") + +var oldsys uint64 + +func bigger() { + if st := runtime.MemStats; oldsys < st.Sys { + oldsys = st.Sys + if *chatty { + println(st.Sys, " system bytes for ", st.Alloc, " Go bytes") + } + if st.Sys > 1e9 { + println("too big") + panic("fail") + } + } +} + +func main() { + runtime.GC() // clean up garbage from init + runtime.MemProfileRate = 0 // disable profiler + runtime.MemStats.Alloc = 0 // 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 { + println("no allocations but stats report", a, "bytes allocated") + panic("fail") + } + b := runtime.Alloc(uintptr(j)) + during := runtime.MemStats.Alloc + runtime.Free(b) + if a := runtime.MemStats.Alloc; a != 0 { + println("allocated ", j, ": wrong stats: during=", during, " after=", a, " (want 0)") + panic("fail") + } + bigger() + } + if i%(1<<10) == 0 && *chatty { + println(i) + } + if i == 0 { + if *chatty { + println("Primed", i) + } + // runtime.frozen = true + } + } +} -- cgit v1.2.3