mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd: remove dead code
Fixes #74076 Change-Id: Icc67b3d4e342f329584433bd1250c56ae8f5a73d Reviewed-on: https://go-review.googlesource.com/c/go/+/690635 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Alan Donovan <adonovan@google.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
parent
a2c45f0eb1
commit
4ee0df8c46
52 changed files with 1 additions and 1033 deletions
|
|
@ -23,18 +23,6 @@ func jumpLoong64(word string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsLoong64MUL reports whether the op (as defined by an loong64.A* constant) is
|
|
||||||
// one of the MUL/DIV/REM instructions that require special handling.
|
|
||||||
func IsLoong64MUL(op obj.As) bool {
|
|
||||||
switch op {
|
|
||||||
case loong64.AMUL, loong64.AMULU, loong64.AMULV, loong64.AMULVU,
|
|
||||||
loong64.ADIV, loong64.ADIVU, loong64.ADIVV, loong64.ADIVVU,
|
|
||||||
loong64.AREM, loong64.AREMU, loong64.AREMV, loong64.AREMVU:
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsLoong64RDTIME reports whether the op (as defined by an loong64.A*
|
// IsLoong64RDTIME reports whether the op (as defined by an loong64.A*
|
||||||
// constant) is one of the RDTIMELW/RDTIMEHW/RDTIMED instructions that
|
// constant) is one of the RDTIMELW/RDTIMEHW/RDTIMED instructions that
|
||||||
// require special handling.
|
// require special handling.
|
||||||
|
|
|
||||||
|
|
@ -974,14 +974,6 @@ func (p *Parser) getConstant(prog *obj.Prog, op obj.As, addr *obj.Addr) int64 {
|
||||||
return addr.Offset
|
return addr.Offset
|
||||||
}
|
}
|
||||||
|
|
||||||
// getImmediate checks that addr represents an immediate constant and returns its value.
|
|
||||||
func (p *Parser) getImmediate(prog *obj.Prog, op obj.As, addr *obj.Addr) int64 {
|
|
||||||
if addr.Type != obj.TYPE_CONST || addr.Name != 0 || addr.Reg != 0 || addr.Index != 0 {
|
|
||||||
p.errorf("%s: expected immediate constant; found %s", op, obj.Dconv(prog, addr))
|
|
||||||
}
|
|
||||||
return addr.Offset
|
|
||||||
}
|
|
||||||
|
|
||||||
// getRegister checks that addr represents a register and returns its value.
|
// getRegister checks that addr represents a register and returns its value.
|
||||||
func (p *Parser) getRegister(prog *obj.Prog, op obj.As, addr *obj.Addr) int16 {
|
func (p *Parser) getRegister(prog *obj.Prog, op obj.As, addr *obj.Addr) int16 {
|
||||||
if addr.Type != obj.TYPE_REG || addr.Offset != 0 || addr.Name != 0 || addr.Index != 0 {
|
if addr.Type != obj.TYPE_REG || addr.Offset != 0 || addr.Name != 0 || addr.Index != 0 {
|
||||||
|
|
|
||||||
|
|
@ -9,20 +9,14 @@ package importer
|
||||||
import (
|
import (
|
||||||
"cmd/compile/internal/base"
|
"cmd/compile/internal/base"
|
||||||
"cmd/compile/internal/types2"
|
"cmd/compile/internal/types2"
|
||||||
"fmt"
|
|
||||||
"go/token"
|
"go/token"
|
||||||
"internal/pkgbits"
|
"internal/pkgbits"
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func assert(p bool) {
|
func assert(p bool) {
|
||||||
base.Assert(p)
|
base.Assert(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func errorf(format string, args ...interface{}) {
|
|
||||||
panic(fmt.Sprintf(format, args...))
|
|
||||||
}
|
|
||||||
|
|
||||||
const deltaNewFile = -64 // see cmd/compile/internal/gc/bexport.go
|
const deltaNewFile = -64 // see cmd/compile/internal/gc/bexport.go
|
||||||
|
|
||||||
// Synthesize a token.Pos
|
// Synthesize a token.Pos
|
||||||
|
|
@ -31,108 +25,6 @@ type fakeFileSet struct {
|
||||||
files map[string]*token.File
|
files map[string]*token.File
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *fakeFileSet) pos(file string, line, column int) token.Pos {
|
|
||||||
// TODO(mdempsky): Make use of column.
|
|
||||||
|
|
||||||
// Since we don't know the set of needed file positions, we
|
|
||||||
// reserve maxlines positions per file.
|
|
||||||
const maxlines = 64 * 1024
|
|
||||||
f := s.files[file]
|
|
||||||
if f == nil {
|
|
||||||
f = s.fset.AddFile(file, -1, maxlines)
|
|
||||||
s.files[file] = f
|
|
||||||
// Allocate the fake linebreak indices on first use.
|
|
||||||
// TODO(adonovan): opt: save ~512KB using a more complex scheme?
|
|
||||||
fakeLinesOnce.Do(func() {
|
|
||||||
fakeLines = make([]int, maxlines)
|
|
||||||
for i := range fakeLines {
|
|
||||||
fakeLines[i] = i
|
|
||||||
}
|
|
||||||
})
|
|
||||||
f.SetLines(fakeLines)
|
|
||||||
}
|
|
||||||
|
|
||||||
if line > maxlines {
|
|
||||||
line = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Treat the file as if it contained only newlines
|
|
||||||
// and column=1: use the line number as the offset.
|
|
||||||
return f.Pos(line - 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
fakeLines []int
|
|
||||||
fakeLinesOnce sync.Once
|
|
||||||
)
|
|
||||||
|
|
||||||
func chanDir(d int) types2.ChanDir {
|
|
||||||
// tag values must match the constants in cmd/compile/internal/gc/go.go
|
|
||||||
switch d {
|
|
||||||
case 1 /* Crecv */ :
|
|
||||||
return types2.RecvOnly
|
|
||||||
case 2 /* Csend */ :
|
|
||||||
return types2.SendOnly
|
|
||||||
case 3 /* Cboth */ :
|
|
||||||
return types2.SendRecv
|
|
||||||
default:
|
|
||||||
errorf("unexpected channel dir %d", d)
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var predeclared = []types2.Type{
|
|
||||||
// basic types
|
|
||||||
types2.Typ[types2.Bool],
|
|
||||||
types2.Typ[types2.Int],
|
|
||||||
types2.Typ[types2.Int8],
|
|
||||||
types2.Typ[types2.Int16],
|
|
||||||
types2.Typ[types2.Int32],
|
|
||||||
types2.Typ[types2.Int64],
|
|
||||||
types2.Typ[types2.Uint],
|
|
||||||
types2.Typ[types2.Uint8],
|
|
||||||
types2.Typ[types2.Uint16],
|
|
||||||
types2.Typ[types2.Uint32],
|
|
||||||
types2.Typ[types2.Uint64],
|
|
||||||
types2.Typ[types2.Uintptr],
|
|
||||||
types2.Typ[types2.Float32],
|
|
||||||
types2.Typ[types2.Float64],
|
|
||||||
types2.Typ[types2.Complex64],
|
|
||||||
types2.Typ[types2.Complex128],
|
|
||||||
types2.Typ[types2.String],
|
|
||||||
|
|
||||||
// basic type aliases
|
|
||||||
types2.Universe.Lookup("byte").Type(),
|
|
||||||
types2.Universe.Lookup("rune").Type(),
|
|
||||||
|
|
||||||
// error
|
|
||||||
types2.Universe.Lookup("error").Type(),
|
|
||||||
|
|
||||||
// untyped types
|
|
||||||
types2.Typ[types2.UntypedBool],
|
|
||||||
types2.Typ[types2.UntypedInt],
|
|
||||||
types2.Typ[types2.UntypedRune],
|
|
||||||
types2.Typ[types2.UntypedFloat],
|
|
||||||
types2.Typ[types2.UntypedComplex],
|
|
||||||
types2.Typ[types2.UntypedString],
|
|
||||||
types2.Typ[types2.UntypedNil],
|
|
||||||
|
|
||||||
// package unsafe
|
|
||||||
types2.Typ[types2.UnsafePointer],
|
|
||||||
|
|
||||||
// invalid type
|
|
||||||
types2.Typ[types2.Invalid], // only appears in packages with errors
|
|
||||||
|
|
||||||
// used internally by gc; never used by this package or in .a files
|
|
||||||
// not to be confused with the universe any
|
|
||||||
anyType{},
|
|
||||||
|
|
||||||
// comparable
|
|
||||||
types2.Universe.Lookup("comparable").Type(),
|
|
||||||
|
|
||||||
// "any" has special handling: see usage of predeclared.
|
|
||||||
}
|
|
||||||
|
|
||||||
type anyType struct{}
|
type anyType struct{}
|
||||||
|
|
||||||
func (t anyType) Underlying() types2.Type { return t }
|
func (t anyType) Underlying() types2.Type { return t }
|
||||||
|
|
|
||||||
|
|
@ -1211,17 +1211,6 @@ func pruneUnusedAutos(ll []*ir.Name, vis *hairyVisitor) []*ir.Name {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
// numNonClosures returns the number of functions in list which are not closures.
|
|
||||||
func numNonClosures(list []*ir.Func) int {
|
|
||||||
count := 0
|
|
||||||
for _, fn := range list {
|
|
||||||
if fn.OClosure == nil {
|
|
||||||
count++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count
|
|
||||||
}
|
|
||||||
|
|
||||||
func doList(list []ir.Node, do func(ir.Node) bool) bool {
|
func doList(list []ir.Node, do func(ir.Node) bool) bool {
|
||||||
for _, x := range list {
|
for _, x := range list {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
|
|
|
||||||
|
|
@ -399,14 +399,6 @@ func LargestNegativeScoreAdjustment(fn *ir.Func, props *FuncProps) int {
|
||||||
return score
|
return score
|
||||||
}
|
}
|
||||||
|
|
||||||
// LargestPositiveScoreAdjustment tries to estimate the largest possible
|
|
||||||
// positive score adjustment that could be applied to a given callsite.
|
|
||||||
// At the moment we don't have very many positive score adjustments, so
|
|
||||||
// this is just hard-coded, not table-driven.
|
|
||||||
func LargestPositiveScoreAdjustment(fn *ir.Func) int {
|
|
||||||
return adjValues[panicPathAdj] + adjValues[initFuncAdj]
|
|
||||||
}
|
|
||||||
|
|
||||||
// callSiteTab contains entries for each call in the function
|
// callSiteTab contains entries for each call in the function
|
||||||
// currently being processed by InlineCalls; this variable will either
|
// currently being processed by InlineCalls; this variable will either
|
||||||
// be set to 'cstabCache' below (for non-inlinable routines) or to the
|
// be set to 'cstabCache' below (for non-inlinable routines) or to the
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,3 @@ func DeepCopy(pos src.XPos, n Node) Node {
|
||||||
}
|
}
|
||||||
return edit(n)
|
return edit(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopyList returns a list of deep copies (using DeepCopy) of the nodes in list.
|
|
||||||
func DeepCopyList(pos src.XPos, list []Node) []Node {
|
|
||||||
var out []Node
|
|
||||||
for _, n := range list {
|
|
||||||
out = append(out, DeepCopy(pos, n))
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -34,15 +34,6 @@ type miniNode struct {
|
||||||
esc uint16
|
esc uint16
|
||||||
}
|
}
|
||||||
|
|
||||||
// posOr returns pos if known, or else n.pos.
|
|
||||||
// For use in DeepCopy.
|
|
||||||
func (n *miniNode) posOr(pos src.XPos) src.XPos {
|
|
||||||
if pos.IsKnown() {
|
|
||||||
return pos
|
|
||||||
}
|
|
||||||
return n.pos
|
|
||||||
}
|
|
||||||
|
|
||||||
// op can be read, but not written.
|
// op can be read, but not written.
|
||||||
// An embedding implementation can provide a SetOp if desired.
|
// An embedding implementation can provide a SetOp if desired.
|
||||||
// (The panicking SetOp is with the other panics below.)
|
// (The panicking SetOp is with the other panics below.)
|
||||||
|
|
|
||||||
|
|
@ -155,19 +155,6 @@ func Any(n Node, cond func(Node) bool) bool {
|
||||||
return do(n)
|
return do(n)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AnyList calls Any(x, cond) for each node x in the list, in order.
|
|
||||||
// If any call returns true, AnyList stops and returns true.
|
|
||||||
// Otherwise, AnyList returns false after calling Any(x, cond)
|
|
||||||
// for every x in the list.
|
|
||||||
func AnyList(list Nodes, cond func(Node) bool) bool {
|
|
||||||
for _, x := range list {
|
|
||||||
if Any(x, cond) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
// EditChildren edits the child nodes of n, replacing each child x with edit(x).
|
// EditChildren edits the child nodes of n, replacing each child x with edit(x).
|
||||||
//
|
//
|
||||||
// Note that EditChildren(n, edit) only calls edit(x) for n's immediate children.
|
// Note that EditChildren(n, edit) only calls edit(x) for n's immediate children.
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ type poser interface{ Pos() syntax.Pos }
|
||||||
type ender interface{ End() syntax.Pos }
|
type ender interface{ End() syntax.Pos }
|
||||||
|
|
||||||
func (m *posMap) pos(p poser) src.XPos { return m.makeXPos(p.Pos()) }
|
func (m *posMap) pos(p poser) src.XPos { return m.makeXPos(p.Pos()) }
|
||||||
func (m *posMap) end(p ender) src.XPos { return m.makeXPos(p.End()) }
|
|
||||||
|
|
||||||
func (m *posMap) makeXPos(pos syntax.Pos) src.XPos {
|
func (m *posMap) makeXPos(pos syntax.Pos) src.XPos {
|
||||||
// Predeclared objects (e.g., the result parameter for error.Error)
|
// Predeclared objects (e.g., the result parameter for error.Error)
|
||||||
|
|
|
||||||
|
|
@ -3681,17 +3681,6 @@ func expandInline(fn *ir.Func, pri pkgReaderIndex) {
|
||||||
typecheck.Target.Funcs = typecheck.Target.Funcs[:topdcls]
|
typecheck.Target.Funcs = typecheck.Target.Funcs[:topdcls]
|
||||||
}
|
}
|
||||||
|
|
||||||
// usedLocals returns a set of local variables that are used within body.
|
|
||||||
func usedLocals(body []ir.Node) ir.NameSet {
|
|
||||||
var used ir.NameSet
|
|
||||||
ir.VisitList(body, func(n ir.Node) {
|
|
||||||
if n, ok := n.(*ir.Name); ok && n.Op() == ir.ONAME && n.Class == ir.PAUTO {
|
|
||||||
used.Add(n)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
return used
|
|
||||||
}
|
|
||||||
|
|
||||||
// @@@ Method wrappers
|
// @@@ Method wrappers
|
||||||
//
|
//
|
||||||
// Here we handle constructing "method wrappers," alternative entry
|
// Here we handle constructing "method wrappers," alternative entry
|
||||||
|
|
|
||||||
|
|
@ -2413,11 +2413,6 @@ func (p posVar) String() string {
|
||||||
return p.pos.String() + ":" + p.var_.String()
|
return p.pos.String() + ":" + p.var_.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *writer) exprList(expr syntax.Expr) {
|
|
||||||
w.Sync(pkgbits.SyncExprList)
|
|
||||||
w.exprs(syntax.UnpackListExpr(expr))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (w *writer) exprs(exprs []syntax.Expr) {
|
func (w *writer) exprs(exprs []syntax.Expr) {
|
||||||
w.Sync(pkgbits.SyncExprs)
|
w.Sync(pkgbits.SyncExprs)
|
||||||
w.Len(len(exprs))
|
w.Len(len(exprs))
|
||||||
|
|
|
||||||
|
|
@ -1468,10 +1468,3 @@ func MarkUsedIfaceMethod(n *ir.CallExpr) {
|
||||||
Add: InterfaceMethodOffset(ityp, midx),
|
Add: InterfaceMethodOffset(ityp, midx),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func deref(t *types.Type) *types.Type {
|
|
||||||
if t.IsPtr() {
|
|
||||||
return t.Elem()
|
|
||||||
}
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -84,14 +84,6 @@ func (s *biasedSparseMap) getEntry(i int) (x uint, v int32) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// add inserts x->0 into s, provided that x is in the range of keys stored in s.
|
|
||||||
func (s *biasedSparseMap) add(x uint) {
|
|
||||||
if int(x) < s.first || int(x) >= s.cap() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.s.set(ID(int(x)-s.first), 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// add inserts x->v into s, provided that x is in the range of keys stored in s.
|
// add inserts x->v into s, provided that x is in the range of keys stored in s.
|
||||||
func (s *biasedSparseMap) set(x uint, v int32) {
|
func (s *biasedSparseMap) set(x uint, v int32) {
|
||||||
if int(x) < s.first || int(x) >= s.cap() {
|
if int(x) < s.first || int(x) >= s.cap() {
|
||||||
|
|
|
||||||
|
|
@ -77,10 +77,6 @@ func (ls *liveSlot) String() string {
|
||||||
return fmt.Sprintf("0x%x.%d.%d", ls.Registers, ls.stackOffsetValue(), int32(ls.StackOffset)&1)
|
return fmt.Sprintf("0x%x.%d.%d", ls.Registers, ls.stackOffsetValue(), int32(ls.StackOffset)&1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ls liveSlot) absent() bool {
|
|
||||||
return ls.Registers == 0 && !ls.onStack()
|
|
||||||
}
|
|
||||||
|
|
||||||
// StackOffset encodes whether a value is on the stack and if so, where.
|
// StackOffset encodes whether a value is on the stack and if so, where.
|
||||||
// It is a 31-bit integer followed by a presence flag at the low-order
|
// It is a 31-bit integer followed by a presence flag at the low-order
|
||||||
// bit.
|
// bit.
|
||||||
|
|
|
||||||
|
|
@ -851,27 +851,6 @@ func (c *registerCursor) plus(regWidth Abi1RO) registerCursor {
|
||||||
return rc
|
return rc
|
||||||
}
|
}
|
||||||
|
|
||||||
// at returns the register cursor for component i of t, where the first
|
|
||||||
// component is numbered 0.
|
|
||||||
func (c *registerCursor) at(t *types.Type, i int) registerCursor {
|
|
||||||
rc := *c
|
|
||||||
if i == 0 || len(c.regs) == 0 {
|
|
||||||
return rc
|
|
||||||
}
|
|
||||||
if t.IsArray() {
|
|
||||||
w := c.config.NumParamRegs(t.Elem())
|
|
||||||
rc.nextSlice += Abi1RO(i * w)
|
|
||||||
return rc
|
|
||||||
}
|
|
||||||
if t.IsStruct() {
|
|
||||||
for j := 0; j < i; j++ {
|
|
||||||
rc.next(t.FieldType(j))
|
|
||||||
}
|
|
||||||
return rc
|
|
||||||
}
|
|
||||||
panic("Haven't implemented this case yet, do I need to?")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *registerCursor) init(regs []abi.RegIndex, info *abi.ABIParamResultInfo, result *[]*Value, storeDest *Value, storeOffset int64) {
|
func (c *registerCursor) init(regs []abi.RegIndex, info *abi.ABIParamResultInfo, result *[]*Value, storeDest *Value, storeOffset int64) {
|
||||||
c.regs = regs
|
c.regs = regs
|
||||||
c.nextSlice = 0
|
c.nextSlice = 0
|
||||||
|
|
@ -930,17 +909,6 @@ type expandState struct {
|
||||||
indentLevel int // Indentation for debugging recursion
|
indentLevel int // Indentation for debugging recursion
|
||||||
}
|
}
|
||||||
|
|
||||||
// intPairTypes returns the pair of 32-bit int types needed to encode a 64-bit integer type on a target
|
|
||||||
// that has no 64-bit integer registers.
|
|
||||||
func (x *expandState) intPairTypes(et types.Kind) (tHi, tLo *types.Type) {
|
|
||||||
tHi = x.typs.UInt32
|
|
||||||
if et == types.TINT64 {
|
|
||||||
tHi = x.typs.Int32
|
|
||||||
}
|
|
||||||
tLo = x.typs.UInt32
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// offsetFrom creates an offset from a pointer, simplifying chained offsets and offsets from SP
|
// offsetFrom creates an offset from a pointer, simplifying chained offsets and offsets from SP
|
||||||
func (x *expandState) offsetFrom(b *Block, from *Value, offset int64, pt *types.Type) *Value {
|
func (x *expandState) offsetFrom(b *Block, from *Value, offset int64, pt *types.Type) *Value {
|
||||||
ft := from.Type
|
ft := from.Type
|
||||||
|
|
@ -964,29 +932,6 @@ func (x *expandState) offsetFrom(b *Block, from *Value, offset int64, pt *types.
|
||||||
return b.NewValue1I(from.Pos.WithNotStmt(), OpOffPtr, pt, offset, from)
|
return b.NewValue1I(from.Pos.WithNotStmt(), OpOffPtr, pt, offset, from)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *expandState) regWidth(t *types.Type) Abi1RO {
|
|
||||||
return Abi1RO(x.f.ABI1.NumParamRegs(t))
|
|
||||||
}
|
|
||||||
|
|
||||||
// regOffset returns the register offset of the i'th element of type t
|
|
||||||
func (x *expandState) regOffset(t *types.Type, i int) Abi1RO {
|
|
||||||
// TODO maybe cache this in a map if profiling recommends.
|
|
||||||
if i == 0 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
if t.IsArray() {
|
|
||||||
return Abi1RO(i) * x.regWidth(t.Elem())
|
|
||||||
}
|
|
||||||
if t.IsStruct() {
|
|
||||||
k := Abi1RO(0)
|
|
||||||
for j := 0; j < i; j++ {
|
|
||||||
k += x.regWidth(t.FieldType(j))
|
|
||||||
}
|
|
||||||
return k
|
|
||||||
}
|
|
||||||
panic("Haven't implemented this case yet, do I need to?")
|
|
||||||
}
|
|
||||||
|
|
||||||
// prAssignForArg returns the ABIParamAssignment for v, assumed to be an OpArg.
|
// prAssignForArg returns the ABIParamAssignment for v, assumed to be an OpArg.
|
||||||
func (x *expandState) prAssignForArg(v *Value) *abi.ABIParamAssignment {
|
func (x *expandState) prAssignForArg(v *Value) *abi.ABIParamAssignment {
|
||||||
if v.Op != OpArg {
|
if v.Op != OpArg {
|
||||||
|
|
|
||||||
|
|
@ -145,10 +145,7 @@ func (l limit) signedMin(m int64) limit {
|
||||||
l.min = max(l.min, m)
|
l.min = max(l.min, m)
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
func (l limit) signedMax(m int64) limit {
|
|
||||||
l.max = min(l.max, m)
|
|
||||||
return l
|
|
||||||
}
|
|
||||||
func (l limit) signedMinMax(minimum, maximum int64) limit {
|
func (l limit) signedMinMax(minimum, maximum int64) limit {
|
||||||
l.min = max(l.min, minimum)
|
l.min = max(l.min, minimum)
|
||||||
l.max = min(l.max, maximum)
|
l.max = min(l.max, maximum)
|
||||||
|
|
|
||||||
|
|
@ -2980,11 +2980,6 @@ type desiredStateEntry struct {
|
||||||
regs [4]register
|
regs [4]register
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *desiredState) clear() {
|
|
||||||
d.entries = d.entries[:0]
|
|
||||||
d.avoid = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// get returns a list of desired registers for value vid.
|
// get returns a list of desired registers for value vid.
|
||||||
func (d *desiredState) get(vid ID) [4]register {
|
func (d *desiredState) get(vid ID) [4]register {
|
||||||
for _, e := range d.entries {
|
for _, e := range d.entries {
|
||||||
|
|
|
||||||
|
|
@ -625,51 +625,16 @@ func truncate64Fto32F(f float64) float32 {
|
||||||
return math.Float32frombits(r)
|
return math.Float32frombits(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
// extend32Fto64F converts a float32 value to a float64 value preserving the bit
|
|
||||||
// pattern of the mantissa.
|
|
||||||
func extend32Fto64F(f float32) float64 {
|
|
||||||
if !math.IsNaN(float64(f)) {
|
|
||||||
return float64(f)
|
|
||||||
}
|
|
||||||
// NaN bit patterns aren't necessarily preserved across conversion
|
|
||||||
// instructions so we need to do the conversion manually.
|
|
||||||
b := uint64(math.Float32bits(f))
|
|
||||||
// | sign | exponent | mantissa |
|
|
||||||
r := ((b << 32) & (1 << 63)) | (0x7ff << 52) | ((b & 0x7fffff) << (52 - 23))
|
|
||||||
return math.Float64frombits(r)
|
|
||||||
}
|
|
||||||
|
|
||||||
// DivisionNeedsFixUp reports whether the division needs fix-up code.
|
// DivisionNeedsFixUp reports whether the division needs fix-up code.
|
||||||
func DivisionNeedsFixUp(v *Value) bool {
|
func DivisionNeedsFixUp(v *Value) bool {
|
||||||
return v.AuxInt == 0
|
return v.AuxInt == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// auxFrom64F encodes a float64 value so it can be stored in an AuxInt.
|
|
||||||
func auxFrom64F(f float64) int64 {
|
|
||||||
if f != f {
|
|
||||||
panic("can't encode a NaN in AuxInt field")
|
|
||||||
}
|
|
||||||
return int64(math.Float64bits(f))
|
|
||||||
}
|
|
||||||
|
|
||||||
// auxFrom32F encodes a float32 value so it can be stored in an AuxInt.
|
|
||||||
func auxFrom32F(f float32) int64 {
|
|
||||||
if f != f {
|
|
||||||
panic("can't encode a NaN in AuxInt field")
|
|
||||||
}
|
|
||||||
return int64(math.Float64bits(extend32Fto64F(f)))
|
|
||||||
}
|
|
||||||
|
|
||||||
// auxTo32F decodes a float32 from the AuxInt value provided.
|
// auxTo32F decodes a float32 from the AuxInt value provided.
|
||||||
func auxTo32F(i int64) float32 {
|
func auxTo32F(i int64) float32 {
|
||||||
return truncate64Fto32F(math.Float64frombits(uint64(i)))
|
return truncate64Fto32F(math.Float64frombits(uint64(i)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// auxTo64F decodes a float64 from the AuxInt value provided.
|
|
||||||
func auxTo64F(i int64) float64 {
|
|
||||||
return math.Float64frombits(uint64(i))
|
|
||||||
}
|
|
||||||
|
|
||||||
func auxIntToBool(i int64) bool {
|
func auxIntToBool(i int64) bool {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
return false
|
return false
|
||||||
|
|
@ -703,12 +668,6 @@ func auxIntToValAndOff(i int64) ValAndOff {
|
||||||
func auxIntToArm64BitField(i int64) arm64BitField {
|
func auxIntToArm64BitField(i int64) arm64BitField {
|
||||||
return arm64BitField(i)
|
return arm64BitField(i)
|
||||||
}
|
}
|
||||||
func auxIntToInt128(x int64) int128 {
|
|
||||||
if x != 0 {
|
|
||||||
panic("nonzero int128 not allowed")
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
func auxIntToFlagConstant(x int64) flagConstant {
|
func auxIntToFlagConstant(x int64) flagConstant {
|
||||||
return flagConstant(x)
|
return flagConstant(x)
|
||||||
}
|
}
|
||||||
|
|
@ -750,12 +709,6 @@ func valAndOffToAuxInt(v ValAndOff) int64 {
|
||||||
func arm64BitFieldToAuxInt(v arm64BitField) int64 {
|
func arm64BitFieldToAuxInt(v arm64BitField) int64 {
|
||||||
return int64(v)
|
return int64(v)
|
||||||
}
|
}
|
||||||
func int128ToAuxInt(x int128) int64 {
|
|
||||||
if x != 0 {
|
|
||||||
panic("nonzero int128 not allowed")
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
func flagConstantToAuxInt(x flagConstant) int64 {
|
func flagConstantToAuxInt(x flagConstant) int64 {
|
||||||
return int64(x)
|
return int64(x)
|
||||||
}
|
}
|
||||||
|
|
@ -826,23 +779,6 @@ func uaddOvf(a, b int64) bool {
|
||||||
return uint64(a)+uint64(b) < uint64(a)
|
return uint64(a)+uint64(b) < uint64(a)
|
||||||
}
|
}
|
||||||
|
|
||||||
// loadLSymOffset simulates reading a word at an offset into a
|
|
||||||
// read-only symbol's runtime memory. If it would read a pointer to
|
|
||||||
// another symbol, that symbol is returned. Otherwise, it returns nil.
|
|
||||||
func loadLSymOffset(lsym *obj.LSym, offset int64) *obj.LSym {
|
|
||||||
if lsym.Type != objabi.SRODATA {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, r := range lsym.R {
|
|
||||||
if int64(r.Off) == offset && r.Type&^objabi.R_WEAK == objabi.R_ADDR && r.Add == 0 {
|
|
||||||
return r.Sym
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func devirtLECall(v *Value, sym *obj.LSym) *Value {
|
func devirtLECall(v *Value, sym *obj.LSym) *Value {
|
||||||
v.Op = OpStaticLECall
|
v.Op = OpStaticLECall
|
||||||
auxcall := v.Aux.(*AuxCall)
|
auxcall := v.Aux.(*AuxCall)
|
||||||
|
|
@ -1564,10 +1500,6 @@ func GetPPC64Shiftmb(auxint int64) int64 {
|
||||||
return int64(int8(auxint >> 8))
|
return int64(int8(auxint >> 8))
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetPPC64Shiftme(auxint int64) int64 {
|
|
||||||
return int64(int8(auxint))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test if this value can encoded as a mask for a rlwinm like
|
// Test if this value can encoded as a mask for a rlwinm like
|
||||||
// operation. Masks can also extend from the msb and wrap to
|
// operation. Masks can also extend from the msb and wrap to
|
||||||
// the lsb too. That is, the valid masks are 32 bit strings
|
// the lsb too. That is, the valid masks are 32 bit strings
|
||||||
|
|
|
||||||
|
|
@ -1322,9 +1322,6 @@ func (s *state) constInt(t *types.Type, c int64) *ssa.Value {
|
||||||
}
|
}
|
||||||
return s.constInt32(t, int32(c))
|
return s.constInt32(t, int32(c))
|
||||||
}
|
}
|
||||||
func (s *state) constOffPtrSP(t *types.Type, c int64) *ssa.Value {
|
|
||||||
return s.f.ConstOffPtrSP(t, c, s.sp)
|
|
||||||
}
|
|
||||||
|
|
||||||
// newValueOrSfCall* are wrappers around newValue*, which may create a call to a
|
// newValueOrSfCall* are wrappers around newValue*, which may create a call to a
|
||||||
// soft-float runtime function instead (when emitting soft-float code).
|
// soft-float runtime function instead (when emitting soft-float code).
|
||||||
|
|
@ -5382,26 +5379,6 @@ func (s *state) putArg(n ir.Node, t *types.Type) *ssa.Value {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *state) storeArgWithBase(n ir.Node, t *types.Type, base *ssa.Value, off int64) {
|
|
||||||
pt := types.NewPtr(t)
|
|
||||||
var addr *ssa.Value
|
|
||||||
if base == s.sp {
|
|
||||||
// Use special routine that avoids allocation on duplicate offsets.
|
|
||||||
addr = s.constOffPtrSP(pt, off)
|
|
||||||
} else {
|
|
||||||
addr = s.newValue1I(ssa.OpOffPtr, pt, off, base)
|
|
||||||
}
|
|
||||||
|
|
||||||
if !ssa.CanSSA(t) {
|
|
||||||
a := s.addr(n)
|
|
||||||
s.move(t, addr, a)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
a := s.expr(n)
|
|
||||||
s.storeType(t, addr, a, 0, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
// slice computes the slice v[i:j:k] and returns ptr, len, and cap of result.
|
// slice computes the slice v[i:j:k] and returns ptr, len, and cap of result.
|
||||||
// i,j,k may be nil, in which case they are set to their default value.
|
// i,j,k may be nil, in which case they are set to their default value.
|
||||||
// v may be a slice, string or pointer to an array.
|
// v may be a slice, string or pointer to an array.
|
||||||
|
|
|
||||||
|
|
@ -138,10 +138,6 @@ func impliesSemi(tok token) bool {
|
||||||
|
|
||||||
// TODO(gri) provide table of []byte values for all tokens to avoid repeated string conversion
|
// TODO(gri) provide table of []byte values for all tokens to avoid repeated string conversion
|
||||||
|
|
||||||
func lineComment(text string) bool {
|
|
||||||
return strings.HasPrefix(text, "//")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *printer) addWhitespace(kind ctrlSymbol, text string) {
|
func (p *printer) addWhitespace(kind ctrlSymbol, text string) {
|
||||||
p.pending = append(p.pending, whitespace{p.lastTok, kind /*text*/})
|
p.pending = append(p.pending, whitespace{p.lastTok, kind /*text*/})
|
||||||
switch kind {
|
switch kind {
|
||||||
|
|
|
||||||
|
|
@ -235,27 +235,7 @@
|
||||||
|
|
||||||
package typecheck
|
package typecheck
|
||||||
|
|
||||||
import (
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
const blankMarker = "$"
|
const blankMarker = "$"
|
||||||
|
|
||||||
// TparamName returns the real name of a type parameter, after stripping its
|
|
||||||
// qualifying prefix and reverting blank-name encoding. See TparamExportName
|
|
||||||
// for details.
|
|
||||||
func TparamName(exportName string) string {
|
|
||||||
// Remove the "path" from the type param name that makes it unique.
|
|
||||||
ix := strings.LastIndex(exportName, ".")
|
|
||||||
if ix < 0 {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
name := exportName[ix+1:]
|
|
||||||
if strings.HasPrefix(name, blankMarker) {
|
|
||||||
return "_"
|
|
||||||
}
|
|
||||||
return name
|
|
||||||
}
|
|
||||||
|
|
||||||
// The name used for dictionary parameters or local variables.
|
// The name used for dictionary parameters or local variables.
|
||||||
const LocalDictName = ".dict"
|
const LocalDictName = ".dict"
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,6 @@ func RangeExprType(t *types.Type) *types.Type {
|
||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
func typecheckrangeExpr(n *ir.RangeStmt) {
|
|
||||||
}
|
|
||||||
|
|
||||||
// type check assignment.
|
// type check assignment.
|
||||||
// if this assignment is the definition of a var on the left side,
|
// if this assignment is the definition of a var on the left side,
|
||||||
// fill in the var's type.
|
// fill in the var's type.
|
||||||
|
|
|
||||||
|
|
@ -1694,13 +1694,6 @@ func fieldsHasShape(fields []*Field) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
// newBasic returns a new basic type of the given kind.
|
|
||||||
func newBasic(kind Kind, obj Object) *Type {
|
|
||||||
t := newType(kind)
|
|
||||||
t.obj = obj
|
|
||||||
return t
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewInterface returns a new interface for the given methods and
|
// NewInterface returns a new interface for the given methods and
|
||||||
// embedded types. Embedded types are specified as fields with no Sym.
|
// embedded types. Embedded types are specified as fields with no Sym.
|
||||||
func NewInterface(methods []*Field) *Type {
|
func NewInterface(methods []*Field) *Type {
|
||||||
|
|
|
||||||
|
|
@ -187,10 +187,6 @@ type Config struct {
|
||||||
EnableAlias bool
|
EnableAlias bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func srcimporter_setUsesCgo(conf *Config) {
|
|
||||||
conf.go115UsesCgo = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// Info holds result type information for a type-checked package.
|
// Info holds result type information for a type-checked package.
|
||||||
// Only the information for which a map is provided is collected.
|
// Only the information for which a map is provided is collected.
|
||||||
// If the package has type errors, the collected information may
|
// If the package has type errors, the collected information may
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,6 @@ func AsPointer(t Type) *Pointer {
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
// If t is a signature, AsSignature returns that type, otherwise it returns nil.
|
|
||||||
func AsSignature(t Type) *Signature {
|
|
||||||
u, _ := t.Underlying().(*Signature)
|
|
||||||
return u
|
|
||||||
}
|
|
||||||
|
|
||||||
// If typ is a type parameter, CoreType returns the single underlying
|
// If typ is a type parameter, CoreType returns the single underlying
|
||||||
// type of all types in the corresponding type constraint if it exists, or
|
// type of all types in the corresponding type constraint if it exists, or
|
||||||
// nil otherwise. If the type set contains only unrestricted and restricted
|
// nil otherwise. If the type set contains only unrestricted and restricted
|
||||||
|
|
|
||||||
12
src/cmd/dist/imports.go
vendored
12
src/cmd/dist/imports.go
vendored
|
|
@ -205,18 +205,6 @@ func (r *importReader) readImport(imports *[]string) {
|
||||||
r.readString(imports)
|
r.readString(imports)
|
||||||
}
|
}
|
||||||
|
|
||||||
// readComments is like ioutil.ReadAll, except that it only reads the leading
|
|
||||||
// block of comments in the file.
|
|
||||||
func readComments(f io.Reader) ([]byte, error) {
|
|
||||||
r := &importReader{b: bufio.NewReader(f)}
|
|
||||||
r.peekByte(true)
|
|
||||||
if r.err == nil && !r.eof {
|
|
||||||
// Didn't reach EOF, so must have found a non-space byte. Remove it.
|
|
||||||
r.buf = r.buf[:len(r.buf)-1]
|
|
||||||
}
|
|
||||||
return r.buf, r.err
|
|
||||||
}
|
|
||||||
|
|
||||||
// readimports returns the imports found in the named file.
|
// readimports returns the imports found in the named file.
|
||||||
func readimports(file string) []string {
|
func readimports(file string) []string {
|
||||||
var imports []string
|
var imports []string
|
||||||
|
|
|
||||||
10
src/cmd/dist/util.go
vendored
10
src/cmd/dist/util.go
vendored
|
|
@ -362,16 +362,6 @@ func errprintf(format string, args ...interface{}) {
|
||||||
fmt.Fprintf(os.Stderr, format, args...)
|
fmt.Fprintf(os.Stderr, format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// xsamefile reports whether f1 and f2 are the same file (or dir).
|
|
||||||
func xsamefile(f1, f2 string) bool {
|
|
||||||
fi1, err1 := os.Stat(f1)
|
|
||||||
fi2, err2 := os.Stat(f2)
|
|
||||||
if err1 != nil || err2 != nil {
|
|
||||||
return f1 == f2
|
|
||||||
}
|
|
||||||
return os.SameFile(fi1, fi2)
|
|
||||||
}
|
|
||||||
|
|
||||||
func xgetgoarm() string {
|
func xgetgoarm() string {
|
||||||
// If we're building on an actual arm system, and not building
|
// If we're building on an actual arm system, and not building
|
||||||
// a cross-compiling toolchain, try to exec ourselves
|
// a cross-compiling toolchain, try to exec ourselves
|
||||||
|
|
|
||||||
|
|
@ -52,16 +52,6 @@ func maybeToolchainVersion(name string) string {
|
||||||
return FromToolchain(name)
|
return FromToolchain(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToolchainMax returns the maximum of x and y interpreted as toolchain names,
|
|
||||||
// compared using Compare(FromToolchain(x), FromToolchain(y)).
|
|
||||||
// If x and y compare equal, Max returns x.
|
|
||||||
func ToolchainMax(x, y string) string {
|
|
||||||
if Compare(FromToolchain(x), FromToolchain(y)) < 0 {
|
|
||||||
return y
|
|
||||||
}
|
|
||||||
return x
|
|
||||||
}
|
|
||||||
|
|
||||||
// Startup records the information that went into the startup-time version switch.
|
// Startup records the information that went into the startup-time version switch.
|
||||||
// It is initialized by switchGoToolchain.
|
// It is initialized by switchGoToolchain.
|
||||||
var Startup struct {
|
var Startup struct {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@
|
||||||
package filelock
|
package filelock
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"io/fs"
|
"io/fs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -74,10 +73,3 @@ func (lt lockType) String() string {
|
||||||
return "Unlock"
|
return "Unlock"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsNotSupported returns a boolean indicating whether the error is known to
|
|
||||||
// report that a function is not supported (possibly for a specific input).
|
|
||||||
// It is satisfied by errors.ErrUnsupported as well as some syscall errors.
|
|
||||||
func IsNotSupported(err error) bool {
|
|
||||||
return errors.Is(err, errors.ErrUnsupported)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -387,23 +387,6 @@ func (r *gitRepo) Latest(ctx context.Context) (*RevInfo, error) {
|
||||||
return info, nil
|
return info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// findRef finds some ref name for the given hash,
|
|
||||||
// for use when the server requires giving a ref instead of a hash.
|
|
||||||
// There may be multiple ref names for a given hash,
|
|
||||||
// in which case this returns some name - it doesn't matter which.
|
|
||||||
func (r *gitRepo) findRef(ctx context.Context, hash string) (ref string, ok bool) {
|
|
||||||
refs, err := r.loadRefs(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
for ref, h := range refs {
|
|
||||||
if h == hash {
|
|
||||||
return ref, true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *gitRepo) checkConfigSHA256(ctx context.Context) bool {
|
func (r *gitRepo) checkConfigSHA256(ctx context.Context) bool {
|
||||||
if hashType, sha256CfgErr := r.runGit(ctx, "git", "config", "extensions.objectformat"); sha256CfgErr == nil {
|
if hashType, sha256CfgErr := r.runGit(ctx, "git", "config", "extensions.objectformat"); sha256CfgErr == nil {
|
||||||
return "sha256" == strings.TrimSpace(string(hashType))
|
return "sha256" == strings.TrimSpace(string(hashType))
|
||||||
|
|
|
||||||
|
|
@ -1009,10 +1009,6 @@ func LegacyGoMod(modPath string) []byte {
|
||||||
return fmt.Appendf(nil, "module %s\n", modfile.AutoQuote(modPath))
|
return fmt.Appendf(nil, "module %s\n", modfile.AutoQuote(modPath))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *codeRepo) modPrefix(rev string) string {
|
|
||||||
return r.modPath + "@" + rev
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *codeRepo) retractedVersions(ctx context.Context) (func(string) bool, error) {
|
func (r *codeRepo) retractedVersions(ctx context.Context) (func(string) bool, error) {
|
||||||
vs, err := r.Versions(ctx, "")
|
vs, err := r.Versions(ctx, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ package modindex
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"cmd/go/internal/fsys"
|
"cmd/go/internal/fsys"
|
||||||
"cmd/go/internal/str"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go/ast"
|
"go/ast"
|
||||||
|
|
@ -118,96 +117,12 @@ func (ctxt *Context) joinPath(elem ...string) string {
|
||||||
return filepath.Join(elem...)
|
return filepath.Join(elem...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// splitPathList calls ctxt.SplitPathList (if not nil) or else filepath.SplitList.
|
|
||||||
func (ctxt *Context) splitPathList(s string) []string {
|
|
||||||
if f := ctxt.SplitPathList; f != nil {
|
|
||||||
return f(s)
|
|
||||||
}
|
|
||||||
return filepath.SplitList(s)
|
|
||||||
}
|
|
||||||
|
|
||||||
// isAbsPath calls ctxt.IsAbsPath (if not nil) or else filepath.IsAbs.
|
|
||||||
func (ctxt *Context) isAbsPath(path string) bool {
|
|
||||||
if f := ctxt.IsAbsPath; f != nil {
|
|
||||||
return f(path)
|
|
||||||
}
|
|
||||||
return filepath.IsAbs(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
// isDir reports whether path is a directory.
|
// isDir reports whether path is a directory.
|
||||||
func isDir(path string) bool {
|
func isDir(path string) bool {
|
||||||
fi, err := fsys.Stat(path)
|
fi, err := fsys.Stat(path)
|
||||||
return err == nil && fi.IsDir()
|
return err == nil && fi.IsDir()
|
||||||
}
|
}
|
||||||
|
|
||||||
// hasSubdir calls ctxt.HasSubdir (if not nil) or else uses
|
|
||||||
// the local file system to answer the question.
|
|
||||||
func (ctxt *Context) hasSubdir(root, dir string) (rel string, ok bool) {
|
|
||||||
if f := ctxt.HasSubdir; f != nil {
|
|
||||||
return f(root, dir)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try using paths we received.
|
|
||||||
if rel, ok = hasSubdir(root, dir); ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Try expanding symlinks and comparing
|
|
||||||
// expanded against unexpanded and
|
|
||||||
// expanded against expanded.
|
|
||||||
rootSym, _ := filepath.EvalSymlinks(root)
|
|
||||||
dirSym, _ := filepath.EvalSymlinks(dir)
|
|
||||||
|
|
||||||
if rel, ok = hasSubdir(rootSym, dir); ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if rel, ok = hasSubdir(root, dirSym); ok {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
return hasSubdir(rootSym, dirSym)
|
|
||||||
}
|
|
||||||
|
|
||||||
// hasSubdir reports if dir is within root by performing lexical analysis only.
|
|
||||||
func hasSubdir(root, dir string) (rel string, ok bool) {
|
|
||||||
root = str.WithFilePathSeparator(filepath.Clean(root))
|
|
||||||
dir = filepath.Clean(dir)
|
|
||||||
if !strings.HasPrefix(dir, root) {
|
|
||||||
return "", false
|
|
||||||
}
|
|
||||||
return filepath.ToSlash(dir[len(root):]), true
|
|
||||||
}
|
|
||||||
|
|
||||||
// gopath returns the list of Go path directories.
|
|
||||||
func (ctxt *Context) gopath() []string {
|
|
||||||
var all []string
|
|
||||||
for _, p := range ctxt.splitPathList(ctxt.GOPATH) {
|
|
||||||
if p == "" || p == ctxt.GOROOT {
|
|
||||||
// Empty paths are uninteresting.
|
|
||||||
// If the path is the GOROOT, ignore it.
|
|
||||||
// People sometimes set GOPATH=$GOROOT.
|
|
||||||
// Do not get confused by this common mistake.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(p, "~") {
|
|
||||||
// Path segments starting with ~ on Unix are almost always
|
|
||||||
// users who have incorrectly quoted ~ while setting GOPATH,
|
|
||||||
// preventing it from expanding to $HOME.
|
|
||||||
// The situation is made more confusing by the fact that
|
|
||||||
// bash allows quoted ~ in $PATH (most shells do not).
|
|
||||||
// Do not get confused by this, and do not try to use the path.
|
|
||||||
// It does not exist, and printing errors about it confuses
|
|
||||||
// those users even more, because they think "sure ~ exists!".
|
|
||||||
// The go command diagnoses this situation and prints a
|
|
||||||
// useful error.
|
|
||||||
// On Windows, ~ is used in short names, such as c:\progra~1
|
|
||||||
// for c:\program files.
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
all = append(all, p)
|
|
||||||
}
|
|
||||||
return all
|
|
||||||
}
|
|
||||||
|
|
||||||
var defaultToolTags, defaultReleaseTags []string
|
var defaultToolTags, defaultReleaseTags []string
|
||||||
|
|
||||||
// NoGoError is the error used by Import to describe a directory
|
// NoGoError is the error used by Import to describe a directory
|
||||||
|
|
@ -266,114 +181,12 @@ func fileListForExt(p *build.Package, ext string) *[]string {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var errNoModules = errors.New("not using modules")
|
|
||||||
|
|
||||||
func findImportComment(data []byte) (s string, line int) {
|
|
||||||
// expect keyword package
|
|
||||||
word, data := parseWord(data)
|
|
||||||
if string(word) != "package" {
|
|
||||||
return "", 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// expect package name
|
|
||||||
_, data = parseWord(data)
|
|
||||||
|
|
||||||
// now ready for import comment, a // or /* */ comment
|
|
||||||
// beginning and ending on the current line.
|
|
||||||
for len(data) > 0 && (data[0] == ' ' || data[0] == '\t' || data[0] == '\r') {
|
|
||||||
data = data[1:]
|
|
||||||
}
|
|
||||||
|
|
||||||
var comment []byte
|
|
||||||
switch {
|
|
||||||
case bytes.HasPrefix(data, slashSlash):
|
|
||||||
comment, _, _ = bytes.Cut(data[2:], newline)
|
|
||||||
case bytes.HasPrefix(data, slashStar):
|
|
||||||
var ok bool
|
|
||||||
comment, _, ok = bytes.Cut(data[2:], starSlash)
|
|
||||||
if !ok {
|
|
||||||
// malformed comment
|
|
||||||
return "", 0
|
|
||||||
}
|
|
||||||
if bytes.Contains(comment, newline) {
|
|
||||||
return "", 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
comment = bytes.TrimSpace(comment)
|
|
||||||
|
|
||||||
// split comment into `import`, `"pkg"`
|
|
||||||
word, arg := parseWord(comment)
|
|
||||||
if string(word) != "import" {
|
|
||||||
return "", 0
|
|
||||||
}
|
|
||||||
|
|
||||||
line = 1 + bytes.Count(data[:cap(data)-cap(arg)], newline)
|
|
||||||
return strings.TrimSpace(string(arg)), line
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
slashSlash = []byte("//")
|
slashSlash = []byte("//")
|
||||||
slashStar = []byte("/*")
|
slashStar = []byte("/*")
|
||||||
starSlash = []byte("*/")
|
starSlash = []byte("*/")
|
||||||
newline = []byte("\n")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// skipSpaceOrComment returns data with any leading spaces or comments removed.
|
|
||||||
func skipSpaceOrComment(data []byte) []byte {
|
|
||||||
for len(data) > 0 {
|
|
||||||
switch data[0] {
|
|
||||||
case ' ', '\t', '\r', '\n':
|
|
||||||
data = data[1:]
|
|
||||||
continue
|
|
||||||
case '/':
|
|
||||||
if bytes.HasPrefix(data, slashSlash) {
|
|
||||||
i := bytes.Index(data, newline)
|
|
||||||
if i < 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
data = data[i+1:]
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if bytes.HasPrefix(data, slashStar) {
|
|
||||||
data = data[2:]
|
|
||||||
i := bytes.Index(data, starSlash)
|
|
||||||
if i < 0 {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
data = data[i+2:]
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
|
|
||||||
// parseWord skips any leading spaces or comments in data
|
|
||||||
// and then parses the beginning of data as an identifier or keyword,
|
|
||||||
// returning that word and what remains after the word.
|
|
||||||
func parseWord(data []byte) (word, rest []byte) {
|
|
||||||
data = skipSpaceOrComment(data)
|
|
||||||
|
|
||||||
// Parse past leading word characters.
|
|
||||||
rest = data
|
|
||||||
for {
|
|
||||||
r, size := utf8.DecodeRune(rest)
|
|
||||||
if unicode.IsLetter(r) || '0' <= r && r <= '9' || r == '_' {
|
|
||||||
rest = rest[size:]
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
word = data[:len(data)-len(rest)]
|
|
||||||
if len(word) == 0 {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return word, rest
|
|
||||||
}
|
|
||||||
|
|
||||||
var dummyPkg build.Package
|
var dummyPkg build.Package
|
||||||
|
|
||||||
// fileInfo records information learned about a file included in a build.
|
// fileInfo records information learned about a file included in a build.
|
||||||
|
|
|
||||||
|
|
@ -1039,11 +1039,6 @@ func (r *reader) string() string {
|
||||||
return r.d.stringTableAt(r.int())
|
return r.d.stringTableAt(r.int())
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool reads the next bool.
|
|
||||||
func (r *reader) bool() bool {
|
|
||||||
return r.int() != 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// tokpos reads the next token.Position.
|
// tokpos reads the next token.Position.
|
||||||
func (r *reader) tokpos() token.Position {
|
func (r *reader) tokpos() token.Position {
|
||||||
return token.Position{
|
return token.Position{
|
||||||
|
|
|
||||||
|
|
@ -658,11 +658,6 @@ func EditBuildList(ctx context.Context, add, mustSelect []module.Version) (chang
|
||||||
return changed, nil
|
return changed, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// OverrideRoots edits the global requirement roots by replacing the specific module versions.
|
|
||||||
func OverrideRoots(ctx context.Context, replace []module.Version) {
|
|
||||||
requirements = overrideRoots(ctx, requirements, replace)
|
|
||||||
}
|
|
||||||
|
|
||||||
func overrideRoots(ctx context.Context, rs *Requirements, replace []module.Version) *Requirements {
|
func overrideRoots(ctx context.Context, rs *Requirements, replace []module.Version) *Requirements {
|
||||||
drop := make(map[string]bool)
|
drop := make(map[string]bool)
|
||||||
for _, m := range replace {
|
for _, m := range replace {
|
||||||
|
|
|
||||||
|
|
@ -305,30 +305,6 @@ func (mms *MainModuleSet) Godebugs() []*modfile.Godebug {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Toolchain returns the toolchain set on the single module, in module mode,
|
|
||||||
// or the go.work file in workspace mode.
|
|
||||||
func (mms *MainModuleSet) Toolchain() string {
|
|
||||||
if inWorkspaceMode() {
|
|
||||||
if mms.workFile != nil && mms.workFile.Toolchain != nil {
|
|
||||||
return mms.workFile.Toolchain.Name
|
|
||||||
}
|
|
||||||
return "go" + mms.GoVersion()
|
|
||||||
}
|
|
||||||
if mms != nil && len(mms.versions) == 1 {
|
|
||||||
f := mms.ModFile(mms.mustGetSingleMainModule())
|
|
||||||
if f == nil {
|
|
||||||
// Special case: we are outside a module, like 'go run x.go'.
|
|
||||||
// Assume the local Go version.
|
|
||||||
// TODO(#49228): Clean this up; see loadModFile.
|
|
||||||
return gover.LocalToolchain()
|
|
||||||
}
|
|
||||||
if f.Toolchain != nil {
|
|
||||||
return f.Toolchain.Name
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "go" + mms.GoVersion()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (mms *MainModuleSet) WorkFileReplaceMap() map[module.Version]module.Version {
|
func (mms *MainModuleSet) WorkFileReplaceMap() map[module.Version]module.Version {
|
||||||
return mms.workFileReplaceMap
|
return mms.workFileReplaceMap
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ package work
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"internal/buildcfg"
|
"internal/buildcfg"
|
||||||
"internal/platform"
|
"internal/platform"
|
||||||
|
|
@ -438,32 +437,6 @@ func (gcToolchain) symabis(b *Builder, a *Action, sfiles []string) (string, erro
|
||||||
return symabis, nil
|
return symabis, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// toolVerify checks that the command line args writes the same output file
|
|
||||||
// if run using newTool instead.
|
|
||||||
// Unused now but kept around for future use.
|
|
||||||
func toolVerify(a *Action, b *Builder, p *load.Package, newTool string, ofile string, args []any) error {
|
|
||||||
newArgs := make([]any, len(args))
|
|
||||||
copy(newArgs, args)
|
|
||||||
newArgs[1] = base.Tool(newTool)
|
|
||||||
newArgs[3] = ofile + ".new" // x.6 becomes x.6.new
|
|
||||||
if err := b.Shell(a).run(p.Dir, p.ImportPath, nil, newArgs...); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
data1, err := os.ReadFile(ofile)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
data2, err := os.ReadFile(ofile + ".new")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if !bytes.Equal(data1, data2) {
|
|
||||||
return fmt.Errorf("%s and %s produced different output files:\n%s\n%s", filepath.Base(args[1].(string)), newTool, strings.Join(str.StringList(args...), " "), strings.Join(str.StringList(newArgs...), " "))
|
|
||||||
}
|
|
||||||
os.Remove(ofile + ".new")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (gcToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) error {
|
func (gcToolchain) pack(b *Builder, a *Action, afile string, ofiles []string) error {
|
||||||
absOfiles := make([]string, 0, len(ofiles))
|
absOfiles := make([]string, 0, len(ofiles))
|
||||||
for _, f := range ofiles {
|
for _, f := range ofiles {
|
||||||
|
|
|
||||||
|
|
@ -498,20 +498,6 @@ func exactly16Bytes(s string) string {
|
||||||
// architecture-independent object file output
|
// architecture-independent object file output
|
||||||
const HeaderSize = 60
|
const HeaderSize = 60
|
||||||
|
|
||||||
func ReadHeader(b *bufio.Reader, name string) int {
|
|
||||||
var buf [HeaderSize]byte
|
|
||||||
if _, err := io.ReadFull(b, buf[:]); err != nil {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
aname := strings.Trim(string(buf[0:16]), " ")
|
|
||||||
if !strings.HasPrefix(aname, name) {
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
asize := strings.Trim(string(buf[48:58]), " ")
|
|
||||||
i, _ := strconv.Atoi(asize)
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
|
|
||||||
func FormatHeader(arhdr []byte, name string, size int64) {
|
func FormatHeader(arhdr []byte, name string, size int64) {
|
||||||
copy(arhdr[:], fmt.Sprintf("%-16s%-12d%-6d%-6d%-8o%-10d`\n", name, 0, 0, 0, 0644, size))
|
copy(arhdr[:], fmt.Sprintf("%-16s%-12d%-6d%-6d%-8o%-10d`\n", name, 0, 0, 0, 0644, size))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,11 +56,6 @@ func (w *Writer) Debug(out io.Writer) {
|
||||||
w.debug = out
|
w.debug = out
|
||||||
}
|
}
|
||||||
|
|
||||||
// BitIndex returns the number of bits written to the bit stream so far.
|
|
||||||
func (w *Writer) BitIndex() int64 {
|
|
||||||
return w.index
|
|
||||||
}
|
|
||||||
|
|
||||||
// byte writes the byte x to the output.
|
// byte writes the byte x to the output.
|
||||||
func (w *Writer) byte(x byte) {
|
func (w *Writer) byte(x byte) {
|
||||||
if w.debug != nil {
|
if w.debug != nil {
|
||||||
|
|
@ -98,20 +93,6 @@ func (w *Writer) Ptr(index int64) {
|
||||||
w.lit(1)
|
w.lit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ShouldRepeat reports whether it would be worthwhile to
|
|
||||||
// use a Repeat to describe c elements of n bits each,
|
|
||||||
// compared to just emitting c copies of the n-bit description.
|
|
||||||
func (w *Writer) ShouldRepeat(n, c int64) bool {
|
|
||||||
// Should we lay out the bits directly instead of
|
|
||||||
// encoding them as a repetition? Certainly if count==1,
|
|
||||||
// since there's nothing to repeat, but also if the total
|
|
||||||
// size of the plain pointer bits for the type will fit in
|
|
||||||
// 4 or fewer bytes, since using a repetition will require
|
|
||||||
// flushing the current bits plus at least one byte for
|
|
||||||
// the repeat size and one for the repeat count.
|
|
||||||
return c > 1 && c*n > 4*8
|
|
||||||
}
|
|
||||||
|
|
||||||
// Repeat emits an instruction to repeat the description
|
// Repeat emits an instruction to repeat the description
|
||||||
// of the last n words c times (including the initial description, c+1 times in total).
|
// of the last n words c times (including the initial description, c+1 times in total).
|
||||||
func (w *Writer) Repeat(n, c int64) {
|
func (w *Writer) Repeat(n, c int64) {
|
||||||
|
|
@ -163,36 +144,6 @@ func (w *Writer) ZeroUntil(index int64) {
|
||||||
w.Repeat(1, skip-1)
|
w.Repeat(1, skip-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append emits the given GC program into the current output.
|
|
||||||
// The caller asserts that the program emits n bits (describes n words),
|
|
||||||
// and Append panics if that is not true.
|
|
||||||
func (w *Writer) Append(prog []byte, n int64) {
|
|
||||||
w.flushlit()
|
|
||||||
if w.debug != nil {
|
|
||||||
fmt.Fprintf(w.debug, "gcprog: append prog for %d ptrs\n", n)
|
|
||||||
fmt.Fprintf(w.debug, "\t")
|
|
||||||
}
|
|
||||||
n1 := progbits(prog)
|
|
||||||
if n1 != n {
|
|
||||||
panic("gcprog: wrong bit count in append")
|
|
||||||
}
|
|
||||||
// The last byte of the prog terminates the program.
|
|
||||||
// Don't emit that, or else our own program will end.
|
|
||||||
for i, x := range prog[:len(prog)-1] {
|
|
||||||
if w.debug != nil {
|
|
||||||
if i > 0 {
|
|
||||||
fmt.Fprintf(w.debug, " ")
|
|
||||||
}
|
|
||||||
fmt.Fprintf(w.debug, "%02x", x)
|
|
||||||
}
|
|
||||||
w.byte(x)
|
|
||||||
}
|
|
||||||
if w.debug != nil {
|
|
||||||
fmt.Fprintf(w.debug, "\n")
|
|
||||||
}
|
|
||||||
w.index += n
|
|
||||||
}
|
|
||||||
|
|
||||||
// progbits returns the length of the bit stream encoded by the program p.
|
// progbits returns the length of the bit stream encoded by the program p.
|
||||||
func progbits(p []byte) int64 {
|
func progbits(p []byte) int64 {
|
||||||
var n int64
|
var n int64
|
||||||
|
|
|
||||||
|
|
@ -635,29 +635,11 @@ func (r *Reader) uint64At(off uint32) uint64 {
|
||||||
return binary.LittleEndian.Uint64(b)
|
return binary.LittleEndian.Uint64(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reader) int64At(off uint32) int64 {
|
|
||||||
return int64(r.uint64At(off))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Reader) uint32At(off uint32) uint32 {
|
func (r *Reader) uint32At(off uint32) uint32 {
|
||||||
b := r.BytesAt(off, 4)
|
b := r.BytesAt(off, 4)
|
||||||
return binary.LittleEndian.Uint32(b)
|
return binary.LittleEndian.Uint32(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reader) int32At(off uint32) int32 {
|
|
||||||
return int32(r.uint32At(off))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Reader) uint16At(off uint32) uint16 {
|
|
||||||
b := r.BytesAt(off, 2)
|
|
||||||
return binary.LittleEndian.Uint16(b)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Reader) uint8At(off uint32) uint8 {
|
|
||||||
b := r.BytesAt(off, 1)
|
|
||||||
return b[0]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *Reader) StringAt(off uint32, len uint32) string {
|
func (r *Reader) StringAt(off uint32, len uint32) string {
|
||||||
b := r.b[off : off+len]
|
b := r.b[off : off+len]
|
||||||
if r.readonly {
|
if r.readonly {
|
||||||
|
|
|
||||||
|
|
@ -1054,15 +1054,6 @@ var sysInstFields = map[SpecialOperand]struct {
|
||||||
// Used for padding NOOP instruction
|
// Used for padding NOOP instruction
|
||||||
const OP_NOOP = 0xd503201f
|
const OP_NOOP = 0xd503201f
|
||||||
|
|
||||||
// pcAlignPadLength returns the number of bytes required to align pc to alignedValue,
|
|
||||||
// reporting an error if alignedValue is not a power of two or is out of range.
|
|
||||||
func pcAlignPadLength(ctxt *obj.Link, pc int64, alignedValue int64) int {
|
|
||||||
if !((alignedValue&(alignedValue-1) == 0) && 8 <= alignedValue && alignedValue <= 2048) {
|
|
||||||
ctxt.Diag("alignment value of an instruction must be a power of two and in the range [8, 2048], got %d\n", alignedValue)
|
|
||||||
}
|
|
||||||
return int(-pc & (alignedValue - 1))
|
|
||||||
}
|
|
||||||
|
|
||||||
// size returns the size of the sequence of machine instructions when p is encoded with o.
|
// size returns the size of the sequence of machine instructions when p is encoded with o.
|
||||||
// Usually it just returns o.size directly, in some cases it checks whether the optimization
|
// Usually it just returns o.size directly, in some cases it checks whether the optimization
|
||||||
// conditions are met, and if so returns the size of the optimized instruction sequence.
|
// conditions are met, and if so returns the size of the optimized instruction sequence.
|
||||||
|
|
@ -1209,10 +1200,6 @@ type codeBuffer struct {
|
||||||
data *[]byte
|
data *[]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cb *codeBuffer) pc() int64 {
|
|
||||||
return int64(len(*cb.data))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write a sequence of opcodes into the code buffer.
|
// Write a sequence of opcodes into the code buffer.
|
||||||
func (cb *codeBuffer) emit(op ...uint32) {
|
func (cb *codeBuffer) emit(op ...uint32) {
|
||||||
for _, o := range op {
|
for _, o := range op {
|
||||||
|
|
|
||||||
|
|
@ -729,10 +729,6 @@ func isint32(v int64) bool {
|
||||||
return int64(int32(v)) == v
|
return int64(int32(v)) == v
|
||||||
}
|
}
|
||||||
|
|
||||||
func isuint32(v uint64) bool {
|
|
||||||
return uint64(uint32(v)) == v
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *ctxt0) aclass(a *obj.Addr) int {
|
func (c *ctxt0) aclass(a *obj.Addr) int {
|
||||||
switch a.Type {
|
switch a.Type {
|
||||||
case obj.TYPE_NONE:
|
case obj.TYPE_NONE:
|
||||||
|
|
|
||||||
|
|
@ -771,14 +771,6 @@ func (c *ctxt0) stacksplit(p *obj.Prog, framesize int32) *obj.Prog {
|
||||||
return end
|
return end
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ctxt0) addnop(p *obj.Prog) {
|
|
||||||
q := c.newprog()
|
|
||||||
q.As = ANOOP
|
|
||||||
q.Pos = p.Pos
|
|
||||||
q.Link = p.Link
|
|
||||||
p.Link = q
|
|
||||||
}
|
|
||||||
|
|
||||||
var Linkloong64 = obj.LinkArch{
|
var Linkloong64 = obj.LinkArch{
|
||||||
Arch: sys.ArchLoong64,
|
Arch: sys.ArchLoong64,
|
||||||
Init: buildop,
|
Init: buildop,
|
||||||
|
|
|
||||||
|
|
@ -2137,10 +2137,6 @@ func OPVCC(o uint32, xo uint32, oe uint32, rc uint32) uint32 {
|
||||||
return o<<26 | xo<<1 | oe<<10 | rc&1
|
return o<<26 | xo<<1 | oe<<10 | rc&1
|
||||||
}
|
}
|
||||||
|
|
||||||
func OPCC(o uint32, xo uint32, rc uint32) uint32 {
|
|
||||||
return OPVCC(o, xo, 0, rc)
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Generate MD-form opcode */
|
/* Generate MD-form opcode */
|
||||||
func OPMD(o, xo, rc uint32) uint32 {
|
func OPMD(o, xo, rc uint32) uint32 {
|
||||||
return o<<26 | xo<<2 | rc&1
|
return o<<26 | xo<<2 | rc&1
|
||||||
|
|
|
||||||
|
|
@ -1072,24 +1072,6 @@ func regV(r uint32) uint32 {
|
||||||
return regVal(r, REG_V0, REG_V31)
|
return regVal(r, REG_V0, REG_V31)
|
||||||
}
|
}
|
||||||
|
|
||||||
// regAddr extracts a register from an Addr.
|
|
||||||
func regAddr(a obj.Addr, min, max uint32) uint32 {
|
|
||||||
if a.Type != obj.TYPE_REG {
|
|
||||||
panic(fmt.Sprintf("ill typed: %+v", a))
|
|
||||||
}
|
|
||||||
return regVal(uint32(a.Reg), min, max)
|
|
||||||
}
|
|
||||||
|
|
||||||
// regIAddr extracts the integer register from an Addr.
|
|
||||||
func regIAddr(a obj.Addr) uint32 {
|
|
||||||
return regAddr(a, REG_X0, REG_X31)
|
|
||||||
}
|
|
||||||
|
|
||||||
// regFAddr extracts the float register from an Addr.
|
|
||||||
func regFAddr(a obj.Addr) uint32 {
|
|
||||||
return regAddr(a, REG_F0, REG_F31)
|
|
||||||
}
|
|
||||||
|
|
||||||
// immEven checks that the immediate is a multiple of two. If it
|
// immEven checks that the immediate is a multiple of two. If it
|
||||||
// is not, an error is returned.
|
// is not, an error is returned.
|
||||||
func immEven(x int64) error {
|
func immEven(x int64) error {
|
||||||
|
|
|
||||||
|
|
@ -2677,20 +2677,6 @@ func (c *ctxtz) addrilreloc(sym *obj.LSym, add int64) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ctxtz) addrilrelocoffset(sym *obj.LSym, add, offset int64) {
|
|
||||||
if sym == nil {
|
|
||||||
c.ctxt.Diag("require symbol to apply relocation")
|
|
||||||
}
|
|
||||||
offset += int64(2) // relocation offset from start of instruction
|
|
||||||
c.cursym.AddRel(c.ctxt, obj.Reloc{
|
|
||||||
Type: objabi.R_PCRELDBL,
|
|
||||||
Off: int32(c.pc + offset),
|
|
||||||
Siz: 4,
|
|
||||||
Sym: sym,
|
|
||||||
Add: add + offset + 4,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a CALL relocation for the immediate in a RIL style instruction.
|
// Add a CALL relocation for the immediate in a RIL style instruction.
|
||||||
// The addend will be adjusted as required.
|
// The addend will be adjusted as required.
|
||||||
func (c *ctxtz) addcallreloc(sym *obj.LSym, add int64) {
|
func (c *ctxtz) addcallreloc(sym *obj.LSym, add int64) {
|
||||||
|
|
@ -4745,16 +4731,6 @@ func zI(op, i1 uint32, asm *[]byte) {
|
||||||
*asm = append(*asm, uint8(op>>8), uint8(i1))
|
*asm = append(*asm, uint8(op>>8), uint8(i1))
|
||||||
}
|
}
|
||||||
|
|
||||||
func zMII(op, m1, ri2, ri3 uint32, asm *[]byte) {
|
|
||||||
*asm = append(*asm,
|
|
||||||
uint8(op>>8),
|
|
||||||
(uint8(m1)<<4)|uint8((ri2>>8)&0x0F),
|
|
||||||
uint8(ri2),
|
|
||||||
uint8(ri3>>16),
|
|
||||||
uint8(ri3>>8),
|
|
||||||
uint8(ri3))
|
|
||||||
}
|
|
||||||
|
|
||||||
func zRI(op, r1_m1, i2_ri2 uint32, asm *[]byte) {
|
func zRI(op, r1_m1, i2_ri2 uint32, asm *[]byte) {
|
||||||
*asm = append(*asm,
|
*asm = append(*asm,
|
||||||
uint8(op>>8),
|
uint8(op>>8),
|
||||||
|
|
@ -4807,16 +4783,6 @@ func zRIL(f form, op, r1_m1, i2_ri2 uint32, asm *[]byte) {
|
||||||
uint8(i2_ri2))
|
uint8(i2_ri2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func zRIS(op, r1, m3, b4, d4, i2 uint32, asm *[]byte) {
|
|
||||||
*asm = append(*asm,
|
|
||||||
uint8(op>>8),
|
|
||||||
(uint8(r1)<<4)|uint8(m3&0x0F),
|
|
||||||
(uint8(b4)<<4)|(uint8(d4>>8)&0x0F),
|
|
||||||
uint8(d4),
|
|
||||||
uint8(i2),
|
|
||||||
uint8(op))
|
|
||||||
}
|
|
||||||
|
|
||||||
func zRR(op, r1, r2 uint32, asm *[]byte) {
|
func zRR(op, r1, r2 uint32, asm *[]byte) {
|
||||||
*asm = append(*asm, uint8(op>>8), (uint8(r1)<<4)|uint8(r2&0x0F))
|
*asm = append(*asm, uint8(op>>8), (uint8(r1)<<4)|uint8(r2&0x0F))
|
||||||
}
|
}
|
||||||
|
|
@ -4845,16 +4811,6 @@ func zRRF(op, r3_m3, m4, r1, r2 uint32, asm *[]byte) {
|
||||||
(uint8(r1)<<4)|uint8(r2&0x0F))
|
(uint8(r1)<<4)|uint8(r2&0x0F))
|
||||||
}
|
}
|
||||||
|
|
||||||
func zRRS(op, r1, r2, b4, d4, m3 uint32, asm *[]byte) {
|
|
||||||
*asm = append(*asm,
|
|
||||||
uint8(op>>8),
|
|
||||||
(uint8(r1)<<4)|uint8(r2&0x0F),
|
|
||||||
(uint8(b4)<<4)|uint8((d4>>8)&0x0F),
|
|
||||||
uint8(d4),
|
|
||||||
uint8(m3)<<4,
|
|
||||||
uint8(op))
|
|
||||||
}
|
|
||||||
|
|
||||||
func zRS(op, r1, r3_m3, b2, d2 uint32, asm *[]byte) {
|
func zRS(op, r1, r3_m3, b2, d2 uint32, asm *[]byte) {
|
||||||
*asm = append(*asm,
|
*asm = append(*asm,
|
||||||
uint8(op>>8),
|
uint8(op>>8),
|
||||||
|
|
@ -4863,23 +4819,6 @@ func zRS(op, r1, r3_m3, b2, d2 uint32, asm *[]byte) {
|
||||||
uint8(d2))
|
uint8(d2))
|
||||||
}
|
}
|
||||||
|
|
||||||
func zRSI(op, r1, r3, ri2 uint32, asm *[]byte) {
|
|
||||||
*asm = append(*asm,
|
|
||||||
uint8(op>>8),
|
|
||||||
(uint8(r1)<<4)|uint8(r3&0x0F),
|
|
||||||
uint8(ri2>>8),
|
|
||||||
uint8(ri2))
|
|
||||||
}
|
|
||||||
|
|
||||||
func zRSL(op, l1, b2, d2 uint32, asm *[]byte) {
|
|
||||||
*asm = append(*asm,
|
|
||||||
uint8(op>>8),
|
|
||||||
uint8(l1),
|
|
||||||
(uint8(b2)<<4)|uint8((d2>>8)&0x0F),
|
|
||||||
uint8(d2),
|
|
||||||
uint8(op))
|
|
||||||
}
|
|
||||||
|
|
||||||
func zRSY(op, r1, r3_m3, b2, d2 uint32, asm *[]byte) {
|
func zRSY(op, r1, r3_m3, b2, d2 uint32, asm *[]byte) {
|
||||||
dl2 := uint16(d2) & 0x0FFF
|
dl2 := uint16(d2) & 0x0FFF
|
||||||
*asm = append(*asm,
|
*asm = append(*asm,
|
||||||
|
|
@ -4909,16 +4848,6 @@ func zRXE(op, r1, x2, b2, d2, m3 uint32, asm *[]byte) {
|
||||||
uint8(op))
|
uint8(op))
|
||||||
}
|
}
|
||||||
|
|
||||||
func zRXF(op, r3, x2, b2, d2, m1 uint32, asm *[]byte) {
|
|
||||||
*asm = append(*asm,
|
|
||||||
uint8(op>>8),
|
|
||||||
(uint8(r3)<<4)|uint8(x2&0x0F),
|
|
||||||
(uint8(b2)<<4)|uint8((d2>>8)&0x0F),
|
|
||||||
uint8(d2),
|
|
||||||
uint8(m1)<<4,
|
|
||||||
uint8(op))
|
|
||||||
}
|
|
||||||
|
|
||||||
func zRXY(op, r1_m1, x2, b2, d2 uint32, asm *[]byte) {
|
func zRXY(op, r1_m1, x2, b2, d2 uint32, asm *[]byte) {
|
||||||
dl2 := uint16(d2) & 0x0FFF
|
dl2 := uint16(d2) & 0x0FFF
|
||||||
*asm = append(*asm,
|
*asm = append(*asm,
|
||||||
|
|
@ -4967,16 +4896,6 @@ func zSIY(op, i2, b1, d1 uint32, asm *[]byte) {
|
||||||
uint8(op))
|
uint8(op))
|
||||||
}
|
}
|
||||||
|
|
||||||
func zSMI(op, m1, b3, d3, ri2 uint32, asm *[]byte) {
|
|
||||||
*asm = append(*asm,
|
|
||||||
uint8(op>>8),
|
|
||||||
uint8(m1)<<4,
|
|
||||||
(uint8(b3)<<4)|uint8((d3>>8)&0x0F),
|
|
||||||
uint8(d3),
|
|
||||||
uint8(ri2>>8),
|
|
||||||
uint8(ri2))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Expected argument values for the instruction formats.
|
// Expected argument values for the instruction formats.
|
||||||
//
|
//
|
||||||
// Format a1 a2 a3 a4 a5 a6
|
// Format a1 a2 a3 a4 a5 a6
|
||||||
|
|
@ -5006,26 +4925,6 @@ func zSS(f form, op, l1_r1, l2_i3_r3, b1_b2, d1_d2, b2_b4, d2_d4 uint32, asm *[]
|
||||||
uint8(d2_d4))
|
uint8(d2_d4))
|
||||||
}
|
}
|
||||||
|
|
||||||
func zSSE(op, b1, d1, b2, d2 uint32, asm *[]byte) {
|
|
||||||
*asm = append(*asm,
|
|
||||||
uint8(op>>8),
|
|
||||||
uint8(op),
|
|
||||||
(uint8(b1)<<4)|uint8((d1>>8)&0x0F),
|
|
||||||
uint8(d1),
|
|
||||||
(uint8(b2)<<4)|uint8((d2>>8)&0x0F),
|
|
||||||
uint8(d2))
|
|
||||||
}
|
|
||||||
|
|
||||||
func zSSF(op, r3, b1, d1, b2, d2 uint32, asm *[]byte) {
|
|
||||||
*asm = append(*asm,
|
|
||||||
uint8(op>>8),
|
|
||||||
(uint8(r3)<<4)|(uint8(op)&0x0F),
|
|
||||||
(uint8(b1)<<4)|uint8((d1>>8)&0x0F),
|
|
||||||
uint8(d1),
|
|
||||||
(uint8(b2)<<4)|uint8((d2>>8)&0x0F),
|
|
||||||
uint8(d2))
|
|
||||||
}
|
|
||||||
|
|
||||||
func rxb(va, vb, vc, vd uint32) uint8 {
|
func rxb(va, vb, vc, vd uint32) uint8 {
|
||||||
mask := uint8(0)
|
mask := uint8(0)
|
||||||
if va >= REG_V16 && va <= REG_V31 {
|
if va >= REG_V16 && va <= REG_V31 {
|
||||||
|
|
|
||||||
|
|
@ -2037,23 +2037,6 @@ type nopPad struct {
|
||||||
n int32 // Size of the pad
|
n int32 // Size of the pad
|
||||||
}
|
}
|
||||||
|
|
||||||
// requireAlignment ensures that the function alignment is at
|
|
||||||
// least as high as a, which should be a power of two
|
|
||||||
// and between 8 and 2048, inclusive.
|
|
||||||
//
|
|
||||||
// the boolean result indicates whether the alignment meets those constraints
|
|
||||||
func requireAlignment(a int64, ctxt *obj.Link, cursym *obj.LSym) bool {
|
|
||||||
if !((a&(a-1) == 0) && 8 <= a && a <= 2048) {
|
|
||||||
ctxt.Diag("alignment value of an instruction must be a power of two and in the range [8, 2048], got %d\n", a)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
// By default function alignment is 32 bytes for amd64
|
|
||||||
if cursym.Func().Align < int32(a) {
|
|
||||||
cursym.Func().Align = int32(a)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
|
func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
|
||||||
if ctxt.Retpoline && ctxt.Arch.Family == sys.I386 {
|
if ctxt.Retpoline && ctxt.Arch.Family == sys.I386 {
|
||||||
ctxt.Diag("-spectre=ret not supported on 386")
|
ctxt.Diag("-spectre=ret not supported on 386")
|
||||||
|
|
|
||||||
|
|
@ -852,11 +852,6 @@ func isZeroArgRuntimeCall(s *obj.LSym) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func indir_cx(ctxt *obj.Link, a *obj.Addr) {
|
|
||||||
a.Type = obj.TYPE_MEM
|
|
||||||
a.Reg = REG_CX
|
|
||||||
}
|
|
||||||
|
|
||||||
// loadG ensures the G is loaded into a register (either CX or REGG),
|
// loadG ensures the G is loaded into a register (either CX or REGG),
|
||||||
// appending instructions to p if necessary. It returns the new last
|
// appending instructions to p if necessary. It returns the new last
|
||||||
// instruction and the G register.
|
// instruction and the G register.
|
||||||
|
|
|
||||||
|
|
@ -37,17 +37,3 @@ func ReadFile(filename string) ([]byte, error) {
|
||||||
func RemoveAll(path string) error {
|
func RemoveAll(path string) error {
|
||||||
return removeAll(path)
|
return removeAll(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsEphemeralError reports whether err is one of the errors that the functions
|
|
||||||
// in this package attempt to mitigate.
|
|
||||||
//
|
|
||||||
// Errors considered ephemeral include:
|
|
||||||
// - syscall.ERROR_ACCESS_DENIED
|
|
||||||
// - syscall.ERROR_FILE_NOT_FOUND
|
|
||||||
// - internal/syscall/windows.ERROR_SHARING_VIOLATION
|
|
||||||
//
|
|
||||||
// This set may be expanded in the future; programs must not rely on the
|
|
||||||
// non-ephemerality of any given error.
|
|
||||||
func IsEphemeralError(err error) bool {
|
|
||||||
return isEphemeralError(err)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -72,14 +72,6 @@ type Engine struct {
|
||||||
Quiet bool
|
Quiet bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewEngine returns an Engine configured with a basic set of commands and conditions.
|
|
||||||
func NewEngine() *Engine {
|
|
||||||
return &Engine{
|
|
||||||
Cmds: DefaultCmds(),
|
|
||||||
Conds: DefaultConds(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// A Cmd is a command that is available to a script.
|
// A Cmd is a command that is available to a script.
|
||||||
type Cmd interface {
|
type Cmd interface {
|
||||||
// Run begins running the command.
|
// Run begins running the command.
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,6 @@ import (
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PADDR(x uint32) uint32 {
|
|
||||||
return x &^ 0x80000000
|
|
||||||
}
|
|
||||||
|
|
||||||
func gentext(ctxt *ld.Link, ldr *loader.Loader) {
|
func gentext(ctxt *ld.Link, ldr *loader.Loader) {
|
||||||
initfunc, addmoduledata := ld.PrepareAddmoduledata(ctxt)
|
initfunc, addmoduledata := ld.PrepareAddmoduledata(ctxt)
|
||||||
if initfunc == nil {
|
if initfunc == nil {
|
||||||
|
|
|
||||||
|
|
@ -244,35 +244,6 @@ func decodetypeGcmask(ctxt *Link, s loader.Sym) []byte {
|
||||||
return ctxt.loader.Data(mask)
|
return ctxt.loader.Data(mask)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type.commonType.gc
|
|
||||||
func decodetypeGcprog(ctxt *Link, s loader.Sym) []byte {
|
|
||||||
if ctxt.loader.SymType(s) == sym.SDYNIMPORT {
|
|
||||||
symData := ctxt.loader.Data(s)
|
|
||||||
addr := decodetypeGcprogShlib(ctxt, symData)
|
|
||||||
sect := findShlibSection(ctxt, ctxt.loader.SymPkg(s), addr)
|
|
||||||
if sect != nil {
|
|
||||||
// A gcprog is a 4-byte uint32 indicating length, followed by
|
|
||||||
// the actual program.
|
|
||||||
progsize := make([]byte, 4)
|
|
||||||
_, err := sect.ReadAt(progsize, int64(addr-sect.Addr))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
progbytes := make([]byte, ctxt.Arch.ByteOrder.Uint32(progsize))
|
|
||||||
_, err = sect.ReadAt(progbytes, int64(addr-sect.Addr+4))
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
return append(progsize, progbytes...)
|
|
||||||
}
|
|
||||||
Exitf("cannot find gcprog for %s", ctxt.loader.SymName(s))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
relocs := ctxt.loader.Relocs(s)
|
|
||||||
rs := decodeRelocSym(ctxt.loader, s, &relocs, 2*int32(ctxt.Arch.PtrSize)+8+1*int32(ctxt.Arch.PtrSize))
|
|
||||||
return ctxt.loader.Data(rs)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the elf.Section of a given shared library that contains a given address.
|
// Find the elf.Section of a given shared library that contains a given address.
|
||||||
func findShlibSection(ctxt *Link, path string, addr uint64) *elf.Section {
|
func findShlibSection(ctxt *Link, path string, addr uint64) *elf.Section {
|
||||||
for _, shlib := range ctxt.Shlibs {
|
for _, shlib := range ctxt.Shlibs {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"internal/trace"
|
"internal/trace"
|
||||||
"internal/trace/traceviewer"
|
"internal/trace/traceviewer"
|
||||||
"slices"
|
"slices"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// viewerFrames returns the frames of the stack of ev. The given frame slice is
|
// viewerFrames returns the frames of the stack of ev. The given frame slice is
|
||||||
|
|
@ -40,7 +39,3 @@ func viewerGState(state trace.GoState, inMarkAssist bool) traceviewer.GState {
|
||||||
panic(fmt.Sprintf("unknown GoState: %s", state.String()))
|
panic(fmt.Sprintf("unknown GoState: %s", state.String()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func viewerTime(t time.Duration) float64 {
|
|
||||||
return float64(t) / float64(time.Microsecond)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue