update the common rules of function inlining

hitzhangjie 2021-05-09 19:17:09 +08:00
parent 730605acf0
commit e5c5218db6

@ -80,7 +80,14 @@ Gc compiler does global escape analysis across function and package boundaries.
### Function Inlining
Only short and simple functions are inlined. To be inlined a function must contain less than ~40 expressions and does not contain complex things like loops, labels, closures, `panic`'s, `recover`'s, `select`'s, `switch`'es, etc.
Only short and simple functions are inlined. To be inlined a function must conform to the rules:
- function should be simple enough, the number of AST nodes must less than the budget (80);
- function doesn't contain complex things like loops, closures, defer, recover, select, etc;
- function isn't prefixed by go:noinline;
- function isn't prefixed by go:uintptrescapes, since the escape information will be lost during inlining;
- function has body;
- etc.
* **gc:** 1.0+
* **gccgo:** -O1 and above.