OLD | NEW |
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_INCREMENTAL_MARKING_H_ | 5 #ifndef V8_HEAP_INCREMENTAL_MARKING_H_ |
6 #define V8_HEAP_INCREMENTAL_MARKING_H_ | 6 #define V8_HEAP_INCREMENTAL_MARKING_H_ |
7 | 7 |
8 | 8 |
9 #include "src/execution.h" | 9 #include "src/execution.h" |
10 #include "src/heap/mark-compact.h" | 10 #include "src/heap/mark-compact.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 enum CompletionAction { GC_VIA_STACK_GUARD, NO_GC_VIA_STACK_GUARD }; | 21 enum CompletionAction { GC_VIA_STACK_GUARD, NO_GC_VIA_STACK_GUARD }; |
22 | 22 |
23 enum ForceMarkingAction { FORCE_MARKING, DO_NOT_FORCE_MARKING }; | 23 enum ForceMarkingAction { FORCE_MARKING, DO_NOT_FORCE_MARKING }; |
24 | 24 |
25 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION }; | 25 enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION }; |
26 | 26 |
27 explicit IncrementalMarking(Heap* heap); | 27 explicit IncrementalMarking(Heap* heap); |
28 | 28 |
29 static void Initialize(); | 29 static void Initialize(); |
30 | 30 |
31 void TearDown(); | |
32 | |
33 State state() { | 31 State state() { |
34 DCHECK(state_ == STOPPED || FLAG_incremental_marking); | 32 DCHECK(state_ == STOPPED || FLAG_incremental_marking); |
35 return state_; | 33 return state_; |
36 } | 34 } |
37 | 35 |
38 bool should_hurry() { return should_hurry_; } | 36 bool should_hurry() { return should_hurry_; } |
39 void set_should_hurry(bool val) { should_hurry_ = val; } | 37 void set_should_hurry(bool val) { should_hurry_ = val; } |
40 | 38 |
41 inline bool IsStopped() { return state() == STOPPED; } | 39 inline bool IsStopped() { return state() == STOPPED; } |
42 | 40 |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 inline void WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit); | 135 inline void WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit); |
138 | 136 |
139 inline void SetOldSpacePageFlags(MemoryChunk* chunk) { | 137 inline void SetOldSpacePageFlags(MemoryChunk* chunk) { |
140 SetOldSpacePageFlags(chunk, IsMarking(), IsCompacting()); | 138 SetOldSpacePageFlags(chunk, IsMarking(), IsCompacting()); |
141 } | 139 } |
142 | 140 |
143 inline void SetNewSpacePageFlags(NewSpacePage* chunk) { | 141 inline void SetNewSpacePageFlags(NewSpacePage* chunk) { |
144 SetNewSpacePageFlags(chunk, IsMarking()); | 142 SetNewSpacePageFlags(chunk, IsMarking()); |
145 } | 143 } |
146 | 144 |
147 MarkingDeque* marking_deque() { return &marking_deque_; } | |
148 | |
149 bool IsMarkingDequeEmpty() { return marking_deque_.IsEmpty(); } | |
150 | |
151 bool IsCompacting() { return IsMarking() && is_compacting_; } | 145 bool IsCompacting() { return IsMarking() && is_compacting_; } |
152 | 146 |
153 void ActivateGeneratedStub(Code* stub); | 147 void ActivateGeneratedStub(Code* stub); |
154 | 148 |
155 void NotifyOfHighPromotionRate() { | 149 void NotifyOfHighPromotionRate() { |
156 if (IsMarking()) { | 150 if (IsMarking()) { |
157 if (marking_speed_ < kFastMarking) { | 151 if (marking_speed_ < kFastMarking) { |
158 if (FLAG_trace_gc) { | 152 if (FLAG_trace_gc) { |
159 PrintPID( | 153 PrintPID( |
160 "Increasing marking speed to %d " | 154 "Increasing marking speed to %d " |
161 "due to high promotion rate\n", | 155 "due to high promotion rate\n", |
162 static_cast<int>(kFastMarking)); | 156 static_cast<int>(kFastMarking)); |
163 } | 157 } |
164 marking_speed_ = kFastMarking; | 158 marking_speed_ = kFastMarking; |
165 } | 159 } |
166 } | 160 } |
167 } | 161 } |
168 | 162 |
169 void EnterNoMarkingScope() { no_marking_scope_depth_++; } | 163 void EnterNoMarkingScope() { no_marking_scope_depth_++; } |
170 | 164 |
171 void LeaveNoMarkingScope() { no_marking_scope_depth_--; } | 165 void LeaveNoMarkingScope() { no_marking_scope_depth_--; } |
172 | 166 |
173 void UncommitMarkingDeque(); | |
174 | |
175 void NotifyIncompleteScanOfObject(int unscanned_bytes) { | 167 void NotifyIncompleteScanOfObject(int unscanned_bytes) { |
176 unscanned_bytes_of_large_object_ = unscanned_bytes; | 168 unscanned_bytes_of_large_object_ = unscanned_bytes; |
177 } | 169 } |
178 | 170 |
179 void ClearIdleMarkingDelayCounter(); | 171 void ClearIdleMarkingDelayCounter(); |
180 | 172 |
181 bool IsIdleMarkingDelayCounterLimitReached(); | 173 bool IsIdleMarkingDelayCounterLimitReached(); |
182 | 174 |
183 private: | 175 private: |
184 int64_t SpaceLeftInOldSpace(); | 176 int64_t SpaceLeftInOldSpace(); |
(...skipping 10 matching lines...) Expand all Loading... |
195 | 187 |
196 static void DeactivateIncrementalWriteBarrierForSpace(PagedSpace* space); | 188 static void DeactivateIncrementalWriteBarrierForSpace(PagedSpace* space); |
197 static void DeactivateIncrementalWriteBarrierForSpace(NewSpace* space); | 189 static void DeactivateIncrementalWriteBarrierForSpace(NewSpace* space); |
198 void DeactivateIncrementalWriteBarrier(); | 190 void DeactivateIncrementalWriteBarrier(); |
199 | 191 |
200 static void SetOldSpacePageFlags(MemoryChunk* chunk, bool is_marking, | 192 static void SetOldSpacePageFlags(MemoryChunk* chunk, bool is_marking, |
201 bool is_compacting); | 193 bool is_compacting); |
202 | 194 |
203 static void SetNewSpacePageFlags(NewSpacePage* chunk, bool is_marking); | 195 static void SetNewSpacePageFlags(NewSpacePage* chunk, bool is_marking); |
204 | 196 |
205 void EnsureMarkingDequeIsCommitted(); | |
206 | |
207 INLINE(void ProcessMarkingDeque()); | 197 INLINE(void ProcessMarkingDeque()); |
208 | 198 |
209 INLINE(intptr_t ProcessMarkingDeque(intptr_t bytes_to_process)); | 199 INLINE(intptr_t ProcessMarkingDeque(intptr_t bytes_to_process)); |
210 | 200 |
211 INLINE(void VisitObject(Map* map, HeapObject* obj, int size)); | 201 INLINE(void VisitObject(Map* map, HeapObject* obj, int size)); |
212 | 202 |
213 void IncrementIdleMarkingDelayCounter(); | 203 void IncrementIdleMarkingDelayCounter(); |
214 | 204 |
215 Heap* heap_; | 205 Heap* heap_; |
216 | 206 |
217 State state_; | 207 State state_; |
218 bool is_compacting_; | 208 bool is_compacting_; |
219 | 209 |
220 base::VirtualMemory* marking_deque_memory_; | |
221 bool marking_deque_memory_committed_; | |
222 MarkingDeque marking_deque_; | |
223 | |
224 int steps_count_; | 210 int steps_count_; |
225 int64_t old_generation_space_available_at_start_of_incremental_; | 211 int64_t old_generation_space_available_at_start_of_incremental_; |
226 int64_t old_generation_space_used_at_start_of_incremental_; | 212 int64_t old_generation_space_used_at_start_of_incremental_; |
227 int64_t bytes_rescanned_; | 213 int64_t bytes_rescanned_; |
228 bool should_hurry_; | 214 bool should_hurry_; |
229 int marking_speed_; | 215 int marking_speed_; |
230 intptr_t bytes_scanned_; | 216 intptr_t bytes_scanned_; |
231 intptr_t allocated_; | 217 intptr_t allocated_; |
232 intptr_t write_barriers_invoked_since_last_step_; | 218 intptr_t write_barriers_invoked_since_last_step_; |
233 size_t idle_marking_delay_counter_; | 219 size_t idle_marking_delay_counter_; |
234 | 220 |
235 int no_marking_scope_depth_; | 221 int no_marking_scope_depth_; |
236 | 222 |
237 int unscanned_bytes_of_large_object_; | 223 int unscanned_bytes_of_large_object_; |
238 | 224 |
239 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); | 225 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); |
240 }; | 226 }; |
241 } | 227 } |
242 } // namespace v8::internal | 228 } // namespace v8::internal |
243 | 229 |
244 #endif // V8_HEAP_INCREMENTAL_MARKING_H_ | 230 #endif // V8_HEAP_INCREMENTAL_MARKING_H_ |
OLD | NEW |