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" |
(...skipping 15 matching lines...) Expand all Loading... |
26 explicit StoreBuffer(Heap* heap); | 26 explicit StoreBuffer(Heap* heap); |
27 | 27 |
28 static void StoreBufferOverflow(Isolate* isolate); | 28 static void StoreBufferOverflow(Isolate* isolate); |
29 | 29 |
30 void SetUp(); | 30 void SetUp(); |
31 void TearDown(); | 31 void TearDown(); |
32 | 32 |
33 // This is used to add addresses to the store buffer non-concurrently. | 33 // This is used to add addresses to the store buffer non-concurrently. |
34 inline void Mark(Address addr); | 34 inline void Mark(Address addr); |
35 | 35 |
| 36 // This is used to add addresses to the store buffer when multiple threads |
| 37 // may operate on the store buffer. |
| 38 inline void MarkSynchronized(Address addr); |
| 39 |
36 // This is used by the heap traversal to enter the addresses into the store | 40 // This is used by the heap traversal to enter the addresses into the store |
37 // buffer that should still be in the store buffer after GC. It enters | 41 // buffer that should still be in the store buffer after GC. It enters |
38 // addresses directly into the old buffer because the GC starts by wiping the | 42 // addresses directly into the old buffer because the GC starts by wiping the |
39 // old buffer and thereafter only visits each cell once so there is no need | 43 // old buffer and thereafter only visits each cell once so there is no need |
40 // to attempt to remove any dupes. During the first part of a GC we | 44 // to attempt to remove any dupes. During the first part of a GC we |
41 // are using the store buffer to access the old spaces and at the same time | 45 // are using the store buffer to access the old spaces and at the same time |
42 // we are rebuilding the store buffer using this function. There is, however | 46 // we are rebuilding the store buffer using this function. There is, however |
43 // no issue of overwriting the buffer we are iterating over, because this | 47 // no issue of overwriting the buffer we are iterating over, because this |
44 // stage of the scavenge can only reduce the number of addresses in the store | 48 // stage of the scavenge can only reduce the number of addresses in the store |
45 // buffer (some objects are promoted so pointers to them do not need to be in | 49 // buffer (some objects are promoted so pointers to them do not need to be in |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 209 } |
206 | 210 |
207 ~DontMoveStoreBufferEntriesScope() { | 211 ~DontMoveStoreBufferEntriesScope() { |
208 store_buffer_->may_move_store_buffer_entries_ = stored_state_; | 212 store_buffer_->may_move_store_buffer_entries_ = stored_state_; |
209 } | 213 } |
210 | 214 |
211 private: | 215 private: |
212 StoreBuffer* store_buffer_; | 216 StoreBuffer* store_buffer_; |
213 bool stored_state_; | 217 bool stored_state_; |
214 }; | 218 }; |
215 | |
216 class LocalStoreBuffer BASE_EMBEDDED { | |
217 public: | |
218 LocalStoreBuffer() : top_(new Node(nullptr)) {} | |
219 | |
220 ~LocalStoreBuffer() { | |
221 Node* current = top_; | |
222 while (current != nullptr) { | |
223 Node* tmp = current->next; | |
224 delete current; | |
225 current = tmp; | |
226 } | |
227 } | |
228 | |
229 inline void Record(Address addr); | |
230 inline void Process(StoreBuffer* store_buffer); | |
231 | |
232 private: | |
233 static const int kBufferSize = 16 * KB; | |
234 | |
235 struct Node : Malloced { | |
236 explicit Node(Node* next_node) : next(next_node), count(0) {} | |
237 | |
238 inline bool is_full() { return count == kBufferSize; } | |
239 | |
240 Node* next; | |
241 Address buffer[kBufferSize]; | |
242 int count; | |
243 }; | |
244 | |
245 Node* top_; | |
246 }; | |
247 | |
248 } // namespace internal | 219 } // namespace internal |
249 } // namespace v8 | 220 } // namespace v8 |
250 | 221 |
251 #endif // V8_STORE_BUFFER_H_ | 222 #endif // V8_STORE_BUFFER_H_ |
OLD | NEW |