Enhance footprint for array initialization

Tom Rodriguez Thomas.Rodriguez at Sun.COM
Tue Sep 2 08:32:31 PDT 2008


I think you're on the wrong list.  This is a javac code generation  
issue.  I think you want compiler-dev at openjdk.java.net.

tom

On Sep 1, 2008, at 10:19 AM, Ulf Zibis wrote:

> I my code I have following array initialization:
> (from: https://java-nio-charset-enhanced.dev.java.net/source/browse/java-nio-charset-enhanced/tags/sun_io_CharacterEncoding_using_String 
> [][]/src/sun/io/CharacterEncoding.java?rev=&view=markup)
>
>   private static final String[][] extendedAliasMappings = {
>       {"8859_1",                "ISO8859_1"},
>       {"iso_8859-1:1987",       "ISO8859_1"},
>       {"iso-ir-100",            "ISO8859_1"},
>       {"iso_8859-1",            "ISO8859_1"},
>       // + 475 more pairs ...
>   }
>
> In the class file the following block is repeated 475 times:
> (from: https://java-nio-charset-enhanced.dev.java.net/source/browse/java-nio-charset-enhanced/tags/sun_io_CharacterEncoding_using_String%5B%5D%5B%5D/docs/javap.out/javap%20CharacterEncoding(String%5B%5D%5B%5D).out?rev=&view=markup)
>
>  874:    dup
>  875:    iconst_0
>  876:    iconst_2
>  877:    anewarray    #10; //class java/lang/String
>  880:    dup
>  881:    iconst_0
>  882:    ldc    #40; //String 8859_1
>  884:    aastore
>  885:    dup
>  886:    iconst_1
>  887:    ldc    #41; //String ISO8859_1
>  889:    aastore
>  890:    aastore
>
> IMHO it would be better, to initialize the String[][] by a loop,  
> instead inlining those bytecodes 475 times. This would considerably  
> decrease the footprint of the class file.
>
> Is there any chance, we could have this in the future?
>
> Regards,
>
> -Ulf
>
>




More information about the hotspot-dev mailing list