[Soot-list] DeadAssignmentEliminator bug fix

Archie Cobbs archie at dellroad.org
Sat May 21 15:50:18 EDT 2005


[ Bugzilla seems AWOL... http://svn.sable.mcgill.ca/bugzilla/
   returns "Not Found" ]

The DAE eliminates "new" expressions, which is wrong because they
might trigger class initialization. Same for static field references.

The attached patch hopefully fixes these problems.

An optimization which I didn't implement would be to first check
whether the referenced class was the same class as of the method
being optimized (or any superclass), in which case it's always
OK to eliminate the assignment because that class must have already
been initialized by the time any of its methods are invoked.

Cheers,
-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com
-------------- next part --------------
Index: src/soot/jimple/toolkits/scalar/DeadAssignmentEliminator.java
===================================================================
--- src/soot/jimple/toolkits/scalar/DeadAssignmentEliminator.java	(revision 2030)
+++ src/soot/jimple/toolkits/scalar/DeadAssignmentEliminator.java	(working copy)
@@ -131,6 +131,14 @@
                             // Can trigger ClassCastException
                             isEssential = true;
                         }
+
+                        else if (rhs instanceof NewExpr
+			  || (rhs instanceof FieldRef
+			    && !(rhs instanceof InstanceFieldRef)))
+                        {
+                            // Can trigger class initialization
+                            isEssential = true;
+                        }
                     }
                 }
                 


More information about the Soot-list mailing list