git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@1327 379699f6-c40d-0410-875b-85095c16579emaster
parent
9f97289a90
commit
c30ac484c5
@ -0,0 +1,57 @@ |
||||
2001-07-15 Jochen Hoenicke <jochen@gnu.org> |
||||
Applied patch from Java 1.1 tree: |
||||
|
||||
* jode/expr/Expression.java.in (updateParentTypes): Call setType, |
||||
instead of merging the types. Other childs want to know about the |
||||
type change as well. |
||||
* jode/decompiler/LocalInfo.java (combineWith): Reorganized a bit, |
||||
but no changes. |
||||
* jode/expr/InvokeOperator.java.in (dumpExpression): Always print |
||||
the ThisOperator if a field is from a parent class of an outer |
||||
class is used. And always qualify the this operator if not |
||||
innermost. |
||||
|
||||
2001-07-14 Jochen Hoenicke <jochen@gnu.org> |
||||
Applied patches from the Java 1.1 tree: |
||||
|
||||
* jode/decompiler/TabbedPrintWriter.java: Better gnu style handling: |
||||
(openBraceClass) (closeBraceClass) |
||||
(openBraceNoIndent) (closeBraceNoIndent): new functions. |
||||
(closeBraceNoSpace): Removed. |
||||
* jode/decompiler/TabbedPrintWriter.java (GNU_SPACING): new constant. |
||||
(printOptionalSpace): Print space for GNU_SPACING. |
||||
* jode/decompiler/Options.java (setOptions): changed gnu style |
||||
to include GNU_SPACING. |
||||
* jode/decompiler/ClassAnalyzer.java.in (dumpSource): Use |
||||
open/closeBraceClass. |
||||
* jode/decompiler/MethodAnalyzer.java.in (dumpSource): Use |
||||
open/closeBraceNoIndent. Call printOptionalSpace. |
||||
* jode/decompiler/InvokeOperator.java.in (dumpExpression): |
||||
Call printOptionalSpace, use open/closeBraceClass for inner |
||||
classes. |
||||
* jode/decompiler/UnaryOperator.java (dumpExpression): Call |
||||
printOptionalSpace. |
||||
|
||||
Added pascal style from Rolf Howarth <rolf@squarebox.co.uk> |
||||
* jode/decompiler/Decompiler.java (setOption): detect pascal option. |
||||
* jode/decompiler/TabbedPrintWriter.java (BRACE_FLUSH_LEFT): |
||||
new constant. |
||||
(openBrace, openBraceContinue, closeBrace, closeBraceNoSpace, |
||||
closeBraceContinue): handle flush left. |
||||
|
||||
* jode/type/NullType.java (intersection): Removed, since the |
||||
version in ReferenceType is more correct. Before |
||||
tNull.isOfType(tRange(X,tNull)) returned false, which lead to |
||||
incorrect behaviour in InvokeOperator.needsCast. |
||||
* jode/decompiler/FieldAnalyzer.java.in (dumpSource): Removed the |
||||
"= null" hack for final fields; it was not correct, since the |
||||
field could be initialized in a constructor. |
||||
* jode/decompiler/TabbedPrintWriter.java (BreakPoint.endOp): |
||||
Simplified the code, copy options always from child. |
||||
* jode/expr/InvokeOperator.java (isGetClass): Allow the method to |
||||
be declared inside an outer class: We simply check if we can get |
||||
the method analyzer. |
||||
(simplify): handle unifyParam. |
||||
* jode/expr/PopOperator.java (getBreakPenalty): return penalty of |
||||
inner expression. (dumpExpression): Call dumpExpression of |
||||
subexpression immediately without priority. |
@ -0,0 +1,5 @@ |
||||
Joe Bronkema <joseph.d.bronkema at lmco.com> |
||||
Rolf Howarth <rolf at squarebox.co.uk> for pascal indentaton style. |
||||
Erik Modén <Erik.Moden at emw.ericsson.se> |
||||
Martin Schmitz <m.schmitz at e-sign.com> for finding many bugs in the obfuscator. |
||||
zzzeek <classic at io.com> |
@ -1,118 +0,0 @@ |
||||
/* DeadCodeAnalysis Copyright (C) 1999 Jochen Hoenicke. |
||||
* |
||||
* This program is free software; you can redistribute it and/or modify |
||||
* it under the terms of the GNU General Public License as published by |
||||
* the Free Software Foundation; either version 2, or (at your option) |
||||
* any later version. |
||||
* |
||||
* This program is distributed in the hope that it will be useful, |
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||||
* GNU General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU General Public License |
||||
* along with this program; see the file COPYING. If not, write to |
||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
||||
* |
||||
* $Id$ |
||||
*/ |
||||
|
||||
package jode.decompiler; |
||||
import jode.bytecode.BytecodeInfo; |
||||
import jode.bytecode.Instruction; |
||||
import jode.bytecode.Handler; |
||||
|
||||
///#def COLLECTIONS java.util
|
||||
import java.util.Iterator; |
||||
///#enddef
|
||||
|
||||
public class DeadCodeAnalysis { |
||||
|
||||
private final static String REACHABLE = "R"; |
||||
private final static String REACHCHANGED = "C"; |
||||
|
||||
private static void propagateReachability(BytecodeInfo code) { |
||||
boolean changed; |
||||
do { |
||||
changed = false; |
||||
for (Iterator iter = code.getInstructions().iterator(); |
||||
iter.hasNext(); ) { |
||||
Instruction instr = (Instruction) iter.next(); |
||||
if (instr.getTmpInfo() == REACHCHANGED) { |
||||
changed = true; |
||||
instr.setTmpInfo(REACHABLE); |
||||
Instruction[] succs = instr.getSuccs(); |
||||
if (succs != null) |
||||
for (int i=0; i< succs.length; i++) |
||||
if (succs[i].getTmpInfo() == null) |
||||
succs[i].setTmpInfo(REACHCHANGED); |
||||
if (!instr.doesAlwaysJump() |
||||
&& instr.getNextByAddr() != null) |
||||
if (instr.getNextByAddr().getTmpInfo() == null) |
||||
instr.getNextByAddr().setTmpInfo(REACHCHANGED); |
||||
/*XXX code after jsr reachable iff ret is reachable...*/ |
||||
if (instr.getOpcode() == Opcodes.opc_jsr) |
||||
if (instr.getNextByAddr().getTmpInfo() == null) |
||||
instr.getNextByAddr().setTmpInfo(REACHCHANGED); |
||||
} |
||||
} |
||||
} while (changed); |
||||
} |
||||
|
||||
public static void removeDeadCode(BytecodeInfo code) { |
||||
((Instruction) code.getInstructions().get(0)).setTmpInfo(REACHCHANGED); |
||||
propagateReachability(code); |
||||
Handler[] handlers = code.getExceptionHandlers(); |
||||
boolean changed; |
||||
do { |
||||
changed = false; |
||||
for (int i=0; i < handlers.length; i++) { |
||||
if (handlers[i].catcher.getTmpInfo() == null) { |
||||
/* check if the try block is somewhere reachable |
||||
* and mark the catcher as reachable then. |
||||
*/ |
||||
for (Instruction instr = handlers[i].start; |
||||
instr != null; instr = instr.getNextByAddr()) { |
||||
if (instr.getTmpInfo() != null) { |
||||
handlers[i].catcher.setTmpInfo(REACHCHANGED); |
||||
propagateReachability(code); |
||||
changed = true; |
||||
break; |
||||
} |
||||
if (instr == handlers[i].end) |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
} while (changed); |
||||
|
||||
for (int i=0; i< handlers.length; i++) { |
||||
/* A handler is not reachable iff the catcher is not reachable */ |
||||
if (handlers[i].catcher.getTmpInfo() == null) { |
||||
/* This is very seldom, so we can make it slow */ |
||||
Handler[] newHandlers = new Handler[handlers.length - 1]; |
||||
System.arraycopy(handlers, 0, newHandlers, 0, i); |
||||
System.arraycopy(handlers, i+1, newHandlers, i, |
||||
handlers.length - (i+1)); |
||||
handlers = newHandlers; |
||||
code.setExceptionHandlers(newHandlers); |
||||
i--; |
||||
} else { |
||||
/* This works! */ |
||||
while (handlers[i].start.getTmpInfo() == null) |
||||
handlers[i].start = handlers[i].start.getNextByAddr(); |
||||
while (handlers[i].end.getTmpInfo() == null) |
||||
handlers[i].end = handlers[i].end.getPrevByAddr(); |
||||
} |
||||
} |
||||
|
||||
/* Now remove the dead code and clean up tmpInfo */ |
||||
for (Iterator i = code.getInstructions().iterator(); i.hasNext(); ) { |
||||
Instruction instr = (Instruction) i.next(); |
||||
if (instr.getTmpInfo() != null) |
||||
instr.setTmpInfo(null); |
||||
else |
||||
i.remove(); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue