-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Crossgen2: Support HVA for ARM64 #35576
Conversation
vectorSize = pMT->GetVectorSize(); | ||
if (vectorSize != 0) | ||
{ | ||
return (vectorSize == 8) ? ELEMENT_TYPE_R8 : ELEMENT_TYPE_VALUETYPE; | ||
} |
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 next loop iteration performs this check anyway, so this one is redundant.
@@ -175,6 +175,7 @@ regNumber Compiler::raUpdateRegStateForArg(RegState* regState, LclVarDsc* argDsc | |||
} | |||
else | |||
{ | |||
assert(!regState->rsIsFloat); |
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 could miss this check due to the break
below, then fail later in an unexpected way.
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.
cc: @dotnet/jit-contrib
We have xUnit test coverage for these aspects in the CoreRT repo: https://github.com/dotnet/corert/blob/923eeee2fb70497fe07b74d56bc51bee029c108b/src/ILCompiler.TypeSystem/tests/ValueTypeShapeCharacteristicsTests.cs Issue #200 tracks porting these xUnit tests to the runtime repo, but for now they only compile and run in the experimental CoreRT repo (they will run if you just We haven't made significant type system changes in the runtime repo yet, so there's no process for this. I sync the type system and compiler back to the CoreRT repo on weekends when I have time. Truth to be told, when I port this over and tests stop working, I'm just going to delete the tests because I don't have that much time. If it's not too much hassle, could you do this change in the CoreRT repo too, and adjust/add test coverage as needed? Type system bugs tend to be subtle and that's why we try to unit test as much of it as possible. You should be able to just xcopy src\coreclr\src\tools\Common\TypeSystem to src\Common\src\TypeSystem and src\coreclr\src\tools\Common\JitInterface to src\JitInterface\src. There's about two weeks worth of diffs because I didn't sync in 2 weeks, but it should be manageable to just undo irrelevant changes. |
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'd like to see some effect on GCStress numbers. @janvorli has run GCStress for crossgen2 images on X64, and I imagine he has some instructions for doing so that you could adapt to Arm64.
@@ -120,20 +120,8 @@ public void GetCallRefMap(MethodDesc method, bool isUnboxingStub) | |||
|
|||
for (uint pos = 0; pos < nStackSlots; pos++) | |||
{ | |||
int ofs; | |||
|
|||
if (_target.Architecture == TargetArchitecture.X86) |
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 realize that we don't yet support Crossgen2 for x86, but is removing this special case correct? Should it instead be moved to the OffsetFromGCRefMapPos function?
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 special case is already in OffsetFromGCRefMapPos
overload for x86:
Lines 375 to 385 in 6ce7610
public override int OffsetFromGCRefMapPos(int pos) | |
{ | |
if (pos < NumArgumentRegisters) | |
{ | |
return OffsetOfArgumentRegisters + SizeOfArgumentRegisters - (pos + 1) * PointerSize; | |
} | |
else | |
{ | |
return OffsetOfArgs + (pos - NumArgumentRegisters) * PointerSize; | |
} | |
} |
Running with GC stress enabled is as easy as passing |
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.
LGTM, thank you!
Since we had a public holiday in Slovakia, managed to sync the compiler a bit earlier. dotnet/corert#8122. |
@davidwrighton Below are results of
|
@echesakovMSFT This PR includes minor changes under jit and vm. It would be good to add an assert that if JIT recognizes some type as SIMD (see types in |
@CarolEidt Implementation of HFA/HVA property calculation in this PR is free of issues documented in #35144. We need them to be fixed so that Crossgen2 compiler and VM agree on the calling convention. One possible way of fixing that is to introduce a new enumeration for fundamental data types of homogeneous aggregates, like I did in this PR: https://github.com/dotnet/runtime/pull/35576/files#diff-e553d696b7062596f5653d5bba53d278, and use it as the return type of the |
Did you want to add that to this PR, or perhaps file an issue for the JIT to do that? @AntonLapounov - I was previously thinking that fixing #35144 would require a change to the JIT/EE interface, but I believe it's the case that from a JIT perspective it doesn't really need to distinguish between an HFA of double and an HVA of SIMD8. So I think the fix just needs to be made on the vm side of the JIT/EE interface, as you've done here. |
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 JIT changes LGTM
@CarolEidt I would prefer someone with more JIT knowledge to do that. You are right that technically we do not have to change the |
@AntonLapounov as for the timed out tests, can you please try to bump the execution timeout using the |
Support ARM64 HVAs in Crossgen2.
FieldLayoutAlgorithm.ComputeValueTypeShapeCharacteristics
method to compute the homogeneous aggregate element type and cache it in the existing field. That allows to remove allComputeHomogeneousFloatAggregateElementType
methods.MetadataFieldLayoutAlgorithm.ComputeHomogeneousAggregateCharacteristic
to compute HVAs in addition to HFAs.CorInfoImpl.getHFAType
JIT callback to handle HVAs. Note that returningELEMENT_TYPE_VALUETYPE
indicates theTYP_SIMD16
type (seeCompiler::GetHfaType
).TypeFixupSignature.EncodeTypeLayout
to handle HVAs.ArgIterator
class.TransitionBlock.OffsetFromGCRefMapPos
for ARM64. R2RDump used to dump incorrect offsets.TransitionBlock.OffsetFromGCRefMapPos
inGCRefMapBuilder.GetCallRefMap
to simplify logic.Minor:
GetVectorSize
check inMethodTable::GetHFAType
.Compiler::raUpdateRegStateForArg
.