Examples of InsnList


Examples of org.objectweb.asm.tree.InsnList

        // main routine
        worklist.add(new Instantiation(null, mainSubroutine));

        // Emit instantiations of each subroutine we encounter, including the
        // main subroutine
        InsnList newInstructions = new InsnList();
        List newTryCatchBlocks = new ArrayList();
        List newLocalVariables = new ArrayList();
        while (!worklist.isEmpty()) {
            Instantiation inst = (Instantiation) worklist.removeFirst();
            emitSubroutine(inst,
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

            for (int j = 0; j < limit; j++) {
                ClassNode clazz = (ClassNode) result.get(j);
                List l = clazz.methods;
                for (int k = 0, lim = l.size(); k < lim; k++) {
                    MethodNode m = (MethodNode) l.get(k);
                    InsnList insn = m.instructions;
                    if (insn != null) {
                        insn.clear();
                    }
                }
            }
            memDown(runtime);
            System.out.println("ASM memory load (removed method code): ".concat(memFormat(getUsedMem(runtime)
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

            }
        }
    }

    public void restoreNonInstructionNodes() {
        InsnList newinsns = new InsnList();
        int sz = instructions.size();
        for (int i = 0; i < sz; i++) {
            LabelNode l = getLabelAt(i);
            if (l != null) {
                newinsns.add(l);
            }
            LineNumberNode ln = lineNumberNodes.get(i);
            if (ln != null) {
                newinsns.add(ln);
            }
            AbstractInsnNode ain = instructions.get(i);
            newinsns.add(ain);
        }
       
        LabelNode l = getLabelAt(sz);
        if (l != null) {
            newinsns.add(l);
        }
        LineNumberNode ln = lineNumberNodes.get(sz);
        if (ln != null) {
            newinsns.add(ln);
        }
        super.instructions = newinsns;
    }
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

                    dup.addSuccessor(b);
                }
            }

            if (deepCopy) {
                InsnList extraInsns = new InsnList();
                MethodFlow flow = targetBB.flow;
                InsnList instructions = flow.instructions;
                // copy instructions
                dup.startLabel = labelCopyMap.get(orig.startLabel);
                dup.startPos = instructions.size();
                dup.endPos = dup.startPos + (orig.endPos - orig.startPos);
                // Note: last instruction (@endPos) isn't copied in the loop.
                // If it has labels, a new instruction is generated; either
                // way the last instruction is appended separately.
                int i;
                int newPos = instructions.size();
                int end = orig.endPos;

                // create new labels and instructions
                for (i = orig.startPos;  i <= end; i++, newPos++) {
                    LabelNode l = flow.getLabelAt(i);
                    if (l != null) {
                        l = labelCopyMap.get(l);
                        assert l != null;
                        flow.setLabel(newPos, l);
                    }
                    extraInsns.add(instructions.get(i).clone(labelCopyMap));
                }
               
                // new handlers
                dup.handlers = new ArrayList<Handler>(orig.handlers.size());
                if (orig.handlers.size() > 0) {
                    for (Handler oh : orig.handlers) {
                        Handler h = new Handler(dup.startPos
                                + (oh.from - orig.startPos), dup.endPos
                                + (oh.to - orig.endPos), oh.type, oh.catchBB);
                        dup.handlers.add(h);
                    }
                }
                instructions.add(extraInsns);
            }
            newBBs.add(dup);
        }
        return newBBs;
    }
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

    MethodDelta md = new MethodDelta(oMethod.name, oMethod.desc);
    if (oMethod.access != nMethod.access) {
      md.setAccessChanged(oMethod.access, nMethod.access);
    }
    // TODO annotations
    InsnList oInstructions = oMethod.instructions;
    InsnList nInstructions = nMethod.instructions;
    if (oInstructions.size() != nInstructions.size()) {
      md.setInstructionsChanged(oInstructions.toArray(), nInstructions.toArray());
    } else {
      // TODO Just interested in constructors right now - should add others
      if (oMethod.name.charAt(0) == '<') {
        String oInvokeSpecialDescriptor = null;
        String nInvokeSpecialDescriptor = null;
        int oUninitCount = 0;
        int nUninitCount = 0;
        boolean codeChange = false;
        for (int i = 0, max = oInstructions.size(); i < max; i++) {
          AbstractInsnNode oInstruction = oInstructions.get(i);
          AbstractInsnNode nInstruction = nInstructions.get(i);
          if (!codeChange) {
            if (!sameInstruction(oInstruction, nInstruction)) {
              codeChange = true;
            }

          }
          if (oInstruction.getType() == AbstractInsnNode.TYPE_INSN) {
            if (oInstruction.getOpcode() == Opcodes.NEW) {
              oUninitCount++;
            }
          }
          if (nInstruction.getType() == AbstractInsnNode.TYPE_INSN) {
            if (nInstruction.getOpcode() == Opcodes.NEW) {
              nUninitCount++;
            }
          }
          if (oInstruction.getType() == AbstractInsnNode.METHOD_INSN) {
            MethodInsnNode mi = (MethodInsnNode) oInstruction;
            if (mi.getOpcode() == INVOKESPECIAL && mi.name.equals("<init>")) {
              if (oUninitCount == 0) {
                // this is the one!
                oInvokeSpecialDescriptor = mi.desc;
              } else {
                oUninitCount--;
              }
            }
          }
          if (nInstruction.getType() == AbstractInsnNode.METHOD_INSN) {
            MethodInsnNode mi = (MethodInsnNode) nInstruction;
            if (mi.getOpcode() == INVOKESPECIAL && mi.name.equals("<init>")) {
              if (nUninitCount == 0) {
                // this is the one!
                nInvokeSpecialDescriptor = mi.desc;
              } else {
                nUninitCount--;
              }
            }
          }
        }
        // Has the invokespecial changed?
        if (oInvokeSpecialDescriptor == null) {
          if (nInvokeSpecialDescriptor != null) {
            md.setInvokespecialChanged(oInvokeSpecialDescriptor, nInvokeSpecialDescriptor);
          }
        } else {
          if (!oInvokeSpecialDescriptor.equals(nInvokeSpecialDescriptor)) {
            md.setInvokespecialChanged(oInvokeSpecialDescriptor, nInvokeSpecialDescriptor);
          }
        }
        if (codeChange) {
          md.setCodeChanged(oInstructions.toArray(), nInstructions.toArray());
        }
      }
    }
    if (md.hasAnyChanges()) {
      // it needs recording
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

        // main routine
        worklist.add(new Instantiation(null, mainSubroutine));

        // Emit instantiations of each subroutine we encounter, including the
        // main subroutine
        InsnList newInstructions = new InsnList();
        List<TryCatchBlockNode> newTryCatchBlocks = new ArrayList<TryCatchBlockNode>();
        List<LocalVariableNode> newLocalVariables = new ArrayList<LocalVariableNode>();
        while (!worklist.isEmpty()) {
            Instantiation inst = worklist.removeFirst();
            emitSubroutine(inst, worklist, newInstructions, newTryCatchBlocks,
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

        // main routine
        worklist.add(new Instantiation(null, mainSubroutine));

        // Emit instantiations of each subroutine we encounter, including the
        // main subroutine
        InsnList newInstructions = new InsnList();
        List<TryCatchBlockNode> newTryCatchBlocks = new ArrayList<TryCatchBlockNode>();
        List<LocalVariableNode> newLocalVariables = new ArrayList<LocalVariableNode>();
        while (!worklist.isEmpty()) {
            Instantiation inst = worklist.removeFirst();
            emitSubroutine(inst, worklist, newInstructions, newTryCatchBlocks,
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

    return cloneInsnList(cloneLabels(insns), insns);
  }

  public static InsnList cloneInsnList(Map<LabelNode, LabelNode> labelMap, InsnList insns)
  {
    InsnList clone = new InsnList();
    for (AbstractInsnNode insn = insns.getFirst(); insn != null; insn = insn.getNext())
      clone.add(insn.clone(labelMap));

    return clone;
  }
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

    {
      if (insn instanceof LabelNode)
        labels.put((LabelNode) insn, (LabelNode) insn);
    }

    InsnList importantNodeList = new InsnList();
    for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext())
    {
      if (insn instanceof LabelNode || insn instanceof LineNumberNode)
        continue;

      importantNodeList.add(insn.clone(labels));
    }
    return importantNodeList;
  }
View Full Code Here

Examples of org.objectweb.asm.tree.InsnList

            }
           
            AbstractInsnNode next = insn.getNext();
            if (toNull.cardinality() > 0) {
                // Construct the nulling instructions.
                InsnList nullingInsns = new InsnList();
                for (int i = 0; i < toNull.length(); i++) {
                    if (toNull.get(i)) {
                        AbstractInsnNode pushNull = new InsnNode(Opcodes.ACONST_NULL);
                        AbstractInsnNode store = new VarInsnNode(Opcodes.ASTORE, i);
                        nullingInsns.add(pushNull);
                        nullingInsns.add(store);
                    }
                }
               
                if (AbstractInsnNode.LABEL == insn.getType()) {
                    instructions.insert(insn, nullingInsns);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.