[lworld] Some Unsafe methods to access values are globally synchronized

XMLWordPrintable

      The following methods are synchronized using a global monitor:
        - Unsafe.putValueVolatile()
        - Unsafe.getValueVolatile()

      which means that methods calling those methods are also subject to global synchronization:
        - Unsafe.putValueRelease()
        - Unsafe.getValueAcquire()
        - Unsafe.putValueOpaque()
        - Unsafe.getValueOpaque()
        - Unsafe.getAndSetValue()
        - Unsafe.compareAndSetReference() (in some cases)
        - Unsafe.compareAndSetValue()
        - Unsafe.compareAndExchangeReference() (in some cases)
        - Unsafe.compareAndExchangeValue()

      Use of a single global lock is likely to become a performance bottleneck in applications making heavy use (directly or indirectly) of those APIs.

      Note: volatile is used to ensure proper visibility of a value change by inserting a memory barrier. Volatile also has a semantic to make long and double access atomic. In the case of a flat value with a non-atomic layout, such locking mechanism would not guarantee atomicity because the other ways to access the value (interpreter, runtime, compiled code, JNI) are not aware of this lock.


            Assignee:
            Unassigned
            Reporter:
            Frederic Parain
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: