Summary: | [compiler] Unused locals initialisation is optimized out when it is a single name reference | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Olivier Thomann <Olivier_Thomann> | ||||||||
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> | ||||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||||
Severity: | critical | ||||||||||
Priority: | P3 | ||||||||||
Version: | 3.2 | ||||||||||
Target Milestone: | 3.2.2 | ||||||||||
Hardware: | PC | ||||||||||
OS: | Windows XP | ||||||||||
Whiteboard: | |||||||||||
Attachments: |
|
Description
Olivier Thomann
2006-09-27 15:38:29 EDT
Created attachment 51035 [details]
Proposed fix
Created attachment 51055 [details]
Regression tests updated
Updated the BooleanTest. We optimized out completely the generation of the static field.
Not all SingleNameReferences need to be deoptimized as in previous patch. interface I { int CONST = A.foo(); } class A { static int foo() { System.out.println("SUCCESS"); return 0; } } class B implements I { static int LOCAL_STATIC; B(int param) { int i = CONST; // keep for possible <clinit> int j = param; // may optimize out int k = LOCAL_STATIC; // may optimize out } } public class X { public static void main(String[] args) { new B(12); } } Testcase for QualifiedNameReference: "[I.CONST]" should be printed (amongst others) interface I { Value CONST = A.foo("[I.CONST]"); } class Value { static String NAME = ""; String v; Value(String v) { this.v = v; } } class A { static Value foo(String str) { System.out.print(str); return new Value("str"); } } class B implements I { static Value LOCAL_STATIC = A.foo("[B.LOCAL_STATIC]"); Value local_field = A.foo("[B.local_field]"); B(Value param) { String i = CONST.NAME; // keep for possible <clinit> String j = param.NAME; // may optimize out String k = LOCAL_STATIC.NAME; // may optimize out String l = local_field.NAME; // may optimize out } } public class X { public static void main(String[] args) { new B(new Value("[PARAM]")); } } Same issue with FieldReference: "[I.CONST]" should be printed (amongst others) interface I { Value CONST = A.foo("[I.CONST]"); } class Value { static String NAME = ""; String v; Value(String v) { this.v = v; } } class A { static Value foo(String str) { System.out.print(str); return new Value("str"); } } class B implements I { static Value LOCAL_STATIC = A.foo("[B.LOCAL_STATIC]"); Value local_field = A.foo("[B.local_field]"); B(Value param) { String i = this.CONST.NAME; // keep for possible <clinit> String k = this.LOCAL_STATIC.NAME; // may optimize out String l = this.local_field.NAME; // may optimize out } } public class X { public static void main(String[] args) { new B(new Value("[PARAM]")); } } Added InitializationTest#test189-191; GenericTypeTest#test1039-1041. Created attachment 51079 [details]
Better patch
Solves issues for single/qualified and field references
Released for 3.3M3. Fixed Considering for 3.2.2. Released for 3.2.2 Verified for 3.3 M3 using build I20061030-0010 verified for 3.2.2 using build M20070112-1200 |