Skip to content

Commit 52624e5

Browse files
Mark Freemangopherbot
Mark Freeman
authored andcommitted
internal/pkgbits: rename Reloc* to Section*
This is a basic refactoring. This enumeration refers primarily to the different sections of a UIR file, so this naming is a bit more direct. Change-Id: Ib70ab054e97effaabc035450d246ae4354da8075 Reviewed-on: https://go-review.googlesource.com/c/go/+/671935 Reviewed-by: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Mark Freeman <mark@golang.org>
1 parent 019d798 commit 52624e5

File tree

11 files changed

+143
-144
lines changed

11 files changed

+143
-144
lines changed

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input
3333
imports: imports,
3434
enableAlias: true,
3535

36-
posBases: make([]*syntax.PosBase, input.NumElems(pkgbits.RelocPosBase)),
37-
pkgs: make([]*types2.Package, input.NumElems(pkgbits.RelocPkg)),
38-
typs: make([]types2.Type, input.NumElems(pkgbits.RelocType)),
36+
posBases: make([]*syntax.PosBase, input.NumElems(pkgbits.SectionPosBase)),
37+
pkgs: make([]*types2.Package, input.NumElems(pkgbits.SectionPkg)),
38+
typs: make([]types2.Type, input.NumElems(pkgbits.SectionType)),
3939
}
4040

41-
r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
41+
r := pr.newReader(pkgbits.SectionMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
4242
pkg := r.pkg()
4343

4444
if r.Version().Has(pkgbits.HasInit) {
@@ -52,7 +52,7 @@ func ReadPackage(ctxt *types2.Context, imports map[string]*types2.Package, input
5252
if r.Version().Has(pkgbits.DerivedFuncInstance) {
5353
assert(!r.Bool())
5454
}
55-
r.p.objIdx(r.Reloc(pkgbits.RelocObj))
55+
r.p.objIdx(r.Reloc(pkgbits.SectionObj))
5656
assert(r.Len() == 0)
5757
}
5858

@@ -118,7 +118,7 @@ func (r *reader) pos() syntax.Pos {
118118
}
119119

120120
func (r *reader) posBase() *syntax.PosBase {
121-
return r.p.posBaseIdx(r.Reloc(pkgbits.RelocPosBase))
121+
return r.p.posBaseIdx(r.Reloc(pkgbits.SectionPosBase))
122122
}
123123

124124
func (pr *pkgReader) posBaseIdx(idx pkgbits.Index) *syntax.PosBase {
@@ -127,7 +127,7 @@ func (pr *pkgReader) posBaseIdx(idx pkgbits.Index) *syntax.PosBase {
127127
}
128128
var b *syntax.PosBase
129129
{
130-
r := pr.tempReader(pkgbits.RelocPosBase, idx, pkgbits.SyncPosBase)
130+
r := pr.tempReader(pkgbits.SectionPosBase, idx, pkgbits.SyncPosBase)
131131

132132
filename := r.String()
133133

@@ -150,7 +150,7 @@ func (pr *pkgReader) posBaseIdx(idx pkgbits.Index) *syntax.PosBase {
150150

151151
func (r *reader) pkg() *types2.Package {
152152
r.Sync(pkgbits.SyncPkg)
153-
return r.p.pkgIdx(r.Reloc(pkgbits.RelocPkg))
153+
return r.p.pkgIdx(r.Reloc(pkgbits.SectionPkg))
154154
}
155155

156156
func (pr *pkgReader) pkgIdx(idx pkgbits.Index) *types2.Package {
@@ -160,7 +160,7 @@ func (pr *pkgReader) pkgIdx(idx pkgbits.Index) *types2.Package {
160160
return pkg
161161
}
162162

163-
pkg := pr.newReader(pkgbits.RelocPkg, idx, pkgbits.SyncPkgDef).doPkg()
163+
pkg := pr.newReader(pkgbits.SectionPkg, idx, pkgbits.SyncPkgDef).doPkg()
164164
pr.pkgs[idx] = pkg
165165
return pkg
166166
}
@@ -206,7 +206,7 @@ func (r *reader) typInfo() typeInfo {
206206
if r.Bool() {
207207
return typeInfo{idx: pkgbits.Index(r.Len()), derived: true}
208208
}
209-
return typeInfo{idx: r.Reloc(pkgbits.RelocType), derived: false}
209+
return typeInfo{idx: r.Reloc(pkgbits.SectionType), derived: false}
210210
}
211211

212212
func (pr *pkgReader) typIdx(info typeInfo, dict *readerDict) types2.Type {
@@ -225,7 +225,7 @@ func (pr *pkgReader) typIdx(info typeInfo, dict *readerDict) types2.Type {
225225

226226
var typ types2.Type
227227
{
228-
r := pr.tempReader(pkgbits.RelocType, idx, pkgbits.SyncTypeIdx)
228+
r := pr.tempReader(pkgbits.SectionType, idx, pkgbits.SyncTypeIdx)
229229
r.dict = dict
230230

231231
typ = r.doTyp()
@@ -376,7 +376,7 @@ func (r *reader) obj() (types2.Object, []types2.Type) {
376376
assert(!r.Bool())
377377
}
378378

379-
pkg, name := r.p.objIdx(r.Reloc(pkgbits.RelocObj))
379+
pkg, name := r.p.objIdx(r.Reloc(pkgbits.SectionObj))
380380
obj := pkg.Scope().Lookup(name)
381381

382382
targs := make([]types2.Type, r.Len())
@@ -392,7 +392,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types2.Package, string) {
392392
var objName string
393393
var tag pkgbits.CodeObj
394394
{
395-
rname := pr.tempReader(pkgbits.RelocName, idx, pkgbits.SyncObject1)
395+
rname := pr.tempReader(pkgbits.SectionName, idx, pkgbits.SyncObject1)
396396

397397
objPkg, objName = rname.qualifiedIdent()
398398
assert(objName != "")
@@ -409,7 +409,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types2.Package, string) {
409409
objPkg.Scope().InsertLazy(objName, func() types2.Object {
410410
dict := pr.objDictIdx(idx)
411411

412-
r := pr.newReader(pkgbits.RelocObj, idx, pkgbits.SyncObject1)
412+
r := pr.newReader(pkgbits.SectionObj, idx, pkgbits.SyncObject1)
413413
r.dict = dict
414414

415415
switch tag {
@@ -470,7 +470,7 @@ func (pr *pkgReader) objIdx(idx pkgbits.Index) (*types2.Package, string) {
470470
func (pr *pkgReader) objDictIdx(idx pkgbits.Index) *readerDict {
471471
var dict readerDict
472472
{
473-
r := pr.tempReader(pkgbits.RelocObjDict, idx, pkgbits.SyncObject1)
473+
r := pr.tempReader(pkgbits.SectionObjDict, idx, pkgbits.SyncObject1)
474474

475475
if implicits := r.Len(); implicits != 0 {
476476
base.Fatalf("unexpected object with %v implicit type parameter(s)", implicits)
@@ -484,7 +484,7 @@ func (pr *pkgReader) objDictIdx(idx pkgbits.Index) *readerDict {
484484
dict.derived = make([]derivedInfo, r.Len())
485485
dict.derivedTypes = make([]types2.Type, len(dict.derived))
486486
for i := range dict.derived {
487-
dict.derived[i] = derivedInfo{idx: r.Reloc(pkgbits.RelocType)}
487+
dict.derived[i] = derivedInfo{idx: r.Reloc(pkgbits.SectionType)}
488488
if r.Version().Has(pkgbits.DerivedInfoNeeded) {
489489
assert(!r.Bool())
490490
}

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

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@ The payload is a series of sections. Each section has a kind which determines
2020
its index in the series.
2121
2222
SectionKind = Uint64 .
23-
TODO(markfreeman): Update when we rename RelocFoo to SectionFoo.
24-
Payload = RelocString // TODO(markfreeman) Define.
25-
RelocMeta
26-
RelocPosBase // TODO(markfreeman) Define.
27-
RelocPkg // TODO(markfreeman) Define.
28-
RelocName // TODO(markfreeman) Define.
29-
RelocType // TODO(markfreeman) Define.
30-
RelocObj // TODO(markfreeman) Define.
31-
RelocObjExt // TODO(markfreeman) Define.
32-
RelocObjDict // TODO(markfreeman) Define.
33-
RelocBody // TODO(markfreeman) Define.
23+
Payload = SectionString // TODO(markfreeman) Define.
24+
SectionMeta
25+
SectionPosBase // TODO(markfreeman) Define.
26+
SectionPkg // TODO(markfreeman) Define.
27+
SectionName // TODO(markfreeman) Define.
28+
SectionType // TODO(markfreeman) Define.
29+
SectionObj // TODO(markfreeman) Define.
30+
SectionObjExt // TODO(markfreeman) Define.
31+
SectionObjDict // TODO(markfreeman) Define.
32+
SectionBody // TODO(markfreeman) Define.
3433
.
3534
3635
# Sections
@@ -45,22 +44,22 @@ RelIndex = Uint64 .
4544
The meta section provides fundamental information for a package. It contains
4645
exactly two elements — a public root and a private root.
4746
48-
RelocMeta = PublicRoot
49-
PrivateRoot // TODO(markfreeman): Define.
50-
.
47+
SectionMeta = PublicRoot
48+
PrivateRoot // TODO(markfreeman): Define.
49+
.
5150
5251
The public root element identifies the package and provides references for all
5352
exported objects it contains.
5453
55-
PublicRoot = Relocs
56-
[ SyncPublic ] // TODO(markfreeman): Define.
57-
PackageRef // TODO(markfreeman): Define.
58-
[ HasInit ]
59-
ObjectRefCount // TODO(markfreeman): Define.
60-
{ ObjectRef } // TODO(markfreeman): Define.
61-
.
62-
HasInit = Bool . // Whether the package uses any initialization
63-
// functions.
54+
PublicRoot = Relocs
55+
[ SyncPublic ] // TODO(markfreeman): Define.
56+
PackageRef // TODO(markfreeman): Define.
57+
[ HasInit ]
58+
ObjectRefCount // TODO(markfreeman): Define.
59+
{ ObjectRef } // TODO(markfreeman): Define.
60+
.
61+
HasInit = Bool . // Whether the package uses any initialization
62+
// functions.
6463
6564
# References
6665
A reference table precedes every element. Each entry in the table contains a

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ func (l *linker) relocIdx(pr *pkgReader, k pkgbits.SectionKind, idx index) index
6969

7070
var newidx index
7171
switch k {
72-
case pkgbits.RelocString:
72+
case pkgbits.SectionString:
7373
newidx = l.relocString(pr, idx)
74-
case pkgbits.RelocPkg:
74+
case pkgbits.SectionPkg:
7575
newidx = l.relocPkg(pr, idx)
76-
case pkgbits.RelocObj:
76+
case pkgbits.SectionObj:
7777
newidx = l.relocObj(pr, idx)
7878

7979
default:
@@ -113,8 +113,8 @@ func (l *linker) relocPkg(pr *pkgReader, idx index) index {
113113
return newidx
114114
}
115115

116-
r := pr.NewDecoder(pkgbits.RelocPkg, idx, pkgbits.SyncPkgDef)
117-
w := l.pw.NewEncoder(pkgbits.RelocPkg, pkgbits.SyncPkgDef)
116+
r := pr.NewDecoder(pkgbits.SectionPkg, idx, pkgbits.SyncPkgDef)
117+
w := l.pw.NewEncoder(pkgbits.SectionPkg, pkgbits.SyncPkgDef)
118118
l.pkgs[path] = w.Idx
119119

120120
// TODO(mdempsky): We end up leaving an empty string reference here
@@ -158,19 +158,19 @@ func (l *linker) relocObj(pr *pkgReader, idx index) index {
158158
assert(tag2 != pkgbits.ObjStub)
159159
}
160160

161-
w := l.pw.NewEncoderRaw(pkgbits.RelocObj)
162-
wext := l.pw.NewEncoderRaw(pkgbits.RelocObjExt)
163-
wname := l.pw.NewEncoderRaw(pkgbits.RelocName)
164-
wdict := l.pw.NewEncoderRaw(pkgbits.RelocObjDict)
161+
w := l.pw.NewEncoderRaw(pkgbits.SectionObj)
162+
wext := l.pw.NewEncoderRaw(pkgbits.SectionObjExt)
163+
wname := l.pw.NewEncoderRaw(pkgbits.SectionName)
164+
wdict := l.pw.NewEncoderRaw(pkgbits.SectionObjDict)
165165

166166
l.decls[sym] = w.Idx
167167
assert(wext.Idx == w.Idx)
168168
assert(wname.Idx == w.Idx)
169169
assert(wdict.Idx == w.Idx)
170170

171-
l.relocCommon(pr, &w, pkgbits.RelocObj, idx)
172-
l.relocCommon(pr, &wname, pkgbits.RelocName, idx)
173-
l.relocCommon(pr, &wdict, pkgbits.RelocObjDict, idx)
171+
l.relocCommon(pr, &w, pkgbits.SectionObj, idx)
172+
l.relocCommon(pr, &wname, pkgbits.SectionName, idx)
173+
l.relocCommon(pr, &wdict, pkgbits.SectionObjDict, idx)
174174

175175
// Generic types and functions won't have definitions, and imported
176176
// objects may not either.
@@ -189,7 +189,7 @@ func (l *linker) relocObj(pr *pkgReader, idx index) index {
189189
}
190190
wext.Flush()
191191
} else {
192-
l.relocCommon(pr, &wext, pkgbits.RelocObjExt, idx)
192+
l.relocCommon(pr, &wext, pkgbits.SectionObjExt, idx)
193193
}
194194

195195
// Check if we need to export the inline bodies for functions and
@@ -247,7 +247,7 @@ func (l *linker) exportBody(obj *ir.Name, local bool) {
247247

248248
pri, ok := bodyReaderFor(fn)
249249
assert(ok)
250-
l.bodies[sym] = l.relocIdx(pri.pr, pkgbits.RelocBody, pri.idx)
250+
l.bodies[sym] = l.relocIdx(pri.pr, pkgbits.SectionBody, pri.idx)
251251
}
252252

253253
// relocCommon copies the specified element from pr into w,

0 commit comments

Comments
 (0)