Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Add missing type checks to RyuJIT unbox helpers - #2378

Merged
jkotas merged 1 commit into
dotnet:masterfrom
jkotas:rhunbox
Dec 19, 2016
Merged

jkotas merged 1 commit into
dotnet:masterfrom
jkotas:rhunbox

Conversation

@jkotas

@jkotas jkotas commented Dec 17, 2016

Copy link
Copy Markdown
Member

Fixes #2357

{
EEType* ptrUnboxToEEType = (EEType*)pUnboxToEEType.ToPointer();
if (obj.EEType != ptrUnboxToEEType)
if ((obj == null) || ((obj.EEType != ptrUnboxToEEType) && !UnboxAnyTypeCompare(obj.EEType, ptrUnboxToEEType)))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we get anything out of the (obj.EEType != ptrUnboxToEEType) part? RyuJIT seems to be inlining this check and will skip RhUnbox2 call completely if this is true. It will also conveniently trigger a hardware AV if obj is null.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not inline it if the basic block is rarely executed. But I agree that it may be premature optimization, especially considering how other JIT helpers are written. Once we get to working on runtime perf, we may need to go over all JIT helpers and fine tune their performance.

@jkotas
jkotas merged commit 301a7e2 into dotnet:master Dec 19, 2016
@jkotas
jkotas deleted the rhunbox branch December 19, 2016 18:12
@jkotas jkotas mentioned this pull request Dec 20, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants