Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1229)

Unified Diff: src/heap/spaces.h

Issue 1393293002: [heap] Fix mark bits for partially compacted pages. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compilation Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/mark-compact.cc ('k') | test/unittests/heap/bitmap-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index 5647a520f585b72b0ba30baa243716b5a46f5f58..03ec2d4defba92d27239a5d30fb859835643daad 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 {cell_base_index} is required to be cell aligned.
+ void ClearRange(uint32_t cell_base_index, uint32_t index) {
+ DCHECK_EQ(IndexInCell(cell_base_index), 0);
+ 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;
+ }
};
« no previous file with comments | « src/heap/mark-compact.cc ('k') | test/unittests/heap/bitmap-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698