diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-02-09 08:19:58 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-02-09 08:19:58 +0000 |
commit | 2da6f72bb78de6e6ca3d387d970cb21bf36684be (patch) | |
tree | 7ca86535c5a6b99d4cc432ba5cfddabc5ee4ea16 /libgo/go/runtime | |
parent | 98ea39f2b59cc0a4a0a32b095e8f0faa84fd7882 (diff) | |
download | gcc-2da6f72bb78de6e6ca3d387d970cb21bf36684be.tar.gz |
libgo: Update to weekly.2012-02-07.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@184034 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo/go/runtime')
-rw-r--r-- | libgo/go/runtime/gc_test.go | 11 | ||||
-rw-r--r-- | libgo/go/runtime/mem.go | 21 | ||||
-rw-r--r-- | libgo/go/runtime/pprof/pprof.go | 3 |
3 files changed, 16 insertions, 19 deletions
diff --git a/libgo/go/runtime/gc_test.go b/libgo/go/runtime/gc_test.go index 00b3a04ce9d..739ebcba2ff 100644 --- a/libgo/go/runtime/gc_test.go +++ b/libgo/go/runtime/gc_test.go @@ -10,20 +10,21 @@ import ( ) func TestGcSys(t *testing.T) { + memstats := new(runtime.MemStats) runtime.GC() - runtime.UpdateMemStats() - sys := runtime.MemStats.Sys + runtime.ReadMemStats(memstats) + sys := memstats.Sys for i := 0; i < 1000000; i++ { workthegc() } // Should only be using a few MB. - runtime.UpdateMemStats() - if sys > runtime.MemStats.Sys { + runtime.ReadMemStats(memstats) + if sys > memstats.Sys { sys = 0 } else { - sys = runtime.MemStats.Sys - sys + sys = memstats.Sys - sys } t.Logf("used %d extra bytes", sys) if sys > 4<<20 { diff --git a/libgo/go/runtime/mem.go b/libgo/go/runtime/mem.go index 3f213062910..1301674c027 100644 --- a/libgo/go/runtime/mem.go +++ b/libgo/go/runtime/mem.go @@ -6,9 +6,9 @@ package runtime import "unsafe" -type MemStatsType struct { +// A MemStats records statistics about the memory allocator. +type MemStats struct { // General statistics. - // Not locked during update; approximate. Alloc uint64 // bytes allocated and still in use TotalAlloc uint64 // bytes allocated (even if freed) Sys uint64 // bytes obtained from system (should be sum of XxxSys below) @@ -43,7 +43,6 @@ type MemStatsType struct { DebugGC bool // Per-size allocation statistics. - // Not locked during update; approximate. // 61 is NumSizeClasses in the C code. BySize [61]struct { Size uint32 @@ -54,21 +53,17 @@ type MemStatsType struct { var Sizeof_C_MStats uintptr // filled in by malloc.goc +var VmemStats MemStats + func init() { - if Sizeof_C_MStats != unsafe.Sizeof(MemStats) { - println(Sizeof_C_MStats, unsafe.Sizeof(MemStats)) + if Sizeof_C_MStats != unsafe.Sizeof(VmemStats) { + println(Sizeof_C_MStats, unsafe.Sizeof(VmemStats)) panic("MStats vs MemStatsType size mismatch") } } -// MemStats holds statistics about the memory system. -// The statistics may be out of date, as the information is -// updated lazily from per-thread caches. -// Use UpdateMemStats to bring the statistics up to date. -var MemStats MemStatsType - -// UpdateMemStats brings MemStats up to date. -func UpdateMemStats() +// ReadMemStats populates m with memory allocator statistics. +func ReadMemStats(m *MemStats) // GC runs a garbage collection. func GC() diff --git a/libgo/go/runtime/pprof/pprof.go b/libgo/go/runtime/pprof/pprof.go index d14bb141c4a..a8e78e0ea75 100644 --- a/libgo/go/runtime/pprof/pprof.go +++ b/libgo/go/runtime/pprof/pprof.go @@ -75,7 +75,8 @@ func WriteHeapProfile(w io.Writer) error { // Print memstats information too. // Pprof will ignore, but useful for people. - s := &runtime.MemStats + s := new(runtime.MemStats) + runtime.ReadMemStats(s) fmt.Fprintf(b, "\n# runtime.MemStats\n") fmt.Fprintf(b, "# Alloc = %d\n", s.Alloc) fmt.Fprintf(b, "# TotalAlloc = %d\n", s.TotalAlloc) |