Commit e9eaa181 authored by Rick Hudson's avatar Rick Hudson

[dev.garbage] runtime: simplify nextFreeFast so it is inlined

nextFreeFast is currently not inlined by the compiler due
to its size and complexity. This CL simplifies
nextFreeFast by letting the slow path handle (nextFree)
handle a corner cases.

Change-Id: Ia9c5d1a7912bcb4bec072f5fd240f0e0bafb20e4
Reviewed-on: https://go-review.googlesource.com/22598Reviewed-by: default avatarAustin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
parent b3579c09
...@@ -495,14 +495,11 @@ func nextFreeFast(s *mspan) gclinkptr { ...@@ -495,14 +495,11 @@ func nextFreeFast(s *mspan) gclinkptr {
if theBit < 64 { if theBit < 64 {
result := s.freeindex + uintptr(theBit) result := s.freeindex + uintptr(theBit)
if result < s.nelems { if result < s.nelems {
s.allocCache >>= (theBit + 1)
freeidx := result + 1 freeidx := result + 1
if freeidx%64 == 0 && freeidx != s.nelems { if freeidx%64 == 0 && freeidx != s.nelems {
// We just incremented s.freeindex so it isn't 0 return 0
// so we are moving to the next aCache.
whichByte := freeidx / 8
s.refillAllocCache(whichByte)
} }
s.allocCache >>= (theBit + 1)
s.freeindex = freeidx s.freeindex = freeidx
v := gclinkptr(result*s.elemsize + s.base()) v := gclinkptr(result*s.elemsize + s.base())
s.allocCount++ s.allocCount++
......
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