aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2025-06-17 14:44:56 -0700
committerKeith Randall <khr@golang.org>2025-07-24 16:03:38 -0700
commit741a19ab4197fb528f8d7f7d8a73d3db3ef99355 (patch)
tree53992c6cf41f09265fd7118a5f0c8f55b92ab188 /src/internal
parentce05ad448fe6ea3b9b33c0eab1143dcb40e3bbc3 (diff)
downloadgo-741a19ab4197fb528f8d7f7d8a73d3db3ef99355.tar.xz
runtime: move bounds check constants to internal/abi
For future use by the compiler. Change-Id: Id3da62006b283ac38008261c0ef88aaf71ef5896 Reviewed-on: https://go-review.googlesource.com/c/go/+/682456 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/abi/bounds.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/internal/abi/bounds.go b/src/internal/abi/bounds.go
new file mode 100644
index 0000000000..2266a5f3c6
--- /dev/null
+++ b/src/internal/abi/bounds.go
@@ -0,0 +1,21 @@
+// Copyright 2025 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package abi
+
+// This type and constants are for encoding different
+// kinds of bounds check failures.
+type BoundsErrorCode uint8
+
+const (
+ BoundsIndex BoundsErrorCode = iota // s[x], 0 <= x < len(s) failed
+ BoundsSliceAlen // s[?:x], 0 <= x <= len(s) failed
+ BoundsSliceAcap // s[?:x], 0 <= x <= cap(s) failed
+ BoundsSliceB // s[x:y], 0 <= x <= y failed (but boundsSliceA didn't happen)
+ BoundsSlice3Alen // s[?:?:x], 0 <= x <= len(s) failed
+ BoundsSlice3Acap // s[?:?:x], 0 <= x <= cap(s) failed
+ BoundsSlice3B // s[?:x:y], 0 <= x <= y failed (but boundsSlice3A didn't happen)
+ BoundsSlice3C // s[x:y:?], 0 <= x <= y failed (but boundsSlice3A/B didn't happen)
+ BoundsConvert // (*[x]T)(s), 0 <= x <= len(s) failed
+)