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

Implement EETypePtr.EETypePtrOf intrinsic - #853

Merged
MichalStrehovsky merged 3 commits into
dotnet:masterfrom
MichalStrehovsky:eetypeptrof
Feb 12, 2016
Merged

MichalStrehovsky merged 3 commits into
dotnet:masterfrom
MichalStrehovsky:eetypeptrof

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Resolves #852.

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

I tested this by replacing String.Empty.EETypePtr in String.cs with EETypePtr.EETypePtrOf<String>(), but I'm not sure if it's a win (we still call into the LdTokenHelper, which might be expensive), so I'm not including that part.

@jkotas PTAL

}
}

[Intrinsic]

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.

Could you please put it under #if CORERT ? nutc does not like things that it does not know about to be marked as intrinsics ... yet.

@MichalStrehovsky
MichalStrehovsky force-pushed the eetypeptrof branch 2 times, most recently from cb08a53 to f17c306 Compare February 11, 2016 16:46
return obj is Lock;
#else
return obj.EETypePtr == typeof(Lock).TypeHandle.ToEETypePtr();
return obj.EETypePtr == EETypePtr.EETypePtrOf<Lock>();

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.

I tried removing the CORERT-TODO here, but the intrinsic is still not low level enough and we end up recursing infinitely from the LdToken helper :/

@jkotas

jkotas commented Feb 11, 2016

Copy link
Copy Markdown
Member

I'm not sure if it's a win (we still call into the LdTokenHelper, which might be expensive),

We need to make this inlinable. Not sure why the JIT is not inlining it ... you should be able to find out by building debug ryujit.dll at commit where @kyulee1 snapped it last time. Mark it as forceinline, inline the field fetch so that local is not needed, change the to EEType helper to static method so that the address taken local is not needed ... one of these should help.

@jkotas

jkotas commented Feb 11, 2016

Copy link
Copy Markdown
Member

Part of the plan to make this inlinable may be to change the following line in CorInfoImpl.Intrinsics.cs to map to the raw value helper:

 // table.Add(CorInfoIntrinsics.CORINFO_INTRINSIC_RTH_GetValueInternal, "GetValueInternal", "System", "RuntimeTypeHandle"); // not in .NET Core

- Add support for "LDTOKEN Type"
- Add recognition for GetValueInternal intrinsic
- Fix fallout from being able to compile more code in Hello World:
importing the same P/invoke with a different signature is a thing,
NaN.ToString() won't compile, ~ of double doesn't work.
@MichalStrehovsky

Copy link
Copy Markdown
Member Author

The updated iteration inlines/expands everything as expected. EETypePtrOf is now a single load of a constant!

@jkotas

jkotas commented Feb 12, 2016

Copy link
Copy Markdown
Member

LGTM

@MichalStrehovsky

Copy link
Copy Markdown
Member Author

@dotnet-bot test this please

MichalStrehovsky added a commit that referenced this pull request Feb 12, 2016
Implement EETypePtr.EETypePtrOf intrinsic
@MichalStrehovsky
MichalStrehovsky merged commit d295f74 into dotnet:master Feb 12, 2016
@MichalStrehovsky
MichalStrehovsky deleted the eetypeptrof branch February 12, 2016 13:35
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