From: Keith Randall Date: Thu, 19 Jun 2025 00:09:20 +0000 (-0700) Subject: cmd/compile: remove support for old-style bounds check calls X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=21ab0128b62658ba3e325586f45bb781bee55fda;p=gostls13.git 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 LUCI-TryBot-Result: Go LUCI Reviewed-by: Cuong Manh Le Reviewed-by: Michael Knyszek --- diff --git a/src/cmd/compile/internal/ssa/op.go b/src/cmd/compile/internal/ssa/op.go index d5c7394a26..e8bd5d9acf 100644 --- a/src/cmd/compile/internal/ssa/op.go +++ b/src/cmd/compile/internal/ssa/op.go @@ -485,53 +485,6 @@ const ( 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 // whether the x field is signed. func (b BoundsKind) Code() (rtabi.BoundsErrorCode, bool) { diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index bce94d35f9..72928f267b 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -184,42 +184,6 @@ func InitConfig() { BoundsCheckFunc[ssa.BoundsSlice3C] = typecheck.LookupRuntimeFunc("goPanicSlice3C") BoundsCheckFunc[ssa.BoundsSlice3CU] = typecheck.LookupRuntimeFunc("goPanicSlice3CU") 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) @@ -7758,7 +7722,4 @@ func SpillSlotAddr(spill ssa.Spill, baseReg int16, extraOffset int64) obj.Addr { } } -var ( - BoundsCheckFunc [ssa.BoundsKindCount]*obj.LSym - ExtendCheckFunc [ssa.BoundsKindCount]*obj.LSym -) +var BoundsCheckFunc [ssa.BoundsKindCount]*obj.LSym diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 8f9ab4dd47..8c91c9435a 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -103,9 +103,8 @@ func panicCheck2(err string) { // these (they always look like they're called from the runtime). // Hence, for these, we just check for clearly bad runtime conditions. // -// The panic{Index,Slice} functions are implemented in assembly and tail call -// to the goPanic{Index,Slice} functions below. This is done so we can use -// a space-minimal register calling convention. +// The goPanic{Index,Slice} functions are only used by wasm. All the other architectures +// use panic{Bounds,Extend} in assembly, which then call to panicBounds{64,32,32X}. // 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}) } -// Implemented in assembly, as they take arguments in registers. -// 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) - +// Implemented in assembly. Declared here to mark them as ABIInternal. 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 panicBounds64(pc uintptr, regs *[16]int64) { // called from panicBounds on 64-bit archs f := findfunc(pc) v := pcdatavalue(f, abi.PCDATA_PanicBounds, pc-1)