-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
BitCast<TYP_REF>(TypeHandleToRuntimeTypeHandle(clsHandle)) => nongc obj #97955
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsImproves codegen for #97949, new codegen for ; Assembly listing for method LdtokenRepro:Test():System.Type (FullOpts)
G_M57559_IG01:
sub rsp, 40
G_M57559_IG02:
mov rax, 0x1FA00005580 ; 'System.Int32'
G_M57559_IG03:
add rsp, 40
ret
; Total bytes of code 19
|
@dotnet/jit-contrib PTAL, simple change. Suprisingly, there were some diffs. Basically, it optimizes:
into:
|
0ba2dd0
to
c3b1ad1
Compare
Does the same optimization kick in for native AOT that uses different representation of RuntimeTypeHandle? |
Oh, I forgot that RuntimeType objects are already frozen in NAOT. Currently the function in question emits this on NAOT: ; Assembly listing for method LdtokenRepro:Test():System.Type (FullOpts)
G_M57559_IG01:
sub rsp, 40
G_M57559_IG02:
lea rcx, [(reloc 0x40000000004224d0)] ; System.Int32
call CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE
mov rcx, rax
call System.Type:GetTypeFromHandle(System.RuntimeTypeHandle):System.Type
nop
G_M57559_IG03:
add rsp, 40
ret
; Total bytes of code 30 since |
This comment was marked as outdated.
This comment was marked as outdated.
Ah, nvm, @SingleAccretion pointed to an issue on my side |
897ef3c
to
4f78bdd
Compare
@SingleAccretion can you take a look? |
@SingleAccretion I've addressed your feedback, can you give it another look? thanks |
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.
Code changes LGTM!
#if defined(LATE_DISASM) | ||
node = new (this, LargeOpOpcode()) GenTreeIntCon(TYP_I_IMPL, value, fields DEBUGARG(/*largeNode*/ true)); | ||
node = new (this, LargeOpOpcode()) | ||
GenTreeIntCon(gtGetTypeForIconFlags(flags), value, fields DEBUGARG(/*largeNode*/ true)); | ||
#else | ||
node = new (this, GT_CNS_INT) GenTreeIntCon(TYP_I_IMPL, value, fields); | ||
node = new (this, GT_CNS_INT) GenTreeIntCon(gtGetTypeForIconFlags(flags), value, fields); |
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.
Unrelated, but any idea why this needs a large node for LATE_DISASM
?
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.
Pretty sure it's dead code.
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.
We revived LATE_DISASM
for use in SVE emitter unit tests in #96286, so it's not dead anymore.
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.
Yes, but I don't think this large opcode ifdef
ing is still needed. It seems in the past gtCompileTimeHandle
was part of the requirement for a "large" node:
runtime/src/coreclr/jit/morph.cpp
Lines 12663 to 12669 in 24d149c
#if defined(LATE_DISASM) | |
// GT_CNS_INT is considered small, so ReplaceWith() won't copy all fields | |
if (tree->IsIconHandle()) | |
{ | |
copy->AsIntCon()->gtCompileTimeHandle = tree->AsIntCon()->gtCompileTimeHandle; | |
} | |
#endif |
CI failure is #97049 |
@EgorBo This PR seems to lead to an assert during JitDump:
Here's the test case I'm using:
|
@BruceForstall yeah 🙁 I've fixed it in #98337 (ready for final review) |
Ah, wait, it should be fixed in main after https://github.com/dotnet/runtime/pull/98273/files already. I just added |
Improves codegen for #97949, new codegen for
GetIntType
: