aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/inline/inl.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go
index b8f3f9baee..80be841efa 100644
--- a/src/cmd/compile/internal/inline/inl.go
+++ b/src/cmd/compile/internal/inline/inl.go
@@ -446,8 +446,6 @@ func (v *hairyVisitor) tooHairy(fn *ir.Func) bool {
return false
}
-// doNode visits n and its children, updates the state in v, and returns true if
-// n makes the current function too hairy for inlining.
func (v *hairyVisitor) doNode(n ir.Node) bool {
if n == nil {
return false
@@ -579,10 +577,13 @@ func (v *hairyVisitor) doNode(n ir.Node) bool {
// TODO(danscales): Maybe make budget proportional to number of closure
// variables, e.g.:
//v.budget -= int32(len(n.(*ir.ClosureExpr).Func.ClosureVars) * 3)
- // TODO(austin): However, if we're able to inline this closure into
- // v.curFunc, then we actually pay nothing for the closure captures. We
- // should try to account for that if we're going to account for captures.
v.budget -= 15
+ // Scan body of closure (which DoChildren doesn't automatically
+ // do) to check for disallowed ops in the body and include the
+ // body in the budget.
+ if doList(n.(*ir.ClosureExpr).Func.Body, v.do) {
+ return true
+ }
case ir.OGO,
ir.ODEFER,