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

Refactor the assignment of loader bits in InstanceKlassFlags

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 25
    • None
    • hotspot
    • b25

      AOT uses these bits in InstanceKlassFlags to quickly find out the defining loader of a class, without having to query InstanceKlass::class_loader().

      class InstanceKlassFlags {
       #define IK_FLAGS_DO(flag) \
          flag(is_shared_boot_class , 1 << 7) /* defining class loader is boot class loader */ \
          flag(is_shared_platform_class , 1 << 8) /* defining class loader is platform class loader */ \
          flag(is_shared_app_class , 1 << 9) /* defining class loader is app class loader */ \

      However, there are several problems:

      [1] The bits a mis-named. We assigned these bits even for classes that are loaded outside of the AOT cache. I.e., it's possible for this to be true:

          !ik->is_shared() && is_shared_boot_class()

      [2] These bits are assigned in multiple places, sometimes well after the class becomes visible, so there may be race conditions in reading these bits.

      [3] These bits are used only inside INCLUDE_CDS, but they could be useful even when AOT/CDS is not used.

      =======================
      Proposal:
      - Set these bits exactly once inside ClassFileParser::fill_instance_klass(), to avoid race conditions
      - Set these flags even when AOT/CDS is not used -- the cost is trivial. That way, we don't need to worry if a code path might be invalid when AOT/CDS is disabled.
      - Renamed the flags to the following

          flag(defined_by_boot_loader , 1 << 7) /* defining class loader is boot class loader */ \
          flag(defined_by_platform_loader , 1 << 8) /* defining class loader is platform class loader */ \
          flag(defined_by_app_loader , 1 << 9) /* defining class loader is app class loader */ \
       

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

              Created:
              Updated:
              Resolved: