]> Cypherpunks repositories - gostls13.git/commitdiff
runtime, runtime/debug: access unexported runtime functions with //go:linkname, not...
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Fri, 16 Oct 2015 07:19:14 +0000 (20:19 +1300)
committerMichael Hudson-Doyle <michael.hudson@canonical.com>
Fri, 16 Oct 2015 09:14:25 +0000 (09:14 +0000)
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>

src/runtime/debug/stubs.go
src/runtime/debug/stubs.s [deleted file]
src/runtime/mgc.go
src/runtime/proc1.go
src/runtime/rdebug.go

index 95b33e4da6c97af2e27f1b79413de4faa983dd9d..6c87ffdafedba57f1e0f768c083706df500f0396 100644 (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()
diff --git a/src/runtime/debug/stubs.s b/src/runtime/debug/stubs.s
deleted file mode 100644 (file)
index 9dc8e54..0000000
+++ /dev/null
@@ -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)
index 086fc957f0a972b039f770f9a51e30d45f87f731..f57e16cdeb64f88618fb7e7bb6d5838fc6d42d54 100644 (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
index ec60f8c0d0482c7e56c92ee0973631aead57e85f..614de5110c470c77b8e427ca989d15c99c965013 100644 (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)
index f2766d7937e10120d99852723ec95e0eb75d2c44..ad7b97698911bff8d5174f17baeade82d3b142bf 100644 (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