Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 13
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b16

      Description

      Currently Math.floorMod is implemented as: return x - floorDiv(x, y) * y;

      This can be optimized as:

              int mod = x % y;
              // if the signs are different and modulo not zero, adjust result
              if ((mod ^ y) < 0 && mod != 0) {
                  mod += y;
              }
              return mod;

      While the JIT does a reasonably good job at the current implementation, this ensures we only do a single integer division and no subsequent integer multiplications, speeding up execution by ~1.3x in interpreter (mainly from removing the floorDiv method call overhead) and ~1.1x with C1 and C2.

        Attachments

          Activity

            People

            • Assignee:
              redestad Claes Redestad
              Reporter:
              redestad Claes Redestad
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: