Fix getClassAlignmentRequirement for arm 32-bit architectures#3671
Fix getClassAlignmentRequirement for arm 32-bit architectures#3671jkotas merged 1 commit intodotnet:masterfrom BredPet:master
Conversation
|
This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request. |
|
@jkotas please review |
src/JitInterface/src/CorInfoImpl.cs
Outdated
| private uint getClassAlignmentRequirement(CORINFO_CLASS_STRUCT_* cls, bool fDoubleAlignHint) | ||
| { throw new NotImplementedException("getClassAlignmentRequirement"); } | ||
| { | ||
| if (_compilation.TypeSystemContext.Target.Architecture == TargetArchitecture.ARM || |
There was a problem hiding this comment.
This should not be special cased for ARM. The implementation should work everywhere.
There was a problem hiding this comment.
I have the same opinion, I just test only on ARM. Therefore, I decided not to change the usual logic.
But if you think that this change need and can be extended to other architectures, I think it will be better.
src/JitInterface/src/CorInfoImpl.cs
Outdated
| _compilation.TypeSystemContext.Target.Architecture == TargetArchitecture.ARMEL) | ||
| { | ||
| // Default alignment is sizeof(void*) | ||
| uint result = (uint)sizeof(void*); |
There was a problem hiding this comment.
sizeof(void*) is the size of the pointer of the host where the compiler is running. Instead, this should be Target.PointerSize - size of the pointer on the target.
src/JitInterface/src/CorInfoImpl.cs
Outdated
| // Default alignment is sizeof(void*) | ||
| uint result = (uint)sizeof(void*); | ||
| var type = HandleToObject(cls); | ||
| MetadataType typeDef = type.GetTypeDefinition() as MetadataType; |
There was a problem hiding this comment.
The alignment lives on DefType, so you should be just casting to DefType here - without the rest. Also, the fallback to pointer-size alignment should not happen, and it is probably incorrect if it happens. It may better to just let it throw exception so that we noticed. Taking these two together makes the implementation:
return ((DefType)type).InstanceByteAlignment.AsInt;
Signed-off-by: UIDL YGEN <uidlygen@yandex.ru>
|
@Dmitri-Botcharnikov |
This change need due to crash on 32-bit ARM architectures.
Backtrace:
Signed-off-by: UIDL YGEN uidlygen@yandex.ru