Minor improvements, noticed while investigating other things.
Shorten the prologue.
Make branch direction better for static branch prediction;
the most common case by far is switching stacks (g==curg).
Change-Id: Ib2211d3efecb60446355cda56194221ccb78057d
Reviewed-on: https://go-review.googlesource.com/97377
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
MOVL g(CX), AX // AX = g
MOVL g_m(AX), BX // BX = m
- MOVL m_gsignal(BX), DX // DX = gsignal
- CMPL AX, DX
+ CMPL AX, m_gsignal(BX)
JEQ noswitch
MOVL m_g0(BX), DX // DX = g0
CMPL AX, DX
JEQ noswitch
- MOVL m_curg(BX), BP
- CMPL AX, BP
- JEQ switch
-
- // Bad: g is not gsignal, not g0, not curg. What is it?
- // Hide call from linker nosplit analysis.
- MOVL $runtime·badsystemstack(SB), AX
- CALL AX
+ CMPL AX, m_curg(BX)
+ JNE bad
-switch:
+ // switch stacks
// save our state in g->sched. Pretend to
// be systemstack_switch if the G stack is scanned.
MOVL $runtime·systemstack_switch(SB), (g_sched+gobuf_pc)(AX)
MOVL 0(DI), DI
JMP DI
+bad:
+ // Bad: g is not gsignal, not g0, not curg. What is it?
+ // Hide call from linker nosplit analysis.
+ MOVL $runtime·badsystemstack(SB), AX
+ CALL AX
+
/*
* support for morestack
*/
MOVQ g(CX), AX // AX = g
MOVQ g_m(AX), BX // BX = m
- MOVQ m_gsignal(BX), DX // DX = gsignal
- CMPQ AX, DX
+ CMPQ AX, m_gsignal(BX)
JEQ noswitch
MOVQ m_g0(BX), DX // DX = g0
CMPQ AX, DX
JEQ noswitch
- MOVQ m_curg(BX), R8
- CMPQ AX, R8
- JEQ switch
-
- // Bad: g is not gsignal, not g0, not curg. What is it?
- MOVQ $runtime·badsystemstack(SB), AX
- CALL AX
+ CMPQ AX, m_curg(BX)
+ JNE bad
-switch:
+ // switch stacks
// save our state in g->sched. Pretend to
// be systemstack_switch if the G stack is scanned.
MOVQ $runtime·systemstack_switch(SB), SI
MOVQ 0(DI), DI
JMP DI
+bad:
+ // Bad: g is not gsignal, not g0, not curg. What is it?
+ MOVQ $runtime·badsystemstack(SB), AX
+ CALL AX
+
+
/*
* support for morestack
*/
MOVL g(CX), AX // AX = g
MOVL g_m(AX), BX // BX = m
- MOVL m_gsignal(BX), DX // DX = gsignal
- CMPL AX, DX
+ CMPL AX, m_gsignal(BX)
JEQ noswitch
MOVL m_g0(BX), DX // DX = g0
CMPL AX, DX
JEQ noswitch
- MOVL m_curg(BX), R8
- CMPL AX, R8
- JEQ switch
-
- // Not g0, not curg. Must be gsignal, but that's not allowed.
- // Hide call from linker nosplit analysis.
- MOVL $runtime·badsystemstack(SB), AX
- CALL AX
+ CMPL AX, m_curg(BX)
+ JNE bad
-switch:
+ // switch stacks
// save our state in g->sched. Pretend to
// be systemstack_switch if the G stack is scanned.
MOVL $runtime·systemstack_switch(SB), SI
MOVL 0(DI), DI
JMP DI
+bad:
+ // Not g0, not curg. Must be gsignal, but that's not allowed.
+ // Hide call from linker nosplit analysis.
+ MOVL $runtime·badsystemstack(SB), AX
+ CALL AX
+
/*
* support for morestack
*/