github.com/guyezi/gofrontend@v0.0.0-20200228202240-7a62a49e62c0/libgo/go/runtime/panic32.go (about)

     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  
     5  package runtime
     6  
     7  import _ "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))
    32  func goPanicExtendIndex(x int64, y int) {
    33  	panicCheck1(getcallerpc(), "index out of range")
    34  	panic(boundsError{x: x, signed: true, y: y, code: boundsIndex})
    35  }
    36  func 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))
    42  func 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  }
    46  func 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  }
    50  func 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  }
    54  func 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
    60  func 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  }
    64  func 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))
    70  func 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  }
    74  func 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  }
    78  func 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  }
    82  func 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
    88  func 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  }
    92  func 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
    98  func 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  }
   102  func 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  }