ClosureOptimizer

dotty.tools.backend.jvm.opt.ClosureOptimizer
See theClosureOptimizer companion object
class ClosureOptimizer(ppa: PostProcessorFrontendAccess, backendUtils: BackendUtils, byteCodeRepository: BCodeRepository, callGraph: CallGraph, ts: CoreBTypes, bTypesFromClassfile: BTypesFromClassfile)

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Type members

Classlikes

case class Local(local: Int, opcodeOffset: Int)

Stores a local variable index the opcode offset required for operating on that variable.

Stores a local variable index the opcode offset required for operating on that variable.

The xLOAD / xSTORE opcodes are in the following sequence: I, L, F, D, A, so the offset for a local variable holding a reference (A) is 4. See also method getOpcode in scala.tools.asm.Type.

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
case class LocalsList(locals: List[ClosureOptimizer.this.Local])

A list of local variables. Each local stores information about its type, see class Local.

A list of local variables. Each local stores information about its type, see class Local.

Attributes

Companion
object
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
object LocalsList

Attributes

Companion
class
Supertypes
trait Product
trait Mirror
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

If a closure is allocated and invoked within the same method, re-write the invocation to the closure body method.

If a closure is allocated and invoked within the same method, re-write the invocation to the closure body method.

Note that the closure body method (generated by delambdafy:method) takes additional parameters for the values captured by the closure. The bytecode is transformed from

[generate captured values] [closure init, capturing values] [...] [load closure object] [generate closure invocation arguments] [invoke closure.apply]

to

[generate captured values] [store captured values into new locals] [load the captured values from locals] // a future optimization will eliminate the closure [closure init, capturing values] // instantiation if the closure object becomes unused [...] [load closure object] [generate closure invocation arguments] [store argument values into new locals] [drop the closure object] [load captured values from locals] [load argument values from locals] [invoke the closure body method]

Value parameters

methods

The methods to check for rewrites. If not defined, check all methods with closure instantiations.

Attributes

Returns

The changed methods. The order of the resulting sequence is deterministic.