Skip to content
Snippets Groups Projects
Commit ac0844ec authored by Matthew Dempsky's avatar Matthew Dempsky
Browse files

[dev.unified] cmd/compile: move "has init" to private metadata

Currently, there's a "has init" bool in the public metadata section,
which is only needed by cmd/compile; but because it's in the public
metadata section, it's known to the go/types importers too. This CL
moves it instead to the new compiler-only private metadata section
added in the last CL for the inline bodies index.

The existing bool in the public metadata section is left in place, and
just always set to false, to avoid breaking the x/tools importer. The
next time we bump the export version number, we can remove the bool
properly. But no urgency just yet.

Change-Id: I380f358652374b5a221f85020a53dc65912ddb29
Reviewed-on: https://go-review.googlesource.com/c/go/+/419676


Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: default avatarDavid Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
parent f9959460
Branches
Tags
No related merge requests found
...@@ -39,7 +39,7 @@ func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input ...@@ -39,7 +39,7 @@ func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input
r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic) r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
pkg := r.pkg() pkg := r.pkg()
r.Bool() // has init r.Bool() // TODO(mdempsky): Remove; was "has init"
for i, n := 0, r.Len(); i < n; i++ { for i, n := 0, r.Len(); i < n; i++ {
// As if r.obj(), but avoiding the Scope.Lookup call, // As if r.obj(), but avoiding the Scope.Lookup call,
......
...@@ -161,7 +161,7 @@ func writePkgStub(noders []*noder) string { ...@@ -161,7 +161,7 @@ func writePkgStub(noders []*noder) string {
{ {
w := publicRootWriter w := publicRootWriter
w.pkg(pkg) w.pkg(pkg)
w.Bool(false) // has init; XXX w.Bool(false) // TODO(mdempsky): Remove; was "has init"
scope := pkg.Scope() scope := pkg.Scope()
names := scope.Names() names := scope.Names()
...@@ -237,12 +237,7 @@ func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool) { ...@@ -237,12 +237,7 @@ func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool) {
pkg := r.pkg() pkg := r.pkg()
base.Assertf(pkg == importpkg, "have package %q (%p), want package %q (%p)", pkg.Path, pkg, importpkg.Path, importpkg) base.Assertf(pkg == importpkg, "have package %q (%p), want package %q (%p)", pkg.Path, pkg, importpkg.Path, importpkg)
if r.Bool() { r.Bool() // TODO(mdempsky): Remove; was "has init"
sym := pkg.Lookup(".inittask")
task := ir.NewNameAt(src.NoXPos, sym)
task.Class = ir.PEXTERN
sym.Def = task
}
for i, n := 0, r.Len(); i < n; i++ { for i, n := 0, r.Len(); i < n; i++ {
r.Sync(pkgbits.SyncObject) r.Sync(pkgbits.SyncObject)
...@@ -262,6 +257,13 @@ func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool) { ...@@ -262,6 +257,13 @@ func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool) {
if !localStub { if !localStub {
r := pr.newReader(pkgbits.RelocMeta, pkgbits.PrivateRootIdx, pkgbits.SyncPrivate) r := pr.newReader(pkgbits.RelocMeta, pkgbits.PrivateRootIdx, pkgbits.SyncPrivate)
if r.Bool() {
sym := importpkg.Lookup(".inittask")
task := ir.NewNameAt(src.NoXPos, sym)
task.Class = ir.PEXTERN
sym.Def = task
}
for i, n := 0, r.Len(); i < n; i++ { for i, n := 0, r.Len(); i < n; i++ {
path := r.String() path := r.String()
name := r.String() name := r.String()
...@@ -302,7 +304,7 @@ func writeUnifiedExport(out io.Writer) { ...@@ -302,7 +304,7 @@ func writeUnifiedExport(out io.Writer) {
r.Sync(pkgbits.SyncPkg) r.Sync(pkgbits.SyncPkg)
selfPkgIdx = l.relocIdx(pr, pkgbits.RelocPkg, r.Reloc(pkgbits.RelocPkg)) selfPkgIdx = l.relocIdx(pr, pkgbits.RelocPkg, r.Reloc(pkgbits.RelocPkg))
r.Bool() // has init r.Bool() // TODO(mdempsky): Remove; was "has init"
for i, n := 0, r.Len(); i < n; i++ { for i, n := 0, r.Len(); i < n; i++ {
r.Sync(pkgbits.SyncObject) r.Sync(pkgbits.SyncObject)
...@@ -333,8 +335,7 @@ func writeUnifiedExport(out io.Writer) { ...@@ -333,8 +335,7 @@ func writeUnifiedExport(out io.Writer) {
w.Sync(pkgbits.SyncPkg) w.Sync(pkgbits.SyncPkg)
w.Reloc(pkgbits.RelocPkg, selfPkgIdx) w.Reloc(pkgbits.RelocPkg, selfPkgIdx)
w.Bool(false) // TODO(mdempsky): Remove; was "has init"
w.Bool(typecheck.Lookup(".inittask").Def != nil)
w.Len(len(idxs)) w.Len(len(idxs))
for _, idx := range idxs { for _, idx := range idxs {
...@@ -361,6 +362,8 @@ func writeUnifiedExport(out io.Writer) { ...@@ -361,6 +362,8 @@ func writeUnifiedExport(out io.Writer) {
w := privateRootWriter w := privateRootWriter
w.Bool(typecheck.Lookup(".inittask").Def != nil)
w.Len(len(bodies)) w.Len(len(bodies))
for _, body := range bodies { for _, body := range bodies {
w.String(body.sym.Pkg.Path) w.String(body.sym.Pkg.Path)
......
...@@ -60,7 +60,7 @@ func readUnifiedPackage(fset *token.FileSet, ctxt *types.Context, imports map[st ...@@ -60,7 +60,7 @@ func readUnifiedPackage(fset *token.FileSet, ctxt *types.Context, imports map[st
r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic) r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
pkg := r.pkg() pkg := r.pkg()
r.Bool() // has init r.Bool() // TODO(mdempsky): Remove; was "has init"
for i, n := 0, r.Len(); i < n; i++ { for i, n := 0, r.Len(); i < n; i++ {
// As if r.obj(), but avoiding the Scope.Lookup call, // As if r.obj(), but avoiding the Scope.Lookup call,
......
...@@ -19,6 +19,10 @@ import ( ...@@ -19,6 +19,10 @@ import (
// - v0: initial prototype // - v0: initial prototype
// //
// - v1: adds the flags uint32 word // - v1: adds the flags uint32 word
//
// TODO(mdempsky): For the next version bump:
// - remove the unused dict.derived.needed bool
// - remove the legacy "has init" bool from the public root
const currentVersion uint32 = 1 const currentVersion uint32 = 1
// A PkgEncoder provides methods for encoding a package's Unified IR // A PkgEncoder provides methods for encoding a package's Unified IR
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment