runtime: implement cheaper context switch on Linux/AMD64

Currently, goroutine switches are implemented with libc
getcontext/setcontext functions, which saves/restores the machine
register states and also the signal context. This does more than
what we need, and performs an expensive syscall.

This CL implements a simplified version of getcontext/setcontext,
in assembly, that only saves/restores the necessary part, i.e.
the callee-save registers, and the PC, SP. A simplified version
of makecontext, written in C, is also added. Currently this is
only implemented on Linux/AMD64.

Change-Id: I326347c6530663747c2c46f27e9d1bdc7f073290
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/178298
Reviewed-by: Ian Lance Taylor <iant@golang.org>
9 files changed