Commit 42c7929c authored by Michael Hudson-Doyle's avatar Michael Hudson-Doyle

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

Change-Id: I88f80f5914d6e4c179f3d28aa59fc29b7ef0cc66
Reviewed-on: https://go-review.googlesource.com/15960Reviewed-by: default avatarMinux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 0b8d5833
......@@ -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()
// 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)
......@@ -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
......
......@@ -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)
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment