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 {
}
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());
code.startLine('}');
}
......
package jadx.dex.regions;
import jadx.dex.instructions.args.RegisterArg;
import jadx.dex.nodes.IContainer;
import jadx.dex.nodes.IRegion;
import jadx.dex.nodes.InsnNode;
import java.util.List;
public final class SynchronizedRegion extends AbstractRegion {
private final RegisterArg arg;
private final InsnNode insn;
private final Region region;
public SynchronizedRegion(IRegion parent, RegisterArg arg) {
public SynchronizedRegion(IRegion parent, InsnNode insn) {
super(parent);
this.arg = arg;
this.insn = insn;
this.region = new Region(this);
}
public RegisterArg getArg() {
return arg;
public InsnNode getInsn() {
return insn;
}
public Region getRegion() {
......
......@@ -9,7 +9,7 @@ import jadx.dex.attributes.LoopAttr;
import jadx.dex.instructions.IfNode;
import jadx.dex.instructions.InsnType;
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.IRegion;
import jadx.dex.nodes.InsnNode;
......@@ -269,14 +269,13 @@ public class RegionMaker {
private static final Set<BlockNode> cacheSet = new HashSet<BlockNode>();
private BlockNode processMonitorEnter(IRegion curRegion, BlockNode block, InsnNode insn, RegionStack stack) {
RegisterArg arg = (RegisterArg) insn.getArg(0);
SynchronizedRegion synchRegion = new SynchronizedRegion(curRegion, arg);
SynchronizedRegion synchRegion = new SynchronizedRegion(curRegion, insn);
synchRegion.getSubBlocks().add(block);
curRegion.getSubBlocks().add(synchRegion);
Set<BlockNode> exits = new HashSet<BlockNode>();
cacheSet.clear();
traverseMonitorExits(arg, block, exits, cacheSet);
traverseMonitorExits(insn.getArg(0), block, exits, cacheSet);
block = BlockUtils.getNextBlock(block);
BlockNode exit;
......@@ -298,7 +297,7 @@ public class RegionMaker {
/**
* 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);
for (InsnNode insn : block.getInstructions()) {
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