]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile, cmd/link, cmd/newlink: remove support for weak symbols
authorMichael Hudson-Doyle <michael.hudson@canonical.com>
Sun, 6 Mar 2016 20:47:02 +0000 (09:47 +1300)
committerMichael Hudson-Doyle <michael.hudson@canonical.com>
Sun, 6 Mar 2016 22:28:07 +0000 (22:28 +0000)
They were only used for rtype.ptrToThis which David Crawshaw removed a couple
of weeks ago. Removes two traversals of Ctxt.Allsym from the linker but it
doesn't seem to make much difference to performance.

Change-Id: I5c305e0180186f643221d57822d301de4aa18827
Reviewed-on: https://go-review.googlesource.com/20287
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/lex.go
src/cmd/compile/internal/gc/reflect.go
src/cmd/link/internal/ld/go.go
src/cmd/link/internal/ld/pobj.go
src/cmd/newlink/auto.go
src/cmd/newlink/auto_test.go
src/cmd/newlink/prog.go
src/cmd/newlink/testdata/autoweak.6 [deleted file]
src/cmd/newlink/testdata/autoweak.s [deleted file]

index e1b75d1b0cca42bcac1a1f97fb449aea6241aaa8..d890909ea4ab3e5c6ba91b5977dca15e821a53d2 100644 (file)
@@ -425,8 +425,6 @@ var typepkg *Pkg // fake package for runtime type info (headers)
 
 var typelinkpkg *Pkg // fake package for runtime type info (data)
 
-var weaktypepkg *Pkg // weak references to runtime type info
-
 var unsafepkg *Pkg // package unsafe
 
 var trackpkg *Pkg // fake package for field tracking
index 81bd9461ca2554decc1cfe1c6a928b35123bbcfc..383e076c64bdb0f82b0bf1f2e415a43573d89805 100644 (file)
@@ -140,11 +140,6 @@ func Main() {
        itabpkg.Name = "go.itab"
        itabpkg.Prefix = "go.itab" // not go%2eitab
 
-       weaktypepkg = mkpkg("go.weak.type")
-
-       weaktypepkg.Name = "go.weak.type"
-       weaktypepkg.Prefix = "go.weak.type" // not go%2eweak%2etype
-
        typelinkpkg = mkpkg("go.typelink")
        typelinkpkg.Name = "go.typelink"
        typelinkpkg.Prefix = "go.typelink" // not go%2etypelink
index 3cf480efd4326ef62ef8eab2b5ca70d232973250..1a436c322d3e3b17a34dd785fa9f8f425273d64b 100644 (file)
@@ -844,15 +844,6 @@ func typename(t *Type) *Node {
        return n
 }
 
-func weaktypesym(t *Type) *Sym {
-       p := Tconv(t, obj.FmtLeft)
-       s := Pkglookup(p, weaktypepkg)
-
-       //print("weaktypesym: %s -> %+S\n", p, s);
-
-       return s
-}
-
 // isreflexive reports whether t has a reflexive equality operator.
 // That is, if x==x for all x of type t.
 func isreflexive(t *Type) bool {
index 3ee7b292e387765970c68cd7bd6af1e6b12b6337..28959155060fa02e0938835d2cb0aceb5b2572f9 100644 (file)
@@ -373,9 +373,6 @@ func mark1(s *LSym, parent *LSym) {
        if s == nil || s.Attr.Reachable() {
                return
        }
-       if strings.HasPrefix(s.Name, "go.weak.") {
-               return
-       }
        s.Attr |= AttrReachable
        s.Reachparent = parent
        markQueue = append(markQueue, s)
@@ -494,14 +491,6 @@ func deadcode() {
                }
        }
 
-       for _, s := range Ctxt.Allsym {
-               if strings.HasPrefix(s.Name, "go.weak.") {
-                       s.Attr |= AttrSpecial // do not lay out in data segment
-                       s.Attr |= AttrReachable
-                       s.Attr |= AttrHidden
-               }
-       }
-
        // record field tracking references
        var buf bytes.Buffer
        for _, s := range Ctxt.Allsym {
@@ -532,26 +521,6 @@ func deadcode() {
        addstrdata(tracksym, buf.String())
 }
 
-func doweak() {
-       // resolve weak references only if
-       // target symbol will be in binary anyway.
-       for _, s := range Ctxt.Allsym {
-               if strings.HasPrefix(s.Name, "go.weak.") {
-                       t := Linkrlookup(Ctxt, s.Name[8:], int(s.Version))
-                       if t != nil && t.Type != 0 && t.Attr.Reachable() {
-                               s.Value = t.Value
-                               s.Type = t.Type
-                               s.Outer = t
-                       } else {
-                               s.Type = obj.SCONST
-                               s.Value = 0
-                       }
-
-                       continue
-               }
-       }
-}
-
 func addexport() {
        if HEADTYPE == obj.Hdarwin {
                return
index d36dfc1b6835ae594ee629bfa3764dcdf4cb9fb2..06932c694fb3f1f43156bac5206af5f30945e714 100644 (file)
@@ -216,7 +216,6 @@ func Ldmain() {
        symtab()
        dodata()
        address()
-       doweak()
        reloc()
        Thearch.Asmb()
        undef()
index aaebdd24d3a9f342b5cc21fbbdd233fb2538ecd7..ce7c6269bf26fdfe56efbba9cb799986afd56fed 100644 (file)
@@ -42,8 +42,7 @@ var linkerDefined = map[string]bool{
 
 // isAuto reports whether sym is an automatically-generated data or constant symbol.
 func (p *Prog) isAuto(sym goobj.SymID) bool {
-       return strings.HasPrefix(sym.Name, "go.weak.") ||
-               strings.HasPrefix(sym.Name, "$f64.") ||
+       return strings.HasPrefix(sym.Name, "$f64.") ||
                strings.HasPrefix(sym.Name, "$f32.") ||
                linkerDefined[sym.Name]
 }
@@ -85,24 +84,6 @@ func (p *Prog) autoData() {
        }
 }
 
-// autoConst defines the automatically generated constant symbols needed by p.
-func (p *Prog) autoConst() {
-       for sym := range p.Missing {
-               switch {
-               case strings.HasPrefix(sym.Name, "go.weak."):
-                       // weak symbol resolves to actual symbol if present, or else nil.
-                       delete(p.Missing, sym)
-                       targ := sym
-                       targ.Name = sym.Name[len("go.weak."):]
-                       var addr Addr
-                       if s := p.Syms[targ]; s != nil {
-                               addr = s.Addr
-                       }
-                       p.defineConst(sym.Name, addr)
-               }
-       }
-}
-
 // defineConst defines a new symbol with the given name and constant address.
 func (p *Prog) defineConst(name string, addr Addr) {
        sym := goobj.SymID{Name: name}
index 5447b87a65d105926e486a10dd5dbab5be30bad6..0e18266ecfce85d0c0d3af0196e4326839c12cff 100644 (file)
@@ -22,7 +22,6 @@ import (
 // identical 8-byte sequences.
 var autoTests = []string{
        "testdata/autosection.6",
-       "testdata/autoweak.6",
 }
 
 func TestAuto(t *testing.T) {
index 3ec65fe788d90bfd162f157082fb00778ab6b61e..9cf1402427a59ac0954ed0a257dccc3256538c47 100644 (file)
@@ -149,7 +149,6 @@ func (p *Prog) link(w io.Writer, mainFile string) {
        p.runtime()
        p.autoData()
        p.layout()
-       p.autoConst()
        if p.NumError > 0 {
                return
        }
diff --git a/src/cmd/newlink/testdata/autoweak.6 b/src/cmd/newlink/testdata/autoweak.6
deleted file mode 100644 (file)
index 5c68cdb..0000000
Binary files a/src/cmd/newlink/testdata/autoweak.6 and /dev/null differ
diff --git a/src/cmd/newlink/testdata/autoweak.s b/src/cmd/newlink/testdata/autoweak.s
deleted file mode 100644 (file)
index 6611456..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2014 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Test of go.weak symbols.
-
-TEXT start(SB),7,$0
-       MOVQ $autotab(SB),AX
-       MOVQ $autoptr(SB),AX
-       RET
-
-// go.weak.sym should resolve to sym, because sym is in the binary.
-DATA autotab+0(SB)/8, $go·weak·sym(SB)
-DATA autotab+8(SB)/8, $sym(SB)
-
-// go.weak.missingsym should resolve to 0, because missingsym is not in the binary.
-DATA autotab+16(SB)/8, $go·weak·missingsym(SB)
-DATA autotab+24(SB)/8, $0
-
-// go.weak.deadsym should resolve to 0, because deadsym is discarded during dead code removal
-DATA autotab+32(SB)/8, $go·weak·deadsym(SB)
-DATA autotab+40(SB)/8, $0
-
-GLOBL autotab(SB), $48
-
-GLOBL sym(SB), $1
-
-GLOBL deadsym(SB), $1
-
-GLOBL autoptr(SB), $0