You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes it does, but not as aggressive as it could be. For example, only leaf functions can be inlined, i.e. functions that do not call other functions. IIRC also ASM functions are not inlined, and there are some other conditions.
不过有人已经在做更好的内联编译了, 因为这种方式可以提升性能, go1.13 release note里就提到
Go 内联函数
Go 有内联编译吗?
Yes it does, but not as aggressive as it could be. For example, only leaf functions can be inlined, i.e. functions that do not call other functions. IIRC also ASM functions are not inlined, and there are some other conditions.
不过有人已经在做更好的内联编译了, 因为这种方式可以提升性能, go1.13 release note里就提到
How to disable inline by Compiler?
just add
//go:noinline
before the functionhow to know it is inline or not ?
run
go build --gcflags="-m -m -m"
-m 越多信息越多内联函数的缺点
但在选择使用内联函数时,必须在程序占用空间和程序执行效率之间进行权衡,因为过多的比较复杂的函数进行内联扩展将带来很大的存储资源开支
如果编译器处理的不好, 内联函数debug会更困难, 因为本质上是编译器改了你的代码
The text was updated successfully, but these errors were encountered: