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

Unified Diff: src/heap/marking.h

Issue 2160613002: [heap] Remove black pages and use black areas instead. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: disable black allocation Created 4 years, 5 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
Index: src/heap/marking.h
diff --git a/src/heap/marking.h b/src/heap/marking.h
index 6acea526555682b98a2012ecac798c418170424e..b53f1119b793891ecfa75130e0e6903e32de68b0 100644
--- a/src/heap/marking.h
+++ b/src/heap/marking.h
@@ -106,8 +106,48 @@ class Bitmap {
for (int i = 0; i < CellsCount(); i++) cells()[i] = 0;
}
- void SetAllBits() {
- for (int i = 0; i < CellsCount(); i++) cells()[i] = 0xffffffff;
+ void SetRange(uint32_t start_index, uint32_t end_index) {
ulan 2016/07/19 13:23:32 Let's add a comment describing that it sets bits i
Hannes Payer (out of office) 2016/07/19 14:42:53 Done.
+ unsigned int start_cell_index = start_index >> Bitmap::kBitsPerCellLog2;
+ MarkBit::CellType start_index_mask = 1u << Bitmap::IndexInCell(start_index);
+
+ unsigned int end_cell_index = end_index >> Bitmap::kBitsPerCellLog2;
+ MarkBit::CellType end_index_mask = 1u << Bitmap::IndexInCell(end_index);
+
+ if (start_cell_index != end_cell_index) {
+ // Firstly, fill all bits from the start address to the end of the first
+ // cell with 1s.
+ cells()[start_cell_index] |= ~(start_index_mask - 1);
+ // Then fill all in between cells with 1s.
+ for (unsigned int i = start_cell_index + 1; i < end_cell_index; i++) {
+ cells()[i] = ~0u;
+ }
+ // Finally, fill all bits until the end address in the last cell with 1s.
+ cells()[end_cell_index] |= (end_index_mask - 1);
+ } else {
+ cells()[start_cell_index] |= end_index_mask - start_index_mask;
+ }
+ }
+
+ void ClearRange(uint32_t start_index, uint32_t end_index) {
+ unsigned int start_cell_index = start_index >> Bitmap::kBitsPerCellLog2;
+ MarkBit::CellType start_index_mask = 1u << Bitmap::IndexInCell(start_index);
+
+ unsigned int end_cell_index = end_index >> Bitmap::kBitsPerCellLog2;
+ MarkBit::CellType end_index_mask = 1u << Bitmap::IndexInCell(end_index);
+
+ if (start_cell_index != end_cell_index) {
+ // Firstly, fill all bits from the start address to the end of the first
+ // cell with 0s.
+ cells()[start_cell_index] &= (start_index_mask - 1);
+ // Then fill all in between cells with 0s.
+ for (unsigned int i = start_cell_index + 1; i < end_cell_index; i++) {
+ cells()[i] = 0;
+ }
+ // Finally, set all bits until the end address in the last cell with 0s.
+ cells()[end_cell_index] &= ~(end_index_mask - 1);
+ } else {
+ cells()[start_cell_index] &= ~(end_index_mask - start_index_mask);
+ }
}
static void PrintWord(uint32_t word, uint32_t himask = 0) {
@@ -175,23 +215,6 @@ 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), 0u);
- 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;
- }
};
class Marking : public AllStatic {

Powered by Google App Engine
This is Rietveld 408576698