On Tue, Jul 30, 2019 at 8:58 PM <wangjinjinj...@gmail.com> wrote:
>
> I read go runtime code,but I'm poor in assembly language,
> i can't understand the following code
>         // switch to g0
>         MOVQ    DX, g(CX)
>         MOVQ    (g_sched+gobuf_sp)(DX), BX
>         // make it look like mstart called systemstack on g0, to stop 
> traceback
>         SUBQ    $8, BX
>         MOVQ    $runtime·mstart(SB), DX
>         MOVQ    DX, 0(BX)
>         MOVQ    BX, SP
>
>
> what does copy runtime·mstart to stack means,could someone help me

It does exactly what the comment says: when doing a stack traceback,
it makes it appear that mstart called systemstack.  When a function is
called, the return address is placed on the stack.  In this case the
assembly code is deliberately putting mstart on the stack, so that
that is what a traceback will see.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcUBAfeQuOKfnvvxhXeQcFZMkETF4s3GseDevmQyk5Mjnw%40mail.gmail.com.

Reply via email to