Class Instr

java.lang.Object
org.jruby.ir.instructions.Instr
Direct Known Subclasses:
BranchInstr, MultiBranchInstr, NoOperandInstr, NOperandInstr, OneOperandInstr, ResultBaseInstr, TwoOperandInstr

public abstract class Instr extends Object
  • Field Details

    • EMPTY_OPERANDS

      public static final Operand[] EMPTY_OPERANDS
  • Constructor Details

  • Method Details

    • toStringNonOperandArgs

      public String[] toStringNonOperandArgs()
    • encode

      public void encode(IRWriterEncoder e)
    • toString

      public String toString()
      Instructions are meant to be in a machine-readable format so offline tooling can parse the debugging output. The format is: (result_op '=')? instr '(' (operand ',' )* operand? ';' (extra_arg ',')* extra_arg? ')' extra_arg can either be plain value or in a key: value format.
      Overrides:
      toString in class Object
      Returns:
      a String
    • dumpableFields

      public Field[] dumpableFields()
    • getOperation

      public Operation getOperation()
    • hasSideEffects

      public boolean hasSideEffects()
    • canRaiseException

      public boolean canRaiseException()
    • transfersControl

      public boolean transfersControl()
    • computeScopeFlags

      public boolean computeScopeFlags(IRScope scope, EnumSet<IRFlags> flags)
      Does this instruction do anything the scope is interested in?
      Returns:
      true if it modified the scope or set any flags.
    • isDeletable

      public boolean isDeletable()
      Can this instruction be deleted? LVA will preserve instructions based on whether operands (variables) are living but even if there are no living variables then the instruction itself may not be able to be removed during DCE for other reasons (like if it unconditionally has a side-effect)
    • canBeDeletedFromScope

      public boolean canBeDeletedFromScope(FullInterpreterContext fic)
    • markDead

      public void markDead()
    • isDead

      public boolean isDead()
    • getOperands

      public abstract Operand[] getOperands()
    • setOperand

      public abstract void setOperand(int i, Operand operand)
    • getUsedVariables

      public List<Variable> getUsedVariables()
    • renameVars

      public void renameVars(Map<Operand,Operand> renameMap)
    • clone

      public abstract Instr clone(CloneInfo info)
      Clone the instruction for use in an inlining context (either when a scope is inlined into another scope, or when a block has to be cloned because its associated call belongs to an inlined scope). This might renaming variables and labels to eliminate naming conflicts. The implementation might vary on the cloning mode.
      Parameters:
      info - This object manages renaming of variables and labels, handles args and return values.
      Returns:
      a new instruction that can be used in the target scope.
    • cloneOperands

      public Operand[] cloneOperands(CloneInfo info)
    • simplifyOperands

      protected void simplifyOperands(Map<Operand,Operand> valueMap, boolean force)
      This method takes as input a map of operands to their values, and outputs If the value map provides a value for any of the instruction's operands this method is expected to replace the original operands with the simplified values. It is not required that it do so -- code correctness is not compromised by failure to simplify
    • simplifyOperands

      public Operand simplifyOperands(IRScope scope, Map<Operand,Operand> valueMap)
      This method takes as input a map of operands to their values, and outputs the result of this instruction. If the value map provides a value for any of the instruction's operands the expectation is that the operand will be replaced with the simplified value. It is not required that it do so -- code correctness is not compromised by failure to simplify.
      Parameters:
      scope - where this instr exists
      valueMap - Mapping from operands to their simplified values
      Returns:
      simplified result / output of this instruction
    • simplifyInstr

      public Instr simplifyInstr(IRManager manager)
    • interpret

      public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp)
    • interpretAndGetNewIPC

      public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, StaticScope currScope, IRubyObject self, Object[] temp, int ipc)
    • visit

      public void visit(IRVisitor visitor)