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

private static final method must be hand inlined

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 1.2.1
    • vm-legacy
    • None
    • jit
    • sparc
    • solaris_2.6

      In working in java.math BigInteger, I discovered that hand inlining a method
      called toLong() at least doubled my performance on Solaris. It seems that the symantec
      JIT on windows can inline it. Shouldn't the Solaris JIT take care of this?

      public class Inline {

          private static int size = 1000;

          public static void main(String[] args) throws Exception {
             
              if (args.length >0)
                  size = Integer.parseInt(args[0]);

              runInlineTest();
              runCallTest();
          }

          private static final long toLong(int anInt) {
              return anInt & 0xffffffffL;
          }

          private static long runInlineTest() {
              long startTime = System.currentTimeMillis();
              long c = 0;

              for (int x = 0; x < size; x++)
                  for (int y = 0; y < size; y++)
                      c += x & 0xffffffffL;

              long endTime = System.currentTimeMillis();
              long totalTime = endTime - startTime;

              reportResult("Inlined test", "milliseconds", totalTime);
              return c;
          }

          private static long runCallTest() {
              long startTime = System.currentTimeMillis();
              long c = 0;

              for (int x = 0; x < size; x++)
                  for (int y = 0; y < size; y++)
                      c += toLong(x);

              long endTime = System.currentTimeMillis();
              long totalTime = endTime - startTime;
              
              reportResult("Method call test", "milliseconds", totalTime);
              return c;
          }

          private static void reportResult(String label, String unit, long result) {
              
              StringBuffer message = new StringBuffer(100);
              
              message.append(label + " completed in " + result + " " + unit);
              System.err.println(message);
          }
      }

            Unassigned Unassigned
            mmcclosksunw Michael Mccloskey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: