-
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
Allocate boxed static structs on Frozen Object Heap #77737
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsContributes to #76151 All static fields of value types (non-primitive) are usually boxed and stored in the normal heap. This PR moves them to the Frozen Object Heap, it allows us to avoid an indirect load when we access them (we no longer need a pinned handle to the "movable" object). Example: static DateTime Date { get; set; } Codegen for the getter: ; Assembly listing for method Proga:get_Date():System.DateTime
; Tier-1 compilation
- 48B8C01E00BDFC010000 mov rax, 0x1FCBD001EC0 ; box for Proga:<Date>k__BackingField
+ 48B8E81C94C107020000 mov rax, 0x207C1941CE8 ; 'System.DateTime'
- 488B00 mov rax, gword ptr [rax]
488B4008 mov rax, qword ptr [rax+08H]
C3 ret
-; Total bytes of code 18
+; Total bytes of code 15 Diffs for Libraries (jit-utils -f -pmi):
TODO: Avoid allocating the pinned handle for the boxed structs.
|
86a8833
to
77a42b7
Compare
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@jkotas do we want to avoid allocations of handles here and use that Looks like even large apps don't use statics that a lot to care about? the bingsnr ends up emitting 16kb of statics on FOH with this PR only. So it's only about a slightly better codegen. |
What is the handle you have in mind? I do not think there is any handle to save, without completely redoing how statics are allocated. |
Alright, so then it's ok as is? |
I was only looking at it because nobody else was and it bothers me :). You'll likely be able to come up with a much better fix and much faster than me. Thank you! |
Had to fix an outerloop test that expected statics to change address after |
/azp run runtime-coreclr pgo, runtime-coreclr libraries-pgo |
Azure Pipelines successfully started running 2 pipeline(s). |
…boxed-statics-foh
note: I'm investigating a flaky NullReferenceException happening in System.Text.RegularExpression tests
|
88bbfe7
to
3db4522
Compare
Oops, bad rebase. I think I've found the reason, it was an incorrect fix to handle |
llvmfullaot pipeline fails because of #78290 |
…e getFieldAddress (dotnet#77737)" This reverts commit cabb8b0.
Contributes to #76151
All static fields of value types (non-primitive) are usually boxed and stored in the normal heap. This PR moves them to the Frozen Object Heap, it allows us to avoid an indirect load when we access them (we no longer need a pinned handle to the "movable" object).
Example:
Codegen for the getter:
Diffs for Libraries (jit-utils -f -pmi):
TODO: Avoid allocating the pinned handle for the boxed structs.