imports: imports,
enableAlias: true,
- posBases: make([]*syntax.PosBase, input.NumElems(pkgbits.RelocPosBase)),
- pkgs: make([]*types2.Package, input.NumElems(pkgbits.RelocPkg)),
- typs: make([]types2.Type, input.NumElems(pkgbits.RelocType)),
+ posBases: make([]*syntax.PosBase, input.NumElems(pkgbits.SectionPosBase)),
+ pkgs: make([]*types2.Package, input.NumElems(pkgbits.SectionPkg)),
+ typs: make([]types2.Type, input.NumElems(pkgbits.SectionType)),
}
- r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
+ r := pr.newReader(pkgbits.SectionMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
pkg := r.pkg()
if r.Version().Has(pkgbits.HasInit) {
if r.Version().Has(pkgbits.DerivedFuncInstance) {
assert(!r.Bool())
}
- r.p.objIdx(r.Reloc(pkgbits.RelocObj))
+ r.p.objIdx(r.Reloc(pkgbits.SectionObj))
assert(r.Len() == 0)
}
}
func (r *reader) posBase() *syntax.PosBase {
- return r.p.posBaseIdx(r.Reloc(pkgbits.RelocPosBase))
+ return r.p.posBaseIdx(r.Reloc(pkgbits.SectionPosBase))
}
func (pr *pkgReader) posBaseIdx(idx pkgbits.Index) *syntax.PosBase {
}
var b *syntax.PosBase
{
- r := pr.tempReader(pkgbits.RelocPosBase, idx, pkgbits.SyncPosBase)
+ r := pr.tempReader(pkgbits.SectionPosBase, idx, pkgbits.SyncPosBase)
filename := r.String()
func (r *reader) pkg() *types2.Package {
r.Sync(pkgbits.SyncPkg)
- return r.p.pkgIdx(r.Reloc(pkgbits.RelocPkg))
+ return r.p.pkgIdx(r.Reloc(pkgbits.SectionPkg))
}
func (pr *pkgReader) pkgIdx(idx pkgbits.Index) *types2.Package {
return pkg
}
- pkg := pr.newReader(pkgbits.RelocPkg, idx, pkgbits.SyncPkgDef).doPkg()
+ pkg := pr.newReader(pkgbits.SectionPkg, idx, pkgbits.SyncPkgDef).doPkg()
pr.pkgs[idx] = pkg
return pkg
}
if r.Bool() {
return typeInfo{idx: pkgbits.Index(r.Len()), derived: true}
}
- return typeInfo{idx: r.Reloc(pkgbits.RelocType), derived: false}
+ return typeInfo{idx: r.Reloc(pkgbits.SectionType), derived: false}
}
func (pr *pkgReader) typIdx(info typeInfo, dict *readerDict) types2.Type {
var typ types2.Type
{
- r := pr.tempReader(pkgbits.RelocType, idx, pkgbits.SyncTypeIdx)
+ r := pr.tempReader(pkgbits.SectionType, idx, pkgbits.SyncTypeIdx)
r.dict = dict
typ = r.doTyp()
assert(!r.Bool())
}
- pkg, name := r.p.objIdx(r.Reloc(pkgbits.RelocObj))
+ pkg, name := r.p.objIdx(r.Reloc(pkgbits.SectionObj))
obj := pkg.Scope().Lookup(name)
targs := make([]types2.Type, r.Len())
var objName string
var tag pkgbits.CodeObj
{
- rname := pr.tempReader(pkgbits.RelocName, idx, pkgbits.SyncObject1)
+ rname := pr.tempReader(pkgbits.SectionName, idx, pkgbits.SyncObject1)
objPkg, objName = rname.qualifiedIdent()
assert(objName != "")
objPkg.Scope().InsertLazy(objName, func() types2.Object {
dict := pr.objDictIdx(idx)
- r := pr.newReader(pkgbits.RelocObj, idx, pkgbits.SyncObject1)
+ r := pr.newReader(pkgbits.SectionObj, idx, pkgbits.SyncObject1)
r.dict = dict
switch tag {
func (pr *pkgReader) objDictIdx(idx pkgbits.Index) *readerDict {
var dict readerDict
{
- r := pr.tempReader(pkgbits.RelocObjDict, idx, pkgbits.SyncObject1)
+ r := pr.tempReader(pkgbits.SectionObjDict, idx, pkgbits.SyncObject1)
if implicits := r.Len(); implicits != 0 {
base.Fatalf("unexpected object with %v implicit type parameter(s)", implicits)
dict.derived = make([]derivedInfo, r.Len())
dict.derivedTypes = make([]types2.Type, len(dict.derived))
for i := range dict.derived {
- dict.derived[i] = derivedInfo{idx: r.Reloc(pkgbits.RelocType)}
+ dict.derived[i] = derivedInfo{idx: r.Reloc(pkgbits.SectionType)}
if r.Version().Has(pkgbits.DerivedInfoNeeded) {
assert(!r.Bool())
}
its index in the series.
SectionKind = Uint64 .
-TODO(markfreeman): Update when we rename RelocFoo to SectionFoo.
-Payload = RelocString // TODO(markfreeman) Define.
- RelocMeta
- RelocPosBase // TODO(markfreeman) Define.
- RelocPkg // TODO(markfreeman) Define.
- RelocName // TODO(markfreeman) Define.
- RelocType // TODO(markfreeman) Define.
- RelocObj // TODO(markfreeman) Define.
- RelocObjExt // TODO(markfreeman) Define.
- RelocObjDict // TODO(markfreeman) Define.
- RelocBody // TODO(markfreeman) Define.
+Payload = SectionString // TODO(markfreeman) Define.
+ SectionMeta
+ SectionPosBase // TODO(markfreeman) Define.
+ SectionPkg // TODO(markfreeman) Define.
+ SectionName // TODO(markfreeman) Define.
+ SectionType // TODO(markfreeman) Define.
+ SectionObj // TODO(markfreeman) Define.
+ SectionObjExt // TODO(markfreeman) Define.
+ SectionObjDict // TODO(markfreeman) Define.
+ SectionBody // TODO(markfreeman) Define.
.
# Sections
The meta section provides fundamental information for a package. It contains
exactly two elements — a public root and a private root.
-RelocMeta = PublicRoot
- PrivateRoot // TODO(markfreeman): Define.
- .
+SectionMeta = PublicRoot
+ PrivateRoot // TODO(markfreeman): Define.
+ .
The public root element identifies the package and provides references for all
exported objects it contains.
-PublicRoot = Relocs
- [ SyncPublic ] // TODO(markfreeman): Define.
- PackageRef // TODO(markfreeman): Define.
- [ HasInit ]
- ObjectRefCount // TODO(markfreeman): Define.
- { ObjectRef } // TODO(markfreeman): Define.
- .
-HasInit = Bool . // Whether the package uses any initialization
- // functions.
+PublicRoot = Relocs
+ [ SyncPublic ] // TODO(markfreeman): Define.
+ PackageRef // TODO(markfreeman): Define.
+ [ HasInit ]
+ ObjectRefCount // TODO(markfreeman): Define.
+ { ObjectRef } // TODO(markfreeman): Define.
+ .
+HasInit = Bool . // Whether the package uses any initialization
+ // functions.
# References
A reference table precedes every element. Each entry in the table contains a
var newidx index
switch k {
- case pkgbits.RelocString:
+ case pkgbits.SectionString:
newidx = l.relocString(pr, idx)
- case pkgbits.RelocPkg:
+ case pkgbits.SectionPkg:
newidx = l.relocPkg(pr, idx)
- case pkgbits.RelocObj:
+ case pkgbits.SectionObj:
newidx = l.relocObj(pr, idx)
default:
return newidx
}
- r := pr.NewDecoder(pkgbits.RelocPkg, idx, pkgbits.SyncPkgDef)
- w := l.pw.NewEncoder(pkgbits.RelocPkg, pkgbits.SyncPkgDef)
+ r := pr.NewDecoder(pkgbits.SectionPkg, idx, pkgbits.SyncPkgDef)
+ w := l.pw.NewEncoder(pkgbits.SectionPkg, pkgbits.SyncPkgDef)
l.pkgs[path] = w.Idx
// TODO(mdempsky): We end up leaving an empty string reference here
assert(tag2 != pkgbits.ObjStub)
}
- w := l.pw.NewEncoderRaw(pkgbits.RelocObj)
- wext := l.pw.NewEncoderRaw(pkgbits.RelocObjExt)
- wname := l.pw.NewEncoderRaw(pkgbits.RelocName)
- wdict := l.pw.NewEncoderRaw(pkgbits.RelocObjDict)
+ w := l.pw.NewEncoderRaw(pkgbits.SectionObj)
+ wext := l.pw.NewEncoderRaw(pkgbits.SectionObjExt)
+ wname := l.pw.NewEncoderRaw(pkgbits.SectionName)
+ wdict := l.pw.NewEncoderRaw(pkgbits.SectionObjDict)
l.decls[sym] = w.Idx
assert(wext.Idx == w.Idx)
assert(wname.Idx == w.Idx)
assert(wdict.Idx == w.Idx)
- l.relocCommon(pr, &w, pkgbits.RelocObj, idx)
- l.relocCommon(pr, &wname, pkgbits.RelocName, idx)
- l.relocCommon(pr, &wdict, pkgbits.RelocObjDict, idx)
+ l.relocCommon(pr, &w, pkgbits.SectionObj, idx)
+ l.relocCommon(pr, &wname, pkgbits.SectionName, idx)
+ l.relocCommon(pr, &wdict, pkgbits.SectionObjDict, idx)
// Generic types and functions won't have definitions, and imported
// objects may not either.
}
wext.Flush()
} else {
- l.relocCommon(pr, &wext, pkgbits.RelocObjExt, idx)
+ l.relocCommon(pr, &wext, pkgbits.SectionObjExt, idx)
}
// Check if we need to export the inline bodies for functions and
pri, ok := bodyReaderFor(fn)
assert(ok)
- l.bodies[sym] = l.relocIdx(pri.pr, pkgbits.RelocBody, pri.idx)
+ l.bodies[sym] = l.relocIdx(pri.pr, pkgbits.SectionBody, pri.idx)
}
// relocCommon copies the specified element from pr into w,
return &pkgReader{
PkgDecoder: pr,
- posBases: make([]*src.PosBase, pr.NumElems(pkgbits.RelocPosBase)),
- pkgs: make([]*types.Pkg, pr.NumElems(pkgbits.RelocPkg)),
- typs: make([]*types.Type, pr.NumElems(pkgbits.RelocType)),
+ posBases: make([]*src.PosBase, pr.NumElems(pkgbits.SectionPosBase)),
+ pkgs: make([]*types.Pkg, pr.NumElems(pkgbits.SectionPkg)),
+ typs: make([]*types.Type, pr.NumElems(pkgbits.SectionType)),
newindex: make([]index, pr.TotalElems()),
}
// posBase reads a position base from the bitstream.
func (r *reader) posBase() *src.PosBase {
- return r.inlPosBase(r.p.posBaseIdx(r.Reloc(pkgbits.RelocPosBase)))
+ return r.inlPosBase(r.p.posBaseIdx(r.Reloc(pkgbits.SectionPosBase)))
}
// posBaseIdx returns the specified position base, reading it first if
return b
}
- r := pr.newReader(pkgbits.RelocPosBase, idx, pkgbits.SyncPosBase)
+ r := pr.newReader(pkgbits.SectionPosBase, idx, pkgbits.SyncPosBase)
var b *src.PosBase
absFilename := r.String()
// pkg reads a package reference from the bitstream.
func (r *reader) pkg() *types.Pkg {
r.Sync(pkgbits.SyncPkg)
- return r.p.pkgIdx(r.Reloc(pkgbits.RelocPkg))
+ return r.p.pkgIdx(r.Reloc(pkgbits.SectionPkg))
}
// pkgIdx returns the specified package from the export data, reading
return pkg
}
- pkg := pr.newReader(pkgbits.RelocPkg, idx, pkgbits.SyncPkgDef).doPkg()
+ pkg := pr.newReader(pkgbits.SectionPkg, idx, pkgbits.SyncPkgDef).doPkg()
pr.pkgs[idx] = pkg
return pkg
}
if r.Bool() {
return typeInfo{idx: index(r.Len()), derived: true}
}
- return typeInfo{idx: r.Reloc(pkgbits.RelocType), derived: false}
+ return typeInfo{idx: r.Reloc(pkgbits.SectionType), derived: false}
}
// typListIdx returns a list of the specified types, resolving derived
return typ
}
- r := pr.newReader(pkgbits.RelocType, idx, pkgbits.SyncTypeIdx)
+ r := pr.newReader(pkgbits.SectionType, idx, pkgbits.SyncTypeIdx)
r.dict = dict
typ := r.doTyp()
if r.Version().Has(pkgbits.DerivedFuncInstance) {
assert(!r.Bool())
}
- idx := r.Reloc(pkgbits.RelocObj)
+ idx := r.Reloc(pkgbits.SectionObj)
explicits := make([]typeInfo, r.Len())
for i := range explicits {
// Other sources of internal failure (such as duplicate definitions) still fail
// the build.
func (pr *pkgReader) objIdxMayFail(idx index, implicits, explicits []*types.Type, shaped bool) (ir.Node, error) {
- rname := pr.newReader(pkgbits.RelocName, idx, pkgbits.SyncObject1)
+ rname := pr.newReader(pkgbits.SectionName, idx, pkgbits.SyncObject1)
_, sym := rname.qualifiedIdent()
tag := pkgbits.CodeObj(rname.Code(pkgbits.SyncCodeObj))
return sym.Def.(*ir.Name), nil
}
- r := pr.newReader(pkgbits.RelocObj, idx, pkgbits.SyncObject1)
- rext := pr.newReader(pkgbits.RelocObjExt, idx, pkgbits.SyncObject1)
+ r := pr.newReader(pkgbits.SectionObj, idx, pkgbits.SyncObject1)
+ rext := pr.newReader(pkgbits.SectionObjExt, idx, pkgbits.SyncObject1)
r.dict = dict
rext.dict = dict
// objDictIdx reads and returns the specified object dictionary.
func (pr *pkgReader) objDictIdx(sym *types.Sym, idx index, implicits, explicits []*types.Type, shaped bool) (*readerDict, error) {
- r := pr.newReader(pkgbits.RelocObjDict, idx, pkgbits.SyncObject1)
+ r := pr.newReader(pkgbits.SectionObjDict, idx, pkgbits.SyncObject1)
dict := readerDict{
shaped: shaped,
dict.derived = make([]derivedInfo, r.Len())
dict.derivedTypes = make([]*types.Type, len(dict.derived))
for i := range dict.derived {
- dict.derived[i] = derivedInfo{idx: r.Reloc(pkgbits.RelocType)}
+ dict.derived[i] = derivedInfo{idx: r.Reloc(pkgbits.SectionType)}
if r.Version().Has(pkgbits.DerivedInfoNeeded) {
assert(!r.Bool())
}
// generic functions; see comment in funcExt.
assert(fn.Nname.Defn != nil)
- idx := r.Reloc(pkgbits.RelocBody)
+ idx := r.Reloc(pkgbits.SectionBody)
pri := pkgReaderIndex{r.p, idx, r.dict, method, nil}
bodyReader[fn] = pri
}
func (pri pkgReaderIndex) funcBody(fn *ir.Func) {
- r := pri.asReader(pkgbits.RelocBody, pkgbits.SyncFuncBody)
+ r := pri.asReader(pkgbits.SectionBody, pkgbits.SyncFuncBody)
r.funcBody(fn)
}
}
func (pr *pkgReader) objDictName(idx index, implicits, explicits []*types.Type) *ir.Name {
- rname := pr.newReader(pkgbits.RelocName, idx, pkgbits.SyncObject1)
+ rname := pr.newReader(pkgbits.SectionName, idx, pkgbits.SyncObject1)
_, sym := rname.qualifiedIdent()
tag := pkgbits.CodeObj(rname.Code(pkgbits.SyncCodeObj))
expandInline(fn, pri)
}
- r := pri.asReader(pkgbits.RelocBody, pkgbits.SyncFuncBody)
+ r := pri.asReader(pkgbits.SectionBody, pkgbits.SyncFuncBody)
tmpfn := ir.NewFunc(fn.Pos(), fn.Nname.Pos(), callerfn.Sym(), fn.Type())
tmpfn.ClosureVars = fn.ClosureVars
{
- r := pri.asReader(pkgbits.RelocBody, pkgbits.SyncFuncBody)
+ r := pri.asReader(pkgbits.SectionBody, pkgbits.SyncFuncBody)
// Don't change parameter's Sym/Nname fields.
r.funarghack = true
localPkgReader = newPkgReader(pkgbits.NewPkgDecoder(types.LocalPkg.Path, data))
readPackage(localPkgReader, types.LocalPkg, true)
- r := localPkgReader.newReader(pkgbits.RelocMeta, pkgbits.PrivateRootIdx, pkgbits.SyncPrivate)
+ r := localPkgReader.newReader(pkgbits.SectionMeta, pkgbits.PrivateRootIdx, pkgbits.SyncPrivate)
r.pkgInit(types.LocalPkg, target)
readBodies(target, false)
pw.collectDecls(noders)
- publicRootWriter := pw.newWriter(pkgbits.RelocMeta, pkgbits.SyncPublic)
- privateRootWriter := pw.newWriter(pkgbits.RelocMeta, pkgbits.SyncPrivate)
+ publicRootWriter := pw.newWriter(pkgbits.SectionMeta, pkgbits.SyncPublic)
+ privateRootWriter := pw.newWriter(pkgbits.SectionMeta, pkgbits.SyncPrivate)
assert(publicRootWriter.Idx == pkgbits.PublicRootIdx)
assert(privateRootWriter.Idx == pkgbits.PrivateRootIdx)
// import.
func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool) {
{
- r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
+ r := pr.newReader(pkgbits.SectionMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
pkg := r.pkg()
// This error can happen if "go tool compile" is called with wrong "-p" flag, see issue #54542.
if r.Version().Has(pkgbits.DerivedFuncInstance) {
assert(!r.Bool())
}
- idx := r.Reloc(pkgbits.RelocObj)
+ idx := r.Reloc(pkgbits.SectionObj)
assert(r.Len() == 0)
path, name, code := r.p.PeekObj(idx)
}
if !localStub {
- r := pr.newReader(pkgbits.RelocMeta, pkgbits.PrivateRootIdx, pkgbits.SyncPrivate)
+ r := pr.newReader(pkgbits.SectionMeta, pkgbits.PrivateRootIdx, pkgbits.SyncPrivate)
if r.Bool() {
sym := importpkg.Lookup(".inittask")
for i, n := 0, r.Len(); i < n; i++ {
path := r.String()
name := r.String()
- idx := r.Reloc(pkgbits.RelocBody)
+ idx := r.Reloc(pkgbits.SectionBody)
sym := types.NewPkg(path, "").Lookup(name)
if _, ok := importBodyReader[sym]; !ok {
bodies: make(map[*types.Sym]index),
}
- publicRootWriter := l.pw.NewEncoder(pkgbits.RelocMeta, pkgbits.SyncPublic)
- privateRootWriter := l.pw.NewEncoder(pkgbits.RelocMeta, pkgbits.SyncPrivate)
+ publicRootWriter := l.pw.NewEncoder(pkgbits.SectionMeta, pkgbits.SyncPublic)
+ privateRootWriter := l.pw.NewEncoder(pkgbits.SectionMeta, pkgbits.SyncPrivate)
assert(publicRootWriter.Idx == pkgbits.PublicRootIdx)
assert(privateRootWriter.Idx == pkgbits.PrivateRootIdx)
{
pr := localPkgReader
- r := pr.NewDecoder(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
+ r := pr.NewDecoder(pkgbits.SectionMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
r.Sync(pkgbits.SyncPkg)
- selfPkgIdx = l.relocIdx(pr, pkgbits.RelocPkg, r.Reloc(pkgbits.RelocPkg))
+ selfPkgIdx = l.relocIdx(pr, pkgbits.SectionPkg, r.Reloc(pkgbits.SectionPkg))
if r.Version().Has(pkgbits.HasInit) {
r.Bool()
if r.Version().Has(pkgbits.DerivedFuncInstance) {
assert(!r.Bool())
}
- idx := r.Reloc(pkgbits.RelocObj)
+ idx := r.Reloc(pkgbits.SectionObj)
assert(r.Len() == 0)
xpath, xname, xtag := pr.PeekObj(idx)
assert(xtag != pkgbits.ObjStub)
if types.IsExported(xname) {
- l.relocIdx(pr, pkgbits.RelocObj, idx)
+ l.relocIdx(pr, pkgbits.SectionObj, idx)
}
}
w := publicRootWriter
w.Sync(pkgbits.SyncPkg)
- w.Reloc(pkgbits.RelocPkg, selfPkgIdx)
+ w.Reloc(pkgbits.SectionPkg, selfPkgIdx)
if w.Version().Has(pkgbits.HasInit) {
w.Bool(false)
if w.Version().Has(pkgbits.DerivedFuncInstance) {
w.Bool(false)
}
- w.Reloc(pkgbits.RelocObj, idx)
+ w.Reloc(pkgbits.SectionObj, idx)
w.Len(0)
}
for _, body := range bodies {
w.String(body.sym.Pkg.Path)
w.String(body.sym.Name)
- w.Reloc(pkgbits.RelocBody, body.idx)
+ w.Reloc(pkgbits.SectionBody, body.idx)
}
w.Sync(pkgbits.SyncEOF)
// posBase writes a reference to the given PosBase into the element
// bitstream.
func (w *writer) posBase(b *syntax.PosBase) {
- w.Reloc(pkgbits.RelocPosBase, w.p.posBaseIdx(b))
+ w.Reloc(pkgbits.SectionPosBase, w.p.posBaseIdx(b))
}
// posBaseIdx returns the index for the given PosBase.
return idx
}
- w := pw.newWriter(pkgbits.RelocPosBase, pkgbits.SyncPosBase)
+ w := pw.newWriter(pkgbits.SectionPosBase, pkgbits.SyncPosBase)
w.p.posBasesIdx[b] = w.Idx
w.String(trimFilename(b))
func (w *writer) pkgRef(idx index) {
w.Sync(pkgbits.SyncPkg)
- w.Reloc(pkgbits.RelocPkg, idx)
+ w.Reloc(pkgbits.SectionPkg, idx)
}
// pkgIdx returns the index for the given package, adding it to the
return idx
}
- w := pw.newWriter(pkgbits.RelocPkg, pkgbits.SyncPkgDef)
+ w := pw.newWriter(pkgbits.SectionPkg, pkgbits.SyncPkgDef)
pw.pkgsIdx[pkg] = w.Idx
// The universe and package unsafe need to be handled specially by
w.Len(int(info.idx))
w.derived = true
} else {
- w.Reloc(pkgbits.RelocType, info.idx)
+ w.Reloc(pkgbits.SectionType, info.idx)
}
}
}
}
- w := pw.newWriter(pkgbits.RelocType, pkgbits.SyncTypeIdx)
+ w := pw.newWriter(pkgbits.SectionType, pkgbits.SyncTypeIdx)
w.dict = dict
switch typ := typ.(type) {
if w.Version().Has(pkgbits.DerivedFuncInstance) {
w.Bool(false)
}
- w.Reloc(pkgbits.RelocObj, info.idx)
+ w.Reloc(pkgbits.SectionObj, info.idx)
w.Len(len(info.explicits))
for _, info := range info.explicits {
// TODO(mdempsky): Re-evaluate whether RelocName still makes sense
// to keep separate from RelocObj.
- w := pw.newWriter(pkgbits.RelocObj, pkgbits.SyncObject1)
- wext := pw.newWriter(pkgbits.RelocObjExt, pkgbits.SyncObject1)
- wname := pw.newWriter(pkgbits.RelocName, pkgbits.SyncObject1)
- wdict := pw.newWriter(pkgbits.RelocObjDict, pkgbits.SyncObject1)
+ w := pw.newWriter(pkgbits.SectionObj, pkgbits.SyncObject1)
+ wext := pw.newWriter(pkgbits.SectionObjExt, pkgbits.SyncObject1)
+ wname := pw.newWriter(pkgbits.SectionName, pkgbits.SyncObject1)
+ wdict := pw.newWriter(pkgbits.SectionObjDict, pkgbits.SyncObject1)
pw.objsIdx[obj] = w.Idx // break cycles
assert(wext.Idx == w.Idx)
nderived := len(dict.derived)
w.Len(nderived)
for _, typ := range dict.derived {
- w.Reloc(pkgbits.RelocType, typ.idx)
+ w.Reloc(pkgbits.SectionType, typ.idx)
if w.Version().Has(pkgbits.DerivedInfoNeeded) {
w.Bool(false)
}
}
w.Bool(false) // stub extension
- w.Reloc(pkgbits.RelocBody, body)
+ w.Reloc(pkgbits.SectionBody, body)
w.Sync(pkgbits.SyncEOF)
}
// bodyIdx returns the index for the given function body (specified by
// block), adding it to the export data
func (pw *pkgWriter) bodyIdx(sig *types2.Signature, block *syntax.BlockStmt, dict *writerDict) (idx index, closureVars []posVar) {
- w := pw.newWriter(pkgbits.RelocBody, pkgbits.SyncFuncBody)
+ w := pw.newWriter(pkgbits.SectionBody, pkgbits.SyncFuncBody)
w.sig = sig
w.dict = dict
w.useLocal(cv.pos, cv.var_)
}
- w.Reloc(pkgbits.RelocBody, body)
+ w.Reloc(pkgbits.SectionBody, body)
}
type posVar struct {
ctxt: ctxt,
imports: imports,
- posBases: make([]string, input.NumElems(pkgbits.RelocPosBase)),
- pkgs: make([]*types.Package, input.NumElems(pkgbits.RelocPkg)),
- typs: make([]types.Type, input.NumElems(pkgbits.RelocType)),
+ posBases: make([]string, input.NumElems(pkgbits.SectionPosBase)),
+ pkgs: make([]*types.Package, input.NumElems(pkgbits.SectionPkg)),
+ typs: make([]types.Type, input.NumElems(pkgbits.SectionType)),
}
defer pr.fake.setLines()
- r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
+ r := pr.newReader(pkgbits.SectionMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
pkg := r.pkg()
if r.Version().Has(pkgbits.HasInit) {
r.Bool()
if r.Version().Has(pkgbits.DerivedFuncInstance) {
assert(!r.Bool())
}
- r.p.objIdx(r.Reloc(pkgbits.RelocObj))
+ r.p.objIdx(r.Reloc(pkgbits.SectionObj))
assert(r.Len() == 0)
}
}
func (r *reader) posBase() string {
- return r.p.posBaseIdx(r.Reloc(pkgbits.RelocPosBase))
+ return r.p.posBaseIdx(r.Reloc(pkgbits.SectionPosBase))
}
func (pr *pkgReader) posBaseIdx(idx pkgbits.Index) string {
var filename string
{
- r := pr.tempReader(pkgbits.RelocPosBase, idx, pkgbits.SyncPosBase)
+ r := pr.tempReader(pkgbits.SectionPosBase, idx, pkgbits.SyncPosBase)
// Within types2, position bases have a lot more details (e.g.,
// keeping track of where //line directives appeared exactly).
func (r *reader) pkg() *types.Package {
r.Sync(pkgbits.SyncPkg)
- return r.p.pkgIdx(r.Reloc(pkgbits.RelocPkg))
+ return r.p.pkgIdx(r.Reloc(pkgbits.SectionPkg))
}
func (pr *pkgReader) pkgIdx(idx pkgbits.Index) *types.Package {
return pkg
}
- pkg := pr.newReader(pkgbits.RelocPkg, idx, pkgbits.SyncPkgDef).doPkg()
+ pkg := pr.newReader(pkgbits.SectionPkg, idx, pkgbits.SyncPkgDef).doPkg()
pr.pkgs[idx] = pkg
return pkg
}
if r.Bool() {
return typeInfo{idx: pkgbits.Index(r.Len()), derived: true}
}
- return typeInfo{idx: r.Reloc(pkgbits.RelocType), derived: false}
+ return typeInfo{idx: r.Reloc(pkgbits.SectionType), derived: false}
}
func (pr *pkgReader) typIdx(info typeInfo, dict *readerDict) types.Type {
var typ types.Type
{
- r := pr.tempReader(pkgbits.RelocType, idx, pkgbits.SyncTypeIdx)
+ r := pr.tempReader(pkgbits.SectionType, idx, pkgbits.SyncTypeIdx)
r.dict = dict
typ = r.doTyp()
assert(!r.Bool())
}
- pkg, name := r.p.objIdx(r.Reloc(pkgbits.RelocObj))
+ pkg, name := r.p.objIdx(r.Reloc(pkgbits.SectionObj))
obj := pkgScope(pkg).Lookup(name)
targs := make([]types.Type, r.Len())
var objName string
var tag pkgbits.CodeObj
{
- rname := pr.tempReader(pkgbits.RelocName, idx, pkgbits.SyncObject1)
+ rname := pr.tempReader(pkgbits.SectionName, idx, pkgbits.SyncObject1)
objPkg, objName = rname.qualifiedIdent()
assert(objName != "")
if objPkg.Scope().Lookup(objName) == nil {
dict := pr.objDictIdx(idx)
- r := pr.newReader(pkgbits.RelocObj, idx, pkgbits.SyncObject1)
+ r := pr.newReader(pkgbits.SectionObj, idx, pkgbits.SyncObject1)
r.dict = dict
declare := func(obj types.Object) {
var dict readerDict
{
- r := pr.tempReader(pkgbits.RelocObjDict, idx, pkgbits.SyncObject1)
+ r := pr.tempReader(pkgbits.SectionObjDict, idx, pkgbits.SyncObject1)
if implicits := r.Len(); implicits != 0 {
errorf("unexpected object with %v implicit type parameter(s)", implicits)
}
dict.derived = make([]derivedInfo, r.Len())
dict.derivedTypes = make([]types.Type, len(dict.derived))
for i := range dict.derived {
- dict.derived[i] = derivedInfo{idx: r.Reloc(pkgbits.RelocType)}
+ dict.derived[i] = derivedInfo{idx: r.Reloc(pkgbits.SectionType)}
if r.Version().Has(pkgbits.DerivedInfoNeeded) {
assert(!r.Bool())
}
// StringIdx returns the string value for the given string index.
func (pr *PkgDecoder) StringIdx(idx RelIndex) string {
- return pr.DataIdx(RelocString, idx)
+ return pr.DataIdx(SectionString, idx)
}
// NewDecoder returns a Decoder for the given (section, index) pair,
fmt.Printf("\t[stack trace unavailable; recompile package %q with -d=syncframes]\n", r.common.pkgPath)
}
for _, pc := range writerPCs {
- fmt.Printf("\t%s\n", r.common.StringIdx(r.rawReloc(RelocString, pc)))
+ fmt.Printf("\t%s\n", r.common.StringIdx(r.rawReloc(SectionString, pc)))
}
fmt.Printf("\nexpected %v, reading at:\n", mWant)
// bitstream.
func (r *Decoder) String() string {
r.Sync(SyncString)
- return r.common.StringIdx(r.Reloc(RelocString))
+ return r.common.StringIdx(r.Reloc(SectionString))
}
// Strings decodes and returns a variable-length slice of strings from
func (pr *PkgDecoder) PeekPkgPath(idx RelIndex) string {
var path string
{
- r := pr.TempDecoder(RelocPkg, idx, SyncPkgDef)
+ r := pr.TempDecoder(SectionPkg, idx, SyncPkgDef)
path = r.String()
pr.RetireDecoder(&r)
}
var name string
var rcode int
{
- r := pr.TempDecoder(RelocName, idx, SyncObject1)
+ r := pr.TempDecoder(SectionName, idx, SyncObject1)
r.Sync(SyncSym)
r.Sync(SyncPkg)
- ridx = r.Reloc(RelocPkg)
+ ridx = r.Reloc(SectionPkg)
name = r.String()
rcode = r.Code(SyncCodeObj)
pr.RetireDecoder(&r)
// already present, and returns its index.
func (pw *PkgEncoder) StringIdx(s string) RelIndex {
if idx, ok := pw.stringsIdx[s]; ok {
- assert(pw.elems[RelocString][idx] == s)
+ assert(pw.elems[SectionString][idx] == s)
return idx
}
- idx := RelIndex(len(pw.elems[RelocString]))
- pw.elems[RelocString] = append(pw.elems[RelocString], s)
+ idx := RelIndex(len(pw.elems[SectionString]))
+ pw.elems[SectionString] = append(pw.elems[SectionString], s)
pw.stringsIdx[s] = idx
return idx
}
w.rawUvarint(uint64(m))
w.rawUvarint(uint64(len(frames)))
for _, frame := range frames {
- w.rawUvarint(uint64(w.rawReloc(RelocString, w.p.StringIdx(frame))))
+ w.rawUvarint(uint64(w.rawReloc(SectionString, w.p.StringIdx(frame))))
}
}
// previously encoded string value.
func (w *Encoder) StringRef(idx RelIndex) {
w.Sync(SyncString)
- w.Reloc(RelocString, idx)
+ w.Reloc(SectionString, idx)
}
// Strings encodes and writes a variable-length slice of strings into
pkgbits.V2,
} {
pw := pkgbits.NewPkgEncoder(version, -1)
- w := pw.NewEncoder(pkgbits.RelocMeta, pkgbits.SyncPublic)
+ w := pw.NewEncoder(pkgbits.SectionMeta, pkgbits.SyncPublic)
w.Flush()
var b strings.Builder
input := b.String()
pr := pkgbits.NewPkgDecoder("package_id", input)
- r := pr.NewDecoder(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
+ r := pr.NewDecoder(pkgbits.SectionMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
if r.Version() != w.Version() {
t.Errorf("Expected reader version %q to be the writer version %q", r.Version(), w.Version())
type SectionKind int32 // TODO(markfreeman): Replace with uint8.
const (
- RelocString SectionKind = iota
- RelocMeta
- RelocPosBase
- RelocPkg
- RelocName
- RelocType
- RelocObj
- RelocObjExt
- RelocObjDict
- RelocBody
+ SectionString SectionKind = iota
+ SectionMeta
+ SectionPosBase
+ SectionPkg
+ SectionName
+ SectionType
+ SectionObj
+ SectionObjExt
+ SectionObjDict
+ SectionBody
numRelocs = iota
)
Idx RelIndex
}
-// Reserved indices within the [RelocMeta] section.
+// Reserved indices within the [SectionMeta] section.
const (
PublicRootIdx RelIndex = 0
PrivateRootIdx RelIndex = 1