Commit bceb18e4 authored by Austin Clements's avatar Austin Clements

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/5636Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
parent ce137592
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment