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 #include "vm/store_buffer.h" | 5 #include "vm/store_buffer.h" |
6 | 6 |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/lockers.h" | 8 #include "vm/lockers.h" |
9 #include "vm/runtime_entry.h" | 9 #include "vm/runtime_entry.h" |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 DEFINE_LEAF_RUNTIME_ENTRY(void, StoreBufferBlockProcess, 1, Thread* thread) { | 13 DEFINE_LEAF_RUNTIME_ENTRY(void, StoreBufferBlockProcess, 1, Thread* thread) { |
14 thread->StoreBufferBlockProcess(true); | 14 thread->StoreBufferBlockProcess(true); |
15 } | 15 } |
16 END_LEAF_RUNTIME_ENTRY | 16 END_LEAF_RUNTIME_ENTRY |
17 | 17 |
18 | 18 |
19 StoreBuffer::List* StoreBuffer::global_empty_ = NULL; | 19 StoreBuffer::List* StoreBuffer::global_empty_ = NULL; |
20 Mutex* StoreBuffer::global_mutex_ = NULL; | 20 Mutex* StoreBuffer::global_mutex_ = NULL; |
21 | 21 |
22 | 22 |
23 void StoreBuffer::InitOnce() { | 23 void StoreBuffer::InitOnce() { |
24 global_empty_ = new List(); | 24 global_empty_ = new List(); |
25 global_mutex_ = new Mutex(); | 25 global_mutex_ = new Mutex(); |
26 } | 26 } |
27 | 27 |
28 | 28 |
| 29 void StoreBuffer::ShutDown() { |
| 30 delete global_empty_; |
| 31 delete global_mutex_; |
| 32 } |
| 33 |
| 34 |
29 StoreBuffer::StoreBuffer() : mutex_(new Mutex()) { | 35 StoreBuffer::StoreBuffer() : mutex_(new Mutex()) { |
30 } | 36 } |
31 | 37 |
32 | 38 |
33 StoreBuffer::~StoreBuffer() { | 39 StoreBuffer::~StoreBuffer() { |
34 Reset(); | 40 Reset(); |
35 delete mutex_; | 41 delete mutex_; |
36 } | 42 } |
37 | 43 |
38 | 44 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 104 } |
99 } | 105 } |
100 return PopEmptyBlock(); | 106 return PopEmptyBlock(); |
101 } | 107 } |
102 | 108 |
103 | 109 |
104 StoreBufferBlock* StoreBuffer::PopEmptyBlock() { | 110 StoreBufferBlock* StoreBuffer::PopEmptyBlock() { |
105 { | 111 { |
106 MutexLocker ml(global_mutex_); | 112 MutexLocker ml(global_mutex_); |
107 if (!global_empty_->IsEmpty()) { | 113 if (!global_empty_->IsEmpty()) { |
108 global_empty_->Pop(); | 114 return global_empty_->Pop(); |
109 } | 115 } |
110 } | 116 } |
111 return new StoreBufferBlock(); | 117 return new StoreBufferBlock(); |
112 } | 118 } |
113 | 119 |
114 | 120 |
115 StoreBufferBlock* StoreBuffer::PopNonEmptyBlock() { | 121 StoreBufferBlock* StoreBuffer::PopNonEmptyBlock() { |
116 MutexLocker ml(mutex_); | 122 MutexLocker ml(mutex_); |
117 if (!full_.IsEmpty()) { | 123 if (!full_.IsEmpty()) { |
118 return full_.Pop(); | 124 return full_.Pop(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 175 |
170 | 176 |
171 void StoreBuffer::TrimGlobalEmpty() { | 177 void StoreBuffer::TrimGlobalEmpty() { |
172 DEBUG_ASSERT(global_mutex_->IsOwnedByCurrentThread()); | 178 DEBUG_ASSERT(global_mutex_->IsOwnedByCurrentThread()); |
173 while (global_empty_->length() > kMaxGlobalEmpty) { | 179 while (global_empty_->length() > kMaxGlobalEmpty) { |
174 delete global_empty_->Pop(); | 180 delete global_empty_->Pop(); |
175 } | 181 } |
176 } | 182 } |
177 | 183 |
178 } // namespace dart | 184 } // namespace dart |
OLD | NEW |