Package org.apache.drill.exec.compile.bytecode.ValueHolderIden

Examples of org.apache.drill.exec.compile.bytecode.ValueHolderIden.ValueHolderSub


  @Override
  public void visitTypeInsn(int opcode, String type) {
    ReplacingBasicValue r = getReturn();
    if (r != null) {
      ValueHolderSub sub = r.getIden().getHolderSub(adder);
      oldToNew.put(r.getIndex(), sub);
    } else {
      super.visitTypeInsn(opcode, type);
    }
  }
View Full Code Here


  @Override
  public void visitVarInsn(int opcode, int var) {
    ReplacingBasicValue v;
    if (opcode == Opcodes.ASTORE && (v = popCurrent(true)) != null) {
      if (!v.isFunctionReturn) {
        ValueHolderSub from = oldToNew.get(v.getIndex());

        ReplacingBasicValue current = local(var);
        // if local var is set, then transfer to it to the existing holders in the local position.
        if (current != null) {
          if (oldToNew.get(current.getIndex()).iden() == from.iden()) {
            int targetFirst = oldToNew.get(current.index).first();
            from.transfer(this, targetFirst);
            return;
          }
        }

        // if local var is not set, then check map to see if existing holders are mapped to local var.
        if (oldLocalToFirst.containsKey(var)) {
          ValueHolderSub sub = oldToNew.get(oldLocalToFirst.lget());
          if (sub.iden() == from.iden()) {
            // if they are, then transfer to that.
            from.transfer(this, oldToNew.get(oldLocalToFirst.lget()).first());
            return;
          }
        }


        // map from variables to global space for future use.
        oldLocalToFirst.put(var, v.getIndex());

      } else {
        // this is storage of a function return, we need to map the fields to the holder spots.
        int first;
        if (oldLocalToFirst.containsKey(var)) {
          first = oldToNew.get(oldLocalToFirst.lget()).first();
          v.iden.transferToLocal(adder, first);
        } else {
          first = v.iden.createLocalAndTrasfer(adder);
        }
        ValueHolderSub from = v.iden.getHolderSubWithDefinedLocals(first);
        oldToNew.put(v.getIndex(), from);
        v.disableFunctionReturn();
      }

    } else if (opcode == Opcodes.ALOAD && (v = getReturn()) != null) {
View Full Code Here

          super.visitFieldInsn(opcode, owner, name, desc);
          return;
        } else {
          // we are trying to store a replaced variable in an external context, we need to generate an instance and
          // transfer it out.
          ValueHolderSub sub = oldToNew.get(v.getIndex());
          sub.transferToExternal(adder, owner, name, desc);
          return;
        }
      }

    case Opcodes.GETFIELD:
      // pop again.
      v = popCurrent();
      if (v != null) {
        // super.visitFieldInsn(opcode, owner, name, desc);
        ValueHolderSub sub = oldToNew.get(v.getIndex());
        sub.addInsn(name, this, opcode);
        return;
      }
    }

    super.visitFieldInsn(opcode, owner, name, desc);
View Full Code Here

  @Override
  public void visitTypeInsn(int opcode, String type) {
    ReplacingBasicValue r = getReturn();
    if (r != null) {
      ValueHolderSub sub = r.getIden().getHolderSub(adder);
      oldToNew.put(r.getIndex(), sub);
    } else {
      super.visitTypeInsn(opcode, type);
    }
  }
View Full Code Here

  @Override
  public void visitVarInsn(int opcode, int var) {
    ReplacingBasicValue v;
    if(opcode == Opcodes.ASTORE && (v = popCurrent(true)) != null){
      if(!v.isFunctionReturn){
        ValueHolderSub from = oldToNew.get(v.getIndex());

        ReplacingBasicValue current = local(var);
        // if local var is set, then transfer to it to the existing holders in the local position.
        if(current != null){
          if(oldToNew.get(current.getIndex()).iden() == from.iden()){
            int targetFirst = oldToNew.get(current.index).first();
            from.transfer(this, targetFirst);
            return;
          }
        }

        // if local var is not set, then check map to see if existing holders are mapped to local var.
        if(oldLocalToFirst.containsKey(var)){
          ValueHolderSub sub = oldToNew.get(oldLocalToFirst.lget());
          if(sub.iden() == from.iden()){
            // if they are, then transfer to that.
            from.transfer(this, oldToNew.get(oldLocalToFirst.lget()).first());
            return;
          }
        }


        // map from variables to global space for future use.
        oldLocalToFirst.put(var, v.getIndex());

      }else{
        // this is storage of a function return, we need to map the fields to the holder spots.
        int first;
        if(oldLocalToFirst.containsKey(var)){
          first = oldToNew.get(oldLocalToFirst.lget()).first();
          v.iden.transferToLocal(adder, first);
        }else{
          first = v.iden.createLocalAndTrasfer(adder);
        }
        ValueHolderSub from = v.iden.getHolderSubWithDefinedLocals(first);
        oldToNew.put(v.getIndex(), from);
        v.disableFunctionReturn();
      }

    }else if(opcode == Opcodes.ALOAD && (v = getReturn()) != null){
View Full Code Here

          super.visitFieldInsn(opcode, owner, name, desc);
          return;
        }else{
          // we are trying to store a replaced variable in an external context, we need to generate an instance and
          // transfer it out.
          ValueHolderSub sub = oldToNew.get(v.getIndex());
          sub.transferToExternal(adder, owner, name, desc);
          return;
        }
      }

    case Opcodes.GETFIELD:
      // pop again.
      v = popCurrent();
      if (v != null) {
        // super.visitFieldInsn(opcode, owner, name, desc);
        ValueHolderSub sub = oldToNew.get(v.getIndex());
        sub.addInsn(name, this, opcode);
        return;
      }


    }
View Full Code Here

TOP

Related Classes of org.apache.drill.exec.compile.bytecode.ValueHolderIden.ValueHolderSub

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.