Skip to content

Fold obj.GetType to a constant - #87101

Merged
EgorBo merged 4 commits into
dotnet:mainfrom
EgorBo:fold-obj-gettype
Jun 5, 2023
Merged

Fold obj.GetType to a constant#87101
EgorBo merged 4 commits into
dotnet:mainfrom
EgorBo:fold-obj-gettype

Conversation

@EgorBo

Copy link
Copy Markdown
Member
TypeTest()=>"test".GetType();

Was:

; Method X:Test():System.Type:thissubrsp,40movrcx,0xD1FFAB1E ; 'test'call System.Object:GetType():System.Type:thisnopaddrsp,40ret; Total bytes of code: 25

Now:

; Method X:Test():System.Type:thismovrax,0xD1FFAB1E ; RuntimeType frozen object representing 'System.String'ret; Total bytes of code: 11

@ghostghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 3, 2023
@ghostghost assigned EgorBoJun 3, 2023
@ghost

ghost commented Jun 3, 2023

Copy link
Copy Markdown

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details
TypeTest()=>"test".GetType();

Was:

; Method X:Test():System.Type:thissubrsp,40movrcx,0xD1FFAB1E ; 'test'call System.Object:GetType():System.Type:thisnopaddrsp,40ret; Total bytes of code: 25

Now:

; Method X:Test():System.Type:thismovrax,0xD1FFAB1E ; RuntimeType frozen object representing 'System.String'ret; Total bytes of code: 11
Author:EgorBo
Assignees:EgorBo
Labels:

area-CodeGen-coreclr

Milestone:-

@EgorBo
EgorBo marked this pull request as ready for review June 4, 2023 09:12
@EgorBo

EgorBo commented Jun 4, 2023

Copy link
Copy Markdown
MemberAuthor

Diffs are small: https://dev.azure.com/dnceng-public/public/_build/results?buildId=294970&view=ms.vss-build-web.run-extensions-tab due to new contexts (see missing contexts values).

We already had this optimization (mostly, for value types) this just extends it a bit 🙂 (not sure I understand why so many likes on it 😆)

PTAL @dotnet/jit-contrib

@ShreyasJejurkar

Copy link
Copy Markdown
Contributor

I love to see this kind of improvement where the number of instructions is going down and down and down! 😅
These little improvements here and there contribute a lot to bigger efforts! 🙌

Keep those coming...🫡🎉

@EgorBo
EgorBo merged commit 404aede into dotnet:mainJun 5, 2023
@EgorBo
EgorBo deleted the fold-obj-gettype branch June 5, 2023 15:58
@ghostghost locked as resolved and limited conversation to collaborators Jul 5, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@EgorBo@ShreyasJejurkar@AndyAyersMS