Enum Class MissingVarGen
- All Implemented Interfaces:
ValGen<JitMissingVar>,VarGen<JitMissingVar>,Serializable,Comparable<MissingVarGen>,Constable
In principle, a JitMissingVar should never show up in the use-def graph, since they
should all be replaced by phi outputs. We can be certain these should never show
up as an output, so we prohibit any attempt to generate code that writes to a missing variable.
However, we wait until run time to make that assertion about reads. In theory, it's possible the
generator will generate unreachable code that reads from a variable; however, that code is
unreachable. First, how does this happen? Second, what if it does?
To answer the first question, we note that the passage decoder should never decode any statically unreachable instructions. However, the p-code emitted by those instructions may technically contain unreachable ops.
To answer the second, we note that the ASM library has a built-in control-flow analyzer, and it
ought to detect the unreachable code. In my observation, it replaces that code with
nop and/or athrow. Still, in case it doesn't, or in
case something changes in a later version (or if/when we port this to the JDK's upcoming
classfile API), we emit our own bytecode to throw an AssertionError.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>Nested classes/interfaces inherited from interface ghidra.pcode.emu.jit.gen.var.VarGen
VarGen.BlockTransition<THIS extends JitCompiledPassage> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescription<THIS extends JitCompiledPassage,N extends Emitter.Next>
Emitter<Emitter.Ent<N, Types.TInt>> genReadLegToStack(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v, JitType.MpIntJitType type, int leg, Opnd.Ext ext) Emit code to read a leg of the value onto the stack<THIS extends JitCompiledPassage,N extends Emitter.Next>
Emitter<Emitter.Ent<N, Types.TRef<int[]>>> genReadToArray(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v, JitType.MpIntJitType type, Opnd.Ext ext, Scope scope, int slack) Emit code to read the value into an array<THIS extends JitCompiledPassage,N extends Emitter.Next>
Emitter<Emitter.Ent<N, Types.TInt>> genReadToBool(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v) Emit code to read the value onto the stack as a boolean<THIS extends JitCompiledPassage,N extends Emitter.Next>
Opnd.OpndEm<JitType.MpIntJitType, N> genReadToOpnd(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v, JitType.MpIntJitType type, Opnd.Ext ext, Scope scope) Emit code to read the value into local variables<THIS extends JitCompiledPassage,T extends Types.BPrim<?>, JT extends JitType.SimpleJitType<T, JT>, N extends Emitter.Next>
Emitter<Emitter.Ent<N, T>> genReadToStack(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v, JT type, Opnd.Ext ext) Emit code to read the value onto the stack<THIS extends JitCompiledPassage,N extends Emitter.Next>
Emitter<N> genValInit(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v) Emit code to prepare any class-level items required to use this variable<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, JitMissingVar 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, JitMissingVar 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, JitMissingVar v, JT type, Opnd.Ext ext, Scope scope) Write a value from a stack operand into the given variablesubpiece(int byteShift, int maxByteSize) Create a generator for aPcodeOp.SUBPIECEof a value.static MissingVarGenReturns the enum constant of this class with the specified name.static MissingVarGen[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
GEN
Singleton
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
genValInit
public <THIS extends JitCompiledPassage,N extends Emitter.Next> Emitter<N> genValInit(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v) Description copied from interface:ValGenEmit code to 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.
This should be used to emit code into the constructor.
- Specified by:
genValInitin interfaceValGen<JitMissingVar>- 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 value- Returns:
- the emitter with ...
-
genReadToStack
public <THIS extends JitCompiledPassage,T extends Types.BPrim<?>, Emitter<Emitter.Ent<N,JT extends JitType.SimpleJitType<T, JT>, N extends Emitter.Next> T>> genReadToStack(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v, JT type, Opnd.Ext ext) Description copied from interface:ValGenEmit code to read the value onto the stack- Specified by:
genReadToStackin interfaceValGen<JitMissingVar>- Type Parameters:
THIS- the type of the generated classT- the desired JVM typeJT- the desired p-code typeN- the tail of the stack (...)- Parameters:
em- the emitterlocalThis- a handle tothisgen- the code generatorv- the valuetype- the desired p-code typeext- the kind of extension to apply- Returns:
- the emitter with ..., result
-
genReadToOpnd
public <THIS extends JitCompiledPassage,N extends Emitter.Next> Opnd.OpndEm<JitType.MpIntJitType,N> genReadToOpnd(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v, JitType.MpIntJitType type, Opnd.Ext ext, Scope scope) Description copied from interface:ValGenEmit code to read the value into local variablesNOTE: In some cases, this may not emit any code at all. It may simple compose the operand from locals already allocated for a variable being "read."
- Specified by:
genReadToOpndin interfaceValGen<JitMissingVar>- 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 valuetype- the desired p-code typeext- the kind of extension to applyscope- a scope for generated temporary variables- Returns:
- the operand and emitter with ...
-
genReadLegToStack
public <THIS extends JitCompiledPassage,N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TInt>> genReadLegToStack(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v, JitType.MpIntJitType type, int leg, Opnd.Ext ext) Description copied from interface:ValGenEmit code to read a leg of the value onto the stack- Specified by:
genReadLegToStackin interfaceValGen<JitMissingVar>- 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 valuetype- the desired p-code typeleg- the leg index, 0 being the least significantext- the kind of extension to apply- Returns:
- the emitter with ..., result
-
genReadToArray
public <THIS extends JitCompiledPassage,N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TRef<int[]>>> genReadToArray(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v, JitType.MpIntJitType type, Opnd.Ext ext, Scope scope, int slack) Description copied from interface:ValGenEmit code to read the value into an array- Specified by:
genReadToArrayin interfaceValGen<JitMissingVar>- 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 valuetype- the desired p-code typeext- the kind of extension to applyscope- a scope for generated temporary variablesslack- the number of extra (more significant) elements to allocate in the array- Returns:
- the operand and emitter with ..., arrayref
-
genWriteFromStack
public <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, JitMissingVar v, JT type, Opnd.Ext ext, Scope scope) Description copied from interface:VarGenWrite a value from a stack operand into the given variable- Specified by:
genWriteFromStackin interfaceVarGen<JitMissingVar>- 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
public <THIS extends JitCompiledPassage,N extends Emitter.Next> Emitter<N> genWriteFromOpnd(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v, Opnd<JitType.MpIntJitType> opnd, Opnd.Ext ext, Scope scope) Description copied from interface:VarGenWrite a value from a local operand into the given variable- Specified by:
genWriteFromOpndin interfaceVarGen<JitMissingVar>- 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
public <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, JitMissingVar v, JitType.MpIntJitType type, Opnd.Ext ext, Scope scope) Description copied from interface:VarGenWrite a value from an array operand into the given variable- Specified by:
genWriteFromArrayin interfaceVarGen<JitMissingVar>- 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 ...
-
genReadToBool
public <THIS extends JitCompiledPassage,N extends Emitter.Next> Emitter<Emitter.Ent<N,Types.TInt>> genReadToBool(Emitter<N> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitMissingVar v) Description copied from interface:ValGenEmit code to read the value onto the stack as a boolean- Specified by:
genReadToBoolin interfaceValGen<JitMissingVar>- 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 value- Returns:
- the emitter with ..., result
-
subpiece
Description copied from interface:ValGenCreate a generator for aPcodeOp.SUBPIECEof a value.- Specified by:
subpiecein interfaceValGen<JitMissingVar>- Parameters:
byteShift- the number of least-significant bytes to removemaxByteSize- the maximum size of the resulting variable. In general, a subpiece should never exceed the size of the parent varnode, but if it does, this will truncate that excess.- Returns:
- the resulting subpiece generator
-