1
0
mirror of https://github.com/golang/go synced 2024-11-17 09:04:44 -07: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:
Cuong Manh Le 2022-05-17 16:11:36 +07:00
parent df7cb59de4
commit 3a1f1e1575
8 changed files with 4 additions and 30 deletions

View File

@ -75,11 +75,6 @@ func Main(archInit func(*ssagen.ArchInfo)) {
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
types.BuiltinPkg = types.NewPkg("go.builtin", "") // TODO(gri) name this package go.builtin?
types.BuiltinPkg.Prefix = "go.builtin" // not go%2ebuiltin

View File

@ -219,7 +219,6 @@ type typeDelayInfo struct {
func (g *irgen) generate(noders []*noder) {
types.LocalPkg.Name = g.self.Name()
types.LocalPkg.Height = g.self.Height()
typecheck.TypecheckAllowed = true
// Prevent size calculations until we set the underlying type

View File

@ -288,7 +288,7 @@ func (r *reader) doPkg() *types.Pkg {
}
name := r.String()
height := r.Len()
_ = r.Len() // was package height, but not necessary anymore.
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)
}
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
}

View File

@ -82,7 +82,6 @@ func unified(noders []*noder) {
base.Flag.Lang = fmt.Sprintf("go1.%d", goversion.Version)
types.ParseLangFlag()
types.LocalPkg.Height = 0 // reset so pkgReader.pkgIdx doesn't complain
target := typecheck.Target
typecheck.TypecheckAllowed = true

View File

@ -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)
w.String(path)
w.String(pkg.Name())
w.Len(pkg.Height())
w.Len(0) // was package height, but not necessary anymore.
w.Len(len(pkg.Imports()))
for _, imp := range pkg.Imports() {

View File

@ -405,7 +405,7 @@ func (w *exportWriter) writeIndex(index map[*types.Sym]uint64, mainIndex bool) {
w.string(exportPath(pkg))
if mainIndex {
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.

View File

@ -175,10 +175,9 @@ func ReadImports(pkg *types.Pkg, data string) {
for nPkgs := ird.uint64(); nPkgs > 0; nPkgs-- {
pkg := p.pkgAt(ird.uint64())
pkgName := p.stringAt(ird.uint64())
pkgHeight := int(ird.uint64())
_ = int(ird.uint64()) // was package height, but not necessary anymore.
if pkg.Name == "" {
pkg.Name = pkgName
pkg.Height = pkgHeight
types.NumImport[pkgName]++
// TODO(mdempsky): This belongs somewhere else.
@ -187,9 +186,6 @@ func ReadImports(pkg *types.Pkg, data string) {
if pkg.Name != pkgName {
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-- {

View File

@ -16,9 +16,6 @@ import (
// pkgMap maps a package path to a package.
var pkgMap = make(map[string]*Pkg)
// MaxPkgHeight is a height greater than any likely package height.
const MaxPkgHeight = 1e9
type Pkg struct {
Path string // string literal used in import statement, e.g. "runtime/internal/sys"
Name string // package name, e.g. "sys"
@ -26,12 +23,6 @@ type Pkg struct {
Syms map[string]*Sym
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
}