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

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

Issue 2045263002: [heap] Avoid the use of cells to point from code to new-space objects. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
Index: src/heap/remembered-set.cc
diff --git a/src/heap/remembered-set.cc b/src/heap/remembered-set.cc
index 403c99b05712ec53d2920b40e5ee6ff9e3a2f84c..260f268ccde9bfee03e30a6e9626742d2d5a827e 100644
--- a/src/heap/remembered-set.cc
+++ b/src/heap/remembered-set.cc
@@ -9,6 +9,7 @@
#include "src/heap/slot-set.h"
#include "src/heap/spaces.h"
#include "src/heap/store-buffer.h"
+#include "src/macro-assembler.h"
namespace v8 {
namespace internal {
@@ -16,16 +17,38 @@ 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, chunk](Address addr) {
- Object** slot = reinterpret_cast<Object**>(addr);
- return IsValidSlot(heap, chunk, slot) ? KEEP_SLOT : REMOVE_SLOT;
- });
+ {
+ PageIterator it(heap->old_space());
+ MemoryChunk* chunk;
+ while (it.has_next()) {
+ chunk = it.next();
+ {
+ SlotSet* slots = GetSlotSet(chunk);
+ if (slots != nullptr) {
+ slots->Iterate([heap, chunk](Address addr) {
+ Object** slot = reinterpret_cast<Object**>(addr);
+ return IsValidSlot(heap, chunk, slot) ? KEEP_SLOT : REMOVE_SLOT;
+ });
+ }
+ }
+ }
+ }
+ {
+ PageIterator it(heap->code_space());
+ MemoryChunk* chunk;
+ while (it.has_next()) {
+ chunk = it.next();
+ TypedSlotSet* slots = GetTypedSlotSet(chunk);
+ if (slots != nullptr) {
+ slots->Iterate(
+ [heap, chunk](SlotType type, Address host_addr, Address addr) {
+ if (IsValidTypedSlot(heap, chunk, type, host_addr, addr)) {
ulan 2016/06/08 14:37:00 Just use Marking::IsBlack(Marking::MarkBitFrom(hos
ahaas 2016/06/09 10:34:32 Done.
+ return KEEP_SLOT;
+ } else {
+ return REMOVE_SLOT;
+ }
+ });
+ }
}
}
}
@@ -69,6 +92,51 @@ bool RememberedSet<direction>::IsValidSlot(Heap* heap, MemoryChunk* chunk,
chunk, reinterpret_cast<Address>(slot));
}
+template <PointerDirection direction>
+bool RememberedSet<direction>::IsValidTypedSlot(Heap* heap, MemoryChunk* chunk,
+ SlotType slot_type,
+ Address host_addr,
+ Address slot) {
+ STATIC_ASSERT(direction == OLD_TO_NEW);
+ Object* object;
+ Code* code = reinterpret_cast<Code*>(host_addr);
+ switch (slot_type) {
+ case CODE_TARGET_SLOT: {
+ RelocInfo rinfo(heap->isolate(), slot, RelocInfo::CODE_TARGET, 0, code);
+ object = rinfo.target_object();
+ break;
+ }
+ case CELL_TARGET_SLOT: {
+ RelocInfo rinfo(heap->isolate(), slot, RelocInfo::CELL, 0, code);
+ object = rinfo.target_object();
+ break;
+ }
+ case EMBEDDED_OBJECT_SLOT: {
+ RelocInfo rinfo(heap->isolate(), slot, RelocInfo::EMBEDDED_OBJECT, 0,
+ code);
+ object = rinfo.target_object();
+ break;
+ }
+ case OBJECT_SLOT: {
+ object = *reinterpret_cast<Object**>(slot);
+ break;
+ }
+ default:
+ printf("Slot type: %d\n", slot_type);
+ UNREACHABLE();
+ break;
+ }
+
+ 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)) &&
+ Marking::IsBlack(Marking::MarkBitFrom(host_addr));
+}
+
template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap);
template void RememberedSet<OLD_TO_NEW>::VerifyValidSlots(Heap* heap);
template void RememberedSet<OLD_TO_OLD>::VerifyValidSlots(Heap* heap);

Powered by Google App Engine
This is Rietveld 408576698