|
Message
From: cvs at opencores.org<cvs@o...>
Date: Tue Feb 26 20:38:29 CET 2008
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/08/02 26:20:38 Modified: jop/java/tools/src/joptimizer/optimizer/inline InlineHelper.java InlineChecker.java Log: bugfix for missing appconfig bugfix for invokespecial of non-private methods Revision Changes Path 1.5 jop/java/tools/src/joptimizer/optimizer/inline/InlineHelper.java http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/joptimizer/optimizer/inline/InlineHelper.java.diff?r1=1.4&r2=1.5 (In the diff below, changes in quantity of whitespace are not shown.) Index: InlineHelper.java =================================================================== RCS file: /cvsroot/stefant/jop/java/tools/src/joptimizer/optimizer/inline/InlineHelper.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- InlineHelper.java 25 Feb 2008 23:30:41 -0000 1.4 +++ InlineHelper.java 26 Feb 2008 19:38:28 -0000 1.5 @@ -23,8 +23,10 @@ import com.jopdesign.libgraph.cfg.GraphException; import com.jopdesign.libgraph.cfg.block.BasicBlock; import com.jopdesign.libgraph.cfg.block.CodeBlock; +import com.jopdesign.libgraph.cfg.statements.Statement; import com.jopdesign.libgraph.cfg.statements.StmtHandle; import com.jopdesign.libgraph.cfg.statements.common.InvokeStmt; +import com.jopdesign.libgraph.struct.ClassInfo; import com.jopdesign.libgraph.struct.MethodInfo; import com.jopdesign.libgraph.struct.ModifierInfo; import joptimizer.framework.actions.ActionException; @@ -218,18 +220,70 @@ graph.getFeatures().removeFeature(Features.FEATURE_STACK_INFO); } - public void changeToPublic(Collection changePublic) { + public boolean changeToPublic(Collection changePublic) { for (Iterator it = changePublic.iterator(); it.hasNext();) { ModifierInfo mod = (ModifierInfo) it.next(); // set private methods to final, just to make sure (fields won't be overloaded the same way a method is). if ( mod instanceof MethodInfo && mod.isPrivate() && !((MethodInfo)mod).getName().equals("<init>") ) { + + try { + setVirtual((MethodInfo)mod); + } catch (GraphException e) { + return false; + } + mod.setFinal(true); } mod.setAccessType(ModifierInfo.ACC_PUBLIC); } + return true; } + + private void setVirtual(MethodInfo method) throws GraphException { + + ClassInfo classInfo = method.getClassInfo(); + Collection methods = classInfo.getMethodInfos(); + + for (Iterator it = methods.iterator(); it.hasNext();) { + MethodInfo methodInfo = (MethodInfo) it.next(); + if ( methodInfo.isAbstract() ) { + continue; + } + ControlFlowGraph graph = methodInfo.getMethodCode().getGraph(); + boolean modified = false; + + for (Iterator it2 = graph.getBlocks().iterator(); it2.hasNext();) { + BasicBlock block = (BasicBlock) it2.next(); + CodeBlock code = block.getCodeBlock(); + + for (int i = 0; i < code.size(); i++) { + Statement stmt = code.getStatement(i); + if ( stmt instanceof InvokeStmt ) { + InvokeStmt invoke = (InvokeStmt) stmt; + + MethodInfo invoked = invoke.getMethodInfo(); + if ( invoke.getInvokeType() != InvokeStmt.TYPE_SPECIAL || + invoked == null || !method.isSameMethod(invoked) ) + { + continue; + } + + invoke.setInvokeType(InvokeStmt.TYPE_VIRTUAL); + modified = true; + } + } + } + + if ( modified ) { + graph.setModified(true); + methodInfo.getMethodCode().compileGraph(); + }
+
+ }
+ }
+
}
1.3 jop/java/tools/src/joptimizer/optimizer/inline/InlineChecker.java
http://www.opencores.org/cvsweb.shtml/jop/java/tools/src/joptimizer/optimizer/inline/InlineChecker.java.diff?r1=1.2&r2=1.3
(In the diff below, changes in quantity of whitespace are not shown.)
Index: InlineChecker.java
===================================================================
RCS file: /cvsroot/stefant/jop/java/tools/src/joptimizer/optimizer/inline/InlineChecker.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- InlineChecker.java 15 Feb 2008 00:40:51 -0000 1.2
+++ InlineChecker.java 26 Feb 2008 19:38:28 -0000 1.3
@@ -200,7 +200,7 @@
// check if graph can be created without exceptions
try {
MethodCode code = invoked.getMethodCode();
- ControlFlowGraph srcGraph = code.createGraph();
+ ControlFlowGraph srcGraph = code.getGraph();
if ( !checkCodesize(code.getCodeSize(), srcGraph, localsOffset) ) {
return null;
|
 |