diff options
author | James Iry <jamesiry@gmail.com> | 2013-02-22 15:33:18 -0800 |
---|---|---|
committer | James Iry <jamesiry@gmail.com> | 2013-02-25 16:06:16 -0800 |
commit | e9f6511094c1e616719221970a9f3eec39c72905 (patch) | |
tree | 39637a515bb941559667f6a32cc5714e8d6d78ac /test/files/jvm/t7006/Test.scala | |
parent | 0d2e19cc4c639c27a93c3ed76d892b16d40dcc9b (diff) | |
download | scala-e9f6511094c1e616719221970a9f3eec39c72905.tar.gz scala-e9f6511094c1e616719221970a9f3eec39c72905.tar.bz2 scala-e9f6511094c1e616719221970a9f3eec39c72905.zip |
SI-7006 Eliminate unreachable blocks
GenASM was doing a bunch of stuff to eliminate unreachable exception
handlers, but it was still leaving behind other unreachable blocks, for
instance a finally block associated with an exception handler that got
removed would still be left lying around. ASM would in turn turn those
into a big pile of NOPs, which just take up space uselessly.
This commit replaces all the logic for eliding exception handlers with
a single unreachable block remover that catches unused exception
handlers and a whole lot more.
Diffstat (limited to 'test/files/jvm/t7006/Test.scala')
-rw-r--r-- | test/files/jvm/t7006/Test.scala | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/files/jvm/t7006/Test.scala b/test/files/jvm/t7006/Test.scala new file mode 100644 index 0000000000..5cc38e42a2 --- /dev/null +++ b/test/files/jvm/t7006/Test.scala @@ -0,0 +1,18 @@ +import scala.tools.partest.BytecodeTest +import scala.tools.asm +import asm.tree.InsnList +import scala.collection.JavaConverters._ + +object Test extends BytecodeTest { + def show: Unit = { + val classNode = loadClassNode("Foo_1") + val methodNode = getMethod(classNode, "foo") + assert(countNops(methodNode.instructions) == 0) + } + + def countNops(insnList: InsnList): Int = { + def isNop(node: asm.tree.AbstractInsnNode): Boolean = + (node.getOpcode == asm.Opcodes.NOP) + insnList.iterator.asScala.count(isNop) + } +} |