Re: [go-nuts] Re: go escape analysis

2016-10-02 Thread 刘桂祥
Hi Chris: I am gopher from Beijing China . I am very like programing and adore the old hack culture . and NBA too! I am very happy in google groups and receive the answer so quickly. go on practice programing and improve my badly english ques

Re: [go-nuts] Re: go escape analysis

2016-09-30 Thread 'Chris Manghane' via golang-nuts
Hmm, I'm not so sure if that's the rule. The rules are expressed in the code in https://github.com/golang/go/blob/master/src/cmd/ compile/internal/gc/esc.go, which is unlikely to make any significant changes in the near future. Those rules aren't written in plain english, but we should not discoura

Re: [go-nuts] Re: go escape analysis

2016-09-30 Thread 'Chris Manghane' via golang-nuts
You're correct. I'm sorry about my first response; it was too brief and led to the confusion you have. The Go escape analysis algorithm has a concept of "loopdepth" (shortened as ld in debug output). The loopdepth is -1 for global variables, 0 for input arguments to a function, 1 for the top level

Re: [go-nuts] Re: go escape analysis

2016-09-29 Thread 'Axel Wagner' via golang-nuts
The only real rule is "when the compiler can prove, that it doesn't escape, it doesn't". There is no guarantee or fixed policy around escape analysis. If you are convinced that something doesn't escape and that the compiler should be able to figure it out, you can try filing an issue about that wit

Re: [go-nuts] Re: go escape analysis

2016-09-29 Thread 刘桂祥
package main func main() { var m map[int]int { m = make(map[int]int) } _ = m } if I do this m will not escape just want to know what's the scope rule for escape ? puzzled

Re: [go-nuts] Re: go escape analysis

2016-09-29 Thread Dave Cheney
-gcflags=-m is your guide. There are no documents of the escape analysis done by the gc compiler, but you could read the source of cmd/compile/internal/gc/esc.go -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and

Re: [go-nuts] Re: go escape analysis

2016-09-29 Thread 刘桂祥
veyr thanks and want to know more about go's compile and escape rules 在 2016年9月29日星期四 UTC+8上午1:39:09,Chris Manghane写道: > > In the first example, make does not escape the scope of the for statement. > In the second example, make is assigned to m, which is outside of the scope > of the for statem

Re: [go-nuts] Re: go escape analysis

2016-09-28 Thread Ian Lance Taylor
On Wed, Sep 28, 2016 at 11:15 AM, ⚛ <0xe2.0x9a.0...@gmail.com> wrote: > We could discuss what has "gone wrong" in the Go compiler; and how to make > it work at least in theory. > > Unfortunately, me not being paid by Google is a line I am both unable and > unwilling to cross. > > I feel sorry for n

Re: [go-nuts] Re: go escape analysis

2016-09-28 Thread 'Chris Manghane' via golang-nuts
In the first example, make does not escape the scope of the for statement. In the second example, make is assigned to m, which is outside of the scope of the for statement, which means the make operation escapes its scope and subsequently, is heap allocated. If you want more information about why s