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

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

Issue 2025833002: [heap] Store the host address in the typed remembered set. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase. Created 4 years, 6 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.h ('k') | test/unittests/heap/slot-set-unittest.cc » ('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 1ed2b39b391cbf5c1b542e98f9d91926f6ce86d3..2fac50f9c61f4c33b7aa5874277aaef48cfca5ed 100644
--- a/src/heap/slot-set.h
+++ b/src/heap/slot-set.h
@@ -233,7 +233,30 @@ enum SlotType {
// typed slots contain V8 internal pointers that are not directly exposed to JS.
class TypedSlotSet {
public:
- typedef uint32_t TypedSlot;
+ struct TypedSlot {
+ TypedSlot() : type_and_offset_(0), host_offset_(0) {}
+
+ TypedSlot(SlotType type, uint32_t host_offset, uint32_t offset)
+ : type_and_offset_(TypeField::encode(type) |
+ OffsetField::encode(offset)),
+ host_offset_(host_offset) {}
+
+ bool operator==(const TypedSlot other) {
+ return type_and_offset_ == other.type_and_offset_ &&
+ host_offset_ == other.host_offset_;
+ }
+
+ bool operator!=(const TypedSlot other) { return !(*this == other); }
+
+ SlotType type() { return TypeField::decode(type_and_offset_); }
+
+ uint32_t offset() { return OffsetField::decode(type_and_offset_); }
+
+ uint32_t host_offset() { return host_offset_; }
+
+ uint32_t type_and_offset_;
+ uint32_t host_offset_;
+ };
static const int kMaxOffset = 1 << 29;
explicit TypedSlotSet(Address page_start) : page_start_(page_start) {
@@ -250,8 +273,8 @@ class TypedSlotSet {
}
// The slot offset specifies a slot at address page_start_ + offset.
- void Insert(SlotType type, int offset) {
- TypedSlot slot = ToTypedSlot(type, offset);
+ void Insert(SlotType type, uint32_t host_offset, uint32_t offset) {
+ TypedSlot slot(type, host_offset, offset);
if (!chunk_->AddSlot(slot)) {
chunk_ = new Chunk(chunk_, NextCapacity(chunk_->capacity));
bool added = chunk_->AddSlot(slot);
@@ -272,7 +295,7 @@ class TypedSlotSet {
template <typename Callback>
int Iterate(Callback callback) {
STATIC_ASSERT(NUMBER_OF_SLOT_TYPES < 8);
- const TypedSlot kRemovedSlot = TypeField::encode(NUMBER_OF_SLOT_TYPES);
+ const TypedSlot kRemovedSlot(NUMBER_OF_SLOT_TYPES, 0, 0);
Chunk* chunk = chunk_;
int new_count = 0;
while (chunk != nullptr) {
@@ -281,9 +304,10 @@ class TypedSlotSet {
for (int i = 0; i < count; i++) {
TypedSlot slot = buffer[i];
if (slot != kRemovedSlot) {
- SlotType type = TypeField::decode(slot);
- Address addr = page_start_ + OffsetField::decode(slot);
- if (callback(type, addr) == KEEP_SLOT) {
+ SlotType type = slot.type();
+ Address addr = page_start_ + slot.offset();
+ Address host_addr = page_start_ + slot.host_offset();
+ if (callback(type, host_addr, addr) == KEEP_SLOT) {
new_count++;
} else {
buffer[i] = kRemovedSlot;
@@ -303,10 +327,6 @@ class TypedSlotSet {
return Min(kMaxBufferSize, capacity * 2);
}
- static TypedSlot ToTypedSlot(SlotType type, int offset) {
- return TypeField::encode(type) | OffsetField::encode(offset);
- }
-
class OffsetField : public BitField<int, 0, 29> {};
class TypeField : public BitField<SlotType, 29, 3> {};
« no previous file with comments | « src/heap/remembered-set.h ('k') | test/unittests/heap/slot-set-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698