Community
Participate
Working Groups
The virtual machine on many embedded devices does not do runtime optimation. It would therefore be nice if the compiler performed certain optimizations which although they could have been done by the programmer they would interfere with the understanding of the code. In the following class (initialization and error checking code has been removed)fastCRC runs twice as fast as slowCRC on a Motorola i85s phone, but no programmer wants to write code like fastCRC. Eclipse's compiler should have an option to perform this kind of optimization. public class CRC32 { /** * Table of CRC-32's of all single-byte values */ static int crc_table[]; public static int crc; static public int slowCRC(byte[] buf, int offset, int len) { for(;len>0; offset++,len--) { crc = crc_table[(crc ^ buf[offset]) & 0xff] ^ ((crc >> 8)&0xffffff); } crc = crc ^ 0xFFFFFFFF; return crc; } static public int fastCRC(byte[] buf, int offset, int len) { int lcrc = crc ^ 0xFFFFFFFF; int[] ltable = crc_table; for(;len>0; offset++,len--) { lcrc = ltable[(lcrc ^ buf[offset]) & 0xff] ^ ((lcrc >> 8)&0xffffff); } crc = lcrc ^ 0xFFFFFFFF; return crc; } }
We might consider more bytecode optimizations after R2.0. Is it ok ? It will not get lost.
The current optimizations assume that a JIT will be executing the bytecode. For MIDP devices it seems that the bytecodes are executed directly. An option for inlining or similar optimizations would really help for these platforms.
Shmuel, Would you be interested in implementing these changes ?
Defer
As of now 'LATER' and 'REMIND' resolutions are no longer supported. Please reopen this bug if it is still valid for you.