]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: enable more address bits on macOS/ARM64
authorCherry Zhang <cherryyz@google.com>
Thu, 17 Sep 2020 14:53:10 +0000 (10:53 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 6 Oct 2020 21:55:21 +0000 (21:55 +0000)
Apparently macOS/ARM64 has 47-bit addresses, instead of 33-bit as
on ios/ARM64. Enable more address bits.

Updates #38485.

Change-Id: I8aa64ba22a3933e3d9c4fffd17d902b5f31c30e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/256918
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/malloc.go
src/runtime/mpagealloc_32bit.go
src/runtime/mpagealloc_64bit.go

index c71f856f09883befcce02967d8e4f3c8b0f5ef64..f7e9b7c4b48058dd638cfac888d3cd6b89fe32f0 100644 (file)
@@ -198,7 +198,7 @@ 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
+       // On ios/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
@@ -207,7 +207,7 @@ const (
        // arenaBaseOffset to offset into the top 4 GiB.
        //
        // WebAssembly currently has a limit of 4GB linear memory.
-       heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-(sys.GoosDarwin+sys.GoosIos)*sys.GoarchArm64))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 33*(sys.GoosDarwin+sys.GoosIos)*sys.GoarchArm64
+       heapAddrBits = (_64bit*(1-sys.GoarchWasm)*(1-sys.GoosIos*sys.GoarchArm64))*48 + (1-_64bit+sys.GoarchWasm)*(32-(sys.GoarchMips+sys.GoarchMipsle)) + 33*sys.GoosIos*sys.GoarchArm64
 
        // maxAlloc is the maximum size of an allocation. On 64-bit,
        // it's theoretically possible to allocate 1<<heapAddrBits bytes. On
@@ -514,14 +514,14 @@ func mallocinit() {
                // However, on arm64, we ignore all this advice above and slam the
                // allocation at 0x40 << 32 because when using 4k pages with 3-level
                // translation buffers, the user address space is limited to 39 bits
-               // On darwin/arm64, the address space is even smaller.
+               // On ios/arm64, the address space is even smaller.
                //
                // On AIX, mmaps starts at 0x0A00000000000000 for 64-bit.
                // processes.
                for i := 0x7f; i >= 0; i-- {
                        var p uintptr
                        switch {
-                       case GOARCH == "arm64" && (GOOS == "darwin" || GOOS == "ios"):
+                       case GOARCH == "arm64" && GOOS == "ios":
                                p = uintptr(i)<<40 | uintptrMask&(0x0013<<28)
                        case GOARCH == "arm64":
                                p = uintptr(i)<<40 | uintptrMask&(0x0040<<32)
index 6658a900aca33ca2b5aeda687dea410dff7b4777..90f1e54d6cb0154b519c400930fa4dc79ca7f92a 100644 (file)
@@ -2,14 +2,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build 386 arm mips mipsle wasm darwin,arm64
+// +build 386 arm mips mipsle wasm ios,arm64
 
 // wasm is a treated as a 32-bit architecture for the purposes of the page
 // allocator, even though it has 64-bit pointers. This is because any wasm
 // pointer always has its top 32 bits as zero, so the effective heap address
 // space is only 2^32 bytes in size (see heapAddrBits).
 
-// darwin/arm64 is treated as a 32-bit architecture for the purposes of the
+// ios/arm64 is treated as a 32-bit architecture for the purposes of the
 // page allocator, even though it has 64-bit pointers and a 33-bit address
 // space (see heapAddrBits). The 33 bit address space cannot be rounded up
 // to 64 bits because there are too many summary levels to fit in just 33
index 831626e4b2e2bae3521ba86e432c1595e207cf3a..a1691ba8025c88a044eba25ac39f4c2c21b5b6ab 100644 (file)
@@ -2,9 +2,9 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build amd64 !darwin,arm64 mips64 mips64le ppc64 ppc64le riscv64 s390x
+// +build amd64 !ios,arm64 mips64 mips64le ppc64 ppc64le riscv64 s390x
 
-// See mpagealloc_32bit.go for why darwin/arm64 is excluded here.
+// See mpagealloc_32bit.go for why ios/arm64 is excluded here.
 
 package runtime