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, waitgetByteCodeprotected int insnIndex
protected int position
protected MethodInfo mi
protected java.lang.Object attr
public Instruction asInstruction()
InstructionInterfaceasInstruction in interface InstructionInterfacepublic void setContext(java.lang.String className,
java.lang.String methodName,
int lineNumber,
int offset)
public boolean isFirstInstruction()
isFirstInstruction in interface InstructionInterfacepublic boolean isBackJump()
isBackJump in interface InstructionInterfacepublic boolean isMonitorEnterPrologue()
public boolean isExtendedInstruction()
isExtendedInstruction in interface InstructionInterfacepublic MethodInfo getMethodInfo()
getMethodInfo in interface InstructionInterfacepublic void setMethodInfo(MethodInfo mi)
public Instruction getNext()
getNext in interface InstructionInterfacepublic int getInstructionIndex()
getInstructionIndex in interface InstructionInterfacepublic int getPosition()
getPosition in interface InstructionInterfacepublic void setLocation(int insnIdx,
int pos)
public int getLength()
getLength in interface InstructionInterfacepublic Instruction getPrev()
getPrev in interface InstructionInterfacepublic boolean isCompleted(ThreadInfo ti)
isCompleted in interface InstructionInterfacepublic void cleanupTransients()
public boolean isSchedulingRelevant(SystemState ss, KernelState ks, ThreadInfo ti)
public abstract Instruction execute(ThreadInfo ti)
execute in interface InstructionInterfacepublic java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toPostExecString()
toPostExecString in interface InstructionInterfacepublic java.lang.String getMnemonic()
getMnemonic in interface InstructionInterfacepublic int getLineNumber()
getLineNumber in interface InstructionInterfacepublic java.lang.String getSourceLine()
getSourceLine in interface InstructionInterfacepublic java.lang.String getSourceOrLocation()
public java.lang.String getFileLocation()
getFileLocation in interface InstructionInterfacepublic java.lang.String getFilePos()
getFilePos in interface InstructionInterfacepublic java.lang.String getSourceLocation()
getSourceLocation in interface InstructionInterfacepublic void init(MethodInfo mi, int offset, int position)
public boolean requiresClinitExecution(ThreadInfo ti, ClassInfo ci)
public Instruction getNext(ThreadInfo ti)
getNext in interface InstructionInterfacepublic boolean hasAttr()
hasAttr in interface Attributablepublic boolean hasAttr(java.lang.Class<?> attrType)
hasAttr in interface Attributablepublic java.lang.Object getAttr()
getAttr in interface Attributablepublic void setAttr(java.lang.Object a)
setAttr in interface Attributablepublic void addAttr(java.lang.Object a)
addAttr in interface Attributablepublic void removeAttr(java.lang.Object a)
removeAttr in interface Attributablepublic void replaceAttr(java.lang.Object oldAttr,
java.lang.Object newAttr)
replaceAttr in interface Attributablepublic <T> T getAttr(java.lang.Class<T> attrType)
getAttr in interface Attributablepublic <T> T getNextAttr(java.lang.Class<T> attrType,
java.lang.Object prev)
getNextAttr in interface Attributablepublic ObjectList.Iterator attrIterator()
attrIterator in interface Attributablepublic <T> ObjectList.TypedIterator<T> attrIterator(java.lang.Class<T> attrType)
attrIterator in interface Attributablepublic Instruction typeSafeClone(MethodInfo mi)