2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2010-07-01 21:40:45 -07:00
|
|
|
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-07-16 21:33:21 -07:00
|
|
|
// Simple TaskQueue stats that are collected by default in debug builds.
|
|
|
|
|
|
|
|
#if !defined(TASKQUEUE_STATS) && defined(ASSERT)
|
|
|
|
#define TASKQUEUE_STATS 1
|
|
|
|
#elif !defined(TASKQUEUE_STATS)
|
|
|
|
#define TASKQUEUE_STATS 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if TASKQUEUE_STATS
|
|
|
|
#define TASKQUEUE_STATS_ONLY(code) code
|
|
|
|
#else
|
|
|
|
#define TASKQUEUE_STATS_ONLY(code)
|
|
|
|
#endif // TASKQUEUE_STATS
|
|
|
|
|
|
|
|
#if TASKQUEUE_STATS
|
|
|
|
class TaskQueueStats {
|
|
|
|
public:
|
|
|
|
enum StatId {
|
|
|
|
push, // number of taskqueue pushes
|
|
|
|
pop, // number of taskqueue pops
|
|
|
|
pop_slow, // subset of taskqueue pops that were done slow-path
|
|
|
|
steal_attempt, // number of taskqueue steal attempts
|
|
|
|
steal, // number of taskqueue steals
|
|
|
|
overflow, // number of overflow pushes
|
|
|
|
overflow_max_len, // max length of overflow stack
|
|
|
|
last_stat_id
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
|
|
|
inline TaskQueueStats() { reset(); }
|
|
|
|
|
|
|
|
inline void record_push() { ++_stats[push]; }
|
|
|
|
inline void record_pop() { ++_stats[pop]; }
|
|
|
|
inline void record_pop_slow() { record_pop(); ++_stats[pop_slow]; }
|
|
|
|
inline void record_steal(bool success);
|
|
|
|
inline void record_overflow(size_t new_length);
|
|
|
|
|
2010-08-09 05:41:05 -07:00
|
|
|
TaskQueueStats & operator +=(const TaskQueueStats & addend);
|
|
|
|
|
2010-07-16 21:33:21 -07:00
|
|
|
inline size_t get(StatId id) const { return _stats[id]; }
|
|
|
|
inline const size_t* get() const { return _stats; }
|
|
|
|
|
|
|
|
inline void reset();
|
|
|
|
|
2010-08-09 05:41:05 -07:00
|
|
|
// Print the specified line of the header (does not include a line separator).
|
2010-07-16 21:33:21 -07:00
|
|
|
static void print_header(unsigned int line, outputStream* const stream = tty,
|
|
|
|
unsigned int width = 10);
|
2010-08-09 05:41:05 -07:00
|
|
|
// Print the statistics (does not include a line separator).
|
2010-07-16 21:33:21 -07:00
|
|
|
void print(outputStream* const stream = tty, unsigned int width = 10) const;
|
|
|
|
|
2010-08-09 05:41:05 -07:00
|
|
|
DEBUG_ONLY(void verify() const;)
|
|
|
|
|
2010-07-16 21:33:21 -07:00
|
|
|
private:
|
|
|
|
size_t _stats[last_stat_id];
|
|
|
|
static const char * const _names[last_stat_id];
|
|
|
|
};
|
|
|
|
|
|
|
|
void TaskQueueStats::record_steal(bool success) {
|
|
|
|
++_stats[steal_attempt];
|
|
|
|
if (success) ++_stats[steal];
|
|
|
|
}
|
|
|
|
|
|
|
|
void TaskQueueStats::record_overflow(size_t new_len) {
|
|
|
|
++_stats[overflow];
|
|
|
|
if (new_len > _stats[overflow_max_len]) _stats[overflow_max_len] = new_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TaskQueueStats::reset() {
|
|
|
|
memset(_stats, 0, sizeof(_stats));
|
|
|
|
}
|
|
|
|
#endif // TASKQUEUE_STATS
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template <unsigned int N>
|
2007-12-01 00:00:00 +00:00
|
|
|
class TaskQueueSuper: public CHeapObj {
|
|
|
|
protected:
|
2009-08-05 12:33:29 -07:00
|
|
|
// Internal type for indexing the queue; also used for the tag.
|
|
|
|
typedef NOT_LP64(uint16_t) LP64_ONLY(uint32_t) idx_t;
|
|
|
|
|
|
|
|
// The first free element after the last one pushed (mod N).
|
2009-01-30 14:17:52 -08:00
|
|
|
volatile uint _bottom;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
enum { MOD_N_MASK = N - 1 };
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-08-05 12:33:29 -07:00
|
|
|
class Age {
|
|
|
|
public:
|
|
|
|
Age(size_t data = 0) { _data = data; }
|
|
|
|
Age(const Age& age) { _data = age._data; }
|
|
|
|
Age(idx_t top, idx_t tag) { _fields._top = top; _fields._tag = tag; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-08-05 12:33:29 -07:00
|
|
|
Age get() const volatile { return _data; }
|
|
|
|
void set(Age age) volatile { _data = age._data; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-08-05 12:33:29 -07:00
|
|
|
idx_t top() const volatile { return _fields._top; }
|
|
|
|
idx_t tag() const volatile { return _fields._tag; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-08-05 12:33:29 -07:00
|
|
|
// Increment top; if it wraps, increment tag also.
|
|
|
|
void increment() {
|
|
|
|
_fields._top = increment_index(_fields._top);
|
|
|
|
if (_fields._top == 0) ++_fields._tag;
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-08-05 12:33:29 -07:00
|
|
|
Age cmpxchg(const Age new_age, const Age old_age) volatile {
|
|
|
|
return (size_t) Atomic::cmpxchg_ptr((intptr_t)new_age._data,
|
|
|
|
(volatile intptr_t *)&_data,
|
|
|
|
(intptr_t)old_age._data);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2009-08-05 12:33:29 -07:00
|
|
|
|
|
|
|
bool operator ==(const Age& other) const { return _data == other._data; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct fields {
|
|
|
|
idx_t _top;
|
|
|
|
idx_t _tag;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
size_t _data;
|
|
|
|
fields _fields;
|
|
|
|
};
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
|
|
|
|
2009-08-05 12:33:29 -07:00
|
|
|
volatile Age _age;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-08-05 12:33:29 -07:00
|
|
|
// These both operate mod N.
|
|
|
|
static uint increment_index(uint ind) {
|
|
|
|
return (ind + 1) & MOD_N_MASK;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2009-08-05 12:33:29 -07:00
|
|
|
static uint decrement_index(uint ind) {
|
|
|
|
return (ind - 1) & MOD_N_MASK;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2009-08-05 12:33:29 -07:00
|
|
|
// Returns a number in the range [0..N). If the result is "N-1", it should be
|
|
|
|
// interpreted as 0.
|
2010-03-03 14:48:26 -08:00
|
|
|
uint dirty_size(uint bot, uint top) const {
|
2009-08-05 12:33:29 -07:00
|
|
|
return (bot - top) & MOD_N_MASK;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the size corresponding to the given "bot" and "top".
|
2010-03-03 14:48:26 -08:00
|
|
|
uint size(uint bot, uint top) const {
|
2009-01-30 14:17:52 -08:00
|
|
|
uint sz = dirty_size(bot, top);
|
2009-08-05 12:33:29 -07:00
|
|
|
// Has the queue "wrapped", so that bottom is less than top? There's a
|
|
|
|
// complicated special case here. A pair of threads could perform pop_local
|
|
|
|
// and pop_global operations concurrently, starting from a state in which
|
|
|
|
// _bottom == _top+1. The pop_local could succeed in decrementing _bottom,
|
|
|
|
// and the pop_global in incrementing _top (in which case the pop_global
|
|
|
|
// will be awarded the contested queue element.) The resulting state must
|
|
|
|
// be interpreted as an empty queue. (We only need to worry about one such
|
|
|
|
// event: only the queue owner performs pop_local's, and several concurrent
|
|
|
|
// threads attempting to perform the pop_global will all perform the same
|
|
|
|
// CAS, and only one can succeed.) Any stealing thread that reads after
|
|
|
|
// either the increment or decrement will see an empty queue, and will not
|
|
|
|
// join the competitors. The "sz == -1 || sz == N-1" state will not be
|
|
|
|
// modified by concurrent queues, so the owner thread can reset the state to
|
|
|
|
// _bottom == top so subsequent pushes will be performed normally.
|
|
|
|
return (sz == N - 1) ? 0 : sz;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
TaskQueueSuper() : _bottom(0), _age() {}
|
|
|
|
|
2010-07-01 21:40:45 -07:00
|
|
|
// Return true if the TaskQueue contains/does not contain any tasks.
|
|
|
|
bool peek() const { return _bottom != _age.top(); }
|
|
|
|
bool is_empty() const { return size() == 0; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Return an estimate of the number of elements in the queue.
|
|
|
|
// The "careful" version admits the possibility of pop_local/pop_global
|
|
|
|
// races.
|
2010-03-03 14:48:26 -08:00
|
|
|
uint size() const {
|
2009-08-05 12:33:29 -07:00
|
|
|
return size(_bottom, _age.top());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
uint dirty_size() const {
|
2009-08-05 12:33:29 -07:00
|
|
|
return dirty_size(_bottom, _age.top());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
void set_empty() {
|
|
|
|
_bottom = 0;
|
2009-08-05 12:33:29 -07:00
|
|
|
_age.set(0);
|
2008-06-05 15:57:56 -07:00
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Maximum number of elements allowed in the queue. This is two less
|
|
|
|
// than the actual queue size, for somewhat complicated reasons.
|
2010-03-03 14:48:26 -08:00
|
|
|
uint max_elems() const { return N - 2; }
|
2010-02-24 07:00:33 -08:00
|
|
|
|
|
|
|
// Total size of queue.
|
|
|
|
static const uint total_size() { return N; }
|
2010-07-16 21:33:21 -07:00
|
|
|
|
|
|
|
TASKQUEUE_STATS_ONLY(TaskQueueStats stats;)
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class E, unsigned int N = TASKQUEUE_SIZE>
|
|
|
|
class GenericTaskQueue: public TaskQueueSuper<N> {
|
|
|
|
protected:
|
|
|
|
typedef typename TaskQueueSuper<N>::Age Age;
|
|
|
|
typedef typename TaskQueueSuper<N>::idx_t idx_t;
|
|
|
|
|
|
|
|
using TaskQueueSuper<N>::_bottom;
|
|
|
|
using TaskQueueSuper<N>::_age;
|
|
|
|
using TaskQueueSuper<N>::increment_index;
|
|
|
|
using TaskQueueSuper<N>::decrement_index;
|
|
|
|
using TaskQueueSuper<N>::dirty_size;
|
|
|
|
|
|
|
|
public:
|
|
|
|
using TaskQueueSuper<N>::max_elems;
|
|
|
|
using TaskQueueSuper<N>::size;
|
2010-07-16 21:33:21 -07:00
|
|
|
TASKQUEUE_STATS_ONLY(using TaskQueueSuper<N>::stats;)
|
2010-03-03 14:48:26 -08:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
private:
|
|
|
|
// Slow paths for push, pop_local. (pop_global has no fast path.)
|
2009-01-30 14:17:52 -08:00
|
|
|
bool push_slow(E t, uint dirty_n_elems);
|
|
|
|
bool pop_local_slow(uint localBot, Age oldAge);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
public:
|
2010-03-03 14:48:26 -08:00
|
|
|
typedef E element_type;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Initializes the queue to empty.
|
|
|
|
GenericTaskQueue();
|
|
|
|
|
|
|
|
void initialize();
|
|
|
|
|
2010-07-01 21:40:45 -07:00
|
|
|
// Push the task "t" on the queue. Returns "false" iff the queue is full.
|
2007-12-01 00:00:00 +00:00
|
|
|
inline bool push(E t);
|
|
|
|
|
2010-07-01 21:40:45 -07:00
|
|
|
// Attempts to claim a task from the "local" end of the queue (the most
|
|
|
|
// recently pushed). If successful, returns true and sets t to the task;
|
|
|
|
// otherwise, returns false (the queue is empty).
|
2007-12-01 00:00:00 +00:00
|
|
|
inline bool pop_local(E& t);
|
|
|
|
|
2010-07-01 21:40:45 -07:00
|
|
|
// Like pop_local(), but uses the "global" end of the queue (the least
|
|
|
|
// recently pushed).
|
2007-12-01 00:00:00 +00:00
|
|
|
bool pop_global(E& t);
|
|
|
|
|
|
|
|
// Delete any resource associated with the queue.
|
|
|
|
~GenericTaskQueue();
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
// apply the closure to all elements in the task queue
|
|
|
|
void oops_do(OopClosure* f);
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
private:
|
|
|
|
// Element array.
|
|
|
|
volatile E* _elems;
|
|
|
|
};
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class E, unsigned int N>
|
|
|
|
GenericTaskQueue<E, N>::GenericTaskQueue() {
|
2009-08-05 12:33:29 -07:00
|
|
|
assert(sizeof(Age) == sizeof(size_t), "Depends on this.");
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class E, unsigned int N>
|
|
|
|
void GenericTaskQueue<E, N>::initialize() {
|
2009-08-05 12:33:29 -07:00
|
|
|
_elems = NEW_C_HEAP_ARRAY(E, N);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class E, unsigned int N>
|
|
|
|
void GenericTaskQueue<E, N>::oops_do(OopClosure* f) {
|
2008-06-05 15:57:56 -07:00
|
|
|
// tty->print_cr("START OopTaskQueue::oops_do");
|
2009-01-30 14:17:52 -08:00
|
|
|
uint iters = size();
|
|
|
|
uint index = _bottom;
|
|
|
|
for (uint i = 0; i < iters; ++i) {
|
2008-06-05 15:57:56 -07:00
|
|
|
index = decrement_index(index);
|
|
|
|
// tty->print_cr(" doing entry %d," INTPTR_T " -> " INTPTR_T,
|
|
|
|
// index, &_elems[index], _elems[index]);
|
|
|
|
E* t = (E*)&_elems[index]; // cast away volatility
|
|
|
|
oop* p = (oop*)t;
|
|
|
|
assert((*t)->is_oop_or_null(), "Not an oop or null");
|
|
|
|
f->do_oop(p);
|
|
|
|
}
|
|
|
|
// tty->print_cr("END OopTaskQueue::oops_do");
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class E, unsigned int N>
|
|
|
|
bool GenericTaskQueue<E, N>::push_slow(E t, uint dirty_n_elems) {
|
2009-08-05 12:33:29 -07:00
|
|
|
if (dirty_n_elems == N - 1) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Actually means 0, so do the push.
|
2009-01-30 14:17:52 -08:00
|
|
|
uint localBot = _bottom;
|
2010-03-03 14:48:26 -08:00
|
|
|
// g++ complains if the volatile result of the assignment is unused.
|
|
|
|
const_cast<E&>(_elems[localBot] = t);
|
2009-10-07 09:48:42 -04:00
|
|
|
OrderAccess::release_store(&_bottom, increment_index(localBot));
|
2010-07-16 21:33:21 -07:00
|
|
|
TASKQUEUE_STATS_ONLY(stats.record_push());
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
2009-08-05 12:33:29 -07:00
|
|
|
}
|
|
|
|
return false;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2010-09-20 14:38:38 -07:00
|
|
|
// pop_local_slow() is done by the owning thread and is trying to
|
|
|
|
// get the last task in the queue. It will compete with pop_global()
|
|
|
|
// that will be used by other threads. The tag age is incremented
|
|
|
|
// 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()).
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class E, unsigned int N>
|
2010-07-16 21:33:21 -07:00
|
|
|
bool GenericTaskQueue<E, N>::pop_local_slow(uint localBot, Age oldAge) {
|
2007-12-01 00:00:00 +00:00
|
|
|
// 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
|
|
|
|
// that represents the empty queue for the given value of "_bottom". (We
|
|
|
|
// must also increment "tag" because of the case where "bottom == 1",
|
|
|
|
// "top == 0". A pop_global could read the queue element in that case,
|
|
|
|
// then have the owner thread do a pop followed by another push. Without
|
|
|
|
// the incrementing of "tag", the pop_global's CAS could succeed,
|
|
|
|
// allowing it to believe it has claimed the stale element.)
|
2009-08-05 12:33:29 -07:00
|
|
|
Age newAge((idx_t)localBot, oldAge.tag() + 1);
|
2007-12-01 00:00:00 +00:00
|
|
|
// Perhaps a competing pop_global has already incremented "top", in which
|
|
|
|
// case it wins the element.
|
|
|
|
if (localBot == oldAge.top()) {
|
|
|
|
// No competing pop_global has yet incremented "top"; we'll try to
|
|
|
|
// install new_age, thus claiming the element.
|
2009-08-05 12:33:29 -07:00
|
|
|
Age tempAge = _age.cmpxchg(newAge, oldAge);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (tempAge == oldAge) {
|
|
|
|
// We win.
|
2009-08-05 12:33:29 -07:00
|
|
|
assert(dirty_size(localBot, _age.top()) != N - 1, "sanity");
|
2010-07-16 21:33:21 -07:00
|
|
|
TASKQUEUE_STATS_ONLY(stats.record_pop_slow());
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2009-08-05 12:33:29 -07:00
|
|
|
// We lose; a completing pop_global gets the element. But the queue is empty
|
|
|
|
// and top is greater than bottom. Fix this representation of the empty queue
|
|
|
|
// to become the canonical one.
|
|
|
|
_age.set(newAge);
|
|
|
|
assert(dirty_size(localBot, _age.top()) != N - 1, "sanity");
|
2007-12-01 00:00:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class E, unsigned int N>
|
|
|
|
bool GenericTaskQueue<E, N>::pop_global(E& t) {
|
2009-08-05 12:33:29 -07:00
|
|
|
Age oldAge = _age.get();
|
2009-01-30 14:17:52 -08:00
|
|
|
uint localBot = _bottom;
|
|
|
|
uint n_elems = size(localBot, oldAge.top());
|
2007-12-01 00:00:00 +00:00
|
|
|
if (n_elems == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-08-05 12:33:29 -07:00
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
const_cast<E&>(t = _elems[oldAge.top()]);
|
2009-08-05 12:33:29 -07:00
|
|
|
Age newAge(oldAge);
|
|
|
|
newAge.increment();
|
|
|
|
Age resAge = _age.cmpxchg(newAge, oldAge);
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Note that using "_bottom" here might fail, since a pop_local might
|
|
|
|
// have decremented it.
|
2009-08-05 12:33:29 -07:00
|
|
|
assert(dirty_size(localBot, newAge.top()) != N - 1, "sanity");
|
|
|
|
return resAge == oldAge;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class E, unsigned int N>
|
|
|
|
GenericTaskQueue<E, N>::~GenericTaskQueue() {
|
2007-12-01 00:00:00 +00:00
|
|
|
FREE_C_HEAP_ARRAY(E, _elems);
|
|
|
|
}
|
|
|
|
|
2010-07-01 21:40:45 -07:00
|
|
|
// OverflowTaskQueue is a TaskQueue that also includes an overflow stack for
|
|
|
|
// elements that do not fit in the TaskQueue.
|
|
|
|
//
|
2010-09-28 15:56:15 -07:00
|
|
|
// This class hides two methods from super classes:
|
2010-07-01 21:40:45 -07:00
|
|
|
//
|
|
|
|
// push() - push onto the task queue or, if that fails, onto the overflow stack
|
|
|
|
// is_empty() - return true if both the TaskQueue and overflow stack are empty
|
|
|
|
//
|
2010-09-28 15:56:15 -07:00
|
|
|
// Note that size() is not hidden--it returns the number of elements in the
|
2010-07-01 21:40:45 -07:00
|
|
|
// TaskQueue, and does not include the size of the overflow stack. This
|
|
|
|
// simplifies replacement of GenericTaskQueues with OverflowTaskQueues.
|
|
|
|
template<class E, unsigned int N = TASKQUEUE_SIZE>
|
|
|
|
class OverflowTaskQueue: public GenericTaskQueue<E, N>
|
|
|
|
{
|
|
|
|
public:
|
2010-09-28 15:56:15 -07:00
|
|
|
typedef Stack<E> overflow_t;
|
2010-07-01 21:40:45 -07:00
|
|
|
typedef GenericTaskQueue<E, N> taskqueue_t;
|
|
|
|
|
2010-07-16 21:33:21 -07:00
|
|
|
TASKQUEUE_STATS_ONLY(using taskqueue_t::stats;)
|
|
|
|
|
2010-07-01 21:40:45 -07:00
|
|
|
// Push task t onto the queue or onto the overflow stack. Return true.
|
|
|
|
inline bool push(E t);
|
|
|
|
|
|
|
|
// Attempt to pop from the overflow stack; return true if anything was popped.
|
|
|
|
inline bool pop_overflow(E& t);
|
|
|
|
|
2010-09-28 15:56:15 -07:00
|
|
|
inline overflow_t* overflow_stack() { return &_overflow_stack; }
|
|
|
|
|
2010-07-01 21:40:45 -07:00
|
|
|
inline bool taskqueue_empty() const { return taskqueue_t::is_empty(); }
|
2010-09-28 15:56:15 -07:00
|
|
|
inline bool overflow_empty() const { return _overflow_stack.is_empty(); }
|
2010-07-01 21:40:45 -07:00
|
|
|
inline bool is_empty() const {
|
|
|
|
return taskqueue_empty() && overflow_empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2010-09-28 15:56:15 -07:00
|
|
|
overflow_t _overflow_stack;
|
2010-07-01 21:40:45 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class E, unsigned int N>
|
|
|
|
bool OverflowTaskQueue<E, N>::push(E t)
|
|
|
|
{
|
|
|
|
if (!taskqueue_t::push(t)) {
|
|
|
|
overflow_stack()->push(t);
|
2010-09-28 15:56:15 -07:00
|
|
|
TASKQUEUE_STATS_ONLY(stats.record_overflow(overflow_stack()->size()));
|
2010-07-01 21:40:45 -07:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class E, unsigned int N>
|
|
|
|
bool OverflowTaskQueue<E, N>::pop_overflow(E& t)
|
|
|
|
{
|
|
|
|
if (overflow_empty()) return false;
|
|
|
|
t = overflow_stack()->pop();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
class TaskQueueSetSuper: public CHeapObj {
|
|
|
|
protected:
|
|
|
|
static int randomParkAndMiller(int* seed0);
|
|
|
|
public:
|
|
|
|
// Returns "true" if some TaskQueue in the set contains a task.
|
|
|
|
virtual bool peek() = 0;
|
|
|
|
};
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class T>
|
|
|
|
class GenericTaskQueueSet: public TaskQueueSetSuper {
|
2007-12-01 00:00:00 +00:00
|
|
|
private:
|
2009-01-30 14:17:52 -08:00
|
|
|
uint _n;
|
2010-03-03 14:48:26 -08:00
|
|
|
T** _queues;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
public:
|
2010-03-03 14:48:26 -08:00
|
|
|
typedef typename T::element_type E;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
GenericTaskQueueSet(int n) : _n(n) {
|
2010-03-03 14:48:26 -08:00
|
|
|
typedef T* GenericTaskQueuePtr;
|
2007-12-01 00:00:00 +00:00
|
|
|
_queues = NEW_C_HEAP_ARRAY(GenericTaskQueuePtr, n);
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
|
|
_queues[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-30 14:17:52 -08:00
|
|
|
bool steal_1_random(uint queue_num, int* seed, E& t);
|
|
|
|
bool steal_best_of_2(uint queue_num, int* seed, E& t);
|
|
|
|
bool steal_best_of_all(uint queue_num, int* seed, E& t);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
void register_queue(uint i, T* q);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
T* queue(uint n);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-07-01 21:40:45 -07:00
|
|
|
// The thread with queue number "queue_num" (and whose random number seed is
|
|
|
|
// at "seed") is trying to steal a task from some other queue. (It may try
|
|
|
|
// several queues, according to some configuration parameter.) If some steal
|
|
|
|
// succeeds, returns "true" and sets "t" to the stolen task, otherwise returns
|
|
|
|
// false.
|
2009-01-30 14:17:52 -08:00
|
|
|
bool steal(uint queue_num, int* seed, E& t);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
bool peek();
|
|
|
|
};
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class T> void
|
|
|
|
GenericTaskQueueSet<T>::register_queue(uint i, T* q) {
|
2009-01-30 14:17:52 -08:00
|
|
|
assert(i < _n, "index out of range.");
|
2007-12-01 00:00:00 +00:00
|
|
|
_queues[i] = q;
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class T> T*
|
|
|
|
GenericTaskQueueSet<T>::queue(uint i) {
|
2007-12-01 00:00:00 +00:00
|
|
|
return _queues[i];
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class T> bool
|
|
|
|
GenericTaskQueueSet<T>::steal(uint queue_num, int* seed, E& t) {
|
2010-07-16 21:33:21 -07:00
|
|
|
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));
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
2010-07-16 21:33:21 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
TASKQUEUE_STATS_ONLY(queue(queue_num)->stats.record_steal(false));
|
2007-12-01 00:00:00 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class T> bool
|
|
|
|
GenericTaskQueueSet<T>::steal_best_of_all(uint queue_num, int* seed, E& t) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_n > 2) {
|
|
|
|
int best_k;
|
2009-01-30 14:17:52 -08:00
|
|
|
uint best_sz = 0;
|
|
|
|
for (uint k = 0; k < _n; k++) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (k == queue_num) continue;
|
2009-01-30 14:17:52 -08:00
|
|
|
uint sz = _queues[k]->size();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (sz > best_sz) {
|
|
|
|
best_sz = sz;
|
|
|
|
best_k = k;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return best_sz > 0 && _queues[best_k]->pop_global(t);
|
|
|
|
} else if (_n == 2) {
|
|
|
|
// Just try the other one.
|
|
|
|
int k = (queue_num + 1) % 2;
|
|
|
|
return _queues[k]->pop_global(t);
|
|
|
|
} else {
|
|
|
|
assert(_n == 1, "can't be zero.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class T> bool
|
|
|
|
GenericTaskQueueSet<T>::steal_1_random(uint queue_num, int* seed, E& t) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_n > 2) {
|
2009-01-30 14:17:52 -08:00
|
|
|
uint k = queue_num;
|
2007-12-01 00:00:00 +00:00
|
|
|
while (k == queue_num) k = randomParkAndMiller(seed) % _n;
|
|
|
|
return _queues[2]->pop_global(t);
|
|
|
|
} else if (_n == 2) {
|
|
|
|
// Just try the other one.
|
|
|
|
int k = (queue_num + 1) % 2;
|
|
|
|
return _queues[k]->pop_global(t);
|
|
|
|
} else {
|
|
|
|
assert(_n == 1, "can't be zero.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class T> bool
|
|
|
|
GenericTaskQueueSet<T>::steal_best_of_2(uint queue_num, int* seed, E& t) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_n > 2) {
|
2009-01-30 14:17:52 -08:00
|
|
|
uint k1 = queue_num;
|
2007-12-01 00:00:00 +00:00
|
|
|
while (k1 == queue_num) k1 = randomParkAndMiller(seed) % _n;
|
2009-01-30 14:17:52 -08:00
|
|
|
uint k2 = queue_num;
|
2007-12-01 00:00:00 +00:00
|
|
|
while (k2 == queue_num || k2 == k1) k2 = randomParkAndMiller(seed) % _n;
|
|
|
|
// Sample both and try the larger.
|
2009-01-30 14:17:52 -08:00
|
|
|
uint sz1 = _queues[k1]->size();
|
|
|
|
uint sz2 = _queues[k2]->size();
|
2007-12-01 00:00:00 +00:00
|
|
|
if (sz2 > sz1) return _queues[k2]->pop_global(t);
|
|
|
|
else return _queues[k1]->pop_global(t);
|
|
|
|
} else if (_n == 2) {
|
|
|
|
// Just try the other one.
|
2009-01-30 14:17:52 -08:00
|
|
|
uint k = (queue_num + 1) % 2;
|
2007-12-01 00:00:00 +00:00
|
|
|
return _queues[k]->pop_global(t);
|
|
|
|
} else {
|
|
|
|
assert(_n == 1, "can't be zero.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class T>
|
|
|
|
bool GenericTaskQueueSet<T>::peek() {
|
2007-12-01 00:00:00 +00:00
|
|
|
// Try all the queues.
|
2009-01-30 14:17:52 -08:00
|
|
|
for (uint j = 0; j < _n; j++) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_queues[j]->peek())
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-06-05 15:57:56 -07:00
|
|
|
// When to terminate from the termination protocol.
|
|
|
|
class TerminatorTerminator: public CHeapObj {
|
|
|
|
public:
|
|
|
|
virtual bool should_exit_termination() = 0;
|
|
|
|
};
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// A class to aid in the termination of a set of parallel tasks using
|
|
|
|
// TaskQueueSet's for work stealing.
|
|
|
|
|
2009-02-08 13:18:01 -08:00
|
|
|
#undef TRACESPINNING
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
class ParallelTaskTerminator: public StackObj {
|
|
|
|
private:
|
|
|
|
int _n_threads;
|
|
|
|
TaskQueueSetSuper* _queue_set;
|
2009-01-30 14:17:52 -08:00
|
|
|
int _offered_termination;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-02-08 13:18:01 -08:00
|
|
|
#ifdef TRACESPINNING
|
|
|
|
static uint _total_yields;
|
|
|
|
static uint _total_spins;
|
|
|
|
static uint _total_peeks;
|
|
|
|
#endif
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
bool peek_in_queue_set();
|
|
|
|
protected:
|
|
|
|
virtual void yield();
|
|
|
|
void sleep(uint millis);
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// "n_threads" is the number of threads to be terminated. "queue_set" is a
|
|
|
|
// queue sets of work queues of other threads.
|
|
|
|
ParallelTaskTerminator(int n_threads, TaskQueueSetSuper* queue_set);
|
|
|
|
|
|
|
|
// The current thread has no work, and is ready to terminate if everyone
|
|
|
|
// else is. If returns "true", all threads are terminated. If returns
|
|
|
|
// "false", available work has been observed in one of the task queues,
|
|
|
|
// so the global task is not complete.
|
2008-06-05 15:57:56 -07:00
|
|
|
bool offer_termination() {
|
|
|
|
return offer_termination(NULL);
|
|
|
|
}
|
|
|
|
|
2009-08-05 12:33:29 -07:00
|
|
|
// As above, but it also terminates if the should_exit_termination()
|
2008-06-05 15:57:56 -07:00
|
|
|
// method of the terminator parameter returns true. If terminator is
|
|
|
|
// NULL, then it is ignored.
|
|
|
|
bool offer_termination(TerminatorTerminator* terminator);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Reset the terminator, so that it may be reused again.
|
|
|
|
// The caller is responsible for ensuring that this is done
|
|
|
|
// in an MT-safe manner, once the previous round of use of
|
|
|
|
// the terminator is finished.
|
|
|
|
void reset_for_reuse();
|
2010-09-20 14:38:38 -07:00
|
|
|
// Same as above but the number of parallel threads is set to the
|
|
|
|
// given number.
|
|
|
|
void reset_for_reuse(int n_threads);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2009-02-08 13:18:01 -08:00
|
|
|
#ifdef TRACESPINNING
|
|
|
|
static uint total_yields() { return _total_yields; }
|
|
|
|
static uint total_spins() { return _total_spins; }
|
|
|
|
static uint total_peeks() { return _total_peeks; }
|
|
|
|
static void print_termination_counts();
|
|
|
|
#endif
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class E, unsigned int N> inline bool
|
|
|
|
GenericTaskQueue<E, N>::push(E t) {
|
2009-01-30 14:17:52 -08:00
|
|
|
uint localBot = _bottom;
|
2009-08-05 12:33:29 -07:00
|
|
|
assert((localBot >= 0) && (localBot < N), "_bottom out of range.");
|
|
|
|
idx_t top = _age.top();
|
2009-01-30 14:17:52 -08:00
|
|
|
uint dirty_n_elems = dirty_size(localBot, top);
|
2010-03-03 14:48:26 -08:00
|
|
|
assert(dirty_n_elems < N, "n_elems out of range.");
|
2007-12-01 00:00:00 +00:00
|
|
|
if (dirty_n_elems < max_elems()) {
|
2010-03-03 14:48:26 -08:00
|
|
|
// g++ complains if the volatile result of the assignment is unused.
|
|
|
|
const_cast<E&>(_elems[localBot] = t);
|
2009-10-07 09:48:42 -04:00
|
|
|
OrderAccess::release_store(&_bottom, increment_index(localBot));
|
2010-07-16 21:33:21 -07:00
|
|
|
TASKQUEUE_STATS_ONLY(stats.record_push());
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return push_slow(t, dirty_n_elems);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
template<class E, unsigned int N> inline bool
|
|
|
|
GenericTaskQueue<E, N>::pop_local(E& t) {
|
2009-01-30 14:17:52 -08:00
|
|
|
uint localBot = _bottom;
|
2009-08-05 12:33:29 -07:00
|
|
|
// This value cannot be N-1. That can only occur as a result of
|
2007-12-01 00:00:00 +00:00
|
|
|
// the assignment to bottom in this method. If it does, this method
|
2010-07-01 21:40:45 -07:00
|
|
|
// resets the size to 0 before the next call (which is sequential,
|
2007-12-01 00:00:00 +00:00
|
|
|
// since this is pop_local.)
|
2009-08-05 12:33:29 -07:00
|
|
|
uint dirty_n_elems = dirty_size(localBot, _age.top());
|
|
|
|
assert(dirty_n_elems != N - 1, "Shouldn't be possible...");
|
2007-12-01 00:00:00 +00:00
|
|
|
if (dirty_n_elems == 0) return false;
|
|
|
|
localBot = decrement_index(localBot);
|
|
|
|
_bottom = localBot;
|
|
|
|
// This is necessary to prevent any read below from being reordered
|
|
|
|
// before the store just above.
|
|
|
|
OrderAccess::fence();
|
2010-03-03 14:48:26 -08:00
|
|
|
const_cast<E&>(t = _elems[localBot]);
|
2007-12-01 00:00:00 +00:00
|
|
|
// This is a second read of "age"; the "size()" above is the first.
|
|
|
|
// If there's still at least one element in the queue, based on the
|
|
|
|
// "_bottom" and "age" we've read, then there can be no interference with
|
|
|
|
// a "pop_global" operation, and we're done.
|
2009-08-05 12:33:29 -07:00
|
|
|
idx_t tp = _age.top(); // XXX
|
2007-12-01 00:00:00 +00:00
|
|
|
if (size(localBot, tp) > 0) {
|
2009-08-05 12:33:29 -07:00
|
|
|
assert(dirty_size(localBot, tp) != N - 1, "sanity");
|
2010-07-16 21:33:21 -07:00
|
|
|
TASKQUEUE_STATS_ONLY(stats.record_pop());
|
2007-12-01 00:00:00 +00:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
// Otherwise, the queue contained exactly one element; we take the slow
|
|
|
|
// path.
|
2009-08-05 12:33:29 -07:00
|
|
|
return pop_local_slow(localBot, _age.get());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-01 21:40:45 -07:00
|
|
|
typedef GenericTaskQueue<oop> OopTaskQueue;
|
2010-03-03 14:48:26 -08:00
|
|
|
typedef GenericTaskQueueSet<OopTaskQueue> OopTaskQueueSet;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(push)
|
|
|
|
// warning C4522: multiple assignment operators specified
|
|
|
|
#pragma warning(disable:4522)
|
|
|
|
#endif
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
|
|
|
|
// This is a container class for either an oop* or a narrowOop*.
|
|
|
|
// Both are pushed onto a task queue and the consumer will test is_narrow()
|
|
|
|
// to determine which should be processed.
|
|
|
|
class StarTask {
|
|
|
|
void* _holder; // either union oop* or narrowOop*
|
2010-03-03 14:48:26 -08:00
|
|
|
|
|
|
|
enum { COMPRESSED_OOP_MASK = 1 };
|
|
|
|
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
public:
|
2009-07-14 15:40:39 -07:00
|
|
|
StarTask(narrowOop* p) {
|
|
|
|
assert(((uintptr_t)p & COMPRESSED_OOP_MASK) == 0, "Information loss!");
|
|
|
|
_holder = (void *)((uintptr_t)p | COMPRESSED_OOP_MASK);
|
|
|
|
}
|
|
|
|
StarTask(oop* p) {
|
|
|
|
assert(((uintptr_t)p & COMPRESSED_OOP_MASK) == 0, "Information loss!");
|
|
|
|
_holder = (void*)p;
|
|
|
|
}
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
StarTask() { _holder = NULL; }
|
|
|
|
operator oop*() { return (oop*)_holder; }
|
|
|
|
operator narrowOop*() {
|
|
|
|
return (narrowOop*)((uintptr_t)_holder & ~COMPRESSED_OOP_MASK);
|
|
|
|
}
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
StarTask& operator=(const StarTask& t) {
|
|
|
|
_holder = t._holder;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
volatile StarTask& operator=(const volatile StarTask& t) volatile {
|
|
|
|
_holder = t._holder;
|
|
|
|
return *this;
|
|
|
|
}
|
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
2008-04-13 17:43:42 -04:00
|
|
|
|
|
|
|
bool is_narrow() const {
|
|
|
|
return (((uintptr_t)_holder & COMPRESSED_OOP_MASK) != 0);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-03-03 14:48:26 -08:00
|
|
|
class ObjArrayTask
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ObjArrayTask(oop o = NULL, int idx = 0): _obj(o), _index(idx) { }
|
|
|
|
ObjArrayTask(oop o, size_t idx): _obj(o), _index(int(idx)) {
|
|
|
|
assert(idx <= size_t(max_jint), "too big");
|
|
|
|
}
|
|
|
|
ObjArrayTask(const ObjArrayTask& t): _obj(t._obj), _index(t._index) { }
|
|
|
|
|
|
|
|
ObjArrayTask& operator =(const ObjArrayTask& t) {
|
|
|
|
_obj = t._obj;
|
|
|
|
_index = t._index;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
volatile ObjArrayTask&
|
|
|
|
operator =(const volatile ObjArrayTask& t) volatile {
|
|
|
|
_obj = t._obj;
|
|
|
|
_index = t._index;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline oop obj() const { return _obj; }
|
|
|
|
inline int index() const { return _index; }
|
|
|
|
|
|
|
|
DEBUG_ONLY(bool is_valid() const); // Tasks to be pushed/popped must be valid.
|
|
|
|
|
|
|
|
private:
|
|
|
|
oop _obj;
|
|
|
|
int _index;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#pragma warning(pop)
|
|
|
|
#endif
|
|
|
|
|
2010-07-01 21:40:45 -07:00
|
|
|
typedef OverflowTaskQueue<StarTask> OopStarTaskQueue;
|
2010-03-03 14:48:26 -08:00
|
|
|
typedef GenericTaskQueueSet<OopStarTaskQueue> OopStarTaskQueueSet;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-07-01 21:40:45 -07:00
|
|
|
typedef OverflowTaskQueue<size_t> RegionTaskQueue;
|
|
|
|
typedef GenericTaskQueueSet<RegionTaskQueue> RegionTaskQueueSet;
|
2010-09-20 14:38:38 -07:00
|
|
|
|