Skip to content

Commit 92f32da

Browse files
authored
Add MethodImplAttributes.AggressiveOptimization (#855)
In .NET Core 3.0 and later, `MethodImplOptions` got a new flag value, `AggressiveOptimization` (512). This adds that same flag to `MethodImplAttributes` (and a corresponding property to `MethodDefinition`). It also updates the comments for the flags to match the `MethodImplOptions` documentation better.
1 parent c4cfe16 commit 92f32da

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

Mono.Cecil/MethodDefinition.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,11 @@ public bool AggressiveInlining {
440440
set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.AggressiveInlining, value); }
441441
}
442442

443+
public bool AggressiveOptimization {
444+
get { return impl_attributes.GetAttributes ((ushort) MethodImplAttributes.AggressiveOptimization); }
445+
set { impl_attributes = impl_attributes.SetAttributes ((ushort) MethodImplAttributes.AggressiveOptimization, value); }
446+
}
447+
443448
#endregion
444449

445450
#region MethodSemanticsAttributes

Mono.Cecil/MethodImplAttributes.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,24 @@ namespace Mono.Cecil {
1414

1515
[Flags]
1616
public enum MethodImplAttributes : ushort {
17-
CodeTypeMask = 0x0003,
18-
IL = 0x0000, // Method impl is CIL
19-
Native = 0x0001, // Method impl is native
20-
OPTIL = 0x0002, // Reserved: shall be zero in conforming implementations
21-
Runtime = 0x0003, // Method impl is provided by the runtime
17+
CodeTypeMask = 0x0003,
18+
IL = 0x0000, // Method impl is CIL
19+
Native = 0x0001, // Method impl is native
20+
OPTIL = 0x0002, // Reserved: shall be zero in conforming implementations
21+
Runtime = 0x0003, // Method impl is provided by the runtime
2222

23-
ManagedMask = 0x0004, // Flags specifying whether the code is managed or unmanaged
24-
Unmanaged = 0x0004, // Method impl is unmanaged, otherwise managed
25-
Managed = 0x0000, // Method impl is managed
23+
ManagedMask = 0x0004, // Flags specifying whether the code is managed or unmanaged
24+
Unmanaged = 0x0004, // Method impl is unmanaged, otherwise managed
25+
Managed = 0x0000, // Method impl is managed
2626

27-
// Implementation info and interop
28-
ForwardRef = 0x0010, // Indicates method is defined; used primarily in merge scenarios
29-
PreserveSig = 0x0080, // Reserved: conforming implementations may ignore
30-
InternalCall = 0x1000, // Reserved: shall be zero in conforming implementations
31-
Synchronized = 0x0020, // Method is single threaded through the body
32-
NoOptimization = 0x0040, // Method is not optimized by the JIT.
33-
NoInlining = 0x0008, // Method may not be inlined
34-
AggressiveInlining = 0x0100, // Method should be inlined, if possible.
27+
ForwardRef = 0x0010, // The method is declared, but its implementation is provided elsewhere.
28+
PreserveSig = 0x0080, // The method signature is exported exactly as declared.
29+
InternalCall = 0x1000, // The call is internal, that is, it calls a method that's implemented within the CLR.
30+
Synchronized = 0x0020, // The method can be executed by only one thread at a time.
31+
// Static methods lock on the type, whereas instance methods lock on the instance.
32+
NoOptimization = 0x0040, // The method is not optimized by the just-in-time (JIT) compiler or by native codegen.
33+
NoInlining = 0x0008, // The method cannot be inlined.
34+
AggressiveInlining = 0x0100, // The method should be inlined if possible.
35+
AggressiveOptimization = 0x0200, // The method contains code that should always be optimized by the JIT compiler.
3536
}
3637
}

0 commit comments

Comments
 (0)