Re:Size visualization of Go executables using D3
by senozhatsky on Tuesday April 02, 2019 @06:47AM
(#19552720)
> This is very surprising for a language that targets somewhat high performance.
> Looks like it's a 5-10% performance hit, but makes it easier to provide good backtrace information
Very interesting indeed.
Well, forcing your compiler to start passing parameters via stack is pretty
simple and it's not so uncommon.
And probably (and maybe) the Go team just wanted to make things simple.
Otherwise they would need to have two parameter passing implementations
and sometimes even use a mixed one - when platform does not have enough
registers (e.g. 6 CPU registers and a function which takes 6+ params),
so some parameters would be passed via registers, some via stack; or
maybe all of them via stack. And so on. So I am byuing the "good backtrace"
point.
For example, suppose I have a silly logging function my_func() [C code],
which takes 8 params:
> Looks like it's a 5-10% performance hit, but makes it easier to provide good backtrace information
Very interesting indeed.
Well, forcing your compiler to start passing parameters via stack is pretty simple and it's not so uncommon.
And probably (and maybe) the Go team just wanted to make things simple. Otherwise they would need to have two parameter passing implementations and sometimes even use a mixed one - when platform does not have enough registers (e.g. 6 CPU registers and a function which takes 6+ params), so some parameters would be passed via registers, some via stack; or maybe all of them via stack. And so on. So I am byuing the "good backtrace" point.
For example, suppose I have a silly logging function my_func() [C code], which takes 8 params:
Let's compile it with gcc (-O2) for ARM and let's take a look at what main() does: Looks like a bunch of stores to stack ptr: + 0 bytes; + 4 bytes; + 8 bytes; + 12 bytes.[Edit: should have passed __LINE__ instead of hardcoded 1, but that doesn't change the assembly.]