Skip to content

Commit

Permalink
cmd/compile: move typepkg back to gc package (cleanup)
Browse files Browse the repository at this point in the history
Change-Id: I4d5c54d2dceabf4630e5e642835b20c8c6890524
Reviewed-on: https://go-review.googlesource.com/41616
Run-TryBot: Robert Griesemer <[email protected]>
Reviewed-by: Josh Bleecher Snyder <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
  • Loading branch information
griesemer committed Apr 24, 2017
1 parent 31c96fc commit cdeda79
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
20 changes: 15 additions & 5 deletions src/cmd/compile/internal/gc/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,8 +901,18 @@ func typesymname(t *types.Type) string {
return name
}

// Fake package for runtime type info (headers)
// Don't access directly, use typeLookup below.
var typepkg = types.NewPkg("type", "type")

func typeLookup(name string) *types.Sym {
// Keep this wrapper function as a future
// version may protect typepkg with a mutex.
return typepkg.Lookup(name)
}

func typesym(t *types.Type) *types.Sym {
return types.TypePkgLookup(typesymname(t))
return typeLookup(typesymname(t))
}

// tracksym returns the symbol for tracking use of field/method f, assumed
Expand All @@ -913,7 +923,7 @@ func tracksym(t *types.Type, f *types.Field) *types.Sym {

func typesymprefix(prefix string, t *types.Type) *types.Sym {
p := prefix + "." + t.ShortString()
s := types.TypePkgLookup(p)
s := typeLookup(p)

//print("algsym: %s -> %+S\n", p, s);

Expand Down Expand Up @@ -1541,7 +1551,7 @@ func dalgsym(t *types.Type) *obj.LSym {
// we use one algorithm table for all AMEM types of a given size
p := fmt.Sprintf(".alg%d", t.Width)

s := types.TypePkgLookup(p)
s := typeLookup(p)
lsym = s.Linksym()
if s.AlgGen() {
return lsym
Expand All @@ -1556,7 +1566,7 @@ func dalgsym(t *types.Type) *obj.LSym {
// make hash closure
p = fmt.Sprintf(".hashfunc%d", t.Width)

hashfunc = types.TypePkgLookup(p).Linksym()
hashfunc = typeLookup(p).Linksym()

ot := 0
ot = dsymptr(hashfunc, ot, memhashvarlen, 0)
Expand All @@ -1566,7 +1576,7 @@ func dalgsym(t *types.Type) *obj.LSym {
// make equality closure
p = fmt.Sprintf(".eqfunc%d", t.Width)

eqfunc = types.TypePkgLookup(p).Linksym()
eqfunc = typeLookup(p).Linksym()

ot = 0
ot = dsymptr(eqfunc, ot, memequalvarlen, 0)
Expand Down
7 changes: 0 additions & 7 deletions src/cmd/compile/internal/types/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ var nopkg = &Pkg{
Syms: make(map[string]*Sym),
}

// fake package for runtime type info (headers)
var typepkg = NewPkg("type", "type")

func TypePkgLookup(name string) *Sym {
return typepkg.Lookup(name)
}

func (pkg *Pkg) Lookup(name string) *Sym {
s, _ := pkg.LookupOK(name)
return s
Expand Down

0 comments on commit cdeda79

Please sign in to comment.