Skip to content

Commit 24fd1a0

Browse files
committed
cmd/compile: deprecate has init and derived func instance
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>
1 parent 7dc1ee8 commit 24fd1a0

File tree

5 files changed

+48
-15
lines changed

5 files changed

+48
-15
lines changed

src/cmd/compile/internal/importer/ureader.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,18 @@ func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input
3939

4040
r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
4141
pkg := r.pkg()
42-
r.Bool() // TODO(mdempsky): Remove; was "has init"
42+
43+
if r.Version().Has(pkgbits.HasInit) {
44+
r.Bool()
45+
}
4346

4447
for i, n := 0, r.Len(); i < n; i++ {
4548
// As if r.obj(), but avoiding the Scope.Lookup call,
4649
// to avoid eager loading of imports.
4750
r.Sync(pkgbits.SyncObject)
48-
assert(!r.Bool())
51+
if r.Version().Has(pkgbits.DerivedFuncInstance) {
52+
assert(!r.Bool())
53+
}
4954
r.p.objIdx(r.Reloc(pkgbits.RelocObj))
5055
assert(r.Len() == 0)
5156
}
@@ -366,7 +371,9 @@ func (r *reader) param() *types2.Var {
366371
func (r *reader) obj() (types2.Object, []types2.Type) {
367372
r.Sync(pkgbits.SyncObject)
368373

369-
assert(!r.Bool())
374+
if r.Version().Has(pkgbits.DerivedFuncInstance) {
375+
assert(!r.Bool())
376+
}
370377

371378
pkg, name := r.p.objIdx(r.Reloc(pkgbits.RelocObj))
372379
obj := pkg.Scope().Lookup(name)

src/cmd/compile/internal/noder/reader.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,9 @@ func (r *reader) obj() ir.Node {
640640
// and returns the encoded reference to it, without instantiating it.
641641
func (r *reader) objInfo() objInfo {
642642
r.Sync(pkgbits.SyncObject)
643-
assert(!r.Bool()) // TODO(mdempsky): Remove; was derived func inst.
643+
if r.Version().Has(pkgbits.DerivedFuncInstance) {
644+
assert(!r.Bool())
645+
}
644646
idx := r.Reloc(pkgbits.RelocObj)
645647

646648
explicits := make([]typeInfo, r.Len())

src/cmd/compile/internal/noder/unified.go

+23-7
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,10 @@ func writePkgStub(m posMap, noders []*noder) string {
329329
{
330330
w := publicRootWriter
331331
w.pkg(pkg)
332-
w.Bool(false) // TODO(mdempsky): Remove; was "has init"
332+
333+
if w.Version().Has(pkgbits.HasInit) {
334+
w.Bool(false)
335+
}
333336

334337
scope := pkg.Scope()
335338
names := scope.Names()
@@ -410,11 +413,15 @@ func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool) {
410413
base.ErrorExit()
411414
}
412415

413-
r.Bool() // TODO(mdempsky): Remove; was "has init"
416+
if r.Version().Has(pkgbits.HasInit) {
417+
r.Bool()
418+
}
414419

415420
for i, n := 0, r.Len(); i < n; i++ {
416421
r.Sync(pkgbits.SyncObject)
417-
assert(!r.Bool())
422+
if r.Version().Has(pkgbits.DerivedFuncInstance) {
423+
assert(!r.Bool())
424+
}
418425
idx := r.Reloc(pkgbits.RelocObj)
419426
assert(r.Len() == 0)
420427

@@ -477,11 +484,15 @@ func writeUnifiedExport(out io.Writer) {
477484
r.Sync(pkgbits.SyncPkg)
478485
selfPkgIdx = l.relocIdx(pr, pkgbits.RelocPkg, r.Reloc(pkgbits.RelocPkg))
479486

480-
r.Bool() // TODO(mdempsky): Remove; was "has init"
487+
if r.Version().Has(pkgbits.HasInit) {
488+
r.Bool()
489+
}
481490

482491
for i, n := 0, r.Len(); i < n; i++ {
483492
r.Sync(pkgbits.SyncObject)
484-
assert(!r.Bool())
493+
if r.Version().Has(pkgbits.DerivedFuncInstance) {
494+
assert(!r.Bool())
495+
}
485496
idx := r.Reloc(pkgbits.RelocObj)
486497
assert(r.Len() == 0)
487498

@@ -508,12 +519,17 @@ func writeUnifiedExport(out io.Writer) {
508519

509520
w.Sync(pkgbits.SyncPkg)
510521
w.Reloc(pkgbits.RelocPkg, selfPkgIdx)
511-
w.Bool(false) // TODO(mdempsky): Remove; was "has init"
522+
523+
if w.Version().Has(pkgbits.HasInit) {
524+
w.Bool(false)
525+
}
512526

513527
w.Len(len(idxs))
514528
for _, idx := range idxs {
515529
w.Sync(pkgbits.SyncObject)
516-
w.Bool(false)
530+
if w.Version().Has(pkgbits.DerivedFuncInstance) {
531+
w.Bool(false)
532+
}
517533
w.Reloc(pkgbits.RelocObj, idx)
518534
w.Len(0)
519535
}

src/cmd/compile/internal/noder/writer.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,9 @@ func (w *writer) obj(obj types2.Object, explicits *types2.TypeList) {
730730
// bitstream.
731731
func (w *writer) objInfo(info objInfo) {
732732
w.Sync(pkgbits.SyncObject)
733-
w.Bool(false) // TODO(mdempsky): Remove; was derived func inst.
733+
if w.Version().Has(pkgbits.DerivedFuncInstance) {
734+
w.Bool(false)
735+
}
734736
w.Reloc(pkgbits.RelocObj, info.idx)
735737

736738
w.Len(len(info.explicits))

src/go/internal/gcimporter/ureader.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,17 @@ func readUnifiedPackage(fset *token.FileSet, ctxt *types.Context, imports map[st
6565

6666
r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
6767
pkg := r.pkg()
68-
r.Bool() // TODO(mdempsky): Remove; was "has init"
68+
if r.Version().Has(pkgbits.HasInit) {
69+
r.Bool()
70+
}
6971

7072
for i, n := 0, r.Len(); i < n; i++ {
7173
// As if r.obj(), but avoiding the Scope.Lookup call,
7274
// to avoid eager loading of imports.
7375
r.Sync(pkgbits.SyncObject)
74-
assert(!r.Bool())
76+
if r.Version().Has(pkgbits.DerivedFuncInstance) {
77+
assert(!r.Bool())
78+
}
7579
r.p.objIdx(r.Reloc(pkgbits.RelocObj))
7680
assert(r.Len() == 0)
7781
}
@@ -428,7 +432,9 @@ func (r *reader) param() *types.Var {
428432
func (r *reader) obj() (types.Object, []types.Type) {
429433
r.Sync(pkgbits.SyncObject)
430434

431-
assert(!r.Bool())
435+
if r.Version().Has(pkgbits.DerivedFuncInstance) {
436+
assert(!r.Bool())
437+
}
432438

433439
pkg, name := r.p.objIdx(r.Reloc(pkgbits.RelocObj))
434440
obj := pkgScope(pkg).Lookup(name)

0 commit comments

Comments
 (0)