Bug 37387 - Compiler generates unnecessary byte codes
Summary: Compiler generates unnecessary byte codes
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.1.1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-05-08 10:39 EDT by Andreas Winter CLA
Modified: 2003-06-30 13:10 EDT (History)
1 user (show)

See Also:


Attachments
Fix proposal (675 bytes, patch)
2003-05-08 13:04 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Winter CLA 2003-05-08 10:39:53 EDT
Compiling 
   private static final Object X[] = new Object[]{null,null}
yields much longer byte code in Eclipse 2.1.1 (200305071103) than in 2.0.2
(200211071448).
The compiler generates unnecessary stores for the null values.
Comment 1 Olivier Thomann CLA 2003-05-08 12:55:11 EDT
The reason is that we no longer consider null has a constant. This case could
still be optimized. I will investigate.
Comment 2 Olivier Thomann CLA 2003-05-08 13:04:05 EDT
Created attachment 4825 [details]
Fix proposal

Philippe, I attached a patch that optimizes this case. We now generate the same
bytecodes than jikes. javac 1.4.1_02 or 1.4.2b21 still generate the whole array
initializer. Let me know if you want me to release it.
Comment 3 Philipe Mulet CLA 2003-05-12 06:04:35 EDT
Please release this patch. Indeed, I forgot about this codegen optimization 
when removing null constant expressions.
Comment 4 Philipe Mulet CLA 2003-05-12 06:04:59 EDT
Olivier, also backport it to 2.1 maintenance stream.
Comment 5 Olivier Thomann CLA 2003-05-12 10:45:11 EDT
Fixed and released in HEAD stream.
Comment 6 Olivier Thomann CLA 2003-05-12 10:55:12 EDT
Backported to 2.1 maintenance stream.
Comment 7 Olivier Thomann CLA 2003-05-12 11:39:57 EDT
Regression test added.
Comment 8 David Audel CLA 2003-06-06 07:02:28 EDT
Verified.