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

Unified Diff: src/heap/remembered-set.cc

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.h ('k') | src/heap/slot-set.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/remembered-set.cc
diff --git a/src/heap/remembered-set.cc b/src/heap/remembered-set.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d9d59142737ef85c429355cd52029b30b2b5005d
--- /dev/null
+++ b/src/heap/remembered-set.cc
@@ -0,0 +1,69 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/heap/remembered-set.h"
+#include "src/heap/heap-inl.h"
+#include "src/heap/heap.h"
+#include "src/heap/mark-compact.h"
+#include "src/heap/slot-set.h"
+#include "src/heap/spaces.h"
+#include "src/heap/store-buffer.h"
+
+namespace v8 {
+namespace internal {
+
+template <PointerDirection direction>
+void RememberedSet<direction>::ClearInvalidSlots(Heap* heap) {
+ STATIC_ASSERT(direction == OLD_TO_NEW);
+ PageIterator it(heap->old_space());
+ MemoryChunk* chunk;
+ while (it.has_next()) {
+ chunk = it.next();
+ SlotSet* slots = GetSlotSet(chunk);
+ if (slots != nullptr) {
+ slots->Iterate([heap](Address addr) {
+ Object** slot = reinterpret_cast<Object**>(addr);
+ return IsValidSlot(heap, slot) ? SlotSet::KEEP_SLOT
+ : SlotSet::REMOVE_SLOT;
+ });
+ }
+ }
+}
+
+template <PointerDirection direction>
+void RememberedSet<direction>::VerifyValidSlots(Heap* heap) {
+ STATIC_ASSERT(direction == OLD_TO_NEW);
+ Iterate(heap, [heap](Address addr) {
+ Object** slot = reinterpret_cast<Object**>(addr);
+ Object* object = *slot;
+ if (Page::FromAddress(addr)->owner() != nullptr &&
+ Page::FromAddress(addr)->owner()->identity() == OLD_SPACE) {
+ CHECK(IsValidSlot(heap, slot));
+ heap->mark_compact_collector()->VerifyIsSlotInLiveObject(
+ reinterpret_cast<Address>(slot), HeapObject::cast(object));
+ }
+ return SlotSet::KEEP_SLOT;
+ });
+}
+
+template <PointerDirection direction>
+bool RememberedSet<direction>::IsValidSlot(Heap* heap, Object** slot) {
+ STATIC_ASSERT(direction == OLD_TO_NEW);
+ Object* object = *slot;
+ if (!heap->InNewSpace(object)) {
+ return false;
+ }
+ HeapObject* heap_object = HeapObject::cast(object);
+ // If the target object is not black, the source slot must be part
+ // of a non-black (dead) object.
+ return Marking::IsBlack(Marking::MarkBitFrom(heap_object)) &&
+ heap->mark_compact_collector()->IsSlotInLiveObject(
+ reinterpret_cast<Address>(slot));
+}
+
+template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap);
+template void RememberedSet<OLD_TO_NEW>::VerifyValidSlots(Heap* heap);
+
+} // namespace internal
+} // namespace v8
« no previous file with comments | « src/heap/remembered-set.h ('k') | src/heap/slot-set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698