New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: investigate closure capture issue #18300

Open
bradfitz opened this Issue Dec 13, 2016 · 4 comments

Comments

Projects
None yet
8 participants
@bradfitz
Member

bradfitz commented Dec 13, 2016

This change reduces allocations:

https://go-review.googlesource.com/c/33765/4/src/encoding/json/encode.go

Why? Can the compiler be changed instead?

(See test file in same CL for details)

/cc @randall77 @mdempsky @aclements

@bradfitz bradfitz added this to the Go1.9Maybe milestone Dec 13, 2016

@randall77

This comment has been minimized.

Contributor

randall77 commented Dec 13, 2016

I suspect this would require a finer-grained escape analysis. Contrast these:

  f := new(int)
  doesntEscape(f)
  f = new(int)
  escapes(f)
  x := new(int)
  doesntEscape(x)
  y := new(int)
  escapes(y)

There's only one declaration in the first example. Escape analysis works on declarations. So f has to be declared as escaping. In contrast, the second example has 2 declarations so x can be seen to not escape.

I guess escape analysis would have to be augmented to split declarations into unconnected subsets somehow and then treat each subset independently.

@dr2chase

@mrjrieke

This comment has been minimized.

mrjrieke commented Dec 16, 2016

Interesting...

@bcmills

This comment has been minimized.

Member

bcmills commented Apr 28, 2017

Escape analysis works on declarations.

Does that change with SSA? I would expect escape analysis to apply to SSA variables/slots/whatever rather than source variables.

@dr2chase

This comment has been minimized.

Contributor

dr2chase commented May 2, 2017

No change here, sorry.

@bradfitz bradfitz modified the milestones: Go1.9Maybe, Go1.10 Jul 20, 2017

@cherrymui cherrymui modified the milestones: Go1.10, Go1.11 Nov 29, 2017

@gopherbot gopherbot modified the milestones: Go1.11, Unplanned May 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment