runtime: avoid inconsistent goroutine state in profiler

Because profiling signals can arrive at any time, we must
handle the case where a profiling signal arrives halfway
through a goroutine switch. Luckily, although there is much
to think through, very little needs to change.

Fixes issue 6000.
Fixes issue 6015.

R=golang-dev, dvyukov
CC=golang-dev
https://codereview.appspot.com/13421048