Packages

trait BytecodeOptimizer extends MethodsBinding

Performs some very basic, in-place control-flow simplifications to make the code more regular. In particular to make it more likely that an if that is actually a loop's if actually jumps back.

The following transformations are performed:

  • trivial gotos which jump to the immediately succeeding instruction are replaced by nops (the CFG may contain less basic blocks afterwards)
  • goto chains are shortened (i.e., a goto jumping to another goto) (this primarily reduces the number of instructions that need to be evaluated at abstract interpretation time; it may - however - also reduce the number of basic blocks)
  • useless ifs where the jump target is the next instruction are replaced by nops (the CFG may contain less basic blocks afterwards)
  • if -> goto instruction sequences are resolved (this primarily reduces the number of instructions that need to be evaluated at abstract interpretation time; it may - however - also reduce the number of basic blocks)
  • useless switches are replaced (the CFG may contain less basic blocks afterwards)

The target array has the same size as the source array to make sure that branch offsets/line- numbers etc. point to the correct instruction. Furthermore, we try to avoid the introduction of dead code.

Self Type
BytecodeOptimizer with ClassFileBinding with ConstantPoolBinding with AttributeBinding
Source
BytecodeOptimizer.scala
Note

All transformation always only reduce the number of basic blocks and never create new basic blocks. The existing stack map table attributes are never effected and remain valid; they may just contain more entries than strictly necessary.

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BytecodeOptimizer
  2. MethodsBinding
  3. MethodsReader
  4. Constant_PoolAbstractions
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. abstract type Attributes
    Definition Classes
    MethodsReader
  2. abstract type CONSTANT_Utf8_info <: (BytecodeOptimizer.this)#Constant_Pool_Entry
    Definition Classes
    Constant_PoolAbstractions
  3. abstract type ClassFile
    Definition Classes
    Constant_PoolAbstractions
  4. final type Constant_Pool = Array[(BytecodeOptimizer.this)#Constant_Pool_Entry]
    Definition Classes
    Constant_PoolAbstractions
  5. abstract type Constant_Pool_Entry <: ConstantPoolEntry
    Definition Classes
    Constant_PoolAbstractions
  6. final type Constant_Pool_Index = Int
    Definition Classes
    Constant_PoolAbstractions
  7. type DeferredActionsStore = Buffer[((BytecodeOptimizer.this)#ClassFile) => (BytecodeOptimizer.this)#ClassFile] with (BytecodeOptimizer.this)#Constant_Pool_Entry

    A DeferredActionsStore stores all functions that need to perform post load actions.

    A DeferredActionsStore stores all functions that need to perform post load actions.

    One example is the resolution of references to attributes. (The constant pool is the only structure that is passed around and hence it is the only place where to store information/functions related to a specific class file).

    Definition Classes
    Constant_PoolAbstractions
  8. type Method_Info = Method
    Definition Classes
    MethodsBindingMethodsReader
  9. type Methods = ArraySeq[(BytecodeOptimizer.this)#Method_Info]
    Definition Classes
    MethodsReader

Abstract Value Members

  1. abstract def applyDeferredActions(cp: (BytecodeOptimizer.this)#Constant_Pool, classFile: (BytecodeOptimizer.this)#ClassFile): (BytecodeOptimizer.this)#ClassFile

    This method is called/needs to be called after the class file was completely loaded to perform class file specific transformations.

    This method is called/needs to be called after the class file was completely loaded to perform class file specific transformations.

    Definition Classes
    Constant_PoolAbstractions
  2. implicit abstract val constantPoolEntryType: ClassTag[(BytecodeOptimizer.this)#Constant_Pool_Entry]
    Definition Classes
    Constant_PoolAbstractions

Concrete Value Members

  1. final val LogControlFlowSimplifications: Boolean
  2. def Method_Info(cp: (BytecodeOptimizer.this)#Constant_Pool, accessFlags: Int, name_index: Int, descriptor_index: Int, attributes: (BytecodeOptimizer.this)#Attributes): (BytecodeOptimizer.this)#Method_Info
  3. def Methods(cp: (BytecodeOptimizer.this)#Constant_Pool, in: DataInputStream): (BytecodeOptimizer.this)#Methods
    Definition Classes
    MethodsReader
  4. final val PerformControlFlowSimplifications: Boolean
  5. implicit val methodInfoType: ClassTag[(BytecodeOptimizer.this)#Method_Info]
    Definition Classes
    MethodsBindingMethodsReader
  6. def optimizeInstructions(exceptionsHandlers: ExceptionHandlers, instructions: Array[Instruction]): Boolean