From 350767bf22688f7645fe959370240825a3cf0421 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 16 Nov 2016 18:33:11 +0000 Subject: runtime: replace runtime1.goc with Go and C code A step toward eliminating goc2c. Drop the exported parfor code; it was needed for tests in the past, but no longer is. The Go 1.7 runtime no longer uses parfor. Reviewed-on: https://go-review.googlesource.com/33324 From-SVN: r242509 --- libgo/go/runtime/debug.go | 17 +++++++++++++++-- libgo/go/runtime/error.go | 5 ++++- libgo/go/runtime/export_test.go | 28 ++-------------------------- libgo/go/runtime/extern.go | 4 +--- libgo/go/runtime/stubs.go | 1 + 5 files changed, 23 insertions(+), 32 deletions(-) (limited to 'libgo/go') diff --git a/libgo/go/runtime/debug.go b/libgo/go/runtime/debug.go index 56e307f..43f6e1e 100644 --- a/libgo/go/runtime/debug.go +++ b/libgo/go/runtime/debug.go @@ -4,6 +4,11 @@ package runtime +import ( + "runtime/internal/atomic" + "unsafe" +) + // GOMAXPROCS sets the maximum number of CPUs that can be executing // simultaneously and returns the previous setting. If n < 1, it does not // change the current setting. @@ -19,10 +24,18 @@ func GOMAXPROCS(n int) int func NumCPU() int // NumCgoCall returns the number of cgo calls made by the current process. -func NumCgoCall() int64 +func NumCgoCall() int64 { + var n int64 + for mp := (*m)(atomic.Loadp(unsafe.Pointer(allm()))); mp != nil; mp = mp.alllink { + n += int64(mp.ncgocall) + } + return n +} // NumGoroutine returns the number of goroutines that currently exist. -func NumGoroutine() int +func NumGoroutine() int { + return int(gcount()) +} // Get field tracking information. Only fields with a tag go:"track" // are tracked. This function will add every such field that is diff --git a/libgo/go/runtime/error.go b/libgo/go/runtime/error.go index 3683001..d5d502c 100644 --- a/libgo/go/runtime/error.go +++ b/libgo/go/runtime/error.go @@ -133,7 +133,10 @@ type stringer interface { String() string } -func typestring(interface{}) string +func typestring(x interface{}) string { + e := efaceOf(&x) + return *e._type.string +} // For calling from C. // Prints an argument passed to panic. diff --git a/libgo/go/runtime/export_test.go b/libgo/go/runtime/export_test.go index d3443566..b8b129d 100644 --- a/libgo/go/runtime/export_test.go +++ b/libgo/go/runtime/export_test.go @@ -21,11 +21,10 @@ import ( //var F64toint = f64toint //var Sqrt = sqrt -func golockedOSThread() bool - var Entersyscall = entersyscall var Exitsyscall = exitsyscall -var LockedOSThread = golockedOSThread + +// var LockedOSThread = lockedOSThread // var Xadduintptr = xadduintptr @@ -44,29 +43,6 @@ func LFStackPop(head *uint64) *LFNode { return (*LFNode)(unsafe.Pointer(lfstackpop(head))) } -type ParFor struct { - body func(*ParFor, uint32) - done uint32 - Nthr uint32 - thrseq uint32 - Cnt uint32 - wait bool -} - -func newParFor(nthrmax uint32) *ParFor -func parForSetup(desc *ParFor, nthr, n uint32, wait bool, body func(*ParFor, uint32)) -func parForDo(desc *ParFor) -func parForIters(desc *ParFor, tid uintptr) (uintptr, uintptr) - -var NewParFor = newParFor -var ParForSetup = parForSetup -var ParForDo = parForDo - -func ParForIters(desc *ParFor, tid uint32) (uint32, uint32) { - begin, end := parForIters(desc, uintptr(tid)) - return uint32(begin), uint32(end) -} - func GCMask(x interface{}) (ret []byte) { return nil } diff --git a/libgo/go/runtime/extern.go b/libgo/go/runtime/extern.go index e0c5aac..c074687 100644 --- a/libgo/go/runtime/extern.go +++ b/libgo/go/runtime/extern.go @@ -274,13 +274,11 @@ func SetFinalizer(obj interface{}, finalizer interface{}) // the actual system call. func KeepAlive(interface{}) -func getgoroot() string - // GOROOT returns the root of the Go tree. // It uses the GOROOT environment variable, if set, // or else the root used during the Go build. func GOROOT() string { - s := getgoroot() + s := gogetenv("GOROOT") if s != "" { return s } diff --git a/libgo/go/runtime/stubs.go b/libgo/go/runtime/stubs.go index d0641ed..8d90cd6 100644 --- a/libgo/go/runtime/stubs.go +++ b/libgo/go/runtime/stubs.go @@ -501,6 +501,7 @@ func needm() func dropm() func sigprof() func mcount() int32 +func gcount() int32 // Signal trampoline, written in C. func sigtramp() -- cgit v1.1