Chromium Code Reviews| 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 24 matching lines...) Expand all Loading... | |
| 35 void Push(RawObject* obj) { | 35 void Push(RawObject* obj) { |
| 36 ASSERT(!IsFull()); | 36 ASSERT(!IsFull()); |
| 37 pointers_[top_++] = obj; | 37 pointers_[top_++] = obj; |
| 38 } | 38 } |
| 39 | 39 |
| 40 RawObject* Pop() { | 40 RawObject* Pop() { |
| 41 ASSERT(!IsEmpty()); | 41 ASSERT(!IsEmpty()); |
| 42 return pointers_[--top_]; | 42 return pointers_[--top_]; |
| 43 } | 43 } |
| 44 | 44 |
| 45 RawObject* At(intptr_t index) { | |
|
Ivan Posva
2015/08/06 07:02:09
Is this still needed?
koda
2015/08/07 12:59:07
No. Removed.
| |
| 46 ASSERT(0 <= index && index < top_); | |
| 47 return pointers_[index]; | |
| 48 } | |
| 49 | |
| 45 #if defined(TESTING) | 50 #if defined(TESTING) |
| 46 bool Contains(RawObject* obj) const { | 51 bool Contains(RawObject* obj) const { |
| 47 for (intptr_t i = 0; i < Count(); i++) { | 52 for (intptr_t i = 0; i < Count(); i++) { |
| 48 if (pointers_[i] == obj) { | 53 if (pointers_[i] == obj) { |
| 49 return true; | 54 return true; |
| 50 } | 55 } |
| 51 } | 56 } |
| 52 return false; | 57 return false; |
| 53 } | 58 } |
| 54 #endif // TESTING | 59 #endif // TESTING |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 81 static void InitOnce(); | 86 static void InitOnce(); |
| 82 | 87 |
| 83 // Interrupt when crossing this threshold of non-empty blocks in the buffer. | 88 // Interrupt when crossing this threshold of non-empty blocks in the buffer. |
| 84 static const intptr_t kMaxNonEmpty = 100; | 89 static const intptr_t kMaxNonEmpty = 100; |
| 85 | 90 |
| 86 // Adds and transfers ownership of the block to the buffer. | 91 // Adds and transfers ownership of the block to the buffer. |
| 87 void PushBlock(StoreBufferBlock* block, bool check_threshold = true); | 92 void PushBlock(StoreBufferBlock* block, bool check_threshold = true); |
| 88 // Partially filled blocks can be reused, and there is an "inifite" supply | 93 // 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 | 94 // of empty blocks (reused or newly allocated). In any case, the caller |
| 90 // takes ownership of the returned block. | 95 // takes ownership of the returned block. |
| 91 StoreBufferBlock* PopBlock(); | 96 StoreBufferBlock* PopNonFullBlock(); |
| 92 StoreBufferBlock* PopEmptyBlock(); | 97 StoreBufferBlock* PopEmptyBlock(); |
| 98 StoreBufferBlock* PopNonEmptyBlock(); | |
| 93 | 99 |
| 94 // Pops and returns all non-empty blocks as a linked list (owned by caller). | 100 // Pops and returns all non-empty blocks as a linked list (owned by caller). |
| 95 StoreBufferBlock* Blocks(); | 101 StoreBufferBlock* Blocks(); |
| 96 | 102 |
| 97 // Discards the contents of this store buffer. | 103 // Discards the contents of this store buffer. |
| 98 void Reset(); | 104 void Reset(); |
| 99 | 105 |
| 100 // Check whether non-empty blocks have exceeded kMaxNonEmpty. | 106 // Check whether non-empty blocks have exceeded kMaxNonEmpty. |
| 101 bool Overflowed(); | 107 bool Overflowed(); |
| 102 | 108 |
| 109 bool IsEmpty(); | |
| 110 | |
| 103 private: | 111 private: |
| 104 class List { | 112 class List { |
| 105 public: | 113 public: |
| 106 List() : head_(NULL), length_(0) {} | 114 List() : head_(NULL), length_(0) {} |
| 107 ~List(); | 115 ~List(); |
| 108 void Push(StoreBufferBlock* block); | 116 void Push(StoreBufferBlock* block); |
| 109 StoreBufferBlock* Pop(); | 117 StoreBufferBlock* Pop(); |
| 110 intptr_t length() const { return length_; } | 118 intptr_t length() const { return length_; } |
| 111 bool IsEmpty() const { return head_ == NULL; } | 119 bool IsEmpty() const { return head_ == NULL; } |
| 112 StoreBufferBlock* PopAll(); | 120 StoreBufferBlock* PopAll(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 126 static const intptr_t kMaxGlobalEmpty = 100; | 134 static const intptr_t kMaxGlobalEmpty = 100; |
| 127 static List* global_empty_; | 135 static List* global_empty_; |
| 128 static Mutex* global_mutex_; | 136 static Mutex* global_mutex_; |
| 129 | 137 |
| 130 DISALLOW_COPY_AND_ASSIGN(StoreBuffer); | 138 DISALLOW_COPY_AND_ASSIGN(StoreBuffer); |
| 131 }; | 139 }; |
| 132 | 140 |
| 133 } // namespace dart | 141 } // namespace dart |
| 134 | 142 |
| 135 #endif // VM_STORE_BUFFER_H_ | 143 #endif // VM_STORE_BUFFER_H_ |
| OLD | NEW |