Post

This is a fun one: I just sent go.dev/cl/790740, which elides method wrappers for embedded types at offset zero, common for mixins/inherited data types. Doing this removes 60 _thousand_ method wrappers from tsgo's AST package, dropping the compilation of our main exe from 49s to 28s on my machine.

It also shaves 1.3% off of the cmd/compile binary as it also uses embedding in the same way tsgo does for its AST/types (and, probably will even more in the future if I'm able to find time) In addition, 0.6% off of go, 0.66% off of pprof. This is more or less a "fix" for github.com/golang/go/is...

github.comcmd/compile: deduplicate wrappers for promoted methods · Issue #57916 · golang/goGiven: type X int func (*X) m() {} type A struct { X } type B struct { b int32; X } type C struct { c uint32; X } the compiler currently synthesizes method wrappers for the promoted methods: func (...

Frankly I'm shocked this worked on the first try, with just one tweak, disabling it in linkshared mode (yay relative relocs) Here's to hoping I haven't missed anything, but trybots are happy, so......

To be clear, this all is about this pattern: type E struct{ x int } func (e *E) M() int { return e.x } type T struct { E; y int } You don't need any special wrapper / adapter for this because it's a pointer. Can't do this for value receivers, since you need to be able to "call" with T.

No replies yet.