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

Micro-optimize Method::can_be_statically_bound assertions

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 20
    • 11, 17, 19, 20
    • hotspot
    • b07

      If you profile this test:

      $ CONF=linux-x86_64-server-fastdebug make test TEST=java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java

      The hotpath is in the method below, where we have `ResourceMark` that is needed for possible call to `name_and_sig_as_C_string()`:

      ```
      bool Method::can_be_statically_bound(AccessFlags class_access_flags) const {
         ...
      #ifdef ASSERT
        ResourceMark rm;
        bool is_nonv = (vtable_index() == nonvirtual_vtable_index);
        if (class_access_flags.is_interface()) {
            assert(is_nonv == is_static() || is_nonv == is_private(),
                   "nonvirtual unexpected for non-static, non-private: %s",
                   name_and_sig_as_C_string());
        }
      #endif
        ...
      }
      ```

      ...but we end up doing `ResourceMark` destruction all the time on all paths, which includes `ZapResourceArea` code, which zaps the entirety of *untouched* `ResourceArea` chunk.

      We can move `ResourceMark` so that it is only used when we are about to fire the error.

            shade Aleksey Shipilev
            shade Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: