aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2019-11-06 23:56:03 +0000
committerMichael Knyszek <mknyszek@google.com>2019-11-07 02:33:31 +0000
commit198f0452b0292eb245bb5122510b1dfd0050dacc (patch)
tree05be04599e2c045b66fe9110826e10d8d8dd0700 /src/runtime
parente3a7d6c29757fd81c753b0e6267936c839e972c3 (diff)
downloadgo-198f0452b0292eb245bb5122510b1dfd0050dacc.tar.xz
runtime: define darwin/arm64's address space as 33 bits
On iOS, the address space is not 48 bits as one might believe, since it's arm64 hardware. In fact, all pointers are truncated to 33 bits, and the OS only gives applications access to the range [1<<32, 2<<32). While today this has no effect on the Go runtime, future changes which care about address space size need this to be correct. Updates #35112. Change-Id: Id518a2298080f7e3d31cf7d909506a37748cc49a Reviewed-on: https://go-review.googlesource.com/c/go/+/205758 Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/malloc.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index 854609220d..1f82dbd124 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -206,8 +206,16 @@ const (
// mips32 only has access to the low 2GB of virtual memory, so
// we further limit it to 31 bits.
//
+ // On darwin/arm64, although 64-bit pointers are presumably
+ // available, pointers are truncated to 33 bits. Furthermore,
+ // only the top 4 GiB of the address space are actually available
+ // to the application, but we allow the whole 33 bits anyway for
+ // simplicity.
+ // TODO(mknyszek): Consider limiting it to 32 bits and using
+ // arenaBaseOffset to offset into the top 4 GiB.
+ //
// WebAssembly currently has a limit of 4GB linear memory.
- heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosAix))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 60*sys.GoosAix
+ heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosAix)*(1-sys.GoosDarwin*sys.GoarchArm64))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 60*sys.GoosAix + 33*sys.GoosDarwin*sys.GoarchArm64
// maxAlloc is the maximum size of an allocation. On 64-bit,
// it's theoretically possible to allocate 1<<heapAddrBits bytes. On