diff options
| author | Austin Clements <austin@google.com> | 2024-04-01 15:39:41 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-04-02 16:25:18 +0000 |
| commit | 94dba61276f26c01b7d3d1a4abb195bdcc596bfd (patch) | |
| tree | 1d1bcc6e167f1889771d3bfbfd01bec53d36e752 /src/cmd | |
| parent | cb6d15a747ee7875504fdb4fc28c64c67c5f8d82 (diff) | |
| download | go-94dba61276f26c01b7d3d1a4abb195bdcc596bfd.tar.xz | |
internal/abi: clean up type of Kind and Type.Kind_
Currently, Type.Kind_ is a uint8, Kind is a uint, and some of the
abi.Kind consts are not of type Kind. Clean this all up by making Kind
a uint8, then making Type.Kind a Kind, and finally making all Kind
consts actually have type Kind. This has some ripple effect, but I
think all of the changes are improvements.
Change-Id: If39be74699c2cdb52bf0ad7092d392bc8fb68d15
Reviewed-on: https://go-review.googlesource.com/c/go/+/575579
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd')
| -rw-r--r-- | src/cmd/link/internal/ld/data.go | 2 | ||||
| -rw-r--r-- | src/cmd/link/internal/ld/deadcode.go | 4 | ||||
| -rw-r--r-- | src/cmd/link/internal/ld/decodesym.go | 8 | ||||
| -rw-r--r-- | src/cmd/link/internal/ld/dwarf.go | 2 |
4 files changed, 8 insertions, 8 deletions
diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index b4930277e4..11dc48b18b 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -1346,7 +1346,7 @@ func (p *GCProg) AddSym(s loader.Sym) { } sval := ldr.SymValue(s) - if decodetypeUsegcprog(p.ctxt.Arch, typData) == 0 { + if !decodetypeUsegcprog(p.ctxt.Arch, typData) { // Copy pointers from mask into program. mask := decodetypeGcmask(p.ctxt, typ) for i := int64(0); i < nptr; i++ { diff --git a/src/cmd/link/internal/ld/deadcode.go b/src/cmd/link/internal/ld/deadcode.go index f635d7582f..241cf603db 100644 --- a/src/cmd/link/internal/ld/deadcode.go +++ b/src/cmd/link/internal/ld/deadcode.go @@ -512,7 +512,7 @@ func (d *deadcodePass) decodeIfaceMethod(ldr *loader.Loader, arch *sys.Arch, sym if p == nil { panic(fmt.Sprintf("missing symbol %q", ldr.SymName(symIdx))) } - if abi.Kind(decodetypeKind(arch, p)&abi.KindMask) != abi.Interface { + if decodetypeKind(arch, p) != abi.Interface { panic(fmt.Sprintf("symbol %q is not an interface", ldr.SymName(symIdx))) } relocs := ldr.Relocs(symIdx) @@ -533,7 +533,7 @@ func (d *deadcodePass) decodetypeMethods(ldr *loader.Loader, arch *sys.Arch, sym panic(fmt.Sprintf("no methods on %q", ldr.SymName(symIdx))) } off := commonsize(arch) // reflect.rtype - switch abi.Kind(decodetypeKind(arch, p) & abi.KindMask) { + switch decodetypeKind(arch, p) { case abi.Struct: // reflect.structType off += 4 * arch.PtrSize case abi.Pointer: // reflect.ptrType diff --git a/src/cmd/link/internal/ld/decodesym.go b/src/cmd/link/internal/ld/decodesym.go index 99f058aed2..ab2b8fac59 100644 --- a/src/cmd/link/internal/ld/decodesym.go +++ b/src/cmd/link/internal/ld/decodesym.go @@ -37,13 +37,13 @@ func structfieldSize(arch *sys.Arch) int { return abi.StructFieldSize(arch.PtrSi func uncommonSize(arch *sys.Arch) int { return int(abi.UncommonSize()) } // runtime.uncommontype // Type.commonType.kind -func decodetypeKind(arch *sys.Arch, p []byte) uint8 { - return p[2*arch.PtrSize+7] & abi.KindMask // 0x13 / 0x1f +func decodetypeKind(arch *sys.Arch, p []byte) abi.Kind { + return abi.Kind(p[2*arch.PtrSize+7]) & abi.KindMask // 0x13 / 0x1f } // Type.commonType.kind -func decodetypeUsegcprog(arch *sys.Arch, p []byte) uint8 { - return p[2*arch.PtrSize+7] & abi.KindGCProg // 0x13 / 0x1f +func decodetypeUsegcprog(arch *sys.Arch, p []byte) bool { + return abi.Kind(p[2*arch.PtrSize+7])&abi.KindGCProg != 0 // 0x13 / 0x1f } // Type.commonType.size diff --git a/src/cmd/link/internal/ld/dwarf.go b/src/cmd/link/internal/ld/dwarf.go index 50fbdf1f18..886c1ff672 100644 --- a/src/cmd/link/internal/ld/dwarf.go +++ b/src/cmd/link/internal/ld/dwarf.go @@ -542,7 +542,7 @@ func (d *dwctxt) newtype(gotype loader.Sym) *dwarf.DWDie { bytesize := decodetypeSize(d.arch, tdata) var die, typedefdie *dwarf.DWDie - switch abi.Kind(kind) { + switch kind { case abi.Bool: die = d.newdie(&dwtypes, dwarf.DW_ABRV_BASETYPE, name) newattr(die, dwarf.DW_AT_encoding, dwarf.DW_CLS_CONSTANT, dwarf.DW_ATE_boolean, 0) |
