diff --git a/jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java b/jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java index bad9e5ce83f..801c01753c8 100644 --- a/jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java +++ b/jadx-core/src/main/java/jadx/core/dex/nodes/MethodNode.java @@ -1,8 +1,10 @@ package jadx.core.dex.nodes; import java.util.ArrayList; +import java.util.BitSet; import java.util.Collections; import java.util.List; +import java.util.Map; import java.util.Objects; import org.jetbrains.annotations.NotNull; @@ -73,6 +75,7 @@ public class MethodNode extends NotificationAttrNode implements IMethodDetails, private int blocksMaxCId; private BlockNode enterBlock; private BlockNode exitBlock; + private Map postDominanceMap; private List sVars; private List exceptionHandlers; private List loops; @@ -119,6 +122,7 @@ public void unload() { blocks = null; enterBlock = null; exitBlock = null; + postDominanceMap = null; region = null; exceptionHandlers = Collections.emptyList(); loops = Collections.emptyList(); @@ -399,6 +403,14 @@ public boolean isPreExitBlocks(BlockNode block) { return exitBlock.getPredecessors().contains(block); } + public Map getPostDominanceMap() { + return postDominanceMap; + } + + public void setPostDominanceMap(Map postDominanceMap) { + this.postDominanceMap = postDominanceMap; + } + public void registerLoop(LoopInfo loop) { if (loops.isEmpty()) { loops = new ArrayList<>(5); diff --git a/jadx-core/src/main/java/jadx/core/utils/BlockUtils.java b/jadx-core/src/main/java/jadx/core/utils/BlockUtils.java index e0e48b7f71e..88b5462f29c 100644 --- a/jadx-core/src/main/java/jadx/core/utils/BlockUtils.java +++ b/jadx-core/src/main/java/jadx/core/utils/BlockUtils.java @@ -1148,7 +1148,12 @@ public static boolean replaceInsn(MethodNode mth, InsnNode oldInsn, InsnNode new } public static Map calcPostDominance(MethodNode mth) { - return calcPartialPostDominance(mth, mth.getBasicBlocks(), mth.getPreExitBlocks().get(0)); + Map postDominanceMap = mth.getPostDominanceMap(); + if (postDominanceMap == null) { + postDominanceMap = calcPartialPostDominance(mth, mth.getBasicBlocks(), mth.getPreExitBlocks().get(0)); + mth.setPostDominanceMap(postDominanceMap); + } + return postDominanceMap; } public static Map calcPartialPostDominance(MethodNode mth, Collection blockNodes, BlockNode exitBlock) {