summaryrefslogtreecommitdiff
path: root/dx/tests/031-bb-dead-code
diff options
context:
space:
mode:
Diffstat (limited to 'dx/tests/031-bb-dead-code')
-rw-r--r--dx/tests/031-bb-dead-code/blort.j182
-rw-r--r--dx/tests/031-bb-dead-code/expected.txt190
-rw-r--r--dx/tests/031-bb-dead-code/info.txt3
-rw-r--r--dx/tests/031-bb-dead-code/run18
4 files changed, 393 insertions, 0 deletions
diff --git a/dx/tests/031-bb-dead-code/blort.j b/dx/tests/031-bb-dead-code/blort.j
new file mode 100644
index 0000000..b6854f2
--- /dev/null
+++ b/dx/tests/031-bb-dead-code/blort.j
@@ -0,0 +1,182 @@
+; Copyright (C) 2007 The Android Open Source Project
+;
+; Licensed under the Apache License, Version 2.0 (the "License");
+; you may not use this file except in compliance with the License.
+; You may obtain a copy of the License at
+;
+; http://www.apache.org/licenses/LICENSE-2.0
+;
+; Unless required by applicable law or agreed to in writing, software
+; distributed under the License is distributed on an "AS IS" BASIS,
+; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+; See the License for the specific language governing permissions and
+; limitations under the License.
+
+.class blort
+.super java/lang/Object
+
+.method public <init>()V
+ .limit locals 1
+
+ aload_0
+ invokespecial java/lang/Object/<init>()V
+ return
+.end method
+
+; dead code after the last reachable instruction in a method
+.method public test_deadend1()V
+ return
+ aload_0
+.end method
+
+; dead code after the last reachable instruction in a method
+.method public test_deadend2()V
+ ireturn
+ aload_0
+ aload_0
+.end method
+
+; dead code after the last reachable instruction in a method
+.method public test_deadend3()V
+ aconst_null
+ athrow
+ sipush 0x1234
+.end method
+
+; make sure an exception handler for a dead range doesn't get enlivened
+.method public test_dead_exception_handler()V
+ return
+ nop
+blort:
+ nop
+ nop
+ return
+handler:
+ nop
+ return
+ .catch all from blort to handler using handler
+.end method
+
+; dead code after goto instruction
+.method public test_dead_goto()V
+ goto blort
+ nop
+blort:
+ return
+.end method
+
+; dead code after ret instruction
+.method public test_dead_ret()V
+ ifeq blort
+ ret 0
+ iconst_m1
+blort:
+ return
+.end method
+
+; dead code after tableswitch instruction
+.method public test_dead_tableswitch()V
+ tableswitch 0x10
+ blort
+ default: blort
+ nop
+ nop
+ nop
+ aload_0
+ aload_1
+ aload_2
+ aload_3
+blort:
+ return
+.end method
+
+; dead code after lookupswitch instruction
+.method public test_dead_lookupswitch()V
+ lookupswitch
+ 0x10: blort
+ 0x20: blort
+ default: blort
+ ldc "WHYA REYO UREA DING THIS ?"
+blort:
+ return
+.end method
+
+; dead code after ireturn instruction
+.method public test_dead_ireturn()V
+ ifeq blort
+ ireturn
+ iconst_1
+blort:
+ return
+.end method
+
+; dead code after lreturn instruction
+.method public test_dead_lreturn()V
+ ifeq blort
+ lreturn
+ iconst_1
+blort:
+ return
+.end method
+
+; dead code after freturn instruction
+.method public test_dead_freturn()V
+ ifeq blort
+ freturn
+ iconst_1
+blort:
+ return
+.end method
+
+; dead code after dreturn instruction
+.method public test_dead_dreturn()V
+ ifeq blort
+ dreturn
+ iconst_1
+blort:
+ return
+.end method
+
+; dead code after areturn instruction
+.method public test_dead_areturn()V
+ ifeq blort
+ areturn
+ iconst_1
+blort:
+ return
+.end method
+
+; dead code after return instruction
+.method public test_dead_return()V
+ ifeq blort
+ return
+ iconst_1
+blort:
+ return
+.end method
+
+; dead code after athrow instruction
+.method public test_dead_athrow()V
+ ifeq blort
+ athrow
+ iconst_1
+blort:
+ return
+.end method
+
+; dead code after wide ret instruction
+.method public test_dead_wideret()V
+ ifeq blort
+ ret 0x0100
+ iconst_1
+blort:
+ return
+.end method
+
+; dead code after goto_w instruction
+.method public test_dead_goto_w()V
+ goto_w blort
+ iconst_1
+blort:
+ return
+.end method
diff --git a/dx/tests/031-bb-dead-code/expected.txt b/dx/tests/031-bb-dead-code/expected.txt
new file mode 100644
index 0000000..1cd4959
--- /dev/null
+++ b/dx/tests/031-bb-dead-code/expected.txt
@@ -0,0 +1,190 @@
+Generated: ./blort.class
+reading blort.class...
+method <init> ()V
+block 0000: 0000..0004
+ 0000: aload_0 // 00
+ 0001: invokespecial method{java.lang.Object.<init>:()V}
+ next 0004
+block 0004: 0004..0005
+ 0004: return
+ returns
+
+method test_deadend1 ()V
+block 0000: 0000..0001
+ 0000: return
+ returns
+dead code 0001..0002
+
+method test_deadend2 ()V
+block 0000: 0000..0001
+ 0000: ireturn
+ returns
+dead code 0001..0003
+
+method test_deadend3 ()V
+block 0000: 0000..0002
+ 0000: aconst_null
+ 0001: athrow
+ returns
+dead code 0002..0005
+
+method test_dead_exception_handler ()V
+block 0000: 0000..0001
+ 0000: return
+ returns
+dead code 0001..0007
+
+method test_dead_goto ()V
+block 0000: 0000..0003
+ 0000: goto 0004
+ next 0004
+dead code 0003..0004
+block 0004: 0004..0005
+ 0004: return
+ returns
+
+method test_dead_ret ()V
+block 0000: 0000..0003
+ 0000: ifeq 0006
+ next 0003
+ next 0006
+block 0003: 0003..0005
+ 0003: ret 00
+ returns
+dead code 0005..0006
+block 0006: 0006..0007
+ 0006: return
+ returns
+
+method test_dead_tableswitch ()V
+block 0000: 0000..0014
+ 0000: tableswitch
+ default: 001b
+ next 001b
+dead code 0014..001b
+block 001b: 001b..001c
+ 001b: return
+ returns
+
+method test_dead_lookupswitch ()V
+block 0000: 0000..001c
+ 0000: lookupswitch
+ default: 001e
+ next 001e
+dead code 001c..001e
+block 001e: 001e..001f
+ 001e: return
+ returns
+
+method test_dead_ireturn ()V
+block 0000: 0000..0003
+ 0000: ifeq 0005
+ next 0003
+ next 0005
+block 0003: 0003..0004
+ 0003: ireturn
+ returns
+dead code 0004..0005
+block 0005: 0005..0006
+ 0005: return
+ returns
+
+method test_dead_lreturn ()V
+block 0000: 0000..0003
+ 0000: ifeq 0005
+ next 0003
+ next 0005
+block 0003: 0003..0004
+ 0003: lreturn
+ returns
+dead code 0004..0005
+block 0005: 0005..0006
+ 0005: return
+ returns
+
+method test_dead_freturn ()V
+block 0000: 0000..0003
+ 0000: ifeq 0005
+ next 0003
+ next 0005
+block 0003: 0003..0004
+ 0003: freturn
+ returns
+dead code 0004..0005
+block 0005: 0005..0006
+ 0005: return
+ returns
+
+method test_dead_dreturn ()V
+block 0000: 0000..0003
+ 0000: ifeq 0005
+ next 0003
+ next 0005
+block 0003: 0003..0004
+ 0003: dreturn
+ returns
+dead code 0004..0005
+block 0005: 0005..0006
+ 0005: return
+ returns
+
+method test_dead_areturn ()V
+block 0000: 0000..0003
+ 0000: ifeq 0005
+ next 0003
+ next 0005
+block 0003: 0003..0004
+ 0003: areturn
+ returns
+dead code 0004..0005
+block 0005: 0005..0006
+ 0005: return
+ returns
+
+method test_dead_return ()V
+block 0000: 0000..0003
+ 0000: ifeq 0005
+ next 0003
+ next 0005
+block 0003: 0003..0004
+ 0003: return
+ returns
+dead code 0004..0005
+block 0005: 0005..0006
+ 0005: return
+ returns
+
+method test_dead_athrow ()V
+block 0000: 0000..0003
+ 0000: ifeq 0005
+ next 0003
+ next 0005
+block 0003: 0003..0004
+ 0003: athrow
+ returns
+dead code 0004..0005
+block 0005: 0005..0006
+ 0005: return
+ returns
+
+method test_dead_wideret ()V
+block 0000: 0000..0003
+ 0000: ifeq 0008
+ next 0003
+ next 0008
+block 0003: 0003..0007
+ 0003: wide ret 0100
+ returns
+dead code 0007..0008
+block 0008: 0008..0009
+ 0008: return
+ returns
+
+method test_dead_goto_w ()V
+block 0000: 0000..0005
+ 0000: goto_w 00000006
+ next 0006
+dead code 0005..0006
+block 0006: 0006..0007
+ 0006: return
+ returns
diff --git a/dx/tests/031-bb-dead-code/info.txt b/dx/tests/031-bb-dead-code/info.txt
new file mode 100644
index 0000000..d5aa398
--- /dev/null
+++ b/dx/tests/031-bb-dead-code/info.txt
@@ -0,0 +1,3 @@
+This test checks to see that the basic block recognizer properly omits
+dead code. There is at least one example of dead code after each instruction
+that *doesn't* flow to the next instruction.
diff --git a/dx/tests/031-bb-dead-code/run b/dx/tests/031-bb-dead-code/run
new file mode 100644
index 0000000..4f82e15
--- /dev/null
+++ b/dx/tests/031-bb-dead-code/run
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# Copyright (C) 2007 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+jasmin -d . blort.j
+dx --debug --dump --basic-blocks --width=200 blort.class