Uh oh!
There was an error while loading. Please reload this page.
Allocate boxed static structs on Frozen Object Heap - #77737
Conversation
ghost
commented
Nov 1, 2022
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: staticDateTimeDate{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 15Diffs for Libraries (jit-utils -f -pmi): TODO: Avoid allocating the pinned handle for the boxed structs.
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
86a8833 to
77a42b7CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
EgorBo
commented
Nov 2, 2022
@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. |
jkotas
commented
Nov 2, 2022
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. |
EgorBo
commented
Nov 2, 2022
Alright, so then it's ok as is? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
MichalStrehovsky
commented
Nov 10, 2022
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! |
EgorBo
commented
Nov 10, 2022
Had to fix an outerloop test that expected statics to change address after |
EgorBo
commented
Nov 10, 2022
/azp run runtime-coreclr pgo, runtime-coreclr libraries-pgo |
|
Azure Pipelines successfully started running 2 pipeline(s). |
note: I'm investigating a flaky NullReferenceException happening in System.Text.RegularExpression tests |
88bbfe7 to
3db4522CompareOops, bad rebase. I think I've found the reason, it was an incorrect fix to handle |
EgorBo
commented
Nov 13, 2022
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.