| 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, Address end, | 22 typedef void (StoreBuffer::*RegionCallback)(Address start, Address end, |
| 23 ObjectSlotCallback slot_callback, | 23 ObjectSlotCallback slot_callback); |
| 24 bool clear_maps); | |
| 25 | 24 |
| 26 // Used to implement the write barrier by collecting addresses of pointers | 25 // Used to implement the write barrier by collecting addresses of pointers |
| 27 // between spaces. | 26 // between spaces. |
| 28 class StoreBuffer { | 27 class StoreBuffer { |
| 29 public: | 28 public: |
| 30 explicit StoreBuffer(Heap* heap); | 29 explicit StoreBuffer(Heap* heap); |
| 31 | 30 |
| 32 static void StoreBufferOverflow(Isolate* isolate); | 31 static void StoreBufferOverflow(Isolate* isolate); |
| 33 | 32 |
| 34 inline Address TopAddress(); | 33 inline Address TopAddress(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 53 // exempt from the store buffer and process the promotion queue. These steps | 52 // exempt from the store buffer and process the promotion queue. These steps |
| 54 // can overflow this buffer. We check for this and on overflow we call the | 53 // can overflow this buffer. We check for this and on overflow we call the |
| 55 // callback set up with the StoreBufferRebuildScope object. | 54 // callback set up with the StoreBufferRebuildScope object. |
| 56 inline void EnterDirectlyIntoStoreBuffer(Address addr); | 55 inline void EnterDirectlyIntoStoreBuffer(Address addr); |
| 57 | 56 |
| 58 // Iterates over all pointers that go from old space to new space. It will | 57 // Iterates over all pointers that go from old space to new space. It will |
| 59 // delete the store buffer as it starts so the callback should reenter | 58 // delete the store buffer as it starts so the callback should reenter |
| 60 // surviving old-to-new pointers into the store buffer to rebuild it. | 59 // surviving old-to-new pointers into the store buffer to rebuild it. |
| 61 void IteratePointersToNewSpace(ObjectSlotCallback callback); | 60 void IteratePointersToNewSpace(ObjectSlotCallback callback); |
| 62 | 61 |
| 63 // Same as IteratePointersToNewSpace but additonally clears maps in objects | |
| 64 // referenced from the store buffer that do not contain a forwarding pointer. | |
| 65 void IteratePointersToNewSpaceAndClearMaps(ObjectSlotCallback callback); | |
| 66 | |
| 67 static const int kStoreBufferOverflowBit = 1 << (14 + kPointerSizeLog2); | 62 static const int kStoreBufferOverflowBit = 1 << (14 + kPointerSizeLog2); |
| 68 static const int kStoreBufferSize = kStoreBufferOverflowBit; | 63 static const int kStoreBufferSize = kStoreBufferOverflowBit; |
| 69 static const int kStoreBufferLength = kStoreBufferSize / sizeof(Address); | 64 static const int kStoreBufferLength = kStoreBufferSize / sizeof(Address); |
| 70 static const int kOldStoreBufferLength = kStoreBufferLength * 16; | 65 static const int kOldStoreBufferLength = kStoreBufferLength * 16; |
| 71 static const int kHashSetLengthLog2 = 12; | 66 static const int kHashSetLengthLog2 = 12; |
| 72 static const int kHashSetLength = 1 << kHashSetLengthLog2; | 67 static const int kHashSetLength = 1 << kHashSetLengthLog2; |
| 73 | 68 |
| 74 void Compact(); | 69 void Compact(); |
| 75 | 70 |
| 76 void GCPrologue(); | 71 void GCPrologue(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 void ClearFilteringHashSets(); | 144 void ClearFilteringHashSets(); |
| 150 | 145 |
| 151 bool SpaceAvailable(intptr_t space_needed); | 146 bool SpaceAvailable(intptr_t space_needed); |
| 152 void Uniq(); | 147 void Uniq(); |
| 153 void ExemptPopularPages(int prime_sample_step, int threshold); | 148 void ExemptPopularPages(int prime_sample_step, int threshold); |
| 154 | 149 |
| 155 // Set the map field of the object to NULL if contains a map. | 150 // Set the map field of the object to NULL if contains a map. |
| 156 inline void ClearDeadObject(HeapObject* object); | 151 inline void ClearDeadObject(HeapObject* object); |
| 157 | 152 |
| 158 void ProcessOldToNewSlot(Address slot_address, | 153 void ProcessOldToNewSlot(Address slot_address, |
| 159 ObjectSlotCallback slot_callback, bool clear_maps); | 154 ObjectSlotCallback slot_callback); |
| 160 | |
| 161 void IteratePointersToNewSpace(ObjectSlotCallback callback, bool clear_maps); | |
| 162 | 155 |
| 163 void FindPointersToNewSpaceInRegion(Address start, Address end, | 156 void FindPointersToNewSpaceInRegion(Address start, Address end, |
| 164 ObjectSlotCallback slot_callback, | 157 ObjectSlotCallback slot_callback); |
| 165 bool clear_maps); | |
| 166 | 158 |
| 167 // For each region of pointers on a page in use from an old space call | 159 // For each region of pointers on a page in use from an old space call |
| 168 // visit_pointer_region callback. | 160 // visit_pointer_region callback. |
| 169 // If either visit_pointer_region or callback can cause an allocation | 161 // If either visit_pointer_region or callback can cause an allocation |
| 170 // in old space and changes in allocation watermark then | 162 // in old space and changes in allocation watermark then |
| 171 // can_preallocate_during_iteration should be set to true. | 163 // can_preallocate_during_iteration should be set to true. |
| 172 void IteratePointersOnPage(PagedSpace* space, Page* page, | 164 void IteratePointersOnPage(PagedSpace* space, Page* page, |
| 173 RegionCallback region_callback, | 165 RegionCallback region_callback, |
| 174 ObjectSlotCallback slot_callback); | 166 ObjectSlotCallback slot_callback); |
| 175 | 167 |
| 176 void IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback, | 168 void IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback); |
| 177 bool clear_maps); | |
| 178 | 169 |
| 179 #ifdef VERIFY_HEAP | 170 #ifdef VERIFY_HEAP |
| 180 void VerifyPointers(LargeObjectSpace* space); | 171 void VerifyPointers(LargeObjectSpace* space); |
| 181 #endif | 172 #endif |
| 182 | 173 |
| 183 friend class StoreBufferRebuildScope; | 174 friend class StoreBufferRebuildScope; |
| 184 friend class DontMoveStoreBufferEntriesScope; | 175 friend class DontMoveStoreBufferEntriesScope; |
| 185 }; | 176 }; |
| 186 | 177 |
| 187 | 178 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 } | 213 } |
| 223 | 214 |
| 224 private: | 215 private: |
| 225 StoreBuffer* store_buffer_; | 216 StoreBuffer* store_buffer_; |
| 226 bool stored_state_; | 217 bool stored_state_; |
| 227 }; | 218 }; |
| 228 } | 219 } |
| 229 } // namespace v8::internal | 220 } // namespace v8::internal |
| 230 | 221 |
| 231 #endif // V8_STORE_BUFFER_H_ | 222 #endif // V8_STORE_BUFFER_H_ |
| OLD | NEW |