24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "gc/shared/ptrQueue.hpp" |
26 #include "gc/shared/ptrQueue.hpp" |
27 #include "memory/allocation.hpp" |
27 #include "memory/allocation.hpp" |
28 #include "runtime/interfaceSupport.inline.hpp" |
28 #include "runtime/interfaceSupport.inline.hpp" |
29 #include "runtime/orderAccess.hpp" |
29 #include "runtime/atomic.hpp" |
30 #include "runtime/semaphore.inline.hpp" |
30 #include "runtime/semaphore.inline.hpp" |
31 #include "runtime/thread.hpp" |
31 #include "runtime/thread.hpp" |
32 #include "utilities/globalCounter.inline.hpp" |
32 #include "utilities/globalCounter.inline.hpp" |
33 #include "utilities/globalDefinitions.hpp" |
33 #include "utilities/globalDefinitions.hpp" |
34 #include "utilities/ostream.hpp" |
34 #include "utilities/ostream.hpp" |
148 _continue_running(continue_running), |
148 _continue_running(continue_running), |
149 _allocations(0) |
149 _allocations(0) |
150 {} |
150 {} |
151 |
151 |
152 virtual void main_run() { |
152 virtual void main_run() { |
153 while (OrderAccess::load_acquire(_continue_running)) { |
153 while (Atomic::load_acquire(_continue_running)) { |
154 BufferNode* node = _allocator->allocate(); |
154 BufferNode* node = _allocator->allocate(); |
155 _cbl->push(node); |
155 _cbl->push(node); |
156 ++_allocations; |
156 ++_allocations; |
157 ThreadBlockInVM tbiv(this); // Safepoint check. |
157 ThreadBlockInVM tbiv(this); // Safepoint check. |
158 } |
158 } |
182 virtual void main_run() { |
182 virtual void main_run() { |
183 while (true) { |
183 while (true) { |
184 BufferNode* node = _cbl->pop(); |
184 BufferNode* node = _cbl->pop(); |
185 if (node != NULL) { |
185 if (node != NULL) { |
186 _allocator->release(node); |
186 _allocator->release(node); |
187 } else if (!OrderAccess::load_acquire(_continue_running)) { |
187 } else if (!Atomic::load_acquire(_continue_running)) { |
188 return; |
188 return; |
189 } |
189 } |
190 ThreadBlockInVM tbiv(this); // Safepoint check. |
190 ThreadBlockInVM tbiv(this); // Safepoint check. |
191 } |
191 } |
192 } |
192 } |
224 tty->print_cr("Stressing allocator for %u ms", milliseconds_to_run); |
224 tty->print_cr("Stressing allocator for %u ms", milliseconds_to_run); |
225 { |
225 { |
226 ThreadInVMfromNative invm(this_thread); |
226 ThreadInVMfromNative invm(this_thread); |
227 this_thread->sleep(milliseconds_to_run); |
227 this_thread->sleep(milliseconds_to_run); |
228 } |
228 } |
229 OrderAccess::release_store(&allocator_running, false); |
229 Atomic::release_store(&allocator_running, false); |
230 for (uint i = 0; i < nthreads; ++i) { |
230 for (uint i = 0; i < nthreads; ++i) { |
231 ThreadInVMfromNative invm(this_thread); |
231 ThreadInVMfromNative invm(this_thread); |
232 post.wait_with_safepoint_check(this_thread); |
232 post.wait_with_safepoint_check(this_thread); |
233 } |
233 } |
234 OrderAccess::release_store(&processor_running, false); |
234 Atomic::release_store(&processor_running, false); |
235 for (uint i = 0; i < nthreads; ++i) { |
235 for (uint i = 0; i < nthreads; ++i) { |
236 ThreadInVMfromNative invm(this_thread); |
236 ThreadInVMfromNative invm(this_thread); |
237 post.wait_with_safepoint_check(this_thread); |
237 post.wait_with_safepoint_check(this_thread); |
238 } |
238 } |
239 ASSERT_TRUE(BufferNode::TestSupport::try_transfer_pending(allocator)); |
239 ASSERT_TRUE(BufferNode::TestSupport::try_transfer_pending(allocator)); |