]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: deprecate has init and derived func instance
authorTim King <taking@google.com>
Thu, 15 Aug 2024 20:57:53 +0000 (13:57 -0700)
committerTim King <taking@google.com>
Tue, 20 Aug 2024 23:11:53 +0000 (23:11 +0000)
Removes 'has init' and 'derived func instance' fields from unified IR
starting with V2.

This should be a no-op at the moment as the writer is hardwired to create V1.

Updates #68778

Change-Id: I84a606cbc27cd6d8bd6eee2aff44c89f4aa7413c
Reviewed-on: https://go-review.googlesource.com/c/go/+/606035
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/importer/ureader.go
src/cmd/compile/internal/noder/reader.go
src/cmd/compile/internal/noder/unified.go
src/cmd/compile/internal/noder/writer.go
src/go/internal/gcimporter/ureader.go

index e0405b9afbe271ef4069520db14eb4a4418b67c9..467b1d418f41c9263ed9f68a20e21f40bd64e1d7 100644 (file)
@@ -39,13 +39,18 @@ func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input
 
        r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
        pkg := r.pkg()
-       r.Bool() // TODO(mdempsky): Remove; was "has init"
+
+       if r.Version().Has(pkgbits.HasInit) {
+               r.Bool()
+       }
 
        for i, n := 0, r.Len(); i < n; i++ {
                // As if r.obj(), but avoiding the Scope.Lookup call,
                // to avoid eager loading of imports.
                r.Sync(pkgbits.SyncObject)
-               assert(!r.Bool())
+               if r.Version().Has(pkgbits.DerivedFuncInstance) {
+                       assert(!r.Bool())
+               }
                r.p.objIdx(r.Reloc(pkgbits.RelocObj))
                assert(r.Len() == 0)
        }
@@ -366,7 +371,9 @@ func (r *reader) param() *types2.Var {
 func (r *reader) obj() (types2.Object, []types2.Type) {
        r.Sync(pkgbits.SyncObject)
 
-       assert(!r.Bool())
+       if r.Version().Has(pkgbits.DerivedFuncInstance) {
+               assert(!r.Bool())
+       }
 
        pkg, name := r.p.objIdx(r.Reloc(pkgbits.RelocObj))
        obj := pkg.Scope().Lookup(name)
index dcb4e3d1d9d3e18eacc151fec29d9fe9a1cf8696..a825d60f7eb813c292a9663dc423697155948033 100644 (file)
@@ -640,7 +640,9 @@ func (r *reader) obj() ir.Node {
 // and returns the encoded reference to it, without instantiating it.
 func (r *reader) objInfo() objInfo {
        r.Sync(pkgbits.SyncObject)
-       assert(!r.Bool()) // TODO(mdempsky): Remove; was derived func inst.
+       if r.Version().Has(pkgbits.DerivedFuncInstance) {
+               assert(!r.Bool())
+       }
        idx := r.Reloc(pkgbits.RelocObj)
 
        explicits := make([]typeInfo, r.Len())
index 4577ff666300e3bb0a42a25a88c6fe2de6270516..ead348f0c12b89811143a4a6e530b2184cbb7736 100644 (file)
@@ -329,7 +329,10 @@ func writePkgStub(m posMap, noders []*noder) string {
        {
                w := publicRootWriter
                w.pkg(pkg)
-               w.Bool(false) // TODO(mdempsky): Remove; was "has init"
+
+               if w.Version().Has(pkgbits.HasInit) {
+                       w.Bool(false)
+               }
 
                scope := pkg.Scope()
                names := scope.Names()
@@ -410,11 +413,15 @@ func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool) {
                        base.ErrorExit()
                }
 
-               r.Bool() // TODO(mdempsky): Remove; was "has init"
+               if r.Version().Has(pkgbits.HasInit) {
+                       r.Bool()
+               }
 
                for i, n := 0, r.Len(); i < n; i++ {
                        r.Sync(pkgbits.SyncObject)
-                       assert(!r.Bool())
+                       if r.Version().Has(pkgbits.DerivedFuncInstance) {
+                               assert(!r.Bool())
+                       }
                        idx := r.Reloc(pkgbits.RelocObj)
                        assert(r.Len() == 0)
 
@@ -477,11 +484,15 @@ func writeUnifiedExport(out io.Writer) {
                r.Sync(pkgbits.SyncPkg)
                selfPkgIdx = l.relocIdx(pr, pkgbits.RelocPkg, r.Reloc(pkgbits.RelocPkg))
 
-               r.Bool() // TODO(mdempsky): Remove; was "has init"
+               if r.Version().Has(pkgbits.HasInit) {
+                       r.Bool()
+               }
 
                for i, n := 0, r.Len(); i < n; i++ {
                        r.Sync(pkgbits.SyncObject)
-                       assert(!r.Bool())
+                       if r.Version().Has(pkgbits.DerivedFuncInstance) {
+                               assert(!r.Bool())
+                       }
                        idx := r.Reloc(pkgbits.RelocObj)
                        assert(r.Len() == 0)
 
@@ -508,12 +519,17 @@ func writeUnifiedExport(out io.Writer) {
 
                w.Sync(pkgbits.SyncPkg)
                w.Reloc(pkgbits.RelocPkg, selfPkgIdx)
-               w.Bool(false) // TODO(mdempsky): Remove; was "has init"
+
+               if w.Version().Has(pkgbits.HasInit) {
+                       w.Bool(false)
+               }
 
                w.Len(len(idxs))
                for _, idx := range idxs {
                        w.Sync(pkgbits.SyncObject)
-                       w.Bool(false)
+                       if w.Version().Has(pkgbits.DerivedFuncInstance) {
+                               w.Bool(false)
+                       }
                        w.Reloc(pkgbits.RelocObj, idx)
                        w.Len(0)
                }
index 0d59d84b614971b7f990d0539183302a59f9d8a1..c3ca40879062d0e36c3cda7f8480ee9db4e08018 100644 (file)
@@ -730,7 +730,9 @@ func (w *writer) obj(obj types2.Object, explicits *types2.TypeList) {
 // bitstream.
 func (w *writer) objInfo(info objInfo) {
        w.Sync(pkgbits.SyncObject)
-       w.Bool(false) // TODO(mdempsky): Remove; was derived func inst.
+       if w.Version().Has(pkgbits.DerivedFuncInstance) {
+               w.Bool(false)
+       }
        w.Reloc(pkgbits.RelocObj, info.idx)
 
        w.Len(len(info.explicits))
index 68d50626c5cafee3d89ea1b8b73a33692d311807..e4b4e17749903ae27ae059f13f53edd166ec4c59 100644 (file)
@@ -65,13 +65,17 @@ func readUnifiedPackage(fset *token.FileSet, ctxt *types.Context, imports map[st
 
        r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
        pkg := r.pkg()
-       r.Bool() // TODO(mdempsky): Remove; was "has init"
+       if r.Version().Has(pkgbits.HasInit) {
+               r.Bool()
+       }
 
        for i, n := 0, r.Len(); i < n; i++ {
                // As if r.obj(), but avoiding the Scope.Lookup call,
                // to avoid eager loading of imports.
                r.Sync(pkgbits.SyncObject)
-               assert(!r.Bool())
+               if r.Version().Has(pkgbits.DerivedFuncInstance) {
+                       assert(!r.Bool())
+               }
                r.p.objIdx(r.Reloc(pkgbits.RelocObj))
                assert(r.Len() == 0)
        }
@@ -428,7 +432,9 @@ func (r *reader) param() *types.Var {
 func (r *reader) obj() (types.Object, []types.Type) {
        r.Sync(pkgbits.SyncObject)
 
-       assert(!r.Bool())
+       if r.Version().Has(pkgbits.DerivedFuncInstance) {
+               assert(!r.Bool())
+       }
 
        pkg, name := r.p.objIdx(r.Reloc(pkgbits.RelocObj))
        obj := pkgScope(pkg).Lookup(name)