aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/slice.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2018-01-01 21:51:47 -0500
committerAustin Clements <austin@google.com>2018-02-15 21:12:26 +0000
commitd7691d055a7ab39a0d437eb5e20751dc1e339c2a (patch)
tree0ba675a54e6cd9a50345d3040604177c1f550aea /src/runtime/slice.go
parent90666b8a3d5545f4295d9c2517ad607ce5d45e52 (diff)
downloadgo-d7691d055a7ab39a0d437eb5e20751dc1e339c2a.tar.gz
go-d7691d055a7ab39a0d437eb5e20751dc1e339c2a.zip
runtime: replace _MaxMem with maxAlloc
Now that we have memLimit, also having _MaxMem is a bit confusing. Replace it with maxAlloc, which better conveys what it limits. We also define maxAlloc slightly differently: since it's now clear that it limits allocation size, we can account for a subtle difference between 32-bit and 64-bit. Change-Id: Iac39048018cc0dae7f0919e25185fee4b3eed529 Reviewed-on: https://go-review.googlesource.com/85890 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime/slice.go')
-rw-r--r--src/runtime/slice.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/runtime/slice.go b/src/runtime/slice.go
index 351fec067d..9f35a89400 100644
--- a/src/runtime/slice.go
+++ b/src/runtime/slice.go
@@ -25,14 +25,14 @@ type notInHeapSlice struct {
// The index is the size of the slice element.
var maxElems = [...]uintptr{
^uintptr(0),
- _MaxMem / 1, _MaxMem / 2, _MaxMem / 3, _MaxMem / 4,
- _MaxMem / 5, _MaxMem / 6, _MaxMem / 7, _MaxMem / 8,
- _MaxMem / 9, _MaxMem / 10, _MaxMem / 11, _MaxMem / 12,
- _MaxMem / 13, _MaxMem / 14, _MaxMem / 15, _MaxMem / 16,
- _MaxMem / 17, _MaxMem / 18, _MaxMem / 19, _MaxMem / 20,
- _MaxMem / 21, _MaxMem / 22, _MaxMem / 23, _MaxMem / 24,
- _MaxMem / 25, _MaxMem / 26, _MaxMem / 27, _MaxMem / 28,
- _MaxMem / 29, _MaxMem / 30, _MaxMem / 31, _MaxMem / 32,
+ maxAlloc / 1, maxAlloc / 2, maxAlloc / 3, maxAlloc / 4,
+ maxAlloc / 5, maxAlloc / 6, maxAlloc / 7, maxAlloc / 8,
+ maxAlloc / 9, maxAlloc / 10, maxAlloc / 11, maxAlloc / 12,
+ maxAlloc / 13, maxAlloc / 14, maxAlloc / 15, maxAlloc / 16,
+ maxAlloc / 17, maxAlloc / 18, maxAlloc / 19, maxAlloc / 20,
+ maxAlloc / 21, maxAlloc / 22, maxAlloc / 23, maxAlloc / 24,
+ maxAlloc / 25, maxAlloc / 26, maxAlloc / 27, maxAlloc / 28,
+ maxAlloc / 29, maxAlloc / 30, maxAlloc / 31, maxAlloc / 32,
}
// maxSliceCap returns the maximum capacity for a slice.
@@ -40,7 +40,7 @@ func maxSliceCap(elemsize uintptr) uintptr {
if elemsize < uintptr(len(maxElems)) {
return maxElems[elemsize]
}
- return _MaxMem / elemsize
+ return maxAlloc / elemsize
}
func makeslice(et *_type, len, cap int) slice {
@@ -133,13 +133,13 @@ func growslice(et *_type, old slice, cap int) slice {
lenmem = uintptr(old.len)
newlenmem = uintptr(cap)
capmem = roundupsize(uintptr(newcap))
- overflow = uintptr(newcap) > _MaxMem
+ overflow = uintptr(newcap) > maxAlloc
newcap = int(capmem)
case ptrSize:
lenmem = uintptr(old.len) * ptrSize
newlenmem = uintptr(cap) * ptrSize
capmem = roundupsize(uintptr(newcap) * ptrSize)
- overflow = uintptr(newcap) > _MaxMem/ptrSize
+ overflow = uintptr(newcap) > maxAlloc/ptrSize
newcap = int(capmem / ptrSize)
default:
lenmem = uintptr(old.len) * et.size
@@ -163,7 +163,7 @@ func growslice(et *_type, old slice, cap int) slice {
// s = append(s, d, d, d, d)
// print(len(s), "\n")
// }
- if cap < old.cap || overflow || capmem > _MaxMem {
+ if cap < old.cap || overflow || capmem > maxAlloc {
panic(errorString("growslice: cap out of range"))
}