Package nginx.clojure.asm.tree.analysis

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


   
    private void emitNewAndDup(MethodVisitor mv, Frame frame, int stackIndex, MethodInsnNode min) {
        int arguments = frame.getStackSize() - stackIndex - 1;
        int neededLocals = 0;
        for(int i=arguments ; i>=1 ; i--) {
            BasicValue v = (BasicValue)frame.getStack(stackIndex+i);
            mv.visitVarInsn(v.getType().getOpcode(Opcodes.ISTORE), lvarStack+1+neededLocals);
            neededLocals += v.getSize();
        }
        db.trace("Inserting NEW & DUP for constructor call %s%s with %d arguments (%d locals)", min.owner, min.desc, arguments, neededLocals);
        if(additionalLocals < neededLocals) {
            additionalLocals = neededLocals;
        }
        ((NewValue)frame.getStack(stackIndex-1)).insn.accept(mv);
        ((NewValue)frame.getStack(stackIndex  )).insn.accept(mv);
        for(int i=1 ; i<=arguments ; i++) {
            BasicValue v = (BasicValue)frame.getStack(stackIndex+i);
            neededLocals -= v.getSize();
            mv.visitVarInsn(v.getType().getOpcode(Opcodes.ILOAD), lvarStack+1+neededLocals);
        }
    }
View Full Code Here


        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

            int idxPrim = 0;
           
            if(f != null) {
                stackSlotIndices = new int[f.getStackSize()];
                for(int i=0 ; i<f.getStackSize() ; i++) {
                    BasicValue v = (BasicValue)f.getStack(i);
                    if(v instanceof NewValue) {
                        NewValue newValue = (NewValue)v;
                        if(db.isDebug()) {
                            db.trace("Omit value from stack idx %d at instruction %d with type %s generated by %s",
                                    i, endInstruction, v, newValue.formatInsn());
                        }
                        if(!newValue.omitted) {
                            newValue.omitted = true;
                            if(db.isDebug()) {
                                // need to log index before replacing instruction
                                db.trace("Omitting instruction %d: %s", insnList.indexOf(newValue.insn), newValue.formatInsn());
                            }
                            insnList.set(newValue.insn, new OmittedInstruction(newValue.insn));
                        }
                        stackSlotIndices[i] = -666; // an invalid index ;)
                    } else if(!isNullType(v)) {
                        if(v.isReference()) {
                            stackSlotIndices[i] = idxObj++;
                        } else {
                            stackSlotIndices[i] = idxPrim++;
                        }
                    } else {
                        stackSlotIndices[i] = -666; // an invalid index ;)
                    }
                }

                localSlotIndices = new int[f.getLocals()];
                for(int i=firstLocal ; i<f.getLocals() ; i++) {
                    BasicValue v = (BasicValue)f.getLocal(i);
                    if(!isNullType(v)) {
                        if(v.isReference()) {
                            localSlotIndices[i] = idxObj++;
                        } else {
                            localSlotIndices[i] = idxPrim++;
                        }
                    } else {
View Full Code Here

                        pop();
                        if(insn.getOpcode() == Opcodes.INVOKESPECIAL && getStackSize() > 0) {
                            if("<init>".equals(((MethodInsnNode)insn).name)) {
                                Value value = pop();
                                if(value instanceof NewValue) {
                                    value = new BasicValue(((NewValue)value).getType());
                                }
                                push(value);
                            }
                        }
                    }
View Full Code Here

      mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, invokedInitInsn.owner, "inch_" + getMD5(invokedInitInsn.desc), "()V");
      mv.visitLabel(invokedInitInsnEnd);
    }
   
    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, lvarCStack, 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, lvarCStack, slotIdx);
View Full Code Here

    cmv.visitVarInsn(Opcodes.ALOAD,lvarCStack);
    emitConst(cmv, fi.numSlots);
    cmv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, CSTACK_NAME, "incRefsAndReserveSpace", "(I)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(cmv, v, lvarCStack, slotIdx);
            } else {
                db.trace("NULL stack entry: type=%s size=%d", v.getType(), v.getSize());
                cmv.visitInsn(Opcodes.POP);
            }
        }
    }
   
    for(int i=firstLocal; i < f.getLocals() ; i++) {
        BasicValue v = (BasicValue) f.getLocal(i);
        if(!isNullType(v)) {
            cmv.visitVarInsn(v.getType().getOpcode(Opcodes.ILOAD), i);
            int slotIdx = fi.localSlotIndices[i];
            assert slotIdx >= 0 && slotIdx < fi.numSlots;
            emitStoreValue(cmv, v, lvarCStack, slotIdx);
        }
    }
View Full Code Here

            int idxPrim = 0;
           
            if(f != null) {
                stackSlotIndices = new int[f.getStackSize()];
                for(int i=0 ; i<f.getStackSize() ; i++) {
                    BasicValue v = (BasicValue)f.getStack(i);
                    if(v instanceof NewValue) {
                        NewValue newValue = (NewValue)v;
                        if(db.isDebug()) {
                            db.trace("Omit value from stack idx %d at instruction %d with type %s generated by %s",
                                    i, endInstruction, v, newValue.formatInsn());
                        }
                        if(!newValue.omitted) {
                            newValue.omitted = true;
                            if(db.isDebug()) {
                                // need to log index before replacing instruction
                                db.trace("Omitting instruction %d: %s", insnList.indexOf(newValue.insn), newValue.formatInsn());
                            }
                            insnList.set(newValue.insn, new OmittedInstruction(newValue.insn));
                        }
                        stackSlotIndices[i] = -666; // an invalid index ;)
                    } else if(!isNullType(v)) {
                        if(v.isReference()) {
                            stackSlotIndices[i] = idxObj++;
                        } else {
                            stackSlotIndices[i] = idxPrim++;
                        }
                    } else {
                        stackSlotIndices[i] = -666; // an invalid index ;)
                    }
                }

                localSlotIndices = new int[f.getLocals()];
                for(int i=firstLocal ; i<f.getLocals() ; i++) {
                    BasicValue v = (BasicValue)f.getLocal(i);
                    if(!isNullType(v)) {
                        if(v.isReference()) {
                            localSlotIndices[i] = idxObj++;
                        } else {
                            localSlotIndices[i] = idxPrim++;
                        }
                    } else {
View Full Code Here

    public BasicValue newValue(Type type) {
        if(type == null) {
            return BasicValue.UNINITIALIZED_VALUE;
        }
        if(type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) {
            return new BasicValue(type);
        }
        return super.newValue(type);
    }
View Full Code Here

            if(t1 == null || t1.getSort() != Type.ARRAY) {
                throw new AnalyzerException(insn, "AALOAD needs an array as first parameter");
            }
           
            Type resultType = Type.getType(t1.getDescriptor().substring(1));
            return new BasicValue(resultType);
        }
        return super.binaryOperation(insn, value1, value2);
    }
View Full Code Here

TOP

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

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.