Commit 60615d01 authored by Skylot's avatar Skylot

Fix issue for wraped synchronized argument

parent cb6ff606
...@@ -152,7 +152,7 @@ public class RegionGen extends InsnGen { ...@@ -152,7 +152,7 @@ public class RegionGen extends InsnGen {
} }
private void makeSynchronizedRegion(SynchronizedRegion cont, CodeWriter code) throws CodegenException { private void makeSynchronizedRegion(SynchronizedRegion cont, CodeWriter code) throws CodegenException {
code.startLine("synchronized(").add(arg(cont.getArg())).add(") {"); code.startLine("synchronized(").add(arg(cont.getInsn().getArg(0))).add(") {");
makeRegionIndent(code, cont.getRegion()); makeRegionIndent(code, cont.getRegion());
code.startLine('}'); code.startLine('}');
} }
......
package jadx.dex.regions; package jadx.dex.regions;
import jadx.dex.instructions.args.RegisterArg;
import jadx.dex.nodes.IContainer; import jadx.dex.nodes.IContainer;
import jadx.dex.nodes.IRegion; import jadx.dex.nodes.IRegion;
import jadx.dex.nodes.InsnNode;
import java.util.List; import java.util.List;
public final class SynchronizedRegion extends AbstractRegion { public final class SynchronizedRegion extends AbstractRegion {
private final RegisterArg arg; private final InsnNode insn;
private final Region region; private final Region region;
public SynchronizedRegion(IRegion parent, RegisterArg arg) { public SynchronizedRegion(IRegion parent, InsnNode insn) {
super(parent); super(parent);
this.arg = arg; this.insn = insn;
this.region = new Region(this); this.region = new Region(this);
} }
public RegisterArg getArg() { public InsnNode getInsn() {
return arg; return insn;
} }
public Region getRegion() { public Region getRegion() {
......
...@@ -9,7 +9,7 @@ import jadx.dex.attributes.LoopAttr; ...@@ -9,7 +9,7 @@ import jadx.dex.attributes.LoopAttr;
import jadx.dex.instructions.IfNode; import jadx.dex.instructions.IfNode;
import jadx.dex.instructions.InsnType; import jadx.dex.instructions.InsnType;
import jadx.dex.instructions.SwitchNode; import jadx.dex.instructions.SwitchNode;
import jadx.dex.instructions.args.RegisterArg; import jadx.dex.instructions.args.InsnArg;
import jadx.dex.nodes.BlockNode; import jadx.dex.nodes.BlockNode;
import jadx.dex.nodes.IRegion; import jadx.dex.nodes.IRegion;
import jadx.dex.nodes.InsnNode; import jadx.dex.nodes.InsnNode;
...@@ -269,14 +269,13 @@ public class RegionMaker { ...@@ -269,14 +269,13 @@ public class RegionMaker {
private static final Set<BlockNode> cacheSet = new HashSet<BlockNode>(); private static final Set<BlockNode> cacheSet = new HashSet<BlockNode>();
private BlockNode processMonitorEnter(IRegion curRegion, BlockNode block, InsnNode insn, RegionStack stack) { private BlockNode processMonitorEnter(IRegion curRegion, BlockNode block, InsnNode insn, RegionStack stack) {
RegisterArg arg = (RegisterArg) insn.getArg(0); SynchronizedRegion synchRegion = new SynchronizedRegion(curRegion, insn);
SynchronizedRegion synchRegion = new SynchronizedRegion(curRegion, arg);
synchRegion.getSubBlocks().add(block); synchRegion.getSubBlocks().add(block);
curRegion.getSubBlocks().add(synchRegion); curRegion.getSubBlocks().add(synchRegion);
Set<BlockNode> exits = new HashSet<BlockNode>(); Set<BlockNode> exits = new HashSet<BlockNode>();
cacheSet.clear(); cacheSet.clear();
traverseMonitorExits(arg, block, exits, cacheSet); traverseMonitorExits(insn.getArg(0), block, exits, cacheSet);
block = BlockUtils.getNextBlock(block); block = BlockUtils.getNextBlock(block);
BlockNode exit; BlockNode exit;
...@@ -298,7 +297,7 @@ public class RegionMaker { ...@@ -298,7 +297,7 @@ public class RegionMaker {
/** /**
* Traverse from monitor-enter thru successors and collect blocks contains monitor-exit * Traverse from monitor-enter thru successors and collect blocks contains monitor-exit
*/ */
private void traverseMonitorExits(RegisterArg arg, BlockNode block, Set<BlockNode> exits, Set<BlockNode> visited) { private void traverseMonitorExits(InsnArg arg, BlockNode block, Set<BlockNode> exits, Set<BlockNode> visited) {
visited.add(block); visited.add(block);
for (InsnNode insn : block.getInstructions()) { for (InsnNode insn : block.getInstructions()) {
if (insn.getType() == InsnType.MONITOR_EXIT if (insn.getType() == InsnType.MONITOR_EXIT
......
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