mirror of
https://github.com/skylot/jadx.git
synced 2024-11-26 22:20:50 +00:00
feat: add method to update all blocks related info in method (#2335)
Some checks failed
Build Artifacts / build (push) Has been cancelled
Build Artifacts / build-win-bundle (push) Has been cancelled
Build Test / tests (ubuntu-latest) (push) Has been cancelled
Build Test / tests (windows-latest) (push) Has been cancelled
CodeQL / Analyze (java) (push) Has been cancelled
Some checks failed
Build Artifacts / build (push) Has been cancelled
Build Artifacts / build-win-bundle (push) Has been cancelled
Build Test / tests (ubuntu-latest) (push) Has been cancelled
Build Test / tests (windows-latest) (push) Has been cancelled
CodeQL / Analyze (java) (push) Has been cancelled
This commit is contained in:
parent
4c74e8e300
commit
417bb7a7e9
@ -408,6 +408,10 @@ public class MethodNode extends NotificationAttrNode implements IMethodDetails,
|
||||
return exitBlock.getPredecessors().contains(block);
|
||||
}
|
||||
|
||||
public void resetLoops() {
|
||||
this.loops = new ArrayList<>();
|
||||
}
|
||||
|
||||
public void registerLoop(LoopInfo loop) {
|
||||
if (loops.isEmpty()) {
|
||||
loops = new ArrayList<>(5);
|
||||
|
@ -94,6 +94,33 @@ public class BlockProcessor extends AbstractVisitor {
|
||||
updateCleanSuccessors(mth);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculate all additional info attached to blocks:
|
||||
*
|
||||
* <pre>
|
||||
* - dominators
|
||||
* - dominance frontier
|
||||
* - post dominators (only if {@link AFlag#COMPUTE_POST_DOM} added to method)
|
||||
* - loops and nested loop info
|
||||
* </pre>
|
||||
*
|
||||
* This method should be called after changing a block tree in custom passes added before
|
||||
* {@link BlockFinisher}.
|
||||
*/
|
||||
public static void updateBlocksData(MethodNode mth) {
|
||||
clearBlocksState(mth);
|
||||
DominatorTree.compute(mth);
|
||||
markLoops(mth);
|
||||
|
||||
DominatorTree.computeDominanceFrontier(mth);
|
||||
registerLoops(mth);
|
||||
processNestedLoops(mth);
|
||||
|
||||
PostDominatorTree.compute(mth);
|
||||
|
||||
updateCleanSuccessors(mth);
|
||||
}
|
||||
|
||||
static void updateCleanSuccessors(MethodNode mth) {
|
||||
mth.getBasicBlocks().forEach(BlockNode::updateCleanSuccessors);
|
||||
}
|
||||
@ -245,6 +272,7 @@ public class BlockProcessor extends AbstractVisitor {
|
||||
}
|
||||
|
||||
private static void registerLoops(MethodNode mth) {
|
||||
mth.resetLoops();
|
||||
mth.getBasicBlocks().forEach(block -> {
|
||||
if (block.contains(AFlag.LOOP_START)) {
|
||||
block.getAll(AType.LOOP).forEach(mth::registerLoop);
|
||||
|
Loading…
Reference in New Issue
Block a user