aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/malloc.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/malloc.go')
-rw-r--r--src/runtime/malloc.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index 86fdb3fdbb..ec4939f1dd 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -491,14 +491,13 @@ var zerobase uintptr
// Otherwise it returns 0.
func (c *mcache) nextFreeFast(sizeclass int8) gclinkptr {
s := c.alloc[sizeclass]
- ctzIndex := uint8(s.allocCache)
- if ctzIndex != 0 {
- theBit := uint64(ctzVals[ctzIndex])
- freeidx := s.freeindex // help the pre ssa compiler out here with cse.
- result := freeidx + uintptr(theBit)
+
+ theBit := sys.Ctz64(s.allocCache) // Is there a free object in the allocCache?
+ if theBit < 64 {
+ result := s.freeindex + uintptr(theBit)
if result < s.nelems {
s.allocCache >>= (theBit + 1)
- freeidx = result + 1
+ freeidx := result + 1
if freeidx%64 == 0 && freeidx != s.nelems {
// We just incremented s.freeindex so it isn't 0
// so we are moving to the next aCache.