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 ...@@ -67,6 +67,7 @@ MarkCompactCollector::MarkCompactCollector() : // NOLINT
compacting_(false), compacting_(false),
was_marked_incrementally_(false), was_marked_incrementally_(false),
sweeping_pending_(false), sweeping_pending_(false),
sequential_sweeping_(false),
tracer_(NULL), tracer_(NULL),
migration_slots_buffer_(NULL), migration_slots_buffer_(NULL),
heap_(NULL), heap_(NULL),
...@@ -3885,7 +3886,7 @@ void MarkCompactCollector::SweepSpaces() { ...@@ -3885,7 +3886,7 @@ void MarkCompactCollector::SweepSpaces() {
// the map space last because freeing non-live maps overwrites them and // 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 // the other spaces rely on possibly non-live maps to get the sizes for
// non-live objects. // non-live objects.
SequentialSweepingScope scope(this);
SweepSpace(heap()->old_pointer_space(), how_to_sweep); SweepSpace(heap()->old_pointer_space(), how_to_sweep);
SweepSpace(heap()->old_data_space(), how_to_sweep); SweepSpace(heap()->old_data_space(), how_to_sweep);
......
...@@ -692,6 +692,14 @@ class MarkCompactCollector { ...@@ -692,6 +692,14 @@ class MarkCompactCollector {
void FinalizeSweeping(); void FinalizeSweeping();
void set_sequential_sweeping(bool sequential_sweeping) {
sequential_sweeping_ = sequential_sweeping;
}
bool sequential_sweeping() const {
return sequential_sweeping_;
}
// Parallel marking support. // Parallel marking support.
void MarkInParallel(); void MarkInParallel();
...@@ -743,6 +751,8 @@ class MarkCompactCollector { ...@@ -743,6 +751,8 @@ class MarkCompactCollector {
// True if concurrent or parallel sweeping is currently in progress. // True if concurrent or parallel sweeping is currently in progress.
bool sweeping_pending_; bool sweeping_pending_;
bool sequential_sweeping_;
// A pointer to the current stack-allocated GC tracer object during a full // A pointer to the current stack-allocated GC tracer object during a full
// collection (NULL before and after). // collection (NULL before and after).
GCTracer* tracer_; GCTracer* tracer_;
...@@ -898,6 +908,22 @@ class MarkCompactCollector { ...@@ -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); const char* AllocationSpaceName(AllocationSpace space);
} } // namespace v8::internal } } // namespace v8::internal
......
...@@ -2553,9 +2553,11 @@ bool PagedSpace::EnsureSweeperProgress(intptr_t size_in_bytes) { ...@@ -2553,9 +2553,11 @@ bool PagedSpace::EnsureSweeperProgress(intptr_t size_in_bytes) {
if (collector->AreSweeperThreadsActivated()) { if (collector->AreSweeperThreadsActivated()) {
if (collector->IsConcurrentSweepingInProgress()) { if (collector->IsConcurrentSweepingInProgress()) {
if (collector->StealMemoryFromSweeperThreads(this) < size_in_bytes) { if (collector->StealMemoryFromSweeperThreads(this) < size_in_bytes) {
collector->WaitUntilSweepingCompleted(); if (!collector->sequential_sweeping()) {
collector->FinalizeSweeping(); collector->WaitUntilSweepingCompleted();
return true; collector->FinalizeSweeping();
return true;
}
} }
return false; return false;
} }
......
...@@ -1765,9 +1765,9 @@ class PagedSpace : public Space { ...@@ -1765,9 +1765,9 @@ class PagedSpace : public Space {
bool AdvanceSweeper(intptr_t bytes_to_sweep); bool AdvanceSweeper(intptr_t bytes_to_sweep);
// When parallel sweeper threads are active this function waits // When parallel sweeper threads are active and the main thread finished
// for them to complete, otherwise AdvanceSweeper with size_in_bytes // its sweeping phase, this function waits for them to complete, otherwise
// is called. // AdvanceSweeper with size_in_bytes is called.
bool EnsureSweeperProgress(intptr_t size_in_bytes); bool EnsureSweeperProgress(intptr_t size_in_bytes);
bool IsLazySweepingComplete() { 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