From 4bf084d477c7a5c56aacd93afed17b21fa4493a3 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 9 Apr 1999 08:03:15 +0000 Subject: [PATCH] handle jsr differently call instr.removeInstruction git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@531 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/decompiler/DeadCodeAnalysis.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jode/jode/decompiler/DeadCodeAnalysis.java b/jode/jode/decompiler/DeadCodeAnalysis.java index 1f4f46b..f2b05ca 100644 --- a/jode/jode/decompiler/DeadCodeAnalysis.java +++ b/jode/jode/decompiler/DeadCodeAnalysis.java @@ -47,6 +47,10 @@ public class DeadCodeAnalysis { if (!instr.alwaysJumps && instr.nextByAddr != null) if (instr.nextByAddr.tmpInfo == null) instr.nextByAddr.tmpInfo = reachChanged; + /*XXX code after jsr reachable iff ret is reachable...*/ + if (instr.opcode == Opcodes.opc_jsr) + if (instr.nextByAddr.tmpInfo == null) + instr.nextByAddr.tmpInfo = reachChanged; } } } while (changed); @@ -78,13 +82,14 @@ public class DeadCodeAnalysis { } } while (changed); /* Now remove the dead code */ + Instruction nextInstr; for (Instruction instr = code.getFirstInstr(); - instr != null; instr = instr.nextByAddr) { + instr != null; instr = nextInstr) { + nextInstr = instr.nextByAddr; if (instr.tmpInfo == null) { + instr.removeInstruction(); + /* adjust length, since someone may rely on this */ /* first block is always reachable, so prevByAddr != null */ - instr.prevByAddr.nextByAddr = instr.nextByAddr; - instr.nextByAddr.prevByAddr = instr.prevByAddr; - /* adjust length, since someon may rely on this */ instr.prevByAddr.length += instr.length; } }