Commit f4627d1b authored by Austin Clements's avatar Austin Clements

[dev.cc] runtime: merge power64 onM/onM_signalok into systemstack

This is the power64 component of CL 174950043.

With this, dev.cc compiles on power64 and power64le and passes
most tests if GOGC=off (but crashes in go_bootstrap if GC is
on).

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/175290043
parent 70f6769b
...@@ -145,58 +145,44 @@ TEXT runtime·mcall(SB), NOSPLIT, $-8-8 ...@@ -145,58 +145,44 @@ TEXT runtime·mcall(SB), NOSPLIT, $-8-8
BL (CTR) BL (CTR)
BR runtime·badmcall2(SB) BR runtime·badmcall2(SB)
// switchtoM is a dummy routine that onM leaves at the bottom // systemstack_switch is a dummy routine that systemstack leaves at the bottom
// of the G stack. We need to distinguish the routine that // of the G stack. We need to distinguish the routine that
// lives at the bottom of the G stack from the one that lives // lives at the bottom of the G stack from the one that lives
// at the top of the M stack because the one at the top of // at the top of the system stack because the one at the top of
// the M stack terminates the stack walk (see topofstack()). // the system stack terminates the stack walk (see topofstack()).
TEXT runtime·switchtoM(SB), NOSPLIT, $0-0 TEXT runtime·systemstack_switch(SB), NOSPLIT, $0-0
UNDEF UNDEF
BL (LR) // make sure this function is not leaf BL (LR) // make sure this function is not leaf
RETURN RETURN
// func onM_signalok(fn func()) // func systemstack(fn func())
TEXT runtime·onM_signalok(SB), NOSPLIT, $8-8 TEXT runtime·systemstack(SB), NOSPLIT, $0-8
MOVD g, R3 // R3 = g
MOVD g_m(R3), R4 // R4 = g->m
MOVD m_gsignal(R4), R4 // R4 = g->m->gsignal
MOVD fn+0(FP), R11 // context for call below
CMP R3, R4
BEQ onsignal
MOVD R11, 8(R1)
BL runtime·onM(SB)
RETURN
onsignal:
MOVD 0(R11), R3 // code pointer
MOVD R3, CTR
BL (CTR)
RETURN
// void onM(fn func())
TEXT runtime·onM(SB), NOSPLIT, $0-8
MOVD fn+0(FP), R3 // R3 = fn MOVD fn+0(FP), R3 // R3 = fn
MOVD R3, R11 // context MOVD R3, R11 // context
MOVD g_m(g), R4 // R4 = m MOVD g_m(g), R4 // R4 = m
MOVD m_gsignal(R4), R5 // R5 = gsignal
CMP g, R5
BEQ noswitch
MOVD m_g0(R4), R5 // R5 = g0 MOVD m_g0(R4), R5 // R5 = g0
CMP g, R5 CMP g, R5
BEQ onm BEQ noswitch
MOVD m_curg(R4), R6 MOVD m_curg(R4), R6
CMP g, R6 CMP g, R6
BEQ oncurg BEQ switch
// Not g0, not curg. Must be gsignal, but that's not allowed. // Bad: g is not gsignal, not g0, not curg. What is it?
// Hide call from linker nosplit analysis. // Hide call from linker nosplit analysis.
MOVD $runtime·badonm(SB), R3 MOVD $runtime·badsystemstack(SB), R3
MOVD R3, CTR MOVD R3, CTR
BL (CTR) BL (CTR)
oncurg: switch:
// save our state in g->sched. Pretend to // save our state in g->sched. Pretend to
// be switchtoM if the G stack is scanned. // be systemstack_switch if the G stack is scanned.
MOVD $runtime·switchtoM(SB), R6 MOVD $runtime·systemstack_switch(SB), R6
ADD $8, R6 // get past prologue ADD $8, R6 // get past prologue
MOVD R6, (g_sched+gobuf_pc)(g) MOVD R6, (g_sched+gobuf_pc)(g)
MOVD R1, (g_sched+gobuf_sp)(g) MOVD R1, (g_sched+gobuf_sp)(g)
...@@ -206,7 +192,7 @@ oncurg: ...@@ -206,7 +192,7 @@ oncurg:
// switch to g0 // switch to g0
MOVD R5, g MOVD R5, g
MOVD (g_sched+gobuf_sp)(g), R3 MOVD (g_sched+gobuf_sp)(g), R3
// make it look like mstart called onM on g0, to stop traceback // make it look like mstart called systemstack on g0, to stop traceback
SUB $8, R3 SUB $8, R3
MOVD $runtime·mstart(SB), R4 MOVD $runtime·mstart(SB), R4
MOVD R4, 0(R3) MOVD R4, 0(R3)
...@@ -224,7 +210,7 @@ oncurg: ...@@ -224,7 +210,7 @@ oncurg:
MOVD R0, (g_sched+gobuf_sp)(g) MOVD R0, (g_sched+gobuf_sp)(g)
RETURN RETURN
onm: noswitch:
// already on m stack, just call directly // already on m stack, just call directly
MOVD 0(R11), R3 // code pointer MOVD 0(R11), R3 // code pointer
MOVD R3, CTR MOVD R3, CTR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment