Enum Class CallOtherOpGen
- All Implemented Interfaces:
OpGen<JitCallOtherOpIf>,Serializable,Comparable<CallOtherOpGen>,Constable
callother.
The checks if Direct invocation is possible. If so, it emits code using
genRunDirectStrategy(Emitter, Local, JitCodeGenerator, JitCallOtherOpIf, JitBlock, Scope).
If not, it emits code using
genRunRetirementStrategy(Emitter, Local, JitCodeGenerator, PcodeOp, JitBlock, PcodeUseropDefinition).
Direct invocation is possible when the userop is functional and all of its parameters and return type have a supported primitive type.
(char is not supported.) Regarding the invocation strategies, see
JitDataFlowUseropLibrary and note that the Inline strategy is already handled by this
point.
For the Standard strategy, we emit code to retire the program counter, decode context, and all
live variables. We then request a field to hold the PcodeOp.CALLOTHER p-code op and the
userop, and emit code to load them. We then emit code to invoke
JitCompiledPassage.invokeUserop(PcodeUseropDefinition, PcodeOp). The userop definition
handles retrieving all of its inputs and writing the output, directly to the
state. Thus, we now need only to emit code to re-birth all the
live variables. If any errors occur, execution is interrupted as usual, and our state is
consistent.
For the Direct strategy, we wish to avoid retirement and re-birth, so we request an
ExceptionHandler. We request a field for the userop, just as in the Standard strategy,
but we emit code to invoke PcodeUseropLibrary.PcodeUseropDefinition.getDefiningLibrary() instead. We can use
PcodeUseropLibrary.PcodeUseropDefinition.getJavaMethod() at generation time to reflect its Java
definition. We then emit code to cast the library and load each of the operands onto the JVM
stack. We then emit the invocation of the Java method, guarded by the exception handler. We then
have to consider whether the userop has an output operand and whether its definition returns a
value. If both are true, we emit code to write the result. If neither is true, we're done. If a
result is returned, but no output operand is provided, we must still emit a
pop.
-
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.op.OpGen
OpGen.DeadOpResult, OpGen.LiveOpResult, OpGen.OpResult -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanCheck if the Direct invocation strategy is applicable (see class documentation)<THIS extends JitCompiledPassage>
OpGen.OpResultgenRun(Emitter<Emitter.Bot> em, Local<Types.TRef<THIS>> localThis, Local<Types.TInt> localCtxmod, Methods.RetReq<Types.TRef<JitCompiledPassage.EntryPoint>> retReq, JitCodeGenerator<THIS> gen, JitCallOtherOpIf op, JitControlFlowModel.JitBlock block, Scope scope) Emit bytecode into therunmethod.static <THIS extends JitCompiledPassage,LIB extends PcodeUseropLibrary<?>>
OpGen.OpResultgenRunDirectStrategy(Emitter<Emitter.Bot> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitCallOtherOpIf op, JitControlFlowModel.JitBlock block, Scope scope) Emit code to implement the Direct strategy (see the class documentation)static <THIS extends JitCompiledPassage>
OpGen.OpResultgenRunRetirementStrategy(Emitter<Emitter.Bot> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, PcodeOp op, JitControlFlowModel.JitBlock block, PcodeUseropLibrary.PcodeUseropDefinition<?> userop) Emit code to implement the Standard strategy (see the class documentation)static CallOtherOpGenReturns the enum constant of this class with the specified name.static CallOtherOpGen[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
GEN
The generator 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
-
genRunRetirementStrategy
public static <THIS extends JitCompiledPassage> OpGen.OpResult genRunRetirementStrategy(Emitter<Emitter.Bot> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, PcodeOp op, JitControlFlowModel.JitBlock block, PcodeUseropLibrary.PcodeUseropDefinition<?> userop) Emit code to implement the Standard strategy (see the class documentation)- Type Parameters:
THIS- the type of the generated passage- Parameters:
em- the emitter typed with the empty stacklocalThis- a handle to the local holding thethisreferencegen- the code generatorop- the p-code opblock- the block containing the opuserop- the userop definition, wrapped by theJitDataFlowUseropLibrary- Returns:
- the result of emitting the userop's bytecode
-
genRunDirectStrategy
public static <THIS extends JitCompiledPassage,LIB extends PcodeUseropLibrary<?>> OpGen.OpResult genRunDirectStrategy(Emitter<Emitter.Bot> em, Local<Types.TRef<THIS>> localThis, JitCodeGenerator<THIS> gen, JitCallOtherOpIf op, JitControlFlowModel.JitBlock block, Scope scope) Emit code to implement the Direct strategy (see the class documentation)- Type Parameters:
THIS- the type of the generated passage- Parameters:
em- the emitter typed with the empty stacklocalThis- a handle to the local holding thethisreferencegen- the code generatorop- the p-code op use-def nodeblock- the block containing the opscope- a scope for generating temporary local storage- Returns:
- the result of emitting the userop's bytecode
-
canDoDirectInvocation
Check if the Direct invocation strategy is applicable (see class documentation)- Parameters:
op- the p-code op use-def node- Returns:
- true if applicable
-
genRun
public <THIS extends JitCompiledPassage> OpGen.OpResult genRun(Emitter<Emitter.Bot> em, Local<Types.TRef<THIS>> localThis, Local<Types.TInt> localCtxmod, Methods.RetReq<Types.TRef<JitCompiledPassage.EntryPoint>> retReq, JitCodeGenerator<THIS> gen, JitCallOtherOpIf op, JitControlFlowModel.JitBlock block, Scope scope) Description copied from interface:OpGenEmit bytecode into therunmethod.This method must emit the code needed to load any input operands, convert them to the appropriate type, perform the actual operation, and then if applicable, store the output operand. The implementations should delegate to
JitCodeGenerator.genReadToStack(Emitter, Local, JitVal, ghidra.pcode.emu.jit.analysis.JitType.SimpleJitType, Ext),JitCodeGenerator.genWriteFromStack(Emitter, Local, JitVar, ghidra.pcode.emu.jit.analysis.JitType.SimpleJitType, Ext, Scope)or similar for mp-int types.- Specified by:
genRunin interfaceOpGen<JitCallOtherOpIf>- Type Parameters:
THIS- the type of the generated passage- Parameters:
em- the emitter typed with the empty stacklocalThis- a handle to the local holding thethisreferencelocalCtxmod- a handle to the local holdingctxmodretReq- an indication of what must be returned by thisJitCompiledPassage.run(int)method.gen- the code generatorop- the p-code op (use-def node) to translateblock- the basic block containing the p-code opscope- a scope for generating temporary local storage- Returns:
- the result of emitting the p-code op's bytecode
-