Package com.tonic.analysis.ssa.lower
Class BytecodeEmitter
- java.lang.Object
-
- com.tonic.analysis.ssa.lower.BytecodeEmitter
-
public class BytecodeEmitter extends Object
Emits JVM bytecode from IR instructions.
-
-
Constructor Summary
Constructors Constructor Description BytecodeEmitter(IRMethod method, ConstPool constPool, RegisterAllocator regAlloc, StackScheduler scheduler)Creates a new bytecode emitter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]emit()Emits bytecode for the IR method.Map<IRBlock,Integer>getBlockEndOffsets()Map<IRBlock,Integer>getBlockOffsets()ByteArrayOutputStreamgetBytecode()ConstPoolgetConstPool()intgetCurrentOffset()DataOutputStreamgetDos()Set<SSAValue>getHandlerExceptionCaptures()Map<InvokeInstruction,NewInstruction>getInitToNew()Set<SSAValue>getInlinedConstants()Map<SSAValue,Constant>getInlinedConstantValue()Map<IRInstruction,Integer>getInstructionOffsets()IRMethodgetMethod()Map<NewInstruction,InvokeInstruction>getNewToInit()IRBlockgetNextBlock()RegisterAllocatorgetRegAlloc()StackSchedulergetScheduler()Set<SSAValue>getStackResidentValues()Map<SSAValue,Integer>getStoreEndOffsets()Set<Integer>getWrittenSlots()
-
-
-
Constructor Detail
-
BytecodeEmitter
public BytecodeEmitter(IRMethod method, ConstPool constPool, RegisterAllocator regAlloc, StackScheduler scheduler)
Creates a new bytecode emitter.- Parameters:
method- the IR method to emitconstPool- the constant poolregAlloc- the register allocatorscheduler- the stack scheduler
-
-
Method Detail
-
getMethod
public IRMethod getMethod()
- Returns:
- the method
-
getConstPool
public ConstPool getConstPool()
- Returns:
- the const pool
-
getRegAlloc
public RegisterAllocator getRegAlloc()
- Returns:
- the reg alloc
-
getScheduler
public StackScheduler getScheduler()
- Returns:
- the scheduler
-
getBytecode
public ByteArrayOutputStream getBytecode()
- Returns:
- the bytecode
-
getDos
public DataOutputStream getDos()
- Returns:
- the dos
-
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
-
getInlinedConstantValue
public Map<SSAValue,Constant> getInlinedConstantValue()
- Returns:
- the inlined constant value
-
getHandlerExceptionCaptures
public Set<SSAValue> getHandlerExceptionCaptures()
- Returns:
- the handler exception captures
-
getNewToInit
public Map<NewInstruction,InvokeInstruction> getNewToInit()
- Returns:
- the new to init
-
getInitToNew
public Map<InvokeInstruction,NewInstruction> getInitToNew()
- Returns:
- the init to new
-
getNextBlock
public IRBlock getNextBlock()
- Returns:
- the next block
-
emit
public byte[] emit()
Emits bytecode for the IR method.- Returns:
- the generated bytecode
-
-