public abstract class Instruction extends Object implements Cloneable
Modifier and Type | Field and Description |
---|---|
protected Object |
attr |
protected int |
insnIndex |
protected MethodInfo |
mi |
protected int |
position |
Constructor and Description |
---|
Instruction() |
Modifier and Type | Method and Description |
---|---|
void |
addAttr(Object a) |
ObjectList.Iterator |
attrIterator() |
<T> ObjectList.TypedIterator<T> |
attrIterator(Class<T> attrType) |
void |
cleanupTransients()
this method can be overridden if instruction classes have to store
information for instructionExecuted() notifications, and this information
should not be stored persistent to avoid memory leaks (e.g.
|
abstract Instruction |
execute(ThreadInfo ti)
this is the real workhorse
returns next instruction to enter in this thread
<2do> it's unfortunate we roll every side effect into this method, because
it diminishes the value of the 'executeInstruction' notification: all
insns that require some sort of late binding (InvokeVirtual, GetField, ..)
are not yet fully analyzable (e.g.
|
Object |
getAttr()
this returns all of them - use either if you know there will be only
one attribute at a time, or check/process result with ObjectList
|
<T> T |
getAttr(Class<T> attrType)
this only returns the first attr of this type, there can be more
if you don't use client private types or the provided type is too general
|
abstract int |
getByteCode() |
String |
getFileLocation()
this returns a "pathname:line" string
|
String |
getFilePos()
this returns a "filename:line" string
|
int |
getInstructionIndex() |
int |
getLength()
return the length in bytes of this instruction.
|
int |
getLineNumber() |
MethodInfo |
getMethodInfo() |
String |
getMnemonic() |
Instruction |
getNext()
this returns the instruction at the following code insnIndex within the same
method, which might or might not be the next one to enter (branches, overlay calls etc.).
|
Instruction |
getNext(ThreadInfo ti)
this is returning the next Instruction to enter, to be called to obtain
the return value of enter() if this is not a branch insn
Be aware of that we might have had exceptions caused by our execution
(-> lower frame), or we might have had overlaid calls (-> higher frame),
i.e.
|
<T> T |
getNextAttr(Class<T> attrType,
Object prev) |
int |
getPosition() |
Instruction |
getPrev() |
String |
getSourceLine() |
String |
getSourceLocation()
this returns a "class.method(line)" string
|
String |
getSourceOrLocation()
this is for debugging/logging if we always want something back telling
us where this insn came from
|
boolean |
hasAttr() |
boolean |
hasAttr(Class<?> attrType) |
void |
init(MethodInfo mi,
int offset,
int position) |
boolean |
isBackJump()
answer if this is a potential loop closing jump
|
boolean |
isCompleted(ThreadInfo ti)
this is for listeners that process instructionExecuted(), but need to
determine if there was a CG registration, an overlayed direct call
(like clinit) etc.
|
boolean |
isExtendedInstruction()
is this one of our own, artificial insns?
|
boolean |
isFirstInstruction()
is this the first instruction in a method
|
boolean |
isSchedulingRelevant(SystemState ss,
KernelState ks,
ThreadInfo ti) |
void |
removeAttr(Object a) |
void |
replaceAttr(Object oldAttr,
Object newAttr) |
boolean |
requiresClinitExecution(ThreadInfo ti,
ClassInfo ci)
this is a misnomer - we actually push the clinit calls here in case
we need some.
|
void |
setAttr(Object a)
this replaces all of them - use only if you know
- there will be only one attribute at a time
- you obtained the value you set by a previous getXAttr()
- you constructed a multi value list with ObjectList.createList()
|
void |
setContext(String className,
String methodName,
int lineNumber,
int offset) |
void |
setLocation(int insnIdx,
int pos) |
void |
setMethodInfo(MethodInfo mi)
that's used for explicit construction of MethodInfos (synthetic methods)
|
String |
toString() |
Instruction |
typeSafeClone(MethodInfo mi)
this is overridden by any Instruction that use a cache for class or
method to provide a type safe cloning
|
protected int insnIndex
protected int position
protected MethodInfo mi
protected Object attr
public abstract int getByteCode()
public boolean isFirstInstruction()
public boolean isBackJump()
public boolean isExtendedInstruction()
public MethodInfo getMethodInfo()
public void setMethodInfo(MethodInfo mi)
public Instruction getNext()
public int getInstructionIndex()
public int getPosition()
public void setLocation(int insnIdx, int pos)
public int getLength()
public Instruction getPrev()
public boolean isCompleted(ThreadInfo ti)
public void cleanupTransients()
public boolean isSchedulingRelevant(SystemState ss, KernelState ks, ThreadInfo ti)
public abstract Instruction execute(ThreadInfo ti)
public String getMnemonic()
public int getLineNumber()
public String getSourceLine()
public String getSourceOrLocation()
public String getFileLocation()
public String getFilePos()
public String getSourceLocation()
public void init(MethodInfo mi, int offset, int position)
public boolean requiresClinitExecution(ThreadInfo ti, ClassInfo ci)
public Instruction getNext(ThreadInfo ti)
public boolean hasAttr()
public boolean hasAttr(Class<?> attrType)
public Object getAttr()
public void setAttr(Object a)
public void addAttr(Object a)
public void removeAttr(Object a)
public <T> T getAttr(Class<T> attrType)
public ObjectList.Iterator attrIterator()
public <T> ObjectList.TypedIterator<T> attrIterator(Class<T> attrType)
public Instruction typeSafeClone(MethodInfo mi)