Index: src/heap/mark-compact.cc |
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc |
index 7a4e2f2d03af344b27294e13720bf99cd0664d68..f55a552386db855044a33528362e74ff9b558a81 100644 |
--- a/src/heap/mark-compact.cc |
+++ b/src/heap/mark-compact.cc |
@@ -1641,6 +1641,9 @@ class MarkCompactCollector::EvacuateVisitorBase |
inline bool TryEvacuateObject(PagedSpace* target_space, HeapObject* object, |
HeapObject** target_object) { |
+#ifdef VERIFY_HEAP |
+ if (AbortCompactionForTesting(object)) return false; |
+#endif // VERIFY_HEAP |
int size = object->Size(); |
AllocationAlignment alignment = object->RequiredAlignment(); |
AllocationResult allocation = target_space->AllocateRaw(size, alignment); |
@@ -1698,6 +1701,26 @@ class MarkCompactCollector::EvacuateVisitorBase |
Memory::Address_at(src_addr) = dst_addr; |
} |
+#ifdef VERIFY_HEAP |
+ bool AbortCompactionForTesting(HeapObject* object) { |
+ if (FLAG_stress_compaction) { |
+ const uintptr_t mask = static_cast<uintptr_t>(FLAG_random_seed) & |
+ Page::kPageAlignmentMask & ~kPointerAlignmentMask; |
+ if ((reinterpret_cast<uintptr_t>(object->address()) & |
+ Page::kPageAlignmentMask) == mask) { |
+ Page* page = Page::FromAddress(object->address()); |
+ if (page->IsFlagSet(Page::COMPACTION_WAS_ABORTED_FOR_TESTING)) { |
+ page->ClearFlag(Page::COMPACTION_WAS_ABORTED_FOR_TESTING); |
+ } else { |
+ page->SetFlag(Page::COMPACTION_WAS_ABORTED_FOR_TESTING); |
+ return true; |
+ } |
+ } |
+ } |
+ return false; |
+ } |
+#endif // VERIFY_HEAP |
+ |
Heap* heap_; |
CompactionSpaceCollection* compaction_spaces_; |
bool profiling_; |