compacting_(false),
was_marked_incrementally_(false),
sweeping_pending_(false),
+ sequential_sweeping_(false),
tracer_(NULL),
migration_slots_buffer_(NULL),
heap_(NULL),
// 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);
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();
// 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_;
};
+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
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;
}
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() {