Package jadx.core.dex.regions

Examples of jadx.core.dex.regions.SynchronizedRegion


  private static void removeSynchronized(MethodNode mth) {
    Region startRegion = mth.getRegion();
    List<IContainer> subBlocks = startRegion.getSubBlocks();
    if (!subBlocks.isEmpty() && subBlocks.get(0) instanceof SynchronizedRegion) {
      SynchronizedRegion synchRegion = (SynchronizedRegion) subBlocks.get(0);
      InsnNode synchInsn = synchRegion.getEnterInsn();
      if (!synchInsn.getArg(0).isThis()) {
        LOG.warn("In synchronized method {}, top region not synchronized by 'this' {}", mth, synchInsn);
        return;
      }
      // replace synchronized block with inner region
      startRegion.getSubBlocks().set(0, synchRegion.getRegion());
      // remove 'monitor-enter' instruction
      InstructionRemover.remove(mth, synchInsn);
      // remove 'monitor-exit' instruction
      for (InsnNode exit : synchRegion.getExitInsns()) {
        InstructionRemover.remove(mth, exit);
      }
      // run region cleaner again
      CleanRegions.process(mth);
      // assume that CodeShrinker will be run after this
View Full Code Here


  }

  private final Set<BlockNode> cacheSet = new HashSet<BlockNode>();

  private BlockNode processMonitorEnter(IRegion curRegion, BlockNode block, InsnNode insn, RegionStack stack) {
    SynchronizedRegion synchRegion = new SynchronizedRegion(curRegion, insn);
    synchRegion.getSubBlocks().add(block);
    curRegion.getSubBlocks().add(synchRegion);

    Set<BlockNode> exits = new HashSet<BlockNode>();
    cacheSet.clear();
    traverseMonitorExits(synchRegion, insn.getArg(0), block, exits, cacheSet);

    for (InsnNode exitInsn : synchRegion.getExitInsns()) {
      InstructionRemover.unbindInsn(mth, exitInsn);
    }

    BlockNode body = getNextBlock(block);
    if (body == null) {
      ErrorsCounter.methodError(mth, "Unexpected end of synchronized block");
      return null;
    }
    BlockNode exit;
    if (exits.size() == 1) {
      exit = getNextBlock(exits.iterator().next());
    } else {
      cacheSet.clear();
      exit = traverseMonitorExitsCross(body, exits, cacheSet);
    }

    stack.push(synchRegion);
    stack.addExit(exit);
    synchRegion.getSubBlocks().add(makeRegion(body, stack));
    stack.pop();
    return exit;
  }
View Full Code Here

TOP

Related Classes of jadx.core.dex.regions.SynchronizedRegion

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.