| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void Finalize(); | 88 void Finalize(); |
| 89 | 89 |
| 90 void Abort(); | 90 void Abort(); |
| 91 | 91 |
| 92 void MarkingComplete(CompletionAction action); | 92 void MarkingComplete(CompletionAction action); |
| 93 | 93 |
| 94 // It's hard to know how much work the incremental marker should do to make | 94 // It's hard to know how much work the incremental marker should do to make |
| 95 // progress in the face of the mutator creating new work for it. We start | 95 // progress in the face of the mutator creating new work for it. We start |
| 96 // of at a moderate rate of work and gradually increase the speed of the | 96 // of at a moderate rate of work and gradually increase the speed of the |
| 97 // incremental marker until it completes. | 97 // incremental marker until it completes. |
| 98 // Do some marking every time this much memory has been allocated. | 98 // Do some marking every time this much memory has been allocated or this many |
| 99 static const intptr_t kAllocatedThreshold = 65536; | 99 // heavy (color-checking) write barriers have been invoked. |
| 100 static const intptr_t kIncrementalMarkingThreshold = 65536; |
| 100 // Start off by marking this many times more memory than has been allocated. | 101 // Start off by marking this many times more memory than has been allocated. |
| 101 static const intptr_t kInitialAllocationMarkingFactor = 1; | 102 static const intptr_t kInitialMarkingSpeed = 1; |
| 102 // But if we are promoting a lot of data we need to mark faster to keep up | 103 // But if we are promoting a lot of data we need to mark faster to keep up |
| 103 // with the data that is entering the old space through promotion. | 104 // with the data that is entering the old space through promotion. |
| 104 static const intptr_t kFastMarking = 3; | 105 static const intptr_t kFastMarking = 3; |
| 105 // After this many steps we increase the marking/allocating factor. | 106 // After this many steps we increase the marking/allocating factor. |
| 106 static const intptr_t kAllocationMarkingFactorSpeedupInterval = 1024; | 107 static const intptr_t kMarkingSpeedAccellerationInterval = 1024; |
| 107 // This is how much we increase the marking/allocating factor by. | 108 // This is how much we increase the marking/allocating factor by. |
| 108 static const intptr_t kAllocationMarkingFactorSpeedup = 2; | 109 static const intptr_t kMarkingSpeedAccelleration = 2; |
| 109 static const intptr_t kMaxAllocationMarkingFactor = 1000; | 110 static const intptr_t kMaxMarkingSpeed = 1000; |
| 110 | 111 |
| 111 void OldSpaceStep(intptr_t allocated) { | 112 void OldSpaceStep(intptr_t allocated) { |
| 112 Step(allocated * kFastMarking / kInitialAllocationMarkingFactor, | 113 Step(allocated * kFastMarking / kInitialMarkingSpeed, |
| 113 GC_VIA_STACK_GUARD); | 114 GC_VIA_STACK_GUARD); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void Step(intptr_t allocated, CompletionAction action); | 117 void Step(intptr_t allocated, CompletionAction action); |
| 117 | 118 |
| 118 inline void RestartIfNotMarking() { | 119 inline void RestartIfNotMarking() { |
| 119 if (state_ == COMPLETE) { | 120 if (state_ == COMPLETE) { |
| 120 state_ = MARKING; | 121 state_ = MARKING; |
| 121 if (FLAG_trace_incremental_marking) { | 122 if (FLAG_trace_incremental_marking) { |
| 122 PrintF("[IncrementalMarking] Restarting (new grey objects)\n"); | 123 PrintF("[IncrementalMarking] Restarting (new grey objects)\n"); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 205 } |
| 205 | 206 |
| 206 MarkingDeque* marking_deque() { return &marking_deque_; } | 207 MarkingDeque* marking_deque() { return &marking_deque_; } |
| 207 | 208 |
| 208 bool IsCompacting() { return IsMarking() && is_compacting_; } | 209 bool IsCompacting() { return IsMarking() && is_compacting_; } |
| 209 | 210 |
| 210 void ActivateGeneratedStub(Code* stub); | 211 void ActivateGeneratedStub(Code* stub); |
| 211 | 212 |
| 212 void NotifyOfHighPromotionRate() { | 213 void NotifyOfHighPromotionRate() { |
| 213 if (IsMarking()) { | 214 if (IsMarking()) { |
| 214 if (allocation_marking_factor_ < kFastMarking) { | 215 if (marking_speed_ < kFastMarking) { |
| 215 if (FLAG_trace_gc) { | 216 if (FLAG_trace_gc) { |
| 216 PrintPID("Increasing marking speed to %d " | 217 PrintPID("Increasing marking speed to %d " |
| 217 "due to high promotion rate\n", | 218 "due to high promotion rate\n", |
| 218 static_cast<int>(kFastMarking)); | 219 static_cast<int>(kFastMarking)); |
| 219 } | 220 } |
| 220 allocation_marking_factor_ = kFastMarking; | 221 marking_speed_ = kFastMarking; |
| 221 } | 222 } |
| 222 } | 223 } |
| 223 } | 224 } |
| 224 | 225 |
| 225 void EnterNoMarkingScope() { | 226 void EnterNoMarkingScope() { |
| 226 no_marking_scope_depth_++; | 227 no_marking_scope_depth_++; |
| 227 } | 228 } |
| 228 | 229 |
| 229 void LeaveNoMarkingScope() { | 230 void LeaveNoMarkingScope() { |
| 230 no_marking_scope_depth_--; | 231 no_marking_scope_depth_--; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 269 |
| 269 int steps_count_; | 270 int steps_count_; |
| 270 double steps_took_; | 271 double steps_took_; |
| 271 double longest_step_; | 272 double longest_step_; |
| 272 int64_t old_generation_space_available_at_start_of_incremental_; | 273 int64_t old_generation_space_available_at_start_of_incremental_; |
| 273 int64_t old_generation_space_used_at_start_of_incremental_; | 274 int64_t old_generation_space_used_at_start_of_incremental_; |
| 274 int steps_count_since_last_gc_; | 275 int steps_count_since_last_gc_; |
| 275 double steps_took_since_last_gc_; | 276 double steps_took_since_last_gc_; |
| 276 int64_t bytes_rescanned_; | 277 int64_t bytes_rescanned_; |
| 277 bool should_hurry_; | 278 bool should_hurry_; |
| 278 int allocation_marking_factor_; | 279 int marking_speed_; |
| 279 intptr_t bytes_scanned_; | 280 intptr_t bytes_scanned_; |
| 280 intptr_t allocated_; | 281 intptr_t allocated_; |
| 282 intptr_t write_barriers_invoked_since_last_step_; |
| 281 | 283 |
| 282 int no_marking_scope_depth_; | 284 int no_marking_scope_depth_; |
| 283 | 285 |
| 284 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); | 286 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); |
| 285 }; | 287 }; |
| 286 | 288 |
| 287 } } // namespace v8::internal | 289 } } // namespace v8::internal |
| 288 | 290 |
| 289 #endif // V8_INCREMENTAL_MARKING_H_ | 291 #endif // V8_INCREMENTAL_MARKING_H_ |
| OLD | NEW |