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

member variable _monitor of MonitorLocker is redundant

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 17
    • 17
    • hotspot
    • b18

      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.

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

              Created:
              Updated:
              Resolved: