Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: src/heap/mark-compact.h

Issue 2442443003: [heap] Uncommit marking deque in concurrent task. (Closed)
Patch Set: x Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/heap/mark-compact.cc » ('j') | src/heap/mark-compact.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_HEAP_MARK_COMPACT_H_ 5 #ifndef V8_HEAP_MARK_COMPACT_H_
6 #define V8_HEAP_MARK_COMPACT_H_ 6 #define V8_HEAP_MARK_COMPACT_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
11 #include "src/base/platform/condition-variable.h"
11 #include "src/heap/marking.h" 12 #include "src/heap/marking.h"
12 #include "src/heap/spaces.h" 13 #include "src/heap/spaces.h"
13 #include "src/heap/store-buffer.h" 14 #include "src/heap/store-buffer.h"
14 15
15 namespace v8 { 16 namespace v8 {
16 namespace internal { 17 namespace internal {
17 18
18 // Callback function, returns whether an object is alive. The heap size 19 // Callback function, returns whether an object is alive. The heap size
19 // of the object is returned in size. It optionally updates the offset 20 // of the object is returned in size. It optionally updates the offset
20 // to the first live object in the page (only used for old and map objects). 21 // to the first live object in the page (only used for old and map objects).
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 class MarkingDeque { 54 class MarkingDeque {
54 public: 55 public:
55 MarkingDeque() 56 MarkingDeque()
56 : backing_store_(nullptr), 57 : backing_store_(nullptr),
57 backing_store_committed_size_(0), 58 backing_store_committed_size_(0),
58 array_(nullptr), 59 array_(nullptr),
59 top_(0), 60 top_(0),
60 bottom_(0), 61 bottom_(0),
61 mask_(0), 62 mask_(0),
62 overflowed_(false), 63 overflowed_(false),
63 in_use_(false) {} 64 in_use_(false),
65 uncommit_task_pending_(false) {}
64 66
65 void SetUp(); 67 void SetUp();
66 void TearDown(); 68 void TearDown();
67 69
68 void StartUsing(); 70 void StartUsing();
69 void StopUsing(); 71 void StopUsing();
70 void Clear(); 72 void Clear();
71 73
72 inline bool IsFull() { return ((top_ + 1) & mask_) == bottom_; } 74 inline bool IsFull() { return ((top_ + 1) & mask_) == bottom_; }
73 75
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 } 117 }
116 } 118 }
117 119
118 HeapObject** array() { return array_; } 120 HeapObject** array() { return array_; }
119 int bottom() { return bottom_; } 121 int bottom() { return bottom_; }
120 int top() { return top_; } 122 int top() { return top_; }
121 int mask() { return mask_; } 123 int mask() { return mask_; }
122 void set_top(int top) { top_ = top; } 124 void set_top(int top) { top_ = top; }
123 125
124 private: 126 private:
127 class UncommitTask : public v8::Task {
128 public:
129 explicit UncommitTask(MarkingDeque* marking_deque)
130 : marking_deque_(marking_deque) {}
131
132 private:
133 // v8::Task overrides.
134 void Run() override {
135 base::LockGuard<base::Mutex> guard(&marking_deque_->mutex_);
136 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.
137 marking_deque_->Uncommit();
138 }
139 marking_deque_->uncommit_task_pending_ = false;
140 marking_deque_->uncommit_task_barrier_.NotifyOne();
141 }
142
143 MarkingDeque* marking_deque_;
144 DISALLOW_COPY_AND_ASSIGN(UncommitTask);
145 };
146
125 static const size_t kMaxSize = 4 * MB; 147 static const size_t kMaxSize = 4 * MB;
126 static const size_t kMinSize = 256 * KB; 148 static const size_t kMinSize = 256 * KB;
127 149
150 // Must be called with mutex lock.
128 void EnsureCommitted(); 151 void EnsureCommitted();
152
153 // Must be called with mutex lock.
129 void Uncommit(); 154 void Uncommit();
130 155
156 // Must be called with mutex lock.
157 void StartUncommitTask();
158
159 void WaitForUncommitTask();
160
161 base::Mutex mutex_;
162 base::ConditionVariable uncommit_task_barrier_;
163
131 base::VirtualMemory* backing_store_; 164 base::VirtualMemory* backing_store_;
132 size_t backing_store_committed_size_; 165 size_t backing_store_committed_size_;
133 HeapObject** array_; 166 HeapObject** array_;
134 // array_[(top - 1) & mask_] is the top element in the deque. The Deque is 167 // array_[(top - 1) & mask_] is the top element in the deque. The Deque is
135 // empty when top_ == bottom_. It is full when top_ + 1 == bottom 168 // empty when top_ == bottom_. It is full when top_ + 1 == bottom
136 // (mod mask + 1). 169 // (mod mask + 1).
137 int top_; 170 int top_;
138 int bottom_; 171 int bottom_;
139 int mask_; 172 int mask_;
140 bool overflowed_; 173 bool overflowed_;
141 bool in_use_; 174 bool in_use_;
175 bool uncommit_task_pending_;
142 176
143 DISALLOW_COPY_AND_ASSIGN(MarkingDeque); 177 DISALLOW_COPY_AND_ASSIGN(MarkingDeque);
144 }; 178 };
145 179
146 180
147 // CodeFlusher collects candidates for code flushing during marking and 181 // CodeFlusher collects candidates for code flushing during marking and
148 // processes those candidates after marking has completed in order to 182 // processes those candidates after marking has completed in order to
149 // reset those functions referencing code objects that would otherwise 183 // reset those functions referencing code objects that would otherwise
150 // be unreachable. Code objects can be referenced in two ways: 184 // be unreachable. Code objects can be referenced in two ways:
151 // - SharedFunctionInfo references unoptimized code. 185 // - SharedFunctionInfo references unoptimized code.
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 764
731 private: 765 private:
732 MarkCompactCollector* collector_; 766 MarkCompactCollector* collector_;
733 }; 767 };
734 768
735 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); 769 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space);
736 } // namespace internal 770 } // namespace internal
737 } // namespace v8 771 } // namespace v8
738 772
739 #endif // V8_HEAP_MARK_COMPACT_H_ 773 #endif // V8_HEAP_MARK_COMPACT_H_
OLDNEW
« no previous file with comments | « no previous file | src/heap/mark-compact.cc » ('j') | src/heap/mark-compact.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698