Commit 052a8db6 authored by Skylot's avatar Skylot

core: resolve minor issues

parent 88ccba16
...@@ -566,7 +566,7 @@ public class InsnGen { ...@@ -566,7 +566,7 @@ public class InsnGen {
private void makeConstructor(ConstructorInsn insn, CodeWriter code) private void makeConstructor(ConstructorInsn insn, CodeWriter code)
throws CodegenException { throws CodegenException {
ClassNode cls = mth.dex().resolveClass(insn.getClassType()); ClassNode cls = mth.dex().resolveClass(insn.getClassType());
if (cls != null && cls.isAnonymous()) { if (cls != null && cls.isAnonymous() && !fallback) {
// anonymous class construction // anonymous class construction
ClassInfo parent; ClassInfo parent;
if (cls.getInterfaces().size() == 1) { if (cls.getInterfaces().size() == 1) {
......
...@@ -20,7 +20,6 @@ public class LiveVarAnalysis { ...@@ -20,7 +20,6 @@ public class LiveVarAnalysis {
public LiveVarAnalysis(MethodNode mth) { public LiveVarAnalysis(MethodNode mth) {
this.mth = mth; this.mth = mth;
runAnalysis();
} }
public void runAnalysis() { public void runAnalysis() {
......
...@@ -32,17 +32,18 @@ public class SSATransform extends AbstractVisitor { ...@@ -32,17 +32,18 @@ public class SSATransform extends AbstractVisitor {
process(mth); process(mth);
} }
private void process(MethodNode mth) { private static void process(MethodNode mth) {
LiveVarAnalysis la = new LiveVarAnalysis(mth); LiveVarAnalysis la = new LiveVarAnalysis(mth);
la.runAnalysis(); la.runAnalysis();
for (int i = 0; i < mth.getRegsCount(); i++) { int regsCount = mth.getRegsCount();
for (int i = 0; i < regsCount; i++) {
placePhi(mth, i, la); placePhi(mth, i, la);
} }
renameVariables(mth); renameVariables(mth);
removeUselessPhi(mth); removeUselessPhi(mth);
} }
private void placePhi(MethodNode mth, int regNum, LiveVarAnalysis la) { private static void placePhi(MethodNode mth, int regNum, LiveVarAnalysis la) {
List<BlockNode> blocks = mth.getBasicBlocks(); List<BlockNode> blocks = mth.getBasicBlocks();
int blocksCount = blocks.size(); int blocksCount = blocks.size();
BitSet hasPhi = new BitSet(blocksCount); BitSet hasPhi = new BitSet(blocksCount);
...@@ -71,7 +72,7 @@ public class SSATransform extends AbstractVisitor { ...@@ -71,7 +72,7 @@ public class SSATransform extends AbstractVisitor {
} }
} }
private void addPhi(BlockNode block, int regNum) { private static void addPhi(BlockNode block, int regNum) {
PhiListAttr phiList = block.get(AType.PHI_LIST); PhiListAttr phiList = block.get(AType.PHI_LIST);
if (phiList == null) { if (phiList == null) {
phiList = new PhiListAttr(); phiList = new PhiListAttr();
...@@ -82,7 +83,7 @@ public class SSATransform extends AbstractVisitor { ...@@ -82,7 +83,7 @@ public class SSATransform extends AbstractVisitor {
block.getInstructions().add(0, phiInsn); block.getInstructions().add(0, phiInsn);
} }
private void renameVariables(MethodNode mth) { private static void renameVariables(MethodNode mth) {
int regsCount = mth.getRegsCount(); int regsCount = mth.getRegsCount();
SSAVar[] vars = new SSAVar[regsCount]; SSAVar[] vars = new SSAVar[regsCount];
int[] versions = new int[regsCount]; int[] versions = new int[regsCount];
...@@ -94,7 +95,7 @@ public class SSATransform extends AbstractVisitor { ...@@ -94,7 +95,7 @@ public class SSATransform extends AbstractVisitor {
renameVar(mth, vars, versions, mth.getEnterBlock()); renameVar(mth, vars, versions, mth.getEnterBlock());
} }
private void renameVar(MethodNode mth, SSAVar[] vars, int[] vers, BlockNode block) { private static void renameVar(MethodNode mth, SSAVar[] vars, int[] vers, BlockNode block) {
SSAVar[] inputVars = Arrays.copyOf(vars, vars.length); SSAVar[] inputVars = Arrays.copyOf(vars, vars.length);
for (InsnNode insn : block.getInstructions()) { for (InsnNode insn : block.getInstructions()) {
if (insn.getType() != InsnType.PHI) { if (insn.getType() != InsnType.PHI) {
...@@ -142,7 +143,7 @@ public class SSATransform extends AbstractVisitor { ...@@ -142,7 +143,7 @@ public class SSATransform extends AbstractVisitor {
System.arraycopy(inputVars, 0, vars, 0, vars.length); System.arraycopy(inputVars, 0, vars, 0, vars.length);
} }
private void removeUselessPhi(MethodNode mth) { private static void removeUselessPhi(MethodNode mth) {
List<PhiInsn> insnToRemove = new ArrayList<PhiInsn>(); List<PhiInsn> insnToRemove = new ArrayList<PhiInsn>();
for (SSAVar var : mth.getSVars()) { for (SSAVar var : mth.getSVars()) {
// phi result not used // phi result not used
...@@ -165,7 +166,7 @@ public class SSATransform extends AbstractVisitor { ...@@ -165,7 +166,7 @@ public class SSATransform extends AbstractVisitor {
removePhiList(mth, insnToRemove); removePhiList(mth, insnToRemove);
} }
private void removePhiWithSameArgs(PhiInsn phi, List<PhiInsn> insnToRemove) { private static void removePhiWithSameArgs(PhiInsn phi, List<PhiInsn> insnToRemove) {
if (phi.getArgsCount() <= 1) { if (phi.getArgsCount() <= 1) {
insnToRemove.add(phi); insnToRemove.add(phi);
return; return;
...@@ -189,7 +190,7 @@ public class SSATransform extends AbstractVisitor { ...@@ -189,7 +190,7 @@ public class SSATransform extends AbstractVisitor {
} }
} }
private void removePhiList(MethodNode mth, List<PhiInsn> insnToRemove) { private static void removePhiList(MethodNode mth, List<PhiInsn> insnToRemove) {
if (insnToRemove.isEmpty()) { if (insnToRemove.isEmpty()) {
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment