| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // of at a moderate rate of work and gradually increase the speed of the | 87 // of at a moderate rate of work and gradually increase the speed of the |
| 88 // incremental marker until it completes. | 88 // incremental marker until it completes. |
| 89 // Do some marking every time this much memory has been allocated. | 89 // Do some marking every time this much memory has been allocated. |
| 90 static const intptr_t kAllocatedThreshold = 8192; | 90 static const intptr_t kAllocatedThreshold = 8192; |
| 91 // Start off by marking this many times more memory than has been allocated. | 91 // Start off by marking this many times more memory than has been allocated. |
| 92 static const intptr_t kInitialAllocationMarkingFactor = 4; | 92 static const intptr_t kInitialAllocationMarkingFactor = 4; |
| 93 // After this many steps we increase the marking/allocating factor. | 93 // After this many steps we increase the marking/allocating factor. |
| 94 static const intptr_t kAllocationMarkingFactorSpeedupInterval = 1024; | 94 static const intptr_t kAllocationMarkingFactorSpeedupInterval = 1024; |
| 95 // This is how much we increase the marking/allocating factor by. | 95 // This is how much we increase the marking/allocating factor by. |
| 96 static const intptr_t kAllocationMarkingFactorSpeedup = 4; | 96 static const intptr_t kAllocationMarkingFactorSpeedup = 4; |
| 97 static const intptr_t kMaxAllocationMarkingFactor = 1000000000; |
| 97 | 98 |
| 98 void Step(intptr_t allocated); | 99 void Step(intptr_t allocated); |
| 99 | 100 |
| 100 inline void RestartIfNotMarking() { | 101 inline void RestartIfNotMarking() { |
| 101 if (state_ == COMPLETE) { | 102 if (state_ == COMPLETE) { |
| 102 state_ = MARKING; | 103 state_ = MARKING; |
| 103 if (FLAG_trace_incremental_marking) { | 104 if (FLAG_trace_incremental_marking) { |
| 104 PrintF("[IncrementalMarking] Restarting (new grey objects)\n"); | 105 PrintF("[IncrementalMarking] Restarting (new grey objects)\n"); |
| 105 } | 106 } |
| 106 } | 107 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 135 } | 136 } |
| 136 | 137 |
| 137 inline int steps_count() { | 138 inline int steps_count() { |
| 138 return steps_count_; | 139 return steps_count_; |
| 139 } | 140 } |
| 140 | 141 |
| 141 inline double steps_took() { | 142 inline double steps_took() { |
| 142 return steps_took_; | 143 return steps_took_; |
| 143 } | 144 } |
| 144 | 145 |
| 146 inline double longest_step() { |
| 147 return longest_step_; |
| 148 } |
| 149 |
| 145 inline int steps_count_since_last_gc() { | 150 inline int steps_count_since_last_gc() { |
| 146 return steps_count_since_last_gc_; | 151 return steps_count_since_last_gc_; |
| 147 } | 152 } |
| 148 | 153 |
| 149 inline double steps_took_since_last_gc() { | 154 inline double steps_took_since_last_gc() { |
| 150 return steps_took_since_last_gc_; | 155 return steps_took_since_last_gc_; |
| 151 } | 156 } |
| 152 | 157 |
| 153 inline void SetOldSpacePageFlags(MemoryChunk* chunk) { | 158 inline void SetOldSpacePageFlags(MemoryChunk* chunk) { |
| 154 SetOldSpacePageFlags(chunk, IsMarking()); | 159 SetOldSpacePageFlags(chunk, IsMarking()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 165 void ActivateGeneratedStub(Code* stub); | 170 void ActivateGeneratedStub(Code* stub); |
| 166 | 171 |
| 167 private: | 172 private: |
| 168 void set_should_hurry(bool val) { | 173 void set_should_hurry(bool val) { |
| 169 should_hurry_ = val; | 174 should_hurry_ = val; |
| 170 } | 175 } |
| 171 | 176 |
| 172 void ResetStepCounters() { | 177 void ResetStepCounters() { |
| 173 steps_count_ = 0; | 178 steps_count_ = 0; |
| 174 steps_took_ = 0; | 179 steps_took_ = 0; |
| 180 longest_step_ = 0.0; |
| 175 steps_count_since_last_gc_ = 0; | 181 steps_count_since_last_gc_ = 0; |
| 176 steps_took_since_last_gc_ = 0; | 182 steps_took_since_last_gc_ = 0; |
| 183 bytes_rescanned_ = 0; |
| 177 allocation_marking_factor_ = kInitialAllocationMarkingFactor; | 184 allocation_marking_factor_ = kInitialAllocationMarkingFactor; |
| 178 } | 185 } |
| 179 | 186 |
| 180 static void ClearMarkbits(PagedSpace* space); | 187 static void ClearMarkbits(PagedSpace* space); |
| 181 static void ClearMarkbits(NewSpace* space); | 188 static void ClearMarkbits(NewSpace* space); |
| 182 void ClearMarkbits(); | 189 void ClearMarkbits(); |
| 183 | 190 |
| 184 #ifdef DEBUG | 191 #ifdef DEBUG |
| 185 void VerifyMarkbitsAreClean(); | 192 void VerifyMarkbitsAreClean(); |
| 186 static void VerifyMarkbitsAreClean(PagedSpace* space); | 193 static void VerifyMarkbitsAreClean(PagedSpace* space); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 201 Heap* heap_; | 208 Heap* heap_; |
| 202 | 209 |
| 203 State state_; | 210 State state_; |
| 204 bool is_compacting_; | 211 bool is_compacting_; |
| 205 | 212 |
| 206 VirtualMemory* marking_deque_memory_; | 213 VirtualMemory* marking_deque_memory_; |
| 207 MarkingDeque marking_deque_; | 214 MarkingDeque marking_deque_; |
| 208 | 215 |
| 209 int steps_count_; | 216 int steps_count_; |
| 210 double steps_took_; | 217 double steps_took_; |
| 218 double longest_step_; |
| 211 int steps_count_since_last_gc_; | 219 int steps_count_since_last_gc_; |
| 212 double steps_took_since_last_gc_; | 220 double steps_took_since_last_gc_; |
| 221 int64_t bytes_rescanned_; |
| 213 bool should_hurry_; | 222 bool should_hurry_; |
| 214 int allocation_marking_factor_; | 223 int allocation_marking_factor_; |
| 215 intptr_t allocated_; | 224 intptr_t allocated_; |
| 225 |
| 226 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); |
| 216 }; | 227 }; |
| 217 | 228 |
| 218 } } // namespace v8::internal | 229 } } // namespace v8::internal |
| 219 | 230 |
| 220 #endif // V8_INCREMENTAL_MARKING_H_ | 231 #endif // V8_INCREMENTAL_MARKING_H_ |
| OLD | NEW |