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

JIT: Store padding information in ClassLayout/ClassLayoutBuilder #112212

Merged
merged 5 commits into from
Feb 6, 2025

Conversation

jakobbotsch
Copy link
Member

  • Rename StructSegments -> SegmentList
  • Add ClassLayout::GetNonPadding to get the non-padding of a class layout. Computed lazily for CORINFO_CLASS_HANDLE backed layouts and saved ahead of time for custom layouts.
  • Add ClassLayoutBuilder::AddPadding and ClassLayoutBuilder::RemovePadding
  • Remove Compiler::GetSignificantSegments and switch uses to ClassLayout->GetNonPadding()

* Rename `StructSegments` -> `SegmentList`
* Add `ClassLayout::GetNonPadding` to get the non-padding of a class
  layout. Computed lazily for `CORINFO_CLASS_HANDLE` backed layouts and
  saved ahead of time for custom layouts.
* Add `ClassLayoutBuilder::AddPadding` and
  `ClassLayoutBuilder::RemovePadding`
* Remove `Compiler::GetSignificantSegments` and switch uses to
  `ClassLayout->GetNonPadding()`
@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 Feb 5, 2025
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@jakobbotsch
Copy link
Member Author

FYI @AndyAyersMS... I don't expect this to get us much given that stack allocated arrays are never handled by physical promotion due to address exposure, and physical promotion is the only user of padding information (today).

I think we can change object stack allocation to create custom layouts for all cases without regressions after this change. That should allow us to remove getTypeForBoxOnStack and simplify the ClassLayout creation logic slightly (we should only see value classes for it now).

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Looks good for struct cases.

Seems like for arrays of structs with padding this may end up creating a lot of data that we may never look at?

@jakobbotsch
Copy link
Member Author

Looks good for struct cases.

Seems like for arrays of structs with padding this may end up creating a lot of data that we may never look at?

True. We can have object stack allocation avoid marking any padding for arrays for now and reevaluate if/when we end up with something that would actually benefit from it.

Also seeing some significant TP regressions, likely from block layouts always allocating the padding information. Will change so that it's created lazily for the cases with no padding.

@jakobbotsch jakobbotsch marked this pull request as ready for review February 6, 2025 16:21
@jakobbotsch
Copy link
Member Author

No diffs now. cc @dotnet/jit-contrib PTAL @AndyAyersMS

@jakobbotsch jakobbotsch merged commit 6d0eae5 into dotnet:main Feb 6, 2025
112 checks passed
@jakobbotsch jakobbotsch deleted the class-layout-padding branch February 6, 2025 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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.

2 participants