Re: [go-nuts] Re: one GC implementation question

2017-03-26 Thread Dave Cheney
x doesn't escape, the result of evaluating *x passed to Println escapes because escape analysis cannot determine if the contents of the ...interface{} passed to fmt.Println are retained. It's a very hard case for escape ananlysis. -- You received this message because you are subscribed to the

Re: [go-nuts] Re: one GC implementation question

2017-03-26 Thread T L
On Wednesday, March 22, 2017 at 7:49:39 PM UTC+8, Dave Cheney wrote: > > Well, that program isn't that simple because of the closure, but also > because it contains a data race > > Something like this is easier to reason about > > var x *int > > func main() { > var a int > x = &a

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread Jesper Louis Andersen
It isn't just inlining that affects closures. Most programming languages with closures use several closure representations at the same time. The compiler picks among them depending on which representation gives the best program efficiency at runtime and depending on what information they staticall

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 10:38:32 PM UTC+8, T L wrote: > > > > On Wednesday, March 22, 2017 at 7:49:39 PM UTC+8, Dave Cheney wrote: >> >> Well, that program isn't that simple because of the closure, but also >> because it contains a data race >> >> Something like this is easier to reason

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 7:49:39 PM UTC+8, Dave Cheney wrote: > > Well, that program isn't that simple because of the closure, but also > because it contains a data race > > Something like this is easier to reason about > > var x *int > > func main() { > var a int > x = &a

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 9:29:32 PM UTC+8, Ian Lance Taylor wrote: > > On Wed, Mar 22, 2017 at 3:59 AM, T L > > wrote: > > > > On Wednesday, March 22, 2017 at 6:40:53 PM UTC+8, Jesse McNelis wrote: > >> > >> On Wed, Mar 22, 2017 at 8:51 PM, T L wrote: > >> > > >> > More accurately

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread Ian Lance Taylor
On Wed, Mar 22, 2017 at 3:59 AM, T L wrote: > > On Wednesday, March 22, 2017 at 6:40:53 PM UTC+8, Jesse McNelis wrote: >> >> On Wed, Mar 22, 2017 at 8:51 PM, T L wrote: >> > >> > More accurately, I think it should be: from the POV of a programmer, >> > it's >> > globals, and things reachable fro

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread Dave Cheney
Well, that program isn't that simple because of the closure, but also because it contains a data race Something like this is easier to reason about var x *int func main() { var a int x = &a fmt.Println(*x) } On Wednesday, 22 March 2017 21:59:17 UTC+11, T L wrote: > > >

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 6:40:53 PM UTC+8, Jesse McNelis wrote: > > On Wed, Mar 22, 2017 at 8:51 PM, T L > > wrote: > > > > More accurately, I think it should be: from the POV of a programmer, > it's > > globals, and things reachable from each goroutine. > > > > The only way to rea

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 6:40:53 PM UTC+8, Jesse McNelis wrote: > > On Wed, Mar 22, 2017 at 8:51 PM, T L > > wrote: > > > > More accurately, I think it should be: from the POV of a programmer, > it's > > globals, and things reachable from each goroutine. > > > > The only way to rea

Re: [go-nuts] Re: one GC implementation question

2017-03-22 Thread Jesse McNelis
On Wed, Mar 22, 2017 at 8:51 PM, T L wrote: > > More accurately, I think it should be: from the POV of a programmer, it's > globals, and things reachable from each goroutine. > The only way to reach a value is through a variable in scope and the only variables in scope are global or on the stack

[go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 6:00:12 PM UTC+8, Dave Cheney wrote: > > > > On Wednesday, 22 March 2017 20:51:18 UTC+11, T L wrote: >> >> >> >> On Wednesday, March 22, 2017 at 4:56:28 PM UTC+8, Dave Cheney wrote: >>> >>> The comment on >>> >>> https://github.com/golang/go/blob/master/src/runtim

[go-nuts] Re: one GC implementation question

2017-03-22 Thread Dave Cheney
On Wednesday, 22 March 2017 20:51:18 UTC+11, T L wrote: > > > > On Wednesday, March 22, 2017 at 4:56:28 PM UTC+8, Dave Cheney wrote: >> >> The comment on >> >> https://github.com/golang/go/blob/master/src/runtime/mgc.go#L47 >> >> //c. GC performs root marking jobs. This includes scanning all

[go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 4:56:28 PM UTC+8, Dave Cheney wrote: > > The comment on > > https://github.com/golang/go/blob/master/src/runtime/mgc.go#L47 > > //c. GC performs root marking jobs. This includes scanning all > //stacks, shading all globals, and shading any heap pointers in

[go-nuts] Re: one GC implementation question

2017-03-22 Thread Dave Cheney
The comment on https://github.com/golang/go/blob/master/src/runtime/mgc.go#L47 //c. GC performs root marking jobs. This includes scanning all //stacks, shading all globals, and shading any heap pointers in //off-heap runtime data structures. Scanning a stack stops a //goroutine,

[go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 4:33:21 PM UTC+8, Dave Cheney wrote: > > > > On Wednesday, 22 March 2017 19:29:02 UTC+11, T L wrote: >> >> >> >> On Wednesday, March 22, 2017 at 4:08:02 PM UTC+8, Dave Cheney wrote: >>> >>> >>> >>> On Wednesday, 22 March 2017 19:04:36 UTC+11, T L wrote: I

[go-nuts] Re: one GC implementation question

2017-03-22 Thread Dave Cheney
On Wednesday, 22 March 2017 19:29:02 UTC+11, T L wrote: > > > > On Wednesday, March 22, 2017 at 4:08:02 PM UTC+8, Dave Cheney wrote: >> >> >> >> On Wednesday, 22 March 2017 19:04:36 UTC+11, T L wrote: >>> >>> In this article: https://blog.golang.org/go15gc , it mentions >>> >>> ..., The GC visits

[go-nuts] Re: one GC implementation question

2017-03-22 Thread T L
On Wednesday, March 22, 2017 at 4:08:02 PM UTC+8, Dave Cheney wrote: > > > > On Wednesday, 22 March 2017 19:04:36 UTC+11, T L wrote: >> >> In this article: https://blog.golang.org/go15gc , it mentions >> >> ..., The GC visits all *roots*, which are objects directly accessible by >>> the applicat

[go-nuts] Re: one GC implementation question

2017-03-22 Thread Dave Cheney
On Wednesday, 22 March 2017 19:04:36 UTC+11, T L wrote: > > In this article: https://blog.golang.org/go15gc , it mentions > > ..., The GC visits all *roots*, which are objects directly accessible by >> the application such as globals and things on the stack, and colors these >> grey. ... > > >