// Figure out if we need to switch to m->g0 stack.
// We get called to create new OS threads too, and those
- // come in on the m->g0 stack already.
+ // come in on the m->g0 stack already. Or we might already
+ // be on the m->gsignal stack.
get_tls(CX)
- MOVL g(CX), BP
- CMPL BP, $0
- JEQ nosave // Don't even have a G yet.
- MOVL g_m(BP), BP
- MOVL m_g0(BP), SI
MOVL g(CX), DI
- CMPL SI, DI
- JEQ noswitch
+ CMPL DI, $0
+ JEQ nosave // Don't even have a G yet.
+ MOVL g_m(DI), BP
CMPL DI, m_gsignal(BP)
JEQ noswitch
+ MOVL m_g0(BP), SI
+ CMPL DI, SI
+ JEQ noswitch
CALL gosave_systemstack_switch<>(SB)
get_tls(CX)
MOVL SI, g(CX)
// Figure out if we need to switch to m->g0 stack.
// We get called to create new OS threads too, and those
- // come in on the m->g0 stack already.
+ // come in on the m->g0 stack already. Or we might already
+ // be on the m->gsignal stack.
get_tls(CX)
- MOVQ g(CX), R8
- CMPQ R8, $0
- JEQ nosave
- MOVQ g_m(R8), R8
- MOVQ m_g0(R8), SI
MOVQ g(CX), DI
- CMPQ SI, DI
+ CMPQ DI, $0
JEQ nosave
+ MOVQ g_m(DI), R8
MOVQ m_gsignal(R8), SI
- CMPQ SI, DI
+ CMPQ DI, SI
+ JEQ nosave
+ MOVQ m_g0(R8), SI
+ CMPQ DI, SI
JEQ nosave
// Switch to system stack.
- MOVQ m_g0(R8), SI
CALL gosave_systemstack_switch<>(SB)
MOVQ SI, g(CX)
MOVQ (g_sched+gobuf_sp)(SI), SP
// Figure out if we need to switch to m->g0 stack.
// We get called to create new OS threads too, and those
- // come in on the m->g0 stack already.
+ // come in on the m->g0 stack already. Or we might already
+ // be on the m->gsignal stack.
MOVW g_m(g), R8
MOVW m_gsignal(R8), R3
CMP R3, g
// Figure out if we need to switch to m->g0 stack.
// We get called to create new OS threads too, and those
- // come in on the m->g0 stack already.
+ // come in on the m->g0 stack already. Or we might already
+ // be on the m->gsignal stack.
MOVD g_m(g), R8
MOVD m_gsignal(R8), R3
CMP R3, g
// Figure out if we need to switch to m->g0 stack.
// We get called to create new OS threads too, and those
- // come in on the m->g0 stack already.
+ // come in on the m->g0 stack already. Or we might already
+ // be on the m->gsignal stack.
MOVV g_m(g), R5
MOVV m_gsignal(R5), R6
BEQ R6, g, g0
// Figure out if we need to switch to m->g0 stack.
// We get called to create new OS threads too, and those
- // come in on the m->g0 stack already.
+ // come in on the m->g0 stack already. Or we might already
+ // be on the m->gsignal stack.
MOVW g_m(g), R5
+ MOVW m_gsignal(R5), R6
+ BEQ R6, g, g0
MOVW m_g0(R5), R6
BEQ R6, g, g0
// Figure out if we need to switch to m->g0 stack.
// We get called to create new OS threads too, and those
- // come in on the m->g0 stack already.
- // Moreover, if it's called inside the signal handler, it must not switch
- // to g0 as it can be in use by another syscall.
+ // come in on the m->g0 stack already. Or we might already
+ // be on the m->gsignal stack.
MOVD g_m(g), R8
MOVD m_gsignal(R8), R6
CMP R6, g
// Figure out if we need to switch to m->g0 stack.
// We get called to create new OS threads too, and those
- // come in on the m->g0 stack already.
+ // come in on the m->g0 stack already. Or we might already
+ // be on the m->gsignal stack.
MOV g_m(g), X6
+ MOV m_gsignal(X6), X7
+ BEQ X7, g, g0
MOV m_g0(X6), X7
BEQ X7, g, g0
// Figure out if we need to switch to m->g0 stack.
// We get called to create new OS threads too, and those
- // come in on the m->g0 stack already.
+ // come in on the m->g0 stack already. Or we might already
+ // be on the m->gsignal stack.
MOVD g_m(g), R6
- MOVD m_g0(R6), R6
- CMPBEQ R6, g, g0
+ MOVD m_gsignal(R6), R7
+ CMPBEQ R7, g, g0
+ MOVD m_g0(R6), R7
+ CMPBEQ R7, g, g0
BL gosave_systemstack_switch<>(SB)
- MOVD R6, g
+ MOVD R7, g
BL runtime·save_g(SB)
MOVD (g_sched+gobuf_sp)(g), R15