mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 11:07:46 +00:00
compiler: special slice bounds check for 64-bit numbers
It is allowed to index with an int64 even on a 32-bit platform, so we have to handle that case. But make sure the normal case isn't penalized by using 32-bit numbers when possible.
This commit is contained in:
@@ -36,6 +36,13 @@ func sliceBoundsCheck(length lenType, low, high uint) {
|
||||
}
|
||||
}
|
||||
|
||||
// Check for bounds in *ssa.Slice. Supports 64-bit indexes.
|
||||
func sliceBoundsCheckLong(length lenType, low, high uint64) {
|
||||
if !(0 <= low && low <= high && high <= uint64(length)) {
|
||||
runtimePanic("slice out of range")
|
||||
}
|
||||
}
|
||||
|
||||
// Check for bounds in *ssa.MakeSlice.
|
||||
func sliceBoundsCheckMake(length, capacity uint) {
|
||||
if !(0 <= length && length <= capacity) {
|
||||
|
||||
Reference in New Issue
Block a user