diff options
| author | Austin Clements <austin@google.com> | 2015-11-16 15:31:50 -0500 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2015-11-16 22:07:41 +0000 |
| commit | 4d39bb6a3a06a7690242559113b7434591e97cbf (patch) | |
| tree | 51c87a9cf540272999d52a22bb1c30d8a437ef28 /src/runtime/malloc.go | |
| parent | 835c83b40dd9b94b51180898551b313a92892ffd (diff) | |
| download | go-4d39bb6a3a06a7690242559113b7434591e97cbf.tar.xz | |
runtime: make mcache.tiny a uintptr
mcache.tiny is in non-GC'd memory, but points to heap memory. As a
result, there may or may not be write barriers when writing to
mcache.tiny. Make it clearer that funny things are going on by making
mcache.tiny a uintptr instead of an unsafe.Pointer.
Change-Id: I732a5b7ea17162f196a9155154bbaff8d4d00eac
Reviewed-on: https://go-review.googlesource.com/16963
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Diffstat (limited to 'src/runtime/malloc.go')
| -rw-r--r-- | src/runtime/malloc.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go index d9f52399b8..ad1123be96 100644 --- a/src/runtime/malloc.go +++ b/src/runtime/malloc.go @@ -589,9 +589,9 @@ func mallocgc(size uintptr, typ *_type, flags uint32) unsafe.Pointer { } else if size&1 == 0 { off = round(off, 2) } - if off+size <= maxTinySize && c.tiny != nil { + if off+size <= maxTinySize && c.tiny != 0 { // The object fits into existing tiny block. - x = add(c.tiny, off) + x = unsafe.Pointer(c.tiny + off) c.tinyoffset = off + size c.local_tinyallocs++ mp.mallocing = 0 @@ -618,8 +618,8 @@ func mallocgc(size uintptr, typ *_type, flags uint32) unsafe.Pointer { (*[2]uint64)(x)[1] = 0 // See if we need to replace the existing tiny block with the new one // based on amount of remaining free space. - if size < c.tinyoffset || c.tiny == nil { - c.tiny = x + if size < c.tinyoffset || c.tiny == 0 { + c.tiny = uintptr(x) c.tinyoffset = size } size = maxTinySize |
