Example #1
0
 /**
  * Create an instruction of the Multianewarray instruction format.
  *
  * @param o the instruction's operator
  * @param Result the instruction's Result operand
  * @param Type the instruction's Type operand
  * @param numVarOps the number of variable length operands that will be stored in the insruction.
  * @return the newly created Multianewarray instruction
  */
 public static OPT_Instruction create(
     OPT_Operator o, OPT_RegisterOperand Result, OPT_TypeOperand Type, int numVarOps) {
   if (VM_Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Multianewarray");
   OPT_Instruction i = new OPT_Instruction(o, Math.max(2 + numVarOps, MIN_OPERAND_ARRAY_LENGTH));
   i.putOperand(0, Result);
   i.putOperand(1, Type);
   return i;
 }
Example #2
0
  /**
   * Mutate the argument instruction into an instruction of the Multianewarray instruction format
   * having the specified operator and operands.
   *
   * @param i the instruction to mutate
   * @param o the instruction's operator
   * @param Result the instruction's Result operand
   * @param Type the instruction's Type operand
   * @param numVarOps the number of variable length operands that will be stored in the insruction.
   * @return the mutated instruction
   */
  public static OPT_Instruction mutate(
      OPT_Instruction i,
      OPT_Operator o,
      OPT_RegisterOperand Result,
      OPT_TypeOperand Type,
      int numVarOps) {
    if (VM_Configuration.ExtremeAssertions && !conforms(o)) fail(o, "Multianewarray");
    if (2 + numVarOps > MIN_OPERAND_ARRAY_LENGTH) i.resizeNumberOfOperands(2 + numVarOps);

    i.operator = o;
    i.putOperand(0, Result);
    i.putOperand(1, Type);
    return i;
  }
Example #3
0
  /**
   * Build a BURS Tree for each OPT_Instruction. Complete BURS trees by adding leaf nodes as needed,
   * and creating tree edges by calling insertChild1() or insertChild2() This step is also where we
   * introduce intermediate tree nodes for any LIR instruction that has > 2 "real" operands e.g., a
   * CALL.
   *
   * @param s The instruction for which a tree must be built
   */
  private OPT_BURS_TreeNode buildTree(OPT_Instruction s) {

    OPT_BURS_TreeNode root = new OPT_BURS_TreeNode(new OPT_DepGraphNode(s));
    OPT_BURS_TreeNode cur = root;
    for (OPT_OperandEnumeration uses = s.getUses(); uses.hasMoreElements(); ) {
      OPT_Operand op = uses.next();
      if (op == null) continue;

      op.clear();
      // Set child = OPT_BURS_TreeNode for operand op
      OPT_BURS_TreeNode child;
      if (op instanceof OPT_RegisterOperand) {
        if (op.asRegister().register.isValidation()) continue;
        child = Register;
      } else if (op instanceof OPT_IntConstantOperand) {
        child = new OPT_BURS_IntConstantTreeNode(((OPT_IntConstantOperand) op).value);
      } else if (op instanceof OPT_LongConstantOperand) {
        child = LongConstant;
      } else if (op instanceof OPT_AddressConstantOperand) {
        child = AddressConstant;
      } else if (op instanceof OPT_BranchOperand && s.isCall()) {
        child = BranchTarget;
        // -#if RVM_WITH_OSR
      } else if (op instanceof OPT_InlinedOsrTypeInfoOperand && s.isYieldPoint()) {
        child = NullTreeNode;
        // -#endif
      } else {
        continue;
      }

      // Attach child as child of cur_parent in correct position
      if (cur.child1 == null) {
        cur.child1 = child;
      } else if (cur.child2 == null) {
        cur.child2 = child;
      } else {
        // Create auxiliary node so as to represent
        // a instruction with arity > 2 in a binary tree.
        OPT_BURS_TreeNode child1 = cur.child2;
        OPT_BURS_TreeNode aux = new OPT_BURS_TreeNode(OTHER_OPERAND_opcode);
        cur.child2 = aux;
        cur = aux;
        cur.child1 = child1;
        cur.child2 = child;
      }
    }

    // patch for calls & return
    switch (s.getOpcode()) {
      case CALL_opcode:
      case SYSCALL_opcode:
        // -#if RVM_WITH_OSR
      case YIELDPOINT_OSR_opcode:
        // -#endif
        if (cur.child2 == null) cur.child2 = NullTreeNode;
        // fall through
      case RETURN_opcode:
        if (cur.child1 == null) cur.child1 = NullTreeNode;
    }
    return root;
  }
Example #4
0
 /**
  * Does the argument instruction have a non-null operand named Result?
  *
  * @param i the instruction to access.
  * @return <code>true</code> if the instruction has an non-null operand named Result or <code>
  *     false</code> if it does not.
  */
 public static boolean hasResult(OPT_Instruction i) {
   if (VM_Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
   return i.getOperand(0) != null;
 }
Example #5
0
 /**
  * Set the operand called Result in the argument instruction to the argument operand. The operand
  * will now point to the argument instruction as its containing instruction.
  *
  * @param i the instruction in which to store the operand
  * @param Result the operand to store
  */
 public static void setResult(OPT_Instruction i, OPT_RegisterOperand Result) {
   if (VM_Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
   i.putOperand(0, Result);
 }
Example #6
0
 /**
  * Get the operand called Result from the argument instruction clearing its instruction pointer.
  * The returned operand will not point to any containing instruction.
  *
  * @param i the instruction to fetch the operand from
  * @return the operand called Result
  */
 public static OPT_RegisterOperand getClearResult(OPT_Instruction i) {
   if (VM_Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
   return (OPT_RegisterOperand) i.getClearOperand(0);
 }
Example #7
0
 /**
  * Change the number of Dimensions that may be stored in the argument instruction to numVarOps.
  *
  * @param i the instruction to access
  * @param numVarOps the new number of variable operands called Dimensions that may be stored in
  *     the instruction
  */
 public static void resizeNumberOfDimensions(OPT_Instruction i, int numVarOps) {
   if (VM_Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
   if (2 + numVarOps > MIN_OPERAND_ARRAY_LENGTH) i.resizeNumberOfOperands(2 + numVarOps);
   else for (int j = 2 + numVarOps; j < MIN_OPERAND_ARRAY_LENGTH; j++) i.putOperand(j, null);
 }
Example #8
0
 /**
  * Does the argument instruction have any operands named Dimension?
  *
  * @param i the instruction to access.
  * @return <code>true</code> if the instruction has operands named Dimension or <code>false</code>
  *     if it does not.
  */
 public static boolean hasDimensions(OPT_Instruction i) {
   if (VM_Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
   return i.getNumberOfOperands() - 2 > 0 && i.getOperand(2) != null;
 }
Example #9
0
 /**
  * How many variable-length operands called Dimensions does the argument instruction have?
  *
  * @param i the instruction to access
  * @return the number of operands called Dimensions the instruction has
  */
 public static int getNumberOfDimensions(OPT_Instruction i) {
   if (VM_Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
   return i.getNumberOfOperands() - 2;
 }
Example #10
0
 /**
  * Does the argument instruction have a non-null k'th operand named Dimension?
  *
  * @param i the instruction to access.
  * @param k the index of the operand.
  * @return <code>true</code> if the instruction has an non-null k'th operand named Dimension or
  *     <code>false</code> if it does not.
  */
 public static boolean hasDimension(OPT_Instruction i, int k) {
   if (VM_Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
   return i.getOperand(2 + k) != null;
 }
Example #11
0
 /**
  * Set the k'th operand called Dimension in the argument instruction to the argument operand. The
  * operand will now point to the argument instruction as its containing instruction.
  *
  * @param i the instruction in which to store the operand
  * @param k the index of the operand
  * @param o the operand to store
  */
 public static void setDimension(OPT_Instruction i, int k, OPT_Operand o) {
   if (VM_Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
   i.putOperand(2 + k, o);
 }
Example #12
0
 /**
  * Get the k'th operand called Dimension from the argument instruction clearing its instruction
  * pointer. The returned operand will not point to any containing instruction.
  *
  * @param i the instruction to fetch the operand from
  * @param k the index of the operand
  * @return the k'th operand called Dimension
  */
 public static OPT_Operand getClearDimension(OPT_Instruction i, int k) {
   if (VM_Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
   return (OPT_Operand) i.getClearOperand(2 + k);
 }
Example #13
0
 /**
  * Set the operand called Type in the argument instruction to the argument operand. The operand
  * will now point to the argument instruction as its containing instruction.
  *
  * @param i the instruction in which to store the operand
  * @param Type the operand to store
  */
 public static void setType(OPT_Instruction i, OPT_TypeOperand Type) {
   if (VM_Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
   i.putOperand(1, Type);
 }
Example #14
0
 /**
  * Get the operand called Type from the argument instruction. Note that the returned operand will
  * still point to its containing instruction.
  *
  * @param i the instruction to fetch the operand from
  * @return the operand called Type
  */
 public static OPT_TypeOperand getType(OPT_Instruction i) {
   if (VM_Configuration.ExtremeAssertions && !conforms(i)) fail(i, "Multianewarray");
   return (OPT_TypeOperand) i.getOperand(1);
 }