Commit 80195113 authored by hpayer@chromium.org's avatar hpayer@chromium.org

Wait for sweeper threads in EnsureSweeperProgress() only if the main thread...

Wait for sweeper threads in EnsureSweeperProgress() only if the main thread finished its sweeping phase.

BUG=

Review URL: https://codereview.chromium.org/12462002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13830 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 29e6b443
......@@ -67,6 +67,7 @@ MarkCompactCollector::MarkCompactCollector() : // NOLINT
compacting_(false),
was_marked_incrementally_(false),
sweeping_pending_(false),
sequential_sweeping_(false),
tracer_(NULL),
migration_slots_buffer_(NULL),
heap_(NULL),
......@@ -3885,7 +3886,7 @@ void MarkCompactCollector::SweepSpaces() {
// the map space last because freeing non-live maps overwrites them and
// the other spaces rely on possibly non-live maps to get the sizes for
// non-live objects.
SequentialSweepingScope scope(this);
SweepSpace(heap()->old_pointer_space(), how_to_sweep);
SweepSpace(heap()->old_data_space(), how_to_sweep);
......
......@@ -692,6 +692,14 @@ class MarkCompactCollector {
void FinalizeSweeping();
void set_sequential_sweeping(bool sequential_sweeping) {
sequential_sweeping_ = sequential_sweeping;
}
bool sequential_sweeping() const {
return sequential_sweeping_;
}
// Parallel marking support.
void MarkInParallel();
......@@ -743,6 +751,8 @@ class MarkCompactCollector {
// True if concurrent or parallel sweeping is currently in progress.
bool sweeping_pending_;
bool sequential_sweeping_;
// A pointer to the current stack-allocated GC tracer object during a full
// collection (NULL before and after).
GCTracer* tracer_;
......@@ -898,6 +908,22 @@ class MarkCompactCollector {
};
class SequentialSweepingScope BASE_EMBEDDED {
public:
explicit SequentialSweepingScope(MarkCompactCollector *collector) :
collector_(collector) {
collector_->set_sequential_sweeping(true);
}
~SequentialSweepingScope() {
collector_->set_sequential_sweeping(false);
}
private:
MarkCompactCollector* collector_;
};
const char* AllocationSpaceName(AllocationSpace space);
} } // namespace v8::internal
......
......@@ -2553,9 +2553,11 @@ bool PagedSpace::EnsureSweeperProgress(intptr_t size_in_bytes) {
if (collector->AreSweeperThreadsActivated()) {
if (collector->IsConcurrentSweepingInProgress()) {
if (collector->StealMemoryFromSweeperThreads(this) < size_in_bytes) {
collector->WaitUntilSweepingCompleted();
collector->FinalizeSweeping();
return true;
if (!collector->sequential_sweeping()) {
collector->WaitUntilSweepingCompleted();
collector->FinalizeSweeping();
return true;
}
}
return false;
}
......
......@@ -1765,9 +1765,9 @@ class PagedSpace : public Space {
bool AdvanceSweeper(intptr_t bytes_to_sweep);
// When parallel sweeper threads are active this function waits
// for them to complete, otherwise AdvanceSweeper with size_in_bytes
// is called.
// When parallel sweeper threads are active and the main thread finished
// its sweeping phase, this function waits for them to complete, otherwise
// AdvanceSweeper with size_in_bytes is called.
bool EnsureSweeperProgress(intptr_t size_in_bytes);
bool IsLazySweepingComplete() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment