From fd58ffc924878e36a9d1dfdd9a8a2f169fd77b97 Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Wed, 26 Aug 2009 17:04:17 +0000 Subject: Fixed faulty constant propagation in the optimi... Fixed faulty constant propagation in the optimizer (#2279) --- .../nsc/backend/icode/analysis/CopyPropagation.scala | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala index d83e7341e6..7f5ca3c357 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/analysis/CopyPropagation.scala @@ -23,7 +23,7 @@ abstract class CopyPropagation { import icodes._ /** Locations can be local variables, this, and fields. */ - abstract sealed class Location; + abstract sealed class Location case class LocalVar(l: Local) extends Location case class Field(r: Record, sym: Symbol) extends Location case object This extends Location @@ -459,11 +459,16 @@ abstract class CopyPropagation { final def cleanReferencesTo(s: copyLattice.State, target: Location) { def cleanRecord(r: Record): Record = { r.bindings retain { (loc, value) => - value match { + (value match { case Deref(loc1) if (loc1 == target) => false case Boxed(loc1) if (loc1 == target) => false case _ => true - } + }) && (target match { + case Field(AllRecords, sym1) => + println(target + " sym1: " + sym1.idString + " loc: " + loc.idString) + !(loc == sym1) + case _ => true + }) } r } @@ -479,8 +484,8 @@ abstract class CopyPropagation { (value match { case Deref(loc1) if (loc1 == target) => false case Boxed(loc1) if (loc1 == target) => false - case Record(_, _) => - cleanRecord(value.asInstanceOf[Record]); + case rec @ Record(_, _) => + cleanRecord(rec); true case _ => true }) && -- cgit v1.2.3