-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Handle Implicit arguments consistently between interpreter and JIT #120339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
davidwrighton
merged 7 commits into
dotnet:main
from
davidwrighton:make_implicit_arg_conversion_consistent
Oct 9, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
efaf813
Handle Implicit arguments consistently between interpreter and JIT
davidwrighton 343607b
Make tests pri0 so that they run in PR
davidwrighton a098f09
Update docs/design/specs/Ecma-335-Augments.md
davidwrighton f5674a9
Code review feedback
davidwrighton 0b92b63
Merge branch 'make_implicit_arg_conversion_consistent' of https://git…
davidwrighton 2956510
Add test exclusion for Mono
davidwrighton cf42174
Fix test build
davidwrighton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
169 changes: 169 additions & 0 deletions
169
src/tests/JIT/Methodical/casts/coverage/implicit_arg_coercion.il
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,169 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| .assembly extern mscorlib { } | ||
| .assembly extern System.Console | ||
| { | ||
| .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A ) | ||
| .ver 4:0:0:0 | ||
| } | ||
| .assembly ASSEMBLY_NAME | ||
| { | ||
| } | ||
| .assembly extern xunit.core {} | ||
| .assembly extern Microsoft.DotNet.XUnitExtensions { .publickeytoken = (31 BF 38 56 AD 36 4E 35 ) } | ||
| .namespace JitTest_implicit_arg_coercion | ||
| { | ||
| .class public auto ansi beforefieldinit TestClass | ||
| extends [mscorlib]System.Object | ||
| { | ||
| .field private static native int s_data | ||
| .field private static native uint s_udata | ||
|
|
||
| .method public hidebysig static native int TakeNativeIntArg(native int) cil managed | ||
| { | ||
| ldarg.0 | ||
| ret | ||
| } | ||
|
|
||
| .method public hidebysig static native uint TakeNativeUIntArg(native uint) cil managed | ||
| { | ||
| ldarg.0 | ||
| ret | ||
| } | ||
|
|
||
| .method public hidebysig static int32 TakeU2Arg(uint16) cil managed | ||
| { | ||
| ldarg.0 | ||
| ret | ||
| } | ||
|
|
||
| .method public hidebysig static int32 TakeU1Arg(uint8) cil managed | ||
| { | ||
| ldarg.0 | ||
| ret | ||
| } | ||
|
|
||
| .method public hidebysig static int32 | ||
| Main() cil managed | ||
| { | ||
| .custom instance void [xunit.core]Xunit.FactAttribute::.ctor() = ( | ||
| 01 00 00 00 | ||
| ) | ||
| .custom instance void [Microsoft.DotNet.XUnitExtensions]Xunit.SkipOnMonoAttribute::.ctor(string, valuetype [Microsoft.DotNet.XUnitExtensions]Xunit.TestPlatforms) = { | ||
| string('Handling of implicit arg coercion rules III.1.6 differs between Mono and CoreCLR, and this tests the CoreCLR behavior, and what we have put in the augments') | ||
| int32(0xFFFFFFFF) // Any | ||
| } | ||
|
|
||
| .entrypoint | ||
| // Code size 36 (0x24) | ||
| .maxstack 2 | ||
| ldc.i4.m1 | ||
| stsfld native int JitTest_implicit_arg_coercion.TestClass::s_data | ||
| ldc.i4.m1 | ||
| stsfld native uint JitTest_implicit_arg_coercion.TestClass::s_udata | ||
|
|
||
| ldsfld native int JitTest_implicit_arg_coercion.TestClass::s_data | ||
| conv.u8 | ||
| box [mscorlib]System.UInt64 | ||
| call void [System.Console]System.Console::WriteLine(object) | ||
|
|
||
| ldsfld native uint JitTest_implicit_arg_coercion.TestClass::s_udata | ||
| conv.u8 | ||
| box [mscorlib]System.UInt64 | ||
| call void [System.Console]System.Console::WriteLine(object) | ||
|
|
||
| ldc.i4.m1 | ||
| conv.i | ||
| box [mscorlib]System.UInt64 | ||
| call void [System.Console]System.Console::WriteLine(object) | ||
|
|
||
| ldc.i4.m1 | ||
| conv.u | ||
| box [mscorlib]System.UInt64 | ||
| call void [System.Console]System.Console::WriteLine(object) | ||
|
|
||
| ldc.i4.m1 | ||
| conv.i | ||
| ldsfld native int JitTest_implicit_arg_coercion.TestClass::s_data | ||
| beq IL_PassNativeInt | ||
| ldstr "Failed conversion of i4 into i for stsfld" | ||
| call void [System.Console]System.Console::WriteLine(string) | ||
| ldc.i4.s 101 | ||
| ret | ||
|
|
||
| IL_PassNativeInt: | ||
| ldc.i4.m1 | ||
| conv.i // The published ECMA 335 spec specifies that we should use the implicit argument coercion rules in section III. | ||
| ldsfld native uint JitTest_implicit_arg_coercion.TestClass::s_udata | ||
| beq IL_PassNativeUInt | ||
| ldstr "Failed conversion of i4 into u for stsfld" | ||
| call void [System.Console]System.Console::WriteLine(string) | ||
| ldc.i4.s 102 | ||
| ret | ||
| IL_PassNativeUInt: | ||
|
|
||
| ldc.i4.m1 | ||
| call native int [ASSEMBLY_NAME]JitTest_implicit_arg_coercion.TestClass::TakeNativeIntArg(native int) | ||
| ldc.i4.m1 | ||
| conv.i | ||
| beq IL_PassNativeIntCall | ||
| ldstr "Failed conversion of i4 into i for argument call" | ||
| call void [System.Console]System.Console::WriteLine(string) | ||
| ldc.i4.s 103 | ||
| ret | ||
| IL_PassNativeIntCall: | ||
|
|
||
| ldc.i4.m1 | ||
| call native uint [ASSEMBLY_NAME]JitTest_implicit_arg_coercion.TestClass::TakeNativeUIntArg(native uint) | ||
| ldc.i4.m1 | ||
| conv.i | ||
| beq IL_PassNativeUIntCall | ||
| ldstr "Failed conversion of i4 into u for argument call" | ||
| call void [System.Console]System.Console::WriteLine(string) | ||
| ldc.i4.s 104 | ||
| ret | ||
| IL_PassNativeUIntCall: | ||
|
|
||
| ldc.i4.m1 | ||
| call int32 [ASSEMBLY_NAME]JitTest_implicit_arg_coercion.TestClass::TakeU2Arg(uint16) | ||
| ldc.i4 0xFFFF | ||
| beq IL_PassU2Call | ||
| ldstr "Failed conversion of i4 into u2 for argument call" | ||
| call void [System.Console]System.Console::WriteLine(string) | ||
| ldc.i4.s 105 | ||
| ret | ||
| IL_PassU2Call: | ||
|
|
||
| ldc.i4.m1 | ||
| call int32 [ASSEMBLY_NAME]JitTest_implicit_arg_coercion.TestClass::TakeU1Arg(uint8) | ||
| ldc.i4 0xFF | ||
| beq IL_PassU1Call | ||
| ldstr "Failed conversion of i4 into u1 for argument call" | ||
| call void [System.Console]System.Console::WriteLine(string) | ||
| ldc.i4.s 105 | ||
| ret | ||
| IL_PassU1Call: | ||
|
|
||
| ldstr "Passed => 100" | ||
| IL_001c: call void [System.Console]System.Console::WriteLine(string) | ||
| IL_0021: ldc.i4.s 100 | ||
| IL_0023: ret | ||
| } // end of method TestClass::Main | ||
|
|
||
| .method public hidebysig specialname rtspecialname | ||
| instance void .ctor() cil managed | ||
| { | ||
| // Code size 7 (0x7) | ||
| .maxstack 8 | ||
| IL_0000: ldarg.0 | ||
| IL_0001: call instance void [mscorlib]System.Object::.ctor() | ||
| IL_0006: ret | ||
| } // end of method TestClass::.ctor | ||
|
|
||
| } // end of class TestClass | ||
|
|
||
| } // end of namespace JitTest_implicit_arg_coercion | ||
|
|
||
| //*********** DISASSEMBLY COMPLETE *********************** | ||
| // WARNING: Created Win32 resource file ldnull.res |
1 change: 1 addition & 0 deletions
1
src/tests/JIT/Methodical/casts/coverage/implicit_arg_coercion_d.il
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #define ASSEMBLY_NAME "implicit_arg_coercion_d" |
12 changes: 12 additions & 0 deletions
12
src/tests/JIT/Methodical/casts/coverage/implicit_arg_coercion_d.ilproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.IL"> | ||
| <PropertyGroup> | ||
| <CLRTestPriority>0</CLRTestPriority> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <DebugType>Full</DebugType> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="implicit_arg_coercion_d.il" /> | ||
| <Compile Include="implicit_arg_coercion.il" /> | ||
| </ItemGroup> | ||
| </Project> |
1 change: 1 addition & 0 deletions
1
src/tests/JIT/Methodical/casts/coverage/implicit_arg_coercion_r.il
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #define ASSEMBLY_NAME "implicit_arg_coercion_r" |
12 changes: 12 additions & 0 deletions
12
src/tests/JIT/Methodical/casts/coverage/implicit_arg_coercion_r.ilproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.IL"> | ||
| <PropertyGroup> | ||
| <CLRTestPriority>0</CLRTestPriority> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <DebugType>PdbOnly</DebugType> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="implicit_arg_coercion_r.il" /> | ||
| <Compile Include="implicit_arg_coercion.il" /> | ||
| </ItemGroup> | ||
| </Project> |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.