1
0
mirror of https://github.com/golang/go synced 2024-11-25 20:57:57 -07:00

runtime: jump to badmcall instead of calling it.

This replaces the mcall frame with the badmcall frame instead of
leaving the mcall frame on the stack and adding the badmcall frame.
Because mcall is no longer on the stack, traceback will now report what
called mcall, which is what we would like to see in this situation.

R=golang-dev, cshapiro
CC=golang-dev
https://golang.org/cl/13012044
This commit is contained in:
Keith Randall 2013-08-29 15:53:34 -07:00
parent 90351506d4
commit 32b770b2c0
4 changed files with 16 additions and 11 deletions

View File

@ -181,14 +181,16 @@ TEXT runtime·mcall(SB), NOSPLIT, $0-4
MOVL m(CX), BX MOVL m(CX), BX
MOVL m_g0(BX), SI MOVL m_g0(BX), SI
CMPL SI, AX // if g == m->g0 call badmcall CMPL SI, AX // if g == m->g0 call badmcall
JNE 2(PC) JNE 3(PC)
CALL runtime·badmcall(SB) MOVL $runtime·badmcall(SB), AX
JMP AX
MOVL SI, g(CX) // g = m->g0 MOVL SI, g(CX) // g = m->g0
MOVL (g_sched+gobuf_sp)(SI), SP // sp = m->g0->sched.sp MOVL (g_sched+gobuf_sp)(SI), SP // sp = m->g0->sched.sp
PUSHL AX PUSHL AX
CALL DI CALL DI
POPL AX POPL AX
CALL runtime·badmcall2(SB) MOVL $runtime·badmcall2(SB), AX
JMP AX
RET RET
/* /*

View File

@ -169,16 +169,16 @@ TEXT runtime·mcall(SB), NOSPLIT, $0-8
MOVQ m_g0(BX), SI MOVQ m_g0(BX), SI
CMPQ SI, AX // if g == m->g0 call badmcall CMPQ SI, AX // if g == m->g0 call badmcall
JNE 3(PC) JNE 3(PC)
ARGSIZE(0) MOVQ $runtime·badmcall(SB), AX
CALL runtime·badmcall(SB) JMP AX
MOVQ SI, g(CX) // g = m->g0 MOVQ SI, g(CX) // g = m->g0
MOVQ (g_sched+gobuf_sp)(SI), SP // sp = m->g0->sched.sp MOVQ (g_sched+gobuf_sp)(SI), SP // sp = m->g0->sched.sp
PUSHQ AX PUSHQ AX
ARGSIZE(8) ARGSIZE(8)
CALL DI CALL DI
POPQ AX POPQ AX
ARGSIZE(0) MOVQ $runtime·badmcall2(SB), AX
CALL runtime·badmcall2(SB) JMP AX
RET RET
/* /*

View File

@ -157,12 +157,13 @@ TEXT runtime·mcall(SB), NOSPLIT, $-4-4
MOVW g, R1 MOVW g, R1
MOVW m_g0(m), g MOVW m_g0(m), g
CMP g, R1 CMP g, R1
BL.EQ runtime·badmcall(SB) B.NE 2(PC)
B runtime·badmcall(SB)
MOVW (g_sched+gobuf_sp)(g), SP MOVW (g_sched+gobuf_sp)(g), SP
SUB $8, SP SUB $8, SP
MOVW R1, 4(SP) MOVW R1, 4(SP)
BL (R0) BL (R0)
BL runtime·badmcall2(SB) B runtime·badmcall2(SB)
RET RET
/* /*

View File

@ -1997,14 +1997,16 @@ runtime·mcount(void)
} }
void void
runtime·badmcall(void) // called from assembly runtime·badmcall(void (*fn)(G*)) // called from assembly
{ {
USED(fn); // TODO: print fn?
runtime·throw("runtime: mcall called on m->g0 stack"); runtime·throw("runtime: mcall called on m->g0 stack");
} }
void void
runtime·badmcall2(void) // called from assembly runtime·badmcall2(void (*fn)(G*)) // called from assembly
{ {
USED(fn);
runtime·throw("runtime: mcall function returned"); runtime·throw("runtime: mcall function returned");
} }