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
-
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionvoid
generateValInitCode
(JitCodeGenerator gen, JitMissingVar v, org.objectweb.asm.MethodVisitor iv) Prepare any class-level items required to use this variablegenerateValReadCode
(JitCodeGenerator gen, JitMissingVar v, JitTypeBehavior typeReq, org.objectweb.asm.MethodVisitor rv) Read the value onto the stackvoid
generateVarWriteCode
(JitCodeGenerator gen, JitMissingVar v, JitType type, org.objectweb.asm.MethodVisitor rv) Write a value from the stack into the given variablestatic MissingVarGen
Returns 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
-
generateValInitCode
public void generateValInitCode(JitCodeGenerator gen, JitMissingVar v, org.objectweb.asm.MethodVisitor iv) Description copied from interface:ValGen
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.
- Specified by:
generateValInitCode
in interfaceValGen<JitMissingVar>
- Parameters:
gen
- the code generatorv
- the valueiv
- the constructor visitor
-
generateValReadCode
public JitType generateValReadCode(JitCodeGenerator gen, JitMissingVar v, JitTypeBehavior typeReq, org.objectweb.asm.MethodVisitor rv) Description copied from interface:ValGen
Read the value onto the stack- Specified by:
generateValReadCode
in interfaceValGen<JitMissingVar>
- 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
-
generateVarWriteCode
public void generateVarWriteCode(JitCodeGenerator gen, JitMissingVar v, JitType type, org.objectweb.asm.MethodVisitor rv) Description copied from interface:VarGen
Write a value from the stack into the given variable- Specified by:
generateVarWriteCode
in interfaceVarGen<JitMissingVar>
- 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 therun
method
-