]> Cypherpunks repositories - gostls13.git/commit
cmd/internal/gc: statically initialize function pointers
authorMatthew Dempsky <mdempsky@google.com>
Thu, 5 Mar 2015 00:33:28 +0000 (16:33 -0800)
committerKeith Randall <khr@golang.org>
Thu, 5 Mar 2015 21:35:07 +0000 (21:35 +0000)
commit632217aae47f8abd2fe8487068367a5bb5f9ea0a
treef0701da9b2a27634df6c98c8f64b627cbf025cd3
parent24a43e6a7542c2aefd1e2f16f0daae8100e4bdce
cmd/internal/gc: statically initialize function pointers

Previously, gc would compile code like

    func foo() { ... }
    var bar = foo

by emitting a static closure to wrap "foo", but then emitting runtime
initialization code to assign the closure to "bar".  This CL changes
gc to instead statically initialize "bar".

Notably, this change shrinks the "go" tool's text segment by ~7.4kB on
linux/amd64 while only increasing the data segment by ~100B:

   text    data     bss     dec     hex filename
7237819  122412  215616 7575847  739927 go.before
7230398  122540  215232 7568170  737b2a go.after

Fixes issue #10081.

Change-Id: If5e26cf46b323393ba6f2199a82a06e9e4baf411
Reviewed-on: https://go-review.googlesource.com/6880
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/internal/gc/sinit.go