]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: only generate ·f symbols when necessary
authorshaharko <skohanim@gmail.com>
Thu, 13 Oct 2016 19:56:38 +0000 (22:56 +0300)
committerShahar Kohanim <skohanim@gmail.com>
Tue, 25 Oct 2016 05:16:34 +0000 (05:16 +0000)
Before go supported buildmode=shared ·f symbols used to be defined
only when they were used. In order to solve #11480 the strategy
was changed to have these symbols defined on declaration which is
less efficient and generates many unneeded symbols.
With this change the best strategy is chosen for each situation,
improving static linking time:

name            old s/op    new s/op    delta
LinkCmdCompile   0.27 ± 5%   0.25 ± 6%  -8.22%   (p=0.000 n=98+96)
LinkCmdGo        0.30 ± 6%   0.29 ± 8%  -5.03%   (p=0.000 n=95+99)

name            old MaxRSS  new MaxRSS  delta
LinkCmdCompile   107k ± 2%    98k ± 3%  -8.32%  (p=0.000 n=99+100)
LinkCmdGo        106k ± 3%   104k ± 3%  -1.94%  (p=0.000 n=99+100)

Change-Id: I965eeee30541e724fd363804adcd6fda10f965a4
Reviewed-on: https://go-review.googlesource.com/31031
Reviewed-by: Michael Hudson-Doyle <michael.hudson@canonical.com>
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/dcl.go

index 506cab1656dc61898732237afe9d23cbfdb574a9..5183510fe5d23ad70ef167b259a08da47f238d78 100644 (file)
@@ -218,7 +218,9 @@ func makeclosure(func_ *Node) *Node {
        xfunc.Func.Nname.Name.Funcdepth = func_.Func.Depth
        xfunc.Func.Depth = func_.Func.Depth
        xfunc.Func.Endlineno = func_.Func.Endlineno
-       makefuncsym(xfunc.Func.Nname.Sym)
+       if Ctxt.Flag_dynlink {
+               makefuncsym(xfunc.Func.Nname.Sym)
+       }
 
        xfunc.Nbody.Set(func_.Nbody.Slice())
        xfunc.Func.Dcl = append(func_.Func.Dcl, xfunc.Func.Dcl...)
index ff485c8377e6eb45634e62196d2a7400c443b49a..d95e8dbd448ec608faeb1697b6aeb38b7c1fc030 100644 (file)
@@ -526,7 +526,7 @@ func funchdr(n *Node) {
                Fatalf("funchdr: dclcontext = %d", dclcontext)
        }
 
-       if importpkg == nil && n.Func.Nname != nil {
+       if Ctxt.Flag_dynlink && importpkg == nil && n.Func.Nname != nil {
                makefuncsym(n.Func.Nname.Sym)
        }
 
@@ -1318,6 +1318,11 @@ func funcsym(s *Sym) *Sym {
        }
 
        s1 := Pkglookup(s.Name+"·f", s.Pkg)
+       if !Ctxt.Flag_dynlink && s1.Def == nil {
+               s1.Def = newfuncname(s1)
+               s1.Def.Func.Shortname = newname(s)
+               funcsyms = append(funcsyms, s1.Def)
+       }
        s.Fsym = s1
        return s1
 }