-
- Downloads
cmd/compile/internal/escape: optimize indirect closure calls
This CL extends escape analysis in two ways. First, we already optimize directly called closures. For example, given: var x int // already stack allocated today p := func() *int { return &x }() we don't need to move x to the heap, because we can statically track where &x flows. This CL extends the same idea to work for indirectly called closures too, as long as we know everywhere that they're called. For example: var x int // stack allocated after this CL f := func() *int { return &x } p := f() This will allow a subsequent CL to move the generation of go/defer wrappers earlier. Second, this CL adds tracking to detect when pointer values flow to the pointee operand of an indirect assignment statement (i.e., flows to p in "*p = x") or to builtins that modify memory (append, copy, clear). This isn't utilized in the current CL, but a subsequent CL will make use of it to better optimize string->[]byte conversions. Updates #2205. Change-Id: I610f9c531e135129c947684833e288ce64406f35 Reviewed-on: https://go-review.googlesource.com/c/go/+/520259 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by:Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by:
Dmitri Shuralyov <dmitshur@google.com>
Showing
- src/cmd/compile/internal/escape/assign.go 6 additions, 2 deletionssrc/cmd/compile/internal/escape/assign.go
- src/cmd/compile/internal/escape/call.go 33 additions, 16 deletionssrc/cmd/compile/internal/escape/call.go
- src/cmd/compile/internal/escape/escape.go 45 additions, 8 deletionssrc/cmd/compile/internal/escape/escape.go
- src/cmd/compile/internal/escape/graph.go 47 additions, 5 deletionssrc/cmd/compile/internal/escape/graph.go
- src/cmd/compile/internal/escape/leaks.go 37 additions, 17 deletionssrc/cmd/compile/internal/escape/leaks.go
- src/cmd/compile/internal/escape/solve.go 80 additions, 43 deletionssrc/cmd/compile/internal/escape/solve.go
- src/cmd/compile/internal/ir/func.go 3 additions, 3 deletionssrc/cmd/compile/internal/ir/func.go
- test/escape_closure.go 14 additions, 0 deletionstest/escape_closure.go
- test/inline_big.go 3 additions, 3 deletionstest/inline_big.go
Loading
Please register or sign in to comment