runtime: copy mstats code from Go 1.7 runtime
commit634150fbd353b4b99a31c94963f1decb51fb8e51
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 13 Oct 2016 15:24:50 +0000 (13 15:24 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 13 Oct 2016 15:24:50 +0000 (13 15:24 +0000)
treed5aaac15d5bd0d4b125140016f3ea84a714e3713
parentff56abd1656bc6c0f4606f203fa06fab74efa1de
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

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241124 138bc75d-0d04-0410-961f-82ee72b054a4
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