Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/coreclr/ilasm/asmparse.y
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
%token VALUE_ VALUETYPE_ NATIVE_ INSTANCE_ SPECIALNAME_ FORWARDER_
%token STATIC_ PUBLIC_ PRIVATE_ FAMILY_ FINAL_ SYNCHRONIZED_ INTERFACE_ SEALED_ NESTED_
%token ABSTRACT_ AUTO_ SEQUENTIAL_ EXPLICIT_ ANSI_ UNICODE_ AUTOCHAR_ IMPORT_ ENUM_
%token VIRTUAL_ NOINLINING_ AGGRESSIVEINLINING_ NOOPTIMIZATION_ AGGRESSIVEOPTIMIZATION_ UNMANAGEDEXP_ BEFOREFIELDINIT_
%token VIRTUAL_ NOINLINING_ AGGRESSIVEINLINING_ NOOPTIMIZATION_ AGGRESSIVEOPTIMIZATION_ UNMANAGEDEXP_ BEFOREFIELDINIT_ ASYNC_
%token STRICT_ RETARGETABLE_ WINDOWSRUNTIME_ NOPLATFORM_
%token METHOD_ FIELD_ PINNED_ MODREQ_ MODOPT_ SERIALIZABLE_ PROPERTY_ TYPE_
%token ASSEMBLY_ FAMANDASSEM_ FAMORASSEM_ PRIVATESCOPE_ HIDEBYSIG_ NEWSLOT_ RTSPECIALNAME_ PINVOKEIMPL_
Expand Down Expand Up @@ -244,6 +244,22 @@ languageDecl : _LANGUAGE SQSTRING
;
/* Basic tokens */
id : ID { $$ = $1; }
/* Allow methodImpl attributes to be used as identifiers */
| NATIVE_ { $$ = newString("native"); }
| CIL_ { $$ = newString("cil"); }
| OPTIL_ { $$ = newString("optil"); }
| MANAGED_ { $$ = newString("managed"); }
| UNMANAGED_ { $$ = newString("unmanaged"); }
| FORWARDREF_ { $$ = newString("forwardref"); }
| PRESERVESIG_ { $$ = newString("preservesig"); }
| RUNTIME_ { $$ = newString("runtime"); }
| INTERNALCALL_ { $$ = newString("internalcall"); }
| SYNCHRONIZED_ { $$ = newString("synchronized"); }
| NOINLINING_ { $$ = newString("noinlining"); }
| AGGRESSIVEINLINING_ { $$ = newString("aggressiveinlining"); }
| NOOPTIMIZATION_ { $$ = newString("nooptimization"); }
| AGGRESSIVEOPTIMIZATION_ { $$ = newString("aggressiveoptimization"); }
| ASYNC_ { $$ = newString("async"); }
| SQSTRING { $$ = $1; }
;

Expand Down Expand Up @@ -857,6 +873,7 @@ implAttr : /* EMPTY */ { $$ = (CorMethodImp
| implAttr AGGRESSIVEINLINING_ { $$ = (CorMethodImpl) ($1 | miAggressiveInlining); }
| implAttr NOOPTIMIZATION_ { $$ = (CorMethodImpl) ($1 | miNoOptimization); }
| implAttr AGGRESSIVEOPTIMIZATION_ { $$ = (CorMethodImpl) ($1 | miAggressiveOptimization); }
| implAttr ASYNC_ { $$ = (CorMethodImpl) ($1 | miAsync); }
| implAttr FLAGS_ '(' int32 ')' { $$ = (CorMethodImpl) ($4); }
;

Expand Down
9,144 changes: 4,800 additions & 4,344 deletions src/coreclr/ilasm/prebuilt/asmparse.cpp

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions src/coreclr/ilasm/prebuilt/asmparse.grammar
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,22 @@ languageDecl : '.language' SQSTRING
;
/* Basic tokens */
id : ID
/* Allow methodImpl attributes to be used as identifiers */
| 'native'
| 'cil'
| 'optil'
| 'managed'
| 'unmanaged'
| 'forwardref'
| 'preservesig'
| 'runtime'
| 'internalcall'
| 'synchronized'
| 'noinlining'
| 'aggressiveinlining'
| 'nooptimization'
| 'aggressiveoptimization'
| 'async'
| SQSTRING
;

Expand Down Expand Up @@ -528,6 +544,7 @@ implAttr : /* EMPTY */
| implAttr 'aggressiveinlining'
| implAttr 'nooptimization'
| implAttr 'aggressiveoptimization'
| implAttr 'async'
| implAttr 'flags' '(' int32 ')'
;

Expand Down
1 change: 1 addition & 0 deletions src/coreclr/ildasm/dasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3751,6 +3751,7 @@ BOOL DumpMethod(mdToken FuncToken, const char *pszClassName, DWORD dwEntryPointT
if(IsMiAggressiveInlining(dwImplAttrs)) szptr+=sprintf_s(szptr,SZSTRING_REMAINING_SIZE(szptr)," aggressiveinlining");
if(IsMiNoOptimization(dwImplAttrs)) szptr+=sprintf_s(szptr,SZSTRING_REMAINING_SIZE(szptr)," nooptimization");
if(IsMiAggressiveOptimization(dwImplAttrs)) szptr+=sprintf_s(szptr,SZSTRING_REMAINING_SIZE(szptr)," aggressiveoptimization");
if(IsMiAsync(dwImplAttrs)) szptr+=sprintf_s(szptr,SZSTRING_REMAINING_SIZE(szptr)," async");
szptr+=sprintf_s(szptr,SZSTRING_REMAINING_SIZE(szptr),KEYWORD((char*)-1));
printLine(GUICookie, szString);
VDELETE(buff);
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/inc/il_kywd.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
KYWD( "noinlining", NOINLINING_, NO_VALUE )
KYWD( "nooptimization", NOOPTIMIZATION_, NO_VALUE )
KYWD( "aggressiveoptimization", AGGRESSIVEOPTIMIZATION_, NO_VALUE )
KYWD( "async", ASYNC_, NO_VALUE )
KYWD( "nomangle", NOMANGLE_, NO_VALUE )
KYWD( "lasterr", LASTERR_, NO_VALUE )
KYWD( "winapi", WINAPI_, NO_VALUE )
Expand Down
7 changes: 5 additions & 2 deletions src/tests/ilasm/MethodImplOptions/MethodImplOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ public MethodImplOptionsTests()
}

[Theory]
[InlineData("AggressiveOptimizationTest", "MiAggressiveOptimization.il", "aggressiveoptimization")]
[InlineData("AggressiveOptimizationTest", "MiAggressiveOptimization.il", "Main", "aggressiveoptimization")]
[InlineData("AsyncIdentifierTest", "MiAsUnquotedIdentifier.il", "'async'", "async")]
[InlineData("RuntimeIdentifierNoInliningTest", "MiAsUnquotedIdentifier.il", "'runtime'", "noinlining")]
public void RunMethodImplOptionsTest(
string testName,
string ilFileName,
string methodName,
string ilDisasmAttributeKeyword)
{
Console.WriteLine(testName);
Expand All @@ -77,7 +80,7 @@ public void RunMethodImplOptionsTest(
string disasmIl = File.ReadAllText(disasmIlFileName);
var findMainAttributeRegex =
new Regex(
@"\bvoid\s+Main\s*\(\s*\).*?\b" + ilDisasmAttributeKeyword + @"\b",
$@"\bvoid\s+{methodName}\s*\(.*?\).*?\b{ilDisasmAttributeKeyword}\b",
RegexOptions.Compiled | RegexOptions.Multiline);

Assert.True(findMainAttributeRegex.IsMatch(disasmIl), $"Attribute '{ilDisasmAttributeKeyword}' did not round-trip through ilasm and ildasm");
Expand Down
43 changes: 43 additions & 0 deletions src/tests/ilasm/MethodImplOptions/MiAsUnquotedIdentifier.il
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

#define CORE_ASSEMBLY "System.Runtime"

.assembly extern CORE_ASSEMBLY {}
.assembly MiAsUnquotedIdentifier {}
.module MiAsUnquotedIdentifier.dll

.class public auto ansi Program extends [CORE_ASSEMBLY]System.Object
{
.method public static int32 Main() il managed
{
.entrypoint
.maxstack 8

ret
}

.method public specialname rtspecialname instance void .ctor() cil managed
{
.maxstack 8

ldarg.0
call instance void [CORE_ASSEMBLY]System.Object::.ctor()
ret
}

.method public instance void async(int32 async) cil managed async
{
.maxstack 8

ret
}

.method public instance void runtime(int32 managed) cil managed noinlining
{
.maxstack 8

ret
}

}
4 changes: 2 additions & 2 deletions src/tests/ilasm/ilasm_tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>TestFiles\%(FileName)%(Extension)</Link>
</None>
<None Include="MethodImplOptions/MiAggressiveOptimization.il">
<None Include="MethodImplOptions/*.il">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Link>MiAggressiveOptimization.il</Link>
<Link>%(Filename).il</Link>
</None>
</ItemGroup>
<Import Project="$(TestSourceDir)MergedTestRunner.targets" />
Expand Down
Loading