| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_STORE_BUFFER_H_ | 5 #ifndef VM_STORE_BUFFER_H_ |
| 6 #define VM_STORE_BUFFER_H_ | 6 #define VM_STORE_BUFFER_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // takes ownership of the returned block. | 90 // takes ownership of the returned block. |
| 91 StoreBufferBlock* PopBlock(); | 91 StoreBufferBlock* PopBlock(); |
| 92 StoreBufferBlock* PopEmptyBlock(); | 92 StoreBufferBlock* PopEmptyBlock(); |
| 93 | 93 |
| 94 // Pops and returns all non-empty blocks as a linked list (owned by caller). | 94 // Pops and returns all non-empty blocks as a linked list (owned by caller). |
| 95 StoreBufferBlock* Blocks(); | 95 StoreBufferBlock* Blocks(); |
| 96 | 96 |
| 97 // Discards the contents of this store buffer. | 97 // Discards the contents of this store buffer. |
| 98 void Reset(); | 98 void Reset(); |
| 99 | 99 |
| 100 // Check whether non-empty blocks have exceeded kMaxNonEmpty. |
| 101 bool Overflowed(); |
| 102 |
| 100 private: | 103 private: |
| 101 class List { | 104 class List { |
| 102 public: | 105 public: |
| 103 List() : head_(NULL), length_(0) {} | 106 List() : head_(NULL), length_(0) {} |
| 104 ~List(); | 107 ~List(); |
| 105 void Push(StoreBufferBlock* block); | 108 void Push(StoreBufferBlock* block); |
| 106 StoreBufferBlock* Pop(); | 109 StoreBufferBlock* Pop(); |
| 107 intptr_t length() const { return length_; } | 110 intptr_t length() const { return length_; } |
| 108 bool IsEmpty() const { return head_ == NULL; } | 111 bool IsEmpty() const { return head_ == NULL; } |
| 109 StoreBufferBlock* PopAll(); | 112 StoreBufferBlock* PopAll(); |
| 110 private: | 113 private: |
| 111 StoreBufferBlock* head_; | 114 StoreBufferBlock* head_; |
| 112 intptr_t length_; | 115 intptr_t length_; |
| 113 DISALLOW_COPY_AND_ASSIGN(List); | 116 DISALLOW_COPY_AND_ASSIGN(List); |
| 114 }; | 117 }; |
| 115 | 118 |
| 116 // Check if we run over the max number of deduplication sets. | |
| 117 // If we did schedule an interrupt. | |
| 118 void CheckThresholdNonEmpty(); | |
| 119 | |
| 120 // If needed, trims the the global cache of empty blocks. | 119 // If needed, trims the the global cache of empty blocks. |
| 121 static void TrimGlobalEmpty(); | 120 static void TrimGlobalEmpty(); |
| 122 | 121 |
| 123 List full_; | 122 List full_; |
| 124 List partial_; | 123 List partial_; |
| 125 Mutex* mutex_; | 124 Mutex* mutex_; |
| 126 | 125 |
| 127 static const intptr_t kMaxGlobalEmpty = 100; | 126 static const intptr_t kMaxGlobalEmpty = 100; |
| 128 static List* global_empty_; | 127 static List* global_empty_; |
| 129 static Mutex* global_mutex_; | 128 static Mutex* global_mutex_; |
| 130 | 129 |
| 131 DISALLOW_COPY_AND_ASSIGN(StoreBuffer); | 130 DISALLOW_COPY_AND_ASSIGN(StoreBuffer); |
| 132 }; | 131 }; |
| 133 | 132 |
| 134 } // namespace dart | 133 } // namespace dart |
| 135 | 134 |
| 136 #endif // VM_STORE_BUFFER_H_ | 135 #endif // VM_STORE_BUFFER_H_ |
| OLD | NEW |