6711316: Open source the Garbage-First garbage collector

First mercurial integration of the code for the Garbage-First garbage collector.

Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, ysr
This commit is contained in:
Y. Srinivas Ramakrishna 2008-06-05 15:57:56 -07:00
parent 39463bb3fc
commit 18f3386a98
215 changed files with 36088 additions and 1249 deletions

View file

@ -120,6 +120,11 @@ public:
return dirty_size(_bottom, get_top());
}
void set_empty() {
_bottom = 0;
_age = Age();
}
// Maximum number of elements allowed in the queue. This is two less
// than the actual queue size, for somewhat complicated reasons.
juint max_elems() { return n() - 2; }
@ -155,6 +160,9 @@ public:
// Delete any resource associated with the queue.
~GenericTaskQueue();
// apply the closure to all elements in the task queue
void oops_do(OopClosure* f);
private:
// Element array.
volatile E* _elems;
@ -171,6 +179,24 @@ void GenericTaskQueue<E>::initialize() {
guarantee(_elems != NULL, "Allocation failed.");
}
template<class E>
void GenericTaskQueue<E>::oops_do(OopClosure* f) {
// tty->print_cr("START OopTaskQueue::oops_do");
int iters = size();
juint index = _bottom;
for (int i = 0; i < iters; ++i) {
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");
}
template<class E>
bool GenericTaskQueue<E>::push_slow(E t, juint dirty_n_elems) {
if (dirty_n_elems == n() - 1) {
@ -383,6 +409,12 @@ bool GenericTaskQueueSet<E>::peek() {
return false;
}
// When to terminate from the termination protocol.
class TerminatorTerminator: public CHeapObj {
public:
virtual bool should_exit_termination() = 0;
};
// A class to aid in the termination of a set of parallel tasks using
// TaskQueueSet's for work stealing.
@ -407,7 +439,14 @@ public:
// 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.
bool offer_termination();
bool offer_termination() {
return offer_termination(NULL);
}
// As above, but it also terminates of the should_exit_termination()
// method of the terminator parameter returns true. If terminator is
// NULL, then it is ignored.
bool offer_termination(TerminatorTerminator* terminator);
// Reset the terminator, so that it may be reused again.
// The caller is responsible for ensuring that this is done