How Go Compiler oprimize method with value or pointer receiver/functions

81 views
Skip to first unread message

Richiise Nugraha

unread,
Oct 8, 2022, 4:58:20 AM10/8/22
to golang-nuts
Hi all, I have a few question regarding Go compiler optimizations.

How Go Compiler (gc) optimize methods with value or pointer receiver (or functions)?
Does a method with value receiver always create a copy of data to its stack or the copy happend if there's a write attempt to it (CoW, or used fields)?
From what I know it always create a copy of data with DUFFCOPY, but I am not sure if there's another cases.

For example I have 2 methods. Value, pointer receiver, respectively:
TEXT main.Donothing(SB), NOSPLIT|ABIInternal, $0-216
TEXT main.PtrDonothing(SB), NOSPLIT|ABIInternal, $0-8

Function `main.Donothing` has a big stack size compared `main.PtrDonothing`
And how does that affect inline budget

Thank you.

Reply all
Reply to author
Forward
0 new messages