Class BytecodeEmitter


  • public class BytecodeEmitter
    extends Object
    Emits JVM bytecode from IR instructions.
    • Constructor Detail

      • BytecodeEmitter

        public BytecodeEmitter​(IRMethod method,
                               ConstPool constPool,
                               RegisterAllocator regAlloc,
                               StackScheduler scheduler)
        Creates a new bytecode emitter.
        Parameters:
        method - the IR method to emit
        constPool - the constant pool
        regAlloc - the register allocator
        scheduler - the stack scheduler
    • Method Detail

      • getMethod

        public IRMethod getMethod()
        Returns:
        the method
      • getConstPool

        public ConstPool getConstPool()
        Returns:
        the const pool
      • getScheduler

        public StackScheduler getScheduler()
        Returns:
        the scheduler
      • getBlockOffsets

        public Map<IRBlock,​Integer> getBlockOffsets()
        Returns:
        the block offsets
      • getBlockEndOffsets

        public Map<IRBlock,​Integer> getBlockEndOffsets()
        Returns:
        the block end offsets
      • getInstructionOffsets

        public Map<IRInstruction,​Integer> getInstructionOffsets()
        Returns:
        the start bytecode offset of each emitted instruction, for instruction-precise local-variable scopes
      • getCurrentOffset

        public int getCurrentOffset()
        Returns:
        the current offset
      • getStoreEndOffsets

        public Map<SSAValue,​Integer> getStoreEndOffsets()
        Returns:
        for each stored value, the pc immediately after its slot store - javac's LVT range start
      • getWrittenSlots

        public Set<Integer> getWrittenSlots()
        Returns:
        every local slot some emitted instruction actually writes
      • getStackResidentValues

        public Set<SSAValue> getStackResidentValues()
        Returns:
        the stack resident values
      • getInlinedConstants

        public Set<SSAValue> getInlinedConstants()
        Returns:
        the inlined constants
      • getInlinedConstantValue

        public Map<SSAValue,​Constant> getInlinedConstantValue()
        Returns:
        the inlined constant value
      • getHandlerExceptionCaptures

        public Set<SSAValue> getHandlerExceptionCaptures()
        Returns:
        the handler exception captures
      • getNextBlock

        public IRBlock getNextBlock()
        Returns:
        the next block
      • emit

        public byte[] emit()
        Emits bytecode for the IR method.
        Returns:
        the generated bytecode