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

G1: Improve comment about mark word handling of displaced mark words

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 16
    • 16
    • hotspot
    • gc
    • b24

       The comment in handling displaced mark words in G1ParScanThreadState::do_oop_evac() is misleading:

            if (old_mark.has_displaced_mark_helper()) {
              // In this case, we have to install the mark word first,
              // otherwise obj looks to be forwarded (the old mark word,
              // which contains the forward pointer, was copied)
              obj->set_mark(old_mark);
              markWord new_mark = old_mark.displaced_mark_helper().set_age(age);
              old_mark.set_displaced_mark_helper(new_mark);

      "in this case" - it is not true that only in this case the mark word looks to be forwarded because of the copy. G1 always copies the mark word containing the forwarded pointer, i.e. after the copy, the mark word in obj is always the forwarding pointer here.
      That's why we need to set it to the (eventually updated) old mark word value in all these cases....

      "we have to install the mark word first" - the order of installing the mark word and updating the displaced mark word is completely irrelevant here - the point is that we need to update the age in the displaced mark word and must not change the old mark word in this branch. The obj->set_mark() call can be at any position actually.

      I.e. this comment is completely misleading about the point of this code. Remove or improve.

            tschatzl Thomas Schatzl
            tschatzl Thomas Schatzl
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: