mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: remove support for old-style bounds check calls
This CL rips out the support for old-style assembly stubs. We need to keep the Go stubs for wasm support. Change-Id: I23d6d9f2f06be1ded8d22b3e0ef04ff6e252a587 Reviewed-on: https://go-review.googlesource.com/c/go/+/682402 Reviewed-by: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
802d056c78
commit
21ab0128b6
3 changed files with 5 additions and 110 deletions
|
|
@ -485,53 +485,6 @@ const (
|
||||||
BoundsKindCount
|
BoundsKindCount
|
||||||
)
|
)
|
||||||
|
|
||||||
// boundsABI determines which register arguments a bounds check call should use. For an [a:b:c] slice, we do:
|
|
||||||
//
|
|
||||||
// CMPQ c, cap
|
|
||||||
// JA fail1
|
|
||||||
// CMPQ b, c
|
|
||||||
// JA fail2
|
|
||||||
// CMPQ a, b
|
|
||||||
// JA fail3
|
|
||||||
//
|
|
||||||
// fail1: CALL panicSlice3Acap (c, cap)
|
|
||||||
// fail2: CALL panicSlice3B (b, c)
|
|
||||||
// fail3: CALL panicSlice3C (a, b)
|
|
||||||
//
|
|
||||||
// When we register allocate that code, we want the same register to be used for
|
|
||||||
// the first arg of panicSlice3Acap and the second arg to panicSlice3B. That way,
|
|
||||||
// initializing that register once will satisfy both calls.
|
|
||||||
// That desire ends up dividing the set of bounds check calls into 3 sets. This function
|
|
||||||
// determines which set to use for a given panic call.
|
|
||||||
// The first arg for set 0 should be the second arg for set 1.
|
|
||||||
// The first arg for set 1 should be the second arg for set 2.
|
|
||||||
func boundsABI(b int64) int {
|
|
||||||
switch BoundsKind(b) {
|
|
||||||
case BoundsSlice3Alen,
|
|
||||||
BoundsSlice3AlenU,
|
|
||||||
BoundsSlice3Acap,
|
|
||||||
BoundsSlice3AcapU,
|
|
||||||
BoundsConvert:
|
|
||||||
return 0
|
|
||||||
case BoundsSliceAlen,
|
|
||||||
BoundsSliceAlenU,
|
|
||||||
BoundsSliceAcap,
|
|
||||||
BoundsSliceAcapU,
|
|
||||||
BoundsSlice3B,
|
|
||||||
BoundsSlice3BU:
|
|
||||||
return 1
|
|
||||||
case BoundsIndex,
|
|
||||||
BoundsIndexU,
|
|
||||||
BoundsSliceB,
|
|
||||||
BoundsSliceBU,
|
|
||||||
BoundsSlice3C,
|
|
||||||
BoundsSlice3CU:
|
|
||||||
return 2
|
|
||||||
default:
|
|
||||||
panic("bad BoundsKind")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the bounds error code needed by the runtime, and
|
// Returns the bounds error code needed by the runtime, and
|
||||||
// whether the x field is signed.
|
// whether the x field is signed.
|
||||||
func (b BoundsKind) Code() (rtabi.BoundsErrorCode, bool) {
|
func (b BoundsKind) Code() (rtabi.BoundsErrorCode, bool) {
|
||||||
|
|
|
||||||
|
|
@ -184,42 +184,6 @@ func InitConfig() {
|
||||||
BoundsCheckFunc[ssa.BoundsSlice3C] = typecheck.LookupRuntimeFunc("goPanicSlice3C")
|
BoundsCheckFunc[ssa.BoundsSlice3C] = typecheck.LookupRuntimeFunc("goPanicSlice3C")
|
||||||
BoundsCheckFunc[ssa.BoundsSlice3CU] = typecheck.LookupRuntimeFunc("goPanicSlice3CU")
|
BoundsCheckFunc[ssa.BoundsSlice3CU] = typecheck.LookupRuntimeFunc("goPanicSlice3CU")
|
||||||
BoundsCheckFunc[ssa.BoundsConvert] = typecheck.LookupRuntimeFunc("goPanicSliceConvert")
|
BoundsCheckFunc[ssa.BoundsConvert] = typecheck.LookupRuntimeFunc("goPanicSliceConvert")
|
||||||
} else {
|
|
||||||
BoundsCheckFunc[ssa.BoundsIndex] = typecheck.LookupRuntimeFunc("panicIndex")
|
|
||||||
BoundsCheckFunc[ssa.BoundsIndexU] = typecheck.LookupRuntimeFunc("panicIndexU")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSliceAlen] = typecheck.LookupRuntimeFunc("panicSliceAlen")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSliceAlenU] = typecheck.LookupRuntimeFunc("panicSliceAlenU")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSliceAcap] = typecheck.LookupRuntimeFunc("panicSliceAcap")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSliceAcapU] = typecheck.LookupRuntimeFunc("panicSliceAcapU")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSliceB] = typecheck.LookupRuntimeFunc("panicSliceB")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSliceBU] = typecheck.LookupRuntimeFunc("panicSliceBU")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSlice3Alen] = typecheck.LookupRuntimeFunc("panicSlice3Alen")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSlice3AlenU] = typecheck.LookupRuntimeFunc("panicSlice3AlenU")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSlice3Acap] = typecheck.LookupRuntimeFunc("panicSlice3Acap")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSlice3AcapU] = typecheck.LookupRuntimeFunc("panicSlice3AcapU")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSlice3B] = typecheck.LookupRuntimeFunc("panicSlice3B")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSlice3BU] = typecheck.LookupRuntimeFunc("panicSlice3BU")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSlice3C] = typecheck.LookupRuntimeFunc("panicSlice3C")
|
|
||||||
BoundsCheckFunc[ssa.BoundsSlice3CU] = typecheck.LookupRuntimeFunc("panicSlice3CU")
|
|
||||||
BoundsCheckFunc[ssa.BoundsConvert] = typecheck.LookupRuntimeFunc("panicSliceConvert")
|
|
||||||
}
|
|
||||||
if Arch.LinkArch.PtrSize == 4 {
|
|
||||||
ExtendCheckFunc[ssa.BoundsIndex] = typecheck.LookupRuntimeVar("panicExtendIndex")
|
|
||||||
ExtendCheckFunc[ssa.BoundsIndexU] = typecheck.LookupRuntimeVar("panicExtendIndexU")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSliceAlen] = typecheck.LookupRuntimeVar("panicExtendSliceAlen")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSliceAlenU] = typecheck.LookupRuntimeVar("panicExtendSliceAlenU")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSliceAcap] = typecheck.LookupRuntimeVar("panicExtendSliceAcap")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSliceAcapU] = typecheck.LookupRuntimeVar("panicExtendSliceAcapU")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSliceB] = typecheck.LookupRuntimeVar("panicExtendSliceB")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSliceBU] = typecheck.LookupRuntimeVar("panicExtendSliceBU")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSlice3Alen] = typecheck.LookupRuntimeVar("panicExtendSlice3Alen")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSlice3AlenU] = typecheck.LookupRuntimeVar("panicExtendSlice3AlenU")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSlice3Acap] = typecheck.LookupRuntimeVar("panicExtendSlice3Acap")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSlice3AcapU] = typecheck.LookupRuntimeVar("panicExtendSlice3AcapU")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSlice3B] = typecheck.LookupRuntimeVar("panicExtendSlice3B")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSlice3BU] = typecheck.LookupRuntimeVar("panicExtendSlice3BU")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSlice3C] = typecheck.LookupRuntimeVar("panicExtendSlice3C")
|
|
||||||
ExtendCheckFunc[ssa.BoundsSlice3CU] = typecheck.LookupRuntimeVar("panicExtendSlice3CU")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wasm (all asm funcs with special ABIs)
|
// Wasm (all asm funcs with special ABIs)
|
||||||
|
|
@ -7758,7 +7722,4 @@ func SpillSlotAddr(spill ssa.Spill, baseReg int16, extraOffset int64) obj.Addr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var BoundsCheckFunc [ssa.BoundsKindCount]*obj.LSym
|
||||||
BoundsCheckFunc [ssa.BoundsKindCount]*obj.LSym
|
|
||||||
ExtendCheckFunc [ssa.BoundsKindCount]*obj.LSym
|
|
||||||
)
|
|
||||||
|
|
|
||||||
|
|
@ -103,9 +103,8 @@ func panicCheck2(err string) {
|
||||||
// these (they always look like they're called from the runtime).
|
// these (they always look like they're called from the runtime).
|
||||||
// Hence, for these, we just check for clearly bad runtime conditions.
|
// Hence, for these, we just check for clearly bad runtime conditions.
|
||||||
//
|
//
|
||||||
// The panic{Index,Slice} functions are implemented in assembly and tail call
|
// The goPanic{Index,Slice} functions are only used by wasm. All the other architectures
|
||||||
// to the goPanic{Index,Slice} functions below. This is done so we can use
|
// use panic{Bounds,Extend} in assembly, which then call to panicBounds{64,32,32X}.
|
||||||
// a space-minimal register calling convention.
|
|
||||||
|
|
||||||
// failures in the comparisons for s[x], 0 <= x < y (y == len(s))
|
// failures in the comparisons for s[x], 0 <= x < y (y == len(s))
|
||||||
//
|
//
|
||||||
|
|
@ -205,28 +204,10 @@ func goPanicSliceConvert(x int, y int) {
|
||||||
panic(boundsError{x: int64(x), signed: true, y: y, code: abi.BoundsConvert})
|
panic(boundsError{x: int64(x), signed: true, y: y, code: abi.BoundsConvert})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implemented in assembly, as they take arguments in registers.
|
// Implemented in assembly. Declared here to mark them as ABIInternal.
|
||||||
// Declared here to mark them as ABIInternal.
|
|
||||||
func panicIndex(x int, y int)
|
|
||||||
func panicIndexU(x uint, y int)
|
|
||||||
func panicSliceAlen(x int, y int)
|
|
||||||
func panicSliceAlenU(x uint, y int)
|
|
||||||
func panicSliceAcap(x int, y int)
|
|
||||||
func panicSliceAcapU(x uint, y int)
|
|
||||||
func panicSliceB(x int, y int)
|
|
||||||
func panicSliceBU(x uint, y int)
|
|
||||||
func panicSlice3Alen(x int, y int)
|
|
||||||
func panicSlice3AlenU(x uint, y int)
|
|
||||||
func panicSlice3Acap(x int, y int)
|
|
||||||
func panicSlice3AcapU(x uint, y int)
|
|
||||||
func panicSlice3B(x int, y int)
|
|
||||||
func panicSlice3BU(x uint, y int)
|
|
||||||
func panicSlice3C(x int, y int)
|
|
||||||
func panicSlice3CU(x uint, y int)
|
|
||||||
func panicSliceConvert(x int, y int)
|
|
||||||
|
|
||||||
func panicBounds() // in asm_GOARCH.s files, called from generated code
|
func panicBounds() // in asm_GOARCH.s files, called from generated code
|
||||||
func panicExtend() // in asm_GOARCH.s files, called from generated code (on 32-bit archs)
|
func panicExtend() // in asm_GOARCH.s files, called from generated code (on 32-bit archs)
|
||||||
|
|
||||||
func panicBounds64(pc uintptr, regs *[16]int64) { // called from panicBounds on 64-bit archs
|
func panicBounds64(pc uintptr, regs *[16]int64) { // called from panicBounds on 64-bit archs
|
||||||
f := findfunc(pc)
|
f := findfunc(pc)
|
||||||
v := pcdatavalue(f, abi.PCDATA_PanicBounds, pc-1)
|
v := pcdatavalue(f, abi.PCDATA_PanicBounds, pc-1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue