aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/malloc.go
diff options
context:
space:
mode:
authorCherry Zhang <cherryyz@google.com>2020-10-29 15:50:53 -0400
committerCherry Zhang <cherryyz@google.com>2020-10-30 01:31:10 +0000
commitf7e26467b4e7ee0bb3219c26e71292ff4aac7da9 (patch)
tree2a8fba91ecc7b74ef977b2d0f4aa466317ec838e /src/runtime/malloc.go
parente62adb1c0b8e7ca49eefc70389fbb9f739d6e32c (diff)
downloadgo-f7e26467b4e7ee0bb3219c26e71292ff4aac7da9.tar.gz
go-f7e26467b4e7ee0bb3219c26e71292ff4aac7da9.zip
runtime: allocate at desired address when race detector is on
Currently, on all supported platforms, the race detector (LLVM TSAN) expects the Go heap is at 0xc000000000 - 0xe000000000. Move the raceenabled condition first, so we always allocate there. This means on Linux/ARM64 when race detector is on we will allocate to 0xc000000000 - 0xe000000000, instead of 0x4000000000. The old address is meant for 39-bit VMA. But the race detector only supports 48-bit VMA anyway. So this is fine. Change-Id: I51ac8eff68297b37c8c651a93145cc94f83a939d Reviewed-on: https://go-review.googlesource.com/c/go/+/266372 Trust: Cherry Zhang <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/malloc.go')
-rw-r--r--src/runtime/malloc.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index d0b8c668c3..0563f49d17 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -521,6 +521,14 @@ func mallocinit() {
for i := 0x7f; i >= 0; i-- {
var p uintptr
switch {
+ case raceenabled:
+ // The TSAN runtime requires the heap
+ // to be in the range [0x00c000000000,
+ // 0x00e000000000).
+ p = uintptr(i)<<32 | uintptrMask&(0x00c0<<32)
+ if p >= uintptrMask&0x00e000000000 {
+ continue
+ }
case GOARCH == "arm64" && GOOS == "ios":
p = uintptr(i)<<40 | uintptrMask&(0x0013<<28)
case GOARCH == "arm64":
@@ -532,14 +540,6 @@ func mallocinit() {
continue
}
p = uintptr(i)<<40 | uintptrMask&(0xa0<<52)
- case raceenabled:
- // The TSAN runtime requires the heap
- // to be in the range [0x00c000000000,
- // 0x00e000000000).
- p = uintptr(i)<<32 | uintptrMask&(0x00c0<<32)
- if p >= uintptrMask&0x00e000000000 {
- continue
- }
default:
p = uintptr(i)<<40 | uintptrMask&(0x00c0<<32)
}