-
Notifications
You must be signed in to change notification settings - Fork 5.2k
NativeAOT: Optimize static fields of gc types #80969
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
Conversation
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch, @kunalspathak Issue DetailsFollow up to #79709 but for gc fields now, e.g.: static string field;
static string GetField() => field;Was: ; Method ConsoleApp1.Program:GetField():System.String
4883EC28 sub rsp, 40
E800000000 call CORINFO_HELP_READYTORUN_GCSTATIC_BASE
488B4008 mov rax, gword ptr [rax+08H]
4883C428 add rsp, 40
C3 ret
; Total bytes of code: 18Now: ; Method ConsoleApp1.Program:GetField():System.String
488B0500000000 mov rax, bword ptr [(reloc 0x40000000004225c0)]
488B4008 mov rax, gword ptr [rax+08H]
C3 ret
; Total bytes of code: 12based on #63620 and @SingleAccretion's suggestions
|
|
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
@SingleAccretion PTAL when you have time 🙂 CI looks good so far |
|
Failures are all Mono-related in |
src/coreclr/tools/aot/ILCompiler.RyuJit/JitInterface/CorInfoImpl.RyuJit.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
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.
Jit part LGTM!
|
@MichalStrehovsky PTAL NAOT side. |
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.
Awesome, thank you!
src/coreclr/jit/importer.cpp
Outdated
| assert(pFieldInfo->fieldLookup.accessType == IAT_PVALUE); | ||
| op1 = gtNewIndOfIconHandleNode(TYP_BYREF, fldAddr, GTF_ICON_STATIC_ADDR_PTR, true); |
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.
Just to double check - typing this a TYP_BYREF and retyping it as TYP_I_IMPL when creating the GT_ADD below won't cause any issues?
Could we just type it as TYP_I_IMPL here? If I'm reading it right we're assuming it's pinned anyway.
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.
Ah, right, TYP_I_IMPL works here to for the static base address (and as we discussed inhttps://github.com//pull/79709 it doesn't lead to constant folding) and won't generate unnecessary gc info. The root GT_IND node has TYP_REF for gc refs so everything should be fine.
Co-authored-by: SingleAccretion <62474226+SingleAccretion@users.noreply.github.com>
Follow up to #79709 but for gc fields now, e.g.:
Was:
Now:
based on #63620 and @SingleAccretion's suggestions