summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2007-12-03 09:50:32 +0000
committerIulian Dragos <jaguarul@gmail.com>2007-12-03 09:50:32 +0000
commitc4a1857e8b439c2317412a80f313085db66f5617 (patch)
treeedcd10ea5bccce32207553b97309cc057e9cf079 /src/compiler
parentdb0cba83507454961d2684ec7ba3ea6c70a9af15 (diff)
downloadscala-c4a1857e8b439c2317412a80f313085db66f5617.tar.gz
scala-c4a1857e8b439c2317412a80f313085db66f5617.tar.bz2
scala-c4a1857e8b439c2317412a80f313085db66f5617.zip
Fixed two minor bugs in dead code elmination an...
Fixed two minor bugs in dead code elmination and icode reader.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala14
-rw-r--r--src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala1
2 files changed, 13 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
index 9c3bd176d0..701a81968a 100644
--- a/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
+++ b/src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala
@@ -68,9 +68,12 @@ abstract class DeadCodeElimination extends SubComponent {
/** the current method. */
var method: IMethod = _
+ /** Map instructions who have a drop on some control path, to that DROP instruction. */
+ val dropOf: mutable.Map[(BasicBlock, Int), (BasicBlock, Int)] = new mutable.HashMap()
+
def dieCodeDie(m: IMethod): Unit = if (m.code ne null) {
log("dead code elimination on " + m);
-// (new DepthFirstLinerizer).linearize(m)
+ dropOf.clear
m.code.blocks.clear
accessedLocals = m.params.reverse
m.code.blocks ++= linearizer.linearize(m)
@@ -110,7 +113,10 @@ abstract class DeadCodeElimination extends SubComponent {
bb1(idx1) match {
case CALL_METHOD(m1, _) if isSideEffecting(m1) => true
case LOAD_EXCEPTION() | DUP(_) | LOAD_MODULE(_) => true
- case _ => false
+ case _ =>
+ dropOf((bb1, idx1)) = (bb, idx)
+// println("DROP is innessential: " + i + " because of: " + bb1(idx1) + " at " + bb1 + ":" + idx1)
+ false
}
}
if (necessary) worklist += ((bb, idx))
@@ -135,6 +141,10 @@ abstract class DeadCodeElimination extends SubComponent {
val instr = bb(idx)
if (!useful(bb)(idx)) {
useful(bb) += idx
+ dropOf.get(bb, idx) match {
+ case Some((bb1, idx1)) => useful(bb1) += idx1
+ case None => ()
+ }
instr match {
case LOAD_LOCAL(l1) =>
for ((l2, bb1, idx1) <- defs((bb, idx)) if l1 == l2; if !useful(bb1)(idx1)) {
diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
index 8cb95aae74..e3d627f2aa 100644
--- a/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
+++ b/src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala
@@ -162,6 +162,7 @@ abstract class ICodeReader extends ClassfileParser {
if (sym != NoSymbol) {
log("Parsing method " + sym.fullNameString + ": " + sym.tpe);
this.method = new IMethod(sym);
+ this.method.returnType = toTypeKind(sym.tpe.resultType)
getCode(jflags).addMethod(this.method)
if ((jflags & JAVA_ACC_NATIVE) != 0)
this.method.native = true