[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

DeadAssignmentEliminator




Contains the following code:

                        if(rhs instanceof InvokeExpr ||
                           rhs instanceof InstanceFieldRef ||
                           rhs instanceof ArrayRef)
                        {
                           // Note that InstanceFieldRef, ArrayRef,
InvokeExpr all can
                           // have side effects (like throwing a null
pointer exception)

                            isEssential = true;
                        }

However, this seems rather conservative.  Specifically, I end up with alot
of assignments
from field this.foo that are dead.

Perhaps better would be something like:
if(rhs instanceof InvokeExpr ||
   rhs instanceof ArrayRef)

    isEssential = true;
} else if(rhs instanceof InstanceFieldRef) {
	if(method.isStatic() &&
		lhs == body.getThisLocal()) {
		isEssential = false;
      } else {
		isEssential = true;
}

What do you all think?

Steve

BEGIN:VCARD
VERSION:2.1
N:Neuendorffer;Stephen
FN:Stephen Neuendorffer
ORG:UC Berkeley;EECS
TITLE:Graduate Student Researcher
TEL;HOME;VOICE:(510) 233-5782
TEL;CELL;VOICE:(510) 367-2057
TEL;WORK;FAX:(510) 642-2739
ADR;WORK:;337 Cory;337 Cory Hall;Berkeley;CA;94720-1770;United States of America
LABEL;WORK;ENCODING=QUOTED-PRINTABLE:337 Cory=0D=0A337 Cory Hall=0D=0ABerkeley, CA 94720-1770=0D=0AUnited States =
of America
ADR;HOME:;;7003 Potrero Ave.;El Cerrito;CA;94530;United States of America
LABEL;HOME;ENCODING=QUOTED-PRINTABLE:7003 Potrero Ave.=0D=0AEl Cerrito, CA 94530=0D=0AUnited States of America
EMAIL;PREF;INTERNET:neuendor@eecs.berkeley.edu
REV:20001220T050447Z
END:VCARD