Top Fields Constructors Methods
org.jruby.ir.instructions

public abstract Class Instr

extends Object
Class Inheritance
Known Direct Subclasses
org.jruby.ir.instructions.MultiBranchInstr, org.jruby.ir.instructions.NoOperandInstr, org.jruby.ir.instructions.NOperandInstr, org.jruby.ir.instructions.OneOperandInstr, org.jruby.ir.instructions.ResultBaseInstr, org.jruby.ir.instructions.TwoOperandInstr, org.jruby.ir.instructions.BranchInstr
Imports
org.jruby.RubyInstanceConfig, org.jruby.ir.IRFlags, .IRManager, .IRScope, .IRVisitor, .Interp, .Operation, org.jruby.ir.interpreter.FullInterpreterContext, org.jruby.ir.operands.LocalVariable, .Operand, .Variable, org.jruby.ir.persistence.IRWriterEncoder, org.jruby.ir.transformations.inlining.CloneInfo, org.jruby.parser.StaticScope, org.jruby.runtime.DynamicScope, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, java.lang.reflect.Field, .Modifier, java.util.ArrayList, .EnumSet, .List, .Map

Field Summary

Modifier and TypeField and Description
private static final ClassValue<Field[]>
dumpableFields

A ClassValue wrapping an array of dumpable Field references for a given Instr type.

private static final Field[]
public static final Operand[]
private boolean
private final transient Operation

Constructor Summary

AccessConstructor and Description
public
Instr(Operation operation)

Method Summary

Modifier and TypeMethod and Description
public boolean
public boolean
public abstract Instr

Returns:

a new instruction that can be used in the target scope.
clone
(CloneInfo
This object manages renaming of variables and labels, handles args and return values.
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).

public Operand[]
public boolean

Returns:

true if it modified the scope or set any flags.
computeScopeFlags
(IRScope scope, EnumSet<IRFlags> flags)

Does this instruction do anything the scope is interested in?

public Field[]
public void
public abstract Operand[]
public Operation
public List<Variable>
public boolean
public Object
interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp)

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

public boolean
public boolean
isDeletable()

Can this instruction be deleted?

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

public Instr
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.

public Operand

Returns:

simplified result / output of this instruction
simplifyOperands
(IRScope
where this instr exists
scope
,
Map<Operand, Operand>
Mapping from operands to their simplified values
valueMap
)

This method takes as input a map of operands to their values, and outputs the result of this instruction.

private StringBuilder
public String

Returns:

a String
toString
()

Overrides java.lang.Object.toString.

Instructions are meant to be in a machine-readable format so offline tooling can parse the debugging output.

public String[]
public boolean
public void
visit(IRVisitor visitor)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

dumpableFieldsback to summary
private static final ClassValue<Field[]> dumpableFields

A ClassValue wrapping an array of dumpable Field references for a given Instr type.

EMPTY_FIELD_ARRAYback to summary
private static final Field[] EMPTY_FIELD_ARRAY
EMPTY_OPERANDSback to summary
public static final Operand[] EMPTY_OPERANDS
isDeadback to summary
private boolean isDead
operationback to summary
private final transient Operation operation

Constructor Detail

Instrback to summary
public Instr(Operation operation)

Method Detail

canBeDeletedFromScopeback to summary
public boolean canBeDeletedFromScope(FullInterpreterContext fic)
canRaiseExceptionback to summary
public boolean canRaiseException()
cloneback to summary
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:CloneInfo

This object manages renaming of variables and labels, handles args and return values.

Returns:Instr

a new instruction that can be used in the target scope.

cloneOperandsback to summary
public Operand[] cloneOperands(CloneInfo info)
computeScopeFlagsback to summary
public boolean computeScopeFlags(IRScope scope, EnumSet<IRFlags> flags)

Does this instruction do anything the scope is interested in?

Returns:boolean

true if it modified the scope or set any flags.

dumpableFieldsback to summary
public Field[] dumpableFields()
encodeback to summary
public void encode(IRWriterEncoder e)
getOperandsback to summary
public abstract Operand[] getOperands()
getOperationback to summary
public Operation getOperation()
Annotations
@Interp
getUsedVariablesback to summary
public List<Variable> getUsedVariables()
hasSideEffectsback to summary
public boolean hasSideEffects()
interpretback to summary
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp)
Annotations
@Interp
interpretAndGetNewIPCback to summary
public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, StaticScope currScope, IRubyObject self, Object[] temp, int ipc)
Annotations
@Interp
isDeadback to summary
public boolean isDead()
Annotations
@Interp
isDeletableback to summary
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)

markDeadback to summary
public void markDead()
renameVarsback to summary
public void renameVars(Map<Operand, Operand> renameMap)
setOperandback to summary
public abstract void setOperand(int i, Operand operand)
simplifyInstrback to summary
public Instr simplifyInstr(IRManager manager)
simplifyOperandsback to summary
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

simplifyOperandsback to summary
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:IRScope

where this instr exists

valueMap:Map<Operand, Operand>

Mapping from operands to their simplified values

Returns:Operand

simplified result / output of this instruction

toArgListback to summary
private StringBuilder toArgList(StringBuilder buf, Object[] args)
toStringback to summary
public String toString()

Overrides java.lang.Object.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.

Returns:String

a String

Annotations
@Override
toStringNonOperandArgsback to summary
public String[] toStringNonOperandArgs()
transfersControlback to summary
public boolean transfersControl()
visitback to summary
public void visit(IRVisitor visitor)