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

Static analysis of IfNode should consider terminating branches

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b55
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        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.

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: