mirror of
https://github.com/golang/go.git
synced 2025-05-05 23:53:05 +00:00
update the common rules of function inlining
parent
730605acf0
commit
e5c5218db6
@ -80,7 +80,14 @@ Gc compiler does global escape analysis across function and package boundaries.
|
|||||||
|
|
||||||
### Function Inlining
|
### 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+
|
* **gc:** 1.0+
|
||||||
* **gccgo:** -O1 and above.
|
* **gccgo:** -O1 and above.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user