1.1 --- a/src/share/vm/compiler/compileBroker.cpp Fri Sep 12 01:04:04 2014 +0000 1.2 +++ b/src/share/vm/compiler/compileBroker.cpp Tue Mar 11 15:06:34 2014 +0400 1.3 @@ -688,13 +688,39 @@ 1.4 return NULL; 1.5 } 1.6 1.7 - CompileTask* task = CompilationPolicy::policy()->select_task(this); 1.8 + CompileTask* task; 1.9 + { 1.10 + No_Safepoint_Verifier nsv; 1.11 + task = CompilationPolicy::policy()->select_task(this); 1.12 + } 1.13 remove(task); 1.14 + purge_stale_tasks(); // may temporarily release MCQ lock 1.15 return task; 1.16 } 1.17 1.18 -void CompileQueue::remove(CompileTask* task) 1.19 -{ 1.20 +// Clean & deallocate stale compile tasks. 1.21 +// Temporarily releases MethodCompileQueue lock. 1.22 +void CompileQueue::purge_stale_tasks() { 1.23 + assert(lock()->owned_by_self(), "must own lock"); 1.24 + if (_first_stale != NULL) { 1.25 + // Stale tasks are purged when MCQ lock is released, 1.26 + // but _first_stale updates are protected by MCQ lock. 1.27 + // Once task processing starts and MCQ lock is released, 1.28 + // other compiler threads can reuse _first_stale. 1.29 + CompileTask* head = _first_stale; 1.30 + _first_stale = NULL; 1.31 + { 1.32 + MutexUnlocker ul(lock()); 1.33 + for (CompileTask* task = head; task != NULL; ) { 1.34 + CompileTask* next_task = task->next(); 1.35 + CompileTaskWrapper ctw(task); // Frees the task 1.36 + task = next_task; 1.37 + } 1.38 + } 1.39 + } 1.40 +} 1.41 + 1.42 +void CompileQueue::remove(CompileTask* task) { 1.43 assert(lock()->owned_by_self(), "must own lock"); 1.44 if (task->prev() != NULL) { 1.45 task->prev()->set_next(task->next()); 1.46 @@ -714,6 +740,16 @@ 1.47 --_size; 1.48 } 1.49 1.50 +void CompileQueue::remove_and_mark_stale(CompileTask* task) { 1.51 + assert(lock()->owned_by_self(), "must own lock"); 1.52 + remove(task); 1.53 + 1.54 + // Enqueue the task for reclamation (should be done outside MCQ lock) 1.55 + task->set_next(_first_stale); 1.56 + task->set_prev(NULL); 1.57 + _first_stale = task; 1.58 +} 1.59 + 1.60 // methods in the compile queue need to be marked as used on the stack 1.61 // so that they don't get reclaimed by Redefine Classes 1.62 void CompileQueue::mark_on_stack() { 1.63 @@ -2011,7 +2047,7 @@ 1.64 1.65 // Note that the queued_for_compilation bits are cleared without 1.66 // protection of a mutex. [They were set by the requester thread, 1.67 - // when adding the task to the complie queue -- at which time the 1.68 + // when adding the task to the compile queue -- at which time the 1.69 // compile queue lock was held. Subsequently, we acquired the compile 1.70 // queue lock to get this task off the compile queue; thus (to belabour 1.71 // the point somewhat) our clearing of the bits must be occurring