diff -r 64752e56d721 -r be27e1b6a4b9 hotspot/src/share/vm/utilities/taskqueue.hpp --- a/hotspot/src/share/vm/utilities/taskqueue.hpp Wed Jun 27 15:23:36 2012 +0200 +++ b/hotspot/src/share/vm/utilities/taskqueue.hpp Thu Jun 28 17:03:16 2012 -0400 @@ -132,8 +132,8 @@ } #endif // TASKQUEUE_STATS -template -class TaskQueueSuper: public CHeapObj { +template +class TaskQueueSuper: public CHeapObj { protected: // Internal type for indexing the queue; also used for the tag. typedef NOT_LP64(uint16_t) LP64_ONLY(uint32_t) idx_t; @@ -249,22 +249,27 @@ TASKQUEUE_STATS_ONLY(TaskQueueStats stats;) }; -template -class GenericTaskQueue: public TaskQueueSuper { -protected: - typedef typename TaskQueueSuper::Age Age; - typedef typename TaskQueueSuper::idx_t idx_t; + - using TaskQueueSuper::_bottom; - using TaskQueueSuper::_age; - using TaskQueueSuper::increment_index; - using TaskQueueSuper::decrement_index; - using TaskQueueSuper::dirty_size; +template +class GenericTaskQueue: public TaskQueueSuper { +protected: + typedef typename TaskQueueSuper::Age Age; + typedef typename TaskQueueSuper::idx_t idx_t; + + using TaskQueueSuper::_bottom; + using TaskQueueSuper::_age; + using TaskQueueSuper::increment_index; + using TaskQueueSuper::decrement_index; + using TaskQueueSuper::dirty_size; public: - using TaskQueueSuper::max_elems; - using TaskQueueSuper::size; - TASKQUEUE_STATS_ONLY(using TaskQueueSuper::stats;) + using TaskQueueSuper::max_elems; + using TaskQueueSuper::size; + +#if TASKQUEUE_STATS + using TaskQueueSuper::stats; +#endif private: // Slow paths for push, pop_local. (pop_global has no fast path.) @@ -302,18 +307,18 @@ volatile E* _elems; }; -template -GenericTaskQueue::GenericTaskQueue() { +template +GenericTaskQueue::GenericTaskQueue() { assert(sizeof(Age) == sizeof(size_t), "Depends on this."); } -template -void GenericTaskQueue::initialize() { - _elems = NEW_C_HEAP_ARRAY(E, N); +template +void GenericTaskQueue::initialize() { + _elems = NEW_C_HEAP_ARRAY(E, N, F); } -template -void GenericTaskQueue::oops_do(OopClosure* f) { +template +void GenericTaskQueue::oops_do(OopClosure* f) { // tty->print_cr("START OopTaskQueue::oops_do"); uint iters = size(); uint index = _bottom; @@ -329,8 +334,8 @@ // tty->print_cr("END OopTaskQueue::oops_do"); } -template -bool GenericTaskQueue::push_slow(E t, uint dirty_n_elems) { +template +bool GenericTaskQueue::push_slow(E t, uint dirty_n_elems) { if (dirty_n_elems == N - 1) { // Actually means 0, so do the push. uint localBot = _bottom; @@ -349,8 +354,8 @@ // whenever the queue goes empty which it will do here if this thread // gets the last task or in pop_global() if the queue wraps (top == 0 // and pop_global() succeeds, see pop_global()). -template -bool GenericTaskQueue::pop_local_slow(uint localBot, Age oldAge) { +template +bool GenericTaskQueue::pop_local_slow(uint localBot, Age oldAge) { // This queue was observed to contain exactly one element; either this // thread will claim it, or a competing "pop_global". In either case, // the queue will be logically empty afterwards. Create a new Age value @@ -382,8 +387,8 @@ return false; } -template -bool GenericTaskQueue::pop_global(E& t) { +template +bool GenericTaskQueue::pop_global(E& t) { Age oldAge = _age.get(); uint localBot = _bottom; uint n_elems = size(localBot, oldAge.top()); @@ -402,9 +407,9 @@ return resAge == oldAge; } -template -GenericTaskQueue::~GenericTaskQueue() { - FREE_C_HEAP_ARRAY(E, _elems); +template +GenericTaskQueue::~GenericTaskQueue() { + FREE_C_HEAP_ARRAY(E, _elems, F); } // OverflowTaskQueue is a TaskQueue that also includes an overflow stack for @@ -418,12 +423,12 @@ // Note that size() is not hidden--it returns the number of elements in the // TaskQueue, and does not include the size of the overflow stack. This // simplifies replacement of GenericTaskQueues with OverflowTaskQueues. -template -class OverflowTaskQueue: public GenericTaskQueue +template +class OverflowTaskQueue: public GenericTaskQueue { public: - typedef Stack overflow_t; - typedef GenericTaskQueue taskqueue_t; + typedef Stack overflow_t; + typedef GenericTaskQueue taskqueue_t; TASKQUEUE_STATS_ONLY(using taskqueue_t::stats;) @@ -445,8 +450,8 @@ overflow_t _overflow_stack; }; -template -bool OverflowTaskQueue::push(E t) +template +bool OverflowTaskQueue::push(E t) { if (!taskqueue_t::push(t)) { overflow_stack()->push(t); @@ -455,15 +460,15 @@ return true; } -template -bool OverflowTaskQueue::pop_overflow(E& t) +template +bool OverflowTaskQueue::pop_overflow(E& t) { if (overflow_empty()) return false; t = overflow_stack()->pop(); return true; } -class TaskQueueSetSuper: public CHeapObj { +class TaskQueueSetSuper { protected: static int randomParkAndMiller(int* seed0); public: @@ -471,8 +476,11 @@ virtual bool peek() = 0; }; -template -class GenericTaskQueueSet: public TaskQueueSetSuper { +template class TaskQueueSetSuperImpl: public CHeapObj, public TaskQueueSetSuper { +}; + +template +class GenericTaskQueueSet: public TaskQueueSetSuperImpl { private: uint _n; T** _queues; @@ -482,7 +490,7 @@ GenericTaskQueueSet(int n) : _n(n) { typedef T* GenericTaskQueuePtr; - _queues = NEW_C_HEAP_ARRAY(GenericTaskQueuePtr, n); + _queues = NEW_C_HEAP_ARRAY(GenericTaskQueuePtr, n, F); for (int i = 0; i < n; i++) { _queues[i] = NULL; } @@ -506,19 +514,19 @@ bool peek(); }; -template void -GenericTaskQueueSet::register_queue(uint i, T* q) { +template void +GenericTaskQueueSet::register_queue(uint i, T* q) { assert(i < _n, "index out of range."); _queues[i] = q; } -template T* -GenericTaskQueueSet::queue(uint i) { +template T* +GenericTaskQueueSet::queue(uint i) { return _queues[i]; } -template bool -GenericTaskQueueSet::steal(uint queue_num, int* seed, E& t) { +template bool +GenericTaskQueueSet::steal(uint queue_num, int* seed, E& t) { for (uint i = 0; i < 2 * _n; i++) { if (steal_best_of_2(queue_num, seed, t)) { TASKQUEUE_STATS_ONLY(queue(queue_num)->stats.record_steal(true)); @@ -529,8 +537,8 @@ return false; } -template bool -GenericTaskQueueSet::steal_best_of_all(uint queue_num, int* seed, E& t) { +template bool +GenericTaskQueueSet::steal_best_of_all(uint queue_num, int* seed, E& t) { if (_n > 2) { int best_k; uint best_sz = 0; @@ -553,11 +561,11 @@ } } -template bool -GenericTaskQueueSet::steal_1_random(uint queue_num, int* seed, E& t) { +template bool +GenericTaskQueueSet::steal_1_random(uint queue_num, int* seed, E& t) { if (_n > 2) { uint k = queue_num; - while (k == queue_num) k = randomParkAndMiller(seed) % _n; + while (k == queue_num) k = TaskQueueSetSuper::randomParkAndMiller(seed) % _n; return _queues[2]->pop_global(t); } else if (_n == 2) { // Just try the other one. @@ -569,13 +577,13 @@ } } -template bool -GenericTaskQueueSet::steal_best_of_2(uint queue_num, int* seed, E& t) { +template bool +GenericTaskQueueSet::steal_best_of_2(uint queue_num, int* seed, E& t) { if (_n > 2) { uint k1 = queue_num; - while (k1 == queue_num) k1 = randomParkAndMiller(seed) % _n; + while (k1 == queue_num) k1 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n; uint k2 = queue_num; - while (k2 == queue_num || k2 == k1) k2 = randomParkAndMiller(seed) % _n; + while (k2 == queue_num || k2 == k1) k2 = TaskQueueSetSuper::randomParkAndMiller(seed) % _n; // Sample both and try the larger. uint sz1 = _queues[k1]->size(); uint sz2 = _queues[k2]->size(); @@ -591,8 +599,8 @@ } } -template -bool GenericTaskQueueSet::peek() { +template +bool GenericTaskQueueSet::peek() { // Try all the queues. for (uint j = 0; j < _n; j++) { if (_queues[j]->peek()) @@ -602,7 +610,7 @@ } // When to terminate from the termination protocol. -class TerminatorTerminator: public CHeapObj { +class TerminatorTerminator: public CHeapObj { public: virtual bool should_exit_termination() = 0; }; @@ -665,8 +673,8 @@ #endif }; -template inline bool -GenericTaskQueue::push(E t) { +template inline bool +GenericTaskQueue::push(E t) { uint localBot = _bottom; assert((localBot >= 0) && (localBot < N), "_bottom out of range."); idx_t top = _age.top(); @@ -683,8 +691,8 @@ } } -template inline bool -GenericTaskQueue::pop_local(E& t) { +template inline bool +GenericTaskQueue::pop_local(E& t) { uint localBot = _bottom; // This value cannot be N-1. That can only occur as a result of // the assignment to bottom in this method. If it does, this method @@ -715,8 +723,8 @@ } } -typedef GenericTaskQueue OopTaskQueue; -typedef GenericTaskQueueSet OopTaskQueueSet; +typedef GenericTaskQueue OopTaskQueue; +typedef GenericTaskQueueSet OopTaskQueueSet; #ifdef _MSC_VER #pragma warning(push) @@ -796,11 +804,11 @@ #pragma warning(pop) #endif -typedef OverflowTaskQueue OopStarTaskQueue; -typedef GenericTaskQueueSet OopStarTaskQueueSet; +typedef OverflowTaskQueue OopStarTaskQueue; +typedef GenericTaskQueueSet OopStarTaskQueueSet; -typedef OverflowTaskQueue RegionTaskQueue; -typedef GenericTaskQueueSet RegionTaskQueueSet; +typedef OverflowTaskQueue RegionTaskQueue; +typedef GenericTaskQueueSet RegionTaskQueueSet; #endif // SHARE_VM_UTILITIES_TASKQUEUE_HPP