mirror of https://github.com/golang/go.git
cmd/compile,runtime: remove runtime.mulUintptr
For #48798 Change-Id: Ice5c9fc23a240be7b2beac77afb0850e8d761e0d
This commit is contained in:
parent
122b35e838
commit
b101a8a54f
|
|
@ -4117,7 +4117,6 @@ func InitTables() {
|
||||||
return s.newValue2(ssa.OpMul64uover, types.NewTuple(types.Types[types.TUINT], types.Types[types.TUINT]), args[0], args[1])
|
return s.newValue2(ssa.OpMul64uover, types.NewTuple(types.Types[types.TUINT], types.Types[types.TUINT]), args[0], args[1])
|
||||||
},
|
},
|
||||||
sys.AMD64, sys.I386, sys.Loong64, sys.MIPS64, sys.RISCV64, sys.ARM64)
|
sys.AMD64, sys.I386, sys.Loong64, sys.MIPS64, sys.RISCV64, sys.ARM64)
|
||||||
alias("runtime", "mulUintptr", "runtime/internal/math", "MulUintptr", all...)
|
|
||||||
add("runtime", "KeepAlive",
|
add("runtime", "KeepAlive",
|
||||||
func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
|
func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
|
||||||
data := s.newValue1(ssa.OpIData, s.f.Config.Types.BytePtr, args[0])
|
data := s.newValue1(ssa.OpIData, s.f.Config.Types.BytePtr, args[0])
|
||||||
|
|
|
||||||
|
|
@ -189,8 +189,6 @@ func unsafestringcheckptr(ptr unsafe.Pointer, len int64)
|
||||||
func panicunsafestringlen()
|
func panicunsafestringlen()
|
||||||
func panicunsafestringnilptr()
|
func panicunsafestringnilptr()
|
||||||
|
|
||||||
func mulUintptr(x, y uintptr) (uintptr, bool)
|
|
||||||
|
|
||||||
func memmove(to *any, frm *any, length uintptr)
|
func memmove(to *any, frm *any, length uintptr)
|
||||||
func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
|
func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr)
|
||||||
func memclrHasPointers(ptr unsafe.Pointer, n uintptr)
|
func memclrHasPointers(ptr unsafe.Pointer, n uintptr)
|
||||||
|
|
|
||||||
|
|
@ -156,87 +156,86 @@ var runtimeDecls = [...]struct {
|
||||||
{"unsafestringcheckptr", funcTag, 120},
|
{"unsafestringcheckptr", funcTag, 120},
|
||||||
{"panicunsafestringlen", funcTag, 9},
|
{"panicunsafestringlen", funcTag, 9},
|
||||||
{"panicunsafestringnilptr", funcTag, 9},
|
{"panicunsafestringnilptr", funcTag, 9},
|
||||||
{"mulUintptr", funcTag, 121},
|
{"memmove", funcTag, 121},
|
||||||
{"memmove", funcTag, 122},
|
{"memclrNoHeapPointers", funcTag, 122},
|
||||||
{"memclrNoHeapPointers", funcTag, 123},
|
{"memclrHasPointers", funcTag, 122},
|
||||||
{"memclrHasPointers", funcTag, 123},
|
{"memequal", funcTag, 123},
|
||||||
{"memequal", funcTag, 124},
|
{"memequal0", funcTag, 124},
|
||||||
{"memequal0", funcTag, 125},
|
{"memequal8", funcTag, 124},
|
||||||
{"memequal8", funcTag, 125},
|
{"memequal16", funcTag, 124},
|
||||||
{"memequal16", funcTag, 125},
|
{"memequal32", funcTag, 124},
|
||||||
{"memequal32", funcTag, 125},
|
{"memequal64", funcTag, 124},
|
||||||
{"memequal64", funcTag, 125},
|
{"memequal128", funcTag, 124},
|
||||||
{"memequal128", funcTag, 125},
|
{"f32equal", funcTag, 125},
|
||||||
{"f32equal", funcTag, 126},
|
{"f64equal", funcTag, 125},
|
||||||
{"f64equal", funcTag, 126},
|
{"c64equal", funcTag, 125},
|
||||||
{"c64equal", funcTag, 126},
|
{"c128equal", funcTag, 125},
|
||||||
{"c128equal", funcTag, 126},
|
{"strequal", funcTag, 125},
|
||||||
{"strequal", funcTag, 126},
|
{"interequal", funcTag, 125},
|
||||||
{"interequal", funcTag, 126},
|
{"nilinterequal", funcTag, 125},
|
||||||
{"nilinterequal", funcTag, 126},
|
{"memhash", funcTag, 126},
|
||||||
{"memhash", funcTag, 127},
|
{"memhash0", funcTag, 127},
|
||||||
{"memhash0", funcTag, 128},
|
{"memhash8", funcTag, 127},
|
||||||
{"memhash8", funcTag, 128},
|
{"memhash16", funcTag, 127},
|
||||||
{"memhash16", funcTag, 128},
|
{"memhash32", funcTag, 127},
|
||||||
{"memhash32", funcTag, 128},
|
{"memhash64", funcTag, 127},
|
||||||
{"memhash64", funcTag, 128},
|
{"memhash128", funcTag, 127},
|
||||||
{"memhash128", funcTag, 128},
|
{"f32hash", funcTag, 128},
|
||||||
{"f32hash", funcTag, 129},
|
{"f64hash", funcTag, 128},
|
||||||
{"f64hash", funcTag, 129},
|
{"c64hash", funcTag, 128},
|
||||||
{"c64hash", funcTag, 129},
|
{"c128hash", funcTag, 128},
|
||||||
{"c128hash", funcTag, 129},
|
{"strhash", funcTag, 128},
|
||||||
{"strhash", funcTag, 129},
|
{"interhash", funcTag, 128},
|
||||||
{"interhash", funcTag, 129},
|
{"nilinterhash", funcTag, 128},
|
||||||
{"nilinterhash", funcTag, 129},
|
{"int64div", funcTag, 129},
|
||||||
{"int64div", funcTag, 130},
|
{"uint64div", funcTag, 130},
|
||||||
{"uint64div", funcTag, 131},
|
{"int64mod", funcTag, 129},
|
||||||
{"int64mod", funcTag, 130},
|
{"uint64mod", funcTag, 130},
|
||||||
{"uint64mod", funcTag, 131},
|
{"float64toint64", funcTag, 131},
|
||||||
{"float64toint64", funcTag, 132},
|
{"float64touint64", funcTag, 132},
|
||||||
{"float64touint64", funcTag, 133},
|
{"float64touint32", funcTag, 133},
|
||||||
{"float64touint32", funcTag, 134},
|
{"int64tofloat64", funcTag, 134},
|
||||||
{"int64tofloat64", funcTag, 135},
|
{"int64tofloat32", funcTag, 136},
|
||||||
{"int64tofloat32", funcTag, 137},
|
{"uint64tofloat64", funcTag, 137},
|
||||||
{"uint64tofloat64", funcTag, 138},
|
{"uint64tofloat32", funcTag, 138},
|
||||||
{"uint64tofloat32", funcTag, 139},
|
{"uint32tofloat64", funcTag, 139},
|
||||||
{"uint32tofloat64", funcTag, 140},
|
{"complex128div", funcTag, 140},
|
||||||
{"complex128div", funcTag, 141},
|
{"getcallerpc", funcTag, 141},
|
||||||
{"getcallerpc", funcTag, 142},
|
{"getcallersp", funcTag, 141},
|
||||||
{"getcallersp", funcTag, 142},
|
|
||||||
{"racefuncenter", funcTag, 31},
|
{"racefuncenter", funcTag, 31},
|
||||||
{"racefuncexit", funcTag, 9},
|
{"racefuncexit", funcTag, 9},
|
||||||
{"raceread", funcTag, 31},
|
{"raceread", funcTag, 31},
|
||||||
{"racewrite", funcTag, 31},
|
{"racewrite", funcTag, 31},
|
||||||
{"racereadrange", funcTag, 143},
|
{"racereadrange", funcTag, 142},
|
||||||
{"racewriterange", funcTag, 143},
|
{"racewriterange", funcTag, 142},
|
||||||
{"msanread", funcTag, 143},
|
{"msanread", funcTag, 142},
|
||||||
{"msanwrite", funcTag, 143},
|
{"msanwrite", funcTag, 142},
|
||||||
{"msanmove", funcTag, 144},
|
{"msanmove", funcTag, 143},
|
||||||
{"asanread", funcTag, 143},
|
{"asanread", funcTag, 142},
|
||||||
{"asanwrite", funcTag, 143},
|
{"asanwrite", funcTag, 142},
|
||||||
{"checkptrAlignment", funcTag, 145},
|
{"checkptrAlignment", funcTag, 144},
|
||||||
{"checkptrArithmetic", funcTag, 147},
|
{"checkptrArithmetic", funcTag, 146},
|
||||||
{"libfuzzerTraceCmp1", funcTag, 148},
|
{"libfuzzerTraceCmp1", funcTag, 147},
|
||||||
{"libfuzzerTraceCmp2", funcTag, 149},
|
{"libfuzzerTraceCmp2", funcTag, 148},
|
||||||
{"libfuzzerTraceCmp4", funcTag, 150},
|
{"libfuzzerTraceCmp4", funcTag, 149},
|
||||||
{"libfuzzerTraceCmp8", funcTag, 151},
|
{"libfuzzerTraceCmp8", funcTag, 150},
|
||||||
{"libfuzzerTraceConstCmp1", funcTag, 148},
|
{"libfuzzerTraceConstCmp1", funcTag, 147},
|
||||||
{"libfuzzerTraceConstCmp2", funcTag, 149},
|
{"libfuzzerTraceConstCmp2", funcTag, 148},
|
||||||
{"libfuzzerTraceConstCmp4", funcTag, 150},
|
{"libfuzzerTraceConstCmp4", funcTag, 149},
|
||||||
{"libfuzzerTraceConstCmp8", funcTag, 151},
|
{"libfuzzerTraceConstCmp8", funcTag, 150},
|
||||||
{"libfuzzerHookStrCmp", funcTag, 152},
|
{"libfuzzerHookStrCmp", funcTag, 151},
|
||||||
{"libfuzzerHookEqualFold", funcTag, 152},
|
{"libfuzzerHookEqualFold", funcTag, 151},
|
||||||
{"addCovMeta", funcTag, 154},
|
{"addCovMeta", funcTag, 153},
|
||||||
{"x86HasPOPCNT", varTag, 6},
|
{"x86HasPOPCNT", varTag, 6},
|
||||||
{"x86HasSSE41", varTag, 6},
|
{"x86HasSSE41", varTag, 6},
|
||||||
{"x86HasFMA", varTag, 6},
|
{"x86HasFMA", varTag, 6},
|
||||||
{"armHasVFPv4", varTag, 6},
|
{"armHasVFPv4", varTag, 6},
|
||||||
{"arm64HasATOMICS", varTag, 6},
|
{"arm64HasATOMICS", varTag, 6},
|
||||||
{"asanregisterglobals", funcTag, 123},
|
{"asanregisterglobals", funcTag, 122},
|
||||||
}
|
}
|
||||||
|
|
||||||
func runtimeTypes() []*types.Type {
|
func runtimeTypes() []*types.Type {
|
||||||
var typs [155]*types.Type
|
var typs [154]*types.Type
|
||||||
typs[0] = types.ByteType
|
typs[0] = types.ByteType
|
||||||
typs[1] = types.NewPtr(typs[0])
|
typs[1] = types.NewPtr(typs[0])
|
||||||
typs[2] = types.Types[types.TANY]
|
typs[2] = types.Types[types.TANY]
|
||||||
|
|
@ -358,40 +357,39 @@ func runtimeTypes() []*types.Type {
|
||||||
typs[118] = newSig(params(typs[3], typs[15], typs[15], typs[15], typs[1]), params(typs[117]))
|
typs[118] = newSig(params(typs[3], typs[15], typs[15], typs[15], typs[1]), params(typs[117]))
|
||||||
typs[119] = newSig(params(typs[1], typs[7], typs[22]), nil)
|
typs[119] = newSig(params(typs[1], typs[7], typs[22]), nil)
|
||||||
typs[120] = newSig(params(typs[7], typs[22]), nil)
|
typs[120] = newSig(params(typs[7], typs[22]), nil)
|
||||||
typs[121] = newSig(params(typs[5], typs[5]), params(typs[5], typs[6]))
|
typs[121] = newSig(params(typs[3], typs[3], typs[5]), nil)
|
||||||
typs[122] = newSig(params(typs[3], typs[3], typs[5]), nil)
|
typs[122] = newSig(params(typs[7], typs[5]), nil)
|
||||||
typs[123] = newSig(params(typs[7], typs[5]), nil)
|
typs[123] = newSig(params(typs[3], typs[3], typs[5]), params(typs[6]))
|
||||||
typs[124] = newSig(params(typs[3], typs[3], typs[5]), params(typs[6]))
|
typs[124] = newSig(params(typs[3], typs[3]), params(typs[6]))
|
||||||
typs[125] = newSig(params(typs[3], typs[3]), params(typs[6]))
|
typs[125] = newSig(params(typs[7], typs[7]), params(typs[6]))
|
||||||
typs[126] = newSig(params(typs[7], typs[7]), params(typs[6]))
|
typs[126] = newSig(params(typs[3], typs[5], typs[5]), params(typs[5]))
|
||||||
typs[127] = newSig(params(typs[3], typs[5], typs[5]), params(typs[5]))
|
typs[127] = newSig(params(typs[7], typs[5]), params(typs[5]))
|
||||||
typs[128] = newSig(params(typs[7], typs[5]), params(typs[5]))
|
typs[128] = newSig(params(typs[3], typs[5]), params(typs[5]))
|
||||||
typs[129] = newSig(params(typs[3], typs[5]), params(typs[5]))
|
typs[129] = newSig(params(typs[22], typs[22]), params(typs[22]))
|
||||||
typs[130] = newSig(params(typs[22], typs[22]), params(typs[22]))
|
typs[130] = newSig(params(typs[24], typs[24]), params(typs[24]))
|
||||||
typs[131] = newSig(params(typs[24], typs[24]), params(typs[24]))
|
typs[131] = newSig(params(typs[20]), params(typs[22]))
|
||||||
typs[132] = newSig(params(typs[20]), params(typs[22]))
|
typs[132] = newSig(params(typs[20]), params(typs[24]))
|
||||||
typs[133] = newSig(params(typs[20]), params(typs[24]))
|
typs[133] = newSig(params(typs[20]), params(typs[62]))
|
||||||
typs[134] = newSig(params(typs[20]), params(typs[62]))
|
typs[134] = newSig(params(typs[22]), params(typs[20]))
|
||||||
typs[135] = newSig(params(typs[22]), params(typs[20]))
|
typs[135] = types.Types[types.TFLOAT32]
|
||||||
typs[136] = types.Types[types.TFLOAT32]
|
typs[136] = newSig(params(typs[22]), params(typs[135]))
|
||||||
typs[137] = newSig(params(typs[22]), params(typs[136]))
|
typs[137] = newSig(params(typs[24]), params(typs[20]))
|
||||||
typs[138] = newSig(params(typs[24]), params(typs[20]))
|
typs[138] = newSig(params(typs[24]), params(typs[135]))
|
||||||
typs[139] = newSig(params(typs[24]), params(typs[136]))
|
typs[139] = newSig(params(typs[62]), params(typs[20]))
|
||||||
typs[140] = newSig(params(typs[62]), params(typs[20]))
|
typs[140] = newSig(params(typs[26], typs[26]), params(typs[26]))
|
||||||
typs[141] = newSig(params(typs[26], typs[26]), params(typs[26]))
|
typs[141] = newSig(nil, params(typs[5]))
|
||||||
typs[142] = newSig(nil, params(typs[5]))
|
typs[142] = newSig(params(typs[5], typs[5]), nil)
|
||||||
typs[143] = newSig(params(typs[5], typs[5]), nil)
|
typs[143] = newSig(params(typs[5], typs[5], typs[5]), nil)
|
||||||
typs[144] = newSig(params(typs[5], typs[5], typs[5]), nil)
|
typs[144] = newSig(params(typs[7], typs[1], typs[5]), nil)
|
||||||
typs[145] = newSig(params(typs[7], typs[1], typs[5]), nil)
|
typs[145] = types.NewSlice(typs[7])
|
||||||
typs[146] = types.NewSlice(typs[7])
|
typs[146] = newSig(params(typs[7], typs[145]), nil)
|
||||||
typs[147] = newSig(params(typs[7], typs[146]), nil)
|
typs[147] = newSig(params(typs[66], typs[66], typs[17]), nil)
|
||||||
typs[148] = newSig(params(typs[66], typs[66], typs[17]), nil)
|
typs[148] = newSig(params(typs[60], typs[60], typs[17]), nil)
|
||||||
typs[149] = newSig(params(typs[60], typs[60], typs[17]), nil)
|
typs[149] = newSig(params(typs[62], typs[62], typs[17]), nil)
|
||||||
typs[150] = newSig(params(typs[62], typs[62], typs[17]), nil)
|
typs[150] = newSig(params(typs[24], typs[24], typs[17]), nil)
|
||||||
typs[151] = newSig(params(typs[24], typs[24], typs[17]), nil)
|
typs[151] = newSig(params(typs[28], typs[28], typs[17]), nil)
|
||||||
typs[152] = newSig(params(typs[28], typs[28], typs[17]), nil)
|
typs[152] = types.NewArray(typs[0], 16)
|
||||||
typs[153] = types.NewArray(typs[0], 16)
|
typs[153] = newSig(params(typs[7], typs[62], typs[152], typs[28], typs[15], typs[66], typs[66]), params(typs[62]))
|
||||||
typs[154] = newSig(params(typs[7], typs[62], typs[153], typs[28], typs[15], typs[66], typs[66]), params(typs[62]))
|
|
||||||
return typs[:]
|
return typs[:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -748,11 +748,23 @@ func walkUnsafeSlice(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
|
||||||
return walkExpr(typecheck.Expr(h), init)
|
return walkExpr(typecheck.Expr(h), init)
|
||||||
}
|
}
|
||||||
|
|
||||||
// mem, overflow := runtime.mulUintptr(et.size, len)
|
// mem, overflow := math.mulUintptr(et.size, len)
|
||||||
mem := typecheck.TempAt(base.Pos, ir.CurFunc, types.Types[types.TUINTPTR])
|
mem := typecheck.TempAt(base.Pos, ir.CurFunc, types.Types[types.TUINTPTR])
|
||||||
overflow := typecheck.TempAt(base.Pos, ir.CurFunc, types.Types[types.TBOOL])
|
overflow := typecheck.TempAt(base.Pos, ir.CurFunc, types.Types[types.TBOOL])
|
||||||
fn := typecheck.LookupRuntime("mulUintptr")
|
|
||||||
call := mkcall1(fn, fn.Type().ResultsTuple(), init, ir.NewInt(base.Pos, sliceType.Elem().Size()), typecheck.Conv(typecheck.Conv(len, lenType), types.Types[types.TUINTPTR]))
|
decl := types.NewSignature(nil,
|
||||||
|
[]*types.Field{
|
||||||
|
types.NewField(base.Pos, nil, types.Types[types.TUINTPTR]),
|
||||||
|
types.NewField(base.Pos, nil, types.Types[types.TUINTPTR]),
|
||||||
|
},
|
||||||
|
[]*types.Field{
|
||||||
|
types.NewField(base.Pos, nil, types.Types[types.TUINTPTR]),
|
||||||
|
types.NewField(base.Pos, nil, types.Types[types.TBOOL]),
|
||||||
|
})
|
||||||
|
|
||||||
|
fn := ir.NewFunc(n.Pos(), n.Pos(), math_MulUintptr, decl)
|
||||||
|
|
||||||
|
call := mkcall1(fn.Nname, fn.Type().ResultsTuple(), init, ir.NewInt(base.Pos, sliceType.Elem().Size()), typecheck.Conv(typecheck.Conv(len, lenType), types.Types[types.TUINTPTR]))
|
||||||
appendWalkStmt(init, ir.NewAssignListStmt(base.Pos, ir.OAS2, []ir.Node{mem, overflow}, []ir.Node{call}))
|
appendWalkStmt(init, ir.NewAssignListStmt(base.Pos, ir.OAS2, []ir.Node{mem, overflow}, []ir.Node{call}))
|
||||||
|
|
||||||
// if overflow || mem > -uintptr(ptr) {
|
// if overflow || mem > -uintptr(ptr) {
|
||||||
|
|
@ -778,6 +790,8 @@ func walkUnsafeSlice(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
|
||||||
return walkExpr(typecheck.Expr(h), init)
|
return walkExpr(typecheck.Expr(h), init)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var math_MulUintptr = &types.Sym{Pkg: types.NewPkg("runtime/internal/math", "math"), Name: "MulUintptr"}
|
||||||
|
|
||||||
func walkUnsafeString(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
|
func walkUnsafeString(n *ir.BinaryExpr, init *ir.Nodes) ir.Node {
|
||||||
ptr := safeExpr(n.X, init)
|
ptr := safeExpr(n.X, init)
|
||||||
len := safeExpr(n.Y, init)
|
len := safeExpr(n.Y, init)
|
||||||
|
|
|
||||||
|
|
@ -117,12 +117,6 @@ func makeslice64(et *_type, len64, cap64 int64) unsafe.Pointer {
|
||||||
return makeslice(et, len, cap)
|
return makeslice(et, len, cap)
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is a wrapper over runtime/internal/math.MulUintptr,
|
|
||||||
// so the compiler can recognize and treat it as an intrinsic.
|
|
||||||
func mulUintptr(a, b uintptr) (uintptr, bool) {
|
|
||||||
return math.MulUintptr(a, b)
|
|
||||||
}
|
|
||||||
|
|
||||||
// growslice allocates new backing store for a slice.
|
// growslice allocates new backing store for a slice.
|
||||||
//
|
//
|
||||||
// arguments:
|
// arguments:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue