]> Cypherpunks repositories - gostls13.git/commitdiff
internal/pkgbits: rename RelocEnt to RefTableEntry
authorMark Freeman <mark@golang.org>
Mon, 19 May 2025 20:06:42 +0000 (16:06 -0400)
committerGopher Robot <gobot@golang.org>
Tue, 20 May 2025 19:55:36 +0000 (12:55 -0700)
Change-Id: I9b1c9a0499ad3444e8cb3e4be187f9fab816c90c
Reviewed-on: https://go-review.googlesource.com/c/go/+/674159
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <mark@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/cmd/compile/internal/noder/doc.go
src/cmd/compile/internal/noder/linker.go
src/internal/pkgbits/decoder.go
src/internal/pkgbits/encoder.go
src/internal/pkgbits/reloc.go

index a35efa886d3f8e2128576b34aaf046b27f8a1450..f76e5723b78fce9aaad6cd712359b71e4cfb1c16 100644 (file)
@@ -59,7 +59,7 @@ contains exactly two elements — a public root and a private root.
 The public root element identifies the package and provides references
 for all exported objects it contains.
 
-    PublicRoot  = Relocs
+    PublicRoot  = RefTable
                   [ Sync ]
                   PkgRef
                   [ HasInit ]
@@ -79,7 +79,7 @@ A base is either a file base or line base (produced by a line
 directive). Every base has a position, line, and column; these are
 constant for file bases and hence not encoded.
 
-    PosBase = Relocs
+    PosBase = RefTable
               [ Sync ]
               StringRef       // the (absolute) file name for the base
               Bool            // true if a file base, else a line base
@@ -118,7 +118,7 @@ packages. The below package paths have special meaning.
     | "unsafe"     | the compiler-known unsafe package |
     +--------------+-----------------------------------+
 
-    Pkg        = Relocs
+    Pkg        = RefTable
                  [ Sync ]
                  StringRef      // path
                  // The below is ommitted for the special package paths
@@ -138,21 +138,17 @@ Note, a PkgRef is *not* equivalent to Ref[Pkg] due to an extra marker.
 
 # References
 A reference table precedes every element. Each entry in the table
-contains a section / index pair denoting the location of the referenced
-element.
-
-    // TODO(markfreeman): Rename to RefTable.
-    Relocs   = [ Sync ]
-               RelocCount
-               { Reloc }
-               .
-    // TODO(markfreeman): Rename to RefTableEntryCount.
-    RelocCount = Uint64 .
-    // TODO(markfreeman): Rename to RefTableEntry.
-    Reloc    = [ Sync ]
-               SectionKind
-               RelIndex
-               .
+contains a (section, index) pair denoting the location of the
+referenced element.
+
+    RefTable      = [ Sync ]
+                    Uint64            // the number of table entries
+                    { RefTableEntry }
+                    .
+    RefTableEntry = [ Sync ]
+                    SectionKind
+                    RelIndex
+                    .
 
 Elements encode references to other elements as an index in the
 reference table — not the location of the referenced element directly.
index 6ee29a205b833319475dde306b399f1d7555519d..51b03a1897e8303d38d75c7de34361c9c61d4eb2 100644 (file)
@@ -47,8 +47,8 @@ type linker struct {
 // relocAll ensures that all elements specified by pr and relocs are
 // copied into the output export data file, and returns the
 // corresponding indices in the output.
-func (l *linker) relocAll(pr *pkgReader, relocs []pkgbits.RelocEnt) []pkgbits.RelocEnt {
-       res := make([]pkgbits.RelocEnt, len(relocs))
+func (l *linker) relocAll(pr *pkgReader, relocs []pkgbits.RefTableEntry) []pkgbits.RefTableEntry {
+       res := make([]pkgbits.RefTableEntry, len(relocs))
        for i, rent := range relocs {
                rent.Idx = l.relocIdx(pr, rent.Kind, rent.Idx)
                res[i] = rent
index 9ff6f5c76cc8a8b5863b24548c78da35f1eb4efc..bbda6e92850a2388c53b25212bbb198f33a60efb 100644 (file)
@@ -54,7 +54,7 @@ type PkgDecoder struct {
        // (or 0, if K==0) and end at elemEndsEnds[K].
        elemEndsEnds [numRelocs]uint32
 
-       scratchRelocEnt []RelocEnt
+       scratchRelocEnt []RefTableEntry
 }
 
 // PkgPath returns the package path for the package
@@ -196,10 +196,10 @@ func (pr *PkgDecoder) NewDecoderRaw(k SectionKind, idx RelIndex) Decoder {
 
        r.Data.Reset(pr.DataIdx(k, idx))
        r.Sync(SyncRelocs)
-       r.Relocs = make([]RelocEnt, r.Len())
+       r.Relocs = make([]RefTableEntry, r.Len())
        for i := range r.Relocs {
                r.Sync(SyncReloc)
-               r.Relocs[i] = RelocEnt{SectionKind(r.Len()), RelIndex(r.Len())}
+               r.Relocs[i] = RefTableEntry{SectionKind(r.Len()), RelIndex(r.Len())}
        }
 
        return r
@@ -219,11 +219,11 @@ func (pr *PkgDecoder) TempDecoderRaw(k SectionKind, idx RelIndex) Decoder {
                r.Relocs = pr.scratchRelocEnt[:l]
                pr.scratchRelocEnt = nil
        } else {
-               r.Relocs = make([]RelocEnt, l)
+               r.Relocs = make([]RefTableEntry, l)
        }
        for i := range r.Relocs {
                r.Sync(SyncReloc)
-               r.Relocs[i] = RelocEnt{SectionKind(r.Len()), RelIndex(r.Len())}
+               r.Relocs[i] = RefTableEntry{SectionKind(r.Len()), RelIndex(r.Len())}
        }
 
        return r
@@ -234,7 +234,7 @@ func (pr *PkgDecoder) TempDecoderRaw(k SectionKind, idx RelIndex) Decoder {
 type Decoder struct {
        common *PkgDecoder
 
-       Relocs []RelocEnt
+       Relocs []RefTableEntry
        Data   strings.Reader
 
        k   SectionKind
index 5c51642e3c4f4d8b797ac74e53188bf2adbde5c9..3d1223bb6397eb1c9102d91ddd6e9dcef6fd07dd 100644 (file)
@@ -147,8 +147,8 @@ func (pw *PkgEncoder) NewEncoderRaw(k SectionKind) *Encoder {
 type Encoder struct {
        p *PkgEncoder
 
-       Relocs   []RelocEnt
-       RelocMap map[RelocEnt]uint32
+       Relocs   []RefTableEntry
+       RelocMap map[RefTableEntry]uint32
        Data     bytes.Buffer // accumulated element bitstream data
 
        encodingRelocHeader bool
@@ -211,13 +211,13 @@ func (w *Encoder) rawVarint(x int64) {
 }
 
 func (w *Encoder) rawReloc(k SectionKind, idx RelIndex) int {
-       e := RelocEnt{k, idx}
+       e := RefTableEntry{k, idx}
        if w.RelocMap != nil {
                if i, ok := w.RelocMap[e]; ok {
                        return int(i)
                }
        } else {
-               w.RelocMap = make(map[RelocEnt]uint32)
+               w.RelocMap = make(map[RefTableEntry]uint32)
        }
 
        i := len(w.Relocs)
index d3b897757f6d3741e66367d140e5f13cd9ad6fce..d132f4e995401a9f06d934bb5ad6bb57feee14e8 100644 (file)
@@ -32,10 +32,10 @@ type Index int32
 // references from Index to RelIndex.
 type RelIndex = Index
 
-// A RelocEnt, or relocation entry, is an entry in an element's reference
-// table. All elements are preceded by a reference table which provides
-// locations for all dereferences that the element may use.
-type RelocEnt struct {
+// A RefTableEntry is an entry in an element's reference table. All
+// elements are preceded by a reference table which provides locations
+// for referenced elements.
+type RefTableEntry struct {
        Kind SectionKind
        Idx  RelIndex
 }