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

Optimize CDS PatchEmbeddedPointers::do_bit()

    XMLWordPrintable

    Details

      Description

      See https://github.com/openjdk/jdk/blob/06d26208c5604c0c640eff4da94ef814c2ebebf0/src/hotspot/share/cds/heapShared.cpp#L1426

      The current implementation reads the narrow oop, decodes it using the "dump time" encoding, encodes it using "runtime" encoding, and then stores it back into the heap:

      // Patch all the embedded oop pointers inside an archived heap region,
      // to be consistent with the runtime oop encoding.
      class PatchEmbeddedPointers: public BitMapClosure {
        narrowOop* _start;

       public:
        PatchEmbeddedPointers(narrowOop* start) : _start(start) {}

        bool do_bit(size_t offset) {
          narrowOop* p = _start + offset;
          narrowOop v = *p;
          assert(!CompressedOops::is_null(v), "null oops should have been filtered out at dump time");
          oop o = HeapShared::decode_from_archive(v);
          RawAccess<IS_NOT_NULL>::oop_store(p, o);
          return true;
        }
      };

      In some cases, the decoding/encoding is not necessary. For example, if the the same number of shifts are used in both dump time and runtime, it can be simplified as:

      const uintx delta = (runtime_heap-base - dumptime_heap_base)
                                    >> num_shifts;

        bool do_bit(size_t offset) {
          narrowOop* p = _start + offset;
          narrowOop v = *p;
          v += delta;
          *p = v;
          return true;
        }

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: