Bug 949171 - SpiderMonkey: Remove fudge from the RawLengthForBits calculation, and fix Safepoint reading to be ok with this. r=nbp

This commit is contained in:
Dan Gohman 2013-12-13 08:27:47 -08:00
parent 669461f75b
commit 38c1738202
3 changed files with 13 additions and 12 deletions

View File

@ -21,8 +21,10 @@ namespace jit {
class BitSet : private TempObject
{
public:
static const size_t BitsPerWord = 8 * sizeof(uint32_t);
static size_t RawLengthForBits(size_t bits) {
return 1 + bits / (8 * sizeof(uint32_t));
return (bits + BitsPerWord - 1) / BitsPerWord;
}
private:
@ -34,11 +36,11 @@ class BitSet : private TempObject
uint32_t *bits_;
static inline uint32_t bitForValue(unsigned int value) {
return 1l << (uint32_t)(value % (8 * sizeof(uint32_t)));
return 1l << uint32_t(value % BitsPerWord);
}
static inline unsigned int wordForValue(unsigned int value) {
return value / (8 * sizeof(uint32_t));
return value / BitsPerWord;
}
inline unsigned int numWords() const {

View File

@ -374,22 +374,21 @@ SafepointReader::InvalidationPatchPoint(IonScript *script, const SafepointIndex
void
SafepointReader::advanceFromGcRegs()
{
currentSlotChunkNumber_ = 0;
currentSlotChunk_ = stream_.readUnsigned();
currentSlotChunk_ = 0;
nextSlotChunkNumber_ = 0;
}
bool
SafepointReader::getSlotFromBitmap(uint32_t *slot)
{
while (currentSlotChunk_ == 0) {
currentSlotChunkNumber_++;
// Are there any more chunks to read?
if (currentSlotChunkNumber_ == BitSet::RawLengthForBits(frameSlots_))
if (nextSlotChunkNumber_ == BitSet::RawLengthForBits(frameSlots_))
return false;
// Yes, read the next chunk.
currentSlotChunk_ = stream_.readUnsigned();
nextSlotChunkNumber_++;
}
// The current chunk still has bits in it, so get the next bit, then mask
@ -399,7 +398,7 @@ SafepointReader::getSlotFromBitmap(uint32_t *slot)
// Return the slot, taking care to add 1 back in since it was subtracted
// when added in the original bitset.
*slot = (currentSlotChunkNumber_ * sizeof(uint32_t) * 8) + bit + 1;
*slot = ((nextSlotChunkNumber_ - 1) * BitSet::BitsPerWord) + bit + 1;
return true;
}
@ -416,8 +415,8 @@ void
SafepointReader::advanceFromGcSlots()
{
// No, reset the counter.
currentSlotChunkNumber_ = 0;
currentSlotChunk_ = stream_.readUnsigned();
currentSlotChunk_ = 0;
nextSlotChunkNumber_ = 0;
}
bool

View File

@ -61,7 +61,7 @@ class SafepointReader
CompactBufferReader stream_;
uint32_t frameSlots_;
uint32_t currentSlotChunk_;
uint32_t currentSlotChunkNumber_;
uint32_t nextSlotChunkNumber_;
uint32_t osiCallPointOffset_;
GeneralRegisterSet gcSpills_;
GeneralRegisterSet valueSpills_;