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

Ensure the layout of StackAllocatedBox<T> matches boxed layouts #107050

Merged
merged 3 commits into from
Aug 28, 2024

Conversation

jakobbotsch
Copy link
Member

The boxed layout of a struct always has its data at +8, as evidenced by Object::UnBox. This means that StackAllocatedBox<T> should have Pack = 1, otherwise this may not be the case. In the test failure we had a StackAllocatedBox<Int128> which had its _value field at offset
16. After object stack allocation this meant that we were saving data in padding of the structure, which promotion does not guarantee to preserve.

Fix #106947

The boxed layout of a struct always has its data at +8, as evidenced by
`Object::UnBox`. This means that `StackAllocatedBox<T>` should have
`Pack = 1`, otherwise this may not be the case. In the test failure we
had a `StackAllocatedBox<Int128>` which had its `_value` field at offset
16. After object stack allocation this meant that we were saving data in
padding of the structure, which promotion does not guarantee to
preserve.

Fix dotnet#106947
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 27, 2024
@@ -10299,7 +10299,7 @@ void ValueNumStore::vnDumpSimdType(Compiler* comp, VNFuncApp* simdType)
int simdSize = ConstantValue<int>(simdType->m_args[0]);
CorInfoType baseJitType = (CorInfoType)ConstantValue<int>(simdType->m_args[1]);

printf("%s(simd%d, %s)", VNFuncName(simdType->m_func), simdSize, varTypeName(JitType2PreciseVarType(baseJitType)));
printf("%s(simd%d, %s)", VNFuncName(simdType->m_func), simdSize, baseJitType == TYP_UNDEF ? varTypeName(TYP_UNDEF) : varTypeName(JitType2PreciseVarType(baseJitType)));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hit assert inside JitType2PreciseVarType with JitDump enabled while investigating -- this fixes the problem.

@jakobbotsch
Copy link
Member Author

/ba-g There are no machines in the Helix queue for Ubuntu.2204.amd64.open.rt, so the jobs are going to time out. There is current investigation happening about the issue.

@jakobbotsch jakobbotsch merged commit 7ff684a into dotnet:main Aug 28, 2024
163 of 167 checks passed
@jakobbotsch jakobbotsch deleted the fix-106947 branch August 28, 2024 09:16
@jakobbotsch
Copy link
Member Author

/backport to release/9.0

Copy link
Contributor

Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/10593809747

jtschuster pushed a commit to jtschuster/runtime that referenced this pull request Sep 17, 2024
…tnet#107050)

The boxed layout of a struct always has its data at +8, as evidenced by
`Object::UnBox`. This means that `StackAllocatedBox<T>` should have
`Pack = 1`, otherwise this may not be the case. In the test failure we
had a `StackAllocatedBox<Int128>` which had its `_value` field at offset
16. After object stack allocation this meant that we were saving data in
padding of the structure, which promotion does not guarantee to
preserve.

Fix dotnet#106947
@github-actions github-actions bot locked and limited conversation to collaborators Sep 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure: System.Text.Json.SourceGeneration.Tests.NumberHandlingTests_Default.Number_AsRootType_RoundTrip
3 participants