Package org.deuce.objectweb.asm

Examples of org.deuce.objectweb.asm.Label


    final int lockLocal = locals(types, isNonStatic);

    atomicVisitor.visitCode();

    // enter synchronized block
    Label l0 = new Label();
    Label l1 = new Label();
    Label l2 = new Label();
    atomicVisitor.visitTryCatchBlock(l0, l1, l2, null);
    Label l3 = new Label();
    atomicVisitor.visitTryCatchBlock(l2, l3, l2, null);
    atomicVisitor.visitFieldInsn(Opcodes.GETSTATIC, "org/deuce/transaction/global/Lock",
        "lock", "Ljava/lang/Object;");
    atomicVisitor.visitInsn(Opcodes.DUP);
    atomicVisitor.visitVarInsn(Opcodes.ASTORE, lockLocal);
View Full Code Here


    }

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

        return LABEL;
    }

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

      return;
    }
   
    String fieldsHolderName = fieldsHolder.getFieldsHolderName(owner);
    mv.visitFieldInsn(Opcodes.GETSTATIC, fieldsHolderName, Util.getAddressField(name), "J");
    Label l1 = new Label();
    mv.visitInsn(Opcodes.LCONST_0);
    mv.visitInsn(Opcodes.LCMP);
    mv.visitJumpInsn(Opcodes.IFGE, l1);
    super.visitFieldInsn(opcode, owner, name, desc);
    Label l2 = new Label();
    mv.visitJumpInsn(Opcodes.GOTO, l2);
    mv.visitLabel(l1);
   
    final Type type = Type.getType(desc);
    switch( opcode) {
View Full Code Here

    }
    return copyLabels;
  }

  private Label getLabel( Label label){
    Label duplicateLabel = labelMap.get( label);
    if( duplicateLabel == null) {
      duplicateLabel = new Label();
      labelMap.put(label, duplicateLabel);
    }
    return duplicateLabel;
  }
View Full Code Here

public class GetterSetterCode implements Opcodes{

  public static void addGttrCode(GetterSetterDetails gSD, MethodVisitor mv, String className) {
    mv.visitCode();
    Label l0 = new Label();
    mv.visitLabel(l0);
    //Get the Field
    mv.visitVarInsn(Opcodes.ALOAD, 0);   
    mv.visitFieldInsn(Opcodes.GETFIELD, className, gSD.fD.VarName, gSD.fD.VarDesc);
    //Return the field value depending on Return type
View Full Code Here

    mv.visitEnd();
  }

  public static void addSttrCode(GetterSetterDetails gSD, MethodVisitor mv, String className) {
    mv.visitCode();
    Label l0 = new Label();
    mv.visitLabel(l0);

    mv.visitVarInsn(Opcodes.ALOAD, 0);
    //Load the Argument Depending upon variable type
    Type arg = Type.getType(gSD.fD.VarDesc);
View Full Code Here

   
    arguements[0]= Type.getType(Object.class);
    System.arraycopy(src, 0, arguements, 1, src.length);
    String desc = Type.getMethodDescriptor(method.getReturnType(), arguements);
   
    Label l0 = new Label();
    Label l1 = new Label();
    Label l2 = new Label();
    mv.visitTryCatchBlock(l0, l1, l2, "java/rmi/RemoteException");
    //If Statement
    Label l3 = new Label();
    mv.visitLabel(l3);
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, className, "$HY$_proxy", "L"+proxyIname+";")//
    Label l4 = new Label();
    mv.visitJumpInsn(IFNULL, l4);    //Go to start of method
    //Start try block
    mv.visitLabel(l0);   
    mv.visitVarInsn(ALOAD, 0);
    mv.visitFieldInsn(GETFIELD, className, "$HY$_proxy", "L"+proxyIname+";");
View Full Code Here

   
    //Add Constructor
    {
      mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, new String[] { Names.RMIException });
      mv.visitCode();
      Label l0 = new Label();
      Label l1 = new Label();
      Label l2 = new Label();
      mv.visitTryCatchBlock(l0, l1, l2, Names.RMIException);
      Label l3 = new Label();
      Label l4 = new Label();
      Label l5 = new Label();
      mv.visitTryCatchBlock(l3, l4, l5, Names.Exception);
      Label l6 = new Label();
      mv.visitLabel(l6);
      //Call Super Class
      mv.visitVarInsn(ALOAD, 0);
      mv.visitMethodInsn(INVOKESPECIAL, Names.UniCastObject, "<init>", "()V");
      Label l7 = new Label();
      mv.visitLabel(l7);
 
      mv.visitMethodInsn(INVOKESTATIC, Names.Hyflow, "getLocator", Type.getMethodDescriptor(Type.getType(DirectoryManager.class), new Type [] {})); //"()Laleph/dir/DirectoryManager;");
      mv.visitTypeInsn(CHECKCAST, Names.ControlFlowDirectory);
      mv.visitVarInsn(ALOAD, 0);
      mv.visitMethodInsn(INVOKEVIRTUAL, Names.ControlFlowDirectory, "addProxy", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {Type.getType(Object.class)})); //"(Ljava/lang/Object;)V");
      Label l8 = new Label();
      mv.visitLabel(l8);
 
      mv.visitMethodInsn(INVOKESTATIC, Names.System, "getSecurityManager", Type.getMethodDescriptor(Type.getType(SecurityManager.class), new Type[]{}));//"()Ljava/lang/SecurityManager;");
      Label l9 = new Label();
      mv.visitJumpInsn(IFNONNULL, l9);
      Label l10 = new Label();
      mv.visitLabel(l10);
 
      mv.visitTypeInsn(NEW, Names.RMISecurityManager);
      mv.visitInsn(DUP);
      mv.visitMethodInsn(INVOKESPECIAL, Names.RMISecurityManager, "<init>", "()V");
      mv.visitMethodInsn(INVOKESTATIC, Names.System, "setSecurityManager", Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {Type.getType(SecurityManager.class)}));//"(Ljava/lang/SecurityManager;)V");
      mv.visitLabel(l9);
   
      mv.visitFrame(Opcodes.F_FULL, 1, new Object[] {proxyName}, 0, new Object[] {});
      mv.visitMethodInsn(INVOKESTATIC, Names.HyflowNetwork, "getInstance", Type.getMethodDescriptor(Type.getType(Network.class), new Type[]{}));//"()Ledu/vt/rt/hyflow/util/network/Network;");
      mv.visitMethodInsn(INVOKEVIRTUAL, Names.HyflowNetwork, "getPort", "()I");
      mv.visitIntInsn(SIPUSH, 1000);
      mv.visitInsn(IADD);
      mv.visitVarInsn(ISTORE, 1);
      Label l11 = new Label();
      mv.visitLabel(l11);
 
      mv.visitInsn(ACONST_NULL);
      mv.visitVarInsn(ASTORE, 2);
      mv.visitLabel(l0);
 
      mv.visitVarInsn(ILOAD, 1);
      mv.visitMethodInsn(INVOKESTATIC, "java/rmi/registry/LocateRegistry", "createRegistry", "(I)Ljava/rmi/registry/Registry;");
      mv.visitVarInsn(ASTORE, 2);
      mv.visitLabel(l1);
      mv.visitJumpInsn(GOTO, l3);
      mv.visitLabel(l2);

      mv.visitFrame(Opcodes.F_FULL, 3, new Object[] {proxyName, Opcodes.INTEGER, "java/rmi/registry/Registry"}, 1, new Object[] {Names.RMIException});
      mv.visitVarInsn(ASTORE, 3);
      Label l12 = new Label();
      mv.visitLabel(l12);

      mv.visitVarInsn(ALOAD, 3);
      mv.visitMethodInsn(INVOKEVIRTUAL, Names.RMIException, "printStackTrace", "()V");
      mv.visitLabel(l3);

      mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
      mv.visitVarInsn(ALOAD, 0);
      mv.visitInsn(ICONST_1);
      mv.visitMethodInsn(INVOKESTATIC, Names.UniCastObject, "unexportObject", "(Ljava/rmi/Remote;Z)Z");
      mv.visitInsn(POP);
      mv.visitLabel(l4);
      Label l13 = new Label();
      mv.visitJumpInsn(GOTO, l13);
      mv.visitLabel(l5);

      mv.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {"java/lang/Exception"});
      mv.visitVarInsn(ASTORE, 3);
      Label l14 = new Label();
      mv.visitLabel(l14);

      mv.visitLdcInsn("RMI unexporting");
      mv.visitMethodInsn(INVOKESTATIC, "edu/vt/rt/hyflow/util/io/Logger", "error", "(Ljava/lang/String;)V");
      mv.visitLabel(l13);

      mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
      mv.visitVarInsn(ALOAD, 0);
      mv.visitInsn(ICONST_0);
      mv.visitMethodInsn(INVOKESTATIC, "java/rmi/server/UnicastRemoteObject", "exportObject", "(Ljava/rmi/Remote;I)Ljava/rmi/Remote;");
      mv.visitTypeInsn(CHECKCAST, proxyIName);
      mv.visitVarInsn(ASTORE, 3);
      Label l15 = new Label();
      mv.visitLabel(l15);

      mv.visitVarInsn(ALOAD, 2);
      mv.visitLdcInsn(Type.getType("L"+className+";"));
      mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Class", "getName", "()Ljava/lang/String;");
      mv.visitVarInsn(ALOAD, 3);
      mv.visitMethodInsn(INVOKEINTERFACE, "java/rmi/registry/Registry", "rebind", "(Ljava/lang/String;Ljava/rmi/Remote;)V");
      Label l16 = new Label();
      mv.visitLabel(l16);

      mv.visitVarInsn(ALOAD, 0);
      mv.visitMethodInsn(INVOKESTATIC, "edu/vt/rt/hyflow/HyFlow", "getLocator", "()Laleph/dir/DirectoryManager;");
      mv.visitFieldInsn(PUTFIELD, proxyName, "locator", "Laleph/dir/DirectoryManager;");
      Label l17 = new Label();
      mv.visitLabel(l17);

      mv.visitInsn(RETURN);

      mv.visitMaxs(0, 0);
      mv.visitEnd()
    }
   
    //Add Methods
    for(RemoteMethodDetails mD: urmdtl){
      mv = cw.visitMethod(ACC_PUBLIC, mD.rmD.name, mD.rmD.desc, null, null);
      Type[] src = Type.getArgumentTypes(mD.rmD.desc);
      Type returnType = Type.getReturnType(mD.rmD.desc);
      int callerIndex = src.length + 1//1 for this
      mv.visitCode();
      Label l0 = new Label();
      mv.visitLabel(l0);
//      mv.visitLineNumber(56, l0);
      mv.visitVarInsn(ALOAD, 2);
      mv.visitMethodInsn(INVOKEVIRTUAL, Names.ControlflowInterface, "getLastExecuter", "()Laleph/comm/Address;");
      mv.visitVarInsn(ASTORE, callerIndex);
      Label l1 = new Label();
      mv.visitLabel(l1);

      mv.visitInsn(ICONST_1);
      mv.visitVarInsn(ALOAD, callerIndex);
      mv.visitMethodInsn(INVOKESTATIC, "edu/vt/rt/hyflow/util/network/Network", "linkDelay", "(ZLaleph/comm/Address;)V");
      Label l2 = new Label();
      mv.visitLabel(l2);

      mv.visitVarInsn(ALOAD, 2);
      mv.visitMethodInsn(INVOKEVIRTUAL, "edu/vt/rt/hyflow/core/tm/control/ControlContext", "getContextId", "()Ljava/lang/Long;");
      mv.visitMethodInsn(INVOKESTATIC, "edu/vt/rt/hyflow/core/tm/control/ControlContext", "getNeighbors", "(Ljava/lang/Long;)Ljava/util/Set;");
      mv.visitVarInsn(ALOAD, callerIndex);
      mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Set", "add", "(Ljava/lang/Object;)Z");
      mv.visitInsn(POP);
      Label l3 = new Label();
      mv.visitLabel(l3);

      mv.visitVarInsn(ALOAD, 0);
      mv.visitFieldInsn(GETFIELD, proxyName, "locator", "Laleph/dir/DirectoryManager;");
      mv.visitVarInsn(ALOAD, 2);
View Full Code Here

    final int commitIndex = throwableIndex + 1;
    final int exceptionIndex = commitIndex + 1;
    final int resultIndex = exceptionIndex + 1;
    final int controlContextIndex = resultIndex +1;

    Label l0 = new Label();
    Label l1 = new Label();
    Label l2 = new Label();
    mv.visitTryCatchBlock(l0, l1, l2, TransactionException.TRANSACTION_EXCEPTION_INTERNAL)// try{
    Label l3 = new Label();
    mv.visitTryCatchBlock(l0, l1, l3, Type.getInternalName( Throwable.class))// try{
   
    Label l4 = new Label(); // Throwable throwable = null;
    mv.visitLabel(l4);
    mv.visitInsn(ACONST_NULL);
    mv.visitVarInsn(ASTORE, throwableIndex);
   
    Label l5 = getContext(contextIndex); // Context context = ContextDelegator.getInstance();
     
    Label l6 = new Label(); // boolean commit = true;
    mv.visitLabel(l6);
    mv.visitInsn(ICONST_1);
    mv.visitVarInsn(ISTORE, commitIndex);
   
    Label l7 = new Label(); // ... result = null;
    mv.visitLabel(l7);
    if( returnReolver != null)
    {
      mv.visitInsn( returnReolver.nullValueCode());
      mv.visitVarInsn( returnReolver.storeCode(), resultIndex);
    }
   
    Label l8 = new Label(); // for( int i=10 ; ... ; ...)
    mv.visitLabel(l8);
    mv.visitLdcInsn( retries);
    mv.visitVarInsn(ISTORE, indexIndex);
   
    Label l9 = new Label();
    mv.visitLabel(l9);
    Label l10 = new Label();
    mv.visitJumpInsn(GOTO, l10);
   
    Label l11 = new Label(); // context.init(atomicBlockId);
    mv.visitLabel(l11);
    mv.visitVarInsn(ALOAD, contextIndex);
    mv.visitLdcInsn(ATOMIC_BLOCK_COUNTER.getAndIncrement());
    mv.visitMethodInsn(INVOKEINTERFACE, Context.CONTEXT_INTERNAL, "init", "(I)V");
   
    /* result = foo( context, ...)  */
    mv.visitLabel(l0);
    if( !isStatic) // load this id if not static
      mv.visitVarInsn(ALOAD, 0);

    // load the rest of the arguments
    int local = isStatic ? 0 : 1;
    for( int i=0 ; i < argumentReolvers.length ; ++i) {
      mv.visitVarInsn(argumentReolvers[i].loadCode(), local);
      local += argumentReolvers[i].localSize(); // move to the next argument
    }
   
    mv.visitVarInsn(ALOAD, contextIndex); // load the context
   
    if( isStatic)
      mv.visitMethodInsn(INVOKESTATIC, className, methodName, newMethod.getDescriptor()); // ... = foo( ...
    else
      mv.visitMethodInsn(INVOKEVIRTUAL, className, methodName, newMethod.getDescriptor()); // ... = foo( ...

    if( returnReolver != null)
      mv.visitVarInsn(returnReolver.storeCode(), resultIndex); // result = ...
   
    mv.visitLabel(l1);
    Label l12 = new Label();
    mv.visitJumpInsn(GOTO, l12);
    mv.visitLabel(l2);
    mv.visitVarInsn(ASTORE, exceptionIndex);
    Label l13 = new Label();
    mv.visitLabel(l13);
    mv.visitInsn(ICONST_0);
    mv.visitVarInsn(ISTORE, commitIndex);
    Label l14 = new Label();
    mv.visitLabel(l14);
    mv.visitJumpInsn(GOTO, l12);
    mv.visitLabel(l3);
    mv.visitVarInsn(ASTORE, exceptionIndex);
    Label l15 = new Label();
    mv.visitLabel(l15);
    mv.visitVarInsn(ALOAD, exceptionIndex);
    mv.visitVarInsn(ASTORE, throwableIndex);
   
    /*
     * if( commit )
      {
        if( context.commit()){
          if( throwable != null)
            throw (IOException)throwable;
          return result;
        }
      }
      else
      {
        context.rollback();
        commit = true;
      }
     */
    mv.visitLabel(l12); // if( commit )
    mv.visitVarInsn(ILOAD, commitIndex);
    Label l16 = new Label();
    mv.visitJumpInsn(IFEQ, l16);
   
    Label l17 = new Label(); // if( context.commit())
    mv.visitLabel(l17);
    mv.visitVarInsn(ALOAD, contextIndex);
    mv.visitMethodInsn(INVOKEINTERFACE, Context.CONTEXT_INTERNAL, "commit", "()Z");
    Label l18 = new Label();
    mv.visitJumpInsn(IFEQ, l18);
   
    //    if( throwable != null)
    //      throw throwable;
    Label l19 = new Label();
    mv.visitLabel(l19);
    mv.visitVarInsn(ALOAD, throwableIndex);
    Label l20 = new Label();
    mv.visitJumpInsn(IFNULL, l20);
    Label l21 = new Label();
    mv.visitLabel(l21);
    mv.visitVarInsn(ALOAD, throwableIndex);
    mv.visitInsn(ATHROW);
   
    // return
    mv.visitLabel(l20);
    if( returnReolver == null) {
      mv.visitInsn( RETURN); // return;
    }
    else {
      mv.visitVarInsn(returnReolver.loadCode(), resultIndex); // return result;
      mv.visitInsn(returnReolver.returnCode());
    }
   
    mv.visitJumpInsn(GOTO, l18);
   
    // else
    //Add additional code here to support Hyflow
    mv.visitLabel(l16); // context.rollback();
    mv.visitVarInsn(ALOAD, contextIndex);
    mv.visitTypeInsn(INSTANCEOF, "edu/vt/rt/hyflow/core/tm/control/ControlContext");
    Label l90 = new Label();   //If (Control Conext)
    mv.visitJumpInsn(IFEQ, l90);
    Label l91 = new Label();
    mv.visitLabel(l91);    //if
    mv.visitVarInsn(ALOAD, contextIndex);    //TODO: Correct the Index
    mv.visitTypeInsn(CHECKCAST, "edu/vt/rt/hyflow/core/tm/control/ControlContext");
    mv.visitMethodInsn(INVOKEVIRTUAL, "edu/vt/rt/hyflow/core/tm/control/ControlContext", "getContextId", "()Ljava/lang/Long;");
    mv.visitMethodInsn(INVOKESTATIC, "edu/vt/rt/hyflow/core/tm/control/ControlContext", "abort", "(Ljava/lang/Long;)V");
   
    mv.visitLabel(l90);    //else   
    mv.visitVarInsn(ALOAD, contextIndex);
    mv.visitMethodInsn(INVOKEINTERFACE, Context.CONTEXT_INTERNAL, "rollback", "()Z");
    mv.visitInsn(POP);
   
    mv.visitInsn(ICONST_1); // commit = true;
    mv.visitVarInsn(ISTORE, commitIndex);
   
    mv.visitLabel(l18)// for( ... ; i>0 ; --i)
    mv.visitIincInsn(indexIndex, -1);
    mv.visitLabel(l10);
    mv.visitVarInsn(ILOAD, indexIndex);
    mv.visitJumpInsn(IFGT, l11);
   
    // throw new TransactionException("Failed to commit ...");
    Label l23 = throwTransactionException();
   
    /* locals */
    Label l24 = new Label();
    mv.visitLabel(l24);
    mv.visitLocalVariable("throwable", "Ljava/lang/Throwable;", null, l5, l24, throwableIndex);
    mv.visitLocalVariable("context", Context.CONTEXT_DESC, null, l6, l24, contextIndex);
    mv.visitLocalVariable("commit", "Z", null, l7, l24, commitIndex);
    if( returnReolver != null)
View Full Code Here

TOP

Related Classes of org.deuce.objectweb.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.