Package nginx.clojure.asm

Examples of nginx.clojure.asm.Label


     * Creates a new {@link Label}.
     *
     * @return a new {@link Label}.
     */
    public Label newLabel() {
        return new Label();
    }
View Full Code Here


     * Marks the current code position with a new label.
     *
     * @return the label that was created to mark the current code position.
     */
    public Label mark() {
        Label label = new Label();
        mv.visitLabel(label);
        return label;
    }
View Full Code Here

            if (keys[i] < keys[i - 1]) {
                throw new IllegalArgumentException(
                        "keys must be sorted ascending");
            }
        }
        Label def = newLabel();
        Label end = newLabel();
        if (keys.length > 0) {
            int len = keys.length;
            int min = keys[0];
            int max = keys[len - 1];
            int range = max - min + 1;
            if (useTable) {
                Label[] labels = new Label[range];
                Arrays.fill(labels, def);
                for (int i = 0; i < len; ++i) {
                    labels[keys[i] - min] = newLabel();
                }
                mv.visitTableSwitchInsn(min, max, def, labels);
                for (int i = 0; i < range; ++i) {
                    Label label = labels[i];
                    if (label != def) {
                        mark(label);
                        generator.generateCase(i + min, end);
                    }
                }
View Full Code Here

        return LABEL;
    }

    public Label getLabel() {
        if (label == null) {
            label = new Label();
        }
        return label;
    }
View Full Code Here

      exps.add(CheckInstrumentationVisitor.EXCEPTION_NAME);
    }
    String[] expss = MethodDatabase.toStringArray(exps);
    MethodNode mv = new MethodNode(Opcodes.ACC_PUBLIC, buildInitHelpMethodName(mn.desc), "()V", null, expss);
   
    Label invokedInitInsnStart = null;
    Label invokedInitInsnEnd = null;
    Label invokedInitInsnCatchAll = null;
    boolean needWaveInvokedInitInsn = invokedInitInsn != null
        && db.checkMethodSuspendType(invokedInitInsn.owner, ClassEntry.key(invokedInitInsn.name, invokedInitInsn.desc), false) == MethodDatabase.SUSPEND_NORMAL;
    if (needWaveInvokedInitInsn) {
      invokedInitInsnStart = new Label();
      invokedInitInsnEnd = new Label();
      invokedInitInsnCatchAll = new Label();
      mv.visitTryCatchBlock(invokedInitInsnStart, invokedInitInsnEnd, invokedInitInsnCatchAll, null);
    }
   
    for(TryCatchBlockNode tcb : mn.tryCatchBlocks) {
            tcb.accept(mv);
View Full Code Here

          verifyVarInfoss = new VerifyVarInfo[numCodeBlocks-1][];
        }
       
        mv.visitCode();
       
        Label lMethodStart = new Label();
        Label lMethodEnd = new Label();
        Label lCatchSEE = new Label();
        Label lCatchAll = new Label();
        Label[] lMethodCalls = new Label[numCodeBlocks-1];
       
        for(int i=1 ; i<numCodeBlocks ; i++) {
            lMethodCalls[i-1] = new Label();
        }
       
        mv.visitTryCatchBlock(lMethodStart, lMethodEnd, lCatchSEE, CheckInstrumentationVisitor.EXCEPTION_NAME);
       
       
        for(TryCatchBlockNode tcb : mn.tryCatchBlocks) {
            if (hasReflectInvoke && REFLECT_EXCEPTION_SET.contains(tcb.type)) {
              if (reflectExceptionHandlers == null){
                reflectExceptionHandlers = new HashSet<LabelNode>();
              }
              reflectExceptionHandlers.add(tcb.handler);
            }
            if(CheckInstrumentationVisitor.EXCEPTION_NAME.equals(tcb.type)) {
                throw new UnableToInstrumentException("catch for " +
                        SuspendExecution.class.getSimpleName(), className, mn.name, mn.desc);
            }
            tcb.accept(mv);
        }
       
        if(mn.visibleParameterAnnotations != null) {
            dumpParameterAnnotations(mv, mn.visibleParameterAnnotations, true);
        }
       
        if(mn.invisibleParameterAnnotations != null) {
            dumpParameterAnnotations(mv, mn.invisibleParameterAnnotations, false);
        }
       
        if(mn.visibleAnnotations != null) {
            for(Object o : mn.visibleAnnotations) {
                AnnotationNode an = (AnnotationNode)o;
                an.accept(mv.visitAnnotation(an.desc, true));
            }
        }
       
        mv.visitTryCatchBlock(lMethodStart, lMethodEnd, lCatchAll, null);
   
        mv.visitMethodInsn(Opcodes.INVOKESTATIC, STACK_NAME, "getStack", "()L"+STACK_NAME+";");
        mv.visitInsn(Opcodes.DUP);
        mv.visitVarInsn(Opcodes.ASTORE, lvarStack);
       
        if (db.isAllowOutofCoroutine()) {
            mv.visitJumpInsn(Opcodes.IFNULL, lMethodStart);
            mv.visitVarInsn(Opcodes.ALOAD, lvarStack);
        }
       
        if (verifyVarInfoss != null) {
          mv.visitLdcInsn(classAndMethod);
          mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, STACK_NAME, "nextMethodEntryV", "(Ljava/lang/String;)I");
        }else {
          mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, STACK_NAME, "nextMethodEntry", "()I");
        }
       
        mv.visitInsn(Opcodes.DUP);
        Label tableSwitchLabel = new Label();
        mv.visitJumpInsn(Opcodes.IFGE, tableSwitchLabel);
        mv.visitInsn(Opcodes.POP);
        mv.visitInsn(Opcodes.ACONST_NULL);
        mv.visitVarInsn(Opcodes.ASTORE, lvarStack);
        mv.visitJumpInsn(Opcodes.GOTO, lMethodStart);
       
        mv.visitLabel(tableSwitchLabel);
        mv.visitTableSwitchInsn(1, numCodeBlocks-1, lMethodStart, lMethodCalls);
       
        mv.visitLabel(lMethodStart);
        dumpCodeBlock(mv, 0, 0);
       
        for(int i=1 ; i<numCodeBlocks ; i++) {
            FrameInfo fi = codeBlocks[i];
           
            MethodInsnNode min = (MethodInsnNode)(mn.instructions.get(fi.endInstruction));
            if(InstrumentClass.COROUTINE_NAME.equals(min.owner) && "yield".equals(min.name)) {
                // special case - call to yield() - resume AFTER the call
                if(min.getOpcode() != Opcodes.INVOKESTATIC) {
                    throw new UnableToInstrumentException("invalid call to yield()", className, mn.name, mn.desc);
                }
               
                if (verifyVarInfoss != null) {
                  mv.visitMethodInsn(Opcodes.INVOKESTATIC, "nginx/clojure/wave/SuspendMethodVerifier", "onYield", "()V");
                }
               
                emitStoreState(mv, i, fi);
                mv.visitFieldInsn(Opcodes.GETSTATIC, STACK_NAME,
                        "exception_instance_not_for_user_code",
                        CheckInstrumentationVisitor.EXCEPTION_DESC);
                mv.visitInsn(Opcodes.ATHROW);
                min.accept(mv); // only the call
                mv.visitLabel(lMethodCalls[i-1]);
                emitRestoreState(mv, i, fi);
                dumpCodeBlock(mv, i, 1);    // skip the call
            } else {
             
                final Label ocl = new Label();
                if (db.isAllowOutofCoroutine()) {
                    mv.visitVarInsn(Opcodes.ALOAD, lvarStack);
                    mv.visitJumpInsn(Opcodes.IFNULL, ocl);
                }
             
View Full Code Here

        }
        mv.visitEnd();
    }

  private void emitRelectExceptionHandleCode(MethodVisitor mv, boolean doThrow) {
    Label lNoReflectException = new Label();
    mv.visitInsn(Opcodes.DUP);
    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Throwable", "getCause", "()Ljava/lang/Throwable;");
    mv.visitFieldInsn(Opcodes.GETSTATIC, "nginx/clojure/Stack", "exception_instance_not_for_user_code", "Lnginx/clojure/SuspendExecution;");
    mv.visitJumpInsn(Opcodes.IF_ACMPNE, lNoReflectException);
    mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, "java/lang/Throwable", "getCause", "()Ljava/lang/Throwable;");
View Full Code Here

        }
    }
   
    private void emitPopMethod(MethodVisitor mv) {
     
        final Label ocl = new Label();
        if (db.isAllowOutofCoroutine()) {
            mv.visitVarInsn(Opcodes.ALOAD, lvarStack);
            mv.visitJumpInsn(Opcodes.IFNULL, ocl);
        }
View Full Code Here

    @Override
    public void visitTypeInsn(final int opcode, final String type) {
        if (opcode == Opcodes.NEW) {
            if (labels == null) {
                Label l = new Label();
                labels = new ArrayList<Label>(3);
                labels.add(l);
                if (mv != null) {
                    mv.visitLabel(l);
                }
View Full Code Here

TOP

Related Classes of nginx.clojure.asm.Label

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.