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

Static analysis of IfNode should consider terminating branches

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • core-libs
    • b55
    • generic
    • generic

        Static analysis of IfNode doesn't properly recognize terminating branches, resulting in unnecessary widening of some variables. E.g. Octane Crypto benchmark contains this code in its bnpFromString function:

          var k;
          if(b == 16) k = 4;
          else if(b == 8) k = 3;
          else if(b == 256) k = 8; // byte array
          else if(b == 2) k = 1;
          else if(b == 32) k = 5;
          else if(b == 4) k = 2;
          else { this.fromRadix(s,b); return; }
          ...
        Currently, the type of k will be OBJECT after the if/elseif statements. This is due to the fact that the analysis doesn't recognize that the only branch that doesn't set it to INT also terminates, therefore it is impossible to exit the last else branch with k being UNDEFINED.

              attila Attila Szegedi
              attila Attila Szegedi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: