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

Unified Diff: src/heap/slot-set.h

Issue 1683653002: Add a generic remembered set class. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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/remembered-set.cc ('k') | src/heap/spaces.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/slot-set.h
diff --git a/src/heap/slot-set.h b/src/heap/slot-set.h
index 65151e8e2f4a7a405c6118746575e1fc42ff1600..9b154e5cbcc3714521dc50458c8c2526e91275f0 100644
--- a/src/heap/slot-set.h
+++ b/src/heap/slot-set.h
@@ -111,6 +111,7 @@ class SlotSet : public Malloced {
// Iterate over all slots in the set and for each slot invoke the callback.
// If the callback returns REMOVE_SLOT then the slot is removed from the set.
+ // Returns the new number of slots.
//
// Sample usage:
// Iterate([](Address slot_address) {
@@ -118,10 +119,11 @@ class SlotSet : public Malloced {
// else return REMOVE_SLOT;
// });
template <typename Callback>
- void Iterate(Callback callback) {
+ int Iterate(Callback callback) {
+ int new_count = 0;
for (int bucket_index = 0; bucket_index < kBuckets; bucket_index++) {
if (bucket[bucket_index] != nullptr) {
- bool bucket_is_empty = true;
+ int in_bucket_count = 0;
uint32_t* current_bucket = bucket[bucket_index];
int cell_offset = bucket_index * kBitsPerBucket;
for (int i = 0; i < kCellsPerBucket; i++, cell_offset += kBitsPerCell) {
@@ -134,7 +136,7 @@ class SlotSet : public Malloced {
uint32_t bit_mask = 1u << bit_offset;
uint32_t slot = (cell_offset + bit_offset) << kPointerSizeLog2;
if (callback(page_start_ + slot) == KEEP_SLOT) {
- bucket_is_empty = false;
+ ++in_bucket_count;
} else {
new_cell ^= bit_mask;
}
@@ -145,11 +147,13 @@ class SlotSet : public Malloced {
}
}
}
- if (bucket_is_empty) {
+ if (in_bucket_count == 0) {
ReleaseBucket(bucket_index);
}
+ new_count += in_bucket_count;
}
}
+ return new_count;
}
private:
« no previous file with comments | « src/heap/remembered-set.cc ('k') | src/heap/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698