| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  145   uintptr_t* hash_set_1_; |  140   uintptr_t* hash_set_1_; | 
|  146   uintptr_t* hash_set_2_; |  141   uintptr_t* hash_set_2_; | 
|  147   bool hash_sets_are_empty_; |  142   bool hash_sets_are_empty_; | 
|  148  |  143  | 
|  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. |  | 
|  156   inline void ClearDeadObject(HeapObject* object); |  | 
|  157  |  | 
|  158   void ProcessOldToNewSlot(Address slot_address, |  150   void ProcessOldToNewSlot(Address slot_address, | 
|  159                            ObjectSlotCallback slot_callback, bool clear_maps); |  151                            ObjectSlotCallback slot_callback); | 
|  160  |  | 
|  161   void IteratePointersToNewSpace(ObjectSlotCallback callback, bool clear_maps); |  | 
|  162  |  152  | 
|  163   void FindPointersToNewSpaceInRegion(Address start, Address end, |  153   void FindPointersToNewSpaceInRegion(Address start, Address end, | 
|  164                                       ObjectSlotCallback slot_callback, |  154                                       ObjectSlotCallback slot_callback); | 
|  165                                       bool clear_maps); |  | 
|  166  |  155  | 
|  167   // For each region of pointers on a page in use from an old space call |  156   // For each region of pointers on a page in use from an old space call | 
|  168   // visit_pointer_region callback. |  157   // visit_pointer_region callback. | 
|  169   // If either visit_pointer_region or callback can cause an allocation |  158   // If either visit_pointer_region or callback can cause an allocation | 
|  170   // in old space and changes in allocation watermark then |  159   // in old space and changes in allocation watermark then | 
|  171   // can_preallocate_during_iteration should be set to true. |  160   // can_preallocate_during_iteration should be set to true. | 
|  172   void IteratePointersOnPage(PagedSpace* space, Page* page, |  161   void IteratePointersOnPage(PagedSpace* space, Page* page, | 
|  173                              RegionCallback region_callback, |  162                              RegionCallback region_callback, | 
|  174                              ObjectSlotCallback slot_callback); |  163                              ObjectSlotCallback slot_callback); | 
|  175  |  164  | 
|  176   void IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback, |  165   void IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback); | 
|  177                                     bool clear_maps); |  | 
|  178  |  166  | 
|  179 #ifdef VERIFY_HEAP |  167 #ifdef VERIFY_HEAP | 
|  180   void VerifyPointers(LargeObjectSpace* space); |  168   void VerifyPointers(LargeObjectSpace* space); | 
|  181 #endif |  169 #endif | 
|  182  |  170  | 
|  183   friend class StoreBufferRebuildScope; |  171   friend class StoreBufferRebuildScope; | 
|  184   friend class DontMoveStoreBufferEntriesScope; |  172   friend class DontMoveStoreBufferEntriesScope; | 
|  185 }; |  173 }; | 
|  186  |  174  | 
|  187  |  175  | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  222   } |  210   } | 
|  223  |  211  | 
|  224  private: |  212  private: | 
|  225   StoreBuffer* store_buffer_; |  213   StoreBuffer* store_buffer_; | 
|  226   bool stored_state_; |  214   bool stored_state_; | 
|  227 }; |  215 }; | 
|  228 } |  216 } | 
|  229 }  // namespace v8::internal |  217 }  // namespace v8::internal | 
|  230  |  218  | 
|  231 #endif  // V8_STORE_BUFFER_H_ |  219 #endif  // V8_STORE_BUFFER_H_ | 
| OLD | NEW |