OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_STORE_BUFFER_H_ | 5 #ifndef V8_STORE_BUFFER_H_ |
6 #define V8_STORE_BUFFER_H_ | 6 #define V8_STORE_BUFFER_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/base/logging.h" | 9 #include "src/base/logging.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
11 #include "src/globals.h" | 11 #include "src/globals.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 class Page; | 16 class Page; |
17 class PagedSpace; | 17 class PagedSpace; |
18 class StoreBuffer; | 18 class StoreBuffer; |
19 | 19 |
20 typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to); | 20 typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to); |
21 | 21 |
22 typedef void (StoreBuffer::*RegionCallback)(Address start, | 22 typedef void (StoreBuffer::*RegionCallback)(Address start, Address end, |
23 Address end, | |
24 ObjectSlotCallback slot_callback, | 23 ObjectSlotCallback slot_callback, |
25 bool clear_maps); | 24 bool clear_maps); |
26 | 25 |
27 // Used to implement the write barrier by collecting addresses of pointers | 26 // Used to implement the write barrier by collecting addresses of pointers |
28 // between spaces. | 27 // between spaces. |
29 class StoreBuffer { | 28 class StoreBuffer { |
30 public: | 29 public: |
31 explicit StoreBuffer(Heap* heap); | 30 explicit StoreBuffer(Heap* heap); |
32 | 31 |
33 static void StoreBufferOverflow(Isolate* isolate); | 32 static void StoreBufferOverflow(Isolate* isolate); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 uintptr_t* hash_set_2_; | 139 uintptr_t* hash_set_2_; |
141 bool hash_sets_are_empty_; | 140 bool hash_sets_are_empty_; |
142 | 141 |
143 void ClearFilteringHashSets(); | 142 void ClearFilteringHashSets(); |
144 | 143 |
145 bool SpaceAvailable(intptr_t space_needed); | 144 bool SpaceAvailable(intptr_t space_needed); |
146 void Uniq(); | 145 void Uniq(); |
147 void ExemptPopularPages(int prime_sample_step, int threshold); | 146 void ExemptPopularPages(int prime_sample_step, int threshold); |
148 | 147 |
149 // Set the map field of the object to NULL if contains a map. | 148 // Set the map field of the object to NULL if contains a map. |
150 inline void ClearDeadObject(HeapObject *object); | 149 inline void ClearDeadObject(HeapObject* object); |
151 | 150 |
152 void IteratePointersToNewSpace(ObjectSlotCallback callback, bool clear_maps); | 151 void IteratePointersToNewSpace(ObjectSlotCallback callback, bool clear_maps); |
153 | 152 |
154 void FindPointersToNewSpaceInRegion(Address start, | 153 void FindPointersToNewSpaceInRegion(Address start, Address end, |
155 Address end, | |
156 ObjectSlotCallback slot_callback, | 154 ObjectSlotCallback slot_callback, |
157 bool clear_maps); | 155 bool clear_maps); |
158 | 156 |
159 // For each region of pointers on a page in use from an old space call | 157 // For each region of pointers on a page in use from an old space call |
160 // visit_pointer_region callback. | 158 // visit_pointer_region callback. |
161 // If either visit_pointer_region or callback can cause an allocation | 159 // If either visit_pointer_region or callback can cause an allocation |
162 // in old space and changes in allocation watermark then | 160 // in old space and changes in allocation watermark then |
163 // can_preallocate_during_iteration should be set to true. | 161 // can_preallocate_during_iteration should be set to true. |
164 void IteratePointersOnPage( | 162 void IteratePointersOnPage(PagedSpace* space, Page* page, |
165 PagedSpace* space, | 163 RegionCallback region_callback, |
166 Page* page, | 164 ObjectSlotCallback slot_callback); |
167 RegionCallback region_callback, | |
168 ObjectSlotCallback slot_callback); | |
169 | 165 |
170 void IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback, | 166 void IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback, |
171 bool clear_maps); | 167 bool clear_maps); |
172 | 168 |
173 #ifdef VERIFY_HEAP | 169 #ifdef VERIFY_HEAP |
174 void VerifyPointers(LargeObjectSpace* space); | 170 void VerifyPointers(LargeObjectSpace* space); |
175 #endif | 171 #endif |
176 | 172 |
177 friend class StoreBufferRebuildScope; | 173 friend class StoreBufferRebuildScope; |
178 friend class DontMoveStoreBufferEntriesScope; | 174 friend class DontMoveStoreBufferEntriesScope; |
179 }; | 175 }; |
180 | 176 |
181 | 177 |
182 class StoreBufferRebuildScope { | 178 class StoreBufferRebuildScope { |
183 public: | 179 public: |
184 explicit StoreBufferRebuildScope(Heap* heap, | 180 explicit StoreBufferRebuildScope(Heap* heap, StoreBuffer* store_buffer, |
185 StoreBuffer* store_buffer, | |
186 StoreBufferCallback callback) | 181 StoreBufferCallback callback) |
187 : store_buffer_(store_buffer), | 182 : store_buffer_(store_buffer), |
188 stored_state_(store_buffer->store_buffer_rebuilding_enabled_), | 183 stored_state_(store_buffer->store_buffer_rebuilding_enabled_), |
189 stored_callback_(store_buffer->callback_) { | 184 stored_callback_(store_buffer->callback_) { |
190 store_buffer_->store_buffer_rebuilding_enabled_ = true; | 185 store_buffer_->store_buffer_rebuilding_enabled_ = true; |
191 store_buffer_->callback_ = callback; | 186 store_buffer_->callback_ = callback; |
192 (*callback)(heap, NULL, kStoreBufferStartScanningPagesEvent); | 187 (*callback)(heap, NULL, kStoreBufferStartScanningPagesEvent); |
193 } | 188 } |
194 | 189 |
195 ~StoreBufferRebuildScope() { | 190 ~StoreBufferRebuildScope() { |
(...skipping 17 matching lines...) Expand all Loading... |
213 } | 208 } |
214 | 209 |
215 ~DontMoveStoreBufferEntriesScope() { | 210 ~DontMoveStoreBufferEntriesScope() { |
216 store_buffer_->may_move_store_buffer_entries_ = stored_state_; | 211 store_buffer_->may_move_store_buffer_entries_ = stored_state_; |
217 } | 212 } |
218 | 213 |
219 private: | 214 private: |
220 StoreBuffer* store_buffer_; | 215 StoreBuffer* store_buffer_; |
221 bool stored_state_; | 216 bool stored_state_; |
222 }; | 217 }; |
223 | 218 } |
224 } } // namespace v8::internal | 219 } // namespace v8::internal |
225 | 220 |
226 #endif // V8_STORE_BUFFER_H_ | 221 #endif // V8_STORE_BUFFER_H_ |
OLD | NEW |