400 // save methods from RedefineClasses across safepoint |
400 // save methods from RedefineClasses across safepoint |
401 // across MethodCompileQueue_lock below. |
401 // across MethodCompileQueue_lock below. |
402 methodHandle save_method; |
402 methodHandle save_method; |
403 methodHandle save_hot_method; |
403 methodHandle save_hot_method; |
404 |
404 |
405 MutexLocker locker(MethodCompileQueue_lock); |
405 MonitorLocker locker(MethodCompileQueue_lock); |
406 // If _first is NULL we have no more compile jobs. There are two reasons for |
406 // If _first is NULL we have no more compile jobs. There are two reasons for |
407 // having no compile jobs: First, we compiled everything we wanted. Second, |
407 // having no compile jobs: First, we compiled everything we wanted. Second, |
408 // we ran out of code cache so compilation has been disabled. In the latter |
408 // we ran out of code cache so compilation has been disabled. In the latter |
409 // case we perform code cache sweeps to free memory such that we can re-enable |
409 // case we perform code cache sweeps to free memory such that we can re-enable |
410 // compilation. |
410 // compilation. |
421 // the stable state, i.e., we do not want to evict methods from the |
421 // the stable state, i.e., we do not want to evict methods from the |
422 // code cache if it is unnecessary. |
422 // code cache if it is unnecessary. |
423 // We need a timed wait here, since compiler threads can exit if compilation |
423 // We need a timed wait here, since compiler threads can exit if compilation |
424 // is disabled forever. We use 5 seconds wait time; the exiting of compiler threads |
424 // is disabled forever. We use 5 seconds wait time; the exiting of compiler threads |
425 // is not critical and we do not want idle compiler threads to wake up too often. |
425 // is not critical and we do not want idle compiler threads to wake up too often. |
426 MethodCompileQueue_lock->wait(5*1000); |
426 locker.wait(5*1000); |
427 |
427 |
428 if (UseDynamicNumberOfCompilerThreads && _first == NULL) { |
428 if (UseDynamicNumberOfCompilerThreads && _first == NULL) { |
429 // Still nothing to compile. Give caller a chance to stop this thread. |
429 // Still nothing to compile. Give caller a chance to stop this thread. |
430 if (can_remove(CompilerThread::current(), false)) return NULL; |
430 if (can_remove(CompilerThread::current(), false)) return NULL; |
431 } |
431 } |
1494 * JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS. |
1494 * JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS. |
1495 * |
1495 * |
1496 * @return true if this thread needs to free/recycle the task |
1496 * @return true if this thread needs to free/recycle the task |
1497 */ |
1497 */ |
1498 bool CompileBroker::wait_for_jvmci_completion(JVMCICompiler* jvmci, CompileTask* task, JavaThread* thread) { |
1498 bool CompileBroker::wait_for_jvmci_completion(JVMCICompiler* jvmci, CompileTask* task, JavaThread* thread) { |
1499 MutexLocker waiter(task->lock(), thread); |
1499 MonitorLocker ml(task->lock(), thread); |
1500 int progress_wait_attempts = 0; |
1500 int progress_wait_attempts = 0; |
1501 int methods_compiled = jvmci->methods_compiled(); |
1501 int methods_compiled = jvmci->methods_compiled(); |
1502 while (!task->is_complete() && !is_compilation_disabled_forever() && |
1502 while (!task->is_complete() && !is_compilation_disabled_forever() && |
1503 task->lock()->wait(JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE)) { |
1503 ml.wait(JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE)) { |
1504 CompilerThread* jvmci_compiler_thread = task->jvmci_compiler_thread(); |
1504 CompilerThread* jvmci_compiler_thread = task->jvmci_compiler_thread(); |
1505 |
1505 |
1506 bool progress; |
1506 bool progress; |
1507 if (jvmci_compiler_thread != NULL) { |
1507 if (jvmci_compiler_thread != NULL) { |
1508 // If the JVMCI compiler thread is not blocked or suspended, we deem it to be making progress. |
1508 // If the JVMCI compiler thread is not blocked or suspended, we deem it to be making progress. |
1556 if (comp->is_jvmci()) { |
1556 if (comp->is_jvmci()) { |
1557 free_task = wait_for_jvmci_completion((JVMCICompiler*) comp, task, thread); |
1557 free_task = wait_for_jvmci_completion((JVMCICompiler*) comp, task, thread); |
1558 } else |
1558 } else |
1559 #endif |
1559 #endif |
1560 { |
1560 { |
1561 MutexLocker waiter(task->lock(), thread); |
1561 MonitorLocker ml(task->lock(), thread); |
1562 free_task = true; |
1562 free_task = true; |
1563 while (!task->is_complete() && !is_compilation_disabled_forever()) { |
1563 while (!task->is_complete() && !is_compilation_disabled_forever()) { |
1564 task->lock()->wait(); |
1564 ml.wait(); |
1565 } |
1565 } |
1566 } |
1566 } |
1567 |
1567 |
1568 thread->set_blocked_on_compilation(false); |
1568 thread->set_blocked_on_compilation(false); |
1569 if (free_task) { |
1569 if (free_task) { |