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

member variable _monitor of MonitorLocker is redundant

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 17
    • Fix Version/s: 17
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b18

      Description

      MonitorLocker is a subclass of MutexLocker. The member variable _monitor has the same value of _mutex in its base class.

      The only difference is type of pointer. Because 2 constructs pass in Monitor*, it's safe to use static_cast<> to cast _mutex to Monitor*. eg.
      Monitor* as_monitor() const {
      return static_cast<Monitor* >(_mutex);
      }

      This can save 1 pointer for a MonitorLocker object. on x86_64 LP64, it can save 8 bytes.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              xliu Xin Liu
              Reporter:
              xliu Xin Liu
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: