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

Optimize CDS PatchEmbeddedPointers::do_bit()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 21
    • 18
    • hotspot
    • b03

      https://github.com/openjdk/jdk/blob/090cdfc7a2e280c620a0926512fb67f0ce7f3c21/src/hotspot/share/cds/archiveHeapLoader.cpp#L90-L104

      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 PatchCompressedEmbeddedPointers: public BitMapClosure {
        narrowOop* _start;

       public:
        PatchCompressedEmbeddedPointers(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 = ArchiveHeapLoader::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;
        }

            matsaave Matias Saavedra Silva
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: