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

Suppress superficial unstable_if traps

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: In Progress
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 19
    • Fix Version/s: tbd
    • Component/s: hotspot
    • Labels:
    • Subcomponent:
    • Understanding:
      Fix Understood

      Description

      This is a follow-up of JDK-8286104.

      A unstable if trap is *trivial* if it can NOT prune any code, or the pruned basic block is too small to compensate its cost.
      A unstable if trap is *superficial* if it can NOT prune any code. Sometimes, the else-section of program is empty. The superficial unstable_if traps not only complicate code shape but also consume codecache. we have to generate debuginfo for them. By definition, speculative compilation can't take any benefit from superficial unstable_if. If the condition changed, HotSpot has to destroy the established nmethod and compile it again. Even though it's likely that the recompilation will avoid "superficial" unstable_if traps, there's no guarantee. It's up to profiling data.

      eg. foo() generates a trivial unstable_if the else branch, even though it's empty.

      public class TrivialUnstableIfTrap {
          public static void main(String[] args) {
              for (int i = 0; i < 20_000; ++i) {
                  foo(true, 1000);
              }
              foo(false, 1000);
          }
          
          public static int foo(boolean cond, int value) {
              int x = 0;
              if (cond) {
                  x = Integer.valueOf(value);
              }
              return x;
          }
      }

      It's possible to determine that an uncommon_trap is superficial in parser. A uncommon_trap which does cut out some code leave at least one basic block unmerged. C2 parser skips those 'unmerged' blocks because it treats them as dead paths. We can bookkeep all unstable_if traps with their target blocks. If the target block is parsed in parser, then the unstable_if trap is superficial. We can suppress those superficial unstable_if traps.

        Attachments

          Activity

            People

            Assignee:
            xliu Xin Liu
            Reporter:
            xliu Xin Liu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: