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.
- Alphabetic
- By Inheritance
- BytecodeOptimizer
- MethodsBinding
- MethodsReader
- Constant_PoolAbstractions
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- abstract type Attributes
- Definition Classes
- MethodsReader
- abstract type CONSTANT_Utf8_info <: (BytecodeOptimizer.this)#Constant_Pool_Entry
- Definition Classes
- Constant_PoolAbstractions
- abstract type ClassFile
- Definition Classes
- Constant_PoolAbstractions
- final type Constant_Pool = Array[(BytecodeOptimizer.this)#Constant_Pool_Entry]
- Definition Classes
- Constant_PoolAbstractions
- abstract type Constant_Pool_Entry <: ConstantPoolEntry
- Definition Classes
- Constant_PoolAbstractions
- final type Constant_Pool_Index = Int
- Definition Classes
- Constant_PoolAbstractions
- 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
- type Method_Info = Method
- Definition Classes
- MethodsBinding → MethodsReader
- type Methods = ArraySeq[(BytecodeOptimizer.this)#Method_Info]
- Definition Classes
- MethodsReader
Abstract Value Members
- abstract def Attributes(cp: (BytecodeOptimizer.this)#Constant_Pool, ap: AttributeParent, ap_name_index: (BytecodeOptimizer.this)#Constant_Pool_Index, ap_descriptor_index: (BytecodeOptimizer.this)#Constant_Pool_Index, in: DataInputStream): (BytecodeOptimizer.this)#Attributes
- Attributes
- protected
- Definition Classes
- MethodsReader
- 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
- implicit abstract val constantPoolEntryType: ClassTag[(BytecodeOptimizer.this)#Constant_Pool_Entry]
- Definition Classes
- Constant_PoolAbstractions
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final val LogControlFlowSimplifications: Boolean
- def Method_Info(cp: (BytecodeOptimizer.this)#Constant_Pool, accessFlags: Int, name_index: Int, descriptor_index: Int, attributes: (BytecodeOptimizer.this)#Attributes): (BytecodeOptimizer.this)#Method_Info
- Definition Classes
- BytecodeOptimizer → MethodsBinding → MethodsReader
- def Methods(cp: (BytecodeOptimizer.this)#Constant_Pool, in: DataInputStream): (BytecodeOptimizer.this)#Methods
- Definition Classes
- MethodsReader
- final val PerformControlFlowSimplifications: Boolean
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @IntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @IntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- implicit val methodInfoType: ClassTag[(BytecodeOptimizer.this)#Method_Info]
- Definition Classes
- MethodsBinding → MethodsReader
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @IntrinsicCandidate()
- def optimizeInstructions(exceptionsHandlers: ExceptionHandlers, instructions: Array[Instruction]): Boolean
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated