mirror of
https://github.com/golang/go.git
synced 2026-04-02 17:30:01 +09:00
cmd/compile/internal/noder: factor out common UIR version
Ensure that the writers and readers use the same UIR version by defining the currently used version in one place rather than setting it in two places which might diverge. Change-Id: Iae139e08c3c01e553250ba6f4f171132b06eb8c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/754662 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Auto-Submit: Robert Griesemer <gri@google.com>
This commit is contained in:
committed by
Gopher Robot
parent
48bbe7996d
commit
655aa335c9
@@ -24,6 +24,10 @@ import (
|
||||
"cmd/internal/src"
|
||||
)
|
||||
|
||||
// uirVersion is the unified IR version to use for encoding/decoding.
|
||||
// Use V2 as the encoded version for aliastypeparams.
|
||||
const uirVersion = pkgbits.V2
|
||||
|
||||
// localPkgReader holds the package reader used for reading the local
|
||||
// package. It exists so the unified IR linker can refer back to it
|
||||
// later.
|
||||
@@ -463,10 +467,8 @@ func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool) {
|
||||
// writeUnifiedExport writes to `out` the finalized, self-contained
|
||||
// Unified IR export data file for the current compilation unit.
|
||||
func writeUnifiedExport(out io.Writer) {
|
||||
// Use V2 as the encoded version for aliastypeparams.
|
||||
version := pkgbits.V2
|
||||
l := linker{
|
||||
pw: pkgbits.NewPkgEncoder(version, base.Debug.SyncFrames),
|
||||
pw: pkgbits.NewPkgEncoder(uirVersion, base.Debug.SyncFrames),
|
||||
|
||||
pkgs: make(map[string]index),
|
||||
decls: make(map[*types.Sym]index),
|
||||
@@ -487,6 +489,12 @@ func writeUnifiedExport(out io.Writer) {
|
||||
r.Sync(pkgbits.SyncPkg)
|
||||
selfPkgIdx = l.relocIdx(pr, pkgbits.SectionPkg, r.Reloc(pkgbits.SectionPkg))
|
||||
|
||||
// Versions must match.
|
||||
// TODO: It seems that we should be able to use r.Version() for NewPkgEncoder
|
||||
// instead of passing uirVersion, but NewPkgEncoder is created before r.
|
||||
// If that is correct, we should make that happen.
|
||||
assert(r.Version() == uirVersion)
|
||||
|
||||
if r.Version().Has(pkgbits.HasInit) {
|
||||
r.Bool()
|
||||
}
|
||||
|
||||
@@ -96,10 +96,8 @@ type pkgWriter struct {
|
||||
// newPkgWriter returns an initialized pkgWriter for the specified
|
||||
// package.
|
||||
func newPkgWriter(m posMap, pkg *types2.Package, info *types2.Info, otherInfo map[*syntax.FuncLit]bool) *pkgWriter {
|
||||
// Use V2 as the encoded version for aliastypeparams.
|
||||
version := pkgbits.V2
|
||||
return &pkgWriter{
|
||||
PkgEncoder: pkgbits.NewPkgEncoder(version, base.Debug.SyncFrames),
|
||||
PkgEncoder: pkgbits.NewPkgEncoder(uirVersion, base.Debug.SyncFrames),
|
||||
|
||||
m: m,
|
||||
curpkg: pkg,
|
||||
|
||||
Reference in New Issue
Block a user