Package ghidra.pcode.emu.jit.gen.var
Interface ValGen<V extends JitVal>
- Type Parameters:
V
- the class op p-code value node in the use-def graph
- All Known Subinterfaces:
LocalVarGen<V>
,MemoryVarGen<V>
,VarGen<V>
- All Known Implementing Classes:
ConstValGen
,DirectMemoryVarGen
,FailValGen
,InputVarGen
,LocalOutVarGen
,MemoryOutVarGen
,MissingVarGen
public interface ValGen<V extends JitVal>
The bytecode generator for a specific value (operand) access.
The JitCodeGenerator
selects the correct generator for each input operand using
lookup(JitVal)
and each output operand VarGen.lookup(JitVar)
. The op generator
has already retrieved the JitOp
whose operands are of the JitVal
class.
Varnode Type | Use-Def Type | Generator Type | Read Bytecodes / Methods | Write Bytecodes / Methods |
---|---|---|---|---|
constant |
JitConstVal |
ConstValGen |
ldc |
|
unique ,register |
JitInputVar ,JitLocalOutVar ,JitMissingVar |
InputVarGen ,LocalOutVarGen |
See JitType.SimpleJitType.opcodeLoad() :iload , lload , fload ,
dload |
See JitType.SimpleJitType.opcodeStore() :istore , lstore , fstore ,
dstore |
memory |
JitDirectMemoryVar ,JitMemoryOutVar |
DirectMemoryVarGen ,MemoryOutVarGen |
readInt* ,
readLong* , etc. |
writeInt* ,
writeLong* , etc. |
*indirect | JitIndirectMemoryVar |
None |
- See Also:
- Implementation Notes:
- Memory-mapped registers are treated as
memory
varnodes, notregister
, because they are shared by all threads. TODO: AJitConfiguration
flag that says "the machine is single threaded!" so we can optimize memory accesses in the same manner we do registers and uniques., There are remnants of experiments and fragments in anticipation of multi-precision integer variables. These are not supported yet, but some of the components for mp-int support are used in degenerate form to support normal ints. Many of these components have "Mp
" in the name., The memory variables are all generally handled as if ints, and thentype conversions
are applied if necessary to access them as floating point.,JitMissingVar
is a special case ofunique
andregister
variable where the definition could not be found. It is used as an intermediate result theJitDataFlowModel
, but should be converted to aJitOutVar
defined by aJitPhiOp
before it enters the use-def graph.,JitIndirectMemoryVar
is a singleton dummy used in theJitDataFlowModel
. It is immediately thrown away, as indirect memory access is instead modeled byJitLoadOp
andJitStoreOp
.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
generateValInitCode
(JitCodeGenerator gen, V v, org.objectweb.asm.MethodVisitor iv) Prepare any class-level items required to use this variablegenerateValReadCode
(JitCodeGenerator gen, V v, JitTypeBehavior typeReq, org.objectweb.asm.MethodVisitor rv) Read the value onto the stacklookup
(V v) Lookup the generator for a given p-code value use-def node
-
Method Details
-
lookup
Lookup the generator for a given p-code value use-def node- Type Parameters:
V
- the class of the value- Parameters:
v
- theJitVal
whose generator to look up- Returns:
- the generator
-
generateValInitCode
Prepare any class-level items required to use this variableFor example, if this represents a direct memory variable, then this can prepare a reference to the portion of the state involved, allowing it to access it readily.
- Parameters:
gen
- the code generatorv
- the valueiv
- the constructor visitor
-
generateValReadCode
JitType generateValReadCode(JitCodeGenerator gen, V v, JitTypeBehavior typeReq, org.objectweb.asm.MethodVisitor rv) Read the value onto the stack- Parameters:
gen
- the code generatorv
- the value to readtypeReq
- the required type of the valuerv
- the visitor for therun
method- Returns:
- the actual p-code type (which determines the JVM type) of the value on the stack
-