Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8369238

Allow virtual thread preemption on some common class initialization paths

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P3 P3
    • 26
    • 26
    • hotspot

      If a thread tries to initialize a class that is already being initialized by another thread, it will block until notified. Since at this blocking point there are native frames on the stack, a virtual thread cannot be unmounted and is pinned to its carrier. Besides harming scalability, this can, in some pathological cases, lead to a deadlock, for example, if the thread executing the class initialization method is blocked waiting for some unmounted virtual thread to run, but all carriers are blocked waiting for that class to be initialized.

      As of JDK-8338383, virtual threads blocked in the VM on ObjectMonitor operations can be preempted. Since synchronization on class initialization is implemented using ObjectLocker, we can reuse the same mechanism to preempt all virtual threads blocked waiting for a class to be initialized along some of the most common initialization paths, in particular, when executing invokestatic, new, getstatic and putstatic from the interpreter.

            pchilanomate Patricio Chilano Mateo
            pchilanomate Patricio Chilano Mateo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: