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

Add size_t versions of Atomic::add, dec, and inc

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • hotspot
    • None
    • b08

      There's no Atomic:add version that operates on size_t typed variables. Instead the code resort to use Atomic::add_ptr, which takes an intptr_t.

      By adding size versions of Atomic::add, dec, and inc, we could clean up the code base to use more correct types for our variables used with Atomic operations.

      One example:
      volatile intptr_t MetaspaceGC::_capacity_until_GC = 0;

      is used as a size_t, but declared intptr_t to work well with:
      size_t MetaspaceGC::inc_capacity_until_GC(size_t v) {
        assert_is_size_aligned(v, Metaspace::commit_alignment());

        return (size_t)Atomic::add_ptr(v, &_capacity_until_GC);
      }

            dsimms David Simms
            stefank Stefan Karlsson
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: