Skip to content
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

Fixed issues related to enabling generic math on primitive types #4

Merged
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
5 changes: 5 additions & 0 deletions src/coreclr/vm/typedesc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,11 @@ BOOL TypeVarTypeDesc::SatisfiesConstraints(SigTypeContext *pTypeContextOfConstra
}
CONTRACTL_END;

// During EEStartup, we cannot safely validate constraints, but we can also be confident that the code doesn't violate them
// Just skip validation and declare that the constraints are satisfied.
if (g_fEEInit)
return TRUE;

IMDInternalImport* pInternalImport = GetModule()->GetMDImport();
mdGenericParamConstraint tkConstraint;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<ILLinkSharedDirectory>$(MSBuildThisFileDirectory)ILLink\</ILLinkSharedDirectory>
<Is64Bit Condition="'$(Platform)' == 'arm64' or '$(Platform)' == 'x64'">true</Is64Bit>
<UseMinimalGlobalizationData Condition="'$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsBrowser)' == 'true'">true</UseMinimalGlobalizationData>
<ILLinkTrimAssembly>false</ILLinkTrimAssembly> <!-- TODO! REMOVE BEFORE MERGING TO MASTER Needed as the current linker will delete all explicit static virtual method implementations! -->
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition="'$(Is64Bit)' != 'true'">$(DefineConstants);TARGET_32BIT</DefineConstants>
Expand Down
2 changes: 2 additions & 0 deletions src/tests/JIT/Math/Generic/GenericMathTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;

namespace System.GenericMath
{
public abstract class GenericMathTests<T>
Expand Down
4 changes: 3 additions & 1 deletion src/tests/JIT/Math/Generic/Int32Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Linq;

namespace System.GenericMath
{
public sealed class Int32Tests : GenericMathTests<int>
Expand All @@ -15,7 +17,7 @@ public override void SumTest()

if (expected != actual)
{
throw new InvalidOperationException($"Expected: {expected}; Actual: {Actual}");
throw new InvalidOperationException($"Expected: {expected}; Actual: {actual}");
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/tests/JIT/Math/Generic/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ private static int Test(Action action)
{
action();
}
catch
catch (Exception e)
{
Console.WriteLine(e);
return -1;
}

Expand Down