Skip to content

Commit 21ab012

Browse files
committed
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 <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cuong Manh Le <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent 802d056 commit 21ab012

File tree

3 files changed

+5
-110
lines changed

3 files changed

+5
-110
lines changed

src/cmd/compile/internal/ssa/op.go

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -485,53 +485,6 @@ const (
485485
BoundsKindCount
486486
)
487487

488-
// boundsABI determines which register arguments a bounds check call should use. For an [a:b:c] slice, we do:
489-
//
490-
// CMPQ c, cap
491-
// JA fail1
492-
// CMPQ b, c
493-
// JA fail2
494-
// CMPQ a, b
495-
// JA fail3
496-
//
497-
// fail1: CALL panicSlice3Acap (c, cap)
498-
// fail2: CALL panicSlice3B (b, c)
499-
// fail3: CALL panicSlice3C (a, b)
500-
//
501-
// When we register allocate that code, we want the same register to be used for
502-
// the first arg of panicSlice3Acap and the second arg to panicSlice3B. That way,
503-
// initializing that register once will satisfy both calls.
504-
// That desire ends up dividing the set of bounds check calls into 3 sets. This function
505-
// determines which set to use for a given panic call.
506-
// The first arg for set 0 should be the second arg for set 1.
507-
// The first arg for set 1 should be the second arg for set 2.
508-
func boundsABI(b int64) int {
509-
switch BoundsKind(b) {
510-
case BoundsSlice3Alen,
511-
BoundsSlice3AlenU,
512-
BoundsSlice3Acap,
513-
BoundsSlice3AcapU,
514-
BoundsConvert:
515-
return 0
516-
case BoundsSliceAlen,
517-
BoundsSliceAlenU,
518-
BoundsSliceAcap,
519-
BoundsSliceAcapU,
520-
BoundsSlice3B,
521-
BoundsSlice3BU:
522-
return 1
523-
case BoundsIndex,
524-
BoundsIndexU,
525-
BoundsSliceB,
526-
BoundsSliceBU,
527-
BoundsSlice3C,
528-
BoundsSlice3CU:
529-
return 2
530-
default:
531-
panic("bad BoundsKind")
532-
}
533-
}
534-
535488
// Returns the bounds error code needed by the runtime, and
536489
// whether the x field is signed.
537490
func (b BoundsKind) Code() (rtabi.BoundsErrorCode, bool) {

src/cmd/compile/internal/ssagen/ssa.go

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -184,42 +184,6 @@ func InitConfig() {
184184
BoundsCheckFunc[ssa.BoundsSlice3C] = typecheck.LookupRuntimeFunc("goPanicSlice3C")
185185
BoundsCheckFunc[ssa.BoundsSlice3CU] = typecheck.LookupRuntimeFunc("goPanicSlice3CU")
186186
BoundsCheckFunc[ssa.BoundsConvert] = typecheck.LookupRuntimeFunc("goPanicSliceConvert")
187-
} else {
188-
BoundsCheckFunc[ssa.BoundsIndex] = typecheck.LookupRuntimeFunc("panicIndex")
189-
BoundsCheckFunc[ssa.BoundsIndexU] = typecheck.LookupRuntimeFunc("panicIndexU")
190-
BoundsCheckFunc[ssa.BoundsSliceAlen] = typecheck.LookupRuntimeFunc("panicSliceAlen")
191-
BoundsCheckFunc[ssa.BoundsSliceAlenU] = typecheck.LookupRuntimeFunc("panicSliceAlenU")
192-
BoundsCheckFunc[ssa.BoundsSliceAcap] = typecheck.LookupRuntimeFunc("panicSliceAcap")
193-
BoundsCheckFunc[ssa.BoundsSliceAcapU] = typecheck.LookupRuntimeFunc("panicSliceAcapU")
194-
BoundsCheckFunc[ssa.BoundsSliceB] = typecheck.LookupRuntimeFunc("panicSliceB")
195-
BoundsCheckFunc[ssa.BoundsSliceBU] = typecheck.LookupRuntimeFunc("panicSliceBU")
196-
BoundsCheckFunc[ssa.BoundsSlice3Alen] = typecheck.LookupRuntimeFunc("panicSlice3Alen")
197-
BoundsCheckFunc[ssa.BoundsSlice3AlenU] = typecheck.LookupRuntimeFunc("panicSlice3AlenU")
198-
BoundsCheckFunc[ssa.BoundsSlice3Acap] = typecheck.LookupRuntimeFunc("panicSlice3Acap")
199-
BoundsCheckFunc[ssa.BoundsSlice3AcapU] = typecheck.LookupRuntimeFunc("panicSlice3AcapU")
200-
BoundsCheckFunc[ssa.BoundsSlice3B] = typecheck.LookupRuntimeFunc("panicSlice3B")
201-
BoundsCheckFunc[ssa.BoundsSlice3BU] = typecheck.LookupRuntimeFunc("panicSlice3BU")
202-
BoundsCheckFunc[ssa.BoundsSlice3C] = typecheck.LookupRuntimeFunc("panicSlice3C")
203-
BoundsCheckFunc[ssa.BoundsSlice3CU] = typecheck.LookupRuntimeFunc("panicSlice3CU")
204-
BoundsCheckFunc[ssa.BoundsConvert] = typecheck.LookupRuntimeFunc("panicSliceConvert")
205-
}
206-
if Arch.LinkArch.PtrSize == 4 {
207-
ExtendCheckFunc[ssa.BoundsIndex] = typecheck.LookupRuntimeVar("panicExtendIndex")
208-
ExtendCheckFunc[ssa.BoundsIndexU] = typecheck.LookupRuntimeVar("panicExtendIndexU")
209-
ExtendCheckFunc[ssa.BoundsSliceAlen] = typecheck.LookupRuntimeVar("panicExtendSliceAlen")
210-
ExtendCheckFunc[ssa.BoundsSliceAlenU] = typecheck.LookupRuntimeVar("panicExtendSliceAlenU")
211-
ExtendCheckFunc[ssa.BoundsSliceAcap] = typecheck.LookupRuntimeVar("panicExtendSliceAcap")
212-
ExtendCheckFunc[ssa.BoundsSliceAcapU] = typecheck.LookupRuntimeVar("panicExtendSliceAcapU")
213-
ExtendCheckFunc[ssa.BoundsSliceB] = typecheck.LookupRuntimeVar("panicExtendSliceB")
214-
ExtendCheckFunc[ssa.BoundsSliceBU] = typecheck.LookupRuntimeVar("panicExtendSliceBU")
215-
ExtendCheckFunc[ssa.BoundsSlice3Alen] = typecheck.LookupRuntimeVar("panicExtendSlice3Alen")
216-
ExtendCheckFunc[ssa.BoundsSlice3AlenU] = typecheck.LookupRuntimeVar("panicExtendSlice3AlenU")
217-
ExtendCheckFunc[ssa.BoundsSlice3Acap] = typecheck.LookupRuntimeVar("panicExtendSlice3Acap")
218-
ExtendCheckFunc[ssa.BoundsSlice3AcapU] = typecheck.LookupRuntimeVar("panicExtendSlice3AcapU")
219-
ExtendCheckFunc[ssa.BoundsSlice3B] = typecheck.LookupRuntimeVar("panicExtendSlice3B")
220-
ExtendCheckFunc[ssa.BoundsSlice3BU] = typecheck.LookupRuntimeVar("panicExtendSlice3BU")
221-
ExtendCheckFunc[ssa.BoundsSlice3C] = typecheck.LookupRuntimeVar("panicExtendSlice3C")
222-
ExtendCheckFunc[ssa.BoundsSlice3CU] = typecheck.LookupRuntimeVar("panicExtendSlice3CU")
223187
}
224188

225189
// Wasm (all asm funcs with special ABIs)
@@ -7758,7 +7722,4 @@ func SpillSlotAddr(spill ssa.Spill, baseReg int16, extraOffset int64) obj.Addr {
77587722
}
77597723
}
77607724

7761-
var (
7762-
BoundsCheckFunc [ssa.BoundsKindCount]*obj.LSym
7763-
ExtendCheckFunc [ssa.BoundsKindCount]*obj.LSym
7764-
)
7725+
var BoundsCheckFunc [ssa.BoundsKindCount]*obj.LSym

src/runtime/panic.go

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,8 @@ func panicCheck2(err string) {
103103
// these (they always look like they're called from the runtime).
104104
// Hence, for these, we just check for clearly bad runtime conditions.
105105
//
106-
// The panic{Index,Slice} functions are implemented in assembly and tail call
107-
// to the goPanic{Index,Slice} functions below. This is done so we can use
108-
// a space-minimal register calling convention.
106+
// The goPanic{Index,Slice} functions are only used by wasm. All the other architectures
107+
// use panic{Bounds,Extend} in assembly, which then call to panicBounds{64,32,32X}.
109108

110109
// failures in the comparisons for s[x], 0 <= x < y (y == len(s))
111110
//
@@ -205,28 +204,10 @@ func goPanicSliceConvert(x int, y int) {
205204
panic(boundsError{x: int64(x), signed: true, y: y, code: abi.BoundsConvert})
206205
}
207206

208-
// Implemented in assembly, as they take arguments in registers.
209-
// Declared here to mark them as ABIInternal.
210-
func panicIndex(x int, y int)
211-
func panicIndexU(x uint, y int)
212-
func panicSliceAlen(x int, y int)
213-
func panicSliceAlenU(x uint, y int)
214-
func panicSliceAcap(x int, y int)
215-
func panicSliceAcapU(x uint, y int)
216-
func panicSliceB(x int, y int)
217-
func panicSliceBU(x uint, y int)
218-
func panicSlice3Alen(x int, y int)
219-
func panicSlice3AlenU(x uint, y int)
220-
func panicSlice3Acap(x int, y int)
221-
func panicSlice3AcapU(x uint, y int)
222-
func panicSlice3B(x int, y int)
223-
func panicSlice3BU(x uint, y int)
224-
func panicSlice3C(x int, y int)
225-
func panicSlice3CU(x uint, y int)
226-
func panicSliceConvert(x int, y int)
227-
207+
// Implemented in assembly. Declared here to mark them as ABIInternal.
228208
func panicBounds() // in asm_GOARCH.s files, called from generated code
229209
func panicExtend() // in asm_GOARCH.s files, called from generated code (on 32-bit archs)
210+
230211
func panicBounds64(pc uintptr, regs *[16]int64) { // called from panicBounds on 64-bit archs
231212
f := findfunc(pc)
232213
v := pcdatavalue(f, abi.PCDATA_PanicBounds, pc-1)

0 commit comments

Comments
 (0)