runtime: copy mstats code from Go 1.7 runtime
commit58f7dab40db417ab669a0a1e146aa6e3227e3989
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 13 Oct 2016 15:24:50 +0000 (13 15:24 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 13 Oct 2016 15:24:50 +0000 (13 15:24 +0000)
treed5aaac15d5bd0d4b125140016f3ea84a714e3713
parent5b1548fd79423c451b96f897701dc4aa51131b86
runtime: copy mstats code from Go 1.7 runtime

    This replaces mem.go and the C runtime_ReadMemStats function with the Go
    1.7 mstats.go.

    The GCStats code is commented out for now.  The corresponding gccgo code
    is in runtime/mgc0.c.

    The variables memstats and worldsema are shared between the Go code and
    the C code, but are not exported.  To make this work, add temporary
    accessor functions acquireWorldsema, releaseWorldsema, getMstats (the
    latter known as mstats in the C code).

    Check the preemptoff field of m when allocating and when considering
    whether to start a GC.  This works with the new stopTheWorld and
    startTheWorld functions in Go, which are essentially the Go 1.7
    versions.

    Change the compiler to stack allocate closures when compiling the
    runtime package.  Within the runtime packages closures do not escape.
    This is similar to what the gc compiler does, except that the gc
    compiler, when compiling the runtime package, gives an error if escape
    analysis shows that a closure does escape.  I added this here because
    the Go version of ReadMemStats calls systemstack with a closure, and
    having that allocate memory was causing some tests that measure memory
    allocations to fail.

    Reviewed-on: https://go-review.googlesource.com/30972

From-SVN: r241124
18 files changed:
gcc/go/gofrontend/MERGE
gcc/go/gofrontend/parse.cc
libgo/go/runtime/mem.go [deleted file]
libgo/go/runtime/mstats.go [new file with mode: 0644]
libgo/go/runtime/stubs.go
libgo/runtime/cpuprof.goc
libgo/runtime/heapdump.c
libgo/runtime/malloc.goc
libgo/runtime/malloc.h
libgo/runtime/mem_posix_memalign.c
libgo/runtime/mgc0.c
libgo/runtime/mheap.c
libgo/runtime/mprof.goc
libgo/runtime/msize.c
libgo/runtime/netpoll.goc
libgo/runtime/netpoll_select.c
libgo/runtime/proc.c
libgo/runtime/runtime.h