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-05 12:14:47 +00:00
|
|
|
#include "src/base/atomicops.h"
|
2014-06-30 13:25:46 +00:00
|
|
|
#include "src/base/platform/platform.h"
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/flags.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 {
|
|
|
|
|
2014-06-30 13:25:46 +00:00
|
|
|
class SweeperThread : public base::Thread {
|
2013-01-30 12:19:32 +00:00
|
|
|
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_;
|
2014-06-30 13:25:46 +00:00
|
|
|
base::Semaphore start_sweeping_semaphore_;
|
|
|
|
base::Semaphore end_sweeping_semaphore_;
|
|
|
|
base::Semaphore stop_semaphore_;
|
2014-06-05 12:14:47 +00:00
|
|
|
volatile base::AtomicWord stop_thread_;
|
2013-01-30 12:19:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|
|
|
|
|
|
|
|
#endif // V8_SWEEPER_THREAD_H_
|