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