Golang function calling convention

307 views
Skip to first unread message

wei.will...@gmail.com

unread,
Sep 21, 2016, 3:54:51 AM9/21/16
to golang-dev
I'm a little confused about golang function calling convention.
Through disassembly, i find that gccgo uses registers to pass paramaters and return value just as c/c++ but go compile uses memory to pass arguments and return value.
Does it mean that golang function calling convention is compiler-dependent?

Thanks
Wei

Dave Cheney

unread,
Sep 21, 2016, 3:57:48 AM9/21/16
to wei.will...@gmail.com, golang-dev

Hello,

The that is correct. For the gc compiler, from golang.org, all arguments and return values are passed on the stack and all registers are caller saved.

This is a tradition inhereted from the plan9 compilers of which the current compile is a distant descendant.


--
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aram Hăvărneanu

unread,
Sep 21, 2016, 6:12:36 AM9/21/16
to Dave Cheney, wei.will...@gmail.com, golang-dev
On Wed, Sep 21, 2016 at 9:57 AM, Dave Cheney <da...@cheney.net> wrote:
> This is a tradition inhereted from the plan9 compilers of which the current
> compile is a distant descendant.

This is not strictly true as Plan 9 uses a register for the 1st
argument and for the return value.

--
Aram Hăvărneanu
Reply all
Reply to author
Forward
0 new messages