Class InstructionSequence
- java.lang.Object
-
- org.jboss.byteman.agent.adapter.cfg.InstructionSequence
-
public class InstructionSequence extends java.lang.Object
Class used to hold a sequence of instructions within a basic block
-
-
Field Summary
Fields Modifier and Type Field Description private int[]
encodedInstructions
data array storing instructions and their operands encoded as ints.private int[]
instructionOffsets
since instructions are encoded with their operands we need an offsets array to identify where each instruction strats, allowing instructions and their operand to be searched forwards and backwardsprivate int
numEncoded
the number of valid entries in array encodedInstructionsprivate int
numInstructions
the number of valid offsets to instructions in array instructionOffsets
-
Constructor Summary
Constructors Constructor Description InstructionSequence()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
add(int insn)
add an instruction to the sequenceint
add(int insn, int arg1)
add an instruction with one encoded argument to the sequenceint
add(int insn, int[] args)
add an instruction with an arbitrary number of encoded arguments to the sequenceint
add(int insn, int arg1, int arg2)
add an instruction with two encoded arguments to the sequenceint
add(int insn, int arg1, int arg2, int arg3)
add an instruction with three encoded arguments to the sequenceint
add(int insn, int arg1, int arg2, int arg3, int arg4)
add an instruction with four encoded arguments to the sequenceprivate void
ensureSpace(int count)
expand the offsets array if necessary to allow room for 1 more instructions with count more argumentsint
get(int i)
return the instruction at the supplied offsetint
getArg(int i, int j)
return a specific encoded argument of a given instructionint
getArgCount(int i)
return the number of encoded arguments of a given instructionint
getType(int i)
return the type of a given instructionint
size()
return the number of instructions in the sequence
-
-
-
Field Detail
-
instructionOffsets
private int[] instructionOffsets
since instructions are encoded with their operands we need an offsets array to identify where each instruction strats, allowing instructions and their operand to be searched forwards and backwards
-
numInstructions
private int numInstructions
the number of valid offsets to instructions in array instructionOffsets
-
encodedInstructions
private int[] encodedInstructions
data array storing instructions and their operands encoded as ints. integer operands are embedded as is operands which are strings (type, const, field etc) must be translated via the names array in the associated cfg. operands which are jump labels must be translated by calling getNthOut() on the associated basic block.
-
numEncoded
private int numEncoded
the number of valid entries in array encodedInstructions
-
-
Method Detail
-
ensureSpace
private void ensureSpace(int count)
expand the offsets array if necessary to allow room for 1 more instructions with count more arguments
-
size
public int size()
return the number of instructions in the sequence- Returns:
- the the number of instructions in the sequence
-
get
public int get(int i)
return the instruction at the supplied offset- Parameters:
i
- the offset- Returns:
- the ith instruction in the sequuence
-
getType
public int getType(int i)
return the type of a given instruction- Parameters:
i
- the instruction index- Returns:
- the ith instruction in the sequuence
-
getArgCount
public int getArgCount(int i)
return the number of encoded arguments of a given instruction- Parameters:
i
- the offset of the instruction- Returns:
- the number of encoded arguments of the ith instruction in the sequuence
-
getArg
public int getArg(int i, int j)
return a specific encoded argument of a given instruction- Parameters:
i
- the offset of the instructionj
- the index of the arguument attached to the instruction- Returns:
- the jth encoded argument of the ith instruction in the sequuence
-
add
public int add(int insn)
add an instruction to the sequence- Parameters:
insn
- the instruction- Returns:
- the index of the newly added instruction
-
add
public int add(int insn, int arg1)
add an instruction with one encoded argument to the sequence- Parameters:
insn
- the instructionarg1
- the argument index- Returns:
- the index of the newly added instruction
-
add
public int add(int insn, int arg1, int arg2)
add an instruction with two encoded arguments to the sequence- Parameters:
insn
- the instructionarg1
- the first argument indexarg2
- the second argument index- Returns:
- the index of the newly added instruction
-
add
public int add(int insn, int arg1, int arg2, int arg3)
add an instruction with three encoded arguments to the sequence- Parameters:
insn
- the instructionarg1
- the first argument indexarg2
- the second argument indexarg3
- the third argument index- Returns:
- the index of the newly added instruction
-
add
public int add(int insn, int arg1, int arg2, int arg3, int arg4)
add an instruction with four encoded arguments to the sequence- Parameters:
insn
- the instructionarg1
- the first argument indexarg2
- the second argument indexarg3
- the third argument indexarg4
- the third argument index- Returns:
- the index of the newly added instruction
-
add
public int add(int insn, int[] args)
add an instruction with an arbitrary number of encoded arguments to the sequence- Parameters:
insn
- the instructionargs
- the arguments- Returns:
- the index of the newly added instruction
-
-