-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Closed
Labels
Milestone
Description
While investigating the optimizations performed by my prove CL 196679, I found out these two instances of what looks like dead code:
Lines 726 to 734 in d99fe1f
| j, searchIdx := s.chunkOf(ci).find(npages, 0) | |
| if j < 0 { | |
| // We couldn't find any space in this chunk despite the summaries telling | |
| // us it should be there. There's likely a bug, so dump some state and throw. | |
| sum := s.summary[len(s.summary)-1][i] | |
| print("runtime: summary[", len(s.summary)-1, "][", i, "] = (", sum.start(), ", ", sum.max(), ", ", sum.end(), ")\n") | |
| print("runtime: npages = ", npages, "\n") | |
| throw("bad summary data") | |
| } |
Lines 768 to 773 in d99fe1f
| j, searchIdx := s.chunkOf(i).find(npages, chunkPageIndex(s.searchAddr)) | |
| if j < 0 { | |
| print("runtime: max = ", max, ", npages = ", npages, "\n") | |
| print("runtime: searchIdx = ", chunkPageIndex(s.searchAddr), ", s.searchAddr = ", hex(s.searchAddr), "\n") | |
| throw("bad summary data") | |
| } |
That branch is never taken because pallocBits.find() return an unsigned number:
Lines 197 to 206 in d99fe1f
| // find searches for npages contiguous free pages in pallocBits and returns | |
| // the index where that run starts, as well as the index of the first free page | |
| // it found in the search. searchIdx represents the first known free page and | |
| // where to begin the search from. | |
| // | |
| // If find fails to find any free space, it returns an index of ^uint(0) and | |
| // the new searchIdx should be ignored. | |
| // | |
| // Note that if npages == 1, the two returned values will always be identical. | |
| func (b *pallocBits) find(npages uintptr, searchIdx uint) (uint, uint) { |
Given the documentation, it looks like the failure is reported as ^uint(0) so the above checks are probably wrong.
/cc @aclements @mknyszek