-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
OS: all
Architecture: all
Example log: https://dev.azure.com/dnceng-public/public/_build/results?buildId=509643&view=results
These two tests have apparently been failing in Crossgen2 mode for quite some time but it remained unnoticed because the somewhat hacky implementation of the helixpublishwitharcade.proj script suppressed the tests in the JIT/Intrinsics folder after the JIT/SIMD tests were converted to the merged test model, for more detailed explanation please see:
The problematic check is the following one:
IsTrue(typeof(GenericEnumClass<>).GetGenericArguments()[0].IsEnum);
The test refers to the following class declaration:
public class GenericEnumClass<T> where T : Enum
{
public T field;
}
Without CG2, runtime JIT optimizes the call to typeof(GenericEnumClass<>).GetGenericArguments into a plain
mov rax, [<MethodTablePtr>+0x70]
that apparently has the IsEnum flag set for the type representing the constrained parameter T; in CG2 mode without JIT optimizations, we use the combination of the helper
GET_RUNTIME_TYPE_HANDLE
and the managed method
System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)
In CG2 mode with JIT optimizations turned on, we end up calling
GET_RUNTIME_TYPE_HANDLE
immediately followed by the call to GetGenericArguments i.o.w. we optimize out the call to Type.GetTypeFromHandle. In either case the IsEnum check on the first generic argument doesn't hold. At the first glance it seems to me that this is a bug in the implementation of the runtime helper but I may be mistaken.
Thanks
Tomas
/cc @dotnet/jit-contrib