Interface ValGen<V extends JitVal>

Type Parameters:
V - the class op p-code value node in the use-def graph
All Known Subinterfaces:
LocalVarGen<V>, MemoryVarGen<V>, VarGen<V>
All Known Implementing Classes:
ConstValGen, DirectMemoryVarGen, FailValGen, InputVarGen, LocalOutVarGen, MemoryOutVarGen, MissingVarGen

public interface ValGen<V extends JitVal>
The bytecode generator for a specific value (operand) access.

The JitCodeGenerator selects the correct generator for each input operand using lookup(JitVal) and each output operand VarGen.lookup(JitVar). The op generator has already retrieved the JitOp whose operands are of the JitVal class.

Varnode Type Use-Def Type Generator Type Read Bytecodes / Methods Write Bytecodes / Methods
constant JitConstVal ConstValGen ldc
unique,
register
JitInputVar,
JitLocalOutVar,
JitMissingVar
InputVarGen,
LocalOutVarGen
See JitType.SimpleJitType.opcodeLoad():
iload, lload, fload, dload
See JitType.SimpleJitType.opcodeStore():
istore, lstore, fstore, dstore
memory JitDirectMemoryVar,
JitMemoryOutVar
DirectMemoryVarGen,
MemoryOutVarGen
readInt*, readLong*, etc. writeInt*, writeLong*, etc.
*indirect JitIndirectMemoryVar None
See Also:
Implementation Notes:
Memory-mapped registers are treated as memory varnodes, not register, because they are shared by all threads. TODO: A JitConfiguration flag that says "the machine is single threaded!" so we can optimize memory accesses in the same manner we do registers and uniques., There are remnants of experiments and fragments in anticipation of multi-precision integer variables. These are not supported yet, but some of the components for mp-int support are used in degenerate form to support normal ints. Many of these components have "Mp" in the name., The memory variables are all generally handled as if ints, and then type conversions are applied if necessary to access them as floating point., JitMissingVar is a special case of unique and register variable where the definition could not be found. It is used as an intermediate result the JitDataFlowModel, but should be converted to a JitOutVar defined by a JitPhiOp before it enters the use-def graph., JitIndirectMemoryVar is a singleton dummy used in the JitDataFlowModel. It is immediately thrown away, as indirect memory access is instead modeled by JitLoadOp and JitStoreOp.
  • Method Details

    • lookup

      static <V extends JitVal> ValGen<V> lookup(V v)
      Lookup the generator for a given p-code value use-def node
      Type Parameters:
      V - the class of the value
      Parameters:
      v - the JitVal whose generator to look up
      Returns:
      the generator
    • generateValInitCode

      void generateValInitCode(JitCodeGenerator gen, V v, org.objectweb.asm.MethodVisitor iv)
      Prepare any class-level items required to use this variable

      For 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.

      Parameters:
      gen - the code generator
      v - the value
      iv - the constructor visitor
    • generateValReadCode

      JitType generateValReadCode(JitCodeGenerator gen, V v, JitTypeBehavior typeReq, org.objectweb.asm.MethodVisitor rv)
      Read the value onto the stack
      Parameters:
      gen - the code generator
      v - the value to read
      typeReq - the required type of the value
      rv - the visitor for the run method
      Returns:
      the actual p-code type (which determines the JVM type) of the value on the stack