mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.unified] cmd/compile: remove package height
After CL 410654, symbols are now sorted by package path, package height is not necessary anymore. Updates #51734 Change-Id: I976edd2e574dda68eb5c76cf95645b9dce051393 Reviewed-on: https://go-review.googlesource.com/c/go/+/410342 Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
df7cb59de4
commit
3a1f1e1575
8 changed files with 4 additions and 30 deletions
|
|
@ -75,11 +75,6 @@ func Main(archInit func(*ssagen.ArchInfo)) {
|
||||||
|
|
||||||
types.LocalPkg = types.NewPkg(base.Ctxt.Pkgpath, "")
|
types.LocalPkg = types.NewPkg(base.Ctxt.Pkgpath, "")
|
||||||
|
|
||||||
// We won't know localpkg's height until after import
|
|
||||||
// processing. In the mean time, set to MaxPkgHeight to ensure
|
|
||||||
// height comparisons at least work until then.
|
|
||||||
types.LocalPkg.Height = types.MaxPkgHeight
|
|
||||||
|
|
||||||
// pseudo-package, for scoping
|
// pseudo-package, for scoping
|
||||||
types.BuiltinPkg = types.NewPkg("go.builtin", "") // TODO(gri) name this package go.builtin?
|
types.BuiltinPkg = types.NewPkg("go.builtin", "") // TODO(gri) name this package go.builtin?
|
||||||
types.BuiltinPkg.Prefix = "go.builtin" // not go%2ebuiltin
|
types.BuiltinPkg.Prefix = "go.builtin" // not go%2ebuiltin
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,6 @@ type typeDelayInfo struct {
|
||||||
|
|
||||||
func (g *irgen) generate(noders []*noder) {
|
func (g *irgen) generate(noders []*noder) {
|
||||||
types.LocalPkg.Name = g.self.Name()
|
types.LocalPkg.Name = g.self.Name()
|
||||||
types.LocalPkg.Height = g.self.Height()
|
|
||||||
typecheck.TypecheckAllowed = true
|
typecheck.TypecheckAllowed = true
|
||||||
|
|
||||||
// Prevent size calculations until we set the underlying type
|
// Prevent size calculations until we set the underlying type
|
||||||
|
|
|
||||||
|
|
@ -288,7 +288,7 @@ func (r *reader) doPkg() *types.Pkg {
|
||||||
}
|
}
|
||||||
|
|
||||||
name := r.String()
|
name := r.String()
|
||||||
height := r.Len()
|
_ = r.Len() // was package height, but not necessary anymore.
|
||||||
|
|
||||||
pkg := types.NewPkg(path, "")
|
pkg := types.NewPkg(path, "")
|
||||||
|
|
||||||
|
|
@ -298,12 +298,6 @@ func (r *reader) doPkg() *types.Pkg {
|
||||||
base.Assertf(pkg.Name == name, "package %q has name %q, but want %q", pkg.Path, pkg.Name, name)
|
base.Assertf(pkg.Name == name, "package %q has name %q, but want %q", pkg.Path, pkg.Name, name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if pkg.Height == 0 {
|
|
||||||
pkg.Height = height
|
|
||||||
} else {
|
|
||||||
base.Assertf(pkg.Height == height, "package %q has height %v, but want %v", pkg.Path, pkg.Height, height)
|
|
||||||
}
|
|
||||||
|
|
||||||
return pkg
|
return pkg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,6 @@ func unified(noders []*noder) {
|
||||||
base.Flag.Lang = fmt.Sprintf("go1.%d", goversion.Version)
|
base.Flag.Lang = fmt.Sprintf("go1.%d", goversion.Version)
|
||||||
types.ParseLangFlag()
|
types.ParseLangFlag()
|
||||||
|
|
||||||
types.LocalPkg.Height = 0 // reset so pkgReader.pkgIdx doesn't complain
|
|
||||||
target := typecheck.Target
|
target := typecheck.Target
|
||||||
|
|
||||||
typecheck.TypecheckAllowed = true
|
typecheck.TypecheckAllowed = true
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ func (pw *pkgWriter) pkgIdx(pkg *types2.Package) pkgbits.Index {
|
||||||
base.Assertf(path != "builtin" && path != "unsafe", "unexpected path for user-defined package: %q", path)
|
base.Assertf(path != "builtin" && path != "unsafe", "unexpected path for user-defined package: %q", path)
|
||||||
w.String(path)
|
w.String(path)
|
||||||
w.String(pkg.Name())
|
w.String(pkg.Name())
|
||||||
w.Len(pkg.Height())
|
w.Len(0) // was package height, but not necessary anymore.
|
||||||
|
|
||||||
w.Len(len(pkg.Imports()))
|
w.Len(len(pkg.Imports()))
|
||||||
for _, imp := range pkg.Imports() {
|
for _, imp := range pkg.Imports() {
|
||||||
|
|
|
||||||
|
|
@ -405,7 +405,7 @@ func (w *exportWriter) writeIndex(index map[*types.Sym]uint64, mainIndex bool) {
|
||||||
w.string(exportPath(pkg))
|
w.string(exportPath(pkg))
|
||||||
if mainIndex {
|
if mainIndex {
|
||||||
w.string(pkg.Name)
|
w.string(pkg.Name)
|
||||||
w.uint64(uint64(pkg.Height))
|
w.uint64(0) // was package height, but not necessary anymore.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort symbols within a package by name.
|
// Sort symbols within a package by name.
|
||||||
|
|
|
||||||
|
|
@ -175,10 +175,9 @@ func ReadImports(pkg *types.Pkg, data string) {
|
||||||
for nPkgs := ird.uint64(); nPkgs > 0; nPkgs-- {
|
for nPkgs := ird.uint64(); nPkgs > 0; nPkgs-- {
|
||||||
pkg := p.pkgAt(ird.uint64())
|
pkg := p.pkgAt(ird.uint64())
|
||||||
pkgName := p.stringAt(ird.uint64())
|
pkgName := p.stringAt(ird.uint64())
|
||||||
pkgHeight := int(ird.uint64())
|
_ = int(ird.uint64()) // was package height, but not necessary anymore.
|
||||||
if pkg.Name == "" {
|
if pkg.Name == "" {
|
||||||
pkg.Name = pkgName
|
pkg.Name = pkgName
|
||||||
pkg.Height = pkgHeight
|
|
||||||
types.NumImport[pkgName]++
|
types.NumImport[pkgName]++
|
||||||
|
|
||||||
// TODO(mdempsky): This belongs somewhere else.
|
// TODO(mdempsky): This belongs somewhere else.
|
||||||
|
|
@ -187,9 +186,6 @@ func ReadImports(pkg *types.Pkg, data string) {
|
||||||
if pkg.Name != pkgName {
|
if pkg.Name != pkgName {
|
||||||
base.Fatalf("conflicting package names %v and %v for path %q", pkg.Name, pkgName, pkg.Path)
|
base.Fatalf("conflicting package names %v and %v for path %q", pkg.Name, pkgName, pkg.Path)
|
||||||
}
|
}
|
||||||
if pkg.Height != pkgHeight {
|
|
||||||
base.Fatalf("conflicting package heights %v and %v for path %q", pkg.Height, pkgHeight, pkg.Path)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for nSyms := ird.uint64(); nSyms > 0; nSyms-- {
|
for nSyms := ird.uint64(); nSyms > 0; nSyms-- {
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,6 @@ import (
|
||||||
// pkgMap maps a package path to a package.
|
// pkgMap maps a package path to a package.
|
||||||
var pkgMap = make(map[string]*Pkg)
|
var pkgMap = make(map[string]*Pkg)
|
||||||
|
|
||||||
// MaxPkgHeight is a height greater than any likely package height.
|
|
||||||
const MaxPkgHeight = 1e9
|
|
||||||
|
|
||||||
type Pkg struct {
|
type Pkg struct {
|
||||||
Path string // string literal used in import statement, e.g. "runtime/internal/sys"
|
Path string // string literal used in import statement, e.g. "runtime/internal/sys"
|
||||||
Name string // package name, e.g. "sys"
|
Name string // package name, e.g. "sys"
|
||||||
|
|
@ -26,12 +23,6 @@ type Pkg struct {
|
||||||
Syms map[string]*Sym
|
Syms map[string]*Sym
|
||||||
Pathsym *obj.LSym
|
Pathsym *obj.LSym
|
||||||
|
|
||||||
// Height is the package's height in the import graph. Leaf
|
|
||||||
// packages (i.e., packages with no imports) have height 0,
|
|
||||||
// and all other packages have height 1 plus the maximum
|
|
||||||
// height of their imported packages.
|
|
||||||
Height int
|
|
||||||
|
|
||||||
Direct bool // imported directly
|
Direct bool // imported directly
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue