-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Moving parts of System.Math
and System.MathF
to be shared with CoreRT.
#14119
Conversation
FYI. @jkotas |
Also FYI. @mellinoe |
@@ -13,712 +13,73 @@ | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention has been to rename the CoreCLR specific part like Math.CoreCLR.cs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
src/mscorlib/src/System/Math.cs
Outdated
return div; | ||
} | ||
[MethodImpl(MethodImplOptions.InternalCall)] | ||
private static extern double fmod(double x, double y); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use CamelCase naming?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
FCIntrinsic("Pow", COMDouble::Pow, CORINFO_INTRINSIC_Pow) | ||
FCIntrinsic("Round", COMDouble::Round, CORINFO_INTRINSIC_Round) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that Round will be no longer treated as intrinsic by the JIT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the mechanism used to treat a non FCALL method as intrinsic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mark the method with [Intrinsic]
attribute and recognize it by name in the JIT.
#13815 introduced this mechanism.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, thanks!
I've already added the [Intrinsic]
attribute, so I should just need to recognize it by name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jkotas, I ended up adding two new named intrinsics (one for Math.Round
and one for MathF.Round
).
I then modified the Compiler::impIntrinsic in importer to map the new named intrinsic to the old CORINFO intrinsic.
This looks to be working end to end right now, since the named intrinsic checks only happen in morph and importer, but only before the GenTree*
has been created.
src/jit/importer.cpp
Outdated
// changes (such as if we support all methods in a class as intrinsic), we can reorder | ||
// the checks to account for that. | ||
|
||
if ((namespaceName != nullptr) && (className != nullptr) && (methodName != nullptr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with the reordering to put all the null checks up front. I have something similar in some of my pending changes.
However, I believe the jit will always be asking if a particular method is an intrinsic here. So I suggest the comment be removed or reworded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed to no longer include the part about reordering if it ever changes.
src/jit/importer.cpp
Outdated
case NI_Math_Round: | ||
{ | ||
// Math.Round and MathF.Round used to be a legacy JIT intrinsic. In order | ||
// to simplify the transition, we will just treat it as if it was still the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: "legacy" has special meaning in the jit code base. Maybe say "used to be a traditional jit intrinsic."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed to use 'traditional' rather than legacy.
} | ||
|
||
retNode = op1; | ||
retNode = impMathIntrinsic(method, sig, callType, intrinsicID, tailCall); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still going to see CORINFO_INTRINISC_Round
on desktop -- desktop does not have the new-style intrinsics.
So it needs to remain in here for now.
If that seems messy, you can hide it from CoreCLR builds with ifdefs, but I wouldn't bother.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AndyAyersMS, just to confirm, removing the mapping from ecalllist
(in the VM layer) should be fine, correct?
Not sure which parts of the codebase are shared with Desktop and which parts aren't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing the mapping from ecalllist (in the VM layer) should be fine, correct?
Yes.
Not sure which parts of the codebase are shared with Desktop and which parts aren't.
JIT and GC is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left you some notes. The desktop compat one is the most serious.
…is required for Desktop compat.
All feedback given so far has been resolved. Please let me know if anything else needs to be changed. |
Going to ping on this to see if it can get merged before EOD today, that way I can work on dotnet/corert#3167 and https://github.com/dotnet/corefx/issues/16428 this weekend. |
// Currently we only have intrinsics at the method level, so we can check that | ||
// namespaceName, className, and methodName are all not null upfront. | ||
|
||
if ((namespaceName != nullptr) && (className != nullptr) && (methodName != nullptr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: It would be nice to early out here to save an extra level of indention for the actual matching code that is likely going to grow pretty big.
@dotnet-bot test Windows_NT x64 corefx_baseline |
The VM and CoreLib parts look fine to me - assuming the corefx tests that I have triggered pass. @AndyAyersMS or somebody else on @dotnet/jit-contrib should sing off on the JIT part. |
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. Looks good.
The Ubuntu job hasn't updated yet but it failed due to
|
Requeued the job and it seems to be actually going now (new machine). The bad machine (missing clang) was: ubuntu1404-20170821-aec340 -- cc @mmitche |
Actually, I take that back. The new run failed as well with the same issue:
CC. @jkotas, it doesn't look to be related to my changes. |
Its definitely strange since clang is found by a separate script at an early step in the build. |
I am sorry, the CoreFX tests in the CI for that change have passed, so I have assumed the VMs were fixed. |
@mikem8361, @tannergooding, @jkotas I am going to revert that change. It requires creating the revert manually though since github doesn't want to do it automatically. |
@jkotas, looks like Windows_NT both failed in an unrelated area. |
It looks like all other tests passed. |
Revert PR is up: dotnet/corefx#24215 |
Windows_NT failure looks to be caused by https://github.com/dotnet/coreclr/blame/8c33e99150cfe9c173f524acff4ea7be320ce08c/src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs#L351. Change was done by @stephentoub |
Which test? |
Oh, I see, that test should be deleted. I'll do so. You can ignore the failure. |
@dotnet-bot test Ubuntu x64 corefx_baseline |
@dotnet-bot test Windows_NT x64 corefx_baseline |
Both known blocking failures have been fixed. I've requeued the tests. @jkotas, am I good to merge later tonight if all three runs come back green? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
Could you please also rename |
Done. Thought I had done this already. |
@dotnet-bot test Windows_NT x64 corefx_baseline |
Ubuntu is failing four of the FileSystemWatcherTests:
I don't see these failing anywhere else, so I will investigate them tomorrow morning. Looks like the failures are all that the test is expected some event to occur, but it is not receiving it |
Ok, looks like the Ubuntu |
Its going to take a bit, but I'm going to try to pin down the commit that introduced the regression. |
The Ubuntu FileSystemWatcherTests failures were introduced in #14043. -- CC. @stephentoub, @pjanotti, @JeremyKuhne |
@jkotas, can this be merged? |
Logged a bug for the issue here: https://github.com/dotnet/coreclr/issues/14154 |
Thanks! |
@jkotas, it looks like a PR to mirror these changes has not gone up to CoreRT yet. Given that there will be some fixup required there as well, could you tag me when it comes up? |
cc @safern |
Taking a look now. |
This splits
System.Math
andSystem.MathF
into partial classes so that parts of the code can be shared with CoreRT.The changes on the native side are:
COMDouble
andCOMSingle
now export aFMod
function which wrapsfmod
COMDouble
andCOMSingle
now export aModF
function which matches the native signatureCOMDouble
andCOMSingle
no longer export aRound
functionThe changes on the managed side are:
AggressiveInlining
attributes, to match CoreRTRound
is now implemented in managed codeRoundInternal
is directly inlined nowTruncate
calls a newmodf
private function, rather thanInternalTruncate
which itself calledSplitFraction
copysign
is a new private function directly implemented in managed code (this supportsRound
)Everything else is just moving the types around between the files or non functional changes such as: