Chromium Code Reviews| Index: src/heap/spaces.h |
| diff --git a/src/heap/spaces.h b/src/heap/spaces.h |
| index 5647a520f585b72b0ba30baa243716b5a46f5f58..87d1ae5be0ff8defbaddbe07168017b0a690092f 100644 |
| --- a/src/heap/spaces.h |
| +++ b/src/heap/spaces.h |
| @@ -165,6 +165,10 @@ class Bitmap { |
| return index >> kBitsPerCellLog2; |
| } |
| + V8_INLINE static uint32_t IndexInCell(uint32_t index) { |
| + return index & kBitIndexMask; |
| + } |
| + |
| INLINE(static uint32_t CellToIndex(uint32_t index)) { |
| return index << kBitsPerCellLog2; |
| } |
| @@ -184,7 +188,7 @@ class Bitmap { |
| } |
| inline MarkBit MarkBitFromIndex(uint32_t index) { |
| - MarkBit::CellType mask = 1 << (index & kBitIndexMask); |
| + MarkBit::CellType mask = 1u << IndexInCell(index); |
| MarkBit::CellType* cell = this->cells() + (index >> kBitsPerCellLog2); |
| return MarkBit(cell, mask); |
| } |
| @@ -256,6 +260,23 @@ class Bitmap { |
| } |
| return true; |
| } |
| + |
| + // Clears all bits starting from {cell_base_index} up to and excluding |
| + // {index}. Note that the start will be cell aligned, while the end can |
| + // be any index following {cell_base_index}. |
| + void ClearTillIndex(uint32_t cell_base_index, uint32_t index) { |
|
ulan
2015/10/08 12:43:14
Let's assert that cell_base_index is aligned.
Michael Lippautz
2015/10/08 12:57:51
Done.
|
| + DCHECK_GE(index, cell_base_index); |
| + uint32_t start_cell_index = IndexToCell(cell_base_index); |
| + uint32_t end_cell_index = IndexToCell(index); |
| + DCHECK_GE(end_cell_index, start_cell_index); |
| + // Clear all cells till the cell containing the last index. |
| + for (uint32_t i = start_cell_index; i < end_cell_index; i++) { |
| + cells()[i] = 0; |
| + } |
| + // Clear all bits in the last cell till the last bit before index. |
| + uint32_t clear_mask = ~((1u << IndexInCell(index)) - 1); |
| + cells()[end_cell_index] &= clear_mask; |
| + } |
| }; |