Index: Source/platform/heap/ThreadState.cpp |
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp |
index 90421079cecaaf7ecf0b5030bc839390d1bd024c..d5bcbb76c8146c6f6ba0b2dd05b863229c73e492 100644 |
--- a/Source/platform/heap/ThreadState.cpp |
+++ b/Source/platform/heap/ThreadState.cpp |
@@ -916,22 +916,25 @@ void ThreadState::preSweep() |
} |
#if defined(ADDRESS_SANITIZER) |
-// TODO(Oilpan): enable the poisoning always. |
-#if ENABLE(OILPAN) |
- for (int i = 0; i < NumberOfHeaps; i++) |
- m_heaps[i]->poisonUnmarkedObjects(); |
-#endif |
+ poisonEagerHeap(SetPoison); |
#endif |
#if ENABLE_LAZY_SWEEPING |
if (gcState() == EagerSweepScheduled) { |
// Eager sweeping should happen only in testing. |
setGCState(Sweeping); |
+ eagerSweep(); |
+#if defined(ADDRESS_SANITIZER) |
+ poisonAllHeaps(); |
+#endif |
completeSweep(); |
} else { |
// The default behavior is lazy sweeping. |
setGCState(Sweeping); |
eagerSweep(); |
+#if defined(ADDRESS_SANITIZER) |
+ poisonAllHeaps(); |
+#endif |
scheduleIdleLazySweep(); |
} |
#else |
@@ -944,6 +947,28 @@ void ThreadState::preSweep() |
#endif |
} |
+#if defined(ADDRESS_SANITIZER) |
+void ThreadState::poisonAllHeaps() |
+{ |
+ // TODO(Oilpan): enable the poisoning always. |
+#if ENABLE(OILPAN) |
+ // Unpoison the live objects remaining in the eager heaps.. |
+ poisonEagerHeap(ClearPoison); |
+ // ..along with poisoning all unmarked objects in the other heaps. |
+ for (int i = 1; i < NumberOfHeaps; i++) |
+ m_heaps[i]->poisonUnmarkedObjects(); |
+#endif |
+} |
+ |
+void ThreadState::poisonEagerHeap(Poisoning poisoning) |
+{ |
+ // TODO(Oilpan): enable the poisoning always. |
+#if ENABLE(OILPAN) |
+ m_heaps[EagerSweepHeapIndex]->poisonHeap(poisoning); |
+#endif |
+} |
+#endif |
+ |
void ThreadState::eagerSweep() |
{ |
// Some objects need to be finalized promptly and cannot be handled |
@@ -987,6 +1012,7 @@ void ThreadState::completeSweep() |
TRACE_EVENT0("blink_gc", "ThreadState::completeSweep"); |
double timeStamp = WTF::currentTimeMS(); |
+ static_assert(EagerSweepHeapIndex == 0, "Eagerly swept heaps must be processed first."); |
for (int i = 0; i < NumberOfHeaps; i++) |
m_heaps[i]->completeSweep(); |