Skip to content

Commit 7c2083c

Browse files
Avoid considering types boxed in the scanner
I'm not completely sure this is a fine assumption to make (we're assuming something that RyuJIT should do). Wanted to collect numbers if this is worth pursuing. Change salvaged out of dotnet#118479, rt-sz will decide if we want to pursue it.
1 parent f23d779 commit 7c2083c

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/coreclr/tools/aot/ILCompiler.Compiler/IL/ILImporter.Scanner.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,10 +1143,8 @@ private void ImportBox(int token)
11431143
{
11441144
var type = (TypeDesc)_methodIL.GetObject(token);
11451145

1146-
// There are some sequences of box with ByRefLike types that are allowed
1147-
// per the extension to the ECMA-335 specification.
1148-
// Everything else is invalid.
1149-
if (!type.IsRuntimeDeterminedType && type.IsByRefLike)
1146+
// Some box operations will trivially be eliminated during import
1147+
if (!type.IsRuntimeDeterminedType)
11501148
{
11511149
ILReader reader = new ILReader(_ilBytes, _currentOffset);
11521150
ILOpcode nextOpcode = reader.ReadILOpcode();
@@ -1180,7 +1178,9 @@ private void ImportBox(int token)
11801178
}
11811179
}
11821180

1183-
ThrowHelper.ThrowInvalidProgramException();
1181+
// If this is a byref-like type, only the above operations are permitted.
1182+
if (type.IsByRefLike)
1183+
ThrowHelper.ThrowInvalidProgramException();
11841184
}
11851185

11861186
AddBoxingDependencies(type, "Box");

0 commit comments

Comments
 (0)