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 25 matching lines...) Expand all Loading... |
36 | 36 |
37 namespace v8 { | 37 namespace v8 { |
38 namespace internal { | 38 namespace internal { |
39 | 39 |
40 class Page; | 40 class Page; |
41 class PagedSpace; | 41 class PagedSpace; |
42 class StoreBuffer; | 42 class StoreBuffer; |
43 | 43 |
44 typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to); | 44 typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to); |
45 | 45 |
46 typedef void (StoreBuffer::*RegionCallback)( | 46 typedef void (StoreBuffer::*RegionCallback)(Address start, |
47 Address start, Address end, ObjectSlotCallback slot_callback); | 47 Address end, |
| 48 ObjectSlotCallback slot_callback, |
| 49 bool clear_maps); |
48 | 50 |
49 // Used to implement the write barrier by collecting addresses of pointers | 51 // Used to implement the write barrier by collecting addresses of pointers |
50 // between spaces. | 52 // between spaces. |
51 class StoreBuffer { | 53 class StoreBuffer { |
52 public: | 54 public: |
53 explicit StoreBuffer(Heap* heap); | 55 explicit StoreBuffer(Heap* heap); |
54 | 56 |
55 static void StoreBufferOverflow(Isolate* isolate); | 57 static void StoreBufferOverflow(Isolate* isolate); |
56 | 58 |
57 inline Address TopAddress(); | 59 inline Address TopAddress(); |
(...skipping 18 matching lines...) Expand all Loading... |
76 // exempt from the store buffer and process the promotion queue. These steps | 78 // exempt from the store buffer and process the promotion queue. These steps |
77 // can overflow this buffer. We check for this and on overflow we call the | 79 // can overflow this buffer. We check for this and on overflow we call the |
78 // callback set up with the StoreBufferRebuildScope object. | 80 // callback set up with the StoreBufferRebuildScope object. |
79 inline void EnterDirectlyIntoStoreBuffer(Address addr); | 81 inline void EnterDirectlyIntoStoreBuffer(Address addr); |
80 | 82 |
81 // Iterates over all pointers that go from old space to new space. It will | 83 // Iterates over all pointers that go from old space to new space. It will |
82 // delete the store buffer as it starts so the callback should reenter | 84 // delete the store buffer as it starts so the callback should reenter |
83 // surviving old-to-new pointers into the store buffer to rebuild it. | 85 // surviving old-to-new pointers into the store buffer to rebuild it. |
84 void IteratePointersToNewSpace(ObjectSlotCallback callback); | 86 void IteratePointersToNewSpace(ObjectSlotCallback callback); |
85 | 87 |
| 88 // Same as IteratePointersToNewSpace but additonally clears maps in objects |
| 89 // referenced from the store buffer that do not contain a forwarding pointer. |
| 90 void IteratePointersToNewSpaceAndClearMaps(ObjectSlotCallback callback); |
| 91 |
86 static const int kStoreBufferOverflowBit = 1 << (14 + kPointerSizeLog2); | 92 static const int kStoreBufferOverflowBit = 1 << (14 + kPointerSizeLog2); |
87 static const int kStoreBufferSize = kStoreBufferOverflowBit; | 93 static const int kStoreBufferSize = kStoreBufferOverflowBit; |
88 static const int kStoreBufferLength = kStoreBufferSize / sizeof(Address); | 94 static const int kStoreBufferLength = kStoreBufferSize / sizeof(Address); |
89 static const int kOldStoreBufferLength = kStoreBufferLength * 16; | 95 static const int kOldStoreBufferLength = kStoreBufferLength * 16; |
90 static const int kHashSetLengthLog2 = 12; | 96 static const int kHashSetLengthLog2 = 12; |
91 static const int kHashSetLength = 1 << kHashSetLengthLog2; | 97 static const int kHashSetLength = 1 << kHashSetLengthLog2; |
92 | 98 |
93 void Compact(); | 99 void Compact(); |
94 | 100 |
95 void GCPrologue(); | 101 void GCPrologue(); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 uintptr_t* hash_set_1_; | 163 uintptr_t* hash_set_1_; |
158 uintptr_t* hash_set_2_; | 164 uintptr_t* hash_set_2_; |
159 bool hash_sets_are_empty_; | 165 bool hash_sets_are_empty_; |
160 | 166 |
161 void ClearFilteringHashSets(); | 167 void ClearFilteringHashSets(); |
162 | 168 |
163 bool SpaceAvailable(intptr_t space_needed); | 169 bool SpaceAvailable(intptr_t space_needed); |
164 void Uniq(); | 170 void Uniq(); |
165 void ExemptPopularPages(int prime_sample_step, int threshold); | 171 void ExemptPopularPages(int prime_sample_step, int threshold); |
166 | 172 |
| 173 void IteratePointersToNewSpace(ObjectSlotCallback callback, bool clear_maps); |
| 174 |
167 void FindPointersToNewSpaceInRegion(Address start, | 175 void FindPointersToNewSpaceInRegion(Address start, |
168 Address end, | 176 Address end, |
169 ObjectSlotCallback slot_callback); | 177 ObjectSlotCallback slot_callback, |
| 178 bool clear_maps); |
170 | 179 |
171 // For each region of pointers on a page in use from an old space call | 180 // For each region of pointers on a page in use from an old space call |
172 // visit_pointer_region callback. | 181 // visit_pointer_region callback. |
173 // If either visit_pointer_region or callback can cause an allocation | 182 // If either visit_pointer_region or callback can cause an allocation |
174 // in old space and changes in allocation watermark then | 183 // in old space and changes in allocation watermark then |
175 // can_preallocate_during_iteration should be set to true. | 184 // can_preallocate_during_iteration should be set to true. |
176 void IteratePointersOnPage( | 185 void IteratePointersOnPage( |
177 PagedSpace* space, | 186 PagedSpace* space, |
178 Page* page, | 187 Page* page, |
179 RegionCallback region_callback, | 188 RegionCallback region_callback, |
180 ObjectSlotCallback slot_callback); | 189 ObjectSlotCallback slot_callback); |
181 | 190 |
182 void FindPointersToNewSpaceInMaps( | 191 void FindPointersToNewSpaceInMaps( |
183 Address start, | 192 Address start, |
184 Address end, | 193 Address end, |
185 ObjectSlotCallback slot_callback); | 194 ObjectSlotCallback slot_callback, |
| 195 bool clear_maps); |
186 | 196 |
187 void FindPointersToNewSpaceInMapsRegion( | 197 void FindPointersToNewSpaceInMapsRegion( |
188 Address start, | 198 Address start, |
189 Address end, | 199 Address end, |
190 ObjectSlotCallback slot_callback); | 200 ObjectSlotCallback slot_callback, |
| 201 bool clear_maps); |
191 | 202 |
192 void FindPointersToNewSpaceOnPage( | 203 void FindPointersToNewSpaceOnPage( |
193 PagedSpace* space, | 204 PagedSpace* space, |
194 Page* page, | 205 Page* page, |
195 RegionCallback region_callback, | 206 RegionCallback region_callback, |
196 ObjectSlotCallback slot_callback); | 207 ObjectSlotCallback slot_callback, |
| 208 bool clear_maps); |
197 | 209 |
198 void IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback); | 210 void IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback, |
| 211 bool clear_maps); |
199 | 212 |
200 #ifdef VERIFY_HEAP | 213 #ifdef VERIFY_HEAP |
201 void VerifyPointers(PagedSpace* space, RegionCallback region_callback); | 214 void VerifyPointers(PagedSpace* space, RegionCallback region_callback); |
202 void VerifyPointers(LargeObjectSpace* space); | 215 void VerifyPointers(LargeObjectSpace* space); |
203 #endif | 216 #endif |
204 | 217 |
205 friend class StoreBufferRebuildScope; | 218 friend class StoreBufferRebuildScope; |
206 friend class DontMoveStoreBufferEntriesScope; | 219 friend class DontMoveStoreBufferEntriesScope; |
207 }; | 220 }; |
208 | 221 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 } | 258 } |
246 | 259 |
247 private: | 260 private: |
248 StoreBuffer* store_buffer_; | 261 StoreBuffer* store_buffer_; |
249 bool stored_state_; | 262 bool stored_state_; |
250 }; | 263 }; |
251 | 264 |
252 } } // namespace v8::internal | 265 } } // namespace v8::internal |
253 | 266 |
254 #endif // V8_STORE_BUFFER_H_ | 267 #endif // V8_STORE_BUFFER_H_ |
OLD | NEW |