diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/backend/opt/DeadCodeElimination.scala | 14 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/classfile/ICodeReader.scala | 1 |
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 |