Package nginx.clojure.asm.tree.analysis

Examples of nginx.clojure.asm.tree.analysis.Frame


    public boolean collectCodeBlocks() {
        int numIns = mn.instructions.size();
       
        codeBlocks[0] = FrameInfo.FIRST;
        for(int i=0 ; i<numIns ; i++) {
            Frame f = frames[i];
            if(f != null) { // reachable ?
                AbstractInsnNode in = mn.instructions.get(i);
                if(in.getType() == AbstractInsnNode.METHOD_INSN) {
                    MethodInsnNode min = (MethodInsnNode)in;
                    int opcode = min.getOpcode();
View Full Code Here


               
            case Opcodes.INVOKESPECIAL:
                MethodInsnNode min = (MethodInsnNode)ins;
                if("<init>".equals(min.name)) {
                    int argSize = TypeAnalyzer.getNumArguments(min.desc);
                    Frame frame = frames[i];
                    if (frame != null) {
                       int stackIndex = frame.getStackSize() - argSize - 1;
                         Value thisValue = frame.getStack(stackIndex);
                         if(stackIndex >= 1 &&
                                 isNewValue(thisValue, true) &&
                                 isNewValue(frame.getStack(stackIndex-1), false)) {
                             NewValue newValue = (NewValue)thisValue;
                             if(newValue.omitted) {
                                 emitNewAndDup(mv, frame, stackIndex, min);
                             }
                         } else {
View Full Code Here

      }
      return null;
    }

    private void emitStoreState(MethodVisitor mv, int idx, FrameInfo fi) {
        Frame f = frames[fi.endInstruction];
       
        if (verifyVarInfoss != null) {
          VerifyVarInfo[] vis = verifyVarInfoss[idx-1] = new VerifyVarInfo[fi.numSlots*2];
            for(int i=f.getStackSize() ; i-->0 ;) {
                BasicValue v = (BasicValue) f.getStack(i);
        if (!isOmitted(v) && !isNullType(v)) {
          VerifyVarInfo vi = new VerifyVarInfo();
          int slotIdx = fi.stackSlotIndices[i];
          vi.idx = i;
          vi.name = "_NGX_STACK_VAL_";
          vi.dataIdx = slotIdx;
          vi.value = v;
          if (v.isReference()) {
            vis[slotIdx] = vi;
          }else {
            vis[fi.numSlots + slotIdx] = vi;
          }
        }
            }
           
            for(int i=firstLocal ; i<f.getLocals() ; i++) {
                BasicValue v = (BasicValue) f.getLocal(i);
                if(!isNullType(v)) {
                  VerifyVarInfo vi = new VerifyVarInfo();
                    int slotIdx = fi.localSlotIndices[i];
          LocalVariableNode lvn = findVarNode(i);
          if (lvn != null) {
            vi.name = lvn.name;
            vi.idx = i;
          }
                    vi.dataIdx = slotIdx;
          vi.value = v;

          if (v.isReference()) {
            vis[slotIdx] = vi;
          }else {
            vis[fi.numSlots + slotIdx] = vi;
          }
                }
            }
        }
       
        if(fi.lBefore != null) {
            fi.lBefore.accept(mv);
        }
           
        mv.visitVarInsn(Opcodes.ALOAD,lvarStack);
        emitConst(mv, idx);
        emitConst(mv, fi.numSlots);
        if (verifyVarInfoss != null) {
          mv.visitLdcInsn(classAndMethod);
          mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, STACK_NAME, "pushMethodAndReserveSpaceV", "(IILjava/lang/String;)V");
        }else {
          mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, STACK_NAME, "pushMethodAndReserveSpace", "(II)V");
        }
       
               
        for(int i=f.getStackSize() ; i-->0 ;) {
            BasicValue v = (BasicValue) f.getStack(i);
            if(!isOmitted(v)) {
                if(!isNullType(v)) {
                    int slotIdx = fi.stackSlotIndices[i];
                    assert slotIdx >= 0 && slotIdx < fi.numSlots;
                    emitStoreValue(mv, v, lvarStack, slotIdx);
                } else {
                    db.trace("NULL stack entry: type=%s size=%d", v.getType(), v.getSize());
                    mv.visitInsn(Opcodes.POP);
                }
            }
        }
       
        for(int i=firstLocal ; i<f.getLocals() ; i++) {
            BasicValue v = (BasicValue) f.getLocal(i);
            if(!isNullType(v)) {
                mv.visitVarInsn(v.getType().getOpcode(Opcodes.ILOAD), i);
                int slotIdx = fi.localSlotIndices[i];
                assert slotIdx >= 0 && slotIdx < fi.numSlots;
                emitStoreValue(mv, v, lvarStack, slotIdx);
View Full Code Here

            }
        }
    }

    private void emitRestoreState(MethodVisitor mv, int idx, FrameInfo fi) {
        Frame f = frames[fi.endInstruction];
       
        for(int i=firstLocal ; i<f.getLocals() ; i++) {
            BasicValue v = (BasicValue) f.getLocal(i);
            if(!isNullType(v)) {
                int slotIdx = fi.localSlotIndices[i];
                assert slotIdx >= 0 && slotIdx < fi.numSlots;
                emitRestoreValue(mv, v, lvarStack, slotIdx);
                mv.visitVarInsn(v.getType().getOpcode(Opcodes.ISTORE), i);
            } else if(v != BasicValue.UNINITIALIZED_VALUE) {
                mv.visitInsn(Opcodes.ACONST_NULL);
                mv.visitVarInsn(Opcodes.ASTORE, i);
            }
        }
       
        for(int i=0 ; i<f.getStackSize() ; i++) {
            BasicValue v = (BasicValue) f.getStack(i);
            if(!isOmitted(v)) {
                if(!isNullType(v)) {
                    int slotIdx = fi.stackSlotIndices[i];
                    assert slotIdx >= 0 && slotIdx < fi.numSlots;
                    emitRestoreValue(mv, v, lvarStack, slotIdx);
View Full Code Here

          db.debug(InstrumentClass.insnToString(insn));
        }
//        System.out.println(insnToString(insn));
        if (insn instanceof MethodInsnNode) {
        MethodInsnNode minsn = (MethodInsnNode) insn;
        Frame mif = frames[i];
        if (minsn.name.equals("<init>") && mif.getLocal(0) == mif.getStack(mif.getStackSize()-1-TypeAnalyzer.getNumArguments(minsn.desc)) ) {
          splitPos = i+1;
          invokedInitInsn = minsn;
          break;
        }
      }
      }
     
      if (splitPos == -1) {
        splitPos = 0;
      }
     
        Frame f = frames[splitPos];
        FrameInfo fi = new FrameInfo(f, firstLocal, splitPos, mn.instructions, db);
        emitShrinkedInitMethod(cv, splitPos, f, fi, invokedInitInsn);
        emitInitHelpMethod(cv, numIns, splitPos, f, fi, invokedInitInsn);
    }
View Full Code Here

TOP

Related Classes of nginx.clojure.asm.tree.analysis.Frame

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.