public class BytecodeTraverser extends Object
This class only intends to provide type information for on-stack replacement, which needs to know the type of a value. This class can only tells basic type information such as : REFERENCE, LONG, DOUBLE, FLOAT, INT, and ReturnAddress. Not like GCMap which tells GC a value is REFERENCE or NON-REFERENCE we also want to know it is INT or DOUBLE, and takes two words value or one word.
The produced type information has to be adjusted by consulting GC maps because two different types may merge at one program point (REF and non-REF types). Bytecode verifier will make the type info undefined in that case. But this class won't know. So the caller should check the GC map to validate a REF type variable.
More or less, this class needs to do the same work as a bytecode verifier, which tells the type and size of each locals and stacks. The JSR/RET instructions pose the difficulty to our case. However, we can assume the bytecode is verified. We use following assumptions:
Modifier and Type | Field and Description |
---|---|
private int |
addr |
private BytecodeStream |
bytecodes |
private boolean |
ignoreGotos |
private byte[] |
ltypes |
private int[] |
retaddr |
private byte[] |
stypes |
private boolean |
TRACE |
private byte[] |
visitedpc |
Constructor and Description |
---|
BytecodeTraverser() |
Modifier and Type | Method and Description |
---|---|
boolean |
computeLocalStackTypes(NormalMethod method,
int bcpoint)
Computes types of local variable and stack slots at an interesting point
for future querying.
|
void |
computeStackHeights(NormalMethod method,
BytecodeStream bcodes,
int[] stackHeights,
boolean adjustExptable) |
byte[] |
getLocalTypes()
Returns an array of type information of locals at the registered
program point.
|
private byte |
getReturnCodeFromSignature(String sig) |
byte[] |
getStackTypes()
Returns an array of type information of stacks at a program
point.
|
void |
prologueStackHeights(NormalMethod method,
BytecodeStream bcodes,
int[] stackHeights)
Compute stack heights of bytecode stream (used for osr prologue)
|
private boolean |
scanBlocks(NormalMethod method,
BytecodeStream bytecodes,
boolean doDFS,
int pcs,
byte[] ltypes,
byte[] stypes,
int startpc,
TypeStack S,
int[] stackHeights) |
private int[] retaddr
private int addr
private byte[] visitedpc
private final boolean TRACE
private boolean ignoreGotos
private BytecodeStream bytecodes
private byte[] ltypes
private byte[] stypes
public BytecodeTraverser()
public boolean computeLocalStackTypes(NormalMethod method, int bcpoint)
method
- whose bytecode to be queriedbcpoint
- the bytecode index which is the interesting point
at the mean time, we only support one PC.public byte[] getLocalTypes()
public byte[] getStackTypes()
public void computeStackHeights(NormalMethod method, BytecodeStream bcodes, int[] stackHeights, boolean adjustExptable)
public void prologueStackHeights(NormalMethod method, BytecodeStream bcodes, int[] stackHeights)
method
- the method that's subject to OSRbcodes
- the bytecode stream for the OSR prologuestackHeights
- the original stack heights computed by the baseline
compilerprivate byte getReturnCodeFromSignature(String sig)
private boolean scanBlocks(NormalMethod method, BytecodeStream bytecodes, boolean doDFS, int pcs, byte[] ltypes, byte[] stypes, int startpc, TypeStack S, int[] stackHeights)