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

Unified Diff: src/heap/mark-compact.cc

Issue 2019343002: [heap] Simulate aborting compaction during --stress-compaction (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comment Created 4 years, 7 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 | « no previous file | src/heap/spaces.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_;
« no previous file with comments | « no previous file | src/heap/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698