Tue, 06 May 2014 09:52:38 +0200
8042428: CompileQueue::free_all() code is incorrect
Summary: Free task after getting next pointer of freelist.
Reviewed-by: kvn, adlertz
src/share/vm/compiler/compileBroker.cpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/compiler/compileBroker.cpp Wed May 07 22:06:42 2014 +0200 1.2 +++ b/src/share/vm/compiler/compileBroker.cpp Tue May 06 09:52:38 2014 +0200 1.3 @@ -664,17 +664,27 @@ 1.4 lock()->notify_all(); 1.5 } 1.6 1.7 +/** 1.8 + * Empties compilation queue by putting all compilation tasks onto 1.9 + * a freelist. Furthermore, the method wakes up all threads that are 1.10 + * waiting on a compilation task to finish. This can happen if background 1.11 + * compilation is disabled. 1.12 + */ 1.13 void CompileQueue::free_all() { 1.14 MutexLocker mu(lock()); 1.15 - if (_first != NULL) { 1.16 - for (CompileTask* task = _first; task != NULL; task = task->next()) { 1.17 - // Wake up thread that blocks on the compile task. 1.18 - task->lock()->notify(); 1.19 - // Puts task back on the freelist. 1.20 - CompileTask::free(task); 1.21 - } 1.22 - _first = NULL; 1.23 + CompileTask* next = _first; 1.24 + 1.25 + // Iterate over all tasks in the compile queue 1.26 + while (next != NULL) { 1.27 + CompileTask* current = next; 1.28 + next = current->next(); 1.29 + // Wake up thread that blocks on the compile task. 1.30 + current->lock()->notify(); 1.31 + // Put the task back on the freelist. 1.32 + CompileTask::free(current); 1.33 } 1.34 + _first = NULL; 1.35 + 1.36 // Wake up all threads that block on the queue. 1.37 lock()->notify_all(); 1.38 }