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

Unified Diff: src/spaces.cc

Issue 380653003: Allow main thread to contribute to the sweeping phase. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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
Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index 12613c7cb0fc4898d9a5ca172deda517d56a2922..d431407d84a9c69e0c690de9465c1a029a5be0f6 100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -2585,8 +2585,20 @@ HeapObject* PagedSpace::WaitForSweeperThreadsAndRetryAllocation(
int size_in_bytes) {
MarkCompactCollector* collector = heap()->mark_compact_collector();
- // If sweeper threads are still running, wait for them.
if (collector->IsConcurrentSweepingInProgress(this)) {
+ // If sweeping is still in progress try to sweep pages on the main thread.
+ int free_chunk =
+ collector->SweepInParallel<MarkCompactCollector::SWEEP_ON_MAIN_THREAD>(
+ this, size_in_bytes);
+ if (free_chunk >= size_in_bytes) {
+ HeapObject* object = free_list_.Allocate(size_in_bytes);
+ // We should be able to allocate an object here since we just freed that
+ // much memory.
+ ASSERT(object != NULL);
+ if (object != NULL) return object;
+ }
+
+ // Wait for the sweeper threads here and complete the sweeping phase.
collector->WaitUntilSweepingCompleted();
// After waiting for the sweeper threads, there may be new free-list
« src/mark-compact.cc ('K') | « src/mark-compact.cc ('k') | src/sweeper-thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698