Class OnDemandOptimizer
An optimizer that computes optimized method bodies on an on-demand basis: method bodies are not optimized until they are requested. Optimized method bodies are cached, so method bodies are never optimized twice.
Inherited Members
Namespace: Flame.Compiler.Pipeline
Assembly: Flame.Compiler.dll
Syntax
public class OnDemandOptimizer : Optimizer
Constructors
| Improve this Doc View SourceOnDemandOptimizer(IReadOnlyList<Optimization>)
Creates a method body optimizer.
Declaration
public OnDemandOptimizer(IReadOnlyList<Optimization> pipeline)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyList<Optimization> | pipeline | A pass pipeline: a sequence of optimizations to apply to every method body. |
OnDemandOptimizer(IReadOnlyList<Optimization>, Func<IMethod, MethodBody>)
Creates a method body optimizer.
Declaration
public OnDemandOptimizer(IReadOnlyList<Optimization> pipeline, Func<IMethod, MethodBody> getInitialMethodBody)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IReadOnlyList<Optimization> | pipeline | A pass pipeline: a sequence of optimizations to apply to every method body. |
System.Func<IMethod, MethodBody> | getInitialMethodBody | A delegate that tries to find an initial method body for a method. This initial method body is is the starting point for further optimizations, both interprocedural and intraprocedural. |
Methods
| Improve this Doc View SourceGetBodyAsync(IMethod)
Asynchronously requests a method's body. This method should only used by external entities: if methods that are being optimized call this method, then they might cause a deadlock.
Declaration
public override Task<MethodBody> GetBodyAsync(IMethod requested)
Parameters
Type | Name | Description |
---|---|---|
IMethod | requested | The method whose body is requested. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<MethodBody> | The method's body. |
Overrides
Remarks
The optimizer is free to return any method body that is
semantically equivalent to requested
's body.
This ranges from requested
's initial method
body to its final optimized body.
Which version of requested
's body is returned
depends on the optimizer. The optimizer is expected to return
a method body that is as optimized as possible given the
constraints imposed by the optimizer's implementation.
GetBodyAsync(IMethod, IMethod)
Asynchronously requests a method's body. This method will never cause a deadlock, even when methods cyclically request each other's method bodies.
Declaration
public override Task<MethodBody> GetBodyAsync(IMethod requested, IMethod requesting)
Parameters
Type | Name | Description |
---|---|---|
IMethod | requested | The method whose body is requested. |
IMethod | requesting | The method that requests |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<MethodBody> | The method's body. |
Overrides
Remarks
The optimizer is free to return any method body that is
semantically equivalent to requested
's body.
This ranges from requested
's initial method
body to its final optimized body.
Which version of requested
's body is returned
depends on the optimizer. The optimizer is expected to return
a method body that is as optimized as possible given the
constraints imposed by the optimizer's implementation.
GetInitialMethodBodyDefault(IMethod)
Gets an initial method body for a method using the default mechanism of checking if the method is a body method and requesting its method body if so.
Declaration
public static MethodBody GetInitialMethodBodyDefault(IMethod method)
Parameters
Type | Name | Description |
---|---|---|
IMethod | method | The recursive generic method declaration to inspect. |
Returns
Type | Description |
---|---|
MethodBody | A method body if one can be found; otherwise |