Index: Source/platform/heap/ThreadState.cpp |
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp |
index 699866a4516830374b32646ac8351c86a8c97e33..c75b6e0a3c0e9484e21dfa377c484200faa58376 100644 |
--- a/Source/platform/heap/ThreadState.cpp |
+++ b/Source/platform/heap/ThreadState.cpp |
@@ -912,6 +912,7 @@ void ThreadState::preSweep() |
} else { |
// The default behavior is lazy sweeping. |
setGCState(Sweeping); |
+ eagerSweep(); |
scheduleIdleLazySweep(); |
} |
#else |
@@ -926,6 +927,29 @@ void ThreadState::preSweep() |
#endif |
} |
+void ThreadState::eagerSweep() |
+{ |
+ // Some objects need to be finalized promptly and cannot be handled |
+ // by lazy sweeping. Keep those in a designated heap and sweep it |
+ // eagerly. |
+ ASSERT(isSweepingInProgress()); |
+ |
+ // Mirroring the completeSweep() condition; see its comment. |
+ if (sweepForbidden()) |
+ return; |
+ |
+ ThreadState::SweepForbiddenScope scope(this); |
+ { |
+ if (isMainThread()) |
+ ScriptForbiddenScope::enter(); |
+ |
+ m_heaps[EagerSweepHeapIndex]->completeSweep(); |
+ |
+ if (isMainThread()) |
+ ScriptForbiddenScope::exit(); |
+ } |
+} |
+ |
void ThreadState::completeSweep() |
{ |
// If we are not in a sweeping phase, there is nothing to do here. |