Class Inlining
The inlining optimization: a transform that copies the function bodies of callees into the caller, replacing the call with its implementation.
Inherited Members
Namespace: Flame.Compiler.Transforms
Assembly: Flame.Compiler.dll
Syntax
public class Inlining : Optimization
Constructors
| Improve this Doc View SourceInlining()
Creates an instance of the inlining optimization.
Declaration
protected Inlining()
Fields
| Improve this Doc View SourceInstance
An instance of the inlining transformation.
Declaration
public static readonly Inlining Instance
Field Value
Type | Description |
---|---|
Inlining | A call-inlining transform. |
Properties
| Improve this Doc View SourceIsCheckpoint
Tells if this optimization checkpoints its result. The optimizer takes care to always return the latest checkpointed method body is returned when a method's optimized method body is requested.
Declaration
public override bool IsCheckpoint { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Tells if this optimization performs a checkpoint. |
Overrides
Methods
| Improve this Doc View SourceApplyAsync(MethodBody, OptimizationState)
Applies the optimization to a method body.
Declaration
public override Task<MethodBody> ApplyAsync(MethodBody body, OptimizationState state)
Parameters
Type | Name | Description |
---|---|---|
MethodBody | body | A method body holder to optimize. |
OptimizationState | state | State associated with optimizations. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<MethodBody> | A task that produces an optimized method body. |
Overrides
| Improve this Doc View SourceCanInline(MethodBody, IMethod, FlowGraph)
Determines if a method body can be inlined, that is, if invalid code will be generated by inlining it.
Declaration
protected virtual bool CanInline(MethodBody calleeBody, IMethod caller, FlowGraph callerBody)
Parameters
Type | Name | Description |
---|---|---|
MethodBody | calleeBody | A method body that is an inlining candidate. |
IMethod | caller | The caller that wants to inline |
FlowGraph | callerBody | The method body for |
Returns
Type | Description |
---|---|
System.Boolean |
|
GetInlineCost(MethodBody)
Gauges a particular method body's inline cost.
Declaration
protected virtual int GetInlineCost(MethodBody body)
Parameters
Type | Name | Description |
---|---|---|
MethodBody | body | A method body that might be inlined. |
Returns
Type | Description |
---|---|
System.Int32 | A number that represents the method body's inline cost. |
GetInlineGain(MethodBody, IReadOnlyList<ValueTag>, FlowGraph)
Gauges a particular method body's inline gain.
Declaration
protected virtual int GetInlineGain(MethodBody body, IReadOnlyList<ValueTag> arguments, FlowGraph caller)
Parameters
Type | Name | Description |
---|---|---|
MethodBody | body | A method body that might be inlined. |
System.Collections.Generic.IReadOnlyList<ValueTag> | arguments | The list of arguments to feed to |
FlowGraph | caller | The control-flow graph of the caller, which defines the arguments. |
Returns
Type | Description |
---|---|
System.Int32 | A number that represents how much new information we expect to gain from inlining. |
ShouldConsider(IMethod, IMethod)
Tells if a method should be considered for inlining.
Declaration
protected virtual bool ShouldConsider(IMethod callee, IMethod caller)
Parameters
Type | Name | Description |
---|---|---|
IMethod | callee | A method that might be inlined. |
IMethod | caller | A method that calls |
Returns
Type | Description |
---|---|
System.Boolean |
|
ShouldInline(MethodBody, IReadOnlyList<ValueTag>, FlowGraph)
Determines if a method body is worth inlining.
Declaration
protected bool ShouldInline(MethodBody body, IReadOnlyList<ValueTag> arguments, FlowGraph caller)
Parameters
Type | Name | Description |
---|---|---|
MethodBody | body | The method body to inline. |
System.Collections.Generic.IReadOnlyList<ValueTag> | arguments | The list of arguments to feed to |
FlowGraph | caller | The control-flow graph of the caller, which defines the arguments. |
Returns
Type | Description |
---|---|
System.Boolean |
|