1// Copyright 2019 The Go Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style 3// license that can be found in the LICENSE file. 4 5package runtime 6 7import _ "unsafe" // for go:linkname 8 9// For gccgo, use go:linkname to export compiler-called functions. 10// 11//go:linkname goPanicExtendIndex 12//go:linkname goPanicExtendIndexU 13//go:linkname goPanicExtendSliceAlen 14//go:linkname goPanicExtendSliceAlenU 15//go:linkname goPanicExtendSliceAcap 16//go:linkname goPanicExtendSliceAcapU 17//go:linkname goPanicExtendSliceB 18//go:linkname goPanicExtendSliceBU 19//go:linkname goPanicExtendSlice3Alen 20//go:linkname goPanicExtendSlice3AlenU 21//go:linkname goPanicExtendSlice3Acap 22//go:linkname goPanicExtendSlice3AcapU 23//go:linkname goPanicExtendSlice3B 24//go:linkname goPanicExtendSlice3BU 25//go:linkname goPanicExtendSlice3C 26//go:linkname goPanicExtendSlice3CU 27 28// Additional index/slice error paths for 32-bit platforms. 29// Used when the high word of a 64-bit index is not zero. 30 31// failures in the comparisons for s[x], 0 <= x < y (y == len(s)) 32func goPanicExtendIndex(x int64, y int) { 33 panicCheck1(getcallerpc(), "index out of range") 34 panic(boundsError{x: x, signed: true, y: y, code: boundsIndex}) 35} 36func goPanicExtendIndexU(x uint64, y int) { 37 panicCheck1(getcallerpc(), "index out of range") 38 panic(boundsError{x: int64(x), signed: false, y: y, code: boundsIndex}) 39} 40 41// failures in the comparisons for s[:x], 0 <= x <= y (y == len(s) or cap(s)) 42func goPanicExtendSliceAlen(x int64, y int) { 43 panicCheck1(getcallerpc(), "slice bounds out of range") 44 panic(boundsError{x: x, signed: true, y: y, code: boundsSliceAlen}) 45} 46func goPanicExtendSliceAlenU(x uint64, y int) { 47 panicCheck1(getcallerpc(), "slice bounds out of range") 48 panic(boundsError{x: int64(x), signed: false, y: y, code: boundsSliceAlen}) 49} 50func goPanicExtendSliceAcap(x int64, y int) { 51 panicCheck1(getcallerpc(), "slice bounds out of range") 52 panic(boundsError{x: x, signed: true, y: y, code: boundsSliceAcap}) 53} 54func goPanicExtendSliceAcapU(x uint64, y int) { 55 panicCheck1(getcallerpc(), "slice bounds out of range") 56 panic(boundsError{x: int64(x), signed: false, y: y, code: boundsSliceAcap}) 57} 58 59// failures in the comparisons for s[x:y], 0 <= x <= y 60func goPanicExtendSliceB(x int64, y int) { 61 panicCheck1(getcallerpc(), "slice bounds out of range") 62 panic(boundsError{x: x, signed: true, y: y, code: boundsSliceB}) 63} 64func goPanicExtendSliceBU(x uint64, y int) { 65 panicCheck1(getcallerpc(), "slice bounds out of range") 66 panic(boundsError{x: int64(x), signed: false, y: y, code: boundsSliceB}) 67} 68 69// failures in the comparisons for s[::x], 0 <= x <= y (y == len(s) or cap(s)) 70func goPanicExtendSlice3Alen(x int64, y int) { 71 panicCheck1(getcallerpc(), "slice bounds out of range") 72 panic(boundsError{x: x, signed: true, y: y, code: boundsSlice3Alen}) 73} 74func goPanicExtendSlice3AlenU(x uint64, y int) { 75 panicCheck1(getcallerpc(), "slice bounds out of range") 76 panic(boundsError{x: int64(x), signed: false, y: y, code: boundsSlice3Alen}) 77} 78func goPanicExtendSlice3Acap(x int64, y int) { 79 panicCheck1(getcallerpc(), "slice bounds out of range") 80 panic(boundsError{x: x, signed: true, y: y, code: boundsSlice3Acap}) 81} 82func goPanicExtendSlice3AcapU(x uint64, y int) { 83 panicCheck1(getcallerpc(), "slice bounds out of range") 84 panic(boundsError{x: int64(x), signed: false, y: y, code: boundsSlice3Acap}) 85} 86 87// failures in the comparisons for s[:x:y], 0 <= x <= y 88func goPanicExtendSlice3B(x int64, y int) { 89 panicCheck1(getcallerpc(), "slice bounds out of range") 90 panic(boundsError{x: x, signed: true, y: y, code: boundsSlice3B}) 91} 92func goPanicExtendSlice3BU(x uint64, y int) { 93 panicCheck1(getcallerpc(), "slice bounds out of range") 94 panic(boundsError{x: int64(x), signed: false, y: y, code: boundsSlice3B}) 95} 96 97// failures in the comparisons for s[x:y:], 0 <= x <= y 98func goPanicExtendSlice3C(x int64, y int) { 99 panicCheck1(getcallerpc(), "slice bounds out of range") 100 panic(boundsError{x: x, signed: true, y: y, code: boundsSlice3C}) 101} 102func goPanicExtendSlice3CU(x uint64, y int) { 103 panicCheck1(getcallerpc(), "slice bounds out of range") 104 panic(boundsError{x: int64(x), signed: false, y: y, code: boundsSlice3C}) 105} 106