runtime: break atomics out into package runtime/internal/atomic

This change breaks out most of the atomics functions in the runtime
into package runtime/internal/atomic. It adds some basic support
in the toolchain for runtime packages, and also modifies linux/arm
atomics to remove the dependency on the runtime's mutex. The mutexes
have been replaced with spinlocks.

all trybots are happy!
In addition to the trybots, I've tested on the darwin/arm64 builder,
on the darwin/arm builder, and on a ppc64le machine.

Change-Id: I6698c8e3cf3834f55ce5824059f44d00dc8e3c2f
Reviewed-on: https://go-review.googlesource.com/14204
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Michael Matloob 2015-11-02 14:09:24 -05:00
parent d33360571f
commit 67faca7d9c
94 changed files with 2302 additions and 1940 deletions

View file

@ -4,7 +4,10 @@
package runtime
import "unsafe"
import (
"runtime/internal/atomic"
"unsafe"
)
var indexError = error(errorString("index out of range"))
@ -569,7 +572,7 @@ func startpanic_m() {
case 0:
_g_.m.dying = 1
_g_.writebuf = nil
xadd(&panicking, 1)
atomic.Xadd(&panicking, 1)
lock(&paniclk)
if debug.schedtrace > 0 || debug.scheddetail > 0 {
schedtrace(true)
@ -626,7 +629,7 @@ func dopanic_m(gp *g, pc, sp uintptr) {
}
unlock(&paniclk)
if xadd(&panicking, -1) != 0 {
if atomic.Xadd(&panicking, -1) != 0 {
// Some other m is panicking too.
// Let it print what it needs to print.
// Wait forever without chewing up cpu.