1484 1485 /** 1486 * Waits for a JVMCI compiler to complete a given task. This thread 1487 * waits until either the task completes or it sees no JVMCI compilation 1488 * progress for N consecutive milliseconds where N is 1489 * JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE * 1490 * JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS. 1491 * 1492 * @return true if this thread needs to free/recycle the task 1493 */ 1494 bool CompileBroker::wait_for_jvmci_completion(JVMCICompiler* jvmci, CompileTask* task, JavaThread* thread) { 1495 MutexLocker waiter(task->lock(), thread); 1496 int progress_wait_attempts = 0; 1497 int methods_compiled = jvmci->methods_compiled(); 1498 while (!task->is_complete() && !is_compilation_disabled_forever() && 1499 task->lock()->wait(!Mutex::_no_safepoint_check_flag, JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE)) { 1500 CompilerThread* jvmci_compiler_thread = task->jvmci_compiler_thread(); 1501 1502 bool progress; 1503 if (jvmci_compiler_thread != NULL) { 1504 // If the JVMCI compiler thread is not blocked, we deem it to be making progress. 1505 progress = jvmci_compiler_thread->thread_state() != _thread_blocked; 1506 } else { 1507 // Still waiting on JVMCI compiler queue. This thread may be holding a lock 1508 // that all JVMCI compiler threads are blocked on. We use the counter for 1509 // successful JVMCI compilations to determine whether JVMCI compilation 1510 // is still making progress through the JVMCI compiler queue. 1511 progress = jvmci->methods_compiled() != methods_compiled; 1512 } 1513 1514 if (!progress) { 1515 if (++progress_wait_attempts == JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS) { 1516 if (PrintCompilation) { 1517 task->print(tty, "wait for blocking compilation timed out"); 1518 } 1519 break; 1520 } 1521 } else { 1522 progress_wait_attempts = 0; 1523 if (jvmci_compiler_thread == NULL) { 1524 methods_compiled = jvmci->methods_compiled(); 1525 } | 1484 1485 /** 1486 * Waits for a JVMCI compiler to complete a given task. This thread 1487 * waits until either the task completes or it sees no JVMCI compilation 1488 * progress for N consecutive milliseconds where N is 1489 * JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE * 1490 * JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS. 1491 * 1492 * @return true if this thread needs to free/recycle the task 1493 */ 1494 bool CompileBroker::wait_for_jvmci_completion(JVMCICompiler* jvmci, CompileTask* task, JavaThread* thread) { 1495 MutexLocker waiter(task->lock(), thread); 1496 int progress_wait_attempts = 0; 1497 int methods_compiled = jvmci->methods_compiled(); 1498 while (!task->is_complete() && !is_compilation_disabled_forever() && 1499 task->lock()->wait(!Mutex::_no_safepoint_check_flag, JVMCI_COMPILATION_PROGRESS_WAIT_TIMESLICE)) { 1500 CompilerThread* jvmci_compiler_thread = task->jvmci_compiler_thread(); 1501 1502 bool progress; 1503 if (jvmci_compiler_thread != NULL) { 1504 // If the JVMCI compiler thread is not blocked or suspended, we deem it to be making progress. 1505 progress = jvmci_compiler_thread->thread_state() != _thread_blocked && 1506 !jvmci_compiler_thread->is_external_suspend(); 1507 } else { 1508 // Still waiting on JVMCI compiler queue. This thread may be holding a lock 1509 // that all JVMCI compiler threads are blocked on. We use the counter for 1510 // successful JVMCI compilations to determine whether JVMCI compilation 1511 // is still making progress through the JVMCI compiler queue. 1512 progress = jvmci->methods_compiled() != methods_compiled; 1513 } 1514 1515 if (!progress) { 1516 if (++progress_wait_attempts == JVMCI_COMPILATION_PROGRESS_WAIT_ATTEMPTS) { 1517 if (PrintCompilation) { 1518 task->print(tty, "wait for blocking compilation timed out"); 1519 } 1520 break; 1521 } 1522 } else { 1523 progress_wait_attempts = 0; 1524 if (jvmci_compiler_thread == NULL) { 1525 methods_compiled = jvmci->methods_compiled(); 1526 } |