@@ -959,23 +959,6 @@ private void ImportLdToken(int token)
959
959
}
960
960
}
961
961
962
- // We might also be able to optimize this if this is typeof(Foo).IsValueType
963
- if ( helperId != ReadyToRunHelperId . NecessaryTypeHandle )
964
- {
965
- reader = new ILReader ( _ilBytes , _currentOffset ) ;
966
- if ( reader . HasNext
967
- && reader . ReadILOpcode ( ) == ILOpcode . call
968
- && IsTypeGetTypeFromHandle ( ( MethodDesc ) _methodIL . GetObject ( reader . ReadILToken ( ) ) ) )
969
- {
970
- if ( reader . HasNext
971
- && reader . ReadILOpcode ( ) is ILOpcode . callvirt or ILOpcode . call
972
- && _methodIL . GetObject ( reader . ReadILToken ( ) ) is MethodDesc { Name : "get_IsValueType" or "get_IsEnum" } )
973
- {
974
- helperId = ReadyToRunHelperId . NecessaryTypeHandle ;
975
- }
976
- }
977
- }
978
-
979
962
_factory . MetadataManager . GetDependenciesDueToAccess ( ref _dependencies , _factory , _methodIL , ( TypeDesc ) _canonMethodIL . GetObject ( token ) ) ;
980
963
981
964
_dependencies . Add ( GetHelperEntrypoint ( ReadyToRunHelper . GetRuntimeTypeHandle ) , "ldtoken" ) ;
@@ -1160,8 +1143,10 @@ private void ImportBox(int token)
1160
1143
{
1161
1144
var type = ( TypeDesc ) _methodIL . GetObject ( token ) ;
1162
1145
1163
- // Some box operations will trivially be eliminated during import
1164
- if ( ! type . IsRuntimeDeterminedType )
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 )
1165
1150
{
1166
1151
ILReader reader = new ILReader ( _ilBytes , _currentOffset ) ;
1167
1152
ILOpcode nextOpcode = reader . ReadILOpcode ( ) ;
@@ -1195,9 +1180,7 @@ private void ImportBox(int token)
1195
1180
}
1196
1181
}
1197
1182
1198
- // If this is a byref-like type, only the above operations are permitted.
1199
- if ( type . IsByRefLike )
1200
- ThrowHelper . ThrowInvalidProgramException ( ) ;
1183
+ ThrowHelper . ThrowInvalidProgramException ( ) ;
1201
1184
}
1202
1185
1203
1186
AddBoxingDependencies ( type , "Box" ) ;
@@ -1370,7 +1353,6 @@ private void ImportConvert(WellKnownType wellKnownType, bool checkOverflow, bool
1370
1353
{
1371
1354
if ( checkOverflow )
1372
1355
{
1373
- //
1374
1356
_dependencies . Add ( GetHelperEntrypoint ( ReadyToRunHelper . Dbl2IntOvf ) , "_dbl2intovf" ) ;
1375
1357
_dependencies . Add ( GetHelperEntrypoint ( ReadyToRunHelper . Dbl2UIntOvf ) , "_dbl2uintovf" ) ;
1376
1358
_dependencies . Add ( GetHelperEntrypoint ( ReadyToRunHelper . Dbl2LngOvf ) , "_dbl2lngovf" ) ;
0 commit comments