Index: src/heap/mark-compact.h |
diff --git a/src/heap/mark-compact.h b/src/heap/mark-compact.h |
index 7203ad05c0eda3e9afb309149d725cc066930191..a13fb9f73e0de3b814f9b27f330d11e5fa57154b 100644 |
--- a/src/heap/mark-compact.h |
+++ b/src/heap/mark-compact.h |
@@ -8,6 +8,7 @@ |
#include <deque> |
#include "src/base/bits.h" |
+#include "src/base/platform/condition-variable.h" |
#include "src/heap/marking.h" |
#include "src/heap/spaces.h" |
#include "src/heap/store-buffer.h" |
@@ -60,7 +61,8 @@ class MarkingDeque { |
bottom_(0), |
mask_(0), |
overflowed_(false), |
- in_use_(false) {} |
+ in_use_(false), |
+ uncommit_task_pending_(false) {} |
void SetUp(); |
void TearDown(); |
@@ -122,12 +124,43 @@ class MarkingDeque { |
void set_top(int top) { top_ = top; } |
private: |
+ class UncommitTask : public v8::Task { |
+ public: |
+ explicit UncommitTask(MarkingDeque* marking_deque) |
+ : marking_deque_(marking_deque) {} |
+ |
+ private: |
+ // v8::Task overrides. |
+ void Run() override { |
+ base::LockGuard<base::Mutex> guard(&marking_deque_->mutex_); |
+ if (!marking_deque_->in_use_) { |
Michael Lippautz
2016/10/24 08:43:23
Can you somewhere document with a comment that in_
ulan
2016/10/24 13:14:09
Done.
|
+ marking_deque_->Uncommit(); |
+ } |
+ marking_deque_->uncommit_task_pending_ = false; |
+ marking_deque_->uncommit_task_barrier_.NotifyOne(); |
+ } |
+ |
+ MarkingDeque* marking_deque_; |
+ DISALLOW_COPY_AND_ASSIGN(UncommitTask); |
+ }; |
+ |
static const size_t kMaxSize = 4 * MB; |
static const size_t kMinSize = 256 * KB; |
+ // Must be called with mutex lock. |
void EnsureCommitted(); |
+ |
+ // Must be called with mutex lock. |
void Uncommit(); |
+ // Must be called with mutex lock. |
+ void StartUncommitTask(); |
+ |
+ void WaitForUncommitTask(); |
+ |
+ base::Mutex mutex_; |
+ base::ConditionVariable uncommit_task_barrier_; |
+ |
base::VirtualMemory* backing_store_; |
size_t backing_store_committed_size_; |
HeapObject** array_; |
@@ -139,6 +172,7 @@ class MarkingDeque { |
int mask_; |
bool overflowed_; |
bool in_use_; |
+ bool uncommit_task_pending_; |
DISALLOW_COPY_AND_ASSIGN(MarkingDeque); |
}; |