As a result of JDK-8141330, the CompileBroker uses a timeout of 1 second when waiting for a blocking JVMCI compilation to complete. This approach is too simple. JVMCI compiler threads themselves flood the compilation queues with compilation requests; such compilations cannot be blocking (the JVMCI compiler executes Java code and so can cause the system to deadlock). This flooding means that application submitted tasks often timeout before the tasks even start compiling.
Once a JVMCI thread starts compiling a task, there is still the risk of it deadlocking. The current timeout mechanism needs to be augmented with a test of the compiler thread's state. As long as it's not blocked for too long, we know the compiler is making progress and will eventually complete.
This issue covers the following changes when the VM is in blocking compilation mode:
1. Blocking tasks are selected before non-blocking tasks from the compilation queue(s).
2. A thread waiting for a compilation task to complete checks the state of the compiler thread periodically (500ms intervals). If 5 successive checks see a blocked thread, the compilation times out and the waiting thread is unblocked.