2013-01-30 12:19:32 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2013-01-30 12:19:32 +00:00
|
|
|
|
|
|
|
#ifndef V8_SWEEPER_THREAD_H_
|
|
|
|
#define V8_SWEEPER_THREAD_H_
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/atomicops.h"
|
|
|
|
#include "src/flags.h"
|
|
|
|
#include "src/platform.h"
|
|
|
|
#include "src/utils.h"
|
2013-01-30 12:19:32 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/spaces.h"
|
2013-01-30 12:19:32 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/heap.h"
|
2013-01-30 12:19:32 +00:00
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
class SweeperThread : public Thread {
|
|
|
|
public:
|
|
|
|
explicit SweeperThread(Isolate* isolate);
|
2013-09-02 12:26:06 +00:00
|
|
|
~SweeperThread() {}
|
2013-01-30 12:19:32 +00:00
|
|
|
|
|
|
|
void Run();
|
|
|
|
void Stop();
|
|
|
|
void StartSweeping();
|
|
|
|
void WaitForSweeperThread();
|
2014-04-29 14:17:42 +00:00
|
|
|
bool SweepingCompleted();
|
2013-01-30 12:19:32 +00:00
|
|
|
|
2013-11-19 11:52:47 +00:00
|
|
|
static int NumberOfThreads(int max_available);
|
|
|
|
|
2013-01-30 12:19:32 +00:00
|
|
|
private:
|
|
|
|
Isolate* isolate_;
|
|
|
|
Heap* heap_;
|
|
|
|
MarkCompactCollector* collector_;
|
2013-09-02 12:26:06 +00:00
|
|
|
Semaphore start_sweeping_semaphore_;
|
|
|
|
Semaphore end_sweeping_semaphore_;
|
|
|
|
Semaphore stop_semaphore_;
|
2013-01-30 12:19:32 +00:00
|
|
|
volatile AtomicWord stop_thread_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_SWEEPER_THREAD_H_
|