1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:14:39 -07:00

runtime, runtime/debug: access unexported runtime functions with //go:linkname, not assembly stubs

Change-Id: I88f80f5914d6e4c179f3d28aa59fc29b7ef0cc66
Reviewed-on: https://go-review.googlesource.com/15960
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Michael Hudson-Doyle 2015-10-16 20:19:14 +13:00
parent 0b8d583320
commit 42c7929c04
5 changed files with 9 additions and 35 deletions

View File

@ -8,12 +8,10 @@ import (
"time"
)
// Uses assembly to call corresponding runtime-internal functions.
// Implemented in package runtime.
func readGCStats(*[]time.Duration)
func freeOSMemory()
func setMaxStack(int) int
func setGCPercent(int32) int32
func setPanicOnFault(bool) bool
func setMaxThreads(int) int
// Implemented in package runtime.
func readGCStats(*[]time.Duration)
func freeOSMemory()

View File

@ -1,30 +0,0 @@
// Copyright 2014 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.
#include "textflag.h"
#ifdef GOARCH_arm
#define JMP B
#endif
#ifdef GOARCH_arm64
#define JMP B
#endif
#ifdef GOARCH_ppc64
#define JMP BR
#endif
#ifdef GOARCH_ppc64le
#define JMP BR
#endif
TEXT ·setMaxStack(SB),NOSPLIT,$0-0
JMP runtime·setMaxStack(SB)
TEXT ·setGCPercent(SB),NOSPLIT,$0-0
JMP runtime·setGCPercent(SB)
TEXT ·setPanicOnFault(SB),NOSPLIT,$0-0
JMP runtime·setPanicOnFault(SB)
TEXT ·setMaxThreads(SB),NOSPLIT,$0-0
JMP runtime·setMaxThreads(SB)

View File

@ -196,6 +196,7 @@ func gcenable() {
memstats.enablegc = true // now that runtime is initialized, GC is okay
}
//go:linkname setGCPercent runtime/debug.setGCPercent
func setGCPercent(in int32) (out int32) {
lock(&mheap_.lock)
out = gcpercent

View File

@ -3645,6 +3645,7 @@ func testSchedLocalQueueSteal() {
}
}
//go:linkname setMaxThreads runtime/debug.setMaxThreads
func setMaxThreads(in int) (out int) {
lock(&sched.lock)
out = int(sched.maxmcount)

View File

@ -4,12 +4,16 @@
package runtime
import _ "unsafe" // for go:linkname
//go:linkname setMaxStack runtime/debug.setMaxStack
func setMaxStack(in int) (out int) {
out = int(maxstacksize)
maxstacksize = uintptr(in)
return out
}
//go:linkname setPanicOnFault runtime/debug.setPanicOnFault
func setPanicOnFault(new bool) (old bool) {
mp := acquirem()
old = mp.curg.paniconfault