]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[dev.unified] cmd/compile: remove package height
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Tue, 17 May 2022 09:11:36 +0000 (16:11 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Mon, 6 Jun 2022 19:19:59 +0000 (19:19 +0000)
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>
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/noder/irgen.go
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/noder/unified.go
src/cmd/compile/internal/noder/writer.go
src/cmd/compile/internal/typecheck/iexport.go
src/cmd/compile/internal/typecheck/iimport.go
src/cmd/compile/internal/types/pkg.go

index 70f1a2f847f71e85fca3e8f01d55c16539c2ce69..a5a2d56c466e94ab3efbd310e55e426d258ac8c7 100644 (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
index 628c0f54fc76f64d7b6c0bf83ff66038e161bba3..74e74010243f0ee06d7d092a70eeb5dc4088b673 100644 (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
index 6614d1693fbee99014eb9de265ad4751a532d142..0440d324ccf0e1f7f96e266dec2f98bc6c74059d 100644 (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
 }
 
index 46acdab79e1b986d77083f62e7b3cb64bcc89c82..f7cf7f90b2a1a31f0f09d011297dc6abbcab4254 100644 (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
index 2d1a7ee4577d0b5221dba457c2e635f31717447d..2fb158343741fa2df28aeffd6f6b6faf7677a17c 100644 (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() {
index d5c4b8e1e84d5a88b8cbc0eda02d3f45207c4713..fa0e292ed26fe19790046a5972d2096f87b068a1 100644 (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.
index 3a51f781f0531688b862e21a01dc7caf0d993a83..1968af7f1c3eb84d68eceb92e29a3ec5d8842fe8 100644 (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-- {
index 4bf39a5e9dfff675890d4bd66fcc0efe28311874..9a2149401729c87e987fa3875d71ff73f091c1cc 100644 (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
 }