| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 static void InitOnce(); | 81 static void InitOnce(); |
| 82 | 82 |
| 83 // Interrupt when crossing this threshold of non-empty blocks in the buffer. | 83 // Interrupt when crossing this threshold of non-empty blocks in the buffer. |
| 84 static const intptr_t kMaxNonEmpty = 100; | 84 static const intptr_t kMaxNonEmpty = 100; |
| 85 | 85 |
| 86 // Adds and transfers ownership of the block to the buffer. | 86 // Adds and transfers ownership of the block to the buffer. |
| 87 void PushBlock(StoreBufferBlock* block, bool check_threshold = true); | 87 void PushBlock(StoreBufferBlock* block, bool check_threshold = true); |
| 88 // Partially filled blocks can be reused, and there is an "inifite" supply | 88 // Partially filled blocks can be reused, and there is an "inifite" supply |
| 89 // of empty blocks (reused or newly allocated). In any case, the caller | 89 // of empty blocks (reused or newly allocated). In any case, the caller |
| 90 // takes ownership of the returned block. | 90 // takes ownership of the returned block. |
| 91 StoreBufferBlock* PopBlock(); | 91 StoreBufferBlock* PopNonFullBlock(); |
| 92 StoreBufferBlock* PopEmptyBlock(); | 92 StoreBufferBlock* PopEmptyBlock(); |
| 93 StoreBufferBlock* PopNonEmptyBlock(); |
| 93 | 94 |
| 94 // Pops and returns all non-empty blocks as a linked list (owned by caller). | 95 // Pops and returns all non-empty blocks as a linked list (owned by caller). |
| 95 StoreBufferBlock* Blocks(); | 96 StoreBufferBlock* Blocks(); |
| 96 | 97 |
| 97 // Discards the contents of this store buffer. | 98 // Discards the contents of this store buffer. |
| 98 void Reset(); | 99 void Reset(); |
| 99 | 100 |
| 100 // Check whether non-empty blocks have exceeded kMaxNonEmpty. | 101 // Check whether non-empty blocks have exceeded kMaxNonEmpty. |
| 101 bool Overflowed(); | 102 bool Overflowed(); |
| 102 | 103 |
| 104 bool IsEmpty(); |
| 105 |
| 103 private: | 106 private: |
| 104 class List { | 107 class List { |
| 105 public: | 108 public: |
| 106 List() : head_(NULL), length_(0) {} | 109 List() : head_(NULL), length_(0) {} |
| 107 ~List(); | 110 ~List(); |
| 108 void Push(StoreBufferBlock* block); | 111 void Push(StoreBufferBlock* block); |
| 109 StoreBufferBlock* Pop(); | 112 StoreBufferBlock* Pop(); |
| 110 intptr_t length() const { return length_; } | 113 intptr_t length() const { return length_; } |
| 111 bool IsEmpty() const { return head_ == NULL; } | 114 bool IsEmpty() const { return head_ == NULL; } |
| 112 StoreBufferBlock* PopAll(); | 115 StoreBufferBlock* PopAll(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 126 static const intptr_t kMaxGlobalEmpty = 100; | 129 static const intptr_t kMaxGlobalEmpty = 100; |
| 127 static List* global_empty_; | 130 static List* global_empty_; |
| 128 static Mutex* global_mutex_; | 131 static Mutex* global_mutex_; |
| 129 | 132 |
| 130 DISALLOW_COPY_AND_ASSIGN(StoreBuffer); | 133 DISALLOW_COPY_AND_ASSIGN(StoreBuffer); |
| 131 }; | 134 }; |
| 132 | 135 |
| 133 } // namespace dart | 136 } // namespace dart |
| 134 | 137 |
| 135 #endif // VM_STORE_BUFFER_H_ | 138 #endif // VM_STORE_BUFFER_H_ |
| OLD | NEW |