| 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 23 matching lines...) Expand all Loading... |
| 34 #include "platform.h" | 34 #include "platform.h" |
| 35 #include "v8globals.h" | 35 #include "v8globals.h" |
| 36 | 36 |
| 37 namespace v8 { | 37 namespace v8 { |
| 38 namespace internal { | 38 namespace internal { |
| 39 | 39 |
| 40 class StoreBuffer; | 40 class StoreBuffer; |
| 41 | 41 |
| 42 typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to); | 42 typedef void (*ObjectSlotCallback)(HeapObject** from, HeapObject* to); |
| 43 | 43 |
| 44 typedef void (StoreBuffer::*RegionCallback)( | 44 typedef void RegionCallback( |
| 45 Address start, Address end, ObjectSlotCallback slot_callback); | 45 StoreBuffer* store_buffer, |
| 46 Address start, |
| 47 Address end, |
| 48 ObjectSlotCallback slot_callback); |
| 46 | 49 |
| 47 // Used to implement the write barrier by collecting addresses of pointers | 50 // Used to implement the write barrier by collecting addresses of pointers |
| 48 // between spaces. | 51 // between spaces. |
| 49 class StoreBuffer { | 52 class StoreBuffer { |
| 50 public: | 53 public: |
| 51 explicit StoreBuffer(Heap* heap); | 54 explicit StoreBuffer(Heap* heap); |
| 52 | 55 |
| 53 static void StoreBufferOverflow(Isolate* isolate); | 56 static void StoreBufferOverflow(Isolate* isolate); |
| 54 | 57 |
| 55 inline Address TopAddress(); | 58 inline Address TopAddress(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 74 // exempt from the store buffer and process the promotion queue. These steps | 77 // exempt from the store buffer and process the promotion queue. These steps |
| 75 // can overflow this buffer. We check for this and on overflow we call the | 78 // can overflow this buffer. We check for this and on overflow we call the |
| 76 // callback set up with the StoreBufferRebuildScope object. | 79 // callback set up with the StoreBufferRebuildScope object. |
| 77 inline void EnterDirectlyIntoStoreBuffer(Address addr); | 80 inline void EnterDirectlyIntoStoreBuffer(Address addr); |
| 78 | 81 |
| 79 // Iterates over all pointers that go from old space to new space. It will | 82 // Iterates over all pointers that go from old space to new space. It will |
| 80 // delete the store buffer as it starts so the callback should reenter | 83 // delete the store buffer as it starts so the callback should reenter |
| 81 // surviving old-to-new pointers into the store buffer to rebuild it. | 84 // surviving old-to-new pointers into the store buffer to rebuild it. |
| 82 void IteratePointersToNewSpace(ObjectSlotCallback callback); | 85 void IteratePointersToNewSpace(ObjectSlotCallback callback); |
| 83 | 86 |
| 84 static const int kStoreBufferOverflowBit = 1 << 16; | 87 static const int kStoreBufferOverflowBit = 1 << 12; |
| 85 static const int kStoreBufferSize = kStoreBufferOverflowBit; | 88 static const int kStoreBufferSize = kStoreBufferOverflowBit; |
| 86 static const int kStoreBufferLength = kStoreBufferSize / sizeof(Address); | 89 static const int kStoreBufferLength = kStoreBufferSize / sizeof(Address); |
| 87 static const int kOldStoreBufferLength = kStoreBufferLength * 64; | 90 static const int kOldStoreBufferLength = kStoreBufferLength * 64; |
| 88 static const int kHashMapLengthLog2 = 12; | 91 static const int kHashMapLengthLog2 = 12; |
| 89 static const int kHashMapLength = 1 << kHashMapLengthLog2; | 92 static const int kHashMapLength = 1 << kHashMapLengthLog2; |
| 90 | 93 |
| 91 void Compact(); | 94 void Compact(); |
| 92 static void GCPrologue(GCType type, GCCallbackFlags flags); | 95 static void GCPrologue(GCType type, GCCallbackFlags flags); |
| 93 static void GCEpilogue(GCType type, GCCallbackFlags flags); | 96 static void GCEpilogue(GCType type, GCCallbackFlags flags); |
| 94 | 97 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 VirtualMemory* virtual_memory_; | 150 VirtualMemory* virtual_memory_; |
| 148 uintptr_t* hash_map_1_; | 151 uintptr_t* hash_map_1_; |
| 149 uintptr_t* hash_map_2_; | 152 uintptr_t* hash_map_2_; |
| 150 | 153 |
| 151 void CheckForFullBuffer(); | 154 void CheckForFullBuffer(); |
| 152 void Uniq(); | 155 void Uniq(); |
| 153 void ZapHashTables(); | 156 void ZapHashTables(); |
| 154 bool HashTablesAreZapped(); | 157 bool HashTablesAreZapped(); |
| 155 void ExemptPopularPages(int prime_sample_step, int threshold); | 158 void ExemptPopularPages(int prime_sample_step, int threshold); |
| 156 | 159 |
| 157 void FindPointersToNewSpaceInRegion(Address start, | 160 enum RecordNewSpacePointers { |
| 158 Address end, | 161 kDontRecord, |
| 159 ObjectSlotCallback slot_callback); | 162 kRecord |
| 163 }; |
| 164 |
| 165 template<RecordNewSpacePointers record> |
| 166 inline void FindPointersToNewSpaceInRegion(Address start, |
| 167 Address end, |
| 168 ObjectSlotCallback slot_callback); |
| 169 |
| 170 // It seems gcc doesn't want to take the address of a templated method, |
| 171 // so we create a new method so that we can give the address. Also, |
| 172 // pointers to methods tend to have gnarly implementations. |
| 173 static void FindPointersToNewSpaceInRegionRecord( |
| 174 StoreBuffer* store_buffer, |
| 175 Address start, |
| 176 Address end, |
| 177 ObjectSlotCallback slot_callback); |
| 178 |
| 179 static void FindPointersToNewSpaceInRegionDontRecord( |
| 180 StoreBuffer* store_buffer, |
| 181 Address start, |
| 182 Address end, |
| 183 ObjectSlotCallback slot_callback); |
| 160 | 184 |
| 161 // For each region of pointers on a page in use from an old space call | 185 // For each region of pointers on a page in use from an old space call |
| 162 // visit_pointer_region callback. | 186 // visit_pointer_region callback. |
| 163 // If either visit_pointer_region or callback can cause an allocation | 187 // If either visit_pointer_region or callback can cause an allocation |
| 164 // in old space and changes in allocation watermark then | 188 // in old space and changes in allocation watermark then |
| 165 // can_preallocate_during_iteration should be set to true. | 189 // can_preallocate_during_iteration should be set to true. |
| 166 void IteratePointersOnPage( | 190 void IteratePointersOnPage( |
| 167 PagedSpace* space, | 191 PagedSpace* space, |
| 168 Page* page, | 192 Page* page, |
| 169 RegionCallback region_callback, | 193 RegionCallback region_callback, |
| 170 ObjectSlotCallback slot_callback); | 194 ObjectSlotCallback slot_callback); |
| 171 | 195 |
| 172 void FindPointersToNewSpaceInMaps( | 196 void FindPointersToNewSpaceInMaps( |
| 173 Address start, | 197 Address start, |
| 174 Address end, | 198 Address end, |
| 175 ObjectSlotCallback slot_callback); | 199 ObjectSlotCallback slot_callback); |
| 176 | 200 |
| 177 void FindPointersToNewSpaceInMapsRegion( | 201 static void FindPointersToNewSpaceInMapsRegion( |
| 202 StoreBuffer* store_buffer, |
| 178 Address start, | 203 Address start, |
| 179 Address end, | 204 Address end, |
| 180 ObjectSlotCallback slot_callback); | 205 ObjectSlotCallback slot_callback); |
| 181 | 206 |
| 182 void FindPointersToNewSpaceOnPage( | 207 void FindPointersToNewSpaceOnPage( |
| 183 PagedSpace* space, | 208 PagedSpace* space, |
| 184 Page* page, | 209 Page* page, |
| 185 RegionCallback region_callback, | 210 RegionCallback region_callback, |
| 186 ObjectSlotCallback slot_callback); | 211 ObjectSlotCallback slot_callback); |
| 187 | 212 |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 } | 263 } |
| 239 | 264 |
| 240 private: | 265 private: |
| 241 StoreBuffer* store_buffer_; | 266 StoreBuffer* store_buffer_; |
| 242 bool stored_state_; | 267 bool stored_state_; |
| 243 }; | 268 }; |
| 244 | 269 |
| 245 } } // namespace v8::internal | 270 } } // namespace v8::internal |
| 246 | 271 |
| 247 #endif // V8_STORE_BUFFER_H_ | 272 #endif // V8_STORE_BUFFER_H_ |
| OLD | NEW |