void RelocInfo::Visit(ObjectVisitor* visitor) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- visitor->VisitPointer(target_object_address());
+ visitor->VisitEmbeddedPointer(host(), target_object_address());
} else if (RelocInfo::IsCodeTarget(mode)) {
visitor->VisitCodeTarget(this);
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
void RelocInfo::Visit(Heap* heap) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- StaticVisitor::VisitPointer(heap, target_object_address());
+ StaticVisitor::VisitEmbeddedPointer(heap, host(), target_object_address());
} else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(heap, this);
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
void RelocInfo::Visit(ObjectVisitor* visitor) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- visitor->VisitPointer(target_object_address());
+ visitor->VisitEmbeddedPointer(host(), target_object_address());
CPU::FlushICache(pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) {
visitor->VisitCodeTarget(this);
void RelocInfo::Visit(Heap* heap) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- StaticVisitor::VisitPointer(heap, target_object_address());
+ StaticVisitor::VisitEmbeddedPointer(heap, host(), target_object_address());
CPU::FlushICache(pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(heap, this);
incremental_marking_(incremental_marking) {
}
+ void VisitEmbeddedPointer(Code* host, Object** p) {
+ Object* obj = *p;
+ if (obj->NonFailureIsHeapObject()) {
+ heap_->mark_compact_collector()->RecordSlot(
+ reinterpret_cast<Object**>(host),
+ p,
+ obj);
+ MarkObject(obj);
+ }
+ }
+
void VisitCodeTarget(RelocInfo* rinfo) {
ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
void IncrementalMarking::SetOldSpacePageFlags(MemoryChunk* chunk,
- bool is_marking) {
+ bool is_marking,
+ bool is_compacting) {
if (is_marking) {
chunk->SetFlag(MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING);
chunk->SetFlag(MemoryChunk::POINTERS_FROM_HERE_ARE_INTERESTING);
+
+ // It's difficult to filter out slots recorded for large objects.
+ if (chunk->owner()->identity() == LO_SPACE &&
+ chunk->size() > static_cast<size_t>(Page::kPageSize) &&
+ is_compacting) {
+ chunk->SetFlag(MemoryChunk::RESCAN_ON_EVACUATION);
+ }
} else if (chunk->owner()->identity() == CELL_SPACE ||
chunk->scan_on_scavenge()) {
chunk->ClearFlag(MemoryChunk::POINTERS_TO_HERE_ARE_INTERESTING);
PageIterator it(space);
while (it.has_next()) {
Page* p = it.next();
- SetOldSpacePageFlags(p, false);
+ SetOldSpacePageFlags(p, false, false);
}
}
LargePage* lop = heap_->lo_space()->first_page();
while (lop->is_valid()) {
- SetOldSpacePageFlags(lop, false);
+ SetOldSpacePageFlags(lop, false, false);
lop = lop->next_page();
}
}
PageIterator it(space);
while (it.has_next()) {
Page* p = it.next();
- SetOldSpacePageFlags(p, true);
+ SetOldSpacePageFlags(p, true, is_compacting_);
}
}
LargePage* lop = heap_->lo_space()->first_page();
while (lop->is_valid()) {
- SetOldSpacePageFlags(lop, true);
+ SetOldSpacePageFlags(lop, true, is_compacting_);
lop = lop->next_page();
}
}
MarkObjectGreyDoNotEnqueue(heap_->polymorphic_code_cache());
}
- if (is_compacting_) {
- // It's difficult to filter out slots recorded for large objects.
- LargeObjectIterator it(heap_->lo_space());
- for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) {
- if (obj->IsFixedArray() || obj->IsCode()) {
- Page* p = Page::FromAddress(obj->address());
- if (p->size() > static_cast<size_t>(Page::kPageSize)) {
- p->SetFlag(Page::RESCAN_ON_EVACUATION);
- }
- }
- }
- }
-
// Mark strong roots grey.
IncrementalMarkingRootMarkingVisitor visitor(heap_, this);
heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG);
}
inline void SetOldSpacePageFlags(MemoryChunk* chunk) {
- SetOldSpacePageFlags(chunk, IsMarking());
+ SetOldSpacePageFlags(chunk, IsMarking(), IsCompacting());
}
inline void SetNewSpacePageFlags(NewSpacePage* chunk) {
void StartMarking();
- static void ActivateIncrementalWriteBarrier(PagedSpace* space);
+ void ActivateIncrementalWriteBarrier(PagedSpace* space);
static void ActivateIncrementalWriteBarrier(NewSpace* space);
void ActivateIncrementalWriteBarrier();
static void DeactivateIncrementalWriteBarrierForSpace(NewSpace* space);
void DeactivateIncrementalWriteBarrier();
- static void SetOldSpacePageFlags(MemoryChunk* chunk, bool is_marking);
+ static void SetOldSpacePageFlags(MemoryChunk* chunk,
+ bool is_marking,
+ bool is_compacting);
+
static void SetNewSpacePageFlags(NewSpacePage* chunk, bool is_marking);
void EnsureMarkingDequeIsCommitted();
heap->mark_compact_collector()->MarkObject(cell, mark);
}
+ static inline void VisitEmbeddedPointer(Heap* heap, Code* host, Object** p) {
+ MarkObjectByPointer(heap->mark_compact_collector(),
+ reinterpret_cast<Object**>(host),
+ p);
+ }
+
static inline void VisitCodeTarget(Heap* heap, RelocInfo* rinfo) {
ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
for (Object** p = start; p < end; p++) UpdatePointer(p);
}
+ void VisitEmbeddedPointer(Code* host, Object** p) {
+ UpdatePointer(p);
+ }
+
void VisitCodeTarget(RelocInfo* rinfo) {
ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
if (mode == RelocInfo::EMBEDDED_OBJECT) {
Object** p = target_object_address();
Object* orig = *p;
- visitor->VisitPointer(p);
+ visitor->VisitEmbeddedPointer(host(), p);
if (*p != orig) {
set_target_object(*p);
}
void RelocInfo::Visit(Heap* heap) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- StaticVisitor::VisitPointer(heap, target_object_address());
+ StaticVisitor::VisitEmbeddedPointer(heap, host(), target_object_address());
} else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(heap, this);
} else if (mode == RelocInfo::GLOBAL_PROPERTY_CELL) {
// Handy shorthand for visiting a single pointer.
virtual void VisitPointer(Object** p) { VisitPointers(p, p + 1); }
+ // Visit pointer embedded into a code object.
+ virtual void VisitEmbeddedPointer(Code* host, Object** p) {
+ // Default implementation for the convenience of users that do
+ // not care about the host object.
+ VisitPointer(p);
+ }
+
// Visits a contiguous arrays of external references (references to the C++
// heap) in the half-open range [start, end). Any or all of the values
// may be modified on return.
void RelocInfo::Visit(ObjectVisitor* visitor) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- visitor->VisitPointer(target_object_address());
+ visitor->VisitEmbeddedPointer(host(), target_object_address());
CPU::FlushICache(pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) {
visitor->VisitCodeTarget(this);
void RelocInfo::Visit(Heap* heap) {
RelocInfo::Mode mode = rmode();
if (mode == RelocInfo::EMBEDDED_OBJECT) {
- StaticVisitor::VisitPointer(heap, target_object_address());
+ StaticVisitor::VisitEmbeddedPointer(heap, host(), target_object_address());
CPU::FlushICache(pc_, sizeof(Address));
} else if (RelocInfo::IsCodeTarget(mode)) {
StaticVisitor::VisitCodeTarget(heap, this);