Sep 26, 2020

[Go] inline gotya

Reference:
https://vsdmars.blogspot.com/2020/02/golang-tooling-update.html
https://github.com/golang/go/wiki/CompilerOptimizations
Proposal:
https://go.googlesource.com/proposal/+/refs/heads/master/design/34481-opencoded-defers.md


Function Inlining: (compiled with -gcflags="-m")
Only short and simple functions are inlined.
To be inlined a function must contain less than ~40 expressions(80 AST nodes)  and does not contain complex things like 
  • loops (for), 
  • labels, 
  • closures,
  • panic's,
  • recover's,
  • select's,
  • switch
  • defer (now up-lifted thanks to Proposal: Low-cost defers through inline code, and extra funcdata to manage the panic case)
  • go (goroutine creation)


Visualize with flag:
-gcflags="-d pctab=pctoinline"

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.