aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2015-02-23 14:33:56 -0500
committerAustin Clements <austin@google.com>2015-02-23 21:49:27 +0000
commitbceb18e4989aee4971fa1de6bb9f5ba7410d5219 (patch)
treec78dda9248ead2249e015ed4945d3707c209031a /src
parentce137592c0ee5fc262675092c6eea7b71f25850b (diff)
downloadgo-bceb18e4989aee4971fa1de6bb9f5ba7410d5219.tar.xz
runtime: eliminate unnecessary assumption in heapBitsForObject
The slow path of heapBitsForObjects somewhat subtly assumes that the pointer will not point to the first word of the object and will round the pointer wrong if this assumption is violated. This assumption is safe because the fast path should always take care of this case, but there's no benefit to making this assumption, it makes the code more difficult to experiment with than necessary, and it's trivial to eliminate. Change-Id: Iedd336f7d529a27d3abeb83e77dfb32a285ea73a Reviewed-on: https://go-review.googlesource.com/5636 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/runtime/mbitmap.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/runtime/mbitmap.go b/src/runtime/mbitmap.go
index dce0bd59ff..369b5ed218 100644
--- a/src/runtime/mbitmap.go
+++ b/src/runtime/mbitmap.go
@@ -198,7 +198,7 @@ func heapBitsForObject(p uintptr) (base uintptr, hbits heapBits) {
return
}
base = s.base()
- if p-base > s.elemsize {
+ if p-base >= s.elemsize {
base += (p - base) / s.elemsize * s.elemsize
}
if base == p {