src/share/vm/compiler/compileBroker.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff src/share/vm/compiler/compileBroker.cpp
src/share/vm/compiler/compileBroker.cpp
Print this page
*** 592,602 ****
/**
* Add a CompileTask to a CompileQueue.
*/
void CompileQueue::add(CompileTask* task) {
! assert(lock()->owned_by_self(), "must own lock");
task->set_next(NULL);
task->set_prev(NULL);
if (_last == NULL) {
--- 592,602 ----
/**
* Add a CompileTask to a CompileQueue.
*/
void CompileQueue::add(CompileTask* task) {
! assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
task->set_next(NULL);
task->set_prev(NULL);
if (_last == NULL) {
*** 623,643 ****
if (LogCompilation && xtty != NULL) {
task->log_task_queued();
}
// Notify CompilerThreads that a task is available.
! lock()->notify_all();
}
/**
* Empties compilation queue by putting all compilation tasks onto
* a freelist. Furthermore, the method wakes up all threads that are
* waiting on a compilation task to finish. This can happen if background
* compilation is disabled.
*/
void CompileQueue::free_all() {
! MutexLocker mu(lock());
CompileTask* next = _first;
// Iterate over all tasks in the compile queue
while (next != NULL) {
CompileTask* current = next;
--- 623,643 ----
if (LogCompilation && xtty != NULL) {
task->log_task_queued();
}
// Notify CompilerThreads that a task is available.
! MethodCompileQueue_lock->notify_all();
}
/**
* Empties compilation queue by putting all compilation tasks onto
* a freelist. Furthermore, the method wakes up all threads that are
* waiting on a compilation task to finish. This can happen if background
* compilation is disabled.
*/
void CompileQueue::free_all() {
! MutexLocker mu(MethodCompileQueue_lock);
CompileTask* next = _first;
// Iterate over all tasks in the compile queue
while (next != NULL) {
CompileTask* current = next;
*** 651,668 ****
CompileTask::free(current);
}
_first = NULL;
// Wake up all threads that block on the queue.
! lock()->notify_all();
}
/**
* Get the next CompileTask from a CompileQueue
*/
CompileTask* CompileQueue::get() {
! MutexLocker locker(lock());
// If _first is NULL we have no more compile jobs. There are two reasons for
// having no compile jobs: First, we compiled everything we wanted. Second,
// we ran out of code cache so compilation has been disabled. In the latter
// case we perform code cache sweeps to free memory such that we can re-enable
// compilation.
--- 651,668 ----
CompileTask::free(current);
}
_first = NULL;
// Wake up all threads that block on the queue.
! MethodCompileQueue_lock->notify_all();
}
/**
* Get the next CompileTask from a CompileQueue
*/
CompileTask* CompileQueue::get() {
! MutexLocker locker(MethodCompileQueue_lock);
// If _first is NULL we have no more compile jobs. There are two reasons for
// having no compile jobs: First, we compiled everything we wanted. Second,
// we ran out of code cache so compilation has been disabled. In the latter
// case we perform code cache sweeps to free memory such that we can re-enable
// compilation.
*** 679,689 ****
// the stable state, i.e., we do not want to evict methods from the
// code cache if it is unnecessary.
// We need a timed wait here, since compiler threads can exit if compilation
// is disabled forever. We use 5 seconds wait time; the exiting of compiler threads
// is not critical and we do not want idle compiler threads to wake up too often.
! lock()->wait(!Mutex::_no_safepoint_check_flag, 5*1000);
}
if (CompileBroker::is_compilation_disabled_forever()) {
return NULL;
}
--- 679,689 ----
// the stable state, i.e., we do not want to evict methods from the
// code cache if it is unnecessary.
// We need a timed wait here, since compiler threads can exit if compilation
// is disabled forever. We use 5 seconds wait time; the exiting of compiler threads
// is not critical and we do not want idle compiler threads to wake up too often.
! MethodCompileQueue_lock->wait(!Mutex::_no_safepoint_check_flag, 5*1000);
}
if (CompileBroker::is_compilation_disabled_forever()) {
return NULL;
}
*** 699,718 ****
}
// Clean & deallocate stale compile tasks.
// Temporarily releases MethodCompileQueue lock.
void CompileQueue::purge_stale_tasks() {
! assert(lock()->owned_by_self(), "must own lock");
if (_first_stale != NULL) {
// Stale tasks are purged when MCQ lock is released,
// but _first_stale updates are protected by MCQ lock.
// Once task processing starts and MCQ lock is released,
// other compiler threads can reuse _first_stale.
CompileTask* head = _first_stale;
_first_stale = NULL;
{
! MutexUnlocker ul(lock());
for (CompileTask* task = head; task != NULL; ) {
CompileTask* next_task = task->next();
CompileTaskWrapper ctw(task); // Frees the task
task->set_failure_reason("stale task");
task = next_task;
--- 699,718 ----
}
// Clean & deallocate stale compile tasks.
// Temporarily releases MethodCompileQueue lock.
void CompileQueue::purge_stale_tasks() {
! assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
if (_first_stale != NULL) {
// Stale tasks are purged when MCQ lock is released,
// but _first_stale updates are protected by MCQ lock.
// Once task processing starts and MCQ lock is released,
// other compiler threads can reuse _first_stale.
CompileTask* head = _first_stale;
_first_stale = NULL;
{
! MutexUnlocker ul(MethodCompileQueue_lock);
for (CompileTask* task = head; task != NULL; ) {
CompileTask* next_task = task->next();
CompileTaskWrapper ctw(task); // Frees the task
task->set_failure_reason("stale task");
task = next_task;
*** 720,730 ****
}
}
}
void CompileQueue::remove(CompileTask* task) {
! assert(lock()->owned_by_self(), "must own lock");
if (task->prev() != NULL) {
task->prev()->set_next(task->next());
} else {
// max is the first element
assert(task == _first, "Sanity");
--- 720,730 ----
}
}
}
void CompileQueue::remove(CompileTask* task) {
! assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
if (task->prev() != NULL) {
task->prev()->set_next(task->next());
} else {
// max is the first element
assert(task == _first, "Sanity");
*** 740,750 ****
}
--_size;
}
void CompileQueue::remove_and_mark_stale(CompileTask* task) {
! assert(lock()->owned_by_self(), "must own lock");
remove(task);
// Enqueue the task for reclamation (should be done outside MCQ lock)
task->set_next(_first_stale);
task->set_prev(NULL);
--- 740,750 ----
}
--_size;
}
void CompileQueue::remove_and_mark_stale(CompileTask* task) {
! assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
remove(task);
// Enqueue the task for reclamation (should be done outside MCQ lock)
task->set_next(_first_stale);
task->set_prev(NULL);
*** 778,788 ****
_c2_compile_queue->print(st);
}
}
void CompileQueue::print(outputStream* st) {
! assert(lock()->owned_by_self(), "must own lock");
st->print_cr("Contents of %s", name());
st->print_cr("----------------------------");
CompileTask* task = _first;
if (task == NULL) {
st->print_cr("Empty");
--- 778,788 ----
_c2_compile_queue->print(st);
}
}
void CompileQueue::print(outputStream* st) {
! assert(MethodCompileQueue_lock->owned_by_self(), "must own lock");
st->print_cr("Contents of %s", name());
st->print_cr("----------------------------");
CompileTask* task = _first;
if (task == NULL) {
st->print_cr("Empty");
*** 1064,1078 ****
#if !defined(ZERO) && !defined(SHARK)
assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?");
#endif // !ZERO && !SHARK
// Initialize the compilation queue
if (c2_compiler_count > 0) {
! _c2_compile_queue = new CompileQueue("C2 compile queue", MethodCompileQueue_lock);
_compilers[1]->set_num_compiler_threads(c2_compiler_count);
}
if (c1_compiler_count > 0) {
! _c1_compile_queue = new CompileQueue("C1 compile queue", MethodCompileQueue_lock);
_compilers[0]->set_num_compiler_threads(c1_compiler_count);
}
int compiler_count = c1_compiler_count + c2_compiler_count;
--- 1064,1078 ----
#if !defined(ZERO) && !defined(SHARK)
assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?");
#endif // !ZERO && !SHARK
// Initialize the compilation queue
if (c2_compiler_count > 0) {
! _c2_compile_queue = new CompileQueue("C2 compile queue");
_compilers[1]->set_num_compiler_threads(c2_compiler_count);
}
if (c1_compiler_count > 0) {
! _c1_compile_queue = new CompileQueue("C1 compile queue");
_compilers[0]->set_num_compiler_threads(c1_compiler_count);
}
int compiler_count = c1_compiler_count + c2_compiler_count;
*** 1212,1222 ****
bool blocking = false;
CompileQueue* queue = compile_queue(comp_level);
// Acquire our lock.
{
! MutexLocker locker(queue->lock(), thread);
// Make sure the method has not slipped into the queues since
// last we checked; note that those checks were "fast bail-outs".
// Here we need to be more careful, see 14012000 below.
if (compilation_is_in_queue(method)) {
--- 1212,1222 ----
bool blocking = false;
CompileQueue* queue = compile_queue(comp_level);
// Acquire our lock.
{
! MutexLocker locker(MethodCompileQueue_lock, thread);
// Make sure the method has not slipped into the queues since
// last we checked; note that those checks were "fast bail-outs".
// Here we need to be more careful, see 14012000 below.
if (compilation_is_in_queue(method)) {
src/share/vm/compiler/compileBroker.cpp
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File