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:
DirectMemoryVarGen,InputVarGen,LocalOutVarGen,LocalVarGen<V>,MemoryOutVarGen,MemoryVarGen<V>,SubLocalVarGen<V>,SubMemoryVarGen<V>
- All Known Implementing Classes:
MissingVarGen,SubDirectMemoryVarGen,SubInputVarGen,SubLocalOutVarGen,SubMemoryOutVarGen,WholeDirectMemoryVarGen,WholeInputVarGen,WholeLocalOutVarGen,WholeMemoryOutVarGen
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 recordVarGen.BlockTransition<THIS extends JitCompiledPassage>A means to emit bytecode on transitions betweenblocks -
Method Summary
Modifier and TypeMethodDescriptionstatic <THIS extends JitCompiledPassage>
VarGen.BlockTransition<THIS> computeBlockTransition(Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitControlFlowModel.JitBlock from, JitControlFlowModel.JitBlock to) Compute the retired and birthed varnodes for a transition between the given blocks.static <THIS extends JitCompiledPassage,N extends Emitter.Next>
Emitter<N> genBirth(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, Set<Varnode> toBirth) For block transitions: emit bytecode that births (loads) variables from thestateinto their allocated JVM locals.static <THIS extends JitCompiledPassage,T extends Types.BPrim<?>, JT extends JitType.SimpleJitType<T, JT>, N extends Emitter.Next>
Emitter<Emitter.Ent<N, T>> genReadValDirectToStack(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JT type, Varnode vn) Emit bytecode that loads the given varnode with the given p-code type from thestateonto the stack.static <THIS extends JitCompiledPassage,N extends Emitter.Next>
Emitter<N> genRetire(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, Set<Varnode> toRetire) For block transitions: emit bytecode the retires (writes) variables into thestatefrom their allocated JVM locals.static <N extends Emitter.Next>
Emitter<N> genVarnodeInit(Emitter<N> em, JitCodeGenerator<?> gen, Varnode vn) Emit bytecode necessary to support access to the given varnode<THIS extends JitCompiledPassage,N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, Types.TRef<int[]>>>
Emitter<N1> genWriteFromArray(Emitter<N0> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v, JitType.MpIntJitType type, Opnd.Ext ext, Scope scope) Write a value from an array operand into the given variable<THIS extends JitCompiledPassage,N extends Emitter.Next>
Emitter<N> genWriteFromOpnd(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v, Opnd<JitType.MpIntJitType> opnd, Opnd.Ext ext, Scope scope) Write a value from a local operand into the given variable<THIS extends JitCompiledPassage,T extends Types.BPrim<?>, JT extends JitType.SimpleJitType<T, JT>, N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, T>>
Emitter<N1> genWriteFromStack(Emitter<N0> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v, JT type, Opnd.Ext ext, Scope scope) Write a value from a stack operand into the given variablestatic <THIS extends JitCompiledPassage,T extends Types.BPrim<?>, JT extends JitType.SimpleJitType<T, JT>, N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, T>>
Emitter<N1> genWriteValDirectFromStack(Emitter<N0> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JT type, JitVarnodeVar v) Emit bytecode that writes the given use-def variable in thestatefrom a stack operand.static <THIS extends JitCompiledPassage,T extends Types.BPrim<?>, JT extends JitType.SimpleJitType<T, JT>, N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, T>>
Emitter<N1> genWriteValDirectFromStack(Emitter<N0> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JT type, Varnode vn) Emit bytecode that writes the given varnode with the given p-code type in thestatefrom a stack operand.lookup(V v) Lookup the generator for a given p-code variable use-def nodeMethods inherited from interface ghidra.pcode.emu.jit.gen.var.ValGen
genReadLegToStack, genReadToArray, genReadToBool, genReadToOpnd, genReadToStack, genValInit, subpiece
-
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
-
genVarnodeInit
static <N extends Emitter.Next> Emitter<N> genVarnodeInit(Emitter<N> em, JitCodeGenerator<?> gen, Varnode vn) 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.- Type Parameters:
N- the tail of the stack (...)- Parameters:
em- the emittergen- the code generatorvn- the varnode- Returns:
- the emitter with ...
-
genReadValDirectToStack
static <THIS extends JitCompiledPassage,T extends Types.BPrim<?>, Emitter<Emitter.Ent<N,JT extends JitType.SimpleJitType<T, JT>, N extends Emitter.Next> T>> genReadValDirectToStack(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JT type, Varnode vn) Emit bytecode that loads the given varnode with the given p-code type from thestateonto the stack.This is used for direct memory accesses and for register/unique scope transitions. The JVM type of the operand is determined by the
typeargument.- Type Parameters:
THIS- the type of the generated classN- the tail of the stack (...)- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatortype- the p-code type of the variablevn- the varnode to read from the state- Returns:
- the emitter with ..., result
-
genWriteValDirectFromStack
static <THIS extends JitCompiledPassage,T extends Types.BPrim<?>, Emitter<N1> genWriteValDirectFromStackJT extends JitType.SimpleJitType<T, JT>, N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, T>> (Emitter<N0> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JT type, Varnode vn) Emit bytecode that writes the given varnode with the given p-code type in thestatefrom a stack operand.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.- Type Parameters:
THIS- the type of the generated classN1- the tail of the stack (...)N0- ..., value- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatortype- the type of the operand on the stackvn- the varnode to write in the state- Returns:
- the emitter with ...
-
genWriteValDirectFromStack
static <THIS extends JitCompiledPassage,T extends Types.BPrim<?>, Emitter<N1> genWriteValDirectFromStackJT extends JitType.SimpleJitType<T, JT>, N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, T>> (Emitter<N0> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JT type, JitVarnodeVar v) Emit bytecode that writes the given use-def variable in thestatefrom a stack operand.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.- Type Parameters:
THIS- the type of the generated classN1- the tail of the stack (...)N0- ..., value- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatortype- the type of the operand on the stackv- the use-def variable node- Returns:
- the emitter with ...
-
genBirth
static <THIS extends JitCompiledPassage,N extends Emitter.Next> Emitter<N> genBirth(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, Set<Varnode> toBirth) For block transitions: emit bytecode that births (loads) variables from thestateinto their allocated JVM locals.- Type Parameters:
THIS- the type of the generated classN- the tail of the stack (...)- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatortoBirth- the set of varnodes to load- Returns:
- the emitter with ...
-
genRetire
static <THIS extends JitCompiledPassage,N extends Emitter.Next> Emitter<N> genRetire(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, Set<Varnode> toRetire) For block transitions: emit bytecode the retires (writes) variables into thestatefrom their allocated JVM locals.- Type Parameters:
THIS- the type of the generated classN- the tail of the stack (...)- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatortoRetire- the set of varnodes to write- Returns:
- the emitter with ...
-
computeBlockTransition
static <THIS extends JitCompiledPassage> VarGen.BlockTransition<THIS> computeBlockTransition(Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> 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.- Type Parameters:
THIS- the type of the generated class- Parameters:
localThis- a handle tothisgen- 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
-
genWriteFromStack
<THIS extends JitCompiledPassage,T extends Types.BPrim<?>, Emitter<N1> genWriteFromStackJT extends JitType.SimpleJitType<T, JT>, N1 extends Emitter.Next, N0 extends Emitter.Ent<N1, T>> (Emitter<N0> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v, JT type, Opnd.Ext ext, Scope scope) Write a value from a stack operand into the given variable- Type Parameters:
THIS- the type of the generated classT- the JVM type of the stack operandJT- the p-code type of the stack operandN1- the tail of the stack (...)N0- ..., value- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatorv- the variable to writetype- the p-code type of the stack operandext- the kind of extension to apply when adjusting from varnode size to JVM sizescope- a scope for temporaries- Returns:
- the emitter with ...
-
genWriteFromOpnd
<THIS extends JitCompiledPassage,N extends Emitter.Next> Emitter<N> genWriteFromOpnd(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v, Opnd<JitType.MpIntJitType> opnd, Opnd.Ext ext, Scope scope) Write a value from a local operand into the given variable- Type Parameters:
THIS- the type of the generated classN- the tail of the stack (...)- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatorv- the variable to writeopnd- the source operandext- the kind of extension to apply when adjusting from varnode size to JVM sizescope- a scope for temporaries- Returns:
- the emitter with ...
-
genWriteFromArray
<THIS extends JitCompiledPassage,N1 extends Emitter.Next, Emitter<N1> genWriteFromArrayN0 extends Emitter.Ent<N1, Types.TRef<int[]>>> (Emitter<N0> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, V v, JitType.MpIntJitType type, Opnd.Ext ext, Scope scope) Write a value from an array operand into the given variable- Type Parameters:
THIS- the type of the generated classN1- the tail of the stack (...)N0- ..., arrayref- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatorv- the variable to writetype- the p-code type of the array operandext- the kind of extension to apply when adjusting from varnode size to JVM sizescope- a scope for temporaries- Returns:
- the emitter with ...
-