Package org.jruby.ir.instructions
Class Instr
java.lang.Object
org.jruby.ir.instructions.Instr
- Direct Known Subclasses:
BranchInstr
,MultiBranchInstr
,NoOperandInstr
,NOperandInstr
,OneOperandInstr
,ResultBaseInstr
,TwoOperandInstr
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
abstract Instr
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).Operand[]
cloneOperands
(CloneInfo info) boolean
computeScopeFlags
(IRScope scope, EnumSet<IRFlags> flags) Does this instruction do anything the scope is interested in?Field[]
void
abstract Operand[]
boolean
interpret
(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) int
interpretAndGetNewIPC
(ThreadContext context, DynamicScope currDynScope, StaticScope currScope, IRubyObject self, Object[] temp, int ipc) boolean
isDead()
boolean
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)void
markDead()
void
renameVars
(Map<Operand, Operand> renameMap) abstract void
setOperand
(int i, Operand operand) simplifyInstr
(IRManager manager) 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.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.toString()
Instructions are meant to be in a machine-readable format so offline tooling can parse the debugging output.String[]
boolean
void
-
Field Details
-
EMPTY_OPERANDS
-
-
Constructor Details
-
Instr
-
-
Method Details
-
toStringNonOperandArgs
-
encode
-
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. -
dumpableFields
-
getOperation
-
hasSideEffects
public boolean hasSideEffects() -
canRaiseException
public boolean canRaiseException() -
transfersControl
public boolean transfersControl() -
computeScopeFlags
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
-
markDead
public void markDead() -
isDead
public boolean isDead() -
getOperands
-
setOperand
-
getUsedVariables
-
renameVars
-
clone
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
-
simplifyOperands
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
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 existsvalueMap
- Mapping from operands to their simplified values- Returns:
- simplified result / output of this instruction
-
simplifyInstr
-
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
-