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

compiler shouldn't initialize elements to 0 in array initializers

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P5 P5
    • 1.1.5
    • 1.1
    • tools
    • None
    • 1.1.5
    • sparc
    • solaris_2.5
    • Verified

      [never 3 dec 96]
      Currently the way the compiler handles initialized arrays is to emit inline code which fills in the values in a newly created array. But it doesn't really need to fill in values that are 0 since the new array should already be full of the default values. This doesn't occur all that often I suspect but there currently in sun.io there are some staggeringly large class files as a result of the way array are initialized. Many of these arrays are large contain a lot of 0's. The savings would be around 15% for the files in sun.io if the compiler were modified to just not emit 0's when initializing an array.

      I think all that needs to be done is to change the code around line 110 in sun/tools/tree/ArrayExpression.java to look like this:

              for (int i = 0 ; i < args.length ; i++) {
                  if (args[i].equalsDefault()) // new code
                    continue; // new code
                  asm.add(where, opc_dup);

      I have no need for this but it seems like it might be a useful optimization. It seems there might be some other simple improvments to the code for initializing arrays...

            dstoutamsunw David Stoutamire (Inactive)
            never Tom Rodriguez
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: