I observed that the regexp package has a pool of onePassMachine objects, 
which I believe exist to avoid allocation due to heap escape caused by 
calling through the 'inputs' interface.

I expected that, using generics, I can replace that interface with a type 
parameter, and hence do away with the need for the pool.

My trial implementation is 
here: https://github.com/golang/go/compare/master...bboreham:generic-exec

But it does not succeed: the generic parameter escapes to the heap.
Compiler says:

regexp/exec.go:391:37: parameter i leaks to {heap} with derefs=0:
regexp/exec.go:391:37:   flow: {heap} = i:
regexp/exec.go:391:37:     from unsafe.Pointer(i) (interface-converted) at 
regexp/exec.go:412:14
regexp/exec.go:391:37:     from (<node EFACE>).step(pos) (call parameter) 
at regexp/exec.go:412:19

Am I holding it wrong?  Why does i get "interface-converted" ?

Thanks,

Bryan

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/14c36114-e7e2-41fd-8276-3e72ae9ee231n%40googlegroups.com.

Reply via email to