-
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
Stack allocate unescaped boxes #103361
Merged
AndyAyersMS
merged 50 commits into
dotnet:main
from
AndyAyersMS:StackAllocateUnescapedBoxes
Jul 1, 2024
Merged
Stack allocate unescaped boxes #103361
Changes from all commits
Commits
Show all changes
50 commits
Select commit
Hold shift + click to select a range
e333c8f
wip
AndyAyersMS 5deb676
post rebase fixes
AndyAyersMS 877927a
wip
AndyAyersMS 0a7f3d4
revert layout changes, rely on KVP instead
AndyAyersMS 56500c3
trying to enable promotion
AndyAyersMS f9e6e47
Small fixes
jakobbotsch 67402d4
Update src/coreclr/jit/lclmorph.cpp
jakobbotsch 5a08c84
Merge pull request #6 from jakobbotsch/stack-allocate-unescaped-boxes…
AndyAyersMS 350d7ca
format
AndyAyersMS 0328665
avoid escaping nullcheck addrs
AndyAyersMS 315916d
fix nullcheck handling
AndyAyersMS 91b83d3
fix colon retyping
AndyAyersMS bcc7c3a
metrics, enable for ref classes too
AndyAyersMS 20a83b4
fix object stack allocation test
AndyAyersMS be657eb
merge main
AndyAyersMS d9d299c
handle not getting a class handle for a box
AndyAyersMS 03ae7ee
Merge branch 'main' into StackAllocateUnescapedBoxes
AndyAyersMS cc1037e
don't recycle packet number
AndyAyersMS 3964a09
fix nullcheck exposure in local morph
AndyAyersMS b1c986d
allow promotion of address-exposed stack allocated boxes
AndyAyersMS ed41d78
unbox helper only captures type
AndyAyersMS 810abdf
merge main
AndyAyersMS 536b2ae
restore lost guid update and related
AndyAyersMS 5e9e3fb
boost inlining more if we pass a box as an arg
AndyAyersMS 0685c58
try and fix promotion to write back if there are helper call struct uses
AndyAyersMS 07f68ee
fix physical promotion writeback logic
AndyAyersMS 2ae83e6
fix layout access for regular case
AndyAyersMS 1cd1022
handle more address comparisons in local morph
AndyAyersMS 40bb560
unbox type test helper
AndyAyersMS 2beb6b3
rewrite unbox helper calls if we stack allocate the box
AndyAyersMS 3522738
undo hacky changes to promotion
AndyAyersMS d88b4a9
more extensive rewriting -- anything that might be a stack allocated box
AndyAyersMS 9c7885d
allow method table access for stack allocated objects
AndyAyersMS 93a3f1d
Merge branch 'main' into StackAllocateUnescapedBoxes_UnboxHelper
AndyAyersMS 06cbf8b
do indir/comma swapping in object allocator
AndyAyersMS 946c780
fall back to relying on (lack of) exposure
AndyAyersMS e63a883
fix type test helper, add range control
AndyAyersMS 41ea7bd
fix unbox helper re-write
AndyAyersMS 337fc7e
need more capable clone
AndyAyersMS 6cdefdf
report all object refs as byrefs for OSR (no retyping to nint)
AndyAyersMS 2c3785e
disable ref class stack allocation for r2r/naot for now
AndyAyersMS 7ca7027
minor TP improvement
AndyAyersMS 351d484
dial back inliner
AndyAyersMS ccad461
fix spmi capture of ref class gclayout
AndyAyersMS 14d2455
Use StackAllocatedBox<T>
AndyAyersMS 8a077ea
Apply suggestions from code review
AndyAyersMS dc873e5
more review feedback
AndyAyersMS 2597a44
fix
AndyAyersMS 504012d
fix typo in comment
AndyAyersMS 7af3d98
more surgical sibling type update for qmark/colon
AndyAyersMS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/StackAllocatedBox.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Runtime.InteropServices; | ||
|
||
namespace System.Runtime.CompilerServices | ||
{ | ||
[StructLayout(LayoutKind.Sequential)] | ||
internal unsafe struct StackAllocatedBox<T> | ||
{ | ||
// These fields are only accessed from jitted code | ||
private MethodTable* _pMethodTable; | ||
private T _value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 suppose it's hard to check what the impact of this change is on its own.
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 had it much more aggressive and it caused some gratuitous size regressions. This seems like a reasonable compromise -- most of the size regressions now are from exposed stack allocated objects.