public abstract class Instruction extends java.lang.Object implements java.lang.Cloneable, InstructionInterface
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
attr |
protected int |
insnIndex |
protected MethodInfo |
mi |
protected int |
position |
Constructor and Description |
---|
Instruction() |
Modifier and Type | Method and Description |
---|---|
void |
addAttr(java.lang.Object a) |
Instruction |
asInstruction()
this is for cases where we need the Instruction type.
|
ObjectList.Iterator |
attrIterator() |
<T> ObjectList.TypedIterator<T> |
attrIterator(java.lang.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.
|
java.lang.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(java.lang.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
|
java.lang.String |
getFileLocation()
this returns a "pathname:line" string
|
java.lang.String |
getFilePos()
this returns a "filename:line" string
|
int |
getInstructionIndex() |
int |
getLength()
return the length in bytes of this instruction.
|
int |
getLineNumber() |
MethodInfo |
getMethodInfo() |
java.lang.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(java.lang.Class<T> attrType,
java.lang.Object prev) |
int |
getPosition() |
Instruction |
getPrev() |
java.lang.String |
getSourceLine() |
java.lang.String |
getSourceLocation()
this returns a "class.method(line)" string
|
java.lang.String |
getSourceOrLocation()
this is for debugging/logging if we always want something back telling
us where this insn came from
|
boolean |
hasAttr() |
boolean |
hasAttr(java.lang.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 |
isMonitorEnterPrologue()
is this instruction part of a monitorenter code pattern
|
boolean |
isSchedulingRelevant(SystemState ss,
KernelState ks,
ThreadInfo ti) |
void |
removeAttr(java.lang.Object a) |
void |
replaceAttr(java.lang.Object oldAttr,
java.lang.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(java.lang.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(java.lang.String className,
java.lang.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)
|
java.lang.String |
toPostExecString()
this can contain additional info that was gathered/cached during execution
|
java.lang.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
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getByteCode
protected int insnIndex
protected int position
protected MethodInfo mi
protected java.lang.Object attr
public Instruction asInstruction()
InstructionInterface
asInstruction
in interface InstructionInterface
public void setContext(java.lang.String className, java.lang.String methodName, int lineNumber, int offset)
public boolean isFirstInstruction()
isFirstInstruction
in interface InstructionInterface
public boolean isBackJump()
isBackJump
in interface InstructionInterface
public boolean isMonitorEnterPrologue()
public boolean isExtendedInstruction()
isExtendedInstruction
in interface InstructionInterface
public MethodInfo getMethodInfo()
getMethodInfo
in interface InstructionInterface
public void setMethodInfo(MethodInfo mi)
public Instruction getNext()
getNext
in interface InstructionInterface
public int getInstructionIndex()
getInstructionIndex
in interface InstructionInterface
public int getPosition()
getPosition
in interface InstructionInterface
public void setLocation(int insnIdx, int pos)
public int getLength()
getLength
in interface InstructionInterface
public Instruction getPrev()
getPrev
in interface InstructionInterface
public boolean isCompleted(ThreadInfo ti)
isCompleted
in interface InstructionInterface
public void cleanupTransients()
public boolean isSchedulingRelevant(SystemState ss, KernelState ks, ThreadInfo ti)
public abstract Instruction execute(ThreadInfo ti)
execute
in interface InstructionInterface
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toPostExecString()
toPostExecString
in interface InstructionInterface
public java.lang.String getMnemonic()
getMnemonic
in interface InstructionInterface
public int getLineNumber()
getLineNumber
in interface InstructionInterface
public java.lang.String getSourceLine()
getSourceLine
in interface InstructionInterface
public java.lang.String getSourceOrLocation()
public java.lang.String getFileLocation()
getFileLocation
in interface InstructionInterface
public java.lang.String getFilePos()
getFilePos
in interface InstructionInterface
public java.lang.String getSourceLocation()
getSourceLocation
in interface InstructionInterface
public void init(MethodInfo mi, int offset, int position)
public boolean requiresClinitExecution(ThreadInfo ti, ClassInfo ci)
public Instruction getNext(ThreadInfo ti)
getNext
in interface InstructionInterface
public boolean hasAttr()
hasAttr
in interface Attributable
public boolean hasAttr(java.lang.Class<?> attrType)
hasAttr
in interface Attributable
public java.lang.Object getAttr()
getAttr
in interface Attributable
public void setAttr(java.lang.Object a)
setAttr
in interface Attributable
public void addAttr(java.lang.Object a)
addAttr
in interface Attributable
public void removeAttr(java.lang.Object a)
removeAttr
in interface Attributable
public void replaceAttr(java.lang.Object oldAttr, java.lang.Object newAttr)
replaceAttr
in interface Attributable
public <T> T getAttr(java.lang.Class<T> attrType)
getAttr
in interface Attributable
public <T> T getNextAttr(java.lang.Class<T> attrType, java.lang.Object prev)
getNextAttr
in interface Attributable
public ObjectList.Iterator attrIterator()
attrIterator
in interface Attributable
public <T> ObjectList.TypedIterator<T> attrIterator(java.lang.Class<T> attrType)
attrIterator
in interface Attributable
public Instruction typeSafeClone(MethodInfo mi)