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

Simplify storage of dump-time class information

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 20
    • 20
    • hotspot
    • b09

      Proposal:

      [1] SystemDictionaryShared::{_dumptime_table, _dumptime_lambda_proxy_class_dictionary} should be allocated at VM bootstrap to so:

      + We don't need to allocate these tables dynamically
      + We don't need to check if these tables exist when writing the archive

      [2] The current implementation guarantees that SystemDictionaryShared::_dumptime_table always contains a DumpTimeClassInfo for each InstanceKlass that's being considered for inclusion in the CDS archive. We can simplify the old SystemDictionaryShared::find_or_allocate_info_for() API to

          // Guaranteed to return non-NULL value for non-shared classes.
          // k must not be a shared class.
          DumpTimeClassInfo* SystemDictionaryShared::get_info(InstanceKlass* k)


      =========================================
      Background:

      The API for SystemDictionaryShared::find_or_allocate_info_for() is too loose and potentially unreliable. By definition, it will allocate a new DumpTimeClassInfo if one doesn't already exist. It's used in places like this:

      https://github.com/openjdk/jdk/blob/b1817a30a00d74f70b247c783047bfbb49515dda/src/hotspot/share/classfile/systemDictionaryShared.cpp#L673-L679

      bool SystemDictionaryShared::is_excluded_class(InstanceKlass* k) {
        assert(_no_class_loading_should_happen, "sanity");
        assert_lock_strong(DumpTimeTable_lock);
        Arguments::assert_is_dumping_archive();
        DumpTimeClassInfo* p = find_or_allocate_info_for_locked(k);
        return (p == NULL) ? true : p->is_excluded();
      }

      However, the implementation will not allocate under some circumstances. The behavior depends on many external states, making the code hard to understand:

      https://github.com/openjdk/jdk/blob/master/src/hotspot/share/cds/dumpTimeClassInfo.cpp#L172-L190

      DumpTimeClassInfo* DumpTimeSharedClassTable::find_or_allocate_info_for(InstanceKlass* k, bool dump_in_progress) {
        bool created = false;
        DumpTimeClassInfo* p;
        if (!dump_in_progress) {
          p = put_if_absent(k, &created);
        } else {
          p = get(k);
        }
        if (created) {
          assert(!SystemDictionaryShared::no_class_loading_should_happen(),
                 "no new classes can be loaded while dumping archive");
          p->_klass = k;
        } else {
          if (!dump_in_progress) {
            assert(p->_klass == k, "Sanity");
          }
        }
        return p;
      }

            iklam Ioi Lam
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: