Class Optimizer
A base class for optimizers: objects that manage method bodies as they are being optimized and respond to method body queries.
Inherited Members
Namespace: Flame.Compiler.Pipeline
Assembly: Flame.Compiler.dll
Syntax
public abstract class Optimizer
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 abstract 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. |
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 abstract 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. |
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.
RunAllAsync(IEnumerable<Func<Task>>)
Runs a sequence of tasks and waits for them to complete.
Declaration
public Task RunAllAsync(IEnumerable<Func<Task>> tasks)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Func<System.Threading.Tasks.Task>> | tasks | A sequence of tasks to run. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A single task that waits for all tasks to complete. |
RunAllAsync(IEnumerable<Task>)
Runs a sequence of tasks and waits for them to complete.
Declaration
public Task RunAllAsync(IEnumerable<Task> tasks)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task> | tasks | A sequence of tasks to run. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A single task that waits for all tasks to complete. |
RunAllAsync<T>(IEnumerable<Func<Task<T>>>)
Runs a sequence of tasks and combines their results. Whether these tasks are run in sequence or in parallel depends on the optimizer.
Declaration
public virtual Task<IReadOnlyList<T>> RunAllAsync<T>(IEnumerable<Func<Task<T>>> tasks)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Func<System.Threading.Tasks.Task<T>>> | tasks | A sequence of tasks to run. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<T>> | A single task that combines the results from all tasks. |
Type Parameters
Name | Description |
---|---|
T | The type of value returned by a task. |
RunAllAsync<T>(IEnumerable<Task<T>>)
Runs a sequence of tasks and combines their results. Whether these tasks are run in sequence or in parallel depends on the optimizer.
Declaration
public Task<IReadOnlyList<T>> RunAllAsync<T>(IEnumerable<Task<T>> tasks)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.Threading.Tasks.Task<T>> | tasks | A sequence of tasks to run. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<T>> | A single task that combines the results from all tasks. |
Type Parameters
Name | Description |
---|---|
T | The type of value returned by a task. |