From 3d84cf9b2f360ecd819109f3147113085568ede4 Mon Sep 17 00:00:00 2001 From: jochen Date: Fri, 14 May 1999 11:33:16 +0000 Subject: [PATCH] fixed jsr handling again more debugging messages git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@810 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/obfuscator/LocalOptimizer.java | 84 +++++++++++++++++------- 1 file changed, 61 insertions(+), 23 deletions(-) diff --git a/jode/jode/obfuscator/LocalOptimizer.java b/jode/jode/obfuscator/LocalOptimizer.java index 406a60d..20a84ae 100644 --- a/jode/jode/obfuscator/LocalOptimizer.java +++ b/jode/jode/obfuscator/LocalOptimizer.java @@ -22,7 +22,7 @@ import java.util.*; import jode.bytecode.*; import jode.type.Type; import jode.AssertError; -import jode.Obfuscator; +import jode.GlobalOptions; /** * This class takes some bytecode and tries to minimize the number @@ -120,6 +120,17 @@ public class LocalOptimizer implements Opcodes { l.usingInstrs.addElement(instr); } } + + public int getFirstAddr() { + int addr = Integer.MAX_VALUE; + Enumeration enum = usingInstrs.elements(); + while (enum.hasMoreElements()) { + InstrInfo instr = (InstrInfo) enum.nextElement(); + if (instr.instr.addr < addr) + addr = instr.instr.addr; + } + return addr; + } } @@ -419,7 +430,7 @@ public class LocalOptimizer implements Opcodes { throw new AssertError("Non standard jsr"); } InstrInfo retInfo - = info.nextReads[info.instr.localSlot]; + = info.nextInfo.nextReads[info.instr.localSlot]; if (retInfo != null) { if (retInfo.instr.opcode != opc_ret) @@ -444,8 +455,8 @@ public class LocalOptimizer implements Opcodes { promoteReads(nextInfo, predInstr, retInfo.usedBySub, true); } - } else - promoteReads(info, instr.preds[i]); + } + promoteReads(info, instr.preds[i]); } } @@ -569,11 +580,31 @@ public class LocalOptimizer implements Opcodes { && info.instr.opcode <= BytecodeInfo.opc_astore) { /* This is a store. It conflicts with every local, whose * value will be read without write. + * + * If this is inside a ret, it also conflicts with + * locals, that are not used inside, and where any jsr + * would conflict with. */ for (int i=0; i < maxlocals; i++) { if (i != info.instr.localSlot && info.nextReads[i] != null) info.local.conflictsWith(info.nextReads[i].local); + if (info.nextInfo.nextReads[i] != null + && info.nextInfo.nextReads[i].jsrTargetInfo != null) { + Instruction[] jsrs = info.nextInfo.nextReads[i] + .jsrTargetInfo.instr.preds; + for (int j=0; j< jsrs.length; j++) { + InstrInfo jsrInfo + = (InstrInfo) instrInfos.get(jsrs[j]); + for (int k=0; k < maxlocals; k++) { + if (!info.nextInfo.nextReads[i].usedBySub + .get(k) + && jsrInfo.nextReads[k] != null) + info.local.conflictsWith + (jsrInfo.nextReads[k].local); + } + } + } } } } @@ -783,15 +814,23 @@ public class LocalOptimizer implements Opcodes { public void dumpLocals() { Vector locals = new Vector(); for (InstrInfo info = firstInfo; info != null; info = info.nextInfo) { -// System.err.print("addr: "+info.instr.addr+ " locals: "); -// for (int i=0; i