Interface VarGen<V extends JitVar>
- Type Parameters:
 V- the class of p-code variable node in the use-def graph
- All Superinterfaces:
 ValGen<V>
- All Known Subinterfaces:
 LocalVarGen<V>,MemoryVarGen<V>
- All Known Implementing Classes:
 DirectMemoryVarGen,InputVarGen,LocalOutVarGen,MemoryOutVarGen,MissingVarGen
 For a table of value types, their use-def types, their generator classes, and relevant read/write
 opcodes, see JitVal. This interface is an extension of the JitVal interface that
 allows writing. The only non-JitVar JitVal is JitConstVal. As such, most
 of the variable-access logic is actually contained here.
- See Also:
 
- 
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA means to emit bytecode on transitions betweenblocks - 
Method Summary
Modifier and TypeMethodDescriptionstatic VarGen.BlockTransitioncomputeBlockTransition(JitCodeGenerator gen, JitControlFlowModel.JitBlock from, JitControlFlowModel.JitBlock to) Compute the retired and birthed varnodes for a transition between the given blocks.static voidgenerateBirthCode(JitCodeGenerator gen, Set<Varnode> toBirth, org.objectweb.asm.MethodVisitor rv) For block transitions: emit bytecode that births (loads) variables from thestateinto their allocated JVM locals.static voidgenerateRetireCode(JitCodeGenerator gen, Set<Varnode> toRetire, org.objectweb.asm.MethodVisitor rv) For block transitions: emit bytecode the retires (writes) variables into thestatefrom their allocated JVM locals.static voidgenerateValInitCode(JitCodeGenerator gen, Varnode vn) Emit bytecode necessary to support access to the given varnodestatic voidgenerateValReadCodeDirect(JitCodeGenerator gen, JitType type, Varnode vn, org.objectweb.asm.MethodVisitor rv) Emit bytecode that loads the given varnode with the given p-code type from thestateonto the JVM stack.static JitTypegenerateValReadCodeDirect(JitCodeGenerator gen, JitVarnodeVar v, JitTypeBehavior typeReq, org.objectweb.asm.MethodVisitor rv) Emit bytecode that loads the given use-def variable from thestateonto the JVM stack.static voidgenerateValWriteCodeDirect(JitCodeGenerator gen, JitType type, Varnode vn, org.objectweb.asm.MethodVisitor rv) Emit bytecode that writes the given varnode with the given p-code type in thestatefrom the JVM stack.static voidgenerateValWriteCodeDirect(JitCodeGenerator gen, JitVarnodeVar v, JitType type, org.objectweb.asm.MethodVisitor rv) Emit bytecode that writes the given use-def variable in thestatefrom the JVM stack.voidgenerateVarWriteCode(JitCodeGenerator gen, V v, JitType type, org.objectweb.asm.MethodVisitor rv) Write a value from the stack into the given variablelookup(V v) Lookup the generator for a given p-code variable use-def nodeMethods inherited from interface ghidra.pcode.emu.jit.gen.var.ValGen
generateValInitCode, generateValReadCode 
- 
Method Details
- 
lookup
Lookup the generator for a given p-code variable use-def node- Type Parameters:
 V- the class of the variable- Parameters:
 v- theJitVarwhose generator to look up- Returns:
 - the generator
 
 - 
generateValInitCode
Emit bytecode necessary to support access to the given varnodeThis applies to all varnode types:
memory,unique, andregister, but notconst. For memory varnodes, we need to pre-fetch the byte arrays backing their pages, so we can access them at the translation site. For unique and register varnodes, we also need to pre-fetch the byte arrays backing their pages, so we can birth and retire them attransitions. Technically, the methods for generating the read and write code will already callJitCodeGenerator.requestFieldForArrDirect(Address); however, we'd like to ensure the fields appear in the classfile in a comprehensible order, so we have the generator iterate the variables in address order and invoke this method, where we make the request first.- Parameters:
 gen- the code generatorvn- the varnode
 - 
generateValReadCodeDirect
static void generateValReadCodeDirect(JitCodeGenerator gen, JitType type, Varnode vn, org.objectweb.asm.MethodVisitor rv) Emit bytecode that loads the given varnode with the given p-code type from thestateonto the JVM stack.This is used for direct memory accesses and for register/unique scope transitions. The JVM type of the stack variable is determined by the
typeargument.- Parameters:
 gen- the code generatortype- the p-code type of the variablevn- the varnode to read from the staterv- the visitor for therunmethod
 - 
generateValReadCodeDirect
static JitType generateValReadCodeDirect(JitCodeGenerator gen, JitVarnodeVar v, JitTypeBehavior typeReq, org.objectweb.asm.MethodVisitor rv) Emit bytecode that loads the given use-def variable from thestateonto the JVM stack.The actual type is determined by resolving the
typeReqargument against the given variable. Since the variable is being loaded directly from the state, which is just raw bytes/bits, we ignore the "assigned" type and convert directly the type required by the operand.- Parameters:
 gen- the code generatorv- the use-def variable nodetypeReq- the type (behavior) required by the operand.rv- the visitor for therunmethod- Returns:
 - the resulting p-code type (which also describes the JVM type) of the value on the JVM stack
 
 - 
generateValWriteCodeDirect
static void generateValWriteCodeDirect(JitCodeGenerator gen, JitType type, Varnode vn, org.objectweb.asm.MethodVisitor rv) Emit bytecode that writes the given varnode with the given p-code type in thestatefrom the JVM stack.This is used for direct memory accesses and for register/unique scope transitions. The expected JVM type of the stack variable is described by the
typeargument.- Parameters:
 gen- the code generatortype- the p-code type of the variablevn- the varnode to write in the staterv- the visitor for therunmethod
 - 
generateValWriteCodeDirect
static void generateValWriteCodeDirect(JitCodeGenerator gen, JitVarnodeVar v, JitType type, org.objectweb.asm.MethodVisitor rv) Emit bytecode that writes the given use-def variable in thestatefrom the JVM stack.The expected type is given by the
typeargument. Since the variable is being written directly into the state, which is just raw bytes/bits, we ignore the "assigned" type and convert using the given type instead.- Parameters:
 gen- the code generatorv- the use-def variable nodetype- the p-code type of the value on the stack, as required by the operandrv- the visitor for therunmethod
 - 
generateBirthCode
static void generateBirthCode(JitCodeGenerator gen, Set<Varnode> toBirth, org.objectweb.asm.MethodVisitor rv) For block transitions: emit bytecode that births (loads) variables from thestateinto their allocated JVM locals.- Parameters:
 gen- the code generatortoBirth- the set of varnodes to loadrv- the visitor for therunmethod
 - 
generateRetireCode
static void generateRetireCode(JitCodeGenerator gen, Set<Varnode> toRetire, org.objectweb.asm.MethodVisitor rv) For block transitions: emit bytecode the retires (writes) variables into thestatefrom their allocated JVM locals.- Parameters:
 gen- the code generatortoRetire- the set of varnodes to writerv- the visitor for therunmethod
 - 
computeBlockTransition
static VarGen.BlockTransition computeBlockTransition(JitCodeGenerator gen, JitControlFlowModel.JitBlock from, JitControlFlowModel.JitBlock to) Compute the retired and birthed varnodes for a transition between the given blocks.Either block may be
nullto indicate entering or leaving the passage. Additionally, thetoblock should benullwhen generating transitions around a hazard.- Parameters:
 gen- the code generatorfrom- the block control flow is leaving (whether by branch or fall through)to- the block control flow is entering- Returns:
 - the means of generating bytecode at the transition
 
 - 
generateVarWriteCode
void generateVarWriteCode(JitCodeGenerator gen, V v, JitType type, org.objectweb.asm.MethodVisitor rv) Write a value from the stack into the given variable- Parameters:
 gen- the code generatorv- the variable to writetype- the p-code type (which also determines the expected JVM type) of the value on the stackrv- the visitor for therunmethod
 
 -