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 28 matching lines...) Expand all Loading... | |
39 | 39 |
40 class IncrementalMarking { | 40 class IncrementalMarking { |
41 public: | 41 public: |
42 enum State { | 42 enum State { |
43 STOPPED, | 43 STOPPED, |
44 SWEEPING, | 44 SWEEPING, |
45 MARKING, | 45 MARKING, |
46 COMPLETE | 46 COMPLETE |
47 }; | 47 }; |
48 | 48 |
49 enum Finalizer { | |
Michael Starzinger
2012/04/02 09:01:46
The name "finalizer" feels wrong. Can we change th
ulan
2012/04/02 09:42:24
Done.
| |
50 GC_VIA_STACK_GUARD, | |
51 NO_GC_VIA_STACK_GUARD | |
52 }; | |
53 | |
49 explicit IncrementalMarking(Heap* heap); | 54 explicit IncrementalMarking(Heap* heap); |
50 | 55 |
51 void TearDown(); | 56 void TearDown(); |
52 | 57 |
53 State state() { | 58 State state() { |
54 ASSERT(state_ == STOPPED || FLAG_incremental_marking); | 59 ASSERT(state_ == STOPPED || FLAG_incremental_marking); |
55 return state_; | 60 return state_; |
56 } | 61 } |
57 | 62 |
58 bool should_hurry() { return should_hurry_; } | 63 bool should_hurry() { return should_hurry_; } |
(...skipping 16 matching lines...) Expand all Loading... | |
75 void PrepareForScavenge(); | 80 void PrepareForScavenge(); |
76 | 81 |
77 void UpdateMarkingDequeAfterScavenge(); | 82 void UpdateMarkingDequeAfterScavenge(); |
78 | 83 |
79 void Hurry(); | 84 void Hurry(); |
80 | 85 |
81 void Finalize(); | 86 void Finalize(); |
82 | 87 |
83 void Abort(); | 88 void Abort(); |
84 | 89 |
85 void MarkingComplete(); | 90 void MarkingComplete(Finalizer finalizer); |
86 | 91 |
87 // It's hard to know how much work the incremental marker should do to make | 92 // It's hard to know how much work the incremental marker should do to make |
88 // progress in the face of the mutator creating new work for it. We start | 93 // progress in the face of the mutator creating new work for it. We start |
89 // of at a moderate rate of work and gradually increase the speed of the | 94 // of at a moderate rate of work and gradually increase the speed of the |
90 // incremental marker until it completes. | 95 // incremental marker until it completes. |
91 // Do some marking every time this much memory has been allocated. | 96 // Do some marking every time this much memory has been allocated. |
92 static const intptr_t kAllocatedThreshold = 65536; | 97 static const intptr_t kAllocatedThreshold = 65536; |
93 // Start off by marking this many times more memory than has been allocated. | 98 // Start off by marking this many times more memory than has been allocated. |
94 static const intptr_t kInitialAllocationMarkingFactor = 1; | 99 static const intptr_t kInitialAllocationMarkingFactor = 1; |
95 // But if we are promoting a lot of data we need to mark faster to keep up | 100 // But if we are promoting a lot of data we need to mark faster to keep up |
96 // with the data that is entering the old space through promotion. | 101 // with the data that is entering the old space through promotion. |
97 static const intptr_t kFastMarking = 3; | 102 static const intptr_t kFastMarking = 3; |
98 // After this many steps we increase the marking/allocating factor. | 103 // After this many steps we increase the marking/allocating factor. |
99 static const intptr_t kAllocationMarkingFactorSpeedupInterval = 1024; | 104 static const intptr_t kAllocationMarkingFactorSpeedupInterval = 1024; |
100 // This is how much we increase the marking/allocating factor by. | 105 // This is how much we increase the marking/allocating factor by. |
101 static const intptr_t kAllocationMarkingFactorSpeedup = 2; | 106 static const intptr_t kAllocationMarkingFactorSpeedup = 2; |
102 static const intptr_t kMaxAllocationMarkingFactor = 1000; | 107 static const intptr_t kMaxAllocationMarkingFactor = 1000; |
103 | 108 |
104 void OldSpaceStep(intptr_t allocated) { | 109 void OldSpaceStep(intptr_t allocated) { |
105 Step(allocated * kFastMarking / kInitialAllocationMarkingFactor); | 110 Step(allocated * kFastMarking / kInitialAllocationMarkingFactor); |
106 } | 111 } |
107 | 112 |
108 void Step(intptr_t allocated); | 113 void Step(intptr_t allocated, Finalizer finalizer = GC_VIA_STACK_GUARD); |
Michael Starzinger
2012/04/02 09:01:46
There are only three other call-sites, could we ge
ulan
2012/04/02 09:42:24
Done.
| |
109 | 114 |
110 inline void RestartIfNotMarking() { | 115 inline void RestartIfNotMarking() { |
111 if (state_ == COMPLETE) { | 116 if (state_ == COMPLETE) { |
112 state_ = MARKING; | 117 state_ = MARKING; |
113 if (FLAG_trace_incremental_marking) { | 118 if (FLAG_trace_incremental_marking) { |
114 PrintF("[IncrementalMarking] Restarting (new grey objects)\n"); | 119 PrintF("[IncrementalMarking] Restarting (new grey objects)\n"); |
115 } | 120 } |
116 } | 121 } |
117 } | 122 } |
118 | 123 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 intptr_t allocated_; | 274 intptr_t allocated_; |
270 | 275 |
271 int no_marking_scope_depth_; | 276 int no_marking_scope_depth_; |
272 | 277 |
273 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); | 278 DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking); |
274 }; | 279 }; |
275 | 280 |
276 } } // namespace v8::internal | 281 } } // namespace v8::internal |
277 | 282 |
278 #endif // V8_INCREMENTAL_MARKING_H_ | 283 #endif // V8_INCREMENTAL_MARKING_H_ |
OLD | NEW |